Repository navigation
fix(capabilities): settle a closing line's queued inputs as deleted - #2586
Draft
yyhhyyyyyy wants to merge 7 commits into
Draft
yyhhyyyyyy wants to merge 7 commits into
yyhhyyyyyy wants to merge 7 commits into
Conversation
A line that ends stops accepting input but could leave an applied or held input pending forever, because the at-most-one rule for input/applied and input/deleted could not express a deletion after application. The contract now chooses input/deleted as the closing settlement, written by InputQueue for every input the line did not consume, after branch/end and before branch/ended; consumed and deleted stay mutually exclusive. The branch close and restore sections describe the settlement and the fixed head it extends, and the InputQueue and Loop pages record the new consumption rules.
InputQueue consumes branch/end, releases nothing more, and writes one atomic input/deleted batch for the entries it still holds once no turn runs or is about to start, so an applied input can settle as deleted only through this close settlement. Loop consumes branch/end and input/deleted, keeps a branch-scope interrupt in this generation's memory, and starts no turn for an ending line; the close drains dispatch to the committed head before the driver stops. Restore settles a stored line through an InputQueue selection before it fixes the line's head and records branch/ended, and the CLI and client projections clear a deleted input's pending row.
The flow tests pin a tool end that keeps a consumed input and settles a held queue input without starting a turn, a close that settles an applied input after its application and before the parent records the end, and a restore that settles a stored end before its result. The restart fixtures expect the settled event in their ended heads.
…ttlement The InputQueue interface in the generated TypeScript declarations carries the new branch/end and close settlement paragraph its Rust owner documents.
…g flag Build the recovery state in one initializer so clippy's field-reassign-with-default lint stays clean.
The Loop page names the live path for a non-tool source's unopened turn, and the InputQueue page names the facts whose handling checks the ending, quiet state.
Collaborator
|
This is a draft, and #2146 is still P3: the contract fork it raises (whether an input applied by a closing line stays pending or settles as deleted) has not been accepted yet, so this PR is not merge-eligible under the issue gate. The rule proposed here — a closing line writes |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An input still queued when its line ended had no terminal outcome: close interrupted the line and unloaded it while the input had neither
input/applied,input/consumednorinput/deleted, so a held input had no fact at all and an applied one stayed pending with no turn left to consume it.docs/design/contracts/session-access.mdnow states that a closing line settles every input it did not consume and that this settlement is the only deletion that may follow an application, withinput/consumedandinput/deletedstill mutually exclusive (docs/design/contracts/session-access.md:L125); its timing table and appendix B recordbranch/end<input/deleted<branch/ended, never consumed and never pending (docs/design/contracts/session-access.md:L132, docs/design/contracts/session-access.md:L472); the result-fact and after-apply rows say when InputQueue writes the fact and that a closing line deletes an applied input (L348, L355); appendix C item 5 carries the rule (L498); the Chinese mirror states the same at L121, L128, L339, L346, L402 and L428.docs/design/timeline-branches.mdadds the settlement batch to close step 5 (docs/design/timeline-branches.md:L412) and to restore, which settles a stored line's unconsumed inputs before fixing its head (docs/design/timeline-branches.md:L424); the Chinese mirror follows at L387 and L399.docs/design/input-state-read.mdsays an ended line's inputs are no longer pending (L21).InputQueue.mdstates when the queue releases nothing and settles (L139), andLoop.mdstates that an ending generation starts no turn and that a branch-scope interrupt is not a durable interrupt (L45).Live close:
InputQueueconsumesbranch/endand marks the line ending; afterbranch/end,turn/endorstop/interrupt, once no turn runs and none is about to start, it writes one atomicinput/deletedbatch for every entry it still holds (crates/dim-agent-capabilities/src/input_queue.rs:L183). The input the final turn end releases is applied and deleted in that batch, the other held inputs are deleted without a new application, and all of it lands beforebranch/ended.Loopmarks the generation ending onbranch/endand on ascope: branchinterrupt without writing a durable interrupt (crates/dim-agent-capabilities/src/agent_loop.rs:L1449), so a turn end cannot open another turn.BranchRuntimedrains dispatch to the committed sequence before it cancels the driver (crates/dim-agent-runtime/src/timeline_context.rs:L857), so the settlement is published before the close finishes.Restore:
settle_stored_lineselects a stored line's inputs without a terminal fact and appends one atomicinput/deletedbatch before the parent'sbranch/endedand before the line's head is fixed (crates/dim-agent-capabilities/src/input_queue/recovery.rs:L505); restore calls it from its descendant and own-end paths (crates/dim-agent-capabilities/src/timeline_tree.rs:L1159, L3304, L3342). It reads fields only, writes nothing when nothing is unsettled, and the existing one-page restore test still reads zero ranges from a store that refuses range reads (L2161).Readers: the CLI projection drops the pending row on
input/deleted(crates/dim-cli/src/projection.rs:L436), and the client window carriesInputDeletedacross page continuations (crates/dim-client/src/window.rs:L270).Existing tests: five expectations in
crates/dim-agent-capabilities/tests/branch_flow.rsmove by one because each end now carries one more input fact,+1at L1143, L1157, L1323 and L2164, and+2at L1326 for the line whose own result and settlement both extend it; each place asserts that the added event is that input'sInputDeleted. New flow tests cover a tool end with a held input (crates/dim-agent-capabilities/tests/branch_flow.rs:L1381), a close that applies and then deletes an input before the parent records the end (crates/dim-agent-capabilities/tests/branch_flow.rs:L1475), and a restore that settles a stored end's inputs before its result (crates/dim-agent-capabilities/tests/branch_flow.rs:L1563).Design rule checklist
branch/endandstop/interruptstay the commands; InputQueue decides from its own held entries and writesinput/deletedas its result, a close that settles nothing writes no event, and no other owner's state is written (session-access.md:L132).input/applied, and the only fact that may follow it is the close settlement defined in the contract, which records that an ending line will not consume the input; it does not return the input to the queue (session-access.md:L125).beforecallbacks. Nobeforecallback is added or changed; the settlement runs from InputQueue's ordered consumption and from the restore's own store read, not inside a write callback.BranchRuntime::closethat waits until dispatch reaches the committed sequence before the driver stops (timeline_context.rs:L857); it has no feature branch and stays inside the branch lifecycle.input/deletedevent (projection.rs:L436, window.rs:L270).input/deletedas one atomic batch, after the last turn end's application, and restore appends one batch before it fixes the head (input_queue.rs:L188, recovery.rs:L505).inputQueuestays a branch data face and its declaration changes only in the documented comment (branch-services.d.ts:L812); noinjectsorprovideschanges.input/deletedis the terminal fact later decisions read (pending reads, restore and clients), and no UI-only state enters the Timeline (session-access.md:L125).Documentation
adr-erratum(ADR 008). No ADR is modified; the input contract and the branch, InputQueue and Loop design pages state the settlement (session-access.md:L125).Verification on this head:
cargo fmt --all -- --check --config error_on_line_overflow=truepassed;cargo clippy --workspace --all-targets --locked -- -D warningspassed;cargo test -p dim-agent-capabilities --test capabilities_flow --lockedpassed 783 with 1 ignored;cargo test -p dim-agent-runtime --lib --test agent_runtime_flow --lockedpassed 14 and 34;cargo test -p dim-cli --lockedpassed 959;cargo test -p dim-client --lockedpassed 2 and 4;cargo run --locked -p xtask -- checkpassed;node scripts/adr-check.mjs --base origin/mainpassed.Fixes #2146