Skip to content

fix(ignore): preserve timeout notice when rules are cut - #1426

Closed
WilliamK112 wants to merge 2 commits into
squirrelscan:mainfrom
WilliamK112:codex/ignore-timeout-cut-1419
Closed

WilliamK112 wants to merge 2 commits into
squirrelscan:mainfrom
WilliamK112:codex/ignore-timeout-cut-1419

Conversation

@WilliamK112

Copy link
Copy Markdown
Contributor

Summary

  • report [[ignore]] timeout indexes at the moment an entry exhausts its work budget
  • retain those indexes when --max-duration cuts the rules phase before it returns a result
  • add a regression test for observing the timeout before rules-phase completion

This is stacked on #1333 because the [[ignore]] implementation is not on main yet. Once #1333 lands, this can be rebased/retargeted to main.

Fixes #1419

Verification

  • bun test packages/rules/tests/ignore-1262.test.ts (24 pass)
  • bun run --filter @squirrelscan/rules typecheck
  • bun run --filter @squirrelscan/audit-engine typecheck
  • bun run --filter @squirrelscan/cli typecheck
  • oxlint -c oxlint.config.mjs src/audit/adapter.ts src/controllers/audit.ts
  • git diff --check

Checklist

  • I added or updated tests for behavioral changes.
  • I did not include secrets, customer data, or incompatible third-party material.
  • Every commit includes a DCO Signed-off-by line (git commit -s).

nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 7dd2529

Verdict: pending maintainer review. Thanks for the fix, the approach is sound. This is a draft stacked on #1333 (base feat/ignore-1262), so it cannot land until that merges and this is retargeted to main.

Findings, most severe first:

  1. Medium: no test for the cut path. [[ignore]]: a cut rules phase loses the 'ignore entry timed out' notice #1419 asks for a test that cuts the rules phase after a timed-out entry and asserts the notice (last acceptance criterion). The new test in packages/rules/tests/ignore-1262.test.ts only checks that onIgnoreTimeout fires from RuleRunner. Nothing exercises the controller path at apps/cli/src/controllers/audit.ts (the ignoreTimedOut: [...ignoreTimedOut] return) with a deadline.
  2. Low: the CLI wrapper runStreamingRules in apps/cli/src/audit/adapter.ts only gains the option type in this diff. Please confirm the options object is forwarded to the engine's runStreamingRules unchanged, otherwise the callback never fires in the CLI. A cut-path test would settle this.
  3. Low: the controller callback dedupes (includes), and IgnoreMatcher already fires once per entry, so the "Called once" doc comments are accurate. On the non-cut path ignoreTimedOut = ruleResults.ignoreTimedOut overwrites the list; that is consistent, but a test for "not cut, no timeout reports the same as today" would cover the third criterion.
  4. Info: CI is not green yet (claude-review skipped on a draft with a non-main base). DCO sign-off is present. No new runtime dependency. Docs do not need an update for this behaviour fix.

Correctness of the change itself looks right: indexes are recorded at the moment of timeout, so a cut run keeps them.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking up #1419 so quickly. This is stacked on #1333, which is in the next release batch (v0.0.148), so we will review it against that and cherry-pick it right after #1333 lands, keeping your authorship. An independent review of the commit on top of #1333 is running now; we will comment here with the result.

nik

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Review result: the change is sound and safe. The runner only hands an entry index to the callback, the cloud path is unchanged, and a run that is not cut reports exactly what it did before. We will adopt it after #1333 with your authorship kept.

One thing to add before we take it: a test that covers the lines that actually carry the fix. The current test shows the runner callback fires, but reverting the controller's retained list back to [], or removing the audit-engine passthrough, fails no test. A good shape is an audit-engine test that runs runStreamingRules with an [[ignore]] that times out, interrupts it with Effect.timeoutOption, and asserts the callback saw index 0. If you would rather not, say so and we will add it ourselves.

nik

@WilliamK112

Copy link
Copy Markdown
Contributor Author

Added the requested cut-path regression test in packages/audit-engine/tests/ignore-timeout-cut-1419.test.ts (commit 12f07ad5). It runs the real runStreamingRules adapter with an [[ignore]] entry that exhausts its work budget, crosses the deadline only after onIgnoreTimeout observes index 0, then verifies Effect.timeoutOption cuts the phase while the callback-retained index remains. This also exercises the options passthrough from the audit engine.

Validation:

  • focused rules + audit-engine tests: 25 passed
  • audit-engine typecheck passed
  • new test formatting and git diff --check passed

@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Thanks for the test. It runs the real runStreamingRules under a timeout, fails when the audit-engine passthrough or the runner callback is removed, and passed 5 of 5 under load. We will cherry-pick both commits into the batch right after #1333, with your authorship kept. One optional follow-up we may add ourselves: a controller-level test that pins the [...ignoreTimedOut] line for a cut run.

nik

nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 12f07ad

