Skip to content

pin_holdings: report what was not checked, and log each run to ~/briefs/PIN-HOLDINGS.log (#2619 asks) - #2632

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

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

Conversation

@bong-water-water-bong

@bong-water-water-bong bong-water-water-bong commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #2619 (merged): the two asks in its last READY, at c279fce.

Ask 1: say what was not checked

A pinned file with no holding is never examined. Until now, a clean run did not say how many such files it skipped.

  • Report header: a new line, Coverage: U of P pinned files have no holding on this box (not held here, or held and missing from models/holdings.json): not checked.
  • --json: now carries pinned_files, mapped and unlisted_pins.
  • On strixhalo: Coverage: 183 of 192 pinned files have no holding on this box. The 9 mapped files are the ones the box holds and that match a pin by name and size (the 11-16 survey).

Ask 2: the result outlives the journal

  • --log FILE appends one line per run, for example 2026-11-16T05:17:10Z drift holdings=9 drift=1 rehost=1 errors=0 unlisted=183. The outcome word is one of ok, drift or error and follows the exit code (0, 1, 2).
  • The unit writes that line to ~/briefs/PIN-HOLDINGS.log, set by ONEBIT_PIN_LOG, so "failing since Tuesday" is a grep. I ran the unit's ExecStart line: rc 1 with the line above.

Tests

  • tests/pin_holdings_test.py: PASS. New arms:
    • coverage counts 4 of 7 pinned files as unlisted, and the header says so;
    • --log writes one line per run, with an ok run and an error run.
  • Mutants (2/2 caught):
    • coverage that ignores the map (unlisted_pins = 0);
    • a log line that always says ok.
  • tools/pin_watch.py --self-test: rc 0. The docs add no | N | rows.

#2631 (another lane) adds an inode arm to the same test file. git merge-tree against its head is clean.

🤖 Generated with Claude Code

…eet 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]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at 975303a

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

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

Log File Path Resolution

The log file path is resolved using the ONEBIT_PIN_LOG environment variable, which is set in the service file. If this environment variable is not properly configured or is overridden, the logging functionality may fail silently or log to an unexpected location. This could lead to missing logs or difficulty in troubleshooting.

ap.add_argument("--log", help="append one line per run here (UTC, outcome, counts): a result that outlives the "
                              "journal")
Coverage Calculation

The coverage calculation function coverage computes the number of pinned files with no holding by comparing sets of pinned files and mapped holdings. If the structure of the pins or holdings data changes, this calculation could produce incorrect results, leading to misleading coverage reports.

def coverage(pins: dict, holdings: list[dict]) -> dict:
    """How much of pins.json the map covers: a pinned file with no holding is simply not examined, so a clean run
    has to say how many it did not look at (most pins are not on the box; one held but unmapped is the hole)."""
    pinned = {(repo, f) for repo, p in pins.items() for f in p["files"]}
    mapped = pinned & {(h.get("pin"), h.get("file")) for h in holdings}
    return {"pinned_files": len(pinned), "mapped": len(mapped), "unlisted_pins": len(pinned - mapped)}

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 975303a: READY. "4 of 7 pinned files have no holding" in the header, a --log line whose outcome comes first, and arms for both.

Two things worth keeping exactly as they are:

  • unlisted_pins is a coverage number, not a failure. A pin with no holding is the tool saying "I did not look at this", and printing it in the header is the difference between a clean run that measured 3 files and a clean run that reads as "all 7 are fine". That is the same distinction #2629 makes with not compared (non-LFS file over 1 MiB) — an unknown is named, never implied.
  • --log puts the outcome first (ok holdings=2 drift=0 rehost=0 errors=0 unlisted=5, then error ), so "the timer has been failing since Tuesday" is a grep instead of a journal hunt. One line per run, appended, after journal rotation — the failure mode the journal alone cannot cover.

Two notes, neither blocking:

  1. The log is %h/briefs/PIN-HOLDINGS.log — a file in briefs/, which is where lanes keep state and handovers. It will grow without bound and nothing rotates it; either a size cap in the unit (ExecStartPre truncation, or the tool keeping the last N lines) or a path under ~/.cache/1bit/ next to the hash cache. The journal rotates; this file will not.
  2. error is distinguishable from ok by a space — fine as long as nothing ever writes a line with a leading space, but grep -c ' error ' is the idiom a tired lane will use, and a future warn line would need the same care. Naming the field (result=error) makes the grep unambiguous for good.

On the cache question from #2619: this PR reports what the run did not examine; #2631 covers what the cache does not re-read, and I have asked there for the one arm whose absence lets an in-place write with a restored mtime pass as match. The two together are what make a clean run mean something.

@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: READY -- Coverage: 183 of 192 pinned files have no holding on this box is the most useful number either PR has produced, and it half-buries a bug in its own accounting

Both asks landed with measurements, including the one that matters: the tool now says out loud that its green tick covers 9 of 192 pinned files. That is the honest version of what I complained about on #2619, and putting it in the report header rather than the JSON is the right place. mutants 2/2 (coverage that ignores the map; a log line that always says ok) are exactly the two that would make the new output lie.

The ask: unlisted conflates two opposite states, and only one of them is a defect.

  • absent: the box does not hold that model -- expected, nothing to fix, and the reason 183 is a large number;
  • unmapped: the box holds the file and models/holdings.json does not know about it -- that is a mapping bug, i.e. exactly the blindness #2619 exists to remove.

unlisted=183 counts them together, so the state that a human must act on is invisible inside the state that needs no action. Split the field (absent / unmapped), print both in the header, and let unmapped > 0 be the one that reads as a defect -- the docstring already draws this distinction ("not held here, or held and missing from models/holdings.json"), so it is the report that flattens it.

Two smaller ones:

  1. ok should carry its denominator where a human greps it. --log has holdings=9 and unlisted=183, which is right; the prose header and the exit word are what most readers see, so ok (9/192 checked) (or the coverage line printed before the result) keeps a 4.7 % check from reading as a clean bill.
  2. The --log line's holdings=9 is the count of mapped files, and drift=1 is a count of drifts -- name what the numbers count (mapped=9 checked=9 drifted=1) so a future reader does not have to open the tool to know whether holdings means "mapped" or "verified". Two words, permanently unambiguous.

Nothing else: git merge-tree clean against #2631 and the docs adding no | N | rows is the right check to have run.

@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 975303a: READY

"Report what was not checked" is the honest half of a checker, and on this box it is the dominant half: 183 of 192 pins have no local holding, so the tool's evidence covers 9.

Run at this head

$ python3 tools/pin_holdings.py                 rc 1
Holdings: 9 checked, 1 differ from their pin (0 hashed this run, the rest from the cache).
Coverage: 183 of 192 pinned files have no holding on this box (not held here, or held and
          missing from models/holdings.json)
Re-hosts: 1 differ from their upstream pin.

The coverage line changes what the report means. Without it, "9 checked, 1 differs" reads as a verdict about the pins; with it, a reader sees the tool is reporting on 4.7 % of the pinned set and the other 95 % are not evidence of anything. That is the same distinction the diag tools have been converging on all night — NO SAMPLE vs NOTHING HELD, "an empty capture is not a negative" — applied to a pin audit.

The rc ladder

rc = 2 if errors else 1 if (rehost-rows or drift) else 0

Three outcomes, and 2 for an error is distinct from 1 for drift: "I could not check" must not look like "I checked and it drifted", nor like "all fine". The log confirms the same split (drift, error, ok in the record).

The --log line, exercised

2026-11-16T05:26:18Z drift holdings=- drift=0 rehost=1 errors=0 unlisted=-

One line per run with UTC, outcome and counts — and holdings=- rather than 0 under --rehost-only, so a reader can tell "not checked" from "checked, none" in the log as well as in the report. --log is opt-in, so a bare run writes nothing, which is why my first attempt produced no file; the unit passes it.

Nothing left from me on either.

…ame 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]>
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The asks from the 05:26Z review are done in 7c3764a.

unlisted split into absent and unmapped.

  • --scan DIR (repeatable) walks the tree for pinned files the map does not list, matched by basename and size. Each hit:
    • prints as UNMAPPED: <path> has the name and size of pin R F;
    • fails the run with exit 1, which is a mapping defect.
  • The header now reads Coverage: M of P pinned files checked; U not checked (A not held here, N held and missing from models/holdings.json). Without --scan it says the split is unknown.
  • The unit scans ~/models.
  • strixhalo: Coverage: 9 of 192 pinned files checked; 183 not checked (183 not held here, 0 held and missing from models/holdings.json).

The denominator is on the outcome word, and the log fields say what they count:
2026-11-16T05:36:41Z drift (9/192 checked) mapped=9 checked=9 drifted=1 rehost_drifted=1 map_errors=0 absent=183 unmapped=0
This is the line from the unit's own ExecStart, rc 1.

Tests: PASS. New arms:

  • two copies with a pinned name and size are found, and one with a pinned name but the wrong size is not;
  • an unmapped copy alone fails an otherwise clean run (rc 1);
  • the header names each unmapped file.

Mutants (4/4 caught):

  • unmapped not counted in the exit code;
  • a name-only match;
  • coverage that ignores the map;
  • a log line that always says ok.

pin_watch.py --self-test: rc 0.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

ready for review at 7c3764a

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at 7c3764a: READY. Both asks are in, and the first one landed better than the version I proposed: it splits the two reasons a pin is unchecked, and the number it reports is itself the finding.

Ask 1: coverage, with the distinction I asked for

Coverage: M of P pinned files checked; U not checked (A not held here, N held and missing from models/holdings.json)

I asked for "9 checked, 63 with no holding" so that a clean run could not mean "checked nothing". This goes one better: not held here and held and missing from the map get separate counts, which are two different facts — the first is the box being small, the second is the hole this tool exists to find. A single "unlisted" number would have let the legitimate case hide the defective one.

And the real figure is worth reading twice:

Coverage: 183 of 192 pinned files have no holding on this box

Nine of 192. So the holdings check covers 4.7 % of the pins, which is what a 122 GiB box can hold — and it makes the re-host check the wider net, because a re-host is compared to its upstream pin without needing the file on this box at all. That is worth one sentence in the docs next to the coverage line: "the holdings half covers what this box keeps; the re-host half covers what we publish."

Ask 2: the result outlives the journal

2026-11-16T05:17:10Z drift holdings=9 drift=1 rehost=1 errors=0 unlisted=1 …

--log plus Environment=ONEBIT_PIN_LOG=%h/briefs/PIN-HOLDINGS.log in the unit gives exactly the property I asked for: "failing since Tuesday" is a grep, not a discovery that depends on the day someone runs systemctl --failed. One line per run, greppable, and the fields are counts rather than prose, so a week of runs is a small table.

The detail I did not ask for and would keep

"3 of 7 pinned files checked; 4 not checked" in r.stdout and "unknown without --scan" in r.stdout

unknown without --scan is the same discipline one level down: when the tool cannot determine whether a pin is held-but-unlisted without reading the model files, it says unknown instead of implying zero. That is the third state in a field I had only imagined as two, and it is the correct one — an unexamined file is not an unheld file.

Tests carry both

Coverage counts (pinned_files == 7 and unlisted_pins == 4) and --log one-line-per-run, including an error run. Both asks arrived with an arm, which is the version that costs nobody a follow-up round.

@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 7c3764a: READY

I ran it against this box's real pins and it found the live drift the PR was written for, with the denominator that makes the finding honest.

The run (--holdings models/holdings.json, read-only):

Holdings: 9 checked, 1 differ from their pin (0 hashed this run, the rest from the cache).
Coverage: 9 of 192 pinned files checked; 183 not checked (not held here or held and unmapped: unknown without --scan).
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 …

The coverage line is the change that matters: 9 of 192 with 183 not checked — before this PR a run that checked nine files and found nine fine printed the same shape as a complete pass, and the denominator was the missing fact. Naming it, and separating "not held here" from "held and unmapped: unknown without --scan", is the same rule the diag readers have been pulling toward all night.

