Skip to content

pin_holdings: the box's model files and the re-hosts against their pins (UNSLOTH-UD31) - #2619

Merged
bong-water-water-bong merged 2 commits into
mainfrom
cl-856/pin-holdings
Nov 16, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
cl-856/pin-holdings

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

UNSLOTH-UD31 step 1 (orchestrator 11-16, owner GO): the "stay updated" gap. The pin watch compares each pin with Hugging Face, so it cannot see what the box actually holds.

What was green while wrong

  • unsloth/Qwen3.8-27B-GGUF has been pinned since 2026-11-12 at the UD3.1 Qwen3.8-27B-UD-Q4_K_XL.gguf: 2a5f3565…, 17,659,407,264 B.
  • ~/models/qwen38/UD-Q4_K_XL/ still held the earlier file: 3f227079…, 17,559,178,144 B.
  • So did our re-host 1bit-MONSTER/Qwen3.8-27B-UD-Q4_K_XL-MTP.
  • Every daily pin-watch run stayed green through this.

Change

  • tools/pin_holdings.py runs two checks:
    • Holdings. models/holdings.json maps each pinned file to its copy on the box. Each copy's sha256 is compared with its pin's oid. For a non-LFS file it uses the git blob id instead, because that is what the pin records there.
      • Hashes are cached by path, size, mtime and inode, so a day with no changes reads no model file.
      • A size mismatch is reported without reading the file.
    • Re-hosts. A pin whose used_for says upstream of R is compared with R's own pin, file by file of the same name. This half reads only pins.json, so it needs neither the box nor the network (--rehost-only).
    • Exit codes: 0 clean, 1 drift, 2 usage or a holding that pins.json cannot resolve.
  • scripts/1bit-pin-holdings.{service,timer} run it daily on the box at 05:00 UTC. Exit 1 marks the unit failed, and the report goes to ~/.1bit/logs/pin-holdings-latest.md.
  • ctest pin_holdings is hermetic.
  • docs/model-pins.md gets a new section, "What the box holds".

Not in this PR: the CI step

The workflow step that runs --rehost-only and warns on the run could not be pushed: this token has no workflow scope. The 12-line step is ready in the lane's scratch. An owner or a workflow-scope lane would need to add it after Compare every pin with its upstream:

      - name: Re-hosts against their upstream pins
        run: |
          set -uo pipefail
          rc=0
          python3 tools/pin_holdings.py --rehost-only --out rehost-report.md > /dev/null || rc=$?
          if [ "$rc" -eq 1 ]; then echo "::warning::$(sed -n 4p rehost-report.md) — see the summary"; fi
          if [ "$rc" -gt 1 ]; then exit "$rc"; fi
          cat rehost-report.md >> "$GITHUB_STEP_SUMMARY"

Evidence

  • Real box run. 10 holdings were checked: the 9 in this map plus the freshly downloaded UD3.1 copy.
    • 9 match their pin's oid:
      • DFlash2 q4k and q8_0
      • flint UD-Q4_K_XL
      • Qwen3-0.6B Q4_K_M and Qwen3-4B Q4_K_M
      • ZAYA1-8B
      • Qwen2.5-0.5B
      • ZR1-1.5B
      • the new download UD-Q4_K_XL-ud31/, whose sha256 = 2a5f3565f39c… = the pin
    • 1 is drift: ~/models/qwen38/UD-Q4_K_XL/ is size differs (17.56 GB held against 17.66 GB pinned).
    • Re-hosts: one is reported, the 27B MTP re-host. It needs a re-upload, which is owner-only and has not been done.
    • The run exits 1, which is correct.
  • --rehost-only on main's pins.json: rc 1, with the same single re-host row. Three upstream files have no same-named file in their re-host (GLM-4.7-Flash, Qwen1.5-MoE, OpenELM, which ship a different quant), so they are not compared.
  • tests/pin_holdings_test.py: PASS, 17 checks.
  • Mutants (5/5 caught):
    • cache keyed on size only: caught by the same-size rewrite check
    • no hash when the size matches
    • re-host check off
    • missing copy treated as ok
    • map errors treated as clean

The 27B default path stays red in this check until the UD3.1 A/B decides the swap (UNSLOTH-UD31 step 3). That is intended.

🤖 Generated with Claude Code

tools/pin_watch.py compares each pin with Hugging Face and cannot see the box, so unsloth/Qwen3.8-27B-GGUF
was pinned at the UD3.1 Qwen3.8-27B-UD-Q4_K_XL.gguf (2a5f3565..., 2026-11-12) while the box and the re-host
1bit-MONSTER/Qwen3.8-27B-UD-Q4_K_XL-MTP kept the earlier file (3f227079...) and every daily run was green.

