Skip to content

feat(roadmap): implement writes a typed result and hands off its log #4071

Closed

Description

@dan-petty

Problem

Two faults in what a runner Job leaves for the next Job and for the Service.

  1. The Job does not tell the Service how its run ended.
    • _Ended (implement_run.py) has the values ready, stopped, yielded and returned. The Job does not write it.
    • The Service guesses from the item (_settles_as_stop in implement_submit.py).
    • A Job that leaves the item out (a claim by a person or an agent) exits 0.
    • A Job that the kernel killed leaves the item In Progress. The Service then reads the log of the Job and picks a class with classify_failure from the text.
    • A stop that the runner wrote has its class on record (implement.failure). A Job that wrote nothing has only its log.
  2. The failed check log and the files of a conflict are written at a stop (implement.check_log, implement.conflict). They are only cleared: stop_clear.py and _start (target.retry) set them to None. The first step of the next Job never reads them. So it starts without the log that the stop recorded.

Some keys have no reader in code: implement.group, implement.sha and implement.wip. The spec roadmap-implement-job (line 231) keeps them as a record for a person to read.

Expected

This issue is blocked by #3677. #3677 is open and has no pull request. It changes _start and _groups. Start this issue after #3677 and after the issue #4070.

Typed result.

  • Add the key implement.result to ImplementRecordKey. The values are those of _Ended: ready, stopped, yielded, returned.
  • The runner writes it as the last mark of each item run, in the marks write of the end.
  • The Service reads it in _report. A Job with the result yielded or returned is not a stop.
  • A Job with no result (killed, evicted or gone) uses the log and classify_failure, as today. The class of a stop that the runner wrote stays in implement.failure.
  • fix(roadmap): read the pod status to find an out-of-memory kill #3727 stays the owner of the pod exit status for the class oom. This change reads the result only.

Hand-off.

  • _start reads implement.check_log and implement.conflict before it clears them (target.retry).
  • It gives both to the first step of the run. Use a new input of run_step and a new section in the prompt roadmap_implement_step.md.
  • stop_clear.py clears the two keys only after the new Job writes its first mark.

Keys with no reader. Add a test that lists the members of ImplementRecordKey. For each member, the test names the function that reads it. Or it lists the member as "record for a person" with the name of the spec line that requires it. A new key with neither fails the test. Do not remove group, sha and wip.

Update docs/ROADMAP_WORKFLOW.md and the spec roadmap-implement-job for the new key.

Acceptance criteria

  • uv run pytest tests/roadmap/implement/test_roadmap_implement_typed_result.py -k typed_result - the runner writes implement.result at the end of each run. The Service reads it. A Job with result yielded makes no stop.
  • uv run pytest tests/roadmap/implement/test_roadmap_implement_typed_result.py -k no_result - a Job with no result still gets a class from its log, as before.
  • uv run pytest tests/roadmap/implement/test_roadmap_implement_typed_result.py -k handoff - the first step of a retry gets the check log and the conflict files of the earlier stop. The keys are cleared only after the first mark of the new Job.
  • uv run pytest tests/roadmap/implement/test_roadmap_implement_record_readers.py - every ImplementRecordKey member has a named reader or a named spec line. A test key with neither fails.

Every command above fails on the unchanged code. The pull request cites the fail-to-pass run (devops ci fail-to-pass --base <ref>).

Feasibility

I read these files at origin/main:

  • implement_run.py: _Ended, _implement_item, _start, stop.
  • implement_submit.py: _settles_as_stop, _recorded_failure, _failure_of, _report.
  • stop_clear.py.
  • stores/store.py: ImplementRecordKey.
  • The spec roadmap-implement-job (lines 231 and 975).

I did not run the code.

I checked that #3677 is open and that no open pull request holds a branch for it.

An earlier plan wanted a typed StepName for the implement stop. That is dropped. implement.stopped holds the step label that stop_clear.py matches. A change there is a larger rewrite with no fault that needs it.

Existing tool considered

