Skip to content

Provider-neutral session compaction + opt-in token_usage auto-compact policy (schema v62) - #252

Open
0thernet wants to merge 8 commits into
mainfrom
devin/session-compaction-main
Open

0thernet wants to merge 8 commits into
mainfrom
devin/session-compaction-main

Conversation

@0thernet

Copy link
Copy Markdown
Member

Summary

  • Provider-neutral session.compact: Codex dispatches thread/compact/start through the pinned app-server client, Claude writes /compact on the stream-json input, and Devin sends the pinned CLI's advertised /compact slash command as an ACP session/prompt between turns (the client's single-prompt guard fences mid-turn). All three reduce to one durable compaction timeline event (outcome/trigger/strategy/token fields only, no text), receipted before dispatch, idempotent by key, refused mid-turn, and reconciled against the event stream without replay.
  • Opt-in per-session auto-compaction: schema v62 adds session_compact_policies (STRICT, cascade FK, default-off seed trigger, monotonic-revision transition guard, delete guard, backfill). session.compact-policy get/set exposes it with revision CAS; CLI grammar oompa session compact-policy <session> on|off [--trigger-tokens 20000..4000000] [--min-interval-ms 30000..86400000] [--expected-revision n]. After a durable token_usage event, evaluateAutoCompact (pure, total, property-tested) schedules session.compact under the session serializer with trigger: "policy" and a deterministic per-bucket idempotency key — exactly one dispatch per usage bucket; the serialized closure re-evaluates fresh policy/interval/turn state before dispatch.
  • Migration chain: v60→v61 keeps main's Devin readmission (Restore active Devin provider support #225); the released joined-61 boundary is proved before the additive v61→v62 compact-policy step; older cohorts chain 60→61→62.
  • Defaults: enabled: false, triggerTokens: 250_000, minIntervalMs: 300_000 — compacting at 250k instead of provider-default ~1M roughly halves the average context cost.
  • Docs: docs/providers/codex.md (new) and docs/providers/claude.md record the verified provider compaction contracts; site/content.ts command reference matches CLI help; plan kb/plans/session-compaction.md is complete with full evidence.

Supersedes #246 (same feature ported from claude/oompa-v0.8.0 onto main; the compact-policy migration renumbered v61→v62 because main's v61 is the Devin readmission, and Devin compact() support was added).

Test plan

  • bun run check green on the final main-based tree: support-runtime, cost-surfaces, install-pins, effect-architecture, security-primitives (48 files), eslint, tsc --noEmit; scripts 2305/2306 (one 5s browser-handoff timeout under host load ~12, verified 20/20 in isolation), local-efficiency plugin 166/166, cloud-efficiency plugin 36/36, bun test ./src --isolate --max-concurrency=1 6217/6217, convex 407/407, pr 22/22, site 188/188, app 668/668; build:site -- --check, build:app, build clean; check:package green in a governed-ref clone (complete-history scan on governed refs only, 235-entry release inventory, isolated consumer verification).
  • Focused suites on the merged tree: domain compact-policy 12 (incl. seeded fast-check properties), service compact 7/7, state-store policy 7/7, devin-runtime-adapter 18/18 (incl. new /compact dispatch coverage), daemon-adapters + domain 123/123, parser 75/75, all touched storage/migration suites green (joined-state-upgrade, canonical-join-waypoint, combined49-history/adoption, autorespond-store, canonical-profile, effect-evidence, schema-sql-admission, work-upgrade, historical-runtime-profile, retained-usage, queue-attachment, attachment-custody, automatic-pointer-move, schema-cohort-bridge, cli schema tests).
  • Independent review round: no authority/recovery findings; four hardening fixes landed (dispatch-time re-evaluation, CONFLICT suppression noise, delete guard, fast-check properties).
  • Live-provider resume of custom compacted Codex records remains quota-blocked (noted in plan).

Generated with Devin

0thernet and others added 7 commits September 17, 2026 05:17
Codex dispatches thread/compact/start through the pinned app-server
client and Claude sends provider-native /compact between turns, both
behind a durable session.compact command bound to the session's exact
authority generation. Provider facts project to one bounded compaction
timeline event (outcome, trigger, strategy, token counts only), and an
indeterminate dispatch reconciles against the retained event stream
rather than replaying.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
A durable per-session session_compact_policies row (schema v61, STRICT
table, cascade FK, default-off seed trigger, monotonic-revision
transition guard, delete guard, backfill) backs the new
session.compact-policy get/set contract and CLI surface with revision
CAS. After a token_usage event is durable, the pure evaluateAutoCompact
decision (trigger capped by model context window, in-flight turn and
minimum-interval suppression) can schedule the existing durable
session.compact under the session serializer with trigger "policy" and
a deterministic per-usage-bucket idempotency key, so a second
observation in the same bucket replays the command instead of
dispatching twice. The serialized closure re-evaluates fresh policy,
interval, and turn state before dispatch, and beginEffect re-fences the
turn check so a refused attempt stays prepared and retryable without
burning the key or the interval budget.

Docs record the verified provider compaction contract for Codex and
Claude, the public command reference matches CLI help, and the reviewed
release inventory and public-text allowlist were refreshed for the new
shipped module and main's new public dependencies.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Port the token_usage-triggered auto-compaction policy onto updated main:

- Renumber the session_compact_policies migration from v61 to v62; main's
  schema 61 is the Devin readmission, so the chain is now v60->v61->v62 and
  a new initialVersion===61 step proves the released joined-61 boundary
  before the additive v62 step.
- Implement compact() on PinnedDevinRuntimeManager: the pinned Devin CLI
  advertises /compact over ACP, sent as a session/prompt between turns and
  fenced by the client's single-prompt guard. UnavailableDevinRuntime and
  the test FakeDevin gain the port method.
- Bump every current-schema literal in tests from 61 to 62, move future
  sentinels to 63, extend expected migration ledgers by one entry, and
  drop the v62 objects in the joined-state-upgrade rewind simulation.
- Recompute the reviewed release inventory (235 files) and refresh the
  install pins for the merged src/cli.ts.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The between-turns test asserts the session/prompt frame carries the
/compact slash command, no turn facts leak from the compaction request,
and an in-flight turn fences compaction with INVALID_INPUT.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
The earlier inventory was computed before the Devin compact() adapter
edit; the file size changed without changing the entry count or
canonical byte length, so only the sha256 drifted.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@vercel

vercel Bot commented Sep 17, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
oompa Ready Ready Preview Sep 17, 2026 2:43pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
oompa-app Ignored Ignored Preview Sep 17, 2026 2:43pm UTC

Request Review

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
0thernet added a commit to hraness/gobstopper that referenced this pull request Sep 17, 2026
- roadmap: oompa auto-compaction now open as hraness/oompa#252 (main,
  schema v62); aicharts ingest merged (#278, verified in production).
- design + config.example: agentrouter -> agentmixer rename.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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