host, provision: share one record listing across a pass's legs (#964)
Each record walk on a fleet box lists the account's whole apps/ tree over the store door (about 2.3 s on dev r10r, 11 s on Tito production), and a first pass made about five such listings. One listing is now shared by the legs of a pass whose fresh-read rules allow it (the offline view at arming, the boot pass's reconcile, the runs boot pass, the instance and sidecar scans); the moves pass, snapshot rewalks and removal rewalks keep their own. Record bodies are still read fresh. The boot listing is reused only if the first tick seeds the same serial it saw, so a change during the boot walk is not hidden. First pass 5 listings to 2, steady state 3 to 2; requests per box per day go down for every account size (plan's budget table, counting test). Release manager chose this over the parked adaptive walk. Astra and Fable reviewed; census approved on #280. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Prompts: <task-notification> <task-id>bvidsbb3g</task-id> <tool-use-id>toolu_01E4NAHmsEUvnzatfLQiHeeD</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/68be7e6f-7841-4936-9fa0-2041da778685/tasks/bvidsbb3g.output</output-file> <status>completed</status> <summary>Background command "sleep 30; until s=$(amadan ci status carlos/platform -branch fleet-door-record-walk 2>&1 | head -1); echo "$s" | grep -q 2e35066 && ! echo "$s" | grep -q "queued\|running"; do sleep 30; done; echo "$s"" completed (exit code 0)</summary> </task-notification> Squashed from fleet-shared-walk into main.
30 files changed,
+1,562
−67
docs/superpowers/notes/census-proposal-fleet-first-reconcile-speed-5.md+35 −0docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md+194 −0internal/host/agent.go+12 −4internal/host/fastboot.go+21 −11internal/host/fastboot_test.go+8 −6internal/host/group_names_test.go+7 −2internal/host/haingress_test.go+5 −2internal/host/lifetime_gating_test.go+1 −1internal/host/movesoffline.go+10 −2internal/host/movesoffline_seal_test.go+1 −1internal/host/movesoffline_stage_test.go+1 −1internal/host/movesoffline_test.go+3 −3internal/host/runs.go+3 −1internal/host/startupmeasure_e2e_test.go+1 −1internal/host/walkshare.go+142 −0internal/host/walkshare_e2e_test.go+472 −0internal/host/walkshare_test.go+107 −0internal/provision/fleet_first_reconcile_speed_5_census_test.go+49 −0internal/provision/haingress.go+1 −1internal/provision/lifetime_judge.go+24 −7internal/provision/lifetime_judge_test.go+1 −1internal/provision/plan9_b8_census_test.go+1 −1internal/provision/reconcile.go+25 −15internal/provision/reconcile_test.go+1 −1internal/provision/sidecar_reconcile.go+9 −6internal/provision/testdata/plan14-root-reads-chain.tsv+1 −0internal/provision/testdata/plan14-root-reads-fleet-first-reconcile-speed-5.tsv+22 −0internal/provision/walkshare.go+143 −0internal/provision/walkshare_test.go+261 −0scripts/gitleaks-gate/notscanned.go+1 −0
CI cancelled — superseded by a newer push — run details
CI log
=== gate === go: downloading go1.26.10 (linux/arm64) go version go1.26.10 linux/arm64 opentofu: arm64, tofu 1.13.9, aws 6.73.0, archive 2.8.1 tofu: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/tofu_1.13.9_linux_arm64.tar.gz tofu: downloaded, digest verified aws: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-aws_6.73.0_linux_arm64.zip aws: downloaded, digest verified archive: downloading https://carlos-ci-mirror-640012953448.s3.eu-west-1.amazonaws.com/opentofu/terraform-provider-archive_2.8.1_linux_arm64.zip archive: downloaded, digest verified installed in /tmp/carlos-opentofu-428M9h .amadan/test-gate.sh go: downloading github.com/aws/aws-sdk-go-v2 v1.44.0 go: downloading github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.68.0 go: downloading github.com/aws/aws-sdk-go-v2/service/costexplorer v1.67.5 go: downloading github.com/aws/aws-sdk-go-v2/service/s3 v1.105.0 go: downloading github.com/aws/smithy-go v1.28.1 go: downloading golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e go: downloading golang.org/x/net v0.62.0 go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/aws/aws-sdk-go-v2/service/sns v1.43.0 go: downloading golang.org/x/crypto v0.58.0 go: downloading github.com/aws/aws-sdk-go-v2/service/acm v1.45.0 go: downloading github.com/aws/aws-sdk-go-v2/service/ec2 v1.324.0 go: downloading github.com/aws/aws-sdk-go-v2/service/iam v1.58.2 go: downloading github.com/aws/aws-sdk-go-v2/service/resourcegroupstaggingapi v1.37.0 go: downloading github.com/aws/aws-sdk-go-v2/service/route53 v1.64.1 go: downloading golang.org/x/sys v0.49.0 go: downloading golang.org/x/mod v0.41.0 go: downloading github.com/pierrec/lz4/v4 v4.1.22 go: downloading github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.20.18 go: downloading github.com/beorn7/perks v1.0.1 go: downloading github.com/cespare/xxhash/v2 v2.3.0 go: downloading github.com/prometheus/client_model v0.5.0 go: downloading github.com/prometheus/common v0.45.0 go: downloading github.com/prometheus/procfs v0.12.0 go: downloading google.golang.org/protobuf v1.36.10 go: downloading github.com/pion/dtls/v3 v3.1.4 go: downloading github.com/klauspost/compress v1.20.2 go: downloading github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 go: downloading github.com/wlynxg/anet v0.0.5 go: downloading golang.org/x/text v0.43.0 go: downloading modernc.org/sqlite v1.55.0 go: downloading github.com/klauspost/compress v1.20.2 go: downloading github.com/aws/aws-sdk-go-v2/service/ecs v1.91.0 go: downloading github.com/pierrec/lz4/v4 v4.1.22 go: downloading modernc.org/libc v1.74.1 go: downloading modernc.org/libc v1.74.1 go: downloading modernc.org/memory v1.11.0 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading modernc.org/mathutil v1.7.1 go: downloading github.com/google/uuid v1.6.0 go: downloading github.com/dustin/go-humanize v1.0.1 go: downloading github.com/google/uuid v1.6.0 go: downloading modernc.org/mathutil v1.7.1 go: downloading github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec amadan: job cancelled — a newer push superseded it
diff --git a/docs/superpowers/notes/census-proposal-fleet-first-reconcile-speed-5.md b/docs/superpowers/notes/census-proposal-fleet-first-reconcile-speed-5.md| new file mode 100644 |
| index 000000000..517b765f8 |
| --- /dev/null |
| +++ b/docs/superpowers/notes/census-proposal-fleet-first-reconcile-speed-5.md |
| @@ -0,0 +1,35 @@ |
| +# Census approval: fleet-first-reconcile-speed-5 |
| + |
| +Ruling `census-ruling-fleet-first-reconcile-speed-5`. The independent reviewer approves or rejects every change below, 3 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26). |
| + |
| +| unit | change | read sites | what changed | |
| +|---|---|---|---| |
| +| `internal/host/agent.go` `fastConvergeLoop` | body | unchanged (1) | Shared record walk (fleet first reconcile Task 5): the first-tick closure handed to fastBoot.start now takes the context start gives it (the arming context carrying the boot walk) and runs the first tick under it. Same calls, same store wrappers, no read added; read sites unchanged (1). Agent, not root. | |
| +| `internal/host/agent.go` `fastTick` | body | unchanged (1) | Shared record walk (Task 5, review round 1 fix): where the first good serial read seeds lastSerial, confirmBootWalk(ctx, doc.Serial) marks the boot walk takeable only if the serial read before the boot walk read and equals the seed; otherwise the first hold lists for itself. In-memory flag only; no read or write added; read sites unchanged (1). Agent, not root. | |
| +| `internal/host/fastboot.go` `fastBoot.seed` | body | unchanged (1) | Shared record walk (Task 5): takes the boot context beside ctx and runs the runs boot pass under it, so that pass lists records through the boot walk's share; every other seed keeps ctx. Same calls and keys; no read added. Agent, not root. | |
| +| `internal/host/fastboot.go` `fastBoot.start` | body | unchanged (1) | Shared record walk (Task 5): makes the boot context (withBootWalk(ctx, b.viewStore): an in-memory WalkShare, the reconcile epoch and, review round 1 fix, one release.ReadSerial of the deployment serial read before the offline view's walk, kept to compare with the first tick's seed) and hands it to the offline view, the seeds goroutine (for the runs boot pass only) and the first tick. Same calls in the same order plus that one serial GET per boot; nothing is decided from it but whether the first hold may reuse the boot listing. Agent, not root. | |
| +| `internal/provision/reconcile.go` `Reconcile` | body | unchanged (236) | Shared record walk (Task 5): the pass's own instance scan over the live store calls scanInstanceRecords with cfg.liveWalk(s) (the pass's WalkShare, nil over a record view snapshot); the snapshot pass's live re-walk passes nil and lists the bucket itself. The share answers only the account set and the apps/ key listing; every record body and slot is still read by the scan. Read sites unchanged (236); fewer listings, no read added. Agent, not root. | |
| +| `internal/provision/sidecar_reconcile.go` `ReconcileSidecars` | body | unchanged (47) | Shared record walk (Task 5): the scan closure takes a WalkShare and lists accounts and the apps/ keys through it (knownAccounts and listAppSubtree when nil); the pass's own scan over the live store passes cfg.liveWalk(s), the snapshot re-walk over freshStore passes nil and lists the bucket itself. Every record body is still read by the scan. Read sites unchanged (47); no read added. Agent, not root. | |
| + |
| +Envelopes re-pinned: `internal/host`, `internal/provision`. |
| + |
| +Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner. |
| + |
| +Recorded dispositions, which each change must still satisfy: |
| + |
| +- `internal/host/agent.go` `fastConvergeLoop`: authority, task B3. Basis: rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): every pass context carries the box's lifetime judge (provision.WithLifetimes) and the reconcile config is boxProvisionConfig's; read sites unchanged, offsets moved; B3 authority retained;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 12: its pass config is now BoxProvisionConfig(reg, os.Getenv, judge, configure) (BoxProvisionConfig replaces boxProvisionConfig: the hub predicate hubArmed and, on the hub, ReconcileConfig.FleetOwners from hubFleetOwners); a call, no read site; read sites unchanged (2); B3 authority retained.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: wire the coordinator's nonblocking SignalTick to the existing fast tick. No new timer, polling read or authority.;rev3=census-ruling-region-ha-p3b;basis=Bind systemLeg to the existing cached reader fold and handle a nil leg on groups; names-2 rollback gate runs before artifact/request/marker work. Agent-memory evidence only, no new direct or cloud read and no autonomous group update.;rev3=census-ruling-restart-new-box-gap;basis=restart leg closure moved into armRestartLegs (same reg.List + restartRequestLeg); also wires restartGain; read moved, not added;rev3=census-ruling-agent-start-demo-3;basis=Attach the moved reader to the existing shared change watch and advertise that reader as armed. Census read-site delta: unchanged (2).;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only (fleet first reconcile Task 1). Logs its entry offset and one line per arming step, then times the first tick. restartSeed, sidecarWakeSeed, refreshMovesHolds, refreshOfflineView and the one arming systemLeg.observe now read through countStore(store), a pass-through wrapper that counts and times each call and forwards it unchanged with the same key; for that observe, systemLeg.store is swapped to the wrapper and restored. For the first tick only, d.store is a fresh countStore(store) wrapper and d.startup a step logger; both are reset to the plain store and nil after the tick. passLegs gets startup. Same calls in the same order, no read added; read sites unchanged (1). Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=Arming order only (fleet first reconcile Task 4). The moves hold view, the offline view, the restart seed, the sidecar wake seed, the runs boot pass, the arming schedule converge and the arming systemLeg.observe are no longer called here: fastBoot.start runs them (views on this goroutine, then the first tick at once with the seeds beside it). The restart legs, the sidecar wake leg closure (same reg.List + sidecarWakeLeg) and newSystemLeg are built here as before and handed to fastBoot, which gives them to fastDeps once the seeds return, before the second tick. The first tick no longer waits for a tick's sleep. Same calls with the same arguments and keys; no read added; read sites unchanged (1). Agent, not root.;rev3=census-ruling-managed-fleets-2b2;basis=sets fastDeps.managedReady from the armed managedJoin (nil on BYO): the joining ready leg, a store-door GET of fleets/<fleet>/boxes/<label>/ready.json and a local root-door relay; requests a full pass on root's 200; no new read in this unit; merge of origin/main 65951fbb: main's fleet first reconcile speed (startup timing lines, countStore, arming moved into fastBoot), not this branch |
| +- `internal/host/agent.go` `fastTick`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved;rev3=census-ruling-stateless-replicas-1;basis=Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. Final review I3: signal the owned renewal worker instead of waiting for its sequential console HTTP calls. Existing convergence and record read unchanged.;rev3=census-ruling-region-ha-p3a;basis=Run the optional desired-role reader on the existing tick after observing the armed change index; no new root path or timer, nil reader is unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: signals the owned replica worker on the existing tick; coalesced asynchronous execution, no timer or bucket scan added. merge of origin/main 7920cccf: Retain main box-role reader pass on the existing tick alongside the replica worker signal; merge-only body change, unchanged read sites.;rev3=census-ruling-restart-new-box-gap;basis=calls the optional restartGain hook (restartGainSeed) once per existing tick before the serial read; no new root path, timer or read kind; nil hook is unchanged;rev3=census-ruling-agent-start-demo-3;basis=Refresh moved notices through the shared watch before normal convergence; no new per-box poll. Census read-site delta: unchanged (1).;rev3=census-ruling-stateless-replicas-4-task1;basis=Signals the owned replica swap worker (armedReplicaDeploy.tick) beside the placement worker on the existing tick; coalesced background pass, no timer, no bucket read. Its transitions go through the console's authenticated /deploy.;rev3=census-ruling-platform-mail-submission;basis=Task 4: on a serial move, after the schedule leg, starts the armed mail switch cache's Refresh on its own goroutine (each read bounded at 2 s, overlapping refreshes skipped). It re-reads the app sender records already cached, through the agent's deploy store. Agent, not root; the tick waits on nothing new. Fable final P2-1: on a serial move, before the pass set and the restart leg, calls the armed cache's MarkStale (a counter bump under the cache's mutex; no I/O), so a spawn the move causes reads the switch again, bounded, instead of using an answer from before the move. No read added.;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only: d.startup.done(<part>) calls between the existing parts and a deferred one after the sweep. d.startup is nil on every tick but the first after agent start, and its methods are then no-ops. No read added, no order change; read site unchanged (1). Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=Startup serial hold (whole-branch review P1). While fastDeps.serialAfter is open (fastBoot closes it when the restart and sidecar wake baselines have read) the tick skips its one ReadSerial of control/serial, so it neither seeds nor acts on a move; the rest of the tick (backstop full pass, index, sweep) is unchanged. A full pass run while held sets fullBeforeSeed, and the seed then sets fullDue once so the backstop branch runs one more full pass under the clamp. Same read, read sites unchanged (1); no read added. Agent, not root.;rev3=census-ruling-managed-fleets-2b2;basis=calls d.managedReady after the serial read on every tick (nil on BYO, returns at once once admitted); no read of its own added; merge of origin/main 65951fbb: main's replica swap worker tick, mail switch refresh, startup timing and startup serial hold (serialHeld skips the ReadSerial), not this branch; resolution: d.managedReady still runs on every tick after the serial step, with serialOK false on a held tick (no serial was read), so only the leg's backstop applies then |
| +- `internal/host/fastboot.go` `fastBoot.seed`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=New (Task 4): the seeds moved out of fastConvergeLoop, same order. restartSeed is called directly (its own reg.List, then restartBaseline, as fastConvergeLoop called it before), sidecarWakeBaseline over the arming route snapshot (or the existing list-error line), then it closes the serial hold, waits for the views, and runs runRunsBootPass, sd.converge and systemLeg.observe (systemLeg.store swapped to the counting wrapper and restored), the last three through package func vars defaulting to them. A nil test hook (bootBeforeBaseline) precedes each baseline. Same calls and keys as before; no read added. Agent, not root. |
| +- `internal/host/fastboot.go` `fastBoot.start`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=New (Task 4): the arming order moved out of fastConvergeLoop. One reg.List of this box's registry (the route snapshot for the sidecar baseline), starts the seeds goroutine first, then refreshMovesHolds and refreshOfflineView (through package func vars defaulting to them), sets fastDeps.serialAfter, runs the first tick, and returns ready, which waits for the seeds (one log line if over slowLegAfter), runs runRunsPass once (through bootRunsNotes; the same runs pass every full pass runs, for notes the first tick kept while the runs boot pass was unfinished), clears the serial hold and assigns the seeded legs to fastDeps. No read beyond those the moved calls and that existing runs pass already make. Agent, not root. |
| +- `internal/provision/reconcile.go` `Reconcile`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 4, rules 2 and 9): after inScope, a record failing cfg.ownsRecord (on a fleet box, labelled for another box: rec.FleetBox != "" and != cfg.FleetBox) is skipped as out of scope, so it is never minted here; in the removal phase such a record no longer keeps the row (inScope && ownsRecord), so the row goes as record gone. Off a fleet ownsRecord is always true. Read sites unchanged (178). The agent's reconcile loops, not root; it mints less, never more.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call; merge of origin/main 6f1f6ca6: main's fleet-box ownsRecord skip in the record scan and in the removal phase is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (178);rev3=census-ruling-stateless-replicas-1;basis=Task 3b: call the optional binding callback only for applied, owned stateless rows outside dry run. Reuses this pass record and route reads after existing collision, scope, hold, policy and shape checks; no new record read or typed writer. Fix 3b round 1 I1: binding callback failure is logged and falls through to pr.applied; same per-host callback, record writers, scope and removal gates. TestStatelessBindingFailureContinuesReconcile covers second-record convergence, removal, applied bookkeeping and next-pass retry.;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: collect validated instance records from the existing scan before pool filtering; report source completeness separately. Record reads, writes, scope and removal authority unchanged.;rev3=census-ruling-agent-start-demo-1;basis=Keeps local demo rows for signed cleanup instead of deleting the binding on record absence or trash; normal/hub paths unchanged. Merge integration against origin/main 9bd45488 retains main's HA departure inventory scan and family-completeness reporting alongside the early local-demo retention guard; existing record reads retained.;rev3=census-ruling-stateless-replicas-2;basis=Final fix I1: legacy records now reach the legacy ownership/removal judgement for former set rows; a greater local incarnation remains protected. Current set-record lifetime and membership checks remain. Same record/registry reads and removal writers. TestReplicaReconcileLegacySuccessor covers both boxes with and without the judge; P11 newer/unknown set protections remain covered. merge of origin/main 6be08467: Retain main signed demo retirement ownership alongside replica set retirement and legacy successor recovery; merge-only body change, unchanged read sources.;rev3=census-ruling-agent-start-demo-3;basis=Install durable source claim holds and reconcile fresh destination seed gates; preserve owned pending routes and stop orphan seeds before cleanup. Census read-site delta: +registry:Account, +registry:App, +registry:Host, +registry:ImportGate ×2, +registry:SeedSource ×2, +whole:Route ×4.;rev3=census-ruling-region-ha-g2-fixes;basis=Run guarded pool withdrawal, extract the unchanged judged collection rules into scanInstanceRecords, and publish pre-pool HA ingress including stale refusal names. Existing direct route reads remain; indirect withdrawal reads and deletion are separately claimed.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: where a forward row holds an in-scope record's host, a link-placed one (registry.LinkPlacement over the listed row's Region) gets its own log line saying no pass here retires it; the record is still not applied, as before; one +registry:Region read of the listed row, no write added;rev3=census-ruling-stateless-replicas-4-drill1;basis=#511 drill 1 F4: for a stateless row with a copy assignment (record or row), the binding callback gets the row as convergeOwned left it: one local registry Get of the same host after the pass's own writes; a row that cannot be read is logged (round 1, Fable M7) and bound next pass; no record read or write added;rev3=census-ruling-fleet-seeded-create-1;basis=In the per-record seed dispatch (the seedFinishAbort case), Reconcile asks abortRetiresRow(rec) (seedreconcile.go) instead of comparing rec.Seed.Kind to seeds.KindReplica, so an aborted file seed goes through the same row retirement and marker-decided purge as an aborted --from seed; the kind check only, no new read or write, registry read sites unchanged; the agent as carlos, not root; it retires a row it would already retire for a replica seed.;rev3=census-ruling-managed-fleets-2b2;basis=returns nil before any list, mint or removal while ReconcileConfig.Joining answers true (a joining managed box); ownsRecord also refuses every record then; no read added; merge of origin/main 65951fbb: main's link-placed forward log line (+registry:Region), drill 1 F4 row re-read for the stateless binding and abortRetiresRow seed dispatch, not this branch; code-health split: the joining guard, withdrawPools, the demo claim holds and the Now default moved, in order, to ReconcileConfig.passStart, no read added |
| +- `internal/provision/sidecar_reconcile.go` `ReconcileSidecars`: legacy, task accepted-legacy. Basis: accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=the record walk and its sidecars manifest lookup move unchanged into the pass's scan closure (over a store argument) and the removal phase into its retire closure; over a record view snapshot, a pass that reaches a removal candidate (a sidecar gone or no longer placeable here) removes nothing on the snapshot's word: it runs scan again over the bucket (freshStore) and decides every removal that pass from that walk, by the walk's own rules (unusable records protected before scope, hosts matched across every key, placement from the bucket's record and sidecars manifest against this box's inbound); a walk that cannot read cleanly keeps every row; with no candidate, or disarmed, nothing is read again; the registry sites are main's, moved; relative to main's single walk a removal can only be withheld, never added;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: retain validated sidecar records before scope/manifest filtering for coverage, including hidden/out-of-pool records. No new object reads or sidecar HA authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Derive canonical sidecar lifetimes from account/app/synthetic host/CreatedAt; collect HA and manifest placement for departures before scope filtering; update a separate family in the existing lifetime index. Existing record reads, key parsing and removal authority remain.;rev3=census-ruling-region-ha-g2-fixes;basis=Run sidecar-scoped pool withdrawal before the existing pass; existing direct reads unchanged, new indirect stop/record/deletion checks are in withdrawal helpers.;rev3=census-ruling-managed-fleets-2b2;basis=returns nil before any list, mint or removal while ReconcileConfig.Joining answers true; no read added |
| + |
| +New dispositions, which census-propose wrote and the reviewer checks against the unit's reads and the diff: |
| + |
| +- new `internal/host/agent.go:reconcileSerializedAuth`: reads +file:Walk ×2; written legacy, accepted-legacy, frozen |
| +- new `internal/provision/reconcile.go:type ReconcileConfig`: reads +file:Walk; written legacy, accepted-legacy, frozen |
| +- new `internal/provision/walkshare.go:ReconcileConfig.liveWalk`: reads +file:Walk; written legacy, accepted-legacy, frozen |
| + |
| +Seal: `022a082b517b59ada965bbd7673e941be7c8bb4ae7547a5632f6be0570c97551` → `dbdeb2e3a1a89cb8f33584fdb80a3bf1c5adef14ce222fef9d442ed8e059699c`. |
| + |
| +Overlay: `internal/provision/testdata/plan14-root-reads-fleet-first-reconcile-speed-5.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`. |
diff --git a/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md b/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md| index 281471be1..62f33f8de 100644 |
| --- a/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md |
| +++ b/docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md |
| @@ -204,3 +204,197 @@ what that pass needs, not after every seed and a tick's sleep. |
| (Task 1's "duties: wait for the activator startup" line). The latch is a |
| safety order (sweep before wakes and before reconcile acts on seeded |
| records); any change gets its own task and review. |
| + |
| +### Task 3 request budget |
| + |
| +Steady state on a fleet box, nothing changing. A fleet box has no change |
| +index, so its record walks ride the existing instances loop (every 5 to 6 |
| +minutes, mean 5.5: about 262 passes a day). Each pass walks the records |
| +three times: reconcile at `instances/`, the sidecar pass at `sidecars/`, the |
| +moves pass at `instances/`. That is about 785 walks a day, the same before |
| +and after; no timer is added. Each walk also lists `accounts/` and reads |
| +every record (two GETs per record); both are unchanged and left out below. |
| + |
| +Per walk at the hub: the whole-tree listing costs W = ceil(N/1000) S3 LIST |
| +requests (N = objects under the account's `apps/<sqid>/`) and 1 door |
| +request. The per-app walk costs P = ceil((F + A)/1000) for the delimiter |
| +listing of `apps/<sqid>/` (S3 pages it over the F objects directly under |
| +it and the A app directories together), plus, per app, ceil(K/1000) for |
| +its K keys at the sub (one page for none), and 1 + A door requests. Both |
| +are priced exactly from the last whole-tree key set the box received. |
| +The walk takes per app only when P < W. It lists the whole tree when it |
| +has no memory (no memory file, an unusable one, or a root process) and |
| +every 12th walk. So with nothing changing a 12-walk cycle costs W + 11P |
| +if P < W, else 12W: never more than 12W. |
| + |
| +| account | N, A | W, P | S3 LISTs a day before | after | door requests a day before | after | |
| +|---|---|---|---|---|---|---| |
| +| small | 500, 2 | 1, 3 | 785 | 785 | 785 | 785 | |
| +| mid | 5,000, 20 | 5, 21 | 3,925 | 3,925 | 785 | 785 | |
| +| big (r10r estimate) | ~40,000, ~5 | ~40, 6 | ~31,400 | ~6,940 | 785 | ~4,380 | |
| + |
| +The r10r row is an estimate from timing (dev v0.37.0 startup lines): one |
| +whole `apps/` listing through the door took 3.8 to 4.6 s against about |
| +20 ms on a small account, which at 60 to 120 ms per S3 page plus the key |
| +list sent over the tunnel is roughly 30 to 60 pages (30,000 to 60,000 |
| +objects). A is assumed. Door requests are tunnel HTTP to the hub, not S3 |
| +requests; they go up only where S3 LISTs go down more. S3 LIST at |
| +$0.005 per 1000: big account about $0.16 a day before, $0.035 after. |
| + |
| +Witness: `TestScopedWalkNeverCostsTheHubMoreS3Lists` (internal/provision) |
| +counts the hub's S3 requests behind the real door for 24 steady-state |
| +walks per size. The bucket fake pages as S3 does (a delimiter page holds |
| +Contents and CommonPrefixes together), at a 10-key page so the fixtures |
| +stay small: small 24 = 24, mid 192 = 192, big 744 -> 150, and the review's |
| +case (20 apps, one record each, objects directly under the account |
| +outnumbering the apps ten to one) 816 = 816, per app never chosen. |
| + |
| +Changes are transients, not steady state: |
| + |
| +- **Shrink** (log retention empties the tree): per-app walks keep their |
| + price until the recheck, at most 11 walks (about 20 minutes at 3 walks |
| + per 5.5-minute pass). Worst case per shrink event: 11 x (P - 1) extra |
| + S3 LISTs, since the shrunk tree costs at least 1. For the r10r estimate |
| + (P = 6) that is at most 55 LISTs once, against about 31,400 a day saved. |
| + A restart in the window only brings the recheck sooner. |
| + `TestScopedWalkReturnsToTheWholeTreeAfterAShrink` (with and without a |
| + restart) shows the walk back on the whole tree within the cycle, and |
| + staying there. |
| +- **Growth**: whole-tree walks see it on the next walk; per-app walks see |
| + new apps and new keys at their sub on the next walk, and new objects |
| + directly under the account at the recheck. |
| + `TestScopedWalkGoesPerAppAfterAGrowth`. |
| + |
| +Restarts (walk memory file): the agent keeps the walk's cost inputs |
| +(whole-tree pages, objects directly under the account, app count, per-app |
| +pages per subdirectory, the walk count, the account and the box identity) |
| +in `<data dir>/record-walk-cost.json`. A restart's first walk on a big |
| +account is therefore per app instead of a whole-tree listing (r10r: about |
| +6 S3 LISTs instead of about 40, and 1 + A small door listings instead of |
| +a 4 s one). The file is local, so it adds no S3 request. A restart takes |
| +the walk count as the last checkpoint plus 3 and writes that back, so |
| +restarts only bring the recheck sooner, and a box restarted after every |
| +walk still rechecks within 3 restarts |
| +(`TestScopedWalkRecheckSurvivesRepeatedRestarts`). Each recheck costs what |
| +every walk cost before, so the table holds with any number of restarts. |
| +Local writes: the whole-tree listing, every 4th walk, a change in per-app |
| +cost, and one per restart: about 200 a day against 785 walks. A missing, |
| +special, oversized, linked, corrupt, old-format, other-version or |
| +other-box file is no memory: the whole tree, as before. |
| + |
| +## Task 3 outcome: parked (2026-11-16) |
| + |
| +The adaptive door-shaped walk (d941a849, then branch fleet-door-record-walk, |
| +tip 2e350661) reached AGENTS.md stopping rule 2: two review rounds in the S3 |
| +request budget family (Astra: page pricing assumes full S3 pages). Release |
| +manager 8a3d302 chose option C below. The branch stays unmerged; see #964. |
| + |
| +### Task 5: share one record walk across the legs of a pass |
| + |
| +Goal: fewer record walks per pass for every account size, so the steady-state |
| +request budget goes down or stays equal by construction (no pricing logic, no |
| +hub change). Dev v0.37.0 on r10r box-1: each walk lists the account's whole |
| +apps subtree over the door (~2.3 s per list on a big account) and a fleet |
| +box's first pass makes about 4 walks (offline view at arming, reconcile's |
| +record scan, the moves pass, and any others); the goal is 1-2. |
| + |
| +1. Inventory every record walk a pass and the arming path make (who calls |
| + `readAllRecordsJudged`, `listAppSubtree`, the record snapshot in |
| + recordview*.go, `refreshOfflineView`, the moves pass's own snapshot, the |
| + instances loop, the backstop). For each, cite the rule that says how fresh |
| + its read must be. In particular: moves spec §4.3 says the moves pass takes |
| + its own snapshot and is never handed reconcile's snapshot; moves spec §9.4 |
| + and movesoffline.go say the offline keep view must be read before any |
| + reconcile; R1 (stale-wake fence) and R2 (restore-required) and the region |
| + HA rules (§25, §7.5) may require fresh reads at decision points. Write the |
| + result as an explicit table in this plan ("Fresh-read rules"): leg, may |
| + reuse the pass's walk (yes/no), why, rule cited. |
| +2. Build one shared walk per pass (and at arming, the offline view's walk |
| + reused by the boot pass's reconcile if the rules allow), scoped to one |
| + pass, never cached across passes, never a timer. Legs marked "no" keep |
| + their own fresh walk. A spec rule that forbids reuse wins over speed; do |
| + not change any spec. |
| +3. Tests: a test that counts store calls per pass (whole-tree lists and record |
| + GETs) before and after, for a first pass and a steady-state pass, asserting |
| + after <= before; and witnesses that each "no" leg still reads fresh (a |
| + record changed between the shared walk and that leg is seen by it). |
| +4. Request budget: state per box per day with nothing changing, before and |
| + after, for small (1-3 apps), mid (~20) and big (r10r-sized) accounts. It |
| + must not go up for any size. |
| +5. Census as before (NAME=fleet-first-reconcile-speed-5). |
| + |
| +#### Fresh-read rules (Task 5, step 1) |
| + |
| +A record walk has two halves. The **listing**: `List(accounts/)`, one GET |
| +per account manifest, then `List(apps/)` (on the fleet door that is the |
| +account's whole apps subtree whatever the sub, ~2.3 s each on r10r; on a |
| +bucket-shaped store, `ListDirs` and one list per app at the sub). The |
| +**reads**: one GET per record and, under a judge, one per incarnation slot. |
| +Only the listing is ever shared. Every leg still GETs every record and slot |
| +it acts on itself, so a body or slot that changed after the shared listing |
| +is seen by every leg (the R1 and R2 decision points read the record in the |
| +activator at wake and start, outside any walk, and are untouched). |
| + |
| +The shared walk (`provision.WalkShare`) lives for one reconcile hold |
| +(`reconcileSerializedAuth`, one `reconcileMu` hold), or, at arming, from the |
| +offline keep view's walk to the end of the first tick and the runs boot |
| +pass. It holds only a clean listing (no unreadable manifest, no partial |
| +list, no error): anything less is listed again by the next leg. No timer, |
| +no cache across passes. |
| + |
| +| leg | where | may reuse the pass's listing | why | rule cited | |
| +|---|---|---|---|---| |
| +| moves hold view at arming (Phase 1 switch on only; off on fleet boxes) | `refreshMovesHolds` | no | a moves view, built from its own walk; not built here | moves spec §9.4 (unbuilt hold view freezes every host); S3 change-index §4.3 (moves act only on live data) | |
| +| offline keep view at arming | `fastBoot.start` -> `refreshOfflineView` | no: it is the boot walk (produces it, never takes one) | the keep view is always read from the bucket, before any reconcile | S3 change-index §4.3 ("the offline keep view is always read from the bucket"); movesoffline.go (keep fails closed until a listing reads); fastboot.go step 2 | |
| +| offline keep view inside the hold (only when unbuilt or failed) | `reconcileSerializedAuth` | no: it produces the pass's walk when it runs | as above; it runs first in the hold | as above | |
| +| runs boot pass (seeds goroutine, after the views) | `runsWorker.bootPass` | yes, the boot walk's listing | pickup is a CAS on the record, whose body it GETs itself; a record created after the boot listing is not seen by it; if its write bumped the serial, the first tick's reconcile lists for itself (serial check, next row), notes it (`RunSeen`) and `ready`'s runs pass acts on it; a write with no bump waits for the next pass that lists, as an unbumped write always has | run spec §5.2 (pickup from reconcile's record reads; CAS from queued to picked) | |
| +| reconcile instance scan | `scanInstanceRecords` via `Reconcile` | yes: the boot walk on the boot pass, if no reconcile began or was running since that walk began (epoch guard) and the serial the first tick seeds equals the serial read just before the boot walk began (one GET per boot; a held, unread or moved serial burns the boot walk, so a bump the seed puts behind the box never hides a record the boot listing missed); else the offline re-read in the same hold; else it lists and produces | bodies and slots are GET in the hold, so a release made under `reconcileMu` is seen; the shared listing is a live bucket listing, never a snapshot; the pass's walk time (departure inventory, edge asset authority) is the shared listing's start, never later | S3 change-index §4.3 ("a pass's snapshot is never older than the previous pass's": epoch guard), §4.4 ("removals are decided by the bucket's walk": a live listing, bodies read in the hold); movesoffline.go `offlineSourceRevert` (a pass must not mint from a listing read before a release: bodies are read after it); region HA departure inventory `FreshAfter` and edge asset cache §4.2 (the walk's start is the earliest read) | |
| +| reconcile's live re-walk over a record view snapshot | `Reconcile` / `ReconcileSidecars` `scan(freshStore(s))` | no | it exists to be the bucket's own word after a snapshot; never on a fleet box (no view) | S3 change-index §4.4 | |
| +| reconcile over a record view snapshot (index armed) | `Reconcile` with `onSnapshot(s)` | no (the snapshot is the read) | unchanged | S3 change-index §4.3 | |
| +| sidecar scan | `ReconcileSidecars` | yes, same hold, right after the instance scan | same as the instance scan; under the index both families already read one snapshot | S3 change-index §4.1, §4.3; reconcileSerialized (both families under one hold) | |
| +| moves pass | `movesPass` | no | acts only on its own walk; never handed reconcile's copy | S3 change-index §4.3 ("the pass never takes a copy handed over from the Reconcile leg"; final review R1 finding 1) | |
| +| runs pass, interactive pass | `runRunsPass`, `runInteractivePass` | no walk | notes from reconcile's reads | run spec §5.2 | |
| +| HA ingress | `wireHAIngressScan` rides the instance scan; startup scan skipped on fleet boxes | rides reconcile (unchanged) | | region HA §25, §7.5 (no change to leases, departures or forwarding) | |
| +| strict absence readers: `IndexRecords` (proof gate), `RecordHostDeclared`, seed rollback, steering, console sweeps | various | no | each proves an absence on its own walk; not part of a pass | seeded instances spec, S3 change-index §4.6 | |
| +| instances loop, serial and backstop full passes | `instancesLoop`, `passLegs.run` | one share per `reconcileSerialized` call | no reuse across iterations | this task's lifetime rule | |
| + |
| +R1 (stale-wake fence) and R2 (restore-required) read the record at the |
| +activator's start gate (fleet record labels design §3), not from a walk, so |
| +no row above changes them. Region HA §25 (held requests) and §7.5 (unserved |
| +pools) decide on leases, edges files and the departure inventory; the only |
| +walk-derived input is the inventory's walk time, which the share reports as |
| +its earliest read. |
| + |
| +Walks per pass on a fleet box (whole `apps/` listings; each also lists |
| +`accounts/` and GETs the manifest): |
| + |
| +| pass | before | after | |
| +|---|---|---| |
| +| first (arming + boot pass) | 5: offline view, runs boot pass, reconcile, sidecars, moves (2 before the first mint) | 2: offline view, moves (1 before the first mint) | |
| +| steady state (instances loop, serial full pass) | 3: reconcile, sidecars, moves | 2: reconcile, moves | |
| + |
| +Measured by `TestSharedWalkStoreCallsPerPass` (internal/host): first pass |
| +apps/ listings 5 to 2, accounts/ listings 5 to 2, record GETs 20 = 20, |
| +slot GETs 20 = 20; steady pass apps/ 3 to 2, accounts/ 3 to 2, record GETs |
| +10 = 10, slot GETs 10 = 10. |
| + |
| +#### Task 5 request budget (per fleet box per day, nothing changing) |
| + |
| +Same assumptions as Task 3's budget: no change index on a fleet box, so |
| +the steady state is the instances loop, about 262 passes a day. Before, |
| +each pass made 3 walks (reconcile, sidecars, moves): 785 a day. After, 2 |
| +(reconcile and sidecars share one listing; moves lists itself): 524 a |
| +day. Each walk is one door request for `apps/` (W S3 LIST pages behind |
| +it), one for `accounts/` (one page) and one GET per account manifest. |
| +Record and slot GETs are unchanged (every leg still reads them). |
| + |
| +| account | objects under apps/, W | S3 LIST pages a day before | after | door listing requests a day before | after | manifest GETs a day (1 account) before | after | |
| +|---|---|---|---|---|---|---|---| |
| +| small (1-3 apps) | ~500, 1 | 1,570 | 1,048 | 1,570 | 1,048 | 785 | 524 | |
| +| mid (~20 apps) | ~5,000, 5 | 4,710 | 3,144 | 1,570 | 1,048 | 785 | 524 | |
| +| big (r10r estimate) | ~40,000, 40 | 32,185 | 21,484 | 1,570 | 1,048 | 785 | 524 | |
| + |
| +S3 LIST pages are (W + 1) per walk. Every row goes down by a third; none |
| +goes up for any size. Each box start saves 3 more whole listings (5 to 2), |
| +for one more GET: the serial, read before the boot walk (review round 1, |
| +Fable P2-1). |
diff --git a/internal/host/agent.go b/internal/host/agent.go| index accf6b1af..c0d92401c 100644 |
| --- a/internal/host/agent.go |
| +++ b/internal/host/agent.go |
| @@ -2316,11 +2316,18 @@ func reconcileSerializedAuth(ctx context.Context, s release.Store, reg *registry |
| rs, epoch, cached := viewStore(ctx, s) |
| source, complete := provision.DepartureSource(rs) |
| walkStarted := time.Now() |
| + // One record listing for the hold (fresh-read rules, walkshare.go): |
| + // the offline view's re-read below, then the instance scan, then the |
| + // sidecar scan list through cfg.Walk, and each still reads every |
| + // record itself. The boot walk's listing on the first pass only, if no |
| + // reconcile began since it was read; then the epoch marks this hold |
| + // until it returns. A pass that takes the boot walk's listing read the |
| + // bucket as of that listing: the walk's start, and the start the asset |
| + // authority is told, are the listing's when earlier. |
| + defer beginHoldWalk(ctx, cached, &cfg.Walk, &walkStarted, &start)() |
| if !cached { |
| source = walkStarted |
| complete = true |
| - } |
| - if !cached { |
| if v := armedRecordView.Load(); v != nil { |
| if sn := v.Snapshot(); sn != nil { |
| epoch = sn.Epoch |
| @@ -2355,7 +2362,7 @@ func reconcileSerializedAuth(ctx context.Context, s release.Store, reg *registry |
| // Phase 1's hooks are set. |
| if w != nil && w.cfg.OfflineCapable && w.cfg.Offline != nil { |
| if !w.cfg.Offline.built() || w.cfg.Offline.failed() { |
| - refreshOfflineView(ctx, s, w.cfg.Offline) |
| + refreshOfflineView(ctx, s, w.cfg.Offline, cfg.Walk) |
| } |
| cfg = withOfflineHolds(cfg, offlineHold(w.cfg), w.cfg.Offline) |
| } |
| @@ -3476,6 +3483,7 @@ func fastTick(ctx context.Context, d *fastDeps, now time.Time) { |
| // the no-replay rule: the bumps behind it are history a booting box |
| // must not act on (adoptLoop's 1-minute first pass covers boot). |
| d.lastSerial, d.seeded = doc.Serial, true |
| + confirmBootWalk(ctx, doc.Serial) // the boot walk only if no bump since it began |
| d.serialBroken = false |
| // A full pass that ran while the serial was held may have missed |
| // what the bumps behind this seed carried: one more, under the |
| @@ -3959,7 +3967,7 @@ func fastConvergeLoop(reg *registry.Registry, svc *activator.Service, sd *schedu |
| restartMem: restartMem, wakeMem: sidecarWakeMem, system: system, |
| restartGain: restartGain, restartLeg: restartLeg, wakeLeg: wakeLeg, |
| arming: arming, log: startup, seedOps: seedsOps} |
| - ready := boot.start(ctx, d, func() { |
| + ready := boot.start(ctx, d, func(ctx context.Context) { |
| arming.total("total") |
| log.Printf("agent: fast converge loop armed (2s + jitter: serial poll + canary/* + unstaged routes + system pointer)") |
| // The first tick, timed part by part, its own reads counted. |
diff --git a/internal/host/fastboot.go b/internal/host/fastboot.go| index ec4ccffe8..bc8be2e35 100644 |
| --- a/internal/host/fastboot.go |
| +++ b/internal/host/fastboot.go |
| @@ -95,33 +95,42 @@ type fastBoot struct { |
| var ( |
| bootBeforeBaseline func(step string) |
| bootMovesHolds = refreshMovesHolds |
| - bootOfflineView = func(ctx context.Context, s release.Store) { refreshOfflineView(ctx, s, armedOfflineView()) } |
| - bootRunsPass = runRunsBootPass |
| - bootRunsNotes = runRunsPass |
| - bootSchedule = func(ctx context.Context, sd *scheduleDeps) error { return sd.converge(ctx) } |
| - bootSystem = func(ctx context.Context, l *systemLeg) { l.observe(ctx) } |
| + bootOfflineView = func(ctx context.Context, s release.Store) { |
| + refreshOfflineView(ctx, s, armedOfflineView(), bootWalkShare(ctx)) |
| + } |
| + bootRunsPass = runRunsBootPass |
| + bootRunsNotes = runRunsPass |
| + bootSchedule = func(ctx context.Context, sd *scheduleDeps) error { return sd.converge(ctx) } |
| + bootSystem = func(ctx context.Context, l *systemLeg) { l.observe(ctx) } |
| ) |
| // start runs fastBoot's order: the request baselines started, the views |
| // built, then first (the loop's first tick), and returns ready. The loop |
| // calls ready before its second tick, and before any other tick: it is what |
| // hands the loop the seeded legs. |
| -func (b *fastBoot) start(ctx context.Context, d *fastDeps, first func()) (ready func()) { |
| +// |
| +// The offline keep view's record listing is the boot walk (walkshare.go): the |
| +// runs boot pass and the first tick's reconcile reuse it rather than listing |
| +// the records again, and each still reads every record itself. first gets |
| +// the context that carries it; it ends with first and the runs boot pass. |
| +func (b *fastBoot) start(ctx context.Context, d *fastDeps, first func(context.Context)) (ready func()) { |
| // The routes the box serves now, before the first pass mints anything: |
| // the sidecar baseline is taken over this list (fastBoot's comment). |
| routes, listErr := b.reg.List() |
| + boot := withBootWalk(ctx, b.viewStore) // the serial, read before the walk |
| baselined, viewsBuilt, done := make(chan struct{}), make(chan struct{}), make(chan struct{}) |
| go func() { |
| defer close(done) |
| - b.seed(ctx, routes, listErr, baselined, viewsBuilt) |
| + b.seed(ctx, boot, routes, listErr, baselined, viewsBuilt) |
| }() |
| + // The hold view lists for itself: a moves view (fresh-read rules). |
| bootMovesHolds(ctx, b.viewStore) |
| b.arming.done("moves holds") |
| - bootOfflineView(ctx, b.viewStore) |
| + bootOfflineView(boot, b.viewStore) |
| b.arming.done("offline view") |
| close(viewsBuilt) |
| d.serialAfter = baselined |
| - first() |
| + first(boot) |
| var once sync.Once |
| return func() { |
| once.Do(func() { |
| @@ -159,7 +168,8 @@ func waitSeeds(done <-chan struct{}) { |
| // arming, nil with listErr when it could not be read. Its own goroutine: it |
| // touches nothing the loop reads until the loop has seen baselined (the |
| // serial) or ready has waited for it (everything else). |
| -func (b *fastBoot) seed(ctx context.Context, routes []registry.Route, listErr error, baselined chan<- struct{}, viewsBuilt <-chan struct{}) { |
| +// boot is ctx with the boot walk, for the runs boot pass alone. |
| +func (b *fastBoot) seed(ctx, boot context.Context, routes []registry.Route, listErr error, baselined chan<- struct{}, viewsBuilt <-chan struct{}) { |
| steps := b.log.steps("seeds: ", b.seedOps) |
| if bootBeforeBaseline != nil { |
| bootBeforeBaseline("restart seed") |
| @@ -185,7 +195,7 @@ func (b *fastBoot) seed(ctx context.Context, routes []registry.Route, listErr er |
| // the CLI expires a run at 60 s. A runs pass that starts before it has |
| // finished does nothing and keeps reconcile's notes (runsWorker.booted); |
| // ready runs one more pass for the notes the first tick left. |
| - bootRunsPass(ctx) |
| + bootRunsPass(boot) |
| steps.done("runs boot pass") |
| // The schedule converge's own seed, on restartSeed's precedent: the leg |
| // runs only on a serial MOVE, so without one pass here a box that booted |
diff --git a/internal/host/fastboot_test.go b/internal/host/fastboot_test.go| index fdd21da43..bc247a319 100644 |
| --- a/internal/host/fastboot_test.go |
| +++ b/internal/host/fastboot_test.go |
| @@ -89,7 +89,9 @@ func TestFastBootFirstPassDoesNotWaitForTheSeeds(t *testing.T) { |
| d, b := bootFixture(t, f, func() { reconciled <- struct{}{} }) |
| b.system = &systemLeg{} // armed; its observe is the swapped step |
| readyc := make(chan func(), 1) |
| - go func() { readyc <- b.start(ctx, d, func() { fastTick(ctx, d, time.Unix(1762382167, 0)) }) }() |
| + go func() { |
| + readyc <- b.start(ctx, d, func(ctx context.Context) { fastTick(ctx, d, time.Unix(1762382167, 0)) }) |
| + }() |
| var ready func() |
| // Before the fixture's own cleanups: a failing run leaves start |
| // or the seeds blocked; free them and wait them out first. |
| @@ -141,7 +143,7 @@ func TestFastBootFirstPassWaitsForTheViews(t *testing.T) { |
| f := newFastFixture(t) |
| passes := 0 |
| d, b := bootFixture(t, f, func() { passes++; note("reconcile") }) |
| - ready := b.start(ctx, d, func() { fastTick(ctx, d, time.Unix(1762382167, 0)) }) |
| + ready := b.start(ctx, d, func(ctx context.Context) { fastTick(ctx, d, time.Unix(1762382167, 0)) }) |
| ready() |
| at := func(s string) int { return slices.Index(order, s) } |
| @@ -197,7 +199,7 @@ func TestFastBootRestartBaselineNeitherReplaysNorSwallows(t *testing.T) { |
| b.restartGain, b.restartLeg = armRestartLegs(f.reg, f.store, f.dataDir, b.restartMem, |
| func(h string) bool { bounced = append(bounced, h); return true }, nil) |
| - ready := b.start(ctx, d, func() { fastTick(ctx, d, now) }) |
| + ready := b.start(ctx, d, func(ctx context.Context) { fastTick(ctx, d, now) }) |
| ready() |
| fastTick(ctx, d, now.Add(2*time.Second)) // inside the clamp; gains the minted app |
| if passes != 1 { |
| @@ -288,7 +290,7 @@ func TestFastBootRequestDuringTheSeedsIsNeverHalfTaken(t *testing.T) { |
| woken = append(woken, m...) |
| } |
| - ready := b.start(ctx, d, func() { fastTick(ctx, d, now) }) |
| + ready := b.start(ctx, d, func(ctx context.Context) { fastTick(ctx, d, now) }) |
| if passes != 1 { |
| t.Fatalf("the first tick ran %d full passes, want the boot pass", passes) |
| } |
| @@ -373,7 +375,7 @@ func TestFastBootWakesASidecarTheFirstPassMints(t *testing.T) { |
| moved = append(moved, m...) |
| } |
| - ready := b.start(ctx, d, func() { fastTick(ctx, d, now) }) |
| + ready := b.start(ctx, d, func(ctx context.Context) { fastTick(ctx, d, now) }) |
| ready() |
| fastTick(ctx, d, now.Add(2*time.Second)) // the second tick: the serial is seeded by now |
| if err := release.BumpSerial(ctx, f.store, now.Add(time.Hour)); err != nil { |
| @@ -441,7 +443,7 @@ func TestFastBootActsOnTheRunsTheFirstTickNoted(t *testing.T) { |
| w.note(rec) // reconcile's note |
| runRunsPass(ctx) // the full pass's runs leg |
| }) |
| - ready := b.start(ctx, d, func() { fastTick(ctx, d, time.Unix(1762382167, 0)) }) |
| + ready := b.start(ctx, d, func(ctx context.Context) { fastTick(ctx, d, time.Unix(1762382167, 0)) }) |
| if n := launched.count(); n != 0 { |
| t.Fatalf("%d runs launched by the first tick, want 0: a runs pass acted before the boot pass finished", n) |
| } |
diff --git a/internal/host/group_names_test.go b/internal/host/group_names_test.go| index 19730b69a..f1ebefda8 100644 |
| --- a/internal/host/group_names_test.go |
| +++ b/internal/host/group_names_test.go |
| @@ -575,7 +575,10 @@ var groupNameProducerInventory = map[string]string{ |
| // The code-health split moved that guard, withdrawPools, the demo claim |
| // holds and the Now default, in order, to ReconcileConfig.passStart; no |
| // name is derived, minted or published there, same class. |
| - "../provision/reconcile.go:Reconcile": "cd6604d03d44415b05b2b65b08945f6428c7b3085d584eb32f2038880c1c738f", |
| + // Shared record walk (fleet first reconcile Task 5): the pass's own |
| + // scan lists through cfg.liveWalk(s); the same keys are read and the |
| + // same records decide every name. No name-class consequence. |
| + "../provision/reconcile.go:Reconcile": "a15db574e0be9e2f610b10c5afaa476d3b79743e3e6f91035d78a57c8c4b9eb4", |
| // Resident replicas use nested local paths; exact-route names and owners do not change. |
| "../provision/reconcile.go:RouteFor": "f42827f4faca3572837e627a694c72928048e245573c50a75c357a44be28bb8d", |
| "../provision/reconcile.go:mintHeld": "9fe4ad876c727af36cc06bd0105baf344748c61e6f21ced48e5288a323851344", |
| @@ -584,7 +587,9 @@ var groupNameProducerInventory = map[string]string{ |
| // B6 retains the synthetic sidecar name and Kind. HA affects lifetime and |
| // nested DB paths only; TestSidecarNeverAdvertisedOrDialled exercises the |
| // real stamped record/reconcile/publication path as well as the legacy row. |
| - "../provision/sidecar_reconcile.go:ReconcileSidecars": "b01db9dbfa566953f93e29247e648e850d63c357b04be5f584ba31911d8c6fb1", |
| + // Shared record walk (Task 5): the scan lists through the pass's walk; |
| + // same keys and records, no name-class consequence. |
| + "../provision/sidecar_reconcile.go:ReconcileSidecars": "aee515187aa5d4abd869a36472e006489d7edc9a4bd55dad76b8b098a1fa1cff", |
| "../provision/sidecar_reconcile.go:sidecarRouteFor": "c8cc26bdb7a0aff550219b1c095fd0289392620465b659cd29e5ef4e7895028a", |
| "claimretire_transport.go:ClaimRootHTTP.retire": "a60c74d0e0461e0a432f9a338aa25799cc0cd9d163c7b6eb803cfb33d55d7c2a", |
| "claimunit_binding.go:claimUnitShape.route": "f38fd6e10aba680354ee908c255fd34e731fe2d1a22fffd41ac449e8b763dd2c", |
diff --git a/internal/host/haingress_test.go b/internal/host/haingress_test.go| index 99d7437ef..5df5b67aa 100644 |
| --- a/internal/host/haingress_test.go |
| +++ b/internal/host/haingress_test.go |
| @@ -45,8 +45,11 @@ func TestHAIngressMetadataCannotGrantLocalAuthority(t *testing.T) { |
| if err != nil || row != nil { |
| t.Fatalf("ineligible row minted: %+v %v", row, err) |
| } |
| - if !indexed && w.live.count("List", "apps/") != 2 { |
| - t.Fatalf("expected existing instance and sidecar scans only: %v", w.live.got()) |
| + // The instance and sidecar scans share the hold's one record |
| + // listing (fleet first reconcile Task 5, walkshare.go); the HA |
| + // ingress scan rides the instance scan and lists nothing more. |
| + if !indexed && (w.live.count("List", "apps/") != 1 || w.live.count("List", "accounts/") != 1) { |
| + t.Fatalf("expected the instance and sidecar scans' one shared listing only: %v", w.live.got()) |
| } |
| w.live.setFailList("accounts/") |
| _ = reconcileSerializedAuth(t.Context(), w.live, reg, cfg, nil, newAssetAuthority(nil)) |
diff --git a/internal/host/lifetime_gating_test.go b/internal/host/lifetime_gating_test.go| index 5d0256748..eecdddbc9 100644 |
| --- a/internal/host/lifetime_gating_test.go |
| +++ b/internal/host/lifetime_gating_test.go |
| @@ -462,7 +462,7 @@ func TestClaimsOnConsumersReadNoSlot(t *testing.T) { |
| if rt := a.row(offHost); rt == nil { |
| t.Fatal("claims on, reconcile did not mint the record's row") |
| } |
| - refreshOfflineView(ctx, reads, a.w.cfg.Offline) |
| + refreshOfflineView(ctx, reads, a.w.cfg.Offline, nil) |
| if recs, err := appRecords(provision.WithLifetimes(ctx, judge), reads, wd.acct, "app"); err != nil || len(recs) != 1 { |
| t.Fatalf("retention: %d records, %v", len(recs), err) |
| } |
diff --git a/internal/host/movesoffline.go b/internal/host/movesoffline.go| index 28e01b56d..ad88f7f35 100644 |
| --- a/internal/host/movesoffline.go |
| +++ b/internal/host/movesoffline.go |
| @@ -256,11 +256,19 @@ func (v *offlineView) elsewhere(host string) bool { |
| // refreshOfflineView reads the record list once, outside a moves pass: at |
| // agent start, before the reconcile loops, next to refreshMovesHolds. A |
| // failed listing leaves keep failing closed until a listing is read. |
| -func refreshOfflineView(ctx context.Context, s release.Store, v *offlineView) { |
| +// |
| +// It reads the bucket, and is the first walk wherever it runs: its listing |
| +// goes into walk (the boot walk, or the reconcile hold's share) for the legs |
| +// after it, and it never takes one from it (fresh-read rules, walkshare.go). |
| +// A nil walk shares nothing. |
| +func refreshOfflineView(ctx context.Context, s release.Store, v *offlineView, walk *provision.WalkShare) { |
| if v == nil || s == nil { |
| return |
| } |
| - recs, unreadable, err := provision.ListAllRecordsStrictJudged(provision.WithLifetimes(ctx, v.judge), s, v.judge) |
| + if _, filled := walk.ListedAt(); filled { |
| + walk = nil // never read the keep view from a listing another leg made |
| + } |
| + recs, unreadable, err := provision.ListAllRecordsStrictJudgedShared(provision.WithLifetimes(ctx, v.judge), s, v.judge, walk) |
| if err != nil { |
| log.Printf("moves: offline view: list records: %v; every row is kept until a listing reads", err) |
| v.fail() |
diff --git a/internal/host/movesoffline_seal_test.go b/internal/host/movesoffline_seal_test.go| index f01c78632..d0fa908f1 100644 |
| --- a/internal/host/movesoffline_seal_test.go |
| +++ b/internal/host/movesoffline_seal_test.go |
| @@ -144,7 +144,7 @@ func (sw *sealWorld) pass(b *offBox) error { |
| b.reconcile() |
| b.edges() |
| ctx := context.Background() |
| - refreshOfflineView(ctx, sw.s, b.w.cfg.Offline) |
| + refreshOfflineView(ctx, sw.s, b.w.cfg.Offline, nil) |
| return b.w.offlineRound(ctx, sw.s, sw.record()) |
| } |
diff --git a/internal/host/movesoffline_stage_test.go b/internal/host/movesoffline_stage_test.go| index 649e72854..23b529944 100644 |
| --- a/internal/host/movesoffline_stage_test.go |
| +++ b/internal/host/movesoffline_stage_test.go |
| @@ -39,7 +39,7 @@ func (sw *sealWorld) stagePass(b *offBox) error { |
| b.reconcile() |
| sw.stagerEdges(b) |
| ctx := context.Background() |
| - refreshOfflineView(ctx, sw.s, b.w.cfg.Offline) |
| + refreshOfflineView(ctx, sw.s, b.w.cfg.Offline, nil) |
| return b.w.offlineRound(ctx, sw.s, sw.record()) |
| } |
diff --git a/internal/host/movesoffline_test.go b/internal/host/movesoffline_test.go| index 56a0a019d..a833afd63 100644 |
| --- a/internal/host/movesoffline_test.go |
| +++ b/internal/host/movesoffline_test.go |
| @@ -1194,7 +1194,7 @@ func TestOfflineFailedListingHealsOnTheNextReconcile(t *testing.T) { |
| wd := dormantWorld(t) |
| plain, hooked := dormantBoxes(t, wd) |
| v := hooked.w.cfg.Offline |
| - refreshOfflineView(ctx, failingListStore{Store: wd.s, prefix: "apps/", err: errors.New("listing refused")}, v) |
| + refreshOfflineView(ctx, failingListStore{Store: wd.s, prefix: "apps/", err: errors.New("listing refused")}, v, nil) |
| if !v.built() || !v.failed() || !v.keep(offHost) { |
| t.Fatal("a failed startup listing does not keep") |
| } |
| @@ -1218,7 +1218,7 @@ func TestOfflineFailedListingHealsOnTheNextReconcile(t *testing.T) { |
| } |
| sameRegistries(t, plain, hooked) |
| // While the listing keeps failing the view stays closed. |
| - refreshOfflineView(ctx, failingListStore{Store: wd.s, prefix: "apps/", err: errors.New("listing refused")}, v) |
| + refreshOfflineView(ctx, failingListStore{Store: wd.s, prefix: "apps/", err: errors.New("listing refused")}, v, nil) |
| if !v.keep(offHost) { |
| t.Fatal("a failed listing does not keep") |
| } |
| @@ -1239,7 +1239,7 @@ func TestOfflineUndecodableRecordIsKept(t *testing.T) { |
| t.Fatal(err) |
| } |
| a := wd.box("ie-a", "", nil) |
| - refreshOfflineView(ctx, wd.s, a.w.cfg.Offline) |
| + refreshOfflineView(ctx, wd.s, a.w.cfg.Offline, nil) |
| v := a.w.cfg.Offline |
| if v.failed() || !v.keep("broken.example.com") || v.keep(offHost) { |
| t.Fatalf("startup view: failed %v, keep(broken) %v, keep(%s) %v", v.failed(), v.keep("broken.example.com"), offHost, v.keep(offHost)) |
diff --git a/internal/host/runs.go b/internal/host/runs.go| index 8916aab67..6120b6f57 100644 |
| --- a/internal/host/runs.go |
| +++ b/internal/host/runs.go |
| @@ -142,7 +142,9 @@ func (w *runsWorker) bootPass(ctx context.Context) { |
| log.Printf("agent: runs: boot sweep of .carlos-run: %v", err) |
| } |
| ctx = provision.WithLifetimes(ctx, w.judge) |
| - recs, _, err := provision.ListAllRecordsStrictJudged(ctx, w.store, w.judge) |
| + // At agent start the record listing is the boot walk's when it has one |
| + // (walkshare.go); every record is still read here. |
| + recs, _, err := provision.ListAllRecordsStrictJudgedShared(ctx, w.store, w.judge, bootWalkShare(ctx)) |
| if err != nil { |
| log.Printf("agent: runs: boot pass: %v", err) |
| return |
diff --git a/internal/host/startupmeasure_e2e_test.go b/internal/host/startupmeasure_e2e_test.go| index 69cb65316..7195c377b 100644 |
| --- a/internal/host/startupmeasure_e2e_test.go |
| +++ b/internal/host/startupmeasure_e2e_test.go |
| @@ -264,7 +264,7 @@ func measureStartup(t *testing.T, n int, lat time.Duration) string { |
| arming.done("sidecar wake seed") |
| refreshMovesHolds(ctx, store) |
| arming.done("moves holds") |
| - refreshOfflineView(ctx, store, armedOfflineView()) |
| + refreshOfflineView(ctx, store, armedOfflineView(), nil) |
| arming.done("offline view") |
| if leg := newSystemLeg(store, pub, getenv, b.dd, optDir); leg != nil { |
| leg.readers = cachedGroupReaders |
diff --git a/internal/host/walkshare.go b/internal/host/walkshare.go| new file mode 100644 |
| index 000000000..6671251f0 |
| --- /dev/null |
| +++ b/internal/host/walkshare.go |
| @@ -0,0 +1,142 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "sync/atomic" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// One record listing shared across the legs of a pass (fleet first |
| +// reconcile plan, Task 5; the "Fresh-read rules" table there says which leg |
| +// may reuse it and why). On a fleet box every record walk lists the |
| +// account's whole apps subtree over the store door, seconds on a big |
| +// account, and a pass listed once per leg. |
| +// |
| +// Two lifetimes, never longer: |
| +// |
| +// - A reconcile hold (reconcileSerializedAuth): the offline view's re-read |
| +// when it runs, the instance scan and the sidecar scan list once. |
| +// - The boot walk (fastBoot.start): the first clean listing read at arming, |
| +// normally the offline keep view's, is reused by the runs boot pass and |
| +// by the first tick's reconcile, which takes it only if no reconcile |
| +// began or was running since the boot walk started (reconcileEpoch), so |
| +// a pass's listing is never older than the previous pass's (S3 |
| +// change-index design §4.3), and only if the serial the first tick |
| +// seeds is the one read before the boot walk began (confirmBootWalk): |
| +// a bump in between may carry a record the listing missed, and the |
| +// seed puts that bump behind the box, so the hold lists for itself. It |
| +// lives in the context fastBoot hands the views, the runs boot pass and |
| +// the first tick, and nowhere else. |
| +// |
| +// The moves pass never takes either (§4.3: it acts only on its own walk), and |
| +// nothing else reads them. Only listings are shared: every leg reads every |
| +// record and slot it acts on itself. |
| + |
| +// shareRecordWalks turns the sharing on. Tests turn it off to count the walks |
| +// as they were before. |
| +var shareRecordWalks = true |
| + |
| +// reconcileEpoch counts reconcile holds: it moves when a hold begins and when |
| +// it ends, so it is even only while none runs, and a value read before a walk |
| +// still matches after it only if no hold began or ran meanwhile. |
| +var reconcileEpoch atomic.Uint64 |
| + |
| +type bootWalkKey struct{} |
| + |
| +// bootWalk is the boot walk's share, and the reconcile epoch and the serial |
| +// read before it. |
| +type bootWalk struct { |
| + share *provision.WalkShare |
| + epoch uint64 |
| + serial int64 |
| + serialOK bool // the serial read before the walk read |
| + confirmed atomic.Bool // the first tick seeded that same serial |
| + taken atomic.Bool // the first reconcile hold has looked at it |
| +} |
| + |
| +// withBootWalk returns ctx carrying a fresh boot walk, the epoch and the |
| +// serial read now, before the walk: one GET of the serial per boot. With |
| +// sharing off it returns ctx unchanged and reads nothing. |
| +func withBootWalk(ctx context.Context, s release.Store) context.Context { |
| + if !shareRecordWalks { |
| + return ctx |
| + } |
| + b := &bootWalk{share: provision.NewWalkShare(), epoch: reconcileEpoch.Load()} |
| + if s != nil { |
| + doc, _, err := release.ReadSerial(ctx, s) |
| + b.serial, b.serialOK = doc.Serial, err == nil |
| + } |
| + return context.WithValue(ctx, bootWalkKey{}, b) |
| +} |
| + |
| +// confirmBootWalk is the first tick's serial seed: the boot walk stays |
| +// takeable only if the serial read before it read cleanly and equals seed. |
| +// Never called (a held or unread serial), the boot walk is never taken. |
| +func confirmBootWalk(ctx context.Context, seed int64) { |
| + if b, ok := ctx.Value(bootWalkKey{}).(*bootWalk); ok && b.serialOK && b.serial == seed { |
| + b.confirmed.Store(true) |
| + } |
| +} |
| + |
| +// bootWalkShare is the boot walk's share in ctx, nil outside the boot. |
| +func bootWalkShare(ctx context.Context) *provision.WalkShare { |
| + if b, ok := ctx.Value(bootWalkKey{}).(*bootWalk); ok { |
| + return b.share |
| + } |
| + return nil |
| +} |
| + |
| +// takeBootWalk is the boot walk for a reconcile hold, under reconcileMu |
| +// before the hold moves the epoch: once per boot, only once the first tick |
| +// confirmed the serial (confirmBootWalk), only if no reconcile was |
| +// running when the boot walk was set up and none has begun since, and only |
| +// if it already holds a listing, so the hold knows the earliest read it |
| +// takes before it starts (a listing another leg is still reading is not |
| +// taken). nil otherwise, and the hold lists for itself. |
| +func takeBootWalk(ctx context.Context) *provision.WalkShare { |
| + b, ok := ctx.Value(bootWalkKey{}).(*bootWalk) |
| + if !ok || !b.taken.CompareAndSwap(false, true) || !b.confirmed.Load() { |
| + return nil |
| + } |
| + if b.epoch%2 != 0 || reconcileEpoch.Load() != b.epoch { |
| + return nil |
| + } |
| + if _, filled := b.share.ListedAt(); !filled { |
| + return nil |
| + } |
| + return b.share |
| +} |
| + |
| +// beginHoldWalk starts a reconcile hold's shared walk, under reconcileMu |
| +// before the hold reads any record: *walk is the boot walk if takeBootWalk |
| +// gives it, else a fresh share (sharing on), and nil over a record view |
| +// snapshot (cached), whose reads are the snapshot's. Then reconcileEpoch |
| +// moves for the hold. When the share already holds a listing, *walkStarted |
| +// and *passStart go back to its earliest read. The returned func ends the |
| +// hold's epoch; the hold defers it. |
| +func beginHoldWalk(ctx context.Context, cached bool, walk **provision.WalkShare, walkStarted, passStart *time.Time) (end func()) { |
| + w := takeBootWalk(ctx) |
| + reconcileEpoch.Add(1) |
| + switch { |
| + case cached: |
| + w = nil // a snapshot pass lists nothing of its own to share |
| + case w == nil && shareRecordWalks: |
| + w = provision.NewWalkShare() |
| + } |
| + if at, ok := w.ListedAt(); ok { |
| + *walkStarted = minTime(*walkStarted, at) |
| + *passStart = minTime(*passStart, at) |
| + } |
| + *walk = w |
| + return func() { reconcileEpoch.Add(1) } |
| +} |
| + |
| +func minTime(a, b time.Time) time.Time { |
| + if b.Before(a) { |
| + return b |
| + } |
| + return a |
| +} |
diff --git a/internal/host/walkshare_e2e_test.go b/internal/host/walkshare_e2e_test.go| new file mode 100644 |
| index 000000000..ea9de08c5 |
| --- /dev/null |
| +++ b/internal/host/walkshare_e2e_test.go |
| @@ -0,0 +1,472 @@ |
| +//go:build linux |
| + |
| +package host |
| + |
| +import ( |
| + "context" |
| + "crypto/ed25519" |
| + "encoding/base64" |
| + "fmt" |
| + "strings" |
| + "sync/atomic" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/appconfig" |
| + "github.com/carlosframework/platform/internal/apppolicy" |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// The shared record walk (fleet first reconcile, Task 5; "Fresh-read rules" |
| +// in docs/superpowers/plans/2026-11-15-fleet-first-reconcile.md), witnessed |
| +// on the two-box harness over a fake of the fleet store door: the store |
| +// calls a first pass and a steady-state pass make, before and after, and |
| +// that every leg the rules mark "no" still reads the bucket itself. The door |
| +// has no latency: every count comes from its op log, never from a clock. |
| + |
| +// walkWorld is one fleet box (pi-1) over a door-shaped store, armed as the |
| +// agent arms a fleet box, with n-1 instances on each box and one more |
| +// created while pi-1 is "stopped" (last), as in the startup measurement. |
| +type walkWorld struct { |
| + w *fleetWorld |
| + b *fleetBox |
| + door *slowDoor |
| + legs *passLegs |
| + judge *provision.LifetimeJudge |
| + pub ed25519.PublicKey |
| + last string |
| + d *fastDeps // the loop's, from boot |
| + now time.Time // the loop's clock, for its ticks |
| +} |
| + |
| +func newWalkWorld(t *testing.T, n int) *walkWorld { |
| + t.Helper() |
| + ctx := context.Background() |
| + w := newFleetWorld(t, fleetOpts{}) |
| + b := w.pi1 |
| + relPub, relPriv, err := ed25519.GenerateKey(nil) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + cfgKey, _, err := appconfig.GenerateKey() |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + env := map[string]string{ |
| + "CARLOS_RELEASE_PUBKEY": base64.StdEncoding.EncodeToString(relPub), |
| + "CARLOS_SECRETS_KEY": cfgKey, |
| + } |
| + getenv := func(k string) string { |
| + if v, ok := env[k]; ok { |
| + return v |
| + } |
| + return b.getenv(k) |
| + } |
| + if err := apppolicy.PutIfMatch(ctx, w.store, relPriv, apppolicy.Policy{V: 1, Account: w.acct, App: "shop", Revision: 1, |
| + SignedAt: time.Now().UTC()}, ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + host := func(i int) string { return fmt.Sprintf("m%02d.example.com", i) } |
| + for i := 0; i < 2*(n-1); i++ { |
| + w.create(host(i)) |
| + } |
| + b.mustReconcile() |
| + last := host(2 * (n - 1)) |
| + w.create(last) |
| + if rec := w.record(last); rec.FleetBox != b.label { |
| + t.Fatalf("fixture: %s landed on %q, want %s", last, rec.FleetBox, b.label) |
| + } |
| + |
| + judge := newBoxJudge(getenv) |
| + if judge == nil { |
| + t.Fatal("fixture: no lifetime judge, as a claims-off fleet box has") |
| + } |
| + armMeasuredBox(t, b, getenv, judge) |
| + door := &slowDoor{inner: w.store} |
| + if storeExts(door) != doorShape { |
| + t.Fatal("fixture: the fake door is not the fleet door's shape") |
| + } |
| + pub, err := release.ParsePublicKey(getenv("CARLOS_RELEASE_PUBKEY"), "CARLOS_RELEASE_PUBKEY") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + priv, err := appconfig.ParsePrivateKey(getenv("CARLOS_SECRETS_KEY"), "CARLOS_SECRETS_KEY") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + legs := &passLegs{store: door, reg: b.reg, pub: pub, optDir: t.TempDir(), priv: priv, dd: b.dd, |
| + cfg: func() provision.ReconcileConfig { |
| + c := BoxProvisionConfig(b.reg, getenv, judge, nil) |
| + c.Lifetimes = &provision.LifetimeIndex{} |
| + c.Layout = flatLayout |
| + return c |
| + }} |
| + // The runs worker, armed so the runs boot pass reads the records as it |
| + // does on a fleet box (no record carries a run here, so it acts on none). |
| + prevRuns := armedRuns.Load() |
| + t.Cleanup(func() { armedRuns.Store(prevRuns) }) |
| + rw := newRunsWorker(door, b.reg.Get, nil, b.dd, b.label, "boot-walk-test") |
| + rw.judge = judge |
| + armedRuns.Store(rw) |
| + return &walkWorld{w: w, b: b, door: door, legs: legs, judge: judge, pub: pub, last: last, now: time.Unix(1762382167, 0)} |
| +} |
| + |
| +// boot runs fastBoot's start as the agent does (the views, the seeds |
| +// beside the first tick, the boot full pass on the first tick) with the |
| +// production offline view and runs boot pass, the rest of the seeds' steps |
| +// swapped out. afterOffline, when set, runs right after the offline view's |
| +// walk, before the first tick. It returns the door ops from the start to |
| +// ready, and the index in them where afterOffline returned. |
| +func (ww *walkWorld) boot(t *testing.T, afterOffline func()) (ops []doorOp, afterMark int) { |
| + t.Helper() |
| + offline, runs := bootOfflineView, bootRunsPass |
| + swapBootSteps(t) |
| + bootRunsPass = runs |
| + bootOfflineView = func(ctx context.Context, s release.Store) { |
| + offline(ctx, s) |
| + if afterOffline != nil { |
| + afterOffline() |
| + } |
| + afterMark = ww.door.mark() |
| + } |
| + mem := newRestartMemory() |
| + mem.pub = ww.pub |
| + due := &atomic.Bool{} |
| + requestBootFullPass(nil, due) // a fleet box: no record view |
| + ww.d = &fastDeps{reg: ww.b.reg, store: ww.door, pub: ww.pub, optDir: ww.legs.optDir, fullPass: ww.legs.full, fullDue: due} |
| + fb := &fastBoot{reg: ww.b.reg, viewStore: ww.door, seedStore: ww.door, dd: ww.b.dd, |
| + restartMem: mem, wakeMem: newSidecarWakeMemory(false), |
| + restartGain: func(context.Context, time.Time) {}, restartLeg: func(context.Context) {}, wakeLeg: func(context.Context) {}} |
| + from := ww.door.mark() |
| + ctx := provision.WithLifetimes(context.Background(), ww.judge) |
| + ready := fb.start(ctx, ww.d, func(ctx context.Context) { |
| + <-ww.d.serialAfter // an unheld first tick: the request baselines have read |
| + fastTick(ctx, ww.d, ww.now) |
| + }) |
| + ready() // waits for the seeds, the runs boot pass among them |
| + return ww.door.between(from, ww.door.mark()), afterMark - from |
| +} |
| + |
| +// tick is the loop's next tick, 2 s after the last. |
| +func (ww *walkWorld) tick() []doorOp { |
| + ww.now = ww.now.Add(2 * time.Second) |
| + from := ww.door.mark() |
| + fastTick(provision.WithLifetimes(context.Background(), ww.judge), ww.d, ww.now) |
| + return ww.door.between(from, ww.door.mark()) |
| +} |
| + |
| +// pass is one steady-state full pass; it returns its door ops. |
| +func (ww *walkWorld) pass() []doorOp { |
| + from := ww.door.mark() |
| + ww.legs.full(provision.WithLifetimes(context.Background(), ww.judge)) |
| + return ww.door.between(from, ww.door.mark()) |
| +} |
| + |
| +// walkCalls is what a record walk costs at the door: whole apps/ listings |
| +// (each the account's whole subtree), accounts/ listings, record GETs and |
| +// incarnation slot GETs. |
| +type walkCalls struct{ trees, accounts, records, slots int } |
| + |
| +func (ww *walkWorld) calls(ops []doorOp) walkCalls { |
| + var c walkCalls |
| + for _, o := range ops { |
| + switch { |
| + case o.op == opList && o.key == "apps/": |
| + c.trees++ |
| + case o.op == opList && o.key == "accounts/": |
| + c.accounts++ |
| + case o.op == opGet && strings.HasPrefix(o.key, "apps/"+ww.w.acct+"/") && strings.Contains(o.key, "/instances/"): |
| + c.records++ |
| + case o.op == opGet && strings.HasPrefix(o.key, "control/host-incarnations/"): |
| + c.slots++ |
| + } |
| + } |
| + return c |
| +} |
| + |
| +func gotKey(ops []doorOp, op storeOp, key string) bool { |
| + for _, o := range ops { |
| + if o.op == op && o.key == key { |
| + return true |
| + } |
| + } |
| + return false |
| +} |
| + |
| +// putRecord writes a record of app for host straight to the bucket, |
| +// labelled for pi-1 and with no serial bump: a writer that skips the bump |
| +// (a direct-bucket write), or one more app's record in a sized fixture. |
| +func (ww *walkWorld) putRecord(t *testing.T, app, host string) { |
| + t.Helper() |
| + rec := provision.Record{Schema: 1, Host: host, Slug: strings.TrimSuffix(host, ".example.com"), App: app, |
| + Account: ww.w.acct, Region: "fleet/" + fleetName, Channel: "edge", CreatedAt: time.Now().UTC(), CreatedBy: fleetAddr, |
| + FleetBox: ww.b.label, FleetBoxAt: time.Now().UTC().Format(time.RFC3339)} |
| + if err := provision.EnsureAssetGen(&rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := provision.CreateRecord(context.Background(), ww.w.store, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| +} |
| + |
| +// grow adds apps more apps of perApp records each, and junk objects that |
| +// are not records (release artifacts, log chunks) under each, as a big |
| +// account's apps/ subtree holds. |
| +func (ww *walkWorld) grow(t *testing.T, apps, perApp, junk int) { |
| + t.Helper() |
| + ctx := context.Background() |
| + for a := 0; a < apps; a++ { |
| + app := fmt.Sprintf("app%02d", a) |
| + for r := 0; r < perApp; r++ { |
| + ww.putRecord(t, app, fmt.Sprintf("%s-r%d.example.com", app, r)) |
| + } |
| + for j := 0; j < junk; j++ { |
| + key := fmt.Sprintf("apps/%s/%s/releases/v%d/artifact.tar", ww.w.acct, app, j) |
| + if _, err := ww.w.store.Put(ctx, key, []byte("x"), ""); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + } |
| +} |
| + |
| +// TestSharedWalkStoreCallsPerPass counts the store calls of a fleet box's |
| +// first pass (arming, the runs boot pass and the boot full pass on a real |
| +// unheld first tick) and of a steady-state full pass, before (sharing off) |
| +// and after, for a small account (one app), a mid one (~20 apps) and a big |
| +// one (many apps, many non-record objects): whole-tree and accounts |
| +// listings, record GETs across every app, slot GETs. Nothing goes up for |
| +// any size, and the whole apps/ listings go from 5 to 2 (first) and 3 to 2 |
| +// (steady state). |
| +func TestSharedWalkStoreCallsPerPass(t *testing.T) { |
| + sizes := []struct { |
| + name string |
| + apps, perApp, junk int |
| + }{ |
| + {"small", 0, 0, 0}, // shop alone |
| + {"mid", 19, 1, 2}, // shop and 19 more apps |
| + {"big", 39, 2, 30}, // shop and 39 more, 1,170 non-record objects |
| + } |
| + for _, size := range sizes { |
| + t.Run(size.name, func(t *testing.T) { |
| + type run struct{ first, steady walkCalls } |
| + measure := func(shared bool) run { |
| + withWalkSharing(t, shared) |
| + ww := newWalkWorld(t, 3) |
| + ww.grow(t, size.apps, size.perApp, size.junk) |
| + first, _ := ww.boot(t, nil) |
| + if ww.b.row(ww.last) == nil { |
| + t.Fatalf("shared=%v: the boot pass did not mint %s", shared, ww.last) |
| + } |
| + return run{first: ww.calls(first), steady: ww.calls(ww.pass())} |
| + } |
| + before, after := measure(false), measure(true) |
| + t.Logf("first pass: before %+v, after %+v", before.first, after.first) |
| + t.Logf("steady pass: before %+v, after %+v", before.steady, after.steady) |
| + if min := 4 + size.apps*size.perApp; after.steady.records < min { |
| + t.Fatalf("the steady pass read %d records, want every app's (at least %d)", after.steady.records, min) |
| + } |
| + for _, c := range []struct { |
| + name string |
| + before, after walkCalls |
| + trees [2]int |
| + }{ |
| + {"first", before.first, after.first, [2]int{5, 2}}, |
| + {"steady", before.steady, after.steady, [2]int{3, 2}}, |
| + } { |
| + if c.before.trees != c.trees[0] || c.after.trees != c.trees[1] { |
| + t.Errorf("%s pass: whole apps/ listings before %d after %d, want %d and %d", c.name, c.before.trees, c.after.trees, c.trees[0], c.trees[1]) |
| + } |
| + if c.after.accounts > c.before.accounts || c.after.records > c.before.records || c.after.slots > c.before.slots || c.after.trees > c.before.trees { |
| + t.Errorf("%s pass: a store call went up: before %+v, after %+v", c.name, c.before, c.after) |
| + } |
| + if c.after.accounts != c.after.trees { |
| + t.Errorf("%s pass: %d accounts/ listings for %d walks", c.name, c.after.accounts, c.after.trees) |
| + } |
| + } |
| + }) |
| + } |
| +} |
| + |
| +// TestSharedWalkBumpDuringBootWalkListsAgain is the serial check's witness |
| +// (Fable round 1, P2-1): a record created and its bump made after the boot |
| +// walk began, before an unheld first tick, is not in the boot listing, and |
| +// the first tick seeds that bump. The boot walk is burned, so the first |
| +// tick's pass lists for itself and mints the record, rather than leaving it |
| +// to the instances floor. |
| +func TestSharedWalkBumpDuringBootWalkListsAgain(t *testing.T) { |
| + withWalkSharing(t, true) |
| + ww := newWalkWorld(t, 2) |
| + late := "bumped.example.com" |
| + ops, mark := ww.boot(t, func() { |
| + ww.putRecord(t, "shop", late) |
| + if err := release.BumpSerial(context.Background(), ww.w.store, time.Now()); err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| + if got := ww.calls(ops[mark:]).trees; got != 2 { |
| + t.Errorf("after the offline view the boot listed the whole tree %d times, want 2 (its own reconcile, moves)", got) |
| + } |
| + if ww.b.row(late) == nil { |
| + ww.tick() // the second tick, at most |
| + if ww.b.row(late) == nil { |
| + t.Fatalf("%s, created and bumped during the boot walk, was not minted by the first or second tick", late) |
| + } |
| + t.Errorf("%s was minted by the second tick, want the first", late) |
| + } |
| +} |
| + |
| +// TestSharedWalkMovesPassListsItself is the moves pass's witness (rule: |
| +// it acts only on its own walk, S3 change-index §4.3): a record created |
| +// after the pass's shared walk, before the moves pass, is listed and read by |
| +// the moves pass. The pass lists the whole tree once for reconcile and the |
| +// sidecar scan, and once more for the moves pass. The record is minted by |
| +// the next pass: nothing carries over. |
| +func TestSharedWalkMovesPassListsItself(t *testing.T) { |
| + withWalkSharing(t, true) |
| + ww := newWalkWorld(t, 2) |
| + ww.boot(t, nil) |
| + |
| + prevHook := passAfterReconcileHook |
| + t.Cleanup(func() { passAfterReconcileHook = prevHook }) |
| + var mark int |
| + var created string |
| + passAfterReconcileHook = func() { |
| + created = ww.createOnBox(t, "late2") |
| + mark = ww.door.mark() |
| + } |
| + from := ww.door.mark() |
| + ww.legs.full(provision.WithLifetimes(context.Background(), ww.judge)) |
| + passAfterReconcileHook = prevHook |
| + end := ww.door.mark() |
| + beforeMoves, moves := ww.door.between(from, mark), ww.door.between(mark, end) |
| + |
| + if got := ww.calls(beforeMoves).trees; got != 1 { |
| + t.Errorf("reconcile and the sidecar scan listed the whole tree %d times, want 1", got) |
| + } |
| + if got := ww.calls(moves).trees; got != 1 { |
| + t.Errorf("the moves pass listed the whole tree %d times, want 1 (its own walk)", got) |
| + } |
| + key := provision.RecordKey(ww.w.acct, "shop", created) |
| + if !gotKey(moves, opGet, key) { |
| + t.Errorf("the moves pass did not read %s, created after the shared walk", key) |
| + } |
| + if ww.b.row(created) != nil { |
| + t.Fatalf("%s was minted by the pass whose reconcile ran before it existed", created) |
| + } |
| + ww.pass() |
| + if ww.b.row(created) == nil { |
| + t.Errorf("the next pass did not mint %s", created) |
| + } |
| +} |
| + |
| +// createOnBox creates instances until one lands on pi-1 and returns its |
| +// host; the ones that land on pi-2 stay. |
| +func (ww *walkWorld) createOnBox(t *testing.T, prefix string) string { |
| + t.Helper() |
| + for i := 0; i < 4; i++ { |
| + h := fmt.Sprintf("%s%d.example.com", prefix, i) |
| + if rec := ww.w.create(h); rec.FleetBox == ww.b.label { |
| + return h |
| + } |
| + } |
| + t.Fatalf("no instance landed on %s", ww.b.label) |
| + return "" |
| +} |
| + |
| +// TestSharedWalkOfflineViewListsItself is the offline keep view's witness |
| +// (rule: the keep view is always read from the bucket): handed a share that |
| +// already holds a listing, it lists the bucket again and reads a record |
| +// created after that listing. A leg that may reuse the share (the boot |
| +// reader) does not see that record: the share is what the view must not |
| +// take. |
| +func TestSharedWalkOfflineViewListsItself(t *testing.T) { |
| + withWalkSharing(t, true) |
| + ww := newWalkWorld(t, 2) |
| + ctx := provision.WithLifetimes(context.Background(), ww.judge) |
| + share := provision.NewWalkShare() |
| + if _, _, err := provision.ListAllRecordsStrictJudgedShared(ctx, ww.door, ww.judge, share); err != nil { |
| + t.Fatal(err) |
| + } |
| + created := ww.createOnBox(t, "after") |
| + key := provision.RecordKey(ww.w.acct, "shop", created) |
| + |
| + from := ww.door.mark() |
| + refreshOfflineView(ctx, ww.door, armedOfflineView(), share) |
| + view := ww.door.between(from, ww.door.mark()) |
| + if got := ww.calls(view).trees; got != 1 { |
| + t.Errorf("the offline view listed the whole tree %d times with a filled share, want 1", got) |
| + } |
| + if !gotKey(view, opGet, key) { |
| + t.Errorf("the offline view did not read %s, created after the share's listing", key) |
| + } |
| + |
| + from = ww.door.mark() |
| + if _, _, err := provision.ListAllRecordsStrictJudgedShared(ctx, ww.door, ww.judge, share); err != nil { |
| + t.Fatal(err) |
| + } |
| + reuse := ww.door.between(from, ww.door.mark()) |
| + if ww.calls(reuse).trees != 0 || gotKey(reuse, opGet, key) { |
| + t.Errorf("control: a reader that takes the share listed %d times and read the late record: %v", ww.calls(reuse).trees, gotKey(reuse, opGet, key)) |
| + } |
| +} |
| + |
| +// TestSharedWalkBootPassReadsEveryRecordItself is a reusing leg's witness: |
| +// the boot pass takes the offline view's listing (no whole-tree listing for |
| +// reconcile), but a record whose body changed after that listing (moved to |
| +// another region) is read afresh and not minted, and a record created after |
| +// it is left to the next pass, which lists for itself and mints it. |
| +func TestSharedWalkBootPassReadsEveryRecordItself(t *testing.T) { |
| + withWalkSharing(t, true) |
| + ww := newWalkWorld(t, 2) |
| + var created string |
| + ops, mark := ww.boot(t, func() { |
| + ctx := provision.WithLifetimes(context.Background(), ww.judge) |
| + if err := provision.SetRecordRegion(ctx, ww.w.store, ww.w.acct, "shop", ww.last, "eu"); err != nil { |
| + t.Fatal(err) |
| + } |
| + created = "late.example.com" // written with no bump: the serial check keeps the boot walk |
| + ww.putRecord(t, "shop", created) |
| + }) |
| + firstTick := ops[mark:] |
| + if got := ww.calls(firstTick).trees; got != 1 { |
| + t.Errorf("after the offline view the boot lists the whole tree %d times, want 1 (the moves pass)", got) |
| + } |
| + if !gotKey(firstTick, opGet, provision.RecordKey(ww.w.acct, "shop", ww.last)) { |
| + t.Errorf("the boot pass did not read %s itself", ww.last) |
| + } |
| + if ww.b.row(ww.last) != nil { |
| + t.Errorf("the boot pass minted %s from a body older than its own read", ww.last) |
| + } |
| + if ww.b.row(created) != nil { |
| + t.Errorf("the boot pass minted %s, which its shared listing does not hold", created) |
| + } |
| + if got := ww.calls(ww.pass()).trees; got != 2 { |
| + t.Errorf("the next pass listed the whole tree %d times, want 2 (reconcile, moves)", got) |
| + } |
| + if ww.b.row(created) == nil { |
| + t.Errorf("the next pass did not mint %s", created) |
| + } |
| +} |
| + |
| +// TestSharedWalkBootWalkNotTakenAfterAnotherReconcile is the epoch guard's |
| +// witness (S3 change-index §4.3: a pass's listing is never older than the |
| +// previous pass's): a reconcile that runs between the boot walk and the |
| +// first tick makes the boot pass list for itself. |
| +func TestSharedWalkBootWalkNotTakenAfterAnotherReconcile(t *testing.T) { |
| + withWalkSharing(t, true) |
| + ww := newWalkWorld(t, 2) |
| + ops, mark := ww.boot(t, func() { |
| + cfg := ww.legs.cfg() |
| + if err := reconcileSerializedWith(context.Background(), ww.door, ww.b.reg, cfg, nil); err != nil { |
| + t.Fatal(err) |
| + } |
| + }) |
| + firstTick := ops[mark:] |
| + if got := ww.calls(firstTick).trees; got != 2 { |
| + t.Errorf("the boot pass listed the whole tree %d times after another reconcile, want 2 (its reconcile, moves)", got) |
| + } |
| + if ww.b.row(ww.last) == nil { |
| + t.Errorf("%s not minted", ww.last) |
| + } |
| +} |
diff --git a/internal/host/walkshare_test.go b/internal/host/walkshare_test.go| new file mode 100644 |
| index 000000000..c614298c6 |
| --- /dev/null |
| +++ b/internal/host/walkshare_test.go |
| @@ -0,0 +1,107 @@ |
| +package host |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "testing" |
| + |
| + "github.com/carlosframework/platform/internal/provision" |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// failSerialStore refuses every Get: the serial read before the boot walk |
| +// fails. |
| +type failSerialStore struct{ release.Store } |
| + |
| +func (failSerialStore) Get(context.Context, string) ([]byte, string, error) { |
| + return nil, "", errors.New("get refused") |
| +} |
| + |
| +// takeBootWalk's rules (walkshare.go): the boot walk goes to the first hold |
| +// that looks at it, only once, only when it holds a listing, only when the |
| +// first tick seeded the serial read before it (confirmBootWalk), and only |
| +// when no reconcile hold was running when it was set up or has begun since |
| +// (S3 change-index §4.3: a pass's listing is never older than the previous |
| +// pass's). Not parallel: reconcileEpoch is the process's. |
| +func TestTakeBootWalkRules(t *testing.T) { |
| + withWalkSharing(t, true) |
| + store := release.NewDirStore(t.TempDir()) // no serial object: it reads as 0 |
| + fill := func(ctx context.Context) { |
| + t.Helper() |
| + if _, _, err := provision.ListAllRecordsStrictJudgedShared(ctx, store, nil, bootWalkShare(ctx)); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, ok := bootWalkShare(ctx).ListedAt(); !ok { |
| + t.Fatal("fixture: the boot walk holds no listing") |
| + } |
| + } |
| + // boot is a filled boot walk over store, confirmed by a first tick that |
| + // seeds seed. |
| + boot := func(seed int64) context.Context { |
| + t.Helper() |
| + ctx := withBootWalk(context.Background(), store) |
| + fill(ctx) |
| + confirmBootWalk(ctx, seed) |
| + return ctx |
| + } |
| + |
| + if takeBootWalk(context.Background()) != nil { |
| + t.Fatal("a hold outside the boot took a boot walk") |
| + } |
| + |
| + empty := withBootWalk(context.Background(), store) |
| + confirmBootWalk(empty, 0) |
| + if takeBootWalk(empty) != nil { |
| + t.Error("a boot walk with no listing was taken") |
| + } |
| + |
| + ok := boot(0) |
| + if got := takeBootWalk(ok); got == nil || got != bootWalkShare(ok) { |
| + t.Error("the first hold after a clean, confirmed boot walk did not take it") |
| + } |
| + if takeBootWalk(ok) != nil { |
| + t.Error("the boot walk was taken twice") |
| + } |
| + |
| + unconfirmed := withBootWalk(context.Background(), store) |
| + fill(unconfirmed) // no first-tick seed (a held or unread serial) |
| + if takeBootWalk(unconfirmed) != nil { |
| + t.Error("the boot walk was taken with no serial seed to confirm it") |
| + } |
| + |
| + if takeBootWalk(boot(1)) != nil { |
| + t.Error("the boot walk was taken though the serial moved since it began") |
| + } |
| + |
| + unread := withBootWalk(context.Background(), failSerialStore{store}) |
| + fill(unread) |
| + confirmBootWalk(unread, 0) |
| + if takeBootWalk(unread) != nil { |
| + t.Error("the boot walk was taken though the serial before it could not be read") |
| + } |
| + |
| + after := boot(0) |
| + reconcileEpoch.Add(2) // a hold began and ended since the boot walk began |
| + if takeBootWalk(after) != nil { |
| + t.Error("the boot walk was taken after another hold ran") |
| + } |
| + |
| + reconcileEpoch.Add(1) // a hold is running as the boot walk begins |
| + during := boot(0) |
| + if takeBootWalk(during) != nil { |
| + t.Error("the boot walk was taken though a hold ran while it was read") |
| + } |
| + reconcileEpoch.Add(1) |
| + |
| + withWalkSharing(t, false) |
| + if bootWalkShare(withBootWalk(context.Background(), store)) != nil { |
| + t.Error("sharing off, the boot still carries a walk") |
| + } |
| +} |
| + |
| +func withWalkSharing(t *testing.T, on bool) { |
| + t.Helper() |
| + prev := shareRecordWalks |
| + t.Cleanup(func() { shareRecordWalks = prev }) |
| + shareRecordWalks = on |
| +} |
diff --git a/internal/provision/fleet_first_reconcile_speed_5_census_test.go b/internal/provision/fleet_first_reconcile_speed_5_census_test.go| new file mode 100644 |
| index 000000000..9a7d6c036 |
| --- /dev/null |
| +++ b/internal/provision/fleet_first_reconcile_speed_5_census_test.go |
| @@ -0,0 +1,49 @@ |
| +package provision |
| + |
| +// fleetFirstReconcileSpeed5WriteCensusInventory is the record-write census |
| +// for the shared record walk (fleet first reconcile plan, Task 5; branch |
| +// fleet-shared-walk), layered on dpaPDFWriteCensusInventory |
| +// (main's newest at the second merge of origin/main). Reviewed by the |
| +// branch author against the source. No class or site kind changes, no |
| +// unit added; five units are re-pinned, each because its record listing |
| +// now goes through a WalkShare (walkshare.go): |
| +// |
| +// - readAllRecordsJudged, readAllRecords: the account set and the apps/ |
| +// key listing come from w.accounts and w.subtree (knownAccountsNaming |
| +// and listAppSubtree when w is nil, every existing caller). Every |
| +// record key is still parsed and every body read here. |
| +// - scanInstanceRecords: the same through its new walk argument. |
| +// - Reconcile: its own scan passes cfg.liveWalk(s); the snapshot pass's |
| +// live re-walk passes nil. |
| +// - ReconcileSidecars: the scan closure takes the walk; its own scan |
| +// passes cfg.liveWalk(s), the freshStore re-walk nil. |
| +// |
| +// None writes a record it did not write before, and no key site moves. |
| +// Reconcile and ReconcileSidecars are re-pinned over main's own changes to |
| +// them (the Joining guard and the passStart split), which this branch |
| +// leaves as main has them. |
| +func fleetFirstReconcileSpeed5WriteCensusInventory() []censusEntry { |
| + entries := append([]censusEntry(nil), dpaPDFWriteCensusInventory()...) |
| + for _, r := range []censusEntry{ |
| + {"internal/provision/lifetime_judge.go", "readAllRecordsJudged", "key-site", "key:ParseRecordKey,lit:instances", "4701b49ad00a12ee41b5cbaa6615ef4d4759ad9587f2cc5e0253c9f487055813"}, |
| + {"internal/provision/reconcile.go", "Reconcile", "key-site", "key:RecordKey", "d717fa00a4f472487b004b6fdc5455aa574b364a352597a8bb41373cfde082bf"}, |
| + {"internal/provision/reconcile.go", "readAllRecords", "key-site", "key:ParseRecordKey,lit:instances", "dc7c5eabf6b2dbe32b6bf3fd38d67e3f481c480f64e672d5afb3933ac79fa72a"}, |
| + {"internal/provision/reconcile.go", "scanInstanceRecords", "key-site", "key:ParseRecordKey,key:RecordKey,lit:instances", "c207a52d6b6faff169c3eb0e10aa170fda26f0d0d7f5dc718ef69856468f66a8"}, |
| + {"internal/provision/sidecar_reconcile.go", "ReconcileSidecars", "key-site", "key:ParseSidecarKey,key:SidecarRecordKey,lit:sidecars", "5be1b18b60a0c636283e9b8a8ab5ad32fc3c9b417472647157aa76a1bf5b853d"}, |
| + } { |
| + replaced := false |
| + for i, e := range entries { |
| + if e.File == r.File && e.Unit == r.Unit { |
| + if e.Class != r.Class || e.Kinds != r.Kinds { |
| + panic("fleet-first-reconcile-speed-5 census: classification changed for " + r.File + ":" + r.Unit) |
| + } |
| + entries[i], replaced = r, true |
| + break |
| + } |
| + } |
| + if !replaced { |
| + panic("fleet-first-reconcile-speed-5 census: re-pin of an unlisted unit " + r.File + ":" + r.Unit) |
| + } |
| + } |
| + return entries |
| +} |
diff --git a/internal/provision/haingress.go b/internal/provision/haingress.go| index 4533bf63f..7522e13ca 100644 |
| --- a/internal/provision/haingress.go |
| +++ b/internal/provision/haingress.go |
| @@ -70,7 +70,7 @@ func HAIngressRoutesFromRecords(ctx context.Context, s release.Store, records [] |
| // withdrawing pools, or running any reconciliation hooks. |
| func ScanHAIngress(ctx context.Context, s release.Store, cfg ReconcileConfig) ([]Record, error) { |
| cfg.HAIngress = func([]Record, error) {} |
| - sc, err := scanInstanceRecords(WithLifetimes(ctx, cfg.Judge), s, cfg) |
| + sc, err := scanInstanceRecords(WithLifetimes(ctx, cfg.Judge), s, cfg, nil) |
| return sc.ingress, sc.ingressError(err) |
| } |
diff --git a/internal/provision/lifetime_judge.go b/internal/provision/lifetime_judge.go| index 6e2c4fc18..fd8d215ed 100644 |
| --- a/internal/provision/lifetime_judge.go |
| +++ b/internal/provision/lifetime_judge.go |
| @@ -298,7 +298,23 @@ func ListAllRecordsStrictJudged(ctx context.Context, s release.Store, j *Lifetim |
| if j == nil { |
| return ListAllRecordsStrict(ctx, s) |
| } |
| - recs, _, unreadable, err = readAllRecordsJudged(ctx, s, j, true) |
| + recs, _, unreadable, err = readAllRecordsJudged(ctx, s, j, true, nil) |
| + return recs, unreadable, err |
| +} |
| + |
| +// ListAllRecordsStrictJudgedShared is ListAllRecordsStrictJudged listing |
| +// through w (WalkShare): the account set and the apps/ listing come from w |
| +// when it holds them, and a clean listing read here is kept in it. Every |
| +// record and slot is still read here. A nil w is ListAllRecordsStrictJudged. |
| +func ListAllRecordsStrictJudgedShared(ctx context.Context, s release.Store, j *LifetimeJudge, w *WalkShare) (recs []Record, unreadable map[string]bool, err error) { |
| + if j == nil { |
| + recs, _, unreadable, err = readAllRecords(ctx, s, true, w) |
| + if err != nil { |
| + return nil, nil, err |
| + } |
| + return recs, unreadable, nil |
| + } |
| + recs, _, unreadable, err = readAllRecordsJudged(ctx, s, j, true, w) |
| return recs, unreadable, err |
| } |
| @@ -310,28 +326,29 @@ func ListAllRecordsTolerantJudged(ctx context.Context, s release.Store, j *Lifet |
| if j == nil { |
| return ListAllRecordsTolerant(ctx, s) |
| } |
| - recs, complete, _, err = readAllRecordsJudged(ctx, s, j, false) |
| + recs, complete, _, err = readAllRecordsJudged(ctx, s, j, false, nil) |
| return recs, complete, err |
| } |
| // readAllRecordsJudged is the judged sibling of readAllRecords. A corrupt body |
| // goes in unreadable and leaves complete true, as it does there; complete is |
| -// false only for an unreadable observation or a partial listing. |
| -func readAllRecordsJudged(ctx context.Context, s release.Store, j *LifetimeJudge, strict bool) (recs []Record, complete bool, unreadable map[string]bool, err error) { |
| +// false only for an unreadable observation or a partial listing. It lists |
| +// through w (nil: lists itself). |
| +func readAllRecordsJudged(ctx context.Context, s release.Store, j *LifetimeJudge, strict bool, w *WalkShare) (recs []Record, complete bool, unreadable map[string]bool, err error) { |
| complete = true |
| unreadable = map[string]bool{} |
| - known, readFailed, err := knownAccounts(ctx, s) |
| + known, failedAccts, err := w.accounts(ctx, s) |
| if err != nil { |
| return nil, false, nil, err |
| } |
| - if readFailed { |
| + if readFailed := len(failedAccts) > 0; readFailed { |
| if strict { |
| return nil, false, nil, errors.New("provision: an account manifest could not be read cleanly — refusing to report a partial record set") |
| } |
| log.Printf("provision: an account manifest could not be read cleanly: that account's records are skipped") |
| complete = false |
| } |
| - keys, partial, err := listAppSubtree(ctx, s, known, "instances/") |
| + keys, partial, err := w.subtree(ctx, s, known, "instances/") |
| if err != nil { |
| return nil, false, nil, fmt.Errorf("provision: list apps: %w", err) |
| } |
diff --git a/internal/provision/lifetime_judge_test.go b/internal/provision/lifetime_judge_test.go| index ef3a1caa7..eca23bb3c 100644 |
| --- a/internal/provision/lifetime_judge_test.go |
| +++ b/internal/provision/lifetime_judge_test.go |
| @@ -779,7 +779,7 @@ func TestJudgedTolerantListingCorruptBodyKeepsCompleteTrue(t *testing.T) { |
| return nil |
| }} |
| ctx := context.Background() |
| - recs, complete, unreadable, err := readAllRecordsJudged(ctx, s, NewLifetimeJudge(), false) |
| + recs, complete, unreadable, err := readAllRecordsJudged(ctx, s, NewLifetimeJudge(), false, nil) |
| if err != nil || len(recs) != 0 { |
| t.Fatalf("recs %+v err %v", recs, err) |
| } |
diff --git a/internal/provision/plan9_b8_census_test.go b/internal/provision/plan9_b8_census_test.go| index 520b27bc4..504fc4c7e 100644 |
| --- a/internal/provision/plan9_b8_census_test.go |
| +++ b/internal/provision/plan9_b8_census_test.go |
| @@ -366,7 +366,7 @@ func TestPlan9B8RecordWriteCensus(t *testing.T) { |
| if len(got) < 100 { |
| t.Fatalf("census found only %d units under %s; the walk is broken", len(got), root) |
| } |
| - inventory := dpaPDFWriteCensusInventory() |
| + inventory := fleetFirstReconcileSpeed5WriteCensusInventory() |
| problems := append(censusDiff(inventory, got), censusPolicy(inventory)...) |
| if len(problems) > 0 { |
| t.Fatalf("record-write census rejected %d site(s); update the explicit inventory only after reviewing the source:\n %s", len(problems), strings.Join(problems, "\n ")) |
diff --git a/internal/provision/reconcile.go b/internal/provision/reconcile.go| index 645c2cd04..ddcfecf50 100644 |
| --- a/internal/provision/reconcile.go |
| +++ b/internal/provision/reconcile.go |
| @@ -42,7 +42,14 @@ type ReconcileConfig struct { |
| // HAIngress receives the complete pre-pool record scan; errors revoke its evidence. |
| HAIngress func([]Record, error) |
| - Departures *DeparturePass |
| + Departures *DeparturePass |
| + // Walk is the pass's shared record listing (WalkShare): the instance |
| + // scan and then the sidecar scan list through it, so a pass lists the |
| + // records once. Used only over the live store, never over a record |
| + // view snapshot and never for the snapshot pass's live re-walk. Every |
| + // record body is still read by each scan. nil: each scan lists itself. |
| + Walk *WalkShare |
| + |
| ClaimEnabled bool |
| ClaimInstall func(context.Context, ClaimRecord, func(registry.ClaimOwnership) error) error |
| ClaimRetire func(context.Context, registry.Route) error |
| @@ -1201,11 +1208,11 @@ type recordScan struct { |
| unreadHosts map[string]bool |
| } |
| -func scanInstanceRecords(ctx context.Context, st release.Store, cfg ReconcileConfig) (recordScan, error) { |
| +func scanInstanceRecords(ctx context.Context, st release.Store, cfg ReconcileConfig, walk *WalkShare) (recordScan, error) { |
| var ingress []Record |
| var departureRecords []DepartureHost |
| departureInvalid := false |
| - known, failedAccts, err := knownAccountsNaming(ctx, st) |
| + known, failedAccts, err := walk.accounts(ctx, st) |
| if err != nil { |
| return recordScan{}, err |
| } |
| @@ -1213,7 +1220,7 @@ func scanInstanceRecords(ctx context.Context, st release.Store, cfg ReconcileCon |
| unread := map[string]bool{} |
| // --- collect in-scope records -------------------------------------------- |
| - keys, partial, err := listAppSubtree(ctx, st, known, "instances/") |
| + keys, partial, err := walk.subtree(ctx, st, known, "instances/") |
| if err != nil { |
| return recordScan{}, fmt.Errorf("provision: list apps: %w", err) |
| } |
| @@ -1496,10 +1503,12 @@ func Reconcile(ctx context.Context, s release.Store, reg *registry.Registry, cfg |
| cfg.Report.Complete = map[string]bool{} |
| } |
| + // The snapshot pass's live re-walks below list for themselves (nil); |
| + // only the pass's own scan lists through its shared walk (liveWalk). |
| scan := func(st release.Store) (recordScan, error) { |
| - return scanInstanceRecords(ctx, st, cfg) |
| + return scanInstanceRecords(ctx, st, cfg, nil) |
| } |
| - sc, err := scan(s) |
| + sc, err := scanInstanceRecords(ctx, s, cfg, cfg.liveWalk(s)) |
| if cfg.HAIngress != nil { |
| cfg.HAIngress(sc.ingress, sc.ingressError(err)) |
| } |
| @@ -3257,7 +3266,7 @@ func trashGate(ctx context.Context, s release.Store, what string) func(acct, app |
| // skipped and logged (Reconcile's `protect` treatment, minus the registry |
| // bookkeeping). One malformed record must not blind a caller to every other. |
| func ListAllRecords(ctx context.Context, s release.Store) ([]Record, error) { |
| - recs, _, _, err := readAllRecords(ctx, s, true) |
| + recs, _, _, err := readAllRecords(ctx, s, true, nil) |
| return recs, err |
| } |
| @@ -3280,7 +3289,7 @@ func ListAllRecords(ctx context.Context, s release.Store) ([]Record, error) { |
| // under an account with no manifest, or whose manifest is soft-deleted, are |
| // not in recs and not in unreadable. They are invisible, not unreadable. |
| func ListAllRecordsStrict(ctx context.Context, s release.Store) (recs []Record, unreadable map[string]bool, err error) { |
| - recs, _, unreadable, err = readAllRecords(ctx, s, true) |
| + recs, _, unreadable, err = readAllRecords(ctx, s, true, nil) |
| if err != nil { |
| return nil, nil, err |
| } |
| @@ -3296,7 +3305,7 @@ func ListAllRecordsStrict(ctx context.Context, s release.Store) (recs []Record, |
| // when nothing could be read. A caller that also draws conclusions from |
| // absence must act on that only when complete is true. |
| func ListAllRecordsTolerant(ctx context.Context, s release.Store) (recs []Record, complete bool, err error) { |
| - recs, complete, _, err = readAllRecords(ctx, s, false) |
| + recs, complete, _, err = readAllRecords(ctx, s, false, nil) |
| return recs, complete, err |
| } |
| @@ -3307,22 +3316,23 @@ func ListAllRecordsTolerant(ctx context.Context, s release.Store) (recs []Record |
| // view) treats a nonempty unreadable as incomplete. unreadable is non-nil |
| // whenever err is nil. |
| func ListAllRecordsTolerantUnreadable(ctx context.Context, s release.Store) (recs []Record, complete bool, unreadable map[string]bool, err error) { |
| - return readAllRecords(ctx, s, false) |
| + return readAllRecords(ctx, s, false, nil) |
| } |
| // readAllRecords is both: strict fails on any read failure, as |
| // ListAllRecords documents; tolerant logs it, skips what it could not read |
| // and reports complete false. In both modes unreadable holds the path host |
| // of every record that read but did not decode or disagreed with its path |
| -// (skipped, logged); it is non-nil whenever err is nil. |
| -func readAllRecords(ctx context.Context, s release.Store, strict bool) (recs []Record, complete bool, unreadable map[string]bool, err error) { |
| +// (skipped, logged); it is non-nil whenever err is nil. It lists through w |
| +// (WalkShare; nil lists itself). |
| +func readAllRecords(ctx context.Context, s release.Store, strict bool, w *WalkShare) (recs []Record, complete bool, unreadable map[string]bool, err error) { |
| complete = true |
| unreadable = map[string]bool{} |
| - known, readFailed, err := knownAccounts(ctx, s) |
| + known, failedAccts, err := w.accounts(ctx, s) |
| if err != nil { |
| return nil, false, nil, err |
| } |
| - if readFailed { |
| + if readFailed := len(failedAccts) > 0; readFailed { |
| if strict { |
| return nil, false, nil, errors.New("provision: an account manifest could not be read cleanly — refusing to report a partial record set") |
| } |
| @@ -3331,7 +3341,7 @@ func readAllRecords(ctx context.Context, s release.Store, strict bool) (recs []R |
| } |
| // Sorted (listAppSubtree sorts) so the result — and anything folded |
| // from it — is stable call to call, whatever order the store lists in. |
| - keys, partial, err := listAppSubtree(ctx, s, known, "instances/") |
| + keys, partial, err := w.subtree(ctx, s, known, "instances/") |
| if err != nil { |
| return nil, false, nil, fmt.Errorf("provision: list apps: %w", err) |
| } |
diff --git a/internal/provision/reconcile_test.go b/internal/provision/reconcile_test.go| index 65d8d181d..7d233b70d 100644 |
| --- a/internal/provision/reconcile_test.go |
| +++ b/internal/provision/reconcile_test.go |
| @@ -3639,7 +3639,7 @@ func TestReadAllRecordsTolerantNamesUnreadableHosts(t *testing.T) { |
| } |
| } |
| putReplace(t, s, RecordKey(sqid, "shop", "garbled.shop.example.com"), []byte("{not json")) |
| - recs, complete, unreadable, err := readAllRecords(ctx, s, false) |
| + recs, complete, unreadable, err := readAllRecords(ctx, s, false, nil) |
| if err != nil || !complete || len(recs) != 1 || recs[0].Host != "good.shop.example.com" { |
| t.Fatalf("recs %+v complete %v err %v", recs, complete, err) |
| } |
diff --git a/internal/provision/sidecar_reconcile.go b/internal/provision/sidecar_reconcile.go| index a72f752f4..868f00b17 100644 |
| --- a/internal/provision/sidecar_reconcile.go |
| +++ b/internal/provision/sidecar_reconcile.go |
| @@ -219,13 +219,16 @@ func ReconcileSidecars(ctx context.Context, s release.Store, reg *registry.Regis |
| readFailed bool |
| manifestFor func(acct, app string) (SidecarManifest, bool) |
| } |
| - scan := func(st release.Store) (*sidecarScan, error) { |
| + // walk is the pass's shared listing (ReconcileConfig.Walk) for the |
| + // pass's own scan over the live store; the snapshot pass's live |
| + // re-walk lists for itself (walk nil). |
| + scan := func(st release.Store, walk *WalkShare) (*sidecarScan, error) { |
| sc := &sidecarScan{} |
| - known, readFailed, err := knownAccounts(ctx, st) |
| + known, failedAccts, err := walk.accounts(ctx, st) |
| if err != nil { |
| return nil, err |
| } |
| - sc.readFailed = readFailed |
| + sc.readFailed = len(failedAccts) > 0 |
| // --- manifest cache, per (acct, app), lazily ------------------------------ |
| // known=false covers BOTH "no manifest" and "the read failed", and in both |
| @@ -269,7 +272,7 @@ func ReconcileSidecars(ctx context.Context, s release.Store, reg *registry.Regis |
| } |
| // --- collect in-scope records -------------------------------------------- |
| - keys, partial, err := listAppSubtree(ctx, st, known, "sidecars/") |
| + keys, partial, err := walk.subtree(ctx, st, known, "sidecars/") |
| if err != nil { |
| return nil, fmt.Errorf("provision: list apps: %w", err) |
| } |
| @@ -391,7 +394,7 @@ func ReconcileSidecars(ctx context.Context, s release.Store, reg *registry.Regis |
| sc.recs, sc.protect, sc.manifestFor = recs, protect, manifestFor |
| return sc, nil |
| } |
| - sc, err := scan(s) |
| + sc, err := scan(s, cfg.liveWalk(s)) |
| if sc == nil { |
| cfg.Departures.family("sidecar", nil, false) |
| } else { |
| @@ -572,7 +575,7 @@ func ReconcileSidecars(ctx context.Context, s release.Store, reg *registry.Regis |
| // every key, placement from the bucket's record and sidecars manifest |
| // against this box's inbound). Anything it cannot read keeps every row |
| // this pass, as in the walk. |
| - lsc, err := scan(freshStore(s)) |
| + lsc, err := scan(freshStore(s), nil) |
| if err != nil || lsc.readFailed { |
| log.Printf("provision: not removing any sidecar route this pass: the record view lacks a sidecar this box would run, and the bucket's own walk could not be read cleanly%s", walkErrSuffix(err)) |
| return nil |
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv| index 483631184..b6285d89e 100644 |
| --- a/internal/provision/testdata/plan14-root-reads-chain.tsv |
| +++ b/internal/provision/testdata/plan14-root-reads-chain.tsv |
| @@ -300,3 +300,4 @@ plan14-root-reads-store-write-credential-phase2-fixes.tsv ce6e123ac6a66f77f39ca4 |
| plan14-root-reads-static-error-page-headers.tsv 4d4fdb77961d811bcfeae751b17089f0104d2333923a15b4c1ab5cc05d58d89f |
| plan14-root-reads-replica-read-lock-1443.tsv 4d4fdb77961d811bcfeae751b17089f0104d2333923a15b4c1ab5cc05d58d89f |
| plan14-root-reads-litestream-pin-1443.tsv 022a082b517b59ada965bbd7673e941be7c8bb4ae7547a5632f6be0570c97551 |
| +plan14-root-reads-fleet-first-reconcile-speed-5.tsv dbdeb2e3a1a89cb8f33584fdb80a3bf1c5adef14ce222fef9d442ed8e059699c |
diff --git a/internal/provision/testdata/plan14-root-reads-fleet-first-reconcile-speed-5.tsv b/internal/provision/testdata/plan14-root-reads-fleet-first-reconcile-speed-5.tsv| new file mode 100644 |
| index 000000000..f29da80d9 |
| --- /dev/null |
| +++ b/internal/provision/testdata/plan14-root-reads-fleet-first-reconcile-speed-5.tsv |
| @@ -0,0 +1,22 @@ |
| +# Census overlay fleet-first-reconcile-speed-5, written by census-propose (#369). census-ruling-fleet-first-reconcile-speed-5, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-fleet-first-reconcile-speed-5.md. |
| +# 6 body, 0 sites, 2 envelope: each changed unit re-frozen at its existing disposition with its claim appended. |
| +# 3 new dispositions: 0 reads re-frozen at their disposition with the claim, 3 new units frozen accepted-legacy, 0 quiet units retired while they read nothing, 0 other. |
| +@legacy 2de66f6f3468aee56f7ed3681159654ee70fc7d86cdaa480dd57273ef4a97e85 internal/host/agent.go fastTick legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved;rev3=census-ruling-stateless-replicas-1;basis=Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. Final review I3: signal the owned renewal worker instead of waiting for its sequential console HTTP calls. Existing convergence and record read unchanged.;rev3=census-ruling-region-ha-p3a;basis=Run the optional desired-role reader on the existing tick after observing the armed change index; no new root path or timer, nil reader is unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: signals the owned replica worker on the existing tick; coalesced asynchronous execution, no timer or bucket scan added. merge of origin/main 7920cccf: Retain main box-role reader pass on the existing tick alongside the replica worker signal; merge-only body change, unchanged read sites.;rev3=census-ruling-restart-new-box-gap;basis=calls the optional restartGain hook (restartGainSeed) once per existing tick before the serial read; no new root path, timer or read kind; nil hook is unchanged;rev3=census-ruling-agent-start-demo-3;basis=Refresh moved notices through the shared watch before normal convergence; no new per-box poll. Census read-site delta: unchanged (1).;rev3=census-ruling-stateless-replicas-4-task1;basis=Signals the owned replica swap worker (armedReplicaDeploy.tick) beside the placement worker on the existing tick; coalesced background pass, no timer, no bucket read. Its transitions go through the console's authenticated /deploy.;rev3=census-ruling-platform-mail-submission;basis=Task 4: on a serial move, after the schedule leg, starts the armed mail switch cache's Refresh on its own goroutine (each read bounded at 2 s, overlapping refreshes skipped). It re-reads the app sender records already cached, through the agent's deploy store. Agent, not root; the tick waits on nothing new. Fable final P2-1: on a serial move, before the pass set and the restart leg, calls the armed cache's MarkStale (a counter bump under the cache's mutex; no I/O), so a spawn the move causes reads the switch again, bounded, instead of using an answer from before the move. No read added.;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only: d.startup.done(<part>) calls between the existing parts and a deferred one after the sweep. d.startup is nil on every tick but the first after agent start, and its methods are then no-ops. No read added, no order change; read site unchanged (1). Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=Startup serial hold (whole-branch review P1). While fastDeps.serialAfter is open (fastBoot closes it when the restart and sidecar wake baselines have read) the tick skips its one ReadSerial of control/serial, so it neither seeds nor acts on a move; the rest of the tick (backstop full pass, index, sweep) is unchanged. A full pass run while held sets fullBeforeSeed, and the seed then sets fullDue once so the backstop branch runs one more full pass under the clamp. Same read, read sites unchanged (1); no read added. Agent, not root.;rev3=census-ruling-managed-fleets-2b2;basis=calls d.managedReady after the serial read on every tick (nil on BYO, returns at once once admitted); no read of its own added; merge of origin/main 65951fbb: main's replica swap worker tick, mail switch refresh, startup timing and startup serial hold (serialHeld skips the ReadSerial), not this branch; resolution: d.managedReady still runs on every tick after the serial step, with serialOK false on a held tick (no serial was read), so only the leg's backstop applies then;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5, review round 1 fix): where the first good serial read seeds lastSerial, confirmBootWalk(ctx, doc.Serial) marks the boot walk takeable only if the serial read before the boot walk read and equals the seed; otherwise the first hold lists for itself. In-memory flag only; no read or write added; read sites unchanged (1). Agent, not root. registry:Host@7773 afa474b1a584fab5955c96c67024100664d9bbe0948669e1bb56d62e44f41597 |
| +@legacy 6379a4d63018efacbd50ff476ede0d238025961e2d49e7c893df696854e55d8b internal/host/fastboot.go fastBoot.seed legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=New (Task 4): the seeds moved out of fastConvergeLoop, same order. restartSeed is called directly (its own reg.List, then restartBaseline, as fastConvergeLoop called it before), sidecarWakeBaseline over the arming route snapshot (or the existing list-error line), then it closes the serial hold, waits for the views, and runs runRunsBootPass, sd.converge and systemLeg.observe (systemLeg.store swapped to the counting wrapper and restored), the last three through package func vars defaulting to them. A nil test hook (bootBeforeBaseline) precedes each baseline. Same calls and keys as before; no read added. Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): takes the boot context beside ctx and runs the runs boot pass under it, so that pass lists records through the boot walk's share; every other seed keeps ctx. Same calls and keys; no read added. Agent, not root. whole:Route@646 39a5359f700d0d02c589d6c1b4ad0e4095fafd5be46b14e28279039a8f40bbe6 |
| +@legacy ea888f35db1a8792d6652b299165f46c66f3f1f913f16bb62e5993c4887b669c internal/host/fastboot.go fastBoot.start legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=New (Task 4): the arming order moved out of fastConvergeLoop. One reg.List of this box's registry (the route snapshot for the sidecar baseline), starts the seeds goroutine first, then refreshMovesHolds and refreshOfflineView (through package func vars defaulting to them), sets fastDeps.serialAfter, runs the first tick, and returns ready, which waits for the seeds (one log line if over slowLegAfter), runs runRunsPass once (through bootRunsNotes; the same runs pass every full pass runs, for notes the first tick kept while the runs boot pass was unfinished), clears the serial hold and assigns the seeded legs to fastDeps. No read beyond those the moved calls and that existing runs pass already make. Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): makes the boot context (withBootWalk(ctx, b.viewStore): an in-memory WalkShare, the reconcile epoch and, review round 1 fix, one release.ReadSerial of the deployment serial read before the offline view's walk, kept to compare with the first tick's seed) and hands it to the offline view, the seeds goroutine (for the runs boot pass only) and the first tick. Same calls in the same order plus that one serial GET per boot; nothing is decided from it but whether the first hold may reuse the boot listing. Agent, not root. whole:Route@505 42d2fd3a4d1e6ec137227d4df2b0622e0eca67b296d14ce9ab5f01726442af95 |
| +@legacy b7d98bfd479a34f1f3243b3321f288b8020ff304ecdbd180ccea926092eb7133 internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 4, rules 2 and 9): after inScope, a record failing cfg.ownsRecord (on a fleet box, labelled for another box: rec.FleetBox != "" and != cfg.FleetBox) is skipped as out of scope, so it is never minted here; in the removal phase such a record no longer keeps the row (inScope && ownsRecord), so the row goes as record gone. Off a fleet ownsRecord is always true. Read sites unchanged (178). The agent's reconcile loops, not root; it mints less, never more.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call; merge of origin/main 6f1f6ca6: main's fleet-box ownsRecord skip in the record scan and in the removal phase is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (178);rev3=census-ruling-stateless-replicas-1;basis=Task 3b: call the optional binding callback only for applied, owned stateless rows outside dry run. Reuses this pass record and route reads after existing collision, scope, hold, policy and shape checks; no new record read or typed writer. Fix 3b round 1 I1: binding callback failure is logged and falls through to pr.applied; same per-host callback, record writers, scope and removal gates. TestStatelessBindingFailureContinuesReconcile covers second-record convergence, removal, applied bookkeeping and next-pass retry.;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: collect validated instance records from the existing scan before pool filtering; report source completeness separately. Record reads, writes, scope and removal authority unchanged.;rev3=census-ruling-agent-start-demo-1;basis=Keeps local demo rows for signed cleanup instead of deleting the binding on record absence or trash; normal/hub paths unchanged. Merge integration against origin/main 9bd45488 retains main's HA departure inventory scan and family-completeness reporting alongside the early local-demo retention guard; existing record reads retained.;rev3=census-ruling-stateless-replicas-2;basis=Final fix I1: legacy records now reach the legacy ownership/removal judgement for former set rows; a greater local incarnation remains protected. Current set-record lifetime and membership checks remain. Same record/registry reads and removal writers. TestReplicaReconcileLegacySuccessor covers both boxes with and without the judge; P11 newer/unknown set protections remain covered. merge of origin/main 6be08467: Retain main signed demo retirement ownership alongside replica set retirement and legacy successor recovery; merge-only body change, unchanged read sources.;rev3=census-ruling-agent-start-demo-3;basis=Install durable source claim holds and reconcile fresh destination seed gates; preserve owned pending routes and stop orphan seeds before cleanup. Census read-site delta: +registry:Account, +registry:App, +registry:Host, +registry:ImportGate ×2, +registry:SeedSource ×2, +whole:Route ×4.;rev3=census-ruling-region-ha-g2-fixes;basis=Run guarded pool withdrawal, extract the unchanged judged collection rules into scanInstanceRecords, and publish pre-pool HA ingress including stale refusal names. Existing direct route reads remain; indirect withdrawal reads and deletion are separately claimed.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: where a forward row holds an in-scope record's host, a link-placed one (registry.LinkPlacement over the listed row's Region) gets its own log line saying no pass here retires it; the record is still not applied, as before; one +registry:Region read of the listed row, no write added;rev3=census-ruling-stateless-replicas-4-drill1;basis=#511 drill 1 F4: for a stateless row with a copy assignment (record or row), the binding callback gets the row as convergeOwned left it: one local registry Get of the same host after the pass's own writes; a row that cannot be read is logged (round 1, Fable M7) and bound next pass; no record read or write added;rev3=census-ruling-fleet-seeded-create-1;basis=In the per-record seed dispatch (the seedFinishAbort case), Reconcile asks abortRetiresRow(rec) (seedreconcile.go) instead of comparing rec.Seed.Kind to seeds.KindReplica, so an aborted file seed goes through the same row retirement and marker-decided purge as an aborted --from seed; the kind check only, no new read or write, registry read sites unchanged; the agent as carlos, not root; it retires a row it would already retire for a replica seed.;rev3=census-ruling-managed-fleets-2b2;basis=returns nil before any list, mint or removal while ReconcileConfig.Joining answers true (a joining managed box); ownsRecord also refuses every record then; no read added; merge of origin/main 65951fbb: main's link-placed forward log line (+registry:Region), drill 1 F4 row re-read for the stateless binding and abortRetiresRow seed dispatch, not this branch; code-health split: the joining guard, withdrawPools, the demo claim holds and the Now default moved, in order, to ReconcileConfig.passStart, no read added;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): the pass's own instance scan over the live store calls scanInstanceRecords with cfg.liveWalk(s) (the pass's WalkShare, nil over a record view snapshot); the snapshot pass's live re-walk passes nil and lists the bucket itself. The share answers only the account set and the apps/ key listing; every record body and slot is still read by the scan. Read sites unchanged (236); fewer listings, no read added. Agent, not root. registry:Account@26923,registry:Account@28793,registry:Account@48186,registry:Account@48232,registry:Account@49861,registry:Account@50238,registry:Account@50464,registry:Account@50531,registry:Account@50577,registry:Account@50670,registry:Account@50712,registry:Account@51360,registry:Account@51618,registry:Account@52520,registry:Account@52568,registry:Account@52977,registry:Account@53023,registry:Account@53268,registry:Account@53693,registry:Account@54181,registry:Account@54525,registry:Account@55127,registry:Account@55320,registry:Account@55732,registry:Account@55911,registry:Account@56235,registry:Account@56800,registry:App@26896,registry:App@28766,registry:App@48206,registry:App@48244,registry:App@49873,registry:App@50250,registry:App@50476,registry:App@50551,registry:App@50589,registry:App@50690,registry:App@51372,registry:App@51630,registry:App@52532,registry:App@52580,registry:App@52997,registry:App@53035,registry:App@53280,registry:App@53705,registry:App@54193,registry:App@54537,registry:App@55139,registry:App@55332,registry:App@55744,registry:App@55923,registry:App@56247,registry:App@56812,registry:Canary@48699,registry:ClaimOwnership@27510,registry:DBPath@37420,registry:DBPath@37435,registry:DBPath@37681,registry:DBPath@38284,registry:DBPath@38297,registry:EgressAllow@26009,registry:FleetBoxes@38780,registry:FleetBoxes@48660,registry:FleetBoxes@48808,registry:FleetBoxes@55520,registry:Gate@33317,registry:Gate@33457,registry:Gate@33744,registry:Hibernate@31989,registry:Hibernate@32187,registry:Hibernate@32252,registry:Hibernate@32591,registry:Hibernate@32942,registry:Hibernate@33252,registry:HoldOp@18014,registry:HoldOp@54872,registry:HoldOp@54963,registry:HoldOp@55098,registry:HoldOp@55474,registry:Host@15513,registry:Host@18417,registry:Host@18557,registry:Host@48165,registry:Host@48759,registry:Host@49837,registry:Host@50214,registry:Host@50378,registry:Host@50484,registry:Host@51380,registry:Host@51586,registry:Host@52860,registry:Host@53132,registry:Host@53247,registry:Host@53570,registry:Host@53667,registry:Host@54058,registry:Host@54155,registry:Host@54369,registry:Host@54571,registry:Host@54954,registry:Host@55089,registry:Host@55293,registry:Host@55366,registry:Host@55465,registry:Host@55705,registry:Host@55884,registry:Host@55963,registry:Host@56050,registry:Host@56209,registry:Host@56284,registry:Host@56370,registry:Host@56777,registry:ImportGate@34896,registry:ImportGate@35195,registry:Incarnation@18190,registry:Incarnation@48877,registry:Kind@18402,registry:Kind@18542,registry:Kind@27652,registry:Kind@28018,registry:Kind@28300,registry:Kind@28520,registry:Kind@37338,registry:Kind@37351,registry:Kind@37461,registry:Kind@37474,registry:Kind@38195,registry:Kind@38206,registry:Kind@47289,registry:Kind@54360,registry:Kind@55080,registry:Kind@55456,registry:Kind@55696,registry:Kind@56041,registry:Kind@56200,registry:Kind@56361,registry:Platform@48684,registry:PolicyExpiresAt@26034,registry:Pool@47375,registry:Provisioned@26872,registry:Provisioned@28742,registry:Provisioned@47334,registry:RateLimit@33830,registry:RateLimit@33981,registry:RateLimit@34268,registry:Region@17381,registry:Region@47364,registry:ReplicaIncarnation@17898,registry:ReplicaIncarnation@17935,registry:Replication@32676,registry:Replication@32803,registry:Runtime@19586,registry:Runtime@19764,registry:Runtime@22057,registry:Runtime@31356,registry:Runtime@31410,registry:Runtime@31614,registry:Seed@35818,registry:SeedSource@34854,registry:SeedSource@35174,registry:SeedSource@35301,registry:Size@26025,registry:Socket@37386,registry:Socket@37401,registry:Socket@37698,registry:Socket@38254,registry:Socket@38267,registry:Stateless@38355,registry:Unit@37304,registry:Unit@37317,registry:Unit@38221,registry:Unit@38232,whole:ClaimOwnership@27513,whole:ClaimOwnership@27530,whole:Route@15495,whole:Route@15506,whole:Route@15524,whole:Route@16805,whole:Route@17790,whole:Route@18001,whole:Route@18316,whole:Route@18602,whole:Route@18616,whole:Route@18629,whole:Route@18652,whole:Route@20081,whole:Route@20088,whole:Route@20128,whole:Route@20489,whole:Route@20644,whole:Route@20915,whole:Route@21362,whole:Route@21413,whole:Route@21450,whole:Route@23122,whole:Route@23331,whole:Route@23670,whole:Route@23679,whole:Route@23725,whole:Route@25958,whole:Route@26517,whole:Route@26988,whole:Route@26998,whole:Route@27355,whole:Route@27362,whole:Route@27430,whole:Route@27793,whole:Route@27849,whole:Route@27919,whole:Route@27930,whole:Route@28358,whole:Route@29391,whole:Route@32342,whole:Route@35003,whole:Route@37530,whole:Route@38731,whole:Route@38837,whole:Route@39026,whole:Route@39089,whole:Route@39982,whole:Route@40027,whole:Route@40037,whole:Route@40907,whole:Route@41934,whole:Route@47400,whole:Route@47548,whole:Route@48645,whole:Route@49015,whole:Route@49789,whole:Route@50171,whole:Route@52022,whole:Route@54463,whole:Route@55611,whole:Route@56122,whole:Route@56707,whole:Route@56757 d717fa00a4f472487b004b6fdc5455aa574b364a352597a8bb41373cfde082bf |
| +@legacy c39b3321a6b9461f8d7083f0b310448355324e2591727b7b20c8589be594153f internal/provision/sidecar_reconcile.go ReconcileSidecars legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=the record walk and its sidecars manifest lookup move unchanged into the pass's scan closure (over a store argument) and the removal phase into its retire closure; over a record view snapshot, a pass that reaches a removal candidate (a sidecar gone or no longer placeable here) removes nothing on the snapshot's word: it runs scan again over the bucket (freshStore) and decides every removal that pass from that walk, by the walk's own rules (unusable records protected before scope, hosts matched across every key, placement from the bucket's record and sidecars manifest against this box's inbound); a walk that cannot read cleanly keeps every row; with no candidate, or disarmed, nothing is read again; the registry sites are main's, moved; relative to main's single walk a removal can only be withheld, never added;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: retain validated sidecar records before scope/manifest filtering for coverage, including hidden/out-of-pool records. No new object reads or sidecar HA authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Derive canonical sidecar lifetimes from account/app/synthetic host/CreatedAt; collect HA and manifest placement for departures before scope filtering; update a separate family in the existing lifetime index. Existing record reads, key parsing and removal authority remain.;rev3=census-ruling-region-ha-g2-fixes;basis=Run sidecar-scoped pool withdrawal before the existing pass; existing direct reads unchanged, new indirect stop/record/deletion checks are in withdrawal helpers.;rev3=census-ruling-managed-fleets-2b2;basis=returns nil before any list, mint or removal while ReconcileConfig.Joining answers true; no read added;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): the scan closure takes a WalkShare and lists accounts and the apps/ keys through it (knownAccounts and listAppSubtree when nil); the pass's own scan over the live store passes cfg.liveWalk(s), the snapshot re-walk over freshStore passes nil and lists the bucket itself. Every record body is still read by the scan. Read sites unchanged (47); no read added. Agent, not root. registry:Account@13045,registry:Account@13284,registry:Account@14237,registry:Account@14987,registry:App@13018,registry:App@13270,registry:App@14210,registry:App@14973,registry:Args@13862,registry:Args@14133,registry:Channel@13850,registry:ClaimOwnership@13663,registry:Host@10639,registry:Host@16323,registry:Host@16370,registry:Host@16493,registry:Host@16670,registry:Host@16819,registry:Host@16926,registry:Kind@12959,registry:Kind@13233,registry:Kind@14150,registry:Kind@14936,registry:Kind@16156,registry:Pool@16274,registry:Provisioned@12991,registry:Provisioned@13248,registry:Provisioned@14182,registry:Provisioned@14951,registry:Provisioned@16183,registry:Region@16224,whole:ClaimOwnership@13666,whole:ClaimOwnership@13683,whole:Route@10621,whole:Route@10632,whole:Route@10650,whole:Route@10836,whole:Route@11205,whole:Route@11214,whole:Route@12647,whole:Route@13508,whole:Route@13515,whole:Route@13583,whole:Route@13918,whole:Route@14295,whole:Route@16141,whole:Route@16736 5be1b18b60a0c636283e9b8a8ab5ad32fc3c9b417472647157aa76a1bf5b853d |
| +@legacy 3a99ee6c3b77ab5f6a325173b69861a06f7cdfb462268a0e94434f00e5dd9599 internal/host/agent.go reconcileSerializedAuth legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): under reconcileMu, before any record read, beginHoldWalk sets cfg.Walk to the boot walk's share (first hold only, when no hold ran since it was read) or a fresh provision.WalkShare, nil over a record view snapshot, and moves the in-process reconcile epoch for the hold. The departure walk start and the asset authority pass start go back to the share's earliest listing when it holds one (earlier, never later). refreshOfflineView and the instance and sidecar scans list through cfg.Walk; every record body and slot is still read in the hold. Two adjacent !cached blocks merged. The +file:Walk reads are the in-memory config field, no store or file read; fewer bucket listings, no read added. Agent, not root. file:Walk@2029,file:Walk@3851 c36d3e132d3aa8d5ce3e81a21963ef915c27e71fc1631e238c752287a51e1070 |
| +@legacy 65801fe1a192aeebf0dc008ef493c3655b12ece154ca9b31c1c134b21b94b3e4 internal/provision/reconcile.go type ReconcileConfig legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): new field Walk *WalkShare, the pass's shared record listing; nil (every existing caller) lists as before. A config field, no read. file:Walk@667 0b750f71ddc90af7054bfeab88d0f6f383a45210e3b91495a1d455b1bc142ebc |
| +@legacy 01951fde684fa61e3ab9b196accfbf393465f01a13c074ef4540a4fe82f95e4a internal/provision/walkshare.go ReconcileConfig.liveWalk legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=New (Task 5): returns cfg.Walk, or nil when the store is a record view snapshot (onSnapshot). Pure; no store read. file:Walk@110 a6546cc7b098732c364d9a1cd9bc64121cb52d02ed4046eccec9854ac2d80290 |
| +internal/host/agent.go fastConvergeLoop authority B3 rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos): every pass context carries the box's lifetime judge (provision.WithLifetimes) and the reconcile config is boxProvisionConfig's; read sites unchanged, offsets moved; B3 authority retained;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 12: its pass config is now BoxProvisionConfig(reg, os.Getenv, judge, configure) (BoxProvisionConfig replaces boxProvisionConfig: the hub predicate hubArmed and, on the hub, ReconcileConfig.FleetOwners from hubFleetOwners); a call, no read site; read sites unchanged (2); B3 authority retained.;rev3=census-ruling-stateless-replicas-1;basis=Final review I3: wire the coordinator's nonblocking SignalTick to the existing fast tick. No new timer, polling read or authority.;rev3=census-ruling-region-ha-p3b;basis=Bind systemLeg to the existing cached reader fold and handle a nil leg on groups; names-2 rollback gate runs before artifact/request/marker work. Agent-memory evidence only, no new direct or cloud read and no autonomous group update.;rev3=census-ruling-restart-new-box-gap;basis=restart leg closure moved into armRestartLegs (same reg.List + restartRequestLeg); also wires restartGain; read moved, not added;rev3=census-ruling-agent-start-demo-3;basis=Attach the moved reader to the existing shared change watch and advertise that reader as armed. Census read-site delta: unchanged (2).;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only (fleet first reconcile Task 1). Logs its entry offset and one line per arming step, then times the first tick. restartSeed, sidecarWakeSeed, refreshMovesHolds, refreshOfflineView and the one arming systemLeg.observe now read through countStore(store), a pass-through wrapper that counts and times each call and forwards it unchanged with the same key; for that observe, systemLeg.store is swapped to the wrapper and restored. For the first tick only, d.store is a fresh countStore(store) wrapper and d.startup a step logger; both are reset to the plain store and nil after the tick. passLegs gets startup. Same calls in the same order, no read added; read sites unchanged (1). Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=Arming order only (fleet first reconcile Task 4). The moves hold view, the offline view, the restart seed, the sidecar wake seed, the runs boot pass, the arming schedule converge and the arming systemLeg.observe are no longer called here: fastBoot.start runs them (views on this goroutine, then the first tick at once with the seeds beside it). The restart legs, the sidecar wake leg closure (same reg.List + sidecarWakeLeg) and newSystemLeg are built here as before and handed to fastBoot, which gives them to fastDeps once the seeds return, before the second tick. The first tick no longer waits for a tick's sleep. Same calls with the same arguments and keys; no read added; read sites unchanged (1). Agent, not root.;rev3=census-ruling-managed-fleets-2b2;basis=sets fastDeps.managedReady from the armed managedJoin (nil on BYO): the joining ready leg, a store-door GET of fleets/<fleet>/boxes/<label>/ready.json and a local root-door relay; requests a full pass on root's 200; no new read in this unit; merge of origin/main 65951fbb: main's fleet first reconcile speed (startup timing lines, countStore, arming moved into fastBoot), not this branch;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (fleet first reconcile Task 5): the first-tick closure handed to fastBoot.start now takes the context start gives it (the arming context carrying the boot walk) and runs the first tick under it. Same calls, same store wrappers, no read added; read sites unchanged (1). Agent, not root. whole:Route@8145 a7bc76b286ab30e01af6407f4945d3ae0296119feba655dc30624dd86cd15056 |
| +internal/host/agent.go fastTick legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=observes the change index before any pass (observeIndex), runs the backstop's requested full pass and a scoped pass for moved app scopes (indexTick), and arms the canary pointer gate on the sweep (canaryPointerGate) only on a tick whose own index observation succeeded; read site unchanged, offset moved;rev3=census-ruling-stateless-replicas-1;basis=Call coordinator Tick on the existing tick before convergence; client renews held terms only at the pinned interval. Existing registry read unchanged. Final review I3: signal the owned renewal worker instead of waiting for its sequential console HTTP calls. Existing convergence and record read unchanged.;rev3=census-ruling-region-ha-p3a;basis=Run the optional desired-role reader on the existing tick after observing the armed change index; no new root path or timer, nil reader is unchanged.;rev3=census-ruling-stateless-replicas-2;basis=Slice 3b: signals the owned replica worker on the existing tick; coalesced asynchronous execution, no timer or bucket scan added. merge of origin/main 7920cccf: Retain main box-role reader pass on the existing tick alongside the replica worker signal; merge-only body change, unchanged read sites.;rev3=census-ruling-restart-new-box-gap;basis=calls the optional restartGain hook (restartGainSeed) once per existing tick before the serial read; no new root path, timer or read kind; nil hook is unchanged;rev3=census-ruling-agent-start-demo-3;basis=Refresh moved notices through the shared watch before normal convergence; no new per-box poll. Census read-site delta: unchanged (1).;rev3=census-ruling-stateless-replicas-4-task1;basis=Signals the owned replica swap worker (armedReplicaDeploy.tick) beside the placement worker on the existing tick; coalesced background pass, no timer, no bucket read. Its transitions go through the console's authenticated /deploy.;rev3=census-ruling-platform-mail-submission;basis=Task 4: on a serial move, after the schedule leg, starts the armed mail switch cache's Refresh on its own goroutine (each read bounded at 2 s, overlapping refreshes skipped). It re-reads the app sender records already cached, through the agent's deploy store. Agent, not root; the tick waits on nothing new. Fable final P2-1: on a serial move, before the pass set and the restart leg, calls the armed cache's MarkStale (a counter bump under the cache's mutex; no I/O), so a spawn the move causes reads the switch again, bounded, instead of using an answer from before the move. No read added.;rev3=census-ruling-fleet-first-reconcile-speed;basis=Startup timing log lines only: d.startup.done(<part>) calls between the existing parts and a deferred one after the sweep. d.startup is nil on every tick but the first after agent start, and its methods are then no-ops. No read added, no order change; read site unchanged (1). Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=Startup serial hold (whole-branch review P1). While fastDeps.serialAfter is open (fastBoot closes it when the restart and sidecar wake baselines have read) the tick skips its one ReadSerial of control/serial, so it neither seeds nor acts on a move; the rest of the tick (backstop full pass, index, sweep) is unchanged. A full pass run while held sets fullBeforeSeed, and the seed then sets fullDue once so the backstop branch runs one more full pass under the clamp. Same read, read sites unchanged (1); no read added. Agent, not root.;rev3=census-ruling-managed-fleets-2b2;basis=calls d.managedReady after the serial read on every tick (nil on BYO, returns at once once admitted); no read of its own added; merge of origin/main 65951fbb: main's replica swap worker tick, mail switch refresh, startup timing and startup serial hold (serialHeld skips the ReadSerial), not this branch; resolution: d.managedReady still runs on every tick after the serial step, with serialOK false on a held tick (no serial was read), so only the leg's backstop applies then;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5, review round 1 fix): where the first good serial read seeds lastSerial, confirmBootWalk(ctx, doc.Serial) marks the boot walk takeable only if the serial read before the boot walk read and equals the seed; otherwise the first hold lists for itself. In-memory flag only; no read or write added; read sites unchanged (1). Agent, not root. registry:Host@7773 afa474b1a584fab5955c96c67024100664d9bbe0948669e1bb56d62e44f41597 |
| +internal/host/fastboot.go fastBoot.seed legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=New (Task 4): the seeds moved out of fastConvergeLoop, same order. restartSeed is called directly (its own reg.List, then restartBaseline, as fastConvergeLoop called it before), sidecarWakeBaseline over the arming route snapshot (or the existing list-error line), then it closes the serial hold, waits for the views, and runs runRunsBootPass, sd.converge and systemLeg.observe (systemLeg.store swapped to the counting wrapper and restored), the last three through package func vars defaulting to them. A nil test hook (bootBeforeBaseline) precedes each baseline. Same calls and keys as before; no read added. Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): takes the boot context beside ctx and runs the runs boot pass under it, so that pass lists records through the boot walk's share; every other seed keeps ctx. Same calls and keys; no read added. Agent, not root. whole:Route@646 39a5359f700d0d02c589d6c1b4ad0e4095fafd5be46b14e28279039a8f40bbe6 |
| +internal/host/fastboot.go fastBoot.start legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-4;basis=New (Task 4): the arming order moved out of fastConvergeLoop. One reg.List of this box's registry (the route snapshot for the sidecar baseline), starts the seeds goroutine first, then refreshMovesHolds and refreshOfflineView (through package func vars defaulting to them), sets fastDeps.serialAfter, runs the first tick, and returns ready, which waits for the seeds (one log line if over slowLegAfter), runs runRunsPass once (through bootRunsNotes; the same runs pass every full pass runs, for notes the first tick kept while the runs boot pass was unfinished), clears the serial hold and assigns the seeded legs to fastDeps. No read beyond those the moved calls and that existing runs pass already make. Agent, not root.;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): makes the boot context (withBootWalk(ctx, b.viewStore): an in-memory WalkShare, the reconcile epoch and, review round 1 fix, one release.ReadSerial of the deployment serial read before the offline view's walk, kept to compare with the first tick's seed) and hands it to the offline view, the seeds goroutine (for the runs boot pass only) and the first tick. Same calls in the same order plus that one serial GET per boot; nothing is decided from it but whether the first hold may reuse the boot listing. Agent, not root. whole:Route@505 42d2fd3a4d1e6ec137227d4df2b0622e0eca67b296d14ce9ab5f01726442af95 |
| +internal/provision/reconcile.go Reconcile legacy accepted-legacy accepted-legacy;rev3=census-ruling-self-serve-moves-1;basis=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos), from its reconcile loops: each listed record is observed through the box's lifetime judge (ObserveWith: the record, then its host incarnation slot) before the shape, channel and scope checks, a stale record is left out and an unjudgeable one protected; the removal phase observes a row's own record key when the pass holds none for it under that key, and deletes a held row whose record is gone or stale through DeleteIfHold; a nil judge (claims on) is main's body; registry read sites unchanged, offsets moved; fix round 1: the removal phase observes a row's own key only under an account the listing trusts, so a retired or unmaterialised account's row keeps record gone, and the pass arms its own context with the judge; Task 7: under a judge an existing provisioned row of the record's own app and account follows the existing-row rules (heldByVanishedPredecessor and retireHeldPredecessor's DeleteIfHold first, the record then minted on the same pass; the hold; installRowLifetime), each a separate write under the host's hold lock; registry read sites unchanged, offsets moved;rev3=census-ruling-instance-egress-sizes-328-329;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=#328/#329 plan 1 Task 7: the pass reads its apps' policy objects (control/app-policy/<sqid>/<app>.json in the bucket) through the agent's PolicyCache, each verified with ReleasePub by apppolicy.VerifyKey (ed25519 over the policy's own domain line, bound to the account and app, unexpired, not future-dated; anything else is no policy), and carries the columns into its rows. New kinds registry:EgressAllow, registry:Size and registry:PolicyExpiresAt, one site each, all the assignment of a fresh row's columns (nr) from policies.cols; plus one whole:Route site, the existing row handed to policies.forRow. Other read sites unchanged, offsets moved; the agent's own pass, no root decision;rev3=census-ruling-region-ha-p1a;basis=the agent as carlos, from its reconcile loops: after the scan, hands the in-scope records to cfg.Lifetimes (the box's lifetime index): Merge after a failed read or partial listing, Replace after a complete one, nothing on a dry run or with no index; the scan, judge and removal phases unchanged; the same 166 sites, no read added;rev3=census-ruling-rootfs-apps-3;basis=rootfs Plan 3 Tasks 2 and 5 (D5, spec §5.0): a seeded record over a row with a runtime is skipped and logged; a row with a runtime (or a new record with one) takes no seed; runtime and a rootfs row's hibernation are never converged from a record (a mismatch is logged; a record claiming a runtime its row lacks is not applied); reads Runtime of the record and the row; the box writes less; fix wave 1 (ceea6353, whole-branch P1-2): before minting a row for a record with no runtime and no row (both mint paths), the pass reads the app's kind marker once per app per pass (release.ReadAppKindMarker: one GET of the create-only kind.json from the release store s, through freshStore, validated by readAppKindMarker); a rootfs marker leaves the record unmaterialized and logged (an older console stripped its runtime), and a marker that cannot be read defers the mint this pass; a refusal before minting only, registry read sites unchanged, the box writes less; fix wave 2 (whole-branch r2 P1): the kind-marker read and its refusal apply only to a socket-backed instance record (DerivesPaths), so a static or upstream-backed record of a rootfs app, which carries no runtime by design, is minted as before with no read; fewer reads, registry read sites unchanged;rev3=census-ruling-fleet-public-routes;basis=fleet public routes (spec 2026-10-29 rev 4, §4.2 writer rule): Task 10: the forward phase on the hub (FleetOwners set): the scan keeps the fleet-placed records it skips and counts records per host; a trash-only marker prefetch; disputed (failed-GET) hosts; armed, a host an in-scope and a fleet record both name is given neither, its journal waits and the removal phase keeps its row (+registry:Account, +registry:App, +registry:Host x2: the collision guard, its log line and report mark); the instance loop leaves a forward host; retirable excludes forward rows. Same record keys; writes only the registry (PutForward, DeleteForward); no bucket write.;rev3=census-ruling-managed-fleets-1b;basis=managed fleets 1b (Task 4, rules 2 and 9): after inScope, a record failing cfg.ownsRecord (on a fleet box, labelled for another box: rec.FleetBox != "" and != cfg.FleetBox) is skipped as out of scope, so it is never minted here; in the removal phase such a record no longer keeps the row (inScope && ownsRecord), so the row goes as record gone. Off a fleet ownsRecord is always true. Read sites unchanged (178). The agent's reconcile loops, not root; it mints less, never more.;rev3=census-ruling-rootfs-apps-6;basis=rootfs Plan 6 Task 3: in the per-record loop, beside the RunSeen call, calls cfg.InteractiveSeen(rec) when the hook is set and the in-scope record carries an interactive-session marker (rec.Interactive != nil), once per record per pass, before the pass acts on it; the hook is the box worker's non-blocking note (Task 12). Same record keys and literal; no read added (registry read sites unchanged, 178); nothing written by the call; merge of origin/main 6f1f6ca6: main's fleet-box ownsRecord skip in the record scan and in the removal phase is kept as main has it (census-ruling-managed-fleets-1b); this branch's change is the same as above; read sites unchanged (178);rev3=census-ruling-stateless-replicas-1;basis=Task 3b: call the optional binding callback only for applied, owned stateless rows outside dry run. Reuses this pass record and route reads after existing collision, scope, hold, policy and shape checks; no new record read or typed writer. Fix 3b round 1 I1: binding callback failure is logged and falls through to pr.applied; same per-host callback, record writers, scope and removal gates. TestStatelessBindingFailureContinuesReconcile covers second-record convergence, removal, applied bookkeeping and next-pass retry.;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: collect validated instance records from the existing scan before pool filtering; report source completeness separately. Record reads, writes, scope and removal authority unchanged.;rev3=census-ruling-agent-start-demo-1;basis=Keeps local demo rows for signed cleanup instead of deleting the binding on record absence or trash; normal/hub paths unchanged. Merge integration against origin/main 9bd45488 retains main's HA departure inventory scan and family-completeness reporting alongside the early local-demo retention guard; existing record reads retained.;rev3=census-ruling-stateless-replicas-2;basis=Final fix I1: legacy records now reach the legacy ownership/removal judgement for former set rows; a greater local incarnation remains protected. Current set-record lifetime and membership checks remain. Same record/registry reads and removal writers. TestReplicaReconcileLegacySuccessor covers both boxes with and without the judge; P11 newer/unknown set protections remain covered. merge of origin/main 6be08467: Retain main signed demo retirement ownership alongside replica set retirement and legacy successor recovery; merge-only body change, unchanged read sources.;rev3=census-ruling-agent-start-demo-3;basis=Install durable source claim holds and reconcile fresh destination seed gates; preserve owned pending routes and stop orphan seeds before cleanup. Census read-site delta: +registry:Account, +registry:App, +registry:Host, +registry:ImportGate ×2, +registry:SeedSource ×2, +whole:Route ×4.;rev3=census-ruling-region-ha-g2-fixes;basis=Run guarded pool withdrawal, extract the unchanged judged collection rules into scanInstanceRecords, and publish pre-pool HA ingress including stale refusal names. Existing direct route reads remain; indirect withdrawal reads and deletion are separately claimed.;rev3=census-ruling-linked-deployments-slice1;basis=linked deployments slice 1 Task 2: where a forward row holds an in-scope record's host, a link-placed one (registry.LinkPlacement over the listed row's Region) gets its own log line saying no pass here retires it; the record is still not applied, as before; one +registry:Region read of the listed row, no write added;rev3=census-ruling-stateless-replicas-4-drill1;basis=#511 drill 1 F4: for a stateless row with a copy assignment (record or row), the binding callback gets the row as convergeOwned left it: one local registry Get of the same host after the pass's own writes; a row that cannot be read is logged (round 1, Fable M7) and bound next pass; no record read or write added;rev3=census-ruling-fleet-seeded-create-1;basis=In the per-record seed dispatch (the seedFinishAbort case), Reconcile asks abortRetiresRow(rec) (seedreconcile.go) instead of comparing rec.Seed.Kind to seeds.KindReplica, so an aborted file seed goes through the same row retirement and marker-decided purge as an aborted --from seed; the kind check only, no new read or write, registry read sites unchanged; the agent as carlos, not root; it retires a row it would already retire for a replica seed.;rev3=census-ruling-managed-fleets-2b2;basis=returns nil before any list, mint or removal while ReconcileConfig.Joining answers true (a joining managed box); ownsRecord also refuses every record then; no read added; merge of origin/main 65951fbb: main's link-placed forward log line (+registry:Region), drill 1 F4 row re-read for the stateless binding and abortRetiresRow seed dispatch, not this branch; code-health split: the joining guard, withdrawPools, the demo claim holds and the Now default moved, in order, to ReconcileConfig.passStart, no read added;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): the pass's own instance scan over the live store calls scanInstanceRecords with cfg.liveWalk(s) (the pass's WalkShare, nil over a record view snapshot); the snapshot pass's live re-walk passes nil and lists the bucket itself. The share answers only the account set and the apps/ key listing; every record body and slot is still read by the scan. Read sites unchanged (236); fewer listings, no read added. Agent, not root. registry:Account@26923,registry:Account@28793,registry:Account@48186,registry:Account@48232,registry:Account@49861,registry:Account@50238,registry:Account@50464,registry:Account@50531,registry:Account@50577,registry:Account@50670,registry:Account@50712,registry:Account@51360,registry:Account@51618,registry:Account@52520,registry:Account@52568,registry:Account@52977,registry:Account@53023,registry:Account@53268,registry:Account@53693,registry:Account@54181,registry:Account@54525,registry:Account@55127,registry:Account@55320,registry:Account@55732,registry:Account@55911,registry:Account@56235,registry:Account@56800,registry:App@26896,registry:App@28766,registry:App@48206,registry:App@48244,registry:App@49873,registry:App@50250,registry:App@50476,registry:App@50551,registry:App@50589,registry:App@50690,registry:App@51372,registry:App@51630,registry:App@52532,registry:App@52580,registry:App@52997,registry:App@53035,registry:App@53280,registry:App@53705,registry:App@54193,registry:App@54537,registry:App@55139,registry:App@55332,registry:App@55744,registry:App@55923,registry:App@56247,registry:App@56812,registry:Canary@48699,registry:ClaimOwnership@27510,registry:DBPath@37420,registry:DBPath@37435,registry:DBPath@37681,registry:DBPath@38284,registry:DBPath@38297,registry:EgressAllow@26009,registry:FleetBoxes@38780,registry:FleetBoxes@48660,registry:FleetBoxes@48808,registry:FleetBoxes@55520,registry:Gate@33317,registry:Gate@33457,registry:Gate@33744,registry:Hibernate@31989,registry:Hibernate@32187,registry:Hibernate@32252,registry:Hibernate@32591,registry:Hibernate@32942,registry:Hibernate@33252,registry:HoldOp@18014,registry:HoldOp@54872,registry:HoldOp@54963,registry:HoldOp@55098,registry:HoldOp@55474,registry:Host@15513,registry:Host@18417,registry:Host@18557,registry:Host@48165,registry:Host@48759,registry:Host@49837,registry:Host@50214,registry:Host@50378,registry:Host@50484,registry:Host@51380,registry:Host@51586,registry:Host@52860,registry:Host@53132,registry:Host@53247,registry:Host@53570,registry:Host@53667,registry:Host@54058,registry:Host@54155,registry:Host@54369,registry:Host@54571,registry:Host@54954,registry:Host@55089,registry:Host@55293,registry:Host@55366,registry:Host@55465,registry:Host@55705,registry:Host@55884,registry:Host@55963,registry:Host@56050,registry:Host@56209,registry:Host@56284,registry:Host@56370,registry:Host@56777,registry:ImportGate@34896,registry:ImportGate@35195,registry:Incarnation@18190,registry:Incarnation@48877,registry:Kind@18402,registry:Kind@18542,registry:Kind@27652,registry:Kind@28018,registry:Kind@28300,registry:Kind@28520,registry:Kind@37338,registry:Kind@37351,registry:Kind@37461,registry:Kind@37474,registry:Kind@38195,registry:Kind@38206,registry:Kind@47289,registry:Kind@54360,registry:Kind@55080,registry:Kind@55456,registry:Kind@55696,registry:Kind@56041,registry:Kind@56200,registry:Kind@56361,registry:Platform@48684,registry:PolicyExpiresAt@26034,registry:Pool@47375,registry:Provisioned@26872,registry:Provisioned@28742,registry:Provisioned@47334,registry:RateLimit@33830,registry:RateLimit@33981,registry:RateLimit@34268,registry:Region@17381,registry:Region@47364,registry:ReplicaIncarnation@17898,registry:ReplicaIncarnation@17935,registry:Replication@32676,registry:Replication@32803,registry:Runtime@19586,registry:Runtime@19764,registry:Runtime@22057,registry:Runtime@31356,registry:Runtime@31410,registry:Runtime@31614,registry:Seed@35818,registry:SeedSource@34854,registry:SeedSource@35174,registry:SeedSource@35301,registry:Size@26025,registry:Socket@37386,registry:Socket@37401,registry:Socket@37698,registry:Socket@38254,registry:Socket@38267,registry:Stateless@38355,registry:Unit@37304,registry:Unit@37317,registry:Unit@38221,registry:Unit@38232,whole:ClaimOwnership@27513,whole:ClaimOwnership@27530,whole:Route@15495,whole:Route@15506,whole:Route@15524,whole:Route@16805,whole:Route@17790,whole:Route@18001,whole:Route@18316,whole:Route@18602,whole:Route@18616,whole:Route@18629,whole:Route@18652,whole:Route@20081,whole:Route@20088,whole:Route@20128,whole:Route@20489,whole:Route@20644,whole:Route@20915,whole:Route@21362,whole:Route@21413,whole:Route@21450,whole:Route@23122,whole:Route@23331,whole:Route@23670,whole:Route@23679,whole:Route@23725,whole:Route@25958,whole:Route@26517,whole:Route@26988,whole:Route@26998,whole:Route@27355,whole:Route@27362,whole:Route@27430,whole:Route@27793,whole:Route@27849,whole:Route@27919,whole:Route@27930,whole:Route@28358,whole:Route@29391,whole:Route@32342,whole:Route@35003,whole:Route@37530,whole:Route@38731,whole:Route@38837,whole:Route@39026,whole:Route@39089,whole:Route@39982,whole:Route@40027,whole:Route@40037,whole:Route@40907,whole:Route@41934,whole:Route@47400,whole:Route@47548,whole:Route@48645,whole:Route@49015,whole:Route@49789,whole:Route@50171,whole:Route@52022,whole:Route@54463,whole:Route@55611,whole:Route@56122,whole:Route@56707,whole:Route@56757 d717fa00a4f472487b004b6fdc5455aa574b364a352597a8bb41373cfde082bf |
| +internal/provision/sidecar_reconcile.go ReconcileSidecars legacy accepted-legacy accepted-legacy;rev3=J1;basis=root-route;rev3=PROPOSED-s3-change-index;identity=the agent (/opt/carlos/carlos agent, carlos-edge.service, user carlos);basis=the record walk and its sidecars manifest lookup move unchanged into the pass's scan closure (over a store argument) and the removal phase into its retire closure; over a record view snapshot, a pass that reaches a removal candidate (a sidecar gone or no longer placeable here) removes nothing on the snapshot's word: it runs scan again over the bucket (freshStore) and decides every removal that pass from that walk, by the walk's own rules (unusable records protected before scope, hosts matched across every key, placement from the bucket's record and sidecars manifest against this box's inbound); a walk that cannot read cleanly keeps every row; with no candidate, or disarmed, nothing is read again; the registry sites are main's, moved; relative to main's single walk a removal can only be withheld, never added;rev3=census-ruling-region-ha-p1b3b-t;basis=B3b: retain validated sidecar records before scope/manifest filtering for coverage, including hidden/out-of-pool records. No new object reads or sidecar HA authority.;rev3=census-ruling-region-ha-p1b3b-s;basis=Derive canonical sidecar lifetimes from account/app/synthetic host/CreatedAt; collect HA and manifest placement for departures before scope filtering; update a separate family in the existing lifetime index. Existing record reads, key parsing and removal authority remain.;rev3=census-ruling-region-ha-g2-fixes;basis=Run sidecar-scoped pool withdrawal before the existing pass; existing direct reads unchanged, new indirect stop/record/deletion checks are in withdrawal helpers.;rev3=census-ruling-managed-fleets-2b2;basis=returns nil before any list, mint or removal while ReconcileConfig.Joining answers true; no read added;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): the scan closure takes a WalkShare and lists accounts and the apps/ keys through it (knownAccounts and listAppSubtree when nil); the pass's own scan over the live store passes cfg.liveWalk(s), the snapshot re-walk over freshStore passes nil and lists the bucket itself. Every record body is still read by the scan. Read sites unchanged (47); no read added. Agent, not root. registry:Account@13045,registry:Account@13284,registry:Account@14237,registry:Account@14987,registry:App@13018,registry:App@13270,registry:App@14210,registry:App@14973,registry:Args@13862,registry:Args@14133,registry:Channel@13850,registry:ClaimOwnership@13663,registry:Host@10639,registry:Host@16323,registry:Host@16370,registry:Host@16493,registry:Host@16670,registry:Host@16819,registry:Host@16926,registry:Kind@12959,registry:Kind@13233,registry:Kind@14150,registry:Kind@14936,registry:Kind@16156,registry:Pool@16274,registry:Provisioned@12991,registry:Provisioned@13248,registry:Provisioned@14182,registry:Provisioned@14951,registry:Provisioned@16183,registry:Region@16224,whole:ClaimOwnership@13666,whole:ClaimOwnership@13683,whole:Route@10621,whole:Route@10632,whole:Route@10650,whole:Route@10836,whole:Route@11205,whole:Route@11214,whole:Route@12647,whole:Route@13508,whole:Route@13515,whole:Route@13583,whole:Route@13918,whole:Route@14295,whole:Route@16141,whole:Route@16736 5be1b18b60a0c636283e9b8a8ab5ad32fc3c9b417472647157aa76a1bf5b853d |
| +internal/host/agent.go reconcileSerializedAuth legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): under reconcileMu, before any record read, beginHoldWalk sets cfg.Walk to the boot walk's share (first hold only, when no hold ran since it was read) or a fresh provision.WalkShare, nil over a record view snapshot, and moves the in-process reconcile epoch for the hold. The departure walk start and the asset authority pass start go back to the share's earliest listing when it holds one (earlier, never later). refreshOfflineView and the instance and sidecar scans list through cfg.Walk; every record body and slot is still read in the hold. Two adjacent !cached blocks merged. The +file:Walk reads are the in-memory config field, no store or file read; fewer bucket listings, no read added. Agent, not root. file:Walk@2029,file:Walk@3851 c36d3e132d3aa8d5ce3e81a21963ef915c27e71fc1631e238c752287a51e1070 |
| +internal/provision/reconcile.go type ReconcileConfig legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=Shared record walk (Task 5): new field Walk *WalkShare, the pass's shared record listing; nil (every existing caller) lists as before. A config field, no read. file:Walk@667 0b750f71ddc90af7054bfeab88d0f6f383a45210e3b91495a1d455b1bc142ebc |
| +internal/provision/walkshare.go ReconcileConfig.liveWalk legacy accepted-legacy accepted-legacy;rev3=census-ruling-fleet-first-reconcile-speed-5;basis=New (Task 5): returns cfg.Walk, or nil when the store is a record view snapshot (onSnapshot). Pure; no store read. file:Walk@110 a6546cc7b098732c364d9a1cd9bc64121cb52d02ed4046eccec9854ac2d80290 |
| +@coverage internal/host 0abd3f8c5cf61a5982095cbea0f4118948593e0c716ea8b4d5aaf13ed8ce0d7d |
| +@coverage internal/provision d27fac75bb1f4e492cd212fa1a1f316b86bc69679a5e06c462715b9d535950e5 |
diff --git a/internal/provision/walkshare.go b/internal/provision/walkshare.go| new file mode 100644 |
| index 000000000..5ee5440c4 |
| --- /dev/null |
| +++ b/internal/provision/walkshare.go |
| @@ -0,0 +1,143 @@ |
| +package provision |
| + |
| +import ( |
| + "context" |
| + "maps" |
| + "slices" |
| + "sync" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// WalkShare is one pass's record listing, read once and handed to the legs |
| +// of that pass the fresh-read rules allow to reuse it (fleet first |
| +// reconcile plan, Task 5, "Fresh-read rules"). On a fleet box each record |
| +// walk lists the account's whole apps subtree over the store door, and a |
| +// pass made one walk per leg. |
| +// |
| +// It holds listings only: the account set (accounts/ and every account |
| +// manifest) and the key listings under apps/. Never a record body or an |
| +// incarnation slot: every leg GETs each record it acts on itself, so a body |
| +// that changed after the listing is seen by every leg. |
| +// |
| +// It holds a listing only when it read cleanly: no listing error, no |
| +// unreadable manifest, no partial app listing. Anything less is listed again |
| +// by the next leg, as before. Its life is the caller's: one reconcile hold, |
| +// or the boot walk to the end of the first tick. Nothing here expires it, |
| +// and nothing is kept across passes. |
| +// |
| +// A nil *WalkShare shares nothing: every method lists, as before. |
| +type WalkShare struct { |
| + mu sync.Mutex |
| + at time.Time // when the earliest read it holds began |
| + known map[string]bool // the account set; nil until read cleanly |
| + lists map[string][]string // keys by listing: wholeTree, or the sub |
| + reused int |
| +} |
| + |
| +// wholeTree is the listing key of a store listed whole (List("apps/")): one |
| +// listing answers every sub. |
| +const wholeTree = "" |
| + |
| +// NewWalkShare returns an empty share. |
| +func NewWalkShare() *WalkShare { return &WalkShare{lists: map[string][]string{}} } |
| + |
| +// ListedAt reports when the earliest read the share holds began; ok is false |
| +// while it holds nothing. A pass that took anything from the share read the |
| +// bucket as of this time, not as of its own start. |
| +func (w *WalkShare) ListedAt() (at time.Time, ok bool) { |
| + if w == nil { |
| + return time.Time{}, false |
| + } |
| + w.mu.Lock() |
| + defer w.mu.Unlock() |
| + return w.at, !w.at.IsZero() |
| +} |
| + |
| +// Reused reports how many listings the share has answered. |
| +func (w *WalkShare) Reused() int { |
| + if w == nil { |
| + return 0 |
| + } |
| + w.mu.Lock() |
| + defer w.mu.Unlock() |
| + return w.reused |
| +} |
| + |
| +func (w *WalkShare) noteLocked(start time.Time) { |
| + if w.at.IsZero() || start.Before(w.at) { |
| + w.at = start |
| + } |
| +} |
| + |
| +// accounts is knownAccountsNaming through w: the share's account set if it |
| +// holds one, else a fresh read, kept when it read cleanly. |
| +func (w *WalkShare) accounts(ctx context.Context, s release.Store) (known, failed map[string]bool, err error) { |
| + if w == nil { |
| + return knownAccountsNaming(ctx, s) |
| + } |
| + w.mu.Lock() |
| + if w.known != nil { |
| + known = maps.Clone(w.known) |
| + w.reused++ |
| + w.mu.Unlock() |
| + return known, map[string]bool{}, nil |
| + } |
| + w.mu.Unlock() |
| + start := time.Now() |
| + known, failed, err = knownAccountsNaming(ctx, s) |
| + if err == nil && len(failed) == 0 { |
| + w.mu.Lock() |
| + if w.known == nil { |
| + w.known = maps.Clone(known) |
| + w.noteLocked(start) |
| + } |
| + w.mu.Unlock() |
| + } |
| + return known, failed, err |
| +} |
| + |
| +// subtree is listAppSubtree through w. A store listed whole answers every |
| +// sub from one listing; a bucket-shaped one is listed per sub, and its |
| +// listing depends on the account set, so it is shared only under the |
| +// share's own account set. |
| +func (w *WalkShare) subtree(ctx context.Context, s release.Store, known map[string]bool, sub string) (keys []string, partial bool, err error) { |
| + if w == nil { |
| + return listAppSubtree(ctx, s, known, sub) |
| + } |
| + id := wholeTree |
| + if release.HasBucketListDirs(s) { |
| + id = sub |
| + } |
| + w.mu.Lock() |
| + usable := id == wholeTree || (w.known != nil && maps.Equal(w.known, known)) |
| + if got, ok := w.lists[id]; ok && usable { |
| + keys = slices.Clone(got) |
| + w.reused++ |
| + w.mu.Unlock() |
| + return keys, false, nil |
| + } |
| + w.mu.Unlock() |
| + start := time.Now() |
| + keys, partial, err = listAppSubtree(ctx, s, known, sub) |
| + if err == nil && !partial && usable { |
| + w.mu.Lock() |
| + if _, ok := w.lists[id]; !ok { |
| + w.lists[id] = slices.Clone(keys) |
| + w.noteLocked(start) |
| + } |
| + w.mu.Unlock() |
| + } |
| + return keys, partial, err |
| +} |
| + |
| +// liveWalk is the pass's shared walk (cfg.Walk) for a scan over s: nil over |
| +// a record view snapshot, whose reads are the snapshot's (S3 change-index |
| +// §4.3), so a snapshot pass neither takes from nor fills the share. |
| +func (cfg ReconcileConfig) liveWalk(s release.Store) *WalkShare { |
| + if onSnapshot(s) { |
| + return nil |
| + } |
| + return cfg.Walk |
| +} |
diff --git a/internal/provision/walkshare_test.go b/internal/provision/walkshare_test.go| new file mode 100644 |
| index 000000000..f78756fcb |
| --- /dev/null |
| +++ b/internal/provision/walkshare_test.go |
| @@ -0,0 +1,261 @@ |
| +package provision |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "reflect" |
| + "strings" |
| + "sync" |
| + "testing" |
| + "time" |
| + |
| + "github.com/carlosframework/platform/internal/release" |
| +) |
| + |
| +// walkCounter counts the walk's reads on a whole-tree store (DirStore makes |
| +// no bucket-shape promise, as the fleet door does not): listings by prefix, |
| +// and GETs of record keys and of account manifests. failList fails one |
| +// listing prefix while set. |
| +type walkCounter struct { |
| + release.Store |
| + mu sync.Mutex |
| + lists map[string]int |
| + gets map[string]int |
| + failList string |
| +} |
| + |
| +func newWalkCounter(s release.Store) *walkCounter { |
| + return &walkCounter{Store: s, lists: map[string]int{}, gets: map[string]int{}} |
| +} |
| + |
| +func (c *walkCounter) List(ctx context.Context, prefix string) ([]string, error) { |
| + c.mu.Lock() |
| + c.lists[prefix]++ |
| + fail := prefix == c.failList |
| + c.mu.Unlock() |
| + if fail { |
| + return nil, errors.New("listing refused") |
| + } |
| + return c.Store.List(ctx, prefix) |
| +} |
| + |
| +func (c *walkCounter) Get(ctx context.Context, key string) ([]byte, string, error) { |
| + c.mu.Lock() |
| + switch { |
| + case strings.Contains(key, "/instances/"), strings.HasSuffix(key, "/account.json"): |
| + c.gets[key]++ |
| + } |
| + c.mu.Unlock() |
| + return c.Store.Get(ctx, key) |
| +} |
| + |
| +func (c *walkCounter) counts() (lists, gets map[string]int) { |
| + c.mu.Lock() |
| + defer c.mu.Unlock() |
| + lists, gets = map[string]int{}, map[string]int{} |
| + for k, v := range c.lists { |
| + lists[k] = v |
| + } |
| + for k, v := range c.gets { |
| + gets[k] = v |
| + } |
| + return lists, gets |
| +} |
| + |
| +// One pass (the instance pass, then the sidecar pass) lists accounts/ and |
| +// apps/ once through a share, against twice without one, and reads every |
| +// record and manifest it read before: the share holds listings only. |
| +func TestWalkShareOnePassListsOnce(t *testing.T) { |
| + for _, shared := range []bool{false, true} { |
| + s, sqid := setup(t) |
| + if err := CreateRecord(ctx, s, acmeRecord(sqid)); err != nil { |
| + t.Fatal(err) |
| + } |
| + c := newWalkCounter(s) |
| + reg := regWith(t) |
| + cfg := ReconcileConfig{Region: "ie", Pools: []string{"tito"}, DataDir: "/data"} |
| + if shared { |
| + cfg.Walk = NewWalkShare() |
| + } |
| + if err := Reconcile(ctx, c, reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := ReconcileSidecars(ctx, c, reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + mustGet(t, reg, "acme.go.tito.io") |
| + lists, gets := c.counts() |
| + want := 2 |
| + if shared { |
| + want = 1 |
| + } |
| + if lists["apps/"] != want || lists["accounts/"] != want { |
| + t.Errorf("shared=%v: listed apps/ %d and accounts/ %d times, want %d each", shared, lists["apps/"], lists["accounts/"], want) |
| + } |
| + rec := RecordKey(sqid, "tito", "acme.go.tito.io") |
| + if gets[rec] < 1 { |
| + t.Errorf("shared=%v: the record was not read by the pass (%v)", shared, gets) |
| + } |
| + if shared && cfg.Walk.Reused() != 2 { |
| + t.Errorf("the sidecar pass took %d listings from the share, want 2 (accounts and apps)", cfg.Walk.Reused()) |
| + } |
| + } |
| +} |
| + |
| +// A listing that did not read cleanly is never kept: the next leg lists |
| +// again, and the share holds nothing until a clean read. |
| +func TestWalkShareKeepsOnlyCleanListings(t *testing.T) { |
| + s, sqid := setup(t) |
| + if err := CreateRecord(ctx, s, acmeRecord(sqid)); err != nil { |
| + t.Fatal(err) |
| + } |
| + c := newWalkCounter(s) |
| + w := NewWalkShare() |
| + |
| + // An unreadable manifest: the account set is not kept. |
| + putReplace(t, s, "accounts/"+sqid+"/account.json", []byte("not json")) |
| + if _, failed, err := w.accounts(ctx, c); err != nil || len(failed) == 0 { |
| + t.Fatalf("broken manifest: failed %v err %v, want the account named", failed, err) |
| + } |
| + if _, ok := w.ListedAt(); ok { |
| + t.Fatal("the share kept an account set that did not read cleanly") |
| + } |
| + putReplace(t, s, "accounts/"+sqid+"/account.json", accountManifestBody(acctID, sqid, "Tito")) |
| + known, failed, err := w.accounts(ctx, c) |
| + if err != nil || len(failed) != 0 || !known[sqid] { |
| + t.Fatalf("repaired manifest: known %v failed %v err %v", known, failed, err) |
| + } |
| + |
| + // A failed listing: not kept, and the next one lists again. |
| + c.failList = "apps/" |
| + if _, _, err := w.subtree(ctx, c, known, "instances/"); err == nil { |
| + t.Fatal("a refused listing came back without an error") |
| + } |
| + c.failList = "" |
| + keys, partial, err := w.subtree(ctx, c, known, "instances/") |
| + if err != nil || partial { |
| + t.Fatalf("listing: partial %v err %v", partial, err) |
| + } |
| + if _, _, err := w.subtree(ctx, c, known, "sidecars/"); err != nil { |
| + t.Fatal(err) |
| + } |
| + lists, _ := c.counts() |
| + if lists["apps/"] != 2 || lists["accounts/"] != 2 { |
| + t.Errorf("listed apps/ %d and accounts/ %d times, want 2 each (one failed, one kept and reused)", lists["apps/"], lists["accounts/"]) |
| + } |
| + want, _, _ := listAppSubtree(ctx, s, known, "instances/") |
| + if !reflect.DeepEqual(keys, want) { |
| + t.Errorf("the shared listing differs from a fresh one: %v, want %v", keys, want) |
| + } |
| +} |
| + |
| +// ListedAt is the start of the earliest read the share holds, so a pass that |
| +// took anything from it reports a walk no later than that read. |
| +func TestWalkShareListedAtIsTheEarliestRead(t *testing.T) { |
| + s, sqid := setup(t) |
| + if err := CreateRecord(ctx, s, acmeRecord(sqid)); err != nil { |
| + t.Fatal(err) |
| + } |
| + w := NewWalkShare() |
| + if _, ok := w.ListedAt(); ok { |
| + t.Fatal("an empty share has a listing time") |
| + } |
| + before := time.Now() |
| + known, _, err := w.accounts(ctx, s) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + after := time.Now() |
| + if _, _, err := w.subtree(ctx, s, known, "instances/"); err != nil { |
| + t.Fatal(err) |
| + } |
| + at, ok := w.ListedAt() |
| + if !ok || at.Before(before) || at.After(after) { |
| + t.Fatalf("ListedAt %v (ok %v), want the account read's start, in [%v, %v]", at, ok, before, after) |
| + } |
| + var nilShare *WalkShare |
| + if _, ok := nilShare.ListedAt(); ok || nilShare.Reused() != 0 { |
| + t.Fatal("a nil share holds something") |
| + } |
| +} |
| + |
| +// On a bucket-shaped store each sub is its own listing, and a listing is |
| +// shared only under the account set it was made with. |
| +func TestWalkShareBucketShapedIsPerSub(t *testing.T) { |
| + b := &bucketShaped{Store: seedAppListingBucket(t)} |
| + known := map[string]bool{"bab": true, "bad": true} |
| + w := NewWalkShare() |
| + w.known = map[string]bool{"bab": true, "bad": true} // as accounts() keeps it |
| + |
| + first, _, err := w.subtree(ctx, b, known, "instances/") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + dirs := len(b.dirs) |
| + again, _, err := w.subtree(ctx, b, known, "instances/") |
| + if err != nil || !reflect.DeepEqual(first, again) { |
| + t.Fatalf("reused listing %v err %v, want %v", again, err, first) |
| + } |
| + if len(b.dirs) != dirs { |
| + t.Errorf("the same sub was listed twice under the same account set") |
| + } |
| + side, _, err := w.subtree(ctx, b, known, "sidecars/") |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + want, _, _ := listAppSubtree(ctx, b, known, "sidecars/") |
| + if !reflect.DeepEqual(side, want) { |
| + t.Errorf("sidecars/ came back %v, want its own listing %v", side, want) |
| + } |
| + dirs = len(b.dirs) |
| + other := map[string]bool{"bab": true} |
| + if _, _, err := w.subtree(ctx, b, other, "instances/"); err != nil { |
| + t.Fatal(err) |
| + } |
| + if len(b.dirs) == dirs { |
| + t.Error("a listing was shared under a different account set") |
| + } |
| +} |
| + |
| +// The snapshot pass's live re-walk is a "no" leg (S3 change-index §4.4: |
| +// removals are decided by the bucket's walk): handed a share whose listing |
| +// predates a record, a pass over a snapshot that lacks the record lists the |
| +// bucket itself, finds it and keeps its row. Neither the snapshot pass nor |
| +// the re-walk takes from the share. |
| +func TestWalkShareSnapshotRewalkListsItself(t *testing.T) { |
| + s, sqid := setup(t) |
| + v := staleView(t, s) |
| + share := NewWalkShare() |
| + known, _, err := share.accounts(ctx, s) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, _, err := share.subtree(ctx, s, known, "instances/"); err != nil { |
| + t.Fatal(err) |
| + } |
| + rec := acmeRecord(sqid) |
| + if err := CreateRecord(ctx, s, rec); err != nil { |
| + t.Fatal(err) |
| + } |
| + reg := regWith(t) |
| + cfg := ReconcileConfig{Region: "ie", Pools: []string{"tito"}, DataDir: "/data"} |
| + if err := Reconcile(ctx, s, reg, cfg); err != nil { // a walking pass mints the row |
| + t.Fatal(err) |
| + } |
| + mustGet(t, reg, rec.Host) |
| + sn := completeSnapshot(t, v) |
| + if recs, err := ListAllRecords(ctx, sn.Store(s)); err != nil || len(recs) != 0 { |
| + t.Fatalf("fixture: the snapshot has records %v, %v; it should lack the unbumped one", recs, err) |
| + } |
| + cfg.Walk = share |
| + if err := Reconcile(ctx, sn.Store(s), reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := ReconcileSidecars(ctx, sn.Store(s), reg, cfg); err != nil { |
| + t.Fatal(err) |
| + } |
| + mustGet(t, reg, rec.Host) // kept: the re-walk listed the bucket, not the share |
| + if n := share.Reused(); n != 0 { |
| + t.Errorf("a pass over a snapshot took %d listings from the share, want 0", n) |
| + } |
| +} |
diff --git a/scripts/gitleaks-gate/notscanned.go b/scripts/gitleaks-gate/notscanned.go| index 602c47d54..272102868 100644 |
| --- a/scripts/gitleaks-gate/notscanned.go |
| +++ b/scripts/gitleaks-gate/notscanned.go |
| @@ -27,6 +27,7 @@ var notScanned = []string{ |
| "internal/provision/demo_census_test.go", |
| "internal/provision/domains_plan_2a_census_test.go", |
| "internal/provision/edge_asset_cache_1_census_test.go", |
| + "internal/provision/fleet_first_reconcile_speed_5_census_test.go", |
| "internal/provision/fleet_public_routes_census_test.go", |
| "internal/provision/fleet_seeded_create_1_census_test.go", |
| "internal/provision/fleet_seeded_create_2_census_test.go", |