Skip to content

design(2033): target contracts for Goal, SessionTitle, Web and Code Mode - #2099

Closed
eric8810 wants to merge 6 commits into
mainfrom
dim/2033-plugins-contract
Closed

eric8810 wants to merge 6 commits into
mainfrom
dim/2033-plugins-contract

Conversation

@eric8810

@eric8810 eric8810 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #2033 · Refs #2015

Summary

The target contracts of the four owners in the product plugin block, one document each:

  • Goal — the Session entry writes one command input to the line and reads the goal owner's published value (goalLine.read). The process-wide routing table, the Session-side re-fold and the pre-commit callback are removed; the branch owner composes the state record after the business fact.
  • Code Mode — the process owner keeps only the program slots (with_slot, a callback by reference) and the line's owner runs the program (codeModeLine.run). The run opens ToolExecutor's gate, invokes by gate id, and closes the gate once to word its result with the confirmed effects; ToolExecutor closes it again at parent settlement and merges the effects once. The pinned declarations come from toolBinding.adopted. The process runner table, the runner trait and the executor wrapper are removed.
  • SessionTitle — the optional generator name, the required model dependency and the model-text decode are removed: it calls Provider's invoke with Once, the account owner's title when that owner exists, reads Goal's published value, and writes through SessionStore's setTitle(id, change), deciding inside the callback whether the stored title allows the write.
  • Web — unchanged public surface: two tool contributions (one fixed, one dynamic source) and no service. The search call names dimAccount.search and the declaration follows dimAccount.availability and subscribe; the removed managedSearch face is not used.

The requirements the block raises are listed in each document and sent to the owners' issues: #2024 (who provides the line-id operations to Session parts, per the cross-cutting decision), #2027 (inputQueue.submit). #2028's open/invoke and adopted and #2018's setTitle change callback are used as their contracts state; no requirement remains open on either.

Delivery part: #2033 comment (deletion list, caller migration, implementation task, acceptance).

Design rule checklist

  • Scope: the documents state each owner's responsibilities, the callers' business and one row per caller requirement; only rows that cannot be composed produce an operation.
  • Commands and results: the command entry points and the tool results are data; no document adds a command event.
  • Handover: the evaluator line and the child gate are used by id; no branch scope or executor object crosses.
  • Timeline before callbacks: Goal registers none and folds what it committed.
  • Infrastructure: no core change; the four requirements are named below.
  • Core mechanisms and consumers gain no plugin-specific handling: the mechanism resolves a line's owner; no plugin gains a branch-scoped entry in the tree.
  • Batch: Goal's fact and record are separate appends in a stated order; child batches stay ToolExecutor's.
  • Context: goals and titles reach the model only through adopted inputs; Code Mode's children never enter context.
  • No reading another plugin's internal state or deciding for it: each document's dependency table names the owner and its operation.
  • Cross-language faces: every operation is data, a callback by reference or an id; no Rust-only method stays on a public face.
  • Business configuration and language-neutral contracts: the four Settings sources are read at use; no document restates another owner's shape.
  • Missing mechanism capabilities: four requirements, sent to their issues.
  • Timeline holds only facts later decisions use: the goal state is a line fact; the title never enters the Timeline.

Documentation

  • No accepted ADR is modified or deleted.
  • No other module's design is changed: the four documents and the plugin index are this block's.
  • No delivery status added.

Verification

  • node scripts/adr-check.mjs --base origin/main passed.
  • cargo run --locked -p xtask-check passed.

Merge order

#2029 → #2080 → #2091/#2092/#2093 → #2094 → #2096 → the rest.

Sibling heads this change is aligned with: #2091 f7425d55c, #2092 d96802349, #2100 437266bff, #2101 18d5e4f07. A paragraph that depends on a sibling names that PR; its head is the one above.

@eric8810

Copy link
Copy Markdown
Collaborator Author

评审(head ae5cf0888):符合。line_owner::<T>(line) 的写法正确,Code Mode 的 with_slot 回调、SessionTitle 的 setTitle change 回调都对。

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 7ca508580。

  • Goal 的 directory() 示例:改为 tree.directory()?.default(docs(design): define the line directory owner contract #2092 的 directory {} → {default, lines}),删掉 directory(None) 与 DirectoryReply/unreachable!;示例补一次 tree.line(LineRequest { line }),对应操作表里的 line_missing;依赖表把 directory、line、read、create、end 分开列出。
  • line_owner::<T>(line):按跨 PR 汇总第 1 条,保持类型化写法,不改。
  • Code Mode 的 with_slot、SessionTitle 的 setTitle change:评审无意见,不改。

交付评论的 Goal 迁移行与首行 head 已同步;node scripts/adr-check.mjs --base origin/main 与 cargo run --locked -p xtask-check 通过。向其他所有者没有新需求:line_owner 的提供方仍记在 #2024 的需求评论里。

@eric8810
eric8810 marked this pull request as ready for review November 23, 2026 12:13

@yyhhyyyyyy yyhhyyyyyy left a comment

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.

Scope: this PR rewrites the four product plugin owner contracts (Goal, SessionTitle, Web and Code Mode) plus the plugin index for the owner-operations series (refs #2033 and #2015, with the SessionStore contract in #2018/#2091), moving callers to line-id operations, the store's change callback and the account owner's face, and deleting about 1400 lines of mechanism detail.

Verdict: REQUEST_CHANGES

P1

1. session.goal.get changes the wire shape and names types that do not exist

Problem: docs/design/plugins/Goal.md:99 changes the reply to {branchId, goal?} where the goal carries {objective, status, judge, through}, and Goal.md:216 calls GoalStatus and GoalJudge "the existing types in crates/dim-goal". The existing types are GoalView, GoalViewStatus and GoalRead in crates/dim-agent-types/src/goal.rs:5-29; GoalView has objective: String and evaluator: bool, and GoalRead has a top-level through. The delivery comment on #2033 also says the result formats stay unchanged except for the removed sequence.

Failure scenario: crates/dim-cli/src/goal_command.rs:32 deserializes the reply as GoalRead, and crates/dim-cli/src/goal.rs:171 reads goal.evaluator; GoalRead and GoalView use deny_unknown_fields, so the documented reply fails to deserialize (top-level through is missing, judge and through inside the goal are rejected). The CLI /goal, the session host inventory and the ACP goal display break, and a client that keeps the old shape cannot read the new judge or through.

Fix: keep the GoalRead shape ({branchId, through, goal: {objective, status, evaluator}}) on session.goal.get and map GoalValue to it, or state the shape change and migrate every caller (CLI, session host, ACP) in the same delivery; use the real type names or define the new ones instead of calling them existing.

P2

2. The rewrite deletes anchors that standing documents and crate docs still link

Problem: the old headings are gone, but more than 30 links still target them: crates/dim-cli/README.md:744 (Goal.md#a2-session-methods), crates/dim-oauth/docs/design.md:20 and crates/dim-oauth/docs/runtime-contract.md:12 (SessionTitle.md#33-generation-routing-and-optional-service), docs/design/cli-commands.md:576 and :622, docs/design/timeline-branches.md:249, :253, :312, :323, :507, :556, docs/design/model-prompts.md:229, docs/design/plugins/Pursuit.md:16, :36, :46, :50, :58, :81, :93, docs/design/plugins/Scheduler.md:514, docs/design/plugins/Skills.md:526, docs/design/appserver/session-title-metadata.md:9, :72, :78, :154, :202, :206, :216, :230, :284, docs/design/appserver/session-notices.md:5, docs/design/appserver/idle-unload.md:110, docs/design/overview.md:563, docs/design/timeline-read-followups.md:15 and docs/design/acp-gateway-implementation.md:297.

Failure scenario: a reader following any of these links lands at the top of the rewritten document with no matching section; an implementer reading the S5b title metadata or the CLI contract loses the referenced rule. The static check only validates links written in Rust comments, so CI does not catch these.

Fix: update every referrer to the new heading or keep compatibility anchors for the old names; list anything another PR owns instead of leaving a silently broken link.

3. Standing contracts still describe the removed behavior

Problem: docs/design/overview.md:71, :78, :166 and :229 still say Goal folds goal:objective and goal:status blocks and SessionTitle observes the Session broadcast and sends text to the auxiliary model; docs/design/cli-commands.md:605 says every Goal method "replies with its input's sequence"; docs/design/plugin-contract.md:110 still lists sessionMetadata as SessionTitle's service; docs/design/appserver/session-title-metadata.md:92 and :206 still define setTitle {expectedRevision} with conflict and "SessionTitle reads again and retries"; the Chinese mirrors docs/zh/design/plugins/Goal.md, SessionTitle.md and Web.md still describe the old contracts.

Failure scenario: two documents in the same repository give different rules for one owner, and the delivery that follows this PR cannot tell which one is authoritative.

Fix: update these referrers in this PR, or name the PR that will and mark the old sections as superseded. The Chinese mirrors need at least a note that they are stale.

4. Goal's state record has two writers

Problem: Goal.md:81 says the input owner's submit carries "the command input and the state record input"; Goal.md:179 says the timeline's append "accepts an input-message draft" and Goal appends "the fact and then the record"; Goal.md:113 says the branch decision appends both.

Failure scenario: the implementation either bypasses InputQueue's ordering and idempotency by appending the record directly, or uses submit and cannot follow the stated append API. The two statements cannot both hold.

Fix: name one owner for the record: submit for the record and append only for the business fact, or append for both with the input owner's involvement stated.

5. goalLine.read is documented as cancellable but its binding has no cancellation argument

Problem: Goal.md:101 and :112 say the wait can stop and list cancellation, and Goal.md:183 says cancelled is the binding's cancellation argument, but Goal.md:201 declares pub async fn read(&self) with no cancellation argument. GoalError includes Cancelled, which this face cannot produce.

Failure scenario: an implementation following the appendix cannot stop the read when the caller drops or the Session unloads; the cancellation column and the flow row cannot be implemented.

Fix: add the cancellation argument to read and show how NoInstance and Closed map, or remove the cancellation claim and the Cancelled error from this face.

6. Goal's retry rule has no submission id

Problem: Goal.md:29 makes retry safety the row's handling ("the submission id on submit") and Goal.md:146 verifies that a command submitted twice with one submission id is accepted once; the command requests in Goal.md:96-100 have no submission id and no rule derives one.

Failure scenario: a client that retries session.goal.set after a lost reply creates a second input and a second goal execution; the verification only exercises InputQueue's submit, not Goal's method.

Fix: add a submission id to the command requests, or derive it from the client's request id and state it; move the verification to the method.

7. Goal's companion documents still state the old write and evaluator flows

Problem: Goal.md:3 says two places supersede Goal-state-read.md and that they are named below, but only Goal.md:116 names one. Goal-state-read.md:77 still requires one atomic append_batch for the command, the model state input and the business fact, and Goal-state-read.md:79 still says the public methods return the trigger's sequence. Pursuit.md:42 uses invalid_params, Pursuit.md:56 uses treeCommands.create, and Pursuit.md:57 relies on branch/create-failed; the new Goal uses TimelineTree create/end and invalid.

Failure scenario: the documents that Goal calls authoritative for state and evaluator behavior contradict the new contract, so an implementer keeps the atomic batch and the sequence reply.

Fix: update both companions here, or name the owning PR, and make the supersession list accurate.

8. SessionTitle depends on an unmerged store contract and its binding does not match it

Problem: SessionTitle.md:169 calls PR #2091's setTitle {id} + change "SessionStore's current contract" and says no requirement is open, but #2091 is open and main still implements setTitle {sessionId, expectedRevision, title} with conflict (crates/dim-app-server/src/storage/metadata.rs:201, docs/design/appserver/session-title-metadata.md:22 and :92). SessionTitle.md:204 defines a synchronous TitleChange over StoredTitle; #2091's ChangeFn is async (BoxFuture) over TitleState.

Failure scenario: the appendix and the caller examples do not compile against the cited contract; an implementation against main cannot provide the change callback; the document hides a forward dependency behind the word "current".

Fix: mark #2091 as the owning open PR in the dependency table, use TitleState and the async ChangeFn (or say why the binding differs), and state what replaces the S5b expectedRevision/conflict rule.

9. Web says a profile without the account owner has no web_search

Problem: Web.md:72 says "A profile without an account owner declares web_fetch only"; A.5 (Web.md:252) and Appendix D.1 keep the configured adapter path, and the implementation declares web_search for an adapter with its API key (crates/dim-app-server/src/web.rs:1017-1022).

Failure scenario: an operator with a configured adapter and no Dim account loses web_search, contradicting the source's own searchService field and the acceptance test.

Fix: state the adapter path: a configured adapter with a key declares web_search regardless of the account; the account owner decides only when the source names no adapter or a dim-oauth configuration.

10. Code Mode's v4 gate reads a protocol version SessionScope does not provide

Problem: CodeMode.md:29 and :72 say the entry gates on the client's protocol version from SessionScope's config; the SessionScope contract returns SessionConfig (PR #2093), which has no protocol version (crates/dim-agent-runtime/src/config.rs:39-88). The current gate is SessionConfig.excluded_tools, set by exclude_codemode_below (config.rs:190-192, crates/dim-app-server/src/connection.rs:1881-1883).

Failure scenario: the entry cannot compose the v4 gate from config; a v3 Session may be offered codemode, or a v4 Session may be refused.

Fix: keep the mount exclusion as the gate and state it, or add a protocol-version read to SessionScope's contract and link it.

11. Code Mode's slot example cannot return its result

Problem: CodeMode.md:54-59 passes a closure to with_slot, but the SlotWork type at CodeMode.md:170-172 returns Result<(), ProfileError> and the closure returns Ok(program_result(outcome, effects)); with_slot returns Result<(), SlotError>, so the run's ToolResult is dropped. The example also calls executor.close(..., cancelled), while #2100's close takes only CloseRequest. ProfileError is HostError, which has no From<rutis::host::CallError>; the runtime implements that conversion for AgentError (crates/dim-agent-runtime/src/error.rs:283).

Failure scenario: the appendix does not compile, the run cannot answer the outer call, and the callback cannot absorb a bridge call failure.

Fix: make SlotWork and with_slot generic over the work's reply or capture the result outside; call close with the request only; use an error type with the rutis conversion or add it.

12. Goal's evaluator line has no refusal path

Problem: Goal.md:114 opens a child line at the turn end, and Goal.md:19 and :96 allow a goal on any line, but TimelineTree's create refuses a non-opener line (not_opener) and the Session's cap (limit_reached) (PR #2092). Goal's operations, flows and errors name neither.

Failure scenario: a goal with judge: "evaluator" on a child line cannot create the evaluator; the goal stays active and retries at every turn end, or the branch decision fails without a terminal state.

Fix: name the refusal and the paused reason in Goal and Pursuit, or refuse judge: "evaluator" for lines that may not open one.

P3

13. TimelineTree shape names do not match the cited contract

Problem: Goal.md:46 uses LineRequest { line } and calls the unknown-line error line_missing; the TimelineTree contract (PR #2092) defines line as {line} with unknown and closed, and Goal.md:99 lists line_missing for get even though the get example at Goal.md:58 never calls line and maps NoInstance to no_goal_owner.

Failure scenario: a client cannot tell which error an unknown line produces, and the example against the owner contract does not compile.

Fix: use the owner's request shape and error names; add the line check to get or drop line_missing from its row.

14. SessionTitle's ROOT is undefined

Problem: SessionTitle.md:57 reads line: ROOT; the conversation line is directory().default (PR #2092, and Goal.md:44 uses it), and no ROOT exists in the contract.

Failure scenario: the example does not compile, or it titles from a line that is not the conversation line after the default moves.

Fix: resolve tree.directory()?.default.

15. Code Mode and Web binding details

Problem: CodeMode.md:164 marks ProgramSlots with #[rutis::service] while CodeMode.md:159 says the process part provides codeMode; one Rust type is one name, so the catalog name is programSlots unless the attribute says name = "codeMode" (the pattern in PR #2096). CodeMode.md:100 lists interrupted and gate_closed as operation errors, but the run's error list at :79 and RunError at :189-195 have neither. CodeMode.md:68 names Session access (#2025) for the line's owner, while its own requirements at :153 and Goal.md:88 put the line-id mechanism in TimelineTree (#2024). Web.md:153 defines sets() -> Vec<ToolSet>, but the trait is fn sets(&self) -> Vec<Arc<ToolSourceSet>> (crates/dim-agent-capabilities/src/tool_registry.rs:125-135); ToolSet is undefined. Web.md:168 says toolRegistry.registerSource while the dependency table and #2103 use register_source, and Web.md:258 says "belongs to PluginManager (PluginManager)" with no link.

Failure scenario: the catalog would show the wrong process face, the run's error table cannot be returned by its operation, and the two appendices do not compile.

Fix: add name = "codeMode", separate operation errors from program conditions, name one owner for line_owner, use Vec<Arc<ToolSourceSet>>, use one spelling, and link PluginManager.

16. Removed configuration and tool text contracts

Problem: SessionTitle.md:12, :86 and :95 still use maxLength, but the session-title document's defaults, range and user-only/no-project rule are gone; Goal.md:85 keeps maxContinuations without its 1..=1000 range; CodeMode.md:11 names the eight bounds without their values; Goal.md:100 no longer pins the goal_update text that crates/dim-goal/tests/goal_product_flow.rs:487 expects (goal_update recorded: completed.).

Failure scenario: implementers cannot keep the public configuration and tool text, and existing tests break.

Fix: state the retained values or link the schema owner, and say explicitly which texts change.

17. Forward references to open PRs

Problem: the contracts depend on open PRs: #2029 for every rule 7 row, #2091 for SessionStore, #2092 for the line directory, #2093 for SessionScope and line_owner, #2096 for dimAccount and #2100 for ToolExecutor and ToolBinding. Only #2091, #2092 and #2100 are named in the text; #2029 and #2096 are not linked.

Failure scenario: a reader on main cannot resolve the operations the documents call, and the "no requirement remains open" statements hide the landing order.

Fix: list the owning PRs as open dependencies, as the series does elsewhere, and land them in order.

18. Goal's requirement count is wrong

Problem: Goal.md:162 says "Two requirements are listed below", but Goal.md:177-179 lists three: TimelineTree, the input owner and the timeline owner.

Failure scenario: a reader counts two requirements and misses the timeline owner, so the append requirement is never tracked to its owner.

Fix: say three or merge the timeline row.

19. SessionTitle's rule check still lists the Session broadcast

Problem: SessionTitle.md:153 says the part uses the Session broadcast, while the new design observes through TimelineTree read and the Exceptions at SessionTitle.md:123 explicitly remove the subscription.

Failure scenario: the rule check contradicts the flows and keeps a removed dependency visible.

Fix: remove the Session broadcast from the row.

Comment thread docs/design/plugins/Goal.md Outdated
| The model reports completion or blockage | No: the report changes the goal, and its line is the call's line | the tool handler writes one command input to that line |
| A client reads the goal of a line | No: the goal is the line owner's state and nothing else publishes it | `goalLine.read` at the line id |
| The owner states the state to the model | No: the state block restates the whole goal and the live keys when it changes | the branch owner writes the state record input |
| A command is retried after a lost reply | No: accepting a command once is the input owner's rule | the submission id on `submit` |

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.

This row says a retried command is handled by the submission id on submit, but the command requests at docs/design/plugins/Goal.md:96-100 have no submission id and no rule derives one. A client that retries session.goal.set after a lost reply composes a new input and starts a second execution; the verification at Goal.md:146 only tests InputQueue's submit, not Goal's method. Add a submission id to the command requests (or derive it from the client's request id and state that), and move the duplicate test to the method.

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.

Still open: the command requests at docs/design/plugins/Goal.md:96-98 carry no submission id, and no rule derives one; crates/dim-goal/src/session.rs:162-220 still accepts a plain objective and starts a new change per call.

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.

Fixed in 5f9a0f1. Goal.md:29 states the retry rule, :96-98 add submissionId? to every write request, :158 names the client-visible request change, and :147 tests the method rather than only submit.

Comment thread docs/design/plugins/Goal.md Outdated
Some(line) => line,
None => tree.directory()?.default, // TimelineTree's shape (#2092)
};
let _ = tree.line(LineRequest { line: line.clone() })?; // line_missing for a line that does not exist

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.

LineRequest is not a type in the TimelineTree contract this document cites (PR #2092): line takes {line} and answers unknown and closed, not line_missing. The same mismatch appears at docs/design/plugins/Goal.md:103, and the get example at Goal.md:58 never calls line, so it cannot produce the line_missing its row lists. Use the owner's request shape and error names, and either add the line check to get or drop line_missing from it.

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.

Still open: LineRequest is still undefined at docs/design/plugins/Goal.md:46; the TimelineTree contract takes {line} and its example calls tree.line(id) (PR #2092), and the owner's error is unknown, not unknown_branch.

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.

Fixed in 5f9a0f1. Goal.md:46 calls tree.line(line.clone()) and maps the tree's unknown kind to the published code. PR #2092's line takes a line id and answers unknown (TimelineTree.md:131, :153); no LineRequest remains in the contract.

Comment thread docs/design/plugins/Goal.md Outdated
| Owner | Operation | Use |
| --- | --- | --- |
| TimelineTree ([#2024](https://github.com/arcships/dim/issues/2024)) | `directory`, `line`, `read`, `create`, `end` | The conversation line; one line's record for the named line; an ended line's facts; opening and closing the evaluator line |
| The line's input owner ([#2027](https://github.com/arcships/dim/issues/2027)) | `submit` | The command input and the state record input |

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.

This row gives the state record to the input owner's submit, but docs/design/plugins/Goal.md:179 says the timeline's append accepts an input-message draft and that Goal appends the fact and then the record, and Goal.md:113 says the branch decision appends both. Name one writer: submit for the state record and append only for the business fact, or append for both with the input owner's involvement stated; the current text cannot be implemented both ways.

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.

Still open: docs/design/plugins/Goal.md:81 still gives the state record to the input owner's submit, while :113, :116 and :192 append it with the timeline's append; docs/design/contracts/runtime-owner-operations.md:21 now says timeline.append for the record.

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.

Fixed in 5f9a0f1. Goal.md:81 gives the input owner's submit the command input only; :82 gives the timeline's append the business fact and then the state record; :113, :192 and runtime-owner-operations.md:21 agree.

| `session.goal.*` write | Check parameters, resolve the line, compose the command input, submit it; the input owner commits it in order | Before submission nothing is written; after submission the input stays and the branch owner decides | Nothing to release: no id crossed | `closed` once the Session or the input owner is closing | the input owner; the entry holds nothing |
| `goalLine.read` | Wait for the branch part's fold to reach its head, answer the value | The wait stops; the value is unaffected | Nothing to release | `closed` when the part is closing | the branch part |
| Branch decision | Consume a command input, decide from the fold, append the business fact, append the state record, then write the continuation or ask for an evaluation | The line's closers end the branch part's tasks; an admitted input is not withdrawn | — | Closing cancels the tasks, writes `paused` with its reason, then the services are withdrawn | the branch part: its own tasks, the fact and the record; the input owner: the continuation it accepted |
| Evaluator line | Open a child line at the turn end with Goal's operation id; the evaluator reports a conclusion; Goal closes the line | The line's close stops the decision that would open it | — | On rebuild and on close Goal closes the evaluator lines it opened, before the Session closes | the branch part asks; TimelineTree creates, holds and closes the line |

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 evaluator flow opens a child line, but docs/design/plugins/Goal.md:19 and :96 allow a goal on any line, and TimelineTree's create refuses a non-opener line (not_opener) and the Session cap (limit_reached) in PR #2092. Neither refusal appears in Goal's flows or errors, so a judge: "evaluator" goal on a child line cannot create its evaluator and the goal stays active across turn ends. State the refusal and the paused reason, or restrict judge: "evaluator" to lines that may open one.

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.

Still open: docs/design/plugins/Goal.md:114 and :131 open a child line, but the flows and errors at :109-127 name neither branch_not_opener nor branch_limit_reached from TimelineTree's create (PR #2092; crates/dim-agent-runtime/src/error.rs:161-170).

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.

Fixed in 5f9a0f1. Goal.md:115 and :146 name branch_not_opener and branch_limit_reached from TimelineTree's create, and pause the goal with evaluation_failed. The codes exist at crates/dim-agent-runtime/src/error.rs:167-168, and PR #2092's create lists both (TimelineTree.md:127).

Comment thread docs/design/plugins/Goal.md Outdated
#[rutis::service]
impl GoalLine {
/// The goal of this line now; waits until the fold reaches the head.
pub async fn read(&self) -> Result<GoalValue, GoalError>;

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.

read takes no cancellation argument, while docs/design/plugins/Goal.md:101 and :112 say the wait can stop and Goal.md:183 says cancelled is the binding's cancellation argument; GoalError also has a Cancelled variant this face cannot produce. Add the cancellation argument and show how NoInstance and Closed map, or remove the cancellation claim from the read row and the flow.

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.

Still open: docs/design/plugins/Goal.md:105 still says cancelled is the binding's cancellation argument, but the appendix at :214 declares read(&self) with no argument and the flow at :112 says the wait stops.

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.

Fixed in 5f9a0f1. Goal.md:105 keeps the cancellation claim, the appendix at :275 declares read(&self, cancelled: CancelledFn), and :112 says the wait stops while the value is unaffected.

Comment thread docs/design/plugins/CodeMode.md Outdated
| Owner and issue | Dim runtime / ToolExecutor mechanism owner; [#1276](https://github.com/arcships/dim/issues/1276). |
| `invalid` | Fix the program: it exceeds the code byte limit |
| `closed` | The line's run owner, the executor or the process quota is unloading; the next generation serves the next call |
| `interrupted` | The turn was interrupted before the gate existed; the run answers a cancellation result |

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.

interrupted and gate_closed are not operation errors of codeModeLine.run: its error list at docs/design/plugins/CodeMode.md:79 and RunError at :189-195 contain neither, and both are ToolExecutor kinds in #2100 (a child call or a close after settlement). Keep the operation's own errors in this table and state the program-visible conditions separately, or add the variants to RunError and the run's error list.

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.

Partly fixed: docs/design/plugins/CodeMode.md:82 now says gate_closed, interrupted and no_batch are ToolExecutor's errors, but the Errors table at :100-101 still lists interrupted and gate_closed beside the run's own invalid, closed and cancelled.

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.

Partly fixed in 5f9a0f1. CodeMode.md:84 now scopes gate_closed, interrupted and no_batch to ToolExecutor. Remaining: the Errors table at :102-103 still lists interrupted and gate_closed beside the run's own invalid, closed and cancelled. Label the table as covering the child operations too, or drop them from the run's table.

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.

Fixed in 8f440bd. CodeMode.md:102-105 labels interrupted, no_batch and gate_closed as ToolExecutor's kinds, and scopes the run's own errors to invalid, closed and cancelled.

Comment thread docs/design/plugins/CodeMode.md Outdated
```rust
use rutis::host::BoxFuture;

#[rutis::service]

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 process face is documented as codeMode (docs/design/plugins/README.md:37, and the operations table at docs/design/plugins/CodeMode.md:80), but this marks the type ProgramSlots with a plain #[rutis::service]; one Rust type is one name, so the catalog name would be programSlots. PR #2096 shows the pattern for a different name: #[rutis::service(name = "dimAccount")]. Add name = "codeMode" to the attribute or rename the type.

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.

Still open: docs/design/plugins/CodeMode.md:170 says the process part provides codeMode, while the appendix at :175 still marks ProgramSlots with a plain #[rutis::service]; add name = "codeMode" or rename the type.

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.

Partly fixed in 5f9a0f1. CodeMode.md:174 now says both names are set with #[rutis::service(name = ...)]. Remaining: the appendix at :179 still marks ProgramSlots with a plain #[rutis::service], so the catalog name is programSlots, not codeMode.

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.

Fixed in 8f440bd. CodeMode.md:181 sets name = "codeMode"; the appendix and the prose agree.

Comment thread docs/design/plugins/Web.md Outdated
- Non-interactive Sessions see the same declarations for the same configuration and can use them; the tool set stays the same across Sessions (#30).
- Never visible: `structuredContent`, the service name, configuration, the API key, private-host exceptions, diagnostics.
- Fetched page text is untrusted third-party content placed in a tool result without instruction framing (A14).
The account owner is read by its face name when the source names no search adapter. A profile without an account owner declares `web_fetch` only; a profile with one declares `web_search` while that owner reports a usable account.

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.

This sentence says a profile without the account owner declares web_fetch only, but the same document keeps the configured adapter path in A.5 (docs/design/plugins/Web.md:252) and Appendix D.1, and the implementation declares web_search for an adapter with its API key (crates/dim-app-server/src/web.rs:1017-1022). An operator with a configured adapter and no Dim account would lose web_search. State that a configured adapter with a key declares the tool regardless of the account, and that the account decides only when the source names no adapter or a dim-oauth configuration.

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.

Still open: docs/design/plugins/Web.md:72 still says a profile without the account owner declares web_fetch only, while A.5 at :264 and E A3 at :350 keep the configured adapter path, and crates/dim-app-server/src/web.rs:1015-1022 declares web_search for an adapter with its key.

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.

Fixed in 5f9a0f1. Web.md:72 keeps the configured adapter path and sends the account read only when the source names no adapter or dim-oauth; crates/dim-app-server/src/web.rs:1017-1022 declares web_search for an adapter with its key without an account.

Comment thread docs/design/plugins/Web.md Outdated
/// The dynamic source: `sets()` answers one set with `web_search` while a
/// search service is usable and no set otherwise.
impl ToolProvider for SearchSource {
fn sets(&self) -> Vec<ToolSet>;

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.

ToolSet is undefined: the trait is fn sets(&self) -> Vec<Arc<ToolSourceSet>> (crates/dim-agent-capabilities/src/tool_registry.rs:125-135), with ToolSourceSet at :132. The signature as written does not implement ToolProvider. Use the real type and return type; also align registerSource at docs/design/plugins/Web.md:168 with the register_source spelling used by the dependency table and #2103.

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.

Still open: docs/design/plugins/Web.md:165 still returns Vec<ToolSet>; the trait is fn sets(&self) -> Vec<Arc<ToolSourceSet>> (crates/dim-agent-capabilities/src/tool_registry.rs:125-135), and registerSource at :180 still differs from register_source at :70.

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.

Fixed in 5f9a0f1. Web.md:165 returns Vec<Arc<ToolSourceSet>> and :180 uses register_source; the trait at crates/dim-agent-capabilities/src/tool_registry.rs:125-128 matches.

Comment thread docs/design/plugins/Web.md Outdated
| `proxyDns` | boolean; user-only | `true` |

Read at each call and used as delivered: Settings validates the document against the schema Web declares and applies its defaults on write and when reading a persisted file, and Web does not validate it again. Web has no tool that writes configuration, so the document is written only through the client methods (S8b). A change is a data update with notification, never a reload. The row's structural on/off state belongs to PluginManager (§6). Built-in adapter ids are an implementation choice (A13). The API key is `searchService.apiKey` (§1).
Read at each call and used as delivered: Settings validates the document against the schema Web declares and applies its defaults on write and when reading a persisted file, and Web does not validate it again. Web has no tool that writes configuration, so the document is written only through the client methods (S8b). A change is a data update with notification, never a reload. The row's structural on/off state belongs to PluginManager (PluginManager). Built-in adapter ids are an implementation choice (A13). The API key is `searchService.apiKey` (A.5).

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.

PluginManager (PluginManager) repeats the name and drops the link the previous text had to the plugin manager's contract. Point at the PluginManager document (or the anchor that owns the built-in row's on/off state) so the reader can find the structural owner.

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.

Still open: docs/design/plugins/Web.md:270 still reads PluginManager (PluginManager) with no link to the plugin manager's contract.

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.

Fixed in 5f9a0f1. Web.md:270 links PluginManager.md instead of repeating the name.

@eric8810

Copy link
Copy Markdown
Collaborator Author

自查完成(A–G),head 2f15ff7e4。

  • A. 绑定附录:错误改为数据面统一的 {code, message};Goal 的 goalLine.read 与 Code Mode 的 run/with_slot 用这个形状,Session 方法的错误保持已发布的客户端码(invalid_params、unknown_branch、branch_ended、service_reloading、closed、operation_interrupted;rename 为 invalid_params、session_not_found、storage_failed、service_reloading、operation_interrupted)。with_slot 改签名:caller: &Ctx + 回调作为直接参数(不再是请求字段里的 SlotWork),行卸载释放额度由 caller 得出。GoalValue 的裁判字段改为与线上一致的 evaluator,session.goal.get 回复恢复 through,session.goal.* 回复恢复 {sequence}。ServiceError 在 Goal/Code Mode 各定义一次并注明同一形状,不再重复命名别处类型。
  • B. 内部一致:每个操作的错误列出现在流程的每种结束(含 closed);cancelled 只在会等待或中断的操作里写;Goal 的写入方只有入口(命令)与分支部件(事实与记录),Rule check 与职责分界的说法一致;四个文档的部件数与 README By scope 一致。
  • C. Supersedes:Goal、SessionTitle、CodeMode、Web 各加 Supersedes 与 Client-visible changes;按条修改的现有文档段落:runtime-owner-operations.md 的 Goal 两行与 Code Mode 的 toolBinding 读取行、resource-owner-operations.md 的 SessionTitle 行、resource-faces.md 的 SessionTitle 一句、session-title-metadata.md 的 SessionTitle 调用与冲突描述;docs/zh 的三份镜像顶部注明目标以英文契约为准。未改其他所有者的段落与 ADR。
  • D. 客户端:Goal 的 Client-visible changes 只写一处——goal:state 记录不再与命令同批,模型看到命令在前、记录从下一次请求起,文本格式不变;其余三个文档写 None。
  • F. 引用:指向其他 PR 新增文件的链接改用 PR URL;README 的 Index 行与 By scope 一致。
  • G. ADR 027:Goal/Code Mode/Web 各加 ADR 027 D1–D3 的 Rule check 行;line_owner 可调分支组任何数据面,不再限于写输入与读值;line_owner 的提供方需求仍记在 所有者扫描:TimelineTree 与分支线 #2024。

node scripts/adr-check.mjs --base origin/main 与 cargo run --locked -p xtask-check 通过。

@eric8810
eric8810 force-pushed the dim/2033-plugins-contract branch from 2f15ff7 to 9783fa5 Compare November 23, 2026 13:52
@eric8810

Copy link
Copy Markdown
Collaborator Author

分支已清理为 docs-only,head 9783fa50f(基于 origin/main 6c46df95,单个提交)。

  • 只保留 7 个 docs 提交涉及的路径,从 2f15ff7e4 的树取出后重新提交;669722f46..9e0f5dc8e 的代码提交与无关的 ACP/CLI 文档不在历史里。
  • git diff --name-only 6c46df95 HEAD 共 12 个文件,全部在 docs/ 下;gh pr view 2099 --json files 同样是这 12 个路径。
  • 内容与自查评论所述一致,未改任何文字;node scripts/adr-check.mjs --base origin/main 与 cargo run --locked -p xtask-check 在清理后的树上通过。

文件清单:

docs/design/plugins/Goal.md
docs/design/plugins/SessionTitle.md
docs/design/plugins/Web.md
docs/design/plugins/CodeMode.md
docs/design/plugins/README.md
docs/design/appserver/session-title-metadata.md
docs/design/contracts/resource-owner-operations.md
docs/design/contracts/runtime-owner-operations.md
docs/design/resource-faces.md
docs/zh/design/plugins/Goal.md
docs/zh/design/plugins/SessionTitle.md
docs/zh/design/plugins/Web.md

@yyhhyyyyyy yyhhyyyyyy left a comment

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.

Scope: this PR rewrites the Goal, SessionTitle, Web and Code Mode owner contracts and the plugin index for the owner-operations series (refs #2033 and #2015), moving callers to line-id operations, the store's change callback and the account face, and deleting about 1400 lines of mechanism detail.

Verdict: REQUEST_CHANGES

Round-1 status

Round 1 had 1 P1, 11 P2 and 7 P3. The P1 is fixed on the wire shape: docs/design/plugins/Goal.md:99 now matches GoalRead ({branchId, through, goal?} with {objective, status, evaluator}), and GoalJudge is gone. The nonexistent GoalStatus remains and is now P2. Of the P2s, nine are open and two are partial: docs/design/contracts/runtime-owner-operations.md now states the Goal write order and the Chinese mirrors carry a stale note; the standing docs, the companions and the rest are unchanged. Of the P3s, four are open and three are partial.

P1

None open. The round-1 wire-shape break is fixed at docs/design/plugins/Goal.md:99.

P2

1. The Goal command reply sequence changes meaning and contradicts the caller example

Problem: docs/design/plugins/Goal.md:96 defines the reply as {sequence}: the accepted input's position. Goal.md:38 says the same call has "no sequence", :153 says the field stays, and :157 says no client field changes. The current reply is the trigger's sequence (crates/dim-goal/src/session.rs:163 and :220), and crates/dim-goal/tests/goal_product_flow.rs:335 asserts that value; docs/design/plugins/Goal-state-read.md:79 still states it, and the Supersedes list at Goal.md:150 does not include it.

Failure scenario: a client or test that reads from the returned sequence now starts at the command input instead of the trigger. The product-flow test goal_continues_to_the_limit_and_stops_on_completion fails, and a client that positions the state read by the reply sees the input, not the state record.

Fix: keep the trigger's sequence in the reply and remove the input-position wording, or state the semantic change, migrate the test and every caller, and add Goal-state-read.md:79 to the Supersedes list.

2. Goal's state record still has two writers

Problem: docs/design/plugins/Goal.md:81 gives the input owner's submit "the command input and the state record input". :113 and :116 append the business fact and then the state record, and :192 says the timeline's append accepts both and Goal appends the fact and then the record. docs/design/contracts/runtime-owner-operations.md:21 now says Goal appends its state record with timeline.append.

Failure scenario: an implementation either bypasses the input owner's ordering and idempotency by appending the record directly, or follows submit and cannot follow append. The two rows cannot both hold.

Fix: make submit carry only the command input and append carry the fact and the record, or make append carry both with the input owner's role stated.

3. goalLine.read is documented as cancellable but takes no cancellation argument

Problem: docs/design/plugins/Goal.md:105 says cancelled is the binding's cancellation argument and :112 says the wait stops, but the appendix at :214 declares pub async fn read(&self) with no argument.

Failure scenario: a Session unload or a dropped caller cannot stop the wait, so the cancellation column and the flow row cannot be implemented.

Fix: add the cancellation argument and show how closed and NoInstance map, or remove the cancellation claim from the row, the flow and the appendix.

4. Goal's command requests have no submission id

Problem: docs/design/plugins/Goal.md:29 makes retry safety the input owner's rule ("the submission id on submit"), and :146 verifies that one submission id is accepted once, but the command requests at :96-98 carry no submission id and no rule derives one. :191 repeats that submit receives one with its submission id.

Failure scenario: a client that retries session.goal.set after a lost reply composes a new input and starts a second execution. The verification only exercises the input owner, not Goal's method.

Fix: carry a submission id in the command requests or derive it from the client's request id, and test the method.

5. session.goal.get on an ended line becomes a client-visible change

Problem: docs/design/plugins/Goal.md:143 verifies that get on an ended line answers service_reloading, and :133 says Goal does not answer for an ended line. Today crates/dim-goal/src/session.rs:116-128 falls back to crate::read::current and answers the last GoalRead from facts (crates/dim-goal/src/read.rs:34-53), and the CLI displays it (crates/dim-cli/src/goal_command.rs:32-60). Goal.md:157 says no client field, code or notification changes.

Failure scenario: /goal on an ended line shows no goal or an error after the delivery, unless every client is migrated to fold the line's facts. The contract names that migration as business at Goal.md:21 and :30 but not in Client-visible changes.

Fix: state the client change and the affected clients, or keep the ended-line read in the owner.

6. GoalStatus is not an existing type

Problem: docs/design/plugins/Goal.md:206 declares status: GoalStatus and :227 calls GoalStatus and GoalView "the existing types in dim_agent_types". The crate has GoalView and GoalViewStatus (crates/dim-agent-types/src/goal.rs:5-29); GoalStatus does not exist. The wire-shape part of the round-1 P1 is fixed.

Failure scenario: the binding appendix does not compile against the crate it cites, and an implementer adds a parallel type where GoalViewStatus is the existing one.

Fix: use GoalViewStatus, or define GoalStatus in the contract and stop calling it existing.

7. The evaluator line's refusals are missing

Problem: docs/design/plugins/Goal.md:114 and :131 open a child line with TimelineTree's create, but Goal's flows and errors at :109-127 name neither branch_not_opener nor branch_limit_reached, the two create refusals in the TimelineTree contract (PR #2092; crates/dim-agent-runtime/src/error.rs:161-170).

Failure scenario: a judge: "evaluator" goal on a child line cannot open the evaluator. The goal stays active and retries at every turn end, or the branch decision fails without a terminal state.

Fix: name the refusal and the paused reason, or refuse judge: "evaluator" on lines that cannot open one.

8. SessionTitle depends on open #2091 with a different binding

Problem: docs/design/plugins/SessionTitle.md:181 says "None open" and calls #2091 SessionStore's current contract, but #2091 is open and main still implements the revision-checked setTitle (crates/dim-app-server/src/storage/metadata.rs:201). The appendix at :216-218 defines a synchronous TitleChange over Option<StoredTitle> returning Result<..., Rejected>. #2091's ChangeFn is an async BoxFuture over TitleState returning Result<Option<Title>, StoreRejected>, and its set_title takes caller: &Ctx, the request and the change, with no cancellation argument. The examples at :40-45 and :68-72 call TitleChange::new, pass cancelled and omit the caller; StoredTitle and Rejected are not defined there. The rule check at :166 says one requirement is open while the Requirements section says none.

Failure scenario: the appendix and both caller examples do not compile against the store the contract depends on. #2091 also edits SessionTitle.md, session-title-metadata.md, resource-owner-operations.md and resource-faces.md, so landing order is hidden.

Fix: mark #2091 as the open owning PR in the dependency table, use TitleState, the async ChangeFn, StoreRejected and the caller parameter, remove the cancellation argument, and reconcile the requirement count.

9. Web declares web_search without the account even with a configured adapter

Problem: docs/design/plugins/Web.md:72 says "A profile without an account owner declares web_fetch only". A.5 at :264 and Appendix E A3 at :350 keep the configured adapter path, and crates/dim-app-server/src/web.rs:1015-1022 returns true for a brave adapter with its API key without a signed-in account.

Failure scenario: an operator with a configured search adapter and no Dim account loses web_search, contradicting the source's own searchService field and acceptance test 1.

Fix: state that a configured adapter with a key declares web_search regardless of the account, and that the account decides only when the source names no adapter or a dim-oauth configuration.

10. Code Mode's v4 gate reads a protocol version SessionScope does not provide

Problem: docs/design/plugins/CodeMode.md:29 and :72 gate the tool on the client's protocol version from SessionScope's config. SessionScope's config returns SessionConfig (PR #2093), and SessionConfig has no protocol version (crates/dim-agent-runtime/src/config.rs:39-88). The current gate is SessionConfig.excluded_tools, set by exclude_codemode_below (config.rs:190-192, called at crates/dim-app-server/src/agents.rs:1588 and :2004).

Failure scenario: the entry cannot compose the gate; a v3 Session may be offered codemode, or a v4 Session may be refused.

Fix: keep the mount exclusion as the gate and state it, or add a protocol-version read to SessionScope's contract and link it.

11. Code Mode's slot and executor examples do not compile

Problem: docs/design/plugins/CodeMode.md:54-59 passes work to with_slot that returns Ok(program_result(outcome, effects)), but with_slot at :179-184 takes caller: &Ctx and a work callback returning Result<(), ServiceError>; the example omits the caller and returns a ToolResult, so the outer result is dropped. executor.open at :55 omits the caller: &Ctx that ToolExecutor's binding takes, and executor.close at :57 passes cancelled while ToolExecutor's close takes the caller and CloseRequest with no cancellation argument (PR #2100).

Failure scenario: the appendix does not compile and the run cannot answer the outer call.

Fix: take the caller in the examples, make with_slot generic over the work's reply or capture the result outside, and call close with the request only.

12. The rewrite deletes anchors that standing documents still link

Problem: 34 links into the rewritten documents now miss their headings, including crates/dim-cli/README.md:744, crates/dim-oauth/docs/design.md:20, crates/dim-oauth/docs/runtime-contract.md:12, docs/design/timeline-branches.md:249, :253, :312, :323, :507, :556, docs/design/plugins/Pursuit.md:16, :36, :46, :50, :58, :81, :93, docs/design/model-prompts.md:229, docs/design/plugins/Scheduler.md:514, docs/design/plugins/Skills.md:526, docs/design/plugins/Hooks.md:186, docs/design/appserver/idle-unload.md:110, docs/design/appserver/session-notices.md:5, docs/design/overview.md:563, docs/design/acp-gateway-implementation.md:268, docs/design/timeline-read-followups.md:15 and docs/zh/design/plugins/SessionTitle.md:183. No repository check validates Markdown anchors.

Failure scenario: a reader following any of these links lands at the top of the document with no matching section; the S5b title metadata and the CLI contract lose the referenced rule.

Fix: update every referrer to the new heading, or keep compatibility anchors for the old names, and list anything another PR owns.

13. Standing and companion documents still state the removed behavior

Problem: docs/design/overview.md:71, :166 and :229 still fold the goal from goal:objective and goal:status blocks and still have the methods read state; docs/design/plugin-contract.md:110 still lists sessionMetadata; docs/design/appserver/session-title-metadata.md:22 and :205 still define setTitle {sessionId, expectedRevision, title} with a conflict retry, while SessionTitle.md:98 says the caller keeps no retry; docs/design/cli-commands.md:605 still says every call replies with its input's sequence. docs/design/plugins/Goal-state-read.md:77-79 still requires one atomic append_batch and the trigger's sequence; docs/design/plugins/Pursuit.md:17, :56, :57, :68 and :178 still use treeCommands.create, branch/create-failed and treeCommands.input/end. The Chinese mirrors now carry a stale note, but nothing marks these English pages stale.

Failure scenario: two authoritative rules for one owner; an implementer keeps the atomic batch, the revision retry or the old tree API.

Fix: update the referrers in this PR, or mark each old section as superseded and name the PR that will update it.

P3

14. Goal's line request and error names still do not match TimelineTree

Problem: docs/design/plugins/Goal.md:46 calls tree.line(LineRequest { line }), but the TimelineTree contract takes {line} and its example calls tree.line(id) (PR #2092); LineRequest is not defined there. Goal.md:103 calls unknown_branch TimelineTree's line refusal, but the owner's error is unknown; the get row at :99 lists unknown_branch, while its example at :57-63 only resolves line_owner and maps NoInstance to service_reloading, so the row cannot produce that code.

Failure scenario: the example does not compile, and a client that names an unknown line receives service_reloading (shown as no goal) instead of unknown_branch.

Fix: use tree.line(line) and the owner's unknown kind, or state the RPC mapping; add the line check to the get example or drop unknown_branch from its row.

15. Goal's requirement count is still wrong

Problem: docs/design/plugins/Goal.md:173 says "Two requirements are listed below", but :190-192 lists three: TimelineTree, the input owner and the timeline owner.

Failure scenario: the append requirement is not tracked to its owner.

Fix: say three or merge the timeline row.

16. SessionTitle's rule check still lists the Session broadcast

Problem: docs/design/plugins/SessionTitle.md:165 lists the Session broadcast, while :108 and :123 observe the first adopted input at a fixed cutoff and subscribe to nothing.

Failure scenario: the rule check contradicts the flows and keeps a removed dependency visible.

Fix: remove the broadcast from the row.

17. SessionTitle's example names undefined values

Problem: docs/design/plugins/SessionTitle.md:57 reads line: ROOT and fields: INPUT_FIELDS; neither is defined in the contract. The conversation line is tree.directory()?.default, as docs/design/plugins/Goal.md:44 uses.

Failure scenario: the example does not compile, or it titles from a line that is not the conversation line after the default moves.

Fix: resolve the default first and name the field selection.

18. Code Mode and Web binding details are incomplete

Problem: docs/design/plugins/CodeMode.md:170 says the process part provides codeMode, but the appendix at :175 marks ProgramSlots with a plain #[rutis::service], whose catalog name is programSlots; :70 gives adopted {requestId} the reply {adopted}, while ToolBinding answers {adoption, tools} (PR #2100). docs/design/plugins/Web.md:165 returns Vec<ToolSet>; the trait is fn sets(&self) -> Vec<Arc<ToolSourceSet>> (crates/dim-agent-capabilities/src/tool_registry.rs:125-135). Web.md:180 says registerSource while :70 says register_source, and :270 reads PluginManager (PluginManager) with no link.

Failure scenario: the catalog shows the wrong process face, the adopted read does not match its owner, and the appendices do not compile.

Fix: add name = "codeMode", use {adoption, tools}, Vec<Arc<ToolSourceSet>> and one registration spelling, and link PluginManager.

19. Open dependencies are still not listed as such

Problem: docs/design/plugins/SessionTitle.md:181 says "None open" while #2091 is open; docs/design/plugins/Web.md:69 and docs/design/plugins/Goal.md:80 link issue #2019 and #2024 rather than the owning PRs #2096 and #2092; #2029 (ADR 027) is not linked. The Goal and Code Mode requirement sections still cite issues with no landing order.

Failure scenario: a reader on main cannot resolve the operations the documents call, and the "no requirement remains open" statements hide the order.

Fix: list the owning PRs as open dependencies in each dependency table and land them in order.

20. Removed configuration and verification text is not recoverable

Problem: docs/design/plugins/SessionTitle.md:3 and :146 put the generation policy, the text rules and the acceptance list in a previous version of the document that is no longer in the tree; maxLength's default and range are still absent (:86). Goal's maxContinuations range (Goal.md:85) and Code Mode's eight bound values (CodeMode.md:11) are also absent.

Failure scenario: implementers cannot keep the public configuration, and the acceptance list cannot be verified from the contract.

Fix: state the retained values in the contract or link the schema owner, and say which texts and acceptance items change.

Comment thread docs/design/plugins/Goal.md Outdated
| C7:本轮非自动续行驱动,或调用过工具,或连续无进展轮数仍小于 3 | 暂停,reason=no_progress。 |
| Operation | Intent | Request | Reply | Cancellation | Errors |
| --- | --- | --- | --- | --- | --- |
| `session.goal.set` | Start a new execution of a goal on a line | `{sessionId, branchId?, objective, judge?}` | `{sequence}`: the accepted input's position | Before the input is submitted | `invalid_params`, `branch_ended`, `unknown_branch`, `service_reloading`, `closed`, `operation_interrupted` |

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.

{sequence} here is defined as the accepted input's position, but the current reply is the trigger's sequence (crates/dim-goal/src/session.rs:163 and :220), crates/dim-goal/tests/goal_product_flow.rs:335 asserts that value, and docs/design/plugins/Goal-state-read.md:79 still states it. Goal.md:38 also says the call has "no sequence" and :157 says no client field changes. Keep the trigger's sequence, or state the semantic change and migrate the test and every caller.

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.

Fixed in 5f9a0f1. Goal.md:38, :96 and :158 define {sequence} as the committed command input's sequence. The current code returns the trigger's sequence (crates/dim-goal/src/branch.rs:597-605), and crates/dim-goal/tests/goal_product_flow.rs:335 calls the value the set trigger, so "as today" holds.

### A.6 Timeline mechanics
- `set` writes one input to the named line; the branch owner states `active` with the objective; `get` answers the same value while the line is live.
- `pause`, `resume` and `clear` change the status in the stated order; a paused goal does not continue; `clear` retires the model-visible keys.
- `get` on an ended line answers `service_reloading`, and the line's facts still carry the last state for a client that folds them.

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.

This is a client-visible change: today session.goal.get on an ended line answers the last GoalRead from facts (crates/dim-goal/src/session.rs:116-128, crates/dim-goal/src/read.rs:34-53) and the CLI displays it (crates/dim-cli/src/goal_command.rs:32-60). After this row it answers service_reloading, so /goal on an ended line shows no goal unless the client folds the line's facts, while Goal.md:157 says no client-visible changes. Name the client migration and the affected clients, or keep the read.

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.

Fixed in 5f9a0f1. Goal.md:159 states the ended-line change, names the CLI and session-host readers, and gives the migration; :99 and :144 answer service_reloading for an ended line.

Comment thread docs/design/plugins/Goal.md Outdated
| §4 rule 5 (batches) | The fact and the record are separate appends in that order, so recovery never reads state that was not committed. |
| §4 rule 6 (context) | The model reads goals only through adopted inputs; `goalLine.read` serves callers, not context preparation. |
| §4 rule 7 (public events and services) | The branch part uses the Dispatcher, its timeline, TimelineTree and the input owner; the entry uses the registration points and the mechanism. |
| §4 rule 8 (requirements) | Two requirements are listed below; no core change. |

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.

Three requirements are listed at :190-192 (TimelineTree, the input owner, the timeline owner), not two. Say three or merge the timeline row.

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.

Fixed in 5f9a0f1. Goal.md:176 says three requirements; :193-195 are the three requirements and :196 is the routing note for #2127.

Comment thread docs/design/plugins/CodeMode.md Outdated
| --- | --- | --- |
| Session access ([#2025](https://github.com/arcships/dim/issues/2025)) | the line's owner by line id | The entry reaches `CodeModeLine`; the run reaches the line's ToolExecutor |
| ToolExecutor ([#2028](https://github.com/arcships/dim/issues/2028)) | `open {parentCallId, context}` → `{gateId}`; `invoke {gateId, call}` → `{result}`; `close {gateId}` → `{effects}` | Child calls, admission, child facts; the run closes the gate to word its result, and the owner closes it again at parent settlement with the effects merged once |
| ToolBinding ([#2028](https://github.com/arcships/dim/issues/2028)) | `adopted {requestId}` → `{adopted}` | The request's pinned declarations for `tools.list`, `tools.describe`, `tools.call` |

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 owner's reply is {adoption, tools} (docs/design/plugins/ToolBinding.md in PR #2100), not {adopted}. The run needs both the adoption id and the pinned declarations; fix the row to the owner's shape.

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.

Partly fixed in 5f9a0f1. CodeMode.md:72 now uses {adoption, tools}. Remaining: the same reply is still {adopted} at runtime-owner-operations.md:76, while PR #2100's ToolBinding.md:137-138 defines the adoption id plus the pinned declarations.

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.

Fixed in 8f440bd. runtime-owner-operations.md:76 now says adopted({requestId}) -> {adoption, tools}; #2100 ToolBinding.md:137-138 matches.

Comment thread docs/design/plugins/SessionTitle.md Outdated
## 5. Context mapping
```rust
let text = title_text(params.title.as_deref(), &document)?; // owner rules: trim, no control characters, length
let change = TitleChange::new(move |current: Option<StoredTitle>| {

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.

TitleChange::new has no constructor: TitleChange is defined at :216-218 as a bare Arc<dyn Fn...>. The callback is synchronous over Option<StoredTitle> returning Rejected, while #2091's ChangeFn is an async BoxFuture over TitleState returning StoreRejected, and its set_title takes caller: &Ctx, the request and the change with no cancellation argument. The examples at :45 and :72 therefore pass an extra cancelled and no caller. Use the store's ChangeFn, TitleState and StoreRejected and the caller parameter, or state that this is a different adapter.

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.

Fixed in 5f9a0f1. SessionTitle.md:41-46 and :81-89 construct a ChangeFn over TitleState and return StoreRejected; no TitleChange::new remains, and the appendix at :289-292 defers the types to #2091.

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审与自查标准修改,head 5f9a0f1e8(基于 origin/main 6e86d48c8,docs-only,16 个文件)。P1 无遗留。

评审逐条

#1 sequence:回复保持 {sequence} = 已提交命令输入的 sequence(与今天 crates/dim-goal/src/session.rs:163 的值相同);删掉「no sequence」与「input position」的措辞;Goal-state-read.md 加 Supersedes 说明。
#2 状态记录两个写入方:submit 只写命令输入;append 写业务事实与状态记录(输入草稿)。依赖表、流程与要求三处一致。
#3 goalLine.read 无取消参数:签名改为 read(&self, cancelled: CancelledFn);行、流程与附录一致。
#4 命令缺 submission id:五个写方法请求加可选 submissionId;缺省由 Goal 生成;列入客户端可见变更。
#5 结束行的 get:写成客户端可见变更——结束行答 service_reloading,受影响 dim-cli 的 /goal 与 TUI 的 goal 面板,迁移是读该行的 goal/state 事实或显示无目标。
#6 GoalStatus 不存在:改为 GoalViewStatus。
#7 评估行拒绝:create 的 branch_not_opener/branch_limit_reached 写成一条流程,Goal 暂停 evaluation_failed,验收补一条。
#8 SessionTitle 依赖开放 #2091:依赖表标 target, pending #2091;示例与附录改用 set_title(caller, SetTitle { id }, ChangeFn)、TitleState、StoreRejected,不带取消参数;要求一节改为「#2091 开放,落地顺序在它之后」。
#9 Web 配置适配器:明确配置了适配器与 key 时无需账号即声明 web_search;账号只在来源没有适配器或为 dim-oauth 时参与。
#10 Code Mode 的 v4 门:改为 Session 创建记录里的挂载排除(exclude_codemode_below),不再读协议版本;依赖表删掉那条假设。
#11 Code Mode 示例编译:示例传 caller、with_slot<T> 泛型返回外层结果、close(caller, CloseRequest) 不带取消。
#12 失效锚点:Goal 与 SessionTitle 各加「Compatibility anchors」块,保留被代码注释与文档引用的旧标题;其余引用方(Pursuit、timeline-branches、model-prompts、cli-commands、overview、Attachments、Hooks、session-notices、idle-unload、zh 镜像)中属于本所有者段落的已改(见下),不属于本 PR 可达范围的列在交付评论。
#13 保留文档仍写旧行为:Goal-state-read.md 顶部加指向契约的说明;session-title-metadata.md 的 setTitle、conflict、D9、冲突表改成 change 回调;overview.md 三处 Goal 段落加 superseded 指向;plugin-contract.md 的 sessionMetadata 改为 store 的标题操作;Pursuit.md 的 treeCommands.* 改为 timelineTree.*。
#14 Goal 的行与错误名:tree.line(line);TimelineTree 的 unknown 映射为线上的 unknown_branch;get 行去掉 unknown_branch。
#15 要求计数:改为三。
#16 SessionTitle 的广播:从 Rule check 删除。
#17 SessionTitle 示例:先 tree.directory()?.default 取对话行,字段选择写成 ["id", "data.user", "data.blocks"]。
#18 绑定细节:Code Mode 用 #[rutis::service(name = "codeMode")],adopted 回复 {adoption, tools};Web 用 Vec<Arc<ToolSourceSet>>、统一 register_source、链接 PluginManager。
#19 开放依赖:四个依赖表把目标操作标为 target, pending #<PR>(#2091/#2092/#2093/#2094/#2096/#2100/#2103);机制需求链接 #2127。
#20 保留的配置与验收:Goal 的 1..=4000/1..=2000/maxContinuations 1..=1000,SessionTitle 的 maxLength 10..=200、default 80、2000 字符摘录、30 s、三次,Code Mode 的八个上限值都写进契约;SessionTitle 的验收指向前一版 Appendix D。

自查(第 1–3、6–7 条)

  1. 每条关于现状的说法都按路径核对(Goal 的 session.rs:116-135、read.rs:35-63、session.rs:163/220,SessionStore docs(storage): define the session storage owners' target contracts #2091 的类型,ToolExecutor design(tools): target contracts for the branch tool chain #2100 的操作,TimelineTree docs(design): define the line directory owner contract #2092 的 directory/line)。
  2. 冲突在本 PR 解决:resource-owner-operations.md 的合并冲突按 main 内容 + 本所有者行解决。
  3. Supersedes 逐条对应到本 PR 改过的文件;Goal-state-read.md 与 session-title-metadata.md 已改。
  4. 职责分界、示例、操作表、错误表、流程、例外、Rule check 与附录一致;每个流程的结局都出现在错误表;错误写明能否重试与下一步。
  5. 改名的入链按 grep 全仓核对,旧锚点用兼容块保留;未合并引用写 target, pending #PR。

绑定附录编译

四份附录放进临时 crate(/tmp/bind-check,rutis 0.23 + serde + thiserror),含 GoalLine::read(&self, CancelledFn)、Store::set_title(caller, SetTitle, ChangeFn)、ProgramSlots::with_slot<T>(caller, WorkFn<T>, CancelledFn)、ToolProvider::sets() -> Vec<Arc<ToolSourceSet>> 及示例调用:cargo check --offline 通过。临时 crate 未提交。

客户端可见变更

  • session.goal.* 写请求新增可选 submissionId;不发送者行为不变。
  • 结束行的 session.goal.get 答 service_reloading(不再返回最后目标);受影响 dim-cli 的 /goal 与 TUI goal 面板,迁移为读该行 goal/state 或显示无目标。
  • goal:state 记录不再与命令同批(模型先看到命令,记录从下一次请求起);文本格式不变。

评审人请重看。

@yyhhyyyyyy yyhhyyyyyy left a comment

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.

Scope

This PR rewrites the four product owner contracts (Goal, SessionTitle, Web and Code Mode) and the plugin index for the owner-operations series (refs #2033 and #2015). It moves callers to line-id operations, SessionStore's change callback and the account face, and deletes about 1400 lines of mechanism detail. I reviewed the full main...head at 5f9a0f1, not only the round-4 delta.

Verdict

REQUEST_CHANGES

Round-2 status

Fixed and withdrawn:

  • P2 1 sequence, 2 state writer, 3 read cancellation, 4 submission id, 5 ended-line get, 6 GoalStatus, 7 evaluator refusals, 8 SessionTitle #2091, 9 Web account, 10 CodeMode gate.
  • P3 14 LineRequest, 15 requirement count, 16 broadcast, 17 ROOT/INPUT_FIELDS.
  • The round-1 P1 wire shape remains fixed.

Partly fixed:

  • P2 11 CodeMode slot example: caller and close are fixed, and the example returns the result; the operations table still drops it and the appendix uses an undefined callback type (P2 6 below).
  • P2 12 anchors: SessionTitle is mostly fixed; Goal is not (P2 1 below).
  • P2 13 standing documents: the metadata doc is still wrong and Pursuit E1 still names treeCommands (P2 3 and P3 below).
  • P3 18 binding details: adopted, ToolSet, register_source and the PluginManager link are fixed; the codeMode name is not (P2 7 below).
  • P3 19 open dependencies: narrowed to the Goal and Web rows (P3 below).
  • P3 20 previous version: values are now stated; the acceptance list still points at a version not in the tree (P3 below).

P1

None.

P2

1. The Goal compatibility anchors still do not match the links they are meant to preserve

Problem: The new Goal compatibility section uses the Chinese mirror's headings (### 2. 数据与状态, ### A.2 Session 方法), but every broken referrer uses the English headings of the base document (#2-data-and-state, #a2-session-methods). 25 link occurrences (21 distinct source and anchor pairs) into Goal.md still break, and all of them were valid at 6e86d48. SessionTitle.md fixed most of its file with English anchors, but ### 0.1 Fields read for one title attempt is missing, leaving 3 more.

Failure scenario: A reader following docs/design/timeline-branches.md:249 or docs/design/cli-commands.md:576 lands at the top of Goal.md; the context-mapping, branch-clearing and A.2/A.3/A.5 rules the links name are unreachable. A reader following docs/design/plugins/Skills.md:526 or Hooks.md:186 loses SessionTitle's field-selection rule.

Evidence: docs/design/plugins/Goal.md:199-253; broken links at docs/design/timeline-branches.md:249, :253, :312, :507, :556, docs/design/model-prompts.md:229, docs/design/cli-commands.md:576, :622, docs/design/plugins/Pursuit.md:16, :36, :46, :50, :81, crates/dim-cli/README.md:744, docs/design/plugins/Scheduler.md:514, docs/design/acp-gateway-implementation.md:268. docs/design/plugins/SessionTitle.md:204-258; docs/design/plugins/Hooks.md:186, docs/design/plugins/Skills.md:526, docs/design/timeline-read-followups.md:15.

Fix: Use the base English heading text for the Goal anchors (### 2. Data and state, ### 3.4 A new branch clears the inherited goal, ### 5. Context mapping, ### A.2 Session methods, and so on), or add explicit <a id="2-data-and-state"></a> anchors. Add ### 0.1 Fields read for one title attempt to SessionTitle.

2. Goal's error codes do not match the input owner or the codes clients receive today

Problem: Goal.md:103 and :158 say every listed code is one the client already receives. Two are not. AgentError::UnknownBranch maps to session_invalid_input, and crates/dim-goal/tests/goal_product_flow.rs:540 asserts that for a missing branchId; AgentError::Closed maps to session_closed (crates/dim-agent-capabilities/src/methods.rs:138-139). Goal.md:103 also says branch_ended is the input owner's refusal, but PR #2102's submit answers line_ended and closed (InputQueue.md:81, :92), not branch_ended. The retained row runtime-owner-operations.md:25 repeats the same confusion: the tree's line answers unknown, not unknown_branch (PR #2092, TimelineTree.md:131, :153).

Failure scenario: An implementer who makes the table true changes the wire code for a missing line from session_invalid_input to unknown_branch; the existing test at crates/dim-goal/tests/goal_product_flow.rs:540 fails, and the wire code /goal receives for a missing line changes. An implementer who keeps today's mapping still answers session_invalid_input, which the table omits and clients do not handle. Mapping submit's line_ended to branch_ended is stated nowhere, so the entry and the owner disagree. session.goal.get on an unknown line also becomes service_reloading through NoInstance, a client-visible change that Goal.md:159 does not list.

Evidence: docs/design/plugins/Goal.md:96-99, :103, :125, :158-159; crates/dim-agent-capabilities/src/methods.rs:138-139, :186-191; crates/dim-goal/tests/goal_product_flow.rs:540; PR #2102 docs/design/plugins/InputQueue.md:81, :92; PR #2092 docs/design/plugins/TimelineTree.md:131, :153; docs/design/contracts/runtime-owner-operations.md:25.

Fix: Keep today's RPC codes and state the mapping (line_ended to branch_ended, unknown to session_invalid_input, data-face closed to session_closed), or list the new codes as client-visible changes and migrate the test, the CLI and the session-host readers. Make the retained line row say unknown.

3. session-title-metadata.md now states an unimplementable setTitle request and contradicts its own table

Problem: The round-4 replacement puts the phrase "the change callback's current title and revision" inside a request shape, and repeats it inside "commits revision ... + 1". The result is not an implementable request. It contradicts the document's own table at :91 ({id} plus the change), :15 ("revision-checked write") and :95 ("title is required in setTitle"). PR #2091's head already has the coherent text: store.title and store.setTitle(id, change), with no expectedRevision (session-title-metadata.md:3, :22-24, :93).

Failure scenario: An S5b implementer cannot tell whether the request carries a session id, a title, the current revision or a callback; the summary and the method table describe different protocols. The PR and #2091 edit the same paragraphs, so landing either first leaves a semantic conflict.

Evidence: docs/design/appserver/session-title-metadata.md:15, :21-22, :28-29, :91, :95; docs/design/plugins/SessionTitle.md:101; PR #2091 head docs/design/appserver/session-title-metadata.md:3, :22-24, :30, :93; PR #2091 head docs/design/plugins/SessionStore.md:121-122.

Fix: Use #2091's wording: setTitle {id} plus a change callback that receives the current {revision, title} and returns the next title or its own refusal; the store commits the returned title as the next revision and fails rejected, not_found or storage. Update :15, :28-29 and :95 with it, or drop this file from the PR and let #2091 own it.

4. runtime-owner-operations.md still gives toolBinding.adopted the wrong reply

Problem: The retained row says adopted({requestId}) -> {adopted}. Code Mode's table at :72 says {adoption, tools}, and PR #2100's ToolBinding.md:137-138 defines the reply as the adoption id plus the pinned declarations. #2100's copy of the same runtime row already says {adoption, tools}.

Failure scenario: Code Mode's tools.list, tools.describe and tools.call need both the adoption id and the declarations. An implementer following {adopted} returns one opaque value and cannot pass the adoption to invoke or list the pinned tools.

Evidence: docs/design/contracts/runtime-owner-operations.md:76; docs/design/plugins/CodeMode.md:72; PR #2100 docs/design/plugins/ToolBinding.md:137-138; PR #2100 docs/design/contracts/runtime-owner-operations.md:76.

Fix: Change the row to adopted({requestId}) -> {adoption, tools}.

5. Code Mode's dependency table still names SessionScope (#2093) for the line-id mechanism

Problem: CodeMode.md:70 names Session access (#2025, target, pending #2093) as the owner that provides "the line's owner by line id". The same document's requirements at :166-168 say the mechanism is #2127 and "SessionScope's contract has no such operation". PR #2093's SessionScope.md:26 and :39 say SessionScope publishes no operation for that path. Goal.md:88 says the same.

Failure scenario: An implementer adds a SessionScope dependency for line_owner, but #2093 does not provide it, so the entry cannot be assembled. An implementer who follows #2127 has a dependency table that contradicts the requirements.

Evidence: docs/design/plugins/CodeMode.md:70, :166-168; PR #2093 docs/design/plugins/SessionScope.md:26, :39; docs/design/plugins/Goal.md:88; issue #2127.

Fix: Replace the row's owner with "the id routing mechanism (#2127)" and keep the operation as line_owner::<T>(line), or mark the row as a mechanism requirement, not a SessionScope dependency.

6. Code Mode's with_slot still drops the work's result in the operations table and uses an undefined callback type

Problem: CodeMode.md:82 says codeMode.with_slot replies {}, while the round-4 appendix is generic (with_slot<T> -> Result<T, ServiceError>, :183-188) and the example relies on the work's result (let slot: Result<ToolResult, ServiceError> = ...await?, :54-61). The appendix also uses ChangeFn<T>, which is undefined in this contract; ChangeFn is SessionStore's type in SessionTitle.md:289-292, an async callback over TitleState.

Failure scenario: An implementer following the table discards the work's ToolResult, which is the round-2 failure: the run cannot answer the outer tool call. An implementer following the appendix cannot compile ChangeFn<T> and may reuse the store's callback type with the wrong argument.

Evidence: docs/design/plugins/CodeMode.md:82, :54-61, :183-188, :186; docs/design/plugins/SessionTitle.md:289-292.

Fix: State the reply as the work's reply T (the run's Result<ToolResult, ServiceError>), and name or define the callback type, for example WorkFn<T> = Arc<dyn Fn(CancelledFn) -> BoxFuture<'static, Result<T, ServiceError>> + Send + Sync>.

7. Code Mode's binding appendix contradicts its own service-name sentence

Problem: CodeMode.md:174 says both names are set with #[rutis::service(name = ...)] on the owner type, but the appendix at :179 still marks ProgramSlots with a plain #[rutis::service]. One Rust type has one name, so the catalog name is programSlots, while README.md:37, the dependency table and the operations table use codeMode.

Failure scenario: The catalog exposes programSlots; the Session entry and codeMode.with_slot cannot resolve the process face. An implementer who follows the code block ships the wrong name.

Evidence: docs/design/plugins/CodeMode.md:174, :179, :80; docs/design/plugins/README.md:37.

Fix: Add name = "codeMode" to the attribute or rename the type.

P3

  • SessionTitle still points at a version not in the tree. SessionTitle.md:3, :13, :165 and :254 put the generation policy and acceptance list in "the previous version"; maxLength 10..=200 and default 80 are now stated at :12, :105 and :242. State the acceptance items or name the follow-up that carries them.
  • Open dependencies are labeled unevenly. Goal's table at :80, :84, :85 and :86 cites issues #2024, #2025, #2017 and #2026 without the pending PRs #2092, #2093, #2094 and #2103; Web's account row at :69 cites #2019 without pending #2096; SessionTitle's registry row at :106 cites #2026 without pending #2103.
  • Pursuit.md:177 still uses treeCommands.info(own id) after the same file moved P5, section 4 and E2 to timelineTree. The target face is line.
  • Goal.md:57-63 is the session.goal.get example, but it returns the owner's GoalValue fields (objective, status, evaluator, through) while the get reply at :99 is GoalRead {branchId, through, goal?}. Show the mapping.
  • plugin-contract.md:110 no longer names a service in the Name column, while session-title-metadata.md:28-29 and :86 still document sessionMetadata. Either keep the name or mark it superseded consistently.
  • CodeMode.md:102-103 still lists interrupted and gate_closed beside the run's own errors, after :84 scoped them to ToolExecutor. Label the table as covering the child operations too, or drop them from the run's error table.
  • CodeMode.md:166 says "Both requirements below" but the section has three bullets at :168-170; the first two are the line-id requirements and the third is the timeline owner.
  • ADR 027 exists only in open #2029, and the four contracts reference it without a link or a pending label. Use a link to #2029 and label it pending, as the other forward references do.
  • SessionTitle.md:263 imports MetadataError and SessionMetadata (current types) but the appendix uses ChangeFn, TitleState, StoreRejected and SetTitle. Import the target types or drop the old ones.
  • runtime-owner-operations.md:26 still says InputQueue uses timelineTree.input; PR #2102's target is inputQueue.submit. Update the row with #2102, or leave a note that it is #2102's.

Cross-PR and main

  • The PR is rebased on 6e86d48 and reports MERGEABLE. node scripts/adr-check.mjs --base 6e86d48c passes with an isolated HOME, TMPDIR and XDG. CI at the head: ci-ok and changes pass; the other jobs are skipped.
  • docs/design/appserver/session-title-metadata.md is edited by both this PR and #2091. #2091's head already has the coherent target text; this PR's partial edit produces the sentence in P2 3. Landing order matters: #2099 should align with #2091 or drop its edits to that file.
  • docs/design/contracts/runtime-owner-operations.md is edited by #2092, #2093, #2100, #2102, #2103 and this PR. #2093, #2100, #2102 and #2103 still carry the old Goal rows (inputs batch, directory({id})), while #2100's copy already has adopted -> {adoption, tools} and this PR's does not. A later merge can revert this PR's rows or conflict with them.
  • ADR 027 numbering matches the series: D1 reach by id, D2 runtime routing, D3 data faces, D4 call by id is not a dependency, D5 keeping the target loaded belongs to Agents. The Goal and CodeMode rows use D1, D3 and D4 correctly; Web's D2 row is about not resolving a service by id, which is a consequence of D2 and has no numbering error.
  • No conflict with main is visible. The remaining conflicts are the sibling PRs above and the metadata doc.

Unverified

  • I did not run the Goal tests. The session_invalid_input behavior is read from crates/dim-agent-capabilities/src/methods.rs:138-139 and the assertion at crates/dim-goal/tests/goal_product_flow.rs:540, not from a test run.
  • The sibling PR heads were fetched on 2026-11-24; they may move. The line numbers for #2091, #2092, #2093, #2100 and #2102 refer to those heads.
  • The redacted field placeholders in the documents prevent checking the exact Rust field types of GoalValue, RenameRequest and RenameReply.
  • Target-only names such as GoalLine, codeModeLine, the quota face and line_owner have no current code. Their shapes are checked only against the sibling contracts where those names exist.
  • The anchor count uses the GitHub slug algorithm. The Chinese/English mismatch is unambiguous, but GitHub's renderer may vary the exact count.

Previous opinions to withdraw

  • Withdraw the round-2 P2 findings 1 to 10 and P3 findings 14 to 17. The head fixes the sequence wording, the state writer, the read cancellation, the submission id, the ended-line read, GoalStatus, the evaluator refusals, SessionTitle's #2091 binding, Web's account path and CodeMode's gate. The round-1 P1 wire shape is also fixed.
  • Withdraw the claim that Goal's {sequence} semantics are still open. Goal.md:38, :96 and :158 now name the committed command input's sequence, and the current code returns the trigger's sequence (crates/dim-goal/src/branch.rs:597-605), which the test at crates/dim-goal/tests/goal_product_flow.rs:335 calls the set trigger.
  • Keep the round-2 P2 anchor and standing-document findings, narrowed as above.
  • Keep the round-2 P2 slot-example and P3 binding findings, narrowed as above.

Comment thread docs/design/plugins/Goal.md Outdated
以下标题只为保留其他文档与代码注释里的旧锚点;每一节的正文都已并入上面的契约。

返回 {branchId, through, goal};goal 为 null 或 {objective, status, evaluator}。status 为 {kind:active|completed|blocked|none} 或 {kind:paused,reason},保持 GoalRead 的既有外部类型。
### 2. 数据与状态

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.

Problem: these compatibility anchors use the Chinese mirror's headings (### 2. 数据与状态), but every English referrer uses the base document's English anchors. 25 link occurrences (21 distinct source and anchor pairs) into Goal.md still break, and all were valid at 6e86d48. Failure scenario: a reader following docs/design/timeline-branches.md:249 or docs/design/cli-commands.md:576 lands at the top of this document with no matching section. Evidence: docs/design/timeline-branches.md:249, :253, :312, :507, :556, docs/design/plugins/Pursuit.md:16, :36, :46, :50, :81, docs/design/model-prompts.md:229, crates/dim-cli/README.md:744, docs/design/plugins/Scheduler.md:514, docs/design/acp-gateway-implementation.md:268. Fix: use the base English headings (### 2. Data and state, ### 3.4 A new branch clears the inherited goal, ### A.2 Session methods, and so on), or add explicit <a id="2-data-and-state"></a> anchors.

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.

Fixed in 8f440bd. The compatibility section uses the base English headings (2. Data and state, 3.4 A new branch clears the inherited goal, 5. Context mapping, A.2 Session methods, A.5.1 Protocol and policy, and the rest), SessionTitle.md:208 adds the 0.1 anchor, and a fragment check over the modified docs finds no broken links. The 25 Goal and 3 SessionTitle referrers resolve.

Comment thread docs/design/plugins/Goal.md Outdated
| `goalLine.read` | The line's published goal value | `{}` | `{objective?, status, evaluator, through}` | The wait stops; the value is unaffected | `closed` |

加载行为唯一见 [Goal 状态设计](Goal-state-read.md#4-get-与冷恢复):最后 active 映射为内存 paused,不写回、不读取旧轮次和次数、不补答旧决定、不恢复旧评估。set/resume 才开始新执行。
`invalid_params` covers what Goal itself checks: an objective outside 1..=4000 characters, a summary outside 1..=2000, an unknown judge, an empty `branchId`. `unknown_branch` is TimelineTree's `line` refusal (`unknown` in the tree's vocabulary, mapped to the published code); `branch_ended` is the input owner's refusal; `service_reloading` is the mechanism's answer that the line has no live goal owner, which the client shows as no goal and reads from history instead. Every code above is one the client already receives today.

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.

Problem: two of these codes are not received today, and branch_ended is attributed to the wrong owner. AgentError::UnknownBranch maps to session_invalid_input (crates/dim-agent-capabilities/src/methods.rs:138), and crates/dim-goal/tests/goal_product_flow.rs:540 asserts that for a missing branchId; AgentError::Closed maps to session_closed (methods.rs:139). The input owner answers line_ended, not branch_ended (PR #2102, InputQueue.md:81, :92). Failure scenario: making the table true changes the wire code for a missing line and breaks the test at crates/dim-goal/tests/goal_product_flow.rs:540; keeping today's mapping leaves unknown_branch and closed unreachable, and get on an unknown line becomes service_reloading without a client-visible change entry. Fix: keep today's codes and state the line_ended/unknown mapping, or list the new codes as client-visible changes and migrate the callers.

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.

Partly fixed in 8f440bd. session_invalid_input and session_closed now match crates/dim-agent-capabilities/src/methods.rs:137-154, and Goal maps the tree's unknown to session_invalid_input. Remaining: the write table still lists branch_ended, but the target path has no producer: Goal.md:46 discards the line record, #2102's submit answers line_ended (InputQueue.md:81), and NoLine maps to service_reloading (Goal.md:105, :128). The get example has no tree.line check, so a missing line answers service_reloading, not the table's session_invalid_input. runtime-owner-operations.md:25 still says unknown_branch and keeps Goal's ended-history read. The body has findings 1 and 2.

- [SessionStore #2091](https://github.com/arcships/dim/pull/2091) is open: `set_title(caller, SetTitle, ChangeFn)` running the change under the owner's serialization with `rejected` as a kind, and `title` answering `{revision, title?: {text, source}}`. SessionTitle's examples and appendix use that binding; landing order: #2091 before this contract's implementation.


## Compatibility anchors

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.

Problem: the English anchors fix most referrers, but ### 0.1 Fields read for one title attempt is missing, so three links still break. Failure scenario: a reader following docs/design/plugins/Skills.md:526, docs/design/plugins/Hooks.md:186 or docs/design/timeline-read-followups.md:15 lands at the top of this document and loses the field-selection rule. Evidence: SessionTitle.md:204-258; those three links, all valid at 6e86d48. Fix: add the 0.1 compatibility anchor, and the other old headings if the full set is wanted.

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.

Fixed in 8f440bd. SessionTitle.md:208 adds ### 0.1 Fields read for one title attempt; Skills.md:526, Hooks.md:186 and timeline-read-followups.md:15 resolve.

`auto` or `manual`. Clearing keeps the counter, so a revision never repeats.
- **Write.** `setTitle {sessionId, expectedRevision, title | null}` commits revision `expectedRevision + 1` or fails
`conflict`, `not_found` or `storage`. The call is the handover: SessionStore admits the write when called, unless it
- **Write.** `setTitle {sessionId, the change callback's current title and revision, title | null}` commits revision `the change callback's current title and revision + 1` or fails

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.

Problem: this is not a request shape. The sentence makes the request carry "the change callback's current title and revision" and repeats it in "commits revision ... + 1", while the table at :91 says {id} plus the change. It also contradicts :15 ("revision-checked write") and :95 ("title is required in setTitle"). PR #2091's head already has the coherent text: store.title and store.setTitle(id, change), no expectedRevision (SessionStore.md:121-122; #2091's copy of this file at :3, :22-24, :93). Failure scenario: an S5b implementer cannot tell whether the request has a session id, a title, a revision or a callback. Fix: use #2091's wording, or drop this file's edit and let #2091 own it.

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.

Fixed in 8f440bd: the file is no longer in the PR. #2091 owns session-title-metadata.md, and SessionTitle.md:161 says so.

| 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. |
| Loop, ToolExecutor and Code Mode definition readers → `toolBinding` | `bind`, `bindCurrent`, `adopted({requestId}) → {adopted}`, `transfer`, `release`. ToolBinding retains the pinned handler generation; Code Mode reads `adopted` ([CodeMode](../plugins/CodeMode.md#own-contract)). |

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.

Problem: adopted answers {adoption, tools}, not {adopted}. CodeMode.md:72 and PR #2100's ToolBinding.md:137-138 define the reply as the adoption id plus the pinned declarations, and #2100's copy of this row already says {adoption, tools}. Failure scenario: Code Mode's tools.list, tools.describe and tools.call need both the adoption id and the declarations; an implementer following this row returns one opaque value and cannot pass the adoption to invoke or list the pinned tools. Fix: change the reply to {adoption, tools}.

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.

Fixed in 8f440bd. runtime-owner-operations.md:76 now says adopted({requestId}) -> {adoption, tools}, matching #2100 ToolBinding.md:137-138.

Comment thread docs/design/plugins/CodeMode.md Outdated
### 2.1 The `codemode` tool
| Owner | Operation | Use |
| --- | --- | --- |
| Session access ([#2025](https://github.com/arcships/dim/issues/2025), target, pending [#2093](https://github.com/arcships/dim/pull/2093)) | the line's owner by line id | The entry reaches `CodeModeLine`; the run reaches the line's ToolExecutor |

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.

Problem: this row names Session access (#2025, target, pending #2093) for line_owner, while :166-168 say the mechanism is #2127 and "SessionScope's contract has no such operation". PR #2093's SessionScope.md:26 and :39 say SessionScope publishes no operation for that path. Failure scenario: an implementer adds a SessionScope dependency that #2093 does not provide, so the entry cannot be assembled. Fix: name the id routing mechanism (#2127) here and keep the operation as line_owner::<T>(line), or mark the row as a mechanism requirement.

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.

Fixed in 8f440bd. CodeMode.md:70 names the id routing mechanism #2127 and line_owner::<T>(line); #2093 SessionScope.md:26 and :39 publish no such operation.

Comment thread docs/design/plugins/CodeMode.md Outdated
| --- | --- | --- | --- | --- | --- |
| `codemode` | The model submits one program | `{code}` | the program's returned value as JSON text, or a terminal failure text, with the confirmed effects | The program is interrupted: a synchronous loop stops, a pending child is cancelled and new children are refused | `invalid_input` when the arguments or the code size are refused, returned as an error result |
| `codeModeLine.run` | Run one program on this line | `{outerCallId, code, context}` | `ToolResult` | Interrupts the program and closes the gate; committed children settle through ToolExecutor | `invalid`, `closed`, `cancelled` as the service error `{code, message}`; a failed program is the result's text |
| `codeMode.with_slot` | Run one program inside a process slot | `{work}` as a direct callback parameter, plus `caller: &Ctx` | `{}` | The work is cancelled and joined; the slot is released | `closed` as the service error `{code, message}`; a cancelled work is the callback's own result |

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.

Problem: the reply is {} here, but the appendix returns Result<T, ServiceError> (:183-188) and the example uses the work's ToolResult (:54-61). Failure scenario: an implementer following this table drops the run's ToolResult, the round-2 failure; the run cannot answer the outer call. Fix: state the reply as the work's reply T.

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.

Fixed in 8f440bd. CodeMode.md:82 returns the work's reply T, :54-61 returns the program result, and WorkFn is defined at :212-214. The example's let slot: Result<ToolResult, ServiceError> = ... .await? annotation is still wrong; P3 in the body.


## Binding appendix

The process part provides `codeMode`; the branch part provides `codeModeLine`; the Session part registers the tool. Both names are set with `#[rutis::service(name = ...)]` on the owner type. Request, reply and error types are data; `cancelled` is the binding's cancellation argument.

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.

Problem: the prose says both names are set with #[rutis::service(name = ...)], but the appendix at :179 marks ProgramSlots with a plain #[rutis::service]. One Rust type has one name, so the catalog name is programSlots, while this document and README.md:37 use codeMode. Failure scenario: the entry cannot resolve codeMode.with_slot, and the catalog exposes the wrong process face. Fix: add name = "codeMode" to the attribute or rename the type.

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.

Fixed in 8f440bd. CodeMode.md:181 marks ProgramSlots with #[rutis::service(name = "codeMode")]; the two face names match the prose.

Comment thread docs/design/plugins/CodeMode.md Outdated
pub async fn with_slot<T>(
&self,
caller: &Ctx,
work: ChangeFn<T>,

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.

Problem: ChangeFn<T> is undefined in this contract, and ChangeFn is SessionStore's type in SessionTitle.md:289-292, an async callback over TitleState. Failure scenario: the appendix does not compile, or an implementer reuses the store's callback type with the wrong argument. Fix: define or name the quota callback type here, for example WorkFn<T> = Arc<dyn Fn(CancelledFn) -> BoxFuture<'static, Result<T, ServiceError>> + Send + Sync>.

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.

Fixed in 8f440bd. WorkFn<T> is defined at CodeMode.md:212-214; ChangeFn is no longer used in this contract.

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 040bf3602(基于 origin/main 6e86d48c8,docs-only,15 个文件)。

评审逐条

  • Goal.md:203 兼容锚点用中文标题:改为英文标题(2. Data and state、3.4 A new branch clears the inherited goal、5. Context mapping、A.2 Session methods、A.3 Reading the goal、A.4 Continuation decision、A.5 Model-visible texts、A.5.1 Protocol and policy、A.5.2 Evaluation、Appendix A. Interface details、Appendix B. Full conflict table、Appendix E. Assumptions),timeline-branches、Pursuit、model-prompts、cli-commands、Scheduler、dim-cli/README、acp-gateway-implementation 的链接都有对应锚点。
  • Goal.md:103 错误码:改为今天实际收到的码——invalid_params(Goal 自己的参数检查)、session_invalid_input(AgentError::UnknownBranch 与 InvalidInput 的线上码,methods.rs:137-140)、branch_ended(今天结束行的码)、service_reloading、session_closed、operation_interrupted;正文写明 line_ended 随 docs(design): target contracts for the branch turn chain #2102 落地时才是客户端可见变更。tree.line 示例的注释同步为 session_invalid_input。
  • SessionTitle.md:204 缺 0.1:加回 ### 0.1 Fields read for one title attempt,四个字段按固定截止读取,指向依赖表。
  • SessionTitle.md:3/13/165/254 指向已删除的上一版:生成策略、指令文本、2000 字符摘录、maxLength 10..=200(默认 80)、30 s 与三次尝试,以及验收项都写进正文,不再指向不在树里的版本。
  • CodeMode.md:82 with_slot 回复 {}:改为「work 的回复 T」,与附录一致。
  • CodeMode.md:70 行 id 归属:依赖表改为 id 路由机制 按 id 调用:由持有实例的一方选目标(base-1) #2127(line_owner::<T>(line)),并注明 所有者扫描:TimelineTree 与分支线 #2024 的契约给出它服务的操作(docs(design): define the line directory owner contract #2092)。
  • CodeMode.md:102 错误表混入 ToolExecutor 的码:interrupted、no_batch、gate_closed、closed 各自标注为 ToolExecutor 的 open/invoke/close 种类,run 自己的错误是 invalid、closed、cancelled。
  • CodeMode.md:179 附录名字:ProgramSlots 用 #[rutis::service(name = "codeMode")],并补 CodeModeLine 的 #[rutis::service(name = "codeModeLine")] 与 run 签名。
  • CodeMode.md:186 ChangeFn<T> 未定义:改为本契约的 WorkFn<T> = Arc<dyn Fn(CancelledFn) -> BoxFuture<'static, Result<T, ServiceError>> + Send + Sync>。

上一轮已修、本轮复核仍成立的项(Goal.md:29/46/81/114/201/216/96/144/173,SessionTitle.md:57/153/169/204,CodeMode.md:58/72,Web.md:72/153/258)保持不动。

自查发现(1–9)

  1. 现状说法逐条按路径核对:methods.rs:137-154 的线上码、config.rs:190-192 的挂载排除、InputQueue.md(docs(design): target contracts for the branch turn chain #2102)的 line_ended、tool_registry.rs:125-135 的 sets、docs(storage): define the session storage owners' target contracts #2091 的 ChangeFn/TitleState/StoreRejected、docs(design): define the line directory owner contract #2092 的 directory/line、design(tools): target contracts for the branch tool chain #2100 的 open/invoke/close 与 {adoption, tools}。
  2. 与现有文档的冲突在本 PR 内解决:overview.md、Goal-state-read.md、plugin-contract.md、Pursuit.md、resource-*、resource-faces.md 的本所有者段落已改;session-title-metadata.md 退回 main,留给 docs(storage): define the session storage owners' target contracts #2091(见下)。
  3. 一概念一词:line_owner、goalLine、codeMode/codeModeLine、with_slot、WorkFn、SetTitle/ChangeFn(store 的);unknown_branch、GoalStatus、LineRequest、TitleChange、ToolSet、registerSource 已无残留。
  4. 内部一致:操作表、流程、错误表、例外、Rule check 与附录一致;with_slot 的回复、CodeModeLine.run 的签名与错误标注补齐。
  5. 每个结局写了调用方下一步:Goal 的写/读、SessionTitle 的单次/重复/关闭/重载、Code Mode 的 open/invoke/close 各自种类。
  6. 改名/删除后全仓 grep:锚点、Goal.md 的英文兼容锚点、SessionTitle.md 的 0.1 都已补;无残留旧名。
  7. 规则不带 Rust 拼写;未合并目标写 target, pending #PR;机制需求指向 按 id 调用:由持有实例的一方选目标(base-1) #2127,不把扫描 issue 当机制 issue。
  8. 新写的句子按 1–5 复核:新增的 CodeModeLine 附录、错误标注、SessionTitle 验收段与 Goal 错误段。
  9. 引用他 PR 的定义均按其最新 head 打开(docs(storage): define the session storage owners' target contracts #2091 b4bb7f8a3、docs(design): define the line directory owner contract #2092 cf2fec030、docs(design): target contracts for the Session scope and its host ports #2093、design(settings): owner contracts for Settings and the settings sections #2094、design(provider): target contracts for the model and provider owners #2096、design(tools): target contracts for the branch tool chain #2100、docs(design): target contracts for the branch turn chain #2102、docs(design): target contracts for the Session registries and tools #2103)。

留给 step 2 的跨 PR 项

客户端可见变更(本 PR 维持不变)

session.goal.* 写请求新增可选 submissionId;结束行的 session.goal.get 答 service_reloading(受影响 dim-cli 的 /goal 与 TUI goal 面板);goal:state 记录不再与命令同批。

绑定附录编译

四份附录 + 示例(GoalLine::read(cancelled)、Store::set_title(caller, SetTitle, ChangeFn)、ProgramSlots::with_slot<T>(caller, WorkFn<T>, CancelledFn)、CodeModeLine::run(caller, RunProgram, CancelledFn)、ToolProvider::sets() -> Vec<Arc<ToolSourceSet>>)在临时 crate(rutis 0.23)cargo check --offline 通过,未提交。

adr-check 与 xtask-check 通过。评审人请重看。

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 13d8e70b2。

跨 PR 对齐:

验证:node scripts/adr-check.mjs --base origin/main 通过;链接与锚点无新增断链。

@eric8810

Copy link
Copy Markdown
Collaborator Author

补充说明,head 3501002ac(ADR 027 收回到决定层后):

  • Goal 的三种路由答案说明补了 #2127 链接;NoLine/SessionClosing/NoSession 的下一步由 按 id 调用:由持有实例的一方选目标(base-1) #2127 定义,不再引用 ADR 027 D2。
  • Goal 与 CodeMode 的 Rule check 行不再复述 D1/D4 的内容,改为 D1 and D4 加机制链接;Web 的 ADR 027 D2 改为 ADR 027(不适用场景,不涉及三种情况)。

验证:node scripts/adr-check.mjs --base origin/main 通过;链接与锚点无新增断链。

Goal writes a command input to the line and reads the goal owner's published
value; the routing table, the Session-side re-fold and the pre-commit callback
are removed. Code Mode keeps the process program slots as one callback
operation and runs the program in the line's owner. SessionTitle writes titles
through SessionStore's change callback and reads Goal's published value. Web
names its two tool contributions and the Dim account's search operations.

Refs #2033
Refs #2015
Goal keeps the trigger's sequence, names the state record's one writer, takes
cancellation on the line read, carries a submission id, states the ended-line
client change and the evaluator refusals, and uses GoalViewStatus. SessionTitle
follows #2091's ChangeFn binding and drops the broadcast row. Web declares
search for a configured adapter. Code Mode gates on the mount exclusion and its
examples compile. Compatibility anchors and the standing documents' owner
paragraphs point at the new contracts.

Refs #2033
Goal keeps today's wire codes, gets English compatibility anchors, and maps the
tree's unknown kind. SessionTitle adds the 0.1 field anchor and states the
policy and acceptance it used to defer. Code Mode names the id routing
mechanism, returns the work's reply, labels the executor's error kinds and
names both faces in the appendix. The shared S5b title document is left to
#2091.

Refs #2033
The ended-line read, the state record's order and the optional submission id
are stated as separate client-visible changes with their affected callers.

Refs #2033
@eric8810
eric8810 force-pushed the dim/2033-plugins-contract branch from 3bb0861 to 8f440bd Compare November 24, 2026 06:35

@yyhhyyyyyy yyhhyyyyyy left a comment

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.

Scope

This PR rewrites the four product owner contracts (Goal, SessionTitle, Web and Code Mode) and the plugin index for the owner-operations series (refs #2033 and #2015). It moves callers to line-id operations, SessionStore's change callback and the account face, and deletes about 1400 lines of mechanism detail. I reviewed the full main...head at 8f440bd, not only the five commits after the round-3 review.

Verdict

REQUEST_CHANGES

Prior P2 status

Fixed and withdrawn:

  • P2 1 anchors: the Goal compatibility section now uses the base English headings (Goal.md:209-259), SessionTitle adds 0.1 (SessionTitle.md:208), and a fragment check over the modified docs finds no broken links. The 25 Goal and 3 SessionTitle referrers resolve.
  • P2 3 metadata: session-title-metadata.md is no longer in the PR; #2091 owns it.
  • P2 4 adopted: runtime-owner-operations.md:76 now says {adoption, tools}, matching #2100 ToolBinding.md:137-138.
  • P2 5 CodeMode dependency: CodeMode.md:70 names #2127, and #2093's SessionScope.md:26, :39 publish no such operation.
  • P2 6 with_slot: CodeMode.md:82 returns the work's reply T and WorkFn is defined at :212-214. The example still has a type error; see P3.
  • P2 7 service name: CodeMode.md:181 sets name = "codeMode".
  • The round-2 P2s 1-10 and P3s 14-17 stay fixed.

Partly fixed:

  • P2 2 Goal error codes: session_invalid_input and session_closed now match crates/dim-agent-capabilities/src/methods.rs:137-154, and Goal maps the tree's unknown. Remaining: findings 1 and 2.

P2

1. Goal's write and get paths still cannot produce the codes the tables promise

Problem: The write table lists branch_ended at Goal.md:98-100, but no target path produces it. The write example reads tree.line and discards the record (Goal.md:46); for an ended line the target line returns a record with state: ended (#2092 TimelineTree.md:133), not an error. The entry then calls line_owner::<InputQueue>; a line whose scope is gone answers NoLine, which Goal.md:105 maps to service_reloading, and submit on an ending line answers line_ended (#2102 InputQueue.md:81, :92). The paragraph at :105 says both that branch_ended is "the ended-line refusal today" and that line_ended "lands as a client-visible code", and :128 says NoLine includes an ended line and maps to service_reloading. The get table lists session_invalid_input (no such line) at :101, but the get example (:58-64) never calls tree.line; NoLine covers an id that is not this Session's (#2092 TimelineTree.md:98), so a stale branchId answers service_reloading, not session_invalid_input. The Client-visible changes list says "Three changes ... everything else keeps its codes" (:160), while :105 announces the new line_ended code and the get path changes an unlisted error.

Failure scenario: A client on an ended line gets line_ended or service_reloading while the table promises branch_ended, so its handler misses the error. A client with a stale branchId retries service_reloading forever instead of fixing the line. A test written from the shown path cannot trigger branch_ended.

Evidence: docs/design/plugins/Goal.md:46, :58-64, :98-101, :105, :128, :160-164; PR #2102 docs/design/plugins/InputQueue.md:81, :92; PR #2092 docs/architecture/rust-agent/plugins/TimelineTree.md:98, :133; current code crates/dim-goal/src/session.rs:116-130, crates/dim-goal/src/read.rs:33-55.

Fix: Add the tree.line(line.clone())? check to the get example and state that its unknown is session_invalid_input. For writes, either inspect the record's state and answer branch_ended (then delete the line_ended note), or pass line_ended through and add it to the client-visible list. State the NoLine mapping per operation, not once for both.

2. The retained runtime row still says unknown_branch and keeps Goal's ended-line read

Problem: runtime-owner-operations.md:25, which this PR changes, says line({line}) answers one record or unknown_branch. #2092's line answers unknown (TimelineTree.md:133), and Goal.md:105 publishes that as session_invalid_input. The same row says "Goal reads ended history through read", while Goal.md:136 says Goal does not answer for an ended line and :162 says the entry no longer folds and answers service_reloading.

Failure scenario: An implementer handles an unknown_branch kind that no owner returns and misses unknown; the ended-line read path is reintroduced, reverting Goal's first client-visible change.

Evidence: docs/design/contracts/runtime-owner-operations.md:25; PR #2092 docs/architecture/rust-agent/plugins/TimelineTree.md:98, :133; docs/design/plugins/Goal.md:105, :136, :162.

Fix: Say line({line}) answers unknown; say the client reads an ended line's history through read (or drop the clause), and remove Goal's ended-line read.

3. Goal-state-read still keeps the ended-line read the Goal contract removes

Problem: The new note at Goal-state-read.md:9 supersedes only the one-batch command write and its ordering rule. Section 4.2 at :117 still says an ended branch with no live owner is read through TreeCommands.query and preserves the original GoalRead. Goal.md:136 and :162 say the entry no longer folds and answers service_reloading; the client reads the facts. The note's last clause says the load mapping still follows Goal-state-read, so the two documents ship different contracts.

Failure scenario: An implementer follows Goal-state-read's load mapping and keeps the ended-line read; session.goal.get then still returns GoalRead on an ended line while Goal.md says service_reloading, and the client migration in Goal.md:162 is not needed. The ended-line behavior depends on which document the implementer reads.

Evidence: docs/design/plugins/Goal-state-read.md:9, :117; docs/design/plugins/Goal.md:136, :153, :162.

Fix: Extend the note to supersede section 4.2's ended-branch read as well, and mark :117 pre-contract, or update :117 to answer service_reloading and leave the fold to the client.

P3 (optional)

  • SessionTitle.md:52-54: StoreError::NotFound is a struct variant (#2091 SessionStore.md:122, enum at :386-396), so the pattern needs { .. }; the catch-all maps StoreError::Closed to storage_failed although the operations table lists service_reloading. Fix the pattern and map Closed to service_reloading.
  • CodeMode.md:54: quota.with_slot(...).await? yields T = ToolResult, but the annotation is Result<ToolResult, ServiceError>; the WorkFn is Fn and the closure moves code and context into the async block, which Fn cannot. Annotate ToolResult and clone the captures, or change the callback type.
  • Web.md:164-166: ToolProvider::sets is the current trait; the dependency row at :70 and #2103's target use register_source(name, sets, execute) with SourceSet (#2103 ToolRegistry.md:102, :325-330). Show the target call or label the appendix as current-code only.
  • Pursuit.md:177, :181 still use treeCommands.info; the target face is timelineTree.line (#2092 TimelineTree.md:133).
  • Goal.md:59 calls owner.read() without the cancelled argument the appendix declares at :281.
  • Goal.md:257 is the Appendix E. Assumptions stub where Pursuit's A16 link lands; it talks about parameter limits, not the worker-completed request. Move the A16 statement or point the link at Pursuit P4.
  • SessionTitle.md:11 and :13: the generation flow does not state the interactive-leader guard that the acceptance and the current code require (crates/dim-session-title/src/lib.rs:222); a member Session would title.
  • Goal.md:64 and :101/:166: the get example reads GoalValue fields; show the GoalRead { branchId, through, goal } mapping.
  • Open dependency labels: Goal.md:82, :86, :87-88 (#2024 without pending #2092, #2025 without #2093, #2017 without #2094, #2026 without #2103), SessionTitle.md:106 (#2026 without #2103), Web.md:69 (#2019 without #2096).
  • plugin-contract.md:110: the Name column should keep store as the face name (#2091 SessionStore.md:229).
  • SessionTitle.md:267 imports MetadataError and SessionMetadata while the body uses ChangeFn, TitleState, StoreRejected and SetTitle.
  • CodeMode.md:168 says "Both requirements below" while the section has three bullets at :170-172.

Cross-PR and main

  • The PR is based on 4d081fe6, origin/main is decc5894, and the merge base is 4d081fe6; it reports MERGEABLE. node scripts/adr-check.mjs --base 4d081fe6 passes with isolated HOME, TMPDIR and XDG. CI at the head: ci-ok and changes pass; the other jobs are skipped.
  • I checked the current sibling heads: #2091 9ff2b07d, #2092 c80f8e16, #2093 c8f18126, #2098 c3acab35, #2100 437266bf, #2102 3b48e124, #2103 59a77a3d.
  • docs/design/contracts/runtime-owner-operations.md is edited by #2091, #2092, #2093, #2098, #2100, #2102, #2103 and this PR, and their copies disagree on the Goal and InputQueue rows. #2092 deletes the old Goal row and uses line_owner for InputQueue; #2102 adds inputQueue.submit but keeps the old Goal row; this PR changes the Goal row but still says timelineTree.input in the InputQueue row. #2091, #2093, #2098, #2100 and #2103 still carry the old Goal rows. A later merge can revert any of these. Align the row set before landing.
  • docs/design/plugins/SessionTitle.md is edited by #2091 (title binding), #2098 (the 3.4 create_session change) and rewritten here. #2098's change sits in a section this rewrite deletes; #2091's copy is the pre-contract document. Land #2091 first and rebase this rewrite over #2098's 3.4 change.
  • #2091's SessionStore setTitle binding has no cancellation argument (SessionStore.md:409-418), which matches SessionTitle.md:295-296; #2091's own example at :82 still passes cancelled. That is #2091's issue, but it is the binding this document cites.
  • #2100's ToolBinding.adopted matches the new runtime row; #2102's submit answers line_ended and closed, which are the codes Goal must map; #2103's register_source is not the ToolProvider trait Web's appendix still shows.
  • No conflict with origin/main is visible. The remaining conflicts are the sibling rows and the SessionTitle edit.

Unverified

  • I did not run the Rust tests. The code claims come from crates/dim-agent-capabilities/src/methods.rs, crates/dim-goal/src/session.rs, crates/dim-goal/src/read.rs, crates/dim-app-server/src/storage/metadata.rs and crates/dim-session-title/src/lib.rs.
  • The anchor check uses the GitHub slug algorithm; the renderer may vary the exact count, but the once-broken English headings now match the base document.
  • Sibling line numbers are from the heads above and may move.
  • The exact Rust field types of GoalValue, RenameRequest and RenameReply were not independently checked.
  • Target-only names such as GoalLine, codeModeLine, WorkFn and line_owner have no current code; their shapes are checked only against the sibling contracts.

Previous opinions to withdraw

  • Withdraw the round-3 P2 1 anchors, P2 3 metadata, P2 4 adopted, P2 5 CodeMode dependency, P2 6 with_slot reply and ChangeFn (the main claim) and P2 7 service name. They are fixed at 8f440bd.
  • Keep P2 2 narrowed to findings 1 and 2.
  • Withdraw the round-3 P3 about ADR 027 existing only in #2029; ADR 027 is in main at 4d081fe.
  • Withdraw the round-3 P3 about SessionTitle pointing at a version not in the tree; the policy and acceptance are restated.
  • Withdraw the round-3 P3 about CodeMode's Errors table; the kinds are labeled ToolExecutor's.
  • Keep the round-3 P3s about Pursuit's treeCommands.info, the uneven pending labels, the get example's GoalRead mapping, the plugin-contract Name column and the SessionTitle appendix imports; they remain.

| 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. |
| Goal and Shell admission → timelineTree | `directory()` answers the lines and the default; `line({line})` answers one record or `unknown_branch`. Goal reads ended history through `read`; writes retain the ended and unknown errors. |

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.

Problem: this changed row still says line({line}) answers unknown_branch, but PR #2092's line answers unknown (TimelineTree.md:133), and Goal.md:105 publishes that as session_invalid_input. The row also says Goal reads ended history through read, while Goal.md:136 and :162 say the entry no longer folds or answers an ended line. Failure scenario: an implementer handles an unknown_branch kind the owner never returns and misses unknown; the ended-line read path is reintroduced, reverting Goal's first client-visible change. Evidence: this row; PR #2092 docs/architecture/rust-agent/plugins/TimelineTree.md:98, :133; docs/design/plugins/Goal.md:105, :136, :162. Fix: say line({line}) answers unknown; say the client reads an ended line's history through read (or drop the clause), and remove Goal's ended-line read.

```rust
let goal = match line_owner::<GoalLine>(&line) {
Ok(owner) => owner.read().await?,
Err(NoLine) => return Err(AgentError::Reloading("Goal".into())), // service_reloading

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.

Problem: the get example maps NoLine to service_reloading, but the operation table at :101 promises session_invalid_input for a missing line. NoLine covers an id that is not this Session's or is gone (PR #2092 TimelineTree.md:98), so a stale branchId takes this arm and answers service_reloading, not session_invalid_input. Failure scenario: a client with a stale branchId retries service_reloading forever, and the code the table says it gets is unreachable. Evidence: this line; Goal.md:101, :105; PR #2092 TimelineTree.md:98. Fix: add the tree.line(line.clone())? check the write example uses at :46 before this match, and state that the tree's unknown maps to session_invalid_input.

## Client-visible changes

公开入口仍为 session.goal.set/edit/pause/resume/clear/get 和工具 goal_update;参数、GoalRead 和命令 sequence 返回保持原接口。[Appendix A](#appendix-a-interface-details)列出合同。无 Goal 数据库或专用查询机制。
Three changes reach clients; everything else keeps its field names, codes and notifications.

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.

Problem: the list says three client-visible changes and that everything else keeps its codes, but the contract also says the input owner's line_ended lands as a client-visible code (Goal.md:105) and the write table still lists branch_ended (:98-100). The get path's missing-line case also changes to service_reloading unless a tree.line check is added (:60). Failure scenario: a client built from this list does not handle line_ended and treats a missing line's new service_reloading as a reload. Evidence: this line; Goal.md:98-101, :105, :128; PR #2102 InputQueue.md:81, :92. Fix: either map line_ended to branch_ended and keep the three changes, or add line_ended and the missing-line code as client-visible changes with their landing condition.


依据:[Goal](Goal.md)、[读取与输入删除](Goal-property-queries.md)、[设计规则](../../architecture/rust-agent/principles.md)、[ADR 002](../../adr/002-plugin-scope.md)、[插件合同](../plugin-contract.md)、[rutis](../rutis-usage.md)。本文件规定状态保存与读取合同。

> 目标契约见 [Goal](Goal.md)。[Goal](Goal.md#client-visible-changes) 取代本文的命令与状态记录同批规则和「回复是 trigger 的 sequence」之外的排序描述;状态对象、加载映射与属性查询仍以本文为准。

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.

Problem: the note supersedes only the one-batch command write and its ordering rule, while section 4.2 still says an ended branch with no live owner is read through TreeCommands.query and preserves the original GoalRead (:117). Goal.md:136 and :162 say the entry no longer folds and answers service_reloading, and the client reads the facts. Failure scenario: an implementer follows this document's load mapping and keeps the ended-line read, so session.goal.get still returns GoalRead on an ended line while Goal.md promises service_reloading. Evidence: this note; Goal-state-read.md:117; Goal.md:136, :153, :162. Fix: extend the note to supersede the ended-branch read and mark :117 pre-contract, or update :117 to answer service_reloading and leave the fold to the client.

@eric8810

Copy link
Copy Markdown
Collaborator Author

Closing as part of abandoning the owner-split experiment.

@eric8810 eric8810 closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants