Skip to content

fix(install): the no-op replay never re-decides Claude carriers (#5434) - #5447

Merged
Daniel Meppiel (danielmeppiel) merged 6 commits into
mainfrom
danielmeppiel-replay-carriers
Nov 25, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 6 commits into
mainfrom
danielmeppiel-replay-carriers

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 829caf72e52011e0539b8b0b6519fb396cc7f7ae

Dimension Assessment Rationale
Change confidence 8/10 ↑ 16 cells: 12 red on main 8225ec6 (run 45567096815), all 16 green at 0712e90 (run 45567169056; later commits add only the changelog fragment and an empty spec-waiver commit).
↑ The real-CLI cell (tree-10-claude) shows the replay hit on main and a miss here, printing what APM_INSTALL_FAST_PATH=0 prints.
↑ Only decline paths are added; the no-carrier control and the #5394 attested-refusal cell stay green.
↓ W3d ACCEPT at 3bd9908; later folds: a missing package copy counts as routable (Copilot) and the one-owner cell observes the replay (AQ003); QL ruled the engine decline in scope; full CI and Copilot at this head pending.
Diagnosis confidence 9/10 ↑ The replay keys no carrier file, and the engine predicate saw only root carriers, so a nested src/test/AGENTS.md escaped both (W3d RT1 cells).
Evidence fit 9/10 ↑ The cells reproduce the issue's scenarios: carrier appears, carrier removed, and nested carriers (W3d extension).

Description

The verified no-op replay (#5383) printed "up to date" after a Claude carrier changed. The full run reads the root AGENTS.md / CLAUDE.md, the compile record in APM home, and a directory's AGENTS.md for a routable instruction to decide whether a .claude/rules/ file is written or retired.

The fix follows the approved scope: only decline paths are added.

  1. One owner, light. The body of compiled_agents_md_may_carry moves to core/agents_md_compile_record.may_carry (the record exists, or a root carrier does); the compilation function delegates to it. The replay (verdict_record._verified_stdout) declines and the writer (verdict_write._record_after) records no replayable output while it holds. Cost per replay: 2 lstat and one read of the home record, with no compiler import.
  2. Nested carriers at the writer (W3d extension). When a Claude target has a potentially routable instruction, the run records nothing: verdict_record.unknown("claude routing") in instruction_integrator._claude_rule_sources. Routable means always-on or one literal directory, using the static routes_to_agents_md with no root, so an instruction whose directory does not exist yet counts. A record therefore exists only for a state with no routable instruction, and instructions come only from keyed inputs. So no carrier anywhere can change that run's outcome, and the hit stays sound.
  3. Nested carriers at the engine. diff_apply._refuse_claude_carried_rules also declines when a locked package ships a routable instruction (claude_agents_md.lock_ships_routable_instruction, through the integrator's own discovery and frontmatter parser; an unreadable file counts). This check runs before the attested branch, so attested hits are covered too.

Rejected alternative: a whole-tree scan for AGENTS.md on every replay has unbounded cost in monorepos, and it declines states the carrier cannot change.

Cost: projects with a root carrier, a compile record or a routable Claude instruction lose the replay and the engine fast path. The perf-fixture instructions are path-scoped (**/*.lang), so the benches are unaffected. Keying the routed prefixes to win this back is logged for 0.40.

Issue and approved scope

Issue: Fixes #5434

Human scope-approval comment: #5434 (comment), amended for the nested-carrier and engine fast-path declines: #5434 (comment). The nested-carrier extension was requested by W3d (RT1 cells, run 45565931975) and QL v2, and W3d accepted the design with the static-routability change.

Does this PR complete the issue, or what remains? Yes.

Type of change

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

Testing

  • Tested locally (the host load order: tests ran on CI only)
  • All existing tests pass (full CI pending at this head)
  • Added tests for new functionality (if applicable)

Evidence (CI, scratch workflow on each side; neither scratch branch is merged):

  • pytest tests/integration/test_verdict_record.py tests/integration/test_verdict_record_attested_world.py -k "carrier or routing or routable or root_agents_md or control_with_no or compile_record_appearing or claude"
    • main 8225ec6 plus the cells only: 12 failed, 4 passed (run 45567096815). The real-CLI cell fails on [i] verdict record: hit.
    • this head: 16 passed (run 45567169056).
  • ruff check / ruff format (pinned 0.15.12) on the changed files: clean.
promise: P-INV-I2 / outcome.status_matches_state -- a repeated install prints what the full run would do for the same state (source: tests/fixtures/lifecycle_bug_ledger/property_catalog/outcome.status_matches_state.json)
cell: OP=install DEPLOYED=claude-rules GATE=carrier-changed FAST=replay|engine   owner: core/agents_md_compile_record.may_carry, compilation/claude_agents_md.lock_ships_routable_instruction
instrument: today test -> tests/integration/test_verdict_record.py (extends) + tests/integration/test_verdict_record_attested_world.py::test_a_root_agents_md_after_a_replay_record_misses_and_the_full_run_decides (extends)
oracles: [I2, I7, byte-tree unchanged, output == APM_INSTALL_FAST_PATH=0 output]  decisive: "hit" not in traces after AGENTS.md appears
failing-before: run 45567096815 -> 12 failed, 4 passed
passing-after: run 45567169056 -> 16 passed
guard+mutation: n/a     ledger: 5434
hints executed: none printed

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)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

The full run reads the root AGENTS.md / CLAUDE.md and every compiled AGENTS.md
the compile record names (with its directory's CLAUDE.md) to decide whether a
Claude rule is carried. The verdict record did not key them, so a changed
carrier replayed 'up to date'. One owner, agents_md_compile_record.carrier_inputs,
lists them; compiled_agents_md_may_carry shares its root names.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Per the approved scope, the replay declines and the writer records no
replayable output while compiled_agents_md_may_carry holds; its body moves to
the light core/agents_md_compile_record.may_carry so the replay asks it
without importing the compiler. Nested carriers (W3d): a run whose Claude
target had a routable instruction (static routes_to_agents_md) records
nothing, and the engine fast path declines when a locked package ships one.
Replaces the carrier-keying commit, which the scope put out of scope.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 25, 2026 07:20
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
apm-spec-waiver: correctness fix, no spec surface change (#5434)

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

A missing package copy can pass routing checks and later be restored from the git cache while leaving a required Claude rule absent from the locked layout.

2 open issues
What changed in this PR

This PR addresses #5434 by making install optimizations fall back to the full pipeline when Claude instruction placement may depend on changed AGENTS.md or CLAUDE.md files.

Changes:

  • Centralizes carrier detection for the compiler, replay reader, and record writer.
  • Prevents replay recording and engine fast-path execution when routable Claude instructions require live carrier checks.
  • Adds regression coverage, a lifecycle bug record, and a changelog entry.
File Description
tests/​integration/​test_verdict_record.py Tests carrier changes, routing refusals, and replay controls.
tests/​integration/​test_verdict_record_attested_world.py Adds a real-CLI comparison with the full install pipeline.
tests/​fixtures/​lifecycle_bug_ledger/​bugs/​5434.json Records the failure mode and regression tests.
src/​apm_cli/​integration/​instruction_integrator.py Prevents recording runs with potentially routable Claude instructions.
src/​apm_cli/​install/​verdict_write.py Avoids recording replayable output when carriers may apply.
src/​apm_cli/​install/​verdict_record.py Rejects output replay when carriers may apply.
src/​apm_cli/​install/​diff_apply.py Extends engine refusal to locked routable instructions.
src/​apm_cli/​core/​agents_md_compile_record.py Provides the shared carrier-presence predicate.
src/​apm_cli/​compilation/​claude_agents_md.py Delegates carrier detection and inspects locked instructions.
changelog.d/​5447.fixed.md Documents the user-visible replay fix.

Review effort: Balanced

The engine can restore a missing copy from the git cache, so its
instructions are unknown when the predicate runs: decline.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 new engine refusal disables the engine even without an existing carrier and falls outside the explicit human scope approval, requiring amended approval or removal from this PR.

1 open issue
2 resolved since last review

Review effort: Balanced

Comment thread src/apm_cli/install/diff_apply.py Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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 reported for the changes preventing stale install replay when Claude instruction carriers affect rule deployment.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@danielmeppiel Daniel Meppiel (danielmeppiel) added the full-integration Run the full integration suite (ci-integration.yml) on this PR before merge label Nov 25, 2026
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 9d413dc into main Nov 25, 2026
96 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-replay-carriers branch November 25, 2026 08:29
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 25, 2026
…d-root refusal

apm-spec-waiver: no-op fast-path input keying fix; install outcomes are unchanged

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-integration Run the full integration suite (ci-integration.yml) on this PR before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Install no-op replay ignores root AGENTS.md / CLAUDE.md changes that decide Claude rules

2 participants