PRD: reprovision on gateway startup #517

Open
didericis-claude wants to merge 3 commits from prd-gateway-reprovision-on-bringup into main
Collaborator

Implements PRD 0081 (reconcile running bottles against a freshly-booted gateway instead of persisting gateway state on volumes). Supersedes the abandoned persistent-volume PRs #511 / #513.

In this PR so far

  • docs/prds/0081-*.md — the design.
  • OrchestratorCore.update_agent_secret + registry.store_agent_secret (per-key upsert) + POST /bottles/<id>/secret (cli-only) + client.update_agent_secret — update ONE egress token in place, the single-secret counterpart of reprovision_from_secret's restore-all. This is the reusable primitive extracted from the 2026-07-26 hotfix; unit-tested across service/store/server/client.

Still to come on this branch (see #516)

  • Bring-up reconcile: CA push to running agents, git-gate re-provision, host-credential (Codex) token refresh, wired into connect_to_orchestrator.

Refs #516. Addresses the root problems in #510 and #512 (closed by the reconcile once it lands).

🤖 Generated with Claude Code

Implements PRD 0081 (reconcile running bottles against a freshly-booted gateway instead of persisting gateway state on volumes). Supersedes the abandoned persistent-volume PRs #511 / #513. **In this PR so far** - `docs/prds/0081-*.md` — the design. - `OrchestratorCore.update_agent_secret` + `registry.store_agent_secret` (per-key upsert) + `POST /bottles/<id>/secret` (cli-only) + `client.update_agent_secret` — update ONE egress token in place, the single-secret counterpart of `reprovision_from_secret`'s restore-all. This is the reusable primitive extracted from the 2026-07-26 hotfix; unit-tested across service/store/server/client. **Still to come on this branch (see #516)** - Bring-up reconcile: CA push to running agents, git-gate re-provision, host-credential (Codex) token refresh, wired into `connect_to_orchestrator`. Refs #516. Addresses the root problems in #510 and #512 (closed by the reconcile once it lands). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
didericis-claude added 1 commit 2026-07-26 18:48:46 -04:00
Reconcile every running bottle against a freshly-booted gateway (replace
each agent's CA, re-provision git-gate, restore egress tokens) instead of
persisting gateway state on volumes. Supersedes the abandoned CA-volume
(#511) and git-gate-volume (#513) PRs.

Refs #510, #512

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
didericis added 1 commit 2026-07-26 18:52:17 -04:00
feat(orchestrator): update a single egress secret in place (0081)
prd-number-check / require-numbered-prds (pull_request) Successful in 8s
tracker-policy-pr / check-pr (pull_request) Successful in 22s
test / unit (pull_request) Successful in 58s
lint / lint (push) Successful in 1m7s
test / integration-docker (pull_request) Successful in 1m12s
test / coverage (pull_request) Successful in 46s
f9d0e15f13
Add a single-secret counterpart to reprovision_from_secret's restore-all:
update ONE egress token for a running bottle without a relaunch, for
refreshing a short-lived host credential (e.g. the Codex access token)
whose launch-time snapshot has expired.

- registry_store.store_agent_secret: per-key upsert (delete+insert of the
  one row), the counterpart of store_agent_secrets' replace-all.
- OrchestratorCore.update_agent_secret: set the in-memory token AND upsert
  the re-encrypted row under the bottle's env_var_secret, leaving other
  tokens untouched.
- POST /bottles/<id>/secret (cli-only) + client.update_agent_secret.

Refs #510, #512

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
didericis force-pushed prd-gateway-reprovision-on-bringup from eb8ac7f011 to f9d0e15f13 2026-07-26 18:52:17 -04:00 Compare
didericis reviewed 2026-07-26 19:01:58 -04:00
@@ -0,0 +57,4 @@
- The docker / macOS backends. This lands the reconcile for Firecracker (the
backend that boots a fresh gateway rootfs each time); docker keeps its existing
host-bind-mounted CA until the same seam is extended there (follow-up). The
unification target is *per-service*, not *per-backend*.
Owner

No, target is for both. And it should be enforced on the base abc class for the backend/there should be something like a attach_bottled_agents_to_gateway method on the backend that reprovisions all the bottled agents.

No, target is for both. And it should be enforced on the base abc class for the backend/there should be something like a `attach_bottled_agents_to_gateway` method on the backend that reprovisions all the bottled agents.
didericis added 1 commit 2026-07-26 19:06:07 -04:00
docs(prd): reconcile via a backend-ABC method across all backends (0081 review)
prd-number-check / require-numbered-prds (pull_request) Successful in 11s
test / image-input-builds (pull_request) Has started running
test / integration-docker (pull_request) Failing after 1m13s
test / unit (pull_request) Successful in 1m2s
test / coverage (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 10s
4434752db4
Address review: target all backends, not firecracker-only. Make the reconcile
an @abc.abstractmethod `attach_bottled_agents_to_gateway()` on BottleBackend so
every backend implements it (cross-backend by construction) and the host calls
it on gateway bring-up. Drop the docker/macOS non-goal; add the open question of
retiring docker's now-redundant CA bind-mount.

Refs #516
Author
Collaborator

Re: the docker/macOS non-goal (review comment on docs/prds/0081-...md) — agreed, made it target all backends, enforced on the ABC.

Updated in 4434752d:

  • Dropped the docker/macOS non-goal.
  • Design now leads with the contract: attach_bottled_agents_to_gateway() as an @abc.abstractmethod on BottleBackend (backend/base.py). Reconciling running bottles is a backend responsibility (only the backend can enumerate its agents and reach them — firecracker over SSH, docker/macOS over exec/cp), so every backend must implement it — cross-backend by construction, no per-backend follow-up. It reprovisions all registered bottles' CA + git-gate + egress tokens.
  • The host calls it on the gateway bring-up path (cold-boot branch only, never on adopt).
  • New open question: once docker's attach_bottled_agents_to_gateway pushes the CA to running agents, its host_gateway_ca_dir bind-mount is redundant — leaning toward dropping it so docker rotates like firecracker (one behaviour across backends).

The firecracker specifics (hook install, per-agent CA push, git-gate re-init, token reprovision) are now written as that backend's implementation of the abstract method.

Re: the docker/macOS non-goal (review comment on `docs/prds/0081-...md`) — agreed, made it target **all** backends, enforced on the ABC. Updated in 4434752d: - Dropped the docker/macOS non-goal. - Design now leads with the contract: **`attach_bottled_agents_to_gateway()` as an `@abc.abstractmethod` on `BottleBackend`** (`backend/base.py`). Reconciling running bottles is a backend responsibility (only the backend can enumerate its agents and reach them — firecracker over SSH, docker/macOS over `exec`/`cp`), so every backend must implement it — cross-backend by construction, no per-backend follow-up. It reprovisions all registered bottles' CA + git-gate + egress tokens. - The host calls it on the gateway **bring-up** path (cold-boot branch only, never on adopt). - New open question: once docker's `attach_bottled_agents_to_gateway` pushes the CA to running agents, its `host_gateway_ca_dir` bind-mount is redundant — leaning toward dropping it so docker rotates like firecracker (one behaviour across backends). The firecracker specifics (hook install, per-agent CA push, git-gate re-init, token reprovision) are now written as *that backend's implementation* of the abstract method.
Owner

New open question: once docker's attach_bottled_agents_to_gateway pushes the CA to running agents, its host_gateway_ca_dir bind-mount is redundant — leaning toward dropping it so docker rotates like firecracker (one behaviour across backends).

Yes, make it consistent across backends.

> New open question: once docker's attach_bottled_agents_to_gateway pushes the CA to running agents, its host_gateway_ca_dir bind-mount is redundant — leaning toward dropping it so docker rotates like firecracker (one behaviour across backends). Yes, make it consistent across backends.
didericis-claude changed title from PRD 0081: reprovision gateway-dependent state on gateway bring-up to PRD: reprovision on gateway startup 2026-07-26 22:10:34 -04:00
Some optional checks failed
prd-number-check / require-numbered-prds (pull_request) Successful in 11s
test / image-input-builds (pull_request) Has started running
test / integration-docker (pull_request) Failing after 1m13s
test / unit (pull_request) Successful in 1m2s
test / coverage (pull_request) Has been skipped
tracker-policy-pr / check-pr (pull_request) Successful in 10s
Required
Details
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin prd-gateway-reprovision-on-bringup:prd-gateway-reprovision-on-bringup
git checkout prd-gateway-reprovision-on-bringup
Sign in to join this conversation.