Skip to content

test(invariants): validate stage eval fixtures against schema and tree #4059

Open

Description

@dan-petty

Problem

tests/invariants/test_roadmap_eval_fixtures.py tests only implement fixtures under tests/fixtures/roadmap_eval/implement/.
No invariant test checks the 63 stage golden cases under tests/fixtures/roadmap_eval/stage/.
When tests move to new directories, stage golden cases keep outdated file paths.
For example, fixture good-3410 still cites tests/roadmap/test_roadmap_stage_prompt_rules.py, which now lives at tests/roadmap/stage/test_roadmap_stage_prompt_rules.py.
Stage gates must then keep compatibility shims for deleted paths.
Also, invalid schema entries in stage fixtures are not detected until a full replay runs.

Expected

Add invariant tests for tests/fixtures/roadmap_eval/stage/ in tests/invariants/test_roadmap_eval_fixtures.py.
Verify that every stage case loads against StageCase and CaseFacts schemas.
Verify that every golden plan loads against StageProposal (src/devops_cli/roadmap/stage/stage_change.py).
Verify that the paths named in plan.json match existing files or valid created files.
Verify that the total byte size of tests/fixtures/roadmap_eval/stage/ stays below a size limit.

Acceptance criteria

  • uv run pytest tests/invariants/test_roadmap_eval_fixtures.py -k stage - all stage fixtures load against schema and stay below the size cap.
  • Stale module paths in tests/fixtures/roadmap_eval/stage/ are detected before merge.

Feasibility

I read tests/invariants/test_roadmap_eval_fixtures.py and src/devops_cli/roadmap/stage/stage_eval_cases.py.
stage_eval_cases.py defines StageCase, CaseFacts, and load_cases.
The schemas and loader already exist.
The invariant test will load each directory under tests/fixtures/roadmap_eval/stage/ and assert schema validity.

Existing tool considered

Existing pydantic models CaseFacts and StageProposal. No new library is needed.

Cost

Build: about 25k tokens and 1.5 hours (test module, fixture path updates). Keep: about 1k tokens per quarter. Fix: about 4k tokens and 0.25 hours.

Related

Part of #3027. Related to #3347.

Alternatives check of 2026-11-30: not-applicable.
Class: test, no model call.
Tool: none found.

Proposed design

Problem statement

The invariant suite checks only the implement fixtures under tests/fixtures/roadmap_eval/implement/, and no invariant test checks the 63 stage golden cases under tests/fixtures/roadmap_eval/stage/. A test module move leaves an old path in a good case's plan or facts. A stage gate then keeps a compatibility shim for the deleted path. An invalid schema entry in a stage fixture waits for a full replay to appear. Add stage invariant tests for loading, plan paths, good-case paths and a size cap. Correct the stale paths that the new tests find.

Acceptance criteria

Requirement: Stage cases load against their schema

The invariant suite SHALL load every case folder under tests/fixtures/roadmap_eval/stage/ with the stage load_cases loader, so that each case validates against StageCase and CaseFacts.

Scenario: The committed stage set loads

  • WHEN the stage invariant test calls load_cases on tests/fixtures/roadmap_eval/stage/
  • THEN load_cases returns one StageCase for each case folder and raises no ConfigurationError

Requirement: A case folder holds a case.json

The invariant suite SHALL require each folder under tests/fixtures/roadmap_eval/stage/ that holds an issue.txt, a plan.json or a facts.json to hold a case.json too.

Scenario: A case folder misses its case.json

  • WHEN a folder under the stage root holds plan.json and holds no case.json
  • THEN the stage invariant test fails and names the folder

Requirement: A plan breaks the reply schema with no kind defect

The invariant suite SHALL require StageProposal to accept the plan.json of each case that has no defect with the gate kind.

Scenario: A plan breaks the reply schema with no kind defect

  • WHEN StageProposal.model_validate raises for a case that has no defect with the gate kind
  • THEN the stage invariant test fails and names the case and the validation error

Requirement: A kind defect keeps its refused plan

The invariant suite SHALL require StageProposal to refuse the plan.json of each case that has a defect with the gate kind.

Scenario: A kind case loads against the reply schema

  • WHEN a case has a defect with the gate kind and StageProposal.model_validate accepts its plan
  • THEN the stage invariant test fails and names the case

Requirement: A plan names only existing, tracked, created, change-folder or missing paths

The invariant suite SHALL require each path that a group of plan.json names in reads, changes, a task code span or verify to exist in the repository, to be in case.facts.tracked, to be in the creates of a group, to be in case.change_files(), or to be in the paths of a missing_path defect.

Scenario: A plan names a path that no record holds

  • WHEN a path of a group's reads, changes, task code span or verify is absent from the repository, from facts.tracked, from every group's creates, from change_files() and from every missing_path defect
  • THEN the stage invariant test fails and names the case and the path

Requirement: A good case names only current paths

The invariant suite SHALL require each tests/ or src/ path in the plan.json and in facts.tracked of a case whose verdict is good to exist in the repository, unless a group of the plan lists it in creates.

Scenario: A module moved after a good case was recorded

  • WHEN facts.tracked and the plan of good-3410 name tests/roadmap/test_roadmap_stage_prompt_rules.py and the repository holds only tests/roadmap/stage/test_roadmap_stage_prompt_rules.py
  • THEN the stage invariant test fails and names the case and the stale path

Requirement: The good cases name current paths

Each case whose verdict is good SHALL name only current tests/ or src/ paths in its plan.json and facts.json, except for a path that a group lists in creates.

Scenario: The corrected good cases are checked

  • WHEN the stage invariant test reads the plan and facts.tracked of good-3410 and each other good case
  • THEN each tests/ or src/ path in the plan or facts.tracked exists or is listed in a group's creates

Requirement: The stage set stays below its size cap

The invariant suite SHALL require the total byte size of the files under tests/fixtures/roadmap_eval/stage/ to stay below 2500000 bytes.

Scenario: The stage set grows past the cap

  • WHEN the sum of the sizes of the files under the stage root reaches 2500000 bytes
  • THEN the stage invariant test fails and states the measured size and the cap

Requirement: The stage tests are selected by -k stage

The invariant suite SHALL put the word stage in the name of each new test, so that uv run pytest tests/invariants/test_roadmap_eval_fixtures.py -k stage selects them.

Scenario: The stage selection runs

  • WHEN a person runs uv run pytest tests/invariants/test_roadmap_eval_fixtures.py -k stage
  • THEN pytest selects the stage tests, runs them and reports no failure

Existing Tool Considered

The alternatives check of 2026-11-30 recorded not-applicable for this test-class item and named no tool; see the alternatives block in the issue body.

The open, maintained tools that cover the need are pytest==9.2.0 (pyproject.toml:109) and pydantic==2.14.4 (pyproject.toml:15). The project's CaseFacts and StageCase (src/devops_cli/roadmap/stage/stage_eval_cases.py:176,203) validate the fixtures. StageProposal (src/devops_cli/roadmap/stage/stage_change.py) validates the plans. tests/roadmap/stage/test_roadmap_stage_eval_cases.py:167 already asserts the plan-schema rule. They lack a repository-tree check, the group creates rule of path_problems (src/devops_cli/roadmap/stage/stage_paths.py:663) and a size cap. The invariant module adds about 40 lines for these. The written cost is about 25k tokens and 1.5 hours to build, about 1k tokens per quarter to keep, and about 4k tokens and 0.25 hours to fix.

