Skip to content

hardware-doc-init: the existing-checkout update block is unreachable — a clean, behind checkout is adopted as-is and never fast-forwarded #6890

Closed

Description

@dezren39

Problem

scripts/hardware-doc-init.sh promises in its header (:17-21) that an existing sibling hardware-doc checkout is kept current safely — "Only ever fast-forwards. No merge, no rebase, no reset" — and carries a ~35-line update block implementing exactly that: detached-HEAD, dirty-tree, no-upstream, fetch-failure, up-to-date, fast-forward, unpushed-commits and diverged cases (:76-110). That block is unreachable dead code, so an existing checkout is never updated at all.

The reuse-or-clone chain at :59-110 is:

if [ -d "$TARGET/.git" ]; then
  ok "using existing checkout at $TARGET"          # :59-65 — adopt as-is, no update
  ...
elif [ ! -e "$TARGET" ]; then
  ... clone ...                                    # :66-71
elif [ ! -d "$TARGET/.git" ]; then
  err "$TARGET exists but is not a git repository" # :72-74
else
  # --- update, but never destructively ---        # :76-110 — DEAD
  BRANCH="$(git -C "$TARGET" symbolic-ref ...)"
  ...
fi

The else requires all three earlier conditions to be false: ! -d "$TARGET/.git" (from branch 1), $TARGET exists (from branch 2), and -d "$TARGET/.git" (negation of branch 3) — a contradiction. Every existing checkout takes branch 1 and is adopted exactly as found, however stale.

Verified on laptop @ 0a5c705a23 (probe ~/git/fleet/probe-hwdoc, real script verbatim, md5 269dbe024f43bb51f79fb4e3bb439b3a): fixture code repo beside a hardware-doc clone that is clean, on main, upstream configured, and strictly behind by one commit. The script exits 0 printing ✓ using existing checkout at ... and the symlink is created — but the sibling HEAD is byte-identical before and after (06c29b5c1ef…), while upstream sits at 6c2e23ea906…. No fetch, no fast-forward, no warning that the checkout is behind. The dirty/detached/diverged safeguards in the dead block likewise never run, so a diverged checkout is adopted with the same green checkmark as a current one.

Why it matters

  • The script is the documented entry point for bringing the hardware-doc knowledge base beside the repo; anyone re-running it to pick up new hardware research silently keeps whatever vintage they first cloned, while the output claims success.
  • The dead block is the script's entire safety story for updates (never touch a dirty checkout, warn on divergence). Its unreachability means those warnings can never fire either — staleness and divergence are both invisible.
  • The link-2 section comment (:195-205) tells future editors to "mirror the clone/update block used for hardware-doc above" — the block it points at does not execute, so the pattern propagates the defect.

Acceptance criteria

  • Running the script with an existing clean, behind, upstream-tracking hardware-doc checkout fast-forwards it and reports the fast-forward (the :99 message or equivalent).
  • The existing safeguards actually execute: detached HEAD, dirty tree, missing upstream, fetch failure, unpushed commits, and divergence each produce their warning and leave the checkout untouched.
  • The not-a-repository case ($TARGET exists without .git) still errors out, and the absent case still clones.
  • A regression test (fixture repos: behind / dirty / diverged / detached / no-upstream / not-a-repo / absent) covers the branch routing; the symlink behaviour of the current script is unchanged for the clone and adopt paths.

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
    on Nov 7, 2026
  2. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  3. added
    source/creatorFiled by the new-issue-creator job
    priority/normalOrdinary priority (the default)
    effort/sSmall: expected under 2 hours of work
    on Nov 7, 2026
  4. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator (new-issue-creator-code-a)
    • Session / ID: cron job new-issue-creator-code-a, run 2026-11-07T14:05Z
    • Found via: filed this run
    • Task: Filed after verifying on the laptop that scripts/hardware-doc-init.sh's existing-checkout update block (:76-110) is unreachable — the if/elif chain makes the else a contradiction — so a clean, behind hardware-doc checkout is adopted as-is and never fast-forwarded (probe ~/git/fleet/probe-hwdoc @0a5c705a23).
    • Expectation: effort/s — restructure the branch routing so the update block executes for existing checkouts, with fixture-repo regression tests per the acceptance criteria.
    • Links: queue packet enqueued to repo-health-code-pilot this run
  5. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 8, 2026
  6. dezren39 commented on Nov 8, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    • Agent: repo-worker-code-o (lane code-o)
    • Session / ID: cron repo-queue-worker-shift-o, run 2026-11-08T01:19Z
    • Task: task 11287 (small_fix) — restructure scripts/hardware-doc-init.sh reuse-or-clone chain so the existing-checkout update block executes; add fixture-repo regression test.
    • Expectation: branch queue/11287-6890-hardware-doc-init-update, PR opened, task completed or parked on CI per runbook.
  7. 4 remaining items

  8. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · parked

  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 8, 2026
  10. added a commit that references this issue on Nov 8, 2026
  11. developing-today commented on Nov 8, 2026

    @developing-today
    Contributor

    🤖 Agent note · done

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

    effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/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