Skip to content

fix(ci): compare rebased copies against their PR base - #195

Merged
Harrilee merged 2 commits into
mainfrom
codex/ci-pr-base-after-rebase
Sep 14, 2026
Merged

Harrilee merged 2 commits into
mainfrom
codex/ci-pr-base-after-rebase

Conversation

@Harrilee

@Harrilee Harrilee commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Why and what changed

Trusted pull-request/* copies trigger Full CI through push events. After a rebase, push.before can point to an unreachable previous copy head. The whitespace gate then fails with Invalid symmetric difference expression, preventing the runtime suites from starting.

Resolve the originating PR's head and base together, retain exact-head verification, and pass the validated PR base to Fast CI. Fetch missing base history using a temporary, read-only GitHub-token header before checking the complete PR range. The token is not persisted. Other triggers keep their existing whitespace ranges: ordinary main/release pushes use event.before; manual runs outside trusted-copy refs and new release branches retain the last-commit fallback. Collector and prediction comparison bases are unchanged.

Review map

  • Risk level: medium — changes CI execution and comparison-base contracts.
  • Start with: .github/workflows/ci.yml (verify-target → Fast CI input), then .github/workflows/fast-ci.yml (BASE_SHA → authenticated fetch → whitespace check). Tests are in tests/test_ci_workflow_contracts.py and the existing .github/codeowners/test_aisimulate_policy.py mock.
  • Public or serialized contract changed: no product API/schema change; Fast CI adds the optional base_sha reusable-workflow input.
  • Compatibility or rollback concern: retain exact-head checks, read-only permissions, persist-credentials: false, and full-range whitespace validation. Reverting this change restores the rebased-copy failure. Changes are limited to two workflows and two CI test files.

Evidence

  • Tested commit: c08ebd5b8a338f8d6ed85b4117b213c092d3a642.
  • Tests: python -m pytest -c /dev/null .github/codeowners/test_*.py tests/test_ci_workflow_contracts.py tests/test_ci_qualification.py -q -p no:cacheprovider --override-ini='addopts=' --override-ini='filterwarnings=' — 209 passed.
  • Static/policy checks: ruff check --config python/aisimulate/pyproject.toml tests/test_ci_workflow_contracts.py, ruff format --check --config python/aisimulate/pyproject.toml tests/test_ci_workflow_contracts.py, git diff --check, python3 scripts/check_copyright.py, and python3 scripts/check_packaged_legal_files.py passed.
  • Fast CI: passed on c08ebd5b; CODEOWNERS also passed.
  • Full CI: queued on c08ebd5b. Previous revision 68433bad passed on its trusted copy; that result does not certify this follow-up commit.
  • CodeRabbit reviewed commit: 68433bad14cde57a8cf1ab0ccae0aab29b6be1fe; new-head review pending.
  • Codex reviewed commit: c08ebd5b8a338f8d6ed85b4117b213c092d3a642 — author-side call-chain and regression review; reviewer recheck of the follow-up remains pending.
  • Negative or boundary cases: changed PR head; malformed/missing base; API failure; unreachable old copy head; stacked parent changes excluded; whitespace in an earlier PR commit detected; missing history fetched without truncation/tags or persisted credentials; fetch failure terminates before diff; empty/all-zero bases preserve the last-commit fallback. Extracted whitespace and shared workflow scripts use GitHub's Bash error-handling flags.
  • Expected-value derivation: temporary Git histories define the parent base, all commits belonging to the PR, and the last-commit fallback directly; no numerical model assertions.
  • Before/after evidence: original copied-head failure; #122 using its stacked PR base; #190 using its stacked PR base. The missing-base transport test uses a local file origin plus an authentication contract check; it is not a hosted missing-base reproduction.

Modeling or data provenance

N/A — no simulation model, performance data, or product-output changes.

Tracking

Signed-off-by: Harry Lee <harrli@nvidia.com>
@Harrilee
Harrilee requested review from a team as code owners September 14, 2026 00:25
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 0687218c-0299-44fa-9207-8477238f982e

📥 Commits

Reviewing files that changed from the base of the PR and between 68433ba and c08ebd5.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • .github/workflows/fast-ci.yml
  • tests/test_ci_workflow_contracts.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • ai-dynamo/dynamo (manual)
  • ai-dynamo/aiconfigurator (manual)

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (21)
  • GitHub Check: Prediction Regression / Collect prediction snapshot (new)
  • GitHub Check: Prediction Regression / Collect prediction snapshot (old)
  • GitHub Check: Collector Data / Check collector data
  • GitHub Check: Platform Wheels / Build wheels (manylinux_2_28_aarch64)
  • GitHub Check: Collector Data / Perf data sanity (informational)
  • GitHub Check: Platform Wheels / Build wheels (macosx_arm64)
  • GitHub Check: Platform Wheels / Build wheels (manylinux_2_28_x86_64)
  • GitHub Check: Python 3.11 compatibility
  • GitHub Check: Public API Rust (amd64)
  • GitHub Check: Release Artifact Contract (arm64)
  • GitHub Check: Application Test Wheel (arm64)
  • GitHub Check: Release Artifact Contract (amd64)
  • GitHub Check: Public API Rust (arm64)
  • GitHub Check: Application Test Wheel (amd64)
  • GitHub Check: Rust (arm64)
  • GitHub Check: Cargo Deny (workspace, amd64)
  • GitHub Check: Python 3.13 compatibility
  • GitHub Check: Rust feature modes
  • GitHub Check: Engine Golden Regression
  • GitHub Check: Rust (amd64)
  • GitHub Check: Cargo Deny (workspace, arm64)
🧰 Additional context used
📓 Path-based instructions (4)
Only root workflows are active.

⚙️ CodeRabbit configuration file

Files:

  • .github/workflows/fast-ci.yml
  • .github/workflows/ci.yml
Require coverage of the changed behavior and its negative or boundary cases.

⚙️ CodeRabbit configuration file

Files:

  • tests/test_ci_workflow_contracts.py
Read REVIEW.md before commenting.

⚙️ CodeRabbit configuration file

Files:

  • tests/test_ci_workflow_contracts.py
Before making any change under: `python/aisimulate/src/aiconfigurator/generator/**` MUST read: `python/aisimulate/.claude/rules/generator-development.md` Before making any change under `python/aisimulate/collector/**` MUST read: `python/ais...

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • tests/test_ci_workflow_contracts.py
🪛 ast-grep (0.45.3)
tests/test_ci_workflow_contracts.py

[error] 584-601: Command coming from incoming request
Context: subprocess.run(
["bash", "--noprofile", "--norc", "-eo", "pipefail", "-c", script],
cwd=repository,
env={
**os.environ,
"GIT_CONFIG_NOSYSTEM": "1",
"GIT_CONFIG_GLOBAL": os.devnull,
"GITHUB_EVENT_NAME": "push",
"GITHUB_REF": "refs/heads/pull-request/121",
"BEFORE_SHA": "f" * 40,
"BASE_SHA": base,
"TARGET_SHA": target,
"GH_TOKEN": "ci-contract-dummy-token",
},
capture_output=True,
text=True,
check=False,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)


[error] 783-790: Command coming from incoming request
Context: subprocess.run(
["bash", "--noprofile", "--norc", "-eo", "pipefail", "-c", script],
cwd=REPOSITORY_ROOT,
env={**os.environ, **env},
capture_output=True,
text=True,
check=False,
)
Note: [CWE-78] Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').

(subprocess-from-request)

🔀 Multi-repo context ai-dynamo/dynamo, ai-dynamo/aiconfigurator

Linked repositories findings

ai-dynamo/dynamo

  • shared-build-image.yml:163-167, 525-534 defines an optional SHA input and fetches the explicit baseline with --no-tags, matching the PR’s base propagation and history-fetch approach. [::ai-dynamo/dynamo::]
  • pr.yaml:265-268 forwards the resolved merge-base SHA into the reusable workflow. [::ai-dynamo/dynamo::]
  • pre-merge.yml:189-200 fetches the base explicitly and falls back to a strict gate when unavailable, providing a compatible fail-closed precedent. [::ai-dynamo/dynamo::]

ai-dynamo/aiconfigurator

  • build-test.yml:138-156 uses the PR base SHA for diff-scoped checks and falls back to the root commit for invalid/missing metadata. [::ai-dynamo/aiconfigurator::]
  • build-platform-wheels-copied-pr.yml:6-31 invokes validate-platform-wheels.yml, while validate-platform-wheels.yml:5-35 declares no workflow_call base-SHA input; no direct consumer of the PR’s new base_sha contract was found here. [::ai-dynamo/aiconfigurator::]

📝 Summary

Risk: Medium.

Human review should focus on:

  • PR head/base SHA validation for trusted copy branches.
  • Authenticated fetches and fail-closed behavior when base history is missing.
  • The new fast-ci.yml base_sha workflow contract.

Changed behavior:

  • Full CI resolves and validates both SHAs.
  • Full CI fetches missing base history and passes base_sha to Fast CI.
  • Fast CI uses base_sha for complete-range whitespace checks.
  • Trusted-copy verification records the resolved base SHA.

Public contracts changed:

  • fast-ci.yml adds the optional base_sha workflow input.
  • Full CI publishes and passes the resolved base SHA.

Technical evidence:

  • 206 CI and CODEOWNERS contract tests pass.
  • Tests cover rebased copies, stacked bases, malformed metadata, shallow repositories, tag avoidance, and failed base resolution.
  • Strict ownership coverage is 100%.
  • Generated-file, copyright, legal-file, Ruff, and whitespace checks pass.
  • Latest shell inspection completed successfully, but the returned diff output was empty.

Merge readiness:

  • No evidence is supplied for end-to-end hosted GitHub Actions runs.
  • No evidence is supplied for a real trusted PR-copy event.
  • Review must still confirm workflow permissions and authenticated fetch behavior.

Walkthrough

Full CI verifies and exports the trusted PR base SHA. Fast CI receives that SHA, fetches it when needed, and checks whitespace across the complete PR range. Contract tests cover stacked PR metadata, repository history, and fail-closed behavior.

Changes

Trusted base CI flow

Layer / File(s) Summary
Verify and export the trusted base
.github/workflows/ci.yml, .github/codeowners/test_aisimulate_policy.py, tests/test_ci_workflow_contracts.py
Trusted PR verification retrieves and validates both PR head and base SHAs, then writes base_sha to workflow output. Tests cover valid, changed, malformed, missing, and API-failure cases.
Propagate the comparison base
.github/workflows/ci.yml, .github/workflows/fast-ci.yml, tests/test_ci_workflow_contracts.py
Full CI passes the resolved base to Fast CI. Fast CI accepts base_sha and uses it to set BASE_SHA.
Fetch and validate the complete PR range
.github/workflows/fast-ci.yml, tests/test_ci_workflow_contracts.py
Fast CI fetches a missing base commit before the three-dot whitespace check. Tests cover stacked PR ranges, history preservation, tag avoidance, credential handling, and unresolved bases.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Merge Risk: ⚪ Minimal · up to c08eb

The trusted base propagation and complete-range whitespace validation changes have no identified current-head merge risk.

🚥 Pre-merge checks | ✅ 7 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Review Evidence ❓ Inconclusive The description reports 206 passing contract tests, negative cases for rebases, stacked bases, malformed bases, API failure, and missing history, plus a parity statement and hosted Fast CI/Full CI sta… Add the exact validation commands and results. Label which results are local, fake-runner, parity, and hosted production evidence. Keep the queued Full CI run separate from completed hosted results.
✅ Passed checks (7 passed)
Check name Status Explanation
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.
Cross-Layer Contract ✅ Passed PASS. The new fast-ci.yml workflow_call input base_sha has a string type, empty default, caller wiring from Full CI, and a single consumer in python-static.BASE_SHA. Full CI traces the PR API …
Modeling And Data Evidence ✅ Passed The check is not applicable. The pull request changes GitHub Actions SHA resolution, authenticated base fetching, whitespace validation, and contract tests. It introduces no formula, model, performanc…
Compatibility Boundaries ✅ Passed The reviewed range changes only CI workflows and CI contract tests. It does not change Python or Rust source, bindings, schemas, versions, or public package metadata. `python/aisimulate/pyproject.toml…
Title check ✅ Passed The title precisely describes the behavioral change: rebased trusted copies are compared against their originating pull request base. The conventional "fix(ci):" prefix does not make the title vague.
Description check ✅ Passed The description follows the required template and documents the problem, behavior change, review map, contract impact, compatibility risks, test evidence, boundary cases, provenance, and tracking info…
Full details: Review Evidence

Explanation

The description reports 206 passing contract tests, negative cases for rebases, stacked bases, malformed bases, API failure, and missing history, plus a parity statement and hosted Fast CI/Full CI statuses. The changed workflows show that root Fast CI is active for both pull requests and workflow calls, and Full CI is active for trusted-copy push branches. No inactive nested workflow is cited as passing hosted evidence. However, the description does not name exact commands or clearly classify local, fake-runner, parity, and production evidence, so the positive evidence requirement cannot be confirmed.


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

@Arsene12358 Arsene12358 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict: approve — no hard blockers. One P2 (F1) I'd like fixed or explicitly deferred before merge; S1–S4 are non-blocking notes.

Verification

I traced the change from the copy-branch push through verify-target → whitespace-base → the reusable Fast CI input → BASE_SHA → git diff --check, and re-ran the suites on 68433bad.

  • Hosted evidence for the bug: run 34788614489 (pull-request/121 @ 69901699) ran the whitespace step with BASE_SHA=e1dff098… (the previous copy head) and failed with fatal: Invalid symmetric difference expression … (exit 128), which took Fast CI Success and Full CI Success down with it.
  • Hosted evidence for the fix: the stacked copies used their own PR base, a value neither the old expression nor the comparison-base fallback could produce — 34792674185 (pull-request/122) ran with BASE_SHA=7252deba… (#121's head) and 34792673388 (pull-request/190) with BASE_SHA=56ac9f86… (#122's head). The pull-request/121 run used main's tip because #121 still targeted main when it started (it was retargeted 45 s later). This PR's own copy, 34792677350, finished green.
  • Local: the policy + contract + qualification suites collect 206 cases and all 11 new cases pass (also under bash 3.2). Ruff check/format, git diff --check origin/main...HEAD, copyright and packaged-legal checks are clean; actionlint reports only the pre-existing SC2016 info in the readiness step (same on main).
  • No regressions on the other entry points: main/release/* pushes still compare against event.before (via comparison-base), standalone pull_request runs still use pull_request.base.sha (inputs.* is empty outside workflow_call), and the only new value that reaches a shell is pr_base, validated as 40-hex.

F1 (P2): the absent-base fetch cannot authenticate on the hosted runner

The description says "fetch absent base history before checking the complete PR range", and test_fast_ci_whitespace_fetches_an_absent_base_without_truncating_history[fetch-base-history] covers it. On GitHub that path fails every time it is reached: the repository is internal, the python-static checkout runs with persist-credentials: false (its log shows Removing auth unsetting http.https://github.com/.extraheader at the end of the checkout step), and git fetch --no-tags origin "${BASE_SHA}" carries no credentials. collector-check.yml runs the identical fetch and injects github.token as a basic-auth extraheader for exactly this reason (and that fetch succeeds in the same Full CI run). The new test passes only because its origin is a file:// path, which never asks for credentials.

This is not a regression — an absent base already failed with exit 128 — and in every hosted run so far the base was a branch tip already present in the fetch-depth: 0 clone, so the fetch never executed. But it is a shipped path that a test certifies and the description advertises, and the case where it matters (an orphaned .base.sha) is exactly when a clear outcome is needed. Two acceptable fixes: mirror collector-check.yml's token injection (inline suggestion on fast-ci.yml, plus a contract test pinning the header so it cannot silently disappear), or drop the fetch, the fetch-base-history parameterization, and the sentence in the description — for trusted copies the base is always reachable from a branch head, so the check stays correct without it.

Non-blocking notes

  • S1 — whitespace-base falls back to comparison-base, which is main's tip for non-lifecycle runs (ci.yml L95-98). workflow_dispatch runs and the first push of a new release/* branch therefore now check main...target instead of TARGET^..TARGET; for a dispatched stacked head that includes the parent PR's commits. Probably fine (tree-level diff, and every PR already passes this gate on its pull_request event), but it is undocumented — either note it or narrow the output to steps.pr-target.outputs.base_sha so the other triggers keep their previous behavior.
  • S2 — the new helpers execute step scripts with bash -c; GitHub runs shell: bash steps with -eo pipefail. Verdicts coincide today (a failed fetch is followed by a failing git diff), so this is a fidelity nit.
  • S3 — the body doesn't follow the PR template (Review map / risk level / Evidence fields / Tracking). REVIEW.md ties the Codex-review requirement to the declared tier and CodeRabbit rated this Medium; maintainers' call. The hosted runs above are the end-to-end evidence CodeRabbit said was missing and would be worth citing.
  • S4 — after this merges, #121 needs to go back to main as planned (GitHub does it automatically if this branch is deleted on merge).

Comment thread .github/workflows/fast-ci.yml
Comment thread tests/test_ci_workflow_contracts.py
Comment thread .github/workflows/ci.yml Outdated
Comment thread tests/test_ci_workflow_contracts.py Outdated
Signed-off-by: Harry Lee <harrli@nvidia.com>

Copy link
Copy Markdown
Contributor Author

@Arsene12358 Addressed F1 and S1–S2 in c08ebd5b, with details in each inline thread. Local CI/policy suites: 209 passed. Fast CI and CODEOWNERS passed on this exact commit; Full CI is queued.

For S3, the description now follows the repository template, declares medium risk, and distinguishes current-head results from the earlier hosted runs. It also states the local missing-base test's transport limitation. For S4, the tracking section explicitly retains the post-merge step to ensure #121 targets main. This update only changes #195; the runtime stack has not been rebased or retargeted here.

@Harrilee
Harrilee merged commit 1694ffe into main Sep 14, 2026
35 checks passed
@Harrilee
Harrilee deleted the codex/ci-pr-base-after-rebase branch September 14, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-ready Ready for automated and human review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants