Skip to content

test(roadmap): fault-injection tests prove the pipeline recovers #3075

Closed

Description

@dan-petty

What happened

Recovery paths (retry, tier change, continuation, amendment) are only trusted if a test makes the fault happen. So far each fault was found on a live item: OOM, a 25-minute generation, an XML parser error, a wrong plan path, a scratch file in the root.

What should happen

  • A fault-injection set for the stage and implement jobs on stub models and a fake Kubernetes: provider 5xx and timeouts, malformed tool calls, a killed pod, an OOM, a conflicting push, a flaky test, a CI infra failure, a wrong plan. Each case asserts the class (F1), the action, the final state and that no work was lost (D2).

Acceptance criteria

  • At least 12 fault cases run offline in the test suite in under a stated time.
  • Each case asserts the final status label and the comment text.
  • Adding a failure class needs a case (a test checks that every class has one).
  • The suite adds no more than 60 seconds to the test check.

Related: tracker for this set (filed with it), #2908 (issue workflow), #2867 (draft PR evaluator), #3005 (task kind), #3010 to #3015 (plan gates), #2919 (stuck-item metrics), #2953 (Ollama parser).

Alternatives check of 2026-11-04: not-applicable.
Class: test, no search.
Tool: none found.

Proposed design

Problem statement

The roadmap recovery paths are trusted only after a live fault. The project needs an offline fault-injection suite for the stage and implement jobs and for the Service lanes. Each case must prove the failure class or the injected Service error, the action or row result, the final status and comment, and that no finished work is lost.

Acceptance criteria

Requirement: Offline fault suite size

The fault suite SHALL run at least 12 stage, implement and Service lane fault cases offline on in-memory fakes, with no network, process or Kubernetes call.

Scenario: Collected fault cases

  • WHEN The fault suite is collected and run in the test check.
  • THEN It holds at least 12 cases, and the hermetic floor records no real network, process or Kubernetes edge.

Requirement: Stage and implement fault matrix

The fault suite SHALL cover provider 5xx and timeouts, malformed tool calls, a killed pod, an OOM, a conflicting push, a flaky test, a CI infrastructure failure, and a wrong plan.

Scenario: Stage and implement fault matrix

  • WHEN The fault suite runs.
  • THEN Each named stage or implement fault has at least one case.

Requirement: Service lane fault matrix

The fault suite SHALL cover a halt file write failure, an unreadable state file for each of schedule.json, the failure ledger and the intake record, a RoadmapItemChangedError during intake apply, a Service stop between two stage items, and a failed marks write after a draft pull request exists.

Scenario: Service lane fault matrix

  • WHEN The fault suite runs.
  • THEN Each named Service lane fault has at least one case.

Requirement: Stage and implement case assertions

Each stage or implement fault case MUST assert the FailureClass from src/devops_cli/roadmap/failure.py, the recovery action, the final status label, the posted comment text, and that no finished work is lost.

Scenario: Stage and implement case result

  • WHEN Any stage or implement fault case runs.
  • THEN It asserts the class, the action, the final status label, the comment text, and the preserved finished work.

Requirement: Service lane case assertions

Each Service lane fault case MUST assert the injected error class, the row result, the final status label, the posted comment text, and that no finished work is lost.

Scenario: Service lane case result

  • WHEN Any Service lane fault case runs.
  • THEN It asserts the error class, the row result, the final status label, the comment text, and the preserved finished work.

Requirement: Failure class coverage gate

The fault suite MUST fail when a FailureClass in src/devops_cli/roadmap/failure.py has no fault case.

Scenario: New class without a case

  • WHEN A class is added to FailureClass without a matching fault case.
  • THEN The coverage test fails and names the class.

Requirement: No real wait

Every wait of the fault suite MUST go through the injected clock and every edge MUST use an in-memory fake, so the suite adds no real wait and stays within the 60-second budget of the Tests & Coverage check.

Scenario: Fault suite waits

  • WHEN A fault case reaches a retry, timeout or poll.
  • THEN The clock fake records the wait and no real sleep or edge call occurs.

Existing Tool Considered

The alternatives check of 2026-11-04 ran for this test item and found no tool; its class makes no search or model call. pytest, already the project's runner (pyproject.toml:190), with pytest-timeout and pytest-xdist, covers offline collection, parametrization, fixtures and the hang bound. The repository's edge fakes cover every edge: model_fake (tests/support/fakes/model.py:643), process_fake (tests/support/fakes/process.py:432), git_fake (tests/support/fakes/git.py:121), cluster (tests/support/fakes/kubernetes.py:801), roadmap_store (tests/support/fakes/roadmap_store.py) and clock (tests/support/fakes/clock.py:81). They lack a fault-case table keyed by FailureClass and the Service lane cases. The change adds tests only: about 1,200 tokens to write the cases and the table, about 200 tokens per month to keep them, and about one day of elapsed time.

