Skip to content

Runs stop only when they must: tooling failures, environments, ticket diagnoses, existing open PRs - #349

Merged
nambok merged 1 commit into
mainfrom
feat/stop-discipline
Oct 28, 2026
Merged

nambok merged 1 commit into
mainfrom
feat/stop-discipline

Conversation

@nambok

@nambok nambok commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

A run on a failing end-to-end test ticket stopped with "needs more detail". Four things were wrong with that stop:

  1. It was caused by its own tooling: the type-check and lint in a test package outside the workspace failed with missing modules and "command not found".
  2. It treated production content that differs from staging as a contradiction, although the tests run against staging and their own dataset.
  3. The ticket already named the root cause ("test bug, not code bug") and gave a fix plan with acceptance criteria.
  4. Another open PR, opened by a person, already fixed the same failing test.

Each of these is now a rule, enforced in code for every team. The pure logic is in common::stop_rules, and the worker applies it in passes::stop_gate at each point where a run would stop.

Changes

Rule 1: tooling failures are never questions (stop_rules::tooling)

  • Every stop reason is classified. Tooling failures are: a missing package module (a bare Cannot find module 'x', not a relative import or path alias), command not found or exit 127, an npx with no executable, npm, pnpm or yarn install errors, and sandbox errors.
  • Test-package checks now install and run through the package's own manager. The frozen install falls back to refreshing the lockfile, and binaries run with pnpm exec, yarn or bunx.
  • A tooling failure gets one repair in the sandbox: the dependencies of that package are installed, then the command runs again. This applies in the failing-test gate and when the implement pass changed nothing after a failed check.
  • If it still fails, the run ends as a tooling failure: Tooling failure: \cmd` failed: error. The run record gets stop_kind = toolingandtooling_failure {command, error, tried}, which the API returns. It is never needs_input`.
  • A question that quotes a tooling error is refused where clarification questions are raised.

Rule 2: tests are judged where they run (stop_rules::environment, test_fix::read_environment)

  • A failing-test run now reads the suite's own setup before it judges anything:
    • the runner config: base URL and the variables that override it, the other variables it reads, and its setup and stored state;
    • the env files: keys only, plus addresses with credentials removed (no other values are kept);
    • the data and fixture files, and the team's test address.
  • This is saved in the run's evidence (Evidence.environment) and given to every agent, with the rule that a difference between environments is not a contradiction.
  • A question classified as environment_difference is refused.

Rule 3: the ticket's own diagnosis is followed (stop_rules::screen, stop_gate::diagnosis)

  • A model quotes the ticket's root cause, fix plan, acceptance criteria and any request for a separate change, from the ticket and its thread. A quote that is not in the ticket's text is dropped.
  • The full diagnosis goes into every agent's instructions.
  • When the ticket states all three, a planner question is asked only if it claims a contradiction and cites evidence that checks out. That means a path:line that exists at the base branch, or a lookup the planner made.
  • Other questions are dropped. The plan is sent back once to follow the ticket. If it then still asks only refused questions, the run fails with the reasons; it does not ask.
  • The decision questions (where the fix belongs) go through the same screen.
  • Question.evidence is stored, shown in the ticket comment, and returned by the API.

Rule 4: existing open work (stop_rules::existing_work, stop_gate::existing_work)

  • The check runs twice: before planning, and again before the PR opens (now with the change's own files).
  • It searches open PRs by any author for the ticket key, the failing test names, the failing spec files, and changed files that overlap the run's.
  • CoderHelm's own PRs for the ticket are left out, and so are PRs a person already made a choice about.
  • A model reads each match. A PR counts as covering the work only if it matches one of those signals and the model says it does the work.
  • A covered run gets the new terminal status covered_by_pr and keeps a covered_by record. The summary says "Already being fixed in #N", and the same note goes on the ticket (Jira or GitHub).
  • If the ticket asks for a separate change, or a person re-runs with a direction, the check is skipped.
  • covered_by_pr is added to the status list, to retry, to the trigger gate (only a ticket edit starts another run), to the webhook status enum and to the comment reader.

Verification

  • Fixtures under services/common/src/stop_rules/testdata/:
    • sandbox output with missing modules and a missing executable;
    • a real type error, which is not counted as tooling;
    • a Playwright config and an env file with credentials, which are stripped;
    • a ticket that states its own diagnosis;
    • an open PR list.
  • Tests cover each rule:
    • Rule 1: classification, the exact command and error, the repair commands for each package manager, the check steps run through the manager, and the stored reason.
    • Rule 2: reading the environment, keeping it in the evidence, and refusing a question about environment differences.
    • Rule 3: quotes are checked against the ticket, citations are checked, and only evidenced contradictions are asked.
    • Rule 4: the signals, a covering PR needing both a signal and the model's yes, a request for a separate change, and a choice a person made.
  • cargo fmt --check passes, and cargo clippy --workspace --all-targets -D warnings is clean.
  • cargo test --workspace: common 1257, gateway 593 and worker 782 passed, 0 failed.
  • docs/api/openapi.json was regenerated with UPDATE_OPENAPI=1.

… the ticket's own plan followed, open PRs not duplicated

A run on a failing-test ticket stopped with "needs more detail" when its own
type-check failed for want of dependencies, when production and staging
content differed, when the ticket already gave the cause and the plan, and
while another open PR already fixed the same test. Each of those is now a
rule enforced in code (common::stop_rules, worker passes::stop_gate):

1. Tooling: a step that fails for want of a dependency or command (missing
   package modules, command not found, an install that failed, the sandbox)
   is classified as tooling. Package checks install and run through the
   package's own manager; a tooling failure gets one repair (install, then
   the command again) and otherwise ends the run as a tooling failure with
   the exact command and error (stop_kind and tooling_failure on the run).
   A question quoting a tooling error is never asked.
2. Environment: a test-related run reads the suite's runner config, env
   files (keys and credential-free addresses only), setup, data and
   fixtures, records them with its evidence, and every agent is told to
   judge data there. A stop citing a difference between environments is
   refused.
3. Ticket diagnosis: the ticket's root cause, fix plan and acceptance
   criteria are quoted (checked against the ticket's own text) and given to
   every agent. With all three, a question is asked only when it cites a
   path:line that exists or a lookup the run made; others are dropped and
   the plan is sent back to follow the ticket.
4. Existing work: before work starts and again before the PR opens, open
   PRs by anyone are matched on the ticket key, failing test names, spec
   files and changed files; one a model reads as doing the work ends the
   run as covered_by_pr, linked on the run and on the ticket, unless the
   ticket asks for a separate change or a person already chose.
@nambok
nambok force-pushed the feat/stop-discipline branch from a13a759 to d4eb868 Compare October 28, 2026 18:16
@nambok
nambok merged commit fc81f27 into main Oct 28, 2026
8 checks passed
@nambok
nambok deleted the feat/stop-discipline branch October 28, 2026 18:45
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