Skip to content

[BUG] Lifecycle generator rules cite source by line number, so unrelated PRs conflict in a merge train #4696

Closed

Description

Reporting and investigating a bug need no permission. Before implementing a
substantive fix for inclusion in APM, obtain human scope approval and a review
contact on this issue. Trivial documentation corrections have standing
preapproval. See Contributing.

For vulnerabilities, use SECURITY.md
instead of a public issue. Remove credentials and other sensitive data from logs.

Describe the bug
The lifecycle generator rules cite product source by line number, for example exec_gate.py:679 in tests/lifecycle/generator/rules.py, install/services.py:1025 in factors.py, and install.py:1233 in test_generator_rules.py. New rules generated in flight do the same (one cites audit.py:1431). A line number changes whenever the cited file changes, so two PRs that each edit the cited source file and refresh the citation conflict when they are combined in a merge train, even though neither is wrong. Combined landing then has to fall back to one PR at a time.

To Reproduce

  1. Open two PRs that each change src/apm_cli/commands/audit.py and regenerate or update the lifecycle rules that cite it by line.
  2. Combine both PRs in one merge train.
  3. The rule files conflict on the citation lines.

Expected behavior
Rules cite source by a stable anchor, such as module.py::qualname or the symbol name, so an unrelated edit to the cited file does not change the citation.

Environment (please complete the following information):

  • OS: any
  • Python Version: 3.12
  • APM Version: main (0.38.0 development)
  • VSCode Version (if relevant): n/a

Logs
A merge train combining two such PRs failed on the citation conflict.

Additional context
Tests only; no product behaviour change.

Activity

  1. added
    area/testing
    type/bug
    on Nov 21, 2026
  2. danielmeppiel commented on Nov 21, 2026

    @danielmeppiel
    CollaboratorAuthor

    Decision: approve
    Area: project
    Scope: Source citations in the lifecycle generator (tests/lifecycle/generator/rules.py, factors.py, test_generator_rules.py, and whatever emits new rules) use a stable anchor such as module.py::qualname or the symbol name instead of a line number, so an edit elsewhere in the cited file never changes the citation. Existing line-number citations are converted, and a check rejects new path.py:NNN citations in those files. Tests only; no product behaviour change.
    Done when: No file under tests/lifecycle/generator cites source as path.py:; a test fails when one is added; two PRs that both edit a cited source file combine without conflict on the rule files; CI is green. No CHANGELOG line (tests only).
    Out of scope: Citations in product source, docs or other test trees; changes to what the rules assert.
    Review contact: Daniel Meppiel (@danielmeppiel)

  3. added
    status/accepted
    on Nov 21, 2026
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

    area/testingstatus/acceptedtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions