Repository navigation
Description
Problem
infra/github-backup/bin/reconcile.py is the one remaining consumer of plan.json that reads it with a bare json.load and no shape validation — every sibling consumer was moved onto the validated loader in ghb_common (#6637 for fetch_mirrors, #6653 for manifest.py, and clone_all via the same pass), but reconcile's previous-plan read was not part of those fixes.
Sites (current origin/main ed2534c1dd):
reconcile.py:85—old_items = json.load(open(old_plan_path)), bypassingghb_common.load_plan/validate_plan(ghb_common.py:149/:224), which every other plan reader uses and which reports a wrong-shape entry by index and skips it.reconcile.py:86—old = [p["repo"] for p in old_items]subscripts every entry unguarded.reconcile.py:96-102— the last-known-good retention loop (the github-backup(inventory): a null repositoryOwner is silently read as 'this owner has no repos' — reconcile drops the owner's mirrors from plan.json and MANIFEST.json and exits 0 #3229 path, exercised exactly when an owner's inventory has failed) subscriptsitem["repo"]and callsitem["repo"].split("/")unguarded a second time.
A plan.json that is valid JSON but the wrong shape — a poison entry written by a bad emit, a hand edit, or a schema change landing in one writer before this reader — crashes the weekly reconcile at startup, before it writes the new plan, runs the clone pass, writes its dated report, or regenerates MANIFEST.json. The crash is self-perpetuating: the crashing run never rewrites plan.json, so next week's run hits the identical entry.
Evidence (verified this run, laptop @ origin/main ed2534c1dd)
Probe ~/git/fleet/probe-reconcile-old-plan/ on the laptop: the real reconcile.py (sha256 6f22eb29…, byte-identical to origin/main), ghb_common.py, and siblings copied verbatim, driving the real reconcile.main() with load_config / backup_root / inventory stubbed exactly as the in-tree test_reconcile_clone_pass.py does, against a temp backup root holding each test plan.json:
- Control — valid old plan
[{"repo": "good-owner/newrepo", …}]:main()completes its diff/report flow and rewritesplan.json(exit in the probe reflects only the stubbed clone pass reaching the probe dir's missing config, after the plan rewrite). - Old plan entry
123→TypeError: 'int' object is not subscriptable;plan.jsonunchanged. - Old plan entry
"good-owner/newrepo"→TypeError: string indices must be integers, not 'str'; unchanged. - Old plan entry
{"name": "x"}(norepo) →KeyError: 'repo'; unchanged. - Old plan entry
null→TypeError: 'NoneType' object is not subscriptable; unchanged. - Old plan top level
{"repo": "good-owner/newrepo"}(object, not a list) →TypeError: string indices must be integers, not 'str'; unchanged. - Old plan top level
"good-owner/newrepo"(string) → sameTypeError; unchanged. - Mixed old plan
[{"repo": "good-owner/old"}, 123]→TypeError: 'int' object is not subscriptable— the one valid entry is lost with the poison one. - Old plan entry
{"repo": 123}with an inventory error present →AttributeError: 'int' object has no attribute 'split'in the retention path (item["repo"].split).
In every malformed case no new plan is written, no report is written, and MANIFEST regeneration (manifest_mod.build(root) at the end of main()) is never reached.
Why it matters
Reconcile is the weekly correctness floor for the backup estate (module docstring): it is the sweep that guarantees nothing is missed — it re-plans from fresh inventory, clones newly planned mirrors, retains last-known-good entries for owners whose inventory failed, and refreshes MANIFEST.json, the disaster-recovery source. A poison entry in the previous plan does not degrade one repo: it takes down the whole sweep, silently (a traceback in a timer log), and it recurs every week until a human hand-repairs the file. The validated loader already exists in the same directory and already states the contract this read should follow: a bad entry is reported by name/index and skipped; a wrong-shape top level is a single named problem treated as empty. The previous-plan read is the last place that contract is not applied.
Distinct from: #6637 (fetch_mirrors plan/state shape — fixed, and its sibling pass covered manifest/clone_all but not reconcile's previous-plan read), #6653 (manifest build), #6606 (reconcile's clone-status.jsonl lines), #3240 (torn / unparseable JSON and non-atomic writes — these files parse fine), #6575 (drain queue-event shape).
Acceptance criteria
-
reconcile.main()loads the previous plan through the validated path (ghb_common.load_plan/validate_plan, or an equivalent guard): a plan entry that is not an object with a stringrepo, and a non-list top level, are reported by name/index viareport_problems(or an equivalent named warning) and skipped — never a rawTypeError/KeyError/AttributeErrortraceback that aborts the sweep. - Valid entries in the same previous plan still participate exactly as before: the added/removed diff and the github-backup(inventory): a null repositoryOwner is silently read as 'this owner has no repos' — reconcile drops the owner's mirrors from plan.json and MANIFEST.json and exits 0 #3229 last-known-good retention for failed owners both work off the surviving entries.
- A fully poisoned / wrong-shape previous plan behaves as an empty previous plan (all currently planned repos read as newly planned), and the run still writes the new
plan.json, its dated report, and reaches MANIFEST regeneration. - Well-formed behaviour is unchanged: the in-tree reconcile tests (
test_reconcile_clone_pass.py,test_reconcile_retention.py) still pass. - Regression tests in
infra/github-backup/tests/cover at least: old-plan entry123, entry as a string, entry missingrepo, entry{"repo": 123}on the inventory-error retention path, and a top-level object — each fails on current code with the exceptions above and passes after the fix.
Activity
developing-today commentedon Nov 7, 2026
CODE-2104
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
developing-today commentedon Nov 8, 2026
🤖 Agent note · handed off
opencode(§1b); handed off to the claimant.60 remaining items
dezren39 commentedon Nov 11, 2026
Agent note (lane code-b, task 11051): the code fix for this issue is already on main; PR #8684 adds the missing end-to-end regression coverage, completing the acceptance.
Verified on current main (
42c192357f):reconcile.main()loads the previous plan throughghb_common.load_plan, which runsvalidate_plan— a non-list top level is a single named problem treated as empty, and each entry that is not an object with a stringrepois reported by index and skipped. The previously unguarded reads (old = [p["repo"] for p in old_items], the #3229 retention loop'sitem["repo"].split(...)) now only ever see validated entries. The related field-shape hardening is #6834'svalidate_planwork (reference/branch/parent neutralized per entry).Gap closed by PR #8684:
test_plan_state_shape.pycoversvalidate_planas a unit, but nothing drovereconcile.main()with a poisoned previous plan. Newtests/test_reconcile_old_plan_shape.py(40/40 checks) covers entry123, entry as string, entry missingrepo, entrynull, a top-level object, a mixed valid+poison plan (valid entry still counted as removed), a fully poisoned plan behaving as empty (plan.json rewritten, dated report written, MANIFEST regenerated), and{repo: 123}on the inventory-error retention path (valid failed-owner entry retained). Siblings still green:test_reconcile_clone_pass.py14/14,test_reconcile_retention.py9/9,test_plan_state_shape.pyOK.On merge of PR #8684 this issue can close: every acceptance bullet is met by main + that PR.
dezren39 commentedon Nov 11, 2026
agent-note:v1
state: picked-up
queue: repo-health-code-pilot
task: 11051 (small_fix, worker repo-worker-code, lane code-a)
issue: #6831 OPEN, verified fresh 2026-11-11 — no held / user/owned / do-not-merge / do-not-auto-edit labels
execution_lane: direct (assignment row 6766, #8187)
resume: resuming from the awaiting_codex checkpoint — PR #8684 head is 18e34b0 on branch queue/11051-6831-reconcile-prev-plan (supersedes the branch name in the older checkpoint); Codex review of that head is complete and clean (has_any_findings=false, zero review comments); re-ran the suites at that head on the laptop: test_reconcile_old_plan_shape.py 40/40, test_reconcile_clone_pass.py 14/14, test_reconcile_retention.py 9/9
next: squash-merge PR #8684, verify #6831 closes, complete task 11051
test(github-backup): reconcile previous-plan poison shapes end-to-end (…
dezren39 commentedon Nov 11, 2026
agent-note:v1
state: done
queue: repo-health-code-pilot
task: 11051 (small_fix, worker repo-worker-code, lane code-a)
issue: #6831 — closing as completed
outcome: fixed_merged via PR #8684 (#8684), squash-merged 2026-11-11, merge sha 80f83c0; the code fix was already on main via #3240/#6834 sibling work (reconcile.main uses ghb_common.load_plan/validate_plan) — PR #8684 added the end-to-end regression coverage that was the remaining gap
evidence: at PR head 18e34b0 — test_reconcile_old_plan_shape.py 40/40, test_reconcile_clone_pass.py 14/14, test_reconcile_retention.py 9/9 (re-run on the laptop this shift); Codex review of that head complete, no findings; test file verified present on origin/main after the merge