Key questions

  • Which module defines StageCase, CaseFacts and the stage loader, and how does the invariant module import a loader today?: src/devops_cli/roadmap/stage/stage_eval_cases.py holds CASES_DIRECTORY (:78), NO_COMMIT (:82), CaseFacts (:176), StageCase (:203) and load_cases (:286). The invariant module imports the implement loader at tests/invariants/test_roadmap_eval_fixtures.py:12 and reads FIXTURES at :15. The stage tests import the stage loader under the alias load_stage_cases. tests/roadmap/stage/test_roadmap_stage_eval_cases.py:97 already loads the set with that loader. [sources: src/devops_cli/roadmap/stage/stage_eval_cases.py:78, src/devops_cli/roadmap/stage/stage_eval_cases.py:176, src/devops_cli/roadmap/stage/stage_eval_cases.py:203, src/devops_cli/roadmap/stage/stage_eval_cases.py:286, tests/invariants/test_roadmap_eval_fixtures.py:12, tests/invariants/test_roadmap_eval_fixtures.py:15, tests/roadmap/stage/test_roadmap_stage_eval_cases.py:97]
  • Must every plan.json load against StageProposal?: No. A plan fails the reply schema exactly when a defect of the case names the gate kind (src/devops_cli/roadmap/stage/stage_eval_cases.py:17-19). The invariant fails when StageProposal refuses a plan of a case with no kind defect. It also fails when StageProposal accepts a plan of a case with a kind defect. (best practice) [sources: src/devops_cli/roadmap/stage/stage_eval_cases.py:17, src/devops_cli/roadmap/stage/stage_eval_cases.py:19, tests/roadmap/stage/test_roadmap_stage_eval_cases.py:167, src/devops_cli/roadmap/stage/stage_change.py]
    • Rejected: Validate every plan with no exemption. The recorded kind cases break the reply schema on purpose, so this assertion fails on the committed set.
    • Chosen: Fail only when no defect names the gate kind. This is the rule that stage_eval_cases.py states, and it keeps the kind cases in the set.
  • Which paths may a plan name?: A path that a group names in reads, changes, a task code span or verify is valid in five cases. It exists in the repository. facts.tracked holds it. A group lists it in creates. It is in case.change_files(). A missing_path defect names it. This is the rule of path_problems (src/devops_cli/roadmap/stage/stage_paths.py:663-704). It skips a path the tree holds, a path a group creates, and a path of the plan's own change folder. (best practice) [sources: src/devops_cli/roadmap/stage/stage_paths.py:663, src/devops_cli/roadmap/stage/stage_paths.py:675, src/devops_cli/roadmap/stage/stage_paths.py:681, src/devops_cli/roadmap/stage/stage_paths.py:692, src/devops_cli/roadmap/stage/stage_paths.py:696, src/devops_cli/roadmap/stage/stage_paths.py:293, tests/fixtures/roadmap_eval/stage/good-3410-the-stage-gate-proves-a-negative/plan.json:252]
    • Rejected: Accept only tracked paths and the change folder. The good-3410 plan lists tests/fixtures/roadmap_eval/stage/3372-the-stage-plan-of-a-module/plan.json and tests/roadmap/test_roadmap_stage_negative_search.py in a group's creates (plan.json:252-257). Neither is in facts.tracked nor in change_files(), so this check fails on the committed set.
    • Chosen: Accept existing, tracked, created, change-folder and missing paths. It is the rule of path_problems, and the committed set holds all five kinds of path.
  • How does the invariant detect a stale module path?: It requires each tests/ or src/ path in the plan.json and in facts.tracked of a good case to exist in the repository. A group's creates list is the only exception. A good case has no defect and every gate must accept it (src/devops_cli/roadmap/stage/stage_eval_cases.py:28). Its recorded plan and tree must name today's files. A reviewed case records the tree of its base commit and the review that judged it (stage_eval_cases.py:47). Its facts.tracked may name a pre-move path: 3372-the-stage-plan-of-a-module and both reviewed 3410 cases do. Rewriting them would change the recorded evidence. The rule flags the stage paths of good-3264 and good-3410 and the deleted snapshot path tests/ai/__snapshots__/test_ai_client_style_request.ambr in good-2491, good-2735 and good-2739. The change corrects all of them. (best practice) [sources: src/devops_cli/roadmap/stage/stage_eval_cases.py:28, src/devops_cli/roadmap/stage/stage_eval_cases.py:47, src/devops_cli/roadmap/stage/stage_eval_cases.py:55, tests/fixtures/roadmap_eval/stage/good-2491-a-refused-jwt-exchange-of-the/facts.json:55, tests/fixtures/roadmap_eval/stage/good-2735-the-subprocess-environment-guard-accepts-less/facts.json:54, tests/fixtures/roadmap_eval/stage/good-2739-the-subprocess-environment-guard-accepts-gh/facts.json:55, tests/fixtures/roadmap_eval/stage/3372-the-stage-plan-of-a-module/facts.json:3, tests/roadmap/stage/test_roadmap_stage_eval_cases.py:108]
    • Rejected: Check every case's facts.tracked. 3372 and both reviewed 3410 cases record the pre-move tree of their base commit. The check fails on the committed set unless their plans and reviews are rewritten.
    • Chosen: Check only the good cases. Only a good case must pass every gate today, and the stale paths that drive a shim sit in the good cases' plans and facts.
    • Rejected: Compare plan.json with facts.json only. Both files hold the same old path, so the check passes on good-3410 and detects nothing.
  • What size cap should the stage set keep?: 2500000 bytes, summed over the files of tests/fixtures/roadmap_eval/stage/. (best practice) [sources: src/devops_cli/roadmap/stage/stage_eval_cases.py:33, src/devops_cli/roadmap/stage/stage_eval_cases.py:58, tests/roadmap/stage/test_roadmap_stage_eval_cases.py:108, tests/invariants/test_roadmap_eval_fixtures.py:18]
    • Rejected: 1500000 bytes. The recorded about 1 MB and about 165 files of stage_eval_cases.py:58 describe the 37-case set of 2026-11-01 (:33-37). The set now holds 63 cases, so the recorded size scales to about 1.7 MB. 1.5 MB leaves too little room.
    • Chosen: 2500000 bytes. About 50% above the scaled 1.7 MB, it leaves room for the 63-case set and still catches a doubling.
    • Rejected: No cap. The issue asks for a size limit, and the implement invariant already holds one (tests/invariants/test_roadmap_eval_fixtures.py:18).
  • How does the acceptance criterion select the new stage tests?: Each new test name holds the word stage, as test_the_stage_.... -k stage matches a test name, so no marker is necessary. No name of the module holds the word stage today. (best practice) [sources: tests/invariants/test_roadmap_eval_fixtures.py:133, tests/invariants/test_roadmap_eval_fixtures.py:157, tests/invariants/test_roadmap_eval_fixtures.py:202, tests/invariants/test_roadmap_eval_fixtures.py:211]
    • Chosen: Put stage in each test name. -k stage matches a test name, and no name of the module holds the word stage today.
    • Rejected: Add a stage pytest marker. The criterion runs -k stage, which selects by name and not by marker.
  • Which open, maintained tool or library covers the need?: pytest==9.2.0 (pyproject.toml:109) and pydantic==2.14.4 (pyproject.toml:15) are open, maintained and already pinned. The project's CaseFacts and StageCase (src/devops_cli/roadmap/stage/stage_eval_cases.py:176,203) validate the fixtures. StageProposal (src/devops_cli/roadmap/stage/stage_change.py) validates the plans. tests/roadmap/stage/test_roadmap_stage_eval_cases.py:167 already asserts the plan-schema rule. They lack a repository-tree check, the group creates rule of path_problems (src/devops_cli/roadmap/stage/stage_paths.py:663) and a size cap. The invariant module adds about 40 lines for these. (best practice) [sources: pyproject.toml:15, pyproject.toml:109, src/devops_cli/roadmap/stage/stage_eval_cases.py:176, src/devops_cli/roadmap/stage/stage_eval_cases.py:203, src/devops_cli/roadmap/stage/stage_change.py, src/devops_cli/roadmap/stage/stage_paths.py:663, tests/roadmap/stage/test_roadmap_stage_eval_cases.py:167, tests/invariants/test_roadmap_eval_fixtures.py:211]
    • Chosen: Use pytest and the existing pydantic models. Both are open, maintained and already in the project.
    • Rejected: Build a new validator library. The existing models and the invariant module cover the need with about 40 lines.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/test
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 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: none. The title has the scope invariants, and .github/labels.yml declares no scope/invariants label. Add the label to the file to give the scope to this item.
    • Priority: P2-Medium. It prevents stale paths and invalid schema entries from reaching merge but does not fix a current breakage.
    • Value: Medium. It catches fixture drift and invalid entries before a full replay run, saving developer time.
    • Effort: Medium. The body estimates about 1.5 hours to add the test module and update fixture paths.
    • Related: test(roadmap): a golden set of plan cases and a scoring command for the stage job #3028, which asks for a different change. Both concern the stage golden set under tests/fixtures/roadmap_eval/stage/, but #3028 created the fixtures and eval command while the candidate adds invariant tests that validate those fixtures against schemas and check path existence.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 8, 2026
  5. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 3181b22 (see proposed design in issue body).

  6. devops-cli-service commented on Nov 10, 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-10. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    owner/service
    on Nov 18, 2026
  8. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Owner question: The inputs of the step of the task group "Correct the pre-move paths of the good-3264 plan" hold 65128 tokens, over the budget of 64000 tokens, also after the model split the groups once. Split the group or raise the budget of the step?

    Options

    1. Split the group: A person splits the group and runs the item again.
    2. Raise the budget: A person raises the budget of the step and runs the item again.

    Recommendation: Split the group: the plan check keeps the budget of the step.

    Evidence

  9. removed
    owner/service
    on Nov 18, 2026
  10. dan-petty commented on Nov 20, 2026

    @dan-petty
    OwnerAuthor

    Frozen on 2026-11-20. The stage, implement and fix-checks jobs grade under 60%, so the owner rule asks for a re-architecture before more fixes inside the current design (tracker #6519). This item is incremental work on those jobs, so its Dependencies section now names #6521 first. Stage and implement leave this item while #6521 is open. When the experiments of #6519 decide, a person closes #6521 (this item can then continue) or closes this item as not planned.

  11. dan-petty commented on Nov 24, 2026

    @dan-petty
    OwnerAuthor

    Split the group.

  12. added
    status/new
    and removed
    status/ready
    on Nov 26, 2026
  13. devops-cli-service commented on Nov 26, 2026

    @devops-cli-service
    Contributor

    Next step: the open items close, or a person replies in a comment or edits the body. See Dependencies in the section Proposed design of the body.

  14. added
    status/ready
    and removed
    status/new
    on Nov 30, 2026
  15. devops-cli-service commented on Nov 30, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

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-mediumsource/agentstatus/readytype/testvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions