Repository navigation
perf(runtime): compaction writes a short narrative; QQ renders the exact record (CX0+CX1) - #239
Merged
Merged
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
lg2m
added a commit
that referenced
this pull request
Oct 2, 2026
This was referenced Oct 4, 2026
lg2m
added a commit
that referenced
this pull request
Oct 5, 2026
lg2m
force-pushed
the
perf/eng-994-cx1-compaction-summary
branch
from
October 5, 2026 03:03
bc8f866 to
7c4d4b6
Compare
Plan docs/plans/compaction.md (CX0-CX5), ledger with the live-store baseline (110-390 s per compaction, cold cache), and Proposed ADR-0055: the summarizer writes a short narrative and QQ renders the exact record from stored rows. Reserves ADR-0055 in progress/root.md (0054 is taken by Refs: ENG-992, ENG-993
…act record (CX1) The summarizer now writes five short sections (Intent; Decisions and constraints; Work state; Open problems; Next step) instead of retyping user messages, errors and file lists. At commit, in the same transaction, QQ renders a bounded record from stored rows and stores it after the narrative: every user message and applied steering verbatim (older prompts listed by ordinal for search_history), the last reply, files modified and read, and failed calls. The record is rebuilt from rows at every compaction, so it stays exact across any number of folds. - Between runs, shrinkage is required of the narrative; the record is a bounded cost, so a stored six-section summary always folds into the new format. In-run steps count the record too. - The summarizer uses the run's resolved output cap, held to an eighth of a declared window (never below 8 192), instead of a fixed 8 192 clamp. - The in-run commit returns the stored text, so the live splice and replay render the same bytes. - No schema or protocol change. Refs: ENG-992, ENG-994
lg2m
force-pushed
the
perf/eng-994-cx1-compaction-summary
branch
from
October 5, 2026 03:36
7c4d4b6 to
e0fd1a0
Compare
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.
CX0 + CX1: compaction writes a short narrative; QQ renders the exact record
Spec:
docs/plans/compaction.md(CX0, CX1) · ADR-0056 (Proposed) · Linear: ENG-992 (plan), ENG-993, ENG-994Why
On the live store, compaction takes 110–390 s. Most of that time is the model retyping stored data: every user message, error and file list. Summaries are 20–36 KB. The Anthropic route always hits the 8 192-token cap and needs a continuation turn, and Codex takes up to 389 s. Retyped user messages are only "near-verbatim", and they degrade on every fold. The baseline is in
docs/plans/progress/compaction.md.What changed
The model writes a narrative only. It has five sections: Intent; Decisions and constraints; Work state; Open problems; Next step. The target is about 1 200 words, and the model is told not to restate the record.
QQ renders the record. It is built from stored rows in the commit transaction and stored after the narrative in the same
session_compactions.summaryrow. It holds:search_history;tool_callsarguments in SQL;The record is bounded to 64 KiB, or an eighth of a declared window. It is rebuilt from rows at every compaction, so it stays exact however many times a session folds.
Migration always succeeds. Between runs, shrinkage is required of the narrative only, and the record is a bounded cost. So a stored six-section summary always folds into the new format, even when the record makes the assembly larger. In-run steps still count the record toward shrinkage.
Output cap. The summarizer uses the run's resolved cap, held to an eighth of a declared window and never below 8 192. This replaces the fixed 8 192 clamp.
Live equals replay. The in-run commit returns the stored text, so the live splice and replay render the same bytes.
Echoed records are dropped. If a reply echoes a record (a header at the start of a line), it is cut there, so the stored record is always QQ's.
How verified
cargo test --workspaceafter the rebase: 2 089–2 090 passed, 13 ignored. Two unrelated timeout tests (steering_during_a_slice_report_lands_before_the_continuation_notice,shutdown_settles_a_running_parent_and_its_in_flight_child) each failed once under full-workspace load and pass on re-run; the minimalqq-providerprofile passes too.headless::tests::turn_budget_cancels_before_a_silent_over_budget_turn_can_hangfailed once with a 1 s timeout under full-workspace load.mainand 3/3 alone on this branch, and the full suite re-run was green. It doesn't touch compaction.cargo fmt --all -- --checkandcargo clippy --workspace --all-targets --all-features -- -D warningsare clean.sessions/tests/compaction.rs:the_compaction_record_is_exact_bounded_and_cites_what_it_omitsan_in_run_record_holds_the_replaced_turns_steering_files_and_failures: uses a turn-ordinal gap and a case with no kept turn, and checks that the steering dropped by replay equals the steering in the record.small_records_stay_within_budget_and_end_on_a_line: sweeps windows from 0 to 1M tokens.the_summarizer_output_cap_is_the_run_cap_bounded_by_the_windowa_summary_that_echoes_a_record_keeps_only_its_narrativerepeated_compactions_keep_every_user_message_verbatim_without_the_model_retyping_them: five folds with a summarizer that never repeats a user message.an_old_format_summary_folds_into_the_new_format_even_when_the_record_is_largerMeasurements
context_assemblyat 10 000 archived runs, release, 300 iterations, A/B/C × 3. The stored summary length was varied through a temporary bench-only change, which is not committed.The record is rendered only at the compaction commit, never during assembly. The live latency win (CX5) will be measured after CX2/CX3 land.
Compatibility
PROTOCOL_VERSION,DESCRIPTOR_VERSIONand the store schema are unchanged.SessionCompacted.summarynow includes the record (still truncated to 16 KiB).Coordination
mainafter the autonomous-core stack merged (docs(plans): put a progress track first in autonomous-core; ADR-0054 progress means output #232–feat(runtime): record slice checkpoints as report turns; an empty one no longer fails the run (AP3a) #237). docs(plans): put a progress track first in autonomous-core; ADR-0054 progress means output #232 took ADR-0054; ADR-0055 is held for the decision-model ADR (docs(plans): design decision-model support — qq-decision crate, OpenAI Decisions API and Jev (DM0) #231, reverted in revert(docs): unmerge #243, #227 and #231 #246 and reopened as docs(plans): design decision-model support — qq-decision crate, OpenAI Decisions API and Jev (DM0) #249), so this one is ADR-0056, reserved inroot.md. Rebased onmainafter revert(docs): unmerge #243, #227 and #231 #246 (schema 41); CX1 still changes no schema or protocol.Deviation
The first commit is docs, not the failing test. Tests and implementation are in the CX1 commit.
Follow-ups
CX2 (cache-aligned summarizer), CX3 (prune watermark), CX4 (
RunActivity::Compacting), CX5 (live qualification).