Skip to content

feat(state): kernel budgets and lifetime visibility (#233 items 3-4) - #268

Merged
ScriptedAlchemy merged 2 commits into
mainfrom
fix/233-remainder
Sep 2, 2026
Merged

feat(state): kernel budgets and lifetime visibility (#233 items 3-4)#268
ScriptedAlchemy merged 2 commits into
mainfrom
fix/233-remainder

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

Closes the remaining scope of #233 (items 3–4 of the #98 remainder; items 1–2 landed in #251).

Item 3 — kernel-contract budgets (packages/rsc-runtime)

  • defineState accepts optional budgets runtime policy, resolved over fail-closed defaults: maxEventBytes 256 KiB (canonical-JSON bytes per validated payload), maxStateBytes 1 MiB (per committed state), maxRevisions 100 000 (caller-initiated journal revisions), maxCommitMs 5 000 (validation start → pre-append wall clock). Invalid budgets and an over-cap initial state fail invalid-definition.
  • Both drivers (memory + node:sqlite) enforce identical typed budget-exceeded semantics inside their atomic commit boundaries: payload bytes at validation; state bytes, revision cap, and elapsed time immediately before append (SQLite rolls back). Cancellation budgets already existed (AbortSignal → aborted); this completes Provide an optional durable Agent state kernel #98's "cancellation, size, time, and retention budgets".
  • Honesty invariants pinned by the shared conformance suite (runs on both drivers): replaying a committed idempotency key bypasses commit budgets; lowering a budget never breaks reads, change cursors, or exact-revision replay of committed history; budgets are runtime policy, not persisted metadata (reopening with different caps is allowed); kernel migration commits enforce state bytes only, exempt from revision/time caps so a full journal cannot brick open. Time budgets are pinned per driver with injected clocks.
  • New driver-author toolkit exports: AGENT_STATE_DEFAULT_BUDGETS, AgentStateBudgets(Input), expectCommitWithinBudgets, expectMigrationWithinStateBudget.

Item 4 — lifetime visibility (packages/agent-bundle, read-only surfaces only)

  • agent-bundle inspect --state: declared definition id, lifetime, driver kind (memory/sqlite, mirroring entry codegen), provenance/source, the notice-ledger co-mount note, a described (never fabricated) durable location, and budgets as defaults/declared (resolved numbers) or dynamic (statically unreadable — extraction stays parse-only, no new build error). Default human output gains a one-line state summary.
  • agent-bundle doctor: read-only durable-state inventory per installed Cursor bundle and per --from bundle — state/*.sqlite stores by filesystem metadata only (sizes include -wal/-shm sidecars, mtime); databases are never opened, so Doctor cannot disturb SQLite locks. New AB7316 warning for unreadable metadata; also documents the previously missing AB4821.
  • Workbench catalog display stays deferred: the compiled route manifest / artifact inspection carries no state metadata today, so it needs new plumbing (and the workbench is under active parallel work). Runtime-instance identity probing likewise has no existing read-only endpoint (doctor only probes event IPC sockets); recorded on Track remaining #98 state-kernel scope: warm-runtime process state, generated-runtime state mounting, budgets, lifetime visibility #233.

Test plan

  • pnpm build, pnpm lint, pnpm typecheck on the rebased tree
  • pnpm test:unit (all rsc-runtime tests incl. conformance on both drivers + extract/doctor/inspect/cli) — 270 passed, 1 expected durable-only skip
  • pnpm test:route-unit, pnpm test:projection
  • Changesets: @agent-bundle/runtime minor, agent-bundle minor

… the state kernel (#233)

defineState resolves configurable runtime budgets (maxEventBytes,
maxStateBytes, maxRevisions, maxCommitMs) with sane defaults; both the
memory and node:sqlite drivers enforce identical typed budget-exceeded
semantics inside their atomic commit boundaries. Reads, change cursors,
exact-revision replay, and committed idempotent results stay available
after lowering a budget, and kernel migration commits enforce state
bytes only so a full journal cannot brick open. The shared conformance
suite pins the behavior across drivers.
…ore inventory (#233)

agent-bundle inspect gains a --state focus reporting the declared
definition id, lifetime, driver kind, provenance, and statically
extracted budgets (defaults/declared/dynamic, never fabricated), plus a
state line in the default human output. agent-bundle doctor inventories
workspace-durable SQLite stores per installed bundle by filesystem
metadata only (AB7316 warning on unreadable metadata; databases are
never opened). Documents the previously undocumented AB4821.
@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1791401

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@agent-bundle/runtime Minor
agent-bundle Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-02T03:17:00.709074Z 1791401 PR opened
ℹ️ 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.

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