Skip to content

test: keep interpreter start-up out of the early-exit pattern-judge budget (SR-6) - #326

Draft
jothimani-rajendran wants to merge 1 commit into
mainfrom
sr-6-pattern-judge-startup
Draft

jothimani-rajendran wants to merge 1 commit into
mainfrom
sr-6-pattern-judge-startup

Conversation

@jothimani-rajendran

@jothimani-rajendran jothimani-rajendran commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

What

test_the_judge_matches_times_out_and_reports_a_dead_child failed once on a CI runner (3.12) with the patterns gave no verdict within 1s where it expects the pattern judge exited early (; it passed on re-run of the same commit.

Why

judge_patterns starts a child on demand and the caller's budget includes that child's interpreter start-up. After the catastrophic-pattern step kills the child, the next call ("(") starts a fresh one. With a 1 s budget, a loaded runner can still be starting it when the budget runs out, so the early exit is never seen. budget.py already reports an exited child at once (EOF on the pipe); the delay was start-up, not detection.

Change

tests/test_pattern_deadline.py only. The three calls that start a child (first match, the "(" case, the new child after the crash) get budget.PATTERN_SECONDS; they return as soon as the child answers or dies, so the test is not slower. The catastrophic-pattern step keeps the 1 s budget, on a child that is already up. No assertion changed; nothing skipped, retried or marked flaky.

src/chock/gate/budget.py is untouched, so the vendored runtime (.chock/bin, runtime goldens) does not change and needs no owner sync.

Evidence

Race reproduced by running the real test with sys.executable pointed at a wrapper that sleeps 1.5 s before exec'ing Python (a slow child start):

  • before: 1 failed ((None, 'the patterns gave no verdict within 1s ...') where a verdict was expected)
  • after: 1 passed
  • after, normal start: 8 passed in tests/test_pattern_deadline.py; ruff check and ruff format --check clean.

CPU-load reproduction (24 busy loops on 4 cores, 15 runs): 0 failures before the fix, so the slow-start wrapper is the reproduction.

No changelog fragment: test-only.

…udget (SR-6)

judge_patterns spends interpreter start-up out of the caller's budget when it
starts a child. The dead-child test gave those calls the 1 s budget meant for
the catastrophic pattern, so on a loaded runner the fresh child after the
timeout was not up in time and the "(" case reported "no verdict within 1s"
instead of "exited early". The calls that start a child now get
PATTERN_SECONDS; the catastrophic pattern keeps the 1 s budget on an
already-running child. No assertion changed. budget.py and the vendored
runtime are untouched.

Signed-off-by: Jothi Mani Rajendran <250249270+jothimani-rajendran@users.noreply.github.com>

This branch has not been deployed

No deployments
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