carlos / platform Public

plans 4d-1: fix Astra's eight findings (serialised lapse convergence, unreadable claims, sponsorship ends a lapse, crashed and post-move entries, purge bookkeeping, keep incarnations and effective state)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 2db8ca16f8b520b12619d50e65ed9a99d465bd84 parent 889d9f9
18 files changed, +573 −37
  • docs/superpowers/notes/census-proposal-plans-4d-lapse.md +8 −4
  • docs/superpowers/notes/plans-4d1-ledger.md +10 −0
  • docs/superpowers/specs/CODEX-FINDINGS-PLANS-4D1-CODE.md +91 −0
  • internal/activator/activator.go +15 −2
  • internal/activator/activator_disabledfor_test.go +32 −0
  • internal/console/claim_app_identity.go +5 −0
  • internal/console/claim_invariant_fixtures_test.go +11 −1
  • internal/console/plangracepass.go +22 −1
  • internal/console/planlapse.go +31 −9
  • internal/console/planlapse_findings_test.go +215 −0
  • internal/console/planlapse_inventory.go +37 −1
  • internal/console/planlapse_keep.go +42 −6
  • internal/console/planlapse_keep_test.go +5 −5
  • internal/console/server.go +7 −0
  • internal/console/store.go +5 −0
  • internal/domains/claimcache.go +24 −0
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −1
  • internal/provision/testdata/plan14-root-reads-plans-4d-lapse.tsv +12 −7

CI failed — run details

diff --git a/docs/superpowers/notes/census-proposal-plans-4d-lapse.md b/docs/superpowers/notes/census-proposal-plans-4d-lapse.md
index 97c1d8a37..a3a6c4ac4 100644
--- a/docs/superpowers/notes/census-proposal-plans-4d-lapse.md
+++ b/docs/superpowers/notes/census-proposal-plans-4d-lapse.md
@@ -5,24 +5,28 @@ Ruling `census-ruling-plans-4d-lapse`. Every change below keeps the disposition
| unit | change | read sites | what changed |
|---|---|---|---|
| `internal/activator/activator.go` `type Service` | body | unchanged (0) | gains the disabledFor hook field beside maxRunFor (plans 4d). No read added. |
+| `internal/console/claim_app_identity.go` `Store.PurgeClaimAppRow` | body | unchanged (2) | also deletes the purged app's plan_lapse_items rows in the same purge transaction, while the app identity still exists (plans 4d, Astra finding 6); console SQL on its own table; read sites unchanged |
| `internal/console/server.go` `NewServer` | body | unchanged (1) | registers GET and POST /a/{sqid}/plan/keep (the owner-only keep page, plans 4d) beside the account settings routes; no goroutine; read sites unchanged, offsets moved |
+| `internal/console/store.go` `Store.PurgeAppRow` | body | unchanged (1) | also deletes the purged app's plan_lapse_items rows in the same transaction as the row (plans 4d, Astra finding 6); console SQL on its own table; read sites unchanged |
| `internal/console/store.go` `Store.migrate` | body | unchanged (2) | adds the additive account_plans.lapse_since and account_plans.disabled columns and calls migratePlanLapse last, which creates the console's own plan_lapse_items table (plans 4d). No read added; the new store units are the plans-4d-units decision. |
| `internal/console/templates/layout.html` `external` | body | unchanged (1) | the account layout renders a link to the keep page after the plan banner when PlanKeepURL is set (owners of a lapsed account, plans 4d). No read added. |
| `internal/host/agent.go` `runAgent` | body | unchanged (5) | arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved |
| `internal/host/plans_pass.go` `plansPass` | body | unchanged (3) | keeps each account's published turned-off host list (Record.Disabled, lower-cased) in the cache beside its limits and throttle, and carries the last good copy on a read error (plans 4d). The same bucket objects; no read added. |
| `internal/activator/activator.go` `Service.ServeScheduled` | sites | +whole:Route | answers a scheduled request to a route the turned-off hook names with the maintenance response before serve (plans 4d). One more whole-row read: the row handed to the hook (a.disabled), as the fence and maxRunFor are asked. |
-| `internal/activator/activator.go` `Service.sweepOnce` | sites | +whole:Route ×3 | stops a live entry the turned-off hook names (never mid-command, never a probe), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Three more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips. |
-| `internal/activator/activator.go` `Service.wake` | sites | +whole:Route | cancels a wake whose row the turned-off hook names, like a fence, unless it is a move's probe (plans 4d). One more whole-row read: the row handed to the hook (a.disabled). Only refuses. |
+| `internal/activator/activator.go` `Service.sweepOnce` | sites | +whole:Route ×4 | stops a live entry the turned-off hook names (never mid-command, never a move's active probe), stands down an exited worker it names instead of restarting it (Astra finding 4), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Four more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips. |
+| `internal/activator/activator.go` `Service.wake` | sites | +whole:Route | cancels a wake whose row the turned-off hook names, like a fence, unless it is a move's active probe (plans 4d). One more whole-row read: the row handed to the hook (a.disabled). Only refuses. |
| `internal/edge/edge.go` `Edge.ServeHTTP` | sites | +whole:Route | calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here. |
-Envelopes re-pinned: `internal/activator`, `internal/console`, `internal/console/templates`, `internal/edge`, `internal/host`, `internal/plans`.
+Envelopes re-pinned: `internal/activator`, `internal/console`, `internal/console/templates`, `internal/domains`, `internal/edge`, `internal/host`, `internal/plans`.
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. Escalate 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. An escalation goes to the census owner as a decision.
Recorded dispositions, which each change must still satisfy:
- `internal/activator/activator.go` `type Service`: authority, task B,C,D,F,J4. Basis: rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.
+- `internal/console/claim_app_identity.go` `Store.PurgeClaimAppRow`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
- `internal/console/server.go` `NewServer`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console construction adds queue and notification state. The existing logs/data route literal moves; it is not a filesystem read.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets consoleNameCfg from Config.ConsoleName and the challengeSem send bound, and registers the four /auth/email routes; no goroutine; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=census-ruling-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets the forwarded db read's open-read limits (dbReads, held by each read's request) and its timing (dbf); no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=census-ruling-design-edge-rate-limit-358;basis=one route registered beside the gate's form: POST /a/{sqid}/apps/{app}/ratelimit to handleAppRateLimit, the Settings page's rate-limit form, member-gated like the gate; no read added, its one data-literal site unchanged (offset moved)
+- `internal/console/store.go` `Store.PurgeAppRow`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input
- `internal/console/store.go` `Store.migrate`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=adds the sessions.method column (default keymail, the backfill) and calls migrateEmailSignin; SQLite DDL on CONSOLE_DB; the existing site moves;rev3=census-ruling-plans-4-notices-grace;basis=calls migratePlanGrace last, which creates the console's own plan_cap_state table (plans 4a). No read added here; the new store units are the plans-4a-store decision.;rev3=census-ruling-plans-4c-box-throttle;basis=adds the additive account_plans.throttle column (plans 4c). No read added.
- `internal/console/templates/layout.html` `external`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=PROPOSED-console-switcher-filter;basis=Account switcher adds a client-side filter box and a scrolling list; whole embedded template remains frozen as legacy UI input.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=CSS only: email inputs styled as text inputs and sign-in form labels; whole embedded template remains frozen as legacy UI input;rev3=PROPOSED-console-brand-name;identity=the console (cmd/console serve under console.service, user carlos-console);basis=the tab title and header brand name the deployment ({{.Brand}}, CARLOS_CONSOLE_NAME); no new input.;rev3=census-ruling-plans-4-notices-grace;basis=the account layout renders .PlanNotices as banner lines above main content (plans 4a). No read added.
- `internal/host/agent.go` `runAgent`: authority, task B,C,D,F. Basis: rev3=census-ruling-seeded-instances;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with wireSeedPlacement called in the activator start's Configure step, before armMovesPass, and the startup sweep's result stored for the import rollback in Recover; read sites unchanged, offsets moved; main's B,C,D,F authority retained PROPOSED E46: captured claim selection and root journal mutation; root RPC outside service host exclusion; SQL/route data never grants root authority. Executing identity: service controller; root for inventory/retirement callbacks.;rev3=PROPOSED-325;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=passes the agent's log sink to armRunsPass; reads unchanged;rev3=census-ruling-db-region-forward-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=arms the db-reads loop (armDBReads) beside armRunsPass in the activator start's Configure step; reads unchanged, offsets moved; main's authority retained;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=arms the change index (armChangeIndex) and starts the record view's backstop loop before the loops that read through it, and hands the edge the watch loader (edge.WithChangeWatch); read sites unchanged at the same offsets;rev3=census-ruling-edge-request-records;basis=builds the edge request recorder against the existing log sink and data dir (newRequestRecorder, passed os.Getenv and time.Now) and starts reqrecLoop on a minute ticker; no read added;rev3=census-ruling-design-edge-rate-limit-358;basis=arms the edge's plan rate-ceiling hook, e.SetRateCeilingFor(planRateCeilingFor), right after EnableUsage; read sites unchanged (5), offsets moved; no read added;rev3=census-ruling-edge-asset-cache-1;basis=starts edgesFileLoop with the activator's serving build (servingBuildOf(svc): ServingGen's build on a box with generations, nothing otherwise); read sites unchanged (5), none added;rev3=census-ruling-plans-4c-box-throttle;basis=arms svc.SetMaxRunFor(planMaxRunFor) beside SetIdleFor, and e.SetPlanThrottleFor(planThrottleFor), e.SetPlanGovernedFor(planGoverned) and the planAwakeThrottled close hook beside SetRateCeilingFor (plans 4c). No read added.
@@ -32,7 +36,7 @@ Recorded dispositions, which each change must still satisfy:
- `internal/activator/activator.go` `Service.wake`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-wake-latency-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=logs that timer's breakdown to the journal after a successful wake (w.steps.String(), e.host, w.wakeTook); no read added
- `internal/edge/edge.go` `Edge.ServeHTTP`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.
-Seal: `a9653e5722bdb94eb1951d7d6d537534a6f9237e8cd519af0f870e5f5d7989da` → `940182523fc6e81a530a1c751abcc50c199fdc8547d98d9c99de1cdb9304dd27`.
+Seal: `a9653e5722bdb94eb1951d7d6d537534a6f9237e8cd519af0f870e5f5d7989da` → `c2d276bfd84a5d8220717cde6e932771994e9bfe14fe3d063ba9a03d3025b9be`.
Overlay: `internal/provision/testdata/plan14-root-reads-plans-4d-lapse.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/docs/superpowers/notes/plans-4d1-ledger.md b/docs/superpowers/notes/plans-4d1-ledger.md
index 7f2442600..6262244b3 100644
--- a/docs/superpowers/notes/plans-4d1-ledger.md
+++ b/docs/superpowers/notes/plans-4d1-ledger.md
@@ -37,3 +37,13 @@ Task 10: Ruling: docs say carlos db pull/query work on a turned-off instance: ap
Task 10: Ruling: census: 10 changed units claimed through census-propose (overlay plans-4d-lapse); 13 new units are a hand decision overlay plans-4d-units (census-ruling-plans-4d-units), chained before it; record-write layer plans4d_census_test.go (NewServer re-digested, plangrace.go capID const block's "sidecars" literal as key-site); no record writer added. Astra approval of the card is the parent's — cost if wrong: census re-run.
Task 10: Ruling: Astra whole-branch review and CI wait are the parent session's, per the brief; one unreproduced FAIL of the edge -run set seen once after the merge (three -count=1 reruns green) — cost if wrong: a flake for CI to show.
Task 10: complete (commits b2edd8b..3352b43, tests: bash -c 'GOFLAGS=-buildvcs=false go test ./internal/provision/ -run 'TestPlan14RootReadCensus$|TestPlan9B8RecordWriteCensus' -count=1 && GOFLAGS=-buildvcs=false go test ./internal/plans/ ./internal/host/ ./internal/edge/ ./internal/activator/ -run 'LimitsFell|RoundTrip|Disabled|PlansPass|DisabledFor' -count=1 && go test ./internal/console/ -run 'Lapse|Keep|BannerSaysLapse|CLIWarningSaysLapse|ClaimConsoleRouteCensus' -count=1' → ok github.com/carlosframework/platform/internal/console 69.380s)
+Final: review by Astra at 889d9f98 (docs/superpowers/specs/CODEX-FINDINGS-PLANS-4D1-CODE.md): 6 Important + 2 Minor, the parent re-graded both Minors to Important; all eight fixed in one pass.
+Final: fixed 1 stale grace pass can undo an upgrade (per-account lapse lock held by applyAccountPlan, the grace pass's convergence and keep saves; lapseBeforeConverge test hook) — TestStaleGracePassCannotUndoAnUpgrade RED→GREEN
+Final: fixed 2 unreadable claims read as deleted (domains.ClaimCache.ListWithUnread; the inventory fails when an unread claim is a turned-off domain, known to be the account's, or of unknown account while its domains are over) — TestUnreadableClaimKeepsTheDomainOff RED→GREEN
+Final: fixed 3 sponsorship kept a dormant lapse (clearLapseOff clears lapse_since and the lapse caps' grace rows for a sponsored row) — TestSponsorshipEndsTheLapse RED→GREEN
+Final: fixed 4 crash-looping workers bypassed the check (an exited worker the hook names stands down instead of restarting; command and active-probe guards kept) — TestDisabledForStopsACrashedWorkerInsteadOfRestarting RED→GREEN
+Final: fixed 5 finished move probes stayed exempt (activeProbe: probe != nil && !probe.managed, used in the sweep, the exited branch and wake) — TestDisabledForStopsAFinishedProbeEntry RED→GREEN
+Final: fixed 6 lapse rows of a purged app blocked convergence (PurgeAppRow and PurgeClaimAppRow delete the app's plan_lapse_items in their transaction; stale-item deletes are logged and skipped) — TestPurgeRemovesTheAppsLapseItems RED→GREEN, TestConvergenceSkipsAnItemOfAPurgedApp RED→GREEN
+Final: fixed 7 stale keep forms selected a replacement (keep values carry kind:ref@created and must match the incarnation; mutation dropping the check watched failing) — TestKeepSaveRefusesAReplacedIncarnation (GREEN; RED only by format before the fix, so verified by mutation)
+Final: fixed 8 keep page showed an off app's worker on (state from the effective set: items plus the account's disabled host list) — TestKeepPageShowsAnOffAppsWorkerOff RED→GREEN
+Final: Ruling: the census re-run adds no new decision units (the hand overlay plans-4d-units digests are unchanged); two more claimed body changes (Store.PurgeAppRow, Store.PurgeClaimAppRow) and sweepOnce +whole:Route ×4 go through census-propose — cost if wrong: census re-run.
diff --git a/docs/superpowers/specs/CODEX-FINDINGS-PLANS-4D1-CODE.md b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-4D1-CODE.md
new file mode 100644
index 000000000..05b3b02cd
--- /dev/null
+++ b/docs/superpowers/specs/CODEX-FINDINGS-PLANS-4D1-CODE.md
@@ -0,0 +1,91 @@
+**Verdict: changes required** at `889d9f98b4ed4e0265b44f929a77f71c5cdf571b`, compared with `c743efeafef23567c9e2c37d29d351043690e1e4`.
+
+No Critical findings. Six Important and two Minor findings follow.
+
+1. **Important — an older grace pass can turn things off after an upgrade or sponsorship.**
+ [planlapse.go:80](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse.go:80), [plangracepass.go:66](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/plangracepass.go:66), [planlapse.go:203](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse.go:203).
+ There is no shared serialization or revision check between plan changes, grace convergence and keep saves. An hourly pass can capture overdue free-plan state, pause on bucket reads, then resume after an upgrade has cleared and published `Disabled`. It writes the old shutdown selection with a **new** revision, so publication’s revision protection accepts it. Paid or sponsored routes can go off again until another grace pass. A stale pass can also restore grace rows deleted for a further fall. Make assignment/lapse/grace-reset changes atomic and reject or serialize stale convergence.
+
+2. **Important — unreadable domain claims are treated as deleted domains.**
+ [planlapse_inventory.go:88](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_inventory.go:88).
+ `ClaimCache.List` discards its underlying list’s dropped-claim information and returns success when individual claim reads fail. Consequently, a failed GET for an already-disabled custom domain removes it from the inventory, deletes its lapse item and republishes it as enabled. If domains were the only excess, `ClearLapse` also runs; recovering the claim then does not restart enforcement. This violates Review Focus 2. Use a completeness-aware claims read and preserve state when a relevant claim is unreadable.
+
+3. **Important — sponsorship preserves a dormant lapse that resumes when sponsorship ends.**
+ [planlapse.go:237](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse.go:237).
+ `clearLapseOff` clears disabled items and hosts but never clears `LapseSince`. Sequence: paid account lapses → operator sponsors it → operator later removes sponsorship. `lapseStarted` correctly rejects the sponsored-to-free transition, but `lapseEligible` accepts the retained marker. The account enters shutdown again, potentially using an already-expired running-things grace period. End the old lapse when sponsorship takes over, and test the complete transition.
+
+4. **Important — crash-looping workers bypass the disabled check.**
+ [activator.go:4680](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:4680).
+ The new check is below the exited-worker branch at lines 4644–4646. That branch calls `restartWorkerLocked` and continues without checking whether the worker is disabled. A worker that exits between sweeps can keep restarting indefinitely after its lapse, retaining its lease and doing work on each restart. Apply the disabled refusal before supervised restart, while preserving command and probe protections.
+
+5. **Important — completed move probes remain exempt from shutdown.**
+ [activator.go:4680](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:4680).
+ `e.probe == nil` exempts every entry that originated as a probe. `RetireExcept` deliberately retains that metadata after marking the entry managed at lines 5110–5115. Thus an ordinary serving instance after a completed move never enters this shutdown branch. Existing long-lived traffic can keep it running after disablement. Exempt only the active move-probe lifecycle, not retained probe metadata.
+
+6. **Important — lapse rows belonging to a purged app can block account convergence permanently.**
+ [planlapse.go:196](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse.go:196), [planlapse_store.go:90](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_store.go:90).
+ Stale-item deletion requires admission through the app being deleted. After permanent purge removes its app row, `mutationAppID` cannot supply that admission. One surviving lapse item therefore makes convergence return before updating the account’s disabled hosts. For example, keep choices survive an upgrade; their app can subsequently be purged while the account is noneligible, leaving rows that block its next lapse. Remove this bookkeeping within the authorized purge transaction, before losing the app identity.
+
+7. **Minor — stale keep forms can select a replacement incarnation.**
+ [planlapse_keep.go:174](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_keep.go:174).
+ Submitted values contain only kind and name. If an instance is deleted and recreated under the same hostname between GET and POST, the stale checkbox selects the replacement and may displace another running instance. Include and validate the displayed incarnation, consistent with the stored `ThingCreated` check.
+
+8. **Minor — the keep page can label a disabled worker “on.”**
+ [planlapse_keep.go:99](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_keep.go:99).
+ Displayed state considers only each item’s own `DisabledAt`. A worker within its per-app cap has no disabled item when its parent app is turned off, although `lapseHosts` disables it through that parent. Derive displayed state from the effective shutdown set, including parent-app shutdown.
+
+The remaining source checks found the intended no-catalog and box-switch behavior, never-paid exclusion, grace-and-notice predicate, single production `SetAccountPlan` caller, additive record format, owner/CSRF checks and cap validation. The edge refusal precedes metering, caching and activation; ordinary aliases remain independent, door scope remains enforced, and backhauled requests are checked at their serving edge. This branch adds no customer-data deletion or per-box polling.
+
+**Census verdicts**
+
+These verdicts concern root authority and the recorded dispositions; they do not override the functional findings above.
+
+For `plans-4d-lapse`, approve each existing unit:
+
+| Unit and source | Verdict and basis |
+|---|---|
+| `Service` — [activator.go:1134](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:1134) | **Approve:** adds an atomic hook; no new input read. |
+| `NewServer` — [server.go:1361](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/server.go:1361) | **Approve:** registers owner-gated routes; no new worker or root operation. |
+| `Store.migrate` — [store.go:138](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/store.go:138) | **Approve:** additive schema work on the existing console database. |
+| Layout — [layout.html:594](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/templates/layout.html:594) | **Approve:** escaped view-model link only. |
+| `runAgent` — [agent.go:503](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/host/agent.go:503) | **Approve:** wires hooks to the existing snapshot; preserves root authority boundaries. |
+| `plansPass` — [plans_pass.go:70](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/host/plans_pass.go:70) | **Approve:** reads the same account records and preserves last-good state on read errors. |
+| `Service.ServeScheduled` — [activator.go:5386](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:5386) | **Approve:** adds a refusal before serving. |
+| `Service.sweepOnce` — [activator.go:4533](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:4533) | **Approve:** uses existing stop paths and skips wakes; no additional tenant-selected root target. Functional omissions are findings 4–5. |
+| `Service.wake` — [activator.go:1760](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:1760) | **Approve:** cancels ordinary wakes without bypassing existing preparation or seed checks. |
+| `Edge.ServeHTTP` — [edge.go:1706](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/edge/edge.go:1706) | **Approve:** adds a serving refusal after existing scope checks. |
+
+For the hand-written `plans-4d-units` overlay, **escalate each proposed new disposition to Paul**, as required for new census units. I found no added root authority in these bodies, but independent review does not replace the owner’s decision to classify new units as accepted legacy.
+
+| New unit and source | Verdict; technical assessment |
+|---|---|
+| `Service.disabled` — [activator.go:5549](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/activator/activator.go:5549) | **Escalate:** hook invocation only. |
+| `Store.MarkLapse` — [accountplans.go:242](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/accountplans.go:242) | **Escalate:** parameterized account-row update. |
+| `Store.ClearLapse` — [accountplans.go:249](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/accountplans.go:249) | **Escalate:** parameterized account-row update. |
+| `Store.SetAccountDisabled` — [accountplans.go:258](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/accountplans.go:258) | **Escalate:** normalized host-list storage; no host execution. |
+| `Store.migratePlanLapse` — [planlapse_store.go:12](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_store.go:12) | **Escalate:** fixed console-table DDL. |
+| `Store.LapseItems` — [planlapse_store.go:40](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_store.go:40) | **Escalate:** account-scoped SQL read. |
+| `Store.claimRawPutLapseItem` — [planlapse_store.go:62](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_store.go:62) | **Escalate:** parameterized upsert behind app admission. |
+| `Store.claimRawDeleteLapseItem` — [planlapse_store.go:75](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_store.go:75) | **Escalate:** scoped bookkeeping deletion behind app admission. |
+| `Store.LiveAppsCreated` — [planlapse_store.go:99](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/planlapse_store.go:99) | **Escalate:** account-scoped SQL read. |
+| Keep template — [plan_keep.html:1](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/console/templates/plan_keep.html:1) | **Escalate:** escaped template rendering; standard CSRF field. |
+| `Edge.planDisabledAdmit` — [plandisabled.go:75](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/edge/plandisabled.go:75) | **Escalate:** fixed 503 response; no request content echoed. |
+| `planDisabledFor` — [plans_pass.go:245](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/host/plans_pass.go:245) | **Escalate:** in-memory lookup scoped to the route’s account. |
+| `planDisabledRoute` — [plans_pass.go:272](/home/paulca/.cache/tmp/claude-1001/plans-4d-lapse/internal/host/plans_pass.go:272) | **Escalate:** delegates using the route’s own host. |
+
+All six envelope re-pins receive **Approve** for preservation of existing root authority:
+
+| Envelope | Basis |
+|---|---|
+| `internal/activator` | Existing lifecycle operations with additional refusal/stop decisions. |
+| `internal/console` | Console SQL and existing bucket interfaces; app admission remains enforced. |
+| `internal/console/templates` | Escaped presentation only. |
+| `internal/edge` | Fixed refusal before downstream dispatch; existing routing boundaries retained. |
+| `internal/host` | Existing record reads and immutable snapshot hooks; no new polling. |
+| `internal/plans` | Additive wire field and pure limit comparison. |
+
+The two record-write census entries also receive **Approve**: `NewServer` retains its existing route literal, and `plangrace.go`’s `sidecars` literal identifies a cap rather than a provisioning-record key.
+
+Read-only checks matched all 23 unit digests, all six envelope fingerprints, the legacy fingerprints, and both chained seals: `a9653e57…` and `94018252…`. `git diff --check` passed. The targeted Go census test **could not start** because the sandbox refused creation of Go’s build work directory; this is not a test pass.
+
+HEAD and the working tree remain unchanged. No ruling was posted to #280.
\ No newline at end of file
diff --git a/internal/activator/activator.go b/internal/activator/activator.go
index f6e43fe0f..05609da8a 100644
--- a/internal/activator/activator.go
+++ b/internal/activator/activator.go
@@ -1781,7 +1781,7 @@ func (a *Service) wake(e *actEntry) {
}
// A route a lapse turned off is refused like a fence (plans 4d); a
// move's probe wake still runs, so moves keep working.
- if e.probe == nil && a.disabled(e.route) {
+ if !activeProbe(e) && a.disabled(e.route) {
cancel()
}
a.mu.Unlock()
@@ -4641,6 +4641,14 @@ func (a *Service) sweepOnce() {
// bound and is filed as a follow-up: it is a design decision about
// when the platform gives up on a member's bot, not a detail of
// this arm.
+ // A worker a lapse turned off (plans 4d) is not restarted: it
+ // stands down, as a finished one does. Never mid-command, never a
+ // move's active probe.
+ if e.worker && e.cmd == nil && !activeProbe(e) && a.disabled(e.route) {
+ log.Printf("activator: sidecar %s exited and was turned off by its plan — not restarting", e.host)
+ a.beginStopLocked(e, StopExited)
+ continue
+ }
if e.worker && (!e.route.Hibernate || procCrashed(e.proc)) {
a.restartWorkerLocked(e, now)
continue
@@ -4677,7 +4685,7 @@ func (a *Service) sweepOnce() {
// the activator.
// A route a lapse turned off (plans 4d) stops, worker or instance,
// whatever is in flight; never mid-command, and never a move's probe.
- if e.probe == nil && e.cmd == nil && a.disabled(e.route) {
+ if !activeProbe(e) && e.cmd == nil && a.disabled(e.route) {
log.Printf("activator: %s was turned off by its plan — stopping", e.host)
a.beginStopLocked(e, StopIdle)
continue
@@ -5545,6 +5553,11 @@ func (a *Service) SetDisabledFor(f func(registry.Route) bool) {
a.disabledFor.Store(&f)
}
+// activeProbe is whether e is a move's probe still in its move: held, not
+// yet managed by the edge. A finished move's entry keeps its probe metadata
+// once RetireExcept marks it managed, and is an ordinary instance then.
+func activeProbe(e *actEntry) bool { return e.probe != nil && !e.probe.managed }
+
// disabled asks the turned-off hook about rt; false without one.
func (a *Service) disabled(rt registry.Route) bool {
f := a.disabledFor.Load()
diff --git a/internal/activator/activator_disabledfor_test.go b/internal/activator/activator_disabledfor_test.go
index ddd438d9a..b8e9ed368 100644
--- a/internal/activator/activator_disabledfor_test.go
+++ b/internal/activator/activator_disabledfor_test.go
@@ -142,3 +142,35 @@ func TestDisabledForNilUnchanged(t *testing.T) {
t.Fatalf("a hook answering false: starts = %d, want 2", starts)
}
}
+
+// Astra plans-4d finding 4: a crash-looping worker that a lapse turned off
+// is not restarted by the supervisor; it stands down.
+func TestDisabledForStopsACrashedWorkerInsteadOfRestarting(t *testing.T) {
+ t.Parallel()
+ a, b, _, _ := testActivator(t, time.Hour)
+ if err := a.WakeWorker(alwaysOnWorkerRoute("bot.x.internal")); err != nil {
+ t.Fatalf("WakeWorker: %v", err)
+ }
+ a.SetDisabledFor(disabledFor("bot.x.internal"))
+ b.lastWorker().kill()
+ a.sweepOnce()
+ waitFor(t, "the turned-off worker to stand down", func() bool { return !a.Owns("bot.x.internal") })
+ if n := b.workerStarts(); n != 1 {
+ t.Fatalf("worker starts = %d, want 1 (no restart of a turned-off worker)", n)
+ }
+}
+
+// Astra plans-4d finding 5: an entry that began as a move's probe and is now
+// managed (the move finished) is an ordinary instance: a lapse stops it.
+func TestDisabledForStopsAFinishedProbeEntry(t *testing.T) {
+ t.Parallel()
+ a, _, clk, _ := testActivator(t, time.Hour)
+ wakeInstance(t, a, "moved.example.com")
+ a.mu.Lock()
+ a.entries["moved.example.com"].probe = &probeEntry{managed: true}
+ a.mu.Unlock()
+ a.SetDisabledFor(disabledFor("moved.example.com"))
+ clk.advance(time.Second)
+ a.sweepOnce()
+ waitFor(t, "the finished probe entry stopped", func() bool { return !a.Owns("moved.example.com") })
+}
diff --git a/internal/console/claim_app_identity.go b/internal/console/claim_app_identity.go
index 21c9a91bc..0d2bc9bad 100644
--- a/internal/console/claim_app_identity.go
+++ b/internal/console/claim_app_identity.go
@@ -185,6 +185,11 @@ func (s *Store) PurgeClaimAppRow(ctx context.Context, accountID int64, app, appI
if err = revokeClaimDoorKeys(tx, accountID, app); err != nil {
return err
}
+ // Plans 4d: the app's lapse bookkeeping goes with its identity (Astra
+ // finding 6).
+ if _, err = tx.ExecContext(ctx, `DELETE FROM plan_lapse_items WHERE account_id=? AND app=?`, accountID, app); err != nil {
+ return err
+ }
return tx.Commit()
}
diff --git a/internal/console/claim_invariant_fixtures_test.go b/internal/console/claim_invariant_fixtures_test.go
index b62f6b143..5baa57c1f 100644
--- a/internal/console/claim_invariant_fixtures_test.go
+++ b/internal/console/claim_invariant_fixtures_test.go
@@ -1036,7 +1036,7 @@ var claimFixtures = map[string]claimFixture{
"route POST /a/{sqid}/plan/keep": {door: &claimDoor{
apps: claimRefs("bab/kass"),
setup: claimWorldLapse,
- do: claimForm("/a/bab/plan/keep", "keep", "app:kass"),
+ do: claimKeepKass,
check: func(t *testing.T, cx *claimCase, open bool) string {
items, err := cx.st.LapseItems(OpsAccountID)
if err != nil {
@@ -2128,3 +2128,13 @@ func (cx *claimCase) readyClaims(t *testing.T) {
cx.settleRegistrations(t, record.Holder.Account, record.Holder.App)
}
}
+
+// claimKeepKass posts the keep page with kass ticked, naming the
+// incarnation the page showed (Astra plans-4d finding 7).
+func claimKeepKass(t *testing.T, cx *claimCase) int {
+ created, err := cx.st.LiveAppsCreated(OpsAccountID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return cx.form(t, "/a/bab/plan/keep", "keep", "app:kass@"+strconv.FormatInt(created["kass"].Unix(), 10))
+}
diff --git a/internal/console/plangracepass.go b/internal/console/plangracepass.go
index 0ccdc1534..fc473f93a 100644
--- a/internal/console/plangracepass.go
+++ b/internal/console/plangracepass.go
@@ -8,6 +8,7 @@ import (
"net/url"
"strconv"
"strings"
+ "sync"
"time"
)
@@ -58,7 +59,24 @@ func (s *Server) planGracePass(ctx context.Context, now time.Time) {
}
}
+// planGraceAccount is one account's grace pass, under the account's lapse
+// lock so it cannot interleave with a plan change or a keep save.
func (s *Server) planGraceAccount(ctx context.Context, acct *Account, now time.Time) error {
+ defer s.lapseLock(acct.ID)()
+ return s.planGraceAccountLocked(ctx, acct, now)
+}
+
+// lapseLock takes the account's lapse lock and returns its unlock.
+func (s *Server) lapseLock(accountID int64) func() {
+ m, _ := s.lapseLocks.LoadOrStore(accountID, &sync.Mutex{})
+ mu := m.(*sync.Mutex)
+ mu.Lock()
+ return mu.Unlock
+}
+
+// planGraceAccountLocked is planGraceAccount for a caller holding the
+// account's lapse lock.
+func (s *Server) planGraceAccountLocked(ctx context.Context, acct *Account, now time.Time) error {
l, err := s.EffectiveLimits(acct)
if err != nil || l == nil {
return err
@@ -137,13 +155,16 @@ func (s *Server) planGraceAccount(ctx context.Context, acct *Account, now time.T
log.Printf("console: plan grace %s: storage clear: %v", acct.Sqid, err)
}
}
+ if s.lapseBeforeConverge != nil {
+ s.lapseBeforeConverge()
+ }
switch {
case eligible && inv != nil:
if err := s.convergeLapse(ctx, acct, row, l, byState, inv, now); err != nil {
log.Printf("console: plan grace %s: lapse: %v", acct.Sqid, err)
}
case !eligible:
- if err := s.clearLapseOff(ctx, acct, now); err != nil {
+ if err := s.clearLapseOff(ctx, acct, row, now); err != nil {
log.Printf("console: plan grace %s: lapse clear: %v", acct.Sqid, err)
}
}
diff --git a/internal/console/planlapse.go b/internal/console/planlapse.go
index f98a61760..7fd6b0147 100644
--- a/internal/console/planlapse.go
+++ b/internal/console/planlapse.go
@@ -73,6 +73,10 @@ func (s *Server) lapseStarted(old *AccountPlanRow, plan string, packs map[string
// no catalog it writes exactly what Store.SetAccountPlan writes.
func (s *Server) applyAccountPlan(ctx context.Context, acct *Account, plan string, packs map[string]int, source string,
sponsored *plans.Limits, reason, by string, now time.Time) error {
+ // The plan write, the lapse mark, the grace reset and the re-converge
+ // happen under the account's lapse lock, so a grace pass that read the
+ // old plan cannot converge after them (Astra finding 1).
+ defer s.lapseLock(acct.ID)()
old, err := s.store.AccountPlan(acct.ID)
if err != nil {
return err
@@ -95,7 +99,7 @@ func (s *Server) applyAccountPlan(ctx context.Context, acct *Account, plan strin
return nil
}
// Re-converge now, so paying again turns things back on in this call.
- if err := s.planGraceAccount(ctx, acct, now); err != nil {
+ if err := s.planGraceAccountLocked(ctx, acct, now); err != nil {
log.Printf("console: plan %s: grace: %v", acct.Sqid, err)
}
row, err := s.store.AccountPlan(acct.ID)
@@ -187,17 +191,13 @@ func (s *Server) convergeLapse(ctx context.Context, acct *Account, row *AccountP
}
case has && !current:
// A row for an earlier thing of the same name.
- if err := s.store.DeleteLapseItem(ctx, acct.ID, it.App, it.Kind, it.Ref); err != nil {
- return err
- }
+ s.dropStaleLapseItem(ctx, acct, it)
}
}
}
for key, it := range byKey {
if !seen[key] {
- if err := s.store.DeleteLapseItem(ctx, acct.ID, it.App, it.Kind, it.Ref); err != nil {
- return err
- }
+ s.dropStaleLapseItem(ctx, acct, it)
}
}
if _, err := s.store.SetAccountDisabled(acct.ID, lapseHosts(off, inv), now); err != nil {
@@ -214,6 +214,16 @@ func (s *Server) convergeLapse(ctx context.Context, acct *Account, row *AccountP
return nil
}
+// dropStaleLapseItem deletes an item for a thing that is gone. A delete
+// that cannot be admitted (its app no longer exists, Astra finding 6) is
+// logged and skipped: stale bookkeeping never stops the account's
+// convergence.
+func (s *Server) dropStaleLapseItem(ctx context.Context, acct *Account, it lapseItem) {
+ if err := s.store.DeleteLapseItem(ctx, acct.ID, it.App, it.Kind, it.Ref); err != nil {
+ log.Printf("console: plan lapse %s: stale item %s %s of %s left: %v", acct.Sqid, it.Kind, it.Ref, it.App, err)
+ }
+}
+
// lapseItemOn turns one item back on: a kept item keeps its row with
// DisabledAt cleared, any other row goes.
func (s *Server) lapseItemOn(ctx context.Context, acct *Account, it lapseItem, now time.Time) error {
@@ -233,8 +243,20 @@ func (s *Server) lapseItemOn(ctx context.Context, acct *Account, it lapseItem, n
// clearLapseOff turns everything a lapse turned off back on, without an
// inventory: the account is no longer on the lapse path (sponsored, its
-// lapse cleared, or plans that no longer govern it).
-func (s *Server) clearLapseOff(ctx context.Context, acct *Account, now time.Time) error {
+// lapse cleared, or plans that no longer govern it). Sponsorship ends a
+// lapse for good (Astra finding 3): its mark and its caps' grace clocks
+// go, so losing the sponsorship later never resumes the old lapse.
+func (s *Server) clearLapseOff(ctx context.Context, acct *Account, row *AccountPlanRow, now time.Time) error {
+ if row != nil && planRowSponsored(row) && !row.LapseSince.IsZero() {
+ if err := s.store.ClearLapse(acct.ID); err != nil {
+ return err
+ }
+ for _, c := range lapseCaps {
+ if err := s.store.DeleteCapState(acct.ID, c); err != nil {
+ return err
+ }
+ }
+ }
items, err := s.store.LapseItems(acct.ID)
if err != nil {
return err
diff --git a/internal/console/planlapse_findings_test.go b/internal/console/planlapse_findings_test.go
new file mode 100644
index 000000000..ecf70f663
--- /dev/null
+++ b/internal/console/planlapse_findings_test.go
@@ -0,0 +1,215 @@
+package console
+
+import (
+ "context"
+ "net/url"
+ "slices"
+ "strconv"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/domains"
+ "github.com/carlosframework/platform/internal/plans"
+ "github.com/carlosframework/platform/internal/provision"
+)
+
+// Astra plans-4d findings (docs/superpowers/specs/CODEX-FINDINGS-PLANS-4D1-CODE.md).
+
+// Finding 1: a grace pass that read the overdue free plan, then paused,
+// must not turn things off after an upgrade landed meanwhile. The upgrade
+// is started from inside the pass, just before it converges.
+func TestStaleGracePassCannotUndoAnUpgrade(t *testing.T) {
+ fx, acct, _ := lapseFixture(t)
+ applyPlan(t, fx, acct, "free", nil, nil, planNow)
+ var once sync.Once
+ done := make(chan error, 1)
+ fx.srv.lapseBeforeConverge = func() {
+ once.Do(func() {
+ go func() {
+ done <- fx.srv.applyAccountPlan(context.Background(), acct, "personal", nil, PlanSourceOperator, nil, "r", "ops@example.com", planNow.Add(week+time.Minute))
+ }()
+ select {
+ case err := <-done:
+ done <- err // the upgrade finished inside the pass
+ case <-time.After(500 * time.Millisecond):
+ }
+ })
+ }
+ fx.srv.planGracePass(context.Background(), planNow.Add(week))
+ if err := <-done; err != nil {
+ t.Fatal(err)
+ }
+ if got := disabledOf(t, fx, acct); got != nil {
+ t.Fatalf("after the upgrade: disabled = %v, want nothing off", got)
+ }
+ if got := publishedDisabled(t, fx, acct); got != nil {
+ t.Fatalf("after the upgrade: published Disabled = %v", got)
+ }
+}
+
+// Finding 2: a custom domain claim that cannot be read is not a deleted
+// domain: nothing turned off comes back on, and the lapse does not end.
+func TestUnreadableClaimKeepsTheDomainOff(t *testing.T) {
+ fx := newConsoleFixture(t)
+ fx.srv.cfg.PlanCatalog = examplePlanCatalog(t)
+ fx.srv.cfg.AppsDomain = "oncarlos.test"
+ fx.srv.consoleMail = &fakeConsoleMail{ready: true}
+ fx.srv.sendFederated = nil
+ acct := planAccount(t, fx, 501)
+ lapseApp_(t, fx, acct, "shop", at(-100))
+ lapseInstanceRec(t, fx, acct, "shop", "shop-1.example.com", at(-99))
+ lapseClaim(t, fx, acct, "shop", "shop.example.com", true, at(-98))
+ applyPlan(t, fx, acct, "personal", nil, nil, planNow.Add(-time.Hour))
+ applyPlan(t, fx, acct, "free", nil, nil, planNow)
+ fx.srv.planGracePass(context.Background(), planNow.Add(week))
+ want := []string{"*.shop.example.com", "shop.example.com"}
+ if got := disabledOf(t, fx, acct); !slices.Equal(got, want) {
+ t.Fatalf("fixture: disabled = %v, want %v", got, want)
+ }
+ _, etag, err := fx.rel.Get(context.Background(), domains.ClaimKey("shop.example.com"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := fx.rel.Put(context.Background(), domains.ClaimKey("shop.example.com"), []byte(`{not json`), etag); err != nil {
+ t.Fatal(err)
+ }
+ fx.srv.planGracePass(context.Background(), planNow.Add(week+time.Hour))
+ if got := disabledOf(t, fx, acct); !slices.Equal(got, want) {
+ t.Fatalf("unreadable claim: disabled = %v, want %v kept", got, want)
+ }
+ if got := offItems(t, fx, acct); !slices.Equal(got, []string{"shop.example.com"}) {
+ t.Fatalf("unreadable claim: items off = %v", got)
+ }
+ if lapseSince(t, fx, acct).IsZero() {
+ t.Fatal("unreadable claim ended the lapse")
+ }
+}
+
+// Finding 3: sponsorship ends a lapse for good. Paid, lapsed, sponsored,
+// then unsponsored: nothing is turned off on the old lapse.
+func TestSponsorshipEndsTheLapse(t *testing.T) {
+ fx, acct, _ := lapseFixture(t)
+ lapseAndTurnOff(t, fx, acct)
+ applyPlan(t, fx, acct, "free", nil, &plans.Limits{RunningThings: 3}, planNow.Add(week+time.Hour))
+ if got := lapseSince(t, fx, acct); !got.IsZero() {
+ t.Fatalf("sponsored: lapse_since = %v, want cleared", got)
+ }
+ applyPlan(t, fx, acct, "free", nil, nil, planNow.Add(week+2*time.Hour))
+ fx.srv.planGracePass(context.Background(), planNow.Add(3*week))
+ if got := disabledOf(t, fx, acct); got != nil {
+ t.Fatalf("unsponsored: the old lapse turned off %v", got)
+ }
+}
+
+// Finding 6: purging an app removes its lapse bookkeeping in the same
+// transaction.
+func TestPurgeRemovesTheAppsLapseItems(t *testing.T) {
+ st, ids := planStore(t, "bab")
+ id := ids["bab"]
+ if _, err := st.CreateAppIn(id, "shop", "o@example.com", planNow); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.PutLapseItem(context.Background(), lapseItem{AccountID: id, App: "shop", Kind: lapseApp, Ref: "shop",
+ ThingCreated: planNow, Keep: true, UpdatedAt: planNow}); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := st.db.Exec(`UPDATE apps SET deleted_at = ? WHERE app = 'shop'`, planNow.Unix()); err != nil {
+ t.Fatal(err)
+ }
+ if err := st.PurgeAppRow(id, "shop"); err != nil {
+ t.Fatal(err)
+ }
+ if items, _ := st.LapseItems(id); items != nil {
+ t.Fatalf("purged app's lapse items survive: %+v", items)
+ }
+}
+
+// Finding 6: a lapse item whose app no longer exists (no admission can be
+// had for it) does not stop the rest of the account's convergence.
+func TestConvergenceSkipsAnItemOfAPurgedApp(t *testing.T) {
+ cx := newClaimCase(t)
+ claimWorldLapse(t, cx)
+ scope := claimSQLScope{AccountID: OpsAccountID, App: "ghost", AppID: "app-ghost", Mode: claimModeEffect}
+ if err := cx.st.withClaimSQL(gateCtx(t), []claimSQLScope{scope}, allowAllClaimSQL, func(v *Store) error {
+ _, err := v.db.Exec(`INSERT INTO plan_lapse_items (account_id, app, kind, ref, thing_created, keep, updated_at)
+ VALUES (?, 'ghost', 'app', 'ghost', 1, 1, 1)`, OpsAccountID)
+ return err
+ }); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := cx.st.SetAccountDisabled(OpsAccountID, []string{"stale.example.com"}, time.Now()); err != nil {
+ t.Fatal(err)
+ }
+ acct, err := cx.st.AccountByID(OpsAccountID)
+ if err != nil || acct == nil {
+ t.Fatalf("ops account: %v", err)
+ }
+ if err := cx.srv.planGraceAccount(context.Background(), acct, time.Now()); err != nil {
+ t.Logf("pass: %v", err)
+ }
+ row, _ := cx.st.AccountPlan(OpsAccountID)
+ if row.Disabled != nil {
+ t.Fatalf("an unadmittable item stopped convergence: disabled = %v", row.Disabled)
+ }
+}
+
+// Finding 7: a keep form names the incarnation it showed; a thing deleted
+// and recreated under the same name since is refused as stale.
+func TestKeepSaveRefusesAReplacedIncarnation(t *testing.T) {
+ fx, acct, c, csrf := keepFixture(t, false)
+ shown := keepValue(lapseInstance, "blog-1.example.com", at(-97))
+ if err := fx.rel.Delete(context.Background(), provision.RecordKey(acct.Sqid, "blog", "blog-1.example.com")); err != nil {
+ t.Fatal(err)
+ }
+ lapseInstanceRec(t, fx, acct, "blog", "blog-1.example.com", at(5)) // recreated
+ postForm(t, c, keepURL(fx, acct), url.Values{"csrf": {csrf}, "keep": {shown}})
+ if got := keptRefs(t, fx, acct); got != nil {
+ t.Fatalf("a stale form kept the replacement: %v", got)
+ }
+ if _, _, body := get(t, c, keepURL(fx, acct)); !strings.Contains(body, planKeepCopy["keep.stale"]) {
+ t.Fatalf("no stale message:\n%s", body)
+ }
+}
+
+// Finding 8: a worker within its per-app cap whose app is turned off shows
+// as turned off on the keep page.
+func TestKeepPageShowsAnOffAppsWorkerOff(t *testing.T) {
+ fx, acct, c, _ := keepFixture(t, false)
+ worker := lapseSidecarRec(t, fx, acct, "blog", "mailer", at(-95))
+ // Free covers 3: shop, shop-1 and blog stay; keep shop-2 and blog-1 so
+ // that the blog app itself goes off with its worker.
+ for _, ref := range []string{"shop-2.example.com", "shop-1.example.com"} {
+ if err := fx.st.PutLapseItem(context.Background(), lapseItem{AccountID: acct.ID, App: "shop", Kind: lapseInstance, Ref: ref,
+ ThingCreated: thingCreated(ref), Keep: true, UpdatedAt: time.Now()}); err != nil {
+ t.Fatal(err)
+ }
+ }
+ fx.srv.planGracePass(context.Background(), time.Now())
+ if got := disabledOf(t, fx, acct); !slices.Contains(got, worker) {
+ t.Fatalf("fixture: worker %s not turned off: %v", worker, got)
+ }
+ _, _, body := get(t, c, keepURL(fx, acct))
+ i := strings.Index(body, worker)
+ if i < 0 {
+ t.Fatalf("worker not listed:\n%s", body)
+ }
+ row := body[i:]
+ if j := strings.Index(row, "</tr>"); j > 0 {
+ row = row[:j]
+ }
+ if !strings.Contains(row, planKeepCopy["keep.off"]) {
+ t.Fatalf("worker of an off app shows as on: %s", row)
+ }
+}
+
+func keepValue(kind, ref string, created time.Time) string {
+ return kind + ":" + ref + "@" + strconv.FormatInt(created.Unix(), 10)
+}
+
+// thingCreated is the lapseFixture's creation time of an instance.
+func thingCreated(ref string) time.Time {
+ return map[string]time.Time{"shop-1.example.com": at(-99), "blog-1.example.com": at(-97), "shop-2.example.com": at(-96)}[ref]
+}
+
diff --git a/internal/console/planlapse_inventory.go b/internal/console/planlapse_inventory.go
index 70826be5d..c7240713b 100644
--- a/internal/console/planlapse_inventory.go
+++ b/internal/console/planlapse_inventory.go
@@ -9,6 +9,7 @@ import (
"strings"
"time"
+ "github.com/carlosframework/platform/internal/domains"
"github.com/carlosframework/platform/internal/plans"
"github.com/carlosframework/platform/internal/provision"
)
@@ -85,10 +86,13 @@ func (s *Server) lapseInventory(ctx context.Context, acct *Account) (*lapseInven
inv.Sidecars = append(inv.Sidecars, lapseThing{Kind: lapseSidecar, App: app, Ref: strings.ToLower(r.Host), CreatedAt: r.CreatedAt})
}
}
- claims, err := s.claims.List(ctx, s.cfg.Releases)
+ claims, unread, err := s.claims.ListWithUnread(ctx, s.cfg.Releases)
if err != nil {
return nil, err
}
+ if err := s.lapseUnreadClaims(acct, items, unread); err != nil {
+ return nil, err
+ }
for _, c := range claims {
host := strings.ToLower(c.Host)
if c.Account != acct.Sqid {
@@ -110,6 +114,38 @@ func (s *Server) lapseInventory(ctx context.Context, acct *Account) (*lapseInven
return inv, nil
}
+// lapseUnreadClaims fails the inventory when a claim that could matter to
+// the account could not be read (Astra finding 2): one already turned off,
+// one an earlier read knew was the account's, or any unread claim of
+// unknown account while the account's custom domains are over. Unknown is
+// not gone.
+func (s *Server) lapseUnreadClaims(acct *Account, items []lapseItem, unread []domains.UnreadClaim) error {
+ if len(unread) == 0 {
+ return nil
+ }
+ known := map[string]bool{}
+ for _, it := range items {
+ if it.Kind == lapseDomain {
+ known[it.Ref] = true
+ }
+ }
+ states, err := s.store.CapStates(acct.ID)
+ if err != nil {
+ return err
+ }
+ domainsOver := false
+ for _, st := range states {
+ domainsOver = domainsOver || (st.Cap == capCustomDomains && st.Level.over())
+ }
+ for _, u := range unread {
+ host := strings.ToLower(u.Host)
+ if known[host] || u.Account == acct.Sqid || (u.Account == "" && domainsOver) {
+ return fmt.Errorf("claim %s could not be read", host)
+ }
+ }
+ return nil
+}
+
// measureLeftovers measures the two lapse-only caps from an inventory: the
// workers beyond the per-app cap, summed over apps, and the custom domains
// on a plan without them. A cap the plan does not limit is absent.
diff --git a/internal/console/planlapse_keep.go b/internal/console/planlapse_keep.go
index feb11d9cc..082e7a5f5 100644
--- a/internal/console/planlapse_keep.go
+++ b/internal/console/planlapse_keep.go
@@ -6,6 +6,7 @@ import (
"log"
"net/http"
"net/url"
+ "strconv"
"strings"
"time"
)
@@ -96,12 +97,19 @@ func (s *Server) handlePlanKeep(w http.ResponseWriter, r *http.Request) {
if err != nil {
log.Printf("console: plan keep %s: items: %v", acct.Sqid, err)
}
+ // What is off is the effective set (Astra finding 8): an item turned
+ // off itself, or a host the account's turned-off list carries, which
+ // includes every instance and worker of an app that is off.
off := map[string]bool{}
for _, it := range items {
if !it.DisabledAt.IsZero() {
off[lapseKey(it.Kind, it.Ref)] = true
}
}
+ for _, h := range row.Disabled {
+ off[lapseKey(lapseInstance, h)] = true
+ off[lapseKey(lapseSidecar, h)] = true
+ }
view.Intro = fmt.Sprintf(planKeepCopy["keep.intro"], l.RunningThings, l.SidecarsPerApp)
add := func(x lapseThing, indent bool) {
state := planKeepCopy["keep.on"]
@@ -112,7 +120,7 @@ func (s *Server) handlePlanKeep(w http.ResponseWriter, r *http.Request) {
if !x.CreatedAt.IsZero() {
created = x.CreatedAt.UTC().Format("2 January 2006")
}
- view.Rows = append(view.Rows, planKeepRow{Value: x.Kind + ":" + x.Ref, Name: x.Ref, Created: created,
+ view.Rows = append(view.Rows, planKeepRow{Value: planKeepValue(x), Name: x.Ref, Created: created,
State: state, Keep: x.Keep, Indent: indent})
}
for _, x := range inv.Things {
@@ -134,6 +142,32 @@ func (s *Server) handlePlanKeep(w http.ResponseWriter, r *http.Request) {
s.render(w, http.StatusOK, "plan_keep", p)
}
+// planKeepValue is a keep checkbox's value: the thing's kind, name and the
+// creation time of the incarnation the page showed (Astra finding 7).
+func planKeepValue(x lapseThing) string {
+ return x.Kind + ":" + x.Ref + "@" + strconv.FormatInt(unixOrZero(x.CreatedAt), 10)
+}
+
+// planKeepThing resolves a submitted keep value to the inventory thing it
+// names, only when that thing is still the incarnation the form showed: a
+// thing deleted and recreated under the same name since is not it.
+func planKeepThing(v string, byKey map[string]lapseThing) (lapseThing, bool) {
+ kind, rest, ok := strings.Cut(v, ":")
+ at := strings.LastIndex(rest, "@")
+ if !ok || at < 0 || (kind != lapseApp && kind != lapseInstance && kind != lapseSidecar) {
+ return lapseThing{}, false
+ }
+ created, err := strconv.ParseInt(rest[at+1:], 10, 64)
+ if err != nil {
+ return lapseThing{}, false
+ }
+ x, ok := byKey[lapseKey(kind, rest[:at])]
+ if !ok || unixOrZero(x.CreatedAt) != created {
+ return lapseThing{}, false
+ }
+ return x, true
+}
+
func (s *Server) handlePlanKeepSave(w http.ResponseWriter, r *http.Request) {
addr, raw, acct, ok := s.planKeepGate(w, r)
if !ok {
@@ -144,6 +178,9 @@ func (s *Server) handlePlanKeepSave(w http.ResponseWriter, r *http.Request) {
return
}
back := "/a/" + url.PathEscape(acct.Sqid) + "/plan/keep"
+ // Read, validate, write and re-converge under the account's lapse lock
+ // (Astra finding 1).
+ defer s.lapseLock(acct.ID)()
fail := func(msg string) {
s.setFlash(w, "err", msg)
http.Redirect(w, r, back, http.StatusSeeOther)
@@ -172,13 +209,12 @@ func (s *Server) handlePlanKeepSave(w http.ResponseWriter, r *http.Request) {
}
keep := map[string]bool{}
for _, v := range r.Form["keep"] {
- kind, ref, _ := strings.Cut(v, ":")
- key := lapseKey(kind, ref)
- if _, ok := byKey[key]; !ok || (kind != lapseApp && kind != lapseInstance && kind != lapseSidecar) {
+ x, ok := planKeepThing(v, byKey)
+ if !ok {
fail(planKeepCopy["keep.stale"])
return
}
- keep[key] = true
+ keep[lapseKey(x.Kind, x.Ref)] = true
}
// Count what stays: a kept instance keeps its app.
apps, things, perApp := map[string]bool{}, 0, map[string]int{}
@@ -242,7 +278,7 @@ func (s *Server) handlePlanKeepSave(w http.ResponseWriter, r *http.Request) {
}
s.audit(acct, accountAuditSubject, addr, "plan.keep", fmt.Sprintf("chose %d things to keep", len(keep)))
// Take effect at once: re-converge, then publish.
- if err := s.planGraceAccount(r.Context(), acct, now); err != nil {
+ if err := s.planGraceAccountLocked(r.Context(), acct, now); err != nil {
log.Printf("console: plan keep %s: grace: %v", acct.Sqid, err)
}
if row, err := s.store.AccountPlan(acct.ID); err == nil && row != nil && s.cfg.Releases != nil {
diff --git a/internal/console/planlapse_keep_test.go b/internal/console/planlapse_keep_test.go
index 377625286..a597461a0 100644
--- a/internal/console/planlapse_keep_test.go
+++ b/internal/console/planlapse_keep_test.go
@@ -43,7 +43,7 @@ func TestKeepPageListsRunningThings(t *testing.T) {
t.Fatalf("GET = %d", status)
}
for _, want := range []string{planKeepCopy["keep.title"], "shop", "blog", "shop-1.example.com", "blog-1.example.com",
- "shop-2.example.com", `value="instance:blog-1.example.com"`, `value="app:shop"`, "3 apps and instances"} {
+ "shop-2.example.com", `value="` + keepValue(lapseInstance, "blog-1.example.com", at(-97)) + `"`, `value="` + keepValue(lapseApp, "shop", at(-100)) + `"`, "3 apps and instances"} {
if !strings.Contains(body, want) {
t.Fatalf("keep page lacks %q:\n%s", want, body)
}
@@ -87,7 +87,7 @@ func keptRefs(t *testing.T, fx *consoleFixture, acct *Account) []string {
func TestKeepSaveRefusesMoreThanTheCap(t *testing.T) {
fx, acct, c, csrf := keepFixture(t, false)
- form := url.Values{"csrf": {csrf}, "keep": {"app:shop", "app:blog", "instance:shop-1.example.com", "instance:blog-1.example.com"}}
+ form := url.Values{"csrf": {csrf}, "keep": {keepValue(lapseApp, "shop", at(-100)), keepValue(lapseApp, "blog", at(-98)), keepValue(lapseInstance, "shop-1.example.com", at(-99)), keepValue(lapseInstance, "blog-1.example.com", at(-97))}}
if status, _, _ := postForm(t, c, keepURL(fx, acct), form); status != http.StatusSeeOther {
t.Fatalf("POST = %d, want a redirect", status)
}
@@ -102,12 +102,12 @@ func TestKeepSaveRefusesMoreThanTheCap(t *testing.T) {
func TestKeepSaveImpliesTheApp(t *testing.T) {
fx, acct, c, csrf := keepFixture(t, false)
// Two instances of two unticked apps are four running things.
- form := url.Values{"csrf": {csrf}, "keep": {"instance:shop-1.example.com", "instance:blog-1.example.com"}}
+ form := url.Values{"csrf": {csrf}, "keep": {keepValue(lapseInstance, "shop-1.example.com", at(-99)), keepValue(lapseInstance, "blog-1.example.com", at(-97))}}
postForm(t, c, keepURL(fx, acct), form)
if got := keptRefs(t, fx, acct); got != nil {
t.Fatalf("over the cap through implied apps, kept %v", got)
}
- form = url.Values{"csrf": {csrf}, "keep": {"instance:blog-1.example.com"}}
+ form = url.Values{"csrf": {csrf}, "keep": {keepValue(lapseInstance, "blog-1.example.com", at(-97))}}
postForm(t, c, keepURL(fx, acct), form)
if got, want := keptRefs(t, fx, acct), []string{"blog-1.example.com"}; !slices.Equal(got, want) {
t.Fatalf("kept %v, want %v", got, want)
@@ -116,7 +116,7 @@ func TestKeepSaveImpliesTheApp(t *testing.T) {
func TestKeepSaveSwapsWhatIsOffAtOnce(t *testing.T) {
fx, acct, c, csrf := keepFixture(t, true)
- form := url.Values{"csrf": {csrf}, "keep": {"instance:blog-1.example.com"}}
+ form := url.Values{"csrf": {csrf}, "keep": {keepValue(lapseInstance, "blog-1.example.com", at(-97))}}
status, _, _ := postForm(t, c, keepURL(fx, acct), form)
if status != http.StatusSeeOther {
t.Fatalf("POST = %d", status)
diff --git a/internal/console/server.go b/internal/console/server.go
index 353fb6f5c..d22c0e996 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -874,6 +874,13 @@ type Config struct {
// Server is the console's http.Handler.
type Server struct {
+ // lapseBeforeConverge, when set (tests only), runs inside the account's
+ // grace pass just before the lapse converges (plans 4d, Astra finding 1).
+ lapseBeforeConverge func()
+ // lapseLocks serialises, per account, everything that changes what a
+ // lapse turns off (plans 4d, Astra finding 1): a plan change, the grace
+ // pass's convergence and a keep save. Account id to *sync.Mutex.
+ lapseLocks sync.Map
claimLossPageMu sync.Mutex
claimLossPageDone chan struct{}
diff --git a/internal/console/store.go b/internal/console/store.go
index adb27026f..3974f2dbd 100644
--- a/internal/console/store.go
+++ b/internal/console/store.go
@@ -1816,6 +1816,11 @@ func (s *Store) PurgeAppRow(accountID int64, app string) error {
if err := revokeAllDoorKeys(tx, accountID, app); err != nil {
return err
}
+ // Plans 4d: the app's lapse bookkeeping goes with its identity
+ // (Astra finding 6); nothing could admit a delete of it later.
+ if _, err := tx.ExecContext(ctx, `DELETE FROM plan_lapse_items WHERE account_id = ? AND app = ?`, accountID, app); err != nil {
+ return err
+ }
}
return tx.Commit()
}
diff --git a/internal/domains/claimcache.go b/internal/domains/claimcache.go
index 322990ad7..25a31c75e 100644
--- a/internal/domains/claimcache.go
+++ b/internal/domains/claimcache.go
@@ -82,6 +82,30 @@ func (c *ClaimCache) List(ctx context.Context, s release.Store) ([]Claim, error)
return claims, err
}
+// UnreadClaim is a listed claim that produced no claim this pass for a
+// reason other than not existing: a failed read, an unparseable body, a
+// newer schema. Account is its account when an earlier read knew it, else
+// "".
+type UnreadClaim struct{ Host, Account string }
+
+// ListWithUnread is List plus the claims it could not read, so a caller
+// that must not read "unreadable" as "gone" can tell the two apart (plans
+// 4d). A claim that vanished between the listing and its read is gone, not
+// unread.
+func (c *ClaimCache) ListWithUnread(ctx context.Context, s release.Store) ([]Claim, []UnreadClaim, error) {
+ claims, _, dropped, err := c.listWithHosts(ctx, s)
+ if err != nil {
+ return nil, nil, err
+ }
+ var unread []UnreadClaim
+ for _, d := range dropped {
+ if !d.notFound {
+ unread = append(unread, UnreadClaim{Host: d.host, Account: d.account})
+ }
+ }
+ return claims, unread, nil
+}
+
// claimHostFromKey is the hostname a claim key names (ClaimKey's inverse).
func claimHostFromKey(key string) string {
return strings.TrimSuffix(strings.TrimPrefix(key, ClaimsPrefix), ".json")
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index 1a56e9b23..ee75f7fd6 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -34,4 +34,4 @@ plan14-root-reads-plans-4c-units.tsv f6c05461d95d00fb468c5f580487de16370049b9196
plan14-root-reads-plans-4c-box-throttle.tsv c71b2974cd929122afc730f22cb53c63f3fdefdb4b26f7ca60db76fface906de
plan14-root-reads-gated-deploy-watch-164.tsv c5d8767f883f4a8677330039f54aa556124f6dde888e0b4a36095a49b634e634
plan14-root-reads-plans-4d-units.tsv a9653e5722bdb94eb1951d7d6d537534a6f9237e8cd519af0f870e5f5d7989da
-plan14-root-reads-plans-4d-lapse.tsv 940182523fc6e81a530a1c751abcc50c199fdc8547d98d9c99de1cdb9304dd27
+plan14-root-reads-plans-4d-lapse.tsv c2d276bfd84a5d8220717cde6e932771994e9bfe14fe3d063ba9a03d3025b9be
diff --git a/internal/provision/testdata/plan14-root-reads-plans-4d-lapse.tsv b/internal/provision/testdata/plan14-root-reads-plans-4d-lapse.tsv
index 3124c6c27..ba3f007af 100644
--- a/internal/provision/testdata/plan14-root-reads-plans-4d-lapse.tsv
+++ b/internal/provision/testdata/plan14-root-reads-plans-4d-lapse.tsv
@@ -1,26 +1,31 @@
# Census overlay plans-4d-lapse, written by census-propose (#369). census-ruling-plans-4d-lapse, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-plans-4d-lapse.md.
-# 6 body, 4 sites, 6 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+# 8 body, 4 sites, 7 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@legacy 0ea472f3f3bed56f398920b0ad9bd70480825e60d012449527c8fc413a0d8ea2 internal/console/claim_app_identity.go Store.PurgeClaimAppRow legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-plans-4d-lapse;basis=also deletes the purged app's plan_lapse_items rows in the same purge transaction, while the app identity still exists (plans 4d, Astra finding 6); console SQL on its own table; read sites unchanged file:QueryRowContext@218,file:QueryRowContext@790 7c070333d334d8d6e9837d2eefb989194f9a1b08c9e24680a04c03d6b81a0fac
@legacy aa100e04fba1bf66e57437f21dc1baad4455a42b2ea85094802a95ba43f5ba35 internal/console/server.go NewServer legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console construction adds queue and notification state. The existing logs/data route literal moves; it is not a filesystem read.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets consoleNameCfg from Config.ConsoleName and the challengeSem send bound, and registers the four /auth/email routes; no goroutine; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=census-ruling-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets the forwarded db read's open-read limits (dbReads, held by each read's request) and its timing (dbf); no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=census-ruling-design-edge-rate-limit-358;basis=one route registered beside the gate's form: POST /a/{sqid}/apps/{app}/ratelimit to handleAppRateLimit, the Settings page's rate-limit form, member-gated like the gate; no read added, its one data-literal site unchanged (offset moved);rev3=census-ruling-plans-4d-lapse;basis=registers GET and POST /a/{sqid}/plan/keep (the owner-only keep page, plans 4d) beside the account settings routes; no goroutine; read sites unchanged, offsets moved data-literal@9825 3d69a7865f93dc4cff178530a8a79457991802eeb1220844a3d8ecc51851cf10
+@legacy 95ca51aa92327f3c4699e1ab6acb5a2af031d76b6c8f176280827d2c35e76f66 internal/console/store.go Store.PurgeAppRow legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-plans-4d-lapse;basis=also deletes the purged app's plan_lapse_items rows in the same transaction as the row (plans 4d, Astra finding 6); console SQL on its own table; read sites unchanged file:QueryRowContext@549 fd6d5dd89c0a92f8e17ad50ac4f3d58355df86035777da0cb9832f2a23704965
@legacy 67df4d36ed485738c557f191079a61331a8a072b245a7fe35e779b59c72eacc0 internal/console/store.go Store.migrate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=adds the sessions.method column (default keymail, the backfill) and calls migrateEmailSignin; SQLite DDL on CONSOLE_DB; the existing site moves;rev3=census-ruling-plans-4-notices-grace;basis=calls migratePlanGrace last, which creates the console's own plan_cap_state table (plans 4a). No read added here; the new store units are the plans-4a-store decision.;rev3=census-ruling-plans-4c-box-throttle;basis=adds the additive account_plans.throttle column (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=adds the additive account_plans.lapse_since and account_plans.disabled columns and calls migratePlanLapse last, which creates the console's own plan_lapse_items table (plans 4d). No read added; the new store units are the plans-4d-units decision. file:Exec@12017,file:Exec@18552 74d230d6c73c6eb4284bd6b67bb0c0972b0dabb5240f2db119f2c388ae949636
@legacy c555b6f453d617e9a4d761dd3f2a684898f196393885a04239fa32b4d5d10072 internal/console/templates/layout.html external legacy accepted-legacy accepted-legacy;rev3=PROPOSED-console-switcher-filter;basis=Account switcher adds a client-side filter box and a scrolling list; whole embedded template remains frozen as legacy UI input.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=CSS only: email inputs styled as text inputs and sign-in form labels; whole embedded template remains frozen as legacy UI input;rev3=PROPOSED-console-brand-name;identity=the console (cmd/console serve under console.service, user carlos-console);basis=the tab title and header brand name the deployment ({{.Brand}}, CARLOS_CONSOLE_NAME); no new input.;rev3=census-ruling-plans-4-notices-grace;basis=the account layout renders .PlanNotices as banner lines above main content (plans 4a). No read added.;rev3=census-ruling-plans-4d-lapse;basis=the account layout renders a link to the keep page after the plan banner when PlanKeepURL is set (owners of a lapsed account, plans 4d). No read added. file:external@0 60bc5564ae574c6a11b1fa82ec526d0dc287254cd43d70367ec20ffcd9ab5d3a
@legacy a56d080d74106055668ef3650c392322f52aa5a6941b0927605b0b20c3ca7c78 internal/host/plans_pass.go plansPass legacy accepted-legacy accepted-legacy;rev3=PROPOSED-plans-2-box-limits;basis=root-route; the agent's plans pass, serialised by its own mutex, reads its own routes' accounts and two bucket objects (the plans marker, each account's limits record) into a cache; planIdleFor only narrows the activator's idle window. No root decision.;rev3=census-ruling-plans-4c-box-throttle;basis=keeps each account's published throttle from its limits record in the cache beside its limits, and tells planAwakeThrottled when an account first becomes awake-throttled (plans 4c). The same bucket objects; no read added.;rev3=census-ruling-plans-4d-lapse;basis=keeps each account's published turned-off host list (Record.Disabled, lower-cased) in the cache beside its limits and throttle, and carries the last good copy on a read error (plans 4d). The same bucket objects; no read added. registry:Kind@859,whole:Route@845,whole:Route@928 c0ce6a03c6106d8724e1842ec828935369a6b652eedab9041bce82889e04e0a6
@legacy 112095a5dd29b44ac27078916b09213a0c767c594e226de6da126264feb72fa7 internal/activator/activator.go Service.ServeScheduled legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-plans-4d-lapse;basis=answers a scheduled request to a route the turned-off hook names with the maintenance response before serve (plans 4d). One more whole-row read: the row handed to the hook (a.disabled), as the fence and maxRunFor are asked. registry:Hibernate@148,registry:Kind@123,registry:Status@164,registry:Status@183,whole:Route@266,whole:Route@376 177816f752242093286a78636a3c80926a54d70702a804560032eb3384e7196a
-@legacy 75fe0f81e1ec0c01f7004515ee50bb186fcdff74f511c476f95716788c1c3e5e internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a probe), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Three more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips. registry:Hibernate@13304,registry:Hibernate@22475,registry:Hibernate@5124,registry:Hibernate@7127,registry:Hibernate@9652,registry:Host@22544,registry:Host@22602,registry:Host@23069,registry:Host@23162,registry:Host@23897,registry:Host@23979,registry:Host@25044,registry:Host@25331,registry:Host@25380,registry:NextDue@23852,registry:Status@22491,whole:Route@10407,whole:Route@13306,whole:Route@15239,whole:Route@16949,whole:Route@17139,whole:Route@17432,whole:Route@17604,whole:Route@17751,whole:Route@21962,whole:Route@22651,whole:Route@23566,whole:Route@23906,whole:Route@23913,whole:Route@24859,whole:Route@25160,whole:Route@25364,whole:Route@5126,whole:Route@6960,whole:Route@7129,whole:Route@7563,whole:Route@9654 c70fbc09d51bf94c12302b08ae952108d9207c260bf44a03b47fc5b4194d9918
-@legacy c6dfb67ca0ad20696fc836af7412d6db93e0b0e566e6bf3395e199136ba2c205 internal/activator/activator.go Service.wake legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-wake-latency-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=logs that timer's breakdown to the journal after a successful wake (w.steps.String(), e.host, w.wakeTook); no read added;rev3=census-ruling-plans-4d-lapse;basis=cancels a wake whose row the turned-off hook names, like a fence, unless it is a move's probe (plans 4d). One more whole-row read: the row handed to the hook (a.disabled). Only refuses. registry:Socket@7139,registry:Socket@7300,whole:Route@2275,whole:Route@2332,whole:Route@5676,whole:Route@7092,whole:Route@7141,whole:Route@7302,whole:Route@8625,whole:Route@8646,whole:Route@922 ad2ca3730ed8b89616a5e87c99df4f61ac6267845ef9264163a61db7f9269a6b
+@legacy f79cc4e379403c6b0bc59328a1f560e407aaabe41b46016fcc28b523c11ab8bc internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a move's active probe), stands down an exited worker it names instead of restarting it (Astra finding 4), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Four more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips. registry:Hibernate@10051,registry:Hibernate@13703,registry:Hibernate@22874,registry:Hibernate@5522,registry:Hibernate@7526,registry:Host@22943,registry:Host@23001,registry:Host@23468,registry:Host@23561,registry:Host@24296,registry:Host@24378,registry:Host@25443,registry:Host@25730,registry:Host@25779,registry:NextDue@24251,registry:Status@22890,whole:Route@10053,whole:Route@10806,whole:Route@13705,whole:Route@15638,whole:Route@17348,whole:Route@17538,whole:Route@17831,whole:Route@18003,whole:Route@18150,whole:Route@22361,whole:Route@23050,whole:Route@23965,whole:Route@24305,whole:Route@24312,whole:Route@25258,whole:Route@25559,whole:Route@25763,whole:Route@5333,whole:Route@5524,whole:Route@7359,whole:Route@7528,whole:Route@7962 7b71284a6b99292f7297bd8b99a9d58b6f80518d4d7696c5b0523a16f70d59a9
+@legacy 72d6072aa3b483a5137fff85ed2f9948e56a3cc8abf2e108a79ce68ebb730d1d internal/activator/activator.go Service.wake legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-wake-latency-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=logs that timer's breakdown to the journal after a successful wake (w.steps.String(), e.host, w.wakeTook); no read added;rev3=census-ruling-plans-4d-lapse;basis=cancels a wake whose row the turned-off hook names, like a fence, unless it is a move's active probe (plans 4d). One more whole-row read: the row handed to the hook (a.disabled). Only refuses. registry:Socket@7140,registry:Socket@7301,whole:Route@2276,whole:Route@2333,whole:Route@5677,whole:Route@7093,whole:Route@7142,whole:Route@7303,whole:Route@8626,whole:Route@8647,whole:Route@923 0fd0d03cd88f3274feef78c2a0fef743790d8114fcbed831567672c55387bfc5
@legacy 0e4fbc0806f1dc0938faa98d8d306012b82550c081c8b1b943a110353d02c9a6 internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here. registry:Gate@13796,registry:Gate@13856,registry:Gate@13914,registry:Host@13899,registry:ImportGate@18109,registry:Kind@11979,registry:Kind@18080,whole:Route@10017,whole:Route@10209,whole:Route@11982,whole:Route@12540,whole:Route@12635,whole:Route@12711,whole:Route@12755,whole:Route@13799,whole:Route@13859,whole:Route@13902,whole:Route@13917,whole:Route@15550,whole:Route@18083,whole:Route@18112,whole:Route@19944,whole:Route@9805 fc3d83a038fe0662840aa5cab4ed073ce568c42750a03e6561b9168de48281a9
internal/activator/activator.go type Service authority B,C,D,F,J4 rev3=PROPOSED-seed; existing activator lifecycle and due-wake state plus owned seed exclusion and incarnation-keyed diagnostics; normal refusal and preparation ordering remain authoritative; PROPOSED-plans-2-box-limits adds the idleFor hook field, which only narrows idle windows;rev3=census-ruling-plans-4c-box-throttle;basis=gains the maxRunFor hook field beside idleFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added. bde5e77cb4d5e25cec5474395e1caec6f37a0eb311b67681a91f7bf0b7fe463d
+internal/console/claim_app_identity.go Store.PurgeClaimAppRow legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-plans-4d-lapse;basis=also deletes the purged app's plan_lapse_items rows in the same purge transaction, while the app identity still exists (plans 4d, Astra finding 6); console SQL on its own table; read sites unchanged file:QueryRowContext@218,file:QueryRowContext@790 7c070333d334d8d6e9837d2eefb989194f9a1b08c9e24680a04c03d6b81a0fac
internal/console/server.go NewServer legacy accepted-legacy accepted-legacy;rev3=PROPOSED-scan-demand-revival;basis=Console construction adds queue and notification state. The existing logs/data route literal moves; it is not a filesystem read.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets consoleNameCfg from Config.ConsoleName and the challengeSem send bound, and registers the four /auth/email routes; no goroutine; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=census-ruling-db-region-forward-2;identity=the console (cmd/console serve under console.service, user carlos-console);basis=sets the forwarded db read's open-read limits (dbReads, held by each read's request) and its timing (dbf); no goroutine and no store call; the one data-literal is still the logs/data route pattern, moved; the record-write census re-digests the same unit;rev3=census-ruling-design-edge-rate-limit-358;basis=one route registered beside the gate's form: POST /a/{sqid}/apps/{app}/ratelimit to handleAppRateLimit, the Settings page's rate-limit form, member-gated like the gate; no read added, its one data-literal site unchanged (offset moved);rev3=census-ruling-plans-4d-lapse;basis=registers GET and POST /a/{sqid}/plan/keep (the owner-only keep page, plans 4d) beside the account settings routes; no goroutine; read sites unchanged, offsets moved data-literal@9825 3d69a7865f93dc4cff178530a8a79457991802eeb1220844a3d8ecc51851cf10
+internal/console/store.go Store.PurgeAppRow legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=census-ruling-plans-4d-lapse;basis=also deletes the purged app's plan_lapse_items rows in the same transaction as the row (plans 4d, Astra finding 6); console SQL on its own table; read sites unchanged file:QueryRowContext@549 fd6d5dd89c0a92f8e17ad50ac4f3d58355df86035777da0cb9832f2a23704965
internal/console/store.go Store.migrate legacy accepted-legacy accepted-legacy;rev3=J4;basis=root-input;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=adds the sessions.method column (default keymail, the backfill) and calls migrateEmailSignin; SQLite DDL on CONSOLE_DB; the existing site moves;rev3=census-ruling-plans-4-notices-grace;basis=calls migratePlanGrace last, which creates the console's own plan_cap_state table (plans 4a). No read added here; the new store units are the plans-4a-store decision.;rev3=census-ruling-plans-4c-box-throttle;basis=adds the additive account_plans.throttle column (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=adds the additive account_plans.lapse_since and account_plans.disabled columns and calls migratePlanLapse last, which creates the console's own plan_lapse_items table (plans 4d). No read added; the new store units are the plans-4d-units decision. file:Exec@12017,file:Exec@18552 74d230d6c73c6eb4284bd6b67bb0c0972b0dabb5240f2db119f2c388ae949636
internal/console/templates/layout.html external legacy accepted-legacy accepted-legacy;rev3=PROPOSED-console-switcher-filter;basis=Account switcher adds a client-side filter box and a scrolling list; whole embedded template remains frozen as legacy UI input.;rev3=PROPOSED-email-signin;identity=the console (cmd/console serve under console.service, user carlos-console);basis=CSS only: email inputs styled as text inputs and sign-in form labels; whole embedded template remains frozen as legacy UI input;rev3=PROPOSED-console-brand-name;identity=the console (cmd/console serve under console.service, user carlos-console);basis=the tab title and header brand name the deployment ({{.Brand}}, CARLOS_CONSOLE_NAME); no new input.;rev3=census-ruling-plans-4-notices-grace;basis=the account layout renders .PlanNotices as banner lines above main content (plans 4a). No read added.;rev3=census-ruling-plans-4d-lapse;basis=the account layout renders a link to the keep page after the plan banner when PlanKeepURL is set (owners of a lapsed account, plans 4d). No read added. file:external@0 60bc5564ae574c6a11b1fa82ec526d0dc287254cd43d70367ec20ffcd9ab5d3a
internal/host/agent.go runAgent authority B,C,D,F rev3=census-ruling-seeded-instances;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with wireSeedPlacement called in the activator start's Configure step, before armMovesPass, and the startup sweep's result stored for the import rollback in Recover; read sites unchanged, offsets moved; main's B,C,D,F authority retained PROPOSED E46: captured claim selection and root journal mutation; root RPC outside service host exclusion; SQL/route data never grants root authority. Executing identity: service controller; root for inventory/retirement callbacks.;rev3=PROPOSED-325;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=passes the agent's log sink to armRunsPass; reads unchanged;rev3=census-ruling-db-region-forward-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=arms the db-reads loop (armDBReads) beside armRunsPass in the activator start's Configure step; reads unchanged, offsets moved; main's authority retained;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=arms the change index (armChangeIndex) and starts the record view's backstop loop before the loops that read through it, and hands the edge the watch loader (edge.WithChangeWatch); read sites unchanged at the same offsets;rev3=census-ruling-edge-request-records;basis=builds the edge request recorder against the existing log sink and data dir (newRequestRecorder, passed os.Getenv and time.Now) and starts reqrecLoop on a minute ticker; no read added;rev3=census-ruling-design-edge-rate-limit-358;basis=arms the edge's plan rate-ceiling hook, e.SetRateCeilingFor(planRateCeilingFor), right after EnableUsage; read sites unchanged (5), offsets moved; no read added;rev3=census-ruling-edge-asset-cache-1;basis=starts edgesFileLoop with the activator's serving build (servingBuildOf(svc): ServingGen's build on a box with generations, nothing otherwise); read sites unchanged (5), none added;rev3=census-ruling-plans-4c-box-throttle;basis=arms svc.SetMaxRunFor(planMaxRunFor) beside SetIdleFor, and e.SetPlanThrottleFor(planThrottleFor), e.SetPlanGovernedFor(planGoverned) and the planAwakeThrottled close hook beside SetRateCeilingFor (plans 4c). No read added.;rev3=census-ruling-plans-4d-lapse;basis=arms two more plans hooks from the same snapshot: e.SetPlanDisabledFor(planDisabledFor) beside SetPlanGovernedFor, and svc.SetDisabledFor(planDisabledRoute) beside SetMaxRunFor (plans 4d); the reads live in those units (plans-4d-units decision); read sites unchanged, offsets moved file:Exec@13802,file:Open@731,registry:App@10065,whole:Route@10057,whole:Route@23700 254a3e866e97299cecc9de4633520a6c6c89dcd0835c9057a11d3512de6f073e
internal/host/plans_pass.go plansPass legacy accepted-legacy accepted-legacy;rev3=PROPOSED-plans-2-box-limits;basis=root-route; the agent's plans pass, serialised by its own mutex, reads its own routes' accounts and two bucket objects (the plans marker, each account's limits record) into a cache; planIdleFor only narrows the activator's idle window. No root decision.;rev3=census-ruling-plans-4c-box-throttle;basis=keeps each account's published throttle from its limits record in the cache beside its limits, and tells planAwakeThrottled when an account first becomes awake-throttled (plans 4c). The same bucket objects; no read added.;rev3=census-ruling-plans-4d-lapse;basis=keeps each account's published turned-off host list (Record.Disabled, lower-cased) in the cache beside its limits and throttle, and carries the last good copy on a read error (plans 4d). The same bucket objects; no read added. registry:Kind@859,whole:Route@845,whole:Route@928 c0ce6a03c6106d8724e1842ec828935369a6b652eedab9041bce82889e04e0a6
internal/activator/activator.go Service.ServeScheduled legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-plans-4d-lapse;basis=answers a scheduled request to a route the turned-off hook names with the maintenance response before serve (plans 4d). One more whole-row read: the row handed to the hook (a.disabled), as the fence and maxRunFor are asked. registry:Hibernate@148,registry:Kind@123,registry:Status@164,registry:Status@183,whole:Route@266,whole:Route@376 177816f752242093286a78636a3c80926a54d70702a804560032eb3384e7196a
-internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a probe), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Three more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips. registry:Hibernate@13304,registry:Hibernate@22475,registry:Hibernate@5124,registry:Hibernate@7127,registry:Hibernate@9652,registry:Host@22544,registry:Host@22602,registry:Host@23069,registry:Host@23162,registry:Host@23897,registry:Host@23979,registry:Host@25044,registry:Host@25331,registry:Host@25380,registry:NextDue@23852,registry:Status@22491,whole:Route@10407,whole:Route@13306,whole:Route@15239,whole:Route@16949,whole:Route@17139,whole:Route@17432,whole:Route@17604,whole:Route@17751,whole:Route@21962,whole:Route@22651,whole:Route@23566,whole:Route@23906,whole:Route@23913,whole:Route@24859,whole:Route@25160,whole:Route@25364,whole:Route@5126,whole:Route@6960,whole:Route@7129,whole:Route@7563,whole:Route@9654 c70fbc09d51bf94c12302b08ae952108d9207c260bf44a03b47fc5b4194d9918
-internal/activator/activator.go Service.wake legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-wake-latency-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=logs that timer's breakdown to the journal after a successful wake (w.steps.String(), e.host, w.wakeTook); no read added;rev3=census-ruling-plans-4d-lapse;basis=cancels a wake whose row the turned-off hook names, like a fence, unless it is a move's probe (plans 4d). One more whole-row read: the row handed to the hook (a.disabled). Only refuses. registry:Socket@7139,registry:Socket@7300,whole:Route@2275,whole:Route@2332,whole:Route@5676,whole:Route@7092,whole:Route@7141,whole:Route@7302,whole:Route@8625,whole:Route@8646,whole:Route@922 ad2ca3730ed8b89616a5e87c99df4f61ac6267845ef9264163a61db7f9269a6b
+internal/activator/activator.go Service.sweepOnce legacy accepted-legacy accepted-legacy;rev3=PROPOSED-seed;basis=census-ruling-FS-R6; registry remains legacy; PROPOSED-plans-2-box-limits: the sweep also narrows an entry's idle window to its account's plan idle through the SetIdleFor hook (never lengthens it; always-on workers and held probe entries are untouched; the hibernate, inflight and held-for-tick guards are unchanged).;rev3=census-ruling-plans-4c-box-throttle;basis=after the worker max_run branch, stops a non-worker entry past the plans continuous-awake ceiling (maxRunFor, passed the row), busy or not, never mid-command (plans 4c). One more whole-row read: the row handed to the hook, as idleFor already is. This bypasses the inflight and held-for-tick protections the idle stop keeps, on purpose: escalated by Astra and ACCEPTED by Paul (census owner), 2026-10-25.;rev3=census-ruling-plans-4d-lapse;basis=stops a live entry the turned-off hook names (never mid-command, never a move's active probe), stands down an exited worker it names instead of restarting it (Astra finding 4), and skips such rows in the due loop and the always-on arm so they are not woken (plans 4d). Four more whole-row reads: the row handed to the hook (a.disabled), as idleFor and maxRunFor already are. Only stops or skips. registry:Hibernate@10051,registry:Hibernate@13703,registry:Hibernate@22874,registry:Hibernate@5522,registry:Hibernate@7526,registry:Host@22943,registry:Host@23001,registry:Host@23468,registry:Host@23561,registry:Host@24296,registry:Host@24378,registry:Host@25443,registry:Host@25730,registry:Host@25779,registry:NextDue@24251,registry:Status@22890,whole:Route@10053,whole:Route@10806,whole:Route@13705,whole:Route@15638,whole:Route@17348,whole:Route@17538,whole:Route@17831,whole:Route@18003,whole:Route@18150,whole:Route@22361,whole:Route@23050,whole:Route@23965,whole:Route@24305,whole:Route@24312,whole:Route@25258,whole:Route@25559,whole:Route@25763,whole:Route@5333,whole:Route@5524,whole:Route@7359,whole:Route@7528,whole:Route@7962 7b71284a6b99292f7297bd8b99a9d58b6f80518d4d7696c5b0523a16f70d59a9
+internal/activator/activator.go Service.wake legacy accepted-legacy accepted-legacy;rev3=census-ruling-carlos-run;basis=Re-digested at the pre-land merge: the body includes main's own change under census ruling 292, with no further change from this branch. the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body; the stop now carries its reason for a run it interrupts (beginStopLocked's why argument); read sites unchanged, offsets moved;rev3=census-ruling-wake-latency-1;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=logs that timer's breakdown to the journal after a successful wake (w.steps.String(), e.host, w.wakeTook); no read added;rev3=census-ruling-plans-4d-lapse;basis=cancels a wake whose row the turned-off hook names, like a fence, unless it is a move's active probe (plans 4d). One more whole-row read: the row handed to the hook (a.disabled). Only refuses. registry:Socket@7140,registry:Socket@7301,whole:Route@2276,whole:Route@2333,whole:Route@5677,whole:Route@7093,whole:Route@7142,whole:Route@7303,whole:Route@8626,whole:Route@8647,whole:Route@923 0fd0d03cd88f3274feef78c2a0fef743790d8114fcbed831567672c55387bfc5
internal/edge/edge.go Edge.ServeHTTP legacy accepted-legacy accepted-legacy;rev3=census-ruling-seeded-instances;basis=the edge inside the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): main's body with the import gate checked after the door's scope and a gated row left out of the response cache; serving only;rev3=census-ruling-edge-request-records;basis=one more call in the observer defer, observeRecords(up.route, ...), passing on the route the defer already holds; no new kind of read;rev3=census-ruling-design-edge-rate-limit-358;basis=calls rateAdmit twice, and an admitted request holds a slot on both paths: on the upgrade path before the activator or proxy (the handshake holds its slot through slotWriter, given back at the first final answer or at the reverse proxy's hijack on a 101, so an open WebSocket is not counted; released by a defer), and on the ordinary path after the response-cache check and before the activator and proxy (an admitted request holds a slot through slotWriter, released by a defer); a refusal is a 429 written there and returns; the upgrade path's comment now names slotWriter as its one wrapper; one comment on the door mark reworded; read sites unchanged (22: main's 21 plus edge-request-records' observeRecords pass of the route), offsets moved; no read added;rev3=census-ruling-plans-4c-box-throttle;basis=calls planThrottleAdmit before the response cache, and on an upgrade trackUpgrade then planUpgradeAdmit (plans 4c, Astra findings 1 and 2); the new reads live in those units (plans-4c-units decision). The same read sites here.;rev3=census-ruling-plans-4d-lapse;basis=calls planDisabledAdmit right after the import gate, passing the final upstream's route and the request host; a turned-off route gets the fixed disabled page before the meter, gate, cache and activator (plans 4d). The new read lives in that unit (plans-4d-units decision); one more whole-row pass here. registry:Gate@13796,registry:Gate@13856,registry:Gate@13914,registry:Host@13899,registry:ImportGate@18109,registry:Kind@11979,registry:Kind@18080,whole:Route@10017,whole:Route@10209,whole:Route@11982,whole:Route@12540,whole:Route@12635,whole:Route@12711,whole:Route@12755,whole:Route@13799,whole:Route@13859,whole:Route@13902,whole:Route@13917,whole:Route@15550,whole:Route@18083,whole:Route@18112,whole:Route@19944,whole:Route@9805 fc3d83a038fe0662840aa5cab4ed073ce568c42750a03e6561b9168de48281a9
-@coverage internal/activator a15879d1798dde41f5975581837543580917691b11e6c0935f6237e0fef54ff3
-@coverage internal/console a6373b227103f0fcec1551c9b8bd22b3956271fbd77655abe522023d5d10b1b7
+@coverage internal/activator 30c78fd130c50dc3c747e0673aeaf873748593067950e4fb3611c1301362ad77
+@coverage internal/console 32cc76daf21550a922d73435010208556bafb4b55e09e4fd3b599cc374738380
@coverage internal/console/templates d4a8b0c3d6912729aad5ef1b4f66107e9f9ce9fb9e2b8aeacea03f1867caca16
+@coverage internal/domains 237e85fae3c3159a7d7115314781fc976082f6630cacb85a9d03344ba3476f78
@coverage internal/edge 926b094159b7e7781cb1e4ee391bfbf848de0ef52215e7f4410a6485bf8786eb
@coverage internal/host f26e97b13ad911d76d99c91529c9ca43acb319b703ebb2fb634fdb8df12b0b2f
@coverage internal/plans f6351c4a24fb53dbc9bcf299d078ec8db4ca94ac1f9601962c0de20370117eb0