Skip to content

Her collapsed history is a log laid down byte for byte; starts place sources by measured change; one canonical tool head (replay: -20% prefill) - #5805

Merged
joelteply merged 3 commits into
canaryfrom
fable/collapse-log-placement
Nov 7, 2026
Merged

joelteply merged 3 commits into
canaryfrom
fable/collapse-log-placement

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

Stacked on #5803. This serves the residents' pace: path step 1 (Fast) and order-of-work line 2 (a mind's context as an epoch). The engine's KV is a cache keyed by prefix path, and a turnover misses everything after its first change. On the M5 every recorded turnover re-decided her collapsed history from scratch and resumed from the system head. Each design below was scored on the recorded data before it was built.

Scored before building (M5, core ed142f1, 2026-11-06 16:13-19:17Z; 13 recorded starts, 158 pairs)

Method. Each captured prompt's view is cut into source units by its headers, and each history item is marked collapsed when it renders as a handle, a summary or a fold block. A start is compared against the previous epoch as that epoch's start laid it down (its first run per source), not against the latest versions. The scoring scripts are in the scratchpad (score.py, depth.py).

  • +1: append-only collapse. A's collapsed items keep their bytes; the new slice appends.
  • +1+2: append-only collapse plus automatic placement. Units are ordered by s(1-q)/q + k:
    • q is the chance a unit differs at the next start. It blends what her previous starts measured with her per-act change rate over her measured epoch length, 1-(1-p)^E.
    • k is the front a unit keeps when it does change. For the log, k is its whole size.
    • A unit never measured is Unmeasured and goes to the tail. Hysteresis comes from the measurement error.
    • Sharing across minds is weighted at about nothing (measured at about 2% of fresh tokens).
  • Ceiling: every unit unchanged at the start first, then the unit with the longest kept front.
Start Today #5803 +1 +1+2 Ceiling
Aiko 468b0119 14,149 29,535 29,524 29,077 34,629
Aiko 9c054d0e 31,126 30,963 30,947 33,729 34,804
Aiko c62f8de1 14,143 22,181 22,172 28,447 29,018
Aiko 34ffb086 14,143 22,260 22,251 28,525 29,280
Aiko 54a0d83f 13,678 13,675 13,671 42,911 43,289
Aris 358a35b1 19,434 19,393 19,379 24,065 29,856
Aris 5de962fd 13,678 13,675 13,671 13,672 25,326
Aris a5d9d67b 13,678 13,871 13,864 15,731 21,994
Aris 2dc03a95 19,539 19,475 19,458 21,575 25,823
Aris 5a508f83 19,715 19,641 19,619 22,133 26,381
Aris bba062d0 16,890 21,369 21,336 15,705 30,159
Benchy a3242b5d 14,716 14,723 15,610 13,591 21,776
Benchy c3e67a28 14,792 14,754 14,736 17,809 17,809
13 starts (shared tokens) 219,682 255,515 256,239 306,970 370,142
Missed at these starts in 3 h 504,443 tok / 3,503 s 468,610 / 3,254 s 467,886 / 3,249 s 417,156 / 2,897 s

Collapse depth per mind (item 3; measured, no constant):

  • Inputs: W is what her window lets her view hold, g is her median growth per act (both from the delib.view.sized probes), and C is what a start keeps under +1+2.
  • A start of size S lives (W - S) / g acts and misses S - C tokens, so the miss per act is g(S - C) / (W - S).
Mind W (tok) g (tok/act) Start now Epoch now Miss/act now Best start Best epoch Miss/act
Aiko 104,434 1,882 62,589 (d 0.40) 22.2 2,122 23,879 (d 0.77) 42.8 198
Aris 61,246 5,914 23,807 (d 0.61) 6.3 2,974 16,265 (d 0.73) 7.6 1,484
Benchy 47,774 1,622 18,863 (d 0.61) 17.8 797 10,696 (d 0.78) 22.9 264
  • On the miss term alone, miss per act falls as the start shrinks. The best start is therefore the smallest one that still keeps her current state and newest interaction whole: older history whole gets turned into handles.
  • The depth policy is not changed in this PR. The term this objective lacks is what a handle costs her: re-reading what collapsed. The replay can measure that cost, but it is not in this score. Without it, the miss-only optimum always says "collapse everything older", which goes against her working set. Follow-up: choose depth per mind from miss per act plus measured re-read cost. Owner: Fable.

Built, through the owners

1. Append-only collapse (continuum-context view/log.rs and View::begin)

  • An item collapses once. The first start that gives it a summary, a handle, or a place in a fold block writes that rendering to her log.
  • Every later start lays the log down again byte for byte and appends what collapses now.
  • Only each source's oldest collapsed run is logged (up to its first item kept whole), so a source's items keep their order.
  • A logged item still rises when there is room: it renders whole at the front of its source's items and its log entry stays. This keeps the 2026-10-29 restore behaviour (Aiko's fifteen handles).
  • The log folds only when a source's logged history outgrows its grant. delib.view.turnover now carries log_kept_chars and log_folded.

2. Automatic placement, only at a start (continuum-context motion.rs, extending #5803's motion)

  • Each source keeps a per-act change rate, decayed to her last epoch, beside what her starts measured.
  • Motion::rank orders units as scored above. A unit with logged history never goes ahead of the log.
  • Within an epoch the view still only appends. Per your measurement (85% -> 54% hits from per-act reordering), nothing reorders between acts.
  • The first changed block is laid where it stood only when the order puts it next anyway. A block the order moved back is not pulled to the front.

4. One canonical tool order (continuum-cognition tool_surface.rs, ToolSurface::build)

  • Verbs are ordered by how widely they are held (Always, Core, OnDemand, Withheld), then by name.
  • A smaller set is now a prefix of a larger one. Benchy's 30 verbs are a subset of the others' 39 and used to diverge at verb 18, where on-demand focus/* sorted between core hands. Now the shared tools head goes from 12,969 to about 25,310 chars (about 4.3k to 8.3k tokens) across all four minds.
  • The per-mind identity line already follows the shared [Your tools] text: minds with the same tool set share 6,146 system chars. Nothing to move.

Measured (the replay, on the real View code)

continuum-context examples/replay.rs --append-tail 144 over each resident's captures (.prev.jsonl + .jsonl), before (#5803, 80bc75e) and after (f76f8b7):

Capture Prefill before (tok) After (tok) Turnovers Re-prefill per turnover
Aiko (prev) 2,141,502 1,266,844 28 -> 18 50,848 -> 41,382
Aiko 677,594 686,062 9 -> 9 58,438 -> 58,372
Aris (prev) 1,267,926 1,100,314 21 -> 20 39,062 -> 32,128
Aris 329,888 295,750 5 -> 5 44,565 -> 37,740
Benchy 247,158 198,939 5 -> 4 31,011 -> 29,582
Atlas (prev) 728,027 748,658 14 -> 14 33,532 -> 34,868
Atlas 877,890 714,273 16 -> 12 38,829 -> 42,444
Total 6,269,985 5,010,840 (-20.1%)

At 144 tok/s that is 43,542 s -> 34,798 s. Two captures got slightly worse: Aiko's current one (+1%) and Atlas's earlier one (+3%).

Tests (each with a what this catches: note):

  • the collapsed log is laid down byte for byte at every later start, with the new slice after it;
  • adversarial: a source that turns from stable to volatile drifts behind a stable one, and the shared prefix recovers within two starts;
  • rank: never-changed units first, Unmeasured last, ties keep the last order;
  • the log stands by what it keeps, and its sources follow it;
  • the lead rule: a changed block the order moved back stays back;
  • restores still give items back, now with room for the log entry beside them;
  • a smaller tool set is the head of a larger one.

Validation (crate-scoped, nice -n 19, own target dir, no workspace build, no reboot):

Crate Tests Result
continuum-context lib 77 pass
continuum-cognition --features metal lib 941 pass
continuum-grounding lib 6 pass
continuum-mind subset 105 pass
continuum-academy eval 34 pass
continuum-core mind integration 96 pass
continuum-core tool / registry / hands / surface 132 pass

Post-deploy check (owner: Fable)

  • Turnovers: for each delib.view.turnover, compare log_kept_chars and the engine's resume: cached count with the window before deploy. Expect a cached count above the system head at most starts.
  • Load: prefill tokens per act and turnovers per hour, over the same 3 h window shape.
  • Cross-mind: the shared tools head on slot handoffs.
  • Worse than canary on median act time means the node goes back to canary at once.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

joelteply added a commit that referenced this pull request Nov 6, 2026
…down log it did not charge

Codex on #5805: `arrange` charged logged chars only to the sources a start was given, but
`begin` re-emitted the whole retained log, so the entries of a source absent from the start
(shed for want of its floor in `fit_view`, a stream that ended, a room she left) were laid
down charged to no one, survived a zero-source start, and kept the source's items marked
collapsed, so its return showed her stale pointers. Nothing in the caller contract forbids
the absence: `fit_view` sheds sources at a start by design ("A later act's advance offers it
again").

Now `log::arrange` decides, per entry, whether this start charges it (its source is
supplied), and `begin` keeps exactly those: the charge and the emission are one decision.
The dropped chars are receipted (`Start::log_dropped_chars`, probed on delib.view.turnover).

Reproduced first: a zero-source start rendered "head" + s1..s3's three pointers (960 chars
uncharged). Tests: an absent source's log leaves and its items come back whole; a zero-source
start lays down no log; a zero-grant start folds the log to the floor.
Replay (--append-tail 144, stable prev captures): Aiko and Atlas unchanged; Aris prev
1,100,314 -> 1,110,400 tokens (+0.9%), the cost of no longer re-emitting an absent source's
log uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
joelteply added a commit that referenced this pull request Nov 6, 2026
…er measured re-read cost

Her view now measures how often she asks again for what she already observed
(continuum-context rereads.rs, kept in Motion with the per-source stats #5803/#5805
keep): at every act each observing occurrence is exposed at its age in acts, and an
arrival with the same request fingerprint and outcome hash is a re-request at that age,
tallied over every level and over collapsed ones separately, halved at each start.

depth.rs chooses each instrumented growing source's start: walking its items newest
first, an item stays whole only while hazard x whole x (1 + (S-C)/(W-S)) exceeds the
turnover miss it saves, miss(S) = g (S-C)/(W-S). An age nobody was exposed at, a source
whose items carry no act, or no measured growth is Unmeasured and keeps the half rule.
start_grants (cognition) applies the chosen shares and probes delib.view.depth.

Replay (--append-tail 144 --measured-depth, 15 captures, deliberation + act):
8,478,327 -> 8,395,003 prefill tokens (-0.98%), 3 fewer turnovers.

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

Copy link
Copy Markdown
Contributor Author

Fixed Codex's finding in f35ab53: a source absent from a start had its logged history re-emitted without being charged.

1. No caller contract rules out a source disappearing between starts. The caller does it on purpose. fit_view sheds sources at a start (epoch.rs 191-205, act.shed_view_sources()): "a source the allocation could not grant its floor is shed from this epoch ... A later act's advance offers it again". Source::items also allows an item to leave its source (source.rs 155-157).

2. Reproduced through the real View, before the fix. In the test, source s has its three oldest reads logged as pointers. The new tests then failed:

  • A zero-source start (turn_over(head, &[], ..)) rendered head plus [s1: 320 chars …], [s2 …] and [s3 …]: 960 chars that no claim paid for.
  • A start without s also re-emitted them.
  • Those items stayed marked collapsed, so when s returned she saw stale pointers instead of the items.

3. The fix. log::arrange now decides, for each log entry, whether this start charges it: it does when the entry's source is supplied. begin keeps exactly those entries, so charging and emitting are one decision.

  • An absent source's entries are dropped with it.
  • When it returns, its items arrive as themselves.
  • The dropped chars are recorded in Start::log_dropped_chars and probed on delib.view.turnover.
  • A zero-grant start with the source present still folds the log down to the floor (existing behaviour, now tested).

4. Tests (view/tests/absent_source.rs):

  • An absent source's log leaves with it: the start holds exactly head plus the kept source, and the absent source's items come back whole when it returns.
  • Neither a zero-source start nor a zero-grant start lays down log it did not charge.

Validation (crate-scoped, nice -n 19):

  • continuum-context tests: 79 lib (77 + 2) and 21 example tests pass.
  • continuum-cognition --features metal --lib: 941 pass.
  • Clippy on continuum-context: lib clean.
  • Ratchets: every count unchanged.
  • oversized-edits.sh: passes (view.rs 815 lines, view/tests.rs 962).

Cost. Replay (--append-tail 144) on the stable prev captures:

  • Deliberation: Aiko and Atlas unchanged; Aris goes from 1,100,314 to 1,110,400 tokens (+0.9%).
  • Act prompts: Aiko from 420,629 to 425,784 (+1.2%); Aris from 460,326 to 484,232 (+5.2%).

The earlier numbers were lower only because an absent source's log stayed in the prefix without being charged.

#5806 is rebased onto this (a449511).

🤖 Generated with Claude Code

@joelteply
joelteply force-pushed the fable/epoch-start-order branch from 80bc75e to 6764141 Compare November 6, 2026 23:42
Base automatically changed from fable/epoch-start-order to canary November 6, 2026 23:53
joelteply and others added 2 commits November 6, 2026 21:18
…s sources by measured change; tool lists share one canonical head

Every recorded turnover on the M5 (core ed142f1, 2026-11-06) re-decided her collapse from
scratch and resumed from the system head.

- continuum-context view/log.rs: an item collapses ONCE. A start writes her oldest collapsed run
  (summaries, handles, fold blocks) to a log and lays that log down again byte for byte at every
  later start, appending what collapses now; a logged item still rises with room (rendered whole
  at its source's front, its entry kept). The log folds only when a source's logged history
  outgrows its grant (Start::log_folded, log_kept_chars on delib.view.turnover).
- motion: per-act change rate per source (decayed to her last epoch) blended with what her
  starts measured; a start ranks units by the exchange argument over the shared prefix
  (s(1-q)/q + k, the log by what it keeps), Unmeasured to the tail, hysteresis by measurement
  error. Only at a start; within an epoch the view only appends.
- tool_surface: one canonical order, how widely held then by name (Always, Core, OnDemand,
  Withheld), so a smaller tool set is the head of a larger one (Benchy's 30 vs 39 diverged at 18).

Replay (the codec's replay example, real View code, all captures, 144 tok/s): prefill
6,269,985 -> 5,010,840 tokens (-20.1%). Score on the 13 recorded starts: shared 255,515 (#5803)
-> 306,970 tokens (+1+2), ceiling 370,142.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…down log it did not charge

Codex on #5805: `arrange` charged logged chars only to the sources a start was given, but
`begin` re-emitted the whole retained log, so the entries of a source absent from the start
(shed for want of its floor in `fit_view`, a stream that ended, a room she left) were laid
down charged to no one, survived a zero-source start, and kept the source's items marked
collapsed, so its return showed her stale pointers. Nothing in the caller contract forbids
the absence: `fit_view` sheds sources at a start by design ("A later act's advance offers it
again").

Now `log::arrange` decides, per entry, whether this start charges it (its source is
supplied), and `begin` keeps exactly those: the charge and the emission are one decision.
The dropped chars are receipted (`Start::log_dropped_chars`, probed on delib.view.turnover).

Reproduced first: a zero-source start rendered "head" + s1..s3's three pointers (960 chars
uncharged). Tests: an absent source's log leaves and its items come back whole; a zero-source
start lays down no log; a zero-grant start folds the log to the floor.
Replay (--append-tail 144, stable prev captures): Aiko and Atlas unchanged; Aris prev
1,100,314 -> 1,110,400 tokens (+0.9%), the cost of no longer re-emitting an absent source's
log uncharged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the fable/collapse-log-placement branch from f35ab53 to 4fcde58 Compare November 7, 2026 03:28
joelteply added a commit that referenced this pull request Nov 7, 2026
…er measured re-read cost

Her view now measures how often she asks again for what she already observed
(continuum-context rereads.rs, kept in Motion with the per-source stats #5803/#5805
keep): at every act each observing occurrence is exposed at its age in acts, and an
arrival with the same request fingerprint and outcome hash is a re-request at that age,
tallied over every level and over collapsed ones separately, halved at each start.

depth.rs chooses each instrumented growing source's start: walking its items newest
first, an item stays whole only while hazard x whole x (1 + (S-C)/(W-S)) exceeds the
turnover miss it saves, miss(S) = g (S-C)/(W-S). An age nobody was exposed at, a source
whose items carry no act, or no measured growth is Unmeasured and keeps the half rule.
start_grants (cognition) applies the chosen shares and probes delib.view.depth.

Replay (--append-tail 144 --measured-depth, 15 captures, deliberation + act):
8,478,327 -> 8,395,003 prefill tokens (-0.98%), 3 fewer turnovers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…hat she won't need again (#5806)

* A turnover collapses what she won't need again: collapse depth from her measured re-read cost

Her view now measures how often she asks again for what she already observed
(continuum-context rereads.rs, kept in Motion with the per-source stats #5803/#5805
keep): at every act each observing occurrence is exposed at its age in acts, and an
arrival with the same request fingerprint and outcome hash is a re-request at that age,
tallied over every level and over collapsed ones separately, halved at each start.

depth.rs chooses each instrumented growing source's start: walking its items newest
first, an item stays whole only while hazard x whole x (1 + (S-C)/(W-S)) exceeds the
turnover miss it saves, miss(S) = g (S-C)/(W-S). An age nobody was exposed at, a source
whose items carry no act, or no measured growth is Unmeasured and keeps the half rule.
start_grants (cognition) applies the chosen shares and probes delib.view.depth.

Replay (--append-tail 144 --measured-depth, 15 captures, deliberation + act):
8,478,327 -> 8,395,003 prefill tokens (-0.98%), 3 fewer turnovers.

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

* A measured depth never starts her under her newest item: the start is what its lowered grants hold

The depth prices each growing source's base (her floor with her newest item whole) in rounded
tokens; #5807's StartSource::newest prices her newest item ceiled. Lowering a grant to the depth's
share, and sizing the start to the depth's own sum, could leave her one token under her newest
item: the failure #5807 fixed (her newest turn collapsed by a char), reached again through the
measured depth.

- depth_grant (epoch.rs): THE rule for how a measured depth lowers a grant: to the chosen share,
  never below the floor or her newest item, never above the plan's grant.
- The growing start is the sum of the lowered grants, never chosen.start (probed beside it as
  chosen_tokens on delib.view.depth).

Test (prompt/epoch/tests.rs, the file's one test mod):
a_measured_depth_never_starts_her_under_her_newest_item. A 501-char newest item at 0.01 tokens
per char (6 ceiled) whose depth base rounds to 5:
- the guard on the grant alone (the previous head): granted 500 of 501 chars, FAILED;
- the start from the lowered grants without .max(source.newest): 500 of 501, FAILED;
- both: passed; continuum-cognition --lib 954 passed, 1 ignored.

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

* One clock ages her items: each occurrence's birth is the act her view first held it

Codex on #5806: depth::collapsible aged an item by how many newer items its source held
while Rereads bucketed its hazard by acts since birth, and prime reconstructed that birth
as acts minus the newer-item count. A source idle for eight acts priced a 9-act-old item at
age 1; a source that appended three items in one act read them as three ages.

Now Rereads records each occurrence's birth act where it enters (an arrival at act(), what
a start finds at prime), keeps the births with her view (serialized; drained at each start
to what the sources still offer), and answers Rereads::age(id) from them. depth reads that
age, so both read one clock; prime rebuilds the index from recorded births, never from
position, and the first act after a restart ticks the clock like every other. The seen set
is gone: the births map is it. depth::collapsible takes the measurement by reference (a
view-less claims() passes a fresh clock), so no Option stands in for a missing clock.

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

* Her epoch length is read off her one clock: Motion no longer counts acts

Motion.epoch_acts counted every act beside Rereads' clock, and always equalled the acts since
the last start on it. Deleted with its writer (Motion::act, View::advance's call); the current
epoch's length is Rereads::epoch_acts (acts - acts_at_start), read where a start closes the
epoch and where a change rate is extrapolated over her epoch. last_epoch_acts stays: it is the
closed epoch's length, a different fact, now u64 like the clock. No shim for saves with the old
field: serde ignores it, and the current epoch's length comes from the clock.

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

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
@joelteply
joelteply merged commit a071f9f into canary Nov 7, 2026
18 checks passed
@joelteply
joelteply deleted the fable/collapse-log-placement branch November 7, 2026 08:43
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