carlos / platform Public

Merge remote-tracking branch 'origin/main' into ha-departure-evidence

# Conflicts:
#	internal/provision/testdata/plan14-root-reads-chain.tsv
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev 67f7a10ad9e2a5164ae0b5a1defd6d7d868c8ec3 parent d81fe97parent b5d04a8
29 files changed, +1,639 −194
  • apps_policy.go +6 −3
  • apps_policy_test.go +6 −5
  • docs/site/cli.md +5 −5
  • docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md +11 −0
  • docs/superpowers/notes/census-proposal-egress-allow-cidr.md +11 −0
  • docs/superpowers/notes/census-proposal-ha-departure-evidence.md +0 −29
  • docs/superpowers/plans/2026-10-21-instance-policy-copy.json +10 −9
  • docs/superpowers/plans/2026-11-22-egress-allow-cidr.md +261 −0
  • internal/apppolicy/apppolicy.go +13 −8
  • internal/apppolicy/apppolicy_test.go +14 −0
  • internal/console/egressfleet.go +170 −42
  • internal/console/egressfleet_test.go +209 −3
  • internal/dbreads/fixture_test.go +21 −0
  • internal/egressaddr/egressaddr.go +171 −29
  • internal/egressaddr/egressaddr_test.go +184 −1
  • internal/host/egress_fixtures_rootrunner_linux_test.go +48 −16
  • internal/host/egress_prefix_rootrunner_linux_test.go +231 −0
  • internal/host/egress_source_test.go +58 −0
  • internal/instancectl/egress.go +25 −21
  • internal/instancectl/egress_test.go +106 −2
  • internal/instancectl/localaddrs.go +11 −0
  • internal/provision/apppolicy_reconcile_test.go +30 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +2 −1
  • internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv +6 −0
  • internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv +5 −0
  • internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv +0 −18
  • internal/release/layoutintent.go +12 −0
  • internal/release/layoutintent_test.go +11 −0
  • testdata/clireg-golden.jsonl +2 −2

Intent

Human

<task-notification> <task-id>bkc5630qe</task-id> <tool-use-id>toolu_01NtDsoHE6Bu429x2uo5nrZQ</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/70d5e8d6-dd7c-4158-81af-7774784da3d3/tasks/bkc5630qe.output</output-file> <status>completed</status> <summary>Background command "Poll branch CI until it finishes" completed (exit code 0)</summary> </task-notification>

diff --git a/apps_policy.go b/apps_policy.go
index b39815bd9..c9515ace8 100644
--- a/apps_policy.go
+++ b/apps_policy.go
@@ -33,11 +33,14 @@ import (
// Copy (approved by delegation, Luna pass 2026-10-26; deck copy-instance-policy-plan1.md).
const (
- appsSetFlagEgress = `private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; "" clears it. system operators only`
+ appsSetFlagEgress = `private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; "" clears it. system operators only`
appsSetFlagSize = "the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only"
instancesSetFlagSize = "this instance's size: small, standard, large or xlarge. default follows the app's size. system operators only"
appsSetPolicyUsage = `Only system operators may pass --egress-allow or --size. A change reaches
-the app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.`
+the app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.
+--egress-allow takes at most 8 entries. A range must start at its first address, so
+10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on
+every box, and a box refuses a range that holds one of its own addresses.`
appsSetBadEgress = "apps set: --egress-allow: %v"
appsSetBadSize = "apps set: --size is small, standard, large, xlarge or default, not %q"
instancesSetBadSize = "instances set: --size is small, standard, large, xlarge or default, not %q"
@@ -45,7 +48,7 @@ the app's boxes within seconds on a box following the deployment's change index,
appsPolicyChanged = "the policy changed while this ran. run it again"
appsSetEgressDone = "egress allow for %s set to %s"
appsSetEgressCleared = "egress allow for %s cleared"
- appsSetEgressNotChecked = "not checked against these boxes, which publish no address list: %s"
+ appsSetEgressNotChecked = "not checked against these boxes, which publish no address list (fleet boxes never do): %s. each one still refuses an entry that covers its own address"
appsSetSizeDone = "default size for %s set to %s. instances with their own size are unchanged"
appsSetSizeCleared = "default size for %s set to the build's size. instances with their own size are unchanged"
instancesSetSizeDone = "%s size set to %s"
diff --git a/apps_policy_test.go b/apps_policy_test.go
index 190a68d16..2d81f82f0 100644
--- a/apps_policy_test.go
+++ b/apps_policy_test.go
@@ -99,7 +99,8 @@ func TestAppsSetPolicyRefusesClientSide(t *testing.T) {
want string
}{
{[]string{"--egress-allow", "10.0.5.20:5432"}, "has a port"},
- {[]string{"--egress-allow", "10.0.5.0/24"}, "is a range"},
+ {[]string{"--egress-allow", "10.0.64.5/20"}, "has host bits set. write it as 10.0.64.0/20"},
+ {[]string{"--egress-allow", "10.0.0.0/8"}, "is wider than /16"},
{[]string{"--egress-allow", "8.8.8.8"}, "already reachable"},
{[]string{"--egress-allow", "10.0.5.20,8.8.8.8"}, "already reachable"},
}
@@ -287,12 +288,12 @@ func TestAppsShowPrintsThePolicy(t *testing.T) {
// egress_conflicts, marks nothing.
func TestAppsShowMarksConflicts(t *testing.T) {
out := captureStdout(t)
- c := &policyConsole{getBody: `{"policy":{"v":1,"egress_allow":["10.0.5.20","fd00:5::20"]},` +
- `"etag":"e1","not_checked":[],"egress_conflicts":["fd00:5::20","10.0.5.30"]}`}
+ c := &policyConsole{getBody: `{"policy":{"v":1,"egress_allow":["10.0.5.20","10.0.64.0/20","fd00:5::20"]},` +
+ `"etag":"e1","not_checked":[],"egress_conflicts":["fd00:5::20","10.0.5.30","10.0.64.0/20"]}`}
if err := appsShowRun(context.Background(), c.session(t), apiAcct{Seg: "bab"}, "shop"); err != nil {
t.Fatal(err)
}
- if want := "egress allow 10.0.5.20, !fd00:5::20\ndefault size the build's size\n"; out.String() != want {
+ if want := "egress allow 10.0.5.20, !10.0.64.0/20, !fd00:5::20\ndefault size the build's size\n"; out.String() != want {
t.Fatalf("stdout = %q, want %q", out.String(), want)
}
@@ -323,7 +324,7 @@ func TestAppsSetPrintsNotChecked(t *testing.T) {
if out.String() != want {
t.Fatalf("stdout = %q, want %q", out.String(), want)
}
- if want := "not checked against these boxes, which publish no address list: box-c\n"; !strings.HasSuffix(out.String(), want) {
+ if want := "not checked against these boxes, which publish no address list (fleet boxes never do): box-c. each one still refuses an entry that covers its own address\n"; !strings.HasSuffix(out.String(), want) {
t.Fatalf("stdout = %q, want it to end %q", out.String(), want)
}
diff --git a/docs/site/cli.md b/docs/site/cli.md
index 3923a88ca..1b5121cdf 100644
--- a/docs/site/cli.md
+++ b/docs/site/cli.md
@@ -253,21 +253,21 @@ If a box is lost or detached, the requested count stays the same. The platform u
System operators can also set an app's instance policy: which private addresses its instances may reach and the size each instance runs at. `carlos apps show` reads it back.
```sh
-carlos apps set shop --egress-allow 10.0.5.20,fd00:5::20
+carlos apps set shop --egress-allow 10.0.5.20,10.0.64.0/20
carlos apps set shop --size large
carlos instances set shop-a.example.com --app shop --size xlarge
carlos apps show shop
```
-An instance cannot reach a private address unless its app allows it. `--egress-allow` takes the app's whole list, comma-separated, and replaces the list before it. To drop one address, pass the list without it; `--egress-allow ""` removes them all. Each entry is a single IP address, with no range, port or zone. Public addresses are refused because instances can reach them already, and so are loopback, link-local, multicast and reserved addresses, the cloud metadata service and the NAT64 prefix. An app may allow at most 8.
+An instance cannot reach a private address unless its app allows it. `--egress-allow` takes the app's whole list, comma-separated, and replaces the list before it. To drop one entry, pass the list without it; `--egress-allow ""` removes them all. Each entry is a single IP address or a private range such as `10.0.64.0/20` or `fd00:5::/64`, with no port or zone. The widest range is /16 for IPv4 or /48 for IPv6. Every range must start at its first address, so `10.0.64.5/20` is refused. Public addresses are refused because instances can reach them already, and so are loopback, link-local, multicast and reserved addresses, the cloud metadata service and the NAT64 prefix, and any range that contains one of them. An app may allow at most 8 entries, and a range counts as one.
-A change that adds an address is checked against the deployment's boxes. An address that belongs to one of them is refused, and so is any new address while a box does not publish its address list yet. Boxes that publish none at all are named after the change. An allow takes effect only on a box where every instance runs nested (see `carlos status --layout`). It does not take effect while host claims are on. If a box later takes an allowed address, the console sends an alert.
+A change that adds an entry is checked against the deployment's boxes. An entry that covers an address of one of them is refused, and so is any new entry while a box does not publish its address list yet. Boxes that publish no address list are named after the change (fleet boxes never publish one), and each of them still refuses an entry that covers its own address. A range can be added only while every box runs v0.43.0 or later. Single addresses are not affected by the v0.43.0 floor; they keep working on the releases that already support egress allows. Once an app has a range, do not roll a console back below v0.43.0, because an older console cannot read that app's policy, and a later change from it would clear the app's allows and sizes. An allow takes effect only on a box where every instance runs nested (see `carlos status --layout`). It does not take effect while host claims are on. If a box later takes an allowed address, or an address in an allowed range, the console sends an alert.
The sizes are `small` (256 MiB of memory), `standard` (512 MiB), `large` (1 GiB) and `xlarge` (2 GiB), with CPU and IO to match. `carlos apps set --size` sets the app's size, and `--size default` goes back to the build's size. `carlos instances set --size` gives one instance a size of its own, and `--size default` makes it follow the app's size again. A size above `standard` is refused when it is more than a quarter of the memory on the smallest box the app can run on, or when one of those boxes reports no memory total.
After a size change, the command prints each box's memory committed to awake instances, out of its total. CPU and IO change at once. A larger size's memory applies when an instance next starts or is deployed. A smaller size applies only when the instance starts cold. Restart it to apply the new memory now. `carlos status --layout` shows the size each instance runs at.
-The console records a change, and the app's boxes apply it. A box that follows the deployment's change index does so within seconds; any other box within about 33 minutes. `carlos apps show` prints the egress allow, the app's size, and every instance with a size of its own. A `!` before an address means one of the deployment's boxes now holds it.
+The console records a change, and the app's boxes apply it. A box that follows the deployment's change index does so within seconds; any other box within about 33 minutes. `carlos apps show` prints the egress allow, the app's size, and every instance with a size of its own. A `!` before an entry means one of the deployment's boxes now holds that address, or an address in that range.
### carlos ship
@@ -3310,7 +3310,7 @@ socket does not exist. Requests to that address then fail. Like
The REGION column names where each route or box runs, such as London (UK).
-The `SIZE` column is the size an awake nested instance runs at: `swap` while a deploy is swapping it, `?` when its box could not read it, and `-` for anything else. `standard>large` means it runs at standard and its policy asks for large; a note under the table says when that takes effect. The `EGRESS` column is the instance's egress allow as its box applies it. A `!` before an address means one of the deployment's boxes now holds it. A word after `!` means the allow is not in force: `failing`, `policy unreadable`, `policy unverifiable`, `policy expired`, `box not wholly nested`, `not yet supported under claims`, or `refused` when the box dropped an entry. `REASON` gives the detail after `egress:`.
+The `SIZE` column is the size an awake nested instance runs at: `swap` while a deploy is swapping it, `?` when its box could not read it, and `-` for anything else. `standard>large` means it runs at standard and its policy asks for large; a note under the table says when that takes effect. The `EGRESS` column is the instance's egress allow as its box applies it. A `!` before an entry means one of the deployment's boxes now holds that address, or an address in that range. A word after `!` means the allow is not in force: `failing`, `policy unreadable`, `policy unverifiable`, `policy expired`, `box not wholly nested`, `not yet supported under claims`, or `refused` when the box dropped an entry. `REASON` gives the detail after `egress:`.
A box that runs `nested` instances beside `flat`, `foreign` or `external`
ones gets a warning after the table. Each of those still shares the agent's
diff --git a/docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md b/docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md
new file mode 100644
index 000000000..179eb2171
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md
@@ -0,0 +1,11 @@
+# Census approval: egress-allow-cidr-console
+
+Ruling `census-ruling-egress-allow-cidr-console`. 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).
+
+Envelopes re-pinned: `.`, `internal/egressaddr`, `internal/instancectl`, `internal/release`.
+
+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.
+
+Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/census-proposal-egress-allow-cidr.md b/docs/superpowers/notes/census-proposal-egress-allow-cidr.md
new file mode 100644
index 000000000..1d886cb02
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-egress-allow-cidr.md
@@ -0,0 +1,11 @@
+# Census approval: egress-allow-cidr
+
+Ruling `census-ruling-egress-allow-cidr`. 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).
+
+Envelopes re-pinned: `internal/apppolicy`, `internal/egressaddr`, `internal/instancectl`.
+
+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.
+
+Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/census-proposal-ha-departure-evidence.md b/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
deleted file mode 100644
index 1aab8793b..000000000
--- a/docs/superpowers/notes/census-proposal-ha-departure-evidence.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# Census approval: ha-departure-evidence
-
-Ruling `census-ruling-ha-departure-evidence`. The independent reviewer approves or rejects every change below, 3 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
-
-| unit | change | read sites | what changed |
-|---|---|---|---|
-| `internal/host/hadepartures.go` `Controller.step` | sites | +whole:HAPendingTermination ×2 | A pending hint whose bound identity has an unknown or placement-null observation gets code evidence_no_observation: no enqueue, no enrollment, no completion or takeover authority. It claims a page through the new retry_hint_once op (falling back to the ordinary hourly retry if the server refuses it) and marks the hint paged only after PageIdentity succeeds. Reads only the local journal. Round 2: the page-once claim falls back to the ordinary hourly retry only on ErrHAJournal (an older server's refusal); any other journal error fails the pass so a delivered marker is never overwritten. No new read or authority. |
-| `internal/host/hadepartures_wiring.go` `armHADepartures` | sites | -registry:Account, -registry:IID, -registry:Region | The PageIdentity closure moved to the named pageDeparturePending; same fields read, now there instead of here. |
-| `internal/registry/ha_journal.go` `Registry.haJournal` | sites | +file:QueryRowContext, +registry:Account ×4, +registry:At ×5, +registry:Code ×7, +registry:Found ×2, +registry:Hint ×2, +registry:IID ×4, +registry:Region ×4, +registry:sql, +whole:HAPendingTermination ×2, +whole:haJournalResponse ×8 | New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. Round 4 (Paul's option 1): every last_error write on ha_pending_terminations goes through hintLastError, a CASE that keeps a value ending in ' paged'; retry_hint_once treats any paged marker as delivered. Only hint removal clears it. No new table, read or authority. |
-
-Envelopes re-pinned: `internal/alerting`, `internal/host`, `internal/registry`.
-
-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/hadepartures.go` `Controller.step`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: resolve bound same-scope identities, persist validated termination proof before enrollment, and replay bounded pending work outside consumer/fold locks. Existing regional data client and shared cache; inventory only restricts completion, never lifecycle. B3 fix r1: Describe before proof access on suspicion paths. Normalize validated legacy inbox entries in atomic transactions, process bounded per-iid pending pages, and persist hourly escalation. Delete unrelated rows only after complete applicable walks and guarded received timestamps. Acquire/completion authority unchanged. B4: Count unresolved durable hints for the globally throttled summary and call the bounded scanner outside the fold. Acknowledge unrelated hints only after complete applicable discovery; complete departure acknowledgment reads durable state. B4 fix r3: Include refused fixed-box replacements in the existing structured receiver summary, sharing its persisted hourly page claim with pending hints. Read only local refusal state and registry page state; no additional cloud request or completion authority.;rev3=census-ruling-region-ha-p3b;basis=Register admitted departure work and cancel/join it during closure before existing confirmation/import processing. Existing 23 read sites and lease/termination proofs remain; no new root input or takeover permission.;rev3=census-ruling-region-ha-g2-fixes;basis=Include identity and underlying paging errors in existing failure logs; new IID field read only, no new external read or termination authority.;rev3=census-ruling-region-ha-dr5;basis=DR-5: scans every due departure per step (at most 8), reading departure rows from the local journal (PendingDepartures) to detect progress; same ScanPass per departure, no new remote read.
-- `internal/host/hadepartures_wiring.go` `armHADepartures`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes
-- `internal/registry/ha_journal.go` `Registry.haJournal`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.
-
-New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff:
-
-- new `internal/host/hadepartures_wiring.go:pageDeparturePending`: reads +registry:Account, +registry:IID, +registry:Region; written legacy, accepted-legacy, frozen
-- new `internal/registry/ha_journal.go:Registry.MarkPendingTerminationPaged`: reads +whole:HAPendingTermination ×2; written legacy, accepted-legacy, frozen
-- new `internal/registry/ha_journal.go:Registry.RetryPendingTerminationOnce`: reads +registry:Found, +whole:HAPendingTermination ×2; written legacy, accepted-legacy, frozen
-
-Seal: `9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0` → `924ffc4037d32d7b46af1e373bad1476fc7305833fc6c06d50d5c8c3ab5ac177`.
-
-Overlay: `internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/plans/2026-10-21-instance-policy-copy.json b/docs/superpowers/plans/2026-10-21-instance-policy-copy.json
index e07e57792..9fb984da4 100644
--- a/docs/superpowers/plans/2026-10-21-instance-policy-copy.json
+++ b/docs/superpowers/plans/2026-10-21-instance-policy-copy.json
@@ -1,6 +1,7 @@
{
"approved_by": "delegation (Luna pass, gpt-5.6-luna; Paul's standing rule for platform copy decks)",
"approved_on": "2026-10-26",
+ "amended_by": "approved by delegation (Luna pass 2026-11-22): IP1-06, IP1-08, IP1-10, IP1-11, IP1-14, IP1-50, IP1-53, IP2-30, IP2-60",
"source": "docs/superpowers/specs/LUNA-COPY-RESULT-INSTANCE-POLICY.md",
"entries": [
{"id": "IP1-01", "file": "internal/egressaddr/egressaddr.go", "text": "an address is empty"},
@@ -8,15 +9,15 @@
{"id": "IP1-03", "file": "internal/egressaddr/egressaddr.go", "text": "%q has a port. an allow opens an address, never a port"},
{"id": "IP1-04", "file": "internal/egressaddr/egressaddr.go", "text": "%q has a zone. name the address without it"},
{"id": "IP1-05", "file": "internal/egressaddr/egressaddr.go", "text": "%q is not an IP address"},
- {"id": "IP1-06", "file": "internal/egressaddr/egressaddr.go", "text": "%s is a loopback address"},
+ {"id": "IP1-06", "file": "internal/egressaddr/egressaddr.go", "text": "%s is loopback"},
{"id": "IP1-07", "file": "internal/egressaddr/egressaddr.go", "text": "%s is the unspecified address"},
- {"id": "IP1-08", "file": "internal/egressaddr/egressaddr.go", "text": "%s is the cloud metadata service"},
+ {"id": "IP1-08", "file": "internal/egressaddr/egressaddr.go", "text": "%s would reach the cloud metadata service"},
{"id": "IP1-09", "file": "internal/egressaddr/egressaddr.go", "text": "%s is link-local"},
- {"id": "IP1-10", "file": "internal/egressaddr/egressaddr.go", "text": "%s is a multicast address"},
- {"id": "IP1-11", "file": "internal/egressaddr/egressaddr.go", "text": "%s is in %s, a reserved range"},
+ {"id": "IP1-10", "file": "internal/egressaddr/egressaddr.go", "text": "%s is multicast"},
+ {"id": "IP1-11", "file": "internal/egressaddr/egressaddr.go", "text": "%s is in or overlaps %s, a reserved range"},
{"id": "IP1-12", "file": "internal/egressaddr/egressaddr.go", "text": "%s is in the NAT64 prefix 64:ff9b::/96, which reaches any IPv4 address"},
{"id": "IP1-13", "file": "internal/egressaddr/egressaddr.go", "text": "%s is a public address and is already reachable. no allow is needed"},
- {"id": "IP1-14", "file": "internal/egressaddr/egressaddr.go", "text": "at most %d addresses per app (%d given)"},
+ {"id": "IP1-14", "file": "internal/egressaddr/egressaddr.go", "text": "at most %d entries per app (%d given)"},
{"id": "IP1-15", "file": "internal/console/policylease.go", "text": "another console (%s) is the policy writer for this deployment until %s. use that console, or try again after that"},
{"id": "IP1-16", "file": "internal/console/policylease.go", "text": "another console is the policy writer for this deployment until %s. use the console that holds the lease, or try again after that"},
{"id": "IP1-17", "file": "internal/console/policylease.go", "text": "could not take the policy writer lease. try again"},
@@ -57,7 +58,7 @@
{"id": "IP1-35", "file": "apps_policy.go", "text": "the policy changed while this ran. run it again"},
{"id": "IP1-36", "file": "apps_policy.go", "text": "egress allow for %s set to %s"},
{"id": "IP1-37", "file": "apps_policy.go", "text": "egress allow for %s cleared"},
- {"id": "IP2-30", "file": "apps_policy.go", "text": "not checked against these boxes, which publish no address list: %s"},
+ {"id": "IP2-30", "file": "apps_policy.go", "text": "not checked against these boxes, which publish no address list (fleet boxes never do): %s. each one still refuses an entry that covers its own address"},
{"id": "IP1-38", "file": "apps_policy.go", "text": "default size for %s set to %s. instances with their own size are unchanged"},
{"id": "IP1-39", "file": "apps_policy.go", "text": "default size for %s set to the build's size. instances with their own size are unchanged"},
{"id": "IP1-42", "file": "apps_policy.go", "text": "%s size set to %s"},
@@ -65,10 +66,10 @@
{"id": "IP3-10", "file": "apps_policy.go", "text": "%s: %d MiB committed to awake instances, of %d MiB. %d MiB free"},
{"id": "IP3-11", "file": "apps_policy.go", "text": "the new memory size applies at the next start. a larger size also applies at the next deploy; a smaller size waits for a cold start. CPU and IO apply now"},
{"id": "IP1-44", "file": "apps_policy.go", "text": "apps show works through a console, and this shell is in direct bucket mode (CARLOS_DEPLOYMENT_BUCKET or CARLOS_DEPLOYMENT_DIR is set). log in instead: carlos auth login --console <url>"},
- {"id": "IP1-50", "file": "apps_policy.go", "text": "private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; \"\" clears it. system operators only"},
+ {"id": "IP1-50", "file": "apps_policy.go", "text": "private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; \"\" clears it. system operators only"},
{"id": "IP1-51", "file": "apps_policy.go", "text": "the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only"},
{"id": "IP1-52", "file": "apps_policy.go", "text": "this instance's size: small, standard, large or xlarge. default follows the app's size. system operators only"},
- {"id": "IP1-53", "file": "apps_policy.go", "text": "Only system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box."},
+ {"id": "IP1-53", "file": "apps_policy.go", "text": "Only system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\n--egress-allow takes at most 8 entries. A range must start at its first address, so\n10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on\nevery box, and a box refuses a range that holds one of its own addresses."},
{"id": "IP1-54", "file": "apps_policy.go", "text": "usage: carlos apps show <app> [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]"},
{"id": "IP1-60", "file": "apps_policy.go", "text": "egress allow %s"},
{"id": "IP1-61", "file": "apps_policy.go", "text": "default size %s"},
@@ -107,7 +108,7 @@
{"id": "IP2-20", "file": "internal/console/apiinstances.go", "text": "the allow takes effect when the instance next starts"},
{"id": "IP2-21", "file": "internal/console/apiinstances.go", "text": "the box could not apply the allow, and tries again"},
{"id": "IP2-22", "file": "internal/console/apiinstances.go", "text": "the allow is not in force on this box"},
- {"id": "IP2-60", "file": "internal/instancectl/egress.go", "text": "%s: an address of this box (%s)"},
+ {"id": "IP2-60", "file": "internal/instancectl/egress.go", "text": "%s: this box has an address in %s"},
{"id": "IP2-61", "file": "internal/instancectl/egress.go", "text": ": this box's addresses could not be read"},
{"id": "IP2-45", "file": "internal/instancectl/egress.go", "text": "the policy has more than %d addresses (%d); every one is closed"},
{"id": "IP2-49", "file": "internal/instancectl/egress.go", "text": "revoked (restarted)"},
diff --git a/docs/superpowers/plans/2026-11-22-egress-allow-cidr.md b/docs/superpowers/plans/2026-11-22-egress-allow-cidr.md
new file mode 100644
index 000000000..46dac014b
--- /dev/null
+++ b/docs/superpowers/plans/2026-11-22-egress-allow-cidr.md
@@ -0,0 +1,261 @@
+# Egress allow by private CIDR (#1357)
+
+Spec: docs/superpowers/specs/2026-10-21-instance-sizes-and-egress-design.md §4
+(the single-address egress allow, #328). This plan widens §4.1 from "a single
+address" to "a single address or a private prefix". All of the spec's other
+rules and rulings still apply. Issue: #1357 (amadan discuss carlos/platform).
+
+## Findings (what is there today)
+
+- One rule set, `internal/egressaddr`, is applied at the console door
+ (`Normalize`, apipolicy.go ~1047), in `apppolicy.Policy.Validate` (signing
+ and every open on a box), and by root (`instancectl.EgressAsserter.desired`,
+ egress.go ~638). Root writes `IPAddressAllow=` as full-length prefixes,
+ and `readBack`/`parseHeld` already parse prefixes (masked).
+- **Old box given a CIDR entry:** `egressaddr.Parse` refuses any `/`, so
+ `Validate` fails and the policy is `ErrUnverifiable`. `policyColsFor` then
+ fails closed with `Known: true` (apppolicy_reconcile.go ~113-140): the
+ app's whole allow list AND its size override are cleared on that box. It
+ never fails open, but it does regress the app's other entries. So CIDR
+ entries are gated behind a box version floor (Task 3).
+- **~33 minutes:** fleet boxes have no change index
+ (changeindex.go:59-61), so `PolicyCache` re-reads only on the 30-minute
+ backstop (`release.ChangeIndexBackstop`) plus up to 3 minutes of jitter
+ (apppolicy_cache.go:128). Shared boxes follow the change index and apply
+ a change within seconds. A serial-triggered fleet full pass does not
+ re-read an already cached policy (`backstopDue` waits for `c.next`).
+- **"publish no address list":** `apps_policy.go:48`. Grant-time
+ checking reads box addresses from edges files
+ (`control/edges/<box>.json`, `addrs`), and only platform boxes write edges
+ files (edgesfile.go:1267). So for bucketless fleet boxes the warning is
+ accurate and by design (spec §4.2), but its wording reads like a fault.
+ Root on every box, fleet boxes included, still refuses an entry that is
+ one of its own addresses.
+
+## Decisions
+
+1. **Entry forms.** A single address (as today) or a prefix `a.b.c.d/n` /
+ `x::/n`. IPv6 prefixes are accepted, because IPv6 singles are accepted.
+2. **Stored form.** A full-length prefix (`/32`, `/128`) is stored as the
+ bare address, so a policy with singles only is byte-identical to today
+ and old boxes keep reading it. Other prefixes are stored as
+ `netip.Prefix.String()`.
+3. **Host bits set is refused, not normalized** (`10.0.64.5/20`): the
+ operator may have meant the single address. The refusal names the
+ canonical prefix (`10.0.64.0/20`).
+4. **Minimum prefix length:** /16 for IPv4 and /48 for IPv6. /16 is the
+ largest CIDR block an AWS VPC can have, and a common VPC size elsewhere,
+ so one entry covers at most one whole VPC and never spans `10.0.0.0/8`
+ or `172.16.0.0/12`. /48 is a ULA site prefix (RFC 4193), so one entry
+ never spans sites. A wider prefix is refused and names the limit.
+5. **Private ranges only, exactly as today.** A prefix is allowed when its
+ whole range lies inside one `FenceDeny` range and it overlaps none of
+ the refused classes: loopback, unspecified, link-local, both metadata
+ addresses, multicast, the reserved ranges and NAT64. Equivalently,
+ every address in it would pass `Allowed`, and the check is done on
+ prefixes, not by enumeration. Example: `fd00:ec2::/48` is refused
+ because it holds the v6 metadata address.
+6. **Count limit unchanged:** at most `MaxAllow` (8) entries. Each
+ prefix counts as one entry. Exact duplicates collapse, and an entry
+ inside another entry is kept as written (no subsumption). The sort
+ order is address, then prefix length, so `10.0.64.0/20` comes before
+ `10.0.64.0`.
+7. **Root accepts the prefix exactly.** Root writes `IPAddressAllow=` with
+ the entry's own prefix: no widening, and no masking of a stored
+ host-bits entry (`Validate` already refused those). An entry
+ **overlapping** any of the box's own addresses is refused on that box
+ with a reason. `IPAddressAllow` beats `IPAddressDeny` in systemd, so
+ the box's address cannot be carved out of the prefix. The equality rule
+ for singles becomes an overlap rule.
+8. **Console grant check and live report:** an added prefix is refused if
+ any published box address lies inside it, naming the box. This is the
+ §4.2 rule with "equals" widened to "contains". The live report and
+ `apps show`'s `!` work the same way.
+9. **Version floor.** `release.EgressPrefixFloor = v0.43.0` (the next
+ minor; v0.42.1 is the latest tag). A grant that adds a non-full-length
+ prefix is refused with a 409 while any fresh heartbeat box of the
+ deployment reports a release below the floor or no release. This
+ follows the `teamFloorRefusal` pattern in internal/console/teamfloor.go
+ and is not scoped to the app's placement, because an app can move to
+ any box. If the release ships under another number, the floor constant
+ moves with it. A floor set too high only refuses prefixes for longer
+ (fail safe).
+10. **Propagation is documented, not shortened, in this slice.**
+ Shortening it means a fleet full pass that re-lists
+ `control/app-policy/` whenever the serial moves. Serial bumps follow
+ any console activity, so that adds S3 requests on every fleet box, which
+ ruling 11 forbids without a budget. The bound (about 33 minutes on
+ fleet boxes, seconds on shared boxes) is already in docs/site/cli.md.
+ The proposal goes on #1357.
+11. **Fleet-box warning reworded**, not removed. It names the boxes as
+ fleet boxes that do not publish their addresses, and says that root
+ on each of those boxes still refuses an entry holding the box's own
+ address.
+12. **Hostname entries:** not built here. A proposal goes on #1357.
+
+## Global constraints
+
+- `internal/egressaddr` stays a pure leaf package (no platform imports).
+- No new per-box polling, no new S3 reads on a timer.
+- Policies with singles only stay byte-identical (stored form, signed wire,
+ registry column, the `IPAddressAllow=` line root writes).
+- User-facing text: no em dashes, curly quotes in docs prose, plain and
+ short. Refusals are lower-case fragments in the existing `egressaddr`
+ style (`"%q is ..."`). Copy gets a Luna pass after Task 3.
+- No tenant names; examples use `shop`, `10.0.64.0/20`, `fd00:5::/64`.
+- Root-read code changes (instancectl) need a census card
+ (`make census-card` / `census-propose`) if `TestPlan14RootReadCensus`
+ moves.
+- Local tests: targeted `-run` on changed packages only. Also cross-build
+ `GOOS=darwin` and `GOOS=windows` for `./...`-touched packages.
+
+## Task 1: egressaddr prefixes
+
+Files: internal/egressaddr/egressaddr.go, egressaddr_test.go.
+
+- Add `ParseEntry(s string) (netip.Prefix, error)`. A bare address becomes
+ its full-length prefix, with an IPv4-mapped address unmapped. `a/n` is
+ parsed with `netip.ParsePrefix`. A mapped-v4 prefix is refused as
+ not-an-address, to keep it simple. Ports, zones and empty input are
+ refused as today. Host bits set gives `"%q has host bits set. write it
+ as %s"`. Keep `Parse` (single addresses) for existing callers that still
+ need an address.
+- Add `AllowedPrefix(p netip.Prefix) error`:
+ - Full-length → `Allowed(p.Addr())` (same messages as today).
+ - Otherwise:
+ - min length (decision 4): `"%s is wider than /%d. allow at most a /%d"`;
+ - containment in a `FenceDeny` range, else public or partly public:
+ `"%s is not wholly inside a private range"`;
+ - no overlap with loopback, multicast, link-local
+ (`169.254.0.0/16`, `fe80::/10`), the metadata addresses, reserved
+ or NAT64: reuse the existing messages with the prefix in place of
+ the address. Loopback and multicast are already caught by the
+ length plus containment rules, but test them anyway.
+- `Normalize` works on entries (decisions 2, 3 and 6), and stays the one
+ door function.
+- Constants: `MinPrefixV4 = 16`, `MinPrefixV6 = 48`.
+- `Parse` stays the single-address reader and keeps refusing a `/`
+ (Task 2's old-box witness pins that). Update the package doc for
+ ranges.
+- **Witness: table tests.**
+ - Accepted: `10.0.64.0/20`, `10.0.0.0/16`, `172.16.0.0/16`,
+ `192.168.0.0/16`, `100.64.0.0/16`, `fd00:5::/64`, `fd00:5::/48`,
+ `10.0.5.20/32` → stored `10.0.5.20`, `fd00:5::20/128` →
+ `fd00:5::20`.
+ - Refused, each with its message: `10.0.0.0/8`, `10.0.0.0/15`,
+ `fd00::/47`, `10.0.64.5/20`, `169.254.0.0/16`,
+ `169.254.169.0/24`, `fd00:ec2::/48`, `64:ff9b::/96`,
+ `198.18.0.0/16`, `8.8.8.0/24`, `0.0.0.0/16`, `224.0.0.0/16`,
+ `fe80::/64`, `10.0.64.0/20:5432`, `::ffff:10.0.0.0/112`.
+ - Sort and dedup: `10.0.64.0`, `10.0.64.0/20`, `10.0.64.0/20` →
+ `[10.0.64.0/20 10.0.64.0]`.
+ - The count limit holds with prefixes.
+ - A fuzz-free property test: for each accepted prefix, its first and last
+ addresses pass `Allowed`.
+
+## Task 2: the box accepts prefixes exactly
+
+Files:
+- internal/apppolicy/apppolicy.go (Validate uses `ParseEntry`,
+ `AllowedPrefix` and the decision-6 order);
+- internal/instancectl/egress.go (`desired`);
+- internal/instancectl/localaddrs.go (an overlap helper);
+- callers of `egressaddr.Parse` in internal/console/egressfleet.go only as
+ far as compiling needs (the logic is Task 3).
+
+- `desired`:
+ - parse with `ParseEntry`, check with `AllowedPrefix`, and dedup by
+ prefix;
+ - refuse an entry overlapping any local prefix
+ (`"%s: holds an address of this box (%s)"`, with the existing
+ single-address text unchanged for full-length entries);
+ - write the prefix as is.
+- The `want`/read-back comparison already uses masked prefixes. Confirm
+ that systemd's read-back of `10.0.64.0/20` parses equal (a unit test
+ with the fake systemctl).
+- **Witnesses:**
+ - (a) `desired` table: a prefix is written verbatim, a prefix
+ overlapping a local /32 is refused, singles are unchanged, and the
+ count limit applies.
+ - (b) Assert writes `IPAddressAllow=10.0.64.0/20` through the fake
+ systemctl. A read-back of `10.0.64.0/20` counts as in force, not
+ failing.
+ - (c) **old-box safety:** a test in internal/provision that pins the
+ old-box path. A policy whose `Validate` fails (a bad entry) gives
+ fail-closed columns, with an empty allow, never a wider one. Also
+ assert in egressaddr's tests that `Parse` (the old single-address
+ reader, still used by old boxes' code shape) refuses every prefix
+ form. The floor in Task 3 is the guard that stops it happening.
+ - (d) **production-wired:** a registry egress column `10.0.64.0/20
+ 10.0.5.20` goes through the real egress source (internal/host
+ egress_source.go) into the asserter, which writes exactly those two
+ prefixes. Use the existing wiring test's harness
+ (egress_claim_wiring_test.go or egress_source_test.go).
+- Run the census test (`go test ./internal/provision -run
+ TestPlan14RootReadCensus`). If it moves, produce the card per AGENTS.md
+ ("The census: an approval, not a decision").
+
+## Task 3: console door, fleet check, floor, copy
+
+Files:
+- internal/console/egressfleet.go;
+- internal/console/apipolicy.go;
+- internal/console/teamfloor.go (or a new egressfloor.go);
+- internal/release/layoutintent.go (the floor);
+- apps_policy.go, plus the CLI help for `--egress-allow`;
+- docs/site/cli.md (~262).
+
+- `grantAdded` returns added prefixes. The check refuses a prefix that
+ contains any published box address, naming the box and the address.
+ `egressFleetHeldMsg` gets the prefix wording when the entry is a
+ prefix.
+- The live report and `apps show` `!` work on prefix containment.
+- Floor (decision 9): refuse with 409 using the teamfloor phrasing
+ pattern:
+ - `"box %s runs %s. allowing a range needs v%s or later on every box. single addresses are unaffected"`;
+ - a heartbeat read failure → 503, as in teamfloor.
+ - Only grants that add a non-full-length entry are gated. Revokes and
+ singles never are.
+- Fleet warning reworded (decision 11).
+- CLI help and the docs paragraph: entries may be a private range with at
+ least /16 (IPv4) or /48 (IPv6). Host bits refused. Count 8. The floor.
+ The box refuses a range that holds one of its own addresses. The
+ propagation bound stays.
+- **Witnesses:** console tests.
+ - A grant of a prefix holding an edges-file address → 409 naming the
+ box.
+ - A prefix with no conflicts → 200.
+ - Floor: one fresh box at v0.42.1 → 409. All at v0.43.0 → 200. A
+ single address with an old box → 200.
+ - The report flags a prefix that later contains a box address.
+
+## Task 4: kernel witness (root runner)
+
+File: internal/host/egress_kernel_rootrunner_linux_test.go (or a sibling
+`egress_prefix_rootrunner_linux_test.go`), `//go:build linux &&
+rootrunner`.
+
+- Use the kernel proof's dummy-link harness:
+ - put two listeners on a dummy link, one inside `10.250.64.0/20`
+ (`10.250.64.10`) and one outside it but in the same /16
+ (`10.250.80.10`);
+ - give a tenant in a child unit with the template's `IPAddressDeny=`
+ a slice allow of `10.250.64.0/20`, written by the real asserter;
+ - the tenant reaches the inside listener and is refused at the outside
+ one;
+ - revoke, and the inside listener is refused as well.
+- Log one `verdict:` line per question.
+- The controller runs it on the root runner (memory root-runner) and
+ records the run id in the ledger.
+
+## After the tasks (controller)
+
+- Luna copy pass over the new strings and the docs paragraph, then apply it.
+- Post on #1357:
+ - progress;
+ - the propagation finding and proposal (decision 10);
+ - the warning explanation;
+ - the hostname proposal.
+- Final whole-branch review by Astra (max three rounds), CI, squash-merge
+ with amadan.
+- Tell paseo 09cca118 and 8a3d302 the SHA. The release waits for Paul's GO.
diff --git a/internal/apppolicy/apppolicy.go b/internal/apppolicy/apppolicy.go
index 97df1976a..2984b1f0d 100644
--- a/internal/apppolicy/apppolicy.go
+++ b/internal/apppolicy/apppolicy.go
@@ -73,10 +73,12 @@ type SizeOverride struct {
}
// Validate checks the policy's shape: the version, known size names, host
-// keys, and an egress allow already in its stored form (canonical text,
-// strictly ascending, at most egressaddr.MaxAllow). It does not decide
-// whether an address may be granted (the door does, with
-// egressaddr.Normalize) and does not look at the signing fields.
+// keys, and an egress allow already in its stored form (each entry a single
+// address or a prefix in egressaddr.EntryString's text, one
+// egressaddr.AllowedPrefix accepts, strictly ascending in
+// egressaddr.ComparePrefix's order, at most egressaddr.MaxAllow). It does
+// not look at the signing fields. A box whose Validate predates prefixes
+// refuses a policy holding one (#1357), and its reader then fails closed.
func (p Policy) Validate() error {
if p.Demo != nil || p.EgressMode != "" {
if p.Demo == nil || p.EgressMode != "deny-all" || p.DefaultSize != "small" || len(p.EgressAllow) != 0 || len(p.Sizes) != 0 {
@@ -109,13 +111,16 @@ func (p Policy) Validate() error {
if len(p.EgressAllow) > egressaddr.MaxAllow {
return fmt.Errorf("%w: %d egress allows, at most %d", ErrInvalid, len(p.EgressAllow), egressaddr.MaxAllow)
}
- var prev netip.Addr
+ var prev netip.Prefix
for i, e := range p.EgressAllow {
- a, err := egressaddr.Parse(e)
- if err != nil || a.String() != e {
+ a, err := egressaddr.ParseEntry(e)
+ if err != nil || egressaddr.EntryString(a) != e {
return fmt.Errorf("%w: egress allow %q", ErrInvalid, e)
}
- if i > 0 && prev.Compare(a) >= 0 {
+ if err := egressaddr.AllowedPrefix(a); err != nil {
+ return fmt.Errorf("%w: egress allow %v", ErrInvalid, err)
+ }
+ if i > 0 && egressaddr.ComparePrefix(prev, a) >= 0 {
return fmt.Errorf("%w: egress allow %q out of order", ErrInvalid, e)
}
prev = a
diff --git a/internal/apppolicy/apppolicy_test.go b/internal/apppolicy/apppolicy_test.go
index eb4e734ad..1a2ce8b9d 100644
--- a/internal/apppolicy/apppolicy_test.go
+++ b/internal/apppolicy/apppolicy_test.go
@@ -76,6 +76,9 @@ func TestValidate(t *testing.T) {
{V: 1},
{V: 1, AppID: "x", EgressAllow: []string{"10.0.5.20", "fd00:5::20"}, DefaultSize: "small",
Sizes: map[string]SizeOverride{"shop-a.example.com": {"xlarge", t0}}},
+ // Prefixes in their stored form and decision 6's order: address,
+ // then prefix length, so a prefix sorts before its own first address.
+ {V: 1, EgressAllow: []string{"10.0.5.20", "10.0.64.0/20", "10.0.64.0", "fd00:5::/64", "fd00:5::20"}},
} {
if err := p.Validate(); err != nil {
t.Errorf("Validate(%+v) = %v", p, err)
@@ -99,6 +102,17 @@ func TestValidate(t *testing.T) {
"duplicate allows": {V: 1, EgressAllow: []string{"10.0.5.20", "10.0.5.20"}},
"allow with a port": {V: 1, EgressAllow: []string{"10.0.5.20:80"}},
"allow not in canon form": {V: 1, EgressAllow: []string{"::ffff:10.0.5.20"}},
+ "single stored as /32": {V: 1, EgressAllow: []string{"10.0.5.20/32"}},
+ "single stored as /128": {V: 1, EgressAllow: []string{"fd00:5::20/128"}},
+ "prefix with host bits": {V: 1, EgressAllow: []string{"10.0.64.5/20"}},
+ "prefix not canonical": {V: 1, EgressAllow: []string{"fd00:5:0::/64"}},
+ "prefix with space": {V: 1, EgressAllow: []string{" 10.0.64.0/20"}},
+ "prefix after its first": {V: 1, EgressAllow: []string{"10.0.64.0", "10.0.64.0/20"}},
+ "duplicate prefixes": {V: 1, EgressAllow: []string{"10.0.64.0/20", "10.0.64.0/20"}},
+ "prefix too wide": {V: 1, EgressAllow: []string{"10.0.0.0/8"}},
+ "prefix public": {V: 1, EgressAllow: []string{"8.8.8.0/24"}},
+ "prefix holds metadata": {V: 1, EgressAllow: []string{"fd00:ec2::/48"}},
+ "single public": {V: 1, EgressAllow: []string{"8.8.8.8"}},
} {
if err := p.Validate(); !errors.Is(err, ErrInvalid) {
t.Errorf("%s: Validate = %v, want ErrInvalid", name, err)
diff --git a/internal/console/egressfleet.go b/internal/console/egressfleet.go
index abfe747bb..cc4b6c79f 100644
--- a/internal/console/egressfleet.go
+++ b/internal/console/egressfleet.go
@@ -12,6 +12,11 @@
// fleet boxes) cannot be checked; the grant goes through and the door's
// reply names them as not_checked.
//
+// An added entry may be a prefix (#1357): it is refused when any published
+// box address lies in it (decision 8), and it is added only while every
+// fresh box of the deployment runs release.EgressPrefixFloor or later
+// (decision 9). Single addresses are never held by the floor.
+//
// Only additions are checked (ruling C5): a revoke, a re-send of the same
// list or a size-only change reads nothing, so a store outage never holds
// one up. A grant reads the edges files through the console's AddrCache,
@@ -40,37 +45,57 @@ import (
// Door copy (approved by delegation, Luna pass 2026-10-26; deck copy-instance-policy-plan2.md).
const (
- egressFleetHeldMsg = "%s is an address of box %s. an egress allow cannot open a box of this fleet"
+ egressFleetHeldMsg = "%s is an address of box %s. an egress allow cannot open a box of this fleet"
+ // egressFleetRangeHeldMsg and egressRangeBelowFloorMsg are #1357's,
+ // awaiting their copy pass.
+ egressFleetRangeHeldMsg = "%s overlaps %s, an address or range held by box %s. an egress allow cannot open a box of this fleet"
+ // egressRangeBelowFloorMsg is filled with the first fresh box below
+ // release.EgressPrefixFloor (by label), the release it runs
+ // (boxReleaseWord) and the floor.
+ egressRangeBelowFloorMsg = "box %s reports %s. allowing a range needs v%s or later on every box. single addresses are unaffected"
egressFleetUnreadableMsg = "box %s's address list could not be read. try again in a minute"
egressFleetOlderBoxMsg = "box %s does not publish its addresses yet. upgrade it before granting an egress allow"
egressFleetListMsg = "the fleet's address lists could not be read. try again in a minute"
egressFleetBoxesMsg = "the fleet's list of boxes could not be read. try again in a minute"
)
-// egressGrantCheck checks the addresses a grant adds (new minus old) against
+// egressGrantCheck checks the entries a grant adds (new minus old) against
// every readable edges file, whatever its age. notChecked: labels of
// non-stale boxes in systemBoxes that publish no edges file.
//
-// The refusals, in order: an added address a file lists (409, naming the
-// box); a listed file that could not be read (503, naming it); a file with
-// no addrs (409, naming its box); a failed listing of control/edges/ or of
-// the boxes (503). With nothing added it reads nothing.
-func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notChecked []string, ref *doorRefusal) {
+// The refusals, in order: an added range while a fresh box runs below
+// release.EgressPrefixFloor (409, naming the box) or the heartbeats could
+// not be read whole (503); an added entry holding an address a file lists
+// (409, naming the box); a listed file that could not be read (503, naming
+// it); a file with no addrs (409, naming its box); a failed listing of
+// control/edges/ or of the boxes (503). With nothing added it reads
+// nothing.
+func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Prefix) (notChecked []string, ref *doorRefusal) {
if len(added) == 0 {
return []string{}, nil
}
if s.cfg.Releases == nil {
return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetListMsg}
}
+ if slices.ContainsFunc(added, func(p netip.Prefix) bool { return !p.IsSingleIP() }) {
+ if ref := s.egressPrefixFloorRefusal(ctx); ref != nil {
+ return nil, ref
+ }
+ }
inv, err := edgesfile.ReadAddrsCached(ctx, s.cfg.Releases, &s.egressAddrs)
if err != nil {
s.policyLogf("console: egress grant check: list %s: %v", edgesfile.Prefix, err)
return nil, &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetListMsg}
}
- for _, a := range added {
- if box, ok := inv.Holder(a); ok {
- return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetHeldMsg, a, box)}
+ for _, p := range added {
+ box, held, ok := egressHolder(inv, p)
+ if !ok {
+ continue
+ }
+ if p.IsSingleIP() {
+ return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetHeldMsg, p.Addr(), box)}
}
+ return nil, &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressFleetRangeHeldMsg, p, held, box)}
}
if len(inv.Unreadable) > 0 {
s.policyLogf("console: egress grant check: unreadable edges files: %s", strings.Join(inv.Unreadable, ", "))
@@ -103,31 +128,123 @@ func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notC
return slices.Compact(notChecked), nil
}
+// egressHolder names the first box (by label) with a published address that
+// overlaps entry, and that address as the box published it (a bare address,
+// or a prefix). For a single address this is edgesfile's Holder; for a
+// prefix it is containment, the box's address inside the range (decision
+// 8). An IPv4-mapped entry is matched as IPv4.
+func egressHolder(inv edgesfile.AddrInventory, entry netip.Prefix) (box, held string, ok bool) {
+ if a := entry.Addr(); a.Is4In6() && entry.Bits() >= 96 {
+ entry = netip.PrefixFrom(a.Unmap(), entry.Bits()-96)
+ }
+ entry = netip.PrefixFrom(entry.Addr().WithZone(""), entry.Bits())
+ boxes := slices.Sorted(maps.Keys(inv.Boxes))
+ for _, b := range boxes {
+ for _, q := range inv.Boxes[b] {
+ if entry.Overlaps(q) {
+ return b, egressaddr.EntryString(q), true
+ }
+ }
+ }
+ return "", "", false
+}
+
+// egressPrefixFloorRefusal is the version floor on adding a range (decision
+// 9): nil when every fresh heartbeat box of the deployment (the platform's
+// and every fleet's, as an app can move to any box) runs
+// release.EgressPrefixFloor or later. A box below it would read the policy
+// as unverifiable and clear the app's whole allow. A deployment with no
+// fresh box admits, as teamFloorRefusal does. A release that is missing or
+// does not parse counts as below; heartbeats that cannot be read whole are
+// 503.
+func (s *Server) egressPrefixFloorRefusal(ctx context.Context) *doorRefusal {
+ boxes, ok := s.egressFloorBoxes(ctx)
+ if !ok {
+ return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: egressFleetBoxesMsg}
+ }
+ now := time.Now()
+ var old *status.Box
+ for i, b := range boxes {
+ if status.BoxStale(b, now, status.SnapshotPeriod) || boxAtEgressPrefixFloor(b) {
+ continue
+ }
+ if old == nil || b.Label < old.Label {
+ old = &boxes[i]
+ }
+ }
+ if old == nil {
+ return nil
+ }
+ return &doorRefusal{Status: http.StatusConflict, Msg: fmt.Sprintf(egressRangeBelowFloorMsg,
+ old.Label, boxReleaseWord(*old), release.EgressPrefixFloor.String())}
+}
+
+// boxAtEgressPrefixFloor is boxAtTeamFloor against release.EgressPrefixFloor.
+func boxAtEgressPrefixFloor(b status.Box) bool {
+ if b.Metrics == nil {
+ return false
+ }
+ v, ok := release.ParseReleaseVersion(b.Metrics.Release)
+ return ok && v.Compare(release.EgressPrefixFloor) >= 0
+}
+
+// egressFloorBoxes is every heartbeat of the deployment: the platform's and
+// each fleet's, less a fleet's detached boxes. ok is false when the fleets
+// or any heartbeat could not be read (systemBoxes, by contrast, reads past
+// an incomplete listing).
+func (s *Server) egressFloorBoxes(ctx context.Context) ([]status.Box, bool) {
+ reg, fleets, err := s.systemFleets()
+ if err != nil {
+ s.policyLogf("console: egress prefix floor: fleets: %v", err)
+ return nil, false
+ }
+ boxes, complete, err := s.loadBoxes(ctx, s.cfg.Releases, "")
+ if err != nil || !complete {
+ s.policyLogf("console: egress prefix floor: heartbeats: complete %t, %v", complete, err)
+ return nil, false
+ }
+ boxes = slices.Clone(boxes)
+ for _, f := range fleets {
+ fb, complete, err := s.loadBoxes(ctx, s.cfg.Releases, "fleets/"+f.Name+"/")
+ if err != nil || !complete {
+ s.policyLogf("console: egress prefix floor: fleet %s heartbeats: complete %t, %v", f.Name, complete, err)
+ return nil, false
+ }
+ detached, err := detachedFleetBoxes(ctx, reg, f.Name)
+ if err != nil {
+ s.policyLogf("console: egress prefix floor: fleet %s registry boxes: %v; counting every report", f.Name, err)
+ }
+ boxes = append(boxes, withoutDetached(fb, detached)...)
+ }
+ return boxes, true
+}
+
// edgesKeyBox is the box an edges file's key names: control/edges/<box>.json.
func edgesKeyBox(key string) string {
return strings.TrimSuffix(strings.TrimPrefix(key, edgesfile.Prefix), ".json")
}
-// grantAdded is next minus old, as addresses: what a grant opens that the
-// stored allow did not. next is the normalized list, so an entry that does
-// not parse is refused with egressaddr's reason; an old entry that does not
-// parse matches nothing.
-func grantAdded(old, next []string) ([]netip.Addr, error) {
- had := make(map[netip.Addr]bool, len(old))
+// grantAdded is next minus old, as entries (a single address is its
+// full-length prefix): what a grant opens that the stored allow did not. A
+// range and an address inside it are separate entries. next is the
+// normalized list, so an entry that does not parse is refused with
+// egressaddr's reason; an old entry that does not parse matches nothing.
+func grantAdded(old, next []string) ([]netip.Prefix, error) {
+ had := make(map[netip.Prefix]bool, len(old))
for _, o := range old {
- if a, err := egressaddr.Parse(o); err == nil {
- had[a] = true
+ if p, err := egressaddr.ParseEntry(o); err == nil {
+ had[p] = true
}
}
- var added []netip.Addr
+ var added []netip.Prefix
for _, n := range next {
- a, err := egressaddr.Parse(n)
+ p, err := egressaddr.ParseEntry(n)
if err != nil {
return nil, err
}
- if !had[a] {
- had[a] = true
- added = append(added, a)
+ if !had[p] {
+ had[p] = true
+ added = append(added, p)
}
}
return added, nil
@@ -166,12 +283,19 @@ var pageEgressConflict = alerting.Page
const (
egressConflictSubject = "Egress allow %s is now a fleet box's address."
egressConflictBody = "App %s in account id %s may reach %s, and box %s now holds that address. The allow is still in force. Set the whole list again without that address by running carlos apps set %s --egress-allow, or move the address off the box."
+ // The same alert for an allowed range (#1357, awaiting its copy pass).
+ egressRangeConflictSubject = "Egress allow %s now holds a fleet box's address."
+ egressRangeConflictBody = "App %s in account id %s may reach %s, and box %s now holds an address in that range. The allow is still in force. Set the whole list again without that range by running carlos apps set %s --egress-allow, or move the address off the box."
)
-// egressConflictAlert is the report's alert.
-func egressConflictAlert(sqid, app string, addr netip.Addr, box string) (subject, body string) {
- return fmt.Sprintf(egressConflictSubject, addr),
- fmt.Sprintf(egressConflictBody, app, sqid, addr, box, app)
+// egressConflictAlert is the report's alert for an allowed entry.
+func egressConflictAlert(sqid, app string, entry netip.Prefix, box string) (subject, body string) {
+ if !entry.IsSingleIP() {
+ return fmt.Sprintf(egressRangeConflictSubject, entry),
+ fmt.Sprintf(egressRangeConflictBody, app, sqid, entry, box, app)
+ }
+ return fmt.Sprintf(egressConflictSubject, entry.Addr()),
+ fmt.Sprintf(egressConflictBody, app, sqid, entry.Addr(), box, app)
}
// egressReportState is the report's memory. Every field after mu is guarded
@@ -186,10 +310,10 @@ type egressReportState struct {
// genOK (the watch could vouch for it then).
gen uint64
genOK bool
- // conflicts is the last pass's findings, address -> box; nil before
- // the first pass.
+ // conflicts is the last pass's findings, allowed entry (its stored
+ // form) -> box; nil before the first pass.
conflicts map[string]string
- // alerted is when each "<sqid>/<app> <addr>" alert was last sent.
+ // alerted is when each "<sqid>/<app> <entry>" alert was last sent.
alerted map[string]time.Time
now func() time.Time // nil: time.Now
@@ -213,13 +337,17 @@ func (s *Server) egressEdgesGen() (uint64, bool) {
return w.Gen(egressEdgesScope)
}
-// egressAllowed is one address of one app's allow.
+// egressAllowed is one entry of one app's allow: a single address as its
+// full-length prefix, or a range.
type egressAllowed struct {
sqid, app string
- addr netip.Addr
+ entry netip.Prefix
}
-// egressLiveAllows is every address of every live allow, read from the
+// key is the entry's stored form, the report's and the alert's key.
+func (a egressAllowed) key() string { return egressaddr.EntryString(a.entry) }
+
+// egressLiveAllows is every entry of every live allow, read from the
// console's own policy rows (AppPolicyRowsContext) and opened with the key
// they were signed with. unopened names the rows that do not open (or hold
// an entry that does not parse): their allows are not checked.
@@ -236,12 +364,12 @@ func (s *Server) egressLiveAllows(ctx context.Context) (allows []egressAllowed,
continue
}
for _, e := range p.EgressAllow {
- a, err := egressaddr.Parse(e)
+ p, err := egressaddr.ParseEntry(e)
if err != nil {
unopened = append(unopened, r.Sqid+"/"+r.App)
continue
}
- allows = append(allows, egressAllowed{sqid: r.Sqid, app: r.App, addr: a})
+ allows = append(allows, egressAllowed{sqid: r.Sqid, app: r.App, entry: p})
}
}
return allows, unopened, nil
@@ -375,12 +503,12 @@ func (s *Server) egressReportPass(ctx context.Context) error {
}
allowed := map[string]bool{}
for _, a := range allows {
- allowed[a.addr.String()] = true
- box, ok := inv.Holder(a.addr)
+ allowed[a.key()] = true
+ box, _, ok := egressHolder(inv, a.entry)
if !ok {
continue
}
- conflicts[a.addr.String()] = box
+ conflicts[a.key()] = box
s.egressAlert(ctx, a, box, now)
}
st.mu.Lock()
@@ -429,7 +557,7 @@ func egressBoxReadInFull(inv edgesfile.AddrInventory, box string) bool {
// address within egressAlertEvery. The slot is taken before the send and
// given back if it fails, so the next pass tries again.
func (s *Server) egressAlert(ctx context.Context, a egressAllowed, box string, now time.Time) {
- key := a.sqid + "/" + a.app + " " + a.addr.String()
+ key := a.sqid + "/" + a.app + " " + a.key()
st := &s.egressReport
st.mu.Lock()
if at, ok := st.alerted[key]; ok && now.Sub(at) < egressAlertEvery {
@@ -445,7 +573,7 @@ func (s *Server) egressAlert(ctx context.Context, a egressAllowed, box string, n
if page == nil {
page = pageEgressConflict
}
- subject, body := egressConflictAlert(a.sqid, a.app, a.addr, box)
+ subject, body := egressConflictAlert(a.sqid, a.app, a.entry, box)
sctx, cancel := context.WithTimeout(ctx, egressAlertTimeout)
defer cancel()
if err := page(sctx, alerting.LevelWarning, subject, body); err != nil {
@@ -458,8 +586,8 @@ func (s *Server) egressAlert(ctx context.Context, a egressAllowed, box string, n
}
}
-// egressConflicts is the last pass's findings, allowed address -> the box
-// that holds it, or nil before the first pass. The map is a copy.
+// egressConflicts is the last pass's findings, allowed entry -> the box
+// that holds it (or, for a range, an address in it), or nil before the first pass. The map is a copy.
func (s *Server) egressConflicts() map[string]string {
st := &s.egressReport
st.mu.Lock()
diff --git a/internal/console/egressfleet_test.go b/internal/console/egressfleet_test.go
index 8ada88f18..f90544759 100644
--- a/internal/console/egressfleet_test.go
+++ b/internal/console/egressfleet_test.go
@@ -136,11 +136,13 @@ func grantServer(t *testing.T) (*Server, *edgesCountingStore) {
return &Server{cfg: Config{Releases: cs}, policyLog: func(string, ...any) {}}, cs
}
-func addrs(t *testing.T, ss ...string) []netip.Addr {
+// addrs is single addresses as the full-length prefixes grantAdded gives.
+func addrs(t *testing.T, ss ...string) []netip.Prefix {
t.Helper()
- out := make([]netip.Addr, 0, len(ss))
+ out := make([]netip.Prefix, 0, len(ss))
for _, s := range ss {
- out = append(out, netip.MustParseAddr(s))
+ a := netip.MustParseAddr(s)
+ out = append(out, netip.PrefixFrom(a, a.BitLen()))
}
return out
}
@@ -975,3 +977,207 @@ func TestEgressReportKeepsAConflictItCannotRead(t *testing.T) {
fx.mustPut(t, "shop", `{"egress_allow":["10.0.5.21"]}`, policyIfMatch(first.ETag))
pass("the allow narrowed while betty is unreadable", map[string]string{})
}
+
+func prefixes(t *testing.T, ss ...string) []netip.Prefix {
+ t.Helper()
+ out := make([]netip.Prefix, 0, len(ss))
+ for _, s := range ss {
+ if !strings.Contains(s, "/") {
+ a := netip.MustParseAddr(s)
+ out = append(out, netip.PrefixFrom(a, a.BitLen()))
+ continue
+ }
+ out = append(out, netip.MustParsePrefix(s))
+ }
+ return out
+}
+
+// setBoxRelease writes a fresh heartbeat for label naming release rel ("" for
+// a heartbeat that names none).
+func setBoxRelease(t *testing.T, s release.Store, label, rel string, at time.Time) {
+ t.Helper()
+ if err := status.WriteBox(context.Background(), s, status.Box{Label: label, GeneratedAt: at, Metrics: &status.BoxMetrics{Release: rel}}); err != nil {
+ t.Fatalf("snapshot %s: %v", label, err)
+ }
+}
+
+// A range that holds a published box address is refused (409), naming the
+// box and the address; a range that holds none goes through. Decision 8.
+func TestEgressGrantRefusesARangeHoldingAFleetAddress(t *testing.T) {
+ t.Parallel()
+ s, cs := grantServer(t)
+ now := time.Now()
+ putEdgesAddrs(t, cs, "annie", []string{"10.0.64.7", "fd00:5::/64"})
+ setBoxRelease(t, cs, "annie", "v0.43.0", now)
+ for _, c := range []struct {
+ add string
+ want string
+ }{
+ {"10.0.64.0/20", "10.0.64.0/20 overlaps 10.0.64.7, an address or range held by box annie. an egress allow cannot open a box of this fleet"},
+ {"fd00:5::/48", "fd00:5::/48 overlaps fd00:5::/64, an address or range held by box annie. an egress allow cannot open a box of this fleet"},
+ } {
+ nc, ref := s.egressGrantCheck(context.Background(), prefixes(t, c.add))
+ if ref == nil || ref.Status != http.StatusConflict || ref.Msg != c.want {
+ t.Errorf("grant %s = %v %+v, want 409 %q", c.add, nc, ref, c.want)
+ }
+ }
+ nc, ref := s.egressGrantCheck(context.Background(), prefixes(t, "10.0.80.0/20", "fd00:6::/48"))
+ if ref != nil || nc == nil || len(nc) != 0 {
+ t.Fatalf("ranges no box address is in = %#v %+v, want [] and no refusal", nc, ref)
+ }
+}
+
+// Through the door: a range is added only while every fresh box runs
+// EgressPrefixFloor or later (decision 9). A single address is never held
+// up by the floor, nor is a revoke of a range.
+func TestPolicyDoorRangeNeedsTheFloorOnEveryBox(t *testing.T) {
+ t.Parallel()
+ fx := newPolicyFx(t, "code-policy-range-floor")
+ now := time.Now()
+ putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.1.5"})
+ setBoxRelease(t, fx.rel, "annie", "v0.43.0", now)
+ putEdgesAddrs(t, fx.rel, "betty", []string{"10.0.1.6"})
+ setBoxRelease(t, fx.rel, "betty", "v0.42.1", now)
+ putEdgesAddrs(t, fx.rel, "olive", []string{"10.0.1.7"})
+ setBoxRelease(t, fx.rel, "olive", "v0.30.0", now.Add(-24*time.Hour)) // stale: not counted
+
+ st, _, out := fx.put(t, "shop", `{"egress_allow":["10.0.64.0/20"]}`, policyCreate)
+ if want := "box betty reports v0.42.1. allowing a range needs v0.43.0 or later on every box. single addresses are unaffected"; st != http.StatusConflict || errorOf(t, out) != want {
+ t.Fatalf("a range with betty on v0.42.1 = %d %s, want 409 %q", st, out, want)
+ }
+ fx.noObject(t, "shop")
+
+ single := fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.5"]}`, policyCreate)
+
+ setBoxRelease(t, fx.rel, "betty", "v0.43.0", now)
+ ranged := fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.0/20","10.0.64.5"]}`, policyIfMatch(single.ETag))
+ if want := []string{"10.0.64.0/20", "10.0.64.5"}; !slices.Equal(ranged.Policy.EgressAllow, want) {
+ t.Fatalf("allow = %v, want %v", ranged.Policy.EgressAllow, want)
+ }
+
+ setBoxRelease(t, fx.rel, "betty", "", now) // names no release: below
+ if st, _, out := fx.put(t, "shop", `{"egress_allow":["10.0.64.0/20","fd00:5::/64"]}`, policyIfMatch(ranged.ETag)); st != http.StatusConflict ||
+ errorOf(t, out) != "box betty reports no release. allowing a range needs v0.43.0 or later on every box. single addresses are unaffected" {
+ t.Fatalf("a second range with betty naming no release = %d %s, want 409", st, out)
+ }
+ fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.0/20"]}`, policyIfMatch(ranged.ETag))
+}
+
+// A heartbeat read that fails refuses a range with 503: the floor is not
+// passed on what the console could not see.
+func TestEgressGrantRangeFloorUnreadable(t *testing.T) {
+ t.Parallel()
+ s, cs := grantServer(t)
+ putEdgesAddrs(t, cs, "annie", []string{"10.0.1.5"})
+ setBoxRelease(t, cs, "annie", "v0.43.0", time.Now())
+ cs.fail(true)
+ _, ref := s.egressGrantCheck(context.Background(), prefixes(t, "10.0.64.0/20"))
+ if want := "the fleet's list of boxes could not be read. try again in a minute"; ref == nil ||
+ ref.Status != http.StatusServiceUnavailable || ref.Msg != want {
+ t.Fatalf("a range with heartbeats unreadable = %+v, want 503 %q", ref, want)
+ }
+}
+
+// grantAdded works on prefixes: an entry already allowed is not added, and
+// a range and an address inside it are separate entries.
+func TestGrantAddedPrefixes(t *testing.T) {
+ t.Parallel()
+ got, err := grantAdded([]string{"10.0.64.0/20", "10.0.5.20"}, []string{"10.0.64.0/20", "10.0.64.5", "fd00:5::/64"})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if want := prefixes(t, "10.0.64.5", "fd00:5::/64"); !slices.Equal(got, want) {
+ t.Fatalf("added = %v, want %v", got, want)
+ }
+}
+
+// The report checks a range by containment: a box that later takes an
+// address inside an allowed range is found, alerted on, and named by GET
+// (which `apps show` marks with "!").
+func TestEgressReportFlagsARangeHoldingABoxAddress(t *testing.T) {
+ t.Parallel()
+ fx := newReportFx(t, "code-egress-report-range")
+ setBoxRelease(t, fx.cs, "annie", "v0.43.0", time.Now())
+ putEdgesAddrs(t, fx.cs, "annie", []string{"10.0.1.5"})
+ fx.mustPut(t, "shop", `{"egress_allow":["10.0.64.0/20","10.0.5.21"]}`, policyCreate)
+ if !fx.tick(t) {
+ t.Fatal("the first tick with a live allow ran no pass")
+ }
+ if got := fx.srv.egressConflicts(); len(got) != 0 {
+ t.Fatalf("conflicts before a box takes an address = %v", got)
+ }
+ putEdgesAddrs(t, fx.cs, "betty", []string{"10.0.64.9"})
+ if n := fx.ticks(t, reportBackstopTo); n != 1 {
+ t.Fatalf("the backstop ran %d passes, want 1", n)
+ }
+ if got := fx.srv.egressConflicts(); !maps.Equal(got, map[string]string{"10.0.64.0/20": "betty"}) {
+ t.Fatalf("conflicts = %v, want 10.0.64.0/20 on betty", got)
+ }
+ want := "Egress allow 10.0.64.0/20 now holds a fleet box's address.\n" +
+ "App shop in account id " + fx.sqid + " may reach 10.0.64.0/20, and box betty now holds an address in that range. " +
+ "The allow is still in force. Set the whole list again without that range by running carlos apps set shop --egress-allow, or move the address off the box."
+ if got := fx.sent(); len(got) != 1 || got[0] != want {
+ t.Fatalf("pages = %q, want one: %q", got, want)
+ }
+ if g := fx.get(t, "shop"); !slices.Equal(g.EgressConflicts, []string{"10.0.64.0/20"}) {
+ t.Fatalf("GET egress_conflicts = %v, want [10.0.64.0/20]", g.EgressConflicts)
+ }
+}
+
+// carlos status --layout marks a range the report found, in the form the box
+// reports it (the entry's stored form).
+func TestEgressViewMarksARange(t *testing.T) {
+ t.Parallel()
+ e := egressView(status.HostEgress{Allowed: []string{"10.0.5.20", "10.0.64.0/20"}}, true, map[string]string{"10.0.64.0/20": "betty"})
+ if !slices.Equal(e.Conflicts, []string{"10.0.64.0/20"}) {
+ t.Fatalf("conflicts = %v, want [10.0.64.0/20]", e.Conflicts)
+ }
+}
+
+// The floor reads every fleet's heartbeats as well as the platform's: an
+// old box under fleets/<name>/ refuses a range, a detached one does not
+// count, and a fleet heartbeat that cannot be read refuses with 503.
+func TestEgressGrantRangeFloorCountsFleetBoxes(t *testing.T) {
+ t.Parallel()
+ fx := newConsoleFixture(t)
+ now := time.Now()
+ putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.1.5"})
+ setBoxRelease(t, fx.rel, "annie", "v0.43.0", now)
+ reg := openTestReg(t, fx)
+ t.Cleanup(func() { reg.Close() })
+ if _, err := reg.CreateFleet(registry.Fleet{Name: "fx", Account: fx.sqid, Bucket: "fx-data"}); err != nil {
+ t.Fatal(err)
+ }
+ for _, label := range []string{"bx-1", "bx-2"} {
+ if err := reg.AddFleetBox(registry.FleetBox{Fleet: "fx", Label: label, TokenHash: strings.Repeat("a", 64)}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ fleet := release.NewPrefixStore(fx.rel, "fleets/fx/")
+ setBoxRelease(t, fleet, "bx-1", "v0.43.0", now)
+ setBoxRelease(t, fleet, "bx-2", "v0.42.1", now)
+ ctx := context.Background()
+
+ _, ref := fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.0/20"))
+ if want := "box bx-2 reports v0.42.1. allowing a range needs v0.43.0 or later on every box. single addresses are unaffected"; ref == nil ||
+ ref.Status != http.StatusConflict || ref.Msg != want {
+ t.Fatalf("a range with fleet box bx-2 on v0.42.1 = %+v, want 409 %q", ref, want)
+ }
+
+ if err := reg.SetFleetBoxStatus("fx", "bx-2", "detached"); err != nil {
+ t.Fatal(err)
+ }
+ if _, ref := fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.0/20")); ref != nil {
+ t.Fatalf("a range with old bx-2 detached = %+v, want no refusal", ref)
+ }
+
+ putFixtureObject(t, fleet, "status/boxes/bx-3.json", []byte(`{"label":"bx-3",`))
+ _, ref = fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.0/20"))
+ if want := "the fleet's list of boxes could not be read. try again in a minute"; ref == nil ||
+ ref.Status != http.StatusServiceUnavailable || ref.Msg != want {
+ t.Fatalf("a range with a fleet heartbeat unreadable = %+v, want 503 %q", ref, want)
+ }
+ if _, ref := fx.srv.egressGrantCheck(ctx, prefixes(t, "10.0.64.5")); ref != nil {
+ t.Fatalf("a single address with a fleet heartbeat unreadable = %+v, want no refusal", ref)
+ }
+}
diff --git a/internal/dbreads/fixture_test.go b/internal/dbreads/fixture_test.go
index c2ec8ee2e..171c0eb5b 100644
--- a/internal/dbreads/fixture_test.go
+++ b/internal/dbreads/fixture_test.go
@@ -47,6 +47,11 @@ type inProcWorkers struct {
failStart atomic.Bool
// sent is the type of every frame the agent wrote, in order.
sent []byte
+ // running counts the in-process workers still serving: the agent's
+ // Wait ends with the read, while a worker (its own unit in
+ // production) may still be clearing its scratch, so the test waits
+ // for them before its temporary directories go.
+ running sync.WaitGroup
}
// frameTap records the first byte of each Write the agent makes: one frame
@@ -78,10 +83,14 @@ func (w *inProcWorkers) dial(context.Context) (net.Conn, error) {
w.mu.Unlock()
w.dials.Add(1)
w.live.Add(1)
+ // Registered after any TempDir below, so it runs before their removal.
+ defer w.t.Cleanup(w.waitRunning)
+ w.running.Add(1)
if w.failStart.Load() {
// The socket accepted and the service died: the plan's header is
// read by nobody useful, and the connection drops.
go func() {
+ defer w.running.Done()
readFrame(workerEnd)
workerEnd.Close()
time.Sleep(w.linger)
@@ -100,6 +109,7 @@ func (w *inProcWorkers) dial(context.Context) (net.Conn, error) {
opt.Self = func() HelloReply { return HelloReply{V: ProtocolVersion, Interfaces: []string{"lo"}} }
}
go func() {
+ defer w.running.Done()
ServeWorker(workerEnd, opt)
workerEnd.Close()
time.Sleep(w.linger)
@@ -108,6 +118,17 @@ func (w *inProcWorkers) dial(context.Context) (net.Conn, error) {
return frameTap{Conn: agentEnd, w: w}, nil
}
+// waitRunning waits, bounded, for every in-process worker to return.
+func (w *inProcWorkers) waitRunning() {
+ done := make(chan struct{})
+ go func() { w.running.Wait(); close(done) }()
+ select {
+ case <-done:
+ case <-time.After(30 * time.Second):
+ w.t.Error("an in-process worker was still serving 30 s after the test")
+ }
+}
+
func (w *inProcWorkers) units(context.Context) (int, error) { return int(w.live.Load()), nil }
func plentyFree() (uint64, uint64, error) { return 100 << 30, 200 << 30, nil }
diff --git a/internal/egressaddr/egressaddr.go b/internal/egressaddr/egressaddr.go
index bc938751c..384c6cf5c 100644
--- a/internal/egressaddr/egressaddr.go
+++ b/internal/egressaddr/egressaddr.go
@@ -3,11 +3,18 @@
// rule set the console door applies when an operator grants an address and
// root applies again on the box before it writes the allow.
//
-// An allow re-opens one address the instance fence closes. So an allow must
-// be a single address, inside the fence (a public address is already
-// reachable), and never one of the classes no tenant may reach from any
-// box: loopback, unspecified, link-local, the metadata service, multicast,
-// the reserved ranges and the NAT64 prefix.
+// An allow re-opens an address, or a range of addresses, the instance fence
+// closes. An entry is a single address or a prefix (#1357). It must lie
+// wholly inside the fence (a public address is already reachable) and hold
+// none of the classes no tenant may reach from any box: loopback,
+// unspecified, link-local, the metadata service, multicast, the reserved
+// ranges and the NAT64 prefix. A prefix is allowed exactly when every
+// address in it would be allowed alone, checked on the prefix, not by
+// enumeration, and it is no wider than MinPrefixV4 or MinPrefixV6.
+//
+// A single address is stored as the bare address, so a list of singles
+// reads the same as before prefixes. Parse stays the single-address
+// reader for callers that need one address and refuses a prefix.
//
// FenceDeny is the fence itself, the IPAddressDeny= line the instance unit
// templates write. internal/host's TestInstanceFenceIsEgressaddrFenceDeny
@@ -28,9 +35,17 @@ import (
"strings"
)
-// MaxAllow is the most addresses one app may be granted.
+// MaxAllow is the most entries one app may be granted. A prefix counts as
+// one entry.
const MaxAllow = 8
+// The widest prefix an entry may be: /16 is the largest AWS VPC, /48 a ULA
+// site prefix (RFC 4193).
+const (
+ MinPrefixV4 = 16
+ MinPrefixV6 = 48
+)
+
// Refusal text. A person reads these at the door and in root's report.
const (
msgEmpty = "an address is empty"
@@ -38,15 +53,18 @@ const (
msgPort = "%q has a port. an allow opens an address, never a port"
msgZone = "%q has a zone. name the address without it"
msgNotAddr = "%q is not an IP address"
- msgLoopback = "%s is a loopback address"
+ msgLoopback = "%s is loopback"
msgUnspecified = "%s is the unspecified address"
- msgMetadata = "%s is the cloud metadata service"
+ msgMetadata = "%s would reach the cloud metadata service"
msgLinkLocal = "%s is link-local"
- msgMulticast = "%s is a multicast address"
- msgReserved = "%s is in %s, a reserved range"
+ msgMulticast = "%s is multicast"
+ msgReserved = "%s is in or overlaps %s, a reserved range"
msgNAT64 = "%s is in the NAT64 prefix 64:ff9b::/96, which reaches any IPv4 address"
msgPublic = "%s is a public address and is already reachable. no allow is needed"
- msgTooMany = "at most %d addresses per app (%d given)"
+ msgTooMany = "at most %d entries per app (%d given)"
+ msgHostBits = "%q has host bits set. write it as %s"
+ msgWide = "%s is wider than /%d. allow at most a /%d"
+ msgNotPrivate = "%s is not wholly inside a private range"
)
// FenceDeny is the instance fence: the IPAddressDeny= line of the instance
@@ -61,6 +79,12 @@ var FenceDeny = mustPrefixes(
)
var (
+ // The classes a prefix may not overlap, as Allowed's net/netip tests
+ // read them.
+ loopback = mustPrefixes("127.0.0.0/8", "::1/128")
+ linkLocal = mustPrefixes("169.254.0.0/16", "fe80::/10")
+ multicast = mustPrefixes("224.0.0.0/4", "ff00::/8")
+
// The cloud metadata service's two addresses (as ResolverAllowed).
metadataV4 = netip.MustParseAddr("169.254.169.254")
metadataV6 = netip.MustParseAddr("fd00:ec2::254")
@@ -139,40 +163,158 @@ func Allowed(a netip.Addr) error {
return fmt.Errorf(msgPublic, a)
}
+// ParseEntry reads one entry as an operator writes it: surrounding space
+// trimmed, a single address (as Parse reads it) or a prefix a/n with no
+// host bits set, port or zone. A single address becomes its full-length
+// prefix. An IPv4-mapped IPv6 prefix is refused.
+func ParseEntry(s string) (netip.Prefix, error) {
+ s = strings.TrimSpace(s)
+ slash := strings.LastIndex(s, "/")
+ if slash < 0 {
+ a, err := Parse(s)
+ if err != nil {
+ return netip.Prefix{}, err
+ }
+ return netip.PrefixFrom(a, a.BitLen()), nil
+ }
+ if strings.Contains(s[slash:], ":") {
+ return netip.Prefix{}, fmt.Errorf(msgPort, s)
+ }
+ if strings.Contains(s, "%") {
+ return netip.Prefix{}, fmt.Errorf(msgZone, s)
+ }
+ p, err := netip.ParsePrefix(s)
+ if err != nil || p.Addr().Is4In6() {
+ return netip.Prefix{}, fmt.Errorf(msgNotAddr, s)
+ }
+ if m := p.Masked(); m != p {
+ return netip.Prefix{}, fmt.Errorf(msgHostBits, s, m)
+ }
+ return p, nil
+}
+
+// AllowedPrefix reports why p may not be granted, or nil if it may. A
+// full-length prefix is the single address and gets Allowed's answer. A
+// wider one must be no wider than the minimum length, lie wholly inside
+// one FenceDeny range, and overlap none of the refused classes, so every
+// address in it would pass Allowed.
+func AllowedPrefix(p netip.Prefix) error {
+ if !p.IsValid() || (p.Addr().Is4In6() && !p.IsSingleIP()) {
+ return fmt.Errorf(msgNotAddr, p.String())
+ }
+ if p.IsSingleIP() {
+ return Allowed(p.Addr())
+ }
+ if m := p.Masked(); m != p {
+ return fmt.Errorf(msgHostBits, p.String(), m)
+ }
+ minBits := MinPrefixV6
+ if p.Addr().Is4() {
+ minBits = MinPrefixV4
+ }
+ if p.Bits() < minBits {
+ return fmt.Errorf(msgWide, p, minBits, minBits)
+ }
+ inside := false
+ for _, f := range FenceDeny {
+ if f.Bits() <= p.Bits() && f.Contains(p.Addr()) {
+ inside = true
+ break
+ }
+ }
+ if !inside {
+ return fmt.Errorf(msgNotPrivate, p)
+ }
+ // Link-local before metadata: a link-local prefix holding the
+ // metadata address reads better as link-local.
+ switch {
+ case overlapsAny(p, loopback):
+ return fmt.Errorf(msgLoopback, p)
+ case overlapsAny(p, linkLocal):
+ return fmt.Errorf(msgLinkLocal, p)
+ case p.Contains(metadataV4), p.Contains(metadataV6):
+ return fmt.Errorf(msgMetadata, p)
+ case overlapsAny(p, multicast):
+ return fmt.Errorf(msgMulticast, p)
+ }
+ for _, r := range reserved {
+ if r.Overlaps(p) {
+ return fmt.Errorf(msgReserved, p, r)
+ }
+ }
+ if nat64.Overlaps(p) {
+ return fmt.Errorf(msgNAT64, p)
+ }
+ // Unspecified is inside 0.0.0.0/8 (reserved) for IPv4 and outside
+ // the fence for IPv6, so it is refused above; kept for the rule set.
+ if p.Contains(netip.IPv4Unspecified()) || p.Contains(netip.IPv6Unspecified()) {
+ return fmt.Errorf(msgUnspecified, p)
+ }
+ return nil
+}
+
+func overlapsAny(p netip.Prefix, ps []netip.Prefix) bool {
+ for _, q := range ps {
+ if q.Overlaps(p) {
+ return true
+ }
+ }
+ return false
+}
+
// Normalize turns an operator's list into the stored form: every
-// non-empty entry parsed and allowed, duplicates collapsed, sorted (IPv4
-// before IPv6), at most MaxAllow after the collapse, each in its
-// canonical text. An empty result is nil. The first refused entry is the
-// error.
+// non-empty entry parsed and allowed, exact duplicates collapsed (an entry
+// inside another is kept), sorted by address then prefix length (IPv4
+// before IPv6), at most MaxAllow after the collapse. A full-length prefix
+// is stored as the bare address, any other as its canonical prefix text.
+// An empty result is nil. The first refused entry is the error.
func Normalize(in []string) ([]string, error) {
- seen := map[netip.Addr]bool{}
- var addrs []netip.Addr
+ seen := map[netip.Prefix]bool{}
+ var entries []netip.Prefix
for _, s := range in {
if strings.TrimSpace(s) == "" {
continue
}
- a, err := Parse(s)
+ p, err := ParseEntry(s)
if err != nil {
return nil, err
}
- if err := Allowed(a); err != nil {
+ if err := AllowedPrefix(p); err != nil {
return nil, err
}
- if !seen[a] {
- seen[a] = true
- addrs = append(addrs, a)
+ if !seen[p] {
+ seen[p] = true
+ entries = append(entries, p)
}
}
- if len(addrs) > MaxAllow {
- return nil, fmt.Errorf(msgTooMany, MaxAllow, len(addrs))
+ if len(entries) > MaxAllow {
+ return nil, fmt.Errorf(msgTooMany, MaxAllow, len(entries))
}
- if len(addrs) == 0 {
+ if len(entries) == 0 {
return nil, nil
}
- slices.SortFunc(addrs, netip.Addr.Compare)
- out := make([]string, len(addrs))
- for i, a := range addrs {
- out[i] = a.String()
+ slices.SortFunc(entries, ComparePrefix)
+ out := make([]string, len(entries))
+ for i, p := range entries {
+ out[i] = EntryString(p)
}
return out, nil
}
+
+// ComparePrefix is the stored order: by address (IPv4 before IPv6), then
+// by prefix length, so 10.0.64.0/20 comes before 10.0.64.0.
+func ComparePrefix(a, b netip.Prefix) int {
+ if c := a.Addr().Compare(b.Addr()); c != 0 {
+ return c
+ }
+ return a.Bits() - b.Bits()
+}
+
+// EntryString is p's stored form: a full-length prefix as the bare
+// address, any other as its canonical prefix text.
+func EntryString(p netip.Prefix) string {
+ if p.IsSingleIP() {
+ return p.Addr().String()
+ }
+ return p.String()
+}
diff --git a/internal/egressaddr/egressaddr_test.go b/internal/egressaddr/egressaddr_test.go
index b3ec2f03e..d2d07c133 100644
--- a/internal/egressaddr/egressaddr_test.go
+++ b/internal/egressaddr/egressaddr_test.go
@@ -4,6 +4,7 @@ import (
"fmt"
"net/netip"
"reflect"
+ "slices"
"strings"
"testing"
)
@@ -116,7 +117,7 @@ func TestNormalize(t *testing.T) {
for i := 1; i <= 9; i++ {
nine = append(nine, fmt.Sprintf("10.0.5.%d", i))
}
- if _, err := Normalize(nine); err == nil || !strings.Contains(err.Error(), "at most 8 addresses per app (9 given)") {
+ if _, err := Normalize(nine); err == nil || !strings.Contains(err.Error(), "at most 8 entries per app (9 given)") {
t.Errorf("Normalize(nine) error %v, want the cap", err)
}
// The cap counts after the dedupe: eight addresses given twice each fit.
@@ -127,3 +128,185 @@ func TestNormalize(t *testing.T) {
t.Errorf("Normalize with a public address error %v, want it refused", err)
}
}
+
+// acceptedEntries are entries an operator may grant, each with its
+// stored form.
+var acceptedEntries = map[string]string{
+ "10.0.64.0/20": "10.0.64.0/20",
+ "10.0.0.0/16": "10.0.0.0/16",
+ "172.16.0.0/16": "172.16.0.0/16",
+ "192.168.0.0/16": "192.168.0.0/16",
+ "100.64.0.0/16": "100.64.0.0/16",
+ "fd00:5::/64": "fd00:5::/64",
+ "fd00:5::/48": "fd00:5::/48",
+ "10.0.5.20/32": "10.0.5.20",
+ "fd00:5::20/128": "fd00:5::20",
+ "10.0.5.20": "10.0.5.20",
+ " fd00:5::20 ": "fd00:5::20",
+}
+
+func TestEntriesAccepted(t *testing.T) {
+ for in, want := range acceptedEntries {
+ got, err := Normalize([]string{in})
+ if err != nil {
+ t.Errorf("Normalize(%q): %v", in, err)
+ continue
+ }
+ if len(got) != 1 || got[0] != want {
+ t.Errorf("Normalize(%q) = %q, want [%s]", in, got, want)
+ }
+ }
+}
+
+func TestEntriesRefused(t *testing.T) {
+ for in, want := range map[string]string{
+ "10.0.0.0/8": "10.0.0.0/8 is wider than /16. allow at most a /16",
+ "10.0.0.0/15": "10.0.0.0/15 is wider than /16. allow at most a /16",
+ "fd00::/47": "fd00::/47 is wider than /48. allow at most a /48",
+ "10.0.64.5/20": `"10.0.64.5/20" has host bits set. write it as 10.0.64.0/20`,
+ "169.254.0.0/16": "169.254.0.0/16 is link-local",
+ "169.254.169.0/24": "169.254.169.0/24 is link-local",
+ "fd00:ec2::/48": "fd00:ec2::/48 would reach the cloud metadata service",
+ "64:ff9b::/96": "64:ff9b::/96 is in the NAT64 prefix 64:ff9b::/96, which reaches any IPv4 address",
+ "198.18.0.0/16": "198.18.0.0/16 is in or overlaps 198.18.0.0/15, a reserved range",
+ "8.8.8.0/24": "8.8.8.0/24 is not wholly inside a private range",
+ "0.0.0.0/16": "0.0.0.0/16 is in or overlaps 0.0.0.0/8, a reserved range",
+ "224.0.0.0/16": "224.0.0.0/16 is multicast",
+ "127.0.0.0/16": "127.0.0.0/16 is loopback",
+ "fe80::/64": "fe80::/64 is link-local",
+ "10.0.64.0/20:5432": `"10.0.64.0/20:5432" has a port. an allow opens an address, never a port`,
+ "::ffff:10.0.0.0/112": `"::ffff:10.0.0.0/112" is not an IP address`,
+ "10.0.0.0/16%eth0": "has a zone",
+ "10.0.0.0/33": "is not an IP address",
+ "10.0.0.0/": "is not an IP address",
+ "fd00:5::/129": "is not an IP address",
+ "172.16.0.0/12": "172.16.0.0/12 is wider than /16",
+ "fec0::/48": "fec0::/48 is in or overlaps fec0::/10, a reserved range",
+ "2001:db8::/48": "2001:db8::/48 is not wholly inside a private range",
+ "8.8.8.8/32": "8.8.8.8 is a public address",
+ "169.254.169.254/32": "169.254.169.254 would reach the cloud metadata service",
+ } {
+ got, err := Normalize([]string{in})
+ if err == nil {
+ t.Errorf("Normalize(%q) = %q, want an error containing %q", in, got, want)
+ continue
+ }
+ if !strings.Contains(err.Error(), want) {
+ t.Errorf("Normalize(%q) error %q, want it to contain %q", in, err, want)
+ }
+ }
+}
+
+func TestParseEntryUnmapsAndKeepsParseStrict(t *testing.T) {
+ p, err := ParseEntry("::ffff:10.0.5.20")
+ if err != nil || p != netip.MustParsePrefix("10.0.5.20/32") {
+ t.Errorf("ParseEntry(::ffff:10.0.5.20) = %s, %v; want 10.0.5.20/32", p, err)
+ }
+ if _, err := ParseEntry(""); err == nil || err.Error() != "an address is empty" {
+ t.Errorf("ParseEntry(\"\") error %v, want empty", err)
+ }
+ // Parse stays the single-address reader: an old box refuses a range.
+ if _, err := Parse("10.0.64.0/20"); err == nil || !strings.Contains(err.Error(), "is a range") {
+ t.Errorf("Parse(10.0.64.0/20) error %v, want the range refusal", err)
+ }
+}
+
+func TestNormalizeSortsAndDedupsEntries(t *testing.T) {
+ got, err := Normalize([]string{"fd00:5::/64", "10.0.64.0", "10.0.64.0/20", "10.0.64.0/20", "10.0.64.0/32"})
+ if err != nil {
+ t.Fatalf("Normalize: %v", err)
+ }
+ if want := []string{"10.0.64.0/20", "10.0.64.0", "fd00:5::/64"}; !reflect.DeepEqual(got, want) {
+ t.Errorf("Normalize = %q, want %q", got, want)
+ }
+ got, err = Normalize([]string{"10.0.64.0", "10.0.64.0/20", "10.0.64.0/20"})
+ if err != nil {
+ t.Fatalf("Normalize: %v", err)
+ }
+ if want := []string{"10.0.64.0/20", "10.0.64.0"}; !reflect.DeepEqual(got, want) {
+ t.Errorf("Normalize = %q, want %q", got, want)
+ }
+}
+
+func TestNormalizeCountsPrefixesAsEntries(t *testing.T) {
+ var nine []string
+ for i := 1; i <= 9; i++ {
+ nine = append(nine, fmt.Sprintf("10.%d.0.0/16", i))
+ }
+ if _, err := Normalize(nine); err == nil || !strings.Contains(err.Error(), "at most 8 entries per app (9 given)") {
+ t.Errorf("Normalize(nine prefixes) error %v, want the cap", err)
+ }
+ if got, err := Normalize(nine[:8]); err != nil || len(got) != MaxAllow {
+ t.Errorf("Normalize(eight prefixes) = %q, %v; want eight and no error", got, err)
+ }
+}
+
+// lastAddr is the highest address in p.
+func lastAddr(p netip.Prefix) netip.Addr {
+ b := p.Masked().Addr().AsSlice()
+ for i := p.Bits(); i < len(b)*8; i++ {
+ b[i/8] |= 0x80 >> (i % 8)
+ }
+ a, _ := netip.AddrFromSlice(b)
+ return a
+}
+
+// AllowedPrefix agrees with Allowed at the edges: an accepted prefix's
+// first and last addresses would each be accepted alone.
+func TestAcceptedPrefixEdgesPassAllowed(t *testing.T) {
+ for in := range acceptedEntries {
+ p, err := ParseEntry(in)
+ if err != nil {
+ t.Fatalf("ParseEntry(%q): %v", in, err)
+ }
+ if err := AllowedPrefix(p); err != nil {
+ t.Fatalf("AllowedPrefix(%s): %v", p, err)
+ }
+ for _, a := range []netip.Addr{p.Addr(), lastAddr(p)} {
+ if err := Allowed(a); err != nil {
+ t.Errorf("%s is accepted but its edge %s is not: %v", p, a, err)
+ }
+ }
+ }
+}
+
+// Parse is the single-address reader an old box's code shape still uses:
+// it refuses every prefix form, a full-length one included, so an old
+// box's Validate fails on a prefix and never reads it as an address.
+func TestParseRefusesEveryPrefixForm(t *testing.T) {
+ for _, in := range []string{
+ "10.0.64.0/20", "10.0.5.20/32", "10.0.64.5/20", " 10.0.64.0/20 ", "10.0.0.0/8",
+ "fd00:5::/64", "fd00:5::20/128", "::ffff:10.0.5.20/128", "10.0.64.0/", "/20",
+ } {
+ if a, err := Parse(in); err == nil {
+ t.Errorf("Parse(%q) = %s, want a refusal", in, a)
+ }
+ }
+}
+
+// ComparePrefix is decision 6's order, and EntryString the stored form:
+// the one definition Normalize, apppolicy.Validate and root share.
+func TestComparePrefixAndEntryString(t *testing.T) {
+ in := []string{"fd00:5::/64", "10.0.64.0", "fd00:5::", "10.0.64.0/20", "10.0.5.20", "10.0.64.0/24"}
+ var ps []netip.Prefix
+ for _, s := range in {
+ p, err := ParseEntry(s)
+ if err != nil {
+ t.Fatal(err)
+ }
+ ps = append(ps, p)
+ }
+ slices.SortFunc(ps, ComparePrefix)
+ var got []string
+ for _, p := range ps {
+ got = append(got, EntryString(p))
+ }
+ want := []string{"10.0.5.20", "10.0.64.0/20", "10.0.64.0/24", "10.0.64.0", "fd00:5::/64", "fd00:5::"}
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("sorted = %q, want %q", got, want)
+ }
+ norm, err := Normalize(in)
+ if err != nil || !reflect.DeepEqual(norm, want) {
+ t.Errorf("Normalize = %q, %v; want %q", norm, err, want)
+ }
+}
diff --git a/internal/host/egress_fixtures_rootrunner_linux_test.go b/internal/host/egress_fixtures_rootrunner_linux_test.go
index 6cfa25609..cd85608d2 100644
--- a/internal/host/egress_fixtures_rootrunner_linux_test.go
+++ b/internal/host/egress_fixtures_rootrunner_linux_test.go
@@ -197,7 +197,7 @@ func egressTargetNetns(t *testing.T) map[string]string {
// the test's end, tears it down once, last-made first.
func egressTargetNetnsClosable(t *testing.T) (map[string]string, func()) {
t.Helper()
- return egressTargetNetnsAt(t, egressNetnsTask13)
+ return egressTargetNetnsAt(t, egressNetnsTask13, egressNetnsTask13Addrs)
}
// egressNetnsNames names a target fixture's namespace and veth pair, so
@@ -210,9 +210,24 @@ type egressNetnsNames struct {
// egressNetnsTask13 is Task 13's fixture (carlos-egr, carlos-egr1/1n).
var egressNetnsTask13 = egressNetnsNames{ns: egressNetns, hostLink: egressHostLink, nsLink: egressNsLink}
+// egressNetnsAddrs lays out a target fixture's addresses: the box end's
+// IPv4 and IPv6 address (each a host address; box6 "" for none) and the
+// targets inside the namespace, each IPv4 or IPv6.
+type egressNetnsAddrs struct {
+ box4, box6 string
+ targets []string
+}
+
+// egressNetnsTask13Addrs is the layout Task 13's and Task 14's witnesses
+// use: 10.0.5.1 and fd00:5::1 on the box end, egressTargets inside.
+var egressNetnsTask13Addrs = egressNetnsAddrs{box4: "10.0.5.1", box6: "fd00:5::1", targets: egressTargets}
+
// egressTargetNetnsAt is egressTargetNetnsClosable with the fixture's
-// names given.
-func egressTargetNetnsAt(t *testing.T, n egressNetnsNames) (map[string]string, func()) {
+// names and addresses given: the box end holds lay.box4 (and lay.box6), with a
+// host route to each target through the veth from the box address of its
+// family; the namespace end holds the targets, with host routes back to
+// the box addresses.
+func egressTargetNetnsAt(t *testing.T, n egressNetnsNames, lay egressNetnsAddrs) (map[string]string, func()) {
t.Helper()
var steps []func()
var once sync.Once
@@ -268,24 +283,41 @@ func egressTargetNetnsAt(t *testing.T, n egressNetnsNames) (map[string]string, f
}
}
})
- egressIP(t, "addr", "add", "10.0.5.1/32", "dev", n.hostLink)
- egressIP(t, "-6", "addr", "add", "fd00:5::1/128", "dev", n.hostLink, "nodad")
+ for _, target := range lay.targets {
+ if netip.MustParseAddr(target).Is6() && lay.box6 == "" {
+ t.Fatalf("target %s is IPv6, but the fixture's box end has no IPv6 address", target)
+ }
+ }
+ egressIP(t, "addr", "add", lay.box4+"/32", "dev", n.hostLink)
+ if lay.box6 != "" {
+ egressIP(t, "-6", "addr", "add", lay.box6+"/128", "dev", n.hostLink, "nodad")
+ }
egressIP(t, "link", "set", n.hostLink, "up")
- egressIP(t, "route", "add", "10.0.5.20/32", "dev", n.hostLink, "src", "10.0.5.1")
- egressIP(t, "route", "add", "10.0.5.21/32", "dev", n.hostLink, "src", "10.0.5.1")
- egressIP(t, "-6", "route", "add", "fd00:5::20/128", "dev", n.hostLink, "src", "fd00:5::1")
+ for _, target := range lay.targets {
+ if netip.MustParseAddr(target).Is6() {
+ egressIP(t, "-6", "route", "add", target+"/128", "dev", n.hostLink, "src", lay.box6)
+ } else {
+ egressIP(t, "route", "add", target+"/32", "dev", n.hostLink, "src", lay.box4)
+ }
+ }
in := func(args ...string) { t.Helper(); egressIP(t, append([]string{"-n", n.ns}, args...)...) }
in("link", "set", "lo", "up")
- in("addr", "add", "10.0.5.20/32", "dev", n.nsLink)
- in("addr", "add", "10.0.5.21/32", "dev", n.nsLink)
- in("-6", "addr", "add", "fd00:5::20/128", "dev", n.nsLink, "nodad")
+ for _, target := range lay.targets {
+ if netip.MustParseAddr(target).Is6() {
+ in("-6", "addr", "add", target+"/128", "dev", n.nsLink, "nodad")
+ } else {
+ in("addr", "add", target+"/32", "dev", n.nsLink)
+ }
+ }
in("link", "set", n.nsLink, "up")
- in("route", "add", "10.0.5.1/32", "dev", n.nsLink)
- in("-6", "route", "add", "fd00:5::1/128", "dev", n.nsLink)
+ in("route", "add", lay.box4+"/32", "dev", n.nsLink)
+ if lay.box6 != "" {
+ in("-6", "route", "add", lay.box6+"/128", "dev", n.nsLink)
+ }
addrs := map[string]string{}
- for _, a := range egressTargets {
+ for _, a := range lay.targets {
ln, err := egressListenIn(nsPath, net.JoinHostPort(a, "0"))
if err != nil {
t.Fatalf("listen on %s in %s: %v", a, n.ns, err)
@@ -321,7 +353,7 @@ func egressTargetNetnsAt(t *testing.T, n egressNetnsNames) (map[string]string, f
if err != nil {
t.Fatal("LocalAddresses:", err)
}
- for _, a := range egressTargets {
+ for _, a := range lay.targets {
addr := netip.MustParseAddr(a)
for _, p := range local {
if p.Contains(addr) {
@@ -807,7 +839,7 @@ func newEgressPreClaimBoxWith(t *testing.T, o egressBoxOptions) *egressBox {
if o.netns == (egressNetnsNames{}) {
b.targets = egressTargetNetns(t)
} else {
- b.targets, _ = egressTargetNetnsAt(t, o.netns)
+ b.targets, _ = egressTargetNetnsAt(t, o.netns, egressNetnsTask13Addrs)
}
// The build: the test binary, as the platform binary the templates
diff --git a/internal/host/egress_prefix_rootrunner_linux_test.go b/internal/host/egress_prefix_rootrunner_linux_test.go
new file mode 100644
index 000000000..9d7aad764
--- /dev/null
+++ b/internal/host/egress_prefix_rootrunner_linux_test.go
@@ -0,0 +1,231 @@
+//go:build linux && rootrunner
+
+package host
+
+import (
+ "context"
+ "errors"
+ "io/fs"
+ "net/netip"
+ "os"
+ "path/filepath"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/instancectl"
+)
+
+// The prefix witness's names and addresses (#1357 Task 4). The namespace
+// and veth pair are its own: carlos-egr0 (kernel proof), carlos-egr1/1n
+// (Task 13) and carlos-egr2/2n (Task 14) belong to other witnesses.
+const (
+ egressPrefixNetns = "carlos-egr3"
+ egressPrefixHostEnd = "carlos-egr3"
+ egressPrefixNsEnd = "carlos-egr3n"
+
+ egressPrefixAllow = "10.250.64.0/20"
+ egressPrefixInside = "10.250.64.10" // inside the allow
+ egressPrefixOutside = "10.250.80.10" // outside it, in the same /16
+ // egressPrefixBoxAddr is the box's end of the veth pair: outside the
+ // allow, so the asserter's own-address check passes the prefix.
+ egressPrefixBoxAddr = "10.250.96.1"
+
+ egressPrefixHost = "egress-prefix.example.com"
+ egressPrefixUnit = "carlos-egress-prefix-a"
+)
+
+// TestRootEgressPrefixKernelProof is the kernel witness for egress allow
+// prefixes (#1357): a host slice's IPAddressAllow=10.250.64.0/20, written
+// by the production asserter (newEgressAsserter: the real systemctl, the
+// box's own addresses from procfs, cgroupfs for the slice's running
+// units), lets a tenant in a child unit carrying the template's
+// IPAddressDeny= reach an address inside the prefix, refuses it one
+// outside the prefix in the same /16, and once the policy is revoked and
+// the asserter runs again, refuses the inside address too.
+//
+// The asserter's source is an in-memory policy for one host, so no
+// registry or control service is involved; everything from the source on
+// is production code. Its DueDir is in the test's scratch directory, not
+// the box's control directory.
+//
+// Network: the test reaches nothing beyond its own target fixture, a
+// network namespace carlos-egr3 behind a veth pair (carlos-egr3 on the
+// box with 10.250.96.1, carlos-egr3n inside with the two targets). The
+// targets are not addresses of the box, so the asserter's check against
+// LocalAddresses stays on. The tenant is this binary (plan14-tenant)
+// behind a Unix socket in a scratch directory.
+//
+// It logs one "verdict:" line per question (inside reachable, outside
+// refused, revoke closes inside), fails on any wrong answer, fails, never
+// skips, without root, systemd as PID 1 or cgroup v2, and removes every
+// unit, drop-in, slice state, link, namespace, listener and file it made.
+func TestRootEgressPrefixKernelProof(t *testing.T) {
+ verdicts := map[string]string{}
+ order := []string{"inside reachable", "outside refused", "revoke closes inside"}
+ t.Cleanup(func() {
+ for _, k := range order {
+ v := verdicts[k]
+ if v == "" {
+ v = "not reached"
+ }
+ t.Logf("verdict: %s: %s", k, v)
+ }
+ })
+ verdict := func(k string, ok bool) {
+ if ok {
+ verdicts[k] = "yes"
+ } else {
+ verdicts[k] = "no"
+ }
+ }
+
+ egressRootPrereqs(t)
+ ctx := context.Background()
+ host := egressPrefixHost
+ slice := instancectl.SliceName(host)
+ unitName := egressPrefixUnit + ".service"
+
+ // Refuse anything this test would otherwise overwrite or remove. The
+ // nudge leaves a runtime drop-in for the unit, removed on cleanup.
+ unitControl := filepath.Join("/run/systemd/system.control", unitName+".d")
+ if _, err := os.Lstat(unitControl); !errors.Is(err, fs.ErrNotExist) {
+ t.Fatal("unit already has set-property drop-ins", unitControl, err)
+ }
+
+ scratch, err := os.MkdirTemp("", "egrp")
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Cleanup(func() {
+ if err := os.RemoveAll(scratch); err != nil {
+ t.Error(err)
+ }
+ })
+
+ targets := egressPrefixTargets(t)
+ inside, outside := targets[egressPrefixInside], targets[egressPrefixOutside]
+
+ egressSliceProperties(t, slice)
+
+ // The production asserter over an in-memory policy for the host.
+ var mu sync.Mutex
+ allow := []string{egressPrefixAllow}
+ src := func(_ context.Context, h string) (instancectl.EgressPolicy, error) {
+ mu.Lock()
+ defer mu.Unlock()
+ if h != host {
+ return instancectl.EgressPolicy{}, nil
+ }
+ return instancectl.EgressPolicy{Allow: append([]string(nil), allow...), Account: "abc", App: "shop"}, nil
+ }
+ e := newEgressAsserter(src, func() ([]string, error) { return []string{host}, nil })
+ e.Logf = t.Logf
+ e.DueDir = filepath.Join(scratch, "egress-due")
+
+ // Grant before the child starts (the start-path order).
+ if err := e.Assert(ctx, host); err != nil {
+ t.Fatal("grant: Assert:", err)
+ }
+ raw := egressShow(t, slice, "IPAddressAllow")
+ t.Logf("slice IPAddressAllow after the grant: %q", raw)
+ held, err := egressProofPrefixes(raw)
+ if err != nil {
+ t.Fatal("grant:", err)
+ }
+ if len(held) != 1 || held[0] != netip.MustParsePrefix(egressPrefixAllow) {
+ t.Fatalf("grant: slice IPAddressAllow is %v, want exactly [%s]", held, egressPrefixAllow)
+ }
+ rep := e.Reports()[host]
+ t.Logf("report after the grant: %+v", rep)
+ if rep.State != "" || len(rep.Refused) != 0 {
+ t.Fatalf("grant: report %+v, want no state and nothing refused", rep)
+ }
+
+ // The tenant. The cleanup of the nudge's drop-in is registered first,
+ // so it runs after the unit's own cleanup has stopped and removed it.
+ t.Cleanup(func() {
+ if err := os.RemoveAll(unitControl); err != nil {
+ t.Error(err)
+ }
+ if out, err := egressCtl("daemon-reload"); err != nil {
+ t.Errorf("daemon-reload: %v: %s", err, out)
+ }
+ })
+ deny := egressTemplateDeny(t)
+ socket := filepath.Join(scratch, "a.sock")
+ c := egressUnitTenant(t, egressPrefixUnit, slice, deny, socket)
+ t.Logf("unit's IPAddressAllow: %q, IPAddressDeny: %q", egressShow(t, unitName, "IPAddressAllow"), egressShow(t, unitName, "IPAddressDeny"))
+
+ // Question 1: an address inside the prefix is reachable.
+ in := egressWithin(t, time.Now().Add(egressLiveBound), c, true, inside)
+ verdict("inside reachable", in)
+ if !in {
+ egressFirewallDiag(t, unitName, slice, c, inside)
+ t.Errorf("inside: %s (in %s) not reachable under the slice's allow", egressPrefixInside, egressPrefixAllow)
+ }
+
+ // Question 2: an address outside it, in the same /16, is refused.
+ out := !egressReach(t, c, outside)
+ verdict("outside refused", out)
+ if !out {
+ egressFirewallDiag(t, unitName, slice, c, outside)
+ t.Errorf("outside: %s (outside %s) reachable", egressPrefixOutside, egressPrefixAllow)
+ }
+
+ // Question 3: revoke the policy; the asserter's next run closes the
+ // inside address for the running tenant (live, or by restarting it).
+ mu.Lock()
+ allow = nil
+ mu.Unlock()
+ if err := e.Assert(ctx, host); err != nil {
+ t.Fatal("revoke: Assert:", err)
+ }
+ if got := egressShow(t, slice, "IPAddressAllow"); got != "" {
+ t.Fatalf("revoke: slice IPAddressAllow is %q, want empty", got)
+ }
+ rep = e.Reports()[host]
+ t.Logf("report after the revoke: %+v", rep)
+ restarted := rep.Detail == "revoked (restarted)"
+ deadline := time.Now().Add(egressLiveBound)
+ if restarted {
+ deadline = time.Now().Add(egressRestartBound)
+ egressServingBy(t, unitName, c, deadline)
+ }
+ closed := egressWithin(t, deadline, c, false, inside)
+ verdict("revoke closes inside", closed)
+ t.Logf("revoke closed by restart: %v", restarted)
+ if !closed {
+ egressFirewallDiag(t, unitName, slice, c, inside)
+ t.Errorf("revoke: %s still reachable after the policy was revoked (restarted %v)", egressPrefixInside, restarted)
+ }
+}
+
+// egressPrefixTargets is the prefix witness's target fixture: the shared
+// egressTargetNetnsAt with its own names (carlos-egr3, carlos-egr3/3n)
+// and addresses (10.250.96.1 on the box end; 10.250.64.10 and
+// 10.250.80.10 inside). Before and after it, no address of the box may lie
+// in 10.250.64.0/20: the asserter would refuse a prefix holding one, and
+// the witness must not lean on one.
+func egressPrefixTargets(t *testing.T) map[string]string {
+ t.Helper()
+ prefix := netip.MustParsePrefix(egressPrefixAllow)
+ noLocalInPrefix := func(when string) {
+ t.Helper()
+ local, err := instancectl.LocalAddresses()
+ if err != nil {
+ t.Fatal("LocalAddresses:", err)
+ }
+ for _, p := range local {
+ if p.Overlaps(prefix) {
+ t.Fatalf("%s: this box holds %s, inside %s", when, p, prefix)
+ }
+ }
+ }
+ noLocalInPrefix("before the fixture")
+ addrs, _ := egressTargetNetnsAt(t,
+ egressNetnsNames{ns: egressPrefixNetns, hostLink: egressPrefixHostEnd, nsLink: egressPrefixNsEnd},
+ egressNetnsAddrs{box4: egressPrefixBoxAddr, targets: []string{egressPrefixInside, egressPrefixOutside}})
+ noLocalInPrefix("with the fixture up")
+ return addrs
+}
diff --git a/internal/host/egress_source_test.go b/internal/host/egress_source_test.go
index 905bb1a93..fbe033924 100644
--- a/internal/host/egress_source_test.go
+++ b/internal/host/egress_source_test.go
@@ -7,6 +7,7 @@ import (
"encoding/json"
"errors"
"io/fs"
+ "net/netip"
"os"
"path/filepath"
"reflect"
@@ -939,3 +940,60 @@ func TestRegistryEgressSourceRefusesFormerDemo(t *testing.T) {
}
}
}
+
+// TestRegistryPrefixColumnReachesTheSliceExactly is #1357's production
+// wiring: a registry egress column holding a prefix and a single goes
+// through root's real source (registryEgressSource) into root's asserter
+// (newEgressAsserter), which writes exactly those two prefixes, with only
+// systemctl, the box's addresses and the cgroup tree faked.
+func TestRegistryPrefixColumnReachesTheSliceExactly(t *testing.T) {
+ t.Parallel()
+ const host = "shop-a.example.com"
+ reg, dd := egressRegistry(t)
+ clock := &testClock{now: time.Date(2026, 11, 22, 9, 0, 0, 0, time.UTC)}
+ upsertRows(t, reg, nestedRow(dd, host))
+ setAllow(t, reg, host, "10.0.64.0/20 10.0.5.20", unixText(clock.Now().Add(time.Hour)))
+
+ var mu sync.Mutex
+ var sets []string
+ held := ""
+ slice := instancectl.SliceName(host)
+ e := newEgressAsserter(testEgressSource(t, dd, clock.Now), nil)
+ e.Systemctl = func(_ context.Context, args ...string) (string, error) {
+ mu.Lock()
+ defer mu.Unlock()
+ switch {
+ case len(args) == 5 && args[0] == "show" && args[4] == slice:
+ return held + "\n", nil
+ case len(args) == 5 && args[0] == "show":
+ return "\n", nil // the parent holds nothing
+ case len(args) >= 4 && args[0] == "set-property" && args[2] == slice:
+ sets = append(sets, strings.Join(args, " "))
+ held = strings.TrimPrefix(args[len(args)-1], "IPAddressAllow=")
+ return "", nil
+ }
+ return "", errors.New("unexpected call: " + strings.Join(args, " "))
+ }
+ e.LocalAddrs = func() ([]netip.Prefix, error) { return []netip.Prefix{netip.MustParsePrefix("127.0.0.0/8")}, nil }
+ e.CgroupRoot = t.TempDir()
+ e.Logf = func(string, ...any) {}
+ e.DueDir = ""
+
+ if err := e.Assert(context.Background(), host); err != nil {
+ t.Fatal(err)
+ }
+ want := []string{"set-property --runtime " + slice + " IPAddressAllow= IPAddressAllow=10.0.5.20/32 10.0.64.0/20"}
+ if !slices.Equal(sets, want) {
+ t.Fatalf("writes = %q, want %q", sets, want)
+ }
+ if rep := e.Reports()[host]; rep.State != "" || !slices.Equal(rep.Allowed, []string{"10.0.5.20", "10.0.64.0/20"}) {
+ t.Fatalf("report = %+v, want both in force", rep)
+ }
+ // Asserted again: in force as read back, nothing written.
+ if err := e.Assert(context.Background(), host); err != nil {
+ t.Fatal(err)
+ }
+ if len(sets) != 1 {
+ t.Fatalf("writes = %q, want the one write", sets)
+ }
+}
diff --git a/internal/instancectl/egress.go b/internal/instancectl/egress.go
index a8f15b2d9..f4d2365de 100644
--- a/internal/instancectl/egress.go
+++ b/internal/instancectl/egress.go
@@ -630,33 +630,36 @@ func (e *EgressAsserter) Reports() map[string]EgressReport {
return out
}
-// desired validates a policy's entries in order: egressaddr.Parse, then
-// egressaddr.Allowed, then not one of the box's own addresses. It returns
-// the full-length prefixes to write, sorted, and a refusal per entry
-// refused. More than egressaddr.MaxAllow accepted closes them all, and
-// tooMany says so. When the box's addresses cannot be read, no entry is
-// accepted: an allow that might name the box itself is never written.
+// desired validates a policy's entries in order: egressaddr.ParseEntry,
+// then egressaddr.AllowedPrefix, then overlapping none of the box's own
+// addresses (#1357: an entry may be a prefix, and IPAddressAllow beats
+// IPAddressDeny, so a prefix holding one cannot be carved out). It returns
+// each entry's own prefix to write, never widened or masked, sorted, and a
+// refusal per entry refused. More than egressaddr.MaxAllow accepted closes
+// them all, and tooMany says so. When the box's addresses cannot be read,
+// no entry is accepted: an allow that might name the box itself is never
+// written.
func (e *EgressAsserter) desired(host string, allow []string) (want []netip.Prefix, refused []string, tooMany string) {
local, lerr := e.localAddrs()
if lerr != nil {
e.logf("egress: %s: this box's addresses: %v; every entry is closed", host, lerr)
}
- seen := map[netip.Addr]bool{}
+ seen := map[netip.Prefix]bool{}
for _, s := range allow {
s = strings.TrimSpace(s)
if s == "" {
continue
}
- a, err := egressaddr.Parse(s)
- if err == nil && seen[a] {
+ p, err := egressaddr.ParseEntry(s)
+ if err == nil && seen[p] {
continue
}
if err == nil {
- seen[a] = true
- err = egressaddr.Allowed(a)
+ seen[p] = true
+ err = egressaddr.AllowedPrefix(p)
}
if err != nil {
- // egressaddr's errors already name the address.
+ // egressaddr's errors already name the entry.
refused = append(refused, err.Error())
continue
}
@@ -664,11 +667,15 @@ func (e *EgressAsserter) desired(host string, allow []string) (want []netip.Pref
refused = append(refused, s+": this box's addresses could not be read")
continue
}
- if lp, ok := isLocal(a, local); ok {
- refused = append(refused, fmt.Sprintf("%s: an address of this box (%s)", s, lp))
+ if lp, ok := overlapsLocal(p, local); ok {
+ if p.IsSingleIP() {
+ refused = append(refused, fmt.Sprintf("%s: this box has an address in %s", s, lp))
+ } else {
+ refused = append(refused, fmt.Sprintf("%s: overlaps an address or range of this box (%s)", s, lp))
+ }
continue
}
- want = append(want, netip.PrefixFrom(a, a.BitLen()))
+ want = append(want, p)
}
if len(want) > egressaddr.MaxAllow {
return nil, refused, fmt.Sprintf("the policy has more than %d addresses (%d); every one is closed", egressaddr.MaxAllow, len(want))
@@ -784,12 +791,9 @@ func prefixesText(ps []netip.Prefix) string {
return strings.Join(s, " ")
}
-func comparePrefix(a, b netip.Prefix) int {
- if c := a.Addr().Compare(b.Addr()); c != 0 {
- return c
- }
- return a.Bits() - b.Bits()
-}
+// comparePrefix is the stored order (egressaddr.ComparePrefix), so root
+// writes and reports an allow in the order the policy holds it.
+func comparePrefix(a, b netip.Prefix) int { return egressaddr.ComparePrefix(a, b) }
func (e *EgressAsserter) readSource(ctx context.Context, host string) (EgressPolicy, error) {
if e.Source == nil {
diff --git a/internal/instancectl/egress_test.go b/internal/instancectl/egress_test.go
index 78d666162..dc82183f5 100644
--- a/internal/instancectl/egress_test.go
+++ b/internal/instancectl/egress_test.go
@@ -200,7 +200,7 @@ func TestEgressRefusesEachBadEntryWithItsReason(t *testing.T) {
wantCalls(t, ctl.sets(), setCall(egressHost, "10.0.5.20/32", "10.0.5.21/32"))
// egressaddr's errors already name the address (C4): carried as-is.
want := []string{
- "127.0.0.1 is a loopback address",
+ "127.0.0.1 is loopback",
"8.8.8.8 is a public address and is already reachable. no allow is needed",
`"10.0.5.20:5432" has a port. an allow opens an address, never a port`,
}
@@ -220,7 +220,7 @@ func TestEgressDropsTheBoxsOwnAddress(t *testing.T) {
}
rep := mustAssert(t, e, egressHost)
wantCalls(t, ctl.sets(), setCall(egressHost, "10.0.5.21/32"))
- if want := []string{"10.0.5.20: an address of this box (10.0.5.20/32)"}; !reflect.DeepEqual(rep.Refused, want) {
+ if want := []string{"10.0.5.20: this box has an address in 10.0.5.20/32"}; !reflect.DeepEqual(rep.Refused, want) {
t.Fatalf("Refused = %q, want %q", rep.Refused, want)
}
if want := []string{"10.0.5.21"}; !reflect.DeepEqual(rep.Allowed, want) {
@@ -228,6 +228,110 @@ func TestEgressDropsTheBoxsOwnAddress(t *testing.T) {
}
}
+// desired takes a prefix exactly (#1357 decision 7): written as its own
+// prefix, never widened and never masked, refused when it overlaps any of
+// the box's own addresses, a single address as before.
+func TestEgressDesiredTakesPrefixesExactly(t *testing.T) {
+ local := []netip.Prefix{
+ netip.MustParsePrefix("127.0.0.0/8"),
+ netip.MustParsePrefix("10.0.5.20/32"),
+ netip.MustParsePrefix("10.0.80.7/32"),
+ netip.MustParsePrefix("10.1.0.0/24"),
+ netip.MustParsePrefix("fd00:6::9/128"),
+ }
+ pfx := func(ss ...string) []netip.Prefix {
+ var out []netip.Prefix
+ for _, s := range ss {
+ out = append(out, netip.MustParsePrefix(s))
+ }
+ return out
+ }
+ var nine []string
+ for i := 1; i <= 9; i++ {
+ nine = append(nine, fmt.Sprintf("10.%d.0.0/16", 100+i))
+ }
+ for _, c := range []struct {
+ name string
+ allow []string
+ want []netip.Prefix
+ refused []string
+ tooMany bool
+ }{
+ {name: "a prefix is written as is", allow: []string{"10.0.64.0/20", "10.0.5.21"},
+ want: pfx("10.0.5.21/32", "10.0.64.0/20")},
+ {name: "a prefix and its own first address are two entries", allow: []string{"10.0.64.0", "10.0.64.0/20", "fd00:5::/64"},
+ want: pfx("10.0.64.0/20", "10.0.64.0/32", "fd00:5::/64")},
+ {name: "duplicates collapse by prefix", allow: []string{"10.0.64.0/20", " 10.0.64.0/20", "10.0.5.21", "10.0.5.21/32"},
+ want: pfx("10.0.5.21/32", "10.0.64.0/20")},
+ {name: "a prefix holding a local /32 is refused", allow: []string{"10.0.80.0/20", "10.0.64.0/20"},
+ want: pfx("10.0.64.0/20"),
+ refused: []string{"10.0.80.0/20: overlaps an address or range of this box (10.0.80.7/32)"}},
+ {name: "a prefix overlapping a local range is refused", allow: []string{"10.1.0.0/16", "fd00:6::/64"},
+ refused: []string{
+ "10.1.0.0/16: overlaps an address or range of this box (10.1.0.0/24)",
+ "fd00:6::/64: overlaps an address or range of this box (fd00:6::9/128)",
+ }},
+ {name: "a single local address keeps its text", allow: []string{"10.0.5.20", "10.1.0.9"},
+ refused: []string{
+ "10.0.5.20: this box has an address in 10.0.5.20/32",
+ "10.1.0.9: this box has an address in 10.1.0.0/24",
+ }},
+ {name: "a host-bits entry is refused, never masked", allow: []string{"10.0.64.5/20"},
+ refused: []string{`"10.0.64.5/20" has host bits set. write it as 10.0.64.0/20`}},
+ {name: "a wide prefix is refused", allow: []string{"10.0.0.0/8"},
+ refused: []string{"10.0.0.0/8 is wider than /16. allow at most a /16"}},
+ {name: "nine prefixes close every one", allow: nine, tooMany: true},
+ {name: "eight prefixes are written", allow: nine[:8],
+ want: pfx("10.101.0.0/16", "10.102.0.0/16", "10.103.0.0/16", "10.104.0.0/16",
+ "10.105.0.0/16", "10.106.0.0/16", "10.107.0.0/16", "10.108.0.0/16")},
+ } {
+ e := newEgressAsserter(newEgressCtl(), nil)
+ e.LocalAddrs = func() ([]netip.Prefix, error) { return local, nil }
+ want, refused, tooMany := e.desired(egressHost, c.allow)
+ if !slices.Equal(want, c.want) {
+ t.Errorf("%s: want = %v, want %v", c.name, want, c.want)
+ }
+ if !slices.Equal(refused, c.refused) {
+ t.Errorf("%s: refused = %q, want %q", c.name, refused, c.refused)
+ }
+ if (tooMany != "") != c.tooMany {
+ t.Errorf("%s: tooMany = %q, want set %v", c.name, tooMany, c.tooMany)
+ }
+ }
+}
+
+// Assert writes a prefix through systemctl as is, and systemd's read-back
+// of it counts as in force: nothing is written again and nothing fails.
+func TestEgressWritesAPrefixAndReadsItBack(t *testing.T) {
+ ctl := newEgressCtl()
+ e := newEgressAsserter(ctl, staticSource(EgressPolicy{Allow: []string{"10.0.64.0/20", "10.0.5.20", "fd00:5::/64"}}, nil))
+ rep := mustAssert(t, e, egressHost)
+ wantCalls(t, ctl.takeCalls(),
+ showCall(egressHost),
+ setCall(egressHost, "10.0.5.20/32", "10.0.64.0/20", "fd00:5::/64"),
+ showCall(egressHost))
+ if want := (EgressReport{Allowed: []string{"10.0.5.20", "10.0.64.0/20", "fd00:5::/64"}}); !reflect.DeepEqual(rep, want) {
+ t.Fatalf("report = %+v, want %+v", rep, want)
+ }
+
+ // systemd's own form of the same allow, in its order: in force.
+ ctl = newEgressCtl()
+ ctl.setHeld(SliceName(egressHost), "10.0.64.0/20 fd00:5::/64 10.0.5.20/32")
+ e = newEgressAsserter(ctl, staticSource(EgressPolicy{Allow: []string{"10.0.5.20", "10.0.64.0/20", "fd00:5::/64"}}, nil))
+ rep = mustAssert(t, e, egressHost)
+ wantCalls(t, ctl.takeCalls(), showCall(egressHost))
+ if rep.State != "" || !reflect.DeepEqual(rep.Allowed, []string{"10.0.5.20", "10.0.64.0/20", "fd00:5::/64"}) {
+ t.Fatalf("report = %+v, want in force with nothing written", rep)
+ }
+
+ // A held prefix that differs from the wanted one is not in force.
+ ctl = newEgressCtl()
+ ctl.setHeld(SliceName(egressHost), "10.0.0.0/16")
+ e = newEgressAsserter(ctl, staticSource(EgressPolicy{Allow: []string{"10.0.64.0/20"}}, nil))
+ mustAssert(t, e, egressHost)
+ wantCalls(t, ctl.sets(), setCall(egressHost, "10.0.64.0/20"))
+}
+
func TestEgressClosesWhenTheBoxsAddressesCannotBeRead(t *testing.T) {
ctl := newEgressCtl()
ctl.setHeld(SliceName(egressHost), "10.0.5.20/32")
diff --git a/internal/instancectl/localaddrs.go b/internal/instancectl/localaddrs.go
index 4be41e2ec..f0d0ba517 100644
--- a/internal/instancectl/localaddrs.go
+++ b/internal/instancectl/localaddrs.go
@@ -126,6 +126,17 @@ func isLocal(a netip.Addr, local []netip.Prefix) (netip.Prefix, bool) {
return netip.Prefix{}, false
}
+// overlapsLocal names the local prefix p overlaps, if any: for a
+// full-length p, the one holding its address, as isLocal.
+func overlapsLocal(p netip.Prefix, local []netip.Prefix) (netip.Prefix, bool) {
+ for _, l := range local {
+ if l.Overlaps(p) {
+ return l, true
+ }
+ }
+ return netip.Prefix{}, false
+}
+
// LocalAddresses is everything that routes to this box, read from
// procfs as the resolver allow reads it: the egress asserter's
// LocalAddrs, and the agent's list of the box's addresses.
diff --git a/internal/provision/apppolicy_reconcile_test.go b/internal/provision/apppolicy_reconcile_test.go
index a43c3c75a..7e49be561 100644
--- a/internal/provision/apppolicy_reconcile_test.go
+++ b/internal/provision/apppolicy_reconcile_test.go
@@ -4,6 +4,7 @@ import (
"context"
"crypto/ed25519"
"database/sql"
+ "encoding/base64"
"errors"
"fmt"
"os"
@@ -215,6 +216,16 @@ func TestReconcileVerifiesBeforeConverging(t *testing.T) {
other.App = "other"
stale := good()
stale.SignedAt = fx.now.Add(-apppolicy.Lifetime - time.Minute)
+ // A record the release key did sign, holding an entry this box's
+ // Validate refuses: the old-box path (#1357), where a box whose
+ // Validate predates prefixes reads "10.0.64.0/20" the way this one
+ // reads a host-bits or too-wide prefix. The whole allow closes, the
+ // good single beside it included, and nothing wider is ever written.
+ badEntry := func(entry string) []byte {
+ p := good()
+ p.EgressAllow = []string{"10.0.5.20", entry}
+ return signUnchecked(t, fx.priv, p)
+ }
for _, c := range []struct {
name string
@@ -225,6 +236,9 @@ func TestReconcileVerifiesBeforeConverging(t *testing.T) {
{"another key", sign(otherPriv, grant), "policy unverifiable"},
{"another app's record", sign(fx.priv, other), "policy unverifiable"},
{"expired", sign(fx.priv, stale), "policy expired"},
+ {"a host-bits prefix", badEntry("10.0.64.5/20"), "policy unverifiable"},
+ {"a too-wide prefix", badEntry("10.0.0.0/8"), "policy unverifiable"},
+ {"a single stored as /32", badEntry("10.0.5.21/32"), "policy unverifiable"},
} {
converge()
fx.putRaw(c.body)
@@ -236,6 +250,13 @@ func TestReconcileVerifiesBeforeConverging(t *testing.T) {
fx.wantState(c.state)
}
+ // signUnchecked's control: the same signing over a policy this box
+ // accepts converges, so the refusals above are the entry's.
+ fx.putRaw(badEntry("10.0.64.0/20"))
+ fx.run()
+ wantCols(t, fx.row(policyHost), "10.0.5.20 10.0.64.0/20", "large", fx.now.Add(apppolicy.Lifetime).Unix())
+ fx.wantState("")
+
// No release key on the box: a valid record cannot be verified.
converge()
fx.cfg.ReleasePub = nil
@@ -610,3 +631,12 @@ func mintOrder(t *testing.T, reg *registry.Registry) []string {
}
return hosts
}
+
+// signUnchecked signs p the way apppolicy.Sign does, without Sign's
+// Validate: a record the release key signed whose shape a box refuses.
+func signUnchecked(t *testing.T, priv ed25519.PrivateKey, p apppolicy.Policy) []byte {
+ t.Helper()
+ payload := base64.StdEncoding.EncodeToString(mustJSON(t, p))
+ return mustJSON(t, map[string]string{"payload": payload,
+ "sig": base64.StdEncoding.EncodeToString(ed25519.Sign(priv, []byte("carlos app-policy v1\n"+payload)))})
+}
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 9a95901d3..67247eea6 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -279,4 +279,5 @@ plan14-root-reads-group-revoke-readback-1255.tsv 47ebd73418bcbe1bdf9cf34a2b94e33
plan14-root-reads-precert-dns01-1293.tsv b2f039a12bb284c9a36b391339e25e3f77ec94a3d4e38389ec9ef75261d7873f
plan14-root-reads-fleet-client-address-1348.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0
plan14-root-reads-flake-hostexec-renewal.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0
-plan14-root-reads-ha-departure-evidence.tsv 924ffc4037d32d7b46af1e373bad1476fc7305833fc6c06d50d5c8c3ab5ac177
+plan14-root-reads-egress-allow-cidr.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0
+plan14-root-reads-egress-allow-cidr-console.tsv 9fb6041c2fe2f33edf7cc2a0fb6dc05092015414b89cab3610ebcfc04c21d5b0
diff --git a/internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv
new file mode 100644
index 000000000..2292b17bd
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr-console.tsv
@@ -0,0 +1,6 @@
+# Census overlay egress-allow-cidr-console, written by census-propose (#369). census-ruling-egress-allow-cidr-console, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-egress-allow-cidr-console.md.
+# 0 body, 0 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@coverage . 678ff93df9d4bba86e5fb3174b6e521c50a4a2b8e8da278eb7345f1dcc6b28ba
+@coverage internal/egressaddr f23f1c889694411f185a4e46acf541fd5e37320693c3cc5ce8d5f68fba1561ed
+@coverage internal/instancectl 4d36599760134ea7456756dba3fa02a90c7194454d355e8b1fab8f0bcc2a4bea
+@coverage internal/release d5ad27f00e653c322b60826f5174354b6f2deae4f27f41bdd148aad959a35fd1
diff --git a/internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv
new file mode 100644
index 000000000..5d8aad2ca
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-egress-allow-cidr.tsv
@@ -0,0 +1,5 @@
+# Census overlay egress-allow-cidr, written by census-propose (#369). census-ruling-egress-allow-cidr, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-egress-allow-cidr.md.
+# 0 body, 0 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@coverage internal/apppolicy 3162130ffcbc2153e5c075bb08f7c29384b4bd365569aa1cab69014d9eb4747a
+@coverage internal/egressaddr 489cfb43f5fc489a0e824081ad5f34cffc2d46b69c76ef7ce85f393541d6d209
+@coverage internal/instancectl 14cc1cfb38c3e337cc44691bbe2484d137abade42cff654166f5f4d655a5f092
diff --git a/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv b/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
deleted file mode 100644
index f3a9f8e57..000000000
--- a/internal/provision/testdata/plan14-root-reads-ha-departure-evidence.tsv
+++ /dev/null
@@ -1,18 +0,0 @@
-# Census overlay ha-departure-evidence, written by census-propose (#369). census-ruling-ha-departure-evidence, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-ha-departure-evidence.md.
-# 0 body, 3 sites, 3 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-# 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other.
-@legacy d8b5e9b01b291eae4828c32dba09b97fe97efe09c107c6b736f5367be16b4db6 internal/host/hadepartures_wiring.go pageDeparturePending legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=The former PageIdentity closure, now paging through alerting.PageDelivered, which returns ErrNoSink when no sink is armed so the page-once mark is not written without delivery. Same fields, same sinks. registry:Account@241,registry:IID@262,registry:Region@252 7b32a2e3d55fcda0a6d5fa2f3f670e3d5e1d0c33a17af25629952135ae1237b2
-@legacy de5290a2011654dd25871ee9b7dfbb95045989f5b944dc01f1165095dc1ebf24 internal/registry/ha_journal.go Registry.MarkPendingTerminationPaged legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the hint_paged op; local journal only. whole:HAPendingTermination@176,whole:HAPendingTermination@182 d45e190a96beaf27eeadc9800ac113e51cedb36a3a395d0a67128911d60cc6bc
-@legacy c7456932708add3564c8741b2a12a3bd09b44e04c8559c21ff2e80cd822770fa internal/registry/ha_journal.go Registry.RetryPendingTerminationOnce legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the retry_hint_once op; local journal only. registry:Found@243,whole:HAPendingTermination@205,whole:HAPendingTermination@211 61ae470c9b622b0dfd3906278bb4b121b22a43c0ab98712738a0685dbbedb311
-@legacy 52359355fb8d18758e59719e063e0b2cfe280803e380db963edacb255103f98c internal/host/hadepartures.go Controller.step legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: resolve bound same-scope identities, persist validated termination proof before enrollment, and replay bounded pending work outside consumer/fold locks. Existing regional data client and shared cache; inventory only restricts completion, never lifecycle. B3 fix r1: Describe before proof access on suspicion paths. Normalize validated legacy inbox entries in atomic transactions, process bounded per-iid pending pages, and persist hourly escalation. Delete unrelated rows only after complete applicable walks and guarded received timestamps. Acquire/completion authority unchanged. B4: Count unresolved durable hints for the globally throttled summary and call the bounded scanner outside the fold. Acknowledge unrelated hints only after complete applicable discovery; complete departure acknowledgment reads durable state. B4 fix r3: Include refused fixed-box replacements in the existing structured receiver summary, sharing its persisted hourly page claim with pending hints. Read only local refusal state and registry page state; no additional cloud request or completion authority.;rev3=census-ruling-region-ha-p3b;basis=Register admitted departure work and cancel/join it during closure before existing confirmation/import processing. Existing 23 read sites and lease/termination proofs remain; no new root input or takeover permission.;rev3=census-ruling-region-ha-g2-fixes;basis=Include identity and underlying paging errors in existing failure logs; new IID field read only, no new external read or termination authority.;rev3=census-ruling-region-ha-dr5;basis=DR-5: scans every due departure per step (at most 8), reading departure rows from the local journal (PendingDepartures) to detect progress; same ScanPass per departure, no new remote read.;rev3=census-ruling-ha-departure-evidence;basis=A pending hint whose bound identity has an unknown or placement-null observation gets code evidence_no_observation: no enqueue, no enrollment, no completion or takeover authority. It claims a page through the new retry_hint_once op (falling back to the ordinary hourly retry if the server refuses it) and marks the hint paged only after PageIdentity succeeds. Reads only the local journal. Round 2: the page-once claim falls back to the ordinary hourly retry only on ErrHAJournal (an older server's refusal); any other journal error fails the pass so a delivered marker is never overwritten. No new read or authority. file:Walk@2717,registry:Body@1979,registry:IID@2554,registry:IID@2971,registry:IID@3757,registry:IID@3790,registry:IID@4924,registry:IID@5082,registry:Key@2081,registry:Key@2317,registry:LastBlocked@2872,registry:NextAttempt@6644,registry:NextAttempt@6669,registry:ReceivedAt@2300,registry:ReceivedAt@3688,whole:HADeparture@6534,whole:HADeparture@6620,whole:HADeparture@6644,whole:HADeparture@6707,whole:HADeparture@6714,whole:HADeparture@6922,whole:HADeparture@7890,whole:HADeparture@8213,whole:HAPendingTermination@2495,whole:HAPendingTermination@2912,whole:HAPendingTermination@3599,whole:HAPendingTermination@3882,whole:HAPendingTermination@4221,whole:HAPendingTermination@4439,whole:HAPendingTermination@5000,whole:HAPendingTermination@5183,whole:HAPendingTermination@5754,whole:HATerminationInbox@1939 a0a56594ece2c190821bec285c58f2cd19dfb104f449e32b84682f9082a161cc
-@legacy e81e3f0875a853dae915a7a0f630c00f06057284f45a2df1df522230bb37359d internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes;rev3=census-ruling-ha-departure-evidence;basis=The PageIdentity closure moved to the named pageDeparturePending; same fields read, now there instead of here. registry:Account@7677,registry:App@7704,registry:Incarnation@7864,registry:Pool@7723,registry:Region@7744,registry:Revision@8099,registry:Revision@8496,registry:ServingSeq@7892,whole:DutyState@8218,whole:Pair@8081,whole:Pair@8474,whole:Pair@8480,whole:Route@7664,whole:Route@8373 51fdc51482fb21d4dde67a4fd9b4200be97ddc6f79189e4141d6d1ddae26285d
-@legacy 553b3b7b25d3fc8499898859aacb060c8613a5387a825251e40c82e779c6428b internal/registry/ha_journal.go Registry.haJournal legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.;rev3=census-ruling-ha-departure-evidence;basis=New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. Round 4 (Paul's option 1): every last_error write on ha_pending_terminations goes through hintLastError, a CASE that keeps a value ending in ' paged'; retry_hint_once treats any paged marker as delivered. Only hint removal clears it. No new table, read or authority. file:QueryContext@10797,file:QueryContext@2354,file:QueryContext@291,file:QueryContext@8933,file:QueryRowContext@11667,file:QueryRowContext@1271,file:QueryRowContext@13552,file:QueryRowContext@4621,file:QueryRowContext@6290,file:QueryRowContext@7132,file:QueryRowContext@8210,file:QueryRowContext@8410,file:Walk@13188,file:Walk@13211,file:Walk@13232,file:Walk@13252,file:Walk@13325,file:Walk@13748,registry:Account@1498,registry:Account@1978,registry:Account@2744,registry:Account@3169,registry:Account@3537,registry:Account@4284,registry:Account@4734,registry:Account@5502,registry:Account@5726,registry:Account@6103,registry:At@1098,registry:At@10984,registry:At@1117,registry:At@12113,registry:At@12616,registry:At@12641,registry:At@2571,registry:At@3530,registry:At@3577,registry:At@3918,registry:At@3937,registry:At@4249,registry:At@5074,registry:At@5093,registry:At@5450,registry:At@5489,registry:At@5693,registry:At@6524,registry:At@6541,registry:At@6682,registry:At@7344,registry:At@7728,registry:At@7945,registry:At@866,registry:At@8755,registry:At@8774,registry:At@9123,registry:Body@7907,registry:Body@8066,registry:Body@8735,registry:Body@9316,registry:Code@11879,registry:Code@11907,registry:Code@11927,registry:Code@11950,registry:Code@12942,registry:Code@4276,registry:Code@4409,registry:Code@4442,registry:Code@5258,registry:Code@5854,registry:Code@5887,registry:Code@6094,registry:Code@6131,registry:Code@9781,registry:Count@1352,registry:Count@623,registry:Departure@9819,registry:Departures@11444,registry:Departures@11468,registry:EnrolledAt@652,registry:EnrolledAt@6606,registry:EnrolledAt@6633,registry:EnrolledAt@9996,registry:Found@1208,registry:Found@12777,registry:Found@13108,registry:Found@3705,registry:Found@4072,registry:Found@5229,registry:Found@5274,registry:Found@7824,registry:HAJournal@225,registry:Hint@1482,registry:Hint@3034,registry:Hint@3251,registry:Hint@4397,registry:Hint@5842,registry:Hints@2950,registry:Hints@2969,registry:ID@11736,registry:ID@12405,registry:ID@12623,registry:ID@12950,registry:ID@13147,registry:ID@6381,registry:ID@6903,registry:ID@7229,registry:ID@7710,registry:ID@7869,registry:ID@7887,registry:ID@8055,registry:ID@8729,registry:IID@1566,registry:IID@1585,registry:IID@1999,registry:IID@2767,registry:IID@3190,registry:IID@3558,registry:IID@4305,registry:IID@4755,registry:IID@5523,registry:IID@5747,registry:IID@6124,registry:Identity@13062,registry:Identity@13094,registry:Inbox@9467,registry:Inbox@9486,registry:InventoryGeneration@6689,registry:Key@10539,registry:Key@10634,registry:Key@13153,registry:Key@2098,registry:Key@2193,registry:Key@9290,registry:Key@9623,registry:Key@9789,registry:Keys@13188,registry:Keys@13252,registry:LastError@10075,registry:LastError@11351,registry:LastError@2794,registry:LastError@9339,registry:LastPage@10048,registry:LastPage@11410,registry:LastPage@2916,registry:Limit@10722,registry:Limit@10737,registry:Limit@10991,registry:Limit@2279,registry:Limit@2294,registry:Limit@2578,registry:Limit@8858,registry:Limit@8873,registry:Limit@9130,registry:MessageID@9300,registry:Next@12169,registry:Next@12184,registry:Next@12933,registry:Next@9772,registry:NextAttempt@10094,registry:NextAttempt@10485,registry:NextAttempt@11373,registry:NextAttempt@2879,registry:NextAttempt@9428,registry:Offset@13211,registry:Offset@13232,registry:Oldest@718,registry:Oldest@759,registry:Oldest@785,registry:Op@254,registry:Page@12455,registry:Phase@10026,registry:Phase@11332,registry:Phase@6718,registry:ProofDigest@9895,registry:ProofKey@9875,registry:ReceivedAt@1599,registry:ReceivedAt@2018,registry:ReceivedAt@2045,registry:ReceivedAt@2845,registry:ReceivedAt@3209,registry:ReceivedAt@9392,registry:Region@1522,registry:Region@1544,registry:Region@1989,registry:Region@2756,registry:Region@3180,registry:Region@3548,registry:Region@4295,registry:Region@4745,registry:Region@5513,registry:Region@5737,registry:Region@6114,registry:RetryCount@11978,registry:RetryCount@12132,registry:RetryCount@12208,registry:RetryCount@12227,registry:Summary@623,registry:Summary@718,registry:Summary@759,registry:Summary@785,registry:Walk@13188,registry:Walk@13211,registry:Walk@13232,registry:Walk@13252,registry:Walk@13325,registry:Walk@13748,registry:remote@111,registry:remote@142,registry:sql@10797,registry:sql@1271,registry:sql@13381,registry:sql@13552,registry:sql@2354,registry:sql@291,registry:sql@3052,registry:sql@5945,registry:sql@8933,registry:sql@926,registry:sql@9552,registry:sql@9662,whole:HABoxIdentity@13064,whole:HABoxIdentity@13098,whole:HADeparture@10149,whole:HADeparture@11291,whole:HADeparture@11448,whole:HADeparture@11472,whole:HADeparture@11484,whole:HADeparture@11838,whole:HADeparture@12277,whole:HADeparture@582,whole:HADeparture@6483,whole:HADeparture@6763,whole:HADeparture@9821,whole:HADepartureSummary@627,whole:HADepartureSummary@722,whole:HADepartureSummary@763,whole:HADepartureSummary@789,whole:HAIdentityWalk@13190,whole:HAIdentityWalk@13213,whole:HAIdentityWalk@13234,whole:HAIdentityWalk@13254,whole:HAIdentityWalk@13327,whole:HAIdentityWalk@13752,whole:HAPendingTermination@1484,whole:HAPendingTermination@2954,whole:HAPendingTermination@2973,whole:HAPendingTermination@2980,whole:HAPendingTermination@3036,whole:HAPendingTermination@3253,whole:HAPendingTermination@4399,whole:HAPendingTermination@5844,whole:HATerminationInbox@9471,whole:HATerminationInbox@9490,whole:HATerminationInbox@9497,whole:haJournalRequest@1458,whole:haJournalRequest@196,whole:haJournalRequest@207,whole:haJournalResponse@10178,whole:haJournalResponse@10261,whole:haJournalResponse@10523,whole:haJournalResponse@10664,whole:haJournalResponse@10762,whole:haJournalResponse@11026,whole:haJournalResponse@11247,whole:haJournalResponse@11317,whole:haJournalResponse@11607,whole:haJournalResponse@1166,whole:haJournalResponse@11776,whole:haJournalResponse@11863,whole:haJournalResponse@12308,whole:haJournalResponse@1236,whole:haJournalResponse@12434,whole:haJournalResponse@12692,whole:haJournalResponse@12762,whole:haJournalResponse@12978,whole:haJournalResponse@13277,whole:haJournalResponse@13359,whole:haJournalResponse@13686,whole:haJournalResponse@1372,whole:haJournalResponse@13781,whole:haJournalResponse@13810,whole:haJournalResponse@1633,whole:haJournalResponse@1727,whole:haJournalResponse@2082,whole:haJournalResponse@2223,whole:haJournalResponse@230,whole:haJournalResponse@2319,whole:haJournalResponse@2613,whole:haJournalResponse@2830,whole:haJournalResponse@3330,whole:haJournalResponse@3626,whole:haJournalResponse@3692,whole:haJournalResponse@3988,whole:haJournalResponse@399,whole:haJournalResponse@4057,whole:haJournalResponse@4334,whole:haJournalResponse@4467,whole:haJournalResponse@4561,whole:haJournalResponse@4833,whole:haJournalResponse@4857,whole:haJournalResponse@5144,whole:haJournalResponse@518,whole:haJournalResponse@5214,whole:haJournalResponse@5784,whole:haJournalResponse@5912,whole:haJournalResponse@608,whole:haJournalResponse@6230,whole:haJournalResponse@6421,whole:haJournalResponse@6508,whole:haJournalResponse@6579,whole:haJournalResponse@6792,whole:haJournalResponse@6931,whole:haJournalResponse@7057,whole:haJournalResponse@7316,whole:haJournalResponse@7369,whole:haJournalResponse@7791,whole:haJournalResponse@7971,whole:haJournalResponse@8151,whole:haJournalResponse@8332,whole:haJournalResponse@8372,whole:haJournalResponse@8514,whole:haJournalResponse@8576,whole:haJournalResponse@8807,whole:haJournalResponse@8898,whole:haJournalResponse@892,whole:haJournalResponse@9165,whole:haJournalResponse@9377,whole:haJournalResponse@9972,whole:remoteClient@113,whole:remoteClient@144 934b49e5a287e9a69de5db021f074f7999d12bc149bf890e620f4abe58a24fe9
-internal/host/hadepartures_wiring.go pageDeparturePending legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=The former PageIdentity closure, now paging through alerting.PageDelivered, which returns ErrNoSink when no sink is armed so the page-once mark is not written without delivery. Same fields, same sinks. registry:Account@241,registry:IID@262,registry:Region@252 7b32a2e3d55fcda0a6d5fa2f3f670e3d5e1d0c33a17af25629952135ae1237b2
-internal/registry/ha_journal.go Registry.MarkPendingTerminationPaged legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the hint_paged op; local journal only. whole:HAPendingTermination@176,whole:HAPendingTermination@182 d45e190a96beaf27eeadc9800ac113e51cedb36a3a395d0a67128911d60cc6bc
-internal/registry/ha_journal.go Registry.RetryPendingTerminationOnce legacy accepted-legacy accepted-legacy;rev3=census-ruling-ha-departure-evidence;basis=New wrapper over the retry_hint_once op; local journal only. registry:Found@243,whole:HAPendingTermination@205,whole:HAPendingTermination@211 61ae470c9b622b0dfd3906278bb4b121b22a43c0ab98712738a0685dbbedb311
-internal/host/hadepartures.go Controller.step legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: resolve bound same-scope identities, persist validated termination proof before enrollment, and replay bounded pending work outside consumer/fold locks. Existing regional data client and shared cache; inventory only restricts completion, never lifecycle. B3 fix r1: Describe before proof access on suspicion paths. Normalize validated legacy inbox entries in atomic transactions, process bounded per-iid pending pages, and persist hourly escalation. Delete unrelated rows only after complete applicable walks and guarded received timestamps. Acquire/completion authority unchanged. B4: Count unresolved durable hints for the globally throttled summary and call the bounded scanner outside the fold. Acknowledge unrelated hints only after complete applicable discovery; complete departure acknowledgment reads durable state. B4 fix r3: Include refused fixed-box replacements in the existing structured receiver summary, sharing its persisted hourly page claim with pending hints. Read only local refusal state and registry page state; no additional cloud request or completion authority.;rev3=census-ruling-region-ha-p3b;basis=Register admitted departure work and cancel/join it during closure before existing confirmation/import processing. Existing 23 read sites and lease/termination proofs remain; no new root input or takeover permission.;rev3=census-ruling-region-ha-g2-fixes;basis=Include identity and underlying paging errors in existing failure logs; new IID field read only, no new external read or termination authority.;rev3=census-ruling-region-ha-dr5;basis=DR-5: scans every due departure per step (at most 8), reading departure rows from the local journal (PendingDepartures) to detect progress; same ScanPass per departure, no new remote read.;rev3=census-ruling-ha-departure-evidence;basis=A pending hint whose bound identity has an unknown or placement-null observation gets code evidence_no_observation: no enqueue, no enrollment, no completion or takeover authority. It claims a page through the new retry_hint_once op (falling back to the ordinary hourly retry if the server refuses it) and marks the hint paged only after PageIdentity succeeds. Reads only the local journal. Round 2: the page-once claim falls back to the ordinary hourly retry only on ErrHAJournal (an older server's refusal); any other journal error fails the pass so a delivered marker is never overwritten. No new read or authority. file:Walk@2717,registry:Body@1979,registry:IID@2554,registry:IID@2971,registry:IID@3757,registry:IID@3790,registry:IID@4924,registry:IID@5082,registry:Key@2081,registry:Key@2317,registry:LastBlocked@2872,registry:NextAttempt@6644,registry:NextAttempt@6669,registry:ReceivedAt@2300,registry:ReceivedAt@3688,whole:HADeparture@6534,whole:HADeparture@6620,whole:HADeparture@6644,whole:HADeparture@6707,whole:HADeparture@6714,whole:HADeparture@6922,whole:HADeparture@7890,whole:HADeparture@8213,whole:HAPendingTermination@2495,whole:HAPendingTermination@2912,whole:HAPendingTermination@3599,whole:HAPendingTermination@3882,whole:HAPendingTermination@4221,whole:HAPendingTermination@4439,whole:HAPendingTermination@5000,whole:HAPendingTermination@5183,whole:HAPendingTermination@5754,whole:HATerminationInbox@1939 a0a56594ece2c190821bec285c58f2cd19dfb104f449e32b84682f9082a161cc
-internal/host/hadepartures_wiring.go armHADepartures legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3 fix r1: Install proof adapter, adoption identity and suspicion callbacks before asynchronous startup. Lazily retry the same deployment/data clients; lifetime callback reads only the current host through ExecBackend.TerminationLifetime. Add bounded structured paging for unresolved per-iid records. No new bucket, tenant input path or acquire bypass. B4: Wire the shared lock reader and existing AdoptHost entry. Read local route, Pair and duty revision only after authoritative inventory eligibility; bind its record lifetime and refuse missing/mismatched local routes. No route synthesis or pool widening. B5: Publish the armed controller to the existing metrics sampler. No new loop, remote source or process authority.;rev3=census-ruling-region-ha-followups;basis=Inject the existing PageOperator function into the backend when HA departures are armed; no new read or paging transport.;rev3=census-ruling-region-ha-p3b;basis=Require group admission/BeginWork callbacks and pass them into the sole departure consumer, including the production adoption closure. Same store, identity and registry reads; consumer Started remains a lifecycle fact, not duty authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Carry the actual provisionTickConfig pools and inbound posture into CanAdopt; stamped sidecars use the existing production adopter. Legacy unresolved paging remains. No wider tenancy or new remote source.;rev3=census-ruling-region-ha-g2r-fixes;basis=W3: wires the controller's RequestInventory hook to the agent's early-backstop signal. No new store, read or loop.;rev3=census-ruling-ha-1192;basis=wires DepartureConfig.TrashRetired: release.TrashRetired over a.OpenStore (the deployment bucket) with the box's CARLOS_RELEASE_PUBKEY via provisionTickConfig, the same marker and flag reads the reconcile already makes;rev3=census-ruling-ha-departure-evidence;basis=The PageIdentity closure moved to the named pageDeparturePending; same fields read, now there instead of here. registry:Account@7677,registry:App@7704,registry:Incarnation@7864,registry:Pool@7723,registry:Region@7744,registry:Revision@8099,registry:Revision@8496,registry:ServingSeq@7892,whole:DutyState@8218,whole:Pair@8081,whole:Pair@8474,whole:Pair@8480,whole:Route@7664,whole:Route@8373 51fdc51482fb21d4dde67a4fd9b4200be97ddc6f79189e4141d6d1ddae26285d
-internal/registry/ha_journal.go Registry.haJournal legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: read/write bounded termination inbox, pending departures, verified identity cache and retry/cursor state in the existing SQLite registry with remote parity. No reusable receipt, arbitrary path, import/completion/start authority; retries and page times survive replay. B3 fix r1: Add atomic compact hint enrollment, bounded due reads, received-time guarded removal and hourly page claims. Retain old inbox APIs for migration, no queue receipt or authority bit. All reads/writes stay in the existing SQLite registry with remote parity. B4: Extend the existing registry journal/schema/RPC with scan state, guarded completion phases, durable bounded retry count and one receiver-wide identity summary claim/count. All state stays in the existing database; no queue receipt is persisted and no import/start authority is granted by an inbox entry. B4 fix r2: Delegate existing identity RPC operations to historical storage helpers. Remote interface unchanged; historical ref/iid lookups retain the old binding and ref-only lookups return the latest incarnation. B4 fix r3: Inventory-only waiting resets RetryCount like scan/pending and retains the caller 30-second schedule. Add an atomic claim against the existing singleton identity-page row, shared with retry_hint. Existing database and HAJournal RPC only; no filesystem path or identity authority added. B5: Stream pending departure bodies from the existing registry to count all incomplete rows and find oldest enrollment, including delayed retries. Additive enrollment timestamp retains age when evidence is reobserved. No new path or execution input.;rev3=census-ruling-ha-departure-evidence;basis=New ops retry_hint_once (reads the hint's own last_error, claims the existing global hourly page slot, writes next_attempt/last_page/last_error) and hint_paged (sets last_error to code plus paged when it still equals code). Same tables, same transaction helper, no new authority. Round 4 (Paul's option 1): every last_error write on ha_pending_terminations goes through hintLastError, a CASE that keeps a value ending in ' paged'; retry_hint_once treats any paged marker as delivered. Only hint removal clears it. No new table, read or authority. file:QueryContext@10797,file:QueryContext@2354,file:QueryContext@291,file:QueryContext@8933,file:QueryRowContext@11667,file:QueryRowContext@1271,file:QueryRowContext@13552,file:QueryRowContext@4621,file:QueryRowContext@6290,file:QueryRowContext@7132,file:QueryRowContext@8210,file:QueryRowContext@8410,file:Walk@13188,file:Walk@13211,file:Walk@13232,file:Walk@13252,file:Walk@13325,file:Walk@13748,registry:Account@1498,registry:Account@1978,registry:Account@2744,registry:Account@3169,registry:Account@3537,registry:Account@4284,registry:Account@4734,registry:Account@5502,registry:Account@5726,registry:Account@6103,registry:At@1098,registry:At@10984,registry:At@1117,registry:At@12113,registry:At@12616,registry:At@12641,registry:At@2571,registry:At@3530,registry:At@3577,registry:At@3918,registry:At@3937,registry:At@4249,registry:At@5074,registry:At@5093,registry:At@5450,registry:At@5489,registry:At@5693,registry:At@6524,registry:At@6541,registry:At@6682,registry:At@7344,registry:At@7728,registry:At@7945,registry:At@866,registry:At@8755,registry:At@8774,registry:At@9123,registry:Body@7907,registry:Body@8066,registry:Body@8735,registry:Body@9316,registry:Code@11879,registry:Code@11907,registry:Code@11927,registry:Code@11950,registry:Code@12942,registry:Code@4276,registry:Code@4409,registry:Code@4442,registry:Code@5258,registry:Code@5854,registry:Code@5887,registry:Code@6094,registry:Code@6131,registry:Code@9781,registry:Count@1352,registry:Count@623,registry:Departure@9819,registry:Departures@11444,registry:Departures@11468,registry:EnrolledAt@652,registry:EnrolledAt@6606,registry:EnrolledAt@6633,registry:EnrolledAt@9996,registry:Found@1208,registry:Found@12777,registry:Found@13108,registry:Found@3705,registry:Found@4072,registry:Found@5229,registry:Found@5274,registry:Found@7824,registry:HAJournal@225,registry:Hint@1482,registry:Hint@3034,registry:Hint@3251,registry:Hint@4397,registry:Hint@5842,registry:Hints@2950,registry:Hints@2969,registry:ID@11736,registry:ID@12405,registry:ID@12623,registry:ID@12950,registry:ID@13147,registry:ID@6381,registry:ID@6903,registry:ID@7229,registry:ID@7710,registry:ID@7869,registry:ID@7887,registry:ID@8055,registry:ID@8729,registry:IID@1566,registry:IID@1585,registry:IID@1999,registry:IID@2767,registry:IID@3190,registry:IID@3558,registry:IID@4305,registry:IID@4755,registry:IID@5523,registry:IID@5747,registry:IID@6124,registry:Identity@13062,registry:Identity@13094,registry:Inbox@9467,registry:Inbox@9486,registry:InventoryGeneration@6689,registry:Key@10539,registry:Key@10634,registry:Key@13153,registry:Key@2098,registry:Key@2193,registry:Key@9290,registry:Key@9623,registry:Key@9789,registry:Keys@13188,registry:Keys@13252,registry:LastError@10075,registry:LastError@11351,registry:LastError@2794,registry:LastError@9339,registry:LastPage@10048,registry:LastPage@11410,registry:LastPage@2916,registry:Limit@10722,registry:Limit@10737,registry:Limit@10991,registry:Limit@2279,registry:Limit@2294,registry:Limit@2578,registry:Limit@8858,registry:Limit@8873,registry:Limit@9130,registry:MessageID@9300,registry:Next@12169,registry:Next@12184,registry:Next@12933,registry:Next@9772,registry:NextAttempt@10094,registry:NextAttempt@10485,registry:NextAttempt@11373,registry:NextAttempt@2879,registry:NextAttempt@9428,registry:Offset@13211,registry:Offset@13232,registry:Oldest@718,registry:Oldest@759,registry:Oldest@785,registry:Op@254,registry:Page@12455,registry:Phase@10026,registry:Phase@11332,registry:Phase@6718,registry:ProofDigest@9895,registry:ProofKey@9875,registry:ReceivedAt@1599,registry:ReceivedAt@2018,registry:ReceivedAt@2045,registry:ReceivedAt@2845,registry:ReceivedAt@3209,registry:ReceivedAt@9392,registry:Region@1522,registry:Region@1544,registry:Region@1989,registry:Region@2756,registry:Region@3180,registry:Region@3548,registry:Region@4295,registry:Region@4745,registry:Region@5513,registry:Region@5737,registry:Region@6114,registry:RetryCount@11978,registry:RetryCount@12132,registry:RetryCount@12208,registry:RetryCount@12227,registry:Summary@623,registry:Summary@718,registry:Summary@759,registry:Summary@785,registry:Walk@13188,registry:Walk@13211,registry:Walk@13232,registry:Walk@13252,registry:Walk@13325,registry:Walk@13748,registry:remote@111,registry:remote@142,registry:sql@10797,registry:sql@1271,registry:sql@13381,registry:sql@13552,registry:sql@2354,registry:sql@291,registry:sql@3052,registry:sql@5945,registry:sql@8933,registry:sql@926,registry:sql@9552,registry:sql@9662,whole:HABoxIdentity@13064,whole:HABoxIdentity@13098,whole:HADeparture@10149,whole:HADeparture@11291,whole:HADeparture@11448,whole:HADeparture@11472,whole:HADeparture@11484,whole:HADeparture@11838,whole:HADeparture@12277,whole:HADeparture@582,whole:HADeparture@6483,whole:HADeparture@6763,whole:HADeparture@9821,whole:HADepartureSummary@627,whole:HADepartureSummary@722,whole:HADepartureSummary@763,whole:HADepartureSummary@789,whole:HAIdentityWalk@13190,whole:HAIdentityWalk@13213,whole:HAIdentityWalk@13234,whole:HAIdentityWalk@13254,whole:HAIdentityWalk@13327,whole:HAIdentityWalk@13752,whole:HAPendingTermination@1484,whole:HAPendingTermination@2954,whole:HAPendingTermination@2973,whole:HAPendingTermination@2980,whole:HAPendingTermination@3036,whole:HAPendingTermination@3253,whole:HAPendingTermination@4399,whole:HAPendingTermination@5844,whole:HATerminationInbox@9471,whole:HATerminationInbox@9490,whole:HATerminationInbox@9497,whole:haJournalRequest@1458,whole:haJournalRequest@196,whole:haJournalRequest@207,whole:haJournalResponse@10178,whole:haJournalResponse@10261,whole:haJournalResponse@10523,whole:haJournalResponse@10664,whole:haJournalResponse@10762,whole:haJournalResponse@11026,whole:haJournalResponse@11247,whole:haJournalResponse@11317,whole:haJournalResponse@11607,whole:haJournalResponse@1166,whole:haJournalResponse@11776,whole:haJournalResponse@11863,whole:haJournalResponse@12308,whole:haJournalResponse@1236,whole:haJournalResponse@12434,whole:haJournalResponse@12692,whole:haJournalResponse@12762,whole:haJournalResponse@12978,whole:haJournalResponse@13277,whole:haJournalResponse@13359,whole:haJournalResponse@13686,whole:haJournalResponse@1372,whole:haJournalResponse@13781,whole:haJournalResponse@13810,whole:haJournalResponse@1633,whole:haJournalResponse@1727,whole:haJournalResponse@2082,whole:haJournalResponse@2223,whole:haJournalResponse@230,whole:haJournalResponse@2319,whole:haJournalResponse@2613,whole:haJournalResponse@2830,whole:haJournalResponse@3330,whole:haJournalResponse@3626,whole:haJournalResponse@3692,whole:haJournalResponse@3988,whole:haJournalResponse@399,whole:haJournalResponse@4057,whole:haJournalResponse@4334,whole:haJournalResponse@4467,whole:haJournalResponse@4561,whole:haJournalResponse@4833,whole:haJournalResponse@4857,whole:haJournalResponse@5144,whole:haJournalResponse@518,whole:haJournalResponse@5214,whole:haJournalResponse@5784,whole:haJournalResponse@5912,whole:haJournalResponse@608,whole:haJournalResponse@6230,whole:haJournalResponse@6421,whole:haJournalResponse@6508,whole:haJournalResponse@6579,whole:haJournalResponse@6792,whole:haJournalResponse@6931,whole:haJournalResponse@7057,whole:haJournalResponse@7316,whole:haJournalResponse@7369,whole:haJournalResponse@7791,whole:haJournalResponse@7971,whole:haJournalResponse@8151,whole:haJournalResponse@8332,whole:haJournalResponse@8372,whole:haJournalResponse@8514,whole:haJournalResponse@8576,whole:haJournalResponse@8807,whole:haJournalResponse@8898,whole:haJournalResponse@892,whole:haJournalResponse@9165,whole:haJournalResponse@9377,whole:haJournalResponse@9972,whole:remoteClient@113,whole:remoteClient@144 934b49e5a287e9a69de5db021f074f7999d12bc149bf890e620f4abe58a24fe9
-@coverage internal/alerting cec9c6b025b0b6e2082549827a7cde27ee55820d035b05b60d90dd1746953b31
-@coverage internal/host 0741f6152c9070524f77a05467dde38a7cc2053ec0e1c181a11968f5f1298159
-@coverage internal/registry 9b3c36f8d5a45335efcf4305d70859f1d1459fd6a1f37768de47626f41920b92
diff --git a/internal/release/layoutintent.go b/internal/release/layoutintent.go
index baa1d3f71..a358e3e4c 100644
--- a/internal/release/layoutintent.go
+++ b/internal/release/layoutintent.go
@@ -246,6 +246,18 @@ var RootfsLifecycleFloor = SemVer{Major: 0, Minor: 29, Patch: 0}
// TestTeamEnvironmentFloorIsPinned pins it.
var TeamEnvironmentFloor = SemVer{Major: 0, Minor: 30, Patch: 0}
+// EgressPrefixFloor is the first platform release whose boxes accept an
+// egress allow entry that is a prefix (#1357). An older box reads such a
+// policy as unverifiable and clears the app's whole allow and size override
+// on that box (fail closed, but a regression of the app's other entries).
+// So the console adds a prefix entry only while every fresh box of the
+// deployment runs at or above it (console/egressfleet.go); single
+// addresses, and revokes, are never gated. The latest tag at the time of
+// writing is v0.42.1, so this names the next minor: if the release ships
+// under another number, this moves with it (a floor set too high only
+// refuses prefixes for longer). TestEgressPrefixFloorIsPinned pins it.
+var EgressPrefixFloor = SemVer{Major: 0, Minor: 43, Patch: 0}
+
// RegionalDomainsFloor is the first platform release that reads a regional
// custom-domain claim (#447). A box below it skips the claim entirely: a
// regional claim is stamped schema 2, and every older reader refuses a
diff --git a/internal/release/layoutintent_test.go b/internal/release/layoutintent_test.go
index dd43e2df2..888e0dcb7 100644
--- a/internal/release/layoutintent_test.go
+++ b/internal/release/layoutintent_test.go
@@ -322,3 +322,14 @@ func TestFleetForwardFloorAllows(t *testing.T) {
}
}
}
+
+func TestEgressPrefixFloorIsPinned(t *testing.T) {
+ if EgressPrefixFloor != (SemVer{Major: 0, Minor: 43, Patch: 0}) {
+ t.Fatalf("EgressPrefixFloor = %+v, want v0.43.0 (the first release whose boxes accept egress prefixes)", EgressPrefixFloor)
+ }
+ for v, below := range map[string]bool{"v0.42.1": true, "v0.43.0": false, "v0.43.2": false} {
+ if got := BelowFloor(v, EgressPrefixFloor); got != below {
+ t.Errorf("BelowFloor(%q, EgressPrefixFloor) = %v, want %v", v, got, below)
+ }
+ }
+}
diff --git a/testdata/clireg-golden.jsonl b/testdata/clireg-golden.jsonl
index 1cc1f793f..effa3f070 100644
--- a/testdata/clireg-golden.jsonl
+++ b/testdata/clireg-golden.jsonl
@@ -68,8 +68,8 @@
{"case":"apps region | -h","argv":["apps","region","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps region --app <name> [--set <region>] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY; supersedes --account\n --app, -a <string> app whose region to show or change\n --console <string> console to act through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --set <string> the region where this app's new instances start. existing instances stay where they are. only account owners and deployment operators can change it\n"}
{"case":"apps restore | --zz-unknown-flag","argv":["apps","restore","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps restore [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --console <string> console origin to restore through (signed-in mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"}
{"case":"apps restore | -h","argv":["apps","restore","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps restore [flags]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one; ops in direct mode)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account; this is the flag an ambiguity error tells you to use\n --console <string> console origin to restore through (signed-in mode only; default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --registry <string> registry database (resolves --account) (default: $DIR/data/registry.db)\n"}
-{"case":"apps set | --zz-unknown-flag","argv":["apps","set","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"}
-{"case":"apps set | -h","argv":["apps","set","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses every instance of the app may reach, comma-separated, never a port. pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"}
+{"case":"apps set | --zz-unknown-flag","argv":["apps","set","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\n--egress-allow takes at most 8 entries. A range must start at its first address, so\n10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on\nevery box, and a box refuses a range that holds one of its own addresses.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"}
+{"case":"apps set | -h","argv":["apps","set","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps set <app> [--copies <n>] [--swap overlap|hold] [--swap-concurrency <n>] [--interactive on|off] [--account <sqid|name>] [--account-id <sqid>] [--console <origin>] [--egress-allow <ip,...>] [--size <size>]\n\n --swap overlap|hold how a running instance takes a new build. overlap\n starts the new build beside the old one and switches\n once it answers its health check, so no request\n waits. hold stops the old one first, and requests\n wait until the new one is up. Use hold when two\n builds cannot share the database.\n --swap-concurrency <n> how many instances of the app may swap at once on\n one box, after the first has stayed up for ten\n seconds. 1 or more; it starts at 1.\n\nAny member of the app may change these. They reach the app's boxes with its\nconfig, within seconds.\n\n --interactive on|off whether members may open a terminal session on the app's instances, with carlos run -it or carlos console. it is off until an owner turns it on. a session can read and change everything the instance can\n\n carlos apps set <app> [--instance-control <settings>] [--default-updates auto|manual] [--default-channel <channel>] [--default-major <n>]\n\n --instance-control <settings> the settings an instance may change itself:\n any of updates, channel, major and pin,\n comma-separated. Empty keeps them all for\n the app.\n --default-updates auto|manual what instances do when they have not\n chosen. Empty restores auto.\n --default-channel <channel> the channel new instances follow.\n --default-major <n> hold instances on stable at this major\n version. Empty clears it.\n\nOnly system operators may pass --egress-allow or --size. A change reaches\nthe app's boxes within seconds on a box following the deployment's change index, or within about 33 minutes on another box.\n--egress-allow takes at most 8 entries. A range must start at its first address, so\n10.0.64.5/20 is refused; write 10.0.64.0/20. Ranges need v0.43.0 or later on\nevery box, and a box refuses a range that holds one of its own addresses.\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY — supersedes --account\n --app, -a <string> app whose swap or instance policy to set\n --console <string> console to act through (default: the only logged-in one)\n --copies <int> number of copies for each instance on different boxes in the app's fleet (default 1)\n --default-channel <string> the channel new instances follow\n --default-major <string> hold instances on stable at this major version; empty clears\n --default-updates <string> auto or manual: what instances do when they have not chosen; empty restores auto\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n --egress-allow <string> private addresses or ranges every instance of the app may reach, comma-separated, never a port. a range is no wider than /16 (IPv4) or /48 (IPv6). pass the whole list; \"\" clears it. system operators only\n --instance-control <string> settings an instance may change itself: any of updates, channel, major, pin, comma-separated; empty keeps them all for the app\n --interactive <string> on or off: whether members may open terminal sessions on the app's instances\n --message <string> Add a short note describing this change (shown alongside the recorded action).\n --no-prompt Skip the optional change description prompt.\n --size <string> the size the app's instances run at: small, standard, large or xlarge. default uses the build's size. system operators only\n --swap <string> overlap or hold: how a running instance takes a new build\n --swap-concurrency <int> how many instances of the app may swap at once on one box (1 or more)\n"}
{"case":"apps show | --zz-unknown-flag","argv":["apps","show","--zz-unknown-flag"],"exit":2,"stdout":"","stderr":"flag provided but not defined: -zz-unknown-flag\nusage: carlos apps show <app> [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY; supersedes --account\n --console <string> console to act through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
{"case":"apps show | -h","argv":["apps","show","-h"],"exit":0,"stdout":"","stderr":"usage: carlos apps show <app> [--account <sqid|name>] [--account-id <sqid>] [--console <origin>]\nflags:\n --account <string> account (sqid or name) the app belongs to (default: your only account, or the configured/chosen one)\n --account-id <string> account sqid, matched as a sqid ONLY; supersedes --account\n --console <string> console to act through (default: the only logged-in one)\n --destination, -d <name> use the named block from .carlos/config's destinations (default: CARLOS_DESTINATION, else the file's default or only one)\n"}
{"case":"apps source delete | extra","argv":["apps","source","delete"],"exit":1,"stdout":"","stderr":"carlos apps source pull --app <app> [--account <name-or-sqid> | --account-id <sqid>] --console <origin> [--output <path>]\n"}