Skip to content

feat(runtime): record slice checkpoints as report turns; an empty one no longer fails the run (AP3a) - #237

Merged
lg2m merged 4 commits into
test/eng-986-ac0-soakfrom
feat/eng-990-ap3a-report-turns
Oct 2, 2026
Merged

lg2m merged 4 commits into
test/eng-986-ac0-soakfrom
feat/eng-990-ap3a-report-turns

Conversation

@lg2m

@lg2m lg2m commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

Slice AP3a of autonomous-core.md (ADR-0054 § 2) · Linear ENG-990 · Base: #236 (AC0.1), on #235 → #233 → #232.

What changes for users

The 256-call slice checkpoint, where a long run is asked to write down its progress, now works the way it was meant to:

  • The prompt cache survives it. The checkpoint and continuation notices used to be appended to the system prompt, which invalidated the provider's cached prefix twice per slice. They are now runtime messages at the end of the conversation, and the system prompt and static prefix never change.
  • An empty checkpoint no longer fails the run. provider returned an empty slice checkpoint used to end a multi-hour run. An empty metered reply is now a missed report: the slice resets and the run continues. An empty reply with no usage after fresh tool results is still retried as a swallowed gateway failure, which is documented and tested.
  • The checkpoint asks for a report: what is established (with path:line), what is unknown, and the next action. This is the shape AP3b builds on.
  • Steering sent during the report is applied before the continuation, as at any other boundary.

Design

  • Persistence. runtime::TurnNotice { Report, Continuation } is carried on AssistantTurnCompleted. It is persisted as model_turns.notice (store schema 39 → 40, a nullable TEXT column) on the first turn row whose request carried it.
  • Replay. Assembly renders the notice after that boundary's steering and before the turn. A later run therefore sends byte-for-byte the messages the live run sent. A stored value this build doesn't know is a CODEC error.
  • Empty reports. The live context fills an empty report with EMPTY_TURN_PLACEHOLDER, which is exactly what assembly inserts, so live and replay match.
  • In-run compaction. The live splice removes everything before the first kept turn. Replay and the reference oracle now drop that turn's notice and steering too. The steering half of that bug predates this slice; review found it.
  • The column records where a notice entered the conversation, not every attempt it covered. A report retried after a fault or an output-limit cut is placed and stored once. This is documented in architecture.md, and the progress-report query judges each report by its last attempt.
  • Budget-final turns are never told "tools are available again".

Verification

  • Flipped tests (each failed on the base):
    • direct empty checkpoint → Completed, and the live window is [report notice, placeholder, continuation notice];
    • session an_empty_checkpoint_is_a_missed_report_and_the_run_completes_with_its_billing: billed, replay identical, oracle agrees;
    • AC0.1's soak oracle an_empty_checkpoint_is_a_missed_report_and_the_run_continues.
  • Byte identity:
    • restart replay equals the live context across a checkpoint and continuation;
    • text reports, empty reports, steering during a report (both kinds), truncated reports and faulted reports each match the live context and the reference oracle;
    • end to end, three in-run compactions after the report replay the live context. This test fails on the pre-fix replay rule, as does the unit test replay_drops_the_notice_and_steering_the_in_run_splice_removed.
  • The system prompt and Prepared.static_prefix are equal across the seam.
  • A text-only report is never audited (audit always audits only the final answer). A Jev run cannot reach a checkpoint: a test pins MAX_CHECKPOINT_REVIEWS_PER_RUN below the slice size.
  • Migration version_thirty_nine_gains_the_turn_notice_as_null_and_rejects_a_bad_shape: old rows replay unchanged, a bad column shape is refused, and an unknown value is CODEC. Migration tests now assert STORE_SCHEMA_VERSION instead of 27 "39" literals.
  • cargo test --workspace: 2029 passed, twice. Soak --ignored: 5 passed. Clippy (--all-targets --all-features -D warnings) and fmt are clean. Docs-truth passes with the guide's "store schema 40".
  • Benches, A/B with 3 runs each:
    • context_assembly assemble medians: 51.6 / 52.7 / 55.9 µs before, 51.0 / 52.9 / 55.2 µs after;
    • turn_overhead: 15.0–15.6 ms before, 15.4–16.4 ms after, with overlapping ranges.
    • Both are within noise.

Review

There were two independent read-only reviews. The first requested changes: one blocking item (the in-run splice versus replay), four should-fixes, and five test gaps. All are fixed. The second approved and asked for S1–S3 in this PR, which are done. Its S4, the in-run cutoff unit drift that predates this slice, is filed as ENG-991 and recorded as an AC2 input.

Compatibility

  • Store schema 40, a forward-only migration: older binaries refuse an upgraded store. The guide says so.
  • No protocol or descriptor change.
  • System-prompt hashes are unchanged for ordinary turns. Checkpoint and continuation turns now share the run's hash.

lg2m added 3 commits October 1, 2026 17:17
… no longer fails the run

The 256-call slice checkpoint used to append its notice to the system
prompt. That invalidated the provider's cached prefix twice per slice, and
23 of 25 observed checkpoint turns ignored it. An empty reply also failed the
whole run.

The checkpoint and continuation notices are now runtime messages at the end
of the conversation, and the system prompt never changes at the seam. Each
notice is persisted with the first turn whose request carried it, as
model_turns.notice (store schema 40), and assembly replays it before that
turn. Live and restart contexts are therefore byte-identical, which the
reference oracle and a restart test check. An empty checkpoint is a missed
report: the live context fills it with the placeholder assembly inserts,
the slice resets, and the run continues. Steering that arrives at a
text-only checkpoint is applied before the continuation. The checkpoint
text now asks for a report (established with path:line, unknown, next
action).

Flips AC0.1's empty-checkpoint oracle. Migration tests assert
STORE_SCHEMA_VERSION instead of a literal.

AP3a of docs/plans/autonomous-core.md (ADR-0054 § 2).

Linear: ENG-990
…low-up for report turns

The in-run compaction splice removes every message before the first kept
assistant turn, including the steering and the runtime notice in front of
it. Replay dropped only turns through the cutoff, so it re-added both. The
steering half predates this slice. Replay and the reference oracle now drop
the first kept turn's notice and its steering.
replay_drops_the_notice_and_steering_the_in_run_splice_removed failed on
the old rule.

Also:
- a budget-final turn never gets the continuation notice;
- an unmetered empty checkpoint is retried as a swallowed gateway failure
  (documented and tested);
- the notice column's meaning (first attempt) is documented, and the
  runbook query judges each report by its last attempt, checked against a
  schema-40 store;
- a misplaced doc comment is fixed.

New tests: steering during a report, for text and empty reports; audit
always audits only the final answer; a truncated report keeps one notice
and replays identically; one static prefix across the seam.

Linear: ENG-990
Second-review follow-up:
- a budget-final turn after a report gets no continuation notice. The
  regression fails if the guard reverts;
- the runbook query reads blocks from $.content when a turn carries a
  provider replay envelope;
- end to end, a run compacts in-run three times after its slice report and
  a follow-up replays the live context. This fails on the pre-fix replay
  rule;
- a faulted report is retried under one notice, and the stored rows replay
  in live order;
- a Jev run cannot reach a slice report: its per-run review cap, now the
  named MAX_CHECKPOINT_REVIEWS_PER_RUN, is below the slice checkpoint, and
  a test fails if either moves.

The cutoff unit drift found in review predates this slice and is filed as
ENG-991, an AC2 input.

Linear: ENG-990
@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.

@lg2m
lg2m added this pull request to stack #234 October 2, 2026 03:21
…cord the Bedrock check

The plan and ADR-0054 described a 'turn kind' column; what shipped is
model_turns.notice. The plan header still said AC0.1 was unpushed, and
the runbook said schema 39 only. Records the live Bedrock Converse check:
Llama and Mistral reject user text after tool results in any form (ENG-999).

Linear: ENG-990
@lg2m
lg2m merged commit 2a672fe into main Oct 2, 2026
6 checks passed
@lg2m
lg2m deleted the feat/eng-990-ap3a-report-turns branch October 2, 2026 05:26
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