Skip to content

github-backup(reconcile): a wrong-shape entry in the previous plan.json crashes the weekly sweep — reconcile is the last plan reader bypassing validate_plan #6831

Closed

Description

@dezren39

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):

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 rewrites plan.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.json unchanged.
  • Old plan entry "good-owner/newrepo" → TypeError: string indices must be integers, not 'str'; unchanged.
  • Old plan entry {"name": "x"} (no repo) → 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) → same TypeError; 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 string repo, and a non-list top level, are reported by name/index via report_problems (or an equivalent named warning) and skipped — never a raw TypeError / KeyError / AttributeError traceback 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 entry 123, entry as a string, entry missing repo, 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

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    app/github-backupinfra/github-backup estate mirror system
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

  4. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · handed off

  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 8, 2026
  6. 60 remaining items

  7. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    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 through ghb_common.load_plan, which runs validate_plan — a non-list top level is a single named problem treated as empty, and each entry that is not an object with a string repo is reported by index and skipped. The previously unguarded reads (old = [p["repo"] for p in old_items], the #3229 retention loop's item["repo"].split(...)) now only ever see validated entries. The related field-shape hardening is #6834's validate_plan work (reference/branch/parent neutralized per entry).

    Gap closed by PR #8684: test_plan_state_shape.py covers validate_plan as a unit, but nothing drove reconcile.main() with a poisoned previous plan. New tests/test_reconcile_old_plan_shape.py (40/40 checks) covers entry 123, entry as string, entry missing repo, entry null, 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.py 14/14, test_reconcile_retention.py 9/9, test_plan_state_shape.py OK.

    On merge of PR #8684 this issue can close: every acceptance bullet is met by main + that PR.

  8. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    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

  9. added
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 11, 2026
  10. dezren39 commented on Nov 11, 2026

    @dezren39
    MemberAuthor

    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

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

    app/github-backupinfra/github-backup estate mirror systemkind/bugSomething isn't working (prefixed form of the classic bug label)priority/lowNice to have; do when convenientsource/creatorFiled by the new-issue-creator jobstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions