Merge remote-tracking branch 'origin/main' into feat/platform-mail-submission
# Conflicts: # internal/console/apicli.go # internal/provision/testdata/plan14-root-reads-chain.tsv
62 files changed,
+1,681
−103
approved_moves_copy_test.go+1 −0approved_stateless_replicas_copy_test.go+1 −1docs/superpowers/notes/census-claims-probe-burst-block.tsv+1 −0docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md+19 −0docs/superpowers/notes/census-proposal-platform-mail-submission.md+1 −1docs/superpowers/notes/census-proposal-probe-burst-block.md+19 −0docs/superpowers/plans/2026-08-23-console-as-an-app.md+2 −2docs/superpowers/plans/2026-10-05-scanner-host-rollout.md+1 −1docs/superpowers/plans/2026-10-06-console-release-defences-plan-4-d4.md+1 −1docs/superpowers/plans/2026-10-06-moves-phase1-copy.md+6 −0docs/superpowers/plans/2026-10-21-offline-move-runbook.md+1 −0docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md+2 −0docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md+26 −0docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md+19 −0docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md+47 −0docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md+30 −0docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md+24 −0docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md+19 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md+7 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md+11 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md+27 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md+23 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md+51 −0docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md+103 −0docs/superpowers/specs/2026-08-23-console-as-an-app-design.md+1 −1docs/superpowers/specs/2026-10-24-edge-request-protection-design.md+8 −0docs/superpowers/specs/2026-10-24-service-runs-design.md+1 −1docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md+4 −1internal/console/apicli.go+9 −1internal/console/apidomains.go+1 −1internal/console/apidomains_test.go+1 −1internal/console/apierrors.go+14 −5internal/console/apiinstancemove_offline.go+62 −4internal/console/apiinstancemove_offline_stage_test.go+24 −0internal/console/apiinstancemove_offline_test.go+117 −1internal/console/apiinstances.go+2 −2internal/console/appcopies.go+175 −8internal/console/copiespublication_test.go+9 −3internal/console/copiesunlabelled_test.go+249 −0internal/console/fleets.go+7 −0internal/console/managedapi.go+8 −1internal/console/protectionsetting_test.go+22 −4internal/console/rootfs.go+1 −1internal/console/server.go+2 −2internal/domains/claims_proof_test.go+1 −1internal/edge/burst_edge_test.go+121 −31internal/edge/burst_notice.go+26 −0internal/edge/burst_notice_test.go+118 −2internal/edge/edge.go+1 −1internal/edge/guard.go+27 −3internal/edgeguard/catalogue.go+5 −2internal/edgeguard/catalogue_test.go+1 −1internal/host/movesoffline.go+11 −1internal/host/movesoffline_e2e_test.go+37 −6internal/host/movesoffline_land_test.go+4 −0internal/host/movesoffline_test.go+38 −1internal/host/movespass.go+8 −0internal/provision/testdata/plan14-root-reads-chain.tsv+3 −1internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv+5 −0internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv+1 −1internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv+6 −0offline_move_e2e_test.go+109 −9
CI passed — run details
diff --git a/approved_moves_copy_test.go b/approved_moves_copy_test.go| index ce7f73f23..f4ec99c03 100644 |
| --- a/approved_moves_copy_test.go |
| +++ b/approved_moves_copy_test.go |
| @@ -110,6 +110,7 @@ var movesCopyIDs = []string{ |
| "MV-O179", "MV-O180", "MV-O181", "MV-O182", "MV-O183", "MV-O184", "MV-O185", "MV-O186", "MV-O187", "MV-O188", "MV-O189", |
| "MV-O190", "MV-O191", "MV-O192", |
| "MV-O193", |
| + "MV-O194", |
| // #339: refused while the instance still serves, and status after an |
| // abort from staging. |
| "MV-O200", "MV-O202", "MV-O203", "MV-O204", |
diff --git a/approved_stateless_replicas_copy_test.go b/approved_stateless_replicas_copy_test.go| index 37ba671cd..4d2606408 100644 |
| --- a/approved_stateless_replicas_copy_test.go |
| +++ b/approved_stateless_replicas_copy_test.go |
| @@ -9,7 +9,7 @@ import ( |
| const statelessReplicaCopyDeck = "docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md" |
| -var statelessReplicaBuiltCopy = []string{"SR-2-C11", "SR-2-C01", "SR-2-C02", "SR-2-C03", "SR-2-C04", "SR-2-C05", "SR-2-C06", "SR-2-C07", "SR-2-C08", "SR-2-C09", "SR-2-C12", "SR-2-C13", "SR-2-C14", "SR-2-C15", "SR-2-C16", "SR-2-C17", "SR-1-C08", "SR-1-C06", "SR-1-C07", "SR-1-C01", "SR-1-C02", "SR-1-C03", "SR-1-C04", "SR-1-C05", "SR-1-C12", "SR-1-C09", "SR-1-C10", "SR-1-C13", "SR-1-C14"} |
| +var statelessReplicaBuiltCopy = []string{"SR-2-C11", "SR-2-C01", "SR-2-C02", "SR-2-C03", "SR-2-C04", "SR-2-C05", "SR-2-C06", "SR-2-C07", "SR-2-C08", "SR-2-C09", "SR-2-C12", "SR-2-C13", "SR-2-C14", "SR-2-C15", "SR-2-C16", "SR-2-C17", "SR-1-C08", "SR-1-C06", "SR-1-C07", "SR-1-C01", "SR-1-C02", "SR-1-C03", "SR-1-C04", "SR-1-C05", "SR-1-C12", "SR-1-C09", "SR-1-C10", "SR-1-C13", "SR-1-C14", "SR-4-C95", "SR-4-C96"} |
| func statelessReplicaCopyRows(t *testing.T) []copyRow { |
| t.Helper() |
diff --git a/docs/superpowers/notes/census-claims-probe-burst-block.tsv b/docs/superpowers/notes/census-claims-probe-burst-block.tsv| new file mode 100644 |
| index 000000000..b5dc943bc |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-claims-probe-burst-block.tsv |
| @@ -0,0 +1 @@ |
| +internal/edge/guard.go:Edge.noteBurst after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts |
diff --git a/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md| new file mode 100644 |
| index 000000000..916510b6b |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: offline-move-pool-target-413 |
| + |
| +Ruling `census-ruling-offline-move-pool-target-413`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/host/movespass.go` `armOffline` | body | unchanged (1) | sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added | |
| + |
| +Envelopes re-pinned: `internal/host`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/host/movespass.go` `armOffline`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7 |
| + |
| +Seal: `87e151a55efb12fb84e9c5939f2ead9058527d8213e2eb16ee6c0f109787bb16` → `f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-proposal-platform-mail-submission.md b/docs/superpowers/notes/census-proposal-platform-mail-submission.md| index 9f39a9dbc..8cb7b7d5f 100644 |
| --- a/docs/superpowers/notes/census-proposal-platform-mail-submission.md |
| +++ b/docs/superpowers/notes/census-proposal-platform-mail-submission.md |
| @@ -86,6 +86,6 @@ New dispositions, which census-propose wrote and the reviewer checks against the |
| - new `internal/mailsubmit/forward.go:SocketForwarder.Send`: reads +file:ReadAll; written legacy, accepted-legacy, frozen |
| - new `internal/mailsubmit/verb.go:Mount`: reads +registry:App, +registry:Host, +whole:Route; written legacy, accepted-legacy, frozen |
| -Seal: `87e151a55efb12fb84e9c5939f2ead9058527d8213e2eb16ee6c0f109787bb16` → `b782f324a4791147024602f46ab73eab48a589ae3ab9a5035d56a722c92da50e`. |
| +Seal: `94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167` → `3439e77fb7ba7bc8b772706d57fb907c998814e42b0c5a2f45ef2c0fa97d74e4`. |
| Overlay: `internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/notes/census-proposal-probe-burst-block.md b/docs/superpowers/notes/census-proposal-probe-burst-block.md| new file mode 100644 |
| index 000000000..77b54d232 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-probe-burst-block.md |
| @@ -0,0 +1,19 @@ |
| +# Census approval: probe-burst-block |
| + |
| +Ruling `census-ruling-probe-burst-block`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/edge/guard.go` `Edge.noteBurst` | body | unchanged (3) | after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts | |
| + |
| +Envelopes re-pinned: `internal/edge`, `internal/edgeguard`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/edge/guard.go` `Edge.noteBurst`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-probe-burst-limit;basis=new: in the observer defer, counts a not-found (a 404, or a hard or probe match) from a non-browser client (no Sec-Fetch-Mode) toward the in-memory probe-burst limiter, keyed by the route's account/app; on a trip mints a reference code, files a Trip record into the in-memory recorder and queues notices to peer edges; the sites are the route value passed in; reads no file, store or registry; no new root read or write kind;rev3=census-ruling-agent-start-demo-log-skip;basis=skips only the in-memory Trip record when demoUnrecorded(rt, r); cooling, the limiter and peer notices are unchanged; no new read |
| + |
| +Seal: `f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182` → `94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/plans/2026-08-23-console-as-an-app.md b/docs/superpowers/plans/2026-08-23-console-as-an-app.md| index 37318863a..30dd3fede 100644 |
| --- a/docs/superpowers/plans/2026-08-23-console-as-an-app.md |
| +++ b/docs/superpowers/plans/2026-08-23-console-as-an-app.md |
| @@ -1957,7 +1957,7 @@ Run as `carlos`, not root. Verify by reading the routes back, then run one `carl |
| ``` |
| carlos apps create -app console -account ops -control-plane -build-probe /healthz \ |
| - -console https://carlos.tito.io |
| + -console https://console.platform.tito.io |
| ``` |
| then the same against `https://platform.carlosframework.com`. One step, not two: a row without the flag is a window in which any ops member or `Publish` service credential can roll the production console. |
| @@ -1977,7 +1977,7 @@ GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build \ |
| -ldflags "-s -w -X github.com/carlosframework/platform/internal/version.Build=$(git rev-parse --short HEAD)" \ |
| -o /tmp/console ./cmd/console |
| -carlos deploy -app console -account ops -console https://carlos.tito.io \ |
| +carlos deploy -app console -account ops -console https://console.platform.tito.io \ |
| -channel canary/console -host <tito-execstart-host> -target linux-arm64 /tmp/console |
| ``` |
diff --git a/docs/superpowers/plans/2026-10-05-scanner-host-rollout.md b/docs/superpowers/plans/2026-10-05-scanner-host-rollout.md| index 2eb8e2512..13fb4bfb4 100644 |
| --- a/docs/superpowers/plans/2026-10-05-scanner-host-rollout.md |
| +++ b/docs/superpowers/plans/2026-10-05-scanner-host-rollout.md |
| @@ -1495,7 +1495,7 @@ Expected: the scanner's six resources created; `host_ie_object_store` updated in |
| ### Task 12 (GATED): Tito, console, key, wiring, enable |
| - [ ] **Step 1:** Roll Tito's console to the same build as Task 8: `GOFLAGS=-buildvcs=false scripts/roll-console.sh <checkout> tito`, with Paul's go. Its executable check must pass. Before rolling, diff Tito's console environment against the flagship's for variables the new build requires (the 2026-09-11 lesson): `... ssm-run.sh` on each console box, `cut -d= -f1 <envfile> | sort`, and compare. |
| -- [ ] **Step 2:** Task 9 Steps 1 to 7 in Tito's account (profile `titogo`, region `eu-west-1`, `/carlos/scan-tag-key`, console `https://carlos.tito.io`). A **new** key: never copy the flagship's. |
| +- [ ] **Step 2:** Task 9 Steps 1 to 7 in Tito's account (profile `titogo`, region `eu-west-1`, `/carlos/scan-tag-key`, console `https://console.platform.tito.io`). A **new** key: never copy the flagship's. |
| - [ ] **Step 3:** Stop at `antivirus status` (wired, answering, fresh signatures) and `antivirus enable`. **No throwaway app, no grant, no sweep on Tito** (spec §8). |
| - [ ] **Step 4:** Record in the discussion. |
diff --git a/docs/superpowers/plans/2026-10-06-console-release-defences-plan-4-d4.md b/docs/superpowers/plans/2026-10-06-console-release-defences-plan-4-d4.md| index c60289ed5..090ff4aa0 100644 |
| --- a/docs/superpowers/plans/2026-10-06-console-release-defences-plan-4-d4.md |
| +++ b/docs/superpowers/plans/2026-10-06-console-release-defences-plan-4-d4.md |
| @@ -150,7 +150,7 @@ coords() { |
| case $1 in |
| dev) echo "kass carlos-dev-640012953448 i-05498eada6f0afd23 platform.dev.carlosframework.com";; |
| flagship) echo "keymail carlos-flagship-271376211898 i-092c0c1eea75723cb platform.carlosframework.com";; |
| - tito) echo "titogo carlos-tito-platform-665106592142 i-025a0b70f3d93304d carlos.tito.io";; |
| + tito) echo "titogo carlos-tito-platform-665106592142 i-025a0b70f3d93304d console.platform.tito.io";; |
| *) echo "unknown deployment $1: dev, flagship or tito" >&2; exit 2;; |
| esac |
| } |
diff --git a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md| index cc00bfbd7..04f149ae5 100644 |
| --- a/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| +++ b/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md |
| @@ -719,6 +719,12 @@ Three more console door refusals for a staged move (`internal/console/apiinstanc |
| | MV-O192 | internal/console/apiinstancemove_offline.go | <to> now publishes a different data bucket or region from what was recorded when <host> was staged. abort the move and stage it again | approved | |
| | MV-O193 | internal/console/seedmove.go (haMoveSentence; RHA-P1a-C1 approved verbatim; emitted at apiinstancemove.go:450,631 and apiinstancemove_offline.go:538) | %s has high availability turned on. offline moves into or out of it are not available yet | approved | |
| +The start and stage doors' refusal of a region with no box that can hold the instance's row (`internal/console/apiinstancemove_offline.go`, amadan #413). Only a box that hibernates and serves the shared pool counts: a box that serves only a named pool (`CARLOS_POOLS=cohort1`) or a fleet never gets the row, so a move there would wait on it forever. Before this row such a region was refused with MV-O22 and a count of 0. MV-O22 keeps its text and still answers two or more such boxes. `<region>` is the region's name, `<host>` the instance. Approved by Luna 2026-11-13 under Paul's delegation. |
| + |
| +| id | file | text | status | |
| +|---|---|---|---| |
| +| MV-O194 | internal/console/apiinstancemove_offline.go | <region> has no box that can take <host>. an offline move needs one box there that hibernates and serves the shared pool | approved | |
| + |
| ## Offline move: refused while the instance still serves (#339) |
| MV-O200, MV-O203 and MV-O204 approved by Luna on 2026-11-13 (Paul's 2026-10-25 delegation), as Luna rewrote them; MV-O202 approved by Luna unchanged. |
diff --git a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md| index 7a1dbc704..c462692ef 100644 |
| --- a/docs/superpowers/plans/2026-10-21-offline-move-runbook.md |
| +++ b/docs/superpowers/plans/2026-10-21-offline-move-runbook.md |
| @@ -108,6 +108,7 @@ Pass: |
| - one file per live box, and no file for a box that no longer exists (a stale file naming the home placement blocks `seal`; removing it needs Paul); |
| - every box in both regions lists `offline-move-1` **and** `offline-stage-1`; |
| - the target's `placement` is the region you move to, and it has a `data_bucket` (that is `$TGTDATA`); |
| +- exactly one box in the target region has `hibernation_configured` true and `serves_shared_pool` true. That box is the target, and the doors count only its target report. A box beside it that serves only a named pool (`CARLOS_POOLS=cohort1`, like leo-climbing on dev) or a fleet is not a target and takes no part (amadan #413). A region with no such box is refused at `stage` and `start`. Do not change the target box's `CARLOS_POOLS` while a move holds it: a target that stops serving the shared pool skips its own revert, so an abort would leave its landed files unparked. If it has changed, set it back and restart the edge before you abort (amadan #413); |
| - `hibernation_configured` true; |
| - the target's `secrets_key_fp` equals the source's. The start door checks only the target's fingerprint against the console. A box with no `CARLOS_SECRETS_KEY` publishes no fingerprint at all; on dev, leo-climbing is such a box, and it is not a blocker unless it is the target. |
diff --git a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md| index 266232099..d7fae29cf 100644 |
| --- a/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md |
| +++ b/docs/superpowers/plans/2026-11-01-stateless-replicas-copy.md |
| @@ -166,3 +166,5 @@ copy too. Internal wire enums are not an excuse to expose unreviewed text. |
| | SR-4-C92 | internal/activator/replicadeploy.go | the new copy's configuration was not written on its box in time, so it did not start. existing copies keep serving | approved (controller; Luna house rules) (drill 1 round 2) | |
| | SR-4-C93 | docs/site/stateless-replicas.md | An app that creates its own instance.key or report.token file must take those values from a shared source, its configuration or its environment, or run one copy. The platform gives every copy the same CARLOS_INSTANCE_KEY, but it cannot stop each copy of an app from writing a different file of its own. | approved (controller; Luna house rules) (drill 1 round 2, A3 restriction) | |
| | SR-4-C94 | docs/site/stateless-replicas.md | When a copy switches, its old build stops once the new one serves. A response still streaming from the old build when it stops is cut, as when a box stops. Websockets on the old build disconnect and their clients reconnect to a healthy copy. | approved (controller; Luna house rules) (drill 3, H4) | |
| +| SR-4-C95 | internal/console/appcopies.go | <host> is not tied to one box of fleet <fleet>, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now | approved (Paul, copy review u4k4cyxedlsfh72a7vpq3sn2uu as SR-5-C01, 2026-11-14; #1008: refused at ship, at any publication of a stateless build, and at copies above 1) | |
| +| SR-4-C96 | internal/console/appcopies.go | <host> runs a release without a local database and is not tied to a box of fleet <fleet>, so a second active box would stop it. move it to a release with a local database before adding a box | approved (Paul, copy review u4k4cyxedlsfh72a7vpq3sn2uu as SR-5-C02, 2026-11-14; #1008: refused at fleet add-box, box reactivation and a managed fleet add) | |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md| new file mode 100644 |
| index 000000000..b803ec571 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md |
| @@ -0,0 +1,26 @@ |
| +Round 2’s P2: **resolved** for a target that landed and then changed pools. The broader rollback dispatch exposes one storage-safety defect. |
| + |
| +**P1 — A report without a held row authorizes parking on a non-participant.** |
| + |
| +**Invariant:** rollback may move only files belonging to this box’s participation in the move. |
| + |
| +The changed dispatch at [movesoffline.go:424](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline.go:424) now reaches every capable destination box during abort. However, [offlineTargetRevert:245](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline_land.go:245) accepts **any** prior target report when the row is absent. |
| + |
| +A concrete scenario: |
| + |
| +- An older named-pool box reports “no row yet” without ever holding the instance. This is the legacy behaviour explicitly modelled at [apiinstancemove_offline_test.go:1030](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline_test.go:1030). |
| +- Upgrade that box and abort the move. |
| +- Its report passes validation, so rollback renames any existing `H`, `H.env` and `H.config.env` paths despite having landed nothing. A locally registered host named `H.env` passes hostname validation; its flat files directory would also be renamed. Only the row for `H` is checked. |
| + |
| +Ordinary similarly named hosts remain untouched, and row/timer deletion requires the exact host and move. Nevertheless, report-only parking violates the requested non-participant guarantee. Repeated passes leave absent paths alone, but will park paths recreated later; they are not unconditionally harmless. |
| + |
| +**Fix:** require the move’s held row before parking. Since parking already precedes row deletion, retries after deletion can complete reporting without parking again. Add coverage for a legacy no-row report, neighbouring instance files, and repeated abort passes. |
| + |
| +| Census unit or envelope | Verdict | Evidence | |
| +|---|---|---| |
| +| `movespass.go:armOffline` | **APPROVED** | Lines 367–421 retain the existing environment parser and registry hooks; no new read. | |
| +| `internal/host` envelope | **REFUSED** | `offlineRound` lines 424–449 broadens access to the unsafe report-only parking path at `offlineTargetRevert` lines 238–255. | |
| + |
| +Reviewed `e2e54f66` against its parent at HEAD `c71866a8`, within round 2’s existing budget. MV-O194 is marked approved. `git diff --check` passed. Targeted tests could not start because the read-only sandbox blocked Go’s work directory; `GOCACHE` was unset. No files changed. |
| + |
| +**NOT READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md| new file mode 100644 |
| index 000000000..ab3fe5a03 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md |
| @@ -0,0 +1,19 @@ |
| +No P1 or P2 findings in the requested scope at `128c09e356ae5f5d066aec7f524ef7f95df8e351`. This check stays within round 2’s existing budget. |
| + |
| +- **Revert verified:** `e18f4f3c` restores the entire `internal/host` tree, including tests, exactly to the state before `e2e54f66`. Differences from `d024c46d` are confined to merged #339 changes. |
| +- **Accepted limitation documented:** changing the target’s pools can suppress rollback cleanup. The [runbook](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/docs/superpowers/plans/2026-10-21-offline-move-runbook.md:111) prohibits that change and requires restoring the pools and restarting the edge before aborting. |
| +- **Merge semantics preserved:** `offlineBoxFacts` and `offlineMoveEvidence` both select targets through `boxesAt(to)`. A named-pool-only box’s stale link does not trigger #339’s refusal. `reportStatus()` covers every box, including the pool box; both E2E cases remain. |
| +- **Copy records preserved:** MV-O194, MV-O200, MV-O202, MV-O203 and MV-O204 each appear once in the ID list and have approved deck rows. |
| + |
| +| Census unit or envelope | Verdict | Evidence | |
| +|---|---|---| |
| +| `internal/host/movespass.go:armOffline` | **APPROVED** | [Lines 367–421](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movespass.go:367): existing pool parser; unchanged read sites and hooks. Source digest matches the overlay. | |
| +| `internal/host` envelope | **APPROVED** | [Dispatch and eligibility, lines 416–460](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline.go:416): restored pool gate removes the broadened rollback dispatch. Static recomputation matches the 482-file envelope. | |
| + |
| +The chain retains main’s overlays before #413. All 212 overlay fingerprints and seals verify, ending at `f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182`. |
| + |
| +**P3 follow-up — approval wording:** the [deck introduction](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/docs/superpowers/plans/2026-10-06-moves-phase1-copy.md:722) still says “Pending until reviewed,” although MV-O194 is approved. Remove that stale sentence to keep the approval record consistent. No further review round is needed. |
| + |
| +`git diff --check` passed. Targeted Go tests could not start: the read-only sandbox blocked work-directory creation, with `GOCACHE` unset. No files changed. Actual HEAD is `313d9083`; its only addition beyond the reviewed commit is this review’s brief. |
| + |
| +**READY** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md| new file mode 100644 |
| index 000000000..e43485a41 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md |
| @@ -0,0 +1,47 @@ |
| +**NOT READY — round 1 of 3.** Reviewed `4c641678..4ecf608d9a20b130327a8dc3c61d2b5e8792f16c`. Current HEAD adds only the review brief. |
| + |
| +1. **P1 — Older record writers erase the target pin during a mixed-version rollout.** |
| + |
| + The new [`MoveState.TargetBox`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/provision/provision.go:1342) is absent from the base commit’s struct. Older writers decode into that struct and marshal the entire record again through [`updateRecordSeeding`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/provision/provision.go:1175), silently removing `target_box`. |
| + |
| + **Scenario:** a new console starts a pinned move while the sealer still runs the previous release. Its [`OfflineSealedBy` write](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline_seal.go:951) removes the pin. An older target likewise removes it when recording landed. The console then [falls back to every target report](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline.go:222); an old named-pool box’s extra report reproduces the original open hang while the instance is offline. An older console performing a transition has the same preservation problem. |
| + |
| + **Fix:** gate pinned starts on a capability proving participating writers preserve the field, with an explicit console rollout/rollback constraint. Add compatibility coverage using the previous record representation through both seal and landing writes. The new same-version JSON round-trip test cannot detect this. |
| + |
| + **Invariant / fault family:** the selected target must survive every record rewrite throughout the move. |
| + |
| +2. **P2 — The CLI still treats an unpinned target’s failed report as authoritative.** |
| + |
| + [`offlineViewOf`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline.go:1427) returns all reports, although its items and failed flag now exclude other targets. The CLI’s [`failedReport` and `failure`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/move.go:1208) still scan all target reports independently. |
| + |
| + **Scenario:** use the failed pool-box report already constructed by `TestOfflineWaitsOnlyForThePinnedTarget`. The API returns `Failed=false`, successful landing items and `Next=open`; the CLI nevertheless prints abort advice and returns exit 4. [`runFlip`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/move.go:1713) checks that failure before accepting `Next=open`. The runbook script consequently aborts an otherwise successful landing. |
| + |
| + **Fix:** filter irrelevant target reports from the operational API view, or expose the pin and apply it consistently in CLI failure and served checks. Cover the existing fixture through CLI polling and status. Server-side filtering also protects older CLIs. |
| + |
| + **Invariant / fault family:** every operator-facing decision must use the same target evidence. |
| + |
| +3. **P3 — Follow-up: target eligibility still ignores `CARLOS_INBOUND=none`.** |
| + |
| + This is a **pre-existing admission gap**, retained by the new pin. [`offlineCanHold`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/console/apiinstancemove_offline.go:359) checks hibernation and shared-pool membership, but [`mintHeld`](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/provision/reconcile.go:2775) refuses a no-inbound box. |
| + |
| + **Scenario:** the only advertised target hibernates and serves the shared pool but declares no inbound work. Start accepts and pins it; landing waits indefinitely for a row reconcile refuses to create. |
| + |
| + **Fix:** follow up with a target-specific admission check using published inbound eligibility; preserve conservative source-holder checks. |
| + |
| + **Invariant / fault family:** an admitted target must be able to acquire the required row. |
| + |
| +**Census verdicts — source review** |
| + |
| +| Changed unit or envelope | Verdict | Evidence | |
| +|---|---|---| |
| +| `internal/host/movespass.go:armOffline` | **APPROVED** | Lines 367–421: the added pool configuration uses the existing parser; existing registry and release hooks remain unchanged. No new root read or path authority. | |
| +| `internal/host` envelope | **APPROVED** | `offlineRound`, `offlineTargetHere`, `armOffline`, and `moveCfg`: target dispatch gains restrictive pool and identity checks. Existing landing, hold, and release validations remain intact. | |
| +| `internal/provision` envelope | **APPROVED** | `OfflineTargeted` rejects empty targets and invalid resulting states; `TargetBox` adds data without introducing filesystem access or weakening root validation. The P1 above concerns preservation across versions. | |
| + |
| +These census approvals do not resolve the functional findings. |
| + |
| +The remaining checks support the intended behavior: staged start selects the currently eligible box and rechecks staging coordinates; loss of the pinned target before open permits abort without its acknowledgement. After-open recovery remains outside the merged design’s scope. MV-O194 matches the implemented zero-candidate refusal, but its copy row remains **pending**. |
| + |
| +The added E2E models the dev pool-box hang through real reconcile and move passes. It does not exercise older writers or the CLI, explaining the two missed cases. |
| + |
| +`git diff --check` passed. Targeted tests could not start because the sandbox refused Go’s work-directory creation; `GOCACHE` was unset. Network restrictions prevented reading discussion #413 or recording census verdicts on #280. No files were changed. |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md| new file mode 100644 |
| index 000000000..22c3ac004 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md |
| @@ -0,0 +1,30 @@ |
| +Round-1 P1 — **resolved**: the target pin is removed; production record code matches the base, so older writers cannot erase required targeting state. |
| + |
| +Round-1 P2 — **resolved**: `offlineMoveEvidence` filters target reports before both door decisions and API output. Older CLIs receive the same filtered evidence; the new CLI regression test covers flip and status. |
| + |
| +1. **P2 — Pool eligibility now suppresses rollback cleanup for an existing participant.** |
| + |
| + **Invariant:** losing eligibility for a new landing must not cancel cleanup of data already landed. |
| + |
| + The new condition at [movesoffline.go:424](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline.go:424) gates every target step, including `OfflineReverting`. |
| + |
| + **Scenario:** the target lands files, then restarts with `CARLOS_POOLS=cohort1`. The operator aborts. `offlineTargetHere` now returns false, so the worker never reaches [offlineTargetRevert](/home/paulca/amadan.net/carlos/platform/.claude/worktrees/offline-move-pool-target-413/internal/host/movesoffline_land.go:231), which parks the files, env and config and deletes the held row and timers. Reconcile retains the participant while the move exists. Abort can subsequently finish without target acknowledgement, clearing the move while its extracted files remain unparked. |
| + |
| + **Fix:** apply pool admission to landing, while allowing reverting participants through the existing held-row/report ownership checks. Extend the rollback test to land, change pools, restart, abort and tick through production dispatch; assert files are parked and the row and timers removed. |
| + |
| +| Census unit or envelope | Verdict | Evidence | |
| +|---|---|---| |
| +| `internal/host/movespass.go:armOffline` | **APPROVED** | Lines 367–421: the added environment value uses reconcile’s existing pool parser. Registry, release and filesystem hooks remain unchanged. | |
| +| `internal/host` envelope | **APPROVED** | `offlineRound` lines 416–450, `offlineTargetHere` lines 453–460, and `moveCfg.OfflinePools`: no new root read or expanded path authority. The rollback defect above is functional and still needs fixing. | |
| + |
| +Other checks: |
| + |
| +- New consoles handle old boxes’ extra reports without record changes. An old console still needs upgrading to filter reports left by older boxes. |
| +- Staged start rechecks current target eligibility and stored bucket coordinates. Missing target evidence prevents open; abort remains available before open. |
| +- Pool parsing matches reconcile. The previously reported `CARLOS_INBOUND=none` admission gap remains a P3 follow-up. |
| +- The host E2E models the dev named-pool hang; console and CLI tests cover legacy extra reports. None covers eligibility changing before rollback. |
| +- MV-O194 matches the zero-eligible-target refusal. Its copy approval remains marked **pending**. |
| + |
| +Reviewed `4c641678..79afb1d91ab289d342fd8a5d9db2785fd87c000a`; HEAD adds only the brief. `git diff --check` passed. Targeted tests could not start: the read-only sandbox rejected Go’s work-directory creation, with `GOCACHE` unset. Network restrictions blocked discussion #413; census verdicts were not posted to #280. No files changed. |
| + |
| +**READY AFTER FIXES.** No P1 remains: stop review rounds here, apply the P2 fix, and perform the required census and changed-production-storage checks within this round’s budget. |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md| new file mode 100644 |
| index 000000000..48c965fb3 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md |
| @@ -0,0 +1,24 @@ |
| +Reviewed `4c6416787..374bcff00711d247235b7bab0425e3c5ac6f11d8`, round 1. |
| + |
| +No P1 findings. |
| + |
| +**P2 — Notice workers: a stale snapshot can prune a newly created peer.** |
| + |
| +At [burst_notice.go:400](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/burst_notice.go:400), `burstPeerCurrent` reads the snapshot before acquiring `n.mu`, then prunes every peer using that snapshot. |
| + |
| +Failure scenario: a worker captures a snapshot without Betty and pauses. The home map adds Betty; `sendBurstNotices` acquires `n.mu`, reads the newer snapshot and creates Betty’s worker and queue (lines 266–278). The paused worker resumes and prunes Betty using its older snapshot (lines 400–403). Betty’s queued notices are dropped as `Gone` despite her remaining eligible. |
| + |
| +Fix: acquire `n.mu` before reading the home-map snapshot, matching `sendBurstNotices`. Add a deterministic concurrency test covering this ordering. |
| + |
| +Fault family: peer reconciliation must not apply an older snapshot after newer peer creation. Fix within this round; no further review round required. |
| + |
| +No P3 findings. |
| + |
| +Census verdicts: |
| + |
| +- **`internal/edge`: approve.** Read `burst_notice.go` lines 252–305 and 362–494, including the new check and its dispatch caller; also the changed tests and guard comments. The change adds no tenant-controlled root reads or execution paths and preserves signing and transport checks. The P2 concerns erroneous notice loss. |
| +- **`internal/edgeguard`: approve.** Read [catalogue.go:114](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edgeguard/catalogue.go:114), lines 114–170, and the changed lookup test. Promotion changes the existing rule’s mode without adding input paths. Existing catalogue, static-file, fleet and record-only checks remain in place. |
| + |
| +`git diff --check` passed. Targeted tests could not start: the read-only sandbox denied Go’s build-directory creation. No files changed; no full suites run. |
| + |
| +**READY AFTER FIXES** |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md| new file mode 100644 |
| index 000000000..3e7ea5989 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R2.md |
| @@ -0,0 +1,19 @@ |
| +Reviewed `fe516719e18e85445c2972fd4a69b3393d9557cf` against local `amadan/main`, within the brief’s round-2 scope. |
| + |
| +No P1, P2, or P3 findings. |
| + |
| +Round-1 P2: **resolved**. Snapshot acquisition now occurs under `n.mu`, matching peer creation ([burst_notice.go:395](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/burst_notice.go:395), lines 395–406). |
| + |
| +The icon exclusion requires a plain 404 with no guard verdict. Hard/probe matches still count, and cool-down refusal runs before the observer’s exclusion. Both checks start from `r.URL.Path`; catalogue normalization and query matching retain priority through the verdict. Empty paths are safe; trailing slashes are not treated as icon filenames. |
| + |
| +`TestBurstIconMissesNeverCount` tests its stated behavior through a real Edge: repeated icon 404s produce no counts or trips, followed by ordinary misses that trip the same client. It does not directly cover icon-shaped catalogue matches or escaping variants. |
| + |
| +Census verdicts: |
| + |
| +- **`Edge.noteBurst`: APPROVE**, retaining `legacy / accepted-legacy`. Read [guard.go:287](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/guard.go:287), lines 287–352. The added string check introduces no file, store, registry, or execution access and preserves catalogue verdicts. |
| +- **`internal/edge` envelope: APPROVE.** Read the changed functions and tests, including `guard.go` lines 297–352 and [burst_notice.go:252](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edge/burst_notice.go:252), lines 252–305 and 362–498; traced guard callers in `edge.go` lines 2864–2909 and `static.go` lines 638–703. No new tenant-controlled root access; signing, transport checks, static-file exemptions, and record-only behavior remain intact. |
| +- **`internal/edgeguard` envelope: APPROVE.** Read [catalogue.go:114](/home/paulca/github.com/carlosframework/platform-probe-burst-block-491/internal/edgeguard/catalogue.go:114), lines 114–171, and the changed lookup test. Promotion changes the existing rule’s mode without adding input paths or weakening its checks. |
| + |
| +`git diff --check` passed. Targeted tests could not start: the read-only sandbox denied Go’s work-directory creation. No files changed; no full suites run. |
| + |
| +READY |
| \ No newline at end of file |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md| new file mode 100644 |
| index 000000000..290e9d6f5 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-FIXES.md |
| @@ -0,0 +1,7 @@ |
| +# Review brief: #413 round 2 P2 fix, census and storage check (same round budget) |
| + |
| +Repo carlos/platform, branch `offline-move-pool-target-413`. Under review: only the fix for round 2's P2 (`docs/superpowers/reviews/CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R2.md`), commit e2e54f66 against its parent, plus MV-O194 marked approved (Luna, 2026-11-13). |
| + |
| +Not a new round (stopping rule 1). Check only: (1) census per changed unit; (2) the revert path's production-storage and termination behaviour: every destination-region box now runs the revert step during an abort, relying on the revert's own checks to skip non-participants. Can a non-participant box (never held the row) ever park, delete or touch anything for this host, including a pool box that serves another instance with a similar name? Is the revert idempotent across boxes? (3) one line: round 2's P2 resolved, partly, or not. |
| + |
| +Severity as before. End with READY, READY AFTER FIXES or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset). |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md| new file mode 100644 |
| index 000000000..3bd0dd4c2 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-MERGE.md |
| @@ -0,0 +1,11 @@ |
| +# Review brief: #413 after Paul's cut and the main merge (census and merge check, same budget) |
| + |
| +Repo carlos/platform, branch `offline-move-pool-target-413`, commit 128c09e356ae5f5d066aec7f524ef7f95df8e351. |
| +Paul's ruling (#1005): take the cut. e18f4f3c reverts e2e54f66 (back to round 2's code), e89c968e adds the runbook rule "do not change a target box's CARLOS_POOLS while a move holds it". a5815113 merges main (which gained #339, 94a6471e: stale live-link refusals at stage/start and status-report facts), 128c09e3 re-freezes the census. |
| + |
| +Not a new review round. Check only: |
| +1. The revert is exact: internal/host code equals round 2's reviewed state (d024c46d's tree for internal/host apart from the merge) and the round-2 P2 (target that changed pools skips revert) is now the documented limitation, nothing else. |
| +2. The merge's semantics: #339's refusal check and #413's evidence filter together (does #339 consult target facts from non-eligible boxes, or refuse because of a pool box's stale link?); the E2E's shared `reportStatus()` now covering every box; copy IDs and deck. |
| +3. **Census:** the re-frozen overlay `plan14-root-reads-offline-move-pool-target-413.tsv` and the chain order: APPROVED or REFUSED per changed unit. |
| + |
| +End with READY, READY AFTER FIXES or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset). |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md| new file mode 100644 |
| index 000000000..7b2a062c3 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413-R2.md |
| @@ -0,0 +1,27 @@ |
| +# Review brief: offline move waits only on its pinned target (#413), branch, round 2 of 3 |
| + |
| +Repo carlos/platform, branch `offline-move-pool-target-413`, commit 79afb1d91ab289d342fd8a5d9db2785fd87c000a. |
| +Under review: the diff `4c6416787a42ce5da5964588de721817d25fc15d..4ecf608d9a20b130327a8dc3c61d2b5e8792f16c`. |
| +Authorities, merged on main: `docs/superpowers/plans/2026-10-20-offline-operator-move.md`, the offline-move runbook `docs/superpowers/plans/2026-10-21-offline-move-runbook.md`, AGENTS.md (stopping rules, census). Report: `amadan discuss show carlos/platform 413`. Do not review against unmerged branches (offline-move-stage-refusals-339 is separate). |
| + |
| +## The change (rev 2) |
| +Round 1 (`CODEX-FINDINGS-OFFLINE-MOVE-POOL-TARGET-413-R1.md`) found the record pin lost on rewrite by older writers (P1) and the CLI scanning every target report (P2). Rev 2 removes the pin entirely (provision code back to main). One console helper, `offlineMoveEvidence`, keeps a target report only if its box hibernates and serves the shared pool in the target region, from the same edges facts the start door uses; every door and the operational status view read through it, so any CLI sees only eligible targets. Unreadable edges files: no target report counts and open refuses. Box-side pool check and MV-O194 kept. |
| + |
| +## What to check |
| +1. Record compatibility: an additive field on the move record; older consoles and boxes reading or CAS-writing a record that carries it (do they drop it on rewrite, and does that reintroduce the hang or worse?); a mixed-version rollout (console new, boxes old, and the reverse). |
| +2. Can pinning ever make a move wait forever or land on the wrong box: pinned box replaced, renamed or lost mid-move; abort paths; a staged move whose eligible box changes between stage and start. |
| +3. The box-side pool check: same rule reconcile uses to give a row to a box (CARLOS_POOLS, shared pool, hibernation)? Any box that can hold the row but is now refused the target role, or the reverse? (The implementer notes CARLOS_INBOUND=none boxes are not excluded.) |
| +4. Every door and view that counted target reports now consistent (open, finish, status items, failed flag, seal, abort). |
| +5. Tests: would each fail without its guard? The E2E reproduces the dev hang? |
| +6. **Census:** `docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md` and overlay: APPROVED or REFUSED per changed unit (you are the census reviewer). |
| +7. MV-O194 accurate to the behaviour. |
| + |
| +## Round 2 |
| + |
| +First one line per round-1 P1 and P2: resolved, partly, or not. Then new findings, naming the invariant beside each. Re-check census per changed unit (the overlay now re-pins only internal/host). |
| + |
| +## Severity |
| +P1 blocks; P2 fixed without another round; P3 follow-up. P1s state failure scenario and evidence. |
| + |
| +## Output |
| +Findings ranked with evidence, scenario, fix and invariant; a Census verdict table; exactly one verdict: READY, READY AFTER FIXES, or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset). |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md| new file mode 100644 |
| index 000000000..93a9e64aa |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-OFFLINE-MOVE-POOL-TARGET-413.md |
| @@ -0,0 +1,23 @@ |
| +# Review brief: offline move waits only on its pinned target (#413), branch, round 1 of 3 |
| + |
| +Repo carlos/platform, branch `offline-move-pool-target-413`, commit 4ecf608d9a20b130327a8dc3c61d2b5e8792f16c. |
| +Under review: the diff `4c6416787a42ce5da5964588de721817d25fc15d..4ecf608d9a20b130327a8dc3c61d2b5e8792f16c`. |
| +Authorities, merged on main: `docs/superpowers/plans/2026-10-20-offline-operator-move.md`, the offline-move runbook `docs/superpowers/plans/2026-10-21-offline-move-runbook.md`, AGENTS.md (stopping rules, census). Report: `amadan discuss show carlos/platform 413`. Do not review against unmerged branches (offline-move-stage-refusals-339 is separate). |
| + |
| +## The change |
| +Start (direct or staged) records the one eligible box as `move.target_box` (new `provision.OfflineTargeted`); open, finish, the item list and the failed flag read only that box's report (moves started before the change read all reports, as before); a box takes the target role only if its CARLOS_POOLS admit the record and it is the pinned box or nothing is pinned; a region with no eligible box is refused at stage with its own sentence (MV-O194). |
| + |
| +## What to check |
| +1. Record compatibility: an additive field on the move record; older consoles and boxes reading or CAS-writing a record that carries it (do they drop it on rewrite, and does that reintroduce the hang or worse?); a mixed-version rollout (console new, boxes old, and the reverse). |
| +2. Can pinning ever make a move wait forever or land on the wrong box: pinned box replaced, renamed or lost mid-move; abort paths; a staged move whose eligible box changes between stage and start. |
| +3. The box-side pool check: same rule reconcile uses to give a row to a box (CARLOS_POOLS, shared pool, hibernation)? Any box that can hold the row but is now refused the target role, or the reverse? (The implementer notes CARLOS_INBOUND=none boxes are not excluded.) |
| +4. Every door and view that counted target reports now consistent (open, finish, status items, failed flag, seal, abort). |
| +5. Tests: would each fail without its guard? The E2E reproduces the dev hang? |
| +6. **Census:** `docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md` and overlay: APPROVED or REFUSED per changed unit (you are the census reviewer). |
| +7. MV-O194 accurate to the behaviour. |
| + |
| +## Severity |
| +P1 blocks; P2 fixed without another round; P3 follow-up. P1s state failure scenario and evidence. |
| + |
| +## Output |
| +Findings ranked with evidence, scenario, fix and invariant; a Census verdict table; exactly one verdict: READY, READY AFTER FIXES, or NOT READY. Do not edit files; no subagents; targeted tests only (GOCACHE unset). |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md| new file mode 100644 |
| index 000000000..e8515ea72 |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK-ICONS.md |
| @@ -0,0 +1,51 @@ |
| +# Review brief: branch probe-burst-block-491, icon exclusion and census, round 2 of 3 |
| + |
| +Repo carlos/platform, branch `probe-burst-block-491`, commit 4cdfed7fe23e05d8d049bda2e6e6e641787a59a1. |
| +Under review: commit 7065330f4 (the icon exclusion) and the census card |
| +`docs/superpowers/notes/census-proposal-probe-burst-block.md` for the whole |
| +branch against amadan's main (`git diff amadan/main...4cdfed7fe` touches |
| +internal/edge, internal/edgeguard, internal/console and docs; the merge commit |
| +4cdfed7fe only brings main in). |
| +Authorities, merged on main: `docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md`, |
| +`docs/superpowers/specs/2026-10-24-edge-request-protection-design.md` §5.5. |
| + |
| +Round 1 (`docs/superpowers/reviews/CODEX-FINDINGS-PROBE-BURST-BLOCK-R1.md`) |
| +found one P2 (stale snapshot pruning a new peer), fixed in 1cc2ca0f2 with the |
| +test added in f2e5c4e81. Give one line on it: resolved, partly or not. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul approved promotion to block and the icon exclusion (2026-11-14, |
| + recorded on amadan discussion #1004). Whether to exclude icons is decided; |
| + check only that the mechanism is right. |
| + |
| +## What to check |
| + |
| +1. `burstIconPath` and its call in `Edge.noteBurst` (internal/edge/guard.go): |
| + does it exclude only plain not-founds for favicon.ico/.png/.svg, |
| + favicon-*.png and apple-touch-icon*.png? Can a scanner use it to make |
| + catalogue probes uncounted (a hard or probe match must still count), or |
| + to avoid a refusal during a cool-down? Is the path it reads the one the |
| + catalogue matched (escaping, `//`, query, trailing slash)? Any panic on |
| + an empty or odd path? |
| +2. `TestBurstIconMissesNeverCount`: does it test what it says? |
| +3. Census: a verdict for the unit `internal/edge/guard.go` `Edge.noteBurst` |
| + (claim in `docs/superpowers/notes/census-claims-probe-burst-block.tsv`) |
| + and for each re-pinned envelope (`internal/edge`, `internal/edgeguard`), |
| + per AGENTS.md "The census", citing the lines read. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. |
| +- **P3**: clarity or polish. Follow-up list only. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3 with evidence (file:line), failure scenario, |
| +fix and fault family. Then the census verdicts. End with exactly one of |
| +READY, READY AFTER FIXES, NOT READY. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. |
diff --git a/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md| new file mode 100644 |
| index 000000000..50e502f4f |
| --- /dev/null |
| +++ b/docs/superpowers/reviews/CODEX-REVIEW-BRIEF-PROBE-BURST-BLOCK.md |
| @@ -0,0 +1,103 @@ |
| +# Review brief: branch probe-burst-block-491 (whole branch, with its census card), round 1 of 3 |
| + |
| +Repo carlos/platform, branch `probe-burst-block-491`, commit e974371a182279e35011108630d624e07cf657bc. |
| +Under review: the diff `4c6416787..e974371a1` (base is amadan's main). |
| +Authorities, merged on main: |
| +`docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md` (§3, §4, §5a, §6), |
| +`docs/superpowers/specs/2026-10-24-edge-request-protection-design.md` §5.5, |
| +`docs/superpowers/plans/2026-10-31-probe-burst-limit.md`, and the precedent |
| +commit 378646f1c ("Edge protection: the hard tier blocks by default"). |
| + |
| +You are an independent reviewer. Read the diff, then the code it touches, |
| +and check every claim against that code. |
| + |
| +## What the branch does |
| + |
| +1. `internal/edgeguard/catalogue.go`: `BurstRule.Mode` goes from watch to |
| + block, so in the default mode (`guardCatalogue`) a client in a probe-burst |
| + cool-down is refused (429) the catalogue paths an app is not known to |
| + serve, on every app, including cool-downs received as mesh notices. |
| + Tests that relied on watch now name watch mode or demote the rule; |
| + new witness `TestBurstCatalogueRefusesByDefault`; |
| + `TestBurstNoticeAppliesOnThePeer` runs in the default and block modes. |
| +2. `internal/console/apierrors.go`: the telemetry GET |
| + (`GET /api/cli/apps/{account}/{app}/telemetry`, read by |
| + `carlos protection`) answers a person who is a member but not an owner |
| + with the protection half alone, instead of 403. Owners and Operate |
| + service credentials read the whole object. The PUT is unchanged. |
| +3. `internal/edge/burst_notice.go`: a notice worker checks its peer against |
| + the current home map before taking each budget slot (`burstPeerCurrent`), |
| + prunes departed peers, and drops the notice as Gone. New test |
| + `TestBurstNoticeDepartedPeerStopsAtDispatch`. |
| +4. Census: `docs/superpowers/notes/census-proposal-probe-burst-block.md` |
| + re-pins the `internal/edge` and `internal/edgeguard` envelopes; no unit |
| + changes. |
| + |
| +## Fixed: do not re-argue |
| + |
| +- Paul's rulings in the probe-burst spec (thresholds 60/60 s/10 min, |
| + per-app counting, platform-wide cool-down, Sec-Fetch-Mode never counts, |
| + fleet apps only recorded, record-only switch per app). Report only |
| + mechanisms that fail to honour them. |
| +- Whether to promote at all is Paul's call on the calibration evidence, |
| + not this review's. |
| + |
| +## What to check |
| + |
| +1. Promotion: with the rule blocking by default, can anything now be |
| + refused that the spec says must never be: a page not in the catalogue, |
| + a static site's existing file, a fleet app's request, a request to an |
| + app whose record-only switch is on, or a request from a client not |
| + cooling? Is `guardBlock` / `guardWatch` / `guardOff` behaviour unchanged? |
| + Does verdict precedence (`decideVerdict`) still never let a burst |
| + verdict replace or weaken a hard block? |
| +2. Tests: do the changed tests still test what their names say, and does |
| + any test elsewhere (edge, edgeguard, console, reqrec, host) still |
| + assume the burst rule watches by default? Does `demoteBurstRule` restore |
| + global state safely (no `t.Parallel` races on `edgeguard.BurstRule`)? |
| +3. Telemetry GET: is the member read gated correctly (instanceGate, then |
| + role)? Can a member, a non-member, an Instance-role service token or a |
| + linked/scoped credential now read anything beyond the protection half, |
| + or anything at all they could not before? Is the response for an absent |
| + protection half `{}`? Does any other caller of `handleAPITelemetryGet` |
| + or `telemetryGate` change behaviour? |
| +4. Notice workers: can `burstPeerCurrent` deadlock (it takes `n.mu`; is it |
| + ever called with `n.mu` held, or while `sendBurstNotices` holds it and |
| + waits on the worker)? Can pruning close `p.stop` twice, or prune a |
| + freshly created peer for the same box? Does a nil home map now drop |
| + notices that were sent before? Is anything sent to a box no longer in |
| + the targets? |
| +5. Census: give a verdict on each re-pinned envelope (`internal/edge`, |
| + `internal/edgeguard`) per AGENTS.md "The census": reject if the change |
| + lets root open, run, query or follow anything new from tenant-, app- or |
| + agent-controlled input, or weakens a check root relies on. |
| + |
| +## Severity |
| + |
| +- **P1**: unsafe, would not compile, a test fails, or it would not work. |
| + Blocks merge. |
| +- **P2**: wrong or missing. Fixed without reopening this review. (The |
| + census, and review of any newly changed security, root, termination |
| + or production-storage behaviour, still check the fix; see AGENTS.md, |
| + "Stopping rules".) |
| +- **P3**: clarity or polish. Goes on a follow-up list; never a reason for |
| + another round. |
| + |
| +A P1 states its failure scenario and the evidence (file:line). Do not |
| +raise a P2 to P1 to keep the review open. |
| + |
| +## Output |
| + |
| +Findings ranked P1, P2, P3. Each gives the section or task, the problem, |
| +the evidence (file:line, verified), the failure scenario, a concrete |
| +fix and the invariant or trust boundary it breaks (that is its fault |
| +family). Then the census verdict per envelope (approve or reject, citing |
| +the lines read). End with exactly one verdict: |
| + |
| +- **READY**: no P1 and no P2. |
| +- **READY AFTER FIXES**: no P1. The listed P2s are fixed without another |
| + round. |
| +- **NOT READY**: one or more P1s, listed. |
| + |
| +Do not edit files. Do not spawn Anthropic-model reviewers or subagents of |
| +your own. Do not run the full test suites. |
diff --git a/docs/superpowers/specs/2026-08-23-console-as-an-app-design.md b/docs/superpowers/specs/2026-08-23-console-as-an-app-design.md| index 24c2e339b..190ca42cd 100644 |
| --- a/docs/superpowers/specs/2026-08-23-console-as-an-app-design.md |
| +++ b/docs/superpowers/specs/2026-08-23-console-as-an-app-design.md |
| @@ -547,7 +547,7 @@ must reach the boxes **before** the first self-deploy. |
| **0. Survey both boxes** (read-only, no changes). Per box: `console.service`'s |
| `ExecStart` path and its `Type=`; which route carries the `Unit` stamp; |
| every console route and channel (tito is entirely unsurveyed — it has |
| - `console.platform.tito.io` and the still-serving `carlos.tito.io`); |
| + `console.platform.tito.io`, plus a retired alias); |
| `HasOwners("console")`; any legacy `apps/console/` prefix; the bucket |
| production flag on `console`. Flagship's readings are in the appendix; |
| **tito's are not, and step 7 deploys there first.** |
diff --git a/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md b/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md| index ae50a178f..e4a2497a4 100644 |
| --- a/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md |
| +++ b/docs/superpowers/specs/2026-10-24-edge-request-protection-design.md |
| @@ -365,6 +365,14 @@ route (or one allow rule) removes it. *My call:* 60 not-founds in 60 s, a 10-min |
| keyed by `clientIP` truncated as #358 does (/32 IPv4, /64 IPv6); the builder |
| checks both numbers against request records before shipping. |
| +*Calibrated and promoted (#491, Paul 2026-11-14):* seven days of watch records |
| +(2026-11-07 to 11-13) held up 60 in 60 s and 10 minutes, and the rule blocks |
| +by default, platform-wide. One change from the review: a missing site icon |
| +(`favicon.ico`/`.png`/`.svg`, `favicon-*.png`, `apple-touch-icon*.png`, in any |
| +directory) never counts toward a trip, since link-preview fetchers and monitors |
| +ask for them on their own and one tripped four times on nothing else. A hard |
| +or probe match on such a path still counts. |
| + |
| ### 5.6 The "under attack" switch |
| A per-app switch, set by CLI or console and live within seconds, for an incident: |
diff --git a/docs/superpowers/specs/2026-10-24-service-runs-design.md b/docs/superpowers/specs/2026-10-24-service-runs-design.md| index 3aef2a33b..b0e510871 100644 |
| --- a/docs/superpowers/specs/2026-10-24-service-runs-design.md |
| +++ b/docs/superpowers/specs/2026-10-24-service-runs-design.md |
| @@ -263,7 +263,7 @@ runs in `cliRoute` (`authcli.go:455`) before any handler, and that is fine. The |
| on a console without host-claim until #250 adds `cmd` to the reservation |
| protocol. Nothing here bypasses or pre-empts #250. |
| -Tito's console (`carlos.tito.io`) serves runs today: a follow of an unknown |
| +Tito's console (`console.platform.tito.io`) serves runs today: a follow of an unknown |
| run there answers "no such run", not the host-claim refusal (checked |
| 2026-10-24). So Fleet is not blocked by #250. |
diff --git a/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md b/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md| index 8954b0608..5a6949d7d 100644 |
| --- a/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md |
| +++ b/docs/superpowers/specs/2026-10-31-probe-burst-limit-design.md |
| @@ -76,7 +76,10 @@ Added here: |
| - **What counts as a not-found.** A response the edge sends or passes on with |
| status 404, plus any hard or probe tier match (watch or block) whatever the |
| status. A burst-mode rule match (`probe/admin`) counts only if the answer |
| - was a 404, since real admins use those paths. *My call.* |
| + was a 404, since real admins use those paths. *My call.* A plain 404 for a |
| + missing site icon (`favicon.ico`/`.png`/`.svg`, `favicon-*.png`, |
| + `apple-touch-icon*.png`) never counts (Paul, 2026-11-14, from the #491 |
| + calibration review). |
| - **Browsers never count** (builder check 1). A request carrying a |
| `Sec-Fetch-Mode` header, which every current browser sends on every request |
| and scanners do not, never counts toward a trip. *My call:* this stops a |
diff --git a/internal/console/apicli.go b/internal/console/apicli.go| index 8c9359108..8fcab9063 100644 |
| --- a/internal/console/apicli.go |
| +++ b/internal/console/apicli.go |
| @@ -1037,7 +1037,7 @@ func (s *Server) handleAPIPromote(w http.ResponseWriter, r *http.Request) { |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| } |
| - if ref := s.statelessRuntimeRefusal(ctx, channel, man, nil, ""); ref != nil { |
| + if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, man, nil, ""); ref != nil { |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| } |
| @@ -2352,6 +2352,14 @@ func (s *Server) handleAPIShip(w http.ResponseWriter, r *http.Request) { |
| jsonError(w, http.StatusBadRequest, err.Error()) |
| return |
| } |
| + // A stateless build an instance of this app could never wake is |
| + // refused before anything is uploaded (#1008). |
| + if meta.Stateless { |
| + if ref := s.unlabelledFleetRefusal(r.Context(), acct.Sqid, app); ref != nil { |
| + writeDoorRefusal(w, ref) |
| + return |
| + } |
| + } |
| if refuseBadSwap(w, meta.Swap) { |
| return |
| } |
diff --git a/internal/console/apidomains.go b/internal/console/apidomains.go| index c21defecc..18bd3d167 100644 |
| --- a/internal/console/apidomains.go |
| +++ b/internal/console/apidomains.go |
| @@ -59,7 +59,7 @@ import ( |
| // consoleHosts are the hostnames this console itself answers on: the ORIGIN |
| // host, plus the REDIRECT HOSTS (CONSOLE_REDIRECT_HOSTS: retired console |
| -// origins such as tito's carlos.tito.io, which this console still answers on |
| +// origins such as an old console.example.org, which this console still answers on |
| // and 301s to Origin). Every deployment refuses these whether or not it |
| // reserves platform domains (domainHostDenied). The reason is self-harm, not |
| // tenant isolation: an alias on one of these names points the console's own |
diff --git a/internal/console/apidomains_test.go b/internal/console/apidomains_test.go| index a8088c186..00296732e 100644 |
| --- a/internal/console/apidomains_test.go |
| +++ b/internal/console/apidomains_test.go |
| @@ -254,7 +254,7 @@ func TestAPIDomainAttachConflictNeutral(t *testing.T) { |
| // deny domain, under the deployment's apps domain, the console's own origin |
| // host and a name under it, and a RETIRED console origin |
| // (CONSOLE_REDIRECT_HOSTS, which this console still answers on and 301s |
| -// away, such as tito's carlos.tito.io). |
| +// away, such as an old console.example.org). |
| func TestAPIDomainAttachValidation(t *testing.T) { |
| fx, member := instanceFixture(t, "code-dom-validate") |
| fx.srv.cfg.DenyDomains = []string{"", "denied.test"} |
diff --git a/internal/console/apierrors.go b/internal/console/apierrors.go| index f8d6b759f..ec66f3ed6 100644 |
| --- a/internal/console/apierrors.go |
| +++ b/internal/console/apierrors.go |
| @@ -98,9 +98,9 @@ func (s *Server) handleAPIAvailability(w http.ResponseWriter, r *http.Request) { |
| writeJSON(w, http.StatusOK, resp) |
| } |
| -// telemetryGate is the instance gate plus the owner rule both telemetry |
| -// doors keep: the browser forms for these settings are owner-only, so the |
| -// person path here is too. A SERVICE holds no account role (AccountByID does |
| +// telemetryGate is the instance gate plus the owner rule the telemetry PUT |
| +// keeps: the browser forms for these settings are owner-only, so the person |
| +// path here is too. A SERVICE holds no account role (AccountByID does |
| // not populate Role), which is why this reads the kind first. |
| func (s *Server) telemetryGate(w http.ResponseWriter, r *http.Request) (string, *Account, string, bool) { |
| principal, acct, app, ok := s.instanceGate(w, r) |
| @@ -117,12 +117,18 @@ func (s *Server) telemetryGate(w http.ResponseWriter, r *http.Request) (string, |
| // handleAPITelemetryGet answers the app-level telemetry object as stored |
| // (absent halves absent, so the caller sees what is set on the app itself, |
| -// not what it inherits). The PUT's gate: it is that door's read. |
| +// not what it inherits). An owner, or a service credential the PUT would |
| +// take, reads the whole object. A member who is not an owner reads the |
| +// protection half alone (#491): the Protection tab already shows every |
| +// member whether the app records only, so `carlos protection` shows them |
| +// the same; the errors and analytics halves stay the owner's. |
| func (s *Server) handleAPITelemetryGet(w http.ResponseWriter, r *http.Request) { |
| - _, acct, app, ok := s.telemetryGate(w, r) |
| + _, acct, app, ok := s.instanceGate(w, r) |
| if !ok { |
| return |
| } |
| + p, _ := principalFrom(r.Context()) |
| + protectionOnly := p.Kind == PrincipalUser && acct.Role != RoleOwner |
| ctx, cancel := context.WithTimeout(r.Context(), instanceStoreTimeout) |
| defer cancel() |
| st, _, err := telemetry.Read(ctx, s.cfg.Releases, telemetry.AppKey(acct.Sqid, app)) |
| @@ -131,6 +137,9 @@ func (s *Server) handleAPITelemetryGet(w http.ResponseWriter, r *http.Request) { |
| jsonError(w, http.StatusBadGateway, "could not read the settings") |
| return |
| } |
| + if protectionOnly { |
| + st = telemetry.Settings{Protection: st.Protection} |
| + } |
| writeJSON(w, http.StatusOK, st) |
| } |
diff --git a/internal/console/apiinstancemove_offline.go b/internal/console/apiinstancemove_offline.go| index 46db68bfb..fc2a82c57 100644 |
| --- a/internal/console/apiinstancemove_offline.go |
| +++ b/internal/console/apiinstancemove_offline.go |
| @@ -203,6 +203,10 @@ type offlineReport struct { |
| type offlineEvidence struct { |
| reports []offlineReport |
| seal *offlineReport |
| + // targetsUnread: the move has target reports, and the edges files that |
| + // say which of them count could not be read (offlineMoveEvidence), so |
| + // none was kept and no door may decide from the target's side. |
| + targetsUnread bool |
| } |
| func (e offlineEvidence) get(role, box string) (offlineReport, bool) { |
| @@ -280,6 +284,49 @@ func (s *Server) readOfflineEvidence(ctx context.Context, host, id string) (offl |
| return ev, nil |
| } |
| +// offlineMoveEvidence is readOfflineEvidence for a move, with only the |
| +// target reports that count (amadan #413). It is the one read every door |
| +// and the status view decide from, so open, finish, the item list, the |
| +// failed flag and the reports the view returns (which the CLI reads) all |
| +// see the same targets. A target report counts only when the box that wrote |
| +// it is one the start door would have taken: published in the region the |
| +// move goes to, hibernating and serving the shared pool (boxesAt, |
| +// offlineCanHold), read fresh from the edges files. A box beside it that |
| +// serves only a named pool never gets the row, so its report is never |
| +// ready, and an old one that wrote a report anyway is not waited on. The |
| +// start door admits exactly one such box, so one target report counts. |
| +// Nothing is read from the record for this, so a record rewritten by an |
| +// older writer decides the same way. |
| +func (s *Server) offlineMoveEvidence(ctx context.Context, host string, mv *provision.MoveState) (offlineEvidence, error) { |
| + ev, err := s.readOfflineEvidence(ctx, host, mv.ID) |
| + if err != nil || len(ev.byRole(moves.OfflineRoleTarget)) == 0 { |
| + return ev, err |
| + } |
| + fleet, ok := s.readOfflineFleet(ctx) |
| + if !ok { |
| + return offlineEligibleTargets(ev, nil, false), nil |
| + } |
| + return offlineEligibleTargets(ev, fleet.boxesAt(mv.To), true), nil |
| +} |
| + |
| +// offlineEligibleTargets keeps, of ev, the target reports of the boxes in |
| +// eligible, and every report of any other role. read false says the fleet |
| +// could not be read: no target report is kept, and targetsUnread is set. |
| +func offlineEligibleTargets(ev offlineEvidence, eligible []edgesFilePlacementView, read bool) offlineEvidence { |
| + out := offlineEvidence{seal: ev.seal, targetsUnread: !read} |
| + for _, r := range ev.reports { |
| + if r.Role == moves.OfflineRoleTarget && !slices.ContainsFunc(eligible, func(b edgesFilePlacementView) bool { return b.Box == r.Box }) { |
| + continue |
| + } |
| + out.reports = append(out.reports, r) |
| + } |
| + return out |
| +} |
| + |
| +// offlineFleetUnread is the refusal of a step whose evidence it could not |
| +// complete because the edges files could not all be read. |
| +var offlineFleetUnread = &offlineRefusal{status: http.StatusConflict, msg: "the fleet's edges files could not all be read. try again"} |
| + |
| func offlineFresh(r moves.OfflineReport, now time.Time) bool { |
| age := now.Sub(r.At) |
| return !r.At.IsZero() && age <= offlineReportFresh && age >= -time.Minute |
| @@ -377,8 +424,10 @@ func (b offlineClaimsOnBox) ok() bool { |
| // adds none, so every claims-on box fails this condition until one does. |
| func offlineCensusReported(*status.BoxMetrics) *bool { return nil } |
| -// offlineSourceBoxes are the edges files of the record's source placement |
| -// that could hold the host, in box order. |
| +// boxesAt are the edges files of placement code whose boxes could hold the |
| +// host (offlineCanHold), in box order. A box that serves only named pools is |
| +// never one, since reconcile never gives it the row, and nor is one with |
| +// hibernation off. |
| func (f offlineFleet) boxesAt(code string) []edgesFilePlacementView { |
| var out []edgesFilePlacementView |
| for _, b := range f.snap.Files { |
| @@ -399,6 +448,9 @@ func (f offlineFleet) boxesAt(code string) []edgesFilePlacementView { |
| func (s *Server) offlineSelect(ctx context.Context, f offlineFleet, host, from, to string) *offlineRefusal { |
| fromName, toName := s.offlinePlace(from), s.offlinePlace(to) |
| src, tgt := f.boxesAt(from), f.boxesAt(to) |
| + if len(tgt) == 0 { |
| + return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s has no box that can take %s. an offline move needs one box there that hibernates and serves the shared pool", toName, host)} |
| + } |
| if len(tgt) != 1 { |
| return &offlineRefusal{status: http.StatusConflict, msg: fmt.Sprintf("%s has %d boxes. an offline move needs exactly one box in the region it moves to", toName, len(tgt))} |
| } |
| @@ -1121,6 +1173,9 @@ func processRefusal(box, host string) *offlineRefusal { |
| // sealer's living report is from this pass and holds the tombstone for this |
| // move, and every source box is still held, fenced and quiesced. |
| func (s *Server) offlineOpenCheck(ev offlineEvidence, mv *provision.MoveState, host, from string, now time.Time) *offlineRefusal { |
| + if ev.targetsUnread { |
| + return offlineFleetUnread |
| + } |
| tgt := ev.byRole(moves.OfflineRoleTarget) |
| if len(tgt) != 1 { |
| return offlineStateRefusal(mv.State, host) |
| @@ -1160,6 +1215,9 @@ func (s *Server) offlineOpenCheck(ev offlineEvidence, mv *provision.MoveState, h |
| func offlineFinishCheck(ev offlineEvidence, mv *provision.MoveState, host, targetPhase, sealerPhase, sourcePhase string, boxes []string) *offlineRefusal { |
| refuse := offlineStateRefusal(mv.State, host) |
| if targetPhase != "" { |
| + if ev.targetsUnread { |
| + return offlineFleetUnread |
| + } |
| tgt := ev.byRole(moves.OfflineRoleTarget) |
| if len(tgt) != 1 || tgt[0].Phase != targetPhase { |
| return refuse |
| @@ -1223,7 +1281,7 @@ func (s *Server) offlineVerbDoor(verb string) http.HandlerFunc { |
| return |
| } |
| ctx := r.Context() |
| - ev, err := s.readOfflineEvidence(ctx, d.host, mv.ID) |
| + ev, err := s.offlineMoveEvidence(ctx, d.host, mv) |
| if err != nil { |
| log.Printf("console: offline move %s: reports: %v", d.host, err) |
| jsonError(w, http.StatusBadGateway, "could not read the move's reports. try again") |
| @@ -1395,7 +1453,7 @@ func (s *Server) offlineViewOf(ctx context.Context, rec *provision.Record) offli |
| case provision.OfflineStaging, provision.OfflineStopping, provision.OfflineSealing, provision.OfflineSealed, provision.OfflineLanding, provision.OfflineLanded: |
| v.CanAbort = true |
| } |
| - ev, err := s.readOfflineEvidence(ctx, rec.Host, mv.ID) |
| + ev, err := s.offlineMoveEvidence(ctx, rec.Host, mv) |
| if err != nil { |
| log.Printf("console: offline move %s: reading the reports: %v", rec.Host, err) |
| v.Waiting = "could not read the move's reports. try again" |
diff --git a/internal/console/apiinstancemove_offline_stage_test.go b/internal/console/apiinstancemove_offline_stage_test.go| index 9f1445389..b6217a446 100644 |
| --- a/internal/console/apiinstancemove_offline_stage_test.go |
| +++ b/internal/console/apiinstancemove_offline_stage_test.go |
| @@ -154,6 +154,30 @@ func TestOfflineStageRefusesABoxThatCannotStage(t *testing.T) { |
| w.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgO21("uk-box")) |
| } |
| +// amadan #413: a box that serves only a named pool is never where a move |
| +// goes. A region holding nothing else is refused at stage, before anything |
| +// is written or locked; beside a box that serves the shared pool it is |
| +// stepped over (it need not even be able to stage), and the staged move |
| +// starts. |
| +func TestOfflineStageCountsOnlyBoxesThatCanHoldTheRow(t *testing.T) { |
| + poolOnly := func() offlineBox { b := poolOff(ukOff("uk-pool")); b.NoStageCap = true; return b } |
| + w := newOfflineWorld(t, ieOff("ie-box"), poolOnly()) |
| + w.refused(http.MethodPost, "/stage", `{"region":"uk"}`, http.StatusConflict, msgNoTarget("uk")) |
| + if rec := w.record(); rec.Move != nil { |
| + t.Fatalf("a refused stage wrote %+v", rec.Move) |
| + } |
| + if _, ok := w.lock(); ok { |
| + t.Fatal("a refused stage took the lock") |
| + } |
| + |
| + w = newOfflineWorld(t, ieOff("ie-box"), ukOff("uk-box"), poolOnly()) |
| + w.stage() |
| + if rec := w.record(); rec.Move.StageBucket != "data-uk" { |
| + t.Fatalf("staged to %q", rec.Move.StageBucket) |
| + } |
| + w.ok("", `{"region":"uk"}`, provision.OfflineStopping) |
| +} |
| + |
| // Abort from staging: reverting, the region untouched; finish waits for |
| // every source box's reverted (the stager's comes after it has deleted the |
| // staged copy), then ends a move that was never offline and frees the lock. |
diff --git a/internal/console/apiinstancemove_offline_test.go b/internal/console/apiinstancemove_offline_test.go| index c1fcfb622..6f8d15261 100644 |
| --- a/internal/console/apiinstancemove_offline_test.go |
| +++ b/internal/console/apiinstancemove_offline_test.go |
| @@ -440,6 +440,17 @@ func msgMC10(box string) string { |
| func msgO178(box string) string { |
| return "the report from " + box + " is not current. it reports again within a minute. try again then" |
| } |
| + |
| +// msgNoTarget is the start and stage doors' refusal of a region with no |
| +// box that can hold the row (amadan #413). |
| +func msgNoTarget(region string) string { |
| + return region + " has no box that can take " + offlineHost + ". an offline move needs one box there that hibernates and serves the shared pool" |
| +} |
| + |
| +// poolOff is b serving only a named pool: serves_shared_pool false, as a |
| +// CARLOS_POOLS=cohort1 box publishes it. |
| +func poolOff(b offlineBox) offlineBox { b.NotSharedPool = true; return b } |
| + |
| func msgO31(box string) string { |
| return box + " still runs a process for " + offlineHost + ". wait for it to stop, then flip" |
| } |
| @@ -582,7 +593,15 @@ func TestOfflineStartRefusals(t *testing.T) { |
| {name: "an unreadable edges file", boxes: oneEach, body: body, code: 409, msg: "the fleet's edges files could not all be read. try again", |
| setup: func(w *offlineWorld) { offlinePut(t, w.fx.rel, edgesFilePrefix+"broken.json", []byte("{")) }}, |
| {name: "no source box", boxes: []offlineBox{ukOff("uk-box")}, body: body, code: 400, msg: "no eligible box in ie publishes an edges file"}, |
| - {name: "no target box", boxes: []offlineBox{ieOff("ie-box")}, body: body, code: 409, msg: "uk has 0 boxes. an offline move needs exactly one box in the region it moves to"}, |
| + {name: "no target box", boxes: []offlineBox{ieOff("ie-box")}, body: body, code: 409, msg: msgNoTarget("uk")}, |
| + // amadan #413: a box that serves only a named pool, or does not |
| + // hibernate, can never hold the row, so it is not a box the move can |
| + // go to; a region of nothing else has none. |
| + {name: "only a pool box in the target region", boxes: []offlineBox{ieOff("ie-box"), poolOff(ukOff("uk-pool"))}, body: body, code: 409, msg: msgNoTarget("uk")}, |
| + {name: "only a box that does not hibernate in the target region", boxes: []offlineBox{ieOff("ie-box"), func() offlineBox { b := ukOff("uk-cold"); b.NoHibernation = true; return b }()}, |
| + body: body, code: 409, msg: msgNoTarget("uk")}, |
| + {name: "two shared target boxes beside a pool box", boxes: []offlineBox{ieOff("ie-box"), ukOff("uk-a"), ukOff("uk-b"), poolOff(ukOff("uk-pool"))}, body: body, code: 409, |
| + msg: "uk has 2 boxes. an offline move needs exactly one box in the region it moves to"}, |
| {name: "two target boxes", boxes: []offlineBox{ieOff("ie-box"), ukOff("uk-a"), ukOff("uk-b")}, body: body, code: 409, |
| msg: "uk has 2 boxes. an offline move needs exactly one box in the region it moves to"}, |
| {name: "a source box without the capability", boxes: []offlineBox{func() offlineBox { b := ieOff("ie-box"); b.NoCap = true; return b }(), ukOff("uk-box")}, |
| @@ -1013,6 +1032,103 @@ func TestOfflineFinishDoor(t *testing.T) { |
| } |
| } |
| +// amadan #413, seen on dev 2026-10-26: the region a move goes to holds the |
| +// box that can take the row and, beside it, a box that serves only a named |
| +// pool (CARLOS_POOLS=cohort1). Reconcile never gives that box the row, so its |
| +// target report says row_present false with every item not checked, and it |
| +// can never be ready. A target report counts only from a box the edges files |
| +// say can hold the row (offlineMoveEvidence): open, finish, the items, the |
| +// failed flag and the reports the view returns all leave the pool box out. |
| +// Nothing about it is on the record, so a record rewritten by an older |
| +// writer (the sealer's and the target's transitions decode and re-encode |
| +// the whole record) still opens. |
| +func TestOfflineCountsOnlyTargetsThatCanHoldTheRow(t *testing.T) { |
| + w := newOfflineWorld(t, ieOff("ie-box"), ukOff("uk-box"), poolOff(ukOff("uk-a-pool"))) |
| + w.start() |
| + // The pool box (named to sort before the target, so a reader of every |
| + // target report would meet it first) reports as a box from before the |
| + // fix did: no row, every landing item waiting on it, and once failed. |
| + pool := func(phase string) { |
| + w.report(moves.OfflineRoleTarget, "uk-a-pool", phase, func(r *moves.OfflineReport) { |
| + r.Held, r.Fenced, r.Quiesced = false, false, false |
| + r.Items = map[string]moves.Check{} |
| + for _, it := range moves.OfflineOwned(moves.OfflineOwnerLanding) { |
| + r.Items[it.ID] = moves.Check{Reason: "not checked: the row is not held for this move"} |
| + } |
| + }) |
| + } |
| + w.stopped(nil, "ie-box") |
| + w.ok("/seal", "", provision.OfflineSealing) |
| + w.sealed("ie-box") |
| + w.sealerFresh("ie-box") |
| + w.stopped(nil, "ie-box") |
| + w.ok("/flip", "", provision.OfflineLanding) |
| + pool(moves.OfflinePhaseLanded) |
| + w.landed("uk-box") |
| + w.stopped(nil, "ie-box") |
| + w.sealerFresh("ie-box") |
| + // An older writer's rewrite: the record decoded into the move shape every |
| + // release has and written back whole. |
| + w.rewriteRecord() |
| + onlyTarget := func(v offlineView, when string) { |
| + t.Helper() |
| + for _, r := range v.Reports { |
| + if r.Role == moves.OfflineRoleTarget && r.Box != "uk-box" { |
| + t.Fatalf("%s: the view returns %s's target report", when, r.Box) |
| + } |
| + } |
| + for _, it := range v.Items { |
| + if it.Owner == moves.OfflineOwnerLanding && (it.Status != "ok" || it.Detail != "ok") { |
| + t.Fatalf("%s: landing item %s reads %s (%s) from a box that cannot hold the row", when, it.ID, it.Status, it.Detail) |
| + } |
| + } |
| + } |
| + v := w.status() |
| + if v.Next != offlineVerbOpen { |
| + t.Fatalf("landed with a pool box beside the target: next %q, waiting %q", v.Next, v.Waiting) |
| + } |
| + onlyTarget(v, "landed") |
| + pool(moves.OfflinePhaseFailed) |
| + v = w.status() |
| + if v.Failed || v.Next != offlineVerbOpen { |
| + t.Fatalf("a failed report from the pool box: failed %v, next %q", v.Failed, v.Next) |
| + } |
| + onlyTarget(v, "the pool box failed") |
| + // The fleet unread: no target report counts, and open says why. |
| + offlinePut(t, w.fx.rel, edgesFilePrefix+"broken.json", []byte("{")) |
| + w.refused(http.MethodPost, "/open", "", http.StatusConflict, "the fleet's edges files could not all be read. try again") |
| + if err := w.fx.rel.Delete(context.Background(), edgesFilePrefix+"broken.json"); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.ok("/open", "", provision.OfflineOpen) |
| + w.report(moves.OfflineRoleTarget, "uk-box", moves.OfflinePhaseOpened, func(r *moves.OfflineReport) { r.Items = okChecks(moves.OfflineOwnerLanding) }) |
| + w.report(moves.OfflineRoleSource, "ie-box", moves.OfflinePhaseParked, nil) |
| + w.ok("/finish", "", provision.OfflineFinishing) |
| +} |
| + |
| +// rewriteRecord stands in for an older writer's transition: the record read, |
| +// decoded into provision.Record and written back whole under its etag. |
| +func (w *offlineWorld) rewriteRecord() { |
| + w.t.Helper() |
| + ctx := context.Background() |
| + key := provision.RecordKey("bab", "shop", offlineHost) |
| + raw, etag, err := w.fx.rel.Get(ctx, key) |
| + if err != nil { |
| + w.t.Fatal(err) |
| + } |
| + var rec provision.Record |
| + if err := json.Unmarshal(raw, &rec); err != nil { |
| + w.t.Fatal(err) |
| + } |
| + out, err := json.Marshal(rec) |
| + if err != nil { |
| + w.t.Fatal(err) |
| + } |
| + if _, err := w.fx.rel.Put(ctx, key, out, etag); err != nil { |
| + w.t.Fatal(err) |
| + } |
| +} |
| + |
| func TestOfflineAbortDoor(t *testing.T) { |
| // Before the flip: the region is untouched. |
| w := newOfflineWorld(t, oneEach...) |
diff --git a/internal/console/apiinstances.go b/internal/console/apiinstances.go| index 3f19962df..ac7412255 100644 |
| --- a/internal/console/apiinstances.go |
| +++ b/internal/console/apiinstances.go |
| @@ -2201,7 +2201,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| return |
| } |
| if chHead != nil { |
| - if ref := s.statelessRuntimeRefusal(ctx, channel, chHead.Manifest, nil, ""); ref != nil { |
| + if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, chHead.Manifest, nil, ""); ref != nil { |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| } |
| @@ -2523,7 +2523,7 @@ func (s *Server) handleAPIInstanceCreate(w http.ResponseWriter, r *http.Request) |
| if fleetActive != nil && fleetLabelsRecord(rec) && movable(rec) { |
| if box := fleetActive.chooseDestination(rec.Runtime == provision.RuntimeRootfsV1, ""); box != "" { |
| if chHead != nil { |
| - if ref := s.statelessRuntimeRefusal(ctx, channel, chHead.Manifest, fleetActive, box); ref != nil { |
| + if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, chHead.Manifest, fleetActive, box); ref != nil { |
| jsonError(w, ref.Status, ref.Msg) |
| return |
| } |
diff --git a/internal/console/appcopies.go b/internal/console/appcopies.go| index 30b29a4f6..1c0499f4c 100644 |
| --- a/internal/console/appcopies.go |
| +++ b/internal/console/appcopies.go |
| @@ -21,14 +21,18 @@ import ( |
| const ( |
| copiesStopping = "copies are still stopping on other boxes. wait for that to finish before selecting a release with a local database" |
| - copiesBounds = "copies must be a whole number of at least 1" |
| - copiesCapacity = "%d copies need %d eligible boxes. this fleet has %d" |
| - copiesRelease = "more than one copy requires a stateless, always-on release. set --copies 1 before selecting this release" |
| - copiesFloor = "copies above 1 need every fleet box and the console on %s or later. update them and try again" |
| - copiesUnread = "could not check every instance, release and fleet box, so the copy count was left unchanged. try again" |
| - copiesManaged = "more than one copy is available for platform-managed instances on an owned fleet only" |
| - copiesMoving = "this instance has an import or move in progress. finish it before changing the copy count" |
| - copiesOverlap = "more than one copy needs a release and app policy that let each copy switch builds while its old build keeps serving. change them first" |
| + // copiesUnlabelledGrowth (#1008, draft for copy review): host, fleet. |
| + copiesUnlabelledGrowth = "%s runs a release without a local database and is not tied to a box of fleet %s, so a second active box would stop it. move it to a release with a local database before adding a box" |
| + // copiesUnlabelled (#1008, draft for copy review): host, fleet. |
| + copiesUnlabelled = "%s is not tied to one box of fleet %s, and that fleet has more than one box. a release without a local database needs that first, so keep this app on a release with a local database for now" |
| + copiesBounds = "copies must be a whole number of at least 1" |
| + copiesCapacity = "%d copies need %d eligible boxes. this fleet has %d" |
| + copiesRelease = "more than one copy requires a stateless, always-on release. set --copies 1 before selecting this release" |
| + copiesFloor = "copies above 1 need every fleet box and the console on %s or later. update them and try again" |
| + copiesUnread = "could not check every instance, release and fleet box, so the copy count was left unchanged. try again" |
| + copiesManaged = "more than one copy is available for platform-managed instances on an owned fleet only" |
| + copiesMoving = "this instance has an import or move in progress. finish it before changing the copy count" |
| + copiesOverlap = "more than one copy needs a release and app policy that let each copy switch builds while its old build keeps serving. change them first" |
| // copy SR-4-C85 (#511 drill 1, R19) |
| copiesSize = "%d copies need %d boxes with room for size %s. this fleet has %d. choose a smaller size" |
| // copy SR-4-C91 (#511 drill 1 round 1, Astra A2) |
| @@ -213,6 +217,9 @@ func (s *Server) copiesRefusal(ctx context.Context, acct *Account, app string, n |
| if err != nil { |
| return unread() |
| } |
| + if ref := unlabelledFleetRecordRefusal(reg, recs); ref != nil { |
| + return ref |
| + } |
| // A durable create allocation may publish its body during recovery. |
| // Do not admit a larger count while that record is still pending. |
| allocations, err := s.store.PendingLifetimesForApp(acct.Sqid, app) |
| @@ -424,3 +431,163 @@ func (s *Server) copiesSizeRefusal(ctx context.Context, acct *Account, app strin |
| } |
| return nil |
| } |
| + |
| +// statelessPublicationRefusal is the check every door that selects a |
| +// stateless build for an app's instances asks (promote, new canary, |
| +// rollback, fast-track, instance create): the runtime floor, then |
| +// unlabelledFleetRefusal (#1008). Hibernating stateless builds included: |
| +// their wake needs the coordinator too. |
| +func (s *Server) statelessPublicationRefusal(ctx context.Context, sqid, app, channel string, m *release.Manifest, fleet *fleetView, box string) *doorRefusal { |
| + if ref := s.statelessRuntimeRefusal(ctx, channel, m, fleet, box); ref != nil { |
| + return ref |
| + } |
| + if m == nil || !m.Stateless { |
| + return nil |
| + } |
| + return s.unlabelledFleetRefusal(ctx, sqid, app) |
| +} |
| + |
| +// unlabelledFleetRefusal refuses a release without a local database, or |
| +// more than one copy, for an app with a live instance whose record is |
| +// placed on a fleet but tied to no box (no fleet_box, no replica |
| +// assignment) while that fleet has more than one active box (#1008). Every |
| +// box of the fleet serves such a record (provision ownsRecord), and the |
| +// console's coordinator door accepts it only on a one-box fleet |
| +// (replicaFleetRecord's sole-box rule), refusing every box otherwise: a |
| +// stateless build of it could never wake. Refused here, before anything is |
| +// published, rather than left to fail at the next wake. |
| +func (s *Server) unlabelledFleetRefusal(ctx context.Context, sqid, app string) *doorRefusal { |
| + recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), sqid, app) |
| + if err != nil { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread} |
| + } |
| + if !anyUnlabelledFleetRecord(recs) { |
| + return nil |
| + } |
| + reg, err := s.openPassRegistry() |
| + if err != nil { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread} |
| + } |
| + return unlabelledFleetRecordRefusal(reg, recs) |
| +} |
| + |
| +func anyUnlabelledFleetRecord(recs []provision.Record) bool { |
| + for _, rec := range recs { |
| + if _, onFleet := registry.FleetPlacement(rec.Region); onFleet && !rec.Retired && rec.FleetBox == "" && rec.ReplicaAssignment == nil { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// unlabelledFleetRecordRefusal is unlabelledFleetRefusal's judgment over |
| +// records already read. A fleet whose boxes can't be read answers 503. |
| +func unlabelledFleetRecordRefusal(reg consoleRegistry, recs []provision.Record) *doorRefusal { |
| + active := map[string]int{} |
| + for _, rec := range recs { |
| + fleet, onFleet := registry.FleetPlacement(rec.Region) |
| + if !onFleet || rec.Retired || rec.FleetBox != "" || rec.ReplicaAssignment != nil { |
| + continue |
| + } |
| + n, seen := active[fleet] |
| + if !seen { |
| + boxes, err := reg.ListFleetBoxes(fleet) |
| + if err != nil { |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: copiesUnread} |
| + } |
| + for _, box := range boxes { |
| + if box.Status == "active" { |
| + n++ |
| + } |
| + } |
| + active[fleet] = n |
| + } |
| + if n > 1 { |
| + return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(copiesUnlabelled, rec.Host, fleet)} |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// fleetGrowthRefusal refuses adding or reactivating label on fleet when that |
| +// would take the fleet from at most one active box to more than one while |
| +// an unlabelled instance of the fleet runs a stateless build (#1008): the |
| +// coordinator door accepts such a record only on a one-box fleet, so the |
| +// growth alone would cut it off. Reads it can't finish answer 503. |
| +func (s *Server) fleetGrowthRefusal(ctx context.Context, reg consoleRegistry, acct *Account, fleet, label string) *doorRefusal { |
| + return s.fleetGrowthBy(ctx, reg, acct, fleet, label, 1) |
| +} |
| + |
| +// fleetGrowthBy is fleetGrowthRefusal for adding boxes boxes at once (a |
| +// managed fleet's add, judged at reservation so nothing is provisioned). |
| +// label, when set, is the one box being added: already active, it is not |
| +// growth. |
| +func (s *Server) fleetGrowthBy(ctx context.Context, reg consoleRegistry, acct *Account, fleet, label string, boxes int) *doorRefusal { |
| + unread := &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msgFleetBoxNotAdded} |
| + listed, err := reg.ListFleetBoxes(fleet) |
| + if err != nil { |
| + return unread |
| + } |
| + active := 0 |
| + for _, b := range listed { |
| + if b.Status == "active" { |
| + if label != "" && b.Label == label { |
| + return nil // already active: not growth (the door answers the duplicate) |
| + } |
| + active++ |
| + } |
| + } |
| + if boxes < 1 || active+boxes <= 1 { |
| + return nil |
| + } |
| + if s.cfg.Releases == nil { |
| + return unread |
| + } |
| + apps, err := s.store.AppsIn(acct.ID) |
| + if err != nil { |
| + return unread |
| + } |
| + for _, app := range apps { |
| + recs, err := placeRecords(ctx, s.cfg.Releases, provision.JudgeFrom(ctx), acct.Sqid, app) |
| + if err != nil { |
| + return unread |
| + } |
| + for _, rec := range recs { |
| + if rec.Retired || rec.Region != "fleet/"+fleet || rec.FleetBox != "" || rec.ReplicaAssignment != nil { |
| + continue |
| + } |
| + stateless, err := s.channelHeadStateless(ctx, acct.Sqid, app, rec.Channel) |
| + if err != nil { |
| + return unread |
| + } |
| + if stateless { |
| + return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(copiesUnlabelledGrowth, rec.Host, fleet)} |
| + } |
| + } |
| + } |
| + return nil |
| +} |
| + |
| +// channelHeadStateless reports whether channel's current build declares no |
| +// local database. No channel, or an empty one, is false; a read that |
| +// fails is an error, never false. |
| +func (s *Server) channelHeadStateless(ctx context.Context, sqid, app, channel string) (bool, error) { |
| + if channel == "" { |
| + return false, nil |
| + } |
| + ptr, err := release.Channel(ctx, s.cfg.Releases, s.cfg.ReleasePub, sqid, app, channel) |
| + if errors.Is(err, os.ErrNotExist) { |
| + return false, nil |
| + } |
| + if err != nil { |
| + return false, err |
| + } |
| + if ptr == nil || ptr.Version == "" { |
| + return false, nil |
| + } |
| + m, err := release.GetManifest(ctx, s.cfg.Releases, sqid, app, ptr.Version) |
| + if err != nil { |
| + return false, err |
| + } |
| + return m != nil && m.Stateless, nil |
| +} |
diff --git a/internal/console/copiespublication_test.go b/internal/console/copiespublication_test.go| index ba4544803..dc226cda1 100644 |
| --- a/internal/console/copiespublication_test.go |
| +++ b/internal/console/copiespublication_test.go |
| @@ -175,7 +175,10 @@ func TestCopiesPublicationEvidence(t *testing.T) { |
| {"unread config unsafe", false, false, "config", 503}, |
| {"unread config safe", false, true, "config", 200}, |
| {"unread inventory unsafe", true, false, "record", 503}, |
| - {"unread inventory safe", true, true, "record", 200}, |
| + // A stateless target reads the inventory for #1008's guard (an |
| + // unlabelled record on a multi-box fleet), and an unreadable one |
| + // refuses with a retry rather than publish unchecked. |
| + {"unread inventory safe", true, true, "record", 503}, |
| } { |
| t.Run(tc.name, func(t *testing.T) { |
| fx, token := copiesWorld(t) |
| @@ -210,8 +213,11 @@ func TestCopiesPublicationEvidence(t *testing.T) { |
| if counter.gets[cfgKey] != 1 { |
| t.Fatalf("config GETs=%d, want exactly one", counter.gets[cfgKey]) |
| } |
| - if (!tc.explicit || tc.safe) && counter.gets[recKey] != 0 { |
| - t.Fatal("legacy/safe target read assignments") |
| + if !tc.explicit && !tc.safe && counter.gets[recKey] != 0 { |
| + t.Fatal("legacy target read assignments") |
| + } |
| + if tc.safe && tc.failure != "record" && counter.gets[recKey] == 0 { |
| + t.Fatal("stateless target published without reading the inventory (#1008)") |
| } |
| }) |
| } |
diff --git a/internal/console/copiesunlabelled_test.go b/internal/console/copiesunlabelled_test.go| new file mode 100644 |
| index 000000000..45196679d |
| --- /dev/null |
| +++ b/internal/console/copiesunlabelled_test.go |
| @@ -0,0 +1,249 @@ |
| +package console |
| + |
| +import ( |
| + "context" |
| + "crypto/ed25519" |
| + "crypto/rand" |
| + "fmt" |
| + "net/http" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/registry" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// unlabelledStatelessCutOff lists the instances of shop that no box of fleet |
| +// pi could ever coordinate (#1008): live, on the fleet, tied to no box (no |
| +// fleet_box, no replica assignment), on a fleet with more than one active box |
| +// (the coordinator door's sole-box rule refuses every box), while their |
| +// channel's current build declares no local database. |
| +func unlabelledStatelessCutOff(t *testing.T, fx *consoleFixture) []string { |
| + t.Helper() |
| + ctx := context.Background() |
| + reg := openTestReg(t, fx) |
| + defer reg.Close() |
| + boxes, err := reg.ListFleetBoxes("pi") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + active := 0 |
| + for _, b := range boxes { |
| + if b.Status == "active" { |
| + active++ |
| + } |
| + } |
| + recs, err := placeRecords(ctx, fx.rel, nil, fx.sqid, "shop") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + var out []string |
| + for _, rec := range recs { |
| + if rec.Retired || rec.Region != "fleet/pi" || rec.FleetBox != "" || rec.ReplicaAssignment != nil || active <= 1 { |
| + continue |
| + } |
| + stateless, err := fx.srv.channelHeadStateless(ctx, fx.sqid, "shop", rec.Channel) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if stateless { |
| + out = append(out, rec.Host) |
| + } |
| + } |
| + return out |
| +} |
| + |
| +// TestNoTransitionCutsOffAStatelessInstance (#1008, invariant): from each |
| +// starting world, every transition the console ACCEPTS leaves no stateless |
| +// instance that every fleet box would be refused (unlabelledStatelessCutOff |
| +// is empty). The transitions are the trimmed guard's doors: a --stateless |
| +// ship, a stateless promote, a rollback onto a stateless build, copies 2, |
| +// and adding or reactivating a box. The labelled world is the control: |
| +// there the guard refuses nothing. |
| +func TestNoTransitionCutsOffAStatelessInstance(t *testing.T) { |
| + unlabel := func(t *testing.T, fx *consoleFixture) { |
| + placementEdit(t, fx, "a.example.com", func(r *provision.Record) { r.FleetBox, r.FleetBoxAt = "", "" }) |
| + } |
| + type world struct { |
| + name string |
| + setup func(t *testing.T, fx *consoleFixture) |
| + // refused names the transitions this world must refuse with the |
| + // #1008 refusal; every other transition must succeed, except a |
| + // reactivation of a box that is already active (the duplicate). |
| + refused map[string]bool |
| + // other names a transition this world refuses for its own reason |
| + // (not #1008), by a fragment of the refusal. |
| + other map[string]string |
| + } |
| + // edgeHistory gives edge a previous stateless build, so a rollback |
| + // selects one (v2, then back to v1). |
| + edgeHistory := func(t *testing.T, fx *consoleFixture) { |
| + if err := release.Promote(context.Background(), fx.rel, fx.priv, fx.sqid, "shop", "edge", "v2"); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + worlds := []world{ |
| + {"two boxes, unlabelled, edge on a local-database build", func(t *testing.T, fx *consoleFixture) { |
| + unlabel(t, fx) |
| + shipVersion(t, fx, "shop", "s1") |
| + if err := release.Promote(context.Background(), fx.rel, fx.priv, fx.sqid, "shop", "edge", "s1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + }, map[string]bool{"ship stateless": true, "promote stateless onto edge": true, "rollback edge": true, "copies 2": true}, nil}, |
| + {"one box, unlabelled, edge stateless and working", func(t *testing.T, fx *consoleFixture) { |
| + edgeHistory(t, fx) |
| + unlabel(t, fx) |
| + placementEdit(t, fx, "b.example.com", func(r *provision.Record) { r.FleetBox = "pi-1" }) |
| + reg := openTestReg(t, fx) |
| + defer reg.Close() |
| + if err := reg.SetFleetBoxStatus("pi", "pi-2", "detached"); err != nil { |
| + t.Fatal(err) |
| + } |
| + }, map[string]bool{"reactivate pi-2": true, "add pi-3": true}, map[string]string{"copies 2": "eligible boxes"}}, |
| + {"two boxes, labelled", edgeHistory, nil, nil}, |
| + } |
| + type transition struct { |
| + name string |
| + do func(t *testing.T, fx *consoleFixture, token string) (int, string) |
| + } |
| + api := func(method, path, body string) func(*testing.T, *consoleFixture, string) (int, string) { |
| + return func(t *testing.T, fx *consoleFixture, token string) (int, string) { |
| + return copiesCall(t, fx, token, copiesDoor{path, method, path, body}) |
| + } |
| + } |
| + addBox := func(label string) func(*testing.T, *consoleFixture, string) (int, string) { |
| + return func(t *testing.T, fx *consoleFixture, token string) (int, string) { |
| + code, body := postJSON(t, fleetsURL(fx, fx.sqid)+"/pi/boxes", map[string]string{"label": label}, token) |
| + return code, fmt.Sprint(body) |
| + } |
| + } |
| + transitions := []transition{ |
| + {"ship stateless", func(t *testing.T, fx *consoleFixture, token string) (int, string) { |
| + code, body := postShip(t, fx.ts.URL+"/api/cli/apps/"+fx.sqid+"/shop/releases", token, []shipPart{metaStateless(t, "v3"), {name: "linux-amd64", body: tinyProgramForConsole(t, "example.com/shop")}}) |
| + return code, fmt.Sprint(body) |
| + }}, |
| + {"promote stateless onto edge", api("POST", "/promote", `{"channel":"edge","version":"v2","hotfix":true}`)}, |
| + {"rollback edge", api("POST", "/rollback", `{"channel":"edge"}`)}, |
| + {"copies 2", func(t *testing.T, fx *consoleFixture, token string) (int, string) { |
| + return copiesPut(t, fx, token, `{"copies":2}`) |
| + }}, |
| + {"reactivate pi-2", addBox("pi-2")}, |
| + {"add pi-3", addBox("pi-3")}, |
| + } |
| + for _, w := range worlds { |
| + for _, tr := range transitions { |
| + t.Run(w.name+"/"+tr.name, func(t *testing.T) { |
| + fx, token := copiesWorld(t) |
| + w.setup(t, fx) |
| + if cut := unlabelledStatelessCutOff(t, fx); len(cut) != 0 { |
| + t.Fatalf("world starts broken: %v", cut) |
| + } |
| + code, out := tr.do(t, fx, token) |
| + ours := code == http.StatusConflict && (strings.Contains(out, "is not tied to one box") || strings.Contains(out, "is not tied to a box")) |
| + switch { |
| + case w.refused[tr.name]: |
| + if !ours { |
| + t.Fatalf("want the #1008 refusal, got %d %s", code, out) |
| + } |
| + case w.other[tr.name] != "": |
| + if code < 300 || ours || !strings.Contains(out, w.other[tr.name]) { |
| + t.Fatalf("want this world's own refusal %q, got %d %s", w.other[tr.name], code, out) |
| + } |
| + case tr.name == "reactivate pi-2" && w.name != "one box, unlabelled, edge stateless and working": |
| + // pi-2 is already active: the duplicate answer. |
| + if code != http.StatusConflict || ours { |
| + t.Fatalf("duplicate box: %d %s", code, out) |
| + } |
| + default: |
| + if code >= 300 { |
| + t.Fatalf("want accepted, got %d %s", code, out) |
| + } |
| + } |
| + if code < 300 { |
| + if cut := unlabelledStatelessCutOff(t, fx); len(cut) != 0 { |
| + t.Fatalf("accepted %d %s, and left %v cut off from every box", code, out, cut) |
| + } |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +// TestStatelessPublicationCoversHibernating: a hibernating stateless build |
| +// needs the coordinator to wake, so the publication check refuses it too. |
| +func TestStatelessPublicationCoversHibernating(t *testing.T) { |
| + fx, _ := copiesWorld(t) |
| + placementEdit(t, fx, "a.example.com", func(r *provision.Record) { r.FleetBox, r.FleetBoxAt = "", "" }) |
| + ctx := withWriteMemo(t.Context()) |
| + m := &release.Manifest{App: "shop", Version: "h1", Kind: release.KindRootfs, Stateless: true, Hibernate: true} |
| + ref := fx.srv.unlabelledFleetRefusal(ctx, fx.sqid, "shop") |
| + if ref == nil || ref.Msg != fmt.Sprintf(copiesUnlabelled, "a.example.com", "pi") { |
| + t.Fatalf("unlabelled guard: %+v", ref) |
| + } |
| + if got := fx.srv.statelessPublicationRefusal(ctx, fx.sqid, "shop", "edge", m, nil, ""); got == nil || got.Status != http.StatusConflict || got.Msg != fmt.Sprintf(copiesUnlabelled, "a.example.com", "pi") { |
| + t.Fatalf("hibernating stateless publication: %+v", got) |
| + } |
| +} |
| + |
| +func metaStateless(t *testing.T, version string) shipPart { |
| + t.Helper() |
| + return shipPart{name: "meta", body: []byte(`{"version":"` + version + `","kind":"binary","stateless":true}`)} |
| +} |
| + |
| +// TestManagedGrowthCannotCutOffStatelessInstance (#1008): a managed fleet's |
| +// add is the other way a fleet grows. With one active box and an unlabelled |
| +// instance whose channel runs a stateless build, the add is refused before |
| +// anything is reserved; with the record labelled, it is reserved. |
| +func TestManagedGrowthCannotCutOffStatelessInstance(t *testing.T) { |
| + for _, labelled := range []bool{false, true} { |
| + t.Run(fmt.Sprintf("labelled=%v", labelled), func(t *testing.T) { |
| + s := managedAPIFixture(t) |
| + ctx := context.Background() |
| + managedAPIReply(t, managedAPICall(s, "create", "abc", "", managedAPIBody("a", 1))) |
| + // The create has run its course; an add may be asked. |
| + s.store.db.Exec(`UPDATE managed_ops SET state='failed',error='managed_preparation_failed'`) |
| + reg, err := registry.Open(s.cfg.Registry) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer reg.Close() |
| + if err := reg.AddManagedFleetBox(registry.FleetBox{Fleet: "production", Label: "m-1", TokenHash: strings.Repeat("a", 64), Status: "active", AddedAt: time.Now().Unix()}, time.Now().Unix()); err != nil { |
| + t.Fatal(err) |
| + } |
| + pub, priv, _ := ed25519.GenerateKey(rand.Reader) |
| + s.cfg.ReleasePub = pub |
| + if _, err := s.store.CreateAppIn(42, "shop", "owner@example.com", time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + m := release.Manifest{Schema: 1, Kind: "binary", App: "shop", Version: "v1", Stateless: true, Artifacts: map[string]release.Artifact{"linux-amd64": {File: "app"}}} |
| + if err := release.Ship(ctx, s.cfg.Releases, "abc", m, map[string][]byte{"linux-amd64": []byte("app")}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := release.Promote(ctx, s.cfg.Releases, priv, "abc", "shop", "edge", "v1"); err != nil { |
| + t.Fatal(err) |
| + } |
| + rec := provision.Record{Schema: 1, Host: "a.example.com", Slug: "a", App: "shop", Account: "abc", Region: "fleet/production", Channel: "edge", CreatedAt: time.Now().UTC()} |
| + if labelled { |
| + rec.FleetBox = "m-1" |
| + } |
| + if err := provision.CreateRecord(ctx, s.cfg.Releases, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + w := managedAPICall(s, "add", "abc", "production", `{"boxes":1,"request_id":"bbbbbbbbbbbbbbbbbbbbbb"}`) |
| + var adds int |
| + s.store.db.QueryRow(`SELECT count(*) FROM managed_ops WHERE kind='add'`).Scan(&adds) |
| + want := fmt.Sprintf(copiesUnlabelledGrowth, "a.example.com", "production") |
| + if labelled { |
| + if w.Code >= 300 || adds != 1 { |
| + t.Fatalf("labelled control: %d %s, add ops %d", w.Code, w.Body, adds) |
| + } |
| + return |
| + } |
| + if w.Code != http.StatusConflict || !strings.Contains(w.Body.String(), want) || adds != 0 { |
| + t.Fatalf("unlabelled: %d %s, add ops %d, want 409 %q and nothing reserved", w.Code, w.Body, adds, want) |
| + } |
| + }) |
| + } |
| +} |
diff --git a/internal/console/fleets.go b/internal/console/fleets.go| index 06f861fbc..4257d039d 100644 |
| --- a/internal/console/fleets.go |
| +++ b/internal/console/fleets.go |
| @@ -414,6 +414,13 @@ func (s *Server) handleAPIFleetAddBox(w http.ResponseWriter, r *http.Request) { |
| "invalid box label — 1-32 characters of a-z, 0-9 and hyphen") |
| return |
| } |
| + // #1008: a second active box would cut off an unlabelled instance that |
| + // runs a stateless build on a one-box fleet (the coordinator's sole-box |
| + // rule). AddFleetBox both adds and reactivates, so this covers both. |
| + if ref := s.fleetGrowthRefusal(r.Context(), reg, acct, fleet.Name, label); ref != nil { |
| + writeDoorRefusalJSON(w, r, ref) |
| + return |
| + } |
| plaintext, hash, err := mintFleetToken() |
| if err != nil { |
| log.Printf("console: fleet add-box %s/%s: mint token: %v", acct.Sqid, fleet.Name, err) |
diff --git a/internal/console/managedapi.go b/internal/console/managedapi.go| index cae3d2791..a957f8c5a 100644 |
| --- a/internal/console/managedapi.go |
| +++ b/internal/console/managedapi.go |
| @@ -137,7 +137,7 @@ func (s *Server) handleAPIManagedFleetCreate(w http.ResponseWriter, r *http.Requ |
| s.managedAPIReserved(w, r, op) |
| } |
| func (s *Server) handleAPIManagedFleetAdd(w http.ResponseWriter, r *http.Request) { |
| - addr, acct, fleet, _, ok := s.apiFleet(w, r) |
| + addr, acct, fleet, reg, ok := s.apiFleet(w, r) |
| if !ok { |
| return |
| } |
| @@ -181,6 +181,13 @@ func (s *Server) handleAPIManagedFleetAdd(w http.ResponseWriter, r *http.Request |
| if !s.managedAPIEntitlement(w, acct) { |
| return |
| } |
| + // #1008: growth past one active box must not cut off an unlabelled |
| + // instance running a stateless build. Judged before the reservation, |
| + // so nothing is provisioned on a refusal. |
| + if ref := s.fleetGrowthBy(r.Context(), reg, acct, fleet.Name, "", req.Boxes); ref != nil { |
| + writeDoorRefusalJSON(w, r, ref) |
| + return |
| + } |
| op, _, _, err := s.reserveManagedFleet(r.Context(), req) |
| if err != nil { |
| s.managedAPIError(w, err) |
diff --git a/internal/console/protectionsetting_test.go b/internal/console/protectionsetting_test.go| index 344de2c57..9bf3b49eb 100644 |
| --- a/internal/console/protectionsetting_test.go |
| +++ b/internal/console/protectionsetting_test.go |
| @@ -264,8 +264,9 @@ func TestAPITelemetryProtectionAuditLine(t *testing.T) { |
| } |
| } |
| -// The read beside the PUT: the app's stored settings as stored, under the |
| -// PUT's gate (Operate, and a person must own the account). |
| +// The read beside the PUT: the app's stored settings as stored, for an |
| +// Operate credential or an owner. A member reads the protection half alone, |
| +// as the Protection tab shows it to them (#491). |
| func TestAPITelemetryGet(t *testing.T) { |
| fx, _ := ptFixture(t) |
| getURL := fx.ts.URL + "/api/cli/apps/" + fx.sqid + "/shop/telemetry" |
| @@ -297,7 +298,24 @@ func TestAPITelemetryGet(t *testing.T) { |
| t.Fatal(err) |
| } |
| member := cliToken(t, fx, "kim@keymail.dev", "code-ps-get-member") |
| - if status, _, body := rawReq(t, http.MethodGet, getURL, member, ""); status != http.StatusForbidden { |
| - t.Fatalf("member GET = %d %s, want 403", status, body) |
| + status, _, body = rawReq(t, http.MethodGet, getURL, member, "") |
| + var st telemetry.Settings |
| + if status != http.StatusOK || json.Unmarshal([]byte(body), &st) != nil || !telemetry.RecordOnly(st) || |
| + st.Errors != nil || st.Analytics != nil || strings.Contains(body, "log_level") { |
| + t.Fatalf("member GET = %d %s, want the protection half alone", status, body) |
| + } |
| + // Nothing stored for protection: a member sees nothing at all. |
| + if err := telemetry.Update(context.Background(), fx.rel, telemetry.AppKey(fx.sqid, "shop"), func(st *telemetry.Settings) { |
| + st.Protection = nil |
| + }); err != nil { |
| + t.Fatal(err) |
| + } |
| + if status, _, body := rawReq(t, http.MethodGet, getURL, member, ""); status != http.StatusOK || strings.TrimSpace(body) != "{}" { |
| + t.Fatalf("member GET with no protection stored = %d %s, want {}", status, body) |
| + } |
| + // A stranger to the account gets nothing. |
| + stranger := cliToken(t, fx, "sam@keymail.dev", "code-ps-get-stranger") |
| + if status, _, body := rawReq(t, http.MethodGet, getURL, stranger, ""); status == http.StatusOK { |
| + t.Fatalf("non-member GET = %d %s, want a refusal", status, body) |
| } |
| } |
diff --git a/internal/console/rootfs.go b/internal/console/rootfs.go| index 0752ad035..e0e4a7dae 100644 |
| --- a/internal/console/rootfs.go |
| +++ b/internal/console/rootfs.go |
| @@ -79,7 +79,7 @@ func (s *Server) statelessVersionRefusal(ctx context.Context, acct, app, channel |
| if err != nil { |
| return nil |
| } |
| - return s.statelessRuntimeRefusal(ctx, channel, m, nil, "") |
| + return s.statelessPublicationRefusal(ctx, acct, app, channel, m, nil, "") |
| } |
| type statelessSelectionError struct{ ref *doorRefusal } |
diff --git a/internal/console/server.go b/internal/console/server.go| index 949068bec..48ed0ab41 100644 |
| --- a/internal/console/server.go |
| +++ b/internal/console/server.go |
| @@ -5882,7 +5882,7 @@ func (s *Server) handlePromote(w http.ResponseWriter, r *http.Request) { |
| back("err", ref.Msg) |
| return |
| } |
| - if ref := s.statelessRuntimeRefusal(ctx, channel, man, nil, ""); ref != nil { |
| + if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, man, nil, ""); ref != nil { |
| back("err", ref.Msg) |
| return |
| } |
| @@ -6620,7 +6620,7 @@ func (s *Server) handleNewCanary(w http.ResponseWriter, r *http.Request) { |
| back("err", ref.Msg) |
| return |
| } |
| - if ref := s.statelessRuntimeRefusal(ctx, channel, man, nil, ""); ref != nil { |
| + if ref := s.statelessPublicationRefusal(ctx, acct.Sqid, app, channel, man, nil, ""); ref != nil { |
| back("err", ref.Msg) |
| return |
| } |
diff --git a/internal/domains/claims_proof_test.go b/internal/domains/claims_proof_test.go| index 6a8efc0e8..cf3e450af 100644 |
| --- a/internal/domains/claims_proof_test.go |
| +++ b/internal/domains/claims_proof_test.go |
| @@ -186,7 +186,7 @@ func TestChallengeTokenIsBound(t *testing.T) { |
| base := ChallengeToken("console.carloku.com", "bes", "shop.example.com") |
| for name, other := range map[string]string{ |
| "another account": ChallengeToken("console.carloku.com", "bab", "shop.example.com"), |
| - "another deployment": ChallengeToken("carlos.tito.io", "bes", "shop.example.com"), |
| + "another deployment": ChallengeToken("console.example.net", "bes", "shop.example.com"), |
| "another host": ChallengeToken("console.carloku.com", "bes", "www.example.com"), |
| } { |
| if other == base { |
diff --git a/internal/edge/burst_edge_test.go b/internal/edge/burst_edge_test.go| index eed075b06..fbf4fca11 100644 |
| --- a/internal/edge/burst_edge_test.go |
| +++ b/internal/edge/burst_edge_test.go |
| @@ -220,11 +220,11 @@ func (g *burstRig) wantRefused(t *testing.T, w *httptest.ResponseRecorder, until |
| return code |
| } |
| -// The scanner's 60th not-found trips it. In the default (watch) mode its |
| -// 61st catalogue request still reaches the app, and is recorded as the |
| -// refusal it would have been, saying the cool-down started on this app. |
| +// The scanner's 60th not-found trips it. In watch mode its 61st catalogue |
| +// request still reaches the app, and is recorded as the refusal it would |
| +// have been, saying the cool-down started on this app. |
| func TestBurstTripsAndRecordsWouldRefuse(t *testing.T) { |
| - g := newBurstRig(t, "") |
| + g := newBurstRig(t, "watch") |
| until := g.trip(t, burstHost) |
| tr := g.rec.trips[0] |
| ref, err := reqrec.ParseRef(tr.Ref, g.key) |
| @@ -263,6 +263,51 @@ func TestBurstRefusesInBlockMode(t *testing.T) { |
| } |
| } |
| +// The promotion (#491): in the default mode the burst rule refuses. After |
| +// the trip the cooling client's next catalogue request is refused on the |
| +// app it tripped on and on another app, an ordinary page still reaches the |
| +// app, and the probe rules themselves still only watch for a client that is |
| +// not cooling. The app's record-only switch turns the refusal off for that |
| +// app alone. |
| +func TestBurstCatalogueRefusesByDefault(t *testing.T) { |
| + g := newBurstRig(t, "", burstHost+"/about") |
| + if g.e.guard != guardCatalogue { |
| + t.Fatalf("guard mode %v, want the catalogue's", g.e.guard) |
| + } |
| + until := g.trip(t, burstHost) |
| + n := g.upstream.Load() |
| + code := g.wantRefused(t, g.get(burstHost, "/wp-login.php"), until) |
| + m := g.lastMatch(t, "/wp-login.php") |
| + wantBurstMatch(t, m, reqrec.KindBlock, reqrec.CooldownFromThisApp, until) |
| + if m.Ref != code || m.Status != 429 || g.upstream.Load() != n { |
| + t.Fatalf("this app: %+v, upstream %d; want the refusal", m, g.upstream.Load()-n) |
| + } |
| + g.wantRefused(t, g.get(burstOther, "/xmlrpc.php"), until) |
| + wantBurstMatch(t, g.lastMatch(t, "/xmlrpc.php"), reqrec.KindBlock, reqrec.CooldownFromOtherApp, until) |
| + if w := g.get(burstHost, "/about"); w.Code != 200 || w.Body.String() != "page /about" { |
| + t.Fatalf("/about: %d %q, want the page", w.Code, w.Body.String()) |
| + } |
| + |
| + r := httptest.NewRequest("GET", "http://"+burstHost+"/wp-login.php", nil) |
| + r.RemoteAddr = "198.51.100.7:4000" |
| + w := httptest.NewRecorder() |
| + g.e.ServeHTTP(w, r) |
| + if w.Code != 404 || w.Body.String() != "the app's own 404" { |
| + t.Fatalf("a client not cooling: %d %q, want the app's answer", w.Code, w.Body.String()) |
| + } |
| + if m := g.lastMatch(t, "/wp-login.php"); m.Kind != reqrec.KindWatch || m.Tier != reqrec.TierProbe { |
| + t.Fatalf("a client not cooling: match %+v, want the probe watch", m) |
| + } |
| + |
| + g.e.SetProtectionRecordOnly(map[string]bool{"bdk/shop": true}) |
| + n = g.upstream.Load() |
| + if w := g.get(burstHost, "/wp-login.php"); w.Code != 404 || w.Body.String() != "the app's own 404" || g.upstream.Load() != n+1 { |
| + t.Fatalf("record only: %d %q, want the app's answer", w.Code, w.Body.String()) |
| + } |
| + wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), reqrec.KindWatch, reqrec.CooldownFromThisApp, until) |
| + g.wantRefused(t, g.get(burstOther, "/wp-login.php"), until) |
| +} |
| + |
| // Review Focus 1: a page that is not in the catalogue is never refused, |
| // whoever shares the address. |
| func TestBurstNeverRefusesAnOrdinaryPage(t *testing.T) { |
| @@ -318,6 +363,39 @@ func TestBurstBrowserRequestsNeverCount(t *testing.T) { |
| } |
| } |
| +// Missing site icons never count (Paul, #491): a fetcher that asks for |
| +// favicons and touch icons an app does not have is not a scanner, however |
| +// many it misses. Every icon spelling below is a 404 from the app; the same |
| +// number of other misses still trips. |
| +func TestBurstIconMissesNeverCount(t *testing.T) { |
| + icons := []string{"/favicon.ico", "/favicon.png", "/favicon.svg", "/Favicon.ICO", "/favicon-32x32.png", |
| + "/apple-touch-icon.png", "/apple-touch-icon-precomposed.png", "/apple-touch-icon-120x120.png", |
| + "/apple-touch-icon-152x152-precomposed.png", "/static/favicon.ico", "/img/apple-touch-icon.png"} |
| + g := newBurstRig(t, "") |
| + for i := 0; i < burstThreshold+10; i++ { |
| + if w := g.get(burstHost, icons[i%len(icons)]); w.Code != 404 { |
| + t.Fatalf("%s: %d", icons[i%len(icons)], w.Code) |
| + } |
| + } |
| + shop := burstAppKey(registry.Route{Account: "bdk", App: "shop"}) |
| + if n := g.e.burst.ringLen(shop, burstScanner); n != 0 || len(g.rec.trips) != 0 { |
| + t.Fatalf("icon misses counted %d times, %d trips", n, len(g.rec.trips)) |
| + } |
| + // Names that only look like icons count as any other miss. |
| + for _, p := range []string{"/favicon.php", "/apple-touch-icon.php", "/favicon.ico/x", "/myfavicon.ico"} { |
| + if burstIconPath(p) { |
| + t.Fatalf("%s read as an icon", p) |
| + } |
| + } |
| + // The control: ordinary misses from the same client trip. |
| + for i := 0; i < burstThreshold; i++ { |
| + g.get(burstHost, fmt.Sprintf("/missing-%d", i)) |
| + } |
| + if _, _, ok := g.e.burst.cooling(burstScanner); !ok || len(g.rec.trips) != 1 { |
| + t.Fatalf("ordinary misses: cooling %v, trips %d; want one trip", ok, len(g.rec.trips)) |
| + } |
| +} |
| + |
| // An admin page is a page real admins open: a match on it counts only when |
| // the app has no such page. |
| func TestBurstAdminCountsOnlyOn404(t *testing.T) { |
| @@ -400,21 +478,31 @@ func TestBurstFleetAppNeverRefused(t *testing.T) { |
| } |
| // One request has one verdict, one record and one Protection count, however |
| -// many rules it meets. |
| +// many rules it meets. In the default mode that count is a block: the burst |
| +// rule refuses, and the Protection tab counts a refusal as blocked. |
| func TestBurstOneVerdictPerRequest(t *testing.T) { |
| - g := newBurstRig(t, "") |
| - until := g.trip(t, burstHost) |
| - g.meter.Drain() |
| - matches := len(g.rec.match) |
| - g.get(burstHost, "/wp-login.php") |
| - if len(g.rec.match) != matches+1 { |
| - t.Fatalf("%d matches for one request", len(g.rec.match)-matches) |
| - } |
| - wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), reqrec.KindWatch, reqrec.CooldownFromThisApp, until) |
| - f := g.meter.Drain() |
| - d, ok := f.Guard[usage.GuardKey(burstHost, "bdk", "shop")] |
| - if len(f.Guard) != 1 || !ok || d.Checked != 1 || d.Watch != 1 || d.Block != 0 || !maps.Equal(d.Groups, map[string]int64{"burst/probe-burst": 1}) { |
| - t.Fatalf("guard counts %+v, want one recorded burst/probe-burst", f.Guard) |
| + for _, tc := range []struct { |
| + protect string |
| + kind reqrec.Kind |
| + watch, block int64 |
| + }{ |
| + {"", reqrec.KindBlock, 0, 1}, |
| + {"watch", reqrec.KindWatch, 1, 0}, |
| + } { |
| + g := newBurstRig(t, tc.protect) |
| + until := g.trip(t, burstHost) |
| + g.meter.Drain() |
| + matches := len(g.rec.match) |
| + g.get(burstHost, "/wp-login.php") |
| + if len(g.rec.match) != matches+1 { |
| + t.Fatalf("mode %q: %d matches for one request", tc.protect, len(g.rec.match)-matches) |
| + } |
| + wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), tc.kind, reqrec.CooldownFromThisApp, until) |
| + f := g.meter.Drain() |
| + d, ok := f.Guard[usage.GuardKey(burstHost, "bdk", "shop")] |
| + if len(f.Guard) != 1 || !ok || d.Checked != 1 || d.Watch != tc.watch || d.Block != tc.block || !maps.Equal(d.Groups, map[string]int64{"burst/probe-burst": 1}) { |
| + t.Fatalf("mode %q: guard counts %+v, want one %s burst/probe-burst", tc.protect, f.Guard, tc.kind) |
| + } |
| } |
| } |
| @@ -436,9 +524,11 @@ func TestBurstWatchNeverWeakensABlock(t *testing.T) { |
| } |
| }) |
| t.Run("static rewrite", func(t *testing.T) { |
| - // The default mode, where the burst rule watches and the .env rule |
| - // blocks. The .git rule watches here, so a hard-tier request path |
| - // whose own verdict does not block still reaches the static handler. |
| + // The default mode with the burst rule watching, as an app's own |
| + // exemption will make it, and the .env rule blocking. The .git rule |
| + // watches here, so a hard-tier request path whose own verdict does |
| + // not block still reaches the static handler. |
| + demoteBurstRule(t) |
| g := newBurstStaticRig(t, "", map[string]string{".env": "SECRET=1", "_redirects": "/* /.env 200\n"}) |
| until := g.trip(t, burstHost) |
| env, ok := edgeguard.RuleByID("hard.secrets.env") |
| @@ -471,8 +561,8 @@ func TestBurstWatchNeverWeakensABlock(t *testing.T) { |
| if m := g.lastMatch(t, "/.git/config"); m.Kind != reqrec.KindBlock || m.RuleID != "hard.secrets.env" { |
| t.Fatalf("/.git/config: match %+v, want the hard block", m) |
| } |
| - // Without the promotion the burst watch stands, as the first |
| - // verdict that does not block. |
| + // With the .env rule watching too, the burst watch stands, as the |
| + // first verdict that does not block. |
| env.Mode = edgeguard.ModeWatch |
| g.get(burstHost, "/wp-login.php") |
| wantBurstMatch(t, g.lastMatch(t, "/wp-login.php"), reqrec.KindWatch, reqrec.CooldownFromThisApp, until) |
| @@ -795,13 +885,14 @@ func TestBurstStaleFillCountedOnceAtTheHome(t *testing.T) { |
| } |
| } |
| -// promoteBurstRule sets the burst rule's catalogue mode to block for the |
| -// test, as the later one-line promotion will: in the default mode the burst |
| -// rule then refuses while the probe rules still only watch. |
| -func promoteBurstRule(t *testing.T) { |
| +// demoteBurstRule sets the burst rule's catalogue mode back to watch for the |
| +// test, as it was before the promotion (#491): in the default mode the burst |
| +// rule then only records. |
| +func demoteBurstRule(t *testing.T) { |
| t.Helper() |
| - edgeguard.BurstRule.Mode = edgeguard.ModeBlock |
| - t.Cleanup(func() { edgeguard.BurstRule.Mode = edgeguard.ModeWatch }) |
| + mode := edgeguard.BurstRule.Mode |
| + edgeguard.BurstRule.Mode = edgeguard.ModeWatch |
| + t.Cleanup(func() { edgeguard.BurstRule.Mode = mode }) |
| } |
| // Fix round 1, finding 2: a static site's own file is never refused by the |
| @@ -826,8 +917,7 @@ func TestBurstNeverRefusesAnExistingStaticHardFile(t *testing.T) { |
| } |
| } |
| }) |
| - t.Run("burst rule promoted", func(t *testing.T) { |
| - promoteBurstRule(t) |
| + t.Run("default mode", func(t *testing.T) { |
| // With the .env rule watching (as an app's own allow rule will make |
| // it), a burst refusal still never takes a file the site has. |
| env, ok := edgeguard.RuleByID("hard.secrets.env") |
diff --git a/internal/edge/burst_notice.go b/internal/edge/burst_notice.go| index a5a518d75..d174957bf 100644 |
| --- a/internal/edge/burst_notice.go |
| +++ b/internal/edge/burst_notice.go |
| @@ -385,6 +385,27 @@ func (e *Edge) runBurstPeer(n *burstNotices, p *burstPeer) { |
| } |
| } |
| +// burstPeerCurrent reports whether p is still one of this box's notice |
| +// peers in the home map as it stands now, pruning every peer that is not. |
| +// A box that left the edges files, stopped advertising notices or lost its |
| +// dial address is otherwise pruned only on the next trip, so a notice |
| +// queued for it, or waiting for a slot in the budget, would still be sent |
| +// to it (#491 follow-up). Checked before every slot is taken, so a dropped |
| +// notice never spends one. |
| +func (e *Edge) burstPeerCurrent(n *burstNotices, p *burstPeer) bool { |
| + m := e.homes.Load() |
| + if m == nil { |
| + return false |
| + } |
| + // The snapshot is read under n.mu, as sendBurstNotices reads it, so a |
| + // worker can never prune with a map older than the one a newer peer was |
| + // created from (Astra R1 P2). |
| + n.mu.Lock() |
| + defer n.mu.Unlock() |
| + n.pruneLocked(n.targetsLocked(m.snapshot(), e.box, m.privateDial)) |
| + return n.peers[p.box] == p |
| +} |
| + |
| // retire removes an idle peer, unless a notice arrived for it meanwhile. |
| func (n *burstNotices) retire(p *burstPeer) bool { |
| n.mu.Lock() |
| @@ -405,6 +426,11 @@ func (n *burstNotices) retire(p *burstPeer) bool { |
| func (e *Edge) dispatchBurstNotice(n *burstNotices, p *burstPeer, nt burstNotice) { |
| var at time.Time |
| for { |
| + if !e.burstPeerCurrent(n, p) { |
| + n.count(func(s *burstNoticeStats) { s.Gone++ }) |
| + e.logThrottled("burst-notice-gone", fmt.Sprintf("probe-burst notice to %s dropped: the box left the edges files", p.box)) |
| + return |
| + } |
| now := e.burstNow() |
| if now.Sub(nt.trip) > burstNoticeMaxAge || !nt.until.After(now) { |
| n.count(func(s *burstNoticeStats) { s.Stale++ }) |
diff --git a/internal/edge/burst_notice_test.go b/internal/edge/burst_notice_test.go| index 2f578afae..ad07e8706 100644 |
| --- a/internal/edge/burst_notice_test.go |
| +++ b/internal/edge/burst_notice_test.go |
| @@ -3,6 +3,7 @@ package edge |
| import ( |
| "bufio" |
| "bytes" |
| + "cmp" |
| "context" |
| "crypto/rand" |
| "crypto/tls" |
| @@ -309,9 +310,19 @@ func transmitted(x *noticeEdge) int64 { |
| } |
| // A client that trips on annie is refused on betty, on betty's own app, |
| -// with the record saying the cool-down started on another app. |
| +// with the record saying the cool-down started on another app: in block |
| +// mode, and in the default mode since the promotion (#491). |
| func TestBurstNoticeAppliesOnThePeer(t *testing.T) { |
| - s := newNoticeScene(t, true) |
| + for _, protect := range []string{"block", ""} { |
| + t.Run("mode "+cmp.Or(protect, "default"), func(t *testing.T) { |
| + s := newNoticeScene(t, true) |
| + t.Setenv("CARLOS_EDGE_PROTECT", protect) |
| + burstNoticeAppliesOnThePeer(t, s) |
| + }) |
| + } |
| +} |
| + |
| +func burstNoticeAppliesOnThePeer(t *testing.T, s *noticeScene) { |
| a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "bdk", "shop", true) |
| b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "bab", "blog", true) |
| s.publish(t) |
| @@ -542,6 +553,111 @@ func TestBurstNoticeOnlyToAdvertisingPeers(t *testing.T) { |
| } |
| } |
| +// #491 follow-up: a peer that leaves while a notice for it waits for a slot |
| +// in the budget is dropped at dispatch, not sent once the slot frees, and |
| +// its worker stops then rather than on the next trip. A peer that stayed |
| +// still gets its notice. |
| +func TestBurstNoticeDepartedPeerStopsAtDispatch(t *testing.T) { |
| + s := newNoticeScene(t, true) |
| + a := s.add(t, "annie", "127.0.0.11", "shop.example.com", "bdk", "shop", true) |
| + b := s.add(t, "betty", "127.0.0.12", "blog.example.com", "bab", "blog", true) |
| + c := s.add(t, "carol", "127.0.0.13", "docs.example.com", "bab", "docs", true) |
| + s.publish(t) |
| + stats := func() burstNoticeStats { return a.edge().notices.stats() } |
| + peers := func() int { |
| + n := a.edge().notices |
| + n.mu.Lock() |
| + defer n.mu.Unlock() |
| + return len(n.peers) |
| + } |
| + |
| + // 60 trips 50 s in use the whole budget; one more 105 s in waits for the |
| + // slots that free at 110 s, one notice per peer. |
| + s.clock.advance(50 * time.Second) |
| + for i := range 60 { |
| + s.trip(t, a, noticeClient(i)) |
| + } |
| + waitFor(t, 10*time.Second, "120 notices sent", func() bool { return stats().Sent == 120 }) |
| + s.clock.advance(55 * time.Second) |
| + s.trip(t, a, noticeClient(60)) |
| + time.Sleep(300 * time.Millisecond) |
| + if st := stats(); st.Sent != 120 || st.Gone != 0 || peers() != 2 { |
| + t.Fatalf("counts %+v, %d peers while two notices wait for a slot", st, peers()) |
| + } |
| + |
| + // Betty stops advertising notices while hers waits. |
| + b.file.advertise = false |
| + s.publish(t) |
| + s.clock.advance(5*time.Second + 100*time.Millisecond) |
| + waitFor(t, 5*time.Second, "carol's notice sent and betty's dropped", func() bool { |
| + st := stats() |
| + return st.Sent == 121 && st.Gone == 1 |
| + }) |
| + if n := len(b.arrivals()); n != 60 { |
| + t.Fatalf("betty saw %d notices, want the 60 sent before she left", n) |
| + } |
| + if n := len(c.arrivals()); n != 61 { |
| + t.Fatalf("carol saw %d notices, want 61", n) |
| + } |
| + waitFor(t, 5*time.Second, "betty's worker gone", func() bool { return peers() == 1 }) |
| +} |
| + |
| +// Astra R1 P2: a worker checking its peer never prunes with a home map |
| +// older than the one a newer peer was created from. The worker waits on |
| +// n.mu while sendBurstNotices, holding it, sees betty arrive in a newer |
| +// snapshot and creates her peer; once the worker has the lock, betty stays. |
| +// With the snapshot read before the lock the worker would prune her. |
| +func TestBurstPeerCurrentNeverPrunesWithAnOlderSnapshot(t *testing.T) { |
| + file := func(box, eip, host string) edgesFileView { |
| + return edgesFileView{V: 1, Box: box, EIP: eip, BurstNotices: true, Hosts: map[string]edgesHostView{host: {Role: "home"}}} |
| + } |
| + annie, betty, carol := file("annie", "192.0.2.11", "shop.example.com"), file("betty", "192.0.2.12", "blog.example.com"), file("carol", "192.0.2.13", "docs.example.com") |
| + m := &homeMap{snap: &homeSnapshot{read: true, files: map[string]edgesFileView{ |
| + "control/edges/annie.json": annie, "control/edges/carol.json": carol, |
| + }}} |
| + e := &Edge{box: "annie"} |
| + e.homes.Store(m) |
| + n := newBurstNotices() |
| + peer := func(box string) *burstPeer { |
| + return &burstPeer{box: box, q: make(chan burstNotice, 1), stop: make(chan struct{})} |
| + } |
| + carolPeer := peer("carol") |
| + n.peers["carol"] = carolPeer |
| + |
| + n.mu.Lock() |
| + done := make(chan bool, 1) |
| + go func() { done <- e.burstPeerCurrent(n, carolPeer) }() |
| + // Long enough for the worker to reach the lock (and, read in the old |
| + // order, the snapshot without betty). |
| + time.Sleep(200 * time.Millisecond) |
| + m.mu.Lock() |
| + m.snap = &homeSnapshot{read: true, files: map[string]edgesFileView{ |
| + "control/edges/annie.json": annie, "control/edges/betty.json": betty, "control/edges/carol.json": carol, |
| + }} |
| + m.mu.Unlock() |
| + targets := n.targetsLocked(m.snapshot(), e.box, false) |
| + if len(targets) != 2 { |
| + t.Fatalf("targets %+v, want betty and carol", targets) |
| + } |
| + bettyPeer := peer("betty") |
| + n.peers["betty"] = bettyPeer |
| + n.mu.Unlock() |
| + |
| + if !<-done { |
| + t.Fatal("carol, still a peer, was reported gone") |
| + } |
| + n.mu.Lock() |
| + defer n.mu.Unlock() |
| + if n.peers["betty"] != bettyPeer { |
| + t.Fatal("betty's new peer was pruned with the older snapshot") |
| + } |
| + select { |
| + case <-bettyPeer.stop: |
| + t.Fatal("betty's worker was stopped") |
| + default: |
| + } |
| +} |
| + |
| // R3-2: the budget is taken at dispatch, over any 60 s and not per |
| // calendar minute, and a notice that cannot be sent within 10 s of its |
| // trip is dropped and counted. |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index f6fc9eadb..4f47d2618 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -343,7 +343,7 @@ type Edge struct { |
| // guard is CARLOS_EDGE_PROTECT, read once in New: what the edge does |
| // with a request matching a hard or probe rule (guard.go). By default |
| // each rule's own mode: from catalogue version 2 the hard tier blocks |
| - // and the probe tier watches. |
| + // and the probe tier watches; the probe-burst rule blocks (#491). |
| guard guardMode |
| // guardMint is mintRef, bound once in New: a method value taken per |
| // request would allocate for every guarded request, and most never |
diff --git a/internal/edge/guard.go b/internal/edge/guard.go| index 268ec02d7..8d6ce9961 100644 |
| --- a/internal/edge/guard.go |
| +++ b/internal/edge/guard.go |
| @@ -23,8 +23,9 @@ type guardMode uint8 |
| const ( |
| // guardCatalogue, the default, does what each rule's own mode says. From |
| // catalogue version 2 the hard tier blocks; the probe tier watches and |
| - // the burst rule counts, so their matches are recorded with the app's |
| - // answer. |
| + // its burst-mode rules count, so their matches are recorded with the |
| + // app's answer. The probe-burst rule (edgeguard.BurstRule) blocks since |
| + // its calibration review (#491): a cooling client is refused. |
| guardCatalogue guardMode = iota |
| // guardOff runs no check at all. |
| guardOff |
| @@ -293,11 +294,31 @@ func burstNotFound(status int, v *guardVerdict) bool { |
| return v.rule.Tier == reqrec.TierHard || v.rule.Tier == reqrec.TierProbe |
| } |
| +// burstIconPath reports whether path names a site icon that link-preview |
| +// fetchers, monitors and home-screen shortcuts ask for on their own: |
| +// favicon.ico or favicon.png/.svg, favicon-*.png, and apple-touch-icon*.png, |
| +// in any directory, any case. A miss on one never counts toward a trip |
| +// (Paul, #491 calibration, 2026-11-14): on 2026-11-13 a fetcher tripped four |
| +// times on one app collecting nothing but missing icons. A scanner gains |
| +// nothing from it, since an icon is never a catalogue path. |
| +func burstIconPath(path string) bool { |
| + name := strings.ToLower(path[strings.LastIndexByte(path, '/')+1:]) |
| + switch name { |
| + case "favicon.ico", "favicon.png", "favicon.svg": |
| + return true |
| + } |
| + if strings.HasPrefix(name, "favicon-") && strings.HasSuffix(name, ".png") { |
| + return true |
| + } |
| + return strings.HasPrefix(name, "apple-touch-icon") && strings.HasSuffix(name, ".png") |
| +} |
| + |
| // noteBurst counts one answered request toward the probe-burst limit, from |
| // the observer defer of the box that saw the visitor's own headers: a |
| // request the guard ran for, that no browser sent (every current browser |
| // sends Sec-Fetch-Mode on every request, scanners do not), and that is a |
| -// not-found by burstNotFound. A far edge's asset fill this box acknowledged |
| +// not-found by burstNotFound, and not a missing site icon (burstIconPath). |
| +// A far edge's asset fill this box acknowledged |
| // is the far edge's to count. On a trip it mints the trip's code once, |
| // files the trip record and tells the other edges. |
| func (e *Edge) noteBurst(rt registry.Route, r *http.Request, status int, out *outcome) { |
| @@ -310,6 +331,9 @@ func (e *Edge) noteBurst(rt registry.Route, r *http.Request, status int, out *ou |
| if !burstNotFound(status, out.guard.verdict) { |
| return |
| } |
| + if out.guard.verdict == nil && burstIconPath(r.URL.Path) { |
| + return |
| + } |
| if _, browser := r.Header["Sec-Fetch-Mode"]; browser { |
| return |
| } |
diff --git a/internal/edgeguard/catalogue.go b/internal/edgeguard/catalogue.go| index 111686ca5..5ade98fec 100644 |
| --- a/internal/edgeguard/catalogue.go |
| +++ b/internal/edgeguard/catalogue.go |
| @@ -116,8 +116,11 @@ var ( |
| // it, because the cool-down is about the client, and the edge decides it |
| // beside Check rather than through it. It is here so a record or a |
| // reference code that names it is explained like any other rule (RuleByID, |
| -// RuleByHash). Its mode is watch until blocking is approved. |
| -var BurstRule = &Rule{ID: reqrec.BurstRuleID, Group: "probe-burst", Tier: reqrec.TierBurst, Mode: ModeWatch} |
| +// RuleByHash). It blocks: a client in a cool-down is refused the catalogue |
| +// paths the app is not known to serve, wherever the cool-down started. It |
| +// watched from release until the calibration review (#491); an app's |
| +// record-only switch still turns it off for that app. |
| +var BurstRule = &Rule{ID: reqrec.BurstRuleID, Group: "probe-burst", Tier: reqrec.TierBurst, Mode: ModeBlock} |
| var burstRuleHash = reqrec.RuleHash(BurstRule.ID) |
diff --git a/internal/edgeguard/catalogue_test.go b/internal/edgeguard/catalogue_test.go| index 792703b1d..305f9aee6 100644 |
| --- a/internal/edgeguard/catalogue_test.go |
| +++ b/internal/edgeguard/catalogue_test.go |
| @@ -155,7 +155,7 @@ func TestParseAccepts(t *testing.T) { |
| // ever matches it, because a cool-down is about the client, not the request. |
| func TestBurstRuleLookups(t *testing.T) { |
| r := BurstRule |
| - if r.ID != "burst.probe-burst.cooldown" || r.Group != "probe-burst" || r.Tier != reqrec.TierBurst || r.Mode != ModeWatch { |
| + if r.ID != "burst.probe-burst.cooldown" || r.Group != "probe-burst" || r.Tier != reqrec.TierBurst || r.Mode != ModeBlock { |
| t.Fatalf("BurstRule = %+v", *r) |
| } |
| if got, ok := RuleByID(r.ID); !ok || got != r { |
diff --git a/internal/host/movesoffline.go b/internal/host/movesoffline.go| index 0859e78b7..28e01b56d 100644 |
| --- a/internal/host/movesoffline.go |
| +++ b/internal/host/movesoffline.go |
| @@ -421,7 +421,7 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro |
| } |
| here := cfg.parkRegion() |
| source := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.From, here) |
| - target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here) |
| + target := here != "" && regionname.PlacementMatches(cfg.ParkHomeRegion, m.To, here) && cfg.offlineTargetHere(rec) |
| sealer := cfg.Box != "" && cfg.Box == m.Sealer |
| if !cfg.OfflineCapable { |
| if source || target || sealer { |
| @@ -450,6 +450,16 @@ func (w *movesWorker) offlineRound(ctx context.Context, s release.Store, rec pro |
| return errors.Join(errs...) |
| } |
| +// offlineTargetHere says whether this box, in the region the move goes to, |
| +// can be the move's target (amadan #413): its pools admit the record. A box |
| +// whose pools do not never gets the row from reconcile, so it writes no |
| +// target report and lands nothing. The console counts a target report only |
| +// from a box its edges file says can hold the row, so this is the box's own |
| +// half of the same rule, and it reads nothing from the record but the pool. |
| +func (c moveCfg) offlineTargetHere(rec provision.Record) bool { |
| + return c.OfflinePools.Serves(rec.Pool) |
| +} |
| + |
| // offlineReassertEvery is how often a box that takes part in an offline move |
| // rewrites the reports a door judges by age (harness Run 9, finding 7). The |
| // doors believe a report for two minutes (offlineReportFresh, internal/ |
diff --git a/internal/host/movesoffline_e2e_test.go b/internal/host/movesoffline_e2e_test.go| index 9c9a1a831..6491aaf69 100644 |
| --- a/internal/host/movesoffline_e2e_test.go |
| +++ b/internal/host/movesoffline_e2e_test.go |
| @@ -214,6 +214,18 @@ type e2eWorld struct { |
| srcFiles, srcEnv, cfg string |
| srcTimers map[string]registry.Timer |
| rows int |
| + // pool is uk-pool when the world has one (landOpts.poolBox): a box in |
| + // uk that serves only cohort1, ticked beside the others. |
| + pool *offBox |
| +} |
| + |
| +// boxes are the world's boxes in the order they tick. |
| +func (w *e2eWorld) boxes() []*offBox { |
| + out := []*offBox{w.ie, w.uk} |
| + if w.pool != nil { |
| + out = append(out, w.pool) |
| + } |
| + return out |
| } |
| func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| @@ -342,6 +354,10 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| lw.ukEB = &activator.ExecBackend{ServedPools: testSharedPoolEvidence, DataDir: lw.uk.dd, OptDir: lw.uk.opt, Region: "uk"} |
| lw.arm(lw.uk) |
| w := &e2eWorld{landWorld: lw, t: t, rs: rs, base: ts.URL + "/api/cli/apps/" + wd.acct + "/app/instances/" + offHost + "/move/offline", token: token} |
| + if opts.poolBox { |
| + w.pool = sw.box("uk-pool", "uk", map[string]string{"CARLOS_HIBERNATE_BUCKET": sealUK, "CARLOS_SECRETS_KEY": keyB64, |
| + "CARLOS_HIBERNATE_REGION": sealUKRegion, "CARLOS_RELEASE_PUBKEY": pubB64, "CARLOS_POOLS": "cohort1"}) |
| + } |
| // The source box's production build-state carry, and each box's launch |
| // composer under its own agent environment. |
| @@ -395,6 +411,8 @@ func newE2EWorld(t *testing.T, opts landOpts) *e2eWorld { |
| // probe (offlineMoveFactsProbe, #339), with the box's worker armed for the |
| // call, under the box's name. The loop's assignment is checked first |
| // (requireStatusLoopReportsOfflineFacts), so the snapshots are the loop's. |
| +// Every box reports, the pool box among them (#413), since the console's |
| +// fleet read sees all of them. |
| func (w *e2eWorld) reportStatus() { |
| w.t.Helper() |
| requireStatusLoopReportsOfflineFacts(w.t) |
| @@ -403,7 +421,7 @@ func (w *e2eWorld) reportStatus() { |
| } |
| prev := armedMovesWorker.Load() |
| defer armedMovesWorker.Store(prev) |
| - for _, b := range []*offBox{w.ie, w.uk} { |
| + for _, b := range w.boxes() { |
| routes, err := b.reg.List() |
| if err != nil { |
| w.t.Fatal(err) |
| @@ -511,8 +529,9 @@ func (w *e2eWorld) setBoxClock(at time.Time) { |
| func (w *e2eWorld) tickAll() { |
| w.t.Helper() |
| - w.tick(w.ie) |
| - w.tick(w.uk) |
| + for _, b := range w.boxes() { |
| + w.tick(b) |
| + } |
| } |
| // door posts to one of the doors (verb "" is start). |
| @@ -1172,6 +1191,10 @@ func TestOfflineMoveE2E(t *testing.T) { |
| // minutes of belief in a report. |
| t.Run("doors back to back", func(t *testing.T) { offlineMoveDoorsApart(t, 0) }) |
| t.Run("doors three minutes apart", func(t *testing.T) { offlineMoveDoorsApart(t, 3*time.Minute) }) |
| + // amadan #413, seen on dev 2026-10-26: uk also holds a box that serves |
| + // only a named pool. Reconcile never gives it the row, so it must not |
| + // report as the target, and no step may wait on it. |
| + t.Run("a pool box beside the target", func(t *testing.T) { offlineMoveDone(t, landOpts{poolBox: true}) }) |
| // #339: a stale live link that failed a move only after the instance |
| // was offline is refused by stage and start, from the target box's own |
| // status report. |
| @@ -1245,7 +1268,7 @@ type e2eLoops struct { |
| func (w *e2eWorld) loops() *e2eLoops { |
| l := &e2eLoops{w: w, fast: map[*offBox]*fastDeps{}, tickAt: time.Now()} |
| - for _, b := range []*offBox{w.ie, w.uk} { |
| + for _, b := range w.boxes() { |
| // The sweep's registry is empty: the sweep stages releases and is |
| // not what this test is about. The serial leg is. |
| l.fast[b] = &fastDeps{reg: restartTestRegistry(w.t), store: w.rs, fullPass: func(context.Context) { |
| @@ -1261,7 +1284,7 @@ func (w *e2eWorld) loops() *e2eLoops { |
| func (l *e2eLoops) round() bool { |
| before := l.passes |
| l.tickAt = l.tickAt.Add(fastFullClamp + time.Second) |
| - for _, b := range []*offBox{l.w.ie, l.w.uk} { |
| + for _, b := range l.w.boxes() { |
| fastTick(context.Background(), l.fast[b], l.tickAt) |
| } |
| return l.passes > before |
| @@ -1295,7 +1318,7 @@ func (l *e2eLoops) after(gap time.Duration) { |
| func (l *e2eLoops) reassert(at time.Time) { |
| l.w.setBoxClock(at) |
| - for _, b := range []*offBox{l.w.ie, l.w.uk} { |
| + for _, b := range l.w.boxes() { |
| b.w.offlineReassert(context.Background(), l.w.rs) |
| } |
| l.again++ |
| @@ -1420,6 +1443,14 @@ func offlineMoveDone(t *testing.T, opts landOpts) { |
| if r := w.wd.reportFor(w.id, moves.OfflineRoleTarget, "uk-box"); !r.Items["env-pin"].OK { |
| t.Fatalf("env-pin across the two agent environments: %+v", r.Items["env-pin"]) |
| } |
| + if w.pool != nil { |
| + if rt := w.pool.row(offHost); rt != nil { |
| + t.Fatalf("uk-pool holds a row for the host: %+v", rt) |
| + } |
| + if _, _, err := w.wd.s.Get(ctx, moves.OfflineReportKey(offHost, w.id, moves.OfflineRoleTarget, "uk-pool")); !errors.Is(err, os.ErrNotExist) { |
| + t.Fatalf("uk-pool reported as a target: %v", err) |
| + } |
| + } |
| w.requireStopped("after the landing") |
| w.open() |
| if opts.lifetime { |
diff --git a/internal/host/movesoffline_land_test.go b/internal/host/movesoffline_land_test.go| index 3954d3c2e..615d1a324 100644 |
| --- a/internal/host/movesoffline_land_test.go |
| +++ b/internal/host/movesoffline_land_test.go |
| @@ -93,6 +93,10 @@ type landOpts struct { |
| // incarnation creates the record at that incarnation with no slot, as |
| // a claims-on box (no judge) sees one; only without judged or lifetime. |
| incarnation uint64 |
| + // poolBox adds uk-pool beside uk-box in uk, a capable box that serves |
| + // only the named pool cohort1 (CARLOS_POOLS=cohort1), as leo did on dev |
| + // (amadan #413). Only the end-to-end world reads it. |
| + poolBox bool |
| } |
| // landWorld is offHost at home (ie-a, data-ie) moving to uk (uk-box, |
diff --git a/internal/host/movesoffline_test.go b/internal/host/movesoffline_test.go| index 73d84ec62..19ba781bf 100644 |
| --- a/internal/host/movesoffline_test.go |
| +++ b/internal/host/movesoffline_test.go |
| @@ -215,7 +215,7 @@ func (b *offBox) restart() { |
| func (b *offBox) reconcile() { |
| b.wd.t.Helper() |
| - cfg := provision.ReconcileConfig{Region: b.region, DataDir: b.dd, Judge: b.wd.judge} |
| + cfg := provision.ReconcileConfig{Region: b.region, Pools: provision.ParseBoxPools(b.getenv("CARLOS_POOLS")), DataDir: b.dd, Judge: b.wd.judge} |
| if b.nested { |
| cfg.Layout = func(context.Context, release.Store) (string, error) { return release.LayoutModeNested, nil } |
| } else { |
| @@ -285,6 +285,43 @@ func writeFile(t *testing.T, p, body string) { |
| // --- the hold --------------------------------------------------------------- |
| +// amadan #413: in the region a move goes to, a box takes the target role |
| +// only when its pools admit the record. armOffline reads the pools from |
| +// CARLOS_POOLS the way reconcile does, so a box serving only cohort1 (leo on |
| +// dev) never lands a shared-pool record nor reports for it. |
| +func TestOfflineTargetIsABoxThatCanHoldTheRow(t *testing.T) { |
| + armed := func(pools string) moveCfg { |
| + cfg := moveCfg{Region: "uk", Box: "uk-box"} |
| + armOffline(&cfg, t.TempDir(), nil, nil, nil, hostwrite.Config{}, func(k string) string { |
| + switch k { |
| + case "CARLOS_POOLS": |
| + return pools |
| + case "CARLOS_HIBERNATE_BUCKET": |
| + return "data-uk" |
| + } |
| + return "" |
| + }) |
| + return cfg |
| + } |
| + rec := provision.Record{Host: offHost, Region: "uk", Move: &provision.MoveState{Kind: provision.MoveKindOffline, ID: offID, To: "uk", State: provision.OfflineLanding}} |
| + for _, c := range []struct { |
| + name string |
| + cfg moveCfg |
| + want bool |
| + }{ |
| + {"a shared box", armed(""), true}, |
| + {"a box serving the shared pool beside a named one", armed("@shared,cohort1"), true}, |
| + {"a box serving only a named pool", armed("cohort1"), false}, |
| + {"a box with no pools armed", moveCfg{Region: "uk", Box: "uk-box"}, false}, |
| + } { |
| + t.Run(c.name, func(t *testing.T) { |
| + if got := c.cfg.offlineTargetHere(rec); got != c.want { |
| + t.Fatalf("offlineTargetHere = %v, want %v", got, c.want) |
| + } |
| + }) |
| + } |
| +} |
| + |
| // offlineHold's table: a pure function of the record and the box's |
| // placement. The home's "" and a named region; every state. |
| func TestOfflineHoldIsAFunctionOfTheRecord(t *testing.T) { |
diff --git a/internal/host/movespass.go b/internal/host/movespass.go| index c74154783..d4f2fe74b 100644 |
| --- a/internal/host/movespass.go |
| +++ b/internal/host/movespass.go |
| @@ -22,6 +22,7 @@ import ( |
| "github.com/carlosframework/platform/internal/cgroup" |
| "github.com/carlosframework/platform/internal/controlsock" |
| "github.com/carlosframework/platform/internal/dbverify" |
| + "github.com/carlosframework/platform/internal/edgesfile" |
| "github.com/carlosframework/platform/internal/hostbox" |
| "github.com/carlosframework/platform/internal/hostclaim" |
| "github.com/carlosframework/platform/internal/hostguard" |
| @@ -365,6 +366,7 @@ func armMovesPass(hib activator.Config, dataDir string, reg *registry.Registry, |
| // for a record with an offline move. |
| func armOffline(cfg *moveCfg, dataDir string, reg *registry.Registry, svc *activator.Service, eb *activator.ExecBackend, writes hostwrite.Config, getenv func(string) string) { |
| cfg.OfflineCapable = offlineCapable(getenv, hibernationConfigured(getenv)) |
| + cfg.OfflinePools = provision.ReconcileConfig{Pools: provision.ParseBoxPools(getenv("CARLOS_POOLS"))}.ServedPools() |
| cfg.Offline = newOfflineView(*cfg, holdStageRequester(dataDir)) |
| if svc != nil { |
| cfg.FenceAs = fenceAsWith(svc) |
| @@ -1009,6 +1011,12 @@ type moveCfg struct { |
| // keep view reconcile reads (offlineView.keep); the hold needs none. |
| OfflineCapable bool |
| Offline *offlineView |
| + // OfflinePools are the pools this box serves, from CARLOS_POOLS through |
| + // provision.ParseBoxPools, the parse reconcile and the edges file use. |
| + // A box whose pools do not admit a record never takes the target role |
| + // for it (offlineTargetHere): reconcile never gives it the row. Nil |
| + // serves no pool. |
| + OfflinePools edgesfile.PoolEvidence |
| // FenceAs installs, or meets again, an owned activator fence |
| // (activator.Service.FenceAndStopAs under a 2 s deadline, |
| // ErrStopUnproven counted as installed: fenceAsWith); LiftFenceAs lifts |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 8816bc7b6..6d8cedae7 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -211,4 +211,6 @@ plan14-root-reads-g6-fence.tsv 3f43afa4b0c18ad678a952b48b511e74e849992cd629b9aa1 |
| plan14-root-reads-offline-move-stage-refusals-339.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332 |
| plan14-root-reads-fleet-tunnel-tls-state.tsv 846d1f22e6eb6b2cd8b3086fa554f15deba70418c6542b46b2e2a6a138b6c332 |
| plan14-root-reads-replica-console-account.tsv 87e151a55efb12fb84e9c5939f2ead9058527d8213e2eb16ee6c0f109787bb16 |
| -plan14-root-reads-platform-mail-submission.tsv b782f324a4791147024602f46ab73eab48a589ae3ab9a5035d56a722c92da50e |
| +plan14-root-reads-offline-move-pool-target-413.tsv f79b455e32eb0f63e19ba8b5c67129e1af9315b8650c9e0807e83ec630a82182 |
| +plan14-root-reads-probe-burst-block.tsv 94ccbabaf19c3a449cec248a0c32fcc8593c82d3f7f433c6a48b6e0fdf068167 |
| +plan14-root-reads-platform-mail-submission.tsv 3439e77fb7ba7bc8b772706d57fb907c998814e42b0c5a2f45ef2c0fa97d74e4 |
diff --git a/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv| new file mode 100644 |
| index 000000000..9b1ce2106 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-offline-move-pool-target-413.tsv |
| @@ -0,0 +1,5 @@ |
| +# Census overlay offline-move-pool-target-413, written by census-propose (#369). census-ruling-offline-move-pool-target-413, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-offline-move-pool-target-413.md. |
| +# 1 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy 1c7bd4ba117b1b09a161422e9344a24460fddd7418477fdca993d513254791b3 internal/host/movespass.go armOffline legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7;rev3=census-ruling-offline-move-pool-target-413;basis=sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added whole:Route@2258 9a021c1f9794e1e55b785db0117059bb5e1d0775286d914ce155b7eb01b259dd |
| +internal/host/movespass.go armOffline legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=root-route (J1, as main's moves units); the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): census-ruling-moves-offline's body, which also arms moveCfg.ReleaseHoldSeq (releaseHeldSeq over the registry, touching the stage-requested marker after a release that landed); closes over the registry and reads nothing itself; self-serve moves 1 Task 7;rev3=census-ruling-offline-move-pool-target-413;basis=sets moveCfg.OfflinePools from CARLOS_POOLS through provision.ParseBoxPools (an env string the agent already reads for reconcile; no file read), so offlineTargetHere keeps a box whose pools do not admit the record out of the offline target role (amadan #413); no read added whole:Route@2258 9a021c1f9794e1e55b785db0117059bb5e1d0775286d914ce155b7eb01b259dd |
| +@coverage internal/host 3b9380676b3e427ba4cb36e74310831fe635e65e80b91929c73daa7ef31a54fe |
diff --git a/internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv b/internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv| index bb9708d43..aeece6937 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-platform-mail-submission.tsv |
| @@ -90,7 +90,7 @@ internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-self-serve- |
| @coverage infra/modules/region-host d1a978ca67367880d0940ae7aa460f311addd4335c196a279d86caa6fe1e1721 |
| @coverage infra/modules/region-host/tests 1aa5c549b79e7d8b19a266a2aeae8e4e2bb22b40072f36362da95bcf2c439a07 |
| @coverage internal/activator 457bc68060d4b9293294bd27cce112ca64946b1b45779e4afe61616a0f8a0d4f |
| -@coverage internal/host 2635ff930ef387fefe663ccd44c2b550f9f8d2e9669a45186e13d97fef177411 |
| +@coverage internal/host d32e924772a9f80dd03d0d4b48789841ad0f42c4c54cdbcfb5902a6f9d2ba84c |
| @coverage internal/host/demo_units 3a34238356068c6176879f3ee189c81af8e08bfcc0246c5feba80d7169f7af6a |
| @coverage internal/host/units 63a333f0bb4a354fdde9802089f4ec6794cdfbf774c20fbd48cffab805cd022c |
| @coverage internal/hostenv 6c96c4abe8548fe3cf12d3a220de3e2917c3edfa5320b1662ea76bdf364d24b5 |
diff --git a/internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv b/internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv| new file mode 100644 |
| index 000000000..415f6fb6c |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-probe-burst-block.tsv |
| @@ -0,0 +1,6 @@ |
| +# Census overlay probe-burst-block, written by census-propose (#369). census-ruling-probe-burst-block, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-probe-burst-block.md. |
| +# 1 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy ed0009717059de6de9cd99d188bcac56ec8a873d8910bb8821fe7cb3fea29815 internal/edge/guard.go Edge.noteBurst legacy accepted-legacy accepted-legacy;rev3=census-ruling-probe-burst-limit;basis=new: in the observer defer, counts a not-found (a 404, or a hard or probe match) from a non-browser client (no Sec-Fetch-Mode) toward the in-memory probe-burst limiter, keyed by the route's account/app; on a trip mints a reference code, files a Trip record into the in-memory recorder and queues notices to peer edges; the sites are the route value passed in; reads no file, store or registry; no new root read or write kind;rev3=census-ruling-agent-start-demo-log-skip;basis=skips only the in-memory Trip record when demoUnrecorded(rt, r); cooling, the limiter and peer notices are unchanged; no new read;rev3=census-ruling-probe-burst-block;basis=after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts whole:Route@574,whole:Route@742,whole:Route@800 922524dfba524388e85449817d024288a23f775c6bd5ccdb4b1a3fd47a5bcd9b |
| +internal/edge/guard.go Edge.noteBurst legacy accepted-legacy accepted-legacy;rev3=census-ruling-probe-burst-limit;basis=new: in the observer defer, counts a not-found (a 404, or a hard or probe match) from a non-browser client (no Sec-Fetch-Mode) toward the in-memory probe-burst limiter, keyed by the route's account/app; on a trip mints a reference code, files a Trip record into the in-memory recorder and queues notices to peer edges; the sites are the route value passed in; reads no file, store or registry; no new root read or write kind;rev3=census-ruling-agent-start-demo-log-skip;basis=skips only the in-memory Trip record when demoUnrecorded(rt, r); cooling, the limiter and peer notices are unchanged; no new read;rev3=census-ruling-probe-burst-block;basis=after the not-found check, returns early (counts nothing) when the request matched no rule and its path names a site icon (burstIconPath: favicon.ico/.png/.svg, favicon-*.png, apple-touch-icon*.png, a pure string test on r.URL.Path); no new read, no file or store access, only fewer counts whole:Route@574,whole:Route@742,whole:Route@800 922524dfba524388e85449817d024288a23f775c6bd5ccdb4b1a3fd47a5bcd9b |
| +@coverage internal/edge 46e4db369a9df88989104adffc0a3a13833d4c3397c41e276d37b6d358d308ce |
| +@coverage internal/edgeguard a26fa6f359b091151c8df59275bccd02cd2621686f40c4164f48f7155ac16895 |
diff --git a/offline_move_e2e_test.go b/offline_move_e2e_test.go| index 7cc471e29..1c7125041 100644 |
| --- a/offline_move_e2e_test.go |
| +++ b/offline_move_e2e_test.go |
| @@ -32,6 +32,9 @@ type offlineE2E struct { |
| put func(id, box, role, phase string, edit func(*moves.OfflineReport)) |
| // srv is the real console, for a test that reads its region names. |
| srv *console.Server |
| + // publish writes one more box's edges file and status snapshot; |
| + // shared false is a box that serves only a named pool. |
| + publish func(box, placement, aws, bucket string, shared bool) |
| } |
| func newOfflineE2E(t *testing.T, caps []string) *offlineE2E { |
| @@ -109,23 +112,23 @@ func newOfflineE2E(t *testing.T, caps []string) *offlineE2E { |
| if res.StatusCode != http.StatusCreated { |
| t.Fatalf("create the instance = %d", res.StatusCode) |
| } |
| - for _, b := range []struct{ box, placement, aws, bucket string }{ |
| - {"ie-box", "ie", "eu-west-1", "data-ie"}, |
| - {"uk-box", "uk", "eu-west-2", "data-uk"}, |
| - } { |
| + publish := func(box, placement, aws, bucket string, shared bool) { |
| + t.Helper() |
| body, _ := json.Marshal(map[string]any{ |
| - "v": 1, "box": b.box, "box_id": b.box, "eip": "1.2.3.4", "region": b.aws, "placement": b.placement, |
| - "data_bucket": b.bucket, "hibernation_configured": true, "serves_shared_pool": true, |
| + "v": 1, "box": box, "box_id": box, "eip": "1.2.3.4", "region": aws, "placement": placement, |
| + "data_bucket": bucket, "hibernation_configured": true, "serves_shared_pool": shared, |
| "accepts_inbound": true, "secrets_key_fp": fp, |
| "capabilities": caps, "hosts": map[string]any{}, |
| }) |
| - if _, err := rel.Put(ctx, "control/edges/"+b.box+".json", body, ""); err != nil { |
| + if _, err := rel.Put(ctx, "control/edges/"+box+".json", body, ""); err != nil { |
| t.Fatal(err) |
| } |
| - if err := status.WriteBox(ctx, rel, status.Box{Label: b.box, GeneratedAt: time.Now(), Metrics: &status.BoxMetrics{}}); err != nil { |
| + if err := status.WriteBox(ctx, rel, status.Box{Label: box, GeneratedAt: time.Now(), Metrics: &status.BoxMetrics{}}); err != nil { |
| t.Fatal(err) |
| } |
| } |
| + publish("ie-box", "ie", "eu-west-1", "data-ie", true) |
| + publish("uk-box", "uk", "eu-west-2", "data-uk", true) |
| run := func(c context.Context, args ...string) (int, string) { |
| var out bytes.Buffer |
| @@ -158,7 +161,7 @@ func newOfflineE2E(t *testing.T, caps []string) *offlineE2E { |
| } |
| } |
| - return &offlineE2E{host: host, rel: rel, run: run, put: put, srv: srv} |
| + return &offlineE2E{host: host, rel: rel, run: run, put: put, srv: srv, publish: publish} |
| } |
| // TestMoveOfflineAgainstTheRealDoors drives `carlos move offline start` and |
| @@ -383,3 +386,100 @@ func TestMoveOfflineNamesRegionsThroughTheRealDoors(t *testing.T) { |
| cancel() |
| <-done |
| } |
| + |
| +// TestMoveOfflineFlipStepsOverAPoolBox (amadan #413, Astra round 1 finding |
| +// 2): uk also holds uk-a-pool, a box that serves only a named pool, and its |
| +// target report says it failed (it never gets the row). Through moveMain |
| +// against the real console, flip follows the landing past that report to |
| +// next == open and exits 0, and status says the move is ready to open: the |
| +// console returns only the reports of targets that can hold the row, so the |
| +// CLI, old or new, never reads the pool box's. The sealer, the source and |
| +// the target are played by their reports, and the target's landed |
| +// transition is written while flip polls. |
| +func TestMoveOfflineFlipStepsOverAPoolBox(t *testing.T) { |
| + e := newOfflineE2E(t, []string{"region-ha-1", "offline-move-1"}) |
| + e.publish("uk-a-pool", "uk", "eu-west-2", "data-uk", false) |
| + host, rel, ctx := e.host, e.rel, context.Background() |
| + const id = "mv_abcdefghijklmnopqrstuvwxyz" |
| + move := func(mut func(*provision.Record) error) { |
| + t.Helper() |
| + if _, err := provision.SetRecordMove(ctx, rel, release.OpsAccount, "shop", host, mut); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + sealed := map[string]moves.Check{} |
| + for _, it := range moves.OfflineSourced() { |
| + sealed[it.ID] = moves.Check{OK: true, Reason: "ok"} |
| + } |
| + landed := map[string]moves.Check{} |
| + for _, it := range moves.OfflineOwned(moves.OfflineOwnerLanding) { |
| + landed[it.ID] = moves.Check{OK: true, Reason: "ok"} |
| + } |
| + move(provision.OfflineStart(id, "ie", "uk", "paul@keymail.dev", time.Now())) |
| + move(provision.OfflineSeal(id, "ie-box", []string{"ie-box"})) |
| + seal, err := json.Marshal(moves.OfflineReport{V: moves.OfflineReportVersion, Op: id, Host: host, Box: "ie-box", Role: moves.OfflineRoleSealer, |
| + Phase: moves.OfflinePhaseSealed, At: time.Now().UTC(), Items: sealed, FinalTXID: 7, TombstoneOwner: moves.TombstoneOwner(id)}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err := rel.Put(ctx, moves.OfflineSealKey(host, id), seal, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + move(provision.OfflineSealedBy(id, "ie-box", provision.MoveSource{FinalTXID: 7, Evidence: moves.OfflineSealEvidence(host, id, seal)})) |
| + e.put(id, "ie-box", moves.OfflineRoleSource, moves.OfflinePhaseStopped, nil) |
| + e.put(id, "ie-box", moves.OfflineRoleSealer, moves.OfflinePhaseSealed, func(r *moves.OfflineReport) { |
| + r.Items, r.TombstoneOwner, r.TombstoneUntil = sealed, moves.TombstoneOwner(id), time.Now().Add(moves.TombstoneTTL) |
| + }) |
| + e.put(id, "uk-box", moves.OfflineRoleTarget, moves.OfflinePhaseLanded, func(r *moves.OfflineReport) { r.Items = landed }) |
| + e.put(id, "uk-a-pool", moves.OfflineRoleTarget, moves.OfflinePhaseFailed, func(r *moves.OfflineReport) { |
| + r.Held, r.Fenced, r.Quiesced = false, false, false |
| + r.Items = map[string]moves.Check{} |
| + for _, it := range moves.OfflineOwned(moves.OfflineOwnerLanding) { |
| + r.Items[it.ID] = moves.Check{Reason: "not checked: the row is not held for this move"} |
| + } |
| + }) |
| + |
| + fctx, cancel := context.WithTimeout(ctx, 30*time.Second) |
| + defer cancel() |
| + type result struct { |
| + code int |
| + out string |
| + } |
| + flipped := make(chan result, 1) |
| + go func() { |
| + code, out := e.run(fctx, "flip") |
| + flipped <- result{code, out} |
| + }() |
| + // flip polls the landing; a few polls later the target says landed. |
| + for deadline := time.Now().Add(20 * time.Second); ; time.Sleep(10 * time.Millisecond) { |
| + rec, err := provision.GetRecord(ctx, rel, release.OpsAccount, "shop", host) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if rec.Move != nil && rec.Move.State == provision.OfflineLanding { |
| + break |
| + } |
| + if time.Now().After(deadline) { |
| + t.Fatal("flip never moved the record") |
| + } |
| + } |
| + time.Sleep(100 * time.Millisecond) |
| + move(provision.OfflineLandedBy(id, "uk")) |
| + ready := "uk holds everything " + host + " needs. Nothing is served yet. Run carlos move offline open --host " + host + " to serve it from uk." |
| + select { |
| + case r := <-flipped: |
| + if r.code != 0 { |
| + t.Fatalf("flip exit %d:\n%s", r.code, r.out) |
| + } |
| + wantLines(t, r.out, ready) |
| + wantNoLine(t, r.out, "could not take") |
| + case <-time.After(25 * time.Second): |
| + t.Fatal("flip never finished") |
| + } |
| + code, out := e.run(ctx, "status") |
| + if code != 0 { |
| + t.Fatalf("status exit %d:\n%s", code, out) |
| + } |
| + wantLines(t, out, ready) |
| + wantNoLine(t, out, "could not take", "uk-a-pool") |
| +} |