Skip to content

fix(roadmap): Skip Python keywords in stage removal names #6328

Closed

Description

@dan-petty

Problem

On 2026-11-18, a live devops roadmap eval stage case on origin/main failed with RoadmapStageError. The error lists every test file of the repository, each with unhandled reference to 'and':

tests/ai/agents/test_agent.py: unhandled reference to 'and'. tests/ai/agents/test_agent_invariants.py: unhandled reference to 'and'. ...

find_removed_names in src/devops_cli/roadmap/stage/stage_removal_references.py keeps each backticked span after a removal verb when str.isidentifier() is true. "and".isidentifier() is true, so a plan line such as "drops and from the title" makes and a removed name. scan_removal_references then finds and in every Python file and the stage item fails. A Python keyword is never an entity that a plan removes.

Expected behavior

  • find_removed_names skips a span that is a Python keyword (keyword.iskeyword) or a soft keyword (keyword.issoftkeyword).
  • A test shows that a plan text with "drops and from" gives no removed name, and that "removes old_helper" still gives old_helper.

Related

Alternatives check of 2026-11-18: covers.
Tool: python/cpython (https://github.com/python/cpython), NOASSERTION, last activity 2026-11-18, maintained.
Reason: Searches found no third-party library, but Python's own standard-library keyword module already answers the question exactly (iskeyword, issoftkeyword), and the issue itself names those calls as the fix.

Covers:

  • Rejects hard keywords such as and, for and class
  • Rejects soft keywords such as match, case and _
  • Ships with Python, so no new dependency or pin

Lacks:

  • Does not find backticked spans after a removal verb
  • Does not test whether a span is an identifier (str.isidentifier)
  • Knows nothing of plan text or the files to scan

Proposed design

Problem statement

find_removed_names keeps every backticked span after a removal verb whose text passes str.isidentifier(). "and".isidentifier() is true, so a plan line such as "drops and from the title" makes and a removed name, scan_removal_references finds it in every Python file, and the stage fails with RoadmapStageError. A Python hard or soft keyword is never an entity that a plan removes, so the extraction excludes them.

Acceptance criteria

Requirement: Hard keyword skip

find_removed_names SHALL exclude a backticked span that is a Python hard keyword.

Scenario: A plan drops and

  • WHEN find_removed_names receives the text "The change drops and from the title."
  • THEN The test asserts that the returned set is empty.

Requirement: Soft keyword skip

find_removed_names SHALL exclude a backticked span that is a Python soft keyword.

Scenario: A plan drops match

  • WHEN find_removed_names receives the text "The change drops match from the title."
  • THEN The test asserts that the returned set is empty.

Requirement: Passive keyword skip

find_removed_names SHALL exclude a keyword span in the passive removal form as well as the active one.

Scenario: A plan says and is removed

  • WHEN find_removed_names receives the text "and is removed from the title."
  • THEN The test asserts that the returned set is empty.

Requirement: Ordinary identifier kept

find_removed_names SHALL keep a backticked span that is an ordinary Python identifier after a removal verb.

Scenario: A plan removes old_helper

  • WHEN find_removed_names receives the text "The change removes old_helper."
  • THEN The test asserts that the returned set is {"old_helper"}.

Requirement: Stage scan survives a keyword span

scan_removal_references SHALL report no unhandled test reference for a plan whose only removed span is a Python keyword.

Scenario: A change folder drops and

  • WHEN scan_removal_references runs on a change whose proposal.md says "drops and from the title" and on a repository whose test file contains and.
  • THEN The test asserts that has_test_failures is false and unhandled_tests is empty.

Existing Tool Considered

python/cpython (https://github.com/python/cpython) is the open, maintained tool that covers this need: the alternatives block of 2026-11-18 in the issue body records the verdict covers and states what the tool lacks. The change calls keyword.iskeyword and keyword.issoftkeyword in find_removed_names.

Key questions

  • Should the item adopt the keyword module of python/cpython, or keep its own keyword list?: Adopt the standard-library keyword module: guard each candidate span with keyword.iskeyword(span) or keyword.issoftkeyword(span) next to the existing span.isidentifier() check, and add import keyword. The project floor is Python 3.14 (pyproject.toml:10), which ships both calls, so no dependency or pin is added. (best practice) [sources: src/devops_cli/roadmap/stage/stage_removal_references.py:74, src/devops_cli/roadmap/stage/stage_removal_references.py:84, pyproject.toml:10]
    • Chosen: Standard-library keyword module (python/cpython). It rejects hard and soft keywords exactly, ships with the supported Python floor, and needs no new dependency or pin.
    • Rejected: Hard-coded keyword tuple. It duplicates CPython's list and drifts from the interpreter, and it misses soft keywords unless it is maintained by hand.
    • Rejected: Third-party parser library such as libcst. It adds a dependency for a one-line membership test that the standard library already answers.
    • Rejected: Keep only str.isidentifier(). It accepts and, which is the cause of the stage failure.
  • Where should the keyword guard go?: Put the rule in one private helper _is_removable_identifier(span) that strips the span and returns true only when it is an identifier that is neither a hard nor a soft keyword. Call it from both the passive match loop and the active match loop, so the two paths cannot drift apart. (best practice) [sources: src/devops_cli/roadmap/stage/stage_removal_references.py:72, src/devops_cli/roadmap/stage/stage_removal_references.py:77]
    • Chosen: One private helper used by both match paths. The passive and active loops share one rule, so a later change reaches both paths at once.
    • Rejected: An inline condition in each loop. The same rule appears twice and can change in one place only.
    • Rejected: Filter the final set. The scan builds its patterns from the set, and a final filter hides which span the extraction rejected.
  • Why does the current code treat and as a removed name?: Both match paths accept a span when str.isidentifier() is true alone. str.isidentifier() returns true for and, so the span is added to the removed names and later matched in every Python file. [sources: src/devops_cli/roadmap/stage/stage_removal_references.py:74, src/devops_cli/roadmap/stage/stage_removal_references.py:84, src/devops_cli/roadmap/stage/stage_removal_references.py:185]

Open questions

  • The alternatives check found that https://github.com/python/cpython covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

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

    @dan-petty
    OwnerAuthor
    • Priority: P0-Critical. A live stage job on origin/main fails with RoadmapStageError, which is a service job failure.
    • Related: feat(roadmap): Check test references to entities a plan removes #3324, which asks for a different change. #3324 added the removal-reference check; this candidate fixes a bug in that check where Python keywords are treated as removed names.
  3. added
    scope/roadmap
    status/new
    effort/low
    value/high
    priority/p0-critical
    on Nov 18, 2026
  4. devops-cli-service commented on Nov 18, 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 (10)

    Tools considered:

    Searches run:

    • Python keyword module iskeyword issoftkeyword identifiers, results: 5
    • Python library detect identifiers excluding keywords from text, results: 5
    • python stdlib keyword module documentation, results: 5
    • docs.python.org keyword issoftkeyword iskeyword test whether string is reserved, results: 5
    • "keyword" module Python 3 standard library iskeyword issoftkeyword soft keywords match case, results: 5
    • iskeyword function python check string is a keyword, results: 5
    • libcst PyPI parse Python source identifiers, results: 5
    • pypi requests library, results: 5
    • python keyword issoftkeyword documentation library reference, results: 5
    • github python cpython Lib/keyword.py iskeyword source, results: 5

    Sources:

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

    @devops-cli-service
    Contributor

    Owner question: The alternatives check found that https://github.com/python/cpython covers this item. Adopt the tool, or keep the item and give the reason. (a person decides)

    Options

    1. Decide the question: The job refines the item with your answer.
    2. Leave it to the job: The job records the best-practice answer and goes on.

    Recommendation: Decide the question: only a person can answer it.

    Evidence

  6. dan-petty commented on Nov 19, 2026

    @dan-petty
    OwnerAuthor

    Decision on the owner question: adopt the tool. The fix uses the standard-library keyword module of python/cpython.

    Reason: the owner's standing direction is "follow best practices". The module is part of Python 3.14, the project floor, so the fix adds no dependency. A hand-made keyword list would not follow new Python releases.

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

    @devops-cli-service
    Contributor

    Live since 2026-11-19 05:06 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/lowpriority/p0-criticalscope/roadmapsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions