Skip to content

fix(governance): require reconstructable queue provenance - #1147

Closed
seonghobae wants to merge 4 commits into
fix/bounded-subprocess-current-review-988from
fix/pr-queue-source-provenance-1146
Closed

seonghobae wants to merge 4 commits into
fix/bounded-subprocess-current-review-988from
fix/pr-queue-source-provenance-1146

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Closes #1146.

Stack and exact scope

This is a direct child of the active PR-queue/procurement writer #1015. At creation the live parent is fix/bounded-subprocess-current-review-988@5a855b731f9857d4a177263f94c9987952be224c; the child is exactly three commits ahead and zero behind with merge-base equal to that parent. If #1015 moves, inspect the intervening delta and revalidate this stack before integration.

The sibling procurement child #1145 changes a different source/test pair; neither child mutates the parent branch.

Defect

build_pr_queue_governance.py::_source_commit() returned "unknown" for every non-timeout Git failure and accepted arbitrary non-empty git rev-parse HEAD output. Queue-governance JSON/HTML evidence could therefore be generated without a reconstructable source revision.

RED → GREEN

  • RED 24ace9807f237065060874f007e4ac3a6839b39a: add fail-closed regressions for non-zero Git exit and unavailable Git; reject empty, abbreviated, uppercase, non-hexadecimal, undersized, and oversized identities; preserve the bounded deadline and canonical full SHA-1/SHA-256 compatibility.
  • GREEN 22691f9dc5f3803d6d2a52a189c0168aef3d74dd: normalize OS/subprocess failures to stable package-owned RuntimeError and require lowercase 40-hex SHA-1 or 64-hex SHA-256 output before returning source identity.
  • Evidence ce4f38c9d33050152cb323b35e64d3ab04c9b39c: governed changelog fragment.

Effective parent-relative scope is only scripts/build_pr_queue_governance.py, tests/test_pr_queue_governance_git_timeout.py, and one changelog fragment. Existing queue classification, duplicate/overlap analysis, bounded GitHub transport/retry behavior, HTML/JSON rendering, and protected gates are unchanged.

Ownership boundary

Repository-governance provenance/control-plane only. No likelihood, estimator, scoring, fit statistic, uncertainty, recovery, or other production psychometric/statistical arithmetic changes; Rust-first numerical ownership and downstream psychometrics-commons ownership remain unchanged.

Review boundary

Keep Draft until this exact current head has terminal required CI/security/package/provenance evidence and effective independent review requirements are satisfied. Parent/predecessor-head evidence does not transfer; no bypass or self-approval.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b6f72a6-87b7-4ca5-a92f-e7aeff1258a8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review the exact current Draft head ce4f38c9d33050152cb323b35e64d3ab04c9b39c. Treat parent/predecessor-head evidence as historical; focus on the three-file parent-relative PR-queue governance provenance delta and fail-closed SHA-1/SHA-256 admission contract.

@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

expected_head='ce4f38c9d33050152cb323b35e64d3ab04c9b39c'
parent_ref='fix/bounded-subprocess-current-review-988'
parent_commit='5a855b731f9857d4a177263f94c9987952be224c'

echo '== HEAD =='
git rev-parse HEAD
git status --short

echo '== parent refs =='
git branch -a --contains "$parent_commit" || true
git show -s --format='%H%n%P%n%s' "$parent_commit"

echo '== ancestry and merge base =='
git merge-base HEAD "$parent_commit"
git rev-list --left-right --count "$parent_commit"...HEAD
git merge-base --is-ancestor "$parent_commit" HEAD && echo 'parent_is_ancestor=yes' || echo 'parent_is_ancestor=no'

echo '== parent-relative changed files =='
git diff --name-status "$parent_commit"...HEAD
git diff --stat "$parent_commit"...HEAD

echo '== parent-relative patch =='
git diff --find-renames --find-copies --unified=80 "$parent_commit"...HEAD -- \
  scripts/build_pr_queue_governance.py \
  tests/test_pr_queue_governance_git_timeout.py \
  ':!scripts/build_pr_queue_governance.py' ':!tests/test_pr_queue_governance_git_timeout.py'

echo '== source outline =='
ast-grep outline scripts/build_pr_queue_governance.py --items all --match '_source_commit|run|subprocess|RuntimeError' --view expanded || true

echo '== test outline =='
ast-grep outline tests/test_pr_queue_governance_git_timeout.py --items all --view expanded || true

echo '== source and test contract references =='
rg -n -C 5 -e 'def _source_commit\b' -e '_source_commit\s*\(' -e 'rev-parse' -e 'SHA-1|SHA-256|[0-9a-f]' \
  scripts/build_pr_queue_governance.py tests/test_pr_queue_governance_git_timeout.py

Length of output: 100947


🏁 Script executed:

#!/bin/bash
set -euo pipefail

parent_commit='5a855b731f9857d4a177263f94c9987952be224c'
head_commit='ce4f38c9d33050152cb323b35e64d3ab04c9b39c'

echo '== exact parent-relative patch =='
git diff --find-renames --find-copies --unified=60 "$parent_commit" "$head_commit" -- \
  docs/changelog.d/1146-pr-queue-source-provenance.md \
  scripts/build_pr_queue_governance.py \
  tests/test_pr_queue_governance_git_timeout.py

echo '== commits in reviewed delta =='
git log --format='%H%n%P%n%s%n%b%n---' "$parent_commit..$head_commit"

echo '== complete focused test file =='
cat -n tests/test_pr_queue_governance_git_timeout.py

echo '== source-commit call sites and output-write order =='
rg -n -C 12 -e '\b_source_commit\s*\(' -e 'write_text\s*\(' \
  scripts/build_pr_queue_governance.py tests

echo '== changelog fragment =='
cat -n docs/changelog.d/1146-pr-queue-source-provenance.md

echo '== exact current PR metadata and reviews =='
gh pr view 1147 --repo ContextualWisdomLab/fast-mlsirm \
  --json number,state,isDraft,headRefOid,baseRefOid,headRefName,baseRefName,reviewDecision,mergeStateStatus,statusCheckRollup,reviews \
  --jq '{
    number, state, isDraft, headRefOid, baseRefOid, headRefName, baseRefName,
    reviewDecision, mergeStateStatus,
    reviews: [.reviews[] | {author: .author.login, state, commit: .commit.oid}],
    checks: [.statusCheckRollup[] | {
      name: (.name // .context),
      status,
      conclusion,
      headSha: (.workflowRun.headSha // null),
      workflow: (.workflowName // null)
    }]
  }'

Length of output: 220447


@seonghobae I found one blocking test incompatibility.

tests/test_pr_queue_governance.py still asserts the old contract in test_source_commit_and_json_helpers_cover_success_and_failure.

  • Line 682 expects abbreviated deadbeef to be accepted.
  • Line 689 expects OSError to return "unknown".

The new _source_commit() implementation correctly rejects deadbeef and raises RuntimeError for OSError. This existing test will fail in the current suite.

Update or split that test to assert the new fail-closed behavior. The focused new tests cover the replacement contract.

The reviewed head is ce4f38c9d33050152cb323b35e64d3ab04c9b39c. It is three commits ahead of, and zero commits behind, the stated parent. Current CI and security checks for this head are still queued.

⚠️ 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.

@seonghobae

Copy link
Copy Markdown
Contributor Author

Closing: this branch is a strict ancestor of its base fix/bounded-subprocess-current-review-988 (compare shows base ahead by 4, this PR ahead by 0) — the base has already absorbed everything this PR offered plus later fixes (including the _source_commit fail-closed-vs-fallback behavior that's currently failing this PR's own CI on a stale copy of the code). Nothing left to merge.

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.

1 participant