Repository navigation
Conversation
…t heads from publication
…ted branch lifecycle
…9-tree # Conflicts: # crates/dim-agent-capabilities/src/timeline_tree.rs # crates/dim-agent-capabilities/tests/branch_flow.rs # docs/architecture/rust-agent/plugins/TimelineTree.md # docs/design/timeline-branches.md # docs/zh/design/timeline-branches.md
…to impl-1909-tree
…to impl-1909-tree
…to impl-1909-tree
zerob13
left a comment
There was a problem hiding this comment.
In timeline_tree.rs:323–340, the cancellation arm calls cancel.cancel() and then polls called again even if dispatch has not reached the selected owner yet. For example, the compaction handler at context_methods.rs:85–99 admits the command before waiting for its result with the token. A caller can see cancellation even though the cancelled request started a new compaction. Refuse cancellation before owner admission, while allowing the owner to settle work already admitted. Please cover a request cancelled before dispatch as distinct from cancellation after admission. This is a static finding; the exact child CI passed.
yyhhyyyyyy
left a comment
There was a problem hiding this comment.
Review
This PR consolidates the Session tree on timelineTree, retires treeCommands, timelineFactory and timelineTreeControl, and routes selected-branch calls through timelineTree.call. The direction matches the owner contract, and the catalog, generated declarations and runtime fixtures move together. One previously reported blocking issue remains, and one new contract contradiction needs a decision.
Verdict: REQUEST_CHANGES.
Blocking
Cancellation is not checked before owner admission. Agree with the earlier review on this arm: TimelineTree::call (crates/dim-agent-capabilities/src/timeline_tree.rs:332-340) cancels the token and then polls call_branch, so an operation that has not reached its owner is still started. compact commits agentLoop.compact at crates/dim-agent-capabilities/src/context_methods.rs:91-93 and only observes the token later, at :200. Failure scenario: a client disconnects while session.context.compact is being dispatched. call takes the cancellation arm, then polls call_branch, which commits agentLoop.compact; the caller receives operation_interrupted, a compaction runs anyway, and a retry can commit another. No test separates cancellation before dispatch from cancellation after admission. Fix as proposed earlier: check the caller's cancellation before polling call_branch and answer operation_interrupted without admitting; once the owner has admitted work, let it settle and return the owner's result instead of reporting interruption.
New finding
inputQueue.withdraw refuses the steer that the owner contract says it accepts. The withdraw helper on the public tree face (crates/dim-agent-capabilities/src/timeline_tree.rs:655-663) forwards to InputQueue::withdraw, which rejects every steer (crates/dim-agent-capabilities/src/input_queue.rs:244-250). The contract says inputQueue.withdraw takes the owner's existing command and the caller runs the submit checks for steer before writing (docs/design/contracts/runtime-owner-operations.md:27,54). Failure scenario: a foreign plugin follows the contract, runs its submit checks, and calls timelineTree.call with {kind:"inputQueue.withdraw", command:{input_id, steer}}. It receives session_invalid_input and cannot replace the withdrawn input, while the checked steer path is only the App Server's session.input.withdraw method. Fix the contract to state that steer is refused here and stays on session.input.withdraw, or add a checked steer variant to the tree operation. The contract change is the smaller one.
Optional
directory_entry is documented as returning a record for a "published or still opening" line (crates/dim-agent-capabilities/src/timeline_tree.rs:1779-1781), but Node::directory_entry returns None unless the node is published (crates/dim-agent-capabilities/src/timeline_tree.rs:153-155). Goal, Shell and Collaboration now call directory_entry where they used get (crates/dim-goal/src/session.rs:121,199, crates/dim-agent-capabilities/src/shell_input.rs:227, crates/dim-app-server/src/collaboration.rs:1309), so a line in its opening window answers session_invalid_input instead of being accepted from its built context (the context is stored at timeline_tree.rs:1243, before publication at :1310). The design already treats an opening line as unknown for end (docs/design/timeline-branches.md:396), so if the same rule is intended for these admission checks, correct the comment and state it in the contract; otherwise include opening nodes with their context head.
Cross-PR and CI
The head does not merge cleanly into origin/main: git merge-tree --write-tree origin/main HEAD reports conflicts in 26 paths, including crates/dim-agent-capabilities/src/input_queue.rs, crates/dim-agent-capabilities/src/timeline_tree.rs and docs/design/timeline-branches.md. This belongs to the stack: the base PR #1911 is DIRTY against main, while this PR is CLEAN against its declared base, and #1911's head is an ancestor of this head. There is no conflict with #1911 itself.
Required CI at head 6f36d5d passed: ci-ok, static-checks, macos-native and verify (linux). The verify (linux) job includes a passing "Verify public Node bindings" step, so the changed declarations and TypeScript fixtures were exercised. "Verify Python plugins" was skipped, so the renamed runtime/fixtures/python/python_branch_part.py was not exercised. The scripts and web jobs were also skipped by change selection.
| Ok(async move { approval.decide(request_id, decision).await }) | ||
| } | ||
|
|
||
| pub fn withdraw( |
There was a problem hiding this comment.
This helper forwards to InputQueue::withdraw, which rejects any steer (crates/dim-agent-capabilities/src/input_queue.rs:244-250). The owner contract says inputQueue.withdraw takes the owner's existing command and the caller runs the submit checks for steer before writing (docs/design/contracts/runtime-owner-operations.md:27,54). A foreign caller following that contract sends {kind:"inputQueue.withdraw", command:{input_id, steer}} and receives session_invalid_input, so it cannot replace a withdrawn input through this face; the checked steer path is the App Server's session.input.withdraw method, which this face does not expose. Fix the contract to state that steer is refused here and stays on session.input.withdraw, or add a checked steer variant to this operation.
| /// A line's directory record, published or still opening; absent once a | ||
| /// failed creation removed it. | ||
| fn info(&self, id: &str) -> Option<TimelineInfo> { | ||
| pub fn directory_entry(&self, id: &str) -> Result<BranchDirectoryEntry> { |
There was a problem hiding this comment.
The comment says "published or still opening", but Node::directory_entry returns None unless ready is Some(Ok(_)) (crates/dim-agent-capabilities/src/timeline_tree.rs:153-155), so a line in its opening window returns UnknownBranch. Goal (crates/dim-goal/src/session.rs:121,199), Shell (crates/dim-agent-capabilities/src/shell_input.rs:227) and Collaboration cancel (crates/dim-app-server/src/collaboration.rs:1309) now call this where they used get, which accepted a built context before publication (the context is stored at crates/dim-agent-capabilities/src/timeline_tree.rs:1243, before ready is published at :1310). A caller that learns a branch id from branch/create and writes before publication now gets session_invalid_input. The design already treats an opening line as unknown for end (docs/design/timeline-branches.md:396). If the same rule is intended here, correct the comment and state the behavior in the contract; otherwise include opening nodes with their context head.
Refs #1292
Implementation
timelineTree.treeCommands,timelineFactoryandtimelineTreeControlnames. Session assembly retains its private constructor and lifecycle access.timelineTree.calldispatchescompactAndWait,contextUsage.read,approval.pending,approval.decideandinputQueue.withdraw. Session Context RPC calls the selected branch through this operation.prompt.configureandprompt.adoptedConfigurationthrough Migrate branch control, Prompt and selected-branch consumers #1911’s Prompt owner. Report andsession.agent.getread adopted configuration through the selected tree. This PR is stacked on Migrate branch control, Prompt and selected-branch consumers #1911.Callers and operations
Final API
timelineTreecreate/end/info/input/list/page/queryretain their existing signatures on the single Session tree face. Creation returns the branch ID.timelineTreetimelineTree.directory({}) → [{info, head, state, endEvent?}], including ending and ended branches.directory({id})returns the matching directory entry or the unknown-branch error using a single-branch lookup. Goal reads ended history throughquery; writes retain the ended/unknown errors.inputs(id, inputs) → committed events. One validated atomic batch for the Goal record and trigger.display(id) → {entry,purpose?,cutMessages?,end?}.batchEnd(id, sequence) → void,pageEnd(id, after, limit, through) → sequence, andpageat the same cutoff. Preserve complete batches and the fixed head of ended lines.Reuse
defaultBranch/setDefaultBranch. For a selected live branch,timelineTree.call({branchId,operation},cancelled) → operation reply. Variants: contextUsage.read, compactAndWait, prompt.configure, prompt.adoptedConfiguration, inputQueue.withdraw, approval.pending and approval.decide.Acceptance
timelineTree,timelineTreeControl,timelineFactory.Owner contract · Baseline catalog