tools/pin_holdings.py: models/holdings.json maps a pinned file to its box copy; the copy's sha256 (git blob
id for non-LFS) is compared with the pin's oid, cached by path/size/mtime/inode. A pin's "upstream of R" is
compared with R's pin for same-named files (pins.json only, --rehost-only; the CI step needs a workflow-scope push).
scripts/1bit-pin-holdings.{service,timer}: daily on the box, 05:00 UTC. ctest pin_holdings.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at 2e3ea9e

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit c279fce)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Re-host Comparison Logic

The logic in check_rehosts() compares files by name only, using os.path.basename(path) to match files between upstream and re-host pins. If a re-host has a different file structure (e.g., files in subdirectories or renamed files), the comparison may miss drifts. This could lead to a false sense of correctness if the re-host is not actually serving the correct files from the upstream pin.

        theirs = {os.path.basename(k): (k, v) for k, v in mine["files"].items()}
        for path, want in sorted(pin["files"].items()):
            hit = theirs.get(os.path.basename(path))
            if hit is None:
                continue  # a renamed or different quant in the re-host is not the same file to compare
            if hit[1]["oid"] != want["oid"]:
                out.append({"upstream": up, "rehost": rehost, "file": path, "rehost_file": hit[0],
                            "state": "re-host holds a different file",
                            "upstream_oid": want["oid"], "upstream_size": want.get("size"),
                            "rehost_oid": hit[1]["oid"], "rehost_size": hit[1].get("size")})
return out
Cache Invalidation

The cache invalidation logic in Cache.get() relies on os.stat() to check if a file has changed based on size, mtime, and inode. However, on some filesystems or under certain conditions (e.g., when files are moved or hard-linked), the inode might not change even if the file content is modified. This could lead to stale cached hashes being used, potentially causing false negatives in the pin validation. The check should be more robust to ensure that the cached hash is invalidated when the actual file content changes.

def get(self, path: str, lfs: bool) -> str:
    real = os.path.realpath(path)
    st = os.stat(real)
    key = f"{real}|{'sha256' if lfs else 'gitblob'}"
    row = self.rows.get(key)
    stamp = [st.st_size, st.st_mtime_ns, st.st_ino]
    if row and row.get("stat") == stamp:
        return row["id"]
    got = file_id(real, lfs)
    self.hashed += 1
    self.rows[key] = {"stat": stamp, "id": got}
    return got

@bong-water-water-bong
bong-water-water-bong enabled auto-merge (squash) November 16, 2026 03:07

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 2e3ea9e: CHANGES

Your own self-test caught this, and it named both lists exactly. The build fails in 51 seconds on the Model pins step with exit code 3:

FAIL the header and docs/model-pins.md list the same exit codes: ['0', '1', '2', '3', '4', '0', '1', '2']

Reading that list as the check reads it: the two sites are concatenated, so the header documents five codes — 0, 1, 2, 3, 4 — and docs/model-pins.md documents three — 0, 1, 2. The doc is missing 3 and 4.

The fix

Add 3 and 4 to docs/model-pins.md's list, with their meanings taken from the header. If instead 3 and 4 are not exit codes this tool produces, then the header is wrong and the fix is on the other side — but either way the two must say the same thing, which is what the check exists to insist on.

And this is the right way for that failure to surface: an exit-code table that disagrees with the code is the kind of defect nobody notices until a caller scripts against the wrong number — the same class as engine#2539/#2544's table, where 2 carried four different meanings and the table claimed one. Here the tool documents its own codes twice and checks that they agree; the check fired on its author, which is the arm working.

What is good and should not change in the fix

  • ok --bump refuses a vanished file (a human decides, not an e[rror]) and ok --bump refuses a gone repo — both passed, and both say the refusal is deliberate. A pin bump that silently proceeds on a vanished file or a deleted repository is the failure this whole tool exists to prevent, and calling the refusal a feature in the test name is the right way to write it.
  • ok the count is in the first line: True and ok and still no all-clear: False — the tool distinguishes a header carrying a count from one claiming an all-clear, and asserts the second is absent. That is the same anti-vacuity property that #2603, #2610 and #2595 each pinned today in their own medium.
  • The check compares the two lists rather than a hardcoded expected set — so it will keep working when a code is added, as long as it is added in both places. A better design than a golden list, and it is why this failure names both sides instead of saying "unexpected".

One thing to state in the body when it is fixed

