Skip to content

fix(heal): secrets-broker restart cadence starves its first refresh #13081

Open

Description

@dezren39

The laptop-channel heal loop can starve the secrets broker's refresh indefinitely.

Observed 2026-11-23 ~01:54-01:58 CST: the heal restarted fleet serve secrets-broker at 07:54:27Z, 07:54:32Z, 07:55:21Z and 07:56:24Z because health kept returning 503 with refreshing:true, secrets:0. But a full refresh shells out to one bws secret get per secret (~221 secrets) and takes longer than the heal's restart patience — every restart killed the in-flight refresh, so the broker never reached serving:true. Left alone, the 07:56 instance completed its refresh and health went green (221 secrets) with no other intervention.

Fix shape: the heal should not restart a secrets broker whose health reports refreshing:true with refresh progress underway (or whose bws children are active); give the first refresh a patience window sized to the secret count, and only restart when the process is absent, wedged with no bws activity, or still not serving after that window.

Activity

  1. developing-today commented on Nov 23, 2026

    @developing-today
    Contributor
  2. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    xaltha picking this up. Root-cause check against the code first: the only heal rule that restarts fleet serve secrets-broker on a health verdict is the sandbox prelude's (broker ≥120s old + health not serving:true → kill), and it never looks at refreshing. The repo-owned half of the defect is in the broker itself: installs are batch-atomic, so for the whole first refresh /health reports secrets: 0 with no progress signal — a heal cannot tell a slow-but-advancing refresh from a wedged one, which is exactly the distinction this issue's fix shape needs ("refreshing:true with refresh progress underway"). Landing the broker-side fix in fleet-queue: per-secret installs land as fetches complete (the module doc already promises this), and /health publishes refresh progress (fetched/total + refresh start) so a heal can apply the refreshing-aware patience rule. The prelude-side rule change is flagged separately — it is not versioned in this repo.

  3. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    Progress — broker-side fix landed as PR #13125 (Refs, not Closes: one half remains outside this repo).

    Root cause confirmed in code, both halves:

    • Heal half: the sandbox prelude's kill rule (broker ≥120s old + /health not serving:true → kill) never consults refreshing. A first refresh (~221 bws gets, 8-way parallel) outlasts that fixed patience, so each kill restarted the refresh from zero — the observed 07:54–07:56Z starvation. Left alone, the refresh completed.
    • Broker half (this PR): installs were batch-atomic, so /health reported secrets: 0 for the whole first refresh with no progress signal — the issue's prescribed rule ("don't restart while refreshing with progress underway") was not implementable against the health body as it stood.

    PR #13125 changes (fleet-queue secrets_broker.rs only, +207/−5): /health now publishes refresh_progress {started_unix, fetched, total} while a refresh is in flight (null when idle); each successful fetch installs into the live cache as it completes (the per-secret install the module doc already promised — batch-end install still owns eviction and the all-failed rule), so secrets climbs during a first refresh and early secrets serve while siblings fetch; the heal contract (patience sized to refresh_progress.total, restart only on absent / not-refreshing / no-progress-past-window) is documented in the module doc.

    Evidence: cargo test -p fleet-queue --lib --features secrets-broker 143 passed / 0 failed (sandbox, local rustup toolchain); secrets_broker module 26/26 including 3 new oracle-named tests (progress published only while refreshing; fetched secrets visible before the first refresh completes; progress counts completions and closes with the refresh). rustfmt clean; clippy is CI's first pass.

    Remaining, outside this repo: the prelude rule in ~/tools/init-ensure.sh (sandbox-local, not versioned here) must consult refreshing/refresh_progress before killing a not-serving broker, with the vault-sized patience. Flagging for the seat that owns init-ensure — once that lands, this issue's acceptance is fully covered.

  4. dezren39 commented on Nov 23, 2026

    @dezren39
    MemberAuthor

    init-ensure half applied by the xaltha main seat (2026-11-23): the sandbox prelude in ~/tools/init-ensure.sh no longer kills a not-serving broker on the flat 120s rule. It now reads /health once and, while "refreshing":true, allows a 900s (one TTL) patience; when the broker publishes refresh_progress (PR #13125), a fetched count frozen across init runs for 300s is treated as wedged and restarts at once. Progress state is tracked in ~/.cache/secrets-broker/.refresh-watch and cleared whenever the broker is serving or absent. Verified live after the edit: two init-ensure runs exit 0, the broker was not restarted (last_refresh_unix unchanged, serving:true, 221 secrets), and all four doctor legs are green. Backup of the pre-edit script: ~/tools/init-ensure.sh.bak-20261123-13081. With PR #13125 (broker-side progress + per-secret install visibility) this covers the issue's acceptance from this seat; the PR stays Refs #13081 since the prelude is sandbox-local tooling, not repo code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions