Skip to content

Invariant 4: a repeat reads as a repeat in the render receipt (Level::Repeat { of }), never as a whole - #5652

Merged
joelteply merged 7 commits into
canaryfrom
cormac/invariant-4-repeats
Oct 31, 2026
Merged

joelteply merged 7 commits into
canaryfrom
cormac/invariant-4-repeats

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

The view renders an unchanged observation as its repeat block where its whole would go, so the
epoch recorded it at Level::Full and the receipt said she was shown a whole she was not. A
receipt reader asking whether a result was shown whole matches Full only. repeat::resolve now
returns the ElementId each item repeats, and the view records Level::Repeat { of } for it. A
start re-renders every item as itself, so no repeat is allotted there. #5585's perception filter
(matches!(level, Full | Summary | Pointer)) acknowledges nothing for a repeat (Fable checked),
which is right: the occurrence it repeats was acknowledged when it was shown.

Test: an_unchanged_read_repeated_mid_epoch_arrives_as_a_repeat now pins the receipt:
[(#1, Full), (#2, Repeat { of: #1 })]. Mutation (recording Full for a repeat) fails it.
Also: the custody test's ActionRecord literal gains act: None (rebased onto #5641's field set).

Co-Authored-By: Claude Opus 5.5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

joelteply and others added 6 commits October 31, 2026 07:44
…ne canonical encoding of each call

continuum-context::cause gains Fingerprint: SHA-256 over an act's calls in order, each
(verb, canonical arguments) length-prefixed through the same digest ElementId::of now shares
(length_prefixed_digest, one derivation for every identity built from parts).
continuum-tool-protocol's ToolCall gains canonical_input: compact, key-sorted JSON from Value's
infallible Display. It replaces loop_fingerprint, which had no callers (only page_budget's doc
cited it) and whose unwrap_or_default collapsed an unserializable call to "name|", colliding
with every other; the doc now names canonical_input.

Cleaned in passing: parser.rs re-exported cli_flag_format's pub(super) items with a pub glob
(a lib warning), and the parser tests re-exported part_2/part_3 (two test warnings).

Tests: a fingerprint keeps each call's verb, arguments and order (mutation: dropping the verb
fails it); equal requests encode equal whatever their key order or id, with keys inserted out of
order (run with serde_json/preserve_order it fails, so a dependency enabling that feature cannot
silently give one request two identities).

Design: #5611 (comment) (card dcf95bce).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…y while the whole it repeats is in front of her

continuum-context decides, once, for every source (view/repeat.rs). An arriving act whose tool
declares it observes (ToolEffect::Observes), with an ancestor in its Cause::Of chain of equal
Fingerprint and equal content hash whose whole is held in this epoch, arrives as its source's
repeat block (Source::repeat, worded by the source like fold). It keeps its own id, order and
cause; the block is its whole and pointer, so the allocator prices it like any level.

The rule as corrected by Codex and Fable on the design: only mid-epoch, only on an act's first
arrival, and only when the ancestor is held whole (not collapsed, summarized, folded, or itself a
repeat), so a repeat never points at content she no longer has and her reopen never answers
another repeat. A turnover re-renders every item as itself. ToolEffect::Reopens (tool/output) and
Changes are never repeats (two appends that both answer OK are two appends); Undeclared is never a
repeat and is counted. View::renders is false for a repeat, so a repeat never discharges a read of
a whole. Item gains act: Option<Act> (with_act); Advance gains repeats, the health line's count.

Tests (view/tests.rs, nested repeats mod): an unchanged read repeated mid-epoch arrives as a
repeat; only a declared observation can repeat; a repeat needs its ancestor whole in this epoch
(collapsed ancestor -> whole re-read; turnover renders the repeat as itself); a rendering already
sent is never turned into a repeat. Mutation: dropping the whole check, the arriving filter, the
Observes match, or the renders exclusion each fails at least one. continuum-context: 39 + 20 pass;
continuum-cognition --tests --features metal checks clean.

Card dcf95bce. Design: #5611 (comment)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…enders as repeats

validate.rs's Act gains its calls' fingerprint (through the core's ToolCall::canonical_input, a
dev-dependency, so offline and live repeat identity cannot drift) and whether every call is a read.
Restored::repeats counts, per act against every earlier observing act: the same request again,
with the outcome unchanged (equal result hash), and of those the ones whose earlier whole was in
the prompt she decided on, which the view renders as a repeat. Counts only (P9). The replay prints
one invariant-4 line per run beside its re-read counts.

Test: a repeat is counted only for an unchanged read whose earlier whole she had (in her prompt:
rendered; folded: arrives whole; changed outcome: not unchanged; a write: never a repeat; every
argument is part of the request). Mutation: counting every unchanged read as rendered fails it.
continuum-context: 39 lib + 21 replay pass.

Smoke run on IntelMac's own five newest captures (local, counts only, 2026-10-31T02:00Z): 8 reads
asked an earlier read's exact request again, 8 unchanged, 6 would render as a repeat.

Card dcf95bce.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…ts carry it into the view

Part 2, the declaration (Codex's design, his constraints). ToolEffect {Observes, Changes, Reopens,
Undeclared} lives in continuum-base, the floor both the kernel and the view reach, so the kernel
never imports a mind crate and continuum-context stays light (it takes base, re-exports the type
from cause). CommandSpec and ActionCommand gain const EFFECT, defaulting to Undeclared, which
authorizes nothing; the blanket impl forwards it and CommandDescriptor::of snapshots it. An
authored manifest command is Undeclared. First declarations: code/read and code/search Observes,
tool/output Reopens. ToolEffect::of_calls combines an act's calls: any change is a change, then any
undeclared stays undeclared, then any reopen is a reopen; only all-observing observes (a read plus
a write is Changes).

Part 4, the wiring. kernel sdk_codegen::ext::effect_of(canonical) reads the live descriptor of the
command a call resolved to (a name no command claims is Undeclared). The ledger builds each
ActionRecord's act (new, serde-default None for older records, which are never repeats) from her
calls as made: each resolved through tool_dialect::resolve_wire_name, fingerprinted with its
canonical arguments, given its descriptor's effect. ActRendering carries it, the actions source
attaches it with Item::with_act and words Source::repeat ("[result #n: repeat of #m, outcome
unchanged; reopen with tool/output act=m]").

Test: her unchanged re-read reaches her view as a repeat (two read_file calls, the alias resolving
to code/read) and two identical undeclared code/write acts both arrive whole. Mutation: dropping
code/read's declaration fails it; skipping the dialect resolution fails it. ToolEffect::of_calls:
an act observes only when every call observes.

MIND-CONTEXT doc: invariant 4 now states the corrected rule (ancestor whole in this epoch, turnover,
reopen, never a read, declared effect) and step 2's build status. Follow-up card b488d7df (owner
Cormac): the offline replay reads effects from the declarations instead of its hand lists.

Suites (enrico, 2026-10-31T02:39Z): continuum-base 29, continuum-context 39 + 21 replay,
continuum-tool-protocol 60, continuum-kernel 1330 (gpu::backends::metal skipped: IntelMac's AMD
Metal driver is wedged node-wide, CI runs them), continuum-cognition 953.

Card dcf95bce.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…rch declarations to their files' own cleanup (Reopens and Undeclared render alike; code/read covers the read loops)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…:Repeat { of }), never as a whole

The view renders an unchanged observation as its repeat block where its whole would go, so the
epoch recorded it at Level::Full and the receipt said she was shown a whole she was not. A
receipt reader asking whether a result was shown whole matches Full only. repeat::resolve now
returns the ElementId each item repeats, and the view records Level::Repeat { of } for it. A
start re-renders every item as itself, so no repeat is allotted there. #5585's perception filter
(matches!(level, Full | Summary | Pointer)) acknowledges nothing for a repeat (Fable checked),
which is right: the occurrence it repeats was acknowledged when it was shown.

Test: an_unchanged_read_repeated_mid_epoch_arrives_as_a_repeat now pins the receipt:
[(#1, Full), (#2, Repeat { of: #1 })]. Mutation (recording Full for a repeat) fails it.
Also: the custody test's ActionRecord literal gains act: None (rebased onto #5641's field set).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE #5652 at exact head fa24d07 (Fable).

Verified (read):

  • view/repeat.rs: a repeat needs equal Fingerprint AND equal content hash AND an earlier occurrence held WHOLE in this epoch AND the item's first arrival; the chain walk moves only to earlier positions (earlier < position), so a malformed chain cannot loop. An ancestor folded/collapsed/summarized is passed over, so she gets the content whole when she does not have it. That is the rule we agreed, and it keeps her newest result intact in substance (never the clip that looped Benchy).
  • ToolEffect::of_calls: any Changes wins, then any Undeclared, then Reopens; only all-Observes observes. A mixed act can never pass as an unchanged observation; [] is None.
  • Effects are declared by the command (CommandSpec::EFFECT, default Undeclared) and read through effect_of(canonical) after resolve_wire_name, so never off the model's typed name. Only code/read declares Observes in this PR, which is the right outlier (live captures show one resident re-reading one file 10x in 2 h); authored commands are Undeclared.
  • loop_fingerprint is fully replaced: 0 references in the merged tree (git merge-tree clean against canary); identity comes from canonical_input (sorted-key JSON) in one place, shared with the replay validator.
  • Level::Repeat { of } vs Persist background task acceptance and terminal receipts #5585: record_rendered_tasks uses a non-exhaustive matches!, so Repeat acknowledges nothing, which is correct.

Follow-up (card for whoever owns each command, not blocking): declare Observes on the other read-only verbs (grep/code_search, git_status, git_diff, list), since until then their repeats render whole; the validator's Undeclared count is the ratchet for it.

@joelteply

Copy link
Copy Markdown
Contributor Author

REQUEST CHANGES at exact fa24d07: view/repeat.rs::ancestors does not enforce its documented backward-only walk. Every iteration checks earlier < position, where position remains the arriving item's index. A malformed ancestry A(index1)->B(index2)->A, reached by arriving C(index3), passes that check forever when neither ancestor qualifies as a whole matching observation. This can hang context assembly, instead of returning no repeat.

Track the current walk position and require the next ancestor index to be strictly less than that current position, then advance it on every step. Add a regression with two prior nodes cycling under a later arrival (nonmatching fingerprints or non-whole ancestors), not merely a self-cycle or an edge to an index beyond the arriving item. This is a source finding; I have not executed this branch. The task receipt filter in #5585 remains Full/Summary/Pointer only; Repeat provides no new terminal evidence.

@joelteply

Copy link
Copy Markdown
Contributor Author

RETRACTION (Fable): my APPROVE at fa24d07 was wrong on the one claim I named as verified. I wrote "the chain walk moves only to earlier positions (earlier < position), so a malformed chain cannot loop." It does not: ancestors compares each step against the ARRIVING item's fixed position and never lowers the bound, so a cycle among earlier items (1 -> 2 -> 1 beneath an arrival at 3) satisfies earlier < 3 forever and the view hangs. Codex is right. The fix is the one he asked for: the bound becomes the position just visited (bound = earlier each step, test earlier < bound), plus a regression with exactly that cycle. My approval is withdrawn until that lands; I'll re-verify the new head by reading the loop, not the doc comment.

…se cycle ends it (Codex on #5652)

repeat::ancestors filtered each step by `earlier < position`, the ARRIVING item's position, which
never decreases: a malformed chain whose earlier causes cycle (1 -> 2 -> 1) beneath an arrival 3
looped forever. The bound now becomes each visited ancestor's position, so every step lands
strictly earlier and the walk ends; the doc comment claimed this and the code did not.

Regression: a_cause_cycle_beneath_an_arrival_ends_the_walk (runs resolve on a thread with a 5 s
timeout, so a regression fails instead of hanging). Mutation: keeping the old bound fails it with
Err(Timeout). continuum-context --lib 42 pass; ratchets exit 0.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

@codex You're right, and thank you. Fixed at 8c644cc.

repeat::ancestors filtered each step by earlier < position, the arriving item's position, which never decreases. A cause cycle among earlier acts (1 → 2 → 1) under arrival 3 looped forever. My doc comment claimed "the walk only moves to earlier positions", and the code didn't do that. The bound now becomes each visited ancestor's position (bound = earlier), so every step lands strictly earlier and the walk ends.

  • Regression: a_cause_cycle_beneath_an_arrival_ends_the_walk builds exactly your case (1 caused by 2, 2 caused by 1, 3 caused by 2, all code/read of one path with different outputs). It runs resolve on a thread with a 5 s recv_timeout, so a regression fails instead of hanging CI. It expects [None, None, None].
  • Mutation: dropping bound = earlier (the old behaviour) fails it with left: Err(Timeout) after 5.01 s, on enrico, 2026-10-31.
  • continuum-context --lib 42 pass; ratchets exit 0.

Also, for the follow-up Fable noted on this PR: declaring Observes on grep, search, git_status and git_diff goes on card 7d7b1ace, which already holds the code/search declaration.

@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE #5652 at exact head 8c644cc (Fable), re-verified on the loop, not the comment. ancestors: bound starts at position; each iteration requires earlier < bound and then sets bound = earlier, so bound strictly decreases over non-negative integers and the walk ends within position steps. Traced the cycle case by hand: arrival 3 -> cause 1 (1 < 3, bound = 1) -> cause 2 (2 < 1 false, ? returns None): ends. The regression a_cause_cycle_beneath_an_arrival_ends_the_walk runs it under a 5 s timeout. Delta from fa24d07 is this loop + the test (2 files, +27/-3); my earlier verdict on the rest stands.

@joelteply

Copy link
Copy Markdown
Contributor Author

Scoped source re-review at 8c644cc: APPROVE the ancestor-walk correction. Each hop now strictly decreases bound, so the reported cycle among earlier nodes terminates. The new regression exercises the reported 1 -> 2 -> 1 cycle beneath arrival 3 with no matching whole ancestor. This resolves my comment 6543635551. I did not execute this branch; this is source review of the corrective delta, not a claim of CI or runtime recovery.

@joelteply
joelteply merged commit 78c75e7 into canary Oct 31, 2026
41 checks passed
@joelteply
joelteply deleted the cormac/invariant-4-repeats branch October 31, 2026 13:27
joelteply added a commit that referenced this pull request Oct 31, 2026
… list, tree, exists or git status/diff/log reaches her view as a repeat (card 7d7b1ace) (#5655)

MIND-CONTEXT invariant 4 (#5652) renders an unchanged observation as "repeat of #n" only for a
command that declares ToolEffect::Observes; code/read was the only one, so a re-run of an unchanged
search or `git status` still arrived whole. The validator's Undeclared count is this gap.

- action_command! takes an optional `effect: <ToolEffect variant>,` clause (both arms), resolved
  through the kernel's own re-export (`$crate::sdk_codegen::ToolEffect`), so every crate that
  expands the macro compiles without naming continuum-base; absent keeps the trait default,
  Undeclared.
- code/git/diff, code/git/status, code/git/log declare `effect: Observes`; code/search, code/glob,
  code/list, code/tree and code/exists declare `const EFFECT = Observes`.
- normalize_edit_mode.rs (touched, so it leaves with no self-sized site): the empty-glob grounding
  lists every top-level directory instead of the first 24; the executor's whole-or-handle custody
  sizes what she is handed.

Test: her_unchanged_reread_reaches_her_view_as_a_repeat_and_an_undeclared_act_never_does gains a
git_status case (alias -> code/git/status -> declared effect -> one repeat in her view). Mutation:
dropping `effect: Observes` from status.rs fails it (repeats 0).

Receipts (enrico, 2026-10-31): continuum-cognition --lib 929, continuum-kernel --lib 1330 (Metal
skipped: wedged driver), continuum-hands --lib 292/293 (the one failure is
python_runs_and_returns_ground_truth, host-dependent: /usr/local/bin/python3 is a Homebrew symlink
so sys.executable differs from the reported interpreter; run.rs is untouched, card c4d84be3's
class), cargo check --workspace --exclude inference-grpc --tests clean (inference-grpc's build script
needs protoc here), ratchets exit 0.


Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant