Repository navigation
Description
Problem or Motivation
A refused alternatives reply is not logged with its reason or counted, so the alternatives success rate is not known; 1 Ready item holds alternatives.failed_error=RefusedReply now. The item waits 3 days for the next try with no return.
Proposed Solution & Architectural Design
Log the reason code of a refused reply (alternatives.py) in the #4845 line. Run the fixable check (point alternatives.reply_fixable, #4847): fixable when the reason is a schema or form error and it does not repeat. Fixable -> one return with the reason, inside the 10 searches and 30 fact reads. Not fixable -> wait 3 days as today. Mode shadow until 5 refusals in 7 days with a fixable share of 2/3.
Target Subsystem
SDLC, Git & PR Governance (roadmap alternatives).
Existing Tool Considered
The #4847 chain and the #4845 result line. Cost to build: about 0.5M tokens, 3 hours.
Acceptance Criteria
- A test: a refused reply followed by a valid one records a verdict.
- A test: a repeated reason refuses with no return.
- The feat(roadmap): log one result line for each roadmap job attempt #4845 line holds the reason code.
Dependencies
Source: #4843
Alternatives check of 2026-11-14: in-use.
The repository already uses this tool.
Tool: jd/tenacity (https://github.com/jd/tenacity), Apache-2.0, last activity 2026-11-01, maintained.
Proposed design
Problem statement
The alternatives job refuses a reply and then waits 3 days with no return, and the #4845 result line names only the class RefusedReply, so the reason and the alternatives success rate are not known; one Ready item holds alternatives.failed_error=RefusedReply now. This change gives each refusal a stable reason code, writes it in the result line and in the item's job record, classifies the refusal as fixable or not with the alternatives.reply_fixable point, and sends a fixable refusal back once through the existing output_check. The point runs a rule and ships in shadow; a person turns the one return on after the gate of 5 refusals in 7 days with a fixable share of 2/3.
Acceptance criteria
Requirement: Refusal reason code on the result line
The alternatives job SHALL write a stable reason code of a refused reply in the reason field of its #4845 result line.
Scenario: A refused reply names its reason code
- WHEN the job refuses a reply whose reason is the message
alternatives_reason_no_search - THEN the result line holds
result=refusedandreason=no_search
Requirement: Last refusal code in the job record
The alternatives job SHALL keep the reason code of the last refused reply in the item's job record.
Scenario: A refusal writes its code beside the error class
- WHEN the job refuses a reply with the reason code
no_search - THEN the job record holds
alternatives.failed_reason=no_searchand keepsalternatives.failed_error=RefusedReply
Requirement: One return for a fixable refusal
The alternatives job SHALL send a fixable refusal back to the model exactly once, with the reason, when the point's mode is on.
Scenario: A form refusal returns once and a valid reply records a verdict
- WHEN the mode of
alternatives.reply_fixableison, the reply is refused with the form codeno_tool, and the job record holds no earlier refusal with that code - THEN the rule gives the band
review,output_checksends the reason back once, and a valid second reply records a verdict
Requirement: No return for a repeated reason
The alternatives job MUST NOT send a refusal back when its reason code equals the code in the item's job record.
Scenario: The same reason code twice
- WHEN the reply is refused with a code that the item's job record already holds
- THEN the rule gives the band
continue, the job makes no second model call and sets the next try 3 days later
Requirement: 3-day wait for a not-fixable refusal
The alternatives job SHALL keep the 3-day wait for a refusal whose reason is not a schema or form error.
Scenario: A timeout reason waits 3 days
- WHEN the run stops on
UsageLimitExceeded, or the reply is cut by the output limit - THEN the code is not fixable, the rule gives the band
continue, the job makes no second model call and sets the next try 3 days later
Requirement: Return inside the attempt budget
The alternatives job MUST keep the one return inside the 10 searches and 30 fact reads of the attempt.
Scenario: The return stops at the budget
- WHEN the job makes the one return after a fixable refusal and the model calls
search_webpast the 10th search - THEN the tool answers the call as text with no search, and the attempt reports at most 10 searches and 30 fact reads
Requirement: Rule-only point with its table in the cuts file
The alternatives.reply_fixable point SHALL resolve with a rule and MUST read its fixable code table from its cuts file, not from a constant.
Scenario: The settings load accepts the point in shadow
- WHEN
roadmap.decisionssetsalternatives.reply_fixabletoshadow - THEN the settings load, and the cuts file of the point holds the fixable code table
Requirement: Shadow mode records the band only
The alternatives.reply_fixable decision point SHALL run in mode shadow and record its band with no change to the job behavior.
Scenario: Shadow records a band and keeps the 3-day wait
- WHEN the mode of
alternatives.reply_fixableisshadowand the reply is a fixable refusal - THEN the result line holds the band
reviewand the job makes no second model call and sets the next try 3 days later
Existing Tool Considered
jd/tenacity (https://github.com/jd/tenacity), Apache-2.0, last activity 2026-11-01, maintained: the repository already uses this tool (src/devops_cli/ai/retries/__init__.py:15, src/devops_cli/http/retry.py:32). It covers a conditional retry and an attempt cap in general, but the one return itself needs no new retry code: investigate already sends the first refused reply back once through output_check and ModelRetry (src/devops_cli/roadmap/refine/refine_investigation.py:493, src/devops_cli/roadmap/alternatives.py:1148). It lacks the classification of a reason code as a schema or form error, the memory of a repeated reason, the write of the reason code into the #4845 result line, the alternatives success-rate count, the shadow mode and its gate, the 3-day wait and the enforcement of the 10 searches / 30 fact reads budget. That code stays in alternatives.py, at the written cost of about 0.5M tokens and 3 hours that the body gives.
Key questions
- Which retry mechanism makes the one return after a refused reply?: The one return reuses the existing
output_checkpath ofinvestigate:_retry_oncesends the message back withModelRetryfor the first refused reply only, so the model gets one more turn in the same run. No new retry loop and no tenacity call is added for it. (best practice) [sources: src/devops_cli/roadmap/refine/refine_investigation.py:493, src/devops_cli/roadmap/refine/refine_investigation.py:626, src/devops_cli/roadmap/alternatives.py:1148, src/devops_cli/roadmap/alternatives.py:1162, openspec/changes/archive/2026-11-01-2946-the-alternatives-check-must-search-before/design.md:9]- Chosen: The existing
output_checkandModelRetrypath. The alternatives job already passesoutput_checkand counts the return, and the reason goes back into the same run, so the sameUsageLimitsand the same tool counters bound it. - Rejected: A tenacity retry around the run. It would start a second run with a new
UsageLimitsand a new tool counter, and it cannot put the reason into the same conversation asModelRetrydoes. - Rejected: A hand-kept retry loop in
alternatives.py. It repeats the one-return guard that_retry_oncealready gives and that thereturnscount already records.
- Chosen: The existing
- Does the one return run with a new search and fact-read budget?: No.
_retry_onceis an output validator of the sameagent.run_sync, so the return runs under the sameUsageLimitsand the sameAlternativesToolscounters. The 10 searches and 30 fact reads of the attempt still bound it, and no second budget is opened. [sources: src/devops_cli/roadmap/refine/refine_investigation.py:593, src/devops_cli/roadmap/refine/refine_investigation.py:628, src/devops_cli/roadmap/alternatives.py:1155, src/devops_cli/config/constants.py:3495, src/devops_cli/config/constants.py:3496] - Where does the job write the reason code, and where does it keep the memory of a repeated reason?: The feat(roadmap): log one result line for each roadmap job attempt #4845 result line's
reasonfield holds the code of a refused reply; todayalternatives.pypasseserror_classthere, which isRefusedReply. The memory that a reason repeated is a new job-record keyalternatives.failed_reason, written besidealternatives.failed_errorand cleared when a check is written.alternatives.failed_errorkeeps the classRefusedReply, asdocs/ROADMAP_WORKFLOW.mdand the result-line test state; a log line is not a durable store. (best practice) [sources: src/devops_cli/roadmap/alternatives.py:1377, src/devops_cli/roadmap/alternatives.py:1392, src/devops_cli/roadmap/stores/store.py:210, src/devops_cli/roadmap/job_result.py:8, docs/ROADMAP_WORKFLOW.md:138, docs/adr/0021-the-roadmap-service-is-a-webhook-router-cluster-pods-run-the-roadmap-jobs-and-valkey-holds-their-shared-state.md:78, src/devops_cli/config/constants.py:3516]- Chosen: The result line plus a new
alternatives.failed_reasonrecord key. The line is the per-attempt record that the gate counts, and the job record is the durable copy that the next run reads, whilefailed_errorkeeps its documented class. - Rejected: Put the code in
alternatives.failed_error. The key is documented as the class of the error, holdsRefusedReply, and the existing result-line test pins that value. - Rejected: Read the code back from the Loki line. A log line is not the store of a decision; ADR 0021 keeps the GitHub job record as the source of truth.
- Chosen: The result line plus a new
- How does the job decide that a refusal is fixable, and with what resolver?: A refusal is fixable when its reason is the reply's form or schema and its code is not already in the item's job record. The form reasons are the keys of
_refusal(alternatives_reason_skip_only,_job_verdict,_no_search,_no_tool,_no_facts,_url); the schema reason is the run stop withschema_broken. A timeout, an output-limit cut, invalid tool-call JSON, a provider error and an inventory read error are not fixable. A rule gives the band, and its code table is data in the point's cuts file; no model takes part. (best practice) [sources: src/devops_cli/roadmap/alternatives.py:770, src/devops_cli/roadmap/refine/refine_investigation.py:549, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:60, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:70, src/devops_cli/roadmap/decision_table.py:22]- Chosen: A rule whose code table is data in the point's cuts file. The reason is deterministic at the refusal, so a rule answers it; ADR 0020 puts a proven rule before a model, and a point in shadow needs a cuts file, which this file gives.
- Rejected: A model resolver on the point. No labelled refusal outcome exists to fit a cut, and ADR 0020 adds a model only where it is measured to add to the rule.
- Rejected: The code table as a constant in
alternatives.py. ADR 0020 refuses a parameter that is a guess in a constant; the parameters of a rule are data, and a shadow point must name its cuts file.
- What does the job do in shadow mode?: In mode
shadowthe point runs its rule, records its band, and the job behaves as it does today: no second model call, the next try 3 days later. The one return acts only when the mode ison. (best practice) [sources: CONTEXT.md:138, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:64, docs/CONFIGURATION.md:308]- Chosen: Record the band and keep today's wait. ADR 0020 says shadow records the answer and the workflow acts as with
off. - Rejected: Apply the return from the first release. It skips the measured record that ADR 0020 requires before a person turns the point on.
- Chosen: Record the band and keep today's wait. ADR 0020 says shadow records the answer and the workflow acts as with
- How does the gate count 5 refusals in 7 days and the fixable share of 2/3?: From the feat(roadmap): log one result line for each roadmap job attempt #4845 result lines: each refused attempt writes
result=refused, itsreasoncode and its fixable band, so one Lokicount_over_timeover 7 days gives the refusal count and the share of lines whose band isreview. No new counter is added; the lines are the per-attempt record that the job grade already reads. (best practice) [sources: src/devops_cli/roadmap/job_result.py:1, CONTEXT.md:142, docs/roadmap/job-success.md:22, docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:84]- Chosen: Count from the result lines in Loki. The line already exists for each attempt, and the gate is a one-time read of the record that ADR 0020 asks for.
- Rejected: Add a Prometheus counter for refusals. It adds a series for a one-time gate, and the result line already holds the reason and the band.
- Is the promotion from shadow to
onpart of this change?: No. A person turns the point on after reading the record and the fit report, so this change ships the point inshadow. The gate of 5 refusals in 7 days with a fixable share of 2/3 is the evidence for that later decision, and a later change makes it. (a person decides) [sources: docs/adr/0020-a-decision-point-is-a-unit-of-a-workflow-with-a-resolver-chain-and-a-rule-goes-before-a-decision-model.md:84, docs/CONFIGURATION.md:308] - Does this change still wait on feat(roadmap): log one result line for each roadmap job attempt #4845?: No. The feat(roadmap): log one result line for each roadmap job attempt #4845 result line is merged:
src/devops_cli/roadmap/job_result.pyand the alternatives writer that logs it are in the tree, and the change folder is archived. feat(roadmap): add the soft-cap and fix-check chain to decision points #4847 (the soft-cap chain of decision points) is still Status New, so the dependency on it stands. [sources: openspec/changes/archive/2026-11-12-4845-log-one-result-line-for-each/proposal.md:9, src/devops_cli/roadmap/job_result.py:1, src/devops_cli/roadmap/alternatives.py:1385, openspec/changes/archive/2026-11-13-4851-extend-stage-gate-returns/proposal.md:44]
Open questions
- Is the promotion from shadow to
onpart of this change? (a person decides)
Fit
Fits in one pull request.
Suspected block
None.
Activity
dan-petty commentedon Nov 11, 2026
Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.
featprefix of the title gives the type.(roadmap)scope of the title gives the scope.It improves observability of the alternatives success rate and adds one conditional retry, but no live item is blocked by its absence.Users gain a visible success rate and one faster retry for fixable refusals, which reduces idle wait time.The body states about 0.5M tokens and 3 hours of work, scoped to one file and two tests.Both handle alternatives check failures, but #2949 isolates a failed item from the round and retries after days, while the candidate logs the reason code and allows one immediate return for fixable refusals.devops-cli-service commentedon Nov 14, 2026
Alternatives check: in-use
Reason: The searches found no tool that logs the alternatives refusal reason code, classifies a refusal as fixable or counts the success rate; that part stays in
alternatives.py. The general retry library tenacity covers only the retry mechanism the issue asks for: a predicate chooses which failures get another try, and an attempt cap gives exactly one return.The repository already uses this tool.
Tool: jd/tenacity (https://github.com/jd/tenacity)
Covers:
Lacks:
Tools considered:
Searches run:
Sources:
Checked on 2026-11-14. A person decides what this means for the item. The check changes no label and closes no issue.
devops-cli-service commentedon Nov 15, 2026
Owner question: Is the promotion from shadow to
onpart of this change? (a person decides)Options
Recommendation: Decide the question: only a person can answer it.
Evidence
feat(roadmap): a refused alternatives reply goes back once (#4864)
devops-cli-service commentedon Nov 16, 2026
Released in v0.162.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.162.0
devops-cli-service commentedon Nov 16, 2026
Live since 2026-11-16 11:49 UTC