Skip to main content

Pack · files

files.toolset

packs/files/blocks/toolset.yaml

packfiles
1entity
8commands
5events
1view
32refusals
3KPIs

The file tools an agent calls, as conceptual tools a harness binds its own tools to: read_file, write_file, edit_file, list_dir, search, move, copy and delete. Each tool is one command, typed by its input, its answer and its effect: which file it reads, creates, changes or removes. A file lives in a workspace (agentic.workspace). Every tool that writes names a live lease of that workspace and is refused without one; reading needs none. An edit names the content it expects, so an edit over a file that changed since it was read is refused. Which concrete tool of which harness plays a conceptual tool is a binding, not this block.

Depends on​

Used by​

No block depends on this one.

Entities​

File​

One file in one workspace, with the digest of its content.

Identified by file_id (FileId).

fieldtypemeaning
workspace_idWorkspaceId
pathPath
contentContent
executableboolean
last_lease_idLeaseIdThe lease the last write was made under.

Relations:

  • workspace references Workspace of workspace (one, by workspace_id)
  • last_lease references Lease of workspace (one, by last_lease_id)

Lifecycle: one state, Present; a recorded File does not change.

Commands​

CopyFile​

copy. Copies one file to a new path in the same workspace. Input: the source, the new file, the workspace, a lease, the new path. Effect: a new File with the source's content.

Called by: File tool.

fieldtype
file_idFileId
source_file_idFileId
workspace_idWorkspaceId
lease_idLeaseId
toPath
attimestamp
outcomewhenresult
exists refusedthe File exists alreadyFileExists: A file of this identity exists. write_file creates a file; replacing a whole file is edit_file with a Whole edit.
no-such-source refusedno File for source_file_idFileNotFound: No file of this identity exists.
unknown-lease refusedno Lease for lease_idUnknownLease: No lease of this identity exists.
source-in-other-workspace refusedthe File of source_file_id has workspace_id != input.workspace_idOtherWorkspace: The file lives in another workspace than the one named.
lease-not-live refusedthe Lease of lease_id has state != LiveLeaseNotLive: The lease is requested, released or expired; nothing is written under it.
lease-of-other-workspace refusedthe Lease of lease_id has workspace_id != input.workspace_idLeaseOfOtherWorkspace: The lease is a lease of another workspace.
path-taken refuseda File with workspace_id == input.workspace_id and path == input.toPathTaken: Another file of the workspace holds this path.
copiedotherwisecreates a File in Present; emits FileCopied

DeleteFile​

delete. Removes one file. Input: the file, its workspace, a lease. Effect: the File is gone.

Called by: File tool.

fieldtype
file_idFileId
workspace_idWorkspaceId
lease_idLeaseId
attimestamp
outcomewhenresult
no-such-file refusedno such FileFileNotFound: No file of this identity exists.
other-workspace refusedworkspace_id != input.workspace_idOtherWorkspace: The file lives in another workspace than the one named.
unknown-lease refusedno Lease for lease_idUnknownLease: No lease of this identity exists.
lease-not-live refusedthe Lease of lease_id has state != LiveLeaseNotLive: The lease is requested, released or expired; nothing is written under it.
lease-of-other-workspace refusedthe Lease of lease_id has workspace_id != input.workspace_idLeaseOfOtherWorkspace: The lease is a lease of another workspace.
deletedotherwiseemits FileDeleted

EditFile​

edit_file. Changes one file by a line range, by replacing an anchor that occurs once, or as a whole. Input: the file, its workspace, a lease, the content it expects and the edit. Answer: the new content. Effect: the File's content.

Called by: File tool.

fieldtypemeaning
file_idFileId
workspace_idWorkspaceId
lease_idLeaseId
expectedstringThe digest of the content the edit was made against.
editEdit
attimestamp
outcomewhenresult
no-such-file refusedno such FileFileNotFound: No file of this identity exists.
other-workspace refusedworkspace_id != input.workspace_idOtherWorkspace: The file lives in another workspace than the one named.
content-changed refusedcontent.digest != input.expectedContentChanged: The file's content is no longer the content the edit expected: it changed since it was read.
unknown-lease refusedno Lease for lease_idUnknownLease: No lease of this identity exists.
lease-not-live refusedthe Lease of lease_id has state != LiveLeaseNotLive: The lease is requested, released or expired; nothing is written under it.
lease-of-other-workspace refusedthe Lease of lease_id has workspace_id != input.workspace_idLeaseOfOtherWorkspace: The lease is a lease of another workspace.
does-not-apply refusedthe anchor does not occur exactly once, or the range lies outside the fileEditDoesNotApply: The anchor does not occur exactly once, or the line range lies outside the file. Decided by the tool on the file's content, which this block holds only as a digest.
editedotherwiseupdates the File; emits FileEdited

ListDir​

list_dir. Lists one directory of a workspace. Input: workspace, directory. Answer: its entries. Effect: none.

Called by: File tool.

fieldtype
workspace_idWorkspaceId
directoryPath
outcomewhenresult
unknown-workspace refusedno such WorkspaceUnknownWorkspace: No workspace of this identity exists.
listedotherwiseleaves the Workspace as it is

MoveFile​

move. Gives one file another path. Input: the file, its workspace, a lease, the new path. Effect: the File's path.

Called by: File tool.

fieldtype
file_idFileId
workspace_idWorkspaceId
lease_idLeaseId
toPath
attimestamp
outcomewhenresult
no-such-file refusedno such FileFileNotFound: No file of this identity exists.
other-workspace refusedworkspace_id != input.workspace_idOtherWorkspace: The file lives in another workspace than the one named.
unknown-lease refusedno Lease for lease_idUnknownLease: No lease of this identity exists.
lease-not-live refusedthe Lease of lease_id has state != LiveLeaseNotLive: The lease is requested, released or expired; nothing is written under it.
lease-of-other-workspace refusedthe Lease of lease_id has workspace_id != input.workspace_idLeaseOfOtherWorkspace: The lease is a lease of another workspace.
movedotherwiseupdates the File; emits FileMoved

ReadFile​

read_file. Reads one file. Input: the file. Answer: its path, content and whether it is executable. Effect: none.

Called by: File tool.

fieldtype
file_idFileId
outcomewhenresult
no-such-file refusedno such FileFileNotFound: No file of this identity exists.
readotherwiseleaves the File as it is

search. Finds text in the files of a workspace. Input: workspace, pattern, an optional directory to search under. Answer: the matches, with path, line and excerpt. Effect: none.

Called by: File tool.

fieldtype
workspace_idWorkspaceId
patternstring
underoptional Path
outcomewhenresult
unknown-workspace refusedno such WorkspaceUnknownWorkspace: No workspace of this identity exists.
searchedotherwiseleaves the Workspace as it is

WriteFile​

write_file. Creates one file. Input: workspace, lease, path, content. Effect: a new File.

Called by: File tool.

fieldtype
file_idFileId
workspace_idWorkspaceId
lease_idLeaseId
pathPath
contentContent
executableboolean
attimestamp
outcomewhenresult
exists refusedthe File exists alreadyFileExists: A file of this identity exists. write_file creates a file; replacing a whole file is edit_file with a Whole edit.
unknown-workspace refusedno Workspace for workspace_idUnknownWorkspace: No workspace of this identity exists.
unknown-lease refusedno Lease for lease_idUnknownLease: No lease of this identity exists.
lease-not-live refusedthe Lease of lease_id has state != LiveLeaseNotLive: The lease is requested, released or expired; nothing is written under it.
lease-of-other-workspace refusedthe Lease of lease_id has workspace_id != input.workspace_idLeaseOfOtherWorkspace: The lease is a lease of another workspace.
writtenotherwisecreates a File in Present; emits FileWritten

Events​

eventfieldsemitted by
FileCopiedfile_id FileId, source_file_id FileId, lease_id LeaseId, to Path, at timestampCopyFile
FileDeletedfile_id FileId, lease_id LeaseId, at timestampDeleteFile
FileEditedfile_id FileId, lease_id LeaseId, before Content, at timestampEditFile
FileMovedfile_id FileId, lease_id LeaseId, from Path, to Path, at timestampMoveFile
FileWrittenfile_id FileId, workspace_id WorkspaceId, lease_id LeaseId, path Path, content Content, at timestampWriteFile

Views​

viewrowsfields
Files
Files
each Filefile_id FileId, workspace_id WorkspaceId, path Path, content Content, executable boolean, last_lease_id LeaseId, state State

Types​

typeisvalues or fields
AnchoredEdit
Replace the text anchor, which must occur exactly once in the file, with replacement.
a recordanchor Content, replacement Content
DirectoryEntrya recordpath Path, kind EntryKind
Editexactly one ofAnchor AnchoredEdit, Range RangeEdit, Whole Content
EntryKindone ofFile, Directory
FileIdan identifier or valueuuid
RangeEdit
Replace the lines from first_line to last_line, both included, counted from 1.
a recordfirst_line integer, last_line integer, replacement Content
SearchMatcha recordpath Path, line integer, excerpt string

KPIs​

3 KPIs from the pack's catalogue, packs/files/kpis.yaml. A gate must be zero for a variant of an architecture to count.

Correctness​

KPIunitbettergatestatus
write_after_lease_end
File changes made under a lease that had already ended.
How: FileWritten, FileEdited, FileCopied, FileMoved and FileDeleted events whose lease has a LeaseReleased or LeaseExpired before the change. The tools refuse these; any found is an implementation defect. Must be 0.
countlowergateplanned
source: design

Quality​

KPIunitbettergatestatus
file_churn_ratio
Edits per file an agent changed in one run.
How: FileEdited events divided by the distinct files written or edited, per lease. A high ratio is an agent editing the same file over and over.
ratiolower–planned
source: design
stale_edit_share
Share of edits made against content that had changed since it was read.
How: edit_file calls refused content-changed divided by all edit_file calls. Counted from the tool's answers; each refusal is an agent working from a stale read.
sharelower–planned
source: design

Settings​

The settings a part of this block carries in an architecture document. agenticspec sim check refuses any other setting (setting_unknown) and a value outside its type (setting_invalid), and a part that lacks a setting marked required in the default column; the contract copies a setting into the ports it narrows. The last rows of each table are the settings every part takes. What no setting here types (a file, a path, an audience, the use of a model) goes into the part's notes, a map with free keys and values that the check takes as written and nothing reads.

A part files.toolset:

settingtypeunitdefaultcontractwhat
countinteger of at least 11How many copies of the part run.
perpartOne copy of the part for each copy of the named part.
notesnotesFree notes on the part, a map with keys and values of any kind: what no setting of its block types. The check takes any map; the simulator, the search and the contract never read it.