Skip to content

fix(roadmap): refine watches numbers and names as file paths #6444

Closed

Description

@dan-petty

Problem Description

Refine records the "files" of a person wait in refine.wait_refs. It takes them from the wait text with text_paths (src/devops_cli/roadmap/refine/refine.py:2260-2268). text_paths keeps each match of _CITED_PATH_RE (refine.py:781-783):

r"(?:[\s\(\[`]|^)([a-zA-Z0-9_\-\./]+\.[a-zA-Z0-9_]+)(?::(\d+)(?:-(\d+))?)?(?:[\s\)\]`:]|$)"

The pattern matches every token with a dot in it. A decimal (0.202), a version (v1.37.2), a dotted setting (ai.portkey_url), a Python name (DevOpsCLIError.__init__) or a domain (deps.dev) is a "path". text_paths does not check that the path exists. It then keeps only the first CONST_ROADMAP_REFINE_MAX_WAIT_CHECKS = 5 paths (src/devops_cli/config/constants.py:3440). So false paths take the slots of the cap, and a real file that the text names after them is not watched. A change of that file does not end the wait.

The pattern also misses a real path that a period or a comma follows, because the character after the path must be a space, a bracket, a backtick, a colon or the end of the text. In the text "Read src/devops_cli/commands/ai.py." the path is not found.

Each false path also costs one GitHub commits read in each round that checks the wait: _named_cause_ended (refine.py:2339-2348) calls changed_since, and path_changed_at (src/devops_cli/roadmap/stores/github_store.py:1094-1102) reads the commits of the path.

The cause: _CITED_PATH_RE came on 2026-10-04 (e70df90) to put cited files in the model context. There, _read_git_file (refine.py:787-792) drops a path that the commit does not hold. #3555 (ce689f4, 2026-11-04) used the same pattern for the wait watch, with no such check. stage_rejected.py:172 uses text_paths for the reason of a rejected plan, so the stage hold has the same defect.

Real records (job records in the issue bodies, read 2026-11-19 from 1,175 issues updated since 2026-11-01):

The spec says that the record holds "the issues, then the paths, that the wait text names" (openspec/specs/roadmap-refine/waits/spec.md:91). docs/roadmap/refine.md:31 says "A round reads at most 5 issues and 5 files of one wait."

Reproduction Steps

  1. On origin/main (0d90de5), run:

    uv run python -c "
    from devops_cli.roadmap.refine.refine import text_paths
    t = ('Edit AGENTS.md and src/devops_cli/commands/ai.py first. The current path has nDCG@10 0.202 today. '
         'Hybrid has 0.453 (+0.252). Bump v1.37.2 first, then read docs/roadmap/refine.md '
         'and src/devops_cli/roadmap/refine/refine.py today.')
    print(text_paths(t))"
  2. See ['AGENTS.md', 'src/devops_cli/commands/ai.py', '0.202', '0.453', 'v1.37.2']. The two real files at the end are not in the list.

  3. Read the job record of feat(ai): give every agent brain tools through MCP, CLI and skill #4671: refine.wait_refs ends in 0.202,0.453.

Expected vs Actual Behavior

Expected: refine.wait_refs holds only paths of files (or directories) of the repository tree. A number, a version, a setting key, a Python name or a domain takes no slot of the cap. The 5 slots go to the first 5 real paths that the wait text names.

Actual: every dotted token is a path. False paths fill the cap, real cited files drop out, and each false path costs one GitHub read in each round that checks the wait.

Environment Diagnostics

  • DevOps CLI Version: 0.180.0 (origin/main 0d90de5)
  • Python Version: 3.14.10
  • Execution Environment: the refine job of the roadmap Service in the cluster; the replay ran in the devcontainer.

Logs, Traces, or Terminal Output

# Job record of #4671
"refine.wait_refs": "#4880,#3904,#4921,#4884,#4479,AGENTS.md,src/devops_cli/commands/ai.py,CONTEXT.md,0.202,0.453"

# Job record of #6365
"refine.wait_refs": "...,v3.16.0,1.27.3,1.26.11,1.27.4,v0.62.0"

# Job record of #4750
"refine.wait_refs": "...,4.53,4.52,4.48,4.51,1.0.44"

Pre-Submission Checklist

Acceptance Criteria

  • A test: a wait text that names 0.202, v1.37.2, ai.portkey_url and deps.dev before 2 real files gives a refine.wait_refs with the 2 real files and none of the 4 tokens.
  • A test: a wait text that names 6 real files keeps the first 5, as today.
  • A test: a real path that a period or a comma follows ("Read src/devops_cli/commands/ai.py.") is in refine.wait_refs.
  • A test: the stage hold of a rejected plan (stage_rejected.py:172) keeps no number or setting key as a path.
  • A test: a false path makes no commits read (path_changed_at).
  • Live proof: after the merge and the release, the next round that reads the comments of feat(ai): give every agent brain tools through MCP, CLI and skill #4671 records no 0.202 or 0.453. A comment gives the new record value.

Dependencies

Alternatives check of 2026-11-19: none.
Tool: none found.
Reason: Searches found no library that pulls repository paths out of prose or filters dotted tokens; only path validators and Git clients exist, and the fix is a small regex boundary plus a git tree check the project already runs.

Lacks:

  • No token extraction from wait text
  • No sentence punctuation boundary handling
  • No repository tree membership filter
  • No five-path cap or duplicate removal

Proposed design

Problem statement

Refine must keep only real repository paths in refine.wait_refs. False dotted tokens fill the 5-path cap and cost GitHub commits reads. Real files then drop out. The stage hold of a rejected plan has the same defect. The fix filters candidates by the default branch tree and finds a path before a period or a comma.

Acceptance criteria

Requirement: False dotted tokens take no path slot

The wait path extractor SHALL keep only candidates that the repository tree check accepts as a file or a directory.

Scenario: Dotted values before two real files

  • WHEN A unit test gives a wait text with 0.202, v1.37.2, ai.portkey_url and deps.dev before two real files. The tree lookup accepts only the two real files.
  • THEN The extractor returns ['AGENTS.md', 'src/devops_cli/commands/ai.py'] and none of the four dotted values.

Requirement: Cap keeps the first five real paths

The wait path extractor SHALL apply the 5-path cap after it drops the candidates that the tree check rejects.

Scenario: Six real files

  • WHEN A unit test gives a wait text with 6 real repository files in order. The tree lookup accepts all 6 files.
  • THEN The extractor returns the first 5 files and drops the sixth.

Requirement: Path before a period or a comma

The cited-path pattern SHALL accept a period or a comma after a repository path.

Scenario: Sentence punctuation after a path

  • WHEN A unit test gives Read src/devops_cli/commands/ai.py. and See AGENTS.md,. The tree lookup accepts both paths.
  • THEN The extractor returns src/devops_cli/commands/ai.py and AGENTS.md.

Requirement: Stage hold drops dotted values

The stage hold of a rejected plan MUST use the same repository-tree filter as the refine wait.

Scenario: Rejected plan with a decimal and a version

  • WHEN A unit test gives a rejected-plan reason with 0.202 and v1.37.2 before AGENTS.md. The tree lookup accepts only AGENTS.md.
  • THEN The stage hold records AGENTS.md only and holds no decimal or version.

Requirement: No commits read for a false path

The wait check MUST read no commits for a token that the repository-tree filter rejects.

Scenario: False token in a wait text

  • WHEN A unit test runs the wait check with 0.202 and src/devops_cli/commands/ai.py. The tree lookup accepts only the real file. The fake store records path reads.
  • THEN The fake store records one path_changed_at call for src/devops_cli/commands/ai.py and no call for 0.202.

Requirement: Directory path is watched

The wait path extractor SHALL accept a repository directory as a watched path.

Scenario: Directory in the tree

  • WHEN A unit test gives foo.bar and the tree lookup reports that repository directory.
  • THEN The extractor returns foo.bar.

Existing Tool Considered

The alternatives check in the issue body records verdict none and no tool. No open maintained library covers the need. The plan adds a small filter around Git. The written cost is about 15 lines, under 2,000 tokens, and about 1 hour to build, keep and fix.

Key questions

  • How does the fix tell a real repository path from a dotted token?: It checks each candidate against the repository tree before the candidate takes a slot. A regex allowlist cannot tell a decimal, a version, a setting, a Python name or a domain from a file. The project already drops a cited path that the commit does not hold. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:781, src/devops_cli/roadmap/refine/refine.py:787, src/devops_cli/roadmap/refine/refine.py:2260]
    • Rejected: Regex allowlist of known file types. The false tokens use the same characters as real paths, so a fixed set does not cover them.
    • Chosen: Repository tree check. Only tree membership tells a real path, and the project already checks cited paths against a commit.
    • Rejected: New path-parser library. No library knows this repository's tree, and Git already covers the membership check.
  • Which tree does the check read?: It reads the default branch tree that the wait watch reads, not the working tree. It accepts a file or a directory that the pattern finds. (best practice) [sources: src/devops_cli/roadmap/stores/github_store.py:1094, src/devops_cli/roadmap/refine/refine.py:787, docs/roadmap/refine.md:31]
    • Rejected: Working tree with Path.exists(). A local file can pass and a default branch file can fail.
    • Chosen: Default branch tree with a Git tree check. It matches the commits that the wait watch reads and accepts a directory.
    • Rejected: GitHub contents API. It adds a request for each token.
  • Where does the 5-path cap apply?: It applies after the tree check drops false candidates. The first 5 real paths take the slots. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:2260, src/devops_cli/config/constants.py:3443, docs/roadmap/refine.md:31, openspec/specs/roadmap-refine/waits/spec.md:91]
    • Rejected: Apply the cap before the tree check. False tokens fill the cap and real files drop out.
    • Chosen: Apply the cap after the tree check. It matches the expected behavior and the documented 5-file limit.
    • Rejected: Remove the cap. The docs and the spec set 5, and each path costs a GitHub read.
  • How does the pattern handle a period or a comma after a real path?: Add . and , to the trailing boundary of _CITED_PATH_RE at src/devops_cli/roadmap/refine/refine.py:781. The path group stays unchanged, so ai.py. and AGENTS.md, match. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:781]
    • Chosen: Add . and , to the trailing boundary. The regex accepts the sentence punctuation and keeps the path group unchanged.
    • Rejected: Strip punctuation after a match. The regex still rejects the text before the strip.
    • Rejected: Match all dotted tokens and split. It adds ambiguity for real file names.
  • Does the stage hold use the same filter?: Yes. stage_rejected.py:172 calls the same wait path extractor with the same tree check. A rejected plan keeps no decimal or setting key as a path. (best practice) [sources: src/devops_cli/roadmap/stage/stage_rejected.py:172, src/devops_cli/roadmap/refine/refine.py:2260]
    • Chosen: Shared wait path filter. It removes the same defect and one test covers both callers.
    • Rejected: Stage-only filter. It duplicates the code and the two filters can drift.
  • How does the fix stop a false path from causing a commits read?: The tree check drops the false token before the caller writes refine.wait_refs. _named_cause_ended then never passes it to path_changed_at. (best practice) [sources: src/devops_cli/roadmap/refine/refine.py:2339, src/devops_cli/roadmap/stores/github_store.py:1094]
    • Rejected: Filter inside path_changed_at. The token already took a cap slot and the record is wrong.
    • Chosen: Filter before the record. The false token never reaches the store.
    • Rejected: Cache negative reads. The first GitHub read still costs and the cap stays full.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    scope/roadmap
    on Nov 19, 2026
  2. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. Each false path costs a GitHub API read per round and real file changes fail to end waits, causing increased spend and incorrect behavior. The regression commit ce689f4 does not set P0: the author has no write access, and no caller attached it as evidence. A person can set P0 with the label priority/p0-critical.
    • Related: fix(roadmap): the stage job refuses a plan that names a path that does not exist #3010, which asks for a different change. Both deal with path existence validation in the roadmap, but #3010 fixes the stage job plan rejection while this candidate fixes the refine wait watch path extraction.
  3. added
    status/new
    value/medium
    effort/medium
    priority/p1-high
    on Nov 19, 2026
  4. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

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

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (7)

    Tools considered:

    Searches run:

    • python validate file path exists in git repository tree library, results: 5
    • python library extract file paths from text regex, results: 5
    • pathvalidate PyPI path validation library, results: 5
    • "file path" extraction from prose text library github, results: 5
    • dulwich git library python tree membership, results: 5
    • python package parse file paths mentioned in text, results: 5
    • library that finds repository file paths in prose with existence check, results: 5

    Sources:

  6. added
    status/ready
    and removed
    status/new
    on Nov 19, 2026
  7. devops-cli-service commented on Nov 19, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  8. added
    owner/service
    on Nov 20, 2026
  9. devops-cli-service commented on Nov 20, 2026

    @devops-cli-service
    Contributor

    Plan state: branch fix/6444-refine-watches-numbers-and-names-as, draft pull request #6546. The pull request plans the item and closes no issue. The stage job and the step fix-plan edit this comment, and a comment of each run tells what the run did.

    The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:

    1. Keep only the paths that the tree holds in a wait and in explain: 45410 tokens
    2. Filter the paths of a rejected plan's hold: 53811 tokens
    3. State the tree filter in the refine document: 23334 tokens

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • major other at tasks (2): The new tree filter drops the reason's only path from the stage hold, because the stage test clone does not track src/devops_cli/roadmap/runner_tools.py, yet the existing case asserts that path. The plan names no update of that case, so the group's own verify fails. Evidence: "paths=("src/devops_cli/roadmap/runner_tools.py",),"
    • major other at tasks (1): Group 1 gives the tree only from plan_refine, but the public select_candidates calls _select_round with no checkout, and refine_left_out builds _Selection(store) for devops roadmap explain. The plan says nothing about the filter there, so that path either raises for the missing tree or keeps false paths and ends a wait the round keeps, which the module forbids (fix(roadmap): refine looks again when the cause of a wait ends #3483). Evidence: "selected, waiting, _ = _select_round(store, item_number=item_number, limit=limit, actor=actor)"
    • minor false_premise at tasks (1): Group 1 tells the implementer to give the tree to _Select, a class the module does not hold; the selection class is _Selection. Evidence: "class _Selection:"
    • minor other at tasks (3): The group's documentation line says to update tests/roadmap/test_roadmap_limit_classes.py, but the group changes only a hand-written document and lists no test in changes; that registry holds limit constants and no edit of docs/roadmap/refine.md touches it. Evidence: "Update tests/roadmap/test_roadmap_limit_classes.py"
    • major other at tasks (2): The plan moves the reason's cited path to CONTEXT.md, but it leaves test_a_commit_that_changed_a_file_the_reason_names_ends_the_hold seeding a commit on src/devops_cli/roadmap/runner_tools.py. The record then holds only CONTEXT.md, so the hold never ends and the freed selection in that case is empty, which fails the group's own verify. Evidence: "make the constant EVIDENCE cite CONTEXT.md, and update the expected paths of test_a_rejected_plan_returns_the_item_to_new_and_records_the_rejection to ("CONTEXT.md",)"
    • major other at tasks (1): The plan tells the select_candidates cases to take the tree of their clone, but the bound case in test_roadmap_refine_person_wait.py names twelve src/gone_*.py paths that the git_repo clone does not track. The filter drops all twelve, so the expected five path_changed_at reads become none and the group's verify fails. Evidence: "Give the select_candidates cases of tests/roadmap/refine/test_roadmap_refine_person_wait.py and of tests/roadmap/refine/test_roadmap_refine_selection.py the tree of their clone"
    • minor spec_delta_wrong at spec roadmap-refine/waits (A wait keeps only the paths that the tree holds): The delta adds a requirement about what refine.wait_refs holds but does not modify the existing requirement A read of the comments of a waiting item is recorded, which still says the record holds the paths that the wait text names. The spec then states two different contents for the same record. Evidence: "openspec/specs/roadmap-refine/waits/spec.md:91:(the issues, then the paths, that the wait text names)"
    • minor other at tasks (3): Group 3's documentation tells the builder to update tests/roadmap/test_roadmap_limit_classes.py, but the group's changes list only docs/roadmap/refine.md and the plan adds no limit constant, so the registry of limits needs no update and the group would touch an undeclared test file. Evidence: "Update tests/roadmap/test_roadmap_limit_classes.py"
    • minor missing_path at tasks (1): Group 1 makes explain_item read the tree, but the plan does not change src/devops_cli/roadmap/request_plan.py, whose explain_requests lists every read that devops roadmap explain --dry-run prints, so the dry-run list misses the new git read. Evidence: "read the tracked paths once with tree_files of the clone's HEAD in explain_item and give the set to _refine_verdict and to refine_left_out"
    • minor spec_delta_wrong at spec roadmap-refine/waits (A wait records only the paths that the tree holds): The delta adds a second rule for refine.wait_refs and leaves the base requirement that the record holds the paths the wait text names unmodified, so the capability keeps a requirement that the new tree filter breaks. Evidence: "and refine.wait_refs (the issues, then the paths, that the wait text names)"
  10. 19 remaining items

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

    @devops-cli-service
    Contributor

    Live since 2026-11-20 22:40 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/p1-highscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions