backstop-tick: order-repos runs from the FIRST repo's vendored copy — mixed pins break stalest-first ordering (date: invalid date) #83

Closed
opened 2026-08-25 16:13:18 +00:00 by ben · 4 comments
Owner

Found during the matou-website install (matou-website#2). matou-workstation backstop.log has 48× date: invalid date ‘-Matou/idss minutes’ since the registry gained its 4th repo.

Cause: the rendered factory-cron/backstop-tick.sh calls schedule-backstop.sh order-repos <slugs...> from the FIRST registry repo's checkout (/home/dev/swarm/Matou/idss/.sandcastle/...). idss is pinned older than the current order-repos contract, so the old copy mis-parses the slug list and feeds a slug into date -d "-<N> minutes".

Consequence: dispatches still happen (each repo's tick uses its own vendored copy), but stalest-first ordering degrades and the log fills with date errors — and any host whose first-listed repo lags the pin re-breaks silently.

Fix options: (a) render order-repos from the FACTORY checkout on the host (the registry knows it? it doesn't — but host-cron render runs from one), (b) ship the order-repos logic INTO the generated backstop-tick.sh so it has no cross-repo dependency, or (c) pick the newest-pinned repo's copy. (b) removes the mixed-pin class entirely.

Offline test: onboarding/tests host-cron render fixtures.

Found during the matou-website install (matou-website#2). `matou-workstation` backstop.log has 48× `date: invalid date ‘-Matou/idss minutes’` since the registry gained its 4th repo. **Cause**: the rendered `factory-cron/backstop-tick.sh` calls `schedule-backstop.sh order-repos <slugs...>` from the FIRST registry repo's checkout (`/home/dev/swarm/Matou/idss/.sandcastle/...`). idss is pinned older than the current `order-repos` contract, so the old copy mis-parses the slug list and feeds a slug into `date -d "-<N> minutes"`. **Consequence**: dispatches still happen (each repo's tick uses its own vendored copy), but stalest-first ordering degrades and the log fills with date errors — and any host whose first-listed repo lags the pin re-breaks silently. **Fix options**: (a) render order-repos from the FACTORY checkout on the host (the registry knows it? it doesn't — but host-cron render runs from one), (b) ship the order-repos logic INTO the generated backstop-tick.sh so it has no cross-repo dependency, or (c) pick the newest-pinned repo's copy. (b) removes the mixed-pin class entirely. Offline test: onboarding/tests host-cron render fixtures.

Severity correction from live forensics (2026-08-25 mission-control session): the outage is TOTAL, not ordering-only. backstop.log has zero dispatch/skip lines since the 04:15Z tick — the old pinned copy dies under its own set -euo pipefail on date -d "-Matou/idss minutes" before printing anything, so the $(order-repos ...) substitution is EMPTY and the for-loop never calls run_repo for ANY repo. No backstop ticks at all since 04:15Z on matou-workstation; Forgejo's own scheduler is carrying the cadence alone. Suggested extra acceptance: an order-repos failure must fall back to registry order (|| printf per-slug) so a mixed-pin fleet degrades to unordered ticks, never to silence. Duplicate report #84 closed in favour of this ticket.

Severity correction from live forensics (2026-08-25 mission-control session): the outage is TOTAL, not ordering-only. backstop.log has zero dispatch/skip lines since the 04:15Z tick — the old pinned copy dies under its own set -euo pipefail on date -d "-Matou/idss minutes" before printing anything, so the $(order-repos ...) substitution is EMPTY and the for-loop never calls run_repo for ANY repo. No backstop ticks at all since 04:15Z on matou-workstation; Forgejo's own scheduler is carrying the cadence alone. Suggested extra acceptance: an order-repos failure must fall back to registry order (|| printf per-slug) so a mixed-pin fleet degrades to unordered ticks, never to silence. Duplicate report #84 closed in favour of this ticket.

This was generated by AI during triage.

Triage: ready-for-agent + bug + priority

Ruled by agent under ADR 0174 — veto anytime.

Ruling: take option (b) — move the ordering into the generated tick so it has no cross-repo dependency — and land the fallback the follow-up comment asks for: an ordering failure degrades to registry order, never to silence. Also applying priority: per the comment's forensics this is a total backstop outage on at least one host, not a cosmetic log-noise bug, and priority is exactly the additive urgency marker the queue reads first.

Why (b) over (a)/(c): the fault is not "we picked the wrong checkout", it is "the tick depends on another repo's pinned copy of a contract it does not control". (c) picks a different repo and keeps the dependency — the newest-pinned repo can still be older than the tick's expectations, and the failure returns silently the next time pins spread. (a) needs the registry to know a factory checkout, which it does not. (b) deletes the class.

The fallback is not optional belt-and-braces: it is what converts any future ordering fault from silence into degraded-but-working. Ordering is a fairness optimisation (#45); dispatching is the job. The job must never depend on the optimisation succeeding.

Why this is a two-way door: a change to one generator function plus its render fixtures, revertible by a later commit, provable offline by onboarding/tests/host-state-lib-test.sh — no host, no network, no token. Not on the one-way-door list. Landing it changes nothing on any host until an operator re-renders, and host_state_install backs the live crontab up first so even that step is one crontab <backup> from undone.

Verification — confirmed at 9e2aaf6, including the total-outage severity

The generator in onboarding/host-state-lib.sh emits, verbatim:

for _slug in $(bash "<caller>/.sandcastle/schedule-backstop.sh" order-repos <slugs...>); do
  run_repo "$_slug"
done

where <caller> is bound from the first backstop row of the registry — the code comment states the assumption outright: "any repo's byte-identical, tokenless order-repos gives the same answer". That assumption is exactly what mixed pins break, and nothing enforces it.

The severity correction in the follow-up comment is right, and the mechanism is visible in the source: the dispatch is a for … in $(…) over a command substitution. When the old pinned order-repos dies, the substitution is empty, the loop body executes zero times, and run_repo is never called for any repo — while the generated tick's own set -u (no -e) means the script exits 0 and reports nothing. Silent, total, and indistinguishable in the log from a quiet-but-healthy host. Duplicate #84 correctly closed in favour of this ticket.

Agent Brief

Category: bug
Summary: The generated backstop tick orders its repos by shelling into the first registry repo's vendored copy of order-repos; under mixed pins that copy dies, the substitution is empty, and the host dispatches nothing at all.

Current behavior: Stalest-first ordering is delegated to one arbitrarily-chosen consumer's pinned schedule-backstop.sh. If that copy predates the current order-repos contract it mis-parses the slug list and dies (observed: date: invalid date '-<slug> minutes', 48× on one host). Because the call sits in a command substitution driving the dispatch loop, its failure silently suppresses every repo's tick — the host stops backstopping entirely and Forgejo's own scheduler carries the cadence alone.

Desired behavior: The tick computes its own dispatch order with no dependency on any consumer's vendored code. If ordering cannot be computed for any reason, the tick dispatches every registered repo in registry order and says so on stdout. A tick never dispatches zero repos because ordering failed.

Key interfaces:

  • The host-cron tick generator (the function that renders <home>/factory-cron/backstop-tick.sh and its companion crontab block) — the rendered script must be self-contained with respect to ordering. Everything it needs is already pure and tokenless: the comparison reads only the mtimes of the per-repo lastready stamps, with a missing stamp treated as the stalest of all, and ties preserving input order (a stable sort). Preserve all three properties, and preserve the stamp-path override seam the tests use.
  • schedule-backstop.sh order-repos — decide deliberately whether it stays as a standalone subcommand. It has other value as a pure, testable unit; if you keep it, the generated tick must no longer depend on a foreign checkout's copy of it. Duplicating a small pure comparison into the generated artifact is acceptable here and is the point of the fix; if you keep one source of truth, make it one the tick owns.
  • The dispatch loop's failure semantics — the ordering result must be validated before it drives the loop. A defensive shape such as order || printf '%s\n' <slugs> is what the follow-up comment asks for; whatever form you choose, the property to test is the loop body runs once per registered repo, always.

Acceptance criteria:

  • The rendered backstop-tick.sh contains no invocation of any consumer checkout's schedule-backstop.sh for ordering purposes. (tick itself still calls each repo's own copy to dispatch — that is correct and stays.)
  • Given lastready stamps of differing ages, the rendered tick dispatches stalest-first; a repo with no stamp sorts first; equal ages keep registry order.
  • With ordering forced to fail (or return empty), the tick still calls run_repo exactly once for every registered repo, in registry order, and emits a visible note that ordering degraded. A test asserting the dispatch count must fail on today's code.
  • Each repo's every backstop workflow still ticks together, in that repo's registry order (today's grouping is unchanged).
  • onboarding/tests/host-state-lib-test.sh render fixtures updated in the same commit (repo rule), covering both the ordered and the degraded paths.
  • Full offline suite green: for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done

Out of scope:

  • The stalest-first policy itself (#45) — the metric and its tie-breaking are correct; only where the computation lives and how it fails are in scope.
  • The registry format, the crontab splice, and the conflict detection.
  • Re-rendering host cron on matou-workstation, and clearing its 48 logged errors. That is the deploy step that ends the live outage, and it is a human's to run (onboard.sh host-cron, which diffs first and backs the crontab up before installing). Note in the close report that the fix is inert until a host re-renders — landing this ticket does not by itself restart the stopped backstop.
  • Bumping .sandcastle/FACTORY_REF.
> *This was generated by AI during triage.* ## Triage: `ready-for-agent` + `bug` + `priority` **Ruled by agent under ADR 0174 — veto anytime.** **Ruling:** take **option (b)** — move the ordering into the generated tick so it has no cross-repo dependency — **and** land the fallback the follow-up comment asks for: an ordering failure degrades to registry order, never to silence. Also applying `priority`: per the comment's forensics this is a **total** backstop outage on at least one host, not a cosmetic log-noise bug, and `priority` is exactly the additive urgency marker the queue reads first. Why (b) over (a)/(c): the fault is not "we picked the wrong checkout", it is "the tick depends on *another repo's* pinned copy of a contract it does not control". (c) picks a different repo and keeps the dependency — the newest-pinned repo can still be older than the tick's expectations, and the failure returns silently the next time pins spread. (a) needs the registry to know a factory checkout, which it does not. (b) deletes the class. The fallback is not optional belt-and-braces: it is what converts *any* future ordering fault from silence into degraded-but-working. Ordering is a fairness optimisation (#45); dispatching is the job. The job must never depend on the optimisation succeeding. **Why this is a two-way door:** a change to one generator function plus its render fixtures, revertible by a later commit, provable offline by `onboarding/tests/host-state-lib-test.sh` — no host, no network, no token. Not on the one-way-door list. Landing it changes nothing on any host until an operator re-renders, and `host_state_install` backs the live crontab up first so even that step is one `crontab <backup>` from undone. ### Verification — confirmed at `9e2aaf6`, including the total-outage severity The generator in `onboarding/host-state-lib.sh` emits, verbatim: ``` for _slug in $(bash "<caller>/.sandcastle/schedule-backstop.sh" order-repos <slugs...>); do run_repo "$_slug" done ``` where `<caller>` is bound from the **first** `backstop` row of the registry — the code comment states the assumption outright: "*any repo's byte-identical, tokenless order-repos gives the same answer*". That assumption is exactly what mixed pins break, and nothing enforces it. The severity correction in the follow-up comment is right, and the mechanism is visible in the source: the dispatch is a `for … in $(…)` over a command substitution. When the old pinned `order-repos` dies, the substitution is **empty**, the loop body executes zero times, and `run_repo` is never called for **any** repo — while the generated tick's own `set -u` (no `-e`) means the script exits 0 and reports nothing. Silent, total, and indistinguishable in the log from a quiet-but-healthy host. Duplicate #84 correctly closed in favour of this ticket. ## Agent Brief **Category:** bug **Summary:** The generated backstop tick orders its repos by shelling into the first registry repo's vendored copy of `order-repos`; under mixed pins that copy dies, the substitution is empty, and the host dispatches nothing at all. **Current behavior:** Stalest-first ordering is delegated to one arbitrarily-chosen consumer's pinned `schedule-backstop.sh`. If that copy predates the current `order-repos` contract it mis-parses the slug list and dies (observed: `date: invalid date '-<slug> minutes'`, 48× on one host). Because the call sits in a command substitution driving the dispatch loop, its failure silently suppresses **every** repo's tick — the host stops backstopping entirely and Forgejo's own scheduler carries the cadence alone. **Desired behavior:** The tick computes its own dispatch order with no dependency on any consumer's vendored code. If ordering cannot be computed for any reason, the tick dispatches every registered repo in **registry order** and says so on stdout. A tick never dispatches zero repos because ordering failed. **Key interfaces:** - The host-cron tick generator (the function that renders `<home>/factory-cron/backstop-tick.sh` and its companion crontab block) — the rendered script must be self-contained with respect to ordering. Everything it needs is already pure and tokenless: the comparison reads only the mtimes of the per-repo lastready stamps, with a **missing stamp treated as the stalest of all**, and ties preserving input order (a stable sort). Preserve all three properties, and preserve the stamp-path override seam the tests use. - `schedule-backstop.sh order-repos` — decide deliberately whether it stays as a standalone subcommand. It has other value as a pure, testable unit; if you keep it, the generated tick must no longer *depend* on a foreign checkout's copy of it. Duplicating a small pure comparison into the generated artifact is acceptable here and is the point of the fix; if you keep one source of truth, make it one the tick owns. - The dispatch loop's failure semantics — the ordering result must be validated before it drives the loop. A defensive shape such as `order || printf '%s\n' <slugs>` is what the follow-up comment asks for; whatever form you choose, the property to test is *the loop body runs once per registered repo, always*. **Acceptance criteria:** - [ ] The rendered `backstop-tick.sh` contains no invocation of any consumer checkout's `schedule-backstop.sh` for ordering purposes. (`tick` itself still calls each repo's own copy to dispatch — that is correct and stays.) - [ ] Given lastready stamps of differing ages, the rendered tick dispatches stalest-first; a repo with **no** stamp sorts first; equal ages keep registry order. - [ ] With ordering forced to fail (or return empty), the tick still calls `run_repo` **exactly once for every registered repo**, in registry order, and emits a visible note that ordering degraded. A test asserting the dispatch count must fail on today's code. - [ ] Each repo's every backstop workflow still ticks together, in that repo's registry order (today's grouping is unchanged). - [ ] `onboarding/tests/host-state-lib-test.sh` render fixtures updated in the same commit (repo rule), covering both the ordered and the degraded paths. - [ ] Full offline suite green: `for t in tests/*.sh onboarding/tests/*.sh; do case "$t" in *fakebin*|*fixtures*) continue;; esac; bash "$t" || echo "FAIL: $t"; done` **Out of scope:** - The stalest-first *policy* itself (#45) — the metric and its tie-breaking are correct; only where the computation lives and how it fails are in scope. - The registry format, the crontab splice, and the conflict detection. - Re-rendering host cron on `matou-workstation`, and clearing its 48 logged errors. That is the deploy step that ends the live outage, and it is a human's to run (`onboard.sh host-cron`, which diffs first and backs the crontab up before installing). **Note in the close report that the fix is inert until a host re-renders** — landing this ticket does not by itself restart the stopped backstop. - Bumping `.sandcastle/FACTORY_REF`.

swarm-claim host=matou-dev-server-01 run=973
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=973 (automated multi-host claim — lowest live claim id works this ticket)

close-report for #83 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 83,
  "status": "success",
  "commits": [
    "50f672b"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "onboarding/host-state-lib.sh",
    "onboarding/tests/host-state-lib-test.sh"
  ],
  "tests": [
    {
      "command": "bash onboarding/tests/host-state-lib-test.sh",
      "exit_code": 0
    },
    {
      "command": "bash tests/schedule-backstop-test.sh",
      "exit_code": 0
    },
    {
      "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL: $t; done",
      "exit_code": 0
    }
  ],
  "criteria": {
    "Rendered backstop-tick.sh contains no invocation of any consumer checkout's schedule-backstop.sh for ordering (tick still calls each repo's own copy to dispatch)": "onboarding/host-state-lib.sh emits an embedded order_repos and drives the loop off it; test 'render_backstop owns its ordering — no foreign order-repos dependency (#83)' asserts ! grep schedule-backstop.sh order-repos and ! grep order-repos, while the per-repo dispatch tick() call stays.",
    "Given lastready stamps of differing ages, rendered tick dispatches stalest-first; no-stamp repo sorts first; equal ages keep registry order": "test 'rendered tick dispatches stalest-first: missing stamp first, ties in registry order (#45)' RUNS the rendered tick over three repos (gamma no stamp, alpha/beta tied) and asserts order gamma, alpha, beta.",
    "With ordering forced to fail/return empty, tick still calls run_repo exactly once per registered repo in registry order and emits a visible degraded note; a dispatch-count test fails on today's code": "test 'rendered tick still dispatches every repo exactly once when ordering fails (#83)' forces order_repos empty via a failing sort, asserts 3 dispatches in registry order + 'ordering degraded' note; without the fallback the empty $_order runs the loop zero times, so the count assertion fails.",
    "Each repo's every backstop workflow still ticks together, in that repo's registry order (grouping unchanged)": "run_repo case grouping is unchanged; existing tests 'render_backstop ticks every one of a repo's workflows from its OWN checkout' and 'emits one tick per workflow' stay green.",
    "onboarding/tests/host-state-lib-test.sh render fixtures updated same commit, covering ordered and degraded paths": "same-commit test update adds the #83 run-the-tick block covering both paths.",
    "Full offline suite green": "for-loop over tests/*.sh + onboarding/tests/*.sh printed no FAIL (exit 0)."
  },
  "summary": "The generated backstop tick now computes its own stalest-first order via an embedded pure order_repos with a registry-order fallback, removing the mixed-pin foreign-checkout dependency that silently suppressed all dispatches.",
  "blockers": []
}
**close-report** for #83 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 83, "status": "success", "commits": [ "50f672b" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "onboarding/host-state-lib.sh", "onboarding/tests/host-state-lib-test.sh" ], "tests": [ { "command": "bash onboarding/tests/host-state-lib-test.sh", "exit_code": 0 }, { "command": "bash tests/schedule-backstop-test.sh", "exit_code": 0 }, { "command": "for t in tests/*.sh onboarding/tests/*.sh; do case \"$t\" in *fakebin*|*fixtures*) continue;; esac; bash \"$t\" || echo FAIL: $t; done", "exit_code": 0 } ], "criteria": { "Rendered backstop-tick.sh contains no invocation of any consumer checkout's schedule-backstop.sh for ordering (tick still calls each repo's own copy to dispatch)": "onboarding/host-state-lib.sh emits an embedded order_repos and drives the loop off it; test 'render_backstop owns its ordering — no foreign order-repos dependency (#83)' asserts ! grep schedule-backstop.sh order-repos and ! grep order-repos, while the per-repo dispatch tick() call stays.", "Given lastready stamps of differing ages, rendered tick dispatches stalest-first; no-stamp repo sorts first; equal ages keep registry order": "test 'rendered tick dispatches stalest-first: missing stamp first, ties in registry order (#45)' RUNS the rendered tick over three repos (gamma no stamp, alpha/beta tied) and asserts order gamma, alpha, beta.", "With ordering forced to fail/return empty, tick still calls run_repo exactly once per registered repo in registry order and emits a visible degraded note; a dispatch-count test fails on today's code": "test 'rendered tick still dispatches every repo exactly once when ordering fails (#83)' forces order_repos empty via a failing sort, asserts 3 dispatches in registry order + 'ordering degraded' note; without the fallback the empty $_order runs the loop zero times, so the count assertion fails.", "Each repo's every backstop workflow still ticks together, in that repo's registry order (grouping unchanged)": "run_repo case grouping is unchanged; existing tests 'render_backstop ticks every one of a repo's workflows from its OWN checkout' and 'emits one tick per workflow' stay green.", "onboarding/tests/host-state-lib-test.sh render fixtures updated same commit, covering ordered and degraded paths": "same-commit test update adds the #83 run-the-tick block covering both paths.", "Full offline suite green": "for-loop over tests/*.sh + onboarding/tests/*.sh printed no FAIL (exit 0)." }, "summary": "The generated backstop tick now computes its own stalest-first order via an embedded pure order_repos with a registry-order fallback, removing the mixed-pin foreign-checkout dependency that silently suppressed all dispatches.", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/dev-factory#83
No description provided.