Skip to content

fix(install): capture acquired manifest versions on first install - #3311

Merged
Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
danielmeppiel-issue-version-snapshots
Oct 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 11 commits into
mainfrom
danielmeppiel-issue-version-snapshots

Conversation

@danielmeppiel

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

Copy link
Copy Markdown
Collaborator

Description

fix(install): record versions from the acquired package snapshot

TL;DR: The first ordinary install after a branch switch now records manifest-derived metadata from the acquired package, rather than an older descriptor cached for the same apm_modules path. Local, cached and fresh acquisition use one adapter while registry/Git-semver version precedence remains intact. This is a partial, non-closing PR: the accepted inventory-version-only frozen veto is excluded because it conflicts with current req-lk-019.

Important

The maintainer explicitly authorized bypass of missing imposed external CodeQL analysis. Missing analysis is not a passing scan, and no security settings, SARIF or approvals were changed. The independent marketplace catalog gap has now been repaired by consuming the sole #3304 owner's published test-only commit 21b9c82, preserving its authorship. The previously failing catalog assertion now passes; no private patch, duplicate implementation or waiver was used.

Problem (WHY)

  • The local branch-switch reproduction deploys Body 1.1.0. while recording version: 1.0.0 on the first install. A production bypass reproduces that mismatch at attempt=1.
  • Resolution can cache an old installed manifest before acquisition replaces the bytes at that path. Reusing the descriptor during materialization carries its stale version into InstalledPackage.
  • Fixed-ref Git-subdirectory installation already passed on the original baseline; it remains a control, not a newly claimed Git defect.

The evidence follows the Agent Skills validation loop: "do the work, run a validator (a script, a reference checklist, or a self-check), fix any issues, and repeat until validation passes." The advisory distinguished correctness within optional inventory recording from a new normative obligation; the Mode B heuristic was not used to invent one.

Approach (WHAT)

  • Read the acquired manifest through existing load_yaml and APMPackage.from_mapping, without changing the process-wide path cache.
  • Capture metadata before constructing installed-package evidence in all three acquisition paths.
  • Preserve local source anchors, identity and resolved commits.
  • Preserve native/legacy projections and absent optional metadata; invalid required APM metadata remains an explicit error.
  • Leave resolver-selected versions and frozen verification authority unchanged.

Implementation (HOW)

File Change
src/apm_cli/install/source_helpers.py Own acquired-manifest capture; delegate interpretation to the existing full parser.
src/apm_cli/install/sources.py Route local, cached and fresh acquisition through that owner.
.apm/architecture/owners/install-deployment.json Register the decision and guard.
scripts/architecture_linter/checks/install_manifest_snapshot.py, install_deployment_analyzers.py Detect cache reuse, missing handoffs, lost local anchors, lost legacy exclusions and duplicate ownership.
tests/integration/test_architecture_manifest_snapshot.py, tests/unit/scripts/test_architecture_runner.py Exercise bypasses/duplicate ownership and register the rule vocabulary.
tests/integration/test_architecture_owner_rule_mutations.py Add the snapshot MutationCase; consume the separately authored public marketplace cases with attribution.
tests/unit/install/test_materialized_manifest_snapshot.py Cover cache independence, complete metadata, invalid required metadata and native/legacy handling.
tests/spec_conformance/test_acquired_manifest_reqs.py Bind real nonmapping rejection, unset omission and resolver/inventory round-trip to existing requirements.
CONFORMANCE.json, CONFORMANCE.md Mechanically update only this PR's three requirement mappings/counts; retain landed main's independent mappings.
tests/integration/test_manifest_version_snapshot_lifecycle.py Exercise installed-CLI branch switches, repeated installs and compatible warm/cold frozen replay.
docs/src/content/docs/reference/cli/install.md, packages/apm-guide/.apm/skills/apm-usage/commands.md Explain ordinary coherence and inventory versus replay pins.

Diagram

The dashed node is the new capture boundary; existing lock construction still decides version authority.

flowchart LR
    subgraph Acquire["Existing acquisition"]
        L["Local copy"]
        C["Verified cached package"]
        F["Fresh download"]
    end
    subgraph Capture["Acquired metadata"]
        S["materialized_manifest_snapshot"]
        P["load_yaml and APMPackage.from_mapping"]
        N["Native or legacy projection"]
    end
    subgraph Record["Existing lock construction"]
        I["InstalledPackage"]
        V["Resolver version precedence"]
        K["apm.lock.yaml"]
    end
    L --> S
    C --> S
    F --> S
    S -->|"Authored APM manifest"| P
    S -->|"Native or legacy format"| N
    P --> I
    N --> I
    I --> V --> K
    classDef new stroke-dasharray: 5 5;
    class S new;
Loading

Trade-offs

  • Parse one acquired manifest per handoff instead of invalidating global parser state. No unconditional redownload is added.
  • Keep native and legacy synthetic descriptors authoritative. fix(deps): invalidate the manifest parse cache when apm.yml is rewritten, so re-downloads re-stamp #2627's synthetic plugin redownload/stamping work is neither copied nor claimed.
  • Keep inventory-only frozen mismatches non-gating. The stronger accepted veto remains unresolved, not replaced by warnings or automatic rebaselining.
  • Use local Git fixtures and installed APM CLI execution; no native-client activation, live registry service, credentials or inference.

Benefits

  1. The first ordinary local install retains the correct checked-out lock rather than requiring a second install.
  2. Three consecutive installs preserve exact manifest/lock bytes and independently observed deployed payload.
  3. One guarded capture boundary covers all acquisition paths without changing version authority.

Issue and approved scope

Issue: Refs #3246.

Human scope-approval comment: #3246 (comment)

This PR implements only ordinary snapshot coherence. It does not complete #3246 or rewrite its acceptance record. The accepted inventory-only frozen refusal remains excluded: current req-lk-019 says dependency-manifest-derived versions "MUST NOT drive frozen replay" for Git/local entries. Existing frozen content/pin/MCP checks remain in place. Future resolution of that excluded scope is not a landing condition for this working subset.

Original report: Rafael Azevedo (@rrazvd); independent reproduction: Kaustubh Arora (@Kaustubh1235). #3206 supplies related fixed-ref evidence only and remains open. This PR does not claim completion of #2627.

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

Current head: 806c776c57b030fd93416d18d6272c2c9471233e; integrated public main: 6f691d2c8e76f11519bfcc1d5b371b0979138fe4. Normal merges preserved landed #3307, #3316, #3308 and #3277; #3304's public catalog commit was cherry-picked with original authorship and a Cherry-picked-from trailer. No force-push or shared-stash operation.

Engineering CI and the specification gate passed at this head, including Windows compatibility/native-symlink checks and lifecycle smoke. The missing native CodeQL comparison remains NEUTRAL and explicitly bypass-authorized. The independent ordinary-subset ship_now source review remains valid. The later CEO authority-delta returned ship_with_followups; its catalog follow-up has now been folded and verified, not cosmetically relabeled.

Check Actual result
Native CodeQL comparison NEUTRAL, "1 configuration not found" at 119173563113: main's API-upload/default configuration lacks a PR counterpart. Introduced alerts indeterminate; bypass explicitly authorized, not a passing scan.
Canonical Ruff pair, source guards, pylint R0801, auth and architecture boundaries Passed at current head
Acquired-snapshot and newly landed schema compatibility 175 passed in 132.61s, including all six installed-CLI snapshot/frozen scenarios
Snapshot static guards and central catalog completeness/order 9 passed in 71.03s at current head
Public catalog mutation cases and snapshot central case 18 passed at preceding integration b04385df3; cases/guards unchanged by the final schema/triage merge
Native-service interaction controls 59 passed in 76.57s at b04385df3, including the previously selected controls and landed service-boundary cases
Production local-capture bypass On b04385df3, first-install assertion failed; exact restoration and same witness passed. Snapshot owner/handoffs/static guard remain byte-identical at current head.
Three additional production mutations Historical 3306f1548 proof: 3 rejection failures, 2 resolver-precedence failures, 1 omission failure; exact restoration and same witnesses passed
Assertion and duplicate-test ratchets; canonical Mode B; orphan check Passed at current head
Strict owner-v2 verification Passed, terminal_evidence_required: true, one touched owner and two executed exact-head lifecycle witnesses
Full conformance collection; canonical generation twice 455 collected; both generators exit 0, byte-identical outputs, merged statements unchanged
Full conformance execution Historical 369 passed / 2 skipped before the 3306f1548 commit; not misrepresented as execution of all 455 current cases
Mermaid rendering Previously passed; diagram unchanged

The former 151-pass/1-failure catalog result remains historical. The exact failed completeness assertion now passes after the public repair. Two recorder schema mistakes (pending versus yellow, then missing interim completion fields) were corrected in evidence artifacts only; no source change or test replay was needed. The complete corrected owner proof was schema-validated and strictly verified.

Executed current-head commands and evidence

Python commands use the existing offline/no-sync environment. Exact argv, output and hashes are retained in 3246-recovery-final-main-806/{receipt,delta-receipt,owner-schema-repair}.json; preceding integrated mutation evidence is in 3246-recovery-public-main-b043/receipt.json.

uv run --frozen --no-sync --extra dev ruff check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py
Result: exit 0
uv run --frozen --no-sync --extra dev ruff format --check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py
Result: exit 0
uv run --frozen --no-sync --extra dev python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py
Result: exit 0
bash scripts/lint-auth-signals.sh
Result: exit 0
bash scripts/lint-architecture-boundaries.sh
Result: exit 0
uv run --frozen --no-sync --extra dev python scripts/check_test_assertions.py
Result: exit 0
uv run --frozen --no-sync --extra dev python scripts/check_exact_test_duplicates.py
Result: exit 0
bash tests/spec_conformance/mode_b_detector.sh
Result: exit 0
uv run --frozen --no-sync --extra dev python -m tests.spec_conformance.orphan_check
Result: exit 0
uv run --frozen --no-sync --extra dev python -m tests.spec_conformance.gen_statement
Result: exit 0 twice, after full canonical collection; unchanged, idempotent bytes

The original local reproduction was red on 53ccf06; fixed-ref Git was already green there. Earlier 27-test evidence belongs only to that historical draft. Original proofs and the superseded native-analysis hold are preserved, not overwritten.

Scenario Evidence

Scenario Principle Proof Type
Branch switch over old modules; first and repeated installs retain baseline/deployed bytes DevX, Governed by policy test_manifest_version_snapshot_lifecycle.py::test_first_install_after_checkout_records_current_manifest_snapshot e2e
Warm/cold frozen replay uses pins, not inventory versions Governed by policy test_manifest_version_snapshot_lifecycle.py::test_frozen_replays_pins_without_using_inventory_version e2e
Resolver precedence, optional inventory omission and round-trip Governed by policy tests/spec_conformance/test_acquired_manifest_reqs.py component
Acquired nonmapping rejection, legacy projections, cache independence Secure by default, Multi-harness test_acquired_manifest_reqs.py, test_materialized_manifest_snapshot.py component
Schema identity added on main remains compatible with acquisition Portable by manifest test_dependency_schema_reqs.py, test_manifest_schema_cli_contract.py component / e2e

How to test

  • Set APM_BINARY_PATH to the installed CLI. Run uv run --extra dev pytest -q tests/spec_conformance/test_acquired_manifest_reqs.py tests/unit/install/test_materialized_manifest_snapshot.py tests/integration/test_manifest_version_snapshot_lifecycle.py; expect all 20 cases to pass.
  • Run uv run --extra dev pytest -q tests/integration/test_architecture_manifest_snapshot.py tests/integration/test_architecture_owner_rule_mutations.py::test_matrix_covers_every_registry_guard_exactly_once; both snapshot guards and catalog completeness must pass.
  • Inspect the first-install assertions for independent manifest, commit, payload and exact manifest/lock bytes; a successful retry alone is insufficient.
  • Run canonical Mode B against main without overrides. Its success and frozen compatibility tests do not claim acceptance of the excluded veto.

Spec conformance (OpenAPM v0.1)

If this PR changes behaviour that an OpenAPM v0.1 req-XXX covers,
confirm the three-step ritual in the
development guide:

  • Spec edit: docs/src/content/docs/specs/openapm-v0.1.md updated
    (new/changed <a id="req-XXX"></a> anchor + prose + Appendix C
    row).
  • Manifest edit: docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.yml
    updated.
  • Test edit: a @pytest.mark.req("req-XXX") test under
    tests/spec_conformance/ added or extended.
  • CONFORMANCE.{md,json} regenerated via
    uv run --extra dev python -m tests.spec_conformance.gen_statement
    and committed.
  • N/A -- this PR does not change OpenAPM-observable behaviour.

No new normative requirement is proposed by this PR. Existing req-mf-001 covers nonmapping rejection, req-lk-011 covers unset-field omission, and req-lk-019 preserves inventory round-trip and resolver/frozen authority. Meaningful production mutations demonstrate those bindings. Landed main's separate schema proposal is preserved without claiming ratification. Install-reference and packaged-guide updates remain aligned; no repeated documentation panel is claimed.

Co-authored-by: Copilot [email protected]

…ment

Preserve resolver and legacy-plugin version authority; match acquired package-type evidence by the unique lock identity. Integrates main693 documentation without losing conflict-repair guidance. Current-head qualification remains pending; historical first-green evidence belongs to the earlier53cc draft.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Preserve landed local-content preflight and pre-transformation hashing alongside the acquired-version guard and unique package-type identity. No current-head validation has run; rebind qualification to this merge.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Faithfully integrate dc7b6a6 without changing the acquired-version repair, frozen local-content preflight, or canonical source hashing. Qualification remains unrun and requires a newly bound grant.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Faithfully integrate 70a924a. Preserve both dry-run documentation and acquired-version frozen checks. No qualification has run for this head; a newly bound grant remains required.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Retain public-main cold frozen MCP and local-content protection. Remove the unshipped inventory-version-only veto, which remains an unresolved accepted-scope requirement under req-lk-019. Preserve ordinary snapshot coherence and compatibility controls for a non-closing draft delivery.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Co-authored-by: Copilot App <[email protected]>

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Move real inventory-authority controls into conformance and exercise acquired nonmapping rejection with cached descriptors. Regenerate only the derived requirement test mappings; keep frozen replay and the specification unchanged.

Co-authored-by: Copilot App <[email protected]>
Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
@danielmeppiel

Daniel Meppiel (danielmeppiel) commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

The ordinary-subset source review remains valid. Its catalog follow-up is now repaired and verified. Missing imposed external CodeQL analysis is explicitly bypass-authorized, not represented as successful.

panel-mode=delta; personas=apm-ceo

The genuine ordinary-subset assessment was ship_now at 3306f15. The subsequent independent CEO authority-delta recommendation was ship_with_followups, with one nonblocking follow-up: consume the separately owned public catalog repair. That exact recommendation is preserved rather than cosmetically changed after delivery. No unchanged source panel was rerun.

Delivery evidence update

Current head is 806c776, with public main 6f691d2 normally integrated. The snapshot implementation remains byte-identical to the reviewed source. Landed native-service, audit, schema and triage changes are retained.

The sole #3304 owner's public test-only commit 21b9c82 was consumed with original authorship and a Cherry-picked-from trailer. Its two marketplace MutationCases and snapshot central case passed in the 18-case integration selection. The formerly failing catalog completeness assertion now passes at the current head. The historical 151-pass/1-failure result is preserved, not called a pass retroactively.

Current-head evidence: 175 acquired-snapshot/schema compatibility cases passed, 9 snapshot/catalog static checks passed, canonical lint and boundary/quality ratchets passed, and strict owner-v2 verification reported terminal_evidence_required: true with two executed lifecycle witnesses. Full canonical collection found 455 cases; two statement generations were byte-identical and left the merged statements unchanged. The preceding integrated head passed 59 native-service/compatibility cases and the real production snapshot bypass/restoration witness. Historical full-suite 369-pass/2-skip evidence is not claimed as execution of all 455 current cases.

The initial Python Architect found no production correctness or authority-split defect. The Test Coverage Expert's two meaningful conformance findings were folded in 3306f15 and its coverage delta found no remaining in-scope gap. Real acquired-nonmapping rejection exercises req-mf-001; resolver precedence/inventory round-trip exercises req-lk-019; omission exercises req-lk-011. Production mutations caused three rejection failures, two precedence failures and one omission failure, followed by exact restoration and passing witnesses. This is correctness within optional inventory recording, not a new normative freshness MUST.

Native-analysis disposition

The maintainer explicitly instructed: "missing codeql analysis is not a reason not to merge, bypass merge PRs even if that CodeQL analysis is missing. It is an imposed external analysis that we cannot run." This supersedes the old missing-analysis-only hold. Current-head CodeQL check 119173563113 is NEUTRAL with "1 configuration not found": main's API-upload/default configuration has no matching PR result, so introduced alerts cannot be determined. Neither successful Analyze jobs nor aggregate checks prove native differential clearance. No security setting, SARIF, approval or reviewer identity was changed to obtain a green result.

Aligned with: secure-by-default acquired-manifest rejection; manifest-portable inventory with preserved resolver authority; unchanged frozen replay policy.

Panel summary

Persona B R N Takeaway
APM CEO 0 1 0 Missing external analysis is user-excepted. The public catalog follow-up has now been folded and verified.

Counts preserve the actual authority-delta return. Its one recommendation is now resolved by delivery; no new review is implied.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

The independently recorded stance remains ship_with_followups; the ordinary source ship_now remains valid, and the only catalog follow-up is now complete. The PR is non-draft and non-closing. Merge Master exclusively performs the final landing assessment and authorized bypass merge.

The inventory-version-only frozen veto remains excluded under current req-lk-019. This working ordinary subset does not complete or close #3246, and #3206 remains open. Future resolution of that wider scope is not a condition on this scoped PR.

Original proof, the initial ordinary completion, and the superseded native-analysis hold remain preserved as history.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.

Merge Master final readiness: ship_now

My independent assessment of exact head 806c776c57b030fd93416d18d6272c2c9471233e is ship_now for the ordinary acquired-manifest subset. This is my landing assessment, not a relabeling of the genuine CEO ship_with_followups delta or a new source panel. The original ordinary-source ship_now remains supported.

I verified the sealed release/completion, strict terminal owner-v2 result (one owner, two exact-head lifecycle witnesses), actual 175 passing functional cases, nine current static/catalog checks and canonical lint. The causal production mutation failed on the first-install stale-version assertion and passed after exact restoration; the relevant owner/oracle files are unchanged at this head. The public catalog repair retains its original author and Cherry-picked-from attribution, and its stable patch ID matches the sole producer's public commit. Its 18-case integration selection and current completeness assertion passed. The former catalog failure is historical, not retroactively declared successful.

Current public main 6f691d2c8e76f11519bfcc1d5b371b0979138fe4 is an ancestor of this head; the strict combined tree is b975e24613880a65bb2546855906dd55600daff6. All 24 own-head checks are complete and nonfailing. The imposed CodeQL comparison remains missing/undetermined and explicitly excepted, not passed. No source tests, mutations or panel were rerun by the Merge Master.

All writer roles are explicitly released. The PR is nonclosing: #3246 and #3206 remain open, and the inventory-version-only frozen veto remains excluded. This assessment does not claim full issue completion or that the merge has already happened.


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

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.

🔵 Needs a closer look

Reported native CodeQL clearance remains indeterminate and requires maintainer resolution before landing.

No open issues 🎉

What changed in this PR

Fixes stale manifest-derived lockfile versions on the first ordinary install after a branch switch, addressing part of #3246 without changing frozen replay rules.

Changes:

  • Capture current manifest metadata through one adapter for local, cached and fresh acquisition.
  • Add regression, conformance and architecture-guard coverage.
  • Document inventory versions separately from resolver-selected versions and replay pins.
File Description
tests/​unit/​scripts/​test_architecture_runner.py Register expected guard vocabulary.
tests/​unit/​install/​test_materialized_manifest_snapshot.py Test cache independence and metadata handling.
tests/​spec_conformance/​test_acquired_manifest_reqs.py Cover existing manifest and lockfile contracts.
tests/​integration/​test_manifest_version_snapshot_lifecycle.py Test branch switches, repeated installs and frozen replay.
tests/​integration/​test_architecture_owner_rule_mutations.py Add the central guard mutation case.
tests/​integration/​test_architecture_manifest_snapshot.py Test guard bypass detection.
src/​apm_cli/​install/​sources.py Capture metadata across all acquisition paths.
src/​apm_cli/​install/​source_helpers.py Add the acquired-manifest snapshot adapter.
scripts/​architecture_linter/​checks/​install_manifest_snapshot.py Guard snapshot ownership and handoffs.
scripts/​architecture_linter/​checks/​install_deployment_analyzers.py Register the snapshot guard.
packages/​apm-guide/​.apm/​skills/​apm-usage/​commands.md Align packaged install guidance.
docs/​src/​content/​docs/​reference/​cli/​install.md Explain first-install version coherence.
CONFORMANCE.md Update requirement test counts.
CONFORMANCE.json Update requirement test mappings.
.apm/​architecture/​owners/​install-deployment.json Register snapshot ownership.

Review effort: Balanced

Preserve landed #3307 native-service ownership and lock immutability alongside #3311 acquired-manifest inventory capture. Retain both conformance mappings and both install guides; no frozen-version veto or private catalog repair.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Preserve landed #3316 audit path identity and prior #3307 frozen-service changes without changing the ordinary acquired-manifest fix.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Add the two missing canonical mutation cases for declaration association and locked ref evidence. Both use meaningful valid-AST bypasses and prove their owning rule reports a violation; no guard or runtime behavior is weakened.

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

Copilot-Session: 3dea031b-9e0c-4c51-8986-4b55ae7dfbc8
Cherry-picked-from: 21b9c82
Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
Preserve landed #3308 schema identity and #3277 triage changes alongside acquired-manifest capture and the public #3304 catalog repair. No private or speculative producer changes.

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

Copilot-Session: daed9f36-025c-4757-85ea-54b8aaf9442d
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.

2 participants