Skip to content

fix(roadmap): a partial Jev reply stops the intake round #4450

Closed

Description

@dan-petty

Problem Description

A Jev reply that does not hold every asked answer stops the whole intake round. With roadmap.intake.jev: shadow, ADR 0019 rule 6 and the spec of #4395 say: "A Jev error or timeout SHALL change nothing". The code does not do this for a partial reply or for an answer of the wrong kind.

  • src/devops_cli/roadmap/intake/intake_jev_shadow.py, _duplicate: the guard _answer_of(response, f"duplicate_of_{each.number}", object) cannot fail, because isinstance(None, object) is True.
  • best_neighbour in src/devops_cli/roadmap/intake/intake_jev.py then reads response.answers[...] directly and reads .noul. A missing answer raises KeyError. An answer of a different kind raises AttributeError.
  • ShadowIntakeModel.observation catches only (*FAILED, ShadowError). _shadow_mark runs outside the try block of _Planner._propose in intake.py. Thus the error stops plan_intake, and the refine deferral plan stops too.

Mode on has the same gap. proposal_from reads response.answers[name] in _choice and _level, and JevIntakeModel.propose catches only (*FAILED, JevUnusableError). Mode on is not live now.

The trigger is possible. The TypeSafe provider (pydantic_ai/models/typesafe.py) passes on only the answers that the backend sends. The library's own agent path (pydantic_ai/models/decision.py, _fanned_in) raises UnexpectedModelBehavior for the same case.

Reproduction Steps

  1. Make a ProposalRequest with one nearest item (number 7).
  2. Give ShadowIntakeModel.observation a DecisionResponse that has priority, value and effort, and no duplicate_of_7.
  3. Run plan_intake with the Roadmap fake of tests/support/roadmap_intake.py, once with mode off and once with mode shadow, with the same partial reply.

Expected vs Actual Behavior

Expected: the candidate is placed as with mode off, no mark intake.jev_shadow is written, and each asked field counts jev_error in devops_cli_roadmap_intake_jev_fields_total. In mode on, the proposal falls back to the triage model and the fields count fallback.

Actual: step 2 raises KeyError: 'duplicate_of_7'. Step 3 gives off: ['place', 'place'] and shadow: plan_intake raised KeyError 'duplicate_of_1'.

Environment Diagnostics

devops-cli v0.110.0 (merge commit 6cf9251 of #4438). Python 3.14. The error does not depend on the host.

Logs, Traces, or Terminal Output

$ python -c "print(isinstance(None, object))"
True
observation: ESCAPED fail-open guard: KeyError 'duplicate_of_7'
off: ['place', 'place']
shadow: plan_intake raised KeyError 'duplicate_of_1'

Proposed fix

Fix the cause in one place. Add one checked accessor in intake_jev.py that reads an answer by name and kind, and raises UnexpectedModelBehavior when the answer is missing or of the wrong kind, as the library does in _fanned_in. UnexpectedModelBehavior is in FAILED, so both modes already catch it. Use it in _choice, _level and best_neighbour, so that both modes read answers the same way. Use _DUPLICATE_PREFIX from intake_jev.py and do not repeat the literal in the shadow module. Then remove the no-op guard in _duplicate.

Tests first:

  • Shadow: a Jev reply with no duplicate_of_<n> answer. The candidate is placed as with off, no mark is written, and each asked field counts jev_error.
  • Shadow: a duplicate_of_<n> answer of a wrong kind (for example a ChoiceAnswer) gives the same result.
  • On: a reply with no priority answer falls back to the triage model, and each field counts fallback.

Fix this before a person adds jev: shadow to the live ConfigMap.

Pre-Submission Checklist

  • No sensitive credentials, private keys or internal tokens are in this report.
  • I searched the existing issues and pull requests. No duplicate exists.

Source: #4438

Proposed design

Problem statement

A partial or wrong-kind Jev reply does not stop the intake round. The decision model raises UnexpectedModelBehavior before intake reads the reply, and FAILED holds that error, so both modes fail open. The shadow module still holds a guard that checks nothing: _answer_of(response, f"duplicate_of_{each.number}", object) cannot fail, because isinstance(None, object) is true. Its docstring also says that a missing answer raises ShadowError, but only the choice and score answers are checked. The change removes the dead guard and makes the docstring true.

Acceptance criteria

Requirement: Shadow duplicate check

The shadow duplicate check SHALL read the nearest item only through best_neighbour from intake_jev.py, and SHALL NOT hold a duplicate_of_ literal or an answer guard of kind object.

Scenario: Shadow duplicate answer name

  • WHEN A test reads _duplicate in intake_jev_shadow.py.
  • THEN The function calls best_neighbour, holds no duplicate_of_ literal, and holds no _answer_of call whose kind is object.

Requirement: Shadow answer error

observation_of SHALL raise ShadowError when a choice or score answer is missing or has a wrong kind.

Scenario: Missing priority answer

  • WHEN observation_of receives a response with no priority answer.
  • THEN observation_of raises ShadowError.

Requirement: Shadow docstring

The docstring of observation_of SHALL name ShadowError as the error of a missing or wrong-kind choice or score answer, and SHALL state that the decision model refuses a partial reply.

Scenario: Docstring names the error and the model check

  • WHEN A test reads the docstring of observation_of.
  • THEN The docstring names ShadowError and does not say that a missing duplicate answer raises it.

Existing Tool Considered

No alternatives check has run. pydantic-ai covers the need: SystemOneModel.decide raises UnexpectedModelBehavior when the names or the kinds of the answers differ from the questions. FAILED holds that error, so both intake modes fail open. The library lacks a public checked accessor for a DecisionResponse. The change builds no new code: it removes a dead guard of about 3 lines and corrects one docstring, about 10 minutes of elapsed time and no token cost to keep.

Key questions

  • Does this item add the checked answer accessor, or remove the dead guard?: Remove the dead guard. The decision model closes the path, so the item adds no accessor. The change removes the no-op loop in _duplicate and corrects the docstring of observation_of. (best practice) [sources: src/devops_cli/roadmap/intake/intake_jev_shadow.py, src/devops_cli/roadmap/intake/intake_jev.py, src/devops_cli/ai/pydantic_ai_bridge.py]
    • Chosen: Remove the dead guard and correct the docstring. The library refuses a partial reply before intake reads it, so an accessor would serve a closed path (AGENTS.md rule 2). The dead guard checks nothing and the docstring overstates the check.
    • Rejected: Add the checked accessor as the body proposes. No fail-to-pass test is possible. The decision model raises UnexpectedModelBehavior first, and a scratch run with the Jev edge fake placed both candidates in all four cases.
    • Rejected: Close the item as not planned. The dead guard and the wrong docstring remain. A small cleanup delivers both.
  • What does the Jev decision model do with a reply that misses an answer or gives an answer of a wrong kind?: SystemOneModel.decide raises UnexpectedModelBehavior when the answer names differ from the question names, or when an answer is not of the kind of its question. The project builds SystemOneModel for each Jev name and never TypeSafeModel. FAILED holds UnexpectedModelBehavior, so both intake modes catch it. [sources: src/devops_cli/ai/pydantic_ai_bridge.py, src/devops_cli/ai/jev.py, src/devops_cli/roadmap/intake/intake_jev.py]
  • Which error does shadow mode raise for a missing or wrong-kind choice or score answer, and where is it caught?: ShadowError. ShadowIntakeModel.observation catches (*FAILED, ShadowError), logs one warning, and counts jev_error for each asked field. [sources: src/devops_cli/roadmap/intake/intake_jev_shadow.py]
  • What does mode on do with a partial reply?: JevIntakeModel.propose catches (*FAILED, JevUnusableError) and falls back to the triage model. It counts fallback for each asked field. [sources: src/devops_cli/roadmap/intake/intake_jev.py]
  • Where must the name of a duplicate answer come from?: intake_jev.py. _DUPLICATE_PREFIX builds the name in _questions and in best_neighbour, and the shadow module repeats no literal. (best practice) [sources: src/devops_cli/roadmap/intake/intake_jev.py, src/devops_cli/roadmap/intake/intake_jev_shadow.py]
    • Chosen: Use _DUPLICATE_PREFIX in intake_jev.py only. One definition serves both modes. The removal of the shadow loop removes the last literal.
    • Rejected: Repeat duplicate_of_ in the shadow module. It keeps two sources for the same name and keeps the dead guard.
    • Rejected: Build the name in a new shared module. It adds a module for one constant.
  • Does this item block the setting roadmap.intake.jev: shadow in the live ConfigMap?: No. A person can set jev: shadow now. A partial or wrong-kind reply changes nothing, because the decision model raises UnexpectedModelBehavior and the shadow mode counts jev_error. (best practice) [sources: src/devops_cli/roadmap/intake/intake_jev_shadow.py, src/devops_cli/roadmap/intake/intake_jev.py]
    • Chosen: Set jev: shadow now. Both modes already fail open on a partial or wrong-kind reply.
    • Rejected: Wait for the checked accessor. The library closes the path, so the accessor is not needed.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-11: in-use.
The item already names this tool.
Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai), MIT, last activity 2026-11-11, maintained.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 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/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P1-High. A KeyError stops the entire intake round and must be fixed before shadow mode goes live.
    • Value: Medium. Prevents a crash that would block all intake when shadow mode is enabled.
    • Effort: Low. Add one accessor, use it in three call sites, remove one no-op guard, and add three tests.
    • Related: feat(roadmap): a shadow mode for the Jev intake labels #4395, which asks for a different change. Both concern the Jev shadow intake mode, but #4395 adds the mode while this candidate fixes a crash in its error handling.
  3. added
    priority/p1-high
    owner/agent
    on Nov 11, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 11, 2026
  5. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

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

  6. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    The premise does not hold on the real model

    A partial Jev reply, or an answer of the wrong kind, does not stop the intake round. The library refuses such a reply before intake reads it. This item does not block roadmap.intake.jev: shadow in the live ConfigMap.

    Evidence

    1. Each Jev model of the project is a pydantic_ai.models.system_one.SystemOneModel. create_jev_model calls resolve_pydantic_ai_model, and _jev_decision_model in src/devops_cli/ai/pydantic_ai_bridge.py builds the model for each name that _is_jev_decision_name accepts: typesafe:…, system-one:…, and a gateway route of typesafe/jev-…. No path of the project builds pydantic_ai.models.typesafe.TypeSafeModel, the provider that the issue names.
    2. SystemOneModel.decide (pydantic-ai-slim 2.59.0, the locked version) raises UnexpectedModelBehavior when the names of the answers are not the names of the questions (parsed.answers.keys() != questions.keys()). It raises the same error when an answer is not of the kind of its question (isinstance(answer, NoulAnswer) for a NoulQuestion, and the same check for a choice and a score). UnexpectedModelBehavior is in FAILED, so ShadowIntakeModel.observation and JevIntakeModel.propose catch it.
    3. A scratch test on main (6cf78e7) with the Jev edge fake tests/support/fakes/jev.py, which is a transport under the real SystemOneModel:
      • mode shadow: the fake drops each duplicate_of_<n> answer, or sends a choice answer in its place;
      • mode on: the fake drops the priority answer, or sends an answer of the wrong kind.
        In all four runs, plan_intake places both candidates ([place, place]). Result: 4 passed.
    4. The reproduction in the issue gives ShadowIntakeModel.observation a DecisionResponse that the test makes by hand. That skips the check of the library, so it does not show a fault on the real path.

    Thus no fail-to-pass test with the Jev edge fake is possible. The checked accessor would be code for a path that the library already closes (AGENTS.md rule 2), so I did not build it.

    What remains

    Proposal: close this item as not planned, or re-scope it to the removal of the no-op loop.

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

    @devops-cli-service
    Contributor

    Status set to Ready at 2f6114f (see proposed design in issue body).

  10. devops-cli-service commented on Nov 11, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: pydantic-ai is the library the project already uses for the Jev decision step, and its decision model refuses a reply whose answers are missing or of the wrong kind by raising UnexpectedModelBehavior before intake reads the response; that error sits in the project's FAILED tuple, so shadow mode counts jev_error and mode on falls back, which is exactly the fail-open behaviour the issue asks for. The only gap is that the library exposes no public checked accessor for a DecisionResponse, so the dead object-kind guard and the overstated docstring in the shadow module stay as a small cleanup rather than a bug fix.

    The item already names this tool.

    Tool: pydantic/pydantic-ai (https://github.com/pydantic/pydantic-ai)

    • License: MIT
    • Last activity: 2026-11-11
    • Maintained: yes

    Covers:

    • Refuses a partial reply: the decision model raises UnexpectedModelBehavior when the answer names differ from the question names
    • Refuses an answer of the wrong kind (choice, score, Noul) with the same UnexpectedModelBehavior
    • Raises the error before the intake code reads the response, so no KeyError or AttributeError reaches plan_intake
    • The raised error is in FAILED, so ShadowIntakeModel.observation counts jev_error and JevIntakeModel.propose falls back to the triage model

    Lacks:

    • No public checked accessor for a DecisionResponse, so call sites cannot read an answer by name and kind through the library
    • A DecisionResponse built by hand in a test skips the model check, which is what makes the issue's reproduction raise KeyError
    • The shadow module keeps a no-op guard of kind object and a docstring that overstates what raises ShadowError

    Tools considered:

    Searches run:

    • pydantic-ai SystemOneModel DecisionResponse UnexpectedModelBehavior, results: 5
    • pydantic-ai decision model answers of wrong kind raises error, results: 5
    • "pydantic-ai" documentation models decision system one, results: 5

    Sources:

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

  11. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 14, 2026
  12. removed
    status/in-review
    owner/agent
    on Nov 14, 2026
  13. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 21:08 UTC

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/lowpriority/p1-highscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions