Skip to content

docs(design): define the line directory owner contract - #2092

Closed
eric8810 wants to merge 16 commits into
mainfrom
dim/2024-timeline-contract
Closed

eric8810 wants to merge 16 commits into
mainfrom
dim/2024-timeline-contract

Conversation

@eric8810

@eric8810 eric8810 commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

Design part of #2024 (TimelineTree and the branch line), under design rules §7 and the owner-redesign template.

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

Four owner contracts in one change, because the plate changes at once:

  • TimelineTree: the Session's line directory and line lifecycle. Six data operations on the owner type: create, end, set_default, directory, line, read. treeCommands, timelineTreeControl and the Branch facade stop crossing this owner.
  • TreeTimeline: the branch-scope route from a line's facts to the directory; no public face.
  • BranchLine: one line's role, end state, read cursors and held parent block as one read value.
  • BranchTool: the model's branch tool; no service.

A Session part reaches a line's owners with line_owner::<T>(line): any data face of the branch group, resolved by the runtime's index of the instances it constructs (ADR 027). TimelineTree provides no entry into another owner and states the requirement in #2025.

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

Checks: node scripts/adr-check.mjs --base origin/main, cargo run --locked -p xtask-check.

Refs #2024
Refs #2015

@eric8810

Copy link
Copy Markdown
Collaborator Author

