Skip to content

fix(ci): resolve PR Metadata Preflight base live instead of the stale event-payload SHA - #10784

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/ci-metadata-preflight-stale-base
Jul 28, 2026
Merged

fix(ci): resolve PR Metadata Preflight base live instead of the stale event-payload SHA#10784
Git-on-my-level merged 3 commits into
mainfrom
fix/ci-metadata-preflight-stale-base

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

PR Metadata Preflight (repo-checks.yml metadata-preflight job) diffed against github.event.pull_request.base.sha — a value frozen at whatever PR event last delivered it. That job only runs on metadata-only edited/labeled/unlabeled events, which fire with no new commit and don't refresh that field. On PR #10758, main had advanced 37 commits (including a change to backend/routers/memories.py in an unrelated PR) since the last time an event refreshed base.sha, so the diff scope silently ballooned to include those unrelated commits and the job failed on a false INV-MEM-1 citation requirement for files the PR never touched.

The sibling changes job in the same workflow already avoids this: it resolves origin/${{ github.base_ref }} live against the job's own fetch-depth: 0 checkout instead of trusting a payload field. This PR points metadata-preflight at the same thing.

Fix

  • .github/workflows/repo-checks.yml: metadata-preflight's scripts/pr-preflight --base now uses origin/${{ github.base_ref }} instead of github.event.pull_request.base.sha.
  • .github/scripts/test_pr_preflight.py: updated the workflow-content regression test to assert the live-resolved base and guard against reintroducing the stale payload field.

No behavior changes for the changes/hygiene (code) lane — it already used the correct pattern.

Product invariants affected

none

Failure class (fixes)

Failure-Class: new

Registered FC-stale-event-payload-diff-base: a check that diffs a PR against a base ref must resolve that ref live from the checkout, not from a value captured in an event payload that isn't refreshed by every trigger type that can run the check. No existing registered class covers event-payload staleness driving an incorrect diff scope. evidence_prs points at #10758, where this exact failure surfaced. Guard artifact: test_repo_checks_routes_metadata_events_to_the_narrow_preflight now asserts the live-resolved base and would fail if the stale field were reintroduced.

Verification

Related

Filed a follow-up issue: the same github.event.pull_request.base.sha pattern also appears in backend-unit-tests.yml, desktop-swift-ci.yml, backend-hermetic-e2e.yml, and desktop-backend-image-checks.yml. Those jobs trigger on code-changing events (synchronize/opened) where the payload field is refreshed by the same event that needs it, so the staleness window is much narrower — but not zero under queued/delayed runs. Left out of this PR to keep the fix scoped and verifiable; tracked separately.

Review in cubic

… event-payload SHA

github.event.pull_request.base.sha is frozen at whatever PR event last
delivered it. A metadata-only edited/labeled/unlabeled event fired days
after the last push carries a base SHA that main may have moved far past,
so the diff scope silently balloons to include unrelated commits that
landed on main in the interim — producing false invariant-citation
failures on files the PR never touched. The sibling `changes` job in the
same workflow already resolves origin/<base_ref> live against the
fetch-depth:0 checkout; point metadata-preflight at the same thing.

Failure-Class: new
Evidence: PR #10758, where this exact failure surfaced — a diff computed
against a frozen github.event.pull_request.base.sha falsely flagged
INV-MEM-1 on files the PR never touched, because main had advanced 37
commits past that captured SHA with no intervening event to refresh it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87a9ef4dd7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +361 to +362
self.assertNotIn("github.event.pull_request.base.sha", metadata_job)
self.assertIn('--base "origin/${{ github.base_ref }}"', metadata_job)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Add a behavioral regression test for the live base

These assertions only inspect the workflow text, so they remain green if checkout/ref-resolution behavior later leaves origin/main stale or the preflight stops diffing the fetched ref correctly. Because this test is registered as the canonical prevention artifact for the new failure class, add a behavioral contract that creates an advancing remote base plus a stale payload SHA and executes the production preflight seam; retain these assertions only as an explicitly labeled static tripwire.

AGENTS.md reference: AGENTS.md:L49-L49

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch — fixed in 5d7f534. Added test_stale_event_payload_base_widens_diff_scope_past_the_live_base, which exercises the real changed_files() seam against an actual git repo (a captured-then-stale base SHA vs. a live-resolved ref, through a simulated refs/pull/N/merge), and re-labeled this assertion's comment as the static tripwire it is, pointing at the new test for the real coverage.

…base

Codex flagged (P1, PR #10784) that the workflow-content assertions only
inspect text and stay green even if changed_files()'s ref-resolution
behavior regresses. Add a behavioral test that exercises the real
changed_files() seam against an actual git repo: a base SHA captured once
(standing in for github.event.pull_request.base.sha) and never refreshed
picks up unrelated main commits through a merge-ref diff, while a
live-resolved base ref does not. Label the existing text assertion as the
static tripwire it is and point it at this test for the real coverage.
@Git-on-my-level
Git-on-my-level merged commit 530dc9c into main Jul 28, 2026
27 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/ci-metadata-preflight-stale-base branch July 28, 2026 17:46
undivisible pushed a commit to Archit-lal/omi that referenced this pull request Jul 29, 2026
…base

Codex flagged (P1, PR BasedHardware#10784) that the workflow-content assertions only
inspect text and stay green even if changed_files()'s ref-resolution
behavior regresses. Add a behavioral test that exercises the real
changed_files() seam against an actual git repo: a base SHA captured once
(standing in for github.event.pull_request.base.sha) and never refreshed
picks up unrelated main commits through a merge-ref diff, while a
live-resolved base ref does not. Label the existing text assertion as the
static tripwire it is and point it at this test for the real coverage.
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