Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/design/background-task-output.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ contain `session.exec.stop`; the sibling `session.exec.output` does not.
WorkspaceTools registers the leaf; Rpc's built-in list and namespace checks are
unchanged.

Each call resolves the named branch through WorkspaceTools' existing
`TreeCommands`, then asks that branch's BackgroundExec for the active task's
capture. No Session part retains branch business state.
Each call resolves the line with `line_owner::<BackgroundExec>(line)`
([ADR 027](https://github.com/arcships/dim/pull/2029)), then asks that line's
BackgroundExec for the task's output artifact. No Session part retains branch
business state.

**Task identity.** Every request resolves `taskId` inside the branch it names:
`sessionId` admits the Session, `branchId` selects that Session's branch, and
Expand Down
10 changes: 5 additions & 5 deletions docs/design/contracts/runtime-owner-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
| History RPC and line-read tools → timelineTree | `batchEnd(id, sequence) → void`, `pageEnd(id, after, limit, through) → sequence`, and `page` at the same cutoff. Preserve complete batches and the fixed head of ended lines. |
| Context RPC → target branch | `agentLoop.compact` and `contextUsage.read`. |
| Goal and Shell admission → timelineTree | `directory({id})` returns the matching directory entry or the unknown-branch error using a single-branch lookup. Goal reads ended history through `query`; writes retain the ended/unknown errors. |
| InputQueue and Collaboration approvals → target branch | `timelineTree.input`, `inputQueue.withdraw` after submission checks, and `approval.pending/decide` on the selected branch. |
| InputQueue and Collaboration approvals → target branch | `timelineTree.input`, `inputQueue.withdraw` after submission checks, and `approval.pending/decide` on the selected branch([Approval](../plugins/Approval.md)); the caller reaches the line's owner by line id ([ADR 027](https://github.com/arcships/dim/pull/2029)). |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new links at lines 26, 48, 63, 76 and 77 use full-width Chinese parentheses in an English document. Fix: replace them with ASCII parentheses.

| PromptSuggestion → ContextUsage; Report and Agent configuration → Prompt | `contextUsage.read`, `prompt.adoptedConfiguration({}) → adopted configuration or null`. Report also uses `timelineTree.query` at the selected head for evidence. |
| Prompt and ToolBinding → `branchLifecycle` | `registerOpening(completion) → void`. Opening waits for admitted completions under its existing deadline and propagates their errors. |
| Fault producers and Session observers → `sessionLifecycle` | `reportFault(error) → void`, `failure({}) → SessionFault or null`, `observeFault(listener) → id`, `release(id) → boolean`. The listener receives the current failure (initially null) and subsequent reports. Caller unload releases the observation. The first fault wins until a storage failure supersedes it; the first storage failure wins. |
Expand All @@ -45,7 +45,7 @@ own methods.
| --- | --- |
| Context RPC / PromptSuggestion | `contextUsage.read`. The `compactAndWait` variant runs the existing compact RPC handler: it calls `agentLoop.compact` and waits for the compaction fact matching that command sequence and returns the existing completed/skipped/failed reply. The committed sequence watch and bounded query run inside the selected branch for that wait. |
| Session language / Agent configuration / Report | `prompt.configure` or `prompt.adoptedConfiguration` with the existing source, model and outcome records. |
| InputQueue management / Collaboration | `inputQueue.withdraw` with the existing command; the caller runs the existing submit checks for steer before writing. `approval.pending` returns the branch's existing pending requests, and `approval.decide` settles the selected request. Collaboration retains its ended response on closed/ended/unknown detail lookup. |
| InputQueue management / Collaboration | `inputQueue.withdraw` with the existing command; the caller runs the existing submit checks for steer before writing. `approval.pending` returns the line's existing pending requests, and `approval.decide` settles the selected request([Approval](../plugins/Approval.md)). Collaboration retains its ended response on closed/ended/unknown detail lookup. |

For a live main branch, Report captures its published head once at draft capture (`directory({id:"main"}).head`)
and stores it as `conversationThrough` on that draft. Activity evidence and later opt-in
Expand All @@ -60,7 +60,7 @@ substitutes a newer head.
| --- | --- |
| ToolBinding, Session language and Agent configuration → `prompt` | `prompt.initialCompletion({}) → void or opening error`; `prompt.configure({sources, model?}) → unchanged, adopted or superseded`. |
| Prompt and guide adoption → `contextPreparation` | `contextPreparation.publish({adopted, changes, model?, toolAdoption?, inputs}) → sequence or null`; `awaitPublished({sequence}) → sequence`. Publication commits adoption atomically. |
| File read/edit/write tools → branch FileReads | `binding({path}) → TextFileBinding or null`, `writeBinding({path}) → absent, compacted or bound`, `record({path, binding, established}) → void`. The original read supplies the established sequence; file I/O stays on the file node. |
| File read/edit/write tools → branch FileReads | `binding({path, purpose}) → BindingReply` (`bound {binding}` or `unavailable {reason: neverRead\|compacted}`; `path` is canonical), `record({path, binding, established}) → void`([FileReads](../plugins/FileReads.md)). The original read supplies the established sequence; file I/O stays on the file node. |

### Model preparation, history and tools

Expand All @@ -73,5 +73,5 @@ substitutes a newer head.
| Loop and ContextPreparation → HistoryRenderer | `context({branchId, through}) → ContextHistory`, `renderedContext({branchId, through}) → {context, history: HistoryEntry[]}`, `snapshot({context, retainFrom, anchor}) → RecoverySnapshot`, `streamCheckpoint({branchId, through, retainFrom, batch}) → ProjectionCheckpoint`. |
| Loop and ModelProvider → ContextPreparation | `prepare({source: ContextPrepareData, projection?}, cancelled) → ModelRequest`, `validate({requestId, request}, cancelled) → void`. Reuse the prepared projection at the original cutoff. |
| ContextPreparation and usage readers → ContextUsage | `read({through?}, cancelled) → {through, contextWindow, outputTokens, thresholdTokens, estimatedInputTokens, baselineSource}`. |
| Loop, ToolExecutor and Code Mode definition readers → `toolBinding` | `bind({requestId, through, tools, toolSources}) → void`, `bindCurrent({requestId, declared?}) → ToolDefinition[]`, `definitions({requestId}) → ToolDefinition[]`, `transfer({from, to}) → void`, `release({requestId}) → void`. ToolBinding retains the pinned handler generation. |
| Nested tool execution → `toolExecutor` | `open({parentCallId, context}, cancelled) → gateId`, `invoke({gateId, call}) → ToolResult`, `close({gateId}) → ToolEffect[]`. Close joins children in order; interruption releases the gate. |
| Loop, ToolExecutor and Code Mode readers → `toolBinding` | `bind({requestId, turnId, through, declared, sources}) → void`, `adopted({requestId}) → {adoption, tools}`, `claim({requestId, calls, context}) → void`, `transfer({from, to}) → void`, `release({requestId}) → void`, `retain_only({requestId}) → void`([ToolBinding](../plugins/ToolBinding.md)). Settlement follows the line's `step/tool-result` and `turn/end`; `retain_only` is the Loop's own rebuild step. |
| Nested tool execution → `toolExecutor` | `open({parentCallId, context}, cancelled) → gateId`, `invoke({gateId, call}, cancelled) → ToolResult`, `close({gateId}) → {effects}`([ToolExecutor](../plugins/ToolExecutor.md)). The owner closes the gate at the parent's settlement; interruption releases it. |
2 changes: 1 addition & 1 deletion docs/design/contracts/session-boundary.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ No protocol version is added and persistence formats are unchanged.

A Session part contributes a tool by registering it with the Session's `toolRegistry`, from any language. The registration belongs to the part that made it and is withdrawn when that part unloads (ADR 002 D3, D5). ToolRegistry does not depend on the parts that register; they depend on it, so when ToolRegistry reloads, the parts registered with it reload and register again. `SessionConfig.tools` is the Session's optional mount list, fixed at creation ([session-access A.3](session-access.md#a3-sessionconfig-fields)). Without one, the Session declares every host tool in the host's order and every registered tool by name, so a plugin's tools are usable once its part registers them, with no configuration edit (#364); with one, it declares the host and registered tools the list names, in its order, and `[]` declares none of them. Other sources' tools follow in both cases and are governed by their sources' own configuration, not by the mount list. Each mounted registered tool is a registry-owned versioned set keyed `#contributed:<tool>` (#241): it is declared while a part has it registered, withdrawn with the registration, and declared under a new version when a part registers it again. A version is a new UUID, never reused even across registry instances and processes, so a version persisted in `tool_sources` names one generation. Every read takes in what is registered then; once the Session is published, the registry's own task also rereads after every registration and withdrawal, until the Session starts closing. A tool the mount list names that no part has registered is not declared and is reported in diagnostics, and the Session still starts; the tool is declared from the next request after a part registers it, without a Session reload. Required dependency waiting rules are unchanged; an optional part registered when the Session opens settles before publication, and one that is Pending or Failed never fails Session readiness (#132, #207, ADR 006 D3).

ToolBinding reconciles the table through the existing Prompt / BranchLifecycle flow before the Session accepts input. A branch with adopted model configuration uses `Prompt::adopt_tools` when its tool part differs. For a request without adopted configuration, ToolBinding captures a registry snapshot before PrepareModelHost selects from the supplied definitions, then binds the selection against the same retained handlers. With adopted configuration but no tool part, `bind_current` declares and binds the registry's current tools on each request. Registration changes need no adoption in either request path. No new core readiness phase is needed. Source changes, including registered tools in a configuration with a tool part, go through the existing registry notification and Prompt adoption path (`context/configured` with `tool_sources`), and requests retain the handlers selected for their own prefix. A tool name follows `[A-Za-z0-9_-]{1,64}`; a name that is registered already or is a host tool's is refused. The mount list decides what is declared, and only duplicate names in it fail the Session ([tool contributions](../../architecture/rust-agent/tool-contributions.md)). Permission decides whether a declared tool's call runs: its preset and `allowedTools`/`disallowedTools` change live through `session.permission.update` and never change the declarations, which are part of the prompt prefix. To block a tool and keep the context stable, keep it mounted and deny it in Permission; to change what the model sees, create the Session with a different mount list.
ToolBinding's target contract is [ToolBinding](../plugins/ToolBinding.md): a request's record binds to the registry's adoption, claims its calls before the batch fact, and is settled by the owner from the branch's `step/tool-result` and `turn/end`; the adopted configuration fact stays Prompt's (`context/configured` with `tool_sources`). No new core readiness phase is needed. Source changes, including registered tools in a configuration with a tool part, go through the existing registry notification and Prompt adoption path. A tool name follows `[A-Za-z0-9_-]{1,64}`; a name that is registered already or is a host tool's is refused. The mount list decides what is declared, and only duplicate names in it fail the Session ([tool contributions](../../architecture/rust-agent/tool-contributions.md)). Permission decides whether a declared tool's call runs: its preset and `allowedTools`/`disallowedTools` change live through `session.permission.update` and never change the declarations, which are part of the prompt prefix. To block a tool and keep the context stable, keep it mounted and deny it in Permission; to change what the model sees, create the Session with a different mount list.

| Method | Mode | Request | Reply |
| --- | --- | --- | --- |
Expand Down
Loading