Repository navigation
M5: Compaction-checkpoint fast path + budget voter - #2
Merged
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
Closed
This was referenced Aug 27, 2026
cwiklik
added a commit
that referenced
this pull request
Sep 9, 2026
Addresses the two reviews on #242. Ten changes, no change to the three ordered steps in §3.2 or to the shape of the implementation. Blocking finding (§4, SettingsManager): - The three lines cited as "project-scope mutators" were `setProjectTrusted()` calls (`settings-manager.ts:447`), which flip an in-memory boolean and write nothing. Replaced with the set that can write — `updateProjectSettings` (`:635`) → `assertProjectTrustedForWrite` (`:527`), reached from `setProjectPackages` (`:942`), `setProjectExtensionPaths` (`:958`), `setProjectSkillPaths` (`:974`), `setProjectPromptTemplatePaths` (`:990`), `setProjectThemePaths` (`:1006`), plus `saveProjectSettings` (`:618`) and the `"project"` branch of `enqueueWrite` (`:552-553`). - Re-ran the reachability audit against those five, which the review could not settle because GitHub code search does not index the pinned fork. Their only non-test callers are the interactive TUI (`config-selector.ts:484-490`, `:558`) and `pi packages` via `package-manager.ts:798`/`:806`/`:824` → `installAndPersist` (`:989`) / `removeAndPersist` (`:1014`) → `package-manager-cli.ts:601`/`:606`, both also requiring `local: true` (`:783`, `:814`, `:994`). Neither exists in server mode: `sdk.ts` constructs no `PackageManager` and `run-turn.ts` passes none (`:499-504`). The conclusion survives; only the evidence did not, and both are now recorded. - Residual #1 retargeted at the five `setProject*` methods. MU1 composition (§3.6 of the now-merged control-plane spec): - §3.2 step 1 keeps "no new credential *path*" but requires the tagged `UpstreamCredential` union, with both silent failure directions. - §3.2 declines to pin "an inbound `X-SH-Subject` is always honoured"; pins the durable form instead — the subject is resolved from the request, never from process state — with `subject_conflict` (400). - §5 lock-down row rescoped from process to **environment**, citing ADR-0033's accepted divergence; notes the stronger claim should be gated on direct mode being disabled rather than weakened. - §5 fail-closed row rephrased on resolvability, so MU1 need not invert it. P6 (#244) entry-point asks: - §3.2 step 3: land the scrub as an exported function `startServer()` calls, so the VM worker — a third entry point that never calls `listen()` — is not the one path that runs unscrubbed at W×S. - §4: `stdoutTakeoverState` pin reworded to "any non-CLI entry point". - §4: verdicts scoped to correctness and silent on liveness, pointing the liveness question at the deployment-model slice. - §5: write the two-tenant test against a parameterizable entry point. - Residual #2 expanded with the `cwd` → single-lockfile chain, the absence of an async `withLock`, the `AuthStorage` non-hazard (`auth-storage.ts:76-98`, but `getApiKey` `:464` → `refreshOAuthTokenWithLock` `:409` → `withLockAsync` `:417`), and P6 §5.2's event-loop lag p99 as the existing instrument. Nits and coherence: - Quoted `session-manager.ts:1421` in full, including the elided `sessionDir` branch. - `redis-backend.ts:6-7` → full path, with the `buffered-redis-backend.ts` disambiguation. - §6 names P6 as the deployment-model slice's realization and lists the three forward references it consumes; §9 adds MU1 and ADR-0033. Two review details corrected in passing: `package-manager-cli.ts` lives at `packages/coding-agent/src/`, not `src/core/`, and the `AuthStorage` spin starts at `:76`. Refs #239 #244 Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: cwiklik <cwiklikj@gmail.com>
pdettori
added a commit
that referenced
this pull request
Sep 28, 2026
- Adds ActiveSession for managing per-session turn queue, token lifecycle, and retry logic - Implements SessionManager for creating, resuming, and removing sessions - Handles token remint with 30s margin before expiry - Retries on token errors (invalid, expired) and 503 with Retry-After - Never retries once frames have flowed (stream_truncated error continues queue) - Reports turn-start, frame, retrying, and turn-end events - Integrates with TranscriptStore for persistent turn history - Review Focus #1 (truncated stream ends as error, queue continues) and #2 (token_expired remints once and succeeds) both tested and passing Assisted-By: Claude (Anthropic AI) <noreply@anthropic.com> Signed-off-by: Paolo Dettori <dettori@us.ibm.com>
4 of 5 tasks
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