_Ended, implement.failure (#3065) and the record marks. No library is needed.

Cost

Build: about 80k tokens and 4 h (one key, one reader, one hand-off input, the test of keys). Keep: about 3k tokens per quarter. Fix: about 20k tokens and 1.5 h.

Related

Part of #3027. Blocked by #3677 (must merge first). #3727 (pod exit status for oom), #3105, #1535, #3997. Order: after the issue #4070.

Proposed design

Problem statement

The implement Job does not tell the Service how its run ended. The Service guesses the outcome from the item and from the text of the Job log. A run that a claim ended, or that a false premise returned, can then look like a stop. A retry also starts without the check log and the conflict files that its stop recorded. This change writes a typed result into the job record, reads it in the Service, and hands the recorded log and files to the first step of the new run.

Acceptance criteria

Requirement: The result is the last mark of a run

The runner SHALL write implement.result in the record write that ends each item run, with the value of _Ended.

Scenario: A yielded run writes its result

  • WHEN A run ends because an agent or a person claimed the item
  • THEN The job record holds implement.result equal to yielded.

Requirement: A new run clears the earlier result

The runner MUST clear implement.result in the first record write of a new run.

Scenario: A stale result does not survive the start

  • WHEN A run starts on an item whose record holds implement.result equal to ready
  • THEN The first record write of the run holds no implement.result.

Requirement: The Service reads the typed result

The Service SHALL read implement.result in _report and SHALL make no stop for the values ready, yielded and returned.

Scenario: A yielded result makes no stop

  • WHEN The record holds implement.result equal to yielded and the item is In Progress
  • THEN _report records no stop for the item.

Requirement: A Job with no result uses its log

The Service MUST take the class of a Job with no implement.result from the tail of its log with classify_failure.

Scenario: A killed Job keeps the class of its log

  • WHEN A Job ends with no implement.result and its log holds an out-of-memory line
  • THEN The Service records the class oom.

Requirement: Hand-off of the recorded stop

_start SHALL read implement.check_log and implement.conflict before its record write and SHALL give both to the first step of the run.

Scenario: The first step of a retry reads the earlier stop

  • WHEN An item with a recorded check log and recorded conflict files starts a new run
  • THEN The first step receives both values in its input.

Requirement: Clear of the hand-off keys

The runner MUST clear implement.check_log and implement.conflict only in the first record write of the new run.

Scenario: The stop clear keeps the hand-off keys

  • WHEN stop_clear.py clears the stop of an item
  • THEN The record still holds implement.check_log and implement.conflict.

Requirement: The prompt holds the hand-off section

The prompt roadmap_implement_step.md SHALL hold a section that states what the hand-off input contains.

Scenario: The prompt names the hand-off input

  • WHEN A test reads the prompt of the step
  • THEN The prompt holds the section for the check log and the conflict files.

Requirement: A reader for every record key

A test MUST name a reader or a requirement of the spec for every member of ImplementRecordKey.

Scenario: A new key with no reader fails the test

  • WHEN The table of the test holds a key with no reader and no spec requirement
  • THEN The test fails.

Requirement: The documents name the new key

docs/ROADMAP_WORKFLOW.md and the spec roadmap-implement-job SHALL name implement.result.

Scenario: The record-key table names the new key

  • WHEN A test reads docs/ROADMAP_WORKFLOW.md and the spec roadmap-implement-job
  • THEN Both name implement.result in the record keys of the implement job.

Existing Tool Considered

No alternatives check has run. No open library covers the need. The change extends the record marks and the stop path that the repository already holds, in src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/implement/implement_submit.py and src/devops_cli/roadmap/stores/store.py. The written cost to build it is about 80k tokens and 4 hours. The cost to keep it is about 3k tokens per quarter. The cost to fix it is about 20k tokens and 1.5 hours.

Key questions

  • Which record key holds the result of an item run, and which values does it take?: Add implement.result to ImplementRecordKey. It takes the four values of _Ended: ready, stopped, yielded and returned. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/roadmap/stores/store.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: A new key implement.result with the _Ended values. The four values already exist in _Ended, and a new key holds them without a change of the stop path.
    • Rejected: A second value on implement.stopped. implement.stopped holds the step label that the stop path reads and the continue rule compares with job, so a result value there breaks the clear.
    • Rejected: A boolean key implement.finished. It loses the four values, so the Service cannot tell a yield from a return.
  • In which record write does the runner write each of the four values?: _ready writes ready, stop writes stopped, _return_to_new writes returned, and yield_to writes yielded in a marks-only write. Each is the last record write of its run, and the marks-only write changes no field and no owner. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, openspec/specs/roadmap-implement-job/spec.md]
    • Chosen: One write site for each of the four values. Each value ends a different path. yield_to and _return_to_new have no record write of the end today, so the change adds one to yield_to.
    • Rejected: One write in _implement_item after the run returns. The run raises for two of the four paths, so this option needs a second write path and a new return value.
  • Does the runner clear implement.result when a run starts?: Yes. The first record write of a run clears implement.result. A killed Job then leaves no result, and the Service uses the log. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, openspec/changes/archive/2026-11-03-3032-a-trace-of-every-run-kept/proposal.md]
    • Chosen: Clear at the start and write at the end. It is the pattern of implement.trace, and a killed Job cannot leave the result of an earlier run.
    • Rejected: Write at the end only. A killed Job then keeps the result of an earlier run, and the Service reads it as the result of this run.
  • Which results make no stop for the Service?: The values ready, yielded and returned make no stop. A record with no result, or with stopped, keeps the rule of the item. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: Read the result first and keep _settles_as_stop as the fallback. A Job that the kernel killed writes no result, so the item and the log are the only evidence left for it.
    • Rejected: Replace _settles_as_stop with the result alone. A killed Job writes no result, so the Service would never stop the item.
  • What does the Service do when a Job writes no result?: It reads the tail of the Job log and takes the class with classify_failure. A class that the runner wrote stays in implement.failure. fix(roadmap): read the pod status to find an out-of-memory kill #3727 owns the pod exit status. (best practice) [sources: src/devops_cli/roadmap/implement/implement_submit.py, docs/ROADMAP_WORKFLOW.md]
  • How does the first step of a new run get the check log and the conflict files of the earlier stop?: _start reads both keys before its record write. It passes both to run_step as a new optional input. A new section of roadmap_implement_step.md states what the input holds. (best practice) [sources: src/devops_cli/roadmap/implement/implement_run.py, src/devops_cli/ai/tasks/roadmap_implement_step.md]
    • Chosen: A new optional input of run_step. The inputs of a step are fixed, and a new input is the path that the step already takes for its context.
    • Rejected: A file in the checkout. The step refuses a stray file at the root, and the file adds a path that the plan does not name.
    • Rejected: A read of the issue in the step. The step writes nothing to GitHub and reads no issue.
  • When does a new run clear implement.check_log and implement.conflict?: stop_clear.py leaves both keys. The first record write of the new run clears both, after _start read them. (best practice) [sources: src/devops_cli/roadmap/stop_clear.py, src/devops_cli/roadmap/implement/implement_run.py, docs/ROADMAP_WORKFLOW.md]
    • Chosen: Clear both in the first record write of the new run. The first step reads the keys before the clear, so no run starts without the log that its stop recorded.
    • Rejected: Clear both with the stop, as today. The new run then starts without the log, which is the fault of this item.
    • Rejected: Clear both when the first group passes. A stop before that point loses the log again.
  • How does the test keep a reader or a spec requirement for every member of ImplementRecordKey?: The test holds one row for each member. A row names the function that reads it, or the requirement of roadmap-implement-job that requires it as a record for a person. A new member with neither fails the test. (best practice) [sources: src/devops_cli/roadmap/stores/store.py, openspec/specs/roadmap-implement-job/spec.md]
    • Chosen: A table in the test, one row for each member. The table shows a missing reader at the row of the new member, and it names a spec requirement where no code reads the key.
    • Rejected: A comment on each member of the enum. A comment is no test: nothing fails when a new member has no reader.
    • Rejected: Remove the members with no reader. The spec keeps them as a record for a person, and the body forbids their removal.
  • Does this change add members to StepName for the implement stop?: No. implement.stopped keeps the step label that the stop path reads and that the continue rule compares with job. StepName keeps its two members, plan and apply. (best practice) [sources: src/devops_cli/roadmap/failure.py, src/devops_cli/roadmap/stop_clear.py, openspec/changes/archive/2026-11-08-4056-record-the-failure-class-and-step/design.md]
    • Chosen: Keep the step label as a string. A typed step changes the value that stop_clear.py compares with job, and no fault in this item needs it.
    • Rejected: Add the implement steps to StepName. It changes the stop path and the clear, which this item does not fix.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

