carlos / platform Public

Fleet boxes scan every account record for HA ingress (per-box S3 polling) open

Claimed by claude~paul@keymail.dev 3 weeks ago

Found while investigating the stateless replicas dev drill (#511, drill 2, 2026-11-12). A fresh fleet box logged "provision: skipping record" for other apps' records in its own account.

Cause

The HA ingress pass lists and reads every instance record in the account on fleet boxes:

  • runHAIngressStartup (internal/host/agent.go:1048, internal/host/haingress.go:172) calls scanInstanceRecords (internal/provision/reconcile.go:1177);
  • on a fleet box that scan lists apps/ (reconcile.go:3362), which the store door scopes to the account's own apps/<account>/ (internal/edge/storedoor.go:889);
  • it reads every record, because placement lives only in the body, then drops the ones placed elsewhere (reconcile.go:1388-1401).

The ingress step can never produce a forwarding route on a fleet box, so the whole scan does nothing there.

Not a tenancy issue

A fleet box has no IAM access to the deployment bucket. The door limits it to reads of its own account's apps/<acct>/** (by design), with no record writes. The replica workers drop records that don't name the box.

Cost: per-box polling of the whole account folder

Every fleet box lists the whole account folder (logs, errors and analytics included) and makes about 2 GETs per record. It does this every 5 minutes and on each serial change, plus up to 4 times at startup. One unreadable record from any app also leaves the pass incomplete. This is the per-box polling the memory note "s3-requests-cost-money" warns against.

It predates #511: the scan is 98c43eea (11-06), the listing fallback 91bb1a2e (10-05) and the door scope 99e45920 (08-11).

Ask (a): small, about 10-20 lines

Skip the HA ingress record scan on fleet boxes: at startup AND in the 5-minute / serial-change pass, if the periodic pass is the same scan. Keep the startup alias pass. Add a test that a fleet box makes no records LIST for HA ingress.

Follow-up (b): medium, about 200-400 lines, not urgent

Have the store door list only the records placed on the calling fleet, so any remaining fleet-box scan stops reading other apps' records.

Full write-up: the controller's scratch record-enumeration.md (summary above). HA owner: 8a3d302. The builder is another agent, not the #511 session.

MERGED ad371857 (squash of c46d3c75, CI green): a fleet box (region a fleet placement) skips the startup HA ingress record scan and does not take reconcileMu, so its first reconcile is no longer held for the 5 s attempt budget (witness: +17.2 s, target about 2 s). It publishes the empty projection only where none exists, so a published refusal marker stands. Platform boxes unchanged. Witnesses: TestHAIngressStartupFleetBoxListsNoRecords and TestHAIngressStartupFleetBoxDoesNotHoldReconcile. Astra: no findings; census approved on #280. Not released; rides the release after v0.36.1. A dev restart timing witness is still owed.

Fleet box first reconcile (follow-up from the v0.36.2 witness: ~17 s from agent start to the first mint, unchanged by #964):

  • 25c57de (merged): startup timing. One "agent: startup:" journal line per step from agent start to the end of the first full pass, with store door op counts. Log-only.
  • 35b7c25 (merged, not released): the boot full pass runs as soon as the fast converge loop has built the moves hold and offline keep views, with no tick sleep; the restart/wake baselines, runs boot pass, schedule converge and system observe run beside it. The first serial read waits for the request baselines, so no request is half-taken.

Before: armed +9.4 s, first tick about 2.3 s later, mint +17 s (dev r10r box-2, v0.36.2). After: not yet measured on dev. The local slow-door model (60 ms/op) puts the saving at 2 to 3 s, about 0.8 s more where runs are armed. The rest of the gap is in costs the local model cannot show. The two main suspects are the wait for the activator startup latch before the duties start, and the door's whole-subtree List("apps/") in the record walk. The 25c57de lines will settle both after the next release; the door-shaped walk (d941a849, reverted) is ready to cherry-pick if the list numbers justify its S3 cost.

Fleet first reconcile, follow-up 2026-11-16. Dev v0.37.0 startup lines (25c57de) on r10r box-1: the activator latch is not the cause (227 ms). The cost is the fleet store door's whole-subtree listing of a big account's apps/ tree: about 2.3 s per list, and about 4 record walks before the first mint (offline view 4.8 s, reconcile 8.5 s, moves 4.0 s). The same lists take about 20 ms on the demo fleet.

Parked, unmerged: the adaptive per-app walk (d941a849, branch fleet-door-record-walk at 2e350661). It reached AGENTS.md stopping rule 2 on the S3 request budget: Astra's round-2 P1 is that its page pricing assumes S3 fills every page. The branch keeps the request budget analysis in its plan, and its census was approved by both reviewers.

Chosen instead (8a3d302): share one record walk across the legs of a pass (offline view, reconcile, moves) with explicit fresh-read rules. That lowers requests for every account size and takes r10r's first pass from about 4 walks to 1 or 2. Building on branch fleet-shared-walk.

Shared record walk MERGED on main as 3f3dbc1 (2026-11-27, not released). On a fleet box one apps/ listing is now shared by the legs of a pass whose fresh-read rules allow it (offline view at arming, the boot pass's reconcile, the runs boot pass, the instance and sidecar scans); the moves pass and removal rewalks keep their own, and record bodies are still read fresh. First pass 5 whole-tree listings to 2, steady state 3 to 2; requests per box per day down for every account size. Expected first-pass saving on Tito-sized accounts: about three 11 s listings. Witness: the "agent: startup:" lines on a fleet box restart after the next release.