Skip to content

fix(codeql): recover reruns after missing dispatch verdict - #1902

Draft
seonghobae wants to merge 82 commits into
mainfrom
fix/codeql-rerun-missing-verdict-redispatch
Draft

fix(codeql): recover reruns after missing dispatch verdict#1902
seonghobae wants to merge 82 commits into
mainfrom
fix/codeql-rerun-missing-verdict-redispatch

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Root causes

The required CodeQL PR workflow treated run_attempt as proof that a cancelled pre-runner attempt dispatched. Terminal status and direct fallback paths also lacked complete pagination, exact target/base/run/source/SARIF binding, and unique evidence-complete producer settlement. Review then exposed coupled liveness and authority gaps across attempt-wide base capture, predecessor receipts, App validation, protected-base advances during handler execution, and ambiguous complete producers.

Current canonical scope

  • exact head: 9f065583b367df7608ec2bb57ba9337f3926f8fe
  • exact tree: a3b3cc17b0cee93877f1f8814f65243349ef92a7
  • protected base: main@7fd571dbcdbae6acf29d8f4ee704d7ba6297e4db
  • ancestry: ordinary force=false descendants of concurrent late-base repair 3c8da485…
  • lifecycle: Proposed / Draft; exact hosted producer→protected-handler compatibility and qualifying independent review are merge gates

Scheduler/Strix deltas formerly mixed into this history remain carried by successor #1999 and are not reintroduced. Cross-repository credential authority remains the separate #1929 boundary.

Exact-bound repair

  • Keep repository_dispatch.client_payload within GitHub's ten-property limit. Exact run 34214980549 failed after OIDC/App-token success with HTTP 422 because eleven properties were sent. RED 310e9e60... / run 34217639402 reproduced 11 <= 10; the successor groups mode plus exact failed-job identities under rerun_request while the receiver retains legacy compatibility for already queued dispatches.
  • Read every paginated status, producer-run, job, and artifact candidate.
  • Bind dispatch, title, receipt, direct evidence, and settlement to repository, PR, live head, base ref/SHA, required run, immutable producer source, actor, language gate, preserved SARIF, and unexpired run-attempt artifact.
  • Capture one validated base before matrix expansion and use it across every shard and coordinator.
  • On a same-repository/same-ref strict forward base advance, prove ahead, behind 0, and the old SHA as exact base/merge base; restart the exact required run in whole-attempt mode. Retarget, rewrite, divergence, stale head, malformed compare, or unverifiable ancestry fails closed.
  • Revalidate the base again immediately before handler wake. A proven late advance skips old-base receipt consumption and restarts the entire exact attempt.
  • Keep matrix scans at actions: read; one non-matrix settlement alone owns actions: write.
  • Re-authenticate predecessor and App receipts through the same exact producer proof. App creator identity alone is not terminal evidence.
  • Preserve the complete failed compatibility-job map for settlement while scanning only pending languages.
  • If exactly one complete receipt/direct producer exists, consume it. If none exists, the language may dispatch. If more than one exists, emit redaction-safe exact run-ID/state telemetry and terminate before OIDC/App-token acquisition or dispatch, preventing unbounded producer churn.
  • When status POST is forbidden, allow only fully authenticated current-run scan plus preserved, unexpired SARIF evidence.

ADR-0025, CHANGELOG, doctoring, the product/technical Gap baseline, and executable shell contracts record the decision and failure scenes.

Concurrent and successor delta preservation

The tree preserves the concurrent 7ca416ee…, late-base RED b9245808…, and late-window repair 3c8da485… deltas. Draft PR #2039 remains open until hosted equivalence is observed; no predecessor evidence is transferred.

Exact-tree verification

  • ambiguity telemetry RED: 3 failed; GREEN: 3 passed
  • exact CodeQL settlement contract: 62 passed in 43.36s
  • exact-head full repository: 3086 passed, 1 skipped, 21 subtests passed in 284.54s
  • statement/branch coverage: 100%
  • public-doc coverage: 100%
  • compileall: PASS
  • git diff --check: clean
  • local actionlint: unavailable; fresh hosted workflow validation remains a merge gate

Current hosted blocker (exact head)

At 9f065583b367df7608ec2bb57ba9337f3926f8fe, Security, SAST, Python Security, Runtime Quality, OpenCode, Noema, and Strix checks are successful. CodeQL run 34225089444 dispatched successfully but both compatibility shards terminated FAILURE because the protected handler still predates the nested envelope and one-attempt settlement repair. All source review threads are resolved; no qualifying current-head approval exists.

Canonical sequence: ordinarily merge the backward-compatible handler-only prerequisite #2040 after its own exact-head gates, then non-force restack this PR and regenerate terminal dispatch/wake evidence.

Admission and prohibitions

The payload-cardinality source repair, receipt-only self-repository fixture, complete direct-evidence pagination assertion, and ADR heading repair are present on this exact tree; fresh hosted GREEN and current review are still required. Draft preserves the valid delta while the protected-consumer prerequisite is incomplete. Fresh exact-head hosted Checks and a qualifying independent review remain merge gates, and no predecessor result is promoted.

No synthetic status, self-approval, auto-merge authorization, administrator bypass, force update, destructive rebase, mutable-branch consumption, predecessor evidence transfer, empty retrigger commit, manual rerun, or allowlist weakening is authorized.

