Repository navigation
Description
Problem Statement
Refinement is done by hand today. Items reach implementation with open questions, and the gaps show up later as review findings: three remediation PRs merged into release/v0.2.24 on three consecutive days (#683 on 2026-09-28, #719 on 09-29, #736 on 09-30), each fixing findings from a review session. On 2026-10-01 an assessment refined the v0.2.25 and v0.2.26 items one at a time with agents. This item turns that manual pass into a roadmap job, so the next planned release reaches 12 Ready items without it. CONTEXT.md defines Ready as a problem statement, acceptance criteria and an answer to every key question. This item adds the rule that proposed answers count, and a person can override one before the item starts.
What exists at 9c879ae (release/v0.2.25):
- The
devops roadmapgroup exists withmigrateandrender(feat(github): github-sourced roadmap, migration and generated roadmap view (devops roadmap migrate,render) #739, commit 6948e1c).src/devops_cli/commands/roadmap.py:69-110defines both; each takes--repo/-Rand--ref(:43-44) and reads.github/roadmap.tomlthrough the contents API at--ref(:3-4;_open_roadmapat:57-63, which defaults the repo to the current directory'soriginviaget_repo_origin_name()at:59).migratetakes--confirmand--dry-run(:73-74);rendertakes--dry-run(:110). Help text lives inRoadmapCommandHelp(src/devops_cli/lang/en/help.py:857). Both have read-only MCP mirrors (roadmap_renderatsrc/devops_cli/ai/mcp/server.py:627-640,roadmap_migrateat:643-657, exported atai/mcp/__init__.py:72-73and:220-221) that build argv through_validate_mcp_arg(server.py:96). .github/roadmap.tomlsetsboard = 2andplanning_horizon = 3(not 2: the defaultDEFAULT_ROADMAP_PLANNING_HORIZONatconfig/defaults.py:745is 2, and the file overrides it to keep v0.2.26, v0.2.27 and v0.2.28).release_capkeeps its default of 12 (defaults.py:743,roadmap/config.py:32). The board's Status options New, Ready, In Progress, In Review, Done, Blocked are in.github/project-template.json:11-16.- The roadmap store exists (refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768, commit bf746de).
RoadmapStoreis the Protocol atsrc/devops_cli/roadmap/store.py:440-550, withGitHubRoadmapStore(roadmap/github_store.py, every write throughghargv via_writeat:811) andInMemoryRoadmapStore(roadmap/memory_store.py:94).get_roadmap_store(store.py:553) is the one seam tests replace;tests/conftest.py:297(github_roadmap_factory) refuses a real store in command tests and:324-325provides theroadmap_storefixture. The contract suitetests/test_roadmap_store_contract.pyruns against the in-memory adapter (itsstorefixture,:52-56); the GitHub adapter's argv is tested intests/test_roadmap_github_store.py(56 tests, e.g.test_close_issue_comments_then_closes_for_its_reasonat:870). The store has, today:- the job record:
JobRecord = dict[ItemField, str | None](store.py:83), keyed byItemField(:39-52: Release, Status, Priority, Value, Effort), validated by_JOB_RECORD = TypeAdapter(JobRecord)(github_store.py:323) and encoded as JSON offield.valueinto one board text field (encode_job_record/decode_job_record,:366-379).BOARD_FIELDS(store.py:54) is derived fromItemFieldminus Release, so a key that is not a board field must be a second key kind, not a newItemFieldmember; issues()(store.py:503), the only read that returns a body (IssueRecord.body,:190).Item(:141-166) carries no body, anditem(number)(:473) returns anItem;close_issue(number, reason, comment)(:509), the only comment write, andcreate_issue(:506);repository_file(path, ref=)(:512) reads one file through the contents API;- no issue body write, no stand-alone comment write, no repository visibility read (the GraphQL client already fetches
isPrivate,github/graphql.py:107,:371,:838, butsrc/devops_cli/roadmap/never mentions it), noneeds_splitand no hashes. The in-memory adapter records comments (comments_on,memory_store.py:211) and changes (_record,:498), andas_actor(name)(:131) returns the same roadmap written as a person, with no job record; it has no list of issue-body writes.
- the job record:
- A structured model call with no tools exists.
LLMClient.chat_structured(src/devops_cli/ai/client/structured.py:215-292) sends one chat request and validates the reply against a Pydantic model, retries with the validation error, and raisesAIClientError(ai/client/models.py:64) aftermax_retries(:284-290; default 2,config/defaults.py:117). It takes no tools parameter.- Its retries sleep 0.5 s, then 1 s (
structured.py:211;DEFAULT_STRUCTURED_RETRY_BACKOFF_SECONDSatdefaults.py:118), so a test that drives the real retry loop with the defaults takes 1.5 s. - Models are picked per task with
AIConfig.for_task(src/devops_cli/config/settings.py:479); the tasks, includinganalysis, are inAITasksConfig(:400-404).for_taskcarriescontext_windowandnum_ctx(:490-491), which is the budget refine cuts to. - The default provider is Ollama, called directly (
config/defaults.py:63). The gateway is reached by configuring the base URL, which is what the in-cluster runtime does (feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741'sdevops-cli-config).
- Its retries sleep 0.5 s, then 1 s (
- Tavily search exists only as an agent tool that nothing calls.
tavily_search_tool(src/devops_cli/ai/common_tools.py:459-504) is re-exported (ai/agents/__init__.py:383is a lazy attribute lookup,ai/agents/pydantic_agent.py:185an import) but called only by tests (tests/test_common_tools.py:87,tests/test_native_common_tools.py:123).- It returns a failure as result text (
:496-497), so a failed search looks like a result. - No setting holds a Tavily key:
grep -ri tavily src/devops_cli/config/finds no option, onlyDEFAULT_TAVILY_MAX_RESULTS(5) andDEFAULT_TAVILY_TIMEOUT_SECONDS(15 s) atconfig/defaults.py:533-534and their re-exports inconfig/__init__.py.
- Code-context helpers exist.
generate_repo_map(src/devops_cli/ai/repomap.py:244) andtruncate_to_token_limit(src/devops_cli/ai/context_budget.py:65). The repo map walks the file system (_discover_repo_files,repomap.py:162). It skips symlinks (:152) and git-ignored files (:157), but it includes untracked files.src/devops_cli/ai/review/samples.py:136(_git(checkout, *args)) is the existing pattern for argv-only git calls. - Reprioritization (feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740) and intake (feat(github): single-entry item intake with duplicate detection and placement (devops roadmap intake) #742) have not landed.git log --oneline | grep -E '\(#(740|742)\)'returns nothing;grep -riE 'reprioritiz|intake' src/devops_cli/roadmap/ src/devops_cli/commands/roadmap.pyreturns nothing;docs/ROADMAP.md:1075and:1079list both as open under the v0.2.25 heading (:784, "Active Release"; v0.2.26 starts at:1088). The neighbouring items expect this job but leave its interface open:- feat(github): single-entry item intake with duplicate detection and placement (
devops roadmap intake) #742's intake "starts refinement at once for an admitted critical fix or a P0 feature, once refinement exists". - feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740 descopes an item when "refinement found it needs splitting", but it doesn't say where that finding is read from. devops roadmap runwas split out of feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 into feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 (owner decision of 2026-10-02, Q2; the deployment is feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083 since feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 became the in-cluster runtime on 2026-10-03). feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 runs refinement after reprioritization, or when intake's outcome in the same run placed a critical fix or a P0 feature. Its due table holds a row only for each job that has landed when it merges, and it is the last merge of v0.2.26, so it adds refine's row. Its Checkouts keep one clone per repo under the data directory, fetched and reset hard toorigin/release/vX.Y.Zbefore closure or refinement runs, and its refine adapter passes the clone path as--source. feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 (the in-cluster runtime, right after feat(release): production service image for scheduled jobs and webhook handlers #753 in v0.2.26) owns thedevops-cliSecret anddevops k8s push-secrets; this item lands after it and adds theDEVOPS_CLI_TAVILY_API_KEYrow and its README line.
- feat(github): single-entry item intake with duplicate detection and placement (
devops gh project syncwould not undo a Ready that refine sets._forced_status(src/devops_cli/github/projects.py:916-931) forces a status only for closed issues and pull requests, and label mapping applies only when Status is unset (initial_status,:933).
Security. The repository is public, so anyone can write issue text. The roadmap must also work for any repository devops-cli manages (ADR 0001, line 3). In the service, the job acts as the machine account, whose classic token has the repo and project scopes (ADR 0002). In a terminal it acts as the person's gh login (#767). Refinement reads untrusted text (issue bodies and search results) and writes to GitHub. Prompt injection targets exactly that setup.
- Willison, "The lethal trifecta for AI agents" (2025-06-16): the trifecta is private data, untrusted content and a way to send data out. Markdown images are a known way to send data out. GitHub fetches every image URL in an issue body or comment through its image proxy.
- Beurer-Kellner et al., "Design Patterns for Securing LLM Agents against Prompt Injections" (arXiv 2506.08837). This item uses its plan-then-execute and context-minimization patterns.
- OWASP Top 10 for Agentic Applications 2026 (published 2025-12-09), ASI01.
So neither model step holds a tool, and deterministic code decides every write. The text the job writes can't carry any link, image or mention the run didn't produce.
Proposed Solution
devops roadmap refine: a roadmap job that reads one New item's body, the checkout's docs and code slices, and (for public repos) web search results, asks the analysis model for a RefinementProposal in two tool-less structured calls, validates every source deterministically, writes its own marked section into the item's body, and moves Status New → Ready when the deterministic Ready check passes.
Command
devops roadmap refine takes the --dry-run and --confirm every roadmap subcommand takes (#739), --repo OWNER/NAME and --ref as migrate and render take them (commands/roadmap.py:43-44; --ref selects the .github/roadmap.toml read through _open_roadmap, default the default branch, independent of --source's HEAD SHA), plus --item N, --limit (default 3) and --source PATH (default: the current directory). --repo defaults to the --source checkout's origin, so refine resolves the origin from --source, not from the current directory as _open_roadmap does at :59. It gets a read-only MCP mirror roadmap_refine that runs the dry run only, built like roadmap_migrate (ai/mcp/server.py:643-657).
Selection
Without --item, refine works only on New items.
- It takes the New items in the next planned release first, by priority. A person placed them there, so the cap doesn't stop this step.
- Then it takes backlog items by priority, until the Ready items in the next planned release and the backlog together reach the release cap (
release_cap, 12). - It skips an item when neither its body outside the section nor the section has changed since refine last ran on it. The store's job record holds both hashes. A person's edit, such as an answer or an "## Owner decisions" block, makes the item eligible again.
- It stops after
--limititems. - It never touches an item that is Ready, Blocked or started. With
--item, such an item is reported and left alone.
Triggers
devops roadmap run(feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981) calls refine after each reprioritization, and when intake's outcome in the same run placed a critical fix or a P0 feature. feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 is the last merge of v0.2.26 and adds a due-table row for each job that has landed when it merges, so it adds refine's row and this item adds none. Should this item land after feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 instead, this item adds its own row in its own PR (feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981's rule for jobs that land later).- Intake (feat(github): single-entry item intake with duplicate detection and placement (
devops roadmap intake) #742) calls refine for one item straight away when it admits a critical fix or places a P0 feature. feat(github): single-entry item intake with duplicate detection and placement (devops roadmap intake) #742 lands before this item (see Dependencies), so this item adds that call. In feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981, intake's outcome reaches refine's row as a trigger in the same run; a second call on an item whose body and section are unchanged is skipped by Selection, so the two paths never refine an item twice.
Inputs (context minimization)
- The issue body only, not its comments.
CONTEXT.mdanddocs/adr/*.mdfrom the checkout, when present.- Code from the checkout at
--source:- Refine checks that the checkout's
originis the--repo. If it isn't, refine makes no model call, writes nothing and exits non-zero. It records the HEAD SHA and the branch. - It reads file content at the recorded SHA through git (
git show <sha>:<path>,git grep ... <sha>), as argv with no shell (the_gitpattern inai/review/samples.py:136), so untracked files, paths outside the checkout and symlink targets are never read:- the paths and
path:lineranges the body cites; git grep -n -F -w -e <identifier> <sha> --hits for backticked identifiers, with the number of hits capped;- the repo map of the cited directories, limited to the files
git ls-fileslists.
- the paths and
- All of this is cut to the analysis model's context budget (
for_task("analysis").context_window/num_ctx, viatruncate_to_token_limit).
- Refine checks that the checkout's
Two model steps (plan-then-execute)
Both go through chat_structured with ai.for_task("analysis"), and neither holds a tool.
- Research plan. Sees the issue body only and returns at most 3 search queries.
- Deterministic code runs each query through Tavily (5 results each), but only when the store reports the repo as public and the Tavily key is set. If the visibility can't be read, refine runs no search.
- A failed search is recorded as "research failed: ", where the category is the HTTP status, "timeout" or "malformed reply". No exception text is written to the body or passed to the model.
- Proposal. Sees the body, the docs, the code slices and the search results. Returns a
RefinementProposal, a Pydantic model withextra="forbid", holding:- a problem statement;
- acceptance criteria, each with how it is verified;
- key questions: the body's own, plus any a builder would hit. Each answer is marked as fact or decision and lists its sources;
- whether the item fits one PR, with draft split-offs if it doesn't;
- a suspected block, if any;
- dependencies, as issue numbers.
Validation (deterministic)
- A
path:linesource must exist at the recorded SHA. - A URL source must be one of this run's search results.
- An
#Nmust be an issue in the repo (store.issues()). - Invalid sources are dropped.
- A fact answer left with no valid source becomes an open question.
- Deterministic code collects the body's own key questions: the list items under a "Key questions" label. A body question the proposal doesn't answer, matched after normalizing whitespace and emphasis, becomes an open question.
- A decision answer is marked "(proposed)". It is marked "(owner decision)" instead only when it quotes a line that appears in the body's "## Owner decisions" block.
Ready check (deterministic, over the validated proposal)
The item passes when it has a problem statement; at least one acceptance criterion with how it is verified; no open question; a fit in one PR; and no suspected block.
Writes
These are the only writes refine makes, and all go to the item being refined.
- The section between
<!-- devops-roadmap-refine:start -->and<!-- devops-roadmap-refine:end -->at the end of the body. It records the SHA and branch it was checked at.- The renderer builds it from the proposal as plain text. It removes images (inline and reference-style), raw HTML and links. It wraps
@handles,#Nreferences that failed validation, and bare URLs not in this run's search results in code spans. - URLs come only from this run's search results.
- Everything outside the markers stays byte-identical.
- The renderer builds it from the proposal as plain text. It removes images (inline and reference-style), raw HTML and links. It wraps
- Status New → Ready, when the Ready check passes. Refine makes no other status change.
- One reason comment on the item, when its Status changes or when it needs splitting. A fixed template with no model text: the change ("New → Ready" or "needs splitting into N items"), the SHA, and a pointer to the section.
- Too big for one PR: Status stays New; the section lists the proposed split-offs and refine never files them; the store's job record for the item gets
needs_split. This item makes reprioritization's descoping (feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740) read that record, never the body. Descoping applies only to the current release, so this matters for an admitted critical fix. An item in the next planned release stays New, and feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740's release start returns it to the backlog.
Store (this item adds, to both adapters, the contract suite and the GitHub adapter's tests)
None of these exist at 9c879ae:
- an issue body read for one number (today only
issues()returns bodies) and an issue body write; - a stand-alone comment write (today only
close_issuecomments); - a repository visibility read (the GraphQL client already fetches
isPrivate,github/graphql.py:107,:371,:838; the store exposes it); - refine's per-item record values in the job record, as the body already decides (Selection and Writes above):
refine.body_hash,refine.section_hashandrefine.needs_split. They are a second key kind, aStrEnumalongsideItemFieldinJobRecord(store.py:83), so_JOB_RECORD(github_store.py:323) validates them andencode_job_record(:377-379) writes their.valueinto the same board text field;BOARD_FIELDS(store.py:54) stays derived fromItemFieldalone, sorequire_board_fieldand the field writes are untouched. A person's edit (as_actor,memory_store.py:131) never writes them; - a recorded-writes list in the in-memory adapter covering body writes and comments, so tests can assert "nothing else was written".
Tavily
- Add
tavily_search(query, *, api_key, max_results) -> list[TavilySearchResult]toai/common_tools.py. It raises on an HTTP error or a malformed reply.tavily_search_toolwraps it and keeps its current text output. Discovery (feat(ai): roadmap discovery from advisories, alerts, repo signals and web research (devops roadmap discover) #745) can reuse it. - Add a
tavily.api_keyoption, read fromDEVOPS_CLI_TAVILY_API_KEY. It followsqdrant.api_key:config/options.py:65,SECRET_CONFIG_OPTIONS(:220) andKEYRING_KEYS(:236-243),config/env.py:67,:153and the secretEnvVarSpecat:475-480, plus the row inbuild_secret_registry(security/secrets.py:408-424) that every secret option carries.
Scope
In this item's one pull request:
src/devops_cli/roadmap/refine.py(selection, reading, prompts,RefinementProposal, validation, Ready check, renderer, writes, person-edit and size checks) and therefinesubcommand incommands/roadmap.pywith its help text inlang/en/help.pyand theroadmap_refineMCP mirror inai/mcp/server.pyandai/mcp/__init__.py.- Store additions listed above, in
roadmap/store.py,roadmap/memory_store.py,roadmap/github_store.py,tests/test_roadmap_store_contract.pyandtests/test_roadmap_github_store.py. tavily_searchand thetavily.api_keycredential.- The
DEVOPS_CLI_TAVILY_API_KEYentry ondevops/devops-cliin feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's push table: sourcetavily.api_key(keyringtavily_api_key), optional and never generated, and its line in k8s/README.md's "Cluster Secrets" section. - The intake call (feat(github): single-entry item intake with duplicate detection and placement (
devops roadmap intake) #742) and theneeds_splitread in reprioritization's descoping (feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740); both land before this item (see Dependencies). tests/test_roadmap_refine.py, Tavily tests, achangelog.d/744.mdfragment anddocs/agent/tasks/task-744-roadmap-refine.md.
Effort: high. It fits one pull request: #739 shipped as one PR of 57 files (git show --stat 6948e1c: 57 files changed, 4396 insertions), and this item's surface is of the same order.
Key Questions
Answered (decision marks follow the item's own convention; "proposed" answers count toward Ready and a person can override one before the item starts):
-
Who sets Status to Ready? Refine does, and only the move from New to Ready, decided by the deterministic check (proposed). Nothing in feat(github): github-sourced roadmap, migration and generated roadmap view (
devops roadmap migrate,render) #739-feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 moves an item from New to Ready; feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 sets Ready only when a stalled item goes back, and it starts each release from Ready items. The check runs over the validated proposal; the body is never read back as a readiness signal, so a forged section makes nothing Ready. This is the one board write refine makes, anddevops gh project syncdoes not undo it (github/projects.py:916-933). It goes beyond the assessment's "writes only the refinement section"; the owner confirmed it on 2026-10-02 (see the last question). -
Does refine comment on the item? Yes, one fixed-template reason comment when Status changes or the item needs splitting (owner decision, 2026-10-02). feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740 leaves a reason comment for every change, and feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 expects every change and its reason comment to come from a job. The template carries no model text, and comments on other items are forbidden. This also goes beyond "writes only the refinement section"; the owner confirmed it (see the last question). -
Where does refine write, and why in a marked section instead of rewriting the body? The 2026-10-01 assessment's amendment says deterministic code writes only the refinement section. Text a person wrote never changes, and a re-run replaces only refine's own section.
-
How does a person override a proposed answer? By editing the section, or by adding an "## Owner decisions" block (proposed). Refine stores the hash of the section it last wrote, following the compare-before-overwrite rule in ADR 0002 (its line 12). If the section has changed since, or the body holds a section refine has no record of, refine writes nothing more to that item and reports it. A person sets Ready by hand, or deletes the section to have refine run again.
-
When does refine run again on a New item it already refined? Only after the body outside the section changes, for example when a person answers a question or adds an "## Owner decisions" block (proposed). Otherwise the same top items would use up
--limiton every run, and nothing below them would be refined. -
What if the body changes between the read and the write? Refine reads the body again just before writing, and skips the item for this run if it changed (proposed).
-
Why two model calls instead of one agent with a search tool? Plan-then-execute and context minimization (proposed). The step that writes the queries never sees code, so a private repo's code can't leave through a query. The step that sees code has no way to send anything out. One call can't do both.
-
Why no research for private repos? In a private repo, the issue text is private data, and the queries built from it would go to a third party (proposed). No config switch until someone needs one.
-
Does refine read issue comments? No (proposed). The body is the item. On a public repo anyone can comment, and owner decisions live in the body by convention.
-
Does refine check who wrote an "## Owner decisions" block? No (proposed). The design limits what refine can write, not who wrote the text it reads. A person reviews the proposed and quoted answers before the item starts.
-
Which code does refine read, and at which commit? The checkout given by
--source, read at its HEAD SHA and recorded in the section by SHA and branch (proposed). Itsoriginmust be the item's repo. In the service, feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 keeps one checkout per repo under the data directory, reset toorigin/release/vX.Y.Zbefore refine runs, and passes its path as--source. Refine runs nogit fetch. -
Which model?
ai.for_task("analysis"), the review's analysis model, through whatever endpoint the config names (proposed). No new task key. In the cluster, feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's config points it at the in-cluster gateway. -
How is an item that's too big for one PR reported? Status stays New, the draft split-offs go in the section, the store's job record gets
needs_split, and refine posts one reason comment. For a current-release item, feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 then descopes it (proposed). Refine files no issues, because the amendment forbids writes to other issues; a person files the split-offs. -
Does refine set Blocked? No (proposed). It writes "Blocked (suspected): " in the section and leaves Status at New. By CONTEXT.md, Blocked means waiting on hardware, an upstream release or a person's decision, and a person sets it.
-
Does refine record dependencies as blocked-by links? No (proposed). It lists them in the section. A person records the blocked-by link that feat(github): github-sourced roadmap, migration and generated roadmap view (
devops roadmap migrate,render) #739 and feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 read. -
Does refine run again on Ready items? No, only on New items. A person moves an item back to New to run it again (proposed).
-
What does the MCP mirror do? A dry run only, returning the proposal and the planned writes (proposed). An MCP client is itself a model that reads untrusted text, so a write path would reopen what the two-step design closes. Related: feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857. The mirror follows the existing
_validate_mcp_argargv contract (ai/mcp/server.py:96; fix(mcp): mcp tools and resources call commands and options that exist #836, fix(mcp): mcp tools refuse coerced arguments before they run, with prescriptive errors that never echo values #862). -
How many items per run?
--limitdefaults to 3 (proposed). That caps model and search spend per run;devops roadmap run(feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981) calls refine after every reprioritization, so the release fills over several runs. -
What if a model call fails or returns an invalid proposal? Refine writes nothing for that item and reports it. The run moves on to the next item and exits non-zero at the end (proposed).
-
Does this add a GitHub workflow? No (proposed). Refine runs from a terminal and from the service (feat(roadmap): run the roadmap jobs when they are due (
devops roadmap run) #981, deployed by feat(k8s): the roadmap service runs in the cluster's devops namespace, reachable from outside only on /webhooks/github #1083). fix(ci): only collaborators can trigger pr updates with/updateor/synccomments #754 is related, not a dependency: it must land before any workflow holds the machine-account token, and refine adds no workflow. -
Where do the body hash, section hash and
needs_splitlive? In the store's job record, as the body says (Selection, Writes). Settled from the code:JobRecordis keyed byItemField(store.py:83) andBOARD_FIELDSis derived from that enum (:54), so the three keys are a second key kind, aStrEnumthatJobRecord,_JOB_RECORD(github_store.py:323) andencode_job_record(:377-379) accept, kept out ofBOARD_FIELDS(see Store). GitHub stays the source of truth (ADR 0001), the record survives a fresh service pod, a terminal run sees it, and feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 readsneeds_splitfrom one place. The section cannot hold its own hash, and a value in the body could be forged to silence re-runs. -
Does
refinetake--ref? Yes, settled from the code:migrateandrenderread.github/roadmap.tomlonly through_open_roadmap(repo, ref)(commands/roadmap.py:57-63), whichrefinereuses forrelease_cap, so it takes--refwith the same default (the default branch). It is independent of--source's HEAD SHA. -
Is the Tavily function and credential split into its own item? No. It is ~150 lines with tests, its research-isolation tests belong with refine, and discovery (feat(ai): roadmap discovery from advisories, alerts, repo signals and web research (
devops roadmap discover) #745), the only other user, is in the backlog with no release, so a separate PR would spend a release slot for nothing. -
What happens if feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740 or feat(github): single-entry item intake with duplicate detection and placement (devops roadmap intake) #742 has not shipped when this item starts? They land before this item in every case (cross-check ordering of 2026-10-02). feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 is a v0.2.25 item (started onfeat/roadmap-reprioritize), and v0.2.25 ships before v0.2.26 starts (CONTEXT.md: the next release starts when the current one ships). feat(github): single-entry item intake with duplicate detection and placement (devops roadmap intake) #742 moved to v0.2.26 on 2026-10-03 (owner) and starts first there. If either is descoped at the v0.2.25 cut, it moves into v0.2.26 with precedence as a shipped-release leftover and is sequenced ahead of this item and feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981. So this item adds the intake call and theneeds_splitread, and the "Too big" and "Intake hook" criteria stay here. -
Does refine make the two writes beyond the amendment's "writes only the refinement section": Status New → Ready and the one fixed-template reason comment? Yes, both (owner decision, 2026-10-02): Status New → Ready when the Ready check passes, and one fixed-template comment when Status changes or the item needs splitting. Without the Status write no job ever moves an item from New to Ready (nothing in feat(github): github-sourced roadmap, migration and generated roadmap view (
devops roadmap migrate,render) #739-feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 does), so the next planned release could not fill to 12 Ready items without a person, which is the item's purpose. The comment is the convention the roadmap jobs follow (feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 leaves a reason comment for every change; feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 expects every change and its reason comment to come from a job), carries no model text, and is the only visible signal in the needs-splitting case, where Status does not change. So the Store section keeps the stand-alone comment write, and the "Ready check", "Comment", "Too big" and "Intake hook" criteria stand as written.
Acceptance Criteria
Unless marked otherwise, each criterion is a test in tests/test_roadmap_refine.py, run with uv run pytest tests/test_roadmap_refine.py. The tests use the roadmap_store fixture (tests/conftest.py:324) over InMemoryRoadmapStore, a scripted chat_structured and a fake search function.
- Dry run.
devops roadmap refine --item N --dry-runprints the rendered section and the planned writes, and the adapter's recorded writes stay empty. ACliRunnertest, as intests/test_roadmap_render.py:144(test_dry_run_prints_the_file_and_writes_nothing). - Body write. After
--confirm: the body outside the markers is byte-identical to the body before; the section equals the rendered proposal; a second run with the same proposal writes nothing. - Ready check. A complete proposal moves Status from New to Ready and posts one comment on that item. Each of these leaves Status at New, one parametrized case each: an open question; a fact answer whose only source is a
path:linepast the end of the file at the SHA; a body key question the proposal leaves out; a proposal that doesn't fit one PR; a suspected block; no acceptance criterion. - Decision marks. In the rendered section: a decision answer ends with "(proposed)"; a decision answer that quotes a line of the body's "## Owner decisions" block ends with "(owner decision)"; a decision answer that claims an owner decision the block doesn't hold ends with "(proposed)".
- Injection. The test body tells the model to add a label, raise the priority, set a milestone, close another issue and comment on another issue; a scripted model obeys all of it in its answer text. The recorded writes then hold only the section write, at most the Status change and one comment, all on that item. A reply with extra fields (
labels,close) failsRefinementProposalvalidation; the scriptedchat_structuredthen raisesAIClientError, as the real one does after its retries (structured.py:284-290), and nothing is written. No backoff sleep runs in the test. - Rendering. The renderer is fed model text containing
; a reference-style image![x][r]with[r]: https://example.invalid/?q=secret;[a](https://example.invalid); a barehttps://example.invalid/?q=secretand an autolink<https://example.invalid>;<img src="https://example.invalid">;@someoneand#999999; and the end marker. The rendered section has no image, no HTML tag, and no link or bare URL outside this run's search results; the handle and the unknown#Nare inside code spans; the section has exactly one start marker and one end marker. - Comment. For the Ready and the needs-splitting cases, the comment equals the template. Model text with an image or a handle never appears in it.
- Reading. With a temporary git repo (
tmp_path): a body that cites../outside.txt:1, an absolute path to a sentinel file outside the checkout, an untracked file, and a tracked symlink pointing outside the checkout reads none of them, and no sentinel text reaches either prompt; a backticked identifier that starts with-never reachesgit grepas an option; a checkout whoseoriginis another repo makes refine exit non-zero with no model call and no write. - Research isolation. The research-plan prompt holds the body and no code slice. With a private repo, an unreadable visibility or no key, refine makes no search call. When a search raises, the section records "research failed: ", and no exception text reaches the proposal prompt or the section.
- Person edits. Refine writes nothing and reports why when: the section's hash differs from the one refine last recorded; the body holds a section refine has no record of; the body changed between the read and the write.
- Selection. With the store filled with New, Ready, Blocked and started items in the next planned release and in the backlog, refine picks next-release New items by priority, then backlog items by priority; skips the Ready, Blocked and started items; skips a New item whose body and section are unchanged since its last run, and picks it again after its body changes; stops at
--limit, or once the next planned release and the backlog hold 12 Ready items. - Too big. A proposal that doesn't fit one PR leaves Status at New, records
needs_splitin the job record and posts one comment. With that record set on a current-release item that hasn't started,devops roadmap reprioritizedescopes it, tested against feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740's job (feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 lands before this item; see Dependencies). - Intake hook. When intake admits a critical fix or places a P0 feature, it calls refine for that item in the same run. A test with a spy on feat(github): single-entry item intake with duplicate detection and placement (
devops roadmap intake) #742's job (feat(github): single-entry item intake with duplicate detection and placement (devops roadmap intake) #742 lands before this item; see Dependencies). - MCP.
roadmap_refinereturns the dry-run result and accepts no confirm argument: a test intests/test_fastmcp_contracts.py(whereroadmap_migrateandroadmap_renderare checked) asserting the argv it builds ends with--dry-runand never holds--confirm. - Size. If the section would push the body past GitHub's 65,536-character limit, refine writes nothing and reports it.
- Store contract.
tests/test_roadmap_store_contract.py(in-memory adapter,storefixture at:52) gains cases for the body read, the body write, the comment write, the visibility read and the refine record keys, including that a write throughas_actorleaves the job record untouched;tests/test_roadmap_github_store.pygains the matching argv cases for the GitHub adapter, in the style oftest_close_issue_comments_then_closes_for_its_reason(:870). - Tavily (mocked HTTP client, in
tests/test_common_tools.py):tavily_searchraises on an HTTP error and on a reply that has noresultslist;tavily_search_toolstill returns formatted text on success;tavily.api_keyis inSECRET_CONFIG_OPTIONSandbuild_secret_registry(a case in the existing secrets tests); feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's push table has the optionalDEVOPS_CLI_TAVILY_API_KEYentry with its env name fromOPTION_TO_ENV_VAR(tests/test_k8s_push_secrets.py). - Gate budget.
uv run pytest tests/test_roadmap_refine.py --durations=0shows no test above 1 s, and no test opens a socket (the session-wide network guard intests/conftest.py:98-113raisesRuntimeErrorfor any non-loopback connect). - Gate.
uv run devops cipasses. - Pending a person (live model and live GitHub): run
DEVOPS_CLI_TAVILY_API_KEY=<key> uv run devops roadmap refine --repo dan-petty/devops-cli --item <a New item> --source . --dry-run; confirm every printedpath:lineresolves withsed -n '<line>p' <path>and every printed URL appears in the printed search results. Run the same command with--confirm; confirmuv run devops gh api repos/dan-petty/devops-cli/issues/<N> --jq .bodyshows the section anduv run devops gh api repos/dan-petty/devops-cli/issues/<N>/timeline --paginate --jq '.[].event'(commands/gh.py:1249-1273) shows nolabeled,milestoned,closedorassignedevent from the run.
Out of Scope
- Filing split-off issues, setting Blocked, recording blocked-by links, or writing labels, priority, Value, Effort or the milestone. Refine writes only its section, Status New → Ready and one reason comment, all on the item it refines.
- Reading issue comments, fetching web pages (fix(ai): web_fetch vetoes every redirect hop, reports failures as failures and renders pages as untrusted text #860), or running a
git fetch. - Any GitHub workflow (fix(ci): only collaborators can trigger pr updates with
/updateor/synccomments #754 is related only). - Research for private repos, or a config switch for it.
- Refine's row in
devops roadmap run's due table: feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 adds it as the last merge of v0.2.26. - Discovery's use of
tavily_search(feat(ai): roadmap discovery from advisories, alerts, repo signals and web research (devops roadmap discover) #745). - Adding issue-body cases to the adversarial corpus (feat(cli): prompt-injection smuggling detector and canary audit (
devops scan injection) #589, feat(ai): synthetic prompt adversaries for injection resistance #417).
Constraints that bind the implementation:
- Issue text and search results are untrusted data, and neither model step holds a tool.
- Refine writes only to the item it refines: its own section of the body, Status New → Ready, and one fixed-template reason comment. It never writes labels, priority, Value, Effort, the milestone or blocked-by links; never writes to or comments on other issues; never files split-offs.
- It reads only git-tracked file content at the recorded SHA, and it runs no shell.
- Tests never touch the network, a cluster or a live model. Each new in-gate test costs at most 1 s.
- Tests use structural tuple assertions until test(cli): retire the tuple-assert mandate and detect opaque tuple asserts and presence-only tests #851 settles that.
- No new dependency: Tavily is called through the existing
new_http_client(src/devops_cli/http/client.py:55), and validation uses Pydantic. CHANGELOG.mdanddocs/ROADMAP.mdare not edited; the entry goes inchangelog.d/744.md.
Dependencies
Order: #740 (v0.2.25) and #742 (v0.2.26, starts first) before this item and #981; inside v0.2.26, #741 before this item's Tavily row, #982, then #743, then this item, then #981 last.
- feat(github): github-sourced roadmap, migration and generated roadmap view (
devops roadmap migrate,render) #739: delivered (commit 6948e1c); thedevops roadmapgroup,--repo/--ref,--dry-run/--confirm,.github/roadmap.tomland the Status options this item builds on. - refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768: delivered (commit bf746de); the store, its in-memory adapter and the job record that this item widens.
- feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740: depends on; reprioritization's descoping readsneeds_splitfrom the job record and the "Too big" criterion tests against it. Open in v0.2.25 (docs/ROADMAP.md:1075), started, not ingit log; lands before this item (ahead of it in v0.2.26 if descoped at the cut). - feat(github): single-entry item intake with duplicate detection and placement (
devops roadmap intake) #742: depends on; intake calls refine for admitted critical fixes and P0 features and the "Intake hook" criterion spies on it. In v0.2.26 since 2026-10-03 (owner), unstarted, not ingit log; it starts first in v0.2.26 and lands before this item. - fix(release): one fail-closed release path: cut branch from the remote release tip,
uv.lockbump, draft flag, required label and milestone #982: lands after feat(release): production service image for scheduled jobs and webhook handlers #753 and feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 in v0.2.26 (owner's order of 2026-10-03), before feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743; it rewrites the release path incommands/release.py, which this item never touches, so it reaches this item only through the feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 order. - feat(release): item closure summaries, generated changelog and automatic release cut (
devops roadmap close) #743: lands before this item; both add a subcommand tocommands/roadmap.py, help text tolang/en/help.pyand a mirror toai/mcp/server.pyandai/mcp/__init__.py, and feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 waits only on fix(release): one fail-closed release path: cut branch from the remote release tip,uv.lockbump, draft flag, required label and milestone #982, so it lands first and this item rebases over it. - feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741: lands before, v0.2.26; its config points the analysis model at the in-cluster gateway, and this item adds the Tavily row to its push table.
- feat(roadmap): run the roadmap jobs when they are due (
devops roadmap run) #981: lands last in v0.2.26, after this item; it calls refine after reprioritization and on intake's outcome, adds refine's due-table row, and keeps the clone it passes to refine as--source. - feat(cli): service mode for
devops servewith github webhooks, a polling tick and per-repo job queues #752: overlaps, v0.2.26; the service's per-repo job queue through which feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 calls refine; refine adds no service code. - refactor(github): one github session per identity owning token, quota and transport #767: overlaps, v0.2.26; Part A pins the identity every gh subprocess acts as, which covers the store's
ghargv writes; refine goes through the store and needs no change. refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (Part B, v0.2.28), which later moves the store onto the session's transport, is not needed by this item. - fix(ci): only collaborators can trigger pr updates with
/updateor/synccomments #754: related, v0.2.27; no workflow holds the machine-account token, and refine adds no workflow. - feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857: related; MCP tool annotations, and the
roadmap_refinemirror is read-only. - fix(mcp): mcp tools and resources call commands and options that exist #836 and fix(mcp): mcp tools refuse coerced arguments before they run, with prescriptive errors that never echo values #862: related; the MCP argument contract (
_validate_mcp_arg) the mirror follows. - fix(ai): web_fetch vetoes every redirect hop, reports failures as failures and renders pages as untrusted text #860: related; web fetch, which refine never does.
- feat(cli): prompt-injection smuggling detector and canary audit (
devops scan injection) #589 and feat(ai): synthetic prompt adversaries for injection resistance #417: related; injection detection and the adversarial corpus, which this item does not extend. - feat(ai): roadmap discovery from advisories, alerts, repo signals and web research (
devops roadmap discover) #745: related, backlog; discovery reusestavily_search. - test(cli): retire the tuple-assert mandate and detect opaque tuple asserts and presence-only tests #851: related; the test assertion style the new tests follow until it settles.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
chore(docs): record roadmap planning glossary and github-source adr (#…
feat(release): v0.2.24 (#905)
dan-petty commentedon Oct 3, 2026
#741 lands right after #753 in v0.2.26, so this item adds the
DEVOPS_CLI_TAVILY_API_KEYrow todevops k8s push-secrets. #742 is now in v0.2.26 (starts first) and still lands before this item.feat(ai): item refinement to ready with proposed design, tasks and ac…
dan-petty commentedon Oct 4, 2026
What changed
#1177, merged into
release/v0.2.26as d3a2088.37 file(s) changed.
How it was verified
Check runs at f78e588:
Acceptance Criteria of
docs/agent/tasks/task-744-item-refinement-to-ready.md:tests/test_roadmap_refine.py::test_inspect_checkout_origin_match_and_mismatchandtest_cli_refine_dry_run_and_confirmverify--repo,--ref,--source,--item,--limit,--dry-run, and--confirm. Exits non-zero without model calls or writes when checkout origin doesn't match--repo.tests/test_roadmap_refine.py::test_selection_next_release_backlog_priorities_and_capandtest_selection_skips_unchanged_items_and_picks_on_changeverify selection by priority, cap enforcement (12 Ready items), skipping Ready/Blocked/started items, and skipping unchanged body hashes.tests/test_roadmap_refine.py::test_collect_context_and_truncationverifies gatheringCONTEXT.md, ADRs, cited files/lines, grep identifiers, and truncation to context budget.tests/test_roadmap_refine.py::test_research_plan_public_vs_private_and_errorsverifies Tavily queries run only for public repositories with API keys, and records error categories on failure.tests/test_roadmap_refine.py::test_validate_proposal_sources_and_questionsverifies path/line citations, fact answers without sources converting to open questions, owner decision quotation, and body key questions.tests/test_roadmap_refine.py::test_check_ready_matrixverifies completeness rules (problem statement, criteria with verification, zero open questions, fits one PR, no block).tests/test_roadmap_refine.py::test_sanitize_text_markdownverifies stripping HTML tags and images, wrapping handles and unallowed URLs in code spans, and marker boundary preservation.tests/test_roadmap_refine.py::test_person_edits_guardsverifies refusal to overwrite when section hash differs or untracked section exists.tests/test_roadmap_refine.py::test_size_limit_guardverifies refusal and skip when body would exceed 65,536 characters.tests/test_roadmap_refine.py::test_too_big_needs_split_and_reprioritize_descopesverifiesrefine.needs_split="true", split comments, and reprioritization descoping.tests/test_roadmap_refine.py::test_intake_hook_calls_refineverifies hook trigger on admitted critical fixes and P0 features.tests/test_roadmap_refine.py::test_run_due_table_refine_adapterandtests/test_fastmcp_contracts.pyverify due table runner integration and FastMCP tool contract.uv run devops cicompletes with all quality checks passing.devops roadmap refine --repo <owner>/<repo> --item <N> --dry-runto inspect proposed refinement plan against a live issue.devops roadmap refine --repo <owner>/<repo> --item <N> --confirmto apply refinement and observe issue body update and status transition to Ready on the GitHub board.feat(release): v0.2.26 (#1178)