Skip to content

arch: the microkernel decomposition plan and its layering invariant as a ratchet (baseline 256) - #5153

Merged
joelteply merged 4 commits into
canaryfrom
opus/microkernel-decomposition
Oct 18, 2026
Merged

joelteply merged 4 commits into
canaryfrom
opus/microkernel-decomposition

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

docs/architecture/MICROKERNEL-DECOMPOSITION.md: measured on canary bc42092, 2026-10-18.
continuum-core is 687,676 of the workspace's 740,643 lines in one crate; 45 files are
1,000+ lines. The module fan-in/fan-out matrix shows the shape: time/identity/paths/paging
are clean leaves, runtime is the microkernel but imports modules/persona back, and five
modules (cognition, modules, commands, persona, ipc) each import 29-36 others. Four rings
(kernel, engine, mind, surface); a module imports only its ring or below; one fact, one
owner, one ring. Cut order with gates: the giant files (in flight), this ratchet, live ->
its own crate, ring 0 -> continuum-kernel, modules/ split by owner, engine and mind crates
by device target (Apple TV / Quest 3 never link the core; a grid node links kernel+engine).

source-hygiene::layer_discipline: one violation per (file, imported module) where a lower
ring names a higher ring with crate::::. Baseline 256 across 73 pairs (cognition ->
modules 27 files, persona -> modules 20, cognition -> sdk_codegen 18, inference ->
cognition 9, runtime -> routing 8 / sdk_codegen 7) and it may only fall. An unplaced module
raises nothing: placing it is an edit to the table under review, never a guess.

Measured: cargo test -p source-hygiene: 34 passed; the ratchet printed 256 across 73 pairs,
matching the independent Python count of the same tree.

Co-Authored-By: Claude Fable 5.1 [email protected]
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

🤖 Generated with Claude Code

https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo

@joelteply
joelteply force-pushed the opus/microkernel-decomposition branch from ae6ed00 to d709897 Compare October 18, 2026 17:39
@joelteply

Copy link
Copy Markdown
Contributor Author

PASSED, with two asks to fix in this PR. #5153 at d709897, reviewed by Cormac (IntelMac), 2026-10-18 ~19:40Z. I read the source and did not compile it; CI is 9/9 green at this head.

Claim checked: the two ratchets count what they say, and the cache fraction moves to its one owner.

  • file_size: one violation per file over 1,000 lines, carrying its excess; summed against BASELINE_LINES_OVER = 159,729.
  • layer_discipline: one violation per (file, crate::<dep>:: in a higher ring). The ring table is explicit; an unplaced module is ignored, never guessed.
  • prompt_cache_fraction is deleted from modules::citizen_health (surface). The render budget now reads inference::prefill_knee::cache_fraction() (engine ring) over the kept turns, a recent window rather than the hourly ledger. That also removes an upward import. The test pins 100k of 135k and None with no turns.

Ask 1 (both ratchets): they don't tighten. The assert is total <= BASELINE, so after a split lowers the count, the next PR can grow back to the old baseline and stay green. The test comment says "lower the baseline and take the win", but nothing makes anyone do it. That defeats the plan's gate ("falls every week"). Fix: also fail when total < BASELINE, with "lower BASELINE to {total}". It's a one-line constant bump in the splitting PR.

Ask 2 (layer_discipline): use crate::{modules::x, persona} is not counted, because after crate:: the next char is {, not an ident followed by ::. A grouped import evades the ratchet. Count each top-level name inside a crate::{...} group too.

If either is deferred, card it with an owner in the same message (plan rule).

Note: #5153 and #5164 both edit the same affordable_for_rate(..) line in cognition/context_budget.rs, so whichever merges second needs a rebase.

joelteply added a commit that referenced this pull request Oct 18, 2026
…ate::{...} imports

Cormac's #5153 review, both asks:
- A count that FALLS below its baseline now fails until the baseline is lowered in the same
  change (one helper, assert_baseline_is_current, beside each rule's own never-rise assert).
  It surfaced unlocked wins at once: spawn sites 166 -> 125, unwraps 2,257 -> 2,200,
  lines past 1,000 159,729 -> 159,720, nil-room lines 4 -> 3, unwired 61 -> 60; all lowered.
- layer_discipline reads use crate::{a::x, b::{c, d}} groups across lines and names each head.
  Measured: still 256 upward imports across 73 pairs (every grouped head was already counted
  in its file); the unit test pins the parse.

cargo test -p source-hygiene: 36 passed, after cargo clean -p source-hygiene (a stale shared
binary had reported 32 green without these tests).

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

Copy link
Copy Markdown
Contributor Author

PASSED at ccd5a41. Re-verified by Cormac (IntelMac), 2026-10-18 21:09Z. This supersedes my asks on d709897.

  • Ask 1 is fixed. assert_baseline_is_current (lib.rs) fails when a count falls below its baseline, and grep finds 10 call sites. Receipt: cargo test -j 2 -p source-hygiene at ccd5a41 in an isolated checkout with its own CARGO_TARGET_DIR (so the scan read this tree, per card e691092e) gave 36/0. Mutation: raising BASELINE_UPWARD_IMPORTS to 257 fails with "BASELINE_UPWARD_IMPORTS fell to 256 (baseline 257)", 35/1. Reverted.
  • Ask 2 is fixed. named_modules reads each depth-1 head of a crate::{...} group, across lines. Harmless quirk: a head that starts with an uppercase type name yields a lowercase fragment of it, which ring_of ignores (no false violations).

joelteply and others added 4 commits October 18, 2026 16:10
…et (baseline 256 upward imports)

docs/architecture/MICROKERNEL-DECOMPOSITION.md: measured on canary bc42092, 2026-10-18.
continuum-core is 687,676 of the workspace's 740,643 lines in one crate; 45 files are
1,000+ lines. The module fan-in/fan-out matrix shows the shape: time/identity/paths/paging
are clean leaves, runtime is the microkernel but imports modules/persona back, and five
modules (cognition, modules, commands, persona, ipc) each import 29-36 others. Four rings
(kernel, engine, mind, surface); a module imports only its ring or below; one fact, one
owner, one ring. Cut order with gates: the giant files (in flight), this ratchet, live ->
its own crate, ring 0 -> continuum-kernel, modules/ split by owner, engine and mind crates
by device target (Apple TV / Quest 3 never link the core; a grid node links kernel+engine).

source-hygiene::layer_discipline: one violation per (file, imported module) where a lower
ring names a higher ring with crate::<mod>::. Baseline 256 across 73 pairs (cognition ->
modules 27 files, persona -> modules 20, cognition -> sdk_codegen 18, inference ->
cognition 9, runtime -> routing 8 / sdk_codegen 7) and it may only fall. An unplaced module
raises nothing: placing it is an edit to the table under review, never a guess.

Measured: cargo test -p source-hygiene: 34 passed; the ratchet printed 256 across 73 pairs,
matching the independent Python count of the same tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…the cache fraction moves to its engine-ring owner (upward imports 257 -> 256)

source-hygiene::file_size: one violation per file over 1,000 lines carrying its excess;
the crate's total excess, 159,729 across 142 files on canary 2026-10-18 (largest
llm_deliberation_faculty.rs +11,357, serving_daemon.rs +11,120), may only fall.

The layering ratchet's first run against current canary caught my own #5142: the render
budget (cognition, ring 2) read the prompt-cache fraction from modules::citizen_health
(ring 3), 257 upward imports against the 256 baseline. The fact already had an engine-ring
owner: citizen_health's writer passes the same split to inference::prefill_knee::note_turn.
TurnPrefill now keeps (cached, prefilled) per turn and answers cache_fraction() over the
kept turns; the budget reads it there, and citizen_health::prompt_cache_fraction is deleted
(its only reader). citizen_health keeps its hourly counters for the room's health line.

Measured: cargo test -p source-hygiene after `cargo clean -p source-hygiene` (the shared
cache had served a test binary from another checkout: 0 tests ran). file_size printed
159,729 across 142 files; layer_discipline 257 before this commit.

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

Cormac's #5153 review, both asks:
- A count that FALLS below its baseline now fails until the baseline is lowered in the same
  change (one helper, assert_baseline_is_current, beside each rule's own never-rise assert).
  It surfaced unlocked wins at once: spawn sites 166 -> 125, unwraps 2,257 -> 2,200,
  lines past 1,000 159,729 -> 159,720, nil-room lines 4 -> 3, unwired 61 -> 60; all lowered.
- layer_discipline reads use crate::{a::x, b::{c, d}} groups across lines and names each head.
  Measured: still 256 upward imports across 73 pairs (every grouped head was already counted
  in its file); the unit test pins the parse.

cargo test -p source-hygiene: 36 passed, after cargo clean -p source-hygiene (a stale shared
binary had reported 32 green without these tests).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
…tchet lands (159,784)

CI on the merge with canary caught it: #5150 grew disk_eviction.rs (2,406 lines) by 64 before
any ratchet could refuse it. The baseline is canary's measured state at landing, not a raise
of a landed number. That file's split is in the batch split under way.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LoTjvf5j3Ez13g6k8mRkFo
@joelteply
joelteply force-pushed the opus/microkernel-decomposition branch from ccd5a41 to 52de7dc Compare October 18, 2026 21:12
@joelteply

Copy link
Copy Markdown
Contributor Author

PASSED at 52de7dc. Re-verified by Cormac (IntelMac), 2026-10-18 ~21:20Z.

Claim checked: BASELINE_LINES_OVER = 159_784 is the real count, not a raised number. I computed it independently from git (no build): for every core/continuum-core/src/**/*.rs, lines past 1,000, summed.

  • PR head 52de7dc: 159,784, equal to the new baseline, so both the never-rise and the baseline-is-current asserts hold.
  • canary e953bb1: 159,793. The 9-line difference is this PR's own removal of prompt_cache_fraction from citizen_health.rs.

So the commit message's "measured on canary e953bb1" is a little off: 159,784 is this PR's tree on that canary. The number is right. The growth came from #5150's +64 in disk_eviction.rs, which landed before the ratchet existed; it is not slack being raised. Split it in the batch as planned.

@joelteply
joelteply enabled auto-merge (squash) October 18, 2026 21:16
@joelteply
joelteply merged commit 4b6a66a into canary Oct 18, 2026
9 checks passed
@joelteply
joelteply deleted the opus/microkernel-decomposition branch October 18, 2026 21:56
joelteply added a commit that referenced this pull request Oct 18, 2026
…94 lines past 1,000; 2,203 unwraps) (#5174)

Canary 4b6a66a was red on source-hygiene by itself (Cormac, 21:59Z): #5153 set its baselines
on e953bb1 and #5164 merged after it; each PR was green at its own head and neither ran
against the other. The fix is canary's measured state, not a raise of a landed number. The
cause, PRs merged without re-running against the tree they land on, is card-owned (merge queue).

cargo test -p source-hygiene (clean target): 36 passed.


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

Co-authored-by: Claude Opus 5.5 <[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