评审(head d558c6841):需改 2 处;BranchLine、BranchTool、TreeTimeline 其余部分符合。

  1. lineOwner.call 是字符串路由。 {line, operation: "inputQueue.submit", request: json!(..)} 用字符串选操作、用 json! 传请求,等于在每个分支所有者前加一层转发门面,类型也丢了。本 PR 的 BranchTool 和 docs(design): target contracts for the Agents and Collaboration owners #2098、design(2033): target contracts for Goal, SessionTitle, Web and Code Mode #2099、docs(design): target contracts for the Session registries and tools #2103 的调用方写的都是 line_owner::<T>(line)?.op(..):按 line id 解析到该行的分支服务,直接调用它自己的类型化操作。以后者为准;向机制提的需求改成「按 line id 解析分支组服务」,与 docs(design): target contracts for the Session scope and its host ports #2093 一起改。
  2. directory 一个操作两种回复。 DirectoryReply::All/One 让调用方写 unreachable!(本 PR 和 design(2033): target contracts for Goal, SessionTitle, Web and Code Mode #2099 Goal 都有)。拆成 directory() 和 line(id)。

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head cf2fec030。

  1. 按 line id 访问分支所有者,改成类型化写法。 删掉 lineOwner.call({line, operation, request}) 与请求/回复类型;改为 line_owner::<T>(line)?.op(..):机制按 line id 解析该行的分支组服务,调用方直接调用目标所有者的类型化操作。TimelineTree.md 的「Session parts reaching a line's owners」与调用方示例、BranchLine.md 与 BranchTool.md 的示例都按这一种写。向机制提的需求改成「按 line id 解析分支组服务」(NoInstance 表示行不在活动状态、Closed 表示 Session 在关闭),与 docs(design): target contracts for the Session scope and its host ports #2093 一起改;所有者扫描:SessionScope 与 Session 宿主端口 #2025 上的需求评论同步改成这一种。
  2. directory 拆成 directory() 与 line(id)。 去掉 DirectoryReply::All/One;调用方示例不再 match 与 unreachable!。操作表、错误(line 的 unknown)、流程(line 的读与结束前记录)、验证、绑定附录(directory() 与 line() 两个方法、Directory 与 LineRecord 两个类型)同步。

BranchLine、BranchTool、TreeTimeline 其余部分未改(BranchLine 与 BranchTool 的示例只按第 1 条换了写法)。

检查:node scripts/adr-check.mjs --base origin/main、cargo run --locked -p xtask-check 通过。交付评论已同步首行 head 与迁移行。

eric8810 added a commit that referenced this pull request Nov 23, 2026
The Goal caller example resolves the conversation line with directory() and
checks a named line with line(), matching #2092.

Refs #2033
@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: five docs (+782/-0): TimelineTree.md, TreeTimeline.md, BranchLine.md, BranchTool.md and the plugin index row. Design part of #2024 under the proposed section 7 of #2029.

Verdict: REQUEST_CHANGES. The owner split and the data-face direction are right, but the contract contradicts the accepted timeline branches design on the final message, the status note, creation cancellation and the open-line cap, the binding appendix is not a compilable data face, and the branch part keeps a strong tree reference without the Weak access the current owner needs for close to settle.

Findings

  1. P1: final message writer and order. Problem: TimelineTree.md:160 records branch/ended before the final message, and :191 and :193 assign the write to the opener's BranchLine. Failure: a crash after branch/ended but before the message loses it, because restore treats a parent that holds branch/ended as no longer owed; and end cannot answer final_undelivered or retry a message another owner writes. Evidence: the accepted design says TimelineTree delivers it and branch/ended is written after the delivery (docs/design/timeline-branches.md:395, :718, :781, :807); close_and_record delivers before close (crates/dim-agent-capabilities/src/timeline_tree.rs:2413-2438) and deliver_final writes the parent input (:2499-2516). Fix: keep TimelineTree as the writer, order delivery before close and before branch/ended, or move delivery and retry to BranchLine's contract and remove final_undelivered from end.

  2. P1: TreeCommands retirement drops the Weak access that prevents a Session/branch cycle. Problem: BranchLine.md:59 makes BranchLine depend on S:TimelineTree, while the tree holds each line's branch context and the context holds BranchLine. Failure: a strong S:TimelineTree keeps the tree and the line's parts alive in a cycle, so ending a line or closing the Session cannot drop the scope and close cannot settle. Evidence: current TreeCommands holds Weak (crates/dim-agent-capabilities/src/timeline_tree.rs:440-442), BranchLine holds Arc (:3805), and TreeTimeline.md:57 keeps Weak for its own route; issue #2024 states this requirement explicitly. Fix: state the weak handle BranchLine and TreeTimeline receive, where it is built, and how close settles it; a weak view is not the forwarding wrapper that ADR 002 D2 (TimelineTree.md:205) removes.

  3. P2: create cancellation is contradictory. Problem: :126 says an admitted creation is not abandoned but a cancelled one is rolled back before the reply; :159 says a built but unpublished line is rolled back and its slot released; :178 says a cancelled create rolls back and writes branch/create-failed, while an admitted create still publishes. Failure: implementers cannot tell whether a caller's cancellation stops the wait, the build, or the slot, so the same cancel can publish a line or roll it back and a slot can leak. Evidence: the code stops the wait but continues the build after the reservation (crates/dim-agent-capabilities/src/timeline_tree.rs:2624) and the accepted design keeps the reservation and slot when a caller stops waiting (docs/design/timeline-branches.md:194). Fix: name what cancellation stops and when branch/create-failed is written; keep the accepted rule unless the code changes.

  4. P2: BranchLine cannot be implemented from its declared dependencies. Problem: BranchLine.md:55-59 declares no input owner and no GuideEntries, yet :67 writes through "the line's input entry" and owns the roster, idle notice and ended notice. Failure: an implementer finds no service for the write, and the model-facing markers lose their guide entries in the rewrite. Evidence: current BranchLine registers dim-branch-lines, dim-branch-message, dim-branch-idle and dim-branch-ended (crates/dim-agent-capabilities/src/timeline_tree.rs:3710-3712), writes through TreeCommands.input (:4740, :4828, :4987), and the current page lists S:GuideEntries (docs/architecture/rust-agent/plugins/BranchTool.md:132). Fix: declare the input owner and GuideEntries, name the markers BranchLine registers, and say who owns the status note's text.

  5. P2: status note writer stated three ways. Problem: TimelineTree.md:161 has the tree "queue one note per participant"; :171 has the tree write the note into each queue but says the text is BranchLine's; :193 says BranchLine writes it. Failure: an implementer can make the tree write model-facing text owned by BranchLine, or leave BranchLine without the transition it needs. Evidence: the accepted design queues a transition and each line's BranchLine drains it and writes the note (docs/architecture/rust-agent/plugins/TimelineTree.md:15, docs/design/timeline-branches.md:118). Fix: the tree records the transition only; BranchLine writes the keyed note.

  6. P2: error contract gaps. Problem: set_default has no ended-target error (TimelineTree.md:128, :149); end's protected next step says move the conversation first (:146), which cannot help the root; LineError is a thiserror enum without serde (:289-323). Failure: a client moving to an ended line gets no documented kind and may treat it as unknown; a root end tells the caller to do something that never helps; a rutis service method cannot serialize the error and a foreign caller gets no codes. Evidence: selectable returns BranchEnded for an ended line (crates/dim-agent-capabilities/src/timeline_tree.rs:2000-2006); the accepted design answers branch_target_protected for an ending chain (docs/design/timeline-branches.md:383); the code answers the root with an input error (:1918-1920); errors are data with codes (docs/design/rutis-usage.md:162, ADR 002 D5) and the existing codes are in crates/dim-agent-runtime/src/error.rs:138-169. Fix: add ended and protected cases, split the root or state that it never ends, derive serde on LineError with wire codes, and map every owner error in BranchTool.md:94-102, including final_undelivered, parent_ended, invalid_cut, beyond_head, not_batch_boundary and closed (the flows at :108-111 already answer closed).

  7. P2: line_owner's two families exclude operations the contract sends through it. Problem: TimelineTree.md:96 and :212 allow only writing input and reading a published value, while :41 sends compact, withdraw, approve, adopt and usage reads through line_owner::. Failure: a Session part that needs approval.respond or inputQueue.withdraw on a line is told it may not call it, and adding a forwarding facade would violate section 7. Evidence: the accepted plugin contract still says Session to branch goes through treeCommands and never by injecting a branch service (docs/design/plugin-contract.md:70, :117); #2093's SessionScope contract allows the typed resolution. Fix: allow calling the owner's own operation and reading its published value, update plugin-contract or mark the supersession, and update the PR body, which still describes lineOwner.call({line, operation, request}, cancelled) instead of typed line_owner::(line).

  8. P2: rule check counts BranchTool as a branch part. Problem: TimelineTree.md:189 says one Session part and three branch parts (TreeTimeline, BranchLine, BranchTool), while :190 counts only TreeTimeline and BranchLine. Failure: the part list and the scope split disagree, and a reader cannot tell where BranchTool is mounted. Evidence: BranchTool.md:3 and the README row put BranchTool in Session scope. Fix: one Session part (TimelineTree), two branch parts, and BranchTool as a separate Session part.

  9. P2: binding appendix does not compile as written. Problem: ReadLines declares scope twice (TimelineTree.md:281-282); LineError lacks serde (finding 6); BranchLine's LineState (BranchLine.md:155-163) collides with TimelineTree's LineState enum (TimelineTree.md:237-243); LineViewError (BranchLine.md:167) is never defined. Failure: duplicate fields, missing serialization and an undefined error type block implementation. Fix: remove the duplicate, name the view type differently, define the error type, and make fields and reply shapes match the operations table (fields is optional there at :131 but required in the struct at :285).

Minor items (optional):

  • BranchTool.md:27 sends the kin check to timelineTree.directory with {line}; directory takes {} and line takes {line}.
  • BranchLine.md:65 gives state a {line} request while :37 calls state() on a per-line service; :105 says it writes only its own line while :17 writes notices to its opener.
  • TimelineTree.md:110 links SessionScope.md, which exists only in #2093; main gets a broken link if this lands first.
  • README.md:12 adds the index row but the By scope table at :56-57 is not updated.
  • TimelineTree.md:14 makes the tree own the open-line cap while docs/design/timeline-branches.md:192 gives the limit to BranchTool; TreeTimeline.md:72 calls the part not a Capability while docs/design/timeline-branches.md:110 says it is.
  • TimelineTree.md:201-203 uses section 7 labels ("callbacks and ids", "one change", "no proxy reads") that are not headings in the proposed #2029 section 7, and #2029 is unmerged.
  • The PR body says five data operations; the document has six (create, end, set_default, directory, line, read), and the delivery comment on #2024 repeats the five.
  • TimelineTree.md:181 says line answers a reservation, but LineState has no opening state and the record carries a head that a reservation does not have.

Verification: HEAD cf2fec0, base 1bc7d67. node scripts/adr-check.mjs --base origin/main passed (5 changed files). A relative-link check over the five changed files found only SessionScope.md missing. gh pr checks 2092 shows ci-ok pass; docs-only jobs skipped. No full build was run. Every code claim above was checked against the current checkout; the changed docs contain no file:line citations.

Comment thread docs/design/plugins/TimelineTree.md Outdated
| Operation | Normal path | Caller cancels | Caller unloads | Owner closes or reloads | Settled by |
| --- | --- | --- | --- | --- | --- |
| `create` | Validate parent, cut, opener and cap under one lock, reserve the line, build the scope, write the opening blocks and the first input, publish, reply the id | The admission stops; a built but unpublished line is rolled back and its slot released; the caller sees `cancelled` | The line is built and published for the Session: an admitted creation is not abandoned; a waiter that left does not cancel it | A line still building is rolled back; the reply is `closed` | TimelineTree: the scope, the reservation and the slot |
| `end` | Check the target, end descendants deepest first, commit `branch/end`, close the scope, write `branch/ended` on the parent, deliver the final message as data | None; the call answers when the end settles | The end continues; the caller's absence changes nothing | An end in flight finishes before the generation closes; the generation's close waits for it and for the store's answer | TimelineTree: the scope's close and the end 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.

P1 final message. Problem: this row records branch/ended before the final message, and :191 and :193 give the write to the opener's BranchLine. Failure: a crash between the two loses the message, because restore sees the parent holds branch/ended and never delivers; end also cannot return final_undelivered for a write another owner performs. Evidence: docs/design/timeline-branches.md:395, :718, :781 and :807; crates/dim-agent-capabilities/src/timeline_tree.rs:2413-2438 and :2499-2516. Fix: TimelineTree delivers before close and before branch/ended, or move delivery and retry to BranchLine's contract and drop final_undelivered from end.

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 c5bba3d. TimelineTree.md:16, :162, :171 and :182 now put delivery before the scope close and before branch/ended, and keep TimelineTree as the writer; this matches close_and_record in crates/dim-agent-capabilities/src/timeline_tree.rs:2397-2448.

Comment thread docs/design/plugins/TimelineTree.md Outdated

| Operation | Intent | Request | Reply | Cancellation | Errors |
| --- | --- | --- | --- | --- | --- |
| `create` | Open a line at a cut of its parent | `{parent, cut, prompt, source, idle_notice?}` | `{line}` | While the line is admitted and built; an admitted creation is not abandoned and a cancelled one is rolled back before the reply | `invalid_parent` (no such line), `parent_ended`, `invalid_cut` (over the parent's head, or not an atomic-batch boundary), `not_opener` (this line may not open one), `limit_reached` (the Session's cap of open tool lines), `closed`, `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.

P2 create cancellation. Problem: the cell says an admitted creation is not abandoned, then says a cancelled creation is rolled back before the reply. Failure: an implementer cannot tell whether a cancel stops the wait or the build, so the line may publish or roll back and a slot may leak. Evidence: crates/dim-agent-capabilities/src/timeline_tree.rs:2624 stops the wait and lets the build continue; docs/design/timeline-branches.md:194 keeps the reservation and slot. Fix: state which one a cancel stops, whether the slot is released, and when branch/create-failed is written.

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 c5bba3d. TimelineTree.md:127, :154 and :161 state that a cancel stops only the wait: before admission nothing is reserved, and an admitted build publishes and keeps its slot. The code at timeline_tree.rs:2621-2626 matches.

Comment thread docs/design/plugins/TimelineTree.md Outdated
| --- | --- | --- | --- | --- | --- |
| `create` | Open a line at a cut of its parent | `{parent, cut, prompt, source, idle_notice?}` | `{line}` | While the line is admitted and built; an admitted creation is not abandoned and a cancelled one is rolled back before the reply | `invalid_parent` (no such line), `parent_ended`, `invalid_cut` (over the parent's head, or not an atomic-batch boundary), `not_opener` (this line may not open one), `limit_reached` (the Session's cap of open tool lines), `closed`, `cancelled` |
| `end` | End a line and settle it | `{line, source, final?}` | `{}` | None: an admitted end settles even if the caller goes away | `unknown`, `already_ended`, `protected` (the root, the default line, or an ancestor of the default line), `final_undelivered` (the line ended and its final message is still owed; a later end retries delivery only), `closed` |
| `set_default` | Move the conversation to a line | `{line, source}` | `{default}` | None: the move is one commit | `unknown`, `already_default`, `not_selectable` (a plugin line, a line that is ending, or a line whose chain is ending), `closed` |

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.

P2 set_default ended target. Problem: the error list has no kind for an ended line. Failure: a client moves to an ended line from directory and the implementer must invent a kind; returning unknown makes the client treat an existing line as never seen. Evidence: crates/dim-agent-capabilities/src/timeline_tree.rs:2000-2006 answers BranchEnded for an ended target; docs/design/timeline-branches.md:383 keeps branch_target_protected for an ending chain. Fix: add already_ended and protected to set_default, or extend not_selectable to ended lines and say so in the next-action 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 c5bba3d. TimelineTree.md:129 now gives an ended target branch_ended and keeps branch_target_protected for a target or ancestor that is still ending.

Comment thread docs/design/plugins/TimelineTree.md Outdated
| `limit_reached` | End an open tool line, or open on a line whose chain is protected |
| `unknown` | `line` or `read` named an id this Session never had; read `directory` for the lines in force |
| `already_ended` | Nothing happened; read the line with `read` |
| `protected` | The root, the conversation line and its ancestors cannot end; move the conversation first |

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.

P2 protected next action. Problem: the row includes the root and says move the conversation first. Failure: moving the conversation never makes the root endable, so the caller retries and fails again. Evidence: crates/dim-agent-capabilities/src/timeline_tree.rs:1918-1920 answers the root with an input error; docs/design/timeline-branches.md:774 says the end checks only the target. Fix: split the root refusal or state that the root never ends; keep the move advice for the default line and its ancestors.

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 c5bba3d. TimelineTree.md:128 and :145 split the root (branch_cannot_end, it never ends) from the conversation line and its ancestors, which need the move.

Comment thread docs/design/plugins/TimelineTree.md Outdated

| Rule | Application |
| --- | --- |
| §1 parts and Capabilities | TimelineTree is one Session part and three branch parts (TreeTimeline, BranchLine, BranchTool in their own documents). TimelineTree writes Timeline facts and folds no state from them: not a Capability. |

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.

P2 part count. Problem: this row counts BranchTool as a branch part. Failure: the scope split and the part list disagree, and the implementation plan mounts BranchTool in the wrong scope. Evidence: BranchTool.md:3 says Scope: Session; the README row puts it in the Session part column; :190 counts only TreeTimeline and BranchLine. Fix: say one Session part (TimelineTree) and two branch parts, with BranchTool a separate Session part.

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 c5bba3d. TimelineTree.md:205 and README.md:56-57 now count one Session part (TimelineTree), two branch parts (TreeTimeline and BranchLine), and BranchTool as its own Session part.

Comment thread docs/design/plugins/BranchLine.md Outdated

| Operation | Intent | Request | Reply | Cancellation | Errors |
| --- | --- | --- | --- | --- | --- |
| `state` | One line's role, parent, end state and read cursors | `{line}` | `{role, parent?, ending, cursors: [{target, cursor}], blocked}` | None: a read of the owner's folded state | `unknown` (no directory record), `closed` |

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.

P3 state request. Problem: the per-line service takes a line argument in the table and binding, while the caller example calls state() with none. Failure: the caller and the operation disagree; a foreign caller must supply a redundant id. Evidence: BranchLine.md:37, :65 and :167. Fix: drop line from state or pass it in the example; keep one 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.

Partially fixed. BranchLine now publishes view with an empty request (BranchLine.md:68), but BranchTool.md:24, :26 and :54 still call branchLine.state, and LineView has no cursor method for the examples at :55 and BranchLine.md:47.

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 6d0162b. BranchTool.md:24, :26 and :54 use view; :55-57 and BranchLine.md:47 look up cursors. The remaining difference is the if line.ending early refusal at BranchLine.md:44-46, reported in the body.

Comment thread docs/design/plugins/BranchLine.md Outdated
| --- | --- |
| §1 parts and Capabilities | BranchLine is one branch part and a Capability: it folds its own committed facts and writes its own keyed blocks. |
| §2 scopes | Branch scope: role, roster, cursors and notes belong to one line and end with it. |
| §3 orthogonality | It reads its own facts and the directory record; it writes only its own 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.

P3 writes only its own line. Problem: the rule check says BranchLine writes only its own line, but :17 has it write the idle notice and ended notice to its opener. Failure: the orthogonality check misses a cross-line write. Evidence: docs/architecture/rust-agent/plugins/BranchTool.md:169-170 describes the ended notice on the opener; docs/design/timeline-branches.md:417 has the opener's BranchLine write the roster and notice. Fix: say it writes its own line and its opener's input for the notices, and check that relation.

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 c5bba3d. BranchLine.md:84 and :118 now separate writing its own line from steering its opener: the ended notice is written by the opener's own BranchLine, and the idle notice goes through the opener's input 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 in 6d0162b. BranchLine.md:91 still says the idle and ended notices are both written into the opener's line through line_owner, while rule check :119 and timeline-branches.md:417-418 assign the ended notice to the opener's own BranchLine. The code agrees with the latter: the idle notice goes to the parent (crates/dim-agent-capabilities/src/timeline_tree.rs:4663-4677), the ended notice to self.own (:4797-4828). Reported in the body.

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 c80f8e1. BranchLine.md:19, :87 and :94 now separate the own-line writes from the idle steer: only the idle notice crosses into the opener's input owner, and the ended notice and roster retirement stay on the opener's own line.

Comment thread docs/design/plugins/BranchTool.md Outdated
| Read what a line did, continuing where the last read stopped | No: the continuation is the calling line's cursor, owned by BranchLine; the page boundaries and the rendering are the tool's | `branchLine.state`, `timelineTree.read` |
| End the calling tool line with its last word | No: the end and the last word are one settled operation | `timelineTree.end` |
| Learn what the calling line may do | No: role and parent are BranchLine's fold | `branchLine.state` |
| Check that a target belongs to the pair before messaging or reading it | No: the record's parent and source decide it | `timelineTree.directory` with `{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.

P3 wrong operation. Problem: directory takes {} and line takes {line}; this row names directory with {line}. Failure: an implementer cannot check the target pair from the named call. Evidence: TimelineTree.md:129-130. Fix: timelineTree.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.

Fixed in c5bba3d. BranchTool.md:27 now names timelineTree.line with {line}.

Comment thread docs/design/plugins/BranchTool.md Outdated

### Errors

| Code | What the model does next |

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.

P2 error mapping. Problem: the table has no code for final_undelivered, parent_ended, invalid_cut, beyond_head, not_batch_boundary or closed, although the flows at :108-111 answer closed. Failure: refusal_from_line_error has no defined mapping; a model gets invalid for a state it can act on, or no code for a delivered state. Evidence: TimelineTree.md:126-131. Fix: add the owner errors with the model's next action, especially final_undelivered.

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.

Partially fixed. BranchTool.md:98-110 now maps final_undelivered, invalid_cut, beyond_head, not_batch_boundary and closed, but cancelled is still absent although the create flow at :116 answers it. The precedence between final_undelivered and branch_ended is also still undefined; reported separately.

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.

Partially fixed in 6d0162b. cancelled is now at BranchTool.md:112, and final_undelivered, invalid_cut, beyond_head, not_batch_boundary and closed are mapped. Still missing: branch_target_protected (TimelineTree.md:128), which the current tool returns through kind.code() at crates/dim-agent-capabilities/src/timeline_tree.rs:5558-5561. unknown (TimelineTree.md:131-132) is either converted to branch_not_kin at the pair check or missing; the contract should say which.

Comment thread docs/design/plugins/README.md Outdated
| Plugin | Process part | Session part | Branch part | Phase / issue |
| --- | --- | --- | --- | --- |
| [Migration](Migration.md) | on-demand import tasks, source mappings, progress and retry records; unloaded after settlement | — | — | [Delivery plan](../../plan/analysis/legacy-migration.md) |
| [TimelineTree](TimelineTree.md) (owner contract) | — | the line directory, line lifecycle and default line behind the `timelineTree` operations; the model's `branch` tool ([BranchTool](BranchTool.md)) | one line's own view, roster and notices ([BranchLine](BranchLine.md)); the route from a line's facts to the directory ([TreeTimeline](TreeTimeline.md)) | [#2024](https://github.com/arcships/dim/issues/2024) |

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.

P3 scope index. Problem: the new index row is added, but the By scope table at :56-57 is not updated. Failure: the index and the scope summary disagree; a reader looking up Session or branch parts does not find TimelineTree, BranchTool, BranchLine or TreeTimeline. Evidence: README.md:12 and :56-57. Fix: add the parts to the By scope 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 c5bba3d. README.md:56-57 now lists TimelineTree and BranchTool under Session parts and TreeTimeline and BranchLine under branch parts.

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head c5bba3dec。请复审。

P1

  1. 最终消息的写者与次序。 按接受的设计保留 TimelineTree 为写者:branch/end 携带最终消息,交付给父行在作用域关闭之前、在父行的 branch/ended 之前;停在任何一步都只有一个状态,restore 用同一 submission id 补齐一次。final_undelivered 留在 end 的错误里,重试只补消息;流程、异常与验证同这一条。
  2. Weak 句柄。 新增 TreeHandle(Weak<TimelineTree>),在本所有者创建时构建,交给本所有者的两个分支部件;BranchLine 与 TreeTimeline 的依赖改为 S:TreeHandle,并写明「树持有行的作用域、作用域持有部件,强引用成环,close 无法结算」与「树不在时答 closed」。TreeHandle 不是公开面。

P2

  1. create 的取消。 取消只停止等待准入:准入之后构建继续、行发布、槽位不释放、不再收费;branch/create-failed 只在确定性失败时写并释放槽位。操作表、错误(cancelled 的下一步)、流程与验证统一到这个规则。
  2. BranchLine 的依赖。 补 B:InputQueue(自己的行的输入入口)与 S:GuideEntries,列出四个 marker(<dim-branch-lines>、<dim-branch-message>、<dim-branch-idle>、<dim-branch-ended>);状态注记的文本归 BranchLine,TimelineTree 只记录迁移。
  3. 状态注记的写者。 树只排队迁移;BranchLine 排空并写 keyed note。三处表述(职责、流程、异常)统一。
  4. 错误契约。 set_default 补 branch_ended(目标已结束)与 branch_target_protected(目标或祖先在结束);branch_cannot_end 的下一步写明「根永不结束,其余先移动对话行」;LineError 加 serde(#[serde(tag = "code")]),wire code 与错误表一一对应;BranchTool 的码表补上 branch_ended、invalid_cut、beyond_head、not_batch_boundary、continuation_without_cutoff、final_undelivered、closed。
  5. line_owner 的可用面。 按 ADR 027 改为「分支组的任何数据面,除登记点与生命周期服务」;两族限制删除;TimelineTree.md 的请求表行与示例都改为直接调用所有者操作(inputQueue.submit、contextUsage.read、approval.pending)。
  6. 部件计数。 §1 改为:TimelineTree 一个 Session 部件、TreeTimeline 与 BranchLine 两个分支部件、BranchTool 另一个 Session 部件;README 的 index 行与 By scope 表同步。
  7. 绑定附录。 去掉 ReadLines 重复的 scope;LineError 加 serde 与 code;BranchLine 的回复类型改名 LineView 并定义 LineViewError;fields 在操作表与结构体里都改为可选。

Minor

  • BranchTool 的亲属检查改走 timelineTree.line。
  • BranchLine 的 view 请求改为 {}(该操作跑在本行的服务上);写明「写自己的行」与「用 line_owner::<InputQueue> 给开行方写通知」。
  • SessionScope.md 与 ADR 027 都改成 PR 链接(docs(design): target contracts for the Session scope and its host ports #2093、docs(principles): add owners and operations #2029)。
  • README 的 By scope 表补四个部件。
  • 上限:归 BranchTool 的配置,TimelineTree 在预留锁内计费,引用 §6.1。
  • TreeTimeline 标为 Capability(按 §5 的部件表)。
  • §7 的三行子标签合并成一行 §7。
  • PR 描述与交付评论的「五个操作」改为六个。
  • line 不再声称回答预留:预留在发布前答 unknown,并写进 Client-visible changes 的唯一收窄。

Supersedes / 现有文档(规则 C)。 四份契约都加了「Supersedes」与「Client-visible changes」。改动只限描述本所有者的段落:timeline-branches.md 顶部迁移说明与 §10 的 TreeCommands.end 拼写;runtime-owner-operations.md 的 timelineTree 行、call 行与按行 id 的操作行;service-faces.md §3.3 的别名行;plugin-contract.md 的 Session 机制服务、Session→分支方向、treeCommands 行与 TimelineTreeControl 句;branch-typescript.md 的绑定行与两处 treeCommands 引用。已接受的 ADR 未改。

检查:node scripts/adr-check.mjs --base origin/main、cargo run --locked -p xtask-check 通过。

@eric8810
eric8810 requested a review from yyhhyyyyyy November 23, 2026 13:33

@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: the line directory owner contracts for #2024, with the mechanism requirement tracked in #2025 and the owner-redesign rules in #2015; the rule source is section 7 of #2029. Second review at c5bba3d, delta over cf2fec0.

Verdict: REQUEST_CHANGES. Both round-1 P1s are fixed: TimelineTree now owns the final message and orders it before close and before branch/ended, and the branch parts hold a weak handle. Most P2s are fixed too. What remains blocks implementation: the binding appendix still cannot produce the documented data face, BranchTool calls an operation BranchLine no longer has, final_undelivered has no defined precedence, and one changed contract file still specifies the forwarding call it says is removed.

Round 1 status:

  • Fixed: final message writer and order (TimelineTree.md:16, :162, :171, :182; the code matches crates/dim-agent-capabilities/src/timeline_tree.rs:2397-2448); weak access (TimelineTree.md:175, BranchLine.md:62, TreeTimeline.md:37); create cancellation (TimelineTree.md:127, :161; code at timeline_tree.rs:2621-2626); input owner and GuideEntries (BranchLine.md:59-61, :19); status note writer (TimelineTree.md:163, :174); line_owner families (TimelineTree.md:94); part count (TimelineTree.md:205, README.md:56-57).
  • Fixed round-1 P3s: the README scope row, BranchTool's target lookup (BranchTool.md:27), the cap's ownership (TimelineTree.md:15), TreeTimeline as a Capability (TreeTimeline.md:80), the six-operation count (PR body and TimelineTree.md:125-132), and the reservation state (TimelineTree.md:134).
  • Partially fixed: the error contract (LineError serde and the BranchTool mapping), the binding appendix (types and serde), and BranchTool's caller shape (state vs view).
  • Still open: SessionScope and ADR 027 are only in #2093 and #2029.

Findings

P1

None.

P2

  1. runtime-owner-operations.md still defines the removed call. Problem: :7 says the timelineTree.call operation is superseded, but :30-36 still has TimelineTree resolve the live branch and dispatch a tagged union, and says batch input continues to use the tree's methods. Failure: an implementer rebuilds the forwarding facade that section 7 forbids, and a caller uses a request shape the new contract does not have. Evidence: TimelineTree.md:127-132 has neither a call nor an input; #2093 rewrites this same section with line_owner, so whichever lands second must reconcile. Fix: replace :30-42 with the line_owner text or leave the section to #2093, and change :44 from directory({id:"main"}) to line("main") or the new directory read.

  2. BranchTool names an operation BranchLine retired. Problem: BranchTool.md:24, :26 and :54 call branchLine.state and .state(), while BranchLine.md:68 publishes only view with an empty request and :105 says one view replaces the old reads. The examples also call LineView::cursor (:55, BranchLine.md:47), but the published value has cursors and defines no cursor method (:169-179). Failure: the tool cannot compile against the owner, and a foreign caller looks for a removed operation. Fix: call view().await, look the cursor up in cursors, and add the helper to the binding or to the example.

  3. The binding appendix does not compile or serialize. Problem: TimelineTree.md:237 imports IdleNotice from dim_agent_types, but it is the private enum at crates/dim-agent-capabilities/src/timeline_tree.rs:3491; :318 uses dim_agent_types::TimelineEvent, which does not exist (the event type is AgentEvent); :324 tags LineError internally although most kinds are newtype variants over primitives, and serde rejects a tagged newtype variant containing a primitive. BranchLine.md:182 has the same error shape. Failure: the appendix cannot be implemented, and the first refusal fails to serialize, so rutis answers without the documented code. Fix: declare the idle-notice wire enum, use AgentEvent or QueryEvent, and give the error variants named fields or use tag plus content.

  4. final_undelivered has no precedence and the tool cannot retry. Problem: TimelineTree.md:128 lists branch_ended (already ended) and final_undelivered (the line ended and its message is owed), and :149 says the line is ended in the second case too, so an ended line answers either code. BranchTool.md:102 maps the calling line's own end to branch_ended and :119 says an owed message answers final_undelivered and is retried, but the tool returns branch_ended as soon as own.ending is true (crates/dim-agent-capabilities/src/timeline_tree.rs:5529-5533) and never calls the tree. Failure: after a failed delivery a later end action reports branch_ended, the message stays owed, and only restore delivers it. Fix: define that final_undelivered wins while an end is recorded and its message is owed, call that state ending rather than ended, and let the tool's end path reach the tree or drop the retry claim.

P3

  • Link defects. Problem: service-faces.md:117 links ../plugins/TimelineTree.md, which resolves to docs/plugins; TimelineTree.md:15 links #61-the-cap but the heading is 6.1 Resources and limits; BranchLine.md:105 points the branchLine section at the TimelineTree plugin page, but the section is in BranchTool.md#branchline. Failure: the changed pages link to a missing file, a missing anchor and the wrong page. Fix: use plugins/TimelineTree.md, #61-resources-and-limits, and the BranchTool page.

  • Forward references to unmerged contracts. Problem: plugin-contract.md:70 links docs/adr/027-cross-scope-access-by-id.md, which arrives with #2029; TimelineTree.md:111, :227, :229, BranchLine.md:138 and BranchTool.md:171 depend on SessionScope from #2093. Failure: if this lands first, main has a broken relative link and cites a mechanism that does not exist. Fix: use the PR URLs, or state the owning PR and what main has until it lands.

  • Stale request and reply shapes. Problem: timeline-branches.md:381 writes timelineTree.end(id, source) while the new request is {line, source, finalMessage?} (TimelineTree.md:128); TimelineTree.md:316-320 requires both events and rows while :132 says the reply is one or the other. Failure: a reader implements a shape the contract does not define. Fix: use the request object, and make the reply an enum or state that both fields are present with one empty.

  • Wrong client method name. Problem: TimelineTree.md:197 and :199 say session.branch_get; the method is session.branch.get (crates/dim-app-server/src/protocol.rs:1072). Failure: the section that claims no client-visible names change names a method no client has. Fix: use session.branch.get in both places.

  • Incomplete BranchTool error table. Problem: BranchTool.md:94 says every kind the owners answer maps onto a code, but the create flow at :116 answers cancelled and the table has no cancelled row. Failure: refusal_from_line_error has no defined result for a cancelled admitted create. Fix: add the code and its next action, or state that a cancelled call has no result.

  • Cancellation scope in TreeTimeline. Problem: TreeTimeline.md:66 says a child that was never published is cancelled on unload; cancel_pending removes only reservations whose build has not started (crates/dim-agent-capabilities/src/timeline_tree.rs:2683-2685), so an in-flight build is awaited and publishes. Failure: an implementer documents or builds a rollback the code does not perform. Fix: say a reservation that was never dispatched is cancelled; an in-flight build finishes.

Verification: HEAD c5bba3d, merge-base 1bc7d67. node scripts/adr-check.mjs --base 1bc7d67d7e3b357a64fd82c2589f57e4cb4b4bec passed on 10 changed files. A relative link and anchor check over the changed files found the link defects above. gh pr checks 2092 shows ci-ok pass and changes pass, docs-only jobs skipped. No full build was run.

| Caller → owner | Final API |
| --- | --- |
| Branch management, input and history callers → `timelineTree` | `create/end/info/input/list/page/query` retain their existing signatures on the single Session tree face. Creation returns the branch ID. |
| Line directory, lifecycle and history callers → `timelineTree` | The tree's face is [TimelineTree](../plugins/TimelineTree.md): `create`, `end`, `set_default`, `directory`, `line`, `read`. This table's `timelineTree` rows below, and the `timelineTree.call` operation, are superseded. |

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.

P2 stale call section. Problem: this row says the timelineTree.call operation is superseded, but the section at :30-36 still defines that call: TimelineTree resolves the live branch and dispatches a tagged union, and batch input continues to use the tree's methods. Failure: an implementer keeps the forwarding facade section 7 forbids, and a Session caller sends an operation-name request the new contract does not have. Evidence: :30-36, and TimelineTree.md:127-132, which has neither a call nor an input; #2093 rewrites this same section with line_owner, so whichever lands second must reconcile. Fix: replace :30-42 with the line_owner text or defer the section to #2093, and change :44 from directory({id:"main"}) to line("main") or the new directory 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 6d0162b. runtime-owner-operations.md:30-34 now states line_owner::<T>(line), no timelineTree.call and no tag union; :42 uses line("main").head. The only residue is :7, which still says the rows below and the removed call are superseded (P3).

Comment thread docs/design/plugins/BranchTool.md Outdated
| --- | --- | --- |
| Open a line to work on a part of the task | No: the cut is the calling request's own start, which the tool reads from its execution context | `timelineTree.create` |
| Send a line a message or a last word | No: the write belongs to the target line's input owner; the tool decides the kin rule | Target line's input owner by id, with the mode the tool chose |
| Read what a line did, continuing where the last read stopped | No: the continuation is the calling line's cursor, owned by BranchLine; the page boundaries and the rendering are the tool's | `branchLine.state`, `timelineTree.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.

P2 caller shape. Problem: this row and :26 route to branchLine.state, and the example at :54 calls .state(), but BranchLine now publishes only view with an empty request (BranchLine.md:68) and says one view replaces the old reads (:105). The examples also call LineView::cursor (:55, BranchLine.md:47), while the published value exposes cursors and defines no cursor method (:169-179). Failure: BranchTool cannot call the operation it names, and a foreign caller builds against an operation the owner retired. Fix: use view().await and look the cursor up in cursors, and add the helper or the lookup to the example.

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 6d0162b. BranchTool.md:24, :26 and :54 use branchLine.view; :55-57 and BranchLine.md:47 look the cursor up in cursors. No branchLine.state or LineView::cursor remains.

Comment thread docs/design/plugins/TimelineTree.md Outdated

- **The line directory.** Every line's id, parent, cut, source, state (open, ending, ended), head and end event, and the line the Session's conversation is on. One read answers the default together with the whole directory, so a client never pairs a default from before a move with a directory from after one.
- **A line's beginning.** The cut's validity, the caller's eligibility, building the branch scope, publishing it, and the opening blocks the child starts with — identity, the retired roster, the parent block — written where the child has no owner yet.
- **The line cap's enforcement.** The cap is BranchTool's configuration ([timeline branches §6.1](../../design/timeline-branches.md#61-the-cap)); this owner charges it, together with the caller's eligibility and the admitted reservations, in the one lock that reserves the line, counting the open tool lines outside the conversation line's chain.

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.

P3 broken anchor. Problem: #61-the-cap is not a heading in timeline-branches.md; the heading is ### 6.1 Resources and limits. Failure: the link lands at the top of the page, not the cap rule, so a reviewer cannot check the limit's owner. Fix: link #61-resources-and-limits.

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 6d0162b. TimelineTree.md:15 now links #61-resources-and-limits, the heading at timeline-branches.md:174.

Comment thread docs/design/plugins/TimelineTree.md Outdated
| Operation | Intent | Request | Reply | Cancellation | Errors (codes) |
| --- | --- | --- | --- | --- | --- |
| `create` | Open a line at a cut of its parent | `{parent, cut, prompt, source, idleNotice?}`, `cancelled` | `{line}` | The caller's cancel stops only the wait for admission: a creation that was admitted builds and publishes, keeps its slot, and answers nothing to a caller that left; before admission nothing is reserved and the reply is `cancelled` | `invalid_parent`, `branch_ended` (the parent ended), `invalid_cut` (over the parent's head, or not an atomic-batch boundary), `branch_not_opener`, `branch_limit_reached`, `cancelled`, `closed` |
| `end` | End a line and settle it | `{line, source, finalMessage?}` | `{}` | None: an admitted end settles even if the caller goes away | `unknown`, `branch_ended` (already ended), `branch_cannot_end` (the root never ends; the conversation line and its ancestors need a move first), `branch_target_protected` (the target or an ancestor is ending), `final_undelivered` (the line ended and its final message is still owed; a later `end` retries delivery only), `closed` |

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.

P2 final_undelivered precedence. Problem: the row lists branch_ended (already ended) and final_undelivered (the line ended and its final message is still owed), and :149 says the line is ended in the second case too, so the same state answers either code. BranchTool.md:102 maps the calling line's own end to branch_ended, and :119 says an owed message answers final_undelivered and is retried; the tool's current end path returns branch_ended as soon as own.ending is true (crates/dim-agent-capabilities/src/timeline_tree.rs:5529-5533), before the tree can retry. Failure: after a failed delivery, a later end action reports branch_ended, the message stays owed, and only restore delivers it. Fix: state that final_undelivered wins while delivery is owed, call that state ending rather than ended, and make the tool's end path distinguish the two or drop the retry claim.

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.

Partially fixed in 6d0162b. The branch_ended versus final_undelivered precedence is explicit at TimelineTree.md:134, :141 and :149, and BranchTool.md:122 calls the tree on an ending line. Still open: (a) TimelineTree.md:128 and :146 still give branch_target_protected for a target that is ending, the same state as an owed message; (b) timeline-branches.md:397 and :460 still say a second end takes branch_ended and restore delivers, and :381 still requires the target to be open; (c) BranchLine.md:44-46 still returns branch_ended as soon as ending, so the tool never reaches the tree. Reported in the body.

Comment thread docs/design/plugins/TimelineTree.md Outdated

## Client-visible changes

None to names, fields or error codes: `session.branches`, `session.branch_create`, `session.branch_end`, `session.branch_set_default`, `session.branch_get`, `session.history` and `session.model.get` keep their method names, request and reply fields, and the `branch_*` codes. The App Server maps the kinds above onto the codes it answers 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.

P3 method name. Problem: the method is session.branch.get (crates/dim-app-server/src/protocol.rs:1072), not session.branch_get; the same wrong name is at :199. Failure: the section that claims no client-visible names change names a method no client has, so a reader checking the claim finds a mismatch. Fix: use session.branch.get in both places.

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 6d0162b. TimelineTree.md:197 and :199 now use session.branch.get, which is in the method table at crates/dim-app-server/src/protocol.rs:976 and dispatched at :1072.

Comment thread docs/design/plugins/TimelineTree.md Outdated

/// Every kind the owner answers, tagged by the wire code.
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, thiserror::Error)]
#[serde(tag = "code", rename_all = "snake_case")]

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.

P2 error wire shape. Problem: the enum is internally tagged, but most kinds are newtype variants over a primitive: InvalidParent(String), Unknown(String), NotBatchBoundary(u64) and the others. Serde rejects a tagged newtype variant containing a primitive, so serialization fails and rutis falls back to no code. BranchLine.md:182 has the same shape for LineViewError. Failure: a caller that should get invalid_parent or unknown gets a framework failure without the documented code. Fix: give every variant named fields, or use #[serde(tag = "code", content = "data")] and keep the message on the display side.

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 6d0162b. Every primitive newtype variant now has named fields at TimelineTree.md:334-367, so #[serde(tag = "code")] serializes; BranchLine.md:180-187 has the same shape for LineViewError.

Comment thread docs/design/service-faces.md Outdated
| `loader` | `rutis/loader` | 插件管理走数据面 |
| `sessionStore` | `store`、`sessionFiles`、`timelineStore` | 标题与 worktree 关联直接调 store |
| `treeCommands`、`timelineTreeControl` | `timelineTree` | 分支操作直接调用 Session 的树;不保留别名 |
| `treeCommands`、`timelineTreeControl` | `timelineTree` | 已按 [TimelineTree](../plugins/TimelineTree.md) 收敛:两个名字删除,`timelineTree` 是树唯一的数据面 |

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.

P3 broken link. Problem: from docs/design/service-faces.md, ../plugins/TimelineTree.md resolves to docs/plugins/TimelineTree.md; the page is docs/design/plugins/TimelineTree.md. Failure: the changed row links to a missing file. Fix: plugins/TimelineTree.md.

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 6d0162b. service-faces.md:117 now links plugins/TimelineTree.md, which resolves from docs/design/service-faces.md.

Comment thread docs/design/plugin-contract.md Outdated
| --- | --- |
| Up (an enclosing instance, the process) | Inject the service by name |
| Down (Session to branch) | `treeCommands`: input by branch id, branch creation. Never by injecting a branch service |
| Down (Session to branch) | `line_owner::<T>(line)`: resolve the line to the branch scope's service and call that owner's own operation ([ADR 027](../adr/027-cross-scope-access-by-id.md)); registration points and the lifecycle services stay out ([TimelineTree](plugins/TimelineTree.md)) |

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.

P3 forward link. Problem: ../adr/027-cross-scope-access-by-id.md does not exist on main; ADR 027 is added by #2029. Failure: this lands with a broken relative link and cites a rule that is not in the tree. Fix: use the #2029 PR URL as the other changed files do, or land after #2029.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Fixed in 6d0162b. plugin-contract.md:70 now links the #2029 PR URL instead of the missing docs/adr/027 file.

Comment thread docs/design/timeline-branches.md Outdated
`ancestor` names the line whose own end started the cascade: the end that carries no `ancestor` of its own. Every descendant the cascade ends carries that line, `source` is copied from that same end, and the pair therefore names one end operation: who asked, and on which line. A line ended at its own request has a `source` and no `ancestor`, and a descendant whose own end was already committed keeps that pair when the cascade reaches it. `branch/ended` copies `source` and `ancestor` from the line's `branch/end`, and is always written on the ending line's own parent, taken from the directory.

**A general operation.** `TreeCommands.end(id, source)` and `Session::end_branch(id, source)` check only the target: it exists, it is open, it is not the root, it is not the default branch, and it is not an ancestor of the default branch. Ending the root would close the Session, and ending a line ends every line below it, so the default branch's whole chain is protected. These checks are about the target, not the caller. They never check who calls: the user, an opener and a plugin meet the same guards, and ending the default branch always takes a move of the default branch first.
**A general operation.** `timelineTree.end(id, source)` and `Session::end_branch(id, source)` check only the target: it exists, it is open, it is not the root, it is not the default branch, and it is not an ancestor of the default branch. Ending the root would close the Session, and ending a line ends every line below it, so the default branch's whole chain is protected. These checks are about the target, not the caller. They never check who calls: the user, an opener and a plugin meet the same guards, and ending the default branch always takes a move of the default branch first.

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.

P3 stale signature. Problem: the new contract's end request is {line, source, finalMessage?} (TimelineTree.md:128) and the binding takes EndLine; timelineTree.end(id, source) keeps the old positional shape. Failure: a reader implements the line the accepted document names, not the operation this PR defines. Fix: use timelineTree.end({line, source, finalMessage?}) or mark the sentence as the pre-redesign binding like the header does.

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 6d0162b. timeline-branches.md:460 now writes timelineTree.end(EndLine { line, source, final_message }). The sentence still carries the branch_ended rule that conflicts with the new retry; reported in the body.

Comment thread docs/design/plugins/TreeTimeline.md Outdated
## Exceptions with reasons

- The routing crosses two scopes inside one owner: the subscription must live in the branch scope, while the reservation table and the directory are the Session's. `Weak` access to the tree keeps the branch scope from owning the tree, which the tree already holds through this line's scope.
- An accepted creation need not survive this line's unload: a child that was never published is cancelled with its waiters, and a published child is the tree's.

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.

P3 cancellation scope. Problem: cancel_pending on a line's unload removes only reservations whose build has not started (crates/dim-agent-capabilities/src/timeline_tree.rs:2683-2685); a started build is awaited and publishes. The sentence says a child that was never published is cancelled, which includes an in-flight build. Failure: an implementer cancels a started build, or documents a rollback the code does not perform. Fix: say a reservation that was never dispatched is cancelled; an in-flight build finishes.

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 6d0162b. TreeTimeline.md:51 and :66 now say a reservation never dispatched is cancelled and an in-flight build is awaited; this matches cancel_pending at crates/dim-agent-capabilities/src/timeline_tree.rs:2683-2685.

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审与自查标准修改,head 6d0162bfc。请复审。

评审逐条

  1. P2 runtime-owner-operations.md 仍在定义 call。 该文件的「Calls from a Session to a selected branch」整节替换为 line_owner::<T>(line) 的说明:不再有 tagged union、转发表与请求信封,每行都是目标所有者自己的操作;directory({id:"main"}) 改为 line("main")。TimelineTree.md 的 Supersedes 同步列出这一节。
  2. P2 BranchTool 用了 BranchLine 已删的 state。 依赖、要求表、示例都改为 view();游标改为从 view().cursors 里查找,不再调用 LineView::cursor(该类型没有这个方法)。
  3. P2 绑定附录不可编译。 IdleNotice 在附录里声明为线上枚举(steer/none);事件类型改为 dim_agent_types::AgentEvent;ReadReply 改为 #[serde(untagged)] 的 Events { .. } / Rows { .. } 两种之一;LineError 与 LineViewError 全部改为命名字段变体,内部 tag code 因而可序列化。临时 crate(rutis 0.23 + dim-agent-types + dim-agent-runtime,未提交)cargo check 与两条 wire 测试通过:branch_target_protected、branch_limit_reached、closed 的 code,以及 ReadReply 只带一侧字段。
  4. P2 final_undelivered 没有优先级。 定义:行的 branch/end 已记录但作用域未关或最终消息未送达时,状态是 ending;end 在欠消息时一律答 final_undelivered(可重试,只补投递),消息送达且作用域关闭后才转 ended 并答 branch_ended。BranchTool 的 end 在调用行已记录结束时仍调用树的 end,据此映射。
  5. P3 链接。 service-faces.md 的路径改为 plugins/TimelineTree.md;#61-the-cap 改为 #61-resources-and-limits;BranchLine 的 Supersedes 指向 BranchTool.md#branchline。
  6. P3 前向引用。 ADR 027 与 SessionScope 都改成 PR 链接(docs(principles): add owners and operations #2029、docs(design): target contracts for the Session scope and its host ports #2093);line_owner 的机制需求链接 #2127,并注明 Session 一侧在 docs(design): target contracts for the Session scope and its host ports #2093。
  7. P3 形状。 timeline-branches.md §10 的 timelineTree.end(id, source) 改为请求对象;ReadReply 改为枚举(见第 3 条)。
  8. P3 客户端方法名。 session.branch_get 改为 session.branch.get(protocol.rs 的 "session.branch.get")。
  9. P3 BranchTool 错误表缺 cancelled。 补该行:准入后的创建没有工具结果、行仍发布;并说明未准入时什么也没发生。
  10. P3 TreeTimeline 的取消范围。 改为「未派发的预留取消并结算等待者;已开始的构建会完成并发布」。

自查(第 1–3、7 节)

  • 代码/契约/调用方断言逐条对照源文件:IdleNotice 私有于 timeline_tree.rs、QueryRow 在 dim-agent-runtime、AgentEvent 在 dim-agent-types、CancelledFn 的别名在 host.rs、session.branch.get 在 protocol.rs、branch/get 的树侧操作在 timeline_tree.rs。
  • 与现有文档的冲突在本 PR 内解决:runtime-owner-operations.md、service-faces.md、plugin-contract.md、timeline-branches.md、branch-typescript.md 的相关段落已改;resource-owner-operations.md、resource-faces.md、session-boundary.md、process-owner-operations.md 检索后没有本所有者的段落。
  • Supersedes 逐条在本 PR 内落地:四份契约列出的每一节都已修改(timeline-branches 顶部说明、§5 的 BranchLine 行与 S:TreeCommands、§6 的消息写入、§7.1 的父块写入、§10 的 end、§11 的 end 与 read、branch-typescript.md 的绑定行)。
  • 一个词一个概念:view、line、directory、line_owner、final_undelivered、branch_ended、ending 在四份契约与保留文档中一致;错误表每一行都写明可否重试与下一步(单次、重复调用、对方关闭/重载)。
  • 改名检索:本 PR 改到的 treeCommands 引用已逐处更新;timeline-branches.md 顶部声明其余 TreeCommands 引用是改造前的绑定,§15 的变更表与 §20 的验收条保留为历史记录。
  • ADR 027 的编号:引用按新编号写(D1 直达、D2 运行时路由且不交实例键、D3 只解析数据面),机制需求链接 按 id 调用:由持有实例的一方选目标(base-1) #2127。

客户端可见变更

方法名、请求、回复、错误码、通知名、字段名与取值都不变:session.branches、session.branch.create、session.branch.end、session.branch.set_default、session.branch.get、session.history、session.model.get 保持现有形状,branch_* 错误码由 App Server 按现有映射给出。

唯一收窄(沿用上一轮的声明):行在发布后才出现在 session.branches 与 session.branch.get,预留在发布前没有 head 与 state。持久化格式不变。

检查:node scripts/adr-check.mjs --base origin/main、cargo run --locked -p xtask-check 通过;绑定附录的临时 crate cargo check/cargo test 通过。

@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: the full main...head of ten design docs (+920/-50) at 6d0162b, merge base 1bc7d67. The delta over c5bba3d is eight files (+102/-94). The PR defines the TimelineTree and line-directory owner contracts and retires treeCommands, the TreeTimeline TreeCommands route and the Branch facade.

Verdict: REQUEST_CHANGES. The owner split and the data-face direction are right, and most of the earlier findings are fixed. Three contract contradictions still block implementation: the end retry rule disagrees with the retained design and with the caller example, the ended notice still has two writers, and BranchTool's error table is not complete.

Round status:

  • Fixed in c5bba3d and still fixed: final message writer and order, weak access, create cancellation, input owner and GuideEntries, status note writer, line_owner families, part count, README scope row, BranchTool target lookup, the cap's ownership, TreeTimeline as a Capability, the six-operation count, the reservation state.
  • Fixed in 6d0162b: the runtime-owner-operations call section (:30-34 now states line_owner, :42 uses line("main").head), BranchTool's caller shape (:24, :26 and :54 use view; :55-57 and BranchLine.md:47 look the cursor up in cursors), the binding appendix (IdleNotice at :264-271, AgentEvent at :327, ReadReply at :323-329, named error fields at :334-367, one scope field), the error wire shape and LineError serde, the service-faces link (:117), the §6.1 anchor (:15), the ADR 027 link (:70), the timeline-branches end signature (:460), session.branch.get (:197, :199) and the TreeTimeline cancellation scope (:51, :66).
  • Partially fixed: final_undelivered versus branch_ended (P2 1) and BranchTool's error mapping (P2 3).
  • Still open: the ended notice writer (P2 2). The round-2 reply to 4667100958 said this was fixed; the text still routes both notices through the opener's input owner.
  • Forward references: SessionScope and ADR 027 are now PR URLs, not broken relative links. The dependency remains: #2093 and #2029 are unmerged.

Findings

P2 1. The end retry rule contradicts the retained design and the caller example.

Problem: TimelineTree.md:128, :134 and :149 say an end on a line whose own branch/end is recorded and whose final message is owed answers final_undelivered and retries the delivery; BranchTool.md:122 says the same. timeline-branches.md:460, which this PR edits, still says such an end takes branch_ended and writes no second message, and :397 says an already ended line answers branch_ended. The guard at :381 still requires the target to be open. BranchLine.md:44-46 returns branch_ended as soon as ending is true, so the tool never reaches the tree. TimelineTree.md:128 and :146 also give branch_target_protected for "the target ... is ending", the same state as an owed message.

Failure scenario: a tool line's end commits branch/end and the delivery to the parent fails. The line is ending and its message is owed. A later end meets four rules: the BranchLine example refuses branch_ended; the timeline-branches guard refuses because the line is not open; TimelineTree.md:149 says final_undelivered and a retry; TimelineTree.md:146 says branch_target_protected and stop. The message is retried or not depending on which paragraph the implementer reads, and the tool's own end path cannot be implemented as written.

Evidence: docs/design/plugins/TimelineTree.md:128, :134, :146, :149, :162, :183; docs/design/plugins/BranchTool.md:110, :122; docs/design/plugins/BranchLine.md:44-46; docs/design/timeline-branches.md:381, :397, :460; the current tool's own-end path at crates/dim-agent-capabilities/src/timeline_tree.rs:5529-5533 returns branch_ended before the tree is called.

Fix: choose one rule. If a later end retries: update timeline-branches.md:397 and :460, add the retry exception to the :381 open check, remove the BranchLine.md:44-46 early return, and state that final_undelivered wins over branch_target_protected when the target's own end is recorded and its message is owed; keep branch_target_protected for another end on the target or an ancestor. If delivery is restore-only: remove final_undelivered and the retry claim from TimelineTree.md and BranchTool.md and keep the accepted rule.

P2 2. The ended notice still has two writers.

Problem: BranchLine.md:17, :84 and :91 make this line's BranchLine write both the idle and the ended notices into the opener's line through line_owner::<InputQueue>(opener). The rule check at :119 and the retained design at timeline-branches.md:417-418 assign the ended notice to the opener's own BranchLine on its own line. The code agrees with the latter.

Failure scenario: a tool line is ended from outside. Its scope closes before its parent handles the branch/ended fact, so the child's BranchLine is gone and the ended notice is never written; or an implementer writes it from the closing child scope and it is dropped. The opener learns of the end only from the roster retirement, not from the model-facing notice.

Evidence: docs/design/plugins/BranchLine.md:17, :84, :91, :117, :118, :119; docs/design/timeline-branches.md:417-418; crates/dim-agent-capabilities/src/timeline_tree.rs:4663-4677 (the idle notice is written to parent), :4797-4828 (the roster and dim-branch-ended are written into self.own).

Fix: split the writers in the operations row, the flow, the exception and the rule checks. The idle notice is the idle line's BranchLine steering the opener's input owner. The ended notice is the opener's BranchLine writing its own line from the branch/ended fact. Remove the ended notice from the child-side line_owner sentence, and make :118 and :119 match that split.

P2 3. BranchTool's error table is not complete.

Problem: BranchTool.md:96 says every kind the owners answer maps onto one code, but the table at :98-113 has no branch_target_protected row. The tool's end path calls the tree, and the tree answers branch_target_protected when the target or an ancestor is ending (TimelineTree.md:128); the current tool already returns that code through kind.code() at crates/dim-agent-capabilities/src/timeline_tree.rs:5558-5561. The model next action for it is undefined. unknown from line/read is either converted by the pair check to branch_not_kin or missing, and the contract does not say which.

Failure scenario: a tool line ends while an ancestor's cascade is in flight. The tree answers branch_target_protected; the model receives a code the contract never explains, and may retry the same end or treat a chain end as a field error. A read of an id that was never published or ended between calls can likewise return unknown with no row.

Evidence: docs/design/plugins/BranchTool.md:96, :98-113; docs/design/plugins/TimelineTree.md:128, :131, :132; crates/dim-agent-capabilities/src/timeline_tree.rs:5558-5561.

Fix: add a branch_target_protected row with "stop, an end on the chain wins", and state whether unknown becomes branch_not_kin at the pair check or gets its own row. Then the "every kind" claim is true.

Optional (P3):

  • BranchTool.md:92 and :96 say a refusal writes nothing, but final_undelivered is an error result after branch/end committed, and :122 says the end is accepted. Exempt post-write outcomes from "refusal" or call this one a pending result.
  • BranchTool.md:130 says the refusal codes are unchanged, but :112 adds cancelled and :110 gives final_undelivered a new retry meaning. State the visible additions.
  • TimelineTree.md:197 says no error code changes, but final_undelivered is new and the App Server mapping is not stated. Say whether it maps to branch_ended or is a new client code.
  • TimelineTree.md:161 and :181 rely on a "definitively failed creation" with no error kind. The create errors at :127 and LineError at :334-367 have no build or create-failed variant, while SessionScope's openBranch answers build (#2093). Add the kind or state that a build failure reaches the caller as a framework error.
  • Stale wording: runtime-owner-operations.md:7 still names the removed timelineTree.call; TimelineTree.md:190 lists that operation in Supersedes; branch-typescript.md:204 still labels the link "TimelineTree / TreeCommands"; TimelineTree.md:102 calls submit(steer_input, cancelled) while the current InputQueue::submit takes one argument (crates/dim-agent-capabilities/src/input_queue.rs:235) and BranchTool.md:49 uses one; BranchLine.md:167 says "Named apart from TimelineTree's LineState" for a type named LineView; BranchLine.md:109 says the face "gains one operation" after the supersession of resolved, ending and cursor was removed in this commit; BranchLine.md:60 and plugin-contract.md:62 still name sessionLifecycle while #2093 renames it to sessionScope.

Cross-PR: #2103 InputMethods.md:142 still reads timelineTree.query, which this contract removes. #2100 runtime-owner-operations.md:7 and :36 still define timelineTree.call and the old six operations. #2093's runtime-owner-operations.md:7 and :19-27, plugin-contract.md:62, :70 and :117, and service-faces.md:117 still use the old rows. These need rebasing on their side, not changes here; #2092's face is the newer contract.

Verification: HEAD 6d0162b, merge base 1bc7d67, PR open. node scripts/adr-check.mjs --base 1bc7d67d7e3b357a64fd82c2589f57e4cb4b4bec passed on ten changed files. Relative links and anchors in the changed files resolve; the SessionScope and ADR 027 links are PR URLs. gh pr checks 2092 shows ci-ok pass and changes pass; docs-only jobs are skipped. No full build was run. The binding appendix's referenced types exist (AgentEvent at crates/dim-agent-types/src/events.rs:1317, QueryRow at crates/dim-agent-runtime/src/timeline_query/properties.rs:338, PublicService at crates/dim-agent-runtime/src/scope.rs:46, CancelledFn at crates/dim-agent-capabilities/src/host.rs:1169, BranchSource at crates/dim-agent-types/src/events.rs:1004). I did not rebuild the temporary crate the commit message mentions.

Comment thread docs/design/plugins/TimelineTree.md Outdated
| Operation | Intent | Request | Reply | Cancellation | Errors (codes) |
| --- | --- | --- | --- | --- | --- |
| `create` | Open a line at a cut of its parent | `{parent, cut, prompt, source, idleNotice?}`, `cancelled` | `{line}` | The caller's cancel stops only the wait for admission: a creation that was admitted builds and publishes, keeps its slot, and answers nothing to a caller that left; before admission nothing is reserved and the reply is `cancelled` | `invalid_parent`, `branch_ended` (the parent ended), `invalid_cut` (over the parent's head, or not an atomic-batch boundary), `branch_not_opener`, `branch_limit_reached`, `cancelled`, `closed` |
| `end` | End a line and settle it | `{line, source, finalMessage?}` | `{}` | None: an admitted end settles even if the caller goes away | `unknown`, `branch_cannot_end` (the root never ends; the conversation line and its ancestors need a move first), `branch_target_protected` (the target or an ancestor is ending), `final_undelivered` (the line's own end is recorded and its final message is still owed; the call retries delivery only and answers this until the message lands), `branch_ended` (the line is ended and owed nothing), `closed` |

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.

P2: branch_target_protected is defined here as "the target ... is ending", which is exactly the state where :134 and :149 promise final_undelivered and a retry. The same target therefore has two codes, one saying stop and one saying retry, and the retained design at timeline-branches.md:460 still says a second end is branch_ended and restore delivers. Failure scenario: an end commits branch/end and the delivery fails; a later end is refused as protected before it can retry, or answers final_undelivered and retries, depending on which guard runs first. Fix: keep final_undelivered for the target's own recorded end with an owed message, limit branch_target_protected to another end on the target or an ancestor, and update timeline-branches.md:381, :397 and :460 to the chosen rule.

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 d968023. The restore-only rule is now the single rule: docs/architecture/rust-agent/plugins/TimelineTree.md:130 and :150 answer branch_ended once the target's own end is recorded, :136 and :163 say an owed final message is delivered by restore, and final_undelivered is gone from the contract, the appendix and BranchTool.md. branch_target_protected is limited to an ancestor ending or a cascade that has not recorded the target's own end. timeline-branches.md:397 and :460 already state the same rule. The earlier retry reading is withdrawn.

Comment thread docs/design/timeline-branches.md Outdated
| `read` with an `after` past the target's head | `after A is past line T's head H; a read starts at or below H` | none: an error result with no code |

These refusals are the tool's own rules. `TreeCommands.end` itself checks only the target (§10). An `end` whose line already committed its own `branch/end` takes the `branch_ended` row and writes no second final message: the first call's message is the line's last word. Because the guards, `branch/end` and the delivery are one operation under the tree lock a move also takes, a move that makes the target the default branch first is refused before any message is written, and the refusal above is the whole effect. An end that commits `branch/end` and stops before the delivery is not a second end to answer: the message is recorded in `branch/end` itself, and restore delivers it once (§10).
These refusals are the tool's own rules. `timelineTree.end` itself checks only the target (§10). An `end` whose line already committed its own `branch/end` takes the `branch_ended` row and writes no second final message: the first call's message is the line's last word. Because the guards, `branch/end` and the delivery are one operation under the tree lock a move also takes, a move that makes the target the default branch first is refused before any message is written, and the refusal above is the whole effect. An end that commits `branch/end` and stops before the delivery is not a second end to answer: the message is recorded in `branch/end` itself, and restore delivers it once (§10).

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.

P2: this sentence still gives a second end branch_ended and leaves delivery to restore, while TimelineTree.md:134 and :149 and BranchTool.md:122 now answer final_undelivered and retry the delivery from a later end. The guard above still requires the target to be open, so the new retry cannot pass it. Failure scenario: an end commits branch/end and the delivery fails; a second end takes this row and never retries, or takes the new row only if the tree special-cases a non-open target that this paragraph and :381 forbid. Fix: choose one rule and update this paragraph, :381, :397 and BranchLine.md:44-46 together.

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 d968023. This paragraph already stated the chosen restore-only rule, and the contract now matches it: TimelineTree.md:130, :136, :150, :163; BranchTool.md:104, :123; BranchLine.md:45-46. No change to this paragraph is needed.

LineRole::Main | LineRole::User => { /* opens and reads lines, ends none of them */ }
}
if line.ending {
return refused("branch_ended", &execution.branch_id);

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.

P2: this early return refuses branch_ended as soon as ending is true, but ending is also the state where the line's own branch/end is recorded and its final message is still owed (TimelineTree.md:134, :149), which BranchTool.md:122 says must call the tree and retry the delivery. Failure scenario: after a failed delivery, the tool's next end returns branch_ended and the owed message is retried only by restore, the behavior the new contract is trying to replace. Fix: let the end path call the tree and let the tree choose final_undelivered or branch_ended; if the restore-only rule is chosen instead, remove the retry from TimelineTree.md and BranchTool.md.

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 d968023. With the restore-only rule chosen, the early refusal is correct: BranchLine.md:45-46 returns branch_ended when the line's own end is recorded, and BranchTool.md:123 calls the tree only while that end is not recorded. The tree answers branch_ended for the same state (TimelineTree.md:130, :150).

Comment thread docs/design/plugins/BranchLine.md Outdated
- The status note restates the line's birth identity byte for byte: a compaction replays the note, so it must be self-contained; the identity is written by TimelineTree and repeated here only as text. TimelineTree records the move; this owner writes the note.
- A restored line writes a missing note once and, on the conversation line, replaces a note an older rule set wrote: the note's text is this owner's, and the tree only knows the transition.
- The parent block is decided from the line's own state rather than from the parent's signal: a signal that arrives while a block is held must not lose the move, so the queue and the block's consumption decide the write.
- The idle and ended notices are written into the opener's line through the opener's input owner (`line_owner::<InputQueue>`), not by TimelineTree: the notice is this line's statement about itself, and the opener's queue decides its order.

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.

P2: this exception makes the child's BranchLine write both notices into the opener's line, while rule check :119 and timeline-branches.md:417-418 assign the ended notice to the opener's own BranchLine, and the code does that. Failure scenario: a tool line is ended from outside; its scope closes before the parent handles branch/ended, so the child-side writer is gone and the ended notice is lost, or an implementer writes it from the closing child scope. The opener learns of the end only from the roster retirement. Evidence: crates/dim-agent-capabilities/src/timeline_tree.rs:4663-4677 writes the idle notice to parent; :4797-4828 writes the roster and dim-branch-ended into self.own. Fix: split the writers; keep the idle notice on line_owner, and state that the ended notice is written by the opener's BranchLine on its own 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.

Partially fixed in d968023. BranchLine.md:17, :92 and :121 now split the writers, and the code agrees: the idle notice goes to the opener (crates/dim-agent-capabilities/src/timeline_tree.rs:4677), while the roster and <dim-branch-ended> are written into self.own (:4791-4828). What remains: the internal-writes flow at BranchLine.md:85 still says the idle and ended notices steer the opener through line_owner::<InputQueue>(opener). Reported in the body.

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.

Fully fixed in c80f8e1. BranchLine.md:19, :87 and :94 give the ended notice and roster retirement to the opener's own BranchLine; only the idle notice crosses into the opener's input owner. The old split is withdrawn.

Comment thread docs/design/plugins/BranchTool.md Outdated

### Errors

Every kind the owners answer maps onto one code here; a refusal writes nothing.

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.

P2: the claim that every owner kind maps is false. branch_target_protected is reachable from timelineTree.end (TimelineTree.md:128) and the current tool already returns it through kind.code() at crates/dim-agent-capabilities/src/timeline_tree.rs:5558-5561, but the table has no row and no model next action. Failure scenario: a tool line ends while an ancestor's cascade is in flight; the model receives a code the contract never explains and may retry the same end. unknown from line/read (TimelineTree.md:131-132) is either converted to branch_not_kin at the pair check or missing; the contract does not say which. Fix: add the branch_target_protected row, state the unknown conversion or add its row, and keep the completeness claim true.

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 d968023. BranchTool.md:110 adds branch_target_protected with its next action, :111 adds unknown and says the pair check reports branch_not_kin, and :113 adds cancelled. The raised codes now map. One separate conflict with timeline-branches section 11 is reported in the body: the beyond_head row at :107 contradicts the accepted no-code result at timeline-branches.md:458 and :551, while :131 says the codes are unchanged.

@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 91da0de99(已 rebase 到 eacc672da,保留 main 对 timeline-branches.md 用户行身份句的修改)。CI:changes 通过,static-checks/ci-ok 见本轮检查结果。

台账(各轮全部评论,当前 head 核对)

  • R1 12:34(17 条 inline)、R2 14:23(13 条)、R3 04:05(5 条)、R4 06:47(3 条)、R5 08:38(11 条):全部已修,无回退。
  • 第一轮预审(/tmp/prereview-2092.md,P1 1、P2 11、P3 10):
    • P1-1 create 准入按来源分开 —— 已修(user/host 任意存活父行、不计不受 cap;tool 才查 opener 与 cap,branch_not_opener/branch_limit_reached 仅 tool;Client-visible 写明客户端入口不变)。
    • P2-1 拒绝面键名与 invalid —— 已修(structuredContent.error;invalid 为无 code 失败)。
    • P2-2 Flows/Errors 矛盾 —— 已修(closed 为无 code 失败;cancelled 只有一种结局)。
    • P2-3 pair-check 与 NoLine —— 已修(line 的 unknown 在 pair check 处映射 branch_not_kin;pair 通过后的 NoLine 映射 branch_ended;该行移出无码表)。
    • P2-4 idleNotice —— 已修。
    • P2-5 错误表按操作 —— 已修(加 Operations 列;branch_ended 分 create/end 两行;unknown 分预留与从未存在;根行 end 为 invalid_target,branch_cannot_end 只留对话行链)。
    • P2-6 view.cursors —— 已修(view {target?} → 单值 cursor,加载时由自身 step/tool-use/step/tool-result 重建)。
    • P2-7 Current implementation 层级与写入路径 —— 已修(Events and lifetime/Tests 降为子节;路径写回 TreeCommands.input,end 的消息随 branch/end)。
    • P2-8 BranchLine 删三个操作 —— 已修(Client-visible 列出 resolved/ending/cursor → view,并点名 npm/branch-services.d.ts 与 runtime/fixtures/branch-part.ts)。
    • P2-9 plugin-contract 名字 —— 已修(timelineTree 标 designed, not implemented(today: treeCommands);sessionScope 同 docs(design): target contracts for the Session scope and its host ports #2093)。
    • P2-10 指针吞掉别家操作 —— 已修(拆成 InputQueue / Collaboration approvals / PromptSuggestion / Report-Prompt 四行)。
    • P2-11 行结束拒输入 —— 已修(归目标行的输入所有者,branch_ended;BranchTool 的 message 流程同步)。
    • P3-1/2/3/4/6/7/9/10 —— 已修;P3-5 cut 推导与 P3-8 规则编号仍为已知项(见下)。
  • 第二轮预审(/tmp/prereview2-2092.md,P1 2、P2 9、P3 9):
    • P1-1 createdAt —— 已修:LineRecord 增 createdAt(创建事实在父线上的序号),记录段写清与 cut 的区别,并写明记录从预留期起可读(行自己的部件在 apply 里读得到)。
    • P1-2 Goal 原子批 —— 已修:改为对输入所有者的需求 line_owner::<InputQueue>(line)?.submitMany({inputs}) → {sequences}(一次提交,按序回答),提给 #2027;树不保留 inputs。
    • P2-1 游标形状 —— 已修(示例用 own.cursor.unwrap_or(cut))。
    • P2-2 branch_target_protected —— 已修(从 end 与工具无码表删除,只留 set_default,与代码一致)。
    • P2-3 被指针吞掉的两段 —— 已修(默认行恢复、at: {kind:"create"} 回到 design 文档,恢复规则同时进 TimelineTree 契约,Create 变体作为事实值保留)。
    • P2-4 S:TreeHandle —— 已修(统一为所有者内部弱引用,随部件构造传入,依赖表去掉 S:)。
    • P2-5 预留期 line —— 已修(从预留起可答,unknown 收窄为「从未有过的 id」)。
    • P2-6 ended notice 模式 —— 已修(一次 Steer,随 roster 的 keyed 块)。
    • P2-7 Session::end_branch —— 已修(§10/§17 改为今天转发、随 docs(design): target contracts for the Session scope and its host ports #2093 删除,补了缺的句号)。
    • P2-8 feature 归属 —— 已修(两个 feature:TimelineTree + TreeTimeline;BranchTool + BranchLine)。
    • P2-9 Session 名 —— 已修(sessionScope 合并两行,标 designed, not implemented)。
    • P3-1/3/4/5/6/7/9 —— 已修(storage 错误、依赖链接与 readSegments、重复 derive、表被空行切断、LineState 替换关系、依赖表成员、句号)。

改成指针的段落

  • docs/design/contracts/runtime-owner-operations.md:timelineTree 保留行、InputQueue 行、「Calls from a Session to a selected branch」整节(标题保留);Collaboration approvals、PromptSuggestion、Report/Prompt 保留自己的操作。
  • docs/design/branch-typescript.md:页首说明、两行 owner 表项、绑定表行、数据方法要点、Open 一节的结论。
  • docs/design/timeline-branches.md:顶部迁移说明;§4 的 source 段;§5 的 BranchLine 行、injects 句与其后的写入/roster/注记三段;§6 的消息段;§7.1.1 的父块写入段;§10 的通用操作;§11 的 Read 段。
  • docs/design/plugin-contract.md:timelineTree 目录行。

剩余 P2

无。

已知未修的 P3

  • 规则检查表的 §4 rule 编号与 principles.md:59-88 对不上(需四张表整体重排并补 principles rule 3/4 两行),留作下一轮统一改。
  • create 的 cut 推导(父行 step/model-start 两步查询)仍只写「本请求的起点」,留给交付或下一轮。

检查

node scripts/adr-check.mjs --base origin/main、cargo run --locked -p xtask-check 通过(15 个改动文件);四份附录同一临时 crate cargo test 通过(含 invalid_target wire code);链接/锚点脚本无新增断链。

@eric8810
eric8810 requested a review from yyhhyyyyyy November 24, 2026 09:54

@zerob13 zerob13 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.

Use the birth position for line metadata and define reservation visibility. The new createdAt separates the birth fact from the inherited history cut, but the purpose and role lookup still look at cut. For an older start position, those lookups miss the actual create fact. Use createdAt, specify what the building line can read during apply versus what RPC may expose, and keep the failure path explicit. The reserve-before-build order itself is now clear.

The new submitMany requirement names the right owner, but the proposed InputQueue face only offers single input. Track that existing dependency as a delivery gate: align the input and Goal drafts on one atomic batch with ordered committed sequences, rather than replacing the current batch with two independent writes. Exact-head docs checks passed; runtime verification was skipped.

@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.

Review: PR #2092, round 6, head 91da0de

Scope: this PR defines the line directory owner contract for #2024 and its tree owners: TimelineTree, TreeTimeline, BranchLine and BranchTool. It moves BranchLine and TreeTimeline into the architecture pages, rewrites the tree's operations, the line_owner route and the branch tool, and updates the runtime owner, plugin contract, service faces, branch TypeScript and timeline branches documents. I reviewed the full origin/main...HEAD of 15 files (+1142/-287) at 91da0de against current main eacc672, not only the commits after c80f8e1. The branch was rebased, so the previous review head is not an ancestor.

Verdict: REQUEST_CHANGES. No P0 or P1 findings.

Prior round

  • P2 1, TreeTimeline gave the reservation to the create fact: fixed and withdrawn. TreeTimeline.md:15 and :55 now say TimelineTree reserves the child inside create's lock and that the committed branch/create starts the build; the flow test at :76 matches (TimelineTree.md:17, :168).
  • P2 2, the retained Report paragraph passed include_publishing to the tree's read: fixed and withdrawn. runtime-owner-operations.md:7, :21 and :32 now point at the target contracts, and no target read carries a publishing field.
  • P2 3, Session dependency names lagged #2093: the disagreement in this PR's owner contracts is fixed, so the P2 is withdrawn. BranchLine.md:63, TimelineTree.md:121, plugin-contract.md:62 and :119 now use SessionScope and sessionScope. runtime-owner-operations.md:11 and :26, and the R2 paragraph at plugin-contract.md:361-367, still say sessionLifecycle; #2093 at d4e4284 already replaces those shared rows, so they are not re-raised as a P2 here.
  • P2 4, the binding page's Open section denied line_owner: fixed and withdrawn. branch-typescript.md:152-154 now says a Session part cannot inject a per-branch service but reads the branch-group data face by line id.
  • The prior P3s about the README table, the BranchLine route answer count, the own-line input dependency, the submit second argument, the fields type, the {line}/{default} reply shapes, the consolidated view wording, the missing cursor target and the BranchLine injection list are fixed and withdrawn.
  • The prior P3s that remain open are the child-read fallback, the ADR 027 links and the unknown versus unknown_branch spelling. The missing build/error kind and the spelling are part of the existing review's failure-path and reservation-visibility points.

Existing review

I agree with the existing review at this head on its blockers: line metadata must be read at createdAt rather than the inherited cut, reservation visibility needs one rule across line, read, directory, branch.get and end, and the failure path must be explicit. I do not repeat them here; the optional findings below are additional.

P3 findings (optional)

P3 1. The branch tool's first read of a child still falls back to the caller's request start

Problem: BranchTool.md:58 uses cut as the fallback for every target. cut is the current request's start at :38. A first read of the line the caller was cut from starts at the caller's cut, but a first read of a line the caller opened starts at that line's first event (timeline-branches.md:148-151). The current code uses 0 for a child target and the parent's branch point for the parent (crates/dim-agent-capabilities/src/timeline_tree.rs:5533-5546).

Failure scenario: A parent opens a child in an earlier request and later reads it with no after and no cursor. The tool starts after the current request's start, skipping the child's earlier events. A read of after: 0 would work, but the no-after path is the documented continuation.

Evidence: docs/architecture/rust-agent/plugins/BranchTool.md:38, :58; docs/design/timeline-branches.md:148-151; crates/dim-agent-capabilities/src/timeline_tree.rs:5533-5546.

Fix: Use 0 for a line the caller opened and the caller's opening cut for the line it was cut from, or state a different tool rule and implement it.

P3 2. ADR 027 links still point at the #2029 PR

Problem: ADR 027 is merged on main, but several target links still use the PR URL: branch-typescript.md:3, :154, and plugin-contract.md:70. The rest of this PR's target pages link docs/adr/027-cross-scope-access-by-id.md.

Failure scenario: A reader follows a stale PR link instead of the ADR, and the link stops being the canonical decision when the PR page changes or is archived.

Evidence: docs/design/branch-typescript.md:3, :154; docs/design/plugin-contract.md:70; docs/adr/027-cross-scope-access-by-id.md.

Fix: Link the ADR file in all three places.

P3 3. The branch tool lost its branch_target_protected row while the tree still returns it from end

Problem: TimelineTree.md:132 lists branch_target_protected as an end error, and timeline-branches.md:548 says the code is answered by the switch method. The latest BranchTool text removed the row that told the model to read the line and report the state; its coded refusals at BranchTool.md:98-109 do not contain the code, so the general no-code rule at :98 turns it into an uncoded failure. timeline-branches.md:548 and BranchTool.md now imply the tool cannot receive it, while TimelineTree.md:132 says it can.

Failure scenario: A tool line's end races a cascade that is ending an ancestor before the target's own end is recorded. The tree returns branch_target_protected; BranchTool has no mapping or guidance, so the model gets a failed result with no code and cannot tell whether to read the line, retry or stop.

Evidence: docs/architecture/rust-agent/plugins/TimelineTree.md:132; docs/architecture/rust-agent/plugins/BranchTool.md:98-109; docs/design/timeline-branches.md:548.

Fix: Decide whether end can answer branch_target_protected. If it can, restore a BranchTool row and a mapping; if it cannot, remove the code from the end error list and keep it on set_default.

P3 4. The default restore paragraph omits the fork override

Problem: TimelineTree.md:140 says restore keeps the latest branch/default when its line is live and selectable, and names ended, plugin and pre-upgrade host lines as fallbacks. It does not mention a later session/forked on the root. timeline-branches.md:870 and :874 still require a fork to answer the root because every copied branch/default is older than its session/forked.

Failure scenario: A Session forked while a line was the default branch restores from the copied branch/default without considering session/forked; the target contract can put a non-root line back as the default after the fork, contrary to the accepted design.

Evidence: docs/architecture/rust-agent/plugins/TimelineTree.md:140; docs/design/timeline-branches.md:870, :874; TimelineTree.md:430-433 (current implementation already reads the two kinds).

Fix: Add the session/forked override to the default restore paragraph, or point to the dated restore cases and state that §14 remains authoritative.

Cross-PR and main

  • The PR is open, not draft, MERGEABLE, and its head is 91da0de. Current main and the merge base are eacc672; git merge-tree --write-tree origin/main HEAD is clean.
  • #2093 at d4e4284 changes the same runtime-owner-operations.md and plugin-contract.md lines that carry the sessionScope rename and the openBranch build error. #2091 at 05284be also changes plugin-contract.md. All three are open and two edit the same rows, so one of them must rebase after the others; this PR's main merge is clean but does not include those branches.
  • #2080, #2141 and #2142 change no file in this PR's set. #2002 and #1881 are unrelated to the tree contract.

Verification

  • PR state before drafting: head 91da0de, OPEN, not draft, MERGEABLE.
  • git diff --check origin/main...HEAD: passed.
  • node scripts/adr-check.mjs --base origin/main: passed, 15 changed files.
  • Relative-link scan over the changed files: 522 links, none missing.
  • git merge-tree --write-tree origin/main HEAD: clean; no conflict with main.
  • CI at 91da0de: changes, static-checks and ci-ok succeeded; the other jobs were skipped. I did not wait for CI.
  • No Rust build or test was run. This is a documentation-only PR; the target-only types and reservation path have no implementation to compile against.
  • Worktree clean; all checks used isolated HOME, TMPDIR and XDG directories under the review data directory. No shared home or temporary directory was used, and no residual process remains.

Unverified

  • Cross-PR overlap was checked by changed paths and edited rows, not by a full review of every sibling PR.
  • The session/forked restore path was not exercised at runtime.


// read: the cursor is the calling line's, the page is the tool's rendering.
let own = line_owner::<BranchLine>(&execution.branch_id)?.view(Some(target.clone())).await?;
let after = input.after.unwrap_or_else(|| own.cursor.unwrap_or(cut));

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.

P3: this falls back to cut for every target. A first read of a line the caller opened starts at that line's first event, not the current request's start (timeline-branches.md:148-151; the current code uses 0 for a child at timeline_tree.rs:5533-5546). Use 0 for a child and the caller's cut for the parent.

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 43f132d. The child case now starts at 0, but the parent case at BranchTool.md:60 still uses cut from :38, the current request's start, not the caller's opening cut. timeline-branches.md:148 and the current code at timeline_tree.rs:5533-5546 use the caller's cut (its branch_point). BranchLine.md:50 repeats the fallback without defining cut. One more fix remains: derive the parent start from the caller's own record, and keep request_start for create only.

TimelineTree owns a Session's line directory and lifecycle; its public
surface becomes five data operations on the owner type. TreeTimeline,
BranchLine and BranchTool are documented as their own owners in the same
group. Session parts reach a line's owners by line id; the tree provides
no entry into another owner's state and writes no live line's timeline.
The template's Caller example was missing: the contract explained how a
Session part reaches a line's owners but showed no caller of this owner's
five operations. The example covers a client opening, reading the
directory and ending a line, and a method reading one page, with no
version, wait or id to release.
Cross-cutting decision 2 asks this contract who provides the per-line
operations to Session parts. The contract now names it: the Session
access surface (#2025) exposes lineOwner.call({line, operation, request}),
resolved by the runtime's own index of the instances it constructs, and
TimelineTree stays out of the path. Dependencies move to SessionScope's
identity and openBranch.
Review of the contract asked for two shapes. A Session part resolves a
line's owner by type (line_owner::<T>(line)) and calls that owner's own
operation, instead of routing by operation-name strings with json
requests; the mechanism requirement now says so and matches #2093. The
directory read splits into directory() and line(id), so no caller matches
an enum reply or writes unreachable!.
The final message stays with the end that owes it, delivered before the
scope closes and before branch/ended; the owner's branch parts hold a weak
handle, built with the tree, so close can settle the scope; create's
cancellation stops only the wait; BranchLine declares its input owner and
its four markers; the status note's text stays with BranchLine; errors
carry wire codes and every kind is mapped; a Session part reaches any
branch data face with line_owner; the directory splits into directory()
and line(); the binding appendix compiles; the parts, flows and counts
agree. Existing documents' paragraphs describing this owner are replaced
and the contracts list what they supersede.
The line-addressed access follows ADR 027 D1-D3 and links #2127; the
runtime routes the call and hands no instance key out. The binding
appendix compiles in a temporary crate: the idle-notice wire enum and
AgentEvent are declared, ReadReply is one-or-the-other, and every error
variant carries named fields so the code tag serializes. An owed final
message keeps the line ending and answers final_undelivered until it
lands. BranchTool calls BranchLine's view and the tree's end on an
ending line. The retained documents' paragraphs describing this owner
are updated, and links point at the PRs that add them.
…ool error

A repeated end answers branch_ended and an owed final message is delivered
by restore only: final_undelivered and the retry wording leave the
contract, its appendix and the tool. The ended notice is written by the
opener's own BranchLine on its own line; only the idle notice goes through
line_owner. The tool's error table covers an ended or protected target, an
unknown id and a cancelled create, and the branch-construction dependency
names its only caller.
…e tool errors

The BranchLine flow now sends only the idle notice through line_owner; the
ended notice and the roster retirement are written on the opener's own
line when it folds branch/ended. A Session part sees SessionClosing and
NoLine, and NoLine means the instance is closing or gone, not an ending
line; NoSession belongs to process callers. The tool's errors split into
the accepted refusal codes and the endings without a code, so an after
past the head stays the accepted no-code error result.
The rebase left the worktree without files that main tracks, and the
commit's broad add staged their removal. Restore them unchanged.
BranchTool's contract merges into its architecture page, with the code
described under Current implementation; BranchLine and TreeTimeline get
their own architecture pages and leave the design tree. The two READMEs,
the moved pages' inbound links and the example documents that named them
follow.
The paragraphs this contract supersedes in runtime-owner-operations, the
branch TypeScript binding and the timeline-branches note now point at the
contract instead of restating it. The reservation stays with create: the
tree reserves under its own lock and TreeTimeline hands the committed
branch/create over to start the build. BranchLine's target dependency is
SessionScope, a Session part sees two route answers, and the examples and
reply shapes match the binding and the callee signatures.
Create's admission is stated per source: a user or plugin open takes any live
parent and spends no slot, and only a tool open is checked against the opener
rule and the cap. The tool's refusal surface names structuredContent.error,
splits the codes per action, maps the pair check and NoLine, and spells the
input field idleNotice. BranchLine's view takes a target and its cursor is
rebuilt on load; its client-visible section names the three removed
operations and the generated binding and fixture that move with them.
TimelineTree's error table gains an operations column, splits the root from
the conversation chain, and keeps the root's input error; the input refusal
after an end belongs to the line's input owner. ADR 027 is linked in the
repository, and the plugin catalog row marks timelineTree as designed.
LineRecord gains createdAt, the sequence of the line's branch/create on its
parent, and the record answers from the reservation on, which is what a
line's own part reads during apply. Goal's atomic record-and-trigger write
becomes a requirement on the line's input owner, submitMany, since the
tree performs no input writes. The tool's cursor is the single value its
owner publishes, branch_target_protected is set_default's, the default
restore and the Create anchor are stated again, the two handles are
owner-internal references, the ended notice is one Steer, the feature
split and the SessionScope name follow the code and #2093.
…atch gate

A read during the reservation now has one table: the record answers from the
reservation, read and end answer unknown_branch, the directory and branch.get
omit it, and line_owner answers NoLine; a failed build records
branch/create-failed, drops the node and leaves the create fact. The error
kind is spelled unknown_branch throughout and the App Server keeps answering
branch_missing. BranchLine reads a line's role and parent at createdAt, not at
the inherited cut. submitMany is a delivery gate and the InputQueue and Goal
drafts align on it. BranchTool starts a first child read at 0 and a first
parent read at the cut; ADR 027 links point at the ADR; end no longer claims
branch_target_protected; the default restore names the session/forked
override.
eric8810 added a commit that referenced this pull request Nov 24, 2026
read is TimelineTree's and named in #2092; query and sessionConfig exist
only on the store's process face. The catalog row marks openBranch as
Rust-only and cites the shared lifecycle design that section 7 requires
for an object. The projection's wire types are this contract's; the upper
contract aligns its import.

Refs #2025
eric8810 added a commit that referenced this pull request Nov 24, 2026
…ner contracts

Report's extraction calls timelineTree.read with the request shape #2092
defines. The architecture plugin README points at the six Session-scope
owner contracts, which have no page there.

Refs #2025
eric8810 added a commit that referenced this pull request Nov 24, 2026
The Session timelineStore face carries no sessionId: the instance identity
supplies it. The operations table renders again, a fault is still recorded
after close, the tree rows and the plugin-contract cells match #2092, the
adopted allowance is repaired at adoption, and the delivery mapping lists
the current instance errors.

Refs #2025
@eric8810
eric8810 force-pushed the dim/2024-timeline-contract branch from 91da0de to 43f132d Compare November 24, 2026 11:32
@eric8810

Copy link
Copy Markdown
Collaborator Author

已按评审修改,head 43f132d1e(base 5930539bc,已 rebase 到最新 main,无冲突)。

台账

第 1–6 轮(12:34 17 条、14:23 13 条、04:05 5 条、06:47 3 条、08:38 11 条 inline,加各轮 review 正文):全部关闭,无回退。

第 7 轮 zerob13(6037323929)

  • P2「line metadata 用出生位置、并定义 reservation 可见性」→ F:createdAt 成为角色/父行与 purpose 的读取位置(BranchLine.md:15),cut 只保留「继承历史的切点」;reservation 可见性成为一张表(line 从预留起答记录;read/end 答 unknown_branch;directory 不列;branch.get 答 branch_missing;line_owner 答 NoLine;构件所在行的 apply 单列一行);构建失败单列一段(branch/create-failed、节点移除、槽位释放、调用方收到构建错误);错误码统一拼写 unknown_branch,并写明 App Server 仍答 branch_missing。
  • P2「submitMany 作为交付门槛」→ F:契约写明实现任务在输入所有者契约载入该操作前不落地,InputQueue 与 Goal 草稿对齐一次原子批,不拆两次写。

第 7 轮 yyhhyyyyyy(6037661951)

  • P3 1 子行首读从 0、父行首读从 cut → F(BranchTool.md 的 start 与 BranchLine.md 示例,对齐 timeline_tree.rs:5533-5546)。
  • P3 2 ADR 027 用 PR 链接 → F(branch-typescript.md:3/:154、plugin-contract.md:70 改为 docs/adr/027-cross-scope-access-by-id.md)。
  • P3 3 branch_target_protected → F(按代码判定只有 set_default 产生,从 end 错误行与工具删除,保留在 set_default 与错误表)。
  • P3 4 默认行恢复缺 fork → F(补 session/forked 覆盖,指向 timeline-branches §5 的恢复段)。
  • 其 Prior round 列的 4 条 P2 与 9 条 P3 在本 head 复核,仍为已修。

预审一 / 预审二:P1(create 按来源准入;createdAt;Goal 原子批)与全部 P2 已在前几轮关闭,本轮继续保留修复;剩余项见文末。

改成指针的段落

  • docs/design/contracts/runtime-owner-operations.md:timelineTree 保留行、InputQueue 行、「Calls from a Session to a selected branch」整节(标题保留);Collaboration approvals、PromptSuggestion、Report/Prompt 各自保留操作。
  • docs/design/branch-typescript.md:页首说明、两行 owner 表项、绑定表行、数据方法要点、Open 一节的结论。
  • docs/design/timeline-branches.md:顶部迁移说明、§4 的 source 段、§5 的 BranchLine 行/injects 句/写入与 roster 与注记三段、§6 的消息段、§7.1.1 的父块写入段、§10 的通用操作、§11 的 Read 段。
  • docs/design/plugin-contract.md:timelineTree 目录行。

预审摘要

  • P1:无。
  • P2:createdAt、reservation 可见性、submitMany 交付门槛、游标形状、branch_target_protected、被指针吞掉的两段、S:TreeHandle、预留期 line、ended notice 的 Steer、Session::end_branch、feature 归属、Session 名 —— 全部 fixed。
  • P3:子行首读、ADR 链接、branch_target_protected、fork 恢复、storage 错误、依赖链接与 readSegments、重复 derive、表被空行切断、LineState 替换关系、依赖表成员、句号 —— fixed。

剩余 P2(交维护者判断)

已知未修的 P3

  • 四份契约的 Rule check 表 §4 rule 编号与 principles.md 对不上,需四张表整体重排并补 principles rule 3/4 两行(下一轮统一改)。
  • create 的 cut 推导(父行 step/model-start 两步查询)仍只写「本请求的起点」(留给交付)。

检查

  • node scripts/adr-check.mjs --base origin/main:通过(15 文件)。
  • cargo run --locked -p xtask-check:通过。
  • git diff --check origin/main...HEAD:干净。
  • 四份附录(FileStorage、SessionFiles、TimelineTree、SessionScope)同一临时 crate cargo test 通过(含 unknown_branch wire code 断言);PluginFiles 附录待 design(fileStorage): target contract #2080 落地后并入。
  • 链接/锚点脚本:本 PR 改动文件无新增断链。

@eric8810
eric8810 requested a review from yyhhyyyyyy November 24, 2026 11:33

@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.

Review: PR #2092, round 7, head 43f132d

Scope: this PR defines the line directory owner contract for #2024 and its tree owners: TimelineTree, TreeTimeline, BranchLine and BranchTool. It moves BranchLine and TreeTimeline into the architecture pages, rewrites the tree's operations, the line_owner route and the branch tool, and updates the runtime owner, plugin contract, service faces, branch TypeScript and timeline branches documents. I reviewed the full origin/main...HEAD of 15 files (+1157/-287) at 43f132d against current main 5930539, not only the delta over 91da0de. The branch is rebased onto current main.

Verdict: REQUEST_CHANGES. One P2 and three optional P3s.

Prior round

  • P3 1, the child first-read fallback: partly fixed. BranchTool.md:60 now uses 0 for a line the caller opened, but the parent case still uses cut from :38, the current request's start. The rule at timeline-branches.md:148 and the current code at timeline_tree.rs:5533-5546 use the caller's opening cut. See P3 1 below and the reply on the thread.
  • P3 2, ADR 027 links: fixed and withdrawn. branch-typescript.md:3, its Open section, and plugin-contract.md:70 now link ../adr/027-cross-scope-access-by-id.md; no pull/2029 link remains in the 15 files.
  • P3 3, branch_target_protected: fixed and withdrawn. TimelineTree.md:132 no longer lists it on end, :164 keeps it on set_default, and timeline-branches.md:548 keeps it on session.branch_set_default.
  • P3 4, default restore: fixed and withdrawn. TimelineTree.md:152 now says a later session/forked on the root wins and a Session forked while a line was the default comes back on the root, matching timeline-branches.md:870 and :874.
  • The unknown versus unknown_branch spelling is fixed: BranchLine.md:79, :183 and TimelineTree.md:172, :393 use unknown_branch.
  • P2 3 from round 5, the shared sessionLifecycle rows: still not changed in this branch. runtime-owner-operations.md:11 and :26 and plugin-contract.md:363, :367 still say sessionLifecycle. #2093 at 4557d0b replaces those rows with sessionScope (checked in its runtime-owner-operations.md:11 and plugin-contract.md:361). Nothing remains for this PR's owner contracts, so it stays withdrawn as a P2 here.

P2 findings

P2 1. A reserved or failed child is reported as ended or not kin

Problem: BranchTool.md:101 maps unknown_branch from the pair check to branch_not_kin and a NoLine after the pair check to branch_ended. TimelineTree.md now says a reserved line answers NoLine from line_owner (:145) while its record is open with head 0 (:140), and a failed creation answers unknown_branch from line, read and end (:150). So a line the caller opened and that is still building, or whose build failed, is reported as not kin or as ended. The same page calls NoLine final (:98, :252), and ADR 027 D2 treats a missing branch as final while the Session lives, so the reservation rule and the route's own semantics disagree.

Failure scenario: A create is cancelled after admission, so the child keeps building and publishes without a waiter (TimelineTree.md:131, :173). The parent's BranchLine writes the roster from the committed branch/create; the current fold inserts the child at timeline_tree.rs:4137-4149 and the roster keeps every child that is not failed or ended at :4756-4762. The parent's next request sees the child id while the build is still running and the model messages or reads it. line(id) answers the reserved record (:140), so the pair check passes. For message, line_owner:: answers NoLine (:145) and the tool answers branch_ended, which the error table calls not retryable, although the line publishes moments later. For read, tree.read answers unknown_branch (:141), which the tool leaves as an uncoded failure with no retry guidance. If the build fails, line(id) answers unknown_branch (:150), the pair check turns it into branch_not_kin, and the model is told to address a line it opened.

Evidence: docs/architecture/rust-agent/plugins/BranchTool.md:101; docs/architecture/rust-agent/plugins/TimelineTree.md:98, :131, :140, :141, :145, :150, :173, :252; docs/architecture/rust-agent/plugins/BranchLine.md:16, :251; crates/dim-agent-capabilities/src/timeline_tree.rs:4137-4149, :4756-4762; docs/adr/027-cross-scope-access-by-id.md:33.

Fix: Pick one rule for a reserved line and state it in all three places. Either the roster lists only published lines and no Session part can reach a reserved id, or line_owner answers a distinct retryable opening outcome and BranchTool tells the model to retry after publication rather than branch_ended. Give a failed creation its own outcome, or say how the tool learns it from branch/create-failed, so it cannot become branch_not_kin. Make TimelineTree.md:98 and :252 agree with the chosen rule.

P3 findings (optional)

P3 1. The parent case of the read fallback still uses the current request start

Problem: BranchTool.md:60 now sets the start to 0 for a line the caller opened, but the else branch uses cut, which :38 defines as the current request's start. A first read of the line the caller was cut from must start at the caller's opening cut (timeline-branches.md:148; the current code reads the caller's branch_point at timeline_tree.rs:5533-5546). The positions are on different lines: the request start is a sequence on the caller's line, while the parent read needs a sequence on the caller's parent. BranchLine.md:50 repeats the fallback with an undefined cut.

Failure scenario: A caller opened on its parent at cut 10 later runs a request that starts at 100 and reads the parent with no after and no cursor. The example starts at 100 and skips the parent events between 10 and 99, which are part of the inherited history the rule says to read.

Evidence: docs/architecture/rust-agent/plugins/BranchTool.md:38, :58-61; docs/architecture/rust-agent/plugins/BranchLine.md:50; docs/design/timeline-branches.md:148; crates/dim-agent-capabilities/src/timeline_tree.rs:5533-5546.

Fix: Derive the parent start from the caller's own record, for example line(execution.branch_id).cut, and keep request_start for create only. Define the same value in BranchLine.md:50.

P3 2. The reservation table does not render

Problem: TimelineTree.md:138 appends the table header to the end of the paragraph line, and :139 is the delimiter row. GitHub's Markdown does not start a table from a header that shares a line with prose, so the seven answer rows render as plain pipe text.

Failure scenario: A reader of the rendered page sees the reservation visibility rule, which is the fix for the pre-review's reservation point, as one long paragraph and cannot scan the per-operation answers.

Evidence: docs/architecture/rust-agent/plugins/TimelineTree.md:138-146.

Fix: Put a blank line after the paragraph and start the table with the header row on its own line.

P3 3. S:TreeHandle labels an internal handle as a Session service

Problem: TreeTimeline.md:41 writes S:TreeHandle in the contract dependency table, and :61 calls it a service. TimelineTree.md:194 and :429 say TreeHandle is an owner-internal weak reference, not a service and not a catalog name, and BranchLine.md:65 lists it without a scope prefix.

Failure scenario: An implementer reading the dependency table adds a TreeHandle service name to the Session catalog or to the injection graph, while the tree is supposed to pass the handle when it constructs the part. The generated assembly has no such service.

Evidence: docs/architecture/rust-agent/plugins/TreeTimeline.md:41, :61; docs/architecture/rust-agent/plugins/TimelineTree.md:194, :429; docs/architecture/rust-agent/plugins/BranchLine.md:65.

Fix: Drop the S: prefix here and in the Supersedes line, and use owner-internal TreeHandle as the other two pages do.

Existing review

I agree with the existing review on its remaining part: the purpose lookup at TimelineTree.md:40 still reads at the cut, but a line can be cut before its creation, and the record's createdAt (:138) is the sequence that finds the parent's branch/create. The current lookup reads from and through the cut (timeline_tree.rs:4845-4864) and finds no create fact for a delayed create.

Cross-PR and main

  • The PR is open, not draft, MERGEABLE, head 43f132d. Current main and the merge base are 5930539; git merge-tree --write-tree origin/main HEAD is clean.
  • #2093 at 4557d0b changes the same runtime-owner-operations.md and plugin-contract.md rows as this PR. Its SessionScope.md:26 also says NoLine is final for the line, which is the cross-PR side of P2 1. Its runtime-owner-operations.md:25 still writes unknown for line({line}); this PR now uses unknown_branch, so that row needs the same rename.
  • #2091 at c6d1dae, #2100, #2103 and #2098 also change plugin-contract.md, runtime-owner-operations.md or service-faces.md. None changes this PR's four owner pages. The PR body's merge order puts #2091/#2092/#2093 together; whichever merges later rebases.

Verification

  • PR state before drafting: head 43f132d, OPEN, not draft, MERGEABLE.
  • git diff --check origin/main...HEAD: passed.
  • node scripts/adr-check.mjs --base origin/main: passed, 15 changed files.
  • git merge-tree --write-tree origin/main HEAD: clean; no conflict with main.
  • Relative-link scan over the changed files: 538 links. Two anchors are missing, both already on main and not on lines this PR adds: timeline-branches.md:554 (#122-items-for-the-prompt-layer-429) and :570 (appserver/session-deletion-and-fork.md#62-why-main-only).
  • CI at 43f132d: changes, static-checks and ci-ok succeeded; the other jobs were skipped. I did not wait for CI.
  • No Rust build or test was run. This is a documentation-only PR. The checks used isolated HOME, TMPDIR and XDG directories under the review data directory; no residual process remains.

Unverified

  • The unrendered table is judged from the GitHub Markdown rules, not from the rendered PR page.
  • Cross-PR overlap was checked by changed paths and the cited rows, not by a full review of every sibling PR.
  • The reservation path was not exercised at runtime.


### Errors

The tool's coded refusals are the accepted set ([timeline branches §11](../../../design/timeline-branches.md#11-the-branch-tool)); an argument error and every other ending are failed results without a code, so the model-visible result shape does not change. The pair check reads `line(id)` first: `unknown_branch` there becomes `branch_not_kin`, never a separate code. A `NoLine` after the pair check succeeded means the target's instance closed in between, which each action reports as `branch_ended`. `SessionClosing` is a failed result without a code, and a Session part never receives `NoSession` ([#2127](https://github.com/arcships/dim/issues/2127); [TimelineTree](TimelineTree.md#session-parts-reaching-a-lines-owners)).

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.

P2: these mappings are wrong for a child that has not published. TimelineTree.md:145 makes a reserved line answer NoLine from line_owner while its record is open with head 0 (:140), and :150 makes a failed creation answer unknown_branch from line. The pair check here turns the failed case into branch_not_kin, and the next sentence turns NoLine into branch_ended, which the table calls not retryable. A line the caller opened and that is still building is reported as ended, and a failed one as not kin. Say how a reserved line is handled (retry after publication, or keep it out of every Session part's reach until it publishes) and give a failed creation its own outcome. Also reconcile :98 and :252, which call NoLine final.

| `line` | One line's record | `{line}` | `record` | None | `unknown_branch` (an id this Session never had), `closed` |
| `read` | A line's facts at a cutoff, or the line and its ancestors at one cut | `{line, scope?, from?, through?, fields?, limit?}` | `{through, events}` or `{through, rows}` | None: one bounded read | `unknown_branch`, `beyond_head` (a cutoff past the line's head), `not_batch_boundary` (a cutoff inside an atomic batch), `continuation_without_cutoff`, `closed` |

A record is `{line, parent, cut, createdAt, source, state, head, endEvent?}`; `state` is `open`, `ending` or `ended`. `cut` is the point of the parent's history the line starts from; `createdAt` is the sequence of the line's `branch/create` on the parent, which is where the line came into being and what its opener and its own BranchLine read the line's opening by. The two differ: a line cut at an old point is created later than its cut, and a `before` producer's anchor can be either. A record exists from the reservation on. What a read answers while the build is still running, after `create` released its lock and before the scope published: | Read during the reservation | Answer |

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.

P3: the table header is appended to this paragraph line, so GitHub's Markdown does not start a table; the seven answer rows render as plain pipe text. Put a blank line after the paragraph and start the table with the header row on its own line.

| --- | --- |
| `B:Dispatcher` | The line's committed facts, in order. |
| `B:Timeline` / `B:TimelineIdentity` | Creation and end settlement location and this line's id. |
| `S:TreeHandle` | The owner's weak handle to TimelineTree: the internal handover for creation, end and turn end. Weak because the tree holds this line's scope and the scope holds this part. |

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.

P3: S: marks a Session service, but this is the owner-internal weak handle. TimelineTree.md:194 and :429 say TreeHandle is not a service and has no catalog name, and BranchLine.md:65 lists it without a prefix. Drop the prefix here and at :61; an assembly reader could otherwise add a TreeHandle service that does not exist.

@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.

3 participants