Verdict: pending maintainer review. The code change is correct and the earlier requested test is now present; the PR is still a draft stacked on #1333 (base feat/ignore-1262), so it waits for that to land. This agrees with the earlier maintainer decision to cherry-pick both commits after #1333 with your authorship kept.

Earlier requests, checked against this head:

  1. Cut-path regression test (asked for in the review of 7dd2529): addressed. packages/audit-engine/tests/ignore-timeout-cut-1419.test.ts runs the real runStreamingRules under Effect.timeoutOption and asserts the callback saw index 0. It exercises the audit-engine passthrough at packages/audit-engine/src/adapter.ts:3595.
  2. CLI wrapper forwarding (low): the option type is added at apps/cli/src/audit/adapter.ts:513 and the controller passes onIgnoreTimeout at apps/cli/src/controllers/audit.ts:2186. I did not see the wrapper body in the diff, so the maintainer should confirm it forwards the options object unchanged.

Findings, most severe first:

  1. Low: the controller line ignoreTimedOut: [...ignoreTimedOut] (apps/cli/src/controllers/audit.ts:2240) is still not pinned by a test. Reverting it to [] would pass the suite. The maintainer already noted this as an optional follow-up.
  2. Low: the new engine test relies on Bun.sleepSync(1100) against a 1000 ms timeout. It passed under load per the maintainer, but it is timing-based and could flake on a very slow runner.
  3. Low: no CHANGELOG [Unreleased] entry in the diff. Worth adding for a user-visible fix (the timeout notice now survives --max-duration).
  4. Info: untrusted-input safety is fine. The callback receives only an entry index, the controller dedupes with includes, and there are no new loops or regexes. DCO sign-off is present, no new runtime dependency, and docs need no change. The only check is claude-review, which was skipped on a draft with a non-main base.

nik

@WilliamK112
WilliamK112 force-pushed the codex/ignore-timeout-cut-1419 branch from 12f07ad to 9c69645 Compare October 31, 2026 09:20
@WilliamK112
WilliamK112 changed the base branch from feat/ignore-1262 to main October 31, 2026 09:21
@WilliamK112
WilliamK112 marked this pull request as ready for review October 31, 2026 09:21
@WilliamK112

Copy link
Copy Markdown
Contributor Author

#1333 is now in main via v0.0.148, so I rebased the two signed-off commits onto ee532e4e, force-pushed the branch with lease, retargeted this PR to main, and marked it ready for review. The PR now contains only the #1419 fix and its regression tests.

nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Reviewed head: 9c69645

Verdict: pending maintainer review. The code change is correct, the earlier requested test is present, and the branch is now rebased onto main (base ee532e4) and out of draft. It matches the maintainer decision to take both commits with your authorship kept, so the merge call is the maintainer's.

Earlier requests, checked against this head:

  1. Cut-path regression test (asked for after the review of 7dd2529): addressed. packages/audit-engine/tests/ignore-timeout-cut-1419.test.ts runs the real runStreamingRules under Effect.timeoutOption and asserts the callback saw index 0. It fails if the passthrough at packages/audit-engine/src/adapter.ts (createRunner(config, effectiveScope, { onIgnoreTimeout })) is removed.
  2. CLI wrapper forwarding (low): the option type is added to the wrapper in apps/cli/src/audit/adapter.ts and the controller passes onIgnoreTimeout in apps/cli/src/controllers/audit.ts. The wrapper body is not in the diff, so the maintainer should confirm it forwards the options object unchanged.
  3. Optional controller-level test (maintainer follow-up): still open, see finding 1.

Findings, most severe first:

  1. Low: ignoreTimedOut: [...ignoreTimedOut] in the cut-result branch of apps/cli/src/controllers/audit.ts is still not pinned by a test. Reverting it to [] would pass the suite. The maintainer already noted this as optional.
  2. Low: the new engine test relies on Bun.sleepSync(1100) against a 1000 ms timeout. It passed under load, but it is timing-based and could flake on a very slow runner.
  3. Low: no CHANGELOG [Unreleased] entry in the diff. Worth adding, since the timeout notice now survives --max-duration.
  4. Info: untrusted-input safety is fine. The callback receives only an entry index, the controller dedupes with includes, and there are no new loops or regexes. DCO sign-off is declared in the PR checklist, there is no new runtime dependency, and docs need no change. The only check is claude-review, which shows skipped on this head, so there is no CI signal yet.

nik

@nc9 nc9 mentioned this pull request Oct 31, 2026
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Landed in v0.0.149 as 9c6e17fa 15b7a5f2 via #1432. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.149. Thank you William, the timeout notice now survives a cut rules phase. An optional controller-level test that asserts the notice in the report of a cut run would be a good follow-up. Closing this original.

nik

@nc9 nc9 closed this Oct 31, 2026
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.

[[ignore]]: a cut rules phase loses the 'ignore entry timed out' notice

2 participants