Repository navigation
refactor(cognition): typed Observation threaded through act→observe (Steps 0-5 + 18057 acceptance) - #2225
Merged
Conversation
…pes + renderers New `act_observe/observation.rs` owns the typed act value that will thread through the act→observe→re-perceive contract (docs/cognition/TYPED-OBSERVATION-REFACTOR.md): ToolVerb (the ONE verb→class home), ToolOutput (ToolResult + verb + typed paths), ActStatus, Observation, ActOutcome. render_recency / render_recall are pure functions of an Observation delegating to the existing recency helpers (byte-stable, #205). Also lands Step-1 pure helpers: ToolVerb::classify subsumes the `wrote` substring logic and extract_paths() reads typed file paths from call input. No caller changes; apply.rs untouched. cargo check green. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…Outcome
apply_act now builds Vec<Observation> and returns ActOutcome instead of
Option<String>:
- no hands → ActOutcome::NoHands (was None)
- executor batch Err → ActOutcome::ExecutorError { calls, message } (was None —
now distinguishable from no-hands for a future backstop)
- executed / already-satisfied / redundant-orientation → Acted { acts }, each act
a typed Observation whose result correlates by tool_use_id == call.id (NOT the
positional get(i) the string render still uses), verb + paths precomputed.
The two inline renderings + record_receipt/engram admit are UNCHANGED (byte-stable,
#205) — the typed acts are threaded alongside. settle_step's sole call maps
`produced_an_act()` → Acted / ActUnfulfilled (behavior identical to Some/None).
Guard tests migrate string→typed in lockstep; all 35 act_observe tests green.
ts-rs bindings emitted for the 5 new cognition types.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…typed acts on the Receipt WmEntry gains #[serde(default)] acts: Vec<Observation> (back-compat, same contract as saved_at_ms/build_sha). record_receipt_typed(&acts, rendered) stores the byte-identical receipt text ALONGSIDE the typed acts; recent_acts() and active_act() expose them so consumers read the tool result by TYPED FIELD (call.id == result.tool_use_id) instead of re-parsing [action #n] prose (run-18057-f1). apply_act records via record_receipt_typed. Guards: an old volatile.json without acts restores without panic; the typed receipt threads the act by field and keeps recent() byte-stable (#205). Co-Authored-By: Claude Opus 4.8 <[email protected]>
…edicates off receipt prose The live receipt render is a bare name(args) (the 'I ran ' opener was dropped for #158), so the string scans mutated_workspace/wrote_without_observation/ claimed_file_without_act used ('I ran code/write(' …) were DEAD against a real recency window — [no-deliverable]/[unobserved] were structurally unreachable (the seam-5 live drift). Migrate them to read the TYPED verb + paths off WmEntry.acts via recent_entries(): mutated_workspace/wrote_without_observation scope by WmKind::Settlement and test ToolVerb::mutates/observes; claimed_file_without_act matches the claimed file against the typed paths of a MUTATING act (a read no longer backs a completion claim). has_real_action_receipt (brackets-in-prose scan) → any_real_receipt (WmKind::Receipt). settle.rs callers pass recent_entries()/pre_settle entries. Fixtures rebuilt as typed Observations (the string fixtures were GREEN≠REACHABLE — they matched a render the live path never emits). Deferred to keep the sweep green+honest: all_calls_already_satisfied /is_redundant_orientation (still match name(args), which IS in the live receipt, so correct against live data), latest_action_seq, and the Fact-tag→FactKind split. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…_recall are the sole producers The per-call inline format! recency + render_act_for_recall recall blocks in apply_act are gone; both channel strings are now produced ONCE from the typed Observation via the pure render_recency/render_recall helpers (defined in Step 0, byte-identical to the old inline shaping — the humanize/bound/args logic lives in observation.rs now). Render is a pure function of the act, so the recency string and the typed acts can never drift. Sourced from the id-correlated result (tool_use_id == call.id), immune to the fg-vs-original positional hazard. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-thread acceptance assertion Strengthen the_hands_change_the_mind to assert, through the REAL drive_to_settle loop, that the just-executed act's RESULT re-enters via the TYPED field (active_act().output.result.content) and that the call correlates to its result BY ID (call.id == result.tool_use_id) — never a re-parse of [action #n] prose nor a positional index. This is act-grained proof the tool result threads back (the channel run-18057-f1 lost the grep result through as an evictable perception bid → 0-byte patch). recent_acts() exposes the whole investigation off the typed channel. DEFERRED (honest): the message-builder pinned assistant_tool_use↔tool_result pair in llm_deliberation_faculty (the render side of this typed value) is the remaining Step 6 piece. It appends the pair post-arbiter so capacity pressure cannot evict it — but it changes EVERY live persona prompt (KV-prefix shape + adapter tool-part handling + a double-inclusion decision vs the existing wm text trailing), which needs live validation this VDD-gated sweep cannot provide. Not shipped blind. Co-Authored-By: Claude Opus 4.8 <[email protected]>
… evict it (run-18057-f1, #392) The 0-byte SWE-bench patch, structurally. The full result of the act a persona just ran — the grep matches she must edit next, the file she just read — rode the working-memory faculty's single contribution at WORKING_MEMORY_SALIENCE (0.5). That contribution competes in arbiter.focus() top-k, so under capacity pressure the whole thing was truncated and she generated her next turn BLIND to what her own hands had returned. On sympy-18057 that meant: grep for `__eq__`, never see the result, yield nothing. Fix: the live act's full result is now read DIRECTLY from the shared working-memory buffer in the message builder (WorkingMemory::pinned_active_result_block) and appended as its own durable trailing turn — bypassing the faculty bid / arbiter entirely, so no attention pass stands between the hands and the mind. Removed from the evictable faculty contribution (which keeps only the trail + notices + dispatched summary). Identical gating to the old block: settlement-seq gated so it stops re-prefilling once the turn settles (#139/#165), clipped by budget, shown only when it carries more than the trail head. Text on the wire, not structured tool_use/tool_result Parts: content_text() is blind to non-Text parts, so Parts would undercount in fit_messages and risk a window-edge 400, and the live GGUF template renders text reliably. True tool-role Parts is a separate per-template-gated follow-up (#294 family). - New guard `pinned_act_result_reaches_the_prompt_even_with_an_empty_broadcast`: the result reaches the prompt even when NOTHING bid it through the arbiter (the exact eviction state), and never lands in the cacheable system prefix. - Retargeted the three full-result WM tests (whole/clipped/settlement-gate) from the faculty contribution to the pinned block — every invariant preserved. - Fixed a Step-3 test committed red (never run green): restore() appends a [resumed] wake-orientation fact by design (#147/#165), so an N-entry snapshot restores to N+1; the test now asserts survival by content, not an exact count. 945/945 cognition tests green (cargo test -p continuum-core --lib --features metal,accelerate). The live proof — deploy + a persona re-running sympy-18057 with the result threading back to the _sympify edit — is the next step. Co-Authored-By: Claude Opus 4.8 <[email protected]> Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
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.
Gigantic refactor from the blueprint at
docs/cognition/TYPED-OBSERVATION-REFACTOR.md. Kills the stringly-typed act→observe channel — the per-tick re-serialize / re-parse / double-render tax that is BOTH the cognition-loop slowness and the mechanism that drops a persona's tool result (arbiter-evicts the result bid → she yields 0 bytes → false capability-zero on solvable SWE-bench instances like sympy-18057).Landed (Steps 0–5 + Step-6 acceptance):
Observation { call, output, status }+ToolOutput { result: ToolResult, verb, paths }+ToolVerb+ActOutcome(observation.rs), reusing the existingToolCall/ToolResult— no duplication.apply_actreturnsActOutcome(notOption<String>); WorkingMemory stores typed acts (#[serde(default)]back-compat); the 3 dead prose-scanning predicates migrated to typed reads (verb.mutates(), exactpaths); render-once-at-the-boundary.the_hands_change_the_mindnow asserts the tool result threads viaactive_act().output.result.contentandcall.id == result.tool_use_id(id-correlation), not a string split.Local verification:
cargo test -p continuum-core --lib --features metal,accelerate act_observe→ 36 passed, 0 failed (incl. the acceptance assertion + ts-rs exports). Compiles green viacargo checkat every step. CI runs the full suite as the merge gate.DEFERRED (not in this PR): Step-6's actuator — the message-builder pinned
assistant_tool_use↔tool_resultpair (append post-arbiter so capacity pressure can't evict it). That's the literal 18057 fix; it changes every live persona prompt and needs live validation a VDD sweep can't provide. Follow-up, split with BigMama (shared cognition path).🤖 Generated with Claude Code