M5: Compaction-checkpoint fast path + budget voter#2
Merged
Conversation
added 12 commits
June 18, 2026 23:19
Supersedes parent-design §3.3 (gateway forwarding tools). MCP becomes code the model runs in the sandbox; creds injected + per-call audit at the AuthBridge egress waypoint. Near-zero Pi surface; lean-both budget. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
…ssions Add §5: where secrets live (Keycloak + K8s Secret, broker-sidecar memory only); per-user scoping for unattended sessions via SPIFFE actor + bound subject + pre-authorized Keycloak delegation (RFC 8693 §4.1); placeholder swap; OpenShell env-cred complement; best-fit comparison of AuthBridge / OpenShell / DAM. New decisions D8-D10, consequences, and gate criterion 5. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
… HTTP APIs Generalizes M10's MCP-over-HTTP egress into a unified credentialed-egress path where MCP is one special case. Same AuthBridge waypoint, selector, audit producer, and budget machinery; per-destination credential resolver (RFC 8693 mint vs. per-user stored grant). Adds in-mesh front-door for external hosts (no baked CA), generic egress helper + committed GitHub wrapper, and records the per-user external-credential store + linking flow as an M7-M9 identity-plane dependency. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Pivots the non-MCP egress mechanism from an in-mesh front-door + host-based injection (v1.0) to AuthBridge's own placeholder-swap pattern over a forward proxy (HTTPS_PROXY + baked CA). The sandbox/tools hold only inert placeholders; the proxy sees the request at L7 and overwrites with the real resolved credential. gh/curl/SDKs now work natively and unmodified; front-door + correctness-wrappers apparatus collapses; full per-call L7 audit preserved; more faithful to AuthBridge. Accepted cost: a baked CA (trust anchor, not a secret) and a narrow env-inject escape hatch for request-signing APIs (AWS SigV4). Selector and per-user stored-credential model unchanged from v1.0. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Implements the pi-track plan's Milestone M4 (Tasks 13-14), re-targeted to the repo's real architecture: ride Pi's native compaction as the checkpoint, add SessionManager.openFromCheckpoint for O(tail) cold-start reconstruction, and a per-turn token budget voter. Repo milestone 5 (follows m4-knative). Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assigns each entry the Redis stream id "<position>-0" so read(fromPosition) is an XRANGE seek instead of a full-stream scan, and adds positionOfId for the M5 checkpoint marker. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Pure decideBudget policy plus an extension that meters cumulative assistant token spend via ctx.sessionManager.getBranch(), blocks the tool call and appends a single abort entry once the per-turn delta breaches the cap. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Appends a resume-pointer custom entry recording positionOf(firstKeptEntryId) so cold start can seek directly to the kept tail. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Resume via the O(tail) openFromCheckpoint loader, always register the checkpoint-marker extension, and register the budget voter when SH_BUDGET_TOKENS is set. Adds the reconstruction parity gate. Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <paolo.dettori@example.com>
This was referenced Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
M5 — Compaction-Checkpoint Fast Path + Budget Voter
Implements the pi-track plan's M4 (repo milestone 5). Spec:
docs/specs/2026-06-23-m5-compaction-checkpoint-design.md. Plan:docs/superpowers/plans/2026-06-23-m5-compaction-checkpoint.md.Makes cold-start session reconstruction O(tail) by riding Pi's native compaction as the checkpoint, and adds a per-turn budget voter that blocks tool calls once a token cap is breached.
Changes
@sh/session-backend—RedisSessionBackendassigns each entry the Redis stream id"<position>-0", soread(fromPosition)is an O(tail)XRANGEseek instead of a full-stream scan + JS filter. NewpositionOfId;LogStoreinterface extended.SessionManager.openFromCheckpoint()+markerResumePositionhelper: reads only the checkpoint marker'sresumeFromPosition-forward slice, reuses the existingloadFromEntries/buildSessionContextpath, and falls back toopenFromBackendwhen there is no usable marker.openFromBackendis untouched.harness/src/checkpoint-extension.ts— onsession_compact, appends a tinycustom/checkpointmarker recordingpositionOf(firstKeptEntryId).harness/src/budget-voter.ts— puredecideBudget,sessionSpendTotal, andbudgetVoterExtension. Gated by envSH_BUDGET_TOKENS(+ optionalSH_BUDGET_MARGIN); unset ⇒ inert.harness/src/run-turn.ts— resumes viaopenFromCheckpoint; always registers the checkpoint extension; registers the budget voter whenSH_BUDGET_TOKENSis a finite value > 0.Submodule
This PR bumps the
pi-forksubmodule pointer to branchfeat/m5-openfromcheckpointonkagenti/pi(additiveopenFromCheckpointloader + a caveat doc comment). No upstream PR.Verification (no LLM key required)
@sh/session-backend10/10, all against real Redis.openFromCheckpoint(...).buildSessionContext()deep-equalsopenFromBackend(...)after a real compaction; slice read is strictly smaller than the full log.tsgo) passes; targeted session-manager regression tests green.harness/test/run-turn.test.tsis LLM-gated and excluded.Known caveat (documented + test-locked)
Tail-load drops the session-start
thinking_level_changeentry (it precedesfirstKeptEntryId), sothinkingLevelreconstructs to the settings default on the first post-compaction resume; it self-heals on the next turn and is harmless while thinking level is settings-governed.modelis unaffected (re-set by every assistant message, always in the kept tail). A test incheckpoint.test.tslocks this behavior.Deferred (out of scope)
everyK/forced-checkpoint cadence; cross-turn cumulative budget ledger.Assisted-By: Claude (Anthropic AI) noreply@anthropic.com