Summary by CodeRabbit

  • 개선 사항

    • CodeQL 검사가 여러 언어를 안정적으로 처리하고, 현재 PR의 커밋과 기준 브랜치에 정확히 연결됩니다.
    • 검증된 실행 결과와 분석 증거가 있을 때만 검사 결과를 반영하도록 신뢰성·보안 검증을 강화했습니다.
    • 일부 언어 검사 실패 시 필요한 작업만 재실행하며, 기준 브랜치가 변경되면 전체 검사를 다시 수행합니다.
    • 중단되거나 재시도된 검사도 이전 실행 정보에 의존하지 않고 현재 상태를 기준으로 복구합니다.
  • 문서

    • CodeQL 디스패치, 결과 검증 및 재실행 복구 동작을 관련 문서에 정리했습니다.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
📝 Walkthrough

Walkthrough

CodeQL 재실행은 run_attempt 대신 인증된 terminal verdict와 live PR 신원을 사용합니다. 코디네이터는 pending 언어만 디스패치합니다. 정산 job은 base-bound receipt 또는 직접 증거를 검증한 뒤 정확한 실행을 재실행합니다.

Changes

CodeQL 디스패치와 정산

Layer / File(s) Summary
Live base 검증과 current-head 코디네이터
.github/workflows/codeql-pr.yml, tests/test_codeql_pr_workflow_contract.py, tests/test_codeql_pr_rerun_recovery_contract.py
attempt 전체에서 사용할 live base를 캡처합니다. 샤드는 인증된 current-base verdict만 읽습니다. 코디네이터는 terminal verdict가 없는 언어와 정확한 실패 job을 구성하고 한 번에 dispatch합니다.
다중 언어 검증과 base-bound receipt
.github/workflows/codeql-scan-dispatch.yml, tests/test_codeql_scan_dispatch_workflow_contract.py
producer source, required run, 언어 matrix, rerun mode를 검증합니다. SARIF artifact와 base-bound 상태 receipt를 게시합니다. 상태 게시가 실패해도 검증된 직접 증거를 사용합니다.
정확한 실행 정산
.github/workflows/codeql-scan-dispatch.yml, tests/test_codeql_scan_dispatch_workflow_contract.py
비매트릭스 정산 job이 전체 required job의 identity와 attempt를 확인합니다. base가 순방향으로 변경되면 전체 실행을 재실행합니다. 그렇지 않으면 실패 job만 재실행합니다.
아키텍처와 복구 계약 문서화
docs/adr/0025-codeql-required-workflow-dispatch-architecture.md, docs/doctoring/*, CHANGELOG.md, docs/product-technical-gap-baseline.md
attempt 번호 대신 증거 기반 복구를 문서화합니다. base 변경, receipt provenance, pagination, mixed verdict 정산 규칙을 기록합니다.
회귀 계약과 실행 환경 검증
tests/test_codeql_pr_workflow_contract.py, tests/test_codeql_scan_dispatch_workflow_contract.py, tests/test_scheduler_and_codeql_dispatch_runner_image_contract.py
receipt 중복·누락·모호성, pagination, producer source, App fallback, 정산 경계를 검증합니다. 세 dispatch job이 Ubuntu 24.04를 사용함을 확인합니다.

Priority: ➖ Normal — Impact reflects medium issue severity.

Estimated code review effort: 5 (Critical) | ~120 minutes

Severity of issue fixed: Medium

Merge Risk: 🟡 Moderate · up to e0924

Important receipt-authentication and pagination paths are not independently protected by the changed contract tests. Strengthen those tests before merging to reduce the risk of silently breaking CodeQL settlement.

Sequence Diagram(s)

sequenceDiagram
  participant AnalyzeHead
  participant PRAPI
  participant StatusAPI
  participant Coordinator
  participant ScanDispatch
  participant Settlement
  AnalyzeHead->>PRAPI: live head/base 조회
  AnalyzeHead->>StatusAPI: base-bound verdict 조회
  Coordinator->>StatusAPI: pending language evidence 조회
  Coordinator->>ScanDispatch: pending matrix와 failed job map dispatch
  ScanDispatch->>StatusAPI: terminal receipt 게시
  Settlement->>StatusAPI: receipt와 direct evidence 검증
  Settlement->>ScanDispatch: exact run 또는 failed jobs 재실행
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 88.12% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 101 functions across 4 files. (8 skipped: 8…
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 Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 CodeQL 디스패치 verdict 누락 후 재실행 복구라는 PR의 주요 변경을 정확하고 간결하게 설명합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/codeql-rerun-missing-verdict-redispatch

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

Exact-head verification sweep for e47de34288fba93b990a39031503c3e59caeb680: Python Security 33953038123, SAST Semgrep 33953038106, CodeQL PR 33953038159, and Security Scan 33953038143 are all still queued. CodeQL detect job 101271230246 has not executed yet. There are no submitted reviews and no review threads. Protected .github/main remains 6d7fbebec8aec31d88a30a36e71ca5b3925d241d, so no intervening base delta has been adopted yet.

Accordingly the executable test-first regression and minimal source repair remain a development candidate, not hosted GREEN or merge-ready evidence. ADR 0025 is still Proposed and its attempt-one/attempt-two prose must be reconciled before this Draft can advance; do not mark it Accepted merely because the recovery defect is understood.

Copy link
Copy Markdown
Contributor Author

Non-force restack completed on protected main@71dd84d40576281a6218f622d685d13c6b2f5e7b as merge descendant db15e4c516e3eedc6fe41ed5a298857529f0aac0. The intervening main commit #1883 changed admission-controller/audit/scheduler code and tests only; #1902 changes only codeql-pr.yml, its focused rerun regression, and its doctoring trace, so the combined tree preserves both deltas without destructive rebase or force-push. Live PR metadata now reports mergeable=true.

Keep Draft: ADR 0025 still describes the older "attempt one dispatch / attempt two verdict read" sequence and must be made code-current before merge, and this restacked exact head still needs its own full test/coverage/docstring/workflow/security/review evidence. After ordinary protected integration, acceptance remains rerunning unchanged accounting-platform #49 and observing authenticated terminal codeql-dispatch/actions and codeql-dispatch/python verdicts.

Copy link
Copy Markdown
Contributor Author

Fresh owner-head adoption: protected main advanced again to 27d7331cc4e0ae73f2d10122e9f2a8f437c90641 via #1907 after the previous restack. That intervening delta is AGENTS/CLAUDE verification guidance and does not overlap #1902's CodeQL workflow/test/doctoring files. I adopted it with another normal two-parent descendant, 96919601105239c0b035534bbe8961563d113f42, preserving the #1902 blobs exactly and updating the branch with force=false.

Keep Draft. This restack does not address the still-stale ADR 0025 and predecessor checks/reviews do not transfer. Require all evidence on 9691960... before any merge.

Copy link
Copy Markdown
Contributor Author

Additional unchanged-head consumer evidence for this owner defect, 2026-09-05:

ContextualWisdomLab/codec-carver#520@08d1c3ca20e3e41a703ac9e5c5aea6f702962d2d has CI 33905349122, fuzz 33905349153, Security Scan 33905349127, and SAST 33905348978 terminal success, but required CodeQL PR 33905348976 failed solely in both compatibility jobs after successful current-head dispatch requests. Python job 101188835268 and actions job 101188835300 each reached Fail closed without a current-head CodeQL dispatch verdict and then waited roughly three hours before failing. Detect job 101128928869 was successful and checked out the exact target head. This is not a codec-carver source/test failure.

Owner RED: a consumer can obtain runner assignment and successfully request the exact-head CodeQL scan, yet the compatibility workflow never receives an authenticated terminal codeql-dispatch/<language> verdict within its observation horizon and fails closed.

GREEN acceptance remains central: after #1902's recovery semantics land on protected .github, rerun this unchanged codec-carver head and require authenticated terminal codeql-dispatch/python and codeql-dispatch/actions verdicts bound to 08d1c3ca..., without leaf no-op commits, synthetic status, timeout widening as a substitute for missing dispatch authority, or gate weakening. Consumer #520 stays Draft.

Copy link
Copy Markdown
Contributor Author

Fresh protected-main sweep found main@f2f91b806122ed233e3a0e2a325246077c2e15e4, 14 protected-main commits ahead of the prior merge-base and no path overlap with this PR's four-file delta. I adopted that intervening tree through normal two-parent descendant 059933143561513039cabbf911460e1056dbba7a (parents: prior PR head 510e3378f2fc30129debc776f4a187474f5ff6fa + protected main@f2f91b806122ed233e3a0e2a325246077c2e15e4), with no force push, destructive rebase, or delta loss. Fresh compare is ahead 8 / behind 0 and still changes only .github/workflows/codeql-pr.yml, ADR 0025, the recovery doctoring note, and tests/test_codeql_pr_rerun_recovery_contract.py.

This comment supersedes the PR body's older current-head/base sentence. Exact development head is now 059933143561513039cabbf911460e1056dbba7a on protected main@f2f91b806122ed233e3a0e2a325246077c2e15e4. Fresh exact-head Security Scan 33982957907, Python Security 33982957915, CodeQL PR 33982957904, and SAST Semgrep 33982957893 are queued; reviews=0 and review threads=0. Keep Draft and do not merge until one unchanged head has terminal required gates and qualifying independent approval.

Copy link
Copy Markdown
Contributor Author

Fresh canonical-owner verification from AIP consumer lane:

CodeQL PR run 33982957904 on exact head 059933143561513039cabbf911460e1056dbba7a is now terminal failure, but the observed step sequence matches the intended pending-dispatch protocol rather than the old run_attempt != 1 defect. Detect job 101351344454 succeeded. Both actions job 101361129333 and python job 101361129362 successfully executed Request current-head CodeQL scan dispatch and then intentionally failed Release runner or enforce current-head CodeQL verdict while no terminal verdict existed.

The corresponding trusted opencode-agent[bot] repository-dispatch runs exist for the same exact PR/head: 33990372949 (created 20:31:37Z) and 33990538096 (created 20:34:56Z). Both are currently queued. Therefore do not repair this by weakening the pending failure or synthesizing a status. Acceptance remains: each queued dispatch must run on canonical main, publish authenticated terminal codeql-dispatch/<language> for exact head/job identity, and rerun only the exact failed shard. If those dispatches later terminate without publishing/rerunning, that is the next causal owner-path finding.

Copy link
Copy Markdown
Contributor Author

/opencode

Current owner-path head is 059933143561513039cabbf911460e1056dbba7a, but protected main has advanced to d9eb9f79b6ce66c1225c26be385ae814d87d9aca. Compare is diverged: this PR is ahead 8 / behind 1 from merge base f2f91b806122ed233e3a0e2a325246077c2e15e4.

Read and adopt the intervening protected-main delta as a normal descendant; do not force-push or destructively rebase. The intervening merged #1943 changes CHANGELOG.md, scripts/ci/contextual_orchestrator_review_launcher.py, and tests/test_contextual_orchestrator_review_runtime_preflight.py. This PR's own delta remains .github/workflows/codeql-pr.yml, ADR 0025, the rerun-recovery doctoring note, and tests/test_codeql_pr_rerun_recovery_contract.py. Inspect the actual files and resolve any real overlap rather than assuming a race.

Preserve the evidence-driven recovery contract: run_attempt is metadata, not a dispatch receipt; when an exact-head shard has no authenticated terminal verdict, bounded redispatch remains allowed and the shard stays pending until the trusted central handler posts its verdict. Do not synthesize success, weaken required checks, substitute a provider, or add a leaf workaround.

After the non-force adoption, run the focused rerun-recovery contracts plus complete central workflow tests/security/coverage/docstring gates on the new exact head, then update the PR body to the new protected-main parent and exact evidence. Keep Draft until those gates and independent review are terminal.

Copy link
Copy Markdown
Contributor Author

Non-force protected-main adoption completed.

New exact head: 2d4624a3998baf79944d2a76b2a3367946b0d923 with parents 059933143561513039cabbf911460e1056dbba7a and protected main@d9eb9f79b6ce66c1225c26be385ae814d87d9aca. The result tree was built from the protected-main tree plus the exact four blobs owned by this PR, so the intervening #1943 sidecar/CHANGELOG/runtime-preflight changes are retained. Fresh compare from protected main is ahead 9 / behind 0 and the net PR delta is still only .github/workflows/codeql-pr.yml, ADR 0025, docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md, and tests/test_codeql_pr_rerun_recovery_contract.py.

No force update or destructive rebase was used. Exact-head SAST 33994885321, CodeQL PR 33994885323, Python Security 33994885341, and Security Scan 33994885405 are queued, so this descendant is not GREEN and the PR remains Draft. The previous 059933… workflow results are predecessor evidence only.

Copy link
Copy Markdown
Contributor Author

Fresh LineageWeave downstream canary for the rerun-recovery contract: ContextualWisdomLab/LineageWeave#914@61ed3a3712d252e3c179a71d297c52f05e1bac20, required CodeQL run 33979627116. Attempt 1 detected languages successfully; python job 101357239026 (and the javascript-typescript/actions siblings) revalidated the live exact head, found no authenticated codeql-dispatch/<language> terminal status, obtained OIDC/app token, POSTed the codeql-scan repository_dispatch successfully, wrote verdict=pending, then intentionally failed to release the runner. Current exact-head commit statuses still contain no codeql-dispatch/python, /javascript-typescript, or /actions terminal verdict. Tests 33979633195, Security 33979627218, and SAST 33979627205 are success, so the CodeQL handoff is the remaining central required-workflow evidence lane (independent PR approval is separately absent). This consumer cannot safely use a manual rerun while protected central codeql-pr.yml retains the RUN_ATTEMPT != 1 veto: absent a trusted terminal status, attempt 2 would fail before redispatch. Please keep #914 as a post-integration unchanged-head canary for #1902; no leaf no-op commit, synthetic status, predecessor evidence transfer, or gate weakening is requested.

seonghobae pushed a commit that referenced this pull request Sep 6, 2026
…scape a line-leading #1939

The 22:20Z paragraph of signature 3 still counted #1902's green job as
a noema-review success; it was a draft skip with a 1 s verdict step,
as the stage-level tally further down already says. Wrap the
line-leading #1939 reference in inline code (MD018).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BV96rXhqoR3tYZ9AeAVur4

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

Please review exact head e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e after the non-force adoption of protected main@efb8926923de45245338159a489a1b227e81945f. Focus on whether later-attempt recovery can redispatch only when no authenticated exact-head terminal verdict exists, without weakening OIDC/app-token validation, creator/status ownership, per-language isolation, pending fail-closed behavior, or concurrency. Also verify that the two-parent adoption preserved all intervening main changes and the PR remains limited to its four owned paths.

@coderabbitai

coderabbitai Bot commented Sep 6, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

head_expected='e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e'
base='efb8926923de45245338159a489a1b227e81945f'

echo '== HEAD and parents =='
git rev-parse HEAD
git show -s --format='%H%nparents: %P%nsubject: %s' "$head_expected"
echo '== Parent ancestry =='
git merge-base --is-ancestor "$base" "$head_expected" && echo "base-is-ancestor=true"
git diff-tree --no-commit-id --name-status -r "$head_expected"
echo '== Changed paths relative to protected main =='
git diff --name-status "$base" "$head_expected"
echo '== Intervening main changes preserved by merge result =='
git diff --name-status "${head_expected}^1" "$base"
echo '== Four target path blob IDs: base vs head =='
for path in \
  '.github/workflows/codeql-pr.yml' \
  'docs/adr/0025-codeql-pr-rerun-recovery.md' \
  'docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md' \
  'tests/test_codeql_pr_rerun_recovery_contract.py'
do
  printf '%s\n' "$path"
  git rev-parse "$base:$path" 2>&1 || true
  git rev-parse "$head_expected:$path" 2>&1 || true
done

echo '== Candidate files =='
fd -a 'codeql-pr.yml|0025.*codeql|codeql-rerun-pre-runner|test_codeql_pr_rerun_recovery_contract.py' . \
  -E .git -E node_modules -E dist -E build

echo '== Workflow outline / security-sensitive snippets =='
rg -n -C 6 \
  'run_attempt|codeql-dispatch|repository_dispatch|id-token|ACTIONS_ID_TOKEN_REQUEST|create-github-app-token|concurrency|verdict|creator|statuses|sha|head_sha|language|pending|fail.closed|dispatch' \
  .github/workflows/codeql-pr.yml

echo '== Focused regression and doctoring/ADR =='
cat -n tests/test_codeql_pr_rerun_recovery_contract.py
printf '\n== ADR ==\n'
cat -n docs/adr/0025-codeql-pr-rerun-recovery.md
printf '\n== Doctoring ==\n'
cat -n docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md

Length of output: 24265


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head='e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e'
prior='2d4624a3998baf79944d2a76b2a3367946b0d923'
base='efb8926923de45245338159a489a1b227e81945f'

echo '== Exact owned diff against protected main =='
git diff --find-renames --find-copies --stat "$base" "$head"
git diff --find-renames --find-copies -- .github/workflows/codeql-pr.yml "$base" "$head"

echo '== PR-owned changes relative to prior PR parent =='
git diff --name-status "$prior" "$head"
git diff -- .github/workflows/codeql-pr.yml \
  docs/adr/0025-codeql-required-workflow-dispatch-architecture.md \
  docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md \
  tests/test_codeql_pr_rerun_recovery_contract.py \
  "$prior" "$head"

echo '== Merge tree agreement with protected main outside owned paths =='
python3 - <<'PY'
import subprocess
head = 'e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e'
base = 'efb8926923de45245338159a489a1b227e81945f'
owned = {
    '.github/workflows/codeql-pr.yml',
    'docs/adr/0025-codeql-required-workflow-dispatch-architecture.md',
    'docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md',
    'tests/test_codeql_pr_rerun_recovery_contract.py',
}
def entries(rev):
    raw = subprocess.check_output(['git', 'ls-tree', '-r', '-z', rev])
    return {
        item.split(b'\t', 1)[1].decode(): item.split(b'\t', 1)[0].decode().split()[2]
        for item in raw.split(b'\0') if item
    }
h, b = entries(head), entries(base)
unexpected = sorted(
    p for p in set(h) | set(b)
    if p not in owned and h.get(p) != b.get(p)
)
print('unexpected-path-count=' + str(len(unexpected)))
print('\n'.join(unexpected))
PY

echo '== Corrected ADR and doctoring note =='
cat -n docs/adr/0025-codeql-required-workflow-dispatch-architecture.md
cat -n docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md

echo '== CodeQL handler candidates =='
fd -a -i 'codeql*' .github tests -E .git -E node_modules -E dist -E build
echo '== Handler workflow references =='
rg -n -C 5 'codeql-scan|codeql-dispatch|required_run_id|required_job_id|required_language|repository_dispatch|concurrency|createCommitStatus|statuses' \
  .github/workflows tests

Length of output: 202709


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head='e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e'
prior='2d4624a3998baf79944d2a76b2a3367946b0d923'
base='efb8926923de45245338159a489a1b227e81945f'

echo '== Compact merge and scope verification =='
git show -s --format='head=%H%nparents=%P' "$head"
printf 'merge-base='; git merge-base "$prior" "$base"
printf 'base..head paths:\n'; git diff --name-status "$base" "$head"
python3 - <<'PY'
import subprocess
head='e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e'
base='efb8926923de45245338159a489a1b227e81945f'
owned=frozenset((
 '.github/workflows/codeql-pr.yml',
 'docs/adr/0025-codeql-required-workflow-dispatch-architecture.md',
 'docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md',
 'tests/test_codeql_pr_rerun_recovery_contract.py',
))
def tree(ref):
    return {line.split('\t',1)[1]:line.split()[2]
            for line in subprocess.check_output(['git','ls-tree','-r',ref],text=True).splitlines()}
left,right=tree(head),tree(base)
print('non-owned tree differences:', [p for p in sorted(set(left)|set(right)) if p not in owned and left.get(p)!=right.get(p)])
PY

echo '== Exact workflow delta =='
git diff --unified=30 "$prior" "$head" -- .github/workflows/codeql-pr.yml
echo '== ADR delta =='
git diff --unified=12 "$prior" "$head" -- docs/adr/0025-codeql-required-workflow-dispatch-architecture.md

echo '== CodeQL handler structure =='
cat -n .github/workflows/codeql-scan-dispatch.yml | sed -n '1,460p'
echo '== CodeQL-specific test inventory =='
fd -a -i '*codeql*' tests .github/workflows -E .git | sort
echo '== CodeQL-specific assertions =='
rg -n -C 3 'codeql-scan|codeql-dispatch|required_run_id|required_job_id|required_language|RUN_ATTEMPT|OIDC|concurrency|rerun-failed-jobs|statuses' \
  tests/test_code_scanning_required_workflow_contract.py \
  tests/test_codeql_pr_rerun_recovery_contract.py \
  tests/test_required_workflow_queue_contract.py \
  tests/test_scheduler_and_codeql_dispatch_runner_image_contract.py

Length of output: 28847


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head='e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e'
base='efb8926923de45245338159a489a1b227e81945f'

echo '== Workflow diff from protected main =='
git diff --unified=25 "$base" "$head" -- .github/workflows/codeql-pr.yml
echo '== ADR diff from protected main =='
git diff --unified=20 "$base" "$head" -- docs/adr/0025-codeql-required-workflow-dispatch-architecture.md
echo '== Recovery test and doctoring additions =='
git diff --unified=8 "$base" "$head" -- \
  tests/test_codeql_pr_rerun_recovery_contract.py \
  docs/doctoring/codeql-rerun-pre-runner-cancellation-recovery.md

echo '== Handler status publication and exact rerun tail =='
cat -n .github/workflows/codeql-scan-dispatch.yml | sed -n '407,620p'

echo '== CodeQL tests and targeted contract references =='
fd -a -i '.*codeql.*' tests .github/workflows -E .git | sort
rg -n -C 4 'codeql-scan|codeql-dispatch|required_run_id|required_job_id|required_language|rerun-failed-jobs|RUN_ATTEMPT' \
  tests/test_code_scanning_required_workflow_contract.py \
  tests/test_codeql_pr_rerun_recovery_contract.py \
  tests/test_required_workflow_queue_contract.py \
  tests/test_scheduler_and_codeql_dispatch_runner_image_contract.py \
  2>/dev/null || true

Length of output: 47536


@seonghobae Review complete for e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e.

Finding

  • Medium — Paginate the authenticated status lookup before redispatch.
    .github/workflows/codeql-pr.yml Line 204 calls GET /commits/${PR_HEAD_SHA}/statuses without --paginate or an explicit page size. The workflow treats an empty first response page as proof that no authenticated terminal codeql-dispatch/<language> verdict exists. A busy commit can have more statuses than the API default response page. An older authenticated terminal verdict can then be omitted, and a later attempt can redispatch despite an existing verdict. Use a paginated lookup, then filter the complete status history for the trusted creator and language context.

The rest of the requested controls remain present after inspection:

  • The change removes only the RUN_ATTEMPT != 1 veto.
  • The caller retains live PR-head validation, run/job validation, OIDC exchange, app-token exchange, one-language dispatch, and verdict=pending fail-closed behavior.
  • The handler retains actor and sender authorization, live metadata validation, exact run/job/language validation, terminal status publication, and exact failed-job rerun validation.
  • The handler concurrency group remains scoped to target repository, PR number, and language.
  • e72ae30e3e989396b8cfdd1d850f7db1f45c6a7e is a two-parent descendant of the specified protected-main commit.
  • The merge tree differs from protected main@efb8926923de45245338159a489a1b227e81945f only in the four owned paths. No intervening protected-main path was lost.

I did not execute repository tests in this inspection environment.

You are interacting with an AI system.

Copy link
Copy Markdown
Contributor Author

Current exact handler delta map after the new #2040 P1 review:

  • #1902@aed803d9516dfdfbb82f6ca5f803604d7f90e5ba carries nested rerun_request.required_jobs, rerun-mode handling, and one run-wide rerun-failed-jobs settlement path.
  • #2040@e17d1e74e57789141feda99f542759dc99bde6cc carries the target-App/fallback wake credential chain and fail-closed no-credential/all-denied contract.
  • #2043@5e65ab56bf57f711503e32987dd84c4c10cbeed7 carries the versioned pr_head envelope required to remain below GitHub's ten-property client_payload limit.

All three touch the handler contract and tests; none currently contains the other two complete deltas. Before #1902 producer migration, build a normal non-force descendant that preserves all three and add conflict/dual-representation plus two-language HTTP-403 ordering fixtures. Keep #1902 Draft and preserve every branch until the union is exact-head GREEN; no predecessor check transfer or simple closure.

Copy link
Copy Markdown
Contributor Author

Orgmetra consumer canary #63 remains exact 42ef99ae272d78aeeeea7aac6cfd533b800a40a4 with CodeQL run 34089818084 attempt 4 terminal FAILURE at verdict-read/enforcement before same-attempt downstream dispatch evidence arrived. No attempt 5 was started.

Fresh owner inventory now observes this PR at 9f065583b367df7608ec2bb57ba9337f3926f8fe and prerequisite #2040 at dd2796d072180dae76dc5e07653f1cbfe7992d6b; both remain Draft/unmerged against protected main@7fd571dbcdbae6acf29d8f4ee704d7ba6297e4db. Orgmetra will not promote either mutable head as protected CodeQL authority. After #2040 normal integration, this lane’s non-force restack + fresh hosted GREEN + normal protected integration, #63 can rerun unchanged-head CodeQL as the consumer acceptance canary. No no-op source push/manual bypass is planned.

Copy link
Copy Markdown
Contributor Author

Independent exact-head verification for 9f065583b367df7608ec2bb57ba9337f3926f8fe:

  • GITHUB_ACTIONS=true python3 -W error -m pytest tests/test_codeql_pr_workflow_contract.py tests/test_codeql_scan_dispatch_workflow_contract.py -q --tb=short: 139 passed;
  • Python compile and git diff --check against protected main@7fd571dbcdbae6acf29d8f4ee704d7ba6297e4db: PASS;
  • exact-head Security, SAST, Python Security, Runtime Quality, OpenCode, and Noema are successful; Strix remains in progress;
  • exact-head CodeQL run 34225089444 remains terminal FAILURE in both actions and python compatibility jobs.

The owner dependency is #2040. It has implemented one attempt-level settlement, but current head dd2796d072180dae76dc5e07653f1cbfe7992d6b intentionally exposes a still-RED conflicting legacy/nested representation contract. #1902 therefore correctly remains Draft; no predecessor evidence is promoted.

Copy link
Copy Markdown
Contributor Author

Exact canary — run-wide wake race after successful scan (2026-09-08)

Canonical owner live head is 9f065583b367df7608ec2bb57ba9337f3926f8fe (the body still names aed803d...). Consumer canary #2044 exact 057ef77deffcdebea1c5cc55046b3193f4d70abe exposed a remaining run-wide settlement race:

  • required run 34227288794, exact PR head/base/run identity;
  • dispatch run 34227606169;
  • both Actions and Python CodeQL analysis + Medium+ SARIF gates succeeded;
  • Actions wake succeeded first and placed the required run into attempt 2;
  • Python then POSTed exact job 102064628722/rerun while that required run was already running; GitHub rejected it with HTTP 403: The workflow run containing this job is already running;
  • the Python required shard therefore remains failed even though its exact scan/SARIF verdict is success.

Acceptance belongs here: the sole settlement owner must collect all terminal language results and wake the required run/jobs without per-language concurrent rerun POSTs. A running attempt must not strand another successful language. Bind the settlement to exact repository/PR/head/base/required-run plus the complete failed-job map, and exercise the Actions-success/Python-success overlapping-wake schedule in a RED→GREEN hosted canary. Do not turn HTTP 403 into success without proving that every required language will consume its authenticated terminal receipt.

Copy link
Copy Markdown
Contributor Author

Current exact-head checkpoint: 9f065583b367df7608ec2bb57ba9337f3926f8fe / tree a3b3cc17b0cee93877f1f8814f65243349ef92a7 passes 139 producer/handler contract tests with GITHUB_ACTIONS=true -W error, plus Python compile and git diff --check. All 11 source review threads are resolved. CodeQL run 34225089444 remains terminal FAILURE on both compatibility shards until canonical handler owner #2040 is ordinarily integrated; Draft status is therefore retained.

Copy link
Copy Markdown
Contributor Author

Canonical handler contract coordination for current producer head 9f065583b367df7608ec2bb57ba9337f3926f8fe:

#2040 advanced with RED e0800adf0c8df06691b6393ad4417a9dfd187189 → GREEN d93a78ab4262c5228af7eda258ee0af58b880de7. The handler intentionally requires the dispatch matrix to map one-to-one to the complete rerun_request.required_jobs set before the single run-wide settlement owner may mutate the required run.

This producer still builds matrix from pending_matrix while carrying the complete required_jobs map. That partial-matrix/full-job combination will now fail closed; supporting it safely in the handler would duplicate receipt/direct-evidence trust and create an incomplete-settlement ambiguity.

Required successor repair after #2040 lands: send the full detected settlement matrix matching every exact required job, update RED/GREEN fixtures and ADR/doctoring claims, non-force restack, then regenerate producer → protected-handler → exact required-run evidence. Existing base/head/source/run/job/SARIF checks must remain intact. #1902 correctly remains Draft; no branch mutation or predecessor evidence transfer was performed here.

Copy link
Copy Markdown
Contributor Author

Canonical handler checkpoint — 2026-09-08

.github#2040 now carries both the run-wide settlement repair and #2044's valid typed-envelope delta at exact head 5c309930baba08606df16d037ce38b37896ff12c. The handler contract binds producer_source_sha to the live target PR synthetic merge commit and ordered [base, head] parents; combined local evidence is 50 focused and 3,016 full tests (1 skipped, 21 subtests) under GITHUB_ACTIONS=true -W error. Hosted checks on #2040 are newly queued, so this producer remains Draft and must not consume branch evidence. After ordinary handler merge, non-force restack this producer and regenerate end-to-end receipts.

Copy link
Copy Markdown
Contributor Author

Owner base correction — 2026-09-08

Canonical handler .github#2040@5c309930baba08606df16d037ce38b37896ff12c is now retargeted directly to protected main@7fd571dbcdbae6acf29d8f4ee704d7ba6297e4db after GitHub compare proved 30 ahead / 0 behind and full #2043/#2044 valid-delta ancestry/carryover. This removes the Draft predecessor as an unprotected base dependency. #2040 remains Ready only for review admission; CodeQL run 34233449735 is in progress and there is no independent approval, so #1902 remains Draft pending ordinary owner merge and non-force restack.

@seonghobae seonghobae left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Exact-head review at c8d7caa0d699cec0200815fdfbca8bc0b2f7a4ec: no new source finding in the focused delta. RED 940242dfc80169fcac84286fb17b1f58fa6f5ce3 proves that a mixed terminal/pending attempt previously dispatched only the pending language while retaining both failed job IDs. GREEN c8d7caa0d699cec0200815fdfbca8bc0b2f7a4ec derives rerun_matrix from the complete exact failed-job map and rejects a non-bijective wake envelope before credential acquisition. This preserves receipt-based all-terminal suppression and the production provenance/credential checks. Exact remote tree 9e51d259a832af0f7ea31a4ffc9b792a040f07c9 matches the independently tested local tree: CodeQL workflow contracts 76 passed; full GITHUB_ACTIONS=true python -W error -m pytest -q 3089 passed, 1 skipped, 21 subtests; git diff --check clean. Hosted exact-head Checks and qualifying independent approval remain merge gates.

Copy link
Copy Markdown
Contributor Author

Test-first run-wide wake repair is now published on the canonical branch by an ordinary fast-forward (force:false).

  • RED 940242df: mixed terminal/pending evidence expected the complete failed-job matrix and failed against the prior pending-only payload.
  • GREEN c8d7caa0: receipt evidence still suppresses dispatch only when every language is terminal; otherwise matrix and rerun_request.required_jobs are the same exact failed-job language set, with cardinality mismatch rejected before OIDC/token acquisition.
  • Exact remote tree 9e51d259a832af0f7ea31a4ffc9b792a040f07c9 equals the independently verified tree: focused workflow contract 76 passed; full repository under GITHUB_ACTIONS=true and -W error 3089 passed, 1 skipped, 21 subtests; diff check clean.
  • Exact-head review: fix(codeql): recover reruns after missing dispatch verdict #1902 (review)

The PR remains Draft/Proposed. Fresh hosted Checks, the protected-handler prerequisite chain, and qualifying independent approval are not inherited from 9f065583… and remain mandatory.

Copy link
Copy Markdown
Contributor Author

Fresh consumer evidence confirms the just-repaired mixed-language wake contract. On #2002 exact head, required CodeQL run 34234420967 finished with Actions success but Python job 102093048010 terminal failure: its read step returned VERDICT_STATE=pending, the coordinator job succeeded, and the release step then failed exactly as designed while awaiting a wake. This is not a scheduler/SARIF source failure. It is the protected predecessor producer/handler path exhibiting the mixed terminal/pending state that RED 940242df… now covers. Current #1902 head c8d7caa0… sends the complete failed-job matrix whenever any language remains pending, matching the handler's one-to-one run-wide wake contract. Hosted validation on the new head is still queued and no predecessor result is promoted.

Copy link
Copy Markdown
Contributor Author

Dependency handoff from #2040: current #2040 head d4a95632af9031d7a40d3cab7e78c04f87044db4 now publishes each successfully revalidated handler verdict to both codeql-dispatch/<language>/<base_sha> and the temporary legacy codeql-dispatch/<language> context. This removes the handler-first migration cycle while #1902 remains Proposed. After #2040 ordinarily reaches protected main, non-force restack #1902, regenerate exact-head receipts, and remove the legacy bridge only after #1902 is merged and old-producer runs are drained. No #1902 branch mutation was made here.

Copy link
Copy Markdown
Contributor Author

Complete successor carryover update:

#2040 now contains exact #1902 head c8d7caa0d699cec0200815fdfbca8bc0b2f7a4ec as the second parent of RED merge 6901dd6c2b2ca3c63478f57d768fd52a558d4a07, followed non-force by GREEN d7bb95f6d6ca705725596df5170d6e1345080535.

This carries #1902's base/head/run/workflow/actor/job/gate/SARIF/artifact/creator-bound producer and recovery contracts into the same successor as the protected handler. The previously proposed head-only compatibility status was rejected; the combined successor publishes only codeql-dispatch/<language>/<base_sha>, so producer and handler advance atomically without a circular rollout or reusable legacy success.

Exact-tree verification on 588f31d1bc499112064911070c5854d8bcaf3491: focused 139 passed; full 3086 passed, 1 skipped, 21 subtests passed; warning-error mode and diff check clean. #1902 remains open Draft/Proposed until #2040 is ordinarily integrated; this is verified carryover, not premature completion or Close.

Copy link
Copy Markdown
Contributor Author

Fresh downstream reproduction for canonical recovery at current #1902 head c8d7caa0d699cec0200815fdfbca8bc0b2f7a4ec:

Both exact product heads have all other hosted policy/security/test workflows GREEN, so this is central recovery behavior, not product analysis failure. Acceptance remains: one run-wide settlement owner must consume the complete failed-job map after authenticated terminal receipts publish and rerun the exact required jobs without cross-language wake races, preserving repository/PR/head/live-base/required-run identity. No downstream bypass or blind full rerun.

Copy link
Copy Markdown
Contributor Author

Canonical handler prerequisite advanced by ordinary child #2040@91a94a2, exact tree c7580fd56f59344ea9fee3305c7b2469bf548703. It repairs the cross-repository handler-source identity seam and current-head scheduler/security review findings while completely carrying #1902 through ordinary ancestry. #1902 remains Draft/Proposed at c8d7caa0…; no predecessor GREEN or approval transfers. #2040 exact-head CodeQL/Security/SAST/Python Security/Runtime Quality are a fresh queued generation.

Copy link
Copy Markdown
Contributor Author

Successor checkpoint — 2026-09-09

Canonical combined owner #2040 advanced by ordinary child 6706c231ab06a3c91c43fdb5b989cfcd79fff593. Exact handler run 34249932036 proved the remaining protected-handler cutover (SUPPLIED_REQUIRED_JOBS: null); the successor now sends wire-compatible top-level required_jobs for failed mode and reserves the nested envelope for all mode. Focused CodeQL contracts: 133 passed; full warning-error suite: 3088 passed, 1 skipped, 21 subtests passed. New exact-head hosted checks are active. #1902 remains open Proposed; no predecessor GREEN or completion claim is transferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working priority: medium Normal-priority or P2 work status: needs-review Open pull request requiring current-head review or checks type: bug Defect or incorrect behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant