Skip to content

fix(pr-reviews): [#2606] accept audit fixes merged outside the local commit range - #2641

Merged
josecelano merged 12 commits into
torrust:developfrom
josecelano:2606-validate-audit-record-merged-fix-subjects
Oct 25, 2026
Merged

josecelano merged 12 commits into
torrust:developfrom
josecelano:2606-validate-audit-record-merged-fix-subjects

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

validate-audit-record.py required every Resolution reference commit subject to exist in <base>..HEAD. With an up-to-date base, a merged fix is no longer in that range, so valid audits failed (--base torrust/develop failed 3 rows of the PR #2584 audit and 1 row of the PR #2599 audit). With the default base, a stale local develop made the same audits pass by accident. A fix can also merge in another pull request, as the WAIT-001 fix of the PR #2584 audit did in PR #2596.

The valid subjects now come from three sources: the commits of the audited pull request, the commits of every pull request named in a Follow-up PR URL field (both fetched with gh api repos/<owner>/<repo>/pulls/<n>/commits --paginate, which works after merge), and <base>..HEAD for commits not pushed yet. A failed gh call while listing commits exits 2 and names the endpoint; it never falls back to <base>..HEAD. The script stays a Python prototype.

Closes #2606

Files touched

  • .github/skills/dev/pr-reviews/process-pr-review/scripts/validate-audit-record.py: valid_subjects replaces branch_subjects, new pulls_to_check, usage-error exit, help text.
  • .github/skills/dev/pr-reviews/process-pr-review/scripts/test_validate_audit_record.py: new standard-library unittest module with git and gh faked at the process boundary (7 tests).
  • .github/skills/dev/pr-reviews/process-pr-review/SKILL.md: the "Validation Script" section describes the three sources.
  • docs/issues/open/2606-2278-validate-audit-record-merged-fix-subjects/: spec progress, manual-verification-evidence.md, and the new test-design-review.md.

Validation

  • python3 -m unittest discover -s .github/skills/dev/pr-reviews/process-pr-review/scripts: 7 tests pass. Each test increment has its red run and prose-first design review in test-design-review.md.
  • linter all exits 0, and the pre-push hook (nightly checks and the full stable test suite) passed.
  • M1: with --base torrust/develop, the PR docs(issues): add specification for PR review wait poller #2584 and PR docs(pr-reviews): mark WAIT-001 fixed in the PR 2584 audit #2599 audits pass (4 failures before the fix).
  • M2: the result is identical with a stale and a current local develop, with HEAD unchanged.
  • M3: an audit copy with a subject that exists in no commit still fails with exit 1.
  • Rerun of the 157 audits that have a FIXED row: 146 pass; the other 11 also fail with the unmodified script (with more subject failures), for reasons in their own content, so nothing regresses.
  • A transient GitHub HTTP 502 during the rerun produced the designed exit 2 naming the endpoint.

The commands, runtime versions, and output are in manual-verification-evidence.md. Two pulls_to_check tests go beyond the spec's case list; they pin the follow-up URL parsing rule recorded in the spec. The branch was not rebased onto the latest torrust/develop.

josecelano and others added 12 commits October 24, 2026 20:45
…he audited PR's commits

Red: valid_subjects does not exist yet. The design review is recorded in
the issue-local test-design-review.md.

Co-authored-by: Copilot <[email protected]>
… follow-up PR's commits

Red: pulls_to_check does not exist yet.

Co-authored-by: Copilot <[email protected]>
…h failures as usage errors

Red: a gh failure while listing commits raises CalledProcessError instead of exiting 2.

Co-authored-by: Copilot <[email protected]>
…urces of validate-audit-record

Co-authored-by: Copilot <[email protected]>
The 20:30 stamp was written before that time had passed.

Co-authored-by: Copilot <[email protected]>
@josecelano
josecelano requested a review from a team as a code owner October 24, 2026 20:39
Copilot AI balanced review requested due to automatic review settings October 24, 2026 20:39
@josecelano josecelano self-assigned this Oct 24, 2026
@josecelano
josecelano requested a review from da2ce7 October 24, 2026 20:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation matches the specified behavior, with deterministic tests and recorded real-audit verification supporting approval.

No open issues 🎉

What changed in this PR

Fixes #2606 by allowing the PR-review audit validator to recognize fix commits from audited and follow-up pull requests, even after those fixes have merged outside the local commit range.

Changes:

  • Combines commit subjects from the audited PR, recorded follow-up PRs, and <base>..HEAD.
  • Reports failed commit-list requests with exit code 2 and the failing endpoint.
  • Adds seven deterministic tests and documents the behavior, test design, and real-audit verification.
File Description
docs/​issues/​open/​2606-2278-validate-audit-record-merged-fix-subjects/​test-design-review.md Records test rationale and red/green development evidence.
docs/​issues/​open/​2606-2278-validate-audit-record-merged-fix-subjects/​manual-verification-evidence.md Records merged-audit checks and regression comparisons.
docs/​issues/​open/​2606-2278-validate-audit-record-merged-fix-subjects/​ISSUE.md Updates implementation progress and acceptance evidence.
.github/​skills/​dev/​pr-reviews/​process-pr-review/​SKILL.md Documents the three subject sources and failure behavior.
.github/​skills/​dev/​pr-reviews/​process-pr-review/​scripts/​validate-audit-record.py Fetches PR commit subjects and deduplicates follow-up references.
.github/​skills/​dev/​pr-reviews/​process-pr-review/​scripts/​test_validate_audit_record.py Tests subject acceptance, rejection, URL parsing, and request failures.

Review effort: Balanced

@da2ce7 da2ce7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 453c6fa9a5b1070da8556a5558741273a250c2e3. Recomputed from the bytes at this head, against the merge base abce11ec8; git merge-tree against develop d09a45f0a writes a clean tree (bf6ee1ca4).

Verdict: approve. The fix does what the issue asks, but the committed bytecode (F2) should leave the branch before merge. Six findings are inline. None changes the merged tree in a way a later commit cannot repair, and none misreports what the code does.

The change of behaviour.

  • valid_subjects unions <base>..HEAD with the first message line of each listed pull request's commits.
  • pulls_to_check takes every github.com/<owner>/<repo>/pull/<n> in a Follow-up PR URL line, from the repository in the URL (the spec's recorded rule). It skips N/A and NA, and fetches each pull request once, the audited one included.
  • Matching stays exact (ref not in subjects): no prefix or case folding.
  • A CalledProcessError exits 2 naming the endpoint, with no fallback.
  • Every run now needs gh, even with --comments-file, and an absent gh exits 1 (F1).

The tests.

  • Seven tests patch subprocess.run, so no process or network is reached. An unknown endpoint raises KeyError.
  • I ran them with bytecode writes off: seven pass, and the tree stays clean.
  • The two increment tests fail at their own commits on the missing function, and the exit-2 test fails on CalledProcessError. Each following fix commit turns its test green.
  • The rejection test cannot fail (F3).
  • test-design-review.md matches the tests.

The committed bytecode. Both .pyc files are tracked, stale and unignored (F2).

The spec and records.

  • On develop, the #2584 audit has the three FIXED subject rows (WAIT-001 via #2596), and #2599 has one, as counted.
  • The 11 named audits exist. 148 audit records have a FIXED row, against the spec's 157 (F6).
  • The 502 message matches the code's format.
  • Some completion text is stale (F5), and F4 covers the failure message.
  • Links resolve.

Hygiene.

  • Twelve Conventional subjects with issues, pr-reviews and [#2606], and all twelve commits are signed.
  • The bodies match their diffs, and author equals committer.
  • Each commit ends in an attribution footer naming the review bot's account, which no rule in the tree governs.
  • git diff --check is clean, and the commit-id check prints nothing.
  • The description closes #2606 only.

The bot. It started at 20:39:55Z, and the capture holds no review from it.

Findings: F1 (Minor), F2 (Major), F3 (Minor), F4 to F6 (Nit), inline.

Checked, no finding:

  • the help and the skill text against the code, apart from F1;
  • the replacement-PR flow (its fixes land on the replacement pull request);
  • the .gitignore rules;
  • the five sibling test-design-review.md files, which also carry no frontmatter;
  • the stamps against their commits, including the 1e249e2e7 correction.

Checks

On the loop's compute hub at this head, against the merge base abce11ec8, the #2630 merge (receipt server-gates-sojka-452; git merge-tree against develop at 1d14569cd, the #2638 merge, is clean): pre-commit profile gate exit 0 (86 s); linter markdown, linter cspell, linter lychee exit 0; frontmatter-validator --all: 16 errors / 4 warnings at this head and 16 / 4 at the base re-measured, the same 20 diagnostics by path and category, none in the files this PR touches. python3 -m unittest discover -s .github/skills/dev/pr-reviews/process-pr-review/scripts -v on Python 3.12.3: 7 tests, all ok; validate-audit-record.py --help exits 0. git ls-files lists two tracked bytecode files, both added by this PR under scripts/__pycache__/, and no .gitignore rule covers .pyc or __pycache__. The hub has no gh, so the rerun over the existing audits was not repeated. GitHub checks at this head at posting time: "Package Coverage (${{ matrix.package }}): completed/skipped; Package Coverage Regression: completed/success; Docker E2E: completed/skipped; Workspace Packaging: completed/success; Unit (stable): completed/success; Documented Clippy Allows: completed/success; Unit (nightly): completed/success; Generate Coverage Report: completed/success; Layer Boundary Bans: completed/success; Discover Package Coverage: completed/success; Build on ubuntu-latest (stable): completed/success; Build on windows-latest (nightly): completed/success; Test (Docker) (release): queued/pending; Docs Lint: completed/success; Build on macos-latest (nightly): completed/success; Build on macos-latest (stable): completed/success; Build on windows-latest (stable): completed/success; Build on ubuntu-latest (nightly): completed/success". At posting, develop is 722f2b5b2.

@da2ce7

da2ce7 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

ACK 453c6fa — the three-source subject check, its seven faked-process tests and the #2606 records were recomputed at this head.

@josecelano
josecelano requested a review from a team October 25, 2026 06:16
@josecelano

Copy link
Copy Markdown
Member Author

ACK 453c6fa

@josecelano
josecelano merged commit 1b61297 into torrust:develop Oct 25, 2026
21 checks passed
josecelano added a commit that referenced this pull request Oct 26, 2026
…ssues/closed

4b79b09 chore(issues): archive closed issue #2606 spec to docs/issues/closed (Jose Celano)

Pull request description:

  Archives the spec for issue #2606 (closed on GitHub by the merge of PR #2641) from `docs/issues/open/` to `docs/issues/closed/`.

  - Verified issue #2606 is `CLOSED` on GitHub
  - Updated frontmatter (`status: done`, `spec-path`, `related-pr: 2641`, `last-updated-utc`) and the evidence file's `issue-spec` path
  - Ticked the closure checkpoint and added a progress-log entry
  - No other live reference to the old path exists; the two mentions in the PR #2607 and PR #2613 review audits are historical records and are left as written
  - `linter all` and the pre-commit hook passed

  This change moves the spec only. The review findings F1 to F6 submitted on PR #2641 are not addressed here.

ACKs for top commit:
  josecelano:
    ACK 4b79b09

Tree-SHA512: d041c6f7c9d062631c0048b1088096c2315f231723c6980d0a3983c84468296612530cdb3c41f8c2781deec93c4a8e5b561708e3b9e72dff56f4defb42bd1cef
@josecelano

Copy link
Copy Markdown
Member Author

Maintainer approval for the post-merge follow-up of the review submitted on this pull request (review 5640012066, submitted 2026-10-24 21:01 UTC, before the merge at 2026-10-25 06:25 UTC and left unprocessed when it merged).

The maintainer approved this follow-up in chat on 2026-10-26 15:43 UTC, and this comment records that approval on that day: fix findings F1 to F6 in one small pull request with no new issue or specification, and record them in docs/pr-reviews/pr-2641-review/PR-REVIEW.md.

josecelano added a commit that referenced this pull request Oct 26, 2026
… of the validate-audit-record change

5de6253 docs(pr-reviews): record the review audit for PR 2657 (Jose Celano)
585237d docs(issues): [#2606] count the red regression cases as two in the closed spec (Jose Celano)
0c8c40e docs(pr-reviews): record the post-merge review audit for PR 2641 (Jose Celano)
24e5195 docs(issues): [#2606] correct stale records and the audit count in the closed spec (Jose Celano)
0d26ebb fix(pr-reviews): exit 2 when gh is missing and name the three sources in the failure text (Jose Celano)
b7c6df2 test(pr-reviews): pin near-miss rejection in check_row and a missing gh as a usage error (Jose Celano)
2097df5 chore(pr-reviews): untrack Python bytecode and ignore __pycache__ (Jose Celano)

Pull request description:

  ## Summary

  Follow-up for the review of #2641 (review 5640012066, submitted 2026-10-24 21:01 UTC, before that pull request merged at 2026-10-25 06:25 UTC, and unprocessed when it merged). The maintainer approved the follow-up: #2641 (comment). No new issue or specification; the work relates to #2606, which #2641 closed.

  | Finding | Change |
  | ------- | ------ |
  | F1 (Minor) | A missing `gh` now exits 2 and names the commits endpoint, like a failed call; the help text and the skill say `gh` is needed even with `--comments-file`; the spec's Risks line is corrected. |
  | F2 (Major) | The two tracked `__pycache__/*.pyc` files are removed and `__pycache__/` is git-ignored. The blobs stay in the history of `develop`. |
  | F3 (Minor) | The test that could not fail is replaced by `CheckRowTest`, which calls `check_row` with an exact match and with near-miss subjects (other case, prefix, suffix). |
  | F4 (Nit) | The failure text names the three sources and keeps "not a commit subject". |
  | F5 (Nit) | Stale statements in the archived #2606 spec and evidence file are corrected (completion review, recheck status, "fails on the current code"). `related-pr` and `last-updated-utc` were already fixed by the archive. |
  | F6 (Nit) | The "11 of 157" wording now says what was counted (the 157 `PR-REVIEW.md` files that contain the word `FIXED`) and cites the reviewer's 148 files with a `FIXED` row. I did not recount it. |

  The audit record `docs/pr-reviews/pr-2641-review/PR-REVIEW.md` is added in the last commit.

  ## Validation

  - `python3 -m unittest discover -s .github/skills/dev/pr-reviews/process-pr-review/scripts`: 9 tests pass. The missing-`gh` test was red before the fix (`FileNotFoundError`); the `check_row` tests guard existing behavior.
  - `linter all` and the pre-commit hook pass for each commit.

ACKs for top commit:
  josecelano:
    ACK 5de6253

Tree-SHA512: 29f30f086b31128ee9b7a591667e51a444f8f5c547de24ad172e1fb0d372aa72309836796a6d9aba7439d27d42635c2f4187840db9babc3997e68749600719db
@josecelano

Copy link
Copy Markdown
Member Author

Follow-up complete: PR #2657 merged on 2026-10-26 17:59 UTC as merge commit 54eabcbf4. Review 5640012066 on this pull request, all six findings:

Finding Disposition Resolution reference
F1 FIXED fix(pr-reviews): exit 2 when gh is missing and name the three sources in the failure text
F2 FIXED chore(pr-reviews): untrack Python bytecode and ignore __pycache__
F3 FIXED test(pr-reviews): pin near-miss rejection in check_row and a missing gh as a usage error
F4 FIXED fix(pr-reviews): exit 2 when gh is missing and name the three sources in the failure text
F5 FIXED docs(issues): [#2606] correct stale records and the audit count in the closed spec
F6 FIXED docs(issues): [#2606] correct stale records and the audit count in the closed spec

The six threads are resolved and the audit moves to FIXED/RESOLVED in the pull request that follows.

josecelano added a commit that referenced this pull request Oct 26, 2026
…ter its follow-up merged

6295926 docs(pr-reviews): close the loop on the PR 2641 audit after its follow-up merged (Jose Celano)

Pull request description:

  Closes the review loop for #2641 after its follow-up #2657 merged (merge commit `54eabcbf4`), as the process-pr-review skill requires for post-merge feedback.

  - Moves the six rows of `docs/pr-reviews/pr-2641-review/PR-REVIEW.md` from `FOLLOW_UP`/`OPEN` to `FIXED`/`RESOLVED`, with the fixing commit subjects as resolution references and the merge recorded in the Processing Log.
  - The consolidated response is #2641 (comment), and the six threads on #2641 are resolved (a GraphQL fetch shows all six `isResolved: true`).

  Validation: `validate-audit-record.py --pr-number 2641 --base torrust/develop` reports 6 rows, 4 log entries, 0 failures; the pre-commit hook passed.

ACKs for top commit:
  josecelano:
    ACK 6295926

Tree-SHA512: 1c4caa4ad27060531672ba59d2dff9b9a9437e466af5dc391b0dec9c31827643a9ec103b36ea74b3c13ab4a6209e3de16c4bd9e043f05948fd4564ac3bc9adca
@da2ce7

da2ce7 commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Post-merge note: this pull request requested a review from this account and was closed without one at its final head. A post-merge review will not be done: It was approved at its final head commit 453c6fa before it merged, so the requested review exists.

This branch was previously deployed

1 inactive deployment
coverage — 453c6fa9 Deployed Oct 24, 2026 by josecelano via Generate Coverage Report #2787
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate-audit-record.py rejects fixes merged outside its commit range

3 participants