Skip to content

docs(plans): plan the autonomous, embeddable core (ENG-978) - #211

Merged
lg2m merged 6 commits into
mainfrom
docs/eng-978-autonomous-core-plan
Sep 29, 2026
Merged

lg2m merged 6 commits into
mainfrom
docs/eng-978-autonomous-core-plan

Conversation

@lg2m

@lg2m lg2m commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Spec

ENG-978. Research is in docs/design/core-autonomy-audit-2026-09-28.md and the plan is docs/plans/autonomous-core.md. Docs only; no code change.

What this proposes

Goal: qq-core runs one task unattended for 8+ hours to a typed outcome, with bounded memory, disk and fsyncs, and a third party can embed it in under 100 lines. Frontends (TUI, web, supervisors) are clients of that core and are out of scope beyond showing the new state.

New findings, verified from source on 7885f2c

  1. The 4 MiB per-run context reservation is never re-based by in-run compaction. runs.context_increment_bytes counts every streamed chunk and tool result over the whole run (sessions/claim.rs:947–966) and is zeroed only at run start. A long tool-heavy run (roughly 500–2 000 calls) fails Policy: session context reached its 4 MiB limit even though its live context was compacted. The 48-turn in-run compaction test adds about 105 KiB, so it never gets near the limit.
  2. 16 MiB of model text (lib.rs:1618) and one empty-output retry (lib.rs:1382) are also counted over the whole run.
  3. A stopped run has no way back. paused (about 2–3 min of outage) and interrupted (any restart) never continue. The RR4 plan's ResumeRun and "retry to the deadline" were never built.
  4. Fatal on the first failure: the in-run summarizer turn is not covered by turn recovery (lib.rs:1823), and an empty checkpoint reply fails the run (lib.rs:2633).
  5. There is no loop or no-progress guard and no durable goal. Obligations wear away across repeated summaries.
  6. execute is about 2 430 lines inside one stream!, with 63 mutable bindings whose reset scope is implicit. That is why 1 and 2 exist.
  7. Composition (config → provider/ResolvedModel, RuntimeLoader, PlanCache, MCP bridge, headless driver) is about 12 k lines in src/. The only embedding reference is a 150-line test.
  8. htmd brings 22 packages that nothing else uses, for fetch only. Store writes duplicate streamed text, and retention is unbounded (ADR-0038 is still Proposed).

Proposed decisions

ADR Decision
0048 Run bounds reset at their seams (window/streak/slice/turn; caller RunLimits stay lifetime). The summarizer runs under turn recovery. A ContinueRun command plus opt-in AutoContinue (cooldown for paused, startup for interrupted) continue a stopped run as a linked run. A call without a recorded result is never re-executed.
0049 A durable RunGoal (objective plus a bounded checklist, update_goal tool) is re-stated verbatim after every compaction and continuation, and costs zero bytes when unused. A bounded completion audit. An always-on loop guard (3rd identical failing call or 5th identical call → rejection result; 2 idle slices → paused{no_progress}). Continue-if-idle.
0050 A qq-harness composition crate moved out of src/ in three mechanical PRs. qq-core gets a CI-tested examples/embed.rs, a public resolved_model, async compile, a tool-fetch feature, and public-surface hygiene (no rusqlite type in public signatures; product extensions off the core load request).

Slices (AC0–AC16)

Order:

  • AC0 soak and resource harness first. It reproduces findings 1–3 as failing tests and adds turn-overhead, RSS, WAL and fsync metrics.
  • AC1 extracts RunState by reset scope, with zero test edits.
  • Then AC2 and AC3 (the minimum for multi-hour runs), then AC5 and AC6 (continuation).
  • The embedding track AC10–AC13 runs in parallel.
  • Protocol changes are batched into two PROTOCOL_VERSION bumps.

Plan acceptance is measured: a scripted 2 000-turn, 5 000-call soak with ≥ 20 compactions, 3 outages and 2 kills completes with zero Policy failures and no duplicated calls; RSS is flat; per-turn overhead is flat; the embedding example is under 100 lines; the minimal profile builds.

Consolidation / stale-doc cleanup

  • Deleted docs/plans/mid-run-compaction.md. Its design is ADR-0039 (link updated to point at Git history). MRC-4 moves to AC14 and MRC-5 to Goal 5.
  • run-reliability.md: the status block is brought current (RR6, RR7, RR7.1, RR4.1, RR8.1–RR8.4 shipped). The RR4 note now says ResumeRun was not built, and RR12's loop item moves to AC4.
  • plans/README.md: the stale priority 0 (RR1–RR4, all shipped) is replaced, and the F03 triage row is corrected. progress/root.md: F03 is marked shipped.
  • ADR numbers 0048–0050 are reserved. 0047 is shown as held by docs(jev): consolidate Jev docs into one design, plan, ledger and runbook #210 so the two PRs don't collide.

Verification

  • A relative-link check over every changed Markdown file found no broken links.
  • cargo test --offline --bin qq docs_truth → 5 passed.
  • Every file:line citation in the audit was re-checked against 7885f2c. The reference-harness paths were checked under .source/ at the revisions the audit records.

Compatibility / performance

None: docs only. The ADRs are Proposed; each needs a lead decision and a second reviewer before its slices start.

Decisions needed

  1. Accept, amend or reject ADR-0048, 0049 and 0050, in particular the crate name qq-harness and whether the loop guard is on by default (AC4 gates that on T13 evidence).
  2. Merge order with docs(jev): consolidate Jev docs into one design, plan, ledger and runbook #210 and docs(plans): retire the onboarding plan; open the guide-expansion plan #186, which touch the same index files. Whichever lands second rebases the index rows.

Add a read-only source audit (core-autonomy-audit-2026-09-28) of what stops
qq-core from running one task unattended for hours and from being embedded,
and the plan that acts on it (autonomous-core.md, AC0-AC16, ledger).

Three proposed ADRs:
- ADR-0048: run bounds reset at their seams; ContinueRun and opt-in
  auto-continue of paused/interrupted runs, never re-executing a call
  without a recorded result.
- ADR-0049: a durable run goal re-stated verbatim after every compaction,
  a completion audit, an always-on loop guard, continue-if-idle.
- ADR-0050: a qq-harness composition crate out of src/, a tool-fetch
  feature, a CI-tested embedding example and public-surface hygiene.

Consolidation: delete mid-run-compaction.md (design is ADR-0039; MRC-4/5
move to AC14 and Goal 5), move RR12's loop result to AC4, bring
run-reliability status up to date (RR6-RR8.4 shipped; ResumeRun never built),
mark F03 shipped, reserve ADR 0048-0050 (0047 held by #210).

No code change.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 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-09-29T03:17:44.619835Z 5caeb1b New commits
ℹ️ 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: 8c2e15d45a

ℹ️ 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 docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/adr/0039-in-run-compaction.md Resolved
Comment thread docs/plans/README.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Continuation names its run, admits only the session's latest prompt run,
and is race-safe through UNIQUE(continues_run_id). It carries exact limit
remainders against the original deadline, sends a notice instead of the
prompt a second time, and never auto-continues no_progress. The goal is
bound to its run chain and activated at claim, and renders whole within
8 KiB. The completion audit gets its own allowance. The loop guard is
progress-aware. update_goal is in every catalog, exposed per run, so plan
identity is unchanged. qq-harness takes public inputs and is proven by an
external smoke crate. Move PRs are ordered to build on their own. Protocol
pairs land as single PRs. AC15 and AC16 scopes are corrected. The
ADR-0039 edit becomes an appended clarification, and the RR8 remainder is
listed as open.
lg2m added a commit that referenced this pull request Sep 29, 2026
… contract is checked

Review (Codex, #212): only PROTOCOL_VERSION is checked across a connection;
capabilities are advertised, and the descriptor and store schema are checked
locally (plan identity, store open). The runbook said both sides check all of
them. The table and text now say where each is checked.

The policy itself is a durable choice a future maintainer could re-litigate,
so it is recorded as ADR-0051 (0048-0050 are held by #211), indexed, and
reserved in the root ledger.

Refs: ENG-969

@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: b78f0ec0e4

ℹ️ 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 docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
…plan (ENG-978)

Goal writes are checked against a rendered-size cap with bounds that
provably fit. Continuation carries every cumulative RunLimits field and the
remaining repair_turns. AC11 owns every fetch consumer. The loop guard
rejects only after observed repeats and counts new reads as progress. The
reservation rebase travels with the compaction request because the marker
commits before the splice. Headless follows continuation chains.
achieved_pending_audit is durable before publish. Load stages stay a closed
enum. Also corrects the effect class name ReadOnly.
…us-core-plan

# Conflicts:
#	docs/adr/README.md
#	docs/plans/README.md
#	docs/plans/progress/root.md

@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: 6fafe68ee2

ℹ️ 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 docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
…lan (ENG-978)

Correct the audit: in-run compaction shares and is refused at the 32-step
compaction budget, and ADR-0048/AC2 stop charging it there. Also correct the
audit's fsync-cost claims, since activity and chunk writes already share group
commits. AC15 becomes measure-first and keeps ADR-0003's committed JSON.
AC16 becomes a workspace retention gate and the single-session store bound
becomes linear growth. AC12.1 leaves RuntimeBuildError in the binary until
its catalog dependency moves. The goal PR owns the client reducer.

@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: bbf70a4e69

ℹ️ 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 docs/plans/autonomous-core.md Resolved
Comment thread docs/adr/0039-in-run-compaction.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
Comment thread docs/plans/autonomous-core.md Resolved
…erating slice files (ENG-978)

Loop guard: separate the seen set from the repeat counter so short cycles
still pause. A steer no longer claims to resume a finished run. from_runtime
takes an explicit workspace. RunPause becomes reason-tagged. qq-harness
depends on qq-protocol. Owned paths become starting areas: each slice owns
every consumer its type and wire changes force, gated by the workspace
build, and new state must reach snapshots and reducer state in the same PR.
@lg2m
lg2m merged commit 6022d99 into main Sep 29, 2026
4 checks passed
@lg2m
lg2m deleted the docs/eng-978-autonomous-core-plan branch September 29, 2026 03:16

@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: 5caeb1b2e1

ℹ️ 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 on lines +89 to +92
- a **seen set** of every such triple observed in the current slice,
bounded at 4 096 hashes (16-byte hashes, 64 KiB), with eviction
counted as "seen". It is cleared only at a slice boundary or by a
*mutation event*: a successful call with effect class other than

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Keep novelty history across slice boundaries

The revised A/B fix still cannot make the advertised no_progress pause fire: because the seen set is cleared at every slice boundary, the first A and B in each 256-call slice are novel again, so every slice contains novelty and the condition at lines 107–110 never accumulates two no-novelty slices. Fresh evidence beyond the prior alternating-loop comment is this explicit boundary reset in the revised design. Carry the bounded history across the no-progress window, or exclude boundary re-discovery from the slice accounting; otherwise an A/B loop can run indefinitely despite AC4's required fixture.

AGENTS.md reference: AGENTS.md:L81-L82

Useful? React with 👍 / 👎.

Comment on lines +130 to +131
- Continuations are ordinary runs: durable, observable, cancellable. A
cancel or new prompt from a client cancels the pending continuation.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Define cancellation of a scheduled continuation

During the cooldown, the named run is already settled as paused or interrupted, so the current CancelRun handler returns RunAlreadyFinished as soon as it sees the stored outcome (sessions/commands.rs:798–826) and never changes durable state. This promise therefore has no command transition that can cancel the pending schedule; a user can request cancellation and still have the successor start and execute tools. Extend CancelRun to atomically cancel the scheduled continuation with a truthful receipt/event, or add a dedicated command, and test its race with the timer.

AGENTS.md reference: AGENTS.md:L109-L110

Useful? React with 👍 / 👎.

Comment on lines +57 to +59
compaction must still shrink the context (ADR-0039's shrinkage check)
and is charged to the caller's token and cost limits like any turn.
That is the bound on how many can run.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Charge compaction usage to the caller's limits

The current in-run compactor stores usage and cost only on its internal compaction run, then returns InRunCompaction { summary } without accounting (sessions/in_run_compaction.rs:161–195), so the prompt run's BudgetMeter never sees that spend. Removing the 32-step cap therefore does not make token or cost limits the replacement bound claimed here, and AC5's predecessor-chain remainder can also omit every owned compaction row even after all RunLimits fields are enumerated. Require the compactor to return and charge its accounting, include that spend in continuation remainders, and test a low token/cost limit across compaction and continuation.

AGENTS.md reference: AGENTS.md:L149-L150

Useful? React with 👍 / 👎.

lg2m added a commit that referenced this pull request Sep 29, 2026
…ease (#212)

* docs(release): adopt 0ver; contract bumps no longer force a MINOR release

The product number orders releases and stays 0.MINOR.PATCH. PATCH is the
normal step; MINOR is a deliberate milestone. Compatibility is carried by
the contract versions, so the release PR must list every changed contract
constant and the upgrade steps.

* docs(release): record the 0ver decision as ADR-0051; state where each contract is checked

Review (Codex, #212): only PROTOCOL_VERSION is checked across a connection;
capabilities are advertised, and the descriptor and store schema are checked
locally (plan identity, store open). The runbook said both sides check all of
them. The table and text now say where each is checked.

The policy itself is a durable choice a future maintainer could re-litigate,
so it is recorded as ADR-0051 (0048-0050 are held by #211), indexed, and
reserved in the root ledger.

Refs: ENG-969

* docs(release): ship upgrade steps in the release body; ADR-0051 alternatives; client-side protocol check

Review (Codex, #212):
- ADR-0051 said the server refuses a mismatched peer. It does not: requests
  are bearer-authenticated only. The client compares ServerInfo before it
  attaches (local discovery, probe_health). Stated as such.
- Upgrade steps lived only in the bump PR body, while the release workflow
  used --generate-notes alone. The release body is now the tagged
  CHANGELOG.md section (--notes-file, above generated notes), and the job
  fails if the section is missing. The runbook adds a hand-written
  Upgrading block to each such section; the changelog header says so.
- ADR-0051 gains the template's Alternatives and Evidence sections.

Refs: ENG-969

* docs(release): the runbook states the protocol guard as client-side

Review (Codex, #212): the table and 0ver paragraph still said the protocol is
checked "both sides" and "at every connection". Only the client compares
the advertised version before it attaches; the server does not check
callers. Aligned with ADR-0051.

Refs: ENG-969
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