Skip to content

Add a prune Subcommand to Retire Orphaned Canonical Review Passes - #4424

Merged
ptr727 merged 3 commits into
developfrom
burndown/canonical-review-prune
Nov 24, 2026
Merged

ptr727 merged 3 commits into
developfrom
burndown/canonical-review-prune

Conversation

@ptr727

@ptr727 ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Summary

A pass recorded against a canonical unit whose section is later renamed or removed stays in reports/canonical-review.json with nothing able to retire it. status and sweep report the orphan, the ledger's note forbids an edit by hand, and record refuses an unknown unit. This adds canonical_review.py prune --unit '<key>', the maintainer's option 1 from the decision recorded on the issue.

  • prune retires orphaned keys only. It refuses a key the tree still holds, a key no recorded pass names, and a key named twice. A refusal writes nothing and exits 2, the same shape as record's refusals. So a second run over keys a first run retired is refused and leaves the ledger as it was.
  • It holds the ledger lock record holds, now shared through one ledger_held context manager rather than a second copy of the acquire and release.
  • Two codestyle conformances this edit owed, since CODESTYLE.md "Interrupts" binds a script when it is next edited and this one holds a lock:
    • Atomic ledger write. The ledger is written to a temporary file beside it and renamed over it with os.replace, keeping the file's mode.
    • Interrupt handler. SIGINT and SIGTERM take one path. An interrupt mid-write releases the lock, removes the temporary file, prints one line, and ends the script by the signal.
  • The cmd_status comment, the sweep's and report's "pass(es) with no unit" text, the workflow's orphan warning, and scripts/README.md now point at prune rather than saying nothing retires an orphan. In the README that is the canonical_review.py section's subcommand list and exit-code account, and the intro sentence naming which subcommands write.
  • The ledger's six current orphans are left in place. Pruning each one stays a reader's call per key.

Tests

Constructed ledgers in a throwaway repository, with no network:

  • an orphan pruned, leaving orphanedPasses empty
  • a key the tree still holds refused, with the ledger byte-identical
  • a key no pass names refused, with the ledger byte-identical
  • a second run over the same key refused, writing nothing
  • a held lock refusing the prune, then a prune succeeding and releasing it
  • a repeated key refused
  • prune --help and an unknown argument
  • SIGINT, SIGTERM, and SIGINT then SIGTERM delivered mid-write, each ending the script by the first signal with the lock released, no temporary file left, and the ledger unchanged

Local review

Two recorded local-strict-review passes. The first raised six introduced findings. Three were fixed:

  • the ledger_held docstring claimed a lock shared with local_review.write_pass, where only the helper is shared
  • the interrupt test replaced the script's __main__ block instead of running it, so dropping the handlers still passed. It now runs the real block through runpy.run_path, and reverting the block to sys.exit(main()) fails it.
  • the workflow comment had lost its reason for warning on an orphan rather than filing one

Three consolidation findings were declined. Each would need a shared helper in scripts/local_review.py, scripts/backlog_metrics.py, scripts/pr_review.py, or scripts/secrets_sync.py, none of which this change touches. Within canonical_review.py, both ledger lock sites are on the one ledger_held primitive, and no exported primitive exists for the other two to reuse:

  • ledger_held beside the lock sequence local_review.write_pass open-codes
  • the temporary-file-then-replace block beside local_review's receipt write
  • the signal handler beside the same shape in other scripts

The second pass raised nothing.

Closes on promotion: #1648

🤖 Generated with Claude Code

ptr727 and others added 3 commits November 24, 2026 03:56
A pass recorded against a section later renamed or removed stayed in the
ledger with nothing able to retire it. prune removes such a key through
the engine, refusing any key the tree still holds, any key no pass names,
and a repeated key, and writing nothing on a refusal.

The ledger write now renames a temporary file into place, and the script
takes the fleet's SIGINT and SIGTERM handling, since it holds a lock.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The interrupt test now executes the script's own __main__ block, so
dropping the handlers fails it. The ledger_held docstring now says the
helper is shared rather than the lock, and the workflow comment states
why an orphan is warned rather than filed now that prune exists.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 24, 2026
Copilot AI lite review requested due to automatic review settings November 24, 2026 12:05
@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head b0019ff879846880148719cdd519e69f1e9188f3, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between cfce192 and b0019ff.

Files selected for processing: 4

  • .github/workflows/canonical-review-sweep.yml
  • scripts/README.md
  • scripts/canonical_review.py
  • tests/test_canonical_review.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Copilot AI 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.

🟡 Changes recommended

An active P2 nit remains in scripts/canonical_review.py:470 because the lock helper’s docstring contains a malformed sentence that makes its contract unclear.

1 open issue
What changed in this PR

This pull request adds a prune subcommand for retiring orphaned canonical review passes while strengthening ledger integrity during concurrent writes and interrupts.

Changes:

  • Adds validated pruning with shared locking, atomic ledger replacement, and signal-safe cleanup.
  • Adds coverage for pruning, refusal cases, locking, CLI behavior, and interrupted writes.
  • Updates documentation and workflow guidance for retiring orphaned passes.
File Description
tests/​test_canonical_review.py Adds tests for pruning behavior, refusal cases, lock handling, CLI usage, and interrupted writes.
scripts/​README.md Documents the new prune subcommand, ledger-writing behavior, and exit-code contract.
scripts/​canonical_review.py Implements orphan pruning, shared ledger locking, atomic writes, and interrupt handling.
.github/​workflows/​canonical-review-sweep.yml Directs maintainers to prune orphaned canonical review passes reported by the workflow.

Review effort: Lite

Comment thread scripts/canonical_review.py Resolved
@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 24, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 65.85366% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.48%. Comparing base (b38e084) to head (b0019ff).
⚠️ Report is 341 commits behind head on develop.

Files with missing lines Patch % Lines
scripts/canonical_review.py 65.85% 28 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4424      +/-   ##
===========================================
- Coverage    81.60%   79.48%   -2.13%     
===========================================
  Files           26       47      +21     
  Lines         9070    16304    +7234     
===========================================
+ Hits          7402    12960    +5558     
- Misses        1668     3344    +1676     
Flag Coverage Δ
python-3.13 79.48% <65.85%> (-2.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727
ptr727 merged commit 4846538 into develop Nov 24, 2026
15 checks passed
@ptr727
ptr727 deleted the burndown/canonical-review-prune branch November 24, 2026 12:18
ptr727 added a commit that referenced this pull request Nov 24, 2026
…lts, Secret Sync Fields, and Audit Account Fixes (#4428)

Promotes the 28 pull requests that landed on develop since the last
promotion (#4388), from the away-mode backlog burndown run.

- #4391: Drop the false XML comment suppression claim from the .NET
conventions.
- #4390: Blank quotations after a heredoc label on its opening line in
the paste-safe rule.
- #4392: Carry attention lists, cut lists, and opt-in billing in the
`backlog_metrics.py` JSON.
- #4393: Gate `configure.sh apply`'s interaction limit on a committed
bot verification record.
- #4394: Make the gh and node report note say a one-line vendor source
is configured.
- #4395: Add ShellCheck and shfmt lint tasks to the VS Code task
snippets.
- #4396: Count a CodeRabbit clean pass on the head in the digest's
`other_reviewed`.
- #4401: Date the line-ending intentRefs by the skill and trim advisory
restatements.
- #4399: Share one any-level heading region primitive between
`heading_body` and `extract_anchored`.
- #4398: Name the hub pull requests a standup lands through, and add
HACS first-run guidance.
- #4404: Add a PowerShell section to CODESTYLE.md and narrow the shell
rule.
- #4405: Close AUDIT.md section 10's convergence loop and fix three
skill pointers.
- #4409: Route CODESTYLE.md's General section to the language skills
(part of #1153, which stays open).
- #4410: Detect a C# test project by its own text rather than its file
name.
- #4411: Drop the unruled "working gate is not drift" sentence from
CODESTYLE.md.
- #4412: Track the newest upstream line of each pinned host tool.
- #4413: Correct AUDIT.md section 0's account of what the audit checks.
- #4416: Add a required coverage shield class to the README audit.
- #4414: Tie drive-pr's merge to its authorization and align the pass
moments.
- #4417: Pass over a second SIGTERM in `pr_review.py` so an interrupt
prints one line.
- #4418: Point the report-path placeholder at AUDIT.md section 8.
- #4419: Correct the audit account copies outside AUDIT.md section 0.
- #4422: Drop the archived DevKitCIoT from the rollout checklists.
- #4423: Report a stale `pullRequestCheck: false` and correct AUDIT.md
section 6.
- #4424: Add a `prune` subcommand to retire orphaned canonical review
passes.
- #4425: Drop the archived DevKitCIoT from the reusable-workflows
checklists and fix a normalization docstring.
- #4427: Store secret sync metadata in item fields, not 1Password tags.
- #4426: Declare and apply the Actions workflow token defaults through
`configure.sh` (the `configure.sh` part of #1783, which stays open).

## Owed by the maintainer

- #4412: A live run of the new host-tool line tracker. Scheduled runs
start only once this reaches `main`, and a `workflow_dispatch` would
prove it sooner.
- #4426: A fleet `configure.sh apply` for the workflow token defaults,
after the per-repository read the 2026-11-01 answer requires. Please
also confirm the new `--lower-workflow-token` option, which a `write`
repository needs for the apply to lower its default.
- #4427: Run `python3 scripts/secrets_sync.py selftest`, then the
cleanup script in that pull request's body (`move_sync_tags.py`, dry run
first, then `--apply`). Until that runs, every un-migrated secret item
refuses to sync.
- #4393: The pilot's first interaction limit is set by hand in its
settings and its bots verified there. The verification record is
committed afterwards through a hub pull request, and only then does
`apply` set the limit fleet-wide.
- A fleet resync is owed, because carried text changed: AGENTS.md,
GOVERNANCE.md, CODESTYLE.md, and several skills.

Fixes #4387
Fixes #4383
Fixes #4284
Fixes #1095
Fixes #4299
Fixes #4370
Fixes #4364
Fixes #4173
Fixes #4064
Fixes #3536
Fixes #3929
Fixes #3808
Fixes #3812
Fixes #3810
Fixes #4320
Fixes #4232
Fixes #1748
Fixes #1607
Fixes #1270
Fixes #1170
Fixes #3692
Fixes #4415
Fixes #3908
Fixes #1648
Fixes #4276

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants