fix(governance): require reconstructable PR queue source commit provenance - #1379
Conversation
…nance Closes #1146 _source_commit() previously fail-opened: any non-timeout Git failure returned "unknown" and arbitrary non-empty stdout was accepted as the governance source commit, so PR queue governance evidence could cite a non-reconstructable source. Non-timeout failures and executable/OS/ subprocess errors now raise a stable package-owned RuntimeError while keeping the bounded GIT_METADATA_TIMEOUT_SECONDS deadline, and only canonical full lowercase SHA-1 (40 hex) or SHA-256 (64 hex) object identities pass validation; empty, abbreviated, uppercase, non-hexadecimal, undersized, and oversized stdout are rejected before any evidence can be emitted. Build-level tests that exercise queue classification against a temporary non-Git repo root now patch the _source_commit boundary with a canonical identity; the real helper's fail-closed contract is covered exhaustively in tests/test_pr_queue_governance_git_timeout.py.
📝 WalkthroughWalkthroughThe pull request hardens observed-score DIF control validation, requires canonical Git source provenance for PR queue governance, adds regression coverage, wires the DIF safety layer into package exports, and records related release notes. ChangesDIF control safety
PR queue provenance
Additional release notes
Estimated code review effort: 3 (Moderate) | ~30 minutes Merge Risk: 🔵 Low · up to The change makes PR source provenance fail closed and accepts only canonical full commit identities, with the supplied tests passing. It is mergeable with owner awareness that the changelog citation should include a clickable DOI resolver link. 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
Full details: Linked Issues checkExplanation The governance implementation meets the provenance requirements in [ Resolution Remove unrelated DIF production code, DIF documentation, DIF tests, and changes to tests/test_pr_queue_governance.py. Retain only the governance source helper, tests/test_pr_queue_governance_git_timeout.py, and the Full details: Out of Scope Changes checkExplanation The PR includes changes unrelated to [ Full details: Docstring CoverageExplanation Docstring coverage is 53.85% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 65 functions across 7 files. (4 skipped: 4 unsupported.) ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
Devin review thread: catch (OSError, subprocess.SubprocessError) like sibling scripts instead of bare Exception so unrelated programming errors surface instead of masquerading as generic lookup failures.
Closes #1146.
Scope
This PR is now the main-based landing lane for PR-queue source provenance. Its former parent #998 has merged, and the branch has been non-destructively reconciled onto current protected main; it no longer carries the parent DIF/release delta as an effective PR diff.
scripts/build_pr_queue_governance.py::_source_commit()previously failed open:"unknown";That allowed governance evidence to cite a non-reconstructable source. The current implementation preserves the bounded Git deadline, fails closed with package-owned
RuntimeErrorfor lookup failures, and accepts only canonical lowercase full SHA-1 (40 hex) or SHA-256 (64 hex) object identities. Empty, abbreviated, uppercase, non-hexadecimal, undersized, and oversized output is rejected before evidence emission.Focused RED-first coverage preserves timeout handling, non-zero/missing-executable failures, malformed identities, canonical SHA-1/SHA-256 compatibility, offline snapshot behavior, and build-level source propagation. The governed changelog links and summarizes the supply-chain provenance research basis.
Fresh integration boundary
Decision-time protected main:
bdd2638151be6f6f7341f246b453467ea62b5114. Exact current head:2b4f859dcc0af180fc79c383dc7631be17e8234f. The branch is 6 commits ahead / 0 behind current main, open, non-Draft, and mergeable.Exact-head Security Scan, CodeQL, and SAST Semgrep are terminal success; CI is still queued. Review conversations currently associated with the effective governance diff are resolved. Independent approving reviews and the complete protected-central coverage/review/package/fuzz/SBOM/provenance/dependency evidence are still required before merge.
No force update, destructive rebase, gate weakening, review dismissal, self-approval, or numerical psychometric change is used.