carlos / platform Public

console: classify the replica deploy door like release (#511)

POST /api/fleet/replicas/{account}/{app}/{host}/deploy is box-to-console
coordinator transport, the sibling of /release, so it gets the same
classification in every inventory main's census tests check:

- a claim door fixture: claimReplicaDoor("deploy") stages a copy
  assignment, the coordinator term and a passed release, then drives the
  first swap transition (order); a foreign-exclusive claim must leave the
  swap order empty and the open run must record the console's own order
- the route census (testdata/claim-routes.txt)
- the linked-deployments policy: linkedRefuse, with release and
  coordinator, and listed among the box doors the linked walk skips

It is the only route this branch adds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev cff9d23f80947fb4e52e022f5cfd6ff463f2e0fd parent e117f64
5 files changed, +66 −3
  • internal/console/apilinks_test.go +1 −0
  • internal/console/claim_invariant_fixtures_test.go +1 −0
  • internal/console/claim_invariant_replicas_test.go +62 −3
  • internal/console/linkedpolicy.go +1 −0
  • internal/console/testdata/claim-routes.txt +1 −0

Intent

Human

<task-notification> <task-id>a807cb44071d689e3</task-id> <tool-use-id>toolu_012soFHqpmFWYxaW4EGS16y4</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/a807cb44071d689e3.output</output-file> <status>completed</status> <summary>Agent "Merge main into Plan 4 branch" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>All three steps are done, plus one extra test fix, and every verification run passes. Two things went differently from the brief: the census needed a new overlay instead of a re-propose per task, and I committed a fix for a test that was already failing on the branch. Nothing is pushed. **Commits:** - `777ac62a` copy: keep CLI table headers upper case for copies (#511). The header is now HOST BOX BUILD STATE HEALTH WORKERS, Health values are capitalised to match State, and deck rows C02–C11, C49 and C50 are updated with the controller note. - `0b9b7dde` merge main into stateless-replicas-4 (merges origin/main 5fac2ff1). - `20a40dd6` tests: wait for background work in replica activator tests - `e117f649` tests: match the approved copies policy refusal (#511). This is the extra commit (see Not resolved). **Conflicts (only these two):** - **`plan14-root-reads-chain.tsv`:** main's 5 lines first, then our 11 lines in their old order. `census-propose` will only re-run the last overlay in the chain, so I couldn't re-propose each task in order. Instead I recomputed each of our 11 seals with a throwaway test (now deleted) and updated each card's Seal line; overlay contents are unchanged. Three units both sides changed (`Service.wake`, `type Service`, `runAgent`) and the re-pinned envelopes went into a new overlay, `stateless-replicas-4-merge-main`, with its own card. That card needs reviewer approval. - **`plan9_b8_census_test.go`:** kept our Task 5 inventory as the call. Task 1's layer now builds on main's `linkedDeploymentsSlice1` layer, so both sides' entries are kept. Task 5 re-pins three units both sides changed: `handleBrowserRestart`, `handleInstanceRetry` and `routeDecls`. **Census:** `make census-card` reports clean (seal `93c4edae…`), and the root-read and record-write census tests pass. **waitBackground:** the only Services our tests build without a rig are four in `internal/activator/stateless_holdwake_test.go`. None of them uses TempDir, so the cleanup is harmless rather than needed. The touched tests pass with `-count=3`. **Tests:** every listed run passes, and so do the three cross-builds. The `internal/host` run passed outright, without the known lifecycle-provider failures. **Not resolved:** nothing left open. The extra commit fixes `TestCopiesApplyToEveryInstance`, which was already failing on the branch before the merge. The Luna apply (484d4fe2) reworded the copies policy refusal (SR-2-C16), but the test still looked for "overlap deploys". It now checks for the `copiesOverlap` constant.</result> <usage><subagent_tokens>132002</subagent_tokens><tool_uses>57</tool_uses><duration_ms>1379350</duration_ms></usage> </task-notification>

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="f7e27673-a6a7-42fa-995a-c43bbafe007a"> Agent manager 8a3d302: yes to the two-box dev drill. Answers: (a) After two things: the v0.34.46 flagship move-2 window (release agent 82664493, running now, about an hour) posts its release on #421, and your final Astra/Fable branch review shows no open P1. I&apos;ll ping you when the flagship window closes; then post your dev lock and go. (b) You build and install the untagged candidate yourself per platform-roll-recipe (the release agent is busy). Record the dev console&apos;s current build (v0.34.46) and its rollback first; put the console back to v0.34.46 at the end unless Paul says otherwise. Candidate must not reach channels, the tap, apt or any other box. (c) Use a new drill fleet (2x t4g.small per P21; I know of no existing two-box dev fleet). Don&apos;t touch the IE HA group, sophie, leo, dennis, the demo box, or the hapair scripts. No pinfra applies outside the drill fleet&apos;s own resources. Delete the fleet and its buckets/records at the end and say what you deleted. </paseo-system>

Human

<task-notification> <task-id>bn6odnhds</task-id> <tool-use-id>toolu_01QUsNXD1e4ysgVHNfzXhj9L</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bn6odnhds.output</output-file> <status>completed</status> <summary>Background command "Astra census review of Task 5 and merge card" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bjd2qadov</task-id> <tool-use-id>toolu_01C6Zj6u1RZDpQ11oaSQXUVN</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bjd2qadov.output</output-file> <status>completed</status> <summary>Background command "Wait for CI on the integrated tip" completed (exit code 0)</summary> </task-notification>

Human

<paseo-system version="1" kind="agent-message" source-agent-id="8a3d302a-eac7-407c-b61c-f5ccc66b5544" message-id="a9e2a771-65e3-4fc6-a68e-d5a82adfdbbd"> Agent manager 8a3d302: the flagship window closed at 22:33Z (#421). Your dev drill can go once your final review shows no open P1: post your dev lock and proceed as agreed. </paseo-system>

Human

<task-notification> <task-id>bqvf4bga1</task-id> <tool-use-id>toolu_01WRiFjoC4kzqbL3Db9z5Rk5</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bqvf4bga1.output</output-file> <status>completed</status> <summary>Background command "Astra final whole-branch review" completed (exit code 0)</summary> </task-notification>

Human

<task-notification> <task-id>bskrn425u</task-id> <tool-use-id>toolu_01ANFfc5cu7qNKLxJydqF1cX</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/72128d15-58b8-452f-9f7e-8e864e8854d2/tasks/bskrn425u.output</output-file> <status>completed</status> <summary>Background command "Fable final whole-branch review" completed (exit code 0)</summary> </task-notification>

diff --git a/internal/console/apilinks_test.go b/internal/console/apilinks_test.go
index a880eb67a..325b4194e 100644
--- a/internal/console/apilinks_test.go
+++ b/internal/console/apilinks_test.go
@@ -683,6 +683,7 @@ var linkedAllowQuery = map[string]string{
var linkedWalkBoxDoors = map[string]bool{
"POST /api/fleet/replicas/{account}/{app}/{host}/coordinator": true,
"POST /api/fleet/replicas/{account}/{app}/{host}/release": true,
+ "POST /api/fleet/replicas/{account}/{app}/{host}/deploy": true,
}
// worldSnapshot is what a refused request must not change: every console
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index 2ffec9cb0..c2504208f 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -735,6 +735,7 @@ var claimFixtures = map[string]claimFixture{
"route GET /api/cli/apps/{account}/{app}/source": claimSourceDownloadFixture(false),
"route POST /api/fleet/replicas/{account}/{app}/{host}/coordinator": {door: claimReplicaDoor("coordinator")},
"route POST /api/fleet/replicas/{account}/{app}/{host}/release": {door: claimReplicaDoor("release")},
+ "route POST /api/fleet/replicas/{account}/{app}/{host}/deploy": {door: claimReplicaDoor("deploy")},
"route GET /accounts": claimRead("renders only the signed-in person’s account memberships"),
// ---- methodless routes (the handler checks r.Method itself) ----
"route /api/economics/backhaul": claimRead("operator backhaul report (GET only) computed from the economics view; writes nothing"),
diff --git a/internal/console/claim_invariant_replicas_test.go b/internal/console/claim_invariant_replicas_test.go
index 686037490..67fc2bd1e 100644
--- a/internal/console/claim_invariant_replicas_test.go
+++ b/internal/console/claim_invariant_replicas_test.go
@@ -4,6 +4,8 @@ import (
"context"
"encoding/json"
"net/http"
+ "slices"
+ "strconv"
"testing"
"time"
@@ -34,6 +36,26 @@ func claimReplicaDoor(operation string) *claimDoor {
if err := provision.CreateRecord(context.Background(), cx.rel, rec); err != nil {
t.Fatal(err)
}
+ if operation == "deploy" {
+ // The swap transitions need a copy assignment (Plan 4), which
+ // no create writes: put it as the placement pass would.
+ key := provision.RecordKey(rec.Account, rec.App, host)
+ raw, etag, err := cx.rel.Get(context.Background(), key)
+ if err != nil {
+ t.Fatal(err)
+ }
+ var stored provision.Record
+ if err := json.Unmarshal(raw, &stored); err != nil {
+ t.Fatal(err)
+ }
+ stored.ReplicaAssignment = &replicas.Assignment{Revision: stored.RecordSeq, Desired: 1, Boxes: []string{"pi-1"}}
+ if raw, err = json.Marshal(stored); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := cx.rel.Put(context.Background(), key, raw, etag); err != nil {
+ t.Fatal(err)
+ }
+ }
inc, err := provision.Incarnation(rec.Account, rec.App, rec.Host, rec.CreatedAt)
if err != nil {
t.Fatal(err)
@@ -55,7 +77,7 @@ func claimReplicaDoor(operation string) *claimDoor {
t.Fatal(err)
}
cx.vars["replica-token"], cx.vars["replica-incarnation"] = token, inc
- if operation == "release" {
+ if operation == "release" || operation == "deploy" {
code, _, body := claimReplicaRequest(t, cx, "coordinator")
if code != http.StatusOK {
t.Fatalf("stage coordinator: %d %s", code, body)
@@ -66,6 +88,21 @@ func claimReplicaDoor(operation string) *claimDoor {
}
cx.vars["replica-term"] = reply.Lease.Term
}
+ if operation == "deploy" {
+ // The swap follows a passed release: stage deploy-1 to
+ // released, so the door's first transition, order, applies.
+ var d replicas.Deploy
+ for _, op := range []string{"begin", "releasing", "released"} {
+ code, _, body := claimReplicaPost(t, cx, "release", map[string]any{"incarnation": cx.vars["replica-incarnation"], "op": op, "id": "deploy-1", "term": cx.vars["replica-term"], "revision": d.Revision, "target": replicas.Build{Version: "v1", Digest: "digest"}})
+ if code != http.StatusOK {
+ t.Fatalf("stage release %s: %d %s", op, code, body)
+ }
+ if err := json.Unmarshal([]byte(body), &d); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cx.vars["replica-revision"] = strconv.FormatUint(d.Revision, 10)
+ }
},
do: func(t *testing.T, cx *claimCase) int {
code, _, _ := claimReplicaRequest(t, cx, operation)
@@ -83,6 +120,16 @@ func claimReplicaDoor(operation string) *claimDoor {
if open && (rec.Coordinator.Box != "pi-1" || rec.Coordinator.BootID != "fixture-boot") {
return "coordinator did not retain the authenticated box and boot"
}
+ } else if operation == "deploy" {
+ if rec.ReplicaDeploy == nil || rec.ReplicaDeploy.Phase != "released" {
+ return "the staged release did not survive"
+ }
+ if (len(rec.ReplicaDeploy.Swap.Order) != 0) != open {
+ return "deploy order mutation did not match the app's admission"
+ }
+ if open && (!slices.Equal(rec.ReplicaDeploy.Swap.Order, []string{"pi-1"}) || !rec.ReplicaDeploy.Swap.Bootstrap) {
+ return "deploy order did not retain the console's roster order"
+ }
} else {
if (rec.ReplicaDeploy != nil) != open {
return "release mutation did not match the app's admission"
@@ -98,9 +145,21 @@ func claimReplicaDoor(operation string) *claimDoor {
func claimReplicaRequest(t *testing.T, cx *claimCase, operation string) (int, http.Header, string) {
payload := map[string]any{"incarnation": cx.vars["replica-incarnation"], "op": "acquire", "boot_id": "fixture-boot"}
- if operation == "release" {
+ switch operation {
+ case "release":
payload = map[string]any{"incarnation": cx.vars["replica-incarnation"], "op": "begin", "id": "deploy-1", "term": cx.vars["replica-term"], "target": replicas.Build{Version: "v1", Digest: "digest"}}
+ case "deploy":
+ revision, err := strconv.ParseUint(cx.vars["replica-revision"], 10, 64)
+ if err != nil {
+ t.Fatal(err)
+ }
+ payload = map[string]any{"incarnation": cx.vars["replica-incarnation"], "op": "order", "id": "deploy-1", "term": cx.vars["replica-term"], "revision": revision, "target": replicas.Build{Version: "v1", Digest: "digest"}}
}
+ return claimReplicaPost(t, cx, operation, payload)
+}
+
+// claimReplicaPost is one box-signed call to the replica door operation.
+func claimReplicaPost(t *testing.T, cx *claimCase, operation string, payload map[string]any) (int, http.Header, string) {
body, err := json.Marshal(payload)
if err != nil {
t.Fatal(err)
@@ -109,7 +168,7 @@ func claimReplicaRequest(t *testing.T, cx *claimCase, operation string) (int, ht
}
func TestReplicaCoordinatorClaimMutations(t *testing.T) {
- for _, operation := range []string{"coordinator", "release"} {
+ for _, operation := range []string{"coordinator", "release", "deploy"} {
t.Run(operation, func(t *testing.T) {
problems, _ := runClaimDoor(t, claimReplicaDoor(operation))
for _, problem := range problems {
diff --git a/internal/console/linkedpolicy.go b/internal/console/linkedpolicy.go
index 943e735b7..3e26ca8d2 100644
--- a/internal/console/linkedpolicy.go
+++ b/internal/console/linkedpolicy.go
@@ -282,6 +282,7 @@ var linkedPolicies = map[string]linkedPolicy{
// The box doors: a linked app has no instance records for them to name.
"POST /api/fleet/replicas/{account}/{app}/{host}/coordinator": linkedRefuse,
"POST /api/fleet/replicas/{account}/{app}/{host}/release": linkedRefuse,
+ "POST /api/fleet/replicas/{account}/{app}/{host}/deploy": linkedRefuse,
}
// refuseLinkedJSON answers an API door's linked refusal, if any, and
diff --git a/internal/console/testdata/claim-routes.txt b/internal/console/testdata/claim-routes.txt
index be779d7ad..8d30c2b51 100644
--- a/internal/console/testdata/claim-routes.txt
+++ b/internal/console/testdata/claim-routes.txt
@@ -370,6 +370,7 @@ route POST /api/cli/system/update
route POST /api/fleet/enrol
route POST /api/fleet/replicas/{account}/{app}/{host}/coordinator
route POST /api/fleet/replicas/{account}/{app}/{host}/release
+route POST /api/fleet/replicas/{account}/{app}/{host}/deploy
route POST /api/link/publications
route POST /api/link/rotate
route POST /api/ses/events