Repository navigation
perf(compaction): reuse accepted request summaries - #1033
Conversation
Preserve recognized historical evidence through summary input projection, canonical resume and artifact replacement without forwarding stable instructions or elevating runtime controls. Refs #1024.
Precede historical assistant evidence with an auxiliary summary task. Exercise the production Bedrock request builder across three generations, marked and legacy resume, PTL retries and tool pairing. Refs #1024; addresses review comment 4301351399.
Install validated request-time summaries through the canonical rewrite proof so later rounds and resume reuse the accepted working set. Reserve summary space only for actual history pressure and preserve tool pairing, active authority and failure/cancellation fallback. Refs #1023.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Recommendation: REQUEST_CHANGES for exact head 6171143aa96df8a80d6a6010ce1426587c127130, against main at d720c7f4ef3f3393d5950cdaa07a257ac27e959b. This is an author COMMENT review as XuPeng-SH.
One material finding: [P2] Do not install a request summary without authority to replace an existing provider WAL prefix. On the first canonical turn, lifecycle admission initializes the WAL base but initializes the rewrite proof only when had_canonical_head is true. The new acceptance path nevertheless replaces state.messages when begin_canonical_rewrite() returns None. If an AppendOnlyUserTail provider already has a WAL head and the accepted history is shorter than its predecessor, the next provider attempt fails with MissingLinkedPredecessor, surfaced as a contract violation before dispatch. See the inline finding at server_loop_host.rs:17819.
This is in #1033's new reuse delta. Please retain the request-local result when canonical replacement cannot be authorized, or support this first-turn transition through the canonical owner, and cover compaction after an earlier WAL-backed provider round with an empty durable base and no prior canonical head. The new reuse test initializes a rewrite proof even for generation zero, so it does not exercise this admission state.
I reviewed all 15 changed files and their relevant callers, separately checking the five-file performance delta. The historical-summary/Bedrock and MCP correlation work belongs to dependency #1031 at 1edeec65287bec34ad3f304a82c23750f7552975; its author review recommending APPROVE was checked at that exact identity. I found no additional material issue in the inherited integration.
- Design and error boundaries: traced source/projection equality, active human/authority suffix restoration, tool pairing, summary validation after truncation, token reduction, final wire budget enforcement, dropped summary futures, canonical commit/restore and provider WAL authorization. The canonical-state reuse approach is appropriate; the missing first-turn authorization guard is the blocker.
- Database, isolation and resource cost: no new SQL, table, cache, global summary state or persistence owner. Existing run/user/session authority and coordinator transactions still own persistence. Replacement changes the payload written through those paths and adds bounded-candidate allocation and linear checks; production database contention, RSS, throughput and latency were not measured.
- Verification: the exact-head runtime library test executable built with Rust 1.97.0,
--locked --offline; 135 focused tests passed, zero failed in a non-root, network-disabled container with read-only source. These cover request reuse/control, summary failure/cancellation, budget boundaries, canonical proof/recovery, pre-turn/artifact summaries, Bedrock projection and MCP correlation/cancellation. The controlled eight-round comparison reproduces eight request-local summary calls versus one accepted canonical summary in each placement mode; it is not a production performance measurement. - Independent defect fixture: compiled exact production compaction, estimator, canonical-proof and WAL-planning source against the exact-head built dependencies. A valid first-turn history with 165 messages compacts to four: the request-local control plans successfully, but canonical installation without a proof returns
MissingLinkedPredecessor. The same rewrite with an existing canonical head and initialized proof plans successfully. This is an offline source-module fixture, not a live database/provider end-to-end run. make format-checkand both diff whitespace checks passed. Current runtime CI independently reports 5,990 tests passed / 192 skipped, plus two additional checks in that job. I did not rerun all 5,689 owner-reported runtime library tests or local DB/live-provider/load suites.
Optional Harness run 39005353375 remains 16/18. flash_missing_child_model_fail_closed stopped at tool_invalid_args for missing /description, so it does not establish model-policy validation. flash_rejected_delegation_preserves_parent_tools recorded a root additional_properties rejection, only one of two ordered receipts, and an unavailable judge—not a negative quality verdict. The case definitions, validation boundary and logs were inspected; their causes remain unresolved. Repetition does not establish harmlessness or an infrastructure-only cause, and an indirect regression is not excluded. These optional failures are not the basis of the requested change.
Before publication I rechecked identity, open/non-draft state, exact head/base/main, readable requirements, required apps, complete check/status/run/job/file/review pagination and existing comments. Required CI has 13 successful contexts from app 15368, with two proven SDK/Web scope exclusions: scope job 117316582621, all 15 changed paths, the local classifier and unchanged fail-open workflow predicates agree. The tested merge 3afd3e4486a2d86aa2d0d8b78c385bf2dbfa3f98 has the expected parents and the same tree as the reviewed head. No product files or branches were changed.
| if let Some(boundary) = result.boundary.as_mut() { | ||
| boundary.messages_after = result.messages.len(); | ||
| } | ||
| state.messages = candidate; |
There was a problem hiding this comment.
[P2] Preserve request-local fallback when a WAL rewrite cannot be authorized
On a session's first canonical turn, run/lifecycle/mod.rs:17448-17459 does not initialize the rewrite proof because admission.had_canonical_head is false, although the provider WAL base is initialized. Thus begin_canonical_rewrite() above can return None, and finish_canonical_rewrite(None) is a no-op. This assignment still installs the shorter history.
For an AppendOnlyUserTail provider after an earlier WAL-backed round, that leaves provider_canonical_wal_head describing the old prefix with no replacement authorization. plan_provider_canonical_wal_transition then returns MissingLinkedPredecessor when the compacted history is shorter than that head; execute_turn converts it to a contract violation before the next provider dispatch. The prior request-local path leaves the canonical predecessor intact.
An isolated fixture using the exact production helpers reproduces 165 messages becoming four: request-local control succeeds, no-prior-head canonical installation fails, and the same rewrite with an initialized proof succeeds. Please keep the result request-local unless the canonical owner can authorize this transition, or implement first-turn replacement there. Add a regression with an empty durable base, no rewrite proof, and an already populated provider WAL head; the current generation-zero reuse test explicitly initializes a proof and misses this state.
Keep useful summaries request-local when admission has not granted a valid canonical rewrite permit. Preserve the provider WAL predecessor on first canonical turns and stale-proof paths instead of installing an unauthorized shorter history. Cover missing and stale authority with and without an earlier provider WAL head through the real request compactor, WAL planner, and terminal commit owner. Refs #1023; addresses PR #1033 review comment 4301627550.
Merge main while preserving accepted request summaries, valid canonical rewrite authority and request-local fallback for unauthorized WAL replacement. Retain both request-time regressions and main's pre-turn test isolation.
XuPeng-SH
left a comment
There was a problem hiding this comment.
Recommendation: APPROVE for exact head 43c2f107706127c07c5764910e72a23e7fe6ef8f, against main at 3e42b4cc03916cf6d896585a5737ff0146e92af9. This is an author COMMENT review as XuPeng-SH.
No remaining material findings. The first-turn WAL defect from review 5556510988 is addressed. Canonical installation now requires an admitted, valid rewrite permit. Missing or stale proof leaves the successful summary request-local and preserves the canonical predecessor, WAL head and request-prefix protection count. This recommendation supersedes the earlier REQUEST_CHANGES recommendation only for the head named above.
I verified the historical review body SHA256 947eaff24f5ac5ffe2091de05052f044e6bacc696653d06fe63d87d192a133ff and inline comment 4301627550 at its original commit 6171143aa96df8a80d6a6010ce1426587c127130, original line 17819, RIGHT side, position 108. Its current remapping to this head at line 17822 was not treated as original provenance.
I reviewed the complete current six-file PR diff and affected call chains. Relative to current main, implementation is +144/-31, test modules +764/-6, and documentation +24/-0; there are no pure file moves. The compaction, Memoria and wire-assembly blobs match the earlier reviewed versions, so I reused that source analysis while checking their current callers. The permit accessor, installation guard and four-case regression were reviewed afresh. Dependency #1031 is incorporated in main and is outside this six-file delta.
- Design and complexity: the existing canonical proof, provider WAL, terminal commit and continuation restore remain the owners. Accepted summaries replace prior generations and feed subsequent pressure estimates; there is no parallel cache, persistence lifecycle or second history writer. The intentional request-local fallback remains available when canonical authority is absent.
- Authority and recovery: traced exact source/projection matching, restoration of the active human/authority suffix, canonical tool pairing, post-truncation summary validation, net token reduction, final wire budgeting and rebasing of the protected request prefix. WAL admission, one-shot replacement authorization, recovery of a committed replacement and terminal manifest fencing still use the existing typed boundaries.
- I/O, isolation and resources: no new SQL, schema, memory write, global mutable summary state, lock or background task. Memoria retains bound-user authority and strict session scope; canonical persistence retains its existing user/session/run ownership. Successful replacement changes the payload written through existing transactions and adds linear checks and a bounded candidate allocation. Production database contention, RSS, throughput and latency were not measured.
- New local verification: the exact-head runtime library test executable built with Rust 1.97.0 using
--locked --offline. 144 focused tests passed / 0 failed in a non-root, network-disabled container with read-only source/build inputs during execution. These include missing/stale proof crossed with empty/populated WAL, unchanged canonical state and successful next WAL planning, append commit after fallback, accepted generations, small-round/resume reuse, summary failure and dropped futures, invalid source/pairing/non-reducing candidates, budget boundaries, canonical proof/replay, and Bedrock summary projection. - The controlled eight-round tests reproduce eight request-local summary calls versus one accepted canonical summary in both placement modes; subsequent meaningful history produces the next generations. These are fixture call counts and serialized working-set measurements.
make format-checkand diff whitespace checks passed. I did not rerun the full runtime/workspace, live-database, live-provider or load suites locally; earlier owner-reported totals are not presented as new verification for this head.
Before publication I rechecked the exact head/base/main, open/non-draft state, authenticated identity and author, current requirements/apps, complete check/status/run/job/file/review pagination and existing review bodies/original anchors. Required CI has 12 successful contexts from GitHub Actions app 15368 and three source-proven scope exclusions: SDK, Web and turn-core/services/plan. All six changed paths, the current classifier, successful scope jobs 117574445023/117574444689, and unchanged fail-open workflow guards agree. The tested merge 7b227ec733dc80039aabac04f1557976f6da5b31 has the expected base/head parents and tree 8ba43411f4cbdfdb94fac900e2365069f6ed7600, identical to the reviewed head.
The current optional Harness run 39093313058 is successful. Earlier optional 16/18 results and the unexplained failures on historical 2ff are not current failures or evidence of a demonstrated infrastructure root cause. No product or branch changes, remote CI reruns, live paid inference or shared/production services were used.
Summary
Request-time compaction previously summarized and trimmed the same long history again on later tool rounds because its accepted representation never reached
AgenticLoopState.messages. Install a useful summary and bounded history through the existing canonical rewrite proof. Subsequent pipeline and pre-turn pressure estimates use that working set plus new history, and ordinary canonical continuation restores it.Reserve summary space only after history exceeds the actual budget after memory costs. A hypothetical next summary cannot manufacture another compaction in fitting history.
Refs #1023. Dependency #1031 is already incorporated in current main; the remaining diff is six files.
Correctness and ownership
Current revision
Head:
2ffcd2ea8f699105257ba24ae49955a6726cbbe1. Normal merge parents:58a31c103758d6be3b2ac57d39becbaf6362f7fband main8ee927c1714a19d82081a004b1c7f0635675e50d. No history rewrite or force push.Tested tree:
6399ab3dd997554dda9bbd86e30d9ceb5ea55b14. Fetch/readback confirms that published head and GitHub test merge8742134e523fba00f98dd726fd6f3fe70e521530have this exact tree.The merge retains both request-time regression coverage and main's pre-turn test isolation. Relative to current main: implementation +144/-31 (net +113), test modules +764/-6 (net +758), documentation +24/-0 (net +24). No file moves. Added implementation reuses canonical history instead of introducing another state owner.
Local verification
Rust/Cargo 1.97.0:
cargo test --locked -p astra-runtime --lib --no-run: passed. Missing locked dependencies in the fresh environment were downloaded; lockfile was not edited.cargo clippy --locked --offline -p astra-runtime --lib --tests -- -D warnings: passed.make format-check, staged/final diff whitespace checks, andpython3 scripts/ci/validate_repository.py: passed.The initial full test run inside the command sandbox reported 49 workspace-fixture failures because its UID mapping exposes root-owned
/tmpas UID 65534. The unchanged coordination owner requires root-owned sticky/tmpand correctly rejected execution. A read-only host-view check confirmed0:0 / 1777; rerunning the same binary outside that mapping passed every test, without source or system-permission changes. No OS network-isolation claim is made.Regressions cover accepted generations, unchanged/small-round reuse, request-local eight-call control versus one canonical summary in both placements, meaningful new history, canonical commit/restore, WAL authorization, missing/stale proof with empty/populated WAL, owner/session isolation, failure and cancellation. Fixture call counts are not production latency, RSS, throughput or database-cost measurements.
Full-workspace, live-database and live-provider suites were not run locally. No production/shared services or paid provider calls were used.
CI and review
Current Test Suite and Static Checks are pending as of 2026-10-17 15:06 UTC. Complete check/status/run/job pagination was read; required contexts were obtained from current main protection and checked against GitHub Actions app 15368. PR title passed; SDK, Web and turn-core/services jobs are scope-skipped, confirmed by the six changed paths, local classifier and both successful scope-job logs. Other required contexts are still running or awaiting generation; pending is not a pass.
The automatically triggered optional live harness is separate from required protection checks. No remote CI rerun was requested. Independent review remains separately arranged; no self-approval was submitted.