Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/ERRORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Each exception class declares its `error_code` and `exit_code`. A command that a
| `RoadmapPlanRewriteError` | `ROADMAP_PLAN_REWRITE_REFUSED` | `1` | Roadmap | Raised when `devops roadmap plan-recheck --confirm` refuses to write a rewritten plan (#3556). |
| `RoadmapRefineError` | `ROADMAP_REFINE_FAILED` | `1` | Roadmap | Raised after a refine run in which the model call failed for one or more items. |
| `RoadmapRunError` | `DEVOPS_CLI_ERROR` | `1` | Roadmap | Raised when one or more roadmap jobs fail during execution. |
| `RoadmapStageDegenerateError` | `ROADMAP_STAGE_FAILED` | `1` | Roadmap | Raised for an item whose plan reply holds a placeholder in every text of the plan (#4204). |
| `RoadmapStageError` | `ROADMAP_STAGE_FAILED` | `1` | Roadmap | Raised after a stage run in which one or more items failed (#2654). |
| `RunIndexNotConfiguredError` | `DEVOPS_CLI_ERROR` | `1` | Devops_cli.ai.run_store | No shared run index is configured. |
| `SSHRegistrationError` | `GITHUB_OPERATION_FAILED` | `1` | Devops_cli.github.ssh | Raised when SSH/signing key registration on GitHub fails. |
Expand Down
2 changes: 1 addition & 1 deletion docs/TELEMETRY.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ writes by name.
| `devops_cli_roadmap_alternatives_searches` | Histogram | `1` | Web searches that a provider answered for one alternatives check, by verdict. One observation for each check that the alternatives job writes. A search that no provider answered does not count. A check that the job skips for its item class runs no search and observes 0. |
| `devops_cli_roadmap_page_fetches_total` | Counter | `1` | Calls of the tool fetch_page in refine's investigation and in the alternatives check, by toolset (refine or alternatives) and result: ok for a page whose text the tool returned, refused for a URL that the tool refused before any request (not https, not named by a search result or by the item text, or not on a public host), limit for a call over the limit of fetches for one item, and error for a fetch that failed. The fetches that reach the Crawl4AI service also count in devops_cli_crawl4ai_fetches_total. |
| `devops_cli_roadmap_stage_plan_record_total` | Counter | `1` | Uses of the plan file of the stage job, by result: hit for a plan that the job read from the file and so sent the planner no request, miss for an item with no file of its key, and written for a plan that the job wrote to the file. A miss that plans adds one to miss and one to written. The hit rate is hit divided by the sum of hit and miss. |
| `devops_cli_roadmap_stage_total` | Counter | `1` | Items that a stage round handled, one count for each item, by repository and result: staged for an item written as a branch and a draft pull request, needs_split for an item stopped on a task group over the budget, failed for an item that failed in the plan or in the writes, and skipped for an item the job left out with a reason. A plan with no write counts nothing. |
| `devops_cli_roadmap_stage_total` | Counter | `1` | Items that a stage round handled, one count for each item, by repository and result: staged for an item written as a branch and a draft pull request, needs_split for an item stopped on a task group over the budget, failed for an item that failed in the plan or in the writes, degenerate for an item whose plan reply was a placeholder in every text (the job sent no second request), and skipped for an item the job left out with a reason. A plan with no write counts nothing. |
| `devops_cli_roadmap_tool_calls_total` | Counter | `1` | Tool calls of the roadmap planner and verifier, by tool, row, toolset and outcome. The outcome ok is a call that gave its result. The outcome empty is a call that ran and found nothing, such as a search with no match. The outcome error is a call that could not run or got no answer. The row is the job row of the run: stage for the planner, stage_verify for the verifier. Each run adds 0 for every tool of its toolset before its first model request. So a tool that no run calls keeps a series. |
| `devops_cli_roadmap_tool_answer_chars` | Histogram | `{char}` | Characters in the answer of each tool call of the roadmap planner and verifier, after the cut of the tool, by tool, row and toolset. The text of a refusal counts. A call that got no answer adds no observation. |
| `devops_cli_roadmap_tool_calls_per_run` | Histogram | `{call}` | Tool calls of each run of the roadmap planner and verifier, by row and toolset. A run that raised because a model call failed adds no observation. |
Expand Down
2 changes: 1 addition & 1 deletion k8s/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
schema: spec-driven
created: 2026-11-09
skip_specs: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Design

## Decisions

- **Beside the plan file, one refused file for each item.** The file `<n>.refused.json` is in the folder of `<n>.json` and uses the key of the plan input. Both files are deleted by the same step (`_Writer` staging), so there is one cleanup path. The file holds the replies of the last failed plan only: a new failed plan replaces it, so the count of files is the count of failed items, and each file has a size bound.
- **No age limit.** The plan file has none (see Feasibility), and a second rule would be a second retention rule. A file stays until the item is staged. It is small, and a person can delete it.
- **Degenerate means every text.** The check reads `why`, `existing_tool`, each line of `feasibility` and the tasks `test`, `implementation` and `documentation` of every group, with `is_placeholder`. A reply with one real text goes back once, as before, because the model can mend it. The check runs before the gates, so a degenerate reply costs no gate run.
- **A subclass for the stop.** `RoadmapStageDegenerateError` is a `RoadmapStageError`, so `failure_class_of` gives it `plan_defect` and the retry wait of 6 hours stays. The metric and the eval tell it from `failed` by the type, and `StageFailure.degenerate` carries that fact to `stage_results`. A new `FailureClass` would change the table of actions and the wait, and the issue asks for neither.
- **Log fields from the run trace.** The log line reads the last `RunTrace` of the toolbox client, taken after the item was asked (`floor`), so a trace of an earlier item is no source. A plan with no toolbox run (a kept plan, a plain client) logs `request=1 input_tokens=0 tools_offered=False`.
- **Size bound.** A reply over `CONST_ROADMAP_STAGE_REFUSED_REPLY_MAX_BYTES` (131,072) is dropped and its size stays in `reply_bytes`. A problem is masked with `mask_secrets` and cut at `CONST_ROADMAP_STAGE_REFUSED_PROBLEM_MAX_CHARS` (8,000).

## Rejected alternatives

- **Log the whole reply.** The log has no place for a reply of 100 KB, and it can hold text of the issue. The file is the record. Rejected.
- **A 7-day cleanup of the file.** The plan file has no such cleanup, so the premise of #4204 is false. A new cleanup is new code for a file that is bounded and replaced. Rejected.
- **A new failure class `degenerate`.** It would change `ACTION_BY_CLASS`, `RETRY_AFTER` and every consumer of the class, for a fact that one boolean carries. Rejected.
- **Keep the refused replies of the verify rounds too.** `_repaired` raises its own error, and the issue names the first plan run. It can follow if the data asks for it. Rejected for now.
- **Count the degenerate reply as `failed`.** The metric would hide the placeholder rate, and the eval would have no count. Rejected.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Proposal: #4204

## Why

The stage job of the roadmap Service staged no item on 2026-11-09 (#4204). The live run of item #4062 needed the refused reply and the first problem text, and the job kept neither: it kept only the last problem, and a plan that fails the gates leaves no plan file. A reply that holds only placeholders (`x`, `placeholder`) in every text also used the second request, and the second reply was the same. The main causes were found and fixed in other pull requests: the gateway answered through a fallback model (#4216), the reference reason could be null (#4215), the reply was cut at 4096 output tokens (#4224), tool calls were joined (#4243), and the window estimate ended the tools too early (#4238). What remains of #4204 is the record of a refused reply and the early stop.

## What Changes

- `_gated` in `src/devops_cli/roadmap/stage/stage.py` logs one line `stage reply refused: item=#<n> request=<n> input_tokens=<n> tools_offered=<bool> result=<refused|degenerate>` for each refused reply. `request` is the number of the last request of the plan run, `input_tokens` is its input, and `tools_offered` says whether it offered a function tool. `RunTrace` gets the field `last_input_tokens`.
- A failed item keeps its refused replies and their problems in `roadmap/stage/<owner>/<repo>/<n>.refused.json`, beside the plan file, under the key of the plan input. The staging of the item deletes the file, and a new failed plan replaces it. A reply over 128 KiB is dropped and only its size stays, and a problem is cut at 8,000 characters and masked for secrets. The file is written with the same atomic writer as the plan file.
- A first or second reply with a placeholder (`is_placeholder` of the pull request form) in `why`, `existing_tool`, each line of `feasibility` and each task of each group ends the item at once with the new `RoadmapStageDegenerateError`, a subclass of `RoadmapStageError`. The job sends no second request. `StageResult` gets the value `degenerate`, so `devops_cli_roadmap_stage_total{result="degenerate"}` counts the item and `failed` keeps the other failures.
- `devops roadmap eval stage` shows `degenerate N` in the line of how the cases ended, through the new `Outcome.DEGENERATE`.
- The change adds requirements to `roadmap-stage` and `roadmap-stage-eval`, because the log line, the file, the metric result and the report are observable.
- It fits one pull request.

## Criteria of #4204

- 1 (log fields), 2 (kept replies) and 3 (`degenerate` result and eval count) are delivered here. Criterion 2 asks for a 7-day age limit "as the gated plan has". The premise is false: the plan file has no age limit. It goes when the item is staged or its input changes. The refused file follows the same rule, and it has a size bound.
- 4 (`staged` above 0 in each 24 hours) and 5 (name and remove the cause) are results of the fixes of #4215, #4216, #4224, #4238 and #4243, and #4205 holds them. They need Service data, not code.
- A schema violation (`StructuredOutputValidationError`) is not a refused reply: the reply never reaches `_gated`. Its failure line holds a count of violations. The text of the violations in the log is out of this change.

## Capabilities

### New Capabilities

None.

### Modified Capabilities

- `roadmap-stage`: adds the requirements `A refused reply is logged`, `A failed item keeps its refused replies` and `A reply of placeholders ends the item`.
- `roadmap-stage-eval`: adds the requirement `The live report counts the degenerate cases`.

## Impact

- Code: `src/devops_cli/roadmap/stage/stage.py`, `src/devops_cli/roadmap/stage/stage_plan_record.py`, `src/devops_cli/roadmap/stage/stage_eval_run.py`, `src/devops_cli/roadmap/agent_run.py`, `src/devops_cli/exceptions/roadmap.py`, `src/devops_cli/config/constants.py`, `src/devops_cli/lang/en/messages.py`, `src/devops_cli/telemetry/instruments.py`.
- Tests: `tests/roadmap/stage/test_roadmap_stage_refused_reply.py`, `tests/roadmap/stage/test_roadmap_stage_eval_run.py`.
- Documents: `k8s/README.md` (roadmap Service item 15), `docs/TELEMETRY.md` (generated).
- No new setting, so no ConfigMap change and no rollout order. The two constants are code constants.
- Metric: the label `result` of `devops_cli_roadmap_stage_total` gets one more value, `degenerate`. The series count grows by 1 for each repository (1 repository today, so 1 series). No label is added.
- The refused file is on the data volume of the Service, at most about 2 x (128 KiB + 8,000 characters) for each item that failed in the plan, and it is deleted when the item is staged.

## Feasibility

- The premise "the job keeps only the last problem": `_gated` in `stage.py` held `outcome.problem` of the second `_settle` only, and `_keep` wrote a plan file only for a plan that passed. Read in the code at `origin/main` 750cf789.
- The premise "the same placeholder reply returns on the second request": issue #4204 gives the log of 2026-11-08 and the sample of #3566. This change does not prove it; it removes the second request only for a reply that is a placeholder in every text, which the gates refuse in any case (`content`, `form`, `paths`, `spec-delta`). A reply that is only in part a placeholder still goes back once.
- The premise "the plan file has a 7-day age limit": false. `stage_plan_record.py` deletes a plan file when the item is staged or when the key changes (`delete_plan_record` in `_kept` and in the writer). No code ages a file.
- A reply with a placeholder `summary` fails the schema (`summary_problem`), so it never reaches the check. A placeholder in `why`, `existing_tool`, `feasibility` and the tasks passes the schema, as the log of #4204 shows.
- The usage of the last request: pydantic-ai gives `ModelResponse.usage.input_tokens` for each reply, and `RunTrace._add_reply` already sums it. `last_input_tokens` keeps the value of the last reply.
- First check, which fails on origin/main: `uv run devops ci fail-to-pass --base origin/main`. Second check: `uv run devops ci test tests/roadmap/stage/test_roadmap_stage_refused_reply.py tests/roadmap/stage/test_roadmap_stage_eval_run.py`.

## Existing Tool Considered

- pydantic-ai output validators with `ModelRetry` retry an invalid reply. They neither record the refused reply nor tell a placeholder reply from another one, and the stage job already sets the retries of the schema (`_REPLY_RETURNS`).
- `is_placeholder` of `roadmap/pull_form.py` is the placeholder rule of the content gate, and this change reuses it. No second word list.
- `write_json_file` with `atomic=True` and `mask_secrets` are the existing writer and masker. `RefusedRecord` is a pydantic model, as `StagePlanRecord` is.
- No open tool keeps a refused model reply per item in a Service. The cost to build: about 60,000 tokens, with tests, and about 2 hours. The cost to keep is low: one small module and a bounded file. The cost to fix: a change of the file layout touches one module. The change deletes no internal code.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## ADDED Requirements

### Requirement: The live report counts the degenerate cases
The live run SHALL end a case with the outcome `degenerate` when the stage planner stops it on a reply that is a placeholder in every text, and the report SHALL show the count of such cases in the line of how the cases ended, `0` when there are none.

#### Scenario: A reply of placeholders
- **WHEN** the model answers a case with `x` or `placeholder` in every text of the plan
- **THEN** the case ends `degenerate` after one model call, and the report shows `degenerate 1`

#### Scenario: A run with no such reply
- **WHEN** the live run finishes and no reply is a placeholder in every text
- **THEN** the report shows `degenerate 0`
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## ADDED Requirements

### Requirement: A refused reply is logged
The stage job SHALL log one line `stage reply refused` for each reply of the model that it refuses, with the number of the item, the number of the last request of the plan run, the input of that request in tokens, whether that request offered a function tool, and the result `refused` or `degenerate`.

#### Scenario: A reply that the gates refuse
- **WHEN** the gates refuse the reply of item 1 in the second request of a plan run, and that request offered a tool
- **THEN** the log holds one line with `item=#1`, `request=2`, the input of the request in tokens, `tools_offered=True` and `result=refused`

### Requirement: A failed item keeps its refused replies
When a plan fails, the stage job SHALL write the refused replies and their problems to the file `<n>.refused.json` beside the plan file of item `<n>`, under the key of the plan input. A new failed plan SHALL replace the file, and the staging of the item SHALL delete it. A reply over the byte bound SHALL be dropped with its size kept, and a problem SHALL be masked for secrets and cut to the character bound.

#### Scenario: The gates refuse a plan twice
- **WHEN** the gates refuse the first reply and the reply after the return of item 1
- **THEN** the file `1.refused.json` holds the key and both replies, each with its problem, and no plan file exists

#### Scenario: The item is staged
- **WHEN** a later round stages item 1
- **THEN** the file `1.refused.json` is deleted

### Requirement: A reply of placeholders ends the item
The stage job SHALL end an item at once, with no second request, when a reply is a placeholder in `why`, `existing_tool`, each line of `feasibility` and each task of each group. The item SHALL fail with the error `RoadmapStageDegenerateError`, the job SHALL keep the reply as a refused reply, and `devops_cli_roadmap_stage_total` SHALL count the item under the result `degenerate`. A reply with one text that is no placeholder SHALL go back to the model once.

#### Scenario: The first reply is all placeholders
- **WHEN** the first reply of item 1 holds `x` or `placeholder` in every text of the plan
- **THEN** the model gets one request, the item fails with `RoadmapStageDegenerateError`, and the result of the item is `degenerate`

#### Scenario: A reply with one real text
- **WHEN** the first reply holds `x` in `why` and in `feasibility` and a real text in `existing_tool`
- **THEN** the reply goes back to the model once, as for any refused reply, and the result stays `failed` if the second reply is refused
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Tasks

## 1. Refused replies and the degenerate stop

- [x] 1.1 Write the failing tests for the refused file, the log line, the degenerate stop, the metric result and the eval count
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_refused_reply.py tests/roadmap/stage/test_roadmap_stage_eval_run.py`
- [x] 1.2 Add `RefusedRecord`, `RoadmapStageDegenerateError`, `RunTrace.last_input_tokens`, the log line, `StageResult.DEGENERATE` and `Outcome.DEGENERATE`
- Verification: `$ uv run devops ci test tests/roadmap/stage/test_roadmap_stage_refused_reply.py tests/roadmap/stage/test_roadmap_stage_eval_run.py`

## 2. Documents

- [x] 2.1 Update the Service item of `k8s/README.md` and regenerate the metric table
- Verification: `$ uv run devops ci docs`

## Workflow follow-up

- Criteria 4 and 5 of #4204 (the `staged` count above 0 in each 24 hours, and the named cause) are the results of merged fixes. #4205 holds them.
- The text of the violations of a `StructuredOutputValidationError` in the log is not part of this change.
- Pending a person: review the diff in tuicr (tuicr -r <base>..HEAD).
11 changes: 11 additions & 0 deletions openspec/specs/roadmap-stage-eval/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,14 @@ The live run SHALL build the facts context of a case with the same builder as th
#### Scenario: The job keeps its error
- **WHEN** the stage job plans an item and the staged commit lacks `src/devops_cli/roadmap/failure.py`
- **THEN** the job raises `RoadmapStageError` and makes no model call

### Requirement: The live report counts the degenerate cases
The live run SHALL end a case with the outcome `degenerate` when the stage planner stops it on a reply that is a placeholder in every text, and the report SHALL show the count of such cases in the line of how the cases ended, `0` when there are none.

#### Scenario: A reply of placeholders
- **WHEN** the model answers a case with `x` or `placeholder` in every text of the plan
- **THEN** the case ends `degenerate` after one model call, and the report shows `degenerate 1`

#### Scenario: A run with no such reply
- **WHEN** the live run finishes and no reply is a placeholder in every text
- **THEN** the report shows `degenerate 0`
Loading
Loading