refactor: delegate primeFold mirrors to acp-kernel mirror constructors (0.0.35) - #126
Merged
Merged
Conversation
…s (0.0.35) wire-fold.ts drops ~150 lines of hand-rolled wire-shape mirrors (viewToCoreStream/viewToAnthropicCore/viewToResponsesCore bodies) in favour of the kernel's mirror*ToCore constructors (acp-kernel PR #114, v0.0.35). omp keeps only the AgentMessage→MirrorMessage mapping (ref-tag stripping + pi block types); every wire rule — system placement, reasoning_content vs thinking blocks vs summary_text, tool_result folding, whitespace handling — is single-sourced in the kernel, shared with the billion-context proxy.
ranxianglei
force-pushed
the
2026-08-22_kernel-mirror-cutover
branch
from
August 22, 2026 09:53
30bbd98 to
0c04e84
Compare
This was referenced Aug 22, 2026
Open
ranxianglei
added a commit
that referenced
this pull request
Aug 22, 2026
Checkpoint the provider-mode FoldSlot to disk via acp-kernel/persist (StateStore) and restore it at session_start, before the primeFold mirror runs. Why: at restart the wire payload is unavailable until the first provider request, so primeFold folds a session-VIEW mirror — a different fingerprint space than the live wire fold (host transformMessages + convertMessages reshape the view). Every in-stream compress replay then failed the span guard and /acp showed "Blocks: none" until the first provider request refolded the real wire (issue #130). The restored identities live in the WIRE's own content-hash space (coreIdentity is a pure function of content), so the first live fold re-validates the restored slot via LCP; a stale checkpoint degrades to the normal re-fold, never worse. Zero-block checkpoints are neither persisted nor restored — they carry nothing the fresh slot lacks but would suppress the mirror fallback (issue #103 regression found in tests). Crash without shutdown also degrades to the mirror. - new src/fold-persist.ts: policy layer over acp-kernel/persist (dir/env/config, schema v1, snapshot validation, restore w/ forward- compat merge); default dir ~/.omp/acp-omp-folds, env ACP_OMP_FOLD_DIR - runtime: restoreFold/scheduleFoldSnapshot/flushFoldSync; snapshot at live fold + turn commit + compress commit; flushSync at session_shutdown before forgetSession - config: foldPersistence {enabled, dir} (boolean shorthand, default on) - scripts/test.ts isolates ACP_OMP_FOLD_DIR per run (restored snapshots from earlier runs marked replayed calls as already-applied) - tests/fold-persist.test.ts: restart e2e pre-LLM, crash fallback, zero-block guard, corrupt skip, disabled, switch-back no-clobber, incremental LCP on extended history Requires acp-kernel 0.0.40 (persist subpath, kernel PR #126).
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.
Summary
viewToCoreStream/viewToAnthropicCore/viewToResponsesCorebodies, ~150 lines) and delegates to the acp-kernel mirror constructors added in acp-kernel PR chore(deps): bump acp-kernel 0.0.31 -> 0.0.32 #114 (v0.0.35):mirrorOpenaiToCore/mirrorAnthropicToCore/mirrorResponsesToCore.toMirrorView: ref-tag stripping + pi block types →MirrorMessage); every wire rule — system placement, reasoning_content vs thinking blocks vs summary_text, tool_result folding, whitespace handling — is single-sourced in the kernel, shared with the billion-context proxy (one place to fix, issue provider模式重启acp status 压缩块丢失 #64 class).Behavior parity
Byte-level parity asserted by the existing suites, all unchanged and green (260/260
bun test, tsc + tsconfig.test.json clean):<think>demoted host) pass through the kernel constructors unchanged