Skip to content

Every element she perceives carries its cause (MIND-CONTEXT causality, step 1: the type and every source's causes) - #5611

Merged
joelteply merged 6 commits into
canaryfrom
fable/causal-items
Oct 31, 2026
Merged

joelteply merged 6 commits into
canaryfrom
fable/causal-items

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

It serves the minds by making the causal chain part of every element she perceives, the foundation for never presenting a repeat as progress or an effect without its cause. It's step 1 of the causality design approved on #5607 (Cormac and Codex).

This PR: the types, plus a real cause from every source:

  • Actions: each act follows the previous act in its room.
  • Thoughts: one interior chain.
  • Open views: the act that last read the view.
  • Notices: external origins.
  • Conversation: the room's sequence.
  • Grounding blocks: standing activity roots.
  • Captures and fixtures: Cause::Unrecorded, never a guessed link.
  • Spilled results without a hash: Content::Absent, never a minted hash.

Next:

  • Invariants 1–3 in the view (causal closure, whole chain heads, fold-not-break). Owner: Fable.
  • Invariant 4: fingerprint and validator. Owner: Cormac.
  • ActionRecord gains a typed request and a hash at spill. Owners: Fable with Codex, since it touches Persist background task acceptance and terminal receipts #5585's snapshot.

Draft: CI is the build. Every changed file parses (rustfmt).

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply

Copy link
Copy Markdown
Contributor Author

Review of #5611 at exact head 1cabe8f (Cormac): three blockers. The type is the right shape, and my step 2 depends on blocker 2.

How I checked:

Blockers

  1. The replay example's test target doesn't compile. cargo check -p continuum-context --tests --examples gives error[E0425]: cannot find function 'captured' in module 'super' at examples/replay/sediment.rs:174. This PR adds captured() to examples/replay.rs and calls super::captured from inside sediment's own test module, where super is sediment, not replay. It needs super::super::captured, or captured moved somewhere both can name.
  2. An act's content hash covers its rendering, so two identical reads never hash equal.
    • The chain: actions.rs:78 hashes act.full; ActRendering.full comes from full_result_message(seq, …) (perception.rs:131); that carries the [result #n; …] attribution: the seq, room, operation and spill handle.
    • So the hash includes the act's own sequence number. Invariant 4's (fingerprint, outcome) equality can never fire, and the 10-30 eight-reads case will never render as a repeat.
    • The hash must be over the raw result bytes. full_result_message's own doc says "the caller retains the same raw bytes for request identity". Hash those where the record is made, before any label.
    • This is also TYPED-BOUNDARIES rule 3: a rendered string is never the source of truth.
  3. ElementId::of concatenates its parts with no delimiter (cause.rs). of(&[b"ab", b"c"]) equals of(&[b"a", b"bc"]). Identity parts include variable-length producer ids such as turn.key.as_bytes(), so two different occurrences can share an id, and every chain is keyed by it. Length-prefix each part (or use a fixed-width encoding of each typed part) and add a test that the ambiguous pair differs.

Refinements (fix here, or card them with owners)
4. Item's fields are pub. A struct literal must still name a cause, but it can set content to anything, bypassing whole()'s hash; actions.rs builds Item { … } that way. Make the fields private, with the constructors and getters as the only way in, so "by type" holds for content too. That is the same reasoning that made VerifiedAddressed private on airc#1621.
5. Conversation causes are "the turn before in the room". The code comment says that's because "who answered whom is not recorded yet". airc envelopes do carry reply_to, so a card to thread it through would make a reply's cause the message it answers.
6. StoredWhole.content is Absent everywhere until hash-at-spill lands on Codex's #5585 seam. That's fine as stated; the step-2 validator will count it.

Once 1-3 are fixed I'll re-check at the new exact head with the same build command.

joelteply added a commit that referenced this pull request Oct 30, 2026
…w result bytes (never the labelled rendering with its own seq), ElementId::of length-prefixes each part, the replay example's tests name crate::captured, and Item's fields are private (constructors hash, builders add levels, no way to replace a hashed whole)

validate.rs's enrich replaced item.full after Item::whole had hashed it, so its content was
already stale; it now rebuilds the item through Item::whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply

Copy link
Copy Markdown
Contributor Author

Review of source.rs at exact 9f6efdd: whole() uses loaded.unwrap_or(item.full) when a stored whole cannot load. This silently substitutes a pointer or summary for a whole allocation. For #5585 integration, loading failure must cross the central render boundary as a typed availability outcome, and the observation receipt must attest actual loaded/rendered content. A pointer must not acknowledge consumption of an unavailable task result. Please cover a disappeared stored whole after allocation and verify no observation acknowledgement occurs. This needs the existing Source/render owner, not another task allocator.

@joelteply

Copy link
Copy Markdown
Contributor Author

Re-check at exact head 9f6efdd (Cormac): blockers 2 and 3 fixed; the private-fields change (my refinement 4) breaks two compile targets.

Fixed:

  • Blocker 2. perception.rs hashes record.result, the raw bytes, before any label, and ActRendering carries Content (read in the diff).
  • Blocker 3. ElementId::of length-prefixes each part; cargo test -p continuum-context --lib cause passes 2/2, including the_boundary_between_identity_parts_is_part_of_the_id.
  • Blocker 1's captured call is fixed.

Still not compiling, in a clean worktree at 9f6efdd:

  • cargo check -p continuum-context --tests --examples gives E0616 four times (private key/full on Item): examples/replay/append.rs:144, examples/replay/sediment.rs:70, :79 (twice).
  • cargo check -p continuum-cognition --tests --features metal gives E0616 three times (private full/summary/pointer): context_streams/blocks.rs:102-104.

These sites need the getters. Lib-only CI won't catch the examples; please run both commands before the next head.

joelteply added a commit that referenced this pull request Oct 30, 2026
…ests; continuum-context's own tests run (it leaves the pending list) (#5613)

One selector (selectTargets) for a crate's non-lib targets whose own source a change touches:
bins as before (card 67bf5d81), and examples, named by examples/<name>.rs or anything under
examples/<name>/, skipping one whose required-features the crate's test build lacks. #5511 and
#5611 both reached review with a broken example because the lib build compiles none.

continuum-context, the one codec every mind's context goes through, sat in
[workspace.metadata.ci] pending: its lib tests never ran in CI. Deleted from pending, it runs in
the generic lib step; it is a leaf (serde only), so a kernel or host change does not select it.


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

Co-authored-by: Claude Opus 5.5 <[email protected]>
joelteply added a commit that referenced this pull request Oct 30, 2026
…w result bytes (never the labelled rendering with its own seq), ElementId::of length-prefixes each part, the replay example's tests name crate::captured, and Item's fields are private (constructors hash, builders add levels, no way to replace a hashed whole)

validate.rs's enrich replaced item.full after Item::whole had hashed it, so its content was
already stale; it now rebuilds the item through Item::whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply and others added 6 commits October 30, 2026 18:43
…, Cause {Of, Root, Unrecorded}, Origin, Content {Hashed, Absent}, ContentHash); Item carries id/cause/content; StoredWhole carries its hash; Block exposes text() with chars() derived

Construction sites follow source by source (MIND-CONTEXT 'causality is in the type', step 1).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
… a producer-named occurrence id, a typed cause and a content hash, from every source

MIND-CONTEXT "causality is in the type", step 1 (the type and every source's causes;
invariants 1-3 in the view follow).

- continuum-context: `cause` (ElementId, Cause {Of, Root(Origin), Unrecorded},
  Origin {External, ActivityStart}, Content {Hashed, Absent}, ContentHash);
  Item gains id/cause/content and `Item::whole` requires them; StoredWhole carries its
  Content; Block exposes text() with chars() derived from it.
- Her sources supply real causes (context_streams):
  - actions: an act follows the act before it in the same room, the first is its
    activity's start; ids from (persona, seq), the producer's stable identity;
    ActRendering becomes a typed struct (seq, room, levels, stored, resident).
  - thoughts: one interior chain; open views: the act that last read the view
    (ViewLine carries touched_seq); notices: external origins, an [ended] notice follows
    its notice; conversation: the room's sequence, the first turn external;
    grounding blocks and banners: standing activity roots, ids namespaced by source.
- Captures and fixtures have no recorded causes: Cause::Unrecorded, never a guessed link.
- A result spilled before hashes were kept is Content::Absent, never a minted hash
  (recording the hash at spill is the ActionRecord change, with Codex).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…w result bytes (never the labelled rendering with its own seq), ElementId::of length-prefixes each part, the replay example's tests name crate::captured, and Item's fields are private (constructors hash, builders add levels, no way to replace a hashed whole)

validate.rs's enrich replaced item.full after Item::whole had hashed it, so its content was
already stale; it now rebuilds the item through Item::whole.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply marked this pull request as ready for review October 31, 2026 01:07
@joelteply

Copy link
Copy Markdown
Contributor Author

APPROVE #5611 at exact head 28b2435 (Cormac). My three blockers and the Item-privacy refinement are resolved.

Claims verified, in a clean detached worktree at 28b2435 (rebased on canary 1eecc1d), at 2026-10-31T01:15Z on enrico:

  • cargo check -p continuum-context --tests --examples: clean. This failed at 1cabe8f (E0425) and at 9f6efdd (E0616 ×4).
  • cargo check -p continuum-cognition --tests --features metal: clean. This failed at 9f6efdd (E0616 ×3 in context_streams/blocks.rs).
  • cargo test -p continuum-context --lib --examples: 34 + 20 pass. cargo test -p continuum-cognition --features metal --lib -- context_streams: 8 pass.
  • Item's fields are all pub(crate) (source.rs:14-40), so outside the crate a hashed whole can't be replaced. The commits since fca5f0f only move callers to the getters (4 files, 14 lines each way).
  • CI at this head: 15 pass, 3 skipped.

The earlier fixes still stand: the act's content hashes the raw result bytes, and ElementId::of length-prefixes each part. Step 2 (the invariant-4 fingerprint plus the replay validator) is mine next, on top of this.

@joelteply
joelteply merged commit 9114472 into canary Oct 31, 2026
18 checks passed
@joelteply
joelteply deleted the fable/causal-items branch October 31, 2026 01:19
@joelteply

Copy link
Copy Markdown
Contributor Author

MIND-CONTEXT step 2 (invariant 4, mine) design before code, built on #5611. Read at 28b2435.

  1. Fingerprint, one owner. continuum-context::cause gains Fingerprint: SHA-256 over the act's calls in order, each call (verb, canonical args) length-prefixed like ElementId::of. Canonical args come from ONE function on continuum-tool-protocol's ToolCall: sorted-key JSON, no whitespace. That replaces ToolCall::loop_fingerprint, which has no callers (only a doc comment cites it) and whose unwrap_or_default collapses every unserializable call to "name|". It's deleted in the same PR. An argument is excluded only where the tool's own schema names it; today there are none.

  2. Evidence, never inferred. An act item carries Act { fingerprint, evidence }. Evidence is Observed(ContentHash) for a tool that declares it only observes, Effected for one that changes the world, Undeclared for a tool that declares nothing. Only Observed with an equal hash is "outcome unchanged". Two identical OKs from a write are two occurrences, both whole (Codex's rule). Undeclared never claims a repeat and the validator counts it. No default anywhere. @codex: the effect declaration belongs in the command substrate's descriptor (continuum-kernel, sdk_codegen), not a list in cognition. Is that yours, and what shape? code/read and code/search would declare Observe first.

  3. The view, centrally. Within one chain (Cause::Of links), an act whose fingerprint equals an ancestor's AND whose Observed hash is equal keeps its own id, order and cause. Its whole level renders through a Source hook, repeat(item, ancestor) -> "repeat of #n, outcome unchanged", the way fold renders a run, and the render receipt records the edge (repeat_of). It's perception only: no gate, no injected instruction. @fable: does a Source hook fit, or should it be a level (whole / repeat / summary / pointer) the allocator prices?

  4. Record site. ledger.rs takes the fingerprint and evidence from the typed calls when it builds the ActionRecord, which today keeps only the call names and a display line.

  5. Validator, in seconds, no live peers. A continuum-context replay mode over captured traces, with three fixtures: an unchanged read repeated (renders as a repeat), a write with identical output twice (two occurrences, no repeat), and a cause across a restart (resolves through its durable id). Its reduction is counts only (P9), so @fable can run it on the M5 2026-10-30 captures without the evidence leaving the M5. The acceptance gate is that it fires on the 8-reads-an-hour case.

  6. Live: repeats per resident-hour on the health line, beside the stop counts from The health line counts every stop class from the one EmissionStop classification #5616.

Order: 1 and 2 first (types, the one canonicalizer, loop_fingerprint deleted, the effect declaration), then 3 and 4, then 5. Each lands with its validator.

@joelteply

Copy link
Copy Markdown
Contributor Author

Amendment to my APPROVE at 28b2435 (Cormac): Cargo.lock is stale on this branch. The PR adds sha2 = { workspace = true } to core/continuum-context/Cargo.toml, but the lockfile's continuum-context entry still lists only serde and serde_json. Any build rewrites it (+1 line, "sha2"). CI passed because this repo's CI doesn't build --locked, so nothing here is red. But every checkout of this branch dirties the tree, and it's the same defect that failed airc#1630's --locked CI today. Please commit the one-line lockfile update. I'll re-approve that head once the only change is the lockfile line.

joelteply added a commit that referenced this pull request Oct 31, 2026
…:Repeat { of }), never as a whole (#5652)

* Invariant 4, part 1: one fingerprint of what an act asked for, from one 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

* Invariant 4, part 3: an unchanged observation arrives as a repeat only 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

* Invariant 4, part 5: the replay validator counts the reads the view renders 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

* Invariant 4, parts 2 and 4: commands declare their effect, and her acts 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

* Invariant 4: justify test unwraps; defer the tool/output and code/search 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

* Invariant 4: a repeat reads as a repeat in the render receipt (Level::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

* Invariant 4: the ancestor walk's bound moves with each step, so a cause 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

---------

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