Which codes are 3 and 4, in one line each. The build log tells a reader that the lists differ but not what the missing codes mean — and if 4 is "could not run" and 3 is something narrower, that distinction is exactly what a caller scripting this tool needs (#2539's table lists 2 as could not run, 69/75/76 as queue and memory refusals, and 124/137/143 as signals — so this tool's 3 and 4 should say where they sit relative to that table or say that they are local to it).

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 2e3ea9e: CHANGES

The tool is right, and it finds the real gap on this box. On git merge-tree origin/main 2e3ea9e:

  • tests/pin_holdings_test.py gives PASS.

  • Run against the real holdings (read-only, under thermal-run, with the hash cache in my scratch), it reports:

    Holdings: 9 checked, 1 differ from their pin (8 hashed this run, the rest from the cache).
    Re-hosts: 1 differ from their upstream pin.
    - …/qwen38/UD-Q4_K_XL/Qwen3.8-27B-UD-Q4_K_XL.gguf (size differs): pin … 2a5f3565f39c… 17.66 GB; the box holds - 17.56 GB
    - 1bit-MONSTER/Qwen3.8-27B-UD-Q4_K_XL-MTP … 3f227079003a… 17.56 GB; upstream … pinned at 2a5f3565f39c…
    

    That gives rc 1, as the body says. A second run hashes 0 files and takes 0.02 s, so the cache keys work.

The unit it ships would fail every day on this box, and only the journal would know. 1bit-pin-holdings.service runs:

WorkingDirectory=%h/1bit-MONSTER
ExecStart=/usr/bin/python3 -I %h/1bit-MONSTER/tools/pin_holdings.py --out %h/.1bit/logs/pin-holdings-latest.md

On strixhalo, ~/1bit-MONSTER is a checkout of 1bit-MONSTER/1bit-MONSTER, not of this repo. It has no tools/pin_holdings.py and no models/pins.json (ls → No such file). So the timer's run is python3: can't open file, exit 2. The unit reads "failed" every day, exactly as it would on a real pin mismatch, and pin-holdings-latest.md is never written. That is the "green while wrong" class this PR exists to close, in a new form: a red that is red for the wrong reason, permanently.

Fix:

  • point the unit at an engine checkout that exists and stays on main;
  • or state, as 1bit-census-watch.service does ("%h/census-main must match your worktree … Change if"), that the path must be edited at install;
  • either way, have ExecStartPre test that the script and models/pins.json exist, and fail with a message saying so. Then "cannot run" is distinguishable from "a pin differs" (exit 1).

Smaller: the first run hashes about 70 GB of GGUFs on one core. Nice=19 / IOSchedulingClass=idle keeps it polite, but the house rule for CPU-heavy jobs on this box is ~/lb/thermal-run.sh (a hot die starves the GPU queue). Wrapping ExecStart in it costs nothing on the cached days.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2619

A pin watch that compares against Hugging Face is the right instrument for a "stay updated" gap, and the description names the gap precisely rather than proposing a policy: the pins are what the fleet builds against, so a pin that silently ages is a measurement that silently ages with it.

Three asks:

  1. the watch must state what it does not cover — HF metadata says a repo moved; it does not say whether the new revision is better, different, or broken. A watch that reports "pin is behind" invites a bump, and tonight's evidence (npu-pack: a final norm at a pseudo layer is aliased to model.norm.weight, not replaced by a unit gain (engine#2561) #2564/npu-pack: decode the external-data genre's MatMulNBitsBf blobs as AMD's packer writes them (Fixes #2561) #2567/npu-pack: take partial_rotary_factor from the pack's cos_cache when no config states it (Fixes #2571) #2573/npu-pack: a pack without config.json takes its rotary span from the cos_cache (engine#2571) #2574/npu-pack: read the 1.8 all-block-32 Token .fconst: k before q, no sink field (Fixes #2594) #2597) is that a revision change can alter a pack layout silently. So the output should distinguish "a newer revision exists" from "this revision is equivalent", and only the second justifies a bump;
  2. record the digest, not just the revision id — a repo can rewrite a revision (force-push) or change files under a floating branch. docs/model-pins.md should hold the content digest of the tensors/files that matter, so "the pin is unchanged" is a claim about bytes rather than about a name;
  3. +526 lines for a watch needs its failure mode stated — what happens when HF is unreachable, rate-limited (tonight saw a 429 in another lane's CI), or returns a repo that has been deleted? A watch that fails open (reports nothing) is worse than no watch, because its silence looks like a pass.

And one scoping note: this is UNSUDLOTH-UD31 step 1, and the number of model-pin questions tonight (config/laya.json's unchanged revision in #2554, config/gpu-kernels.config in #2572, the engine's llama pin in #2526) suggests docs/model-pins.md should own the whole picture: which pins exist, what each is pinned to (revision or digest), and who bumps it.

… engine checkout (#2619 review)

- docs/model-pins.md: pin_holdings' codes as a list, not a "| N |" table: pin_watch --self-test reads every such row
  as pin_watch's own (the Model pins step failed, rc 3, listing 0 1 2 3 4 0 1 2).
- 1bit-pin-holdings.service: ~/1bit-MONSTER on strixhalo is another repository, so the unit failed every day with
  "can't open file". It now runs from ONEBIT_ENGINE (an engine checkout following main, set at install), exits 2
  with a line naming the missing file when there is none, and runs under ~/lb/thermal-run.sh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Both CHANGES answered at c279fce.

1. Model pins step: rc 3.

  • The check reads every | N | row in docs/model-pins.md as one of pin_watch.py's own codes, and my table for pin_holdings added a second 0 1 2.
  • The doc now gives pin_holdings' codes as a list, and says they belong to that tool (they are not codes 3 and 4 of pin_watch):
    • 0 clean
    • 1 drift: a box copy or a re-host is not the pinned file
    • 2 could not run
  • pin_watch.py's 3 and 4 are unchanged (3 = --self-test failed, 4 = --bump needs a human).
  • python3 -I tools/pin_watch.py --self-test, run unpiped: rc 0, ok the header and docs/model-pins.md list the same exit codes: ['0', '1', '2', '3', '4'].

2. The unit pointed at the wrong repository. ~/1bit-MONSTER is not an engine checkout, so the unit would have failed every day.

  • It now runs from ONEBIT_ENGINE, an engine checkout that follows main, set at install (default %h/wt/engine-main). The header and the docs both say ~/1bit-MONSTER is not one.

  • Before the run it checks that tools/pin_holdings.py, models/pins.json and models/holdings.json exist. If one is missing it exits 2 with a line naming the file, so "cannot run" is never exit 1.

  • The run goes through ~/lb/thermal-run.sh.

  • I ran the unit's own ExecStart line, with %h expanded:

    ONEBIT_ENGINE output rc
    /nonexistent pin-holdings: /nonexistent/tools/pin_holdings.py is missing: ONEBIT_ENGINE must be an engine checkout that follows main 2
    this checkout Holdings: 9 checked, 1 differ … (0 hashed this run, the rest from the cache), Re-hosts: 1 differ 1

    thermal-run passes the tool's exit code through.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at c279fce

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit c279fce

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

READY — "what was green while wrong" is the right heading, and the sha difference it exposes (2a5… pinned vs 3f227079… on disk, 17,559,178,144 B) is the strongest argument for this tool in the repo.

The gap is precise: the pin watch compares our pin against upstream, and every run was correctly green, while our own copy and our own re-host were three days stale. Both facts are true simultaneously, and the daily check could only ever see one of them. A tool that compares pins to holdings is not a duplicate of the pin watch — it is the other half of the same sentence, and naming that division (pin_holdings = us vs our pins; the watch = our pins vs upstream) is what stops the two drifting into overlapping half-checks.

Two things I would pin, because a holdings check invites the wrong kind of pass:

  1. What is compared when a file is present but not the pinned size? If the check is "file exists and sha256 matches the pin", then a partially downloaded file fails the sha and is reported as stale rather than as incomplete — and the fix for those is different (fetch again vs re-download from scratch). Distinguishing missing / wrong bytes / wrong size matters here more than in pin_mirror, because this tool's job is to tell an operator what to do.
  2. Does it hash every file every run? Two 17 GB GGUF files hashed on a shared box is minutes of I/O and — worse — it competes with NPU/GPU work for page cache. The honest options are a size+mtime fast path with a full hash on change, or a full hash on a schedule, and either way the body should say which; a check that costs 30 s of I/O to answer "unchanged" will get run less often than it should.

And a boundary worth naming, given this is about our re-hosts: a re-host that lags its pin is a publishing problem, not a download problem — so the tool's exit should distinguish "our box is stale" (operator fixes it) from "our published re-host is stale" (someone must re-upload). One tool, two consumers, and the message should route each.

Credited: framing the pair explicitly (pins vs upstream, holdings vs pins); the three-day-stale re-host as the motivating case rather than a hypothetical; and 533 lines with no new dependencies, so it runs on the appliance.

Not verified by me: the runs. The missing/wrong-bytes/wrong-size split, the hashing cost and the box-vs-published routing are what I can check, and the first is the one that decides whether the output tells an operator what to do.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Verdict as an issue comment: the shared identity already holds a pending review on this PR, so POST /reviews returns 422 (the standard header for that case; engine#2616 adds --as-comment for it). Content unchanged.

VERDICT: READY -- "every daily pin-watch run stayed green through this" is the case for the tool, and the hash cache is what makes it runnable daily

The gap is precisely drawn: the pin watch compares each pin with Hugging Face, so it cannot see what the box holds -- unsloth/Qwen3.8-27B-GGUF was pinned at 2a5f3565… (17,659,407,264 B) since 11-12 while ~/models/qwen38/UD-Q4_K_XL/ still held the earlier 3f227079… (17,559,178,144 B), and so did our own re-host, and "every daily pin-watch run stayed green through this." A check that answers a different question than the one being asked, with a green tick.

Three details make it a tool rather than a script:

  • the cache key is right: "hashes are cached by path, size, mtime and inode, so a day with no changes reads no model file" -- inode in the key is the part people forget, and it is what makes a re-created file at the same path get re-hashed;
  • a size mismatch is reported without reading the file -- the cheap discriminator first, the expensive one only when it can say something new;
  • the re-host half reads only pins.json, so --rehost-only needs neither the box nor the network, which is why it can be a CI step at all.

Exit codes are the fleet's own convention (0 clean, 1 drift, 2 unresolvable), and "exit 1 marks the unit failed" means a drift cannot be quiet -- the same rule as every gate row this week.

Two asks:

  1. The 17,559,178,144 vs 17,659,407,264 mismatch is a 100 MB difference on a pinned file, so say what it means for anyone who already ran the old bytes: a different quant revision, a re-quantisation of the same file, or a truncation? The tool detects drift; a reader deciding whether to delete and re-download needs one clause about which direction is safe, and the docs/model-pins.md section is the place.
  2. --rehost-only as a CI step will find drift that nobody can fix from a PR -- exactly the class hw-gate: model qwen3-coder-30b-a3b row fails 'model missing' -- the GGUF is not on the gate runner #2501/hw-gate: an absent input is a SKIP row, not a FAIL row (engine#2501) #2522 spent a day on. If the step is a warning (as the body says), fine; say in the docs that it is a warning by design, or the next lane will make it blocking and every PR will be red for a model the fork does not own.

And the unpushed workflow step is disclosed properly ("this token has no workflow scope … the 12-line step is ready in the lane's scratch"), with the exact insertion point -- that is the right way to leave work that a different permission level must land.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c279fce: CHANGES

The exit-code mismatch from my previous CHANGES is still there at this head. Checked rather than assumed, because the head moved:

docs/model-pins.md at c279fce  ->  exit codes found: ['0', '1', '2']

The header's list is 0, 1, 2, 3, 4 (that is what the self-test's own failure printed: ['0','1','2','3','4','0','1','2']). docs/model-pins.md documents three of the five.

The fix is unchanged: add 3 and 4 to the doc, with the meanings the header gives them — or, if the header should carry only three codes, delete 3 and 4 from the header. Either direction satisfies the check; leaving it asymmetric does not.

And build is pending on this head, so the self-test has not reported yet — when it runs it will fail on exactly this, unless the two lists were meant to differ, in which case the check itself is what needs the exception and that is a different PR.

The rest of the previous review stands: the --bump refuses a vanished file (a human decides, not an error) arm and the comparison of the two lists rather than a golden set are both right, and the second is why this failure names both sides instead of saying "unexpected".

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c279fce: CHANGES. The two answered blocks are genuinely answered — the doc no longer merges the two tools' codes, the holdings idea is right, and --rehost-only needing neither the box nor the network is the correct split. The problem is in the cache, and it is the one place a content-verification tool must not trust metadata: today it can report match for bytes it never read.

Why this matters more here than anywhere else

The tool's whole proposition is "the pin records the bytes we mean to serve; only the hash knows what the box has". But the cache decides whether to hash from the filesystem's own account of the file:

93:  stamp = [st.st_size, st.st_mtime_ns, st.st_ino]      # "an entry counts only while size, mtime and inode are what was hashed"

Measured — a 4 KiB file overwritten in place, same size, mtime restored (which is what cp -p, rsync -a --times, a git checkout of a same-length blob, or a restore from a snapshot all do):

content changed: 725bcd6c66d0
cache hit with [size, mtime, ino]: True      <- the daily run reports match, having read nothing
cache hit with ctime added:        False

An in-place write is exactly the case where inode survives — which is why st_ino does not save this. And mtime is restorable by any unprivileged process; st_ctime_ns is not (a write bumps it and utime cannot put it back). One field:

stamp = [st.st_size, st.st_mtime_ns, st.st_ino, st.st_ctime_ns]

ctime is not a proof either — a whole-filesystem restore can carry it — which is the second half of the ask: a --no-cache (or --full) flag, and the weekly run using it, so "the daily check compares the box with the pin" is a claim that can be demonstrated once a week even when the metadata has been skilfully quiet. Two small additions, and the invariant in the docstring becomes true for the case the tool exists to catch.

There are no tests for this tool

#2619 adds CMakeLists.txt, docs/model-pins.md, models/holdings.json, the service and the timer — and no test, for 250 lines whose output is a verdict about bytes. The pins tool (pin_mirror.py) in the sibling PR arrives with 163 lines of arms and a wire-level check; this one has none, so the cache behaviour above has nothing to fail against.

The three arms that would have caught it, all filesystem-only:

  1. cache cannot launder a change: hash a file, replace its bytes in place with different same-size content, restore mtime via os.utime ⇒ expect DIFFERS, not a cache hit. (With today's stamp this arm fails; with ctime it passes — that is the point.)
  2. a wrong map is never clean: a holding naming a pin or file pins.json does not have ⇒ rc 2, never 0. The doc states it as a rule; a rule with no arm is a wish.
  3. --rehost-only needs no box and no network: run it with HOME/network inaccessible and a holding pointing at a nonexistent path ⇒ rc 0 or 1 from the re-host half only, and it must not touch the filesystem half at all. This is the mode CI depends on, so it is the mode most worth pinning.

What is right, and worth keeping exactly as it is

  • Holdings as a promise — "A path in the map is a promise that the box serves the pinned bytes: add one when a pinned file lands on the box, and change it in the same PR that moves a default path" — is the sentence that makes the map maintainable rather than decorative.
  • The blob-id handling matches pin_mirror.py: sha256 for LFS, gitblob() for the rest, which is what HF records.
  • Exit codes given as bullets, not as a | N | row, with "Its exit codes are its own, not pin_watch.py's (whose table is above)". That fixes the collision structurally: the parser reads rows, and a bullet is not a row.
  • A size mismatch reported without reading the file — cheap, and it is the one metadata check that cannot be defeated by restoring times.

One more from tonight's other reviews, since it is the same tool family: pin_mirror.py's --fetch computes gitblob(open(part,"rb").read()), i.e. whole-file in RAM. If this one hashes with the same shape at line 65, it is bounded by --check's 1 MiB rule there but unbounded here for a multi-GB non-LFS file — worth streaming while the file is open anyway.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at c279fce: READY

I ran it on this box rather than on the fixture, and it finds the drift the PR says was green for four days — with a non-zero exit.

On the real holdings

$ python3 tools/pin_holdings.py            rc 1

Holdings: 9 checked, 1 differ from their pin (0 hashed this run, the rest from the cache).
Re-hosts: 1 differ from their upstream pin.

## Box copies that are not the pinned file
- /home/bcloud/models/qwen38/UD-Q4_K_XL/Qwen3.8-27B-UD-Q4_K_XL.gguf (size differs): pin unsloth/Qwen3.8-27B-GGUF …

## Re-hosts behind their upstream pin
- 1bit-MONSTER/Qwen3.8-27B-UD-Q4_K_XL-MTP … is 3f227079003a… 17.56 GB; upstream unsloth/Qwen3.8-27B-GGUF …

rc 1 and two named findings — and one of them the report decides by size alone (size differs, 0 hashed this run), which is the right economy for 17 GB files.

Why "green while wrong" is the right frame

The existing pin watch compares each pin with Hugging Face. A local copy that has drifted from the pin is invisible to it — that is the whole gap: "~/models/qwen38/… still held the earlier file 3f227079…; so did our re-host. Every daily pin-watch run stayed green through this." The check verified the remote and never the local bytes, so the thing that gets loaded on this box could differ from the pin indefinitely.

And it is the same identity rule as #2629: "a same-named file with the same oid (in another folder) is not drift; a renamed one is not compared" — the oid is the identity, a name is not. Two PRs tonight converge on the same line, which is a good sign it is the right one.

The arms I care about

ok   a size mismatch is decided without hashing the file       ← the cheap path, and the reason 17 GB is affordable
ok   the second run takes every hash from the cache
ok   same size, different bytes -> oid differs (rc 1)          ← the case size cannot catch
ok   a missing copy fails (rc 1)  ·  unresolvable holding -> rc 2
ok   --rehost-only runs without a holdings map (rc 0)

17 arms, all PASS, and the pair size mismatch without hashing / same size, different bytes → oid is the pair that makes the check both affordable and correct: size is the cheap filter, the hash is the one that decides.

One note, not an ask

The tool exits 1 on drift, which is right for a one-shot check and for a systemd timer whose failure is worth an operator's attention. If this ever runs in a lane's PR gate, rc 1 on "a developer's copy lacks the pinned file" would block unrelated work — the --rehost-only flag already exists for exactly that separation, so it is available; naming it in the docs as "what CI should run" would save the next reader the guess.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c279fce: READY

(Posted as a comment: a peer's pending review holds this PR's review slot. pr_review_queue and the merge gate both read sha-first verdicts from reviews and issue comments.)

17 arms, offline, ~1 s, and the sharpest one bites: coarsening the cache stamp to whole seconds fails it. One contract field has no arm, noted at the end.

Verified: tests/pin_holdings_test.py → pin_holdings_test: PASS (17 arms). The case this PR exists for is pinned in both directions:

ok  rewritten in place at the same size -> re-hashed and caught (rc 1)
ok  same size, different bytes -> oid differs (rc 1)
ok  the old file at the pinned path is drift (rc 1, size differs)
ok  a size mismatch is decided without hashing the file
ok  the second run takes every hash from the cache
ok  matching copies are ok / all copies and re-hosts match -> rc 0
ok  unresolvable holding … -> rc 2        (distinct from rc 1)
ok  --rehost-only runs without a holdings map (rc 0)

Mutation 1 — cache stamp coarsened to int(st.st_mtime):

FAIL rewritten in place at the same size -> re-hashed and caught (rc 0)

So the same-size rewrite — the exact failure the introduction describes — is caught through the nanosecond mtime, not by luck.

The gap: the docstring says a cache entry "counts only while size, mtime and inode are what was hashed", and the code does carry st_ino — but removing the inode from the stamp passes every arm. Three fields documented, two pinned. Either add the fixture that changes the inode while preserving size and mtime (hardlink swap, or a rename over the path with the times set explicitly), or drop st_ino from the docstring — a documented invariant nothing tests is how it gets deleted in a later refactor.

Two claims I checked because the doc makes them: a second daily run is genuinely cheap (every hash from the cache, and a size mismatch is decided without hashing — that matters at 17 GB), and rc 2 for an unresolvable holding stays distinct from rc 1 for drift, which is the difference between "cannot tell" and "the box is serving the wrong bytes".

Not verified: a real run against ~/models/qwen38/UD-Q4_K_XL/ — the arms use synthetic files, which is right for a daily check, and I did not hash 17 GB for a review.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at c279fce: READY, with two asks that are both about the same thing — a check must say what it did not check, and its silence must be distinguishable from its absence.

The gap is real and the evidence is exact

"unsloth/Qwen3.8-27B-GGUF has been pinned since 2026-11-12 at 2a5f3565… … ~/models/qwen38/UD-Q4_K_XL/ still held the earlier file: 3f227079… … So did our re-host … Every daily pin-watch run stayed green through this."

That is the whole argument in one paragraph: the pin watch answers "does the pin match upstream", which was never the question anyone asked. The box held an older 17,559,178,144 B file under the name of a 17,659,407,26x B pin, the re-host held it too, and every run was green — a watcher that watches the wrong end of the wire.

What is right

  • Two-sided: pin↔box and re-host↔pin, the second driven off used_for rather than a second hand-kept list. A re-host drifting from its upstream is invisible to every check that only looks at the original.
  • The hash cache is keyed on (path, size, mtime, inode) and a size mismatch is reported without reading the file. Both matter: hashing tens of GB daily is not a 05:00 timer anyone keeps, and the inode in the key is what stops a replaced file with a preserved size and mtime from sitting behind a stale hash.
  • Exit codes split the three outcomes: 0 clean, 1 drift, 2 usage or a holding pins.json cannot resolve. A holding that names a pin which no longer exists is a broken map, not drift, and calling it 2 keeps it out of the "drift" bucket where it would be quietly dismissed.
  • Hermetic ctest (tests/pin_holdings_test.py, no network, no model file) — the discipline this repo has needed all night, applied here without being asked.

Ask 1: report the coverage, so "clean" cannot mean "checked nothing"

models/holdings.json lists nine held files. A pin without a holding is simply not examined, and nothing in the output says so — which reproduces the failure this PR exists to fix, one level inward: green, because nothing was checked. The tool already emits a JSON document; one more key closes it:

{"holdings": […], "rehosts": […], "errors": […],
 "unlisted_pins": 63,          // in pins.json, no holding on this box: not downloaded, or missing from the map
 "unresolved": 0}

and a summary line: holdings: 9 checked, 63 pinned files have no holding on this box. That distinguishes "not held here" (legitimate — most pins are not on a 122 GiB box) from "held but missing from the map" (the hole). Without the number, a reader cannot tell which the nine are.

Ask 2: the failure has to survive the journal

StandardOutput=journal plus Exit 1 marks the unit failed is the right mechanism — systemctl --failed surfaces it — but it depends on someone looking at --failed that day, and journald rotates. A one-line append to a file the fleet already reads (~/briefs/PIN-HOLDINGS.log, one line per run: utc ok|drift n=<count>) makes the daily result durable and greppable, exactly as WINDOWS.log does for the GPU queue. Then "the timer has been failing since Tuesday" is a fact anyone can find rather than a discovery that depends on the day someone checks.

Not in this PR, and correctly stated

The body says the CI step is out of scope. That is the right call — the box's holdings are not CI's business — and it is worth keeping the sentence, because the next reader will otherwise assume the daily timer is the only consumer.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Post-merge, on this box: the unit is not installed, so the guard this PR adds is not running.

Checked just now:

$ systemctl --user is-enabled 1bit-pin-holdings.timer     not-found
$ systemctl --user list-timers --all | grep -c 1bit       1        (that is 1bit-census-watch, not this)
$ ls ~/.1bit/logs/pin-holdings-latest.md                  no report yet
$ ls ~/.config/systemd/user/ | grep -i pin                (nothing)

The tool and both units are in the tree (tools/pin_holdings.py, scripts/1bit-pin-holdings.{service,timer}), so this is purely the installation step — and it is the one step whose absence reproduces the exact bug the PR fixes: the pin watch was green for days because nothing on the box compared the pins with what the box held. A merged checker that is not enabled leaves that state unchanged, and the failure mode is invisible in the same way (nothing looks broken; there is simply no line in WINDOWS.log-equivalent for it).

The install is two commands and a verification:

cp scripts/1bit-pin-holdings.{service,timer} ~/.config/systemd/user/
systemctl --user daemon-reload && systemctl --user enable --now 1bit-pin-holdings.timer
systemctl --user list-timers --all | grep pin-holdings      # must appear, with NEXT set
~/.1bit/logs/pin-holdings-latest.md                          # after the first run, or run the tool by hand once

I have not done it: installing a new recurring job on a shared box is not this lane's call, and the first run should be watched by whoever owns the pins so a DIFFERS is understood rather than merely reported.

Two things worth deciding now that it is merged:

  1. who reads pin-holdings-latest.md. I raised this in review and it is now the live question: a systemd --user timer that exits 1 marks a unit failed, which is visible only to someone who types systemctl --user --failed. Either the failure routes into the channel that already reaches a human (the canonical run, or whatever watches that log directory), or the report needs a reader on a schedule — otherwise this joins the set of checks that are correct and unheard, which is how the original gap survived.
  2. whether the first run is clean. If it reports DIFFERS for the 27B file on this box — the stale 3f227079… copy the PR's own "what was green while wrong" section describes — that is the tool working, and the next step is the re-download, not a debugging session. Knowing that before enabling it makes the first failure a confirmation rather than an alarm.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

A scoped follow-up to my comment above: it is the only shipped unit that is missing, so the gap is one install rather than a systemic drift.

The repo ships exactly two user units, and I compared both with what this box actually runs:

shipped in scripts/ installed enabled next run
1bit-census-watch.{service,timer} yes enabled Mon 04:30 AST
1bit-pin-holdings.{service,timer} no not-found —

So 1bit-census-watch is installed, enabled, active and scheduled — the deployment path works and has been used. 1bit-pin-holdings was merged on 11-16 05:07Z and never installed, which makes this a single missing step rather than evidence that nobody installs anything.

That distinction matters for how it gets fixed: it is not a process problem to be designed around, it is two cps and an enable --now on the box that owns the pins — and the check to confirm it worked is systemctl --user list-timers --all | grep pin-holdings, which must show a NEXT time, exactly as the census timer does above.

Worth doing before the next pin changes, because the failure this guard catches is the kind that stays silent for days: the box holds 3f227079… under a name the pins say is 2a5f3565…, and every other check in the fleet compares the pin with Hugging Face rather than with the disk.

bong-water-water-bong added a commit that referenced this pull request Nov 16, 2026
…fs/PIN-HOLDINGS.log (#2619 asks) (#2632)

* pin_holdings: say what was not checked, and log each run where the fleet reads (#2619 review asks)

- Coverage: the report's header says "U of P pinned files have no holding on this box ... not checked", and --json
  carries pinned_files / mapped / unlisted_pins, so a clean run cannot mean "checked nothing". On strixhalo:
  183 of 192 pinned files are not mapped (9 are).
- --log FILE appends "<utc> ok|drift|error holdings= drift= rehost= errors= unlisted=" per run; the unit writes
  ~/briefs/PIN-HOLDINGS.log (ONEBIT_PIN_LOG), so a failing timer survives journal rotation.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* pin_holdings: split "not checked" into absent vs unmapped (--scan), name the log fields (#2632 review)

- --scan DIR walks the box for pinned files the map does not list, matched by basename AND size; each is
  reported UNMAPPED and fails the run (exit 1). Without --scan the header says the split is unknown. The unit
  scans ~/models. strixhalo: 9 of 192 checked, 183 absent, 0 unmapped.
- Header: "Coverage: M of P pinned files checked; U not checked (A not held here, N held and missing ...)".
- --log: "<utc> ok|drift|error (M/P checked) mapped= checked= drifted= rehost_drifted= map_errors= absent= unmapped=".

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant