region HA: planned moves cut streams early; drain release snapshots
The held-requests move took 25-42 s on dev (v0.34.38 W1/W4), so holds hit the 25 s hop cap. Two causes: the move waited its full 10 s in-flight bound for long-lived streams that never end, and the successor restored every L0 file written since the last hourly compaction. F1: at the move start every long-lived stream on the host (SSE of any encoding, upgraded connections, edge-held) is cut by cancelling its request context; clients reconnect, as on a connection drain today. This moves the stream close earlier, from the take to the move's start. No body wrapper; the response hook keeps main's trailer scrubbing. F2: the drain's clean release writes a litestream snapshot at the final position before the marker, so the successor restores one file. Spec 25.4, 25.8, 25.10, 25.15. Astra: three rounds, R3 READY; census approved (#280). No release. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Squashed from held-move-speed into main.
21 files changed,
+1,313
−31
docs/superpowers/notes/census-proposal-held-move-speed.md+29 −0docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md+8 −6internal/activator/activator.go+11 −0internal/activator/hadrainmove.go+4 −0internal/activator/hadrainmove_test.go+99 −0internal/activator/handover.go+3 −0internal/activator/harelease.go+17 −3internal/activator/hawake.go+9 −2internal/activator/movestreams.go+116 −0internal/activator/movestreams_test.go+303 −0internal/edge/edge.go+6 −6internal/edge/movestreams.go+106 −0internal/edge/movestreams_test.go+152 −0internal/host/group_names_test.go+4 −1internal/host/hadrain.go+15 −4internal/host/hadrain_test.go+64 −3internal/lease/lease.go+5 −2internal/lease/release.go+79 −4internal/lease/release_snapshot_test.go+265 −0internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-held-move-speed.tsv+17 −0
CI passed — run details
diff --git a/docs/superpowers/notes/census-proposal-held-move-speed.md b/docs/superpowers/notes/census-proposal-held-move-speed.md| new file mode 100644 |
| index 000000000..2f487d37b |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-held-move-speed.md |
| @@ -0,0 +1,29 @@ |
| +# Census approval: held-move-speed |
| + |
| +Ruling `census-ruling-held-move-speed`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/activator/activator.go` `type Service` | body | unchanged (0) | the agent as carlos: one new field, moveStreams (per-host in-memory set of edge.StreamEnd for requests in flight, own mutex), for the move's early stream cut; actEntry gains drainRelease (bool, under a.mu), set by DrainStop; declarations only, no read added | |
| +| `internal/activator/handover.go` `Service.BeginMove` | body | unchanged (3) | also clears the host's in-memory moveStreams ending flag for the new move (moveStreams.reset); no read added | |
| +| `internal/edge/edge.go` `Edge.Reload` | body | unchanged (94) | the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added | |
| +| `internal/host/hadrain.go` `drainDriver.moveOne` | body | unchanged (2) | right after BeginMove and before the ticket and in-flight wait, calls Service.EndMoveStreams(host) (cancels the request contexts of the host's SSE responses and upgraded connections) and Edge.CloseHeldHost(host) (memory only); the later CloseHeldHost after SetMoveTaken is kept; no read added | |
| +| `internal/activator/activator.go` `Service.serve` | sites | +registry:Host | after begin succeeds, wraps r with an edge.StreamEnd (a cancellable child context) and tracks it under rt.Host in the in-memory moveStreams until the request ends (+registry:Host: the supplied route's Host as the map key); no new kind of read, no root decision | |
| +| `internal/activator/harelease.go` `Service.releaseHAClean` | sites | +registry:Host | reads the entry's drainRelease flag under a.mu; for the drain's release calls the replica's FinishSnapshot (final sync, then a litestream snapshot at the final position, before the store's close; the snapshot reader pipe is closed on every outcome) instead of Finish, and logs a snapshot failure naming rt.Host (+registry:Host, the supplied route); marker order, budgets and clean rule unchanged; no new read | |
| + |
| +Envelopes re-pinned: `internal/activator`, `internal/edge`, `internal/host`, `internal/lease`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/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.;rev3=census-ruling-plans-4d-lapse;basis=gains the disabledFor hook field beside maxRunFor (plans 4d). No read added.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): one field, Fleet (activator.FleetWake: the box's fleet state, not on a fleet by default, on a fleet with a known label and a record reader, or on a fleet with an invalid identity), set by the agent before Start and read only by routeCurrentUnderLease. No read in the declaration. Agent, not root.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing; merge of origin/main 6f1f6ca6: main's one field, Fleet (activator.FleetWake), is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b3a;basis=Add bounded placement peer and diagnostic state and the over-capacity callback; no read in this declaration and no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Add coordinator, existing-record observation callback and per-host preparation locks; no read in the declaration. Task 3a: Add optional canonical storage-selection and durable deploy-ID callbacks; declaration only, no read or authority in these fields.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): adds the heldLegs map to actEntry (legs by id, under a.mu) and heldWakeHook (atomic pointer to a callback) and heldLegSeq (atomic counter) to Service. State only, in memory; no read of tenant, app or box-agent-writable input.;rev3=census-ruling-wake-storm-cap;basis=the agent as carlos: one field, wakeSlots (chan struct{}, the wake semaphore made by New from Config.WakeSlots, default 4); declaration only, no read.;rev3=census-ruling-region-ha-p1b3b-t;basis=Add the B2 DutyStore interface field and process-local duty view, suppression and invalidation state. No read added. B2 adds the verified-successor identity callback; no read in the declaration. B3b adds a nonblocking departure-suspicion callback, invoked only after an accepted holder-forward failure and after cache locks release; it cannot authorize a take.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: immutable callbacks installed before Start for tenant admission, local start permission, fixed route exemptions and shutdown closure; nil callbacks preserve switch-off behavior; no new reads. Fix R1: add an immutable startup-phase callback for response copy, set before service startup. No new read or execution authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Add in-memory HA loss state and pool withdrawal jobs; no new read.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 1: one new field, drain (drainSources: two atomic func pointers for this box's and peers' drain state); no read added. region HA held-requests Task 2: one new field, moves (moveTable: per-host move state, hold counts and admission tickets in memory, under mu); no read added |
| +- `internal/activator/handover.go` `Service.BeginMove`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: Task 5 driver API; sets in-memory holding for an awake HA entry; refuses on a latched loss; no read. Fix round 1: records the awake entry's route (in memory) as the move's lifetime identity; no read added |
| +- `internal/edge/edge.go` `Edge.Reload`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read |
| +- `internal/host/hadrain.go` `drainDriver.moveOne`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: one host's move (BeginMove, tickets and in-flight wait, DrainStop, take, SetMoveTaken or SetMoveLeft); reads the in-memory route Host; no read of its own; Task 5 fix 1: after SetMoveTaken, closes the host's edge-held streams on this edge at an event boundary (Edge.CloseHeldHost, memory only); no read added |
| +- `internal/activator/activator.go` `Service.serve`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-hotfix281;basis=Startup repeats the existing Kind and Hibernate checks; error logging moved to serveWakeError. A request held through startup re-reads its own route's Socket and Addr and can only refuse (wake-timeout 503) when recovery moved them; agent-side, deny-only, no root decision.;rev3=census-ruling-edge-request-records;basis=passes the member request r to begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance is the activator's; same deploy-safety for binary rows;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: a verified HA hop this box cannot serve gets the holder diagnostic; two new whole:Route sites pass the route to answerForwarded/noteNoHolder; no new kind of read;rev3=census-ruling-region-ha-g2-fixes;basis=Refuse latched HA lease loss before startup wait or proxy accounting, and schedule bounded recovery; reads supplied route, no new external read here.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 2: after begin succeeds, edge.ReleaseMoveTicket(r) ends the request's in-memory admission ticket; on the sidecar path the same after BeginSidecarRequest; no read added |
| +- `internal/activator/harelease.go` `Service.releaseHAClean`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: an HA entry's release, in order: host slice read empty through haHostEmpty (else errHostSliceUnproven and nothing written; the same check, moved into that helper by final fix F1), stop and join the files publisher, its final publish (2 min budget), the replica's final sync (Finish, 30 s), the local release record, then the release marker PUT (10 s), clean only when the final publish was complete and the sync and record succeeded; a failed PUT is a persisted lease obligation; +registry:Host, +whole:Route x4;rev3=census-ruling-region-ha-p1b3b-t;basis=Record advisory local-release basis only after ReleaseMarker succeeds. Add a whole-route argument to local duty bookkeeping; release order and lease authority unchanged.;rev3=census-ruling-region-ha-g2-fixes;basis=Latch unexpected lease loss before release and mark intentional release so ErrSpent alone is not treated as loss; no new read.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Cap Final, Finish and marker contexts by the shutdown deadline and reserves; keep calls synchronous and stop proof unchanged; record successful marker completion under the service mutex. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: records the written marker's clean flag on the entry (haReleaseClean) beside haReleased, for the drain report; no read added |
| + |
| +Seal: `a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee` → `837f27a6b7b6ed272f8c68aca07650fa32cf3ec92ce28bf9d812a4282eeb0b58`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-held-move-speed.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md| index b0cf8d1b0..6e5f7f5ff 100644 |
| --- a/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md |
| +++ b/docs/superpowers/specs/2026-10-26-region-ha-without-claims-design.md |
| @@ -1102,10 +1102,10 @@ The roll tool runs a new root verb, `carlos system group-maintenance drain`, ove |
| 2. **Quiesce (H5).** A closes its local start gate for tenant leases. It then settles everything that crossed the gate before it closed: wakes that are restoring, acquires waiting on their conditional PUT, and lost-lease recovery workers. Each either ends awake, and is then moved in step 3, or fails. Pending stops and marker obligations are kept and settled (§5.2). Nothing is cancelled in a way that would drop a writer proof. |
| 3. **Move each awake host H,** up to 4 at a time, busiest first: |
| 1. *Hold.* From now `MoveState(H)` is `holding` (§25.5). |
| - 2. *Finish in-flight work.* Requests already admitted to H's app get up to 10 s, today's HTTP drain bound. Then the stop proceeds as a shutdown stop does, which ends long requests, WebSockets and edge-held stream legs (#432 G5). |
| - 3. *Release.* `finishStop` writes the marker (§5.2), with the drain as its stop reason and the existing budgets. |
| + 2. *Finish in-flight work.* First, at the move's start, A cuts H's long-lived responses on A, because none of them ends on its own: SSE responses (`text/event-stream`, any encoding) and upgraded connections (WebSockets) have their request cancelled and their connection closed, as at today's connection drain, and edge-held SSE streams are closed. A stream that opens later in the move, on a request admitted before it, is cut as soon as its response head shows it is a stream. Their clients reconnect and are held like any other request (§25.8). Every other request already admitted to H's app gets up to 10 s, today's HTTP drain bound. Then the stop proceeds as a shutdown stop does, which ends long requests and edge-held stream legs (#432 G5). (Build change, 2026-11-10: the streams used to be closed at step 5, so one open stream held every move for the whole 10 s.) |
| + 3. *Release.* `finishStop` writes the marker (§5.2), with the drain as its stop reason and the existing budgets. The drain's release, and only the drain's, writes a litestream snapshot (level 9) at the final position after the final sync succeeds and before the store closes, so the snapshot's TXID is the marker's and the successor restores one file instead of every L0 file since the last compaction. If the snapshot fails, A logs it and the release goes on as before: the marker is as clean as it would have been, and the restore replays the L0 files. An idle sleep writes no snapshot. (Build change, 2026-11-10.) |
| 4. *Take.* A chooses a successor B: `ChooseRoomiest` over its eligible serving set (§6.3). **Always-on workers are not taken** (build ruling, 2026-11-09): the duty rule (§7.1, A11) gives a released worker's duties to its releaser, and a take that moved them would need new authority in the duty layer, the I3 family. A drain releases each worker with a marker, which leaves no lease naming A (H5), and the worker resumes on its HRW box (A10) through the departure scan's import (§7.4) after the provider action. The report lists such workers as released. A sends B a signed take request (§25.7). B acquires and wakes H, then answers with the owner it now sees in `lock.json`. That owner is the **confirmed holder**: B, or a third box that won the marker first (§6.7). |
| - 5. *Release the holds* (§25.5). Edge-held SSE streams for H whose outer connection is on A are closed now, per host, at an event boundary, so they reconnect to the new holder without waiting for the rest of the drain (R3.5). `MoveState(H)` becomes `taken(holder, lock generation)` and stays so until `drained` is acknowledged (§25.15 R3.4). |
| + 5. *Release the holds* (§25.5). H's edge-held SSE streams on A were closed at step 2. Any opened on A during the move are closed now, per host, at an event boundary, so they reconnect to the new holder without waiting for the rest of the drain (R3.5). `MoveState(H)` becomes `taken(holder, lock generation)` and stays so until `drained` is acknowledged (§25.15 R3.4). |
| 4. **Drain the connections.** When no lease names A, it publishes `drained` and asks for the same acknowledgement as in step 1. Peers drop holder-cache entries naming A (§6.6). A then closes a barrier: a request that arrives after it gets today's 503 with `Retry-After: 10` through the bounded exit and is never forwarded. A sends `Connection: close` on every response, closes idle keep-alive connections, and closes every edge-held SSE stream still open through it at an event boundary; the browser reconnects through the NLB to another box, with `Last-Event-ID`. A then waits up to 60 s for the requests it is still forwarding to finish. WebSockets and responses still running at 60 s are cancelled and their connections closed, and the report counts them. The drain fails if they have not all ended 10 s after that. |
| 5. **Report.** The report lists hosts moved, each one's confirmed holder, the longest hold, holds that got today's answer, unclean releases, connections closed at the bound, and the agent's incarnation. The agent keeps it until it exits, for the tool's pre-action check (H5). |
| @@ -1181,7 +1181,7 @@ Both control paths, `/.carlos/ha-take` and `/.carlos/ha-drain`, are reserved on |
| ### 25.8 What clients see |
| -- **Zero errors** for every request whose first attempt reaches A. That covers requests through the NLB before Standby, from a peer whose cache names A (the normal in-region case), or through a fixed forwarder in the region. The body must be empty, or have a known length of at most 64 KiB and be copied whole before the first send (H2). An unknown-length body, however small, is not replayable. A request that reached A directly streams its body and has no size limit. The condition is the attempt number on arrival at A and the body's framing (R3.6). Paul's Q2 ruling (2026-11-08) scopes the body rule to in-region traffic: a box has trusted HA metadata only for its own region's hosts, so a cross-region (backhaul) first box replays only bodyless requests, and its requests with bodies stream and are never replayed. The pause is the rest of H's in-flight work (up to 10 s, usually milliseconds), plus the release (about 1 to 3 s), plus the successor's acquire and restore. The target is under 5 s for a small host. |
| +- **Zero errors** for every request whose first attempt reaches A. That covers requests through the NLB before Standby, from a peer whose cache names A (the normal in-region case), or through a fixed forwarder in the region. The body must be empty, or have a known length of at most 64 KiB and be copied whole before the first send (H2). An unknown-length body, however small, is not replayable. A request that reached A directly streams its body and has no size limit. The condition is the attempt number on arrival at A and the body's framing (R3.6). Paul's Q2 ruling (2026-11-08) scopes the body rule to in-region traffic: a box has trusted HA metadata only for its own region's hosts, so a cross-region (backhaul) first box replays only bodyless requests, and its requests with bodies stream and are never replayed. The pause is the rest of H's in-flight work (up to 10 s for an ordinary request, usually milliseconds; streams are ended at once), plus the release (about 1 to 3 s, with the snapshot), plus the successor's acquire and restore of one snapshot file. The target is under 5 s for a small host. |
| - **Today's 503 with `Retry-After: 10`,** only in the seconds that host is moving, for: |
| - a hop whose body is over 64 KiB or of unknown length; |
| - a request whose first attempt went to another box that named A, on any ingress path; most cross-region requests are like this (H3); |
| @@ -1189,7 +1189,7 @@ Both control paths, `/.carlos/ha-take` and `/.carlos/ha-drain`, are reserved on |
| - a call through the edge-local door (#175 P7), a tunnel delivery, or a request on a regional name for the moving host. None of these can be forwarded to another box, so A refuses them at once through the bounded exit (§25.15 R3.3) rather than holding them (build ruling, 2026-11-08); |
| - a request that arrives at A after its connection drain has begun (§25.4 step 4); |
| - any bound hit or failed move. |
| -- **Connections:** keep-alive connections are closed between requests. Any backhaul that carries a body closes the client's connection when the upstream answers before the client has finished sending, so the edge never drains an unbounded upload after an early answer; the client reconnects once and sees no error (build ruling, 2026-11-08). SSE streams reconnect with `Last-Event-ID` after the browser's retry delay. WebSockets still open through A 60 s after its leases have moved are closed, and their clients reconnect. Requests already dispatched to an app (uploads, downloads, upgrades) that run past H's 10 s drain, or past the final 60 s, are cut and never retried, because they may have reached the app (R3.5). |
| +- **Connections:** keep-alive connections are closed between requests. Any backhaul that carries a body closes the client's connection when the upstream answers before the client has finished sending, so the edge never drains an unbounded upload after an early answer; the client reconnects once and sees no error (build ruling, 2026-11-08). Streams for H (SSE and upgraded connections) are cut at the move's start and their clients reconnect, which is today's connection-drain behaviour. The reconnect is held like any other request and forwarded once H is taken. WebSockets of hosts that were not moved and are still open through A 60 s after its leases have moved are closed, and their clients reconnect. Requests already dispatched to an app (uploads, downloads, upgrades) that run past H's 10 s drain, or past the final 60 s, are cut and never retried, because they may have reached the app (R3.5). |
| - **Always-on workers** pause from their release until the departure finishes, a few minutes. They serve no HTTP requests. |
| - **An unplanned death:** today's behaviour, unchanged. |
| @@ -1211,7 +1211,7 @@ A drain is only safe when every box that may send A a request understands the ne |
| - two edges mutations (the drain state, then `drained`), each with its change-index update and §18's reader amplification; a roll adds a third when fence-clear makes the restarted member placeable again; |
| - two acknowledgement rounds, each costing one fold read per live box (one LIST plus one GET per edges file, as at any fold). A failed fold read is retried at the 5 s cadence, so the worst case is 24 fold reads per box per round. The change-index fold that the publication triggers anyway is separate; |
| - the tool's lock check (the sweep): one delimited LIST of the lock prefix (one page per 1,000 hosts), then for each host under it, HA or not, one exact-key LIST and one GET when its `lock.json` exists. A replace or remove sweeps twice, before the action check and again after the edge stops; a resumed or retried stop sweeps again. Per transaction only, never on a timer. |
| -- **Per host moved:** the marker PUT, as at any sleep, plus the successor's acquire (1 GET + 1 PUT) and restore, which the host's next wake would have cost anyway. |
| +- **Per host moved:** the marker PUT, as at any sleep, plus one PUT for the drain's snapshot of the database (§25.4 step 3.3), plus the successor's acquire (1 GET + 1 PUT) and restore, which the host's next wake would have cost anyway. The snapshot makes that restore one GET instead of one per L0 file. Snapshots are kept for the replica's retention (a week), so each planned handover also stores one more copy of the database for that time. No steady-state requests. |
| - **Example:** replacing all 4 members of a region with 200 awake hosts, some moved twice, costs about 300 markers and acquires, 8 edges mutations, 8 acknowledgement rounds over 6 boxes, and 8 lock sweeps (two per replacement) of 500 hosts, each about one LIST and one GET per host. That is about $0.03 in S3 requests, plus retries and the restore GETs. |
| **Simulation (§21.1).** It adds: |
| @@ -1330,6 +1330,8 @@ Paul approved all four §25.14 recommendations and Q1 to Q3 as recommended: drai |
| **The redirect lasts the whole drain (R3.4).** `taken(holder, gen)` is kept per host lifetime until `drained` is acknowledged, not for 30 s. Before A answers a hop from it, A checks the lock with one coalesced read, at most one per host per 5 s. The answer names the current owner, or, when the lock is a release marker, A's placement choice, which a hop receiver may acquire from the marker (§6.4). Anything else gets the bounded refusal. Budget: at most one lock GET per moved host per 5 s on the draining box, only while stale hops arrive. |
| +**Move speed (build change, 2026-11-10).** W4 on dev measured moves of 25 to 42 s: about 10 s waiting for the probe's SSE stream, which never ends, to reach the in-flight bound, and 27 to 29 s of restore replaying over 1,000 L0 files. Two changes, approved by the agent manager: streams are cut at the move's start rather than at the take (§25.4 step 2, §25.8), as the connection drain cuts them today (a graceful end at an event boundary was tried and dropped after Astra round 2: it could run the trailer scrubs before the transport had read the trailers); and the drain's release writes a snapshot at the final position (§25.4 step 3.3, +1 PUT per moved host in §25.10). Holds' bounds, I1 and H1 to H5 are unchanged. A snapshot at every clean sleep, which would make every cross-box wake fast too, is a separate proposal for Paul. |
| + |
| **What the build left owed (2026-11-09).** These are outside the branch and need their own steps: |
| - **The operator policy.** The module code carries the new resource-scoped grants (terminate in this group only, launch-template version reads, and S3 list and get on `control/edges/` and the region's lock keys). Applying them with tofu is a step on a card Paul approves. |
| - **One attended live call on dev** (§25.6) with the operator's real transport, before any window: in particular, a terminate of a Standby member without decrement must leave desired unchanged. |
diff --git a/internal/activator/activator.go b/internal/activator/activator.go| index 69ccad74a..1e95f89d3 100644 |
| --- a/internal/activator/activator.go |
| +++ b/internal/activator/activator.go |
| @@ -600,6 +600,10 @@ type actEntry struct { |
| // haReleaseClean is the clean flag of the marker haReleased says was |
| // written (§5.2), for the drain report (§25.4). Under a.mu. |
| haReleaseClean bool |
| + // drainRelease is set when the drain's own stop began this entry's |
| + // stop (DrainStop): its HA release writes a snapshot at the final |
| + // position before the marker (releaseHAClean). Under a.mu. |
| + drainRelease bool |
| // Activity tracking: an instance is idle only when nothing is in flight |
| // AND the idle window has passed since the last request finished. In-flight |
| @@ -1384,6 +1388,9 @@ type Service struct { |
| // moves is the planned handover's per-host state and admission |
| // tickets (handover.go), under mu. |
| moves moveTable |
| + // moveStreams are the requests in flight per host that a move may end |
| + // early, if they are streams (movestreams.go). |
| + moveStreams moveStreams |
| // drainLog is the drain transaction's release log (hadrainmove.go). |
| drainLog drainReleases |
| @@ -6552,6 +6559,10 @@ func (a *Service) serve(w http.ResponseWriter, r *http.Request, rt registry.Rout |
| return a.serveWakeError(w, r, rt, err) |
| } |
| defer release() |
| + // A move of the host ends it early if its response is a stream |
| + // (movestreams.go). |
| + r, untrack := a.moveStreams.track(rt.Host, r) |
| + defer untrack() |
| // Counted in flight now: the request's admission ticket ends |
| // (handover.go). |
| edge.ReleaseMoveTicket(r) |
diff --git a/internal/activator/hadrainmove.go b/internal/activator/hadrainmove.go| index 795916c6e..35f679080 100644 |
| --- a/internal/activator/hadrainmove.go |
| +++ b/internal/activator/hadrainmove.go |
| @@ -191,6 +191,10 @@ func (a *Service) DrainStop(ctx context.Context, host string) (DrainRelease, err |
| } |
| _, ha := haEntryRep(e) |
| if e.state == actAwake { |
| + // The drain's release leaves a one-file restore for the successor |
| + // (releaseHAClean). A stop already under way (an idle sleep) is |
| + // not the drain's and releases as it would have. |
| + e.drainRelease = true |
| a.beginStopLocked(e, StopDrain) |
| } |
| stopped := e.stopped |
diff --git a/internal/activator/hadrainmove_test.go b/internal/activator/hadrainmove_test.go| index 7aebab924..b44d60030 100644 |
| --- a/internal/activator/hadrainmove_test.go |
| +++ b/internal/activator/hadrainmove_test.go |
| @@ -225,3 +225,102 @@ func TestDrainReleaseLogKeepsAPausedStopsUncleanOutcome(t *testing.T) { |
| t.Fatalf("log after End: %+v", got) |
| } |
| } |
| + |
| +// snapshotSpyRep records which final sync the release asked for: Finish |
| +// (any release) or FinishSnapshot (the drain's, F2). |
| +type snapshotSpyRep struct { |
| + Rep |
| + haRep |
| + real *lease.Replicator |
| + snapErr error |
| + calls chan string |
| +} |
| + |
| +func (r *snapshotSpyRep) Finish(ctx context.Context) (uint64, error) { |
| + r.calls <- "finish" |
| + return r.haRep.Finish(ctx) |
| +} |
| + |
| +func (r *snapshotSpyRep) FinishSnapshot(ctx context.Context) (uint64, error, error) { |
| + r.calls <- "snapshot" |
| + txid, snapErr, err := r.real.FinishSnapshot(ctx) |
| + if r.snapErr != nil { |
| + snapErr = r.snapErr |
| + } |
| + return txid, snapErr, err |
| +} |
| + |
| +func spyOnRelease(t *testing.T, s *haSvc, e *actEntry, snapErr error) chan string { |
| + t.Helper() |
| + s.a.mu.Lock() |
| + defer s.a.mu.Unlock() |
| + real, ok := e.rep.(*lease.Replicator) |
| + if !ok { |
| + t.Fatalf("the entry's replica is a %T", e.rep) |
| + } |
| + calls := make(chan string, 4) |
| + e.rep = &snapshotSpyRep{Rep: real, haRep: real, real: real, snapErr: snapErr, calls: calls} |
| + return calls |
| +} |
| + |
| +func onlyCall(t *testing.T, calls chan string) string { |
| + t.Helper() |
| + var got []string |
| + for { |
| + select { |
| + case c := <-calls: |
| + got = append(got, c) |
| + default: |
| + if len(got) != 1 { |
| + t.Fatalf("the release's final syncs: %v, want one", got) |
| + } |
| + return got[0] |
| + } |
| + } |
| +} |
| + |
| +// The drain's release asks for the snapshot at the final position; an |
| +// idle sleep's does not (region HA §25.4 step 3.3, §25.10). |
| +func TestDrainStopReleasesWithASnapshot(t *testing.T) { |
| + s, e := haServiceEntry(t, "shop.example.com") |
| + calls := spyOnRelease(t, s, e, nil) |
| + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) |
| + defer cancel() |
| + rel, err := s.a.DrainStop(ctx, s.rt.Host) |
| + if err != nil || !rel.Marker || !rel.Clean { |
| + t.Fatalf("drain stop: %+v %v", rel, err) |
| + } |
| + if c := onlyCall(t, calls); c != "snapshot" { |
| + t.Fatalf("the drain's release called %s, want the snapshot", c) |
| + } |
| +} |
| + |
| +func TestIdleStopReleasesWithoutASnapshot(t *testing.T) { |
| + s, e := haServiceEntry(t, "shop.example.com") |
| + calls := spyOnRelease(t, s, e, nil) |
| + s.stopForTest(e) |
| + if c := onlyCall(t, calls); c != "finish" { |
| + t.Fatalf("an idle sleep's release called %s, want the plain final sync", c) |
| + } |
| + if v := s.lockView(t); v.Lock.Release == nil || !v.Lock.Release.Clean { |
| + t.Fatalf("lock after the sleep: %+v", v.Lock.Release) |
| + } |
| +} |
| + |
| +// A snapshot that fails is logged; the release is clean as before. |
| +func TestDrainStopSnapshotFailureStaysClean(t *testing.T) { |
| + s, e := haServiceEntry(t, "shop.example.com") |
| + calls := spyOnRelease(t, s, e, errors.New("the store refused the snapshot")) |
| + ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) |
| + defer cancel() |
| + rel, err := s.a.DrainStop(ctx, s.rt.Host) |
| + if err != nil || !rel.Marker || !rel.Clean { |
| + t.Fatalf("drain stop: %+v %v, want a clean release", rel, err) |
| + } |
| + if c := onlyCall(t, calls); c != "snapshot" { |
| + t.Fatalf("the drain's release called %s", c) |
| + } |
| + if v := s.lockView(t); v.Lock.Release == nil || !v.Lock.Release.Clean { |
| + t.Fatalf("lock: %+v, want a clean marker", v.Lock.Release) |
| + } |
| +} |
diff --git a/internal/activator/handover.go b/internal/activator/handover.go| index 1ebb9bd6e..4a7973f8e 100644 |
| --- a/internal/activator/handover.go |
| +++ b/internal/activator/handover.go |
| @@ -297,6 +297,7 @@ func (a *Service) BeginMove(host string) error { |
| a.moves.hosts = make(map[string]*hostMove) |
| } |
| a.moves.hosts[host] = &hostMove{route: e.route, phase: moveHolding, changed: make(chan struct{})} |
| + a.moveStreams.reset(host) |
| return nil |
| } |
| @@ -381,6 +382,7 @@ func (a *Service) SetMoveLeft(host, reason string) { |
| log.Printf("activator: handover of %s left: %s; its held requests get today's answer", host, reason) |
| m.gone = true |
| delete(a.moves.hosts, host) |
| + a.moveStreams.reset(host) |
| m.notifyLocked() |
| } |
| @@ -392,6 +394,7 @@ func (a *Service) EndDrainMoves() { |
| for host, m := range a.moves.hosts { |
| m.gone = true |
| delete(a.moves.hosts, host) |
| + a.moveStreams.reset(host) |
| m.notifyLocked() |
| } |
| } |
diff --git a/internal/activator/harelease.go b/internal/activator/harelease.go| index 232fc2b35..ca3a403ef 100644 |
| --- a/internal/activator/harelease.go |
| +++ b/internal/activator/harelease.go |
| @@ -161,7 +161,11 @@ func haEntryRep(e *actEntry) (haRep, bool) { |
| // written and errHostSliceUnproven is returned: the lease stays held |
| // and renewing, and the stop stays pending; |
| // 3. stopFiles, then Final; |
| -// 4. Finish, then the local release record; |
| +// 4. Finish, then the local release record. The drain's release |
| +// (DrainStop) finishes with FinishSnapshot instead: the same final |
| +// sync, then a snapshot at the final position before the store's |
| +// close, so the successor restores one file (§25.4 step 3.3). A |
| +// snapshot that fails is logged and changes nothing else; |
| // 5. ReleaseMarker, clean only when Final was complete, Finish succeeded |
| // and the record was written. |
| // |
| @@ -170,7 +174,7 @@ func haEntryRep(e *actEntry) (haRep, bool) { |
| // (*lease.ObligationError) and retries it. |
| func (a *Service) releaseHAClean(ctx context.Context, e *actEntry) error { |
| a.mu.Lock() |
| - rt, rep := e.route, e.rep |
| + rt, rep, drain := e.route, e.rep, e.drainRelease |
| a.mu.Unlock() |
| hr, ok := rep.(haRep) |
| if !ok || !hr.HA() { |
| @@ -198,7 +202,17 @@ func (a *Service) releaseHAClean(ctx context.Context, e *actEntry) error { |
| // a long one must not leave it a spent context, and the database's |
| // last writes unsynced. |
| sctx, scancel := a.haReleaseContext(ctx, haFinalSyncBudget, haShutdownMarkerReserve) |
| - txid, finErr := hr.Finish(sctx) |
| + var txid uint64 |
| + var finErr error |
| + if sr, ok := hr.(haSnapshotRep); ok && drain { |
| + var snapErr error |
| + txid, snapErr, finErr = sr.FinishSnapshot(sctx) |
| + if snapErr != nil && finErr == nil { |
| + log.Printf("activator: %s: no snapshot at the drain's release (%v); the successor's restore replays the replica's files instead", rt.Host, snapErr) |
| + } |
| + } else { |
| + txid, finErr = hr.Finish(sctx) |
| + } |
| scancel() |
| m := hb.haReleaseBase(rt) |
| m.TXID, m.FilesGen, m.At = txid, gen, time.Now().UTC() |
diff --git a/internal/activator/hawake.go b/internal/activator/hawake.go| index 5f06f3fae..147892b34 100644 |
| --- a/internal/activator/hawake.go |
| +++ b/internal/activator/hawake.go |
| @@ -54,9 +54,16 @@ type haRep interface { |
| ReleaseMarker(ctx context.Context, m hafresh.Marker) error |
| } |
| +// haSnapshotRep is an HA replica whose final sync can end with a |
| +// snapshot at the final position: the drain's release (releaseHAClean). |
| +type haSnapshotRep interface { |
| + FinishSnapshot(ctx context.Context) (txid uint64, snapErr, err error) |
| +} |
| + |
| var ( |
| - _ haLease = (*execLease)(nil) |
| - _ haRep = (*lease.Replicator)(nil) |
| + _ haLease = (*execLease)(nil) |
| + _ haRep = (*lease.Replicator)(nil) |
| + _ haSnapshotRep = (*lease.Replicator)(nil) |
| ) |
| func (l *execLease) HA() bool { return l.held.HA() } |
diff --git a/internal/activator/movestreams.go b/internal/activator/movestreams.go| new file mode 100644 |
| index 000000000..dca7d6d11 |
| --- /dev/null |
| +++ b/internal/activator/movestreams.go |
| @@ -0,0 +1,116 @@ |
| +package activator |
| + |
| +// A move cuts its host's long-lived responses at its start (region HA |
| +// spec §25.4 step 2, §25.8). The drain waits up to its in-flight bound |
| +// (10 s) for the host's requests here before it releases the host; an SSE |
| +// stream or an upgraded connection (a WebSocket) never ends on its own, |
| +// so one open stream held every move to the whole bound. Now each request |
| +// served for a host carries an edge.StreamEnd, and EndMoveStreams cuts |
| +// those whose response is a stream by cancelling the request's context, |
| +// as the connection drain does at its bound. Their clients reconnect and |
| +// are held by the move like any other request. An ordinary request is |
| +// not touched and keeps the bound. |
| +// |
| +// Memory only. The table has its own lock, so a request's track and |
| +// untrack never take a.mu; a.mu may be held around reset (lock order: |
| +// a.mu, then moveStreams.mu, never the other way). |
| + |
| +import ( |
| + "net/http" |
| + "sync" |
| + |
| + "github.com/carlosframework/platform/internal/edge" |
| +) |
| + |
| +type moveStreams struct { |
| + mu sync.Mutex |
| + // hosts is every request in flight per host. |
| + hosts map[string]map[*edge.StreamEnd]struct{} |
| + // ending is the hosts whose move has ended its streams: a request |
| + // tracked from then on is ended too once its response is a stream (a |
| + // request admitted on a ticket before the move began). |
| + ending map[string]bool |
| +} |
| + |
| +// track gives r a StreamEnd and counts it under host until the returned |
| +// func runs. |
| +func (m *moveStreams) track(host string, r *http.Request) (*http.Request, func()) { |
| + r, s := edge.WithStreamEnd(r) |
| + m.mu.Lock() |
| + if m.hosts == nil { |
| + m.hosts = make(map[string]map[*edge.StreamEnd]struct{}) |
| + } |
| + set := m.hosts[host] |
| + if set == nil { |
| + set = make(map[*edge.StreamEnd]struct{}) |
| + m.hosts[host] = set |
| + } |
| + set[s] = struct{}{} |
| + ending := m.ending[host] |
| + m.mu.Unlock() |
| + if ending { |
| + s.End() |
| + } |
| + return r, func() { |
| + m.mu.Lock() |
| + defer m.mu.Unlock() |
| + if set := m.hosts[host]; set != nil { |
| + delete(set, s) |
| + if len(set) == 0 { |
| + delete(m.hosts, host) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// reset forgets that host's streams were ended: a move begins or ends. |
| +func (m *moveStreams) reset(host string) { |
| + m.mu.Lock() |
| + defer m.mu.Unlock() |
| + delete(m.ending, host) |
| +} |
| + |
| +// endingLocked marks host's streams ended until reset, and answers the |
| +// requests in flight for it. a.mu is held, so no reset runs in between. |
| +func (m *moveStreams) endingLocked(host string) []*edge.StreamEnd { |
| + m.mu.Lock() |
| + defer m.mu.Unlock() |
| + if m.ending == nil { |
| + m.ending = make(map[string]bool) |
| + } |
| + m.ending[host] = true |
| + var all []*edge.StreamEnd |
| + for s := range m.hosts[host] { |
| + all = append(all, s) |
| + } |
| + return all |
| +} |
| + |
| +// end ends each of all that is a stream, or becomes one, and answers how |
| +// many are streams now. |
| +func end(all []*edge.StreamEnd) int { |
| + n := 0 |
| + for _, s := range all { |
| + s.End() |
| + if s.Stream() { |
| + n++ |
| + } |
| + } |
| + return n |
| +} |
| + |
| +// EndMoveStreams cuts host's long-lived responses on this box at the |
| +// move's start (§25.4 step 2): SSE streams of any encoding and upgraded |
| +// connections, now, and any that open later during the move. It answers |
| +// how many were cut now, and 0 when host is not moving here (BeginMove |
| +// first). |
| +func (a *Service) EndMoveStreams(host string) int { |
| + a.mu.Lock() |
| + if a.moves.hosts[host] == nil { |
| + a.mu.Unlock() |
| + return 0 |
| + } |
| + all := a.moveStreams.endingLocked(host) |
| + a.mu.Unlock() |
| + return end(all) |
| +} |
diff --git a/internal/activator/movestreams_test.go b/internal/activator/movestreams_test.go| new file mode 100644 |
| index 000000000..2d52fcf96 |
| --- /dev/null |
| +++ b/internal/activator/movestreams_test.go |
| @@ -0,0 +1,303 @@ |
| +package activator |
| + |
| +import ( |
| + "bufio" |
| + "compress/gzip" |
| + "context" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "net" |
| + "net/http" |
| + "net/http/httptest" |
| + "net/http/httputil" |
| + "net/url" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/edge" |
| +) |
| + |
| +// A move cuts its host's long-lived responses at its start (region HA |
| +// §25.4 step 2, §25.8): an SSE stream (of any encoding) or an upgraded |
| +// connection open when the move begins no longer holds the in-flight wait |
| +// to its bound. |
| +// An ordinary request still does. The scene is haServiceEntry, served |
| +// through a.ServeHTTP behind a reverse proxy with the edge's move hook, |
| +// as the edge's tenant proxies have it (responseModifier). |
| + |
| +// moveStreamUpstream is the app: /events is an SSE stream that sends an |
| +// event every 20 ms until its client goes; /ws upgrades and echoes until |
| +// either side closes; /slow answers once release is closed. |
| +func moveStreamUpstream(t *testing.T, release <-chan struct{}) *url.URL { |
| + t.Helper() |
| + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + switch r.URL.Path { |
| + case "/events": |
| + w.Header().Set("Content-Type", "text/event-stream") |
| + w.WriteHeader(http.StatusOK) |
| + f := w.(http.Flusher) |
| + for i := 0; ; i++ { |
| + // Two writes per event, so a boundary is never a read's |
| + // edge by accident. |
| + fmt.Fprintf(w, "id: %d\n", i) |
| + f.Flush() |
| + fmt.Fprintf(w, "data: tick %d\n\n", i) |
| + f.Flush() |
| + select { |
| + case <-r.Context().Done(): |
| + return |
| + case <-time.After(20 * time.Millisecond): |
| + } |
| + } |
| + case "/gzevents": |
| + // A compressed SSE stream, negotiated by the client's own |
| + // Accept-Encoding (which the proxy passes on), flushed per event. |
| + if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { |
| + t.Error("the client's Accept-Encoding did not reach the app") |
| + return |
| + } |
| + w.Header().Set("Content-Type", "text/event-stream") |
| + w.Header().Set("Content-Encoding", "gzip") |
| + w.WriteHeader(http.StatusOK) |
| + gz := gzip.NewWriter(w) |
| + f := w.(http.Flusher) |
| + for i := 0; ; i++ { |
| + fmt.Fprintf(gz, "id: %d\ndata: tick %d\n\n", i, i) |
| + gz.Flush() |
| + f.Flush() |
| + select { |
| + case <-r.Context().Done(): |
| + return |
| + case <-time.After(20 * time.Millisecond): |
| + } |
| + } |
| + case "/ws": |
| + conn, brw, err := http.NewResponseController(w).Hijack() |
| + if err != nil { |
| + t.Error(err) |
| + return |
| + } |
| + defer conn.Close() |
| + brw.WriteString("HTTP/1.1 101 Switching Protocols\r\nUpgrade: echo\r\nConnection: Upgrade\r\n\r\n") |
| + brw.Flush() |
| + io.Copy(conn, brw) |
| + case "/slow": |
| + select { |
| + case <-release: |
| + case <-r.Context().Done(): |
| + } |
| + io.WriteString(w, "done") |
| + } |
| + })) |
| + t.Cleanup(srv.Close) |
| + u, _ := url.Parse(srv.URL) |
| + return u |
| +} |
| + |
| +// moveStreamFront serves s's host through a.ServeHTTP and a reverse |
| +// proxy to up whose response hook is the edge's. |
| +func moveStreamFront(t *testing.T, s *haSvc, up *url.URL) string { |
| + t.Helper() |
| + proxy := &httputil.ReverseProxy{ |
| + Rewrite: func(pr *httputil.ProxyRequest) { pr.SetURL(up) }, |
| + ModifyResponse: func(resp *http.Response) error { edge.MarkMoveStream(resp); return nil }, |
| + } |
| + front := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + s.a.ServeHTTP(w, r, s.rt, proxy) |
| + })) |
| + t.Cleanup(front.Close) |
| + return front.URL |
| +} |
| + |
| +func (s *haSvc) inflight() int { |
| + s.a.mu.Lock() |
| + defer s.a.mu.Unlock() |
| + if e := s.a.entries[s.rt.Host]; e != nil { |
| + return e.inflight |
| + } |
| + return 0 |
| +} |
| + |
| +// openEvents opens the SSE stream and reads its first two events. |
| +func openEvents(t *testing.T, front string) (*http.Response, *bufio.Reader) { |
| + t.Helper() |
| + resp, err := http.Get(front + "/events") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Cleanup(func() { resp.Body.Close() }) |
| + br := bufio.NewReader(resp.Body) |
| + for seen := 0; seen < 2; { |
| + line, err := br.ReadString('\n') |
| + if err != nil { |
| + t.Fatalf("reading the stream: %v", err) |
| + } |
| + if line == "\n" { |
| + seen++ |
| + } |
| + } |
| + return resp, br |
| +} |
| + |
| +// moveAndWait begins the move, ends its streams and waits for the host's |
| +// requests here as the drain does, with the drain's 10 s bound. It |
| +// answers how long the wait took and its error. |
| +func moveAndWait(t *testing.T, s *haSvc, bound time.Duration) (time.Duration, error) { |
| + t.Helper() |
| + if err := s.a.BeginMove(s.rt.Host); err != nil { |
| + t.Fatal(err) |
| + } |
| + start := time.Now() |
| + s.a.EndMoveStreams(s.rt.Host) |
| + ctx, cancel := context.WithTimeout(t.Context(), bound) |
| + defer cancel() |
| + err := s.a.WaitDrainInflight(ctx, s.rt.Host) |
| + return time.Since(start), err |
| +} |
| + |
| +func TestMoveEndsAnSSEStreamAtItsStart(t *testing.T) { |
| + s, _ := haServiceEntry(t, "shop.example.com") |
| + front := moveStreamFront(t, s, moveStreamUpstream(t, nil)) |
| + _, br := openEvents(t, front) |
| + if n := s.inflight(); n != 1 { |
| + t.Fatalf("in flight = %d with the stream open, want 1", n) |
| + } |
| + took, err := moveAndWait(t, s, 10*time.Second) |
| + if err != nil || took > time.Second { |
| + t.Fatalf("the in-flight wait took %v (%v): an open SSE stream held the move", took, err) |
| + } |
| + // The stream is cut: the client's read ends, and it reconnects. |
| + wantStreamEnded(t, br) |
| + if n := s.inflight(); n != 0 { |
| + t.Fatalf("in flight = %d after the end", n) |
| + } |
| +} |
| + |
| +// A stream that opens after the move's start (its request admitted before |
| +// it, on a ticket) is cut as soon as its head says it is one. |
| +func TestMoveEndsAStreamThatOpensAfterItsStart(t *testing.T) { |
| + s, _ := haServiceEntry(t, "shop.example.com") |
| + front := moveStreamFront(t, s, moveStreamUpstream(t, nil)) |
| + if _, err := moveAndWait(t, s, 10*time.Second); err != nil { |
| + t.Fatal(err) |
| + } |
| + resp, err := http.Get(front + "/events") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer resp.Body.Close() |
| + wantStreamEnded(t, resp.Body) |
| +} |
| + |
| +// wantStreamEnded waits for r to end, by EOF or by an error: a cut stream |
| +// ends either way. |
| +func wantStreamEnded(t *testing.T, r io.Reader) { |
| + t.Helper() |
| + done := make(chan struct{}) |
| + go func() { io.Copy(io.Discard, r); close(done) }() |
| + select { |
| + case <-done: |
| + case <-time.After(2 * time.Second): |
| + t.Fatal("the stream was not cut") |
| + } |
| +} |
| + |
| +// A compressed SSE stream, which the client asked for, is cut the same |
| +// way, and the drain does not wait out the bound. |
| +func TestMoveClosesAnEncodedSSEStream(t *testing.T) { |
| + s, _ := haServiceEntry(t, "shop.example.com") |
| + front := moveStreamFront(t, s, moveStreamUpstream(t, nil)) |
| + client := &http.Client{Transport: &http.Transport{DisableCompression: true}} |
| + req, _ := http.NewRequest(http.MethodGet, front+"/gzevents", nil) |
| + req.Header.Set("Accept-Encoding", "gzip") |
| + resp, err := client.Do(req) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer resp.Body.Close() |
| + if resp.Header.Get("Content-Encoding") != "gzip" { |
| + t.Fatalf("Content-Encoding %q", resp.Header.Get("Content-Encoding")) |
| + } |
| + // The client decodes two events before the move. |
| + zr, err := gzip.NewReader(resp.Body) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + br := bufio.NewReader(zr) |
| + for seen := 0; seen < 2; { |
| + line, err := br.ReadString('\n') |
| + if err != nil { |
| + t.Fatalf("reading the stream: %v", err) |
| + } |
| + if line == "\n" { |
| + seen++ |
| + } |
| + } |
| + took, err := moveAndWait(t, s, 10*time.Second) |
| + if err != nil || took > time.Second { |
| + t.Fatalf("the in-flight wait took %v (%v): an encoded SSE stream held the move", took, err) |
| + } |
| + wantStreamEnded(t, br) |
| +} |
| + |
| +func TestMoveEndsAnUpgradedConnectionAtItsStart(t *testing.T) { |
| + s, _ := haServiceEntry(t, "shop.example.com") |
| + front := moveStreamFront(t, s, moveStreamUpstream(t, nil)) |
| + conn, err := net.Dial("tcp", strings.TrimPrefix(front, "http://")) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer conn.Close() |
| + io.WriteString(conn, "GET /ws HTTP/1.1\r\nHost: shop.example.com\r\nUpgrade: echo\r\nConnection: Upgrade\r\n\r\n") |
| + br := bufio.NewReader(conn) |
| + resp, err := http.ReadResponse(br, nil) |
| + if err != nil || resp.StatusCode != http.StatusSwitchingProtocols { |
| + t.Fatalf("upgrade: %v %v", resp, err) |
| + } |
| + io.WriteString(conn, "ping") |
| + buf := make([]byte, 4) |
| + if _, err := io.ReadFull(br, buf); err != nil || string(buf) != "ping" { |
| + t.Fatalf("echo: %q %v", buf, err) |
| + } |
| + if n := s.inflight(); n != 1 { |
| + t.Fatalf("in flight = %d with the connection open, want 1", n) |
| + } |
| + took, err := moveAndWait(t, s, 10*time.Second) |
| + if err != nil || took > time.Second { |
| + t.Fatalf("the in-flight wait took %v (%v): an upgraded connection held the move", took, err) |
| + } |
| + conn.SetReadDeadline(time.Now().Add(2 * time.Second)) |
| + if _, err := br.ReadByte(); !errors.Is(err, io.EOF) { |
| + t.Fatalf("the connection is still open: %v", err) |
| + } |
| +} |
| + |
| +// An ordinary request is not ended: it holds the in-flight wait to its |
| +// bound, as before. |
| +func TestMoveKeepsTheBoundForAnOrdinaryRequest(t *testing.T) { |
| + s, _ := haServiceEntry(t, "shop.example.com") |
| + release := make(chan struct{}) |
| + front := moveStreamFront(t, s, moveStreamUpstream(t, release)) |
| + got := make(chan string, 1) |
| + go func() { |
| + resp, err := http.Get(front + "/slow") |
| + if err != nil { |
| + got <- err.Error() |
| + return |
| + } |
| + defer resp.Body.Close() |
| + b, _ := io.ReadAll(resp.Body) |
| + got <- string(b) |
| + }() |
| + waitUntil(t, "the request in flight", func() bool { return s.inflight() == 1 }) |
| + took, err := moveAndWait(t, s, 300*time.Millisecond) |
| + if !errors.Is(err, context.DeadlineExceeded) || took < 300*time.Millisecond { |
| + t.Fatalf("the wait ended after %v (%v): an ordinary request was cut short", took, err) |
| + } |
| + close(release) |
| + if b := <-got; b != "done" { |
| + t.Fatalf("the ordinary request answered %q", b) |
| + } |
| +} |
diff --git a/internal/edge/edge.go b/internal/edge/edge.go| index ab9c51822..e247f30db 100644 |
| --- a/internal/edge/edge.go |
| +++ b/internal/edge/edge.go |
| @@ -1029,7 +1029,7 @@ func (e *Edge) Reload() error { |
| // Sets select only live assigned copies, before legacy fleet fallback. |
| case ArmReplica: |
| p := replicaProxy(t.Host, served.Fleet, e.replicaProberForRouting(), e.tunnels) |
| - p.ModifyResponse = e.responseModifier(t) |
| + p.ModifyResponse = classifyMoveStreams(e.responseModifier(t)) |
| proxy, viaTunnel = p, true |
| ten = tenancy{Arm: ArmReplica, Account: served.Account, App: served.App, Fleet: served.Fleet} |
| replicaRoutes = append(replicaRoutes, t) |
| @@ -1047,7 +1047,7 @@ func (e *Edge) Reload() error { |
| case ArmForward: |
| box, authoritative := fleetBoxOf(t) |
| p := fleetProxy(served.Fleet, box, authoritative, e.tunnels) |
| - p.ModifyResponse = e.responseModifier(t) |
| + p.ModifyResponse = classifyMoveStreams(e.responseModifier(t)) |
| proxy = p |
| viaTunnel = true |
| ten = tenancy{Arm: ArmForward, Account: served.Account, App: served.App, Fleet: served.Fleet} |
| @@ -1090,7 +1090,7 @@ func (e *Edge) Reload() error { |
| // wins outright rather than silently falling back to a stale Addr. |
| case ArmTunnel: |
| p := tunnelProxy(t.Tunnel, e.tunnels) |
| - p.ModifyResponse = e.responseModifier(t) |
| + p.ModifyResponse = classifyMoveStreams(e.responseModifier(t)) |
| proxy = p |
| viaTunnel = true |
| ten = tenancy{Arm: ArmTunnel, Account: t.Account, App: t.App, Tunnel: t.Tunnel} |
| @@ -1120,7 +1120,7 @@ func (e *Edge) Reload() error { |
| } |
| box, authoritative := fleetBoxOf(t) |
| p := fleetProxy(served.Fleet, box, authoritative, e.tunnels) |
| - p.ModifyResponse = e.responseModifier(t) |
| + p.ModifyResponse = classifyMoveStreams(e.responseModifier(t)) |
| proxy = p |
| viaTunnel = true |
| ten = tenancy{Arm: ArmFleet, Account: served.Account, App: served.App, Fleet: served.Fleet} |
| @@ -1136,7 +1136,7 @@ func (e *Edge) Reload() error { |
| } else { |
| p = unixProxy(t.Socket) |
| } |
| - p.ModifyResponse = e.responseModifier(t) |
| + p.ModifyResponse = classifyMoveStreams(e.responseModifier(t)) |
| proxy = p |
| // TCP upstreams. The gate is AddrList (registry), not t.Addr, so a |
| // multi-upstream route — which writes the Addrs column and leaves the |
| @@ -1188,7 +1188,7 @@ func (e *Edge) Reload() error { |
| probeSpecs[t.Host] = probeSpec{Host: t.Host, Addrs: addrs, Health: h} |
| p = multiProxy(t.Host, e.probers, e.hold) |
| } |
| - p.ModifyResponse = e.responseModifier(t) |
| + p.ModifyResponse = classifyMoveStreams(e.responseModifier(t)) |
| proxy = p |
| case ArmStatic: |
| proxy = e.staticHandlerFor(t) |
diff --git a/internal/edge/movestreams.go b/internal/edge/movestreams.go| new file mode 100644 |
| index 000000000..f9d326589 |
| --- /dev/null |
| +++ b/internal/edge/movestreams.go |
| @@ -0,0 +1,106 @@ |
| +package edge |
| + |
| +// Long-lived responses a planned move cuts at its start (region HA spec |
| +// §25.4 step 2, §25.8). A move waits up to its in-flight bound for the |
| +// host's requests here to finish before it releases the host; an SSE |
| +// stream or an upgraded connection never finishes on its own, so without |
| +// this every move with one open waited the whole bound. |
| +// |
| +// The activator gives each request it serves a StreamEnd (WithStreamEnd) |
| +// and keeps it per host while the request runs. The tenant proxies' |
| +// response hook (classifyMoveStreams, around responseModifier) marks it |
| +// when the response head says it is a stream: a 101 (an upgraded |
| +// connection, a WebSocket) or a text/event-stream, of any encoding. It |
| +// reads the head only and never wraps the body, so the trailer scrubs |
| +// below keep their one closer, the proxy. |
| +// |
| +// Ending a stream cancels its request's context: the proxy stops copying |
| +// and the connection is closed, as the connection drain does at its |
| +// bound. The client reconnects (EventSource with Last-Event-ID) and is |
| +// held by the move like any other request. End is a no-op for any other |
| +// request, so an ordinary request keeps the move's bound. |
| + |
| +import ( |
| + "context" |
| + "mime" |
| + "net/http" |
| + "sync" |
| +) |
| + |
| +// StreamEnd is one proxied request a move may cut. Memory only. |
| +type StreamEnd struct { |
| + cancel context.CancelFunc |
| + |
| + mu sync.Mutex |
| + stream bool |
| + ending bool |
| +} |
| + |
| +type streamEndKey struct{} |
| + |
| +// WithStreamEnd gives r a StreamEnd: r's context becomes cancellable by |
| +// it, and the response hook finds it there. |
| +func WithStreamEnd(r *http.Request) (*http.Request, *StreamEnd) { |
| + ctx, cancel := context.WithCancel(r.Context()) |
| + s := &StreamEnd{cancel: cancel} |
| + return r.WithContext(context.WithValue(ctx, streamEndKey{}, s)), s |
| +} |
| + |
| +// End cuts the request if its response is a stream, now or as soon as |
| +// its head says it is one. A request that never becomes one is not |
| +// touched. Idempotent. |
| +func (s *StreamEnd) End() { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + s.ending = true |
| + if s.stream { |
| + s.cancel() |
| + } |
| +} |
| + |
| +// Stream reports whether the response was marked as a stream. |
| +func (s *StreamEnd) Stream() bool { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + return s.stream |
| +} |
| + |
| +func (s *StreamEnd) mark() { |
| + s.mu.Lock() |
| + defer s.mu.Unlock() |
| + s.stream = true |
| + if s.ending { |
| + s.cancel() |
| + } |
| +} |
| + |
| +// MarkMoveStream marks the request's StreamEnd when resp's head says it |
| +// is a stream: a 101, or a text/event-stream of any encoding. It reads |
| +// resp's status and Content-Type only, and changes nothing in resp. A |
| +// response whose request has no StreamEnd is left alone. |
| +func MarkMoveStream(resp *http.Response) { |
| + if resp == nil || resp.Request == nil { |
| + return |
| + } |
| + s, _ := resp.Request.Context().Value(streamEndKey{}).(*StreamEnd) |
| + if s == nil { |
| + return |
| + } |
| + if resp.StatusCode == http.StatusSwitchingProtocols || isEventStream(resp.Header.Get("Content-Type")) { |
| + s.mark() |
| + } |
| +} |
| + |
| +// classifyMoveStreams is a tenant proxy's ModifyResponse: MarkMoveStream |
| +// on the response head, first, then mod (responseModifier), unchanged. |
| +func classifyMoveStreams(mod func(*http.Response) error) func(*http.Response) error { |
| + return func(resp *http.Response) error { |
| + MarkMoveStream(resp) |
| + return mod(resp) |
| + } |
| +} |
| + |
| +func isEventStream(ct string) bool { |
| + mt, _, err := mime.ParseMediaType(ct) |
| + return err == nil && mt == "text/event-stream" |
| +} |
diff --git a/internal/edge/movestreams_test.go b/internal/edge/movestreams_test.go| new file mode 100644 |
| index 000000000..f5fa3fc5c |
| --- /dev/null |
| +++ b/internal/edge/movestreams_test.go |
| @@ -0,0 +1,152 @@ |
| +package edge |
| + |
| +import ( |
| + "bufio" |
| + "fmt" |
| + "io" |
| + "net/http" |
| + "net/http/httptest" |
| + "net/http/httputil" |
| + "net/url" |
| + "strings" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/registry" |
| +) |
| + |
| +// The tenant proxies' hook marks a stream from its head and nothing else, |
| +// and never changes the response: the body the proxy reads is the one |
| +// responseModifier left, wrapper for wrapper. |
| +func TestClassifyMoveStreamsMarksStreamsOnly(t *testing.T) { |
| + e := &Edge{appsDomain: "example.com"} |
| + rt := registry.Route{Host: "shop.example.com"} |
| + hook := classifyMoveStreams(e.responseModifier(rt)) |
| + for _, c := range []struct { |
| + status int |
| + ct, enc string |
| + stream bool |
| + }{ |
| + {http.StatusOK, "text/event-stream; charset=utf-8", "", true}, |
| + {http.StatusOK, "text/event-stream", "gzip", true}, |
| + {http.StatusSwitchingProtocols, "", "", true}, |
| + {http.StatusOK, "text/html", "", false}, |
| + {http.StatusOK, "application/json", "gzip", false}, |
| + } { |
| + mk := func(r *http.Request) *http.Response { |
| + resp := &http.Response{StatusCode: c.status, Header: http.Header{}, Trailer: http.Header{}, Request: r, Body: io.NopCloser(strings.NewReader("data: x\n\n"))} |
| + if c.ct != "" { |
| + resp.Header.Set("Content-Type", c.ct) |
| + } |
| + if c.enc != "" { |
| + resp.Header.Set("Content-Encoding", c.enc) |
| + } |
| + return resp |
| + } |
| + r, s := WithStreamEnd(httptest.NewRequest(http.MethodGet, "https://shop.example.com/", nil)) |
| + resp := mk(r) |
| + if err := hook(resp); err != nil { |
| + t.Fatal(err) |
| + } |
| + plain := mk(httptest.NewRequest(http.MethodGet, "https://shop.example.com/", nil)) |
| + if err := e.responseModifier(rt)(plain); err != nil { |
| + t.Fatal(err) |
| + } |
| + if got, want := fmt.Sprintf("%T", resp.Body), fmt.Sprintf("%T", plain.Body); got != want { |
| + t.Errorf("%d %q: body %s, want responseModifier's own %s: the move hook wrapped it", c.status, c.ct, got, want) |
| + } |
| + if s.Stream() != c.stream { |
| + t.Errorf("%d %q %q: stream %v, want %v", c.status, c.ct, c.enc, s.Stream(), c.stream) |
| + } |
| + s.End() |
| + if cut := r.Context().Err() != nil; cut != c.stream { |
| + t.Errorf("%d %q %q: cut %v by End, want %v", c.status, c.ct, c.enc, cut, c.stream) |
| + } |
| + } |
| + // A stream marked after End (it opened mid-move) is cut at once. |
| + r, s := WithStreamEnd(httptest.NewRequest(http.MethodGet, "https://shop.example.com/", nil)) |
| + s.End() |
| + if r.Context().Err() != nil { |
| + t.Fatal("End cut a request before its head said it is a stream") |
| + } |
| + hook(&http.Response{StatusCode: http.StatusOK, Header: http.Header{"Content-Type": {"text/event-stream"}}, Request: r, Body: http.NoBody}) |
| + if r.Context().Err() == nil { |
| + t.Fatal("a stream classified after End was not cut") |
| + } |
| +} |
| + |
| +// Astra round 2's guard, kept as a test: through the real responseModifier, |
| +// http.Transport and httputil.ReverseProxy, an SSE response whose trailers |
| +// (announced and unannounced platform trailers, and a wide-domain |
| +// Set-Cookie) arrive as a move cuts it. No platform trailer and no |
| +// unscoped cookie may reach the client, whatever the order. Run with -race. |
| +func TestMoveCutKeepsTheTrailerScrubs(t *testing.T) { |
| + for i := 0; i < 30; i++ { |
| + moveCutTrailerRound(t, i%3) |
| + } |
| +} |
| + |
| +func moveCutTrailerRound(t *testing.T, delay int) { |
| + t.Helper() |
| + cut := make(chan struct{}) |
| + up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + w.Header().Set("Content-Type", "text/event-stream") |
| + w.Header().Set("Trailer", holderHeader+", X-App") |
| + w.WriteHeader(http.StatusOK) |
| + io.WriteString(w, "data: x\n\n") |
| + w.(http.Flusher).Flush() |
| + <-cut |
| + time.Sleep(time.Duration(delay) * time.Millisecond) |
| + w.Header().Set(holderHeader, "forged") |
| + w.Header().Set("X-App", "kept") |
| + w.Header().Set(http.TrailerPrefix+HandoverHeader, "1") |
| + w.Header().Set(http.TrailerPrefix+"Carlos-Cache", "hit") |
| + w.Header().Set(http.TrailerPrefix+"Set-Cookie", "sid=forged; Domain=example.com") |
| + })) |
| + defer up.Close() |
| + u, _ := url.Parse(up.URL) |
| + e := &Edge{appsDomain: "example.com"} |
| + proxy := &httputil.ReverseProxy{ |
| + Rewrite: func(pr *httputil.ProxyRequest) { pr.SetURL(u) }, |
| + ModifyResponse: classifyMoveStreams(e.responseModifier(registry.Route{Host: "shop.example.com"})), |
| + ErrorLog: nil, |
| + } |
| + ends := make(chan *StreamEnd, 1) |
| + front := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| + r, s := WithStreamEnd(r) |
| + ends <- s |
| + proxy.ServeHTTP(w, r) |
| + })) |
| + defer front.Close() |
| + resp, err := http.Get(front.URL + "/events") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer resp.Body.Close() |
| + br := bufio.NewReader(resp.Body) |
| + if line, err := br.ReadString('\n'); err != nil || line != "data: x\n" { |
| + t.Fatalf("first line %q %v", line, err) |
| + } |
| + s := <-ends |
| + close(cut) // the app sends its trailers now |
| + s.End() // and the move cuts the stream |
| + done := make(chan struct{}) |
| + go func() { io.Copy(io.Discard, br); close(done) }() |
| + select { |
| + case <-done: |
| + case <-time.After(5 * time.Second): |
| + t.Fatal("the cut stream did not end") |
| + } |
| + for _, h := range []http.Header{resp.Header, resp.Trailer} { |
| + for _, k := range []string{holderHeader, HandoverHeader, "Carlos-Cache"} { |
| + if v := h.Get(k); v != "" { |
| + t.Fatalf("platform trailer %s = %q reached the client", k, v) |
| + } |
| + } |
| + for _, c := range h.Values("Set-Cookie") { |
| + if strings.Contains(strings.ToLower(c), "domain=example.com") { |
| + t.Fatalf("an unscoped cookie reached the client: %q", c) |
| + } |
| + } |
| + } |
| +} |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 85984bf4e..e321b405c 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -436,7 +436,10 @@ var groupNameProducerInventory = map[string]string{ |
| // proxy is built over an existing exact console row and publishes no name. |
| // Edge page cache slice 1: Reload also keeps the rows it read |
| // (pageRoutes) for the page reload hook; no entry is added or renamed. |
| - "../edge/edge.go:*Edge.Reload": "6c745d037af79adfccc1de8254c7f8fd2eba7e549287a4359d1ba0b3da55437d", |
| + // Held requests move speed: the six tenant proxies' response hook is |
| + // wrapped by classifyMoveStreams, which reads only the response head to |
| + // mark a stream for a move's cut; no name is derived, published or routed. |
| + "../edge/edge.go:*Edge.Reload": "9dc1db78179479c5d2d1ac25c5c696c09edf86e6a088f7a6145db11c6ac6f1a9", |
| // Edge page cache slice 1: routeScope builds an in-memory upstream only to |
| // read the route's page scope (account, app, primary host). It publishes, |
| // registers and routes no name; no name class. |
diff --git a/internal/host/hadrain.go b/internal/host/hadrain.go| index fb4f0e006..4a3234cd4 100644 |
| --- a/internal/host/hadrain.go |
| +++ b/internal/host/hadrain.go |
| @@ -79,6 +79,7 @@ type drainActivator interface { |
| DrainHosts() []activator.DrainHost |
| DrainHeld() []string |
| BeginMove(host string) error |
| + EndMoveStreams(host string) int |
| WaitMoveTickets(ctx context.Context, host string) error |
| WaitDrainInflight(ctx context.Context, host string) error |
| SetMoveReleasing(host string) error |
| @@ -716,8 +717,17 @@ func (d *drainDriver) moveOne(ctx context.Context, txn string, h activator.Drain |
| } |
| return leave("begin", err.Error(), activator.DrainRelease{}) |
| } |
| - // 3.2: tickets and the in-flight drain share today's 10 s bound. At the |
| - // bound the stop ends what is left, as a shutdown stop does. |
| + // 3.1: the host's long-lived responses here are cut now, at the |
| + // move's start, not at the take: SSE streams and upgraded connections |
| + // (their request contexts cancelled), and edge-held streams. None ends |
| + // on its own, so each would hold the wait below to its bound. Their |
| + // clients reconnect and are held like any other request until the take |
| + // (§25.8), as at today's connection drain. |
| + d.act.EndMoveStreams(host) |
| + d.edge.CloseHeldHost(host) |
| + // 3.2: tickets and the in-flight drain share today's 10 s bound for |
| + // every other request. At the bound the stop ends what is left, as a |
| + // shutdown stop does. |
| ictx, icancel := context.WithTimeout(ctx, drainInflightBound) |
| _ = d.act.WaitMoveTickets(ictx, host) |
| _ = d.act.WaitDrainInflight(ictx, host) |
| @@ -745,8 +755,9 @@ func (d *drainDriver) moveOne(ctx context.Context, txn string, h activator.Drain |
| if err := d.act.SetMoveTaken(host, holder, gen); err != nil { |
| return leave("take", err.Error(), rel) |
| } |
| - // Its edge-held streams here reconnect to the holder now, at an event |
| - // boundary, not at the end of the drain (R3.5). |
| + // Its edge-held streams were closed at the move's start (3.1). Any |
| + // opened here since then reconnect to the holder now, at an event |
| + // boundary, not at the end of the drain (R3.5). Idempotent. |
| d.edge.CloseHeldHost(host) |
| d.note(func() { |
| rep.Moved = append(rep.Moved, drainMoved{Host: host, Holder: holder, Gen: gen, Confirmed: how}) |
diff --git a/internal/host/hadrain_test.go b/internal/host/hadrain_test.go| index 8b5ca5ebb..f1f19bc7e 100644 |
| --- a/internal/host/hadrain_test.go |
| +++ b/internal/host/hadrain_test.go |
| @@ -65,6 +65,11 @@ type fakeDrainAct struct { |
| logOn bool |
| logEnds int |
| notMoving map[string]bool |
| + // streams are hosts with a stream open here: the in-flight wait |
| + // holds to its bound until the move ends it (EndMoveStreams). |
| + streams map[string]bool |
| + // streamEnded is closed when EndMoveStreams ends a stream. |
| + streamEnded chan struct{} |
| onBeginMove func(string) |
| } |
| @@ -122,8 +127,34 @@ func (f *fakeDrainAct) BeginMove(host string) error { |
| } |
| return nil |
| } |
| -func (f *fakeDrainAct) WaitMoveTickets(context.Context, string) error { return nil } |
| -func (f *fakeDrainAct) WaitDrainInflight(context.Context, string) error { return nil } |
| +func (f *fakeDrainAct) WaitMoveTickets(context.Context, string) error { return nil } |
| +func (f *fakeDrainAct) EndMoveStreams(host string) int { |
| + f.rec.add("end-streams " + host) |
| + f.mu.Lock() |
| + defer f.mu.Unlock() |
| + if !f.streams[host] { |
| + return 0 |
| + } |
| + f.streams[host] = false |
| + close(f.streamEnded) |
| + f.streamEnded = make(chan struct{}) |
| + return 1 |
| +} |
| +func (f *fakeDrainAct) WaitDrainInflight(ctx context.Context, host string) error { |
| + for { |
| + f.mu.Lock() |
| + open, ended := f.streams[host], f.streamEnded |
| + f.mu.Unlock() |
| + if !open { |
| + return nil |
| + } |
| + select { |
| + case <-ended: |
| + case <-ctx.Done(): |
| + return ctx.Err() |
| + } |
| + } |
| +} |
| func (f *fakeDrainAct) SetMoveReleasing(host string) error { |
| f.rec.add("releasing " + host) |
| return nil |
| @@ -504,7 +535,7 @@ func TestDrainDriverWholeSequence(t *testing.T) { |
| t.Fatalf("report counts %+v", rep) |
| } |
| ev := act.rec.events() |
| - order := []string{"draining", "ask draining b", "begin busy.example.com", "stop busy.example.com", "take busy.example.com b", "taken busy.example.com b", "close-held busy.example.com", "drained", "ask drained b", "end-moves", "connections"} |
| + order := []string{"draining", "ask draining b", "begin busy.example.com", "end-streams busy.example.com", "close-held busy.example.com", "releasing busy.example.com", "stop busy.example.com", "take busy.example.com b", "taken busy.example.com b", "drained", "ask drained b", "end-moves", "connections"} |
| last := -1 |
| for _, step := range order { |
| i := indexOf(ev, step) |
| @@ -534,6 +565,36 @@ func TestDrainDriverWholeSequence(t *testing.T) { |
| } |
| } |
| +// A host with a stream open at the move's start (an SSE stream or an |
| +// upgraded connection, which never ends on its own) is not held to the |
| +// in-flight bound: the move ends its streams and its edge-held streams |
| +// right after BeginMove, before the wait, and reaches the release at once |
| +// (§25.4 step 3.1, §25.8). The bound itself is unchanged. |
| +func TestMoveEndsStreamsBeforeTheInflightWait(t *testing.T) { |
| + if drainInflightBound != 10*time.Second { |
| + t.Fatalf("drainInflightBound = %v, want today's 10 s", drainInflightBound) |
| + } |
| + act, ed, marks := healthyDrain() |
| + act.streams = map[string]bool{"busy.example.com": true, "quiet.example.com": true} |
| + act.streamEnded = make(chan struct{}) |
| + d := newDrainDriver(act, ed, marks, fenceOf("t1")) |
| + start := time.Now() |
| + rep := runDrain(t, d, "t1") |
| + if took := time.Since(start); took > time.Second { |
| + t.Fatalf("the drain took %v: open streams held the moves to the in-flight bound", took) |
| + } |
| + if rep.Result != "ok" || len(rep.Moved) != 2 { |
| + t.Fatalf("report %+v", rep) |
| + } |
| + ev := act.rec.events() |
| + for _, host := range []string{"busy.example.com", "quiet.example.com"} { |
| + begin, streams, held, releasing := indexOf(ev, "begin "+host), indexOf(ev, "end-streams "+host), indexOf(ev, "close-held "+host), indexOf(ev, "releasing "+host) |
| + if begin < 0 || streams < begin || held < begin || releasing < streams || releasing < held { |
| + t.Fatalf("%s: streams not ended between BeginMove and the release: %v", host, ev) |
| + } |
| + } |
| +} |
| + |
| // A wake still restoring, or an acquire paused before its PUT, when the |
| // drain starts: nothing moves until the box is quiet. |
| func TestDrainWaitsForQuiescence(t *testing.T) { |
diff --git a/internal/lease/lease.go b/internal/lease/lease.go| index 1c7e7b7c6..389bf4804 100644 |
| --- a/internal/lease/lease.go |
| +++ b/internal/lease/lease.go |
| @@ -494,7 +494,10 @@ type Replicator struct { |
| finalized bool |
| finishTXID uint64 |
| finishErr error |
| - closeErr error |
| + // snapErr is the finalization's snapshot outcome (FinishSnapshot): |
| + // nil for a snapshot written at the final TXID. |
| + snapErr error |
| + closeErr error |
| } |
| // ReplicateWithLease acquires the single-writer lease at |
| @@ -551,7 +554,7 @@ func (r *Replicator) Abandon(ctx context.Context) { |
| // would skip; it ships nothing as long as the caller killed the writer |
| // first, and reclaims the replication goroutines either way. |
| if r.ha { |
| - _, _ = r.finalize(ctx, false) // the one teardown; a later release never syncs |
| + _, _ = r.finalize(ctx, false, false) // the one teardown; a later release never syncs |
| return |
| } |
| _ = r.store.Close(ctx) |
diff --git a/internal/lease/release.go b/internal/lease/release.go| index e50cfcfc6..0ed3af44f 100644 |
| --- a/internal/lease/release.go |
| +++ b/internal/lease/release.go |
| @@ -5,6 +5,7 @@ import ( |
| "context" |
| "errors" |
| "fmt" |
| + "io" |
| "net/http" |
| "time" |
| @@ -12,10 +13,39 @@ import ( |
| awss3 "github.com/aws/aws-sdk-go-v2/service/s3" |
| "github.com/benbjohnson/litestream" |
| lss3 "github.com/benbjohnson/litestream/s3" |
| + "github.com/superfly/ltx" |
| "github.com/carlosframework/platform/internal/hafresh" |
| ) |
| +// snapshotWithin writes the release's snapshot within half of what is left |
| +// of ctx's budget, so a slow one never leaves the store's close (its own |
| +// final sync, which decides the release's clean flag) a spent context. |
| +// |
| +// It is litestream's DB.Snapshot (v0.5.14 db.go) with one difference: it |
| +// owns the snapshot reader and closes it on every outcome. The reader is |
| +// a pipe whose encoder holds the WAL open; DB.Snapshot leaves it open when |
| +// the upload fails without draining it, and the encoder, blocked on the |
| +// pipe, then keeps the WAL descriptor for good (generationClient's |
| +// WriteLTXFile closes it the same way, claimgeneration.go). Skipping |
| +// DB.Snapshot's update of the DB's cached level-9 info is harmless: the |
| +// store closes right after. |
| +func (r *Replicator) snapshotWithin(ctx context.Context) (*ltx.FileInfo, error) { |
| + if d, ok := ctx.Deadline(); ok { |
| + var cancel context.CancelFunc |
| + ctx, cancel = context.WithTimeout(ctx, time.Until(d)/2) |
| + defer cancel() |
| + } |
| + pos, rd, err := r.db.SnapshotReader(ctx) |
| + if err != nil { |
| + return nil, err |
| + } |
| + if c, ok := rd.(io.Closer); ok { |
| + defer c.Close() |
| + } |
| + return r.db.Replica.Client.WriteLTXFile(ctx, litestream.SnapshotLevel, 1, pos.TXID, rd) |
| +} |
| + |
| // releaseWithMarker is the one HA release. lease never deletes an HA lock: |
| // it rewrites it as a release marker, MarkerBody(cur.Generation, m), If-Match |
| // cur's ETag. The caller has stopped the renewer and passes the lease it |
| @@ -150,9 +180,34 @@ func (r *Replicator) MonitorInterval() time.Duration { return r.db.MonitorInterv |
| // (finalize), shared with Close and ReleaseMarker: it runs once, and |
| // later calls return its answer without syncing again. |
| func (r *Replicator) Finish(ctx context.Context) (txid uint64, err error) { |
| - return r.finalize(ctx, true) |
| + return r.finalize(ctx, true, false) |
| } |
| +// FinishSnapshot is Finish for a planned handover's release (the drain, |
| +// region HA §25.4 step 3.3): after the forced full sync has succeeded, |
| +// and before the store's close, it writes a snapshot of the database at |
| +// the final position (litestream's level 9), so the successor's restore |
| +// reads that one file and no L0 tail. Nothing writes the database by |
| +// then (the app is proven stopped), so the snapshot's TXID is the final |
| +// TXID the marker records; snapErr says if it is not. |
| +// |
| +// snapErr is the snapshot's own failure, and changes nothing else: txid |
| +// and err are Finish's, the release is as clean as it would have been |
| +// without it, and the restore replays the L0 files as before. Like Finish |
| +// it is the replicator's one finalization: if a finalization already ran, |
| +// it returns that answer and writes no snapshot (snapErr ErrNoSnapshot). |
| +func (r *Replicator) FinishSnapshot(ctx context.Context) (txid uint64, snapErr, err error) { |
| + txid, err = r.finalize(ctx, true, true) |
| + r.finMu.Lock() |
| + snapErr = r.snapErr |
| + r.finMu.Unlock() |
| + return txid, snapErr, err |
| +} |
| + |
| +// ErrNoSnapshot is FinishSnapshot's snapErr when no snapshot was written: |
| +// the final sync failed, or the finalization had already run without one. |
| +var ErrNoSnapshot = errors.New("lease: no snapshot written at the release") |
| + |
| // errAbandoned is the finalization answer of a replicator Abandon tore |
| // down: no final sync ran, so no marker it writes is clean. |
| var errAbandoned = errors.New("lease: replication abandoned without a final sync") |
| @@ -167,7 +222,7 @@ var finalSyncHook = func() {} |
| // for one already running, so no replica write can follow the marker. |
| // Once it has run, nothing syncs again: later calls, SyncAndWait |
| // included, get its answer or ErrSpent. |
| -func (r *Replicator) finalize(ctx context.Context, sync bool) (uint64, error) { |
| +func (r *Replicator) finalize(ctx context.Context, sync, snapshot bool) (uint64, error) { |
| r.finMu.Lock() |
| defer r.finMu.Unlock() |
| if r.finalized { |
| @@ -179,9 +234,29 @@ func (r *Replicator) finalize(ctx context.Context, sync bool) (uint64, error) { |
| finalSyncHook() |
| syncErr = r.db.SyncAndWait(ctx) |
| } |
| + // The drain's snapshot (FinishSnapshot): only over a final sync that |
| + // succeeded, and before the store's close, which closes the database |
| + // the snapshot reads. Still inside the finalization, so it is never |
| + // after the marker. |
| + var snapTXID uint64 |
| + r.snapErr = ErrNoSnapshot |
| + if snapshot && syncErr == nil { |
| + info, err := r.snapshotWithin(ctx) |
| + switch { |
| + case err != nil: |
| + r.snapErr = fmt.Errorf("lease: snapshot at the release: %w", err) |
| + default: |
| + r.snapErr, snapTXID = nil, uint64(info.MaxTXID) |
| + } |
| + } |
| r.closeErr = r.store.Close(ctx) |
| r.finishTXID = uint64(r.db.Replica.Pos().TXID) |
| r.finishErr = errors.Join(syncErr, r.closeErr, r.rn.Err()) |
| + if r.snapErr == nil && snapTXID != r.finishTXID { |
| + // Harmless for a restore (the snapshot, then the L0 files after |
| + // it), but not the one-file restore this was for. |
| + r.snapErr = fmt.Errorf("lease: snapshot at txid %d, final txid %d", snapTXID, r.finishTXID) |
| + } |
| return r.finishTXID, r.finishErr |
| } |
| @@ -201,7 +276,7 @@ func (r *Replicator) ReleaseMarker(ctx context.Context, m hafresh.Marker) error |
| } |
| r.released = true |
| r.mu.Unlock() |
| - txid, err := r.finalize(ctx, true) |
| + txid, err := r.finalize(ctx, true, false) |
| m = withBase(r.base, m) |
| m.TXID = txid |
| if err != nil { |
| @@ -222,7 +297,7 @@ func (r *Replicator) closeHA(ctx context.Context) error { |
| } |
| r.released = true |
| r.mu.Unlock() |
| - txid, _ := r.finalize(ctx, true) |
| + txid, _ := r.finalize(ctx, true, false) |
| lease := r.rn.stop() |
| relCtx, cancel := context.WithTimeout(context.Background(), 5*time.Second) |
| defer cancel() |
diff --git a/internal/lease/release_snapshot_test.go b/internal/lease/release_snapshot_test.go| new file mode 100644 |
| index 000000000..a0228bc3c |
| --- /dev/null |
| +++ b/internal/lease/release_snapshot_test.go |
| @@ -0,0 +1,265 @@ |
| +package lease_test |
| + |
| +import ( |
| + "context" |
| + "database/sql" |
| + "errors" |
| + "io" |
| + "os" |
| + "path/filepath" |
| + "runtime" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "github.com/benbjohnson/litestream" |
| + lsfile "github.com/benbjohnson/litestream/file" |
| + "github.com/superfly/ltx" |
| + |
| + "github.com/carlosframework/platform/internal/hafresh" |
| + "github.com/carlosframework/platform/internal/lease" |
| + leasetest "github.com/carlosframework/platform/internal/lease/locktest" |
| +) |
| + |
| +// The drain's release leaves a restore of one file (region HA §25.4 step |
| +// 3.3, §25.10): after the final sync and before the marker it writes a |
| +// snapshot at the final position, so the successor restores the snapshot |
| +// and no L0 tail. An idle sleep's release writes none. |
| + |
| +// countingReplica is a replica client that counts the LTX files opened |
| +// (a restore's reads, one GET each on S3) and records the levels written, |
| +// and can refuse snapshot writes. |
| +type countingReplica struct { |
| + litestream.ReplicaClient |
| + mu sync.Mutex |
| + opens int |
| + writes []int |
| + snapshotTXID ltx.TXID |
| + failSnapshot bool |
| + // refuseEarly refuses a snapshot without reading any of it, as an |
| + // upload that fails before it consumes the body. |
| + refuseEarly bool |
| +} |
| + |
| +func (c *countingReplica) OpenLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, offset, size int64) (io.ReadCloser, error) { |
| + c.mu.Lock() |
| + c.opens++ |
| + c.mu.Unlock() |
| + return c.ReplicaClient.OpenLTXFile(ctx, level, minTXID, maxTXID, offset, size) |
| +} |
| + |
| +func (c *countingReplica) WriteLTXFile(ctx context.Context, level int, minTXID, maxTXID ltx.TXID, r io.Reader) (*ltx.FileInfo, error) { |
| + c.mu.Lock() |
| + c.writes = append(c.writes, level) |
| + fail := c.failSnapshot && level == litestream.SnapshotLevel |
| + early := c.refuseEarly && level == litestream.SnapshotLevel |
| + if level == litestream.SnapshotLevel { |
| + c.snapshotTXID = maxTXID |
| + } |
| + c.mu.Unlock() |
| + if early { |
| + return nil, errors.New("the store refused the snapshot at once") |
| + } |
| + if fail { |
| + io.Copy(io.Discard, r) |
| + return nil, errors.New("the store refused the snapshot") |
| + } |
| + return c.ReplicaClient.WriteLTXFile(ctx, level, minTXID, maxTXID, r) |
| +} |
| + |
| +func (c *countingReplica) mark() int { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + return len(c.writes) |
| +} |
| + |
| +func (c *countingReplica) snapshotsSince(n int) int { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + k := 0 |
| + for _, l := range c.writes[n:] { |
| + if l == litestream.SnapshotLevel { |
| + k++ |
| + } |
| + } |
| + return k |
| +} |
| + |
| +func (c *countingReplica) openCount() int { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + return c.opens |
| +} |
| + |
| +// manyL0 replicates a fresh database to dir through rc and makes n small |
| +// transactions, each synced on its own: n L0 files, as a busy host's |
| +// replica has between compactions. |
| +func manyL0(t *testing.T, fx *leasetest.LockFixture, prefix string, rc litestream.ReplicaClient, n int) (*lease.Replicator, string) { |
| + t.Helper() |
| + h := haHeld(t, fx, prefix) |
| + lease.SetReplicaClientForTest(h, rc) |
| + path := tempDB(t) |
| + r, err := h.Replicate(ctx, path, 0) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for i := 0; i < n; i++ { |
| + addRows(t, path, 1) |
| + if err := r.SyncAndWait(ctx); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + return r, path |
| +} |
| + |
| +// restoreCounting restores dir's replica into a new file, counting the |
| +// LTX files it reads. |
| +func restoreCounting(t *testing.T, dir string) (string, int) { |
| + t.Helper() |
| + c := &countingReplica{ReplicaClient: lsfile.NewReplicaClient(dir)} |
| + out := filepath.Join(t.TempDir(), "restored.db") |
| + opt := litestream.NewRestoreOptions() |
| + opt.OutputPath = out |
| + if err := litestream.NewReplicaWithClient(nil, c).Restore(ctx, opt); err != nil { |
| + t.Fatal(err) |
| + } |
| + return out, c.openCount() |
| +} |
| + |
| +func dbRows(t *testing.T, path string) string { |
| + t.Helper() |
| + db, err := sql.Open("sqlite", path) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + defer db.Close() |
| + var n int |
| + var all sql.NullString |
| + if err := db.QueryRow(`SELECT count(*), group_concat(id || ':' || body, ',') FROM (SELECT * FROM t ORDER BY id)`).Scan(&n, &all); err != nil { |
| + t.Fatal(err) |
| + } |
| + return all.String |
| +} |
| + |
| +func TestDrainReleaseSnapshotRestoresFromOneFile(t *testing.T) { |
| + haBox(t) |
| + fx := leasetest.NewLockFixture(t) |
| + dir := t.TempDir() |
| + rc := &countingReplica{ReplicaClient: lsfile.NewReplicaClient(dir)} |
| + r, path := manyL0(t, fx, "instances/h", rc, 200) |
| + before := rc.mark() |
| + txid, snapErr, err := r.FinishSnapshot(ctx) |
| + if err != nil || snapErr != nil || txid == 0 { |
| + t.Fatalf("FinishSnapshot: txid %d, snapshot %v, %v", txid, snapErr, err) |
| + } |
| + if err := r.ReleaseMarker(ctx, hafresh.Marker{V: 1, Clean: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if m := lockView(t, fx, "instances/h").Lock.Release; m == nil || !m.Clean || m.TXID != txid { |
| + t.Fatalf("marker %+v, want clean at %d", m, txid) |
| + } |
| + out, reads := restoreCounting(t, dir) |
| + if reads > 2 { |
| + t.Fatalf("the successor's restore read %d files, want the snapshot alone", reads) |
| + } |
| + if got, want := dbRows(t, out), dbRows(t, path); got != want { |
| + t.Fatalf("restored %q, want %q", got, want) |
| + } |
| + if k := rc.snapshotsSince(before); k != 1 { |
| + t.Fatalf("%d snapshots written by the drain's release, want 1", k) |
| + } |
| + if uint64(rc.snapshotTXID) != txid { |
| + t.Fatalf("snapshot at txid %d, final txid %d", rc.snapshotTXID, txid) |
| + } |
| +} |
| + |
| +// An idle sleep's release (Finish) writes no snapshot. |
| +func TestSleepReleaseWritesNoSnapshot(t *testing.T) { |
| + haBox(t) |
| + fx := leasetest.NewLockFixture(t) |
| + rc := &countingReplica{ReplicaClient: lsfile.NewReplicaClient(t.TempDir())} |
| + r, _ := manyL0(t, fx, "instances/h", rc, 5) |
| + before := rc.mark() |
| + if _, err := r.Finish(ctx); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := r.ReleaseMarker(ctx, hafresh.Marker{V: 1, Clean: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if k := rc.snapshotsSince(before); k != 0 { |
| + t.Fatalf("a sleep's release wrote %d snapshots", k) |
| + } |
| +} |
| + |
| +// A snapshot that fails changes nothing else: the release is clean as |
| +// before, and the restore replays the L0 files. |
| +func TestDrainReleaseSnapshotFailureStaysClean(t *testing.T) { |
| + haBox(t) |
| + fx := leasetest.NewLockFixture(t) |
| + dir := t.TempDir() |
| + rc := &countingReplica{ReplicaClient: lsfile.NewReplicaClient(dir)} |
| + r, path := manyL0(t, fx, "instances/h", rc, 20) |
| + rc.mu.Lock() |
| + rc.failSnapshot = true |
| + rc.mu.Unlock() |
| + txid, snapErr, err := r.FinishSnapshot(ctx) |
| + if err != nil || snapErr == nil || txid == 0 { |
| + t.Fatalf("FinishSnapshot: txid %d, snapshot %v, %v; want the snapshot's failure alone", txid, snapErr, err) |
| + } |
| + if err := r.ReleaseMarker(ctx, hafresh.Marker{V: 1, Clean: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if m := lockView(t, fx, "instances/h").Lock.Release; m == nil || !m.Clean || m.TXID != txid { |
| + t.Fatalf("marker %+v, want clean at %d", m, txid) |
| + } |
| + out, _ := restoreCounting(t, dir) |
| + if got, want := dbRows(t, out), dbRows(t, path); got != want { |
| + t.Fatalf("restored %q, want %q", got, want) |
| + } |
| +} |
| + |
| +// F1.3 (Astra r1): a snapshot refused before any of it is read still |
| +// releases the snapshot encoder and its WAL descriptor; the release is |
| +// clean and the restore correct, as for any failed snapshot. |
| +func TestDrainReleaseSnapshotEarlyRefusalReleasesTheWAL(t *testing.T) { |
| + if runtime.GOOS != "linux" { |
| + t.Skip("reads /proc/self/fd") |
| + } |
| + haBox(t) |
| + fx := leasetest.NewLockFixture(t) |
| + dir := t.TempDir() |
| + rc := &countingReplica{ReplicaClient: lsfile.NewReplicaClient(dir), refuseEarly: true} |
| + r, path := manyL0(t, fx, "instances/h", rc, 5) |
| + txid, snapErr, err := r.FinishSnapshot(ctx) |
| + if err != nil || snapErr == nil { |
| + t.Fatalf("FinishSnapshot: txid %d, snapshot %v, %v; want the snapshot's failure alone", txid, snapErr, err) |
| + } |
| + if err := r.ReleaseMarker(ctx, hafresh.Marker{V: 1, Clean: true}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if m := lockView(t, fx, "instances/h").Lock.Release; m == nil || !m.Clean || m.TXID != txid { |
| + t.Fatalf("marker %+v, want clean at %d", m, txid) |
| + } |
| + wal := path + "-wal" |
| + openWAL := func() bool { |
| + ents, err := os.ReadDir("/proc/self/fd") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + for _, e := range ents { |
| + if target, err := os.Readlink(filepath.Join("/proc/self/fd", e.Name())); err == nil && target == wal { |
| + return true |
| + } |
| + } |
| + return false |
| + } |
| + for deadline := time.Now().Add(2 * time.Second); openWAL(); time.Sleep(10 * time.Millisecond) { |
| + if time.Now().After(deadline) { |
| + t.Fatalf("%s is still open after the release: the snapshot encoder was not released", wal) |
| + } |
| + } |
| + out, _ := restoreCounting(t, dir) |
| + if got, want := dbRows(t, out), dbRows(t, path); got != want { |
| + t.Fatalf("restored %q, want %q", got, want) |
| + } |
| +} |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 76fa3f0c9..a1bc01fc6 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -153,3 +153,4 @@ plan14-root-reads-group-roll-verb.tsv 9668105384b1abd5009d76a73e37eef7f5c358eb5b |
| plan14-root-reads-warm-set-published-724.tsv 158a30344d45448de74c9d6fbcc46eeab1ef76980c17a6baef3bb36e38cac00c |
| plan14-root-reads-gvisor-probe-diag.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee |
| plan14-root-reads-deploy-happy-path.tsv a9ae6b238b6b2e177be1f9c7ae06ea0f24477e4eb0e58abda63f4b7337dbe3ee |
| +plan14-root-reads-held-move-speed.tsv 837f27a6b7b6ed272f8c68aca07650fa32cf3ec92ce28bf9d812a4282eeb0b58 |
diff --git a/internal/provision/testdata/plan14-root-reads-held-move-speed.tsv b/internal/provision/testdata/plan14-root-reads-held-move-speed.tsv| new file mode 100644 |
| index 000000000..fa1de994d |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-held-move-speed.tsv |
| @@ -0,0 +1,17 @@ |
| +# Census overlay held-move-speed, written by census-propose (#369). census-ruling-held-move-speed, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-held-move-speed.md. |
| +# 4 body, 2 sites, 4 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +@legacy e64cf805e37d1f046d902c1b9069cd461361a6a1b304ecbbbeb6ac19cf10ad6e internal/activator/handover.go Service.BeginMove legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: Task 5 driver API; sets in-memory holding for an awake HA entry; refuses on a latched loss; no read. Fix round 1: records the awake entry's route (in memory) as the move's lifetime identity; no read added;rev3=census-ruling-held-move-speed;basis=also clears the host's in-memory moveStreams ending flag for the new move (moveStreams.reset); no read added whole:Route@331,whole:Route@489,whole:Route@498 580cc7aabf4b01e7e473070f48a5b9657e95dcf184e878989cd88a954c82aebf |
| +@legacy b6bc9707a6d29ff49e6027b2bb2c08461667166e4492f914689e8eeaaddef9c6 internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read;rev3=census-ruling-held-move-speed;basis=the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added registry:Account@9994,registry:Alias@25299,registry:Alias@25386,registry:Alias@25966,registry:App@10010,registry:Health@13777,registry:Health@13903,registry:Hibernate@30203,registry:HoldOp@28999,registry:Host@11321,registry:Host@11378,registry:Host@11414,registry:Host@12178,registry:Host@14386,registry:Host@14481,registry:Host@14769,registry:Host@14795,registry:Host@14847,registry:Host@17677,registry:Host@17710,registry:Host@19733,registry:Host@21640,registry:Host@21948,registry:Host@21975,registry:Host@22818,registry:Host@23390,registry:Host@25720,registry:Host@25769,registry:Host@28435,registry:Host@28460,registry:Host@28477,registry:Host@29076,registry:Host@4416,registry:Host@4785,registry:Host@4839,registry:Host@4889,registry:Host@5909,registry:Host@6098,registry:ImportGate@29018,registry:Kind@18069,registry:Kind@18091,registry:Prefix@23365,registry:Socket@12242,registry:Socket@17948,registry:Socket@21956,registry:Status@28975,registry:Status@4710,registry:Target@23377,registry:Tunnel@10025,registry:Tunnel@9833,registry:Version@17800,registry:Version@18050,registry:Version@18152,whole:RegionalDomain@26608,whole:Route@11469,whole:Route@11597,whole:Route@12318,whole:Route@14940,whole:Route@15005,whole:Route@15056,whole:Route@17727,whole:Route@17734,whole:Route@17858,whole:Route@22036,whole:Route@22043,whole:Route@22139,whole:Route@23253,whole:Route@24421,whole:Route@26600,whole:Route@26656,whole:Route@26696,whole:Route@28341,whole:Route@28375,whole:Route@28463,whole:Route@28542,whole:Route@28961,whole:Route@30205,whole:Route@30262,whole:Route@30293,whole:Route@313,whole:Route@3436,whole:Route@3494,whole:Route@4424,whole:Route@5938,whole:Route@6221,whole:Route@6355,whole:Route@6378,whole:Route@6393,whole:Route@7239,whole:Route@7367,whole:Route@9915,whole:RouteAlias@25270,whole:RouteAlias@26664,whole:RoutePath@22796 b8b81c47d3eccbe294c9c3120aa4af8c46c8563a02f2c3e9fee4fb420bafa26e |
| +@legacy 5231d4cda26c5f88a0476a6e5d835394aa289c7b91a2cbb867f8baf59db8b933 internal/host/hadrain.go drainDriver.moveOne legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: one host's move (BeginMove, tickets and in-flight wait, DrainStop, take, SetMoveTaken or SetMoveLeft); reads the in-memory route Host; no read of its own; Task 5 fix 1: after SetMoveTaken, closes the host's edge-held streams on this edge at an event boundary (Edge.CloseHeldHost, memory only); no read added;rev3=census-ruling-held-move-speed;basis=right after BeginMove and before the ticket and in-flight wait, calls Service.EndMoveStreams(host) (cancels the request contexts of the host's SSE responses and upgraded connections) and Edge.CloseHeldHost(host) (memory only); the later CloseHeldHost after SetMoveTaken is kept; no read added registry:Host@135,whole:Route@137 a1a5c445c91224bd1cbe4d61f725b1e8b50c4d39659cb08deab033daa453b157 |
| +@legacy 68d88df2331513f6ce7417597f85076228bc3fb48cc0eec1f11303d02436605a internal/activator/activator.go Service.serve legacy accepted-legacy accepted-legacy;rev3=census-ruling-hotfix281;basis=Startup repeats the existing Kind and Hibernate checks; error logging moved to serveWakeError. A request held through startup re-reads its own route's Socket and Addr and can only refuse (wake-timeout 503) when recovery moved them; agent-side, deny-only, no root decision.;rev3=census-ruling-edge-request-records;basis=passes the member request r to begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance is the activator's; same deploy-safety for binary rows;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: a verified HA hop this box cannot serve gets the holder diagnostic; two new whole:Route sites pass the route to answerForwarded/noteNoHolder; no new kind of read;rev3=census-ruling-region-ha-g2-fixes;basis=Refuse latched HA lease loss before startup wait or proxy accounting, and schedule bounded recovery; reads supplied route, no new external read here.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 2: after begin succeeds, edge.ReleaseMoveTicket(r) ends the request's in-memory admission ticket; on the sidecar path the same after BeginSidecarRequest; no read added;rev3=census-ruling-held-move-speed;basis=after begin succeeds, wraps r with an edge.StreamEnd (a cancellable child context) and tracks it under rt.Host in the in-memory moveStreams until the request ends (+registry:Host: the supplied route's Host as the map key); no new kind of read, no root decision registry:Addr@1131,registry:Addr@1145,registry:Host@1056,registry:Host@1256,registry:Host@4002,registry:Socket@1102,registry:Socket@1118,whole:Route@1081,whole:Route@1190,whole:Route@1324,whole:Route@198,whole:Route@261,whole:Route@2873,whole:Route@2974,whole:Route@298,whole:Route@3788,whole:Route@3851,whole:Route@526 fbdd029dbe4180c6138f2cdfe20428a55c6288d4f8081cc7a4846066f1195b71 |
| +@legacy cfff5550438de4518d4a46ad8db9b5aa8460e7a451f8b6d4fc86f15ae1b4e9b8 internal/activator/harelease.go Service.releaseHAClean legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: an HA entry's release, in order: host slice read empty through haHostEmpty (else errHostSliceUnproven and nothing written; the same check, moved into that helper by final fix F1), stop and join the files publisher, its final publish (2 min budget), the replica's final sync (Finish, 30 s), the local release record, then the release marker PUT (10 s), clean only when the final publish was complete and the sync and record succeeded; a failed PUT is a persisted lease obligation; +registry:Host, +whole:Route x4;rev3=census-ruling-region-ha-p1b3b-t;basis=Record advisory local-release basis only after ReleaseMarker succeeds. Add a whole-route argument to local duty bookkeeping; release order and lease authority unchanged.;rev3=census-ruling-region-ha-g2-fixes;basis=Latch unexpected lease loss before release and mark intentional release so ErrSpent alone is not treated as loss; no new read.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Cap Final, Finish and marker contexts by the shutdown deadline and reserves; keep calls synchronous and stop proof unchanged; record successful marker completion under the service mutex. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: records the written marker's clean flag on the entry (haReleaseClean) beside haReleased, for the drain report; no read added;rev3=census-ruling-held-move-speed;basis=reads the entry's drainRelease flag under a.mu; for the drain's release calls the replica's FinishSnapshot (final sync, then a litestream snapshot at the final position, before the store's close; the snapshot reader pipe is closed on every outcome) instead of Finish, and logs a snapshot failure naming rt.Host (+registry:Host, the supplied route); marker order, budgets and clean rule unchanged; no new read registry:Host@1403,registry:Host@2484,whole:Route@109,whole:Route@1505,whole:Route@1643,whole:Route@2393,whole:Route@267 7d5428b8024aa8f51ee187e08968beeb855f93cfa36c3acf014f279b289a7b35 |
| +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.;rev3=census-ruling-remote-instance-metrics;basis=gains tenancySeq, hostTenants and hostMixed, in-memory fields for Tenancies; no read added;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos: one more field, markers (markerRetry: an atomic running flag and the last log time) for retryOwedMarkers; no read added; merge of origin/main d7ae1d76: main's fields are kept as main has them (census-ruling-remote-instance-metrics: tenancySeq, hostTenants, hostMixed); this branch's change is the same as above;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 7 and 8: new fields for rootfs admission (rootfsArmed, rootfsSwept), the per-host gate ask and refusal memo, and residency state (lister, backoff, start ceiling, cursor, test seam); no read;rev3=census-ruling-rootfs-apps-3-release;basis=rootfs Plan 3 Group R: one new field, releaseOps (host to the in-memory release record, under a.mu); no read;rev3=census-ruling-rootfs-apps-3-workers;basis=rootfs Plan 3 Group W: one new field, leaseNow (a clock seam for a worker start's headroom against the lease deadline, nil is the real clock); no read;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: gains the holder cache and its single-flight state; no read;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (controller ruling after branch review R1, and Paul's R2 ruling): one field, Fleet (activator.FleetWake: the box's fleet state, not on a fleet by default, on a fleet with a known label and a record reader, or on a fleet with an invalid identity), set by the agent before Start and read only by routeCurrentUnderLease. No read in the declaration. Agent, not root.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 7a fix round 1: one field, drainBudget (time.Duration), which New copies from residentDrainBudget and a rootfs entry's lease watch reads in its place, so a test's change of the package var never races a watch goroutine; declaration only, reads nothing; merge of origin/main 6f1f6ca6: main's one field, Fleet (activator.FleetWake), is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above;rev3=census-ruling-region-ha-p1b3a;basis=Add bounded placement peer and diagnostic state and the over-capacity callback; no read in this declaration and no new root authority.;rev3=census-ruling-stateless-replicas-1;basis=Add coordinator, existing-record observation callback and per-host preparation locks; no read in the declaration. Task 3a: Add optional canonical storage-selection and durable deploy-ID callbacks; declaration only, no read or authority in these fields.;rev3=census-ruling-edge-held-streams;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): adds the heldLegs map to actEntry (legs by id, under a.mu) and heldWakeHook (atomic pointer to a callback) and heldLegSeq (atomic counter) to Service. State only, in memory; no read of tenant, app or box-agent-writable input.;rev3=census-ruling-wake-storm-cap;basis=the agent as carlos: one field, wakeSlots (chan struct{}, the wake semaphore made by New from Config.WakeSlots, default 4); declaration only, no read.;rev3=census-ruling-region-ha-p1b3b-t;basis=Add the B2 DutyStore interface field and process-local duty view, suppression and invalidation state. No read added. B2 adds the verified-successor identity callback; no read in the declaration. B3b adds a nonblocking departure-suspicion callback, invoked only after an accepted holder-forward failure and after cache locks release; it cannot authorize a take.;rev3=census-ruling-region-ha-p3a;basis=P3a Task 3: immutable callbacks installed before Start for tenant admission, local start permission, fixed route exemptions and shutdown closure; nil callbacks preserve switch-off behavior; no new reads. Fix R1: add an immutable startup-phase callback for response copy, set before service startup. No new read or execution authority.;rev3=census-ruling-region-ha-g2-fixes;basis=Add in-memory HA loss state and pool withdrawal jobs; no new read.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 1: one new field, drain (drainSources: two atomic func pointers for this box's and peers' drain state); no read added. region HA held-requests Task 2: one new field, moves (moveTable: per-host move state, hold counts and admission tickets in memory, under mu); no read added;rev3=census-ruling-held-move-speed;basis=the agent as carlos: one new field, moveStreams (per-host in-memory set of edge.StreamEnd for requests in flight, own mutex), for the move's early stream cut; actEntry gains drainRelease (bool, under a.mu), set by DrainStop; declarations only, no read added d8e71373ba27185116b52624445629f307bfe57845bd0e88793308378441d4d5 |
| +internal/activator/handover.go Service.BeginMove legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: Task 5 driver API; sets in-memory holding for an awake HA entry; refuses on a latched loss; no read. Fix round 1: records the awake entry's route (in memory) as the move's lifetime identity; no read added;rev3=census-ruling-held-move-speed;basis=also clears the host's in-memory moveStreams ending flag for the new move (moveStreams.reset); no read added whole:Route@331,whole:Route@489,whole:Route@498 580cc7aabf4b01e7e473070f48a5b9657e95dcf184e878989cd88a954c82aebf |
| +internal/edge/edge.go Edge.Reload legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=census-ruling-design-edge-rate-limit-358;basis=each route's upstream entry gains rate: e.parseRateSettings(t), the row's rate_limit column parsed once per reload; the one added site is that whole:Route pass of t (parseRateSettings is a new unit, classified in the decisions overlay); no other read added;rev3=census-ruling-certwarm-wake;basis=the single reload hook call becomes runReloadHooks(), which runs every registered hook in order (#386); no read added, same 57 sites (56 before #358 landed on main);rev3=census-ruling-edge-asset-cache-3;basis=each tenant reverse proxy built in the switch (the tunnel, fleet, socket and TCP arms, every *httputil.ReverseProxy) is installed behind assetScrubbedProxy, which hands the proxy an assetInformationalScrub writer so an app's 1xx (103) loses the asset cache's reserved headers (X-Carlos-Asset-Fill, -Fill-Ack, -Expires, Carlos-Cache) on every local path, as the backhaul already does (final review F6); a type check of the proxy it just built and a wrapper around it; static and status handlers untouched; read sites unchanged (57), offsets moved; no read added;rev3=census-ruling-alias-wake-338;basis=#338 follow-up: after the path fold, a resolved platform alias takes its source's own upstream entry (same proxy, route, hibernating: the existing activator wake, lease and fence), keeping its own prefix map (none for a minted apex) and never inheriting the source's (Astra r2 P1); a refused alias, or one whose source has no entry, is dropped from the map (not served, not Allowed); the attached-hostname fold clears platformAlias;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test (generation proxy, hib, no-activator 404) is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance goes through the activator; binary rows unchanged;rev3=census-ruling-edge-roll-blip;basis=the tcpProxy and multiProxy calls pass e.hold (the per-Edge localHold set once in newEdge): a loopback TCP upstream that refuses is redialled for up to 13 s and a probed route with a local upstream waits for prober readmission instead of answering 502/503 (#434 part B); edge-side dial policy only, no read added, same 52 sites;rev3=census-ruling-regional-domains-447;basis=#447 Task 5: after the alias fold, reads the regional_domains rows (e.reg.ListRegional; an error aborts the reload as every registry read here does) and applies them with foldRegional against the routes slice the same reload read; the added reads are that one registry list and the routes already read;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Tasks 4 and 6: the forward case (fleetProxy toward the binding's FleetBox, throttled refusal); one refusal check before the switch from FleetArmVerdict (sidecar not judged; a non-ready forward row refused; a forward row always judged by FleetServeEligible, any other row only where tunnels are on; an alias of a refused source refused with it); the accountless note; path rows of a forward host not folded; no alias folded onto a refused row; refusedHosts held through every fold. ListFleets and FleetChannelAuth read before the loop (+registry:FleetBox, +registry:Host x7, +whole:Route x3). Serving only; the hub's agent, not root. Review R1 finding 2: the switch reads verdict.Served (FleetArmVerdict) by host; the forward case and the fleet-placed case take their fleet from it (served.Fleet) instead of FleetPlacement(t.Region), and an admitted forward row not Served continues rather than falling through (+registry:Host, -registry:Region); the same rows take the same arms; no read added. Review R2: the switch is on DispatchArm(t, viaFleet, tunnels) (the order moved there unchanged: forward only when in Arm, own Tunnel, fleet, socket, addrs, static, status, else continue), the fleet cases read verdict.Arm (renamed from Served), and the platform-alias fold is foldPlatformAliases with the same take (source entry, own paths, alias marks) and the same refusal log (-registry:Kind x2, -registry:Socket, -registry:Tunnel, +whole:Route: those reads moved into DispatchArm); same rows, same arms, same entries; no read added.;rev3=census-ruling-fleet-routes-followups;basis=the owners map is now e.reg.FleetOwners() instead of ListFleets folded inline: the same fresh-connection ListFleets read and the same name->account map (-registry:Account, -registry:Name, -whole:Fleet x2 move into Registry.FleetOwners); no read added; same error path (abort the reload);rev3=census-ruling-tunnel-websockets;basis=The ArmTunnel arm now records its tenancy (Account, App, Tunnel) copied from the row t that Reload already lists; no new registry query, no file read. Also the reload mutex taken first and held to return, five nil-in-production test hooks, and the sweepUpgrades call after the swap, which reads only the map Reload has just built (spec 7, Tasks 3 and 4).;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 5, rule 3): the two fleet proxy builds pass the row to fleetBoxOf(t) instead of reading t.FleetBox (-registry:FleetBox x2, +whole:Route x2); fleetBoxOf answers FleetLabel as authoritative when set, else FleetBox; an authoritative box has no fallback to another of the fleet's channels (503 errFleetDark instead). The edge in the agent, not root; it routes to fewer channels, never more.;rev3=census-ruling-edge-held-streams;basis=the edge in the agent (carlos-edge.service, user carlos): after the new upstream map is published, closes the held streams of any host the new map no longer holds (absent, not hibernating, route no longer Hibernate). Reads the freshly built in-memory map m and the in-memory held set; no read added beyond the rebuild Reload already does.;rev3=census-ruling-devbox-identity;basis=#486 A: only the devbox edge created by newDevboxEdge (carlos-devbox service user, not root) enables the new proxy hooks. Saves the existing DispatchArm result and reads t.Socket from an already-listed route when that arm is ArmSocket, passing it to configureDevboxProxy for per-request expected-owner validation and visitor-header rewriting. Adds one registry:Socket field site; no new registry query or file open, and ordinary fleet/agent edges leave the hook disabled. Final fix wave: its devbox-only outgoing-header/trailer hooks now also strip case-insensitive underscore/hyphen aliases through stripVisitorHeaders; no new read.;rev3=census-ruling-agent-start-demo-1;basis=Checks demo route eligibility and filters the final folded map using the existing registry listing; no new registry or store query. Merge resolution against origin/main 9bd45488 retains main's devbox proxy hooks (reading the existing route Socket) alongside demo filtering; no additional registry query.;rev3=census-ruling-stateless-replicas-3;basis=Task 3: dispatch admitted stateless set rows through replicaProxy before legacy fleetBoxOf. Read Host and supplied whole Route values from the existing listing to build and filter the set probe inputs after all registry reads and alias folds; synchronize before map publication. Tenancy comes only from FleetArmVerdict. No new external read; no set row reaches legacy fallback, local addresses, provision.Health or hibernation on the hub. Fix round 1 M2: comment and whitespace correction only; read sites and routing behavior unchanged.;rev3=census-ruling-agent-start-demo-2;basis=edge.go:1175-1177 passes an already-listed demo Route to demoProxy; :1358 passes existing Route and RouteAlias slices to demoRefusalNames; :1401 publishes refusal names before upstreams. Adds whole-value uses only, no new registry query; retained names refuse fallback after filtering.;rev3=census-ruling-demo-api-site-route;basis=Build a dedicated demo API proxy from the selected existing socket, TCP or probed console transport in the same atomic route snapshot, before ordinary wrappers. Reads existing route Host twice, Version and two whole Route values for exact operator-configured console eligibility. No additional registry query or external read.;rev3=census-ruling-agent-start-demo-3;basis=Refresh the verified moved snapshot from registry on reload before route-independent serving. Census read-site delta: unchanged (87).;rev3=census-ruling-region-ha-g2-fixes;basis=Derive blocked ingress names from already listed unready/held/import-gated/sidecar and fleet-refused rows; added field reads only.;rev3=census-ruling-edge-page-cache-1;basis=keeps every row this reload already read from the registry (e.pageRoutes, e.pageRoutesRead = routes, true, under reloadMu) for the page reload hook; the +whole:Route sites are that assignment of the same slice; no new read;rev3=census-ruling-held-move-speed;basis=the six tenant reverse proxies' ModifyResponse is now classifyMoveStreams(e.responseModifier(t)): MarkMoveStream first reads the response head (status 101, or Content-Type text/event-stream) and sets a flag on the request's in-memory StreamEnd, then responseModifier runs unchanged (byte-identical to main). The hook never wraps or touches the body, so the trailer scrubs keep the proxy as their one closer (Astra r2 F2.1: the graceful boundary end and its watcher were cut). No read added registry:Account@9994,registry:Alias@25299,registry:Alias@25386,registry:Alias@25966,registry:App@10010,registry:Health@13777,registry:Health@13903,registry:Hibernate@30203,registry:HoldOp@28999,registry:Host@11321,registry:Host@11378,registry:Host@11414,registry:Host@12178,registry:Host@14386,registry:Host@14481,registry:Host@14769,registry:Host@14795,registry:Host@14847,registry:Host@17677,registry:Host@17710,registry:Host@19733,registry:Host@21640,registry:Host@21948,registry:Host@21975,registry:Host@22818,registry:Host@23390,registry:Host@25720,registry:Host@25769,registry:Host@28435,registry:Host@28460,registry:Host@28477,registry:Host@29076,registry:Host@4416,registry:Host@4785,registry:Host@4839,registry:Host@4889,registry:Host@5909,registry:Host@6098,registry:ImportGate@29018,registry:Kind@18069,registry:Kind@18091,registry:Prefix@23365,registry:Socket@12242,registry:Socket@17948,registry:Socket@21956,registry:Status@28975,registry:Status@4710,registry:Target@23377,registry:Tunnel@10025,registry:Tunnel@9833,registry:Version@17800,registry:Version@18050,registry:Version@18152,whole:RegionalDomain@26608,whole:Route@11469,whole:Route@11597,whole:Route@12318,whole:Route@14940,whole:Route@15005,whole:Route@15056,whole:Route@17727,whole:Route@17734,whole:Route@17858,whole:Route@22036,whole:Route@22043,whole:Route@22139,whole:Route@23253,whole:Route@24421,whole:Route@26600,whole:Route@26656,whole:Route@26696,whole:Route@28341,whole:Route@28375,whole:Route@28463,whole:Route@28542,whole:Route@28961,whole:Route@30205,whole:Route@30262,whole:Route@30293,whole:Route@313,whole:Route@3436,whole:Route@3494,whole:Route@4424,whole:Route@5938,whole:Route@6221,whole:Route@6355,whole:Route@6378,whole:Route@6393,whole:Route@7239,whole:Route@7367,whole:Route@9915,whole:RouteAlias@25270,whole:RouteAlias@26664,whole:RoutePath@22796 b8b81c47d3eccbe294c9c3120aa4af8c46c8563a02f2c3e9fee4fb420bafa26e |
| +internal/host/hadrain.go drainDriver.moveOne legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-held-build;basis=new: one host's move (BeginMove, tickets and in-flight wait, DrainStop, take, SetMoveTaken or SetMoveLeft); reads the in-memory route Host; no read of its own; Task 5 fix 1: after SetMoveTaken, closes the host's edge-held streams on this edge at an event boundary (Edge.CloseHeldHost, memory only); no read added;rev3=census-ruling-held-move-speed;basis=right after BeginMove and before the ticket and in-flight wait, calls Service.EndMoveStreams(host) (cancels the request contexts of the host's SSE responses and upgraded connections) and Edge.CloseHeldHost(host) (memory only); the later CloseHeldHost after SetMoveTaken is kept; no read added registry:Host@135,whole:Route@137 a1a5c445c91224bd1cbe4d61f725b1e8b50c4d39659cb08deab033daa453b157 |
| +internal/activator/activator.go Service.serve legacy accepted-legacy accepted-legacy;rev3=census-ruling-hotfix281;basis=Startup repeats the existing Kind and Hibernate checks; error logging moved to serveWakeError. A request held through startup re-reads its own route's Socket and Addr and can only refuse (wake-timeout 503) when recovery moved them; agent-side, deny-only, no root decision.;rev3=census-ruling-edge-request-records;basis=passes the member request r to begin's new req parameter; no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Task 5: the activator-managed test is Route.ActivatorOwned instead of Kind and Hibernate inline, so a resident rootfs instance is the activator's; same deploy-safety for binary rows;rev3=census-ruling-region-ha-p1b2;basis=region HA P1b-2: a verified HA hop this box cannot serve gets the holder diagnostic; two new whole:Route sites pass the route to answerForwarded/noteNoHolder; no new kind of read;rev3=census-ruling-region-ha-g2-fixes;basis=Refuse latched HA lease loss before startup wait or proxy accounting, and schedule bounded recovery; reads supplied route, no new external read here.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 2: after begin succeeds, edge.ReleaseMoveTicket(r) ends the request's in-memory admission ticket; on the sidecar path the same after BeginSidecarRequest; no read added;rev3=census-ruling-held-move-speed;basis=after begin succeeds, wraps r with an edge.StreamEnd (a cancellable child context) and tracks it under rt.Host in the in-memory moveStreams until the request ends (+registry:Host: the supplied route's Host as the map key); no new kind of read, no root decision registry:Addr@1131,registry:Addr@1145,registry:Host@1056,registry:Host@1256,registry:Host@4002,registry:Socket@1102,registry:Socket@1118,whole:Route@1081,whole:Route@1190,whole:Route@1324,whole:Route@198,whole:Route@261,whole:Route@2873,whole:Route@2974,whole:Route@298,whole:Route@3788,whole:Route@3851,whole:Route@526 fbdd029dbe4180c6138f2cdfe20428a55c6288d4f8081cc7a4846066f1195b71 |
| +internal/activator/harelease.go Service.releaseHAClean legacy accepted-legacy accepted-legacy;rev3=census-ruling-region-ha-p1a;basis=new: an HA entry's release, in order: host slice read empty through haHostEmpty (else errHostSliceUnproven and nothing written; the same check, moved into that helper by final fix F1), stop and join the files publisher, its final publish (2 min budget), the replica's final sync (Finish, 30 s), the local release record, then the release marker PUT (10 s), clean only when the final publish was complete and the sync and record succeeded; a failed PUT is a persisted lease obligation; +registry:Host, +whole:Route x4;rev3=census-ruling-region-ha-p1b3b-t;basis=Record advisory local-release basis only after ReleaseMarker succeeds. Add a whole-route argument to local duty bookkeeping; release order and lease authority unchanged.;rev3=census-ruling-region-ha-g2-fixes;basis=Latch unexpected lease loss before release and mark intentional release so ErrSpent alone is not treated as loss; no new read.;rev3=census-ruling-region-ha-graceful-terminate-t2;basis=Cap Final, Finish and marker contexts by the shutdown deadline and reserves; keep calls synchronous and stop proof unchanged; record successful marker completion under the service mutex. No read added.;rev3=census-ruling-region-ha-held-build;basis=region HA held-requests Task 5: records the written marker's clean flag on the entry (haReleaseClean) beside haReleased, for the drain report; no read added;rev3=census-ruling-held-move-speed;basis=reads the entry's drainRelease flag under a.mu; for the drain's release calls the replica's FinishSnapshot (final sync, then a litestream snapshot at the final position, before the store's close; the snapshot reader pipe is closed on every outcome) instead of Finish, and logs a snapshot failure naming rt.Host (+registry:Host, the supplied route); marker order, budgets and clean rule unchanged; no new read registry:Host@1403,registry:Host@2484,whole:Route@109,whole:Route@1505,whole:Route@1643,whole:Route@2393,whole:Route@267 7d5428b8024aa8f51ee187e08968beeb855f93cfa36c3acf014f279b289a7b35 |
| +@coverage internal/activator 240cfdb600a2be7dbf800a0fe314b6801753c3dbb8c95d7c2f3c0c71b5a47874 |
| +@coverage internal/edge 2217fef2829b89a20184acbbae8917bc96a326c79d02a7b09c55aab9a646ac75 |
| +@coverage internal/host a8b23e24d310df47799c85debbfd2f6a451f67a54bc27f3730ad27ede439ad8e |
| +@coverage internal/lease 0709201b86e84adc5d7a7072a533bdefe7f231e09c665a27a7cdeff77063ddb2 |