Skip to content

fix(workflow-registry): fail closed on active-PR path ambiguity - #420

Merged
seonghobae merged 24 commits into
mainfrom
fix/workflow-registry-active-pr-path-ambiguity
Aug 18, 2026
Merged

fix(workflow-registry): fail closed on active-PR path ambiguity#420
seonghobae merged 24 commits into
mainfrom
fix/workflow-registry-active-pr-path-ambiguity

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Hardens the workflow-registry orphan detector and one-at-a-time disablement operator tracked by #226 so a live repair workflow cannot be disabled from ambiguous, incomplete, stale, transiently mismatched, stale-base-inherited, or current-base-only ownership evidence.

Six Noema-owned safety defects are addressed:

  1. Active-PR path case/Unicode-normalization ambiguity now fails closed.
  2. The live disablement operator refreshes the raw registry before the final broad ownership audit so a newly owning PR cannot be missed by stale pre-mutation evidence.
  3. Open-PR ownership is bound to a stable sorted pull_number:head_sha:base_sha snapshot and the dynamic file inventory must exactly match the same PR detail endpoint's advertised changed_files count.
  4. Immutable Git-tree evidence prevents an ABA-shaped dynamic PR-files read from becoming mutation-authorizing ownership evidence.
  5. Workflows merely inherited unchanged from stale history no longer suppress genuine orphan cleanup.
  6. Active-PR workflow ownership is now derived from the immutable merge-base → exact-head workflow-tree delta, not current-base → head. Therefore a workflow deleted only on a newer current base is not falsely attributed to an old PR that never changed it.

Test-first lineage

  • RED 735c37eb96fa61e521fbd839e68b7a5ef9d21e0b → GREEN 649332fa3b5c0af58b7925aefea4ec46ef093629: case/Unicode path collisions fail closed while exact ownership remains distinct.
  • Negative control 74e9ea6c441d681b78391f852ce178186b1352e6: unrelated open-PR workflow paths do not suppress a genuine orphan.
  • RED e472e7f8dde41948c8723c8fdd7117d3cb6b72cc → GREEN 4e985437fb913dc3987aa3396b43eacdf3f14620: a PR adopting the candidate during pre-mutation collection causes zero disable calls.
  • RED 1ee9c955711cf3e98713880fa9e5ca82a98a3792 → GREEN 8a0a7b867a313f0cecef4373287915d4edebbb28: open-PR head/base/snapshot movement fails closed.
  • RED f377fe12627dfabfe36c1b664ea0863ae90d6550 → GREEN 2d1f8f8f9bf9cee11dd0554e4d73770c7e917829: incomplete paginated PR-file inventory fails closed against changed_files.
  • RED 9e9950e21af0496b943c789bf00fb979d5d7332f → initial GREEN c30c3eb9cc70fab370c4d759cdcfc2ee774b4a0b: immutable tree evidence defeats an ABA-shaped file-list mismatch.
  • RED ea92040823c8969a0ef4b335d5e5d43b6807f577 → GREEN c9ceaeddb787cfd530ed6ce8f0c2c99b12d49f59: unchanged stale-base inheritance does not become PR ownership.
  • RED fcb007c6ed8f8d10f960a65ecade96fc871774da → GREEN c30142ee7bd620503340be1ca57ba85214dac636: a workflow removed only on the current base is not falsely attributed to an old PR; ownership is bound to the immutable merge-base→head delta.
  • Fixture alignment 796cc53bb68e2153131c876da2416cd60b9dd7b2 and 6946decded34aa9747b9d0e6e59311477cf779fa: all live-collector tests model the immutable compare/merge-base evidence contract.

Current exact identity and evidence

  • protected base: 027995de4bf14472a1dcdfbbab01785f2aba3eee;
  • exact head: 6946decded34aa9747b9d0e6e59311477cf779fa;
  • application CI 32083191533: success;
  • reviewer-ci 32083191573: success;
  • central Security Scan 32083191588: success;
  • unresolved review threads: 0;
  • formal reviews: 0; current repository guidance explicitly keeps code-owner review gates on hold for the solo-maintainer configuration.

No predecessor-head or model-only evidence is used for merge classification.

Boundaries

  • No workflow is disabled by this PR.
  • No central .github, naruon, contextual-orchestrator, or other dedicated-writer repository is modified.
  • Only exact merge-base→head workflow deltas count as active-PR ownership.
  • Case/normalization ambiguity remains fail-closed.
  • Dynamic PR-file inventory remains independently complete and identity-bound.
  • Truncated/unavailable tree or comparison evidence fails closed.
  • Pagination, protected-main movement, duplicate/reused workflow identity, workflow state, process-local mutation authority, post-disablement verification, and repository binding remain fail-closed.

Related: #226

Summary by CodeRabbit

  • 개선 사항

    • 워크플로 레지스트리 감사가 대소문자 및 Unicode 경로 차이를 구분해 감지합니다.
    • 변경된 워크플로를 전체 Git 트리와 정확한 PR 기준으로 판별합니다.
    • 감사 중 PR 정보나 파일 상태가 변경되면 안전하게 실패하도록 검증을 강화했습니다.
    • 중복 경로, 잘린 응답, 잘못된 커밋 식별자 등 비정상 데이터를 감지합니다.
  • 버그 수정

    • 최신 레지스트리 상태를 확인한 뒤에만 워크플로 비활성화를 진행합니다.
    • 활성 PR이 소유한 워크플로가 실수로 고아 항목으로 분류되거나 비활성화되는 문제를 방지했습니다.

@coderabbitai

coderabbitai Bot commented Aug 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: caecad83-7910-4b98-89ba-6784a9583002

📥 Commits

Reviewing files that changed from the base of the PR and between 027995d and 6946dec.

📒 Files selected for processing (7)
  • scripts/workflow-registry-audit.mjs
  • scripts/workflow-registry-live-audit.mjs
  • scripts/workflow-registry-live-disable.mjs
  • test/workflow-registry-active-pr-path-ambiguity.test.ts
  • test/workflow-registry-live-audit-pr-snapshot.test.ts
  • test/workflow-registry-live-audit.test.ts
  • test/workflow-registry-live-disable-pr-race.test.ts

📝 Walkthrough

Walkthrough

PR 소유 워크플로를 immutable merge-base-to-head Git tree 차이로 판정합니다. 경로 대소문자 및 Unicode 정규화 충돌을 미해결 상태로 분류합니다. 비활성화 전에 라이브 레지스트리와 감사 결과를 다시 수집합니다.

Changes

워크플로 레지스트리 안전성

Layer / File(s) Summary
PR 경로 모호성 분류
scripts/workflow-registry-audit.mjs, test/workflow-registry-active-pr-path-ambiguity.test.ts
대소문자 또는 Unicode NFC 차이가 있는 경로를 unresolved_registry_record로 분류합니다. 각 불일치 오류와 고아 워크플로 분류를 테스트합니다.
불변 PR 트리 기반 감사
scripts/workflow-registry-live-audit.mjs, test/workflow-registry-live-audit.test.ts, test/workflow-registry-live-audit-pr-snapshot.test.ts
recursive Git tree, merge-base, PR head SHA를 사용해 워크플로 소유권을 계산합니다. 잘림, 형식 오류, 중복 경로, PR identity 변경, 파일 수 불일치, 수집 전후 스냅샷 변경을 거부합니다.
비활성화 전 라이브 상태 갱신
scripts/workflow-registry-live-disable.mjs, test/workflow-registry-live-disable-pr-race.test.ts
비활성화 전에 collectLiveWorkflows()를 호출합니다. 감사 결과가 권한 부여 상태가 아니면 비활성화 호출을 차단합니다.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related issues

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant runWorkflowRegistryDisablement
  participant collectLiveWorkflows
  participant collectWorkflowRegistryAudit
  participant disableWorkflow
  runWorkflowRegistryDisablement->>collectLiveWorkflows: 라이브 레지스트리 수집
  runWorkflowRegistryDisablement->>collectWorkflowRegistryAudit: 전체 exact-main 감사 수집
  collectWorkflowRegistryAudit-->>runWorkflowRegistryDisablement: 감사 및 권한 부여 결과
  runWorkflowRegistryDisablement->>disableWorkflow: 검증된 레코드 비활성화
  disableWorkflow-->>runWorkflowRegistryDisablement: mutation 결과
Loading
✨ 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/workflow-registry-active-pr-path-ambiguity

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.

@seonghobae
seonghobae marked this pull request as ready for review August 18, 2026 00:08
@cursor

cursor Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@seonghobae
seonghobae merged commit 028ee5c into main Aug 18, 2026
15 of 16 checks passed
@seonghobae
seonghobae deleted the fix/workflow-registry-active-pr-path-ambiguity branch August 18, 2026 00:08
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