Judge a derived pin by its pattern's output at upstream's tip (issue btclib-org/btclib#3133) #442
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"c2e5cca33c92cec9d1956c25a86db46ebf7f2fd9","has_any_findings":true,"has_unresolved_findings":true,"status":"failed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
<details>
<summary><strong>Codex Review Summary</strong>: ❌ Failed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ❌ Failed <relative-time datetime="2026-11-19T06:23:52.455612Z">2026-11-19T06:23:52.455612Z</relative-time><br/>We couldn’t complete this review. Comment @codex review to try again. | c2e5cca | PR opened |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
<!-- btclib-findings-record -->
Findings on c2e5cca: none open that blocks; those that apply to every copy wait on ISS btclib-org/btclib#3155.
| Round | Head | Reviewer | Verdict |
| --- | --- | --- | --- |
| 1 | c2e5cca | CodeRabbit CLI (local) | 0 findings |
| 2 | c2e5cca | dedicated reviewer (Claude Code) | CLEARED |
| 3 | c2e5cca | fresh reviewer (Claude Code), standing in for Codex by the maintainer's ruling of 2026-11-19 | CLEARED |
| # | Raised by | On | Where | Outcome | Checked on |
| --- | --- | --- | --- | --- | --- |
| 1 | dedicated reviewer | c2e5cca | tests/_data/README.md:71, "ref names the branch" while the ledger's ref lines name commits | open, non-blocking: the sentence is the base's, only refilled here; for the next change on ref | c2e5cca |
| 2 | dedicated reviewer, fresh reviewer | c2e5cca | FakeGh ignores encoding, so no test checks that the tarball call reads bytes | open, every copy: ISS btclib-org/btclib#3155 | c2e5cca |
| 3 | fresh reviewer | c2e5cca | .github/workflows/vendored-vectors.yml:68, the issue title blames upstream for a local edit | open, every copy: ISS btclib-org/btclib#3155 | c2e5cca |
| 4 | dedicated reviewer | c2e5cca | a failed gh call's stderr is not printed, and a server error is not retried (the base's, and no worse here) | collateral: ISS btclib-org/bip32-descriptors#441 | c2e5cca |
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/btclib-org/bip32-descriptors/pull/442?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- recent_review_status_start -->
No actionable comments were generated in the recent review.
<!-- recent_review_status_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>Summary</strong></summary>
<dl>
<dd>
<br>
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
- The vendored-vector checker now supports pattern-derived files, compares locally stored results with upstream data, and reports missing or differing content separately from ordinary version drift.
- Checker output now identifies matching derived files and provides details about differences when derived content does not match.
- Added guidance on pattern entries, how derived files are compared, and how their
behind values are interpreted.<!-- end of auto-generated comment: release notes by coderabbit.ai -->
The vendored-vector checker now parses pattern entries, derives expected files from upstream tarballs, and compares those files with local copies. It reports matching derived files separately from pattern drift and ordinary tip drift.
Changes: Pattern-derived vendored vector checks
|Layer / File(s)|Summary|
|:---|:---|
|Ledger pattern contract <br> .github/scripts/check_vendored_vectors.py, tests/_data/README.md, tests/check_vendored_vectors_test.py|The ledger parser reads pattern fields and skips entries whose headings do not identify one local file. The README documents pattern matching and the regex constraints. Tests cover pattern parsing and skipped entries.|
|Upstream pattern derivation <br> .github/scripts/check_vendored_vectors.py, tests/check_vendored_vectors_test.py|The checker retrieves upstream tree and tarball data, validates archive files against tree metadata, and derives sorted unique matches from regular files. Tests cover matching, symlinks, and invalid upstream responses.|
|Pattern drift reporting <br> .github/scripts/check_vendored_vectors.py, tests/check_vendored_vectors_test.py|The checker compares derived bytes with local files and records differences, including missing files and ordering or byte differences. Issue and CLI output distinguish pattern drift, matching derived files, and ordinary tip drift.|
<!-- change_assessment_start -->
Estimated code review effort: 4 (Complex) | ~45 minutes
<!-- change_assessment_commit:"c2e5cca33c92cec9d1956c25a86db46ebf7f2fd9" -->
<!-- change_assessment_priority:{"version":1,"urgency":"p3","manual":false} -->
Change: Feature
<!-- change_assessment_end -->
Sequence Diagram(s)
sequenceDiagram
participant Checker
participant GitHubAPI as GitHub API
participant LocalFile
Checker->>GitHubAPI: Request recursive tree and tarball at commit
GitHubAPI-->>Checker: Return tree metadata and archive bytes
Checker->>Checker: Validate archive and derive sorted matches
Checker->>LocalFile: Read held derived file
LocalFile-->>Checker: Return file bytes
Checker->>Checker: Compare derived and local bytes
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>c2e5c</code></summary>
<dl>
<dd>
<br>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to c2e5c
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"c2e5cca33c92cec9d1956c25a86db46ebf7f2fd9","coveredCommitId":"c2e5cca33c92cec9d1956c25a86db46ebf7f2fd9","kind":"reviewed"} -->
This change adds an opt-in check for files derived from upstream patterns, along with tests and documentation. It does not alter the existing commit-based checks, and the current ledger has no entries that use it. No actionable merge-blocking risk was found.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
<dl>
<dd>
<br>
| Check name | Status | Explanation |
| :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Title check | !Passed | The title "Judge a derived pin by its pattern's output at upstream's tip (issue btclib-org/btclib#3133)" names the main change: a ledger entry with a pattern line is now judged by what that pattern … |
| Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Description check | !Passed | The description states that the PR ports a pattern-based derived-file check into .github/scripts/check_vendored_vectors.py, along with its tests and README paragraphs. It explains the new find_drif… |
<details>
<summary><strong>Full details: Title check</strong></summary>
<dl>
<dd>
<br>
Explanation
The title "Judge a derived pin by its pattern's output at upstream's tip (issue btclib-org/btclib#3133)" names the main change: a ledger entry with a pattern line is now judged by what that pattern derives at upstream's tip, not by its commit. The changeset matches this, including the checker, tests, and README. The title does not state the repository's required format from the linked standard, which the requirements reference but do not spell out in this context. The title is specific and descriptive, so it passes on content.
</dd>
</dl>
</details>
<details>
<summary><strong>Full details: Description check</strong></summary>
<dl>
<dd>
<br>
Explanation
The description states that the PR ports a pattern-based derived-file check into .github/scripts/check_vendored_vectors.py, along with its tests and README paragraphs. It explains the new find_drift third return list, the changed stdout wording, and the DERIVED and DIFFERS output lines. The changeset's raw summary and objectives match these claims. The description also lists test and lint evidence and known gaps, such as the live API path not being checked locally.
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary><strong>Finishing Touches</strong></summary>
<dl>
<dd>
<br>
<details open>
<summary><strong>Generate unit tests (beta)</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
<!-- tips_start -->
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
<details>
<summary><strong>Share</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
<!-- tips_end -->
<!-- recent_review_start -->
<h6>
<details>
<summary><strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Recent review info</strong></summary>
<dl>
<dd>
<br>
<!-- review_info_content -->
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</strong></summary>
<dl>
<dd>
<br>
Reviewing files that changed from the base of the PR and between 2f626c121d7c4d8cabc00358b107120959552e16 and c2e5cca33c92cec9d1956c25a86db46ebf7f2fd9.
</dd>
</dl>
</details>
<details>
<summary><strong><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 3</strong></summary>
<dl>
<dd>
<br>
.github/scripts/check_vendored_vectors.py tests/_data/README.mdtests/check_vendored_vectors_test.py`
</dd>
</dl>
</details>
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
</dd>
</dl>
</details>
</h6>
<!-- recent_review_end -->
non-blocking: this describes the script's behaviour a second time. The script's new header paragraph (.github/scripts/check_vendored_vectors.py, "An entry whose file upstream does not publish…") already says each of these things: every file is read as text, matches follow _line_matches and git's loop, Python's re is used where git uses PCRE, the entry is derived again at the tip, it is reported where the bytes differ or the file is missing, and commit decides nothing. Entry's docstring says the last one a third time. The organization's standard, section 9, One fact in one place, says: "Two files stating the same thing become two files disagreeing about it; the second points at the first." The ledger should keep what a pattern line means and how a pattern is written, and point at the script for how it checks an entry.
ACK c2e5cca33c92cec9d1956c25a86db46ebf7f2fd9
tests/_data/README.md:82-97 describes how the script checks a pattern entry a second time. The script's header paragraph already says it, and Entry's docstring says part of it a third time. This breaks the organization standard's section 9, One fact in one place: "the second points at the first." I found it by reading the two passages side by side.Not checked: the _matches parametrized cases in tests/check_vendored_vectors_test.py. The comment above them says each answer is what LC_ALL=C git grep --no-index -aohP printed. This session could not write sample files or run git grep on them, so that was not run. The script itself was also not run, since there is no interpreter here.
Non-blocking, and the same in every copy: filed on ISS btclib-org/btclib#3155, to be fixed in btclib first and carried to each copy.
fametrano
This is bip32-descriptors's copy of the change ISS btclib-org/btclib#3133 asks for, which landed in btclib as e0b34057, in ecc as 88352b8e and in btclib-wallet as 3a399ed0. A ledger entry may now name its derivation in a
patternline, and.github/scripts/check_vendored_vectors.pyjudges such an entry, where itsbehindreads zero, by what that pattern derives at the tip of the entry's path, read through the API: it fetches upstream's tarball at that commit, holds each regular file under the path to its blob in the recursive tree, finds the matches asLC_ALL=C git grep -aohPdoes, sorts them bytewise and deduplicates them, and reports the entry where the result is not the file here, naming the lines only the derivation holds and those only the file holds, or where the file is not here at all. The value of the entry'scommitdecides nothing; an entry without apatternline is judged by its commit, as before. This is the maintainer's option 1 on the issue: the change goes in the shared checker every tree's copy runs.bip32-descriptors's ledger holds no entry with a
patternline, so this carries the capability, its tests and the ledger's paragraphs on what such a line means, as btclib-wallet's copy does. This copy callsghthroughsubprocess.runat each call site and has no shared helper or retry, so_derivedmakes its two calls the same way: the tree as text, the tarball as bytes.What this breaks:
find_driftreturns a third list, the derived entries found current with their tip; stdout prints "No checked pin has drifted from upstream's tip." where it printed "Every checked pin is still at upstream's tip."; the issue body's first line and the closing comment are reworded to match; a derived entry prints aDERIVEDor aDIFFERSline.Evidence
| Gate on c2e5cca3 | Command | Exit |
| --- | --- | --- |
| Suite, coverage lane |
uv run --locked --no-default-groups --group test pytest -n 2: 8829 passed, 100.00% | 0 || Hooks |
uv run --locked --only-group lint pre-commit run --all-files --show-diff-on-failure| 0 || Build and sdist lane |
uv build, the suite from the unpacked sdist on Python 3.15: 8336 passed, 100.00% | 0 || Docs |
sphinx-build -n -W, the href grep andcheck_included_links.py| 0 || Sign-off |
check_sign_off.py 2f626c12..c2e5cca3; control717b427exits 1 | 0 |merge-tree --write-treeagainstmainat 2f626c12, the branch's parent, merges clean.subprocess.runand a stand-ingh: a valid tarball derives; a failing call, a body that is not an archive, a cut archive and a truncated tree each end the run with exit 1. Their non-blocking findings are in the findings record; those that apply to every copy are filed on ISS btclib-org/btclib#3155, and the reviewer's collateral (this copy hides a failed call's stderr and does not retry a server error) is ISS btclib-org/bip32-descriptors#441.os-*sweeps and the dist job's other steps run in CI.(issue btclib-org/btclib#3133)
🤖 Generated with Claude Code