CodeIssuesPull RequestsActionsSecurityInsights
✨ AI
More
Settings

fix(autopilot): mirror-sync could never report failure, and mirroring was dead #5482

Merged⚡ AI-generatedXSccantynz wants to mergefix/mirror-sync-cannot-report-ok-while-deadmainopened 21d ago
ccantynzcommented 21d ago

What was actually happening

GitHub→Gluecron mirroring had stopped across the whole estate, and nothing said so:

Repo Behind by Frozen since
vapron 522 commits
davenroe 65
alecrae.com 17 2026-08-07
zoobicon.com 5 2026-07-31
jarvis-platform 5

Every autopilot tick logged mirror-sync ok. The public /status page read "All systems operational". Found on 2026-08-11 only by comparing git ls-remote between the two hosts by hand.

Why it was invisible — three layers, each converting failure into silence

1. The task discarded the result.

{ name: "mirror-sync", run: async () => { await syncAllDue(); } }

syncAllDue() returns {total, ok, failed} and resolves normally no matter what — runMirrorSync records a failed run and, by its own comment, "never throws out". So the counts were thrown away and the task reported ok because nothing threw.

This is the same defect this file's header already documents for the 23 catch-without-rethrow tasks — in a different shape. Those swallowed a throw; this discarded a result. That's precisely why the rethrow fix applied to those could not catch this one.

2. listDueMirrors() ended in catch { return [] }. An unreadable mirror table produced {total: 0} — indistinguishable from "nothing due" to every caller.

3. total === 0 was silent. A wiped or never-created mirror table looked exactly like a host that legitimately has no mirrors.

The change

  • mirror-sync logs total/ok/failed every tick and throws when failed > 0 — including partial failures, because a partial failure is still mirroring that did not happen, and that is how one repo drifts unnoticed.
  • listDueMirrors() logs and rethrows instead of disguising a DB error as nothing-due. Only caller is syncAllDue, reached from this task, which now surfaces it as a failed tick.
  • total === 0 resolves (legitimate on a host with no mirrors) but warns every tick, so "nothing to do" can never again read as "everything is mirrored".

Verification

The regression test exercises the real task from defaultTasks(), not a description of it.

  • Fails 3/4 against the pre-fix code (verified by stashing the fix and re-running)
  • Passes 4/4 after
  • tsc --noEmit clean · sibling autopilot tests 22 pass

Still outstanding after this merges

This fixes the reporting, which is what let it run dead for weeks. It does not by itself restore mirroring — the six repos were fast-forwarded manually on 2026-08-11, and whether enabled repo_mirrors rows exist for them is unverified. Once this is deployed the next tick will say so out loud: either failed > 0, or the NO mirrors warning.

That is the point — it can no longer be quiet about it.


Found during the fleet dead-surface sweep. Context: FINDINGS.md (F27) in ccantynz/platform-contracts.

🤖 Generated with Claude Code

gluecron[bot]🤖 botAI Reviewcommented 21d ago

AI review unavailable

The platform's AI balance is exhausted, so AI generation is temporarily unavailable. Nothing was lost. You can queue this as a repair for the internal agent from the repository's Health page, or try again once the balance is restored. The PR is otherwise unchanged.

ccantynzAI Reviewcommented 21d ago

AI Triage

(no summary)

Priority: medium Risk area: mixed

Suggested labels: (no label suggestions) Suggested reviewers: (no reviewer suggestions)

Suggestions only — nothing has been applied. The PR author stays in control.

Cross-repo impact

See what breaks downstream if this PR merges.

Analyze →
⮌ Merged

This pull request was merged into main.

c comment · e edit title · m merge · a approve · r request changes · ? shortcuts