Repository navigation
Conversation
SeniorHan
added a commit
to SeniorHan/acp-kernel
that referenced
this pull request
Oct 23, 2026
SeniorHan
force-pushed
the
feat/branch-aware-blocks
branch
from
October 23, 2026 15:23
3a100fa to
857b39f
Compare
Author
|
Reopening as #518: renamed the branch to satisfy the YYYY-MM-DD_short-title convention and applied prettier formatting (CI failures were naming + format only, code unchanged). |
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.
Problem
Hosts with rewindable session trees (e.g. pi's
/treenavigation) can land inside a block's range after a rewind.syncBlockskeeps a block active while any covered message is in view — so after the rewind, the block's summary (which describes messages that now live on another branch, including decisions made after the rewind point) replaces the few messages still in view. The model sees a future it has not reached.Reproduced with pi 1.4.0 + acp-kernel 0.0.101: compress e1–e4 into a block,
/treeback to e2, ask anything — the summary's "future decision" is injected into the model's view.Proposal — additive, opt-in
ProcessTurnInputgains one optional field:The host passes the ids of all persisted session entries (the full session tree, not just the current branch). When provided, a block is "off-branch" when some of its covered messages are in view and others are persisted-but-not-in-view. Such blocks are masked as expanded for the turn — their in-view messages show raw instead of being replaced by the other-branch summary.
The mask is turn-scoped and never persisted: the original
expandedflags are restored on the result state, so returning to the full branch reactivates the block. Messages missing for other reasons (never persisted, host-side live ids) keep the default behaviour.Hosts that omit the field: zero behaviour change.
Implementation
src/branch-awareness.ts(new):findOffBranchBlocks()— pure detection, mirrorssyncBlocks'baseIdOfsub-id semantics.src/compress.ts: mask applied to the pipeline's initial state; restore applied toresult.state; input state never mutated.tests/branch-awareness.test.ts: 4 tests — masking + no-persist + input-immunity, full-branch reactivation, unknown-ids fallback, live-instance sub-id matching.npm test→ 1237/1237 (1233 baseline + 4 new),tsc --noEmitclean.Provenance
The mask/restore mechanics are extracted from a working host-side implementation battle-tested across ~80k messages of daily pi usage (weakmap-wrapper variant in a downstream extension), moved kernel-side so every host gets it without per-host wrapping. Detection runs fresh each turn from the declared persisted set — no cross-turn state.