Repository navigation
feat(rpc): authoritative message terminals, metadata and ordered cold edits for the compact reducer (S03b-2b, part of #4272) - #4425
Open
code-yeongyu wants to merge 5 commits into
Open
code-yeongyu wants to merge 5 commits into
code-yeongyu wants to merge 5 commits into
Conversation
… edits for the compact reducer (S03b-2b, part of #4272)
…er-exempt native insert (part of #4272) Merge origin/feat/4272-s03b2-reducer @ 851f442. Activation on first entry into the active set moves to CompactActiveMessages.publishRow, the single writer of active, so seeded_message incarnations are activated too; the direct cold.activate calls are removed. A native insert over a start-content placeholder slot is a takeover, not a duplicate; any other existing block stays a typed duplicate_block.
code-yeongyu
marked this pull request as ready for review
October 27, 2026 05:32
MoerAI
pushed a commit
to MoerAI/senpi
that referenced
this pull request
Oct 27, 2026
…he stack merge (part of code-yeongyu#4272) The merge of code-yeongyu#4374 onto code-yeongyu#4425 compiled S05's CompactSettledMessages against the S03a index API: synchronous has() and a generic FrozenIndex no longer exist, so every append threw. Keep the exact membership S05 relied on in a resident key set (its pruning stays carried item 9), and let a retired lane freeze without asking its retired paged store for a cut. (cherry picked from commit e0fea84)
This branch has not been deployed
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.
Part of #4272. S03b-2b: authoritative message terminals, message metadata/usage/correlation, and ordered cold flows (edit, delete, compaction removal, branching) for the compact reducer (R3.C6.4), behind the OFF-by-default compact-updates flag. Stacked on #4414 (S03b-2a).
S03b-2b: measured size stop with a complete, green candidate
Part of #4272 (R3.C6.4). Worktree
senpi-s03b2b, branchfeat/4272-s03b2b-terminals.DECISION (lane, 2026-10-27): option B approved
The lane approved the single PR as measured (493 added / 145 removed, net 348). The ~400 cap in the brief was the
lane's own; the PR rule is < ~600 production lines. Option A (split into 2b-1 / 2b-2) and option C (cut scope) are
not taken. Moved-lines note for reviewers: about 53 of the 493 added lines are
publish/dropActive/blockandthe active-state fields moved verbatim from
compact-session-state.tsinto the newcompact-active-messages.ts,because adding the message fold in place would have taken that file past the 250-line ceiling (HEAD 236; now 199).
Nothing was compressed to fit. The sections below are the measurement that decision was made on; the post-merge
state is recorded under "Merge of #4414's fold" at the end.
Result: stopped at the brief's size gate. The full S03b-2b scope is implemented and every gate is green, but it
measures 493 added / 145 removed formatted pure production LOC (net 348) against the ~400 cap. No commit, no
fragment, no push. HEAD is still
93698ed91c64cd24ccd0766a5dd28b3778481a72.The candidate is left UNCOMMITTED in the worktree (16 paths) so a GO needs only a fragment and a commit. A safety
copy is archived:
s03b2b-size-stop.patch, 65,346 bytes, SHA-2563b6522592c1a163404af3b14d2a1f1b8021fec425ed821402feff56fc710c8a7, new files included;git apply --check -Ragainst the worktree exits 0.Size (TypeScript 6.0.3 leaf-token line spans after oxfmt; comments and blank lines excluded)
Measured against HEAD with
git diff -U0; new files count in full. Every file is at most 250.Calibration: this method gives 236 for HEAD's compact-session-state.ts (2a's Babel count was 234).
About 53 of the added lines are publish/dropActive/block and the active-state fields moved verbatim from
compact-session-state.ts (which loses 73 pure lines), because adding the message fold there would have taken that file
past 250 (HEAD 236). The cold queue's restructure accounts for 38 of the removed lines.
Measured split (each part independently green; 2b-2 stacks on 2b-1)
initialslot phase andfrozenBlock,the draft's null removal, compact-seeded-messages.ts without
installSettledMessage, compact-active-messages.ts,the session-state
seeded_messagepath, message-field leaves in storage, and the views.Test: 4272-compact-terminal-authority.test.ts.
message_replace,message_install,runAll), compact-cold-flows.ts,installSettledMessage(29), the storage cold hook (11) andapplyColdFlow(4).Test: 4272-cold-message-flows.test.ts.
Contract question (blocks the commit): A/B/C
green candidate, but costs a second review and gate round.
lane's PR rule is < ~600 production lines (BUDGET UPDATE, S03b2 brief). About 53 added lines are a pure move forced
by the 250-per-file rule, and nothing was compressed.
message_install(branch) or the one-slotrunAll. Thatnarrows the approved scope: a compaction of more than 128 messages would then hit
capacitypartway.RED -> GREEN (contract test ids)
The RED run was on unchanged production, exit 1, 8/8 failed (red.log). GREEN: the same tests plus two pinned
additions, 65/65 with their neighbours (green-1.log), then inside the full serial run.
expected [] to matchapplyColdFlow is not a function(new entry point; its per-op semantics RED in the edit test)Mutation probe (mutation.log): removing the
endedguard on raw reuse and the correlation carry on edit fails exactlythe two pinned assertions: the nested
donewith no cutoff in the repair test, and the seeded-row correlation in theedit test. The source was restored byte-identical afterwards.
Gates on the candidate (nice 10, CI=1, TMPDIR=delta-senpi/tmp, five session variables removed, own caches)
Each gate waited until the 5-minute load was below 60 (s03b2b-run.mjs polls every 60 s).
Logs:
senpi-s03b2b/local-ignore/qa-evidence/20261027-s03b2b/.bun run buildnode_modules/.bin/tsc --noEmitnode scripts/lint-ratchet.mjsoxlint --deny-warningson changed filesoxfmt --checkon changed filesbun run checkgit diff --checkAn earlier serial run before the build (suites.log) had 13 failures in worker/epoch/bootstrap suites. All came from
the unbuilt
@earendil-works/pi-aidist (provider-scope.jsmissing, so workers quarantined), not from this change.The built rerun is the evidence. Flag off is byte-identical: no production path constructs this owner yet, and
json-event.ts and structured-session-records.ts are unchanged. No new sync call was added; the no-sync suite passes.
What the candidate implements
seeded_messagetransition: outer message_start/message_end and nested start/done/error.initialslots, which that index's own block start takesover. A start after streamed blocks is rejected
invalid_phase.terminal no longer names survives.
rewrittenFromthat is not ininvalidatedBlocks, so anabandoned stream's raw text and preview never outlive the terminal.
pendingin the same step. Direct error and toolResult terminals need no start.duplicate_or_stale_start. It also callscold.activate(see below). A foreign epoch is rejectedwrong_epoch;malformed cutoffs are rejected
invalid_terminal.seeded_blockgains optionalusageandmessageMetadata(nullremoves a field), folded in the same step.message_replace(edit): the row must exist; persistence and correlation are kept.message_install(branch): the row is installed whole with the given persistence, present or not.runAllruns a whole flow as ONE FIFO unit holding one capacity slot, with one typed outcome per operation.applyColdFlowmaps the flows: edit -> replace; user_delete -> remove; compaction -> ordered removes;branch -> removes, then installs.
active_messageand remains synchronous acceptance work (a live user delete is the acceptedmessage_removetransition).Coordination with the #4414 fold (heads-up received mid-run)
acceptMessage's creation path callsthis.cold.activatedirectly, like the legacy
start(). The fold's helper must cover this path (compact-session-state.ts,acceptMessage).initialphase is a message-start slot, not an open block. The fold's rule that a native re-insert on an openblock is
duplicate_blockshould exemptinitialslots, or a start that seeded content followed by a native insertat that index will be refused. Untouched here: the 2a seeded_block start path and insert semantics.
LOW disposition
??comment)invalidatedBlocks, and a nested done with no cutoff, restore the block from the terminal without its abandoned stream (the repair test, mutation-checked).What S03b-3 must wire
seeded_block {event, usage, messageMetadata};seeded_block {event};seeded_message, with the correlation at creation, thegate's
invalidatedBlocks, and the capture'srewrittenFromon terminals.applyColdFlowafter their accepted transcript transition, with the lane cut:edit, user delete, the compaction removal list, and branch removal + install.
current-epoch-only validation against the S05 registry; supported construction capture with zero peers and
selection OFF; shared frozen component roots for S06/S07.
Assumptions and open items
undefinedproperty (unsupported_value). Real public messages can carryundefinedoptional fields (for example toolResultdetails). S03b-3 must normalize them, or S03b-4 should skipundefined object properties as JSON does. The fixtures here do not hit it.
X07 accounting for that is S03b-3/S12 evidence, not claimed here.
Merge of #4414's fold (origin/feat/4272-s03b2-reducer @ 851f442)
f4a67ca750(author and committer YeonGyu-Kim code.yeon.gyu@gmail.com), fragmentchanges/unreleased/s03b2b.md.--no-ff. Conflicts incompact-seeded-block.tsandcompact-session-state.tsonly.compact-seeded-block.ts: kept the fold'sseedOffset(typedinvalid_seed_frontier), the native-end kind check and thenative-insert
duplicate_block, plus this branch's exportedseedBlock. The insert rule now EXEMPTS a start-contentplaceholder slot (
phase === "initial"), exactly as seeded starts already did; the session-statestartingtest treatsan insert over a placeholder as a start, so the first-ordinal guard still runs and commits.
compact-session-state.ts: kept this branch's structure (publish/dropActive/block live in compact-active-messages.ts) anddropped both direct
this.cold.activatecalls (legacystart()andacceptMessage). The fold's rule "activate on firstentry into
active" now lives inCompactActiveMessages.publishRow, the single writer ofactive, which bothpublish()andinstall()(the seeded_message path) go through.git grep cold.activatefinds exactly one call site.New tests (RED on the mechanical resolution, GREEN after the fix)
applied, expectedactive_messageapplied, expectedactive_messageduplicate_block: 0on the placeholderGuard-removal check: removing the native-insert
duplicate_blockguard fails exactly the new controls test("expected function to throw"); restored byte-identical.
Gates after the merge (staged tree; nice -n 10, load < 60, logs m-*.log)
build 0; serial suites 0 (61 files / 286 tests); tsc 0; lint-ratchet 0 (every count matches baseline); oxlint
--deny-warnings 0 and oxfmt --check 0 on every file changed since 93698ed; root
bun run check0;git diff --cached --check0.LOC after the merge, versus the new base 851f442
Added 497 / removed 148 / net 349. Every file at most 250.