Key questions

  • Which test framework and case layout should the fault-injection suite use?: Use pytest with one parametrized table of fault cases in tests/roadmap/test_roadmap_faults.py, keyed by FailureClass for the stage and implement cases and by the injected error class for the Service lane cases. Use the existing edge fakes and add no runner. (best practice) [sources: pyproject.toml:190, tests/invariants/test_architectural_invariants.py, docs/adr/0004-ci-is-the-authoritative-gate.md]
    • Chosen: pytest parametrized table. It uses the existing runner and the required Tests & Coverage check, and one table shows every case.
    • Rejected: Custom test harness. It duplicates pytest and adds maintenance and time.
    • Rejected: unittest. It adds a second test style to a project that runs pytest.
  • How should the suite stay offline and within the time budget?: Use the existing edge fakes: model_fake for provider and parser faults, process_fake and git_fake for checks and pushes, cluster for the Kubernetes API, roadmap_store for items and comments, and the clock fixture for every wait. Make no network call and no real sleep. Do not assert elapsed time in a test: docs/TESTING.md:141 forbids an upper bound on wall-clock time and the test-elapsed-upper-bound rule enforces it. (best practice) [sources: docs/TESTING.md:67, docs/TESTING.md:68, docs/adr/0007-tests-double-only-process-edges.md:3, docs/TESTING.md:141, tests/support/fakes/model.py:643, tests/support/fakes/kubernetes.py:801, tests/support/fakes/clock.py:81]
    • Chosen: In-process edge fakes and the clock fixture. ADR 0007 doubles only process edges, the hermetic floor refuses a real edge, and the clock fixture records every wait.
    • Rejected: Live cluster and model calls. It violates the offline requirement and adds time.
    • Rejected: Recorded HTTP responses. It adds fixtures and still needs the edge seams and the clock.
  • How should the suite prove that every failure class has a case?: Key the stage and implement case table by FailureClass and assert {case.klass for case in FAULT_CASES} == set(FailureClass), the same introspection that test_each_class_has_exactly_one_default_action_in_one_table uses for ACTION_BY_CLASS. The coverage test names each missing class. (best practice) [sources: src/devops_cli/roadmap/failure.py:83, src/devops_cli/roadmap/failure.py:84, tests/roadmap/test_roadmap_failure.py:494, tests/roadmap/test_roadmap_failure.py:495]
    • Chosen: Introspect FailureClass against the case table. It fails automatically when a class is added without a case, as the existing ACTION_BY_CLASS test does.
    • Rejected: Hand-maintained checklist. It can drift from the code and does not fail on a new class.
  • Which Service lane faults must the suite add?: Add cases for a halt file write failure, an unreadable state file for each of schedule.json, the failure ledger and the intake record, a RoadmapItemChangedError during intake apply, a Service stop between two stage items, and a failed marks write after the draft pull request exists. Each case asserts the injected error class and the row result, not a FailureClass: those errors are not in the implement taxonomy. (best practice) [sources: src/devops_cli/server/service.py:158, src/devops_cli/server/service.py:363, k8s/README.md:662, k8s/README.md:668, src/devops_cli/roadmap/run.py:233, src/devops_cli/roadmap/run.py:272, src/devops_cli/roadmap/run.py:1041, docs/ERRORS.md:106, src/devops_cli/roadmap/stage/stage.py:1871, src/devops_cli/roadmap/stage/stage.py:1872, src/devops_cli/exceptions/roadmap.py:40]
    • Chosen: Add the five Service lane cases. The reply from project standards names them and the code holds each path.
    • Rejected: Stage and implement cases only. It leaves the Service lanes untested.
  • What should each case assert for the final state and the comment?: Assert the exact final status label and the exact comment text that the recovery path posts, plus the class or injected error and the action or row result, and that finished work remains: the branch, the commit, the draft pull request, or the earlier item's record. (best practice) [sources: docs/ROADMAP_WORKFLOW.md:141, docs/ROADMAP_WORKFLOW.md:162, docs/ROADMAP_WORKFLOW.md:371, src/devops_cli/roadmap/failure.py:29]
    • Chosen: Exact label, exact comment text, and preserved work. The issue requires the final status label and the comment text, and D2 requires that no finished work is lost.
    • Rejected: Label only. It misses the comment assertion.
    • Rejected: Comment substring only. It can pass when the wrong action text is posted.
  • How should the 60-second limit be enforced?: Do not assert elapsed time in a test. Keep every wait on the clock fixture and every edge faked, state the measured suite duration in the module docstring, and report the --durations measurement in the pull request. docs/TESTING.md:141 forbids an upper bound on wall-clock time, the test-elapsed-upper-bound rule enforces it, and the Tests & Coverage shard already has a 30-minute timeout. (best practice) [sources: docs/TESTING.md:141, docs/TESTING.md:142, .ast-grep/rules/test-elapsed-upper-bound.yml:6, .github/workflows/ci.yml:113]
    • Chosen: Clock-bound suite with a stated measured duration. It follows docs/TESTING.md:141 and keeps the suite fast without a flaky wall-clock assert.
    • Rejected: Per-test elapsed assertion. docs/TESTING.md:141 and the test-elapsed-upper-bound rule forbid it; a loaded machine fails correct code.
    • Rejected: CI duration assertion. The same suite took 355-528 s on one runner, so a 60-second bound would fail correct code.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    scope/roadmap
    status/new
    value/high
    effort/medium
    on Nov 1, 2026
  2. dan-petty commented on Nov 1, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/test. The test prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Recovery paths are unverified in production; the tests are needed before trusting the pipeline but do not block other work.
    • Value: High. Without these tests the pipeline recovery is unproven and live failures go undetected.
    • Effort: Medium. Twelve or more offline fault cases with stub models and fake Kubernetes, plus assertions, in under 60 seconds.
    • Related: feat(roadmap): a failure taxonomy, and one action for each class #3065, which asks for a different change. Both reference the failure class and action table, but #3065 defines the taxonomy while the candidate writes tests that assert recovery using it.
  3. added
    priority/p2-medium
    on Nov 1, 2026
  4. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at 9179b22 until a person answers the questions below. Reply in a comment or edit the body, and the next refine round looks at the item again.

    • The proposal has no problem statement, no acceptance criterion with its requirement, scenario, WHEN and THEN, or no answer to the existing-tool question. State the problem, the requirements with their scenarios, and the open tool that covers the need or the cost of building it.
  5. devops-cli-service commented on Nov 4, 2026

    @devops-cli-service
    Contributor

    Alternatives check: not-applicable

    Class: test. The check makes no search and no model call for an item of this class.

    Tool: none found

    Checked on 2026-11-04. A person decides what this means for the item. The check changes no label and closes no issue.

  6. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards: add the fault cases of the Service lanes to this suite. The cases are:

    • the halt file cannot be written;
    • a state file is unreadable (schedule.json, the ledger, the intake record);
    • a conflict during the intake apply (RoadmapItemChangedError);
    • a stop of the Service between two items of a stage round;
    • a failure after the draft pull request exists in the stage publish (a failed marks write).

    Each case asserts the class, the action, the final state and that no finished work is lost. The classes come from roadmap/failure.py. The test check must stay under 60 seconds.

  7. added
    status/ready
    and removed
    status/new
    on Nov 7, 2026
  8. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 49f0f14 (see proposed design in issue body).

  9. 5 remaining items

  10. added
    status/blocked
    and removed
    status/in-progress
    on Nov 8, 2026
  11. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    The runner Job devops-cli-runner-20261108-012928-322e ended: succeeded.
    Image digest: sha256:1553d88dcb89e7c579b747c7eaf8e542da38934bed7fa133a260f0520b0d7996

    The last lines of its log:

    Tool call: shell, program grep, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: uv run pytest tests/roadmap/implement/test_roadmap_implement_job_scoped.py -q --durations=8 ...
    Tool call: shell, program uv, ok.
    Tool call: shell, started: grep -n <masked> pyproject.toml | head ...
    Tool call: shell, program grep, ok.
    Tool call: read_file, ok.
    Tool call: shell, started: grep -n implement_step_names -A 14 src/devops_cli/lang/en/messages.py ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -n implement_stop_check_failed\\|implement_stop_no_change\\|implement_stop_program_failed\\|run_stop_reason\\|implement_stop_scoped_failed src/devops_cli/l ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: grep -n line-length\\|\[tool.ruff -A 3 pyproject.toml ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: ls .ast-grep/rules/ | head -60
    Tool call: shell, program ls, ok.
    Tool call: shell, started: cat .ast-grep/rules/test-function-has-assertion.yml
    Tool call: shell, program cat, ok.
    Tool call: shell, started: ls tests/gate/tree_checks/
    Tool call: shell, program ls, ok.
    Tool call: shell, started: grep -rn docstring tests/gate/tree_checks/*.py tests/gate/*.py | ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: ls tests/roadmap/*.py | head; cat tests/roadmap/conftest.py ...
    Tool call: shell, program ls, refused.
    Tool call: shell, started: find tests/roadmap -maxdepth 1 -name conftest.py
    Tool call: shell, program find, ok.
    Tool call: shell, started: grep -n <masked> -A 40 src/devops_cli/exceptions/base.py ...
    Tool call: shell, program grep, ok.
    Tool call: shell, started: uv run python -c __import__("pathlib").Path(".data/agent/scratch").mkdir(parents=<masked>
    Tool call: shell, program uv, ok.
    Tool call: write_file, ok.
    Tool call: shell, started: grep -n <masked> -A 30 tests/support/roadmap_implement.py
    Tool call: shell, program grep, ok.
    Tool call: edit_file, ok.
    Tool call: shell, started: grep -n <masked> -A 20 src/devops_cli/exceptions/ai_pydantic.py
    Tool call: shell, program grep, ok.
    Tool call: shell, started: other
    Tool call: shell, program other:95b6ffada44d, refused.
    Failure class limit_reached. Action left: raise_limit.
    ✓ Took 0 item(s) to a ready pull request, stopped 1.
    Elapsed: 9m 40s
    
  12. removed
    owner/service
    on Nov 8, 2026
  13. added
    owner/agent
    status/in-progress
    and removed
    status/blocked
    on Nov 19, 2026
  14. added
    status/in-review
    and removed
    status/in-progress
    on Nov 19, 2026
  15. removed
    status/in-review
    owner/agent
    on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/roadmapsource/agenttype/testvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions