Skip to content

test(lifecycle): cite generator rule evidence by symbol, never by line - #4702

Merged
Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
ql-w1-4696-symbol-evidence
Nov 22, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 1 commit into
mainfrom
ql-w1-4696-symbol-evidence

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Description

One commit on main (899d17b). When #4711 lands, this rebases and converts its added rules (U11, U-MKT, the re-anchored docs needle) the same way.

The lifecycle generator rules cited product source by line number (Ev(path, line, needle), rendered path:NNN into lifecycle_obligations.json, plus prose citations such as exec_gate.py:679). A line moves on every edit to the cited file, so two unrelated PRs that each refresh the citation conflict in a merge train (Train C'').

Evidence now names a stable symbol:

  • tests/lifecycle/generator/anchors.py (new) resolves path::qualname for Python (a function, class or method including its decorators, or a module-level assignment) and path::heading for Markdown (the section up to the next heading of the same or higher level), by AST and heading scan. An empty symbol means the whole file.
  • Ev(path, symbol, needle) replaces Ev(path, line, needle) in rules.py. The anchors were migrated mechanically: locate the needle in the old window, then take the innermost enclosing symbol. EVIDENCE_WINDOW is gone.
  • emit.py renders deduplicated path::symbol evidence into the ledger's rules block (33 line citations -> 0). Obligation statuses are unchanged (--check clean, obligation-status ratchet clean).
  • Prose citations in factors.py, rules.py and test_generator_rules.py (13) now name symbols.
  • test_every_rule_cites_a_symbol_that_still_says_it checks that every symbol still exists and still contains its needle. It also rejects any file.ext:NNN citation in the generator sources or the ledger's rule evidence (with a regex self-check). I folded it into the existing test so the AQ003 ratchet does not grow.

Root cause line: rule evidence was keyed to a line number, which changes on any unrelated edit to the cited file.

Coupling (H7): this regenerates tests/quality/lifecycle_obligations.json (the rules block only) and rewrites rules.py anchors. Corpus trains that touch rules.py or the ledger rebase on this or carry it; whichever lands second regenerates with python -m tests.lifecycle.generator.

Issue and approved scope

Issue: Fixes #4696

Human scope-approval comment: #4696 (comment)

Completes the issue: no file under tests/lifecycle/generator cites path.py:<line>, and a test fails when one is added (negative controls below). Edits elsewhere in a cited file no longer change any citation, so two such PRs no longer conflict on the rule files.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Validation evidence (local, through host_guard):

  • pytest -p no:xdist tests/lifecycle/generator/ tests/quality/test_promise_obligations.py tests/quality/test_generated_obligations.py: 85 passed.
  • python -m tests.lifecycle.generator --check: up to date.
  • python scripts/check_obligation_status_ratchet.py --base-ref <main>: clean.
  • python scripts/check_test_assertions.py: clean.
  • python scripts/check_complexity_ratchet.py --base-ref <main>: clean.
  • python -m tests.quality.taxonomy --changed: clean.
  • [email protected] check / format --check (CI paths): clean.
  • Negative control 1: a commands/approve.py:255 citation put back into factors.py fails with factors.py:47: commands/approve.py:255.
  • Negative control 2: renaming an anchor to a symbol that does not exist fails with retired_destinations.py::_GONE_SYMBOL: symbol is gone.

Changelog

  • One fragment per section, changelog.d/<pr>.<section>.md, holding
    one line: user-visible effect first, 25 words or fewer, ending with
    (#PR); breaking changes only under upgrade notes; no Highlights; no
    new lines under ## [Unreleased]. See changelog.d/README.md and
    .github/instructions/changelog.instructions.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The heading scan misinterprets shell comments inside fenced code blocks as Markdown headings, truncating sections and causing valid evidence to fail anchor validation.

1 open issue
What changed in this PR

This PR addresses #4696 by replacing line-number citations in the lifecycle generator with stable symbol and heading anchors, reducing merge conflicts caused by unrelated source edits. Product behavior and obligation statuses remain unchanged.

Changes:

  • Adds Python symbol and Markdown heading resolution for evidence validation.
  • Migrates rule evidence and prose citations to stable anchors, deduplicating emitted references.
  • Updates validation to check anchored evidence and reject line-number citations.
File Description
tests/​quality/​lifecycle_obligations.json Regenerates rule evidence with stable, deduplicated anchors.
tests/​lifecycle/​generator/​test_generator_rules.py Validates symbols and needles; rejects line-number citations.
tests/​lifecycle/​generator/​rules.py Migrates evidence definitions and rendering to symbols.
tests/​lifecycle/​generator/​factors.py Updates comment and docstring citations only.
tests/​lifecycle/​generator/​emit.py Deduplicates emitted evidence references.
tests/​lifecycle/​generator/​anchors.py Adds symbol and heading span resolution and citation detection.

Review effort: Balanced

Comment thread tests/lifecycle/generator/anchors.py Resolved
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
…idence for U11, U-MKT and every rule

The train's line-number anchors were re-derived by AST: 88 anchors, four
of which had already drifted (audit.py moved 10 lines; a docs page moved),
the #4696 failure mode itself.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) force-pushed the ql-w1-4696-symbol-evidence branch 2 times, most recently from 73febf4 to 5198b23 Compare November 22, 2026 10:42
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Bundle installation can omit a distinct Claude agent file, and lifecycle checks can award misleading gate, policy-refusal, and routing credits while the generator misclassifies unchanged cases.

5 open issues
1 resolved since last review

Review effort: Balanced

Comment thread tests/lifecycle/generator/emit.py Resolved
Comment thread tests/lifecycle/scenarios/_kit.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The fence parser incorrectly accepts trailing non-whitespace as a closing fence, causing code-block headings to become anchors and truncate sections; the closing-fence check and regression coverage need correction.

6 open issues

Review effort: Balanced

Comment thread tests/lifecycle/generator/anchors.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues blocking approval of the stable-anchor citation changes.

No open issues 🎉

Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the migration from line-number citations to stable symbol anchors.

No open issues 🎉

Review effort: Balanced

Generator rules cited product source as path:line (Ev(path, line, needle)
plus prose comments). A line moves on every edit to the cited file, so two
unrelated PRs that refresh it conflict in a merge train, and anchors drift.
Evidence now names a symbol: path::qualname for Python (function, class or
method with its decorators, or a module-level assignment) and path::heading
for Markdown (code fences ignored; a fence closes only with nothing after it),
resolved in tests/lifecycle/generator/anchors.py; the needle must appear
inside that symbol's span.

test_every_rule_cites_a_symbol_that_still_says_it rejects any file:line
citation in the generator sources and in the ledger's rule evidence. All 88
anchors on main (including #4711's and #4734's) were converted mechanically:
needle located, innermost enclosing symbol taken. Obligation statuses are
unchanged.

Fixes #4696

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the migration from line-number citations to stable source anchors.

No open issues 🎉

Review effort: Balanced

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 76be7b6 into main Nov 22, 2026
72 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the ql-w1-4696-symbol-evidence branch November 22, 2026 20:16
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
Train-5 rule evidence moves to symbol anchors: U-BIN-OPS cites exec_gate.py::plugin_bin_deployable, U-FIRST-PARTY-MCP approve.py::scan_installed_executable_packages, U-MCPOWN-USER retired_destinations.py (module) and ::split_mcp_claims. Every Ev resolves; obligations regenerated.

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
- New architecture check (scripts/architecture_linter/checks/path_check_root.py,
  under transport-platform-url-path-security): only _locator,
  _write_locator, locator_for_path and deployed_path_entry's _try_target may
  build a CheckRoot; a CheckRoot name (built, aliased or a CheckRoot-annotated
  parameter) may only be passed to _encode/_locator/locator_for_path, read
  through .resolve/.within/.resolved/.root, compared or aliased to a local.
  Returns, yields, containers, attribute/subscript stores and
  global/nonlocal fail. The line regex stays as a backstop.
- deployed_path_entry builds one CheckRoot per target attempt; no helper
  returns one.
- Five confirmed-bypass mutations (session attribute, alias store, multiline
  store, helper return, module cache) are caught; the real tree is clean.
- Merge main (symbol-cited lifecycle rule evidence, #4702).

Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants