Repository navigation
refactor(output): remediation-advice owner with executable proofs (#4090, part 1) - #4128
Closed
Daniel Meppiel (danielmeppiel) wants to merge 7 commits into
Closed
Daniel Meppiel (danielmeppiel) wants to merge 7 commits into
Daniel Meppiel (danielmeppiel) wants to merge 7 commits into
Conversation
…ner skeleton (#4090) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Merged
6 of 10 tasks
…iation-advice owner (#4090) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
6 of 17 tasks
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…; fix advice the proofs disproved (#4090) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…ce (#4090) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
…#4090) The native Claude park now renders the owner's trust-bin entry, and its proof runs it on the live user-scope path. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
apm-spec-waiver: remediation advice wording, an additive audit JSON field and a verbose preview cap; no OpenAPM install, lockfile or policy semantics change Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Collaborator
Author
|
Superseded by #4143, which carries the remediation-advice owner and migrates all sites. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
TL;DR
APM printed about 500 pieces of free-text remediation advice (
run 'apm install' to ...), with no owner and no check that the advice works. This PR adds theremediation-adviceowner (core/remediation.py): a closed catalog of structuredRemediation(command, fixes_promise, clears)entries rendered in one place. It moves every advice site ininstall/,policy/,commands/audit.pyandcommands/install.pyonto it and runs each of the 81 entries on the installed CLI to show it clears the state it names. Running them exposed 7 pieces of advice that did not work; all are fixed here.Note
Part 1 of 4 for #4090 (Stream H lane H-I). A closed-world guard pins the 370 sites still outside the owner with an exact, shrink-only per-file baseline. Three follow-up 0.37 PRs (
commands/*; integration, marketplace and bundle; everything else) take it to zero before the 0.37 tag.Problem (WHY)
apm installkeeps a locally edited managed file, so "run apm install to re-sync" could not restore it. The landed fix had no static guard.install --frozenhelp (DX5) andinit --applyimplies--discover(DX6) were fixed in fix(0.37): product fixes found while rebuilding the docs [PR D of #3994] #4004 without guards.apm audit --ci --format jsongave scripts no machine-readable fix, only prose.Why these matter: the repo's architecture rule is "Every durable decision, vocabulary, outcome, write, or contract has exactly ONE canonical owner.", and a centralization is complete only with "a hermetic behavioral regression test" plus "a registered static guard in the architecture linter".
Approach (WHAT)
core/remediation.py: frozenRemediation(id, command, fixes_promise, before, then, clears), built only by_entry(); renderersclause(),sentence(),either(),each(),bind(),to_json().driftcheck share one selector (drift_render.drift_remediations) throughDRIFT_KIND_REMEDIATION.apm audit --cicheck carriesremediations: [{id, command, fixes, clears, before?, then?}].PROVEStuples), enforced bytests/unit/core/test_remediation_catalog.py.Implementation (HOW)
src/apm_cli/core/remediation.py— the owner and its 81-entry catalog. Each entry names the state itclears; unbound{placeholders}raise instead of rendering.policy/ci_checks.py,policy/policy_checks.py,policy/models.py—CheckResult.remediationsis serialized into_json. Messages render owner clauses.install/drift_render.py,install/local_edits.py— the edited-file advice is nowDelete <files>, then run 'apm install' to restore the locked content. The--forcealternative is kept. Generic re-sync applies only tounintegrated,orphanedand uneditedmodifiedfindings.install/**,commands/install.py,commands/audit.py,security/executables.py,core/deployment_ledger.py— sites render owner entries.DEPLOYMENT_OWNER_REMEDIATIONis retired; consumers useINVALID_DEPLOYMENT_OWNERS.policy/install_preflight.py—--verboselifts the five-line dry-run policy preview cap, so the overflow advice (apm install --dry-run --verbose <same-arguments>) is true.scripts/architecture_linter/checks/contracts_remediation_advice.py— four rules registered in thecontracts_testsgroup. The registry adds ownerremediation-advice(steward-approved). DX5's guard joinsfrozen-install-mutation-eligibility; DX6's joinsonboarding-metadata-only.tests/utils/remediation_proof.pyplus seven proof modules undertests/integration/test_remediation_*. Unit assertions now read the owner instead of copying strings.reference/cli/audit.mddocumentsremediations;common-errors.md,baseline-checks.mdandupdate.mdshow the new advice text. The apm-guidecommands.mdnotes the field.Diagrams
Legend: one owner feeds both renderers (text and audit JSON), and each proof runs the advised command through the installed binary.
flowchart LR C["core/remediation.py catalog (81 entries)"] --> T["clause / sentence / either"] C --> J["CheckResult.remediations to_json"] T --> O["CLI text: install, audit, policy"] J --> A["apm audit --ci --format json"] O --> P["proof: run advised command via binary"] A --> P P --> V["state named by clears is gone"] G["linter: contracts-tooling-remediation-advice"] -.->|"rejects free text outside owner"| OTrade-offs
Remediation(...)at sites. Chose a closed catalog: "each entry has a proof" is then a set equality, not a convention. Cost: 81 entries, each with a proof.apm <cmd>. Prose such as "rerun the same install command without --frozen" is out of scope.prune-package-copies,readmit-codex-pluginsandcomplete-codex-migrationneed an OSError or a real Codex CLI. Each runs in a fresh process with a single stub and keeps a recorded reason.Benefits
apm audit --ci --format jsongives scripts an exact command to run for each failed check.src/apm_clioutside the baseline, and the baseline can only shrink.Validation
Advice the proofs disproved, and the fix
apm install --frozen, without packages or --mcp"--frozen <pkg>always refuses package argsapm installapm cache cleanapm cache clean --yes--yesit printsAborted!when non-interactiveapm install --trust-bin <pkg>(and the native park's bareRe-run: apm install --global --trust-bin)apm install --global --trust-binapm config set registry.<n>.urlapm experimental enable registriesapm installapm install -g --target codexapm auditapm install --dry-run --verbose <same-arguments>Red before (main
1b96706b7d, installed CLI):test_remediation_advice_lifecycle.py3/3 FAILED,... carries no structured remediation. Green after: all executed proofs pass.CI-mirror lint chain (merged with main)
Full local unit + spec + quality + architecture + proofs run
30326 passed, 302 failed. Every failure reproduces onmainwith the same environment, or is an artifact of this sandbox: installer ownership (246), release metadata (35), network guard (8), git env/transport (4), credential report (1),test_output_mode(6;APM_E2E_TESTS=1suppresses the update notice by design), andtest_orphan_owner_guard_is_closed_world[renamed-evidence-predicate], which also fails on main640e8c04. The one proof failure,test_trust_bin, was fixed in9cb1b0ff.Scenario Evidence
tests/integration/test_remediation_proofs_*.py,tests/integration/test_remediation_advice_lifecycle.pytests/unit/core/test_remediation_catalog.py::test_every_catalog_entry_has_exactly_one_executed_prooftests/integration/test_remediation_proofs_drift.pytests/integration/test_remediation_advice_lifecycle.py::test_audit_remediation_clears_the_reported_checktests/integration/test_architecture_owner_rule_mutations.py::test_owner_rule_catches_its_guard_mutationHow to test
APM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm uv run --extra dev pytest tests/integration/test_remediation_advice_lifecycle.py tests/integration/test_remediation_proofs_*.py -n 3→ all pass.apm.lock.yaml, then runapm audit --ci --format json→lockfile-existscarriesremediations[0].command == "apm install".apm audit→ the advice says delete, thenapm install, with no plain re-sync line."run 'apm install' to restore"to any priority file, then runbash scripts/lint-architecture-boundaries.sh→contracts-tooling-remediation-advicefails.Issue and approved scope
Issue: Refs #4090 (part 1 of 4). Remaining sites migrate in three follow-up 0.37 PRs that shrink the baseline to zero.
Human scope-approval comment: #4090 (comment)
Does this PR complete the issue, or what remains? Not complete. 370 advice sites in 112 files outside the priority set remain, pinned by the shrink-only baseline in
contracts_remediation_advice.py.Type of change
Testing
Changelog
## [Unreleased]inCHANGELOG.md: user-visible effect first, 25 words or fewer, ending with(#PR); breaking changes only under upgrade notes; no Highlights; see.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedapm-spec-waiver: remediation advice wording, an additive audit JSON field and a verbose preview cap; no OpenAPM install, lockfile or policy semantics change
Co-authored-by: Copilot [email protected]