Skip to content

feat(coordinator,orchestrator): add app-gRPC admin pause/resume and unify HandoffMarker - #1857

Closed
nikhilunni wants to merge 4 commits into
mainfrom
audit/p1-admin-pause-resume-grpc
Closed

nikhilunni wants to merge 4 commits into
mainfrom
audit/p1-admin-pause-resume-grpc

Conversation

@nikhilunni

@nikhilunni nikhilunni commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds in-place admin pause/resume to app-gRPC on the coordinator, and keeps one HandoffMarker definition. This PR is the coordinator half. The orchestrator cutover is a follow-up (see Rollout).

  • App-gRPC PauseSession / ResumeSession: new RPCs on SessionService (engram/app/v1/session.proto, new messages only, new field numbers, buf breaking passes). The coordinator handlers call the same api/admin.rs core functions as the HTTP routes, so the two paths return the same results and error slugs. Generated Rust/TS bindings are regenerated with buf generate.
  • Authorization parity: the HTTP route requires the admin role (CASL manage all) in the orchestrator and the deployment bearer in the coordinator, with no per-org scope. The new RPCs use the same rules: policy-map.ts maps both to manage all (no sessionIdField, the same as Snapshot / EvictIdle), and the coordinator handlers check the app-gRPC bearer first. pause-resume-policy.test.ts asserts anonymous → Unauthenticated, member → PermissionDenied, both with zero upstream calls.
  • Unified HandoffMarker: moves to crates/engram-protocol/src/handoff.rs (re-exported by engram-host-core::shutdown). Field order and serde attributes do not change, so the JSON is byte-identical. handoff.rs pins the compact wire bytes. A new host-agent test pins the pretty on-disk bytes and covers every post-crash state of the tmp-then-rename write (a torn marker at every byte offset is removed and reads as a fresh start; a leftover tmp sibling is ignored).
  • The orchestrator admin routes still forward to the coordinator HTTP routes. Those routes stay.

Rollout

deploy/helm/engram rolls the coordinator and the orchestrator in parallel. An orchestrator that calls the new RPCs on an old coordinator gets Unimplemented. So the change lands in three steps, each one deployed before the next merges:

  1. This PR: coordinator RPCs, generated clients, admin-only policy entries. The orchestrator does not call the RPCs yet. Safe in any roll order and on rollback.
  2. Orchestrator cutover (branch audit/p1-admin-pause-resume-orch, stacked on this branch): routes/admin.ts calls PauseSession / ResumeSession, removes CONTROL_PLANE_HTTP_URL from config.ts, and adds admin-routes.test.ts. Merge only after step 1 is deployed. Do not roll the coordinator back past step 1 while step 2 is deployed.
  3. Contract: remove the coordinator HTTP routes /api/v1/admin/sessions/{id}/{pause,resume}, the CONTROL_PLANE_HTTP_URL chart env and the orchestrator.controlPlane.httpUrl value, and the orchestrator bearer from ENGRAM_AUTH_TOKENS if nothing else uses it. Merge only after step 2 is deployed and no rollback target calls the HTTP routes.

I chose a split over an Unimplemented → REST fallback in admin.ts: the split adds no transitional code to the orchestrator, and the HTTP routes already serve as the compatibility surface.

Merge order

  • audit/p0-coordinator-security (fix(coordinator): fail closed on capabilities and internal auth, check host ownership #1850) also edits api/host_http.rs and api/mod.rs and makes the coordinator HTTP router fail closed. After it lands, the HTTP leg of admin_pause_resume_preserves_state_and_error_mapping in crates/engram-coordinator/tests/grpc_app.rs must send a bearer token. Whichever PR merges second fixes that test and resolves the mod.rs comment conflict.

Validation

  • buf generate, buf breaking, cargo fmt --check, cargo clippy -p engram-protocol -p engram-host-core -p engram-coordinator --all-targets -- -D warnings, cargo hakari generate --diff.
  • cargo test: grpc_app, coordinator unit, protocol, host-core; engram-host-agent handoff tests.
  • orchestrator: bun run typecheck, pause-resume-policy.test.ts, authz.matrix.test.ts.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow CI / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed⏩ skipped⏩ skipped✅ passedDec 2, 2026, 10:00 PM

nikhilunni and others added 2 commits December 2, 2026 11:00
The chart rolls the coordinator and the orchestrator at the same time.
An orchestrator that calls PauseSession or ResumeSession on a
coordinator without those methods gets Unimplemented. This PR now
ships only the coordinator methods, the generated clients, and the
admin-only policy entries. The orchestrator route cutover moves to a
follow-up that merges after this change is deployed.

Restore admin.ts and config.ts to the REST proxy, keep the direct-RPC
policy gate test, and make the coordinator comments state the current
callers of the HTTP routes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The handoff marker type moved to engram-protocol. The successor reads
the file that the previous build wrote, so pin the pretty JSON bytes
the writer produces. Also cover every post-crash state of the
tmp-then-rename write: a torn marker at each byte offset is removed
and reads as a fresh start, and a leftover tmp sibling is ignored.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nikhilunni nikhilunni changed the title feat(coordinator,orchestrator): promote admin pause/resume to app-gRPC and unify HandoffMarker feat(coordinator,orchestrator): add app-gRPC admin pause/resume and unify HandoffMarker Dec 2, 2026
@nikhilunni

Copy link
Copy Markdown
Contributor Author

Combined into #1860 with the other audit PRs, so they merge and deploy together.

@nikhilunni nikhilunni closed this Dec 3, 2026
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