Repository navigation
fix(integration): render, then adopt for every agent writer (#3722) - #3743
Daniel Meppiel (danielmeppiel) merged 12 commits into
Conversation
Signed-off-by: Mohammed Alkindi <alkndymhmd692@gmail.com>
|
Thank you Mohammed Alkindi (@MohammedAlkindi), this is the right seam: routing Codex adoption through |
…t#3722) Codex TOML, Kiro agents and verbatim-copy agents whose relative links APM rewrites now all render first, ask BaseIntegrator._check_adopt_or_skip with expected_content=<rendered>, and write that same text through one AgentIntegrator._deploy_rendered_agent helper. Kiro's inline read_bytes adoption, the raw-source copy_agent adoption and the deprecated integrate_package_agents try_adopt_identical calls are folded into the owner, and the dead _write_kiro_agent writer is removed. A second `apm install -g` of root-local agents (no lockfile entry) now adopts APM's own output instead of reporting files skipped. Guard: install-deployment-agent-render-then-adopt (registered on the file-level-deploy-sync-cleanup owner) forbids raw adoption/collision primitives, adoption-free writers and stray write_text_lf in agent_integrator.py. The Codex link guard now follows _render_codex_agent. Tests: unit render-then-adopt matrix (codex, kiro, copilot, claude, foreign edits, legacy entry) and the RT3 L6 lifecycle oracle (test_global_agent_adoption_lifecycle.py) on the real binary. apm-spec-waiver: adoption is an internal idempotency fix; no OpenAPM observable contract changes Co-authored-by: Mohammed Alkindi <alkndymhmd692@gmail.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | Single-owner render-then-adopt discipline is correct; guard is robust; no blocking regressions in adoption, accounting, or deprecated entry semantics. |
| Test Coverage Expert | 0 | 1 | 0 | Bug fix well defended by unit matrix, real-binary lifecycle oracle and guard mutation; one recommended gap: direct edge-case tests for the adoption comparison primitive. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 1 follow-ups
- [Test Coverage Expert] Add direct unit tests for
is_content_identical_to_text: CRLF normalization, missing target, symlink target and OSError, mirroring the siblingis_content_identical_to_sourcetests. -- The primitive now gates idempotency for every rendered-agent adoption path, and an edge-case failure would show up as a silent rewrite or a false skip.
Recommendation
The unit matrix, the real-binary lifecycle oracle and the guard mutation suite back the fix, and both panelists agree it is correct. Ship after the maintainer lane folds the in-scope follow-up, the direct is_content_identical_to_text edge-case tests. The gap predates this PR, but the primitive is now on a hotter path.
Full per-persona findings
Python Architect
No findings.
Test Coverage Expert
- [recommended]
is_content_identical_to_texthas no direct unit tests, but this PR makes it the comparison primitive for all rendered-agent adoption via_check_adopt_or_skip(expected_content=...). Seetests/unit/integration/test_content_identical_adopt.py.
The method already existed on main. Its siblingis_content_identical_to_sourcehas edge-case tests for CRLF, symlinks, missing targets and OSError, but grep finds no direct test of the text variant. Indirect coverage comes fromTestRenderedAgentAdoption(8 cases).
Suggested: Add aTestIsContentIdenticalToTextclass totests/unit/integration/test_content_identical_adopt.py, mirroring the sibling's edge-case tests and parametrized overlf_normalized_deploy.
Proof (missing at):tests/unit/integration/test_content_identical_adopt.py::TestIsContentIdenticalToText
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
…soft#3722) Folds the review-panel follow-up on microsoft#3743: the rendered-content comparison behind _check_adopt_or_skip(expected_content=...) now decides adoption for every agent writer, so pin its LF-normalization, stale CRLF, missing, symlink and unreadable-target behavior directly. Also correct the try_adopt_identical docstring, which still named the agent integrator as a caller. Co-authored-by: Mohammed Alkindi <alkndymhmd692@gmail.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 0 | 0 | The docstring makes the single-owner adoption boundary clearer; the new unit tests for is_content_identical_to_text cover the key edge cases. No architecture concerns. |
| Test Coverage Expert | 0 | 0 | 0 | The earlier gap is closed: is_content_identical_to_text now has direct unit tests covering 8 parametrized edge cases. This update adds no new coverage gap. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Recommendation
The previous panel's only follow-up is fixed and backed by passing tests. Both panelists report no findings, CI is green so far, and no new debt surfaced. The stance moves from ship_with_followups to ship_now; the maintainer can merge when ready.
Full per-persona findings
Python Architect
No findings.
Test Coverage Expert
No findings.
This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.
Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Folded in this run
Copilot signals reviewed
Regression-trap evidence (mutation-break gate)
Lint contract
CIAll checks are green at the exact head 84d6b77: 23 pass, 3 skipping, 0 pending or failed. This covers Lint, the Build & Test shards, the Lifecycle Smoke shards, the Windows Compatibility Gate, the Spec conformance gate (waived via Mergeability status
Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors. |
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Avoids landing-order conflicts with other queued PRs. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Lane L: main merged for landing
This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel). |
c775a7f
into
microsoft:main
Re-verified the sweep's recorded findings on environment-variables, targets-matrix, install-packages, registries, registry-http-api and governance-guide against current main (after #3785, #3774, #3782, #3743, #3797 merged) and fixed what is still drifted. Refs #3800 Co-authored-by: danielmeppiel <danielmeppiel@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Description
A second
apm install -greported APM's own agents as "files skipped" (#3722). With root-local agents in~/.apm/agents/, no user lockfile records the deployment, so content adoption is the only idempotency path, and three agent writers compared the target against the raw source instead of what they write:.agent.mdvs the TOML APM generated (the reporter's case; the issue title said Kiro, the skipped file was Codex).copy_agent(Copilot, Claude, Cursor, OpenCode, ...): the raw source vs the copy whose relative links APM rewrote.read_bytes()adoption, a second authority.Mohammed Alkindi (@MohammedAlkindi)'s original commit (kept) routed Codex through the
expected_contentseam. This rework, pushed to the same branch, extends that to every agent writer:BaseIntegrator._check_adopt_or_skip(..., expected_content=rendered). Every agent writer renders first (_render_codex_agent,_preflight_render_kiro_agent, new_render_copy_agent) and hands the text to one helper,AgentIntegrator._deploy_rendered_agent. That helper asks the owner and then writes the same string. Kiro's inline adoption and the deprecatedintegrate_package_agentstry_adopt_identicalcalls are folded in. The unused_write_kiro_agentwriter is removed.install-deployment-agent-render-then-adoptis registered on thefile-level-deploy-sync-cleanupowner, with a mutation-matrix case. It rejects these calls inagent_integrator.py:is_content_identical_to_source/_text,try_adopt_identical,check_collision,read_bytes, adoption-free writers (copy_agent,_write_codex_agent) in the deploy loop, andwrite_text_lfoutside the helper. It also pinsexpected_content=renderedfollowed bywrite_text_lf(target_path, rendered). The existinginstall-deployment-codex-agent-link-resolutionguard now follows_render_codex_agent.consumer/install-packages.md. CHANGELOG[Unreleased]entry credits the contributor.Out of scope (per the scope record): F21, which means no user lockfile is written for root-only
-ginstalls. Non-agent writers are also out of scope.Issue and approved scope
Issue: Fixes #3722
Human scope-approval comment: #3722 (comment)
Does this PR complete the issue, or what remains? Completes the issue. F21 (user lockfile for root-only global installs) is explicitly out of scope and routed to the lockfile owner.
Type of change
Testing
New tests:
tests/unit/integration/test_agent_integrator.py::TestRenderedAgentAdoption: adoption withmanaged_files=Nonefor codex, kiro, copilot and claude; foreign edits are still skipped; the legacy multi-target entry point adopts link-rewritten copies.tests/integration/test_global_agent_adoption_lifecycle.py(L6, the red-team oracle, real binary, temp HOME, no network):install -g --forcetheninstall -gwith codex, kiro, copilot and claude reports nothing skipped. Also covers a link-rewritten agent with copilot and claude.Fails-before-fix evidence (the same tests run against the unfixed
agent_integrator.py):TestRenderedAgentAdoption+ Codex testmain(2769573)Kiro passed before the fix because of its inline adoption. The static guard covers that split authority instead: on
mainand on the original head it reports a violation. Mutation checks (expected_content=None, raw-source adopt, inlineread_bytes,copy_agentbypass) each trip the rule.Validation commands (all run locally on this head):
.venv/bin/python -m pytest -p no:xdist -q tests/unit/integration/test_agent_integrator.py tests/unit/integration/test_symlink_rejection.py tests/unit/integration/test_opencode_frontmatter_validation.py tests/integration/test_integrators_validation_rules.py tests/unit/primitives/test_resolve_user_invocable.py: 307 passed.venv/bin/python -m pytest -p no:xdist -qon the 18 other agent-integrator consumer suites (install services, kiro target, content-identical adopt, scope install/uninstall, plugin e2e, install with links, spec conformance manifest reqs, ...): 548 passed, 13 skippedAPM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm .venv/bin/python -m pytest tests/integration/test_global_agent_adoption_lifecycle.py -p no:xdist -q: 2 passed.venv/bin/python -m pytest -p no:xdist -q tests/unit/scripts/test_architecture_runner.py tests/integration/test_architecture_owner_rule_mutations.py -k "test_architecture_runner or matrix_covers or case_order or render-then-adopt or codex-agent-link": 80 passed.venv/bin/python -m pytest -p no:xdist -q tests/quality tests/unit/integration/test_agent_integrator.py tests/unit/integration/test_kiro_target.py tests/unit/integration/test_content_identical_adopt.py tests/unit/scripts/test_lifecycle_smoke_sharding.py: 384 passedtests/integration/test_wave6_integrators_coverage.py tests/integration/test_wave4_pure_logic_coverage.py: 231 passeduvx ruff@0.15.12 checkandformat --checkonsrc/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.pypassed. Pylint R0801 scored 10.00/10.scripts/lint-auth-signals.shis clean andscripts/lint-architecture-boundaries.shexits 0. Files stay under 2100 lines.Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
apm-spec-waiver:line is in the rework commit message.)