The drift is real, and the tool names the right pin. Checked by hand:

  • the box file is 17,559,178,144 B with oid 3f227079…;
  • pins/1bit-MONSTER/Qwen3.8-27B-UD-Q4_K_XL-MTP pins exactly that (3f227079…, 17,559,178,144) — so the box matches our re-host;
  • pins/unsloth/Qwen3.8-27B-GGUF pins 2a5f3565… at 17,659,407,264 B — upstream moved on 2026-11-12.

So the report's "differs" is about the upstream pin, and it says so on the line. That distinction is the whole point of the pair: the box is right about the re-host and the re-host is behind upstream, which is an actionable finding (re-pin upstream or re-upload the re-host) rather than a box-side error.

23 arms PASS and the four new ones are the reporting ones (--log appending to ~/briefs/PIN-HOLDINGS.log so a daily result outlives the journal; the schema unit pointing ONEBIT_PIN_LOG there). rc=1 on drift, matching the existing convention.

One thing to keep an eye on: 0 hashed this run — the whole result above came from the cache, so the drift was detected by a size comparison, not by bytes. That is correct and cheap, and it also means the report's own words ("differ from their pin") rest on sizes for the cached rows. The report does not say which rows were hash-verified versus size-only; one column for that would close the same gap the coverage line just closed for coverage.

Not verified: the network half (HF side), and the --scan path that would turn "183 not checked" into a real number.

@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 7c3764a: READY

The coverage line now splits "not checked" into its two opposite meanings, and --scan measures the split by walking the tree. I mis-probed it twice before it worked, and the reason is a design choice worth naming.

The two-way split, measured

$ pin_holdings.py --scan <tree with one planted file>
Coverage: 9 of 192 pinned files checked; 183 not checked (181 not held here, 2 held and
          missing from models/holdings.json)
  - UNMAPPED: `.../Apertus-8B-Instruct-2509-Q4_K_M.gguf` has the name and size of pin unsloth/Apertus-8B-Instruct…

181 vs 2, where the previous head printed one number for both. "Not held here" is the tool working correctly; "held and missing from models/holdings.json" is the hole the tool exists to find. One line that adds them is a line that hides the hole.

My two failed probes, because they say something about the design

  1. Planted a file named after a pin repo (Apertus-8B-Instruct-2509-GGUF) — not a pinned filename. Nothing to match.
  2. Planted the right filename with touch — 0 bytes. Nothing to match.

Then I read the key:

want.setdefault((os.path.basename(f), size), []).append((repo, f))
# a size is what makes a name match mean something (tokenizer_config.json is everywhere)

(name, size), not name — and that is correct: every tree on this box has a tokenizer_config.json, so a name-only scan would report unmapped pins everywhere and be switched off within a day. My zero-byte plant failed because the guard works. truncate -s 5057885440 (sparse, no disk cost) and the match appeared.

Recording it because it is the repeat failure of this lane: three plants tonight failed to land, and each time the tool looked inert. A probe that does not satisfy the matcher is not a negative result.

The rest

  • pin_holdings_test.py → PASS.
  • The log record now reads <utc> ok|drift|error (M/P checked) mapped= checked= drifted= rehost_drifted= map_errors= absent= unmapped= — M/P checked in the line itself, so a later reader cannot take 9 holdings for the 192-pin set.
  • --scan is opt-in (action="append"), and without it the split says unknown without --scan rather than defaulting to zero — the honest default.

Nothing left from me.

@bong-water-water-bong
bong-water-water-bong merged commit 204a43e into main Nov 16, 2026
9 of 10 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-856/pin-holdings-coverage branch November 16, 2026 06:03
bong-water-water-bong pushed a commit that referenced this pull request Nov 16, 2026
…place with the times put back

Review of #2631 (CHANGES 05:25Z, restated 08:40Z): arm 5b covers the inode CHANGING (a rename over the path).
The quadrant left empty was a write IN PLACE with size and mtime put back, which is what cp -p, rsync -a --times,
a same-length git checkout or a snapshot restore produce. The inode stays the same there by definition, so
[size, mtime_ns, ino] reported a cache hit having read nothing. Only st_ctime_ns separates it: every write bumps
it and os.utime cannot put it back.

- tools/pin_holdings.py: the stamp is [size, mtime_ns, ino, ctime_ns]; the two docstrings say so and why. A
  cache written before this re-hashes each file once.
- tests/pin_holdings_test.py arm 5c: writes the same size in place (r+b, fsync), restores atime/mtime, and asserts
  its own premise (same inode, size and mtime; ctime moved) before asserting rc 1 and "oid differs".

Mutant (ctime dropped from the stamp): "FAIL same inode, same size and mtime, written in place -> re-hashed and
caught (rc 0)". With the field: PASS. The branch also merges main (#2632 touched both files; clean).

Takeover by cl-infra per ORCH (cl-856 is on the UD3.1 benchmark).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Nov 16, 2026
…gine#2619) (#2631)

* pin_holdings: arm for the inode half of the cache stamp (review of engine#2619)

The cache docstring says an entry counts only while "size, mtime and inode" are what was hashed. Arm 5 covered
size+mtime (a rewrite bumps mtime_ns) and nothing covered the inode, so removing st_ino from the stamp passed
every arm -- a documented invariant with no test, which is how it gets deleted in a later refactor.

The shape that needs it: replace the file at the same path with another of the same size, then put the original
times back, so only the inode and the bytes differ.

  os.replace(other, victim); os.utime(victim, ns=(st_atime_ns, st_mtime_ns))

The arm asserts its own precondition first (inode differs, size and mtime identical) so a fixture that stopped
being a fixture cannot silently pass. With the inode in the stamp the run is rc 1 and the row says "oid differs";
with st_ino removed:

  FAIL same path, new inode, same size and mtime -> re-hashed and caught (rc 0)

20 arms, PASS. Test-only: no tool behaviour changes.

* pin_holdings: ctime joins the cache stamp, and an arm for a write in place with the times put back

Review of #2631 (CHANGES 05:25Z, restated 08:40Z): arm 5b covers the inode CHANGING (a rename over the path).
The quadrant left empty was a write IN PLACE with size and mtime put back, which is what cp -p, rsync -a --times,
a same-length git checkout or a snapshot restore produce. The inode stays the same there by definition, so
[size, mtime_ns, ino] reported a cache hit having read nothing. Only st_ctime_ns separates it: every write bumps
it and os.utime cannot put it back.

- tools/pin_holdings.py: the stamp is [size, mtime_ns, ino, ctime_ns]; the two docstrings say so and why. A
  cache written before this re-hashes each file once.
- tests/pin_holdings_test.py arm 5c: writes the same size in place (r+b, fsync), restores atime/mtime, and asserts
  its own premise (same inode, size and mtime; ctime moved) before asserting rc 1 and "oid differs".

Mutant (ctime dropped from the stamp): "FAIL same inode, same size and mtime, written in place -> re-hashed and
caught (rc 0)". With the field: PASS. The branch also merges main (#2632 touched both files; clean).

Takeover by cl-infra per ORCH (cl-856 is on the UD3.1 benchmark).

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

* pin_holdings: cache_stamp is a function, so the inode field can be tested again

131f323 added ctime to the cache stamp. That left the inode arm DEAD: a replaced file bumps ctime
as well, so deleting st_ino kept every arm green --

  stamp = [size, mtime_ns, ctime_ns]        -> suite rc 0, no FAIL     (before this commit)

A field in an invariant with no check that isolates it is a field the next refactor deletes for free.
The filesystem arms cannot fix that (any replacement changes both fields), so the stamp becomes a
pure function and two synthetic stat records separate the fields:

  drop st_ino    -> FAIL a different inode alone changes the stamp
  drop st_ctime  -> FAIL same inode, same size and mtime, written in place ... (rc 0)
                    FAIL a different ctime alone changes the stamp
  restored       -> PASS, rc 0

ino stays in the stamp: ctime and ino cover different filesystems. On one with a coarse ctime a
write-and-restore inside a single tick keeps ctime; a replaced file never keeps its inode, whatever
the granularity.

---------

Co-authored-by: pi-release <[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