Skip to content

fix(runtime): reset run bounds at their seams (AC2) - #278

Merged
lg2m merged 2 commits into
mainfrom
fix/eng-1017-ac2-bounds-reset-at-seams
Oct 12, 2026
Merged

lg2m merged 2 commits into
mainfrom
fix/eng-1017-ac2-bounds-reset-at-seams

Conversation

@lg2m

@lg2m lg2m commented Oct 10, 2026

Copy link
Copy Markdown
Collaborator

Spec / tracking

ENG-1017, autonomous-core AC2, ADR-0048 § 1. Closes ENG-991.

Change

A long run's harness bounds now reset at their seams instead of building up over the run's lifetime:

  • Context reservation (4 MiB): re-based to the retained request plus the framed summary, in the in-run marker's own transaction. InRunCompactionRequest carries the retained weight. A crash leaves either the old marker with the old reservation, or the new marker with the new one.
  • Streamed model text (16 MiB): counted per window (WindowScope::model_text_bytes) and zeroed at each in-run compaction. The error message now says "per-window".
  • Empty-output cap raises: counted per streak of truncated turns (TurnScope::empty_output_retries). Any completed turn restores the allowance.
  • In-run compactions: no longer spend MAX_COMPACTION_STEPS (32). The between-run fold keeps that budget. An in-run step still has to shrink the context and is charged to the caller's limits.
  • ENG-991: the in-run cutoff is now the stored ordinal of the last replaced turn (RunScope::live_turns), not a count of live assistant messages. A faulted attempt inside the replaced span no longer makes replay keep a turn the live run summarized. A debug_assert checks that every live assistant message has its ordinal.

No protocol, store schema or prompt change. docs/design/architecture.md is amended.

Verification

Each new test fails on main (13d9c585), or under the old cutoff rule for ENG-991:

  • Soak tests:
    • separated_empty_truncations_each_recover_with_a_fresh_retry (AC2 c);
    • scripted_soak_completes_across_context_windows (a; main stopped at 399/500 on the 4 MiB limit);
    • forty_in_run_compactions_complete_off_the_between_run_budget (d; main stopped at 32);
    • forty_mib_of_streamed_text_across_windows_completes (b).
  • an_empty_faulted_attempt_inside_the_replaced_span_keeps_replay_equal_to_live (ENG-991): replay equals the live request, and assert_assembly_matches_reference passes.
  • the_between_run_fold_still_stops_at_its_step_budget.
  • one_run_spanning_several_windows… now also asserts context_compaction_attempted = 0 and a re-based reservation below the run's lifetime result bytes.
  • The single-window 4 MiB test is unchanged and passes.

Gates:

  • cargo fmt --all -- --check;
  • workspace all-target/all-feature Clippy with -D warnings;
  • cargo test -p qq-core --lib: 915 passed;
  • qq-core integration tests and examples: passed;
  • cargo test --workspace --exclude qq-core: 1,291 passed;
  • ignored soak suite: 6 passed;
  • cargo build --workspace; git diff --check.

Performance

On the hot path, this adds one Vec<u32> push per settled turn and moves two counters. turn_overhead was not re-measured for this slice. The AC1 qualification receipt (dispatch +4.0% vs A/A +0.14%) is in the ledger and still open with the lead.

Review

docs/plans/workflow.md § 4 requires an independent review because this touches sessions/ and the run loop.

The context reservation re-bases in the in-run marker's transaction,
streamed model text is bounded per window, empty-output cap raises are
per streak, and in-run compactions no longer spend the between-run
32-step fold budget. The in-run cutoff is the stored ordinal of the last
replaced turn, so a faulted attempt or reactive overflow inside the
replaced span no longer shifts replay off the live splice.

Slice AC2 (ENG-1017); closes ENG-991.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…mpaction

Review on #278: the ledger check was a debug assertion, so a release
mismatch would panic on the index or compact against the wrong turn. It
now fails the run as a server fault. Also documents the zero-row re-base
of an already settled prompt run and the per-streak retry allowance.

Slice AC2 (ENG-1017).
@lg2m
lg2m merged commit 9bae693 into main Oct 12, 2026
4 checks passed
@lg2m
lg2m deleted the fix/eng-1017-ac2-bounds-reset-at-seams branch October 12, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant