Repository navigation
2026.10.04 - Phase 3: Pi DCP Compact Markers - #73
Merged
Merged
Conversation
…c and sanitization
…tion during injection
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.
@mN@, or@mN:P@when a compression priority from 1 to 5 is assigned. On a 2,000-message clean workload this cut estimated metadata overhead from about 20,000 tokens to about 4,000. The injected format derives from a strictformatMessageMarker(ref, priority)that round-trips canonical refs throughparseMessageRefand rejects noncanonical inputs or out-of-range priorities (src/utils/message-ids.ts,src/messages/inject.ts,tests/inject.test.ts,tests/message-ids.test.ts).parseBoundaryIdnow tries canonicalm0001, then exact compactm1/@m1@/@m1:3@/@m12:3@, then blockbN.resolveBoundaryIndexre-runs the parsed index throughformatMessageRefbefore comparing withSessionState.messageIds.byIndex, so a copied@m12:3@resolves to the same stored message asm0012rather than merely parsing.parseMessageRefitself stays canonical-only, block parsing rejects unsafe integers, and zero/negative/decimal/partial-padding/wrapped-padded inputs all returnundefined(src/utils/message-ids.ts,src/compress/search.ts,tests/message-ids.test.ts,tests/compress-search.test.ts).DCP_COMPACT_MARKER_LINEregex removes only complete or truncated markers (@m1@,@m1:3@,@m1,@m1:,@m1:2) on a line boundary, under LF or CRLF, with optional horizontal whitespace. The line boundary itself is preserved so surrounding prose is not concatenated. Inline@m1@,person@m1@example.com,@mention, and marker text inside a sentence are left untouched. Compact cleanup runs before the legacy XML fallbacks, which remain active for stored assistant output (src/messages/strip.ts,tests/strip.test.ts,tests/message-end.test.ts).parsePairsinsrc/state/persistence.tsswitches from a permissiveparseMessageRef(entry[1]) ?? 0 > 0check to the strictisCanonicalMessageRefpredicate. A compact persisted ref is discarded rather than normalized,nextRefIndexstays authoritative, the snapshot version is unchanged, and no stored map is migrated (src/state/persistence.ts,src/utils/message-ids.ts,tests/persistence.test.ts).@mN@,@mN:P@, and<dcp-system-reminder>as environment-injected metadata that must not be output, repeated, or invented; the message-mode tool description explains priority values and accepts the padded form as an alternative; the range tool and message tool descriptions usem1/@m1@examples while keepingbNblock examples and the pruned/unavailable explanation. The legacyChoose a message ID (m0001)…error messages innormalizeEntriesare nowChoose a message marker (m1 or @m1@)…(src/prompts/system.ts,src/prompts/compress-message.ts,src/index.ts,src/compress/handler.ts,tests/index.test.ts,tests/integration.test.ts,tests/pipeline.test.ts,tests/compress-cycle.test.ts).tests/benchmark.test.tsnow asserts three deterministic budgets so a token regression failspnpm check: injected-marker overhead onclean-2000-messagesmust stay at or below 6,000 tokens, and therepeated-tool-pairs-2000andrestored-nested-blocks-100reduction ratios must stay within five percentage points of the retained962873 / 1017575and1171 / 1291baselines. Ratios are compared as exact fractions rather than rounded percentages, and elapsed-time reporting remains informational. The retainedbenchmarks/result.jsonwas refreshed on Node 24.21.0 with the compact marker overhead now showing as-3,992instead of-20,000(tests/benchmark.test.ts,benchmarks/result.json,README.md).package.json);CHANGELOG.mdadds a[0.8.0] - 2026-10-04entry under Added / Changed / Removed covering compact markers, normalized lookup, line-bounded sanitization, snapshot canonical validation, and the dropped<dcp-message-id>XML formatter;README.mdreplaces the 0.7.0 block with a focused "What's new in 0.8.0" section and adds a "Message markers and IDs" reference table (package.json,CHANGELOG.md,README.md).docs/superpowers/plans/2026-10-03-phase-03-pi-dcp-compact-markers.md)..gitignoreadds.DS_Store(.gitignore).Automatic pruning timing, canonical padded references, the version-1 persisted snapshot shape, the generated schema, and Pi lifecycle hooks remain unchanged; no new runtime dependencies, no published Pi or OpenCode reference repositories, and no release workflow were touched. Verified end-to-end with
pnpm check(format, warning-free lint, typecheck, tests) andpnpm benchmark(all three workloads complete within the new token gates; retainedbenchmarks/result.jsonrefreshed on Node 24.21.0).