#3677, #4070

Activity

  1. added
    source/agent
    type/feature
    scope/roadmap
    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/feature. The feat prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. Blocked by open issues and improves reliability without breaking existing behaviour.
    • Value: Medium. Reduces Service guessing and ensures the next Job receives the prior stop log, but a fallback path exists.
    • Effort: Medium. Touches runner, Service, stop_clear, tests, and docs across several files.
    • Related: feat(roadmap): implement keeps phase marks and the spend of a killed Job #4070, which asks for a different change. Both modify the implement Job record and _start, but #4070 adds phase marks and spend tracking while the candidate adds the typed result key and log hand-off.
  3. added
    priority/p2-medium
    on Nov 7, 2026
  4. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at c8990be while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/implement/implement_run.py.

  5. devops-cli-service commented on Nov 8, 2026

    @devops-cli-service
    Contributor

    Refine cannot set this item to Ready at c20f73d while the items below stay open. The next refine round looks at the item again when they close, or when a person replies in a comment or edits the body.

    The next refine round also looks at the item again when a commit on the default branch changes one of these files: src/devops_cli/roadmap/implement/implement_run.py.

  6. added
    owner/agent
    status/in-review
    and removed
    status/new
    on Nov 9, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 9, 2026
  8. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-09 10:07 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/mediumpriority/p2-mediumscope/roadmapsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions