Skip to content

feat(runtime): isolate durable side-question execution (SQ1) - #266

Merged
lg2m merged 18 commits into
docs/eng-1011-btw-goals-deliveryfrom
feat/eng-1011-sq1-side-runtime
Oct 9, 2026
Merged

lg2m merged 18 commits into
docs/eng-1011-btw-goals-deliveryfrom
feat/eng-1011-sq1-side-runtime

Conversation

@lg2m

@lg2m lg2m commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Stack

Parent #262; child #270. Tracking https://linear.app/retsu-ai/issue/ENG-1011. Bases preserved for combined merge.

Implemented

Bounded SQL-boundary immutable context capture, current-task quoting with unfinished-tool omissions; durable isolated threads, streaming projection, independent usage/cost/permits/cancellation/deadlines; typed submit/cancel receipts and replay; recovery interrupts without replay. Uses shared CompiledAgentPlan execution with exact built-in inspection authority intersected with effective source policy and managed denies (applied to the derived side plan only; main catalogs unchanged). Main run continues with unchanged slot/transcript/requests/accounting.

Compatibility

Merged with main at v0.1.6, which already shipped protocol 31 (CX4) and store schema 43 (prune watermark). Side questions therefore ship as protocol 32 (goldens under v32/; v31/ is byte-identical to main) and store schema 44 (side_questions). Older clients refuse a 32 server; older binaries cannot open a 44 store.

Codex review (2026-10-09)

14 findings fixed with regression tests: tool-task drain before settlement; delete/prune refuse running side rows; in-flight spend persists unknown; side questions reserved in reconnect snapshots; active-run capture reads streamed chunks; managed denies narrow only side plans; owned submit-launch task; cold client views drop side bodies; per-turn streaming reset; downward SideQueryLimits; geometric partial checkpoints; replacement waits for cancelled owner; side_question_already_finished outcome; typed SideQuestionNotFound. Declined: persisting side tool exchanges for continuation (rationale in thread; recorded in the plan).

Verification

cargo test --workspace: 2,204 passed, 0 failed, 13 ignored (SQ1 head); 2,218 passed on the SQ2 head that includes it. Side filter 48 passed; cargo fmt --all -- --check and cargo clippy --workspace --all-targets --all-features -- -D warnings clean.

Performance

Debug diagnostic (pre-review): full-context p50/p95 1511/1692us vs bounded 5161/5286us. Main stream baseline p95 6612us vs concurrent side 7015us (+6.1%, informational). Review fixes reduce partial-answer persistence from O(n²) to O(n log n) bytes.

@lg2m
lg2m added this pull request to stack #269 October 7, 2026 04:38
@lg2m

lg2m commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed 7846b12: bounded SQL-preflight context capture, isolated core execution/admission/permits, durable schema-43 capture/answer records, continuing side-thread history with explicit reset, cancellation/shutdown handling and active-main-provider isolation tests. Full workspace tests passed with four threads (316 s); workspace Clippy passed after latest edits. Kept the GitHub stack/base unchanged. Still draft: protocol/reducer/replay, per-turn failure accounting, managed-deny/context-fidelity acceptance, crash/cancellation coverage and latency comparison remain. Continuing implementation; not marking SQ1 complete.

@lg2m

lg2m commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

Pushed through d68f58a: protocol 31 submit/cancel receipts + separate replayable side projection and client reducer; partial text durable before publication; recovery interruption events; per-turn failed-run spend; managed-deny catalog intersection; shutdown/panic fixes. Full workspace tests passed (290s) at 6033e5e predecessor, latest focused 27 side-filter tests and workspace Clippy passed. Scripted main-stream baseline/side p95 gaps 6612/7015us (+6.1%, diagnostic only). Still draft: independent review exposed durable admission/finalization waits outside the 120s execution deadline and current-main capture is conservative (current prompt + settled units, unfinished exchanges omitted). Continuing to close these, not relaxing acceptance or changing your stack.

@lg2m

lg2m commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator Author

Latest pushed 5f16d18 closes the final reviewed admission handoff race: deadline applies to capacity acquisition only, accepted send/receipt return is synchronous; settlement returns effective durable state atomically. Added deterministic held-worker receipt and expired-admission tests. 33 focused side-filter tests pass; full workspace tests pass (295.8s, four threads), workspace all-target/all-feature Clippy and build pass. Previous timeout failures are superseded by multiple successful full reruns. All concrete last-review findings addressed; fresh independent review request hit the session eight-agent cap, so no new reviewer approval claimed. SQ1 runtime/protocol/store/reducer is implemented; SQ2 surfaces are next. Keeping your stack base unchanged.

@lg2m lg2m changed the title feat(runtime): isolate side-question execution (SQ1 draft) feat(runtime): isolate durable side-question execution (SQ1) Oct 7, 2026
@lg2m
lg2m marked this pull request as ready for review October 7, 2026 16:26
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-07T16:41:56.717059Z 5f16d18 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f16d18bf4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/qq-core/src/sessions/commands.rs Resolved
Comment thread crates/qq-core/src/sessions/commands.rs Resolved
lg2m added 6 commits October 9, 2026 01:06
…1-side-runtime

Main shipped protocol 31 (CX4) and store schema 43 (prune watermark) in
v0.1.6, so side questions move to protocol 32 and schema 44. v31 goldens
are restored to the released set; v32 carries the side-question fixtures.
Side capture reuses the shared assemble_model_context with a window start.
SessionView::evict_body now clears side questions, and SideQuestionUpdated
applies only to warm views, so summary-only sessions cannot accumulate up
to 64 x 128 KiB of side answers.

Addresses Codex review on #266.

Refs: ENG-1011
Add CommandOutcome::SideQuestionAlreadyFinished { side_question_id, state }
to protocol 32 (mirrors RunAlreadyFinished) with a v32 golden fixture.
Protocol 32 is unreleased, so no version bump.

Addresses Codex review on #266.

Refs: ENG-1011
- Drain each side execution's ToolTasks before durable settlement.
- Refuse DeleteSession/PruneSessions while a side question runs; late
  turn/settlement writes tolerate a vanished row instead of failing the
  runtime.
- Persist in-flight spend as unknown; only committed totals are known.
- Load side questions first from a reserved snapshot budget.
- Reassemble streamed chunks when capturing active-run assistant turns.
- Own SubmitSideQuestion in a spawned task holding a side slot, so a
  dropped caller cannot strand a running row.
- Reset streaming state per turn; geometric partial-update checkpoints.
- Add downward-only SideQueryLimits to SessionRuntimeOptions.
- Hand session ownership to a replacement only after the cancelled owner
  tears down.
- Return SideQuestionAlreadyFinished for a lost cancel and
  SideQuestionNotFound (client error) for unknown ids.
- Document that continued threads replay question/answer text only.

Addresses Codex review on #266.

Refs: ENG-1011
Managed deny_tools filter grants on main runs, not catalog exposure
(headless contract). with_denied_tools is replaced by
AgentProfile::with_side_question_denies, stored on the compiled plan and
applied only when deriving the side-question plan, which has no grant
path. Main catalogs and plan digests are unchanged.

Addresses Codex review on #266.

Refs: ENG-1011
Ledger entry for the protocol 32 / schema 44 move and the Codex review fixes.

Addresses Codex review on #266.

Refs: ENG-1011
@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 merged commit 809a6db into main Oct 9, 2026
6 checks passed
@lg2m
lg2m deleted the feat/eng-1011-sq1-side-runtime branch October 9, 2026 19:48
lg2m added a commit that referenced this pull request Oct 10, 2026
* docs: move research into docs/research and give plans names matching their ledgers

Research snapshots leave design/ (which is present-tense, as built) for
docs/research/ with undated names; the snapshot date stays in each header.
speed-first and terminal-bench plans now share their ledger's name, and the
progress-report runbook is named for what it is: run-output store queries.
Also repairs the two broken links (ADR-0039, concepts.md).

* docs: update references to the renamed speed-first and terminal-bench plans

* docs(plans): retire shipped plans and orphaned ledgers; reconcile statuses with Git

- side-questions plan shipped (SQ0-SQ2, #262/#266/#270): its contract moves
  to design/side-questions.md, written against side_questions.rs.
- Delete ledgers whose plans closed (delegated-approval, onboarding-ux,
  mcp-pinning, codex-device-auth, latest-models, harness-f25-empty-range);
  F25 folds into root.md. Receipts remain in Git history.
- Mark ledger rows Shipped where the commit is on main (GE0, GE10, JV0-JV2,
  RR4.1-RR8.4, TE0, T2.1, U5-U7, D4a.1, D6a.1, F11, F23, F24).
- Collapse tui-redesign to its open L4/U8 slices; the shipped spec is in
  layout.md, transcript.md and theme.md.
- Rewrite plans/README.md and progress/README.md: every plan and ledger
  listed once, stale priorities (CX1-CX4, GE0, T15-T17, TE1) replaced,
  ownership rows for shipped work moved to design pointers.
- docs/README.md gains a research section and a naming convention.

* docs(adr): one index table with titles from each ADR; record reserved and unused numbers

- 0031-0056 move from a bullet list into the table; titles match each H1.
- A gaps table records 0016-0018, 0037 and 0055 as reserved and 0029,
  0044/0045 (#187 closed unmerged) and 0053 as unused; root.md agrees.
- Supersession metadata on 0003, 0028 and 0030 (status lines only).
- root.md: 0028 and 0031-0035 are merged, not local candidates.

* docs(design): make design docs describe the system as built

- architecture.md: real dependency graph (qq-harness; qq-tui -> qq-core),
  real src/ tree, real route shape instead of an invented sketch; present
  tense throughout; tool list, hosting boundary and TUI detail deduplicated
  to links; task-routing section moved out of Intentionally Deferred.
- protocol.md: descriptor 13; one accurate fixture statement (v32 current,
  v17-v31 decode-only); 29/30 deduplicated; 24/25 moved into the history.
- headless-contract.md: --allow-host in the synopsis; the shipped-gaps
  status table folds into the contract (Supervisor Boundary Notes; ADR
  0014/0022/0023 links follow).
- product.md: the real command list; scope restated as present.
- tools.md, theme.md, layout.md, providers.md: plan pointers, slice IDs and
  build checklists removed; layout states that Ultra shows one pane today.
- jev.md: fixed findings restated as behavior; the Direction section moves
  to plans/jev.md § Target design (the plan owns intent).

* docs(runbooks): correct runbooks, guide and contributor docs against the code

- xtask README: homebrew-formula, release --docs/--no-commit; perf workers
  are release-only on Linux, so perf-recording uses cargo run --release.
- local-dev/CONTRIBUTING: the real toolchain and what CI actually runs.
- release.md: version sample uses placeholders instead of stale numbers.
- jev runbook: approval_delegate values match config; limitations stated
  as behavior, without slice IDs; JV2's fixed headless limitation removed.
- Runbook H1s consistent; run-output-queries not Nix- or Linux-only.
- website/README defers to the website runbook; arms/perf READMEs fixed.
- guide: side questions sit with run behavior; mortal plan links replaced;
  cli --tui-qa-root PATH; README lists concepts.
- cli.rs help: qq run exit code 5; config explain lists every field.

* docs(root): link the docs cleanup slice to ENG-1016

* fix(guide): restore the concepts link to cli.md#qq-jev

The site's heading slugs drop the trailing hyphen GitHub would keep for
`qq jev …`; the original anchor was right and the website link check
failed on the changed one.
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