Repository navigation
test(lifecycle): cite generator rule evidence by symbol, never by line - #4702
Conversation
There was a problem hiding this comment.
🟡 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
…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]>
… never by line Co-authored-by: Copilot App <[email protected]>
73febf4 to
5198b23
Compare
… never by line Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
🟡 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
Preserve distinct native filenames through export and installation · New Match the synthetic changed value by equality · New Enable the executable gate for user-scope approval probes · New Require an org-policy block before awarding refusal credit · New Verify instructions for every active target in routing scenarios · New
1 resolved since last review
Review effort: Balanced
5198b23 to
d6133df
Compare
There was a problem hiding this comment.
🟡 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
Preserve distinct native filenames through export and installation Require whitespace after a fence delimiter before closing it · New Verify instructions for every active target in routing scenarios Require an org-policy block before awarding refusal credit Enable the executable gate for user-scope approval probes Match the synthetic changed value by equality
Review effort: Balanced
d6133df to
cdf1ed8
Compare
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the migration from line-number citations to stable symbol anchors.
No open issues 🎉
6 resolved since last review
Preserve distinct native filenames through export and installation Require whitespace after a fence delimiter before closing it Verify instructions for every active target in routing scenarios Require an org-policy block before awarding refusal credit Enable the executable gate for user-scope approval probes Match the synthetic changed value by equality
Review effort: Balanced
cdf1ed8 to
9db35b1
Compare
9db35b1 to
c96e5f5
Compare
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]>
c96e5f5 to
1d6f306
Compare
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]>
- 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]>
…es, regenerate Co-authored-by: Copilot App <[email protected]>


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), renderedpath:NNNintolifecycle_obligations.json, plus prose citations such asexec_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) resolvespath::qualnamefor Python (a function, class or method including its decorators, or a module-level assignment) andpath::headingfor 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)replacesEv(path, line, needle)inrules.py. The anchors were migrated mechanically: locate the needle in the old window, then take the innermost enclosing symbol.EVIDENCE_WINDOWis gone.emit.pyrenders deduplicatedpath::symbolevidence into the ledger'srulesblock (33 line citations -> 0). Obligation statuses are unchanged (--checkclean, obligation-status ratchet clean).factors.py,rules.pyandtest_generator_rules.py(13) now name symbols.test_every_rule_cites_a_symbol_that_still_says_itchecks that every symbol still exists and still contains its needle. It also rejects anyfile.ext:NNNcitation 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(therulesblock only) and rewritesrules.pyanchors. Corpus trains that touchrules.pyor the ledger rebase on this or carry it; whichever lands second regenerates withpython -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/generatorcitespath.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
Testing
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.commands/approve.py:255citation put back intofactors.pyfails withfactors.py:47: commands/approve.py:255.retired_destinations.py::_GONE_SYMBOL: symbol is gone.Changelog
changelog.d/<pr>.<section>.md, holdingone line: user-visible effect first, 25 words or fewer, ending with
(#PR); breaking changes only under upgrade notes; no Highlights; nonew lines under
## [Unreleased]. Seechangelog.d/README.mdand.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated