Repository navigation
fix(lockfile): hash framing hardening with lockfile version 4 - #4026
Conversation
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
9c7b913 to
adb1872
Compare
3dc87b0 to
3bc3715
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
adb1872 to
d887360
Compare
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 2 | 1 | Hash framing stays with one owner, content_hash.py, and promotion sits correctly after carry-forward. Main suggestion: make the stream (framed flag) a required argument instead of defaulting it to True. |
| Supply Chain Security Expert | 0 | 2 | 1 | Hash framing hardening looks sound. Promotion uses only verified or same-run bytes, frozen and audit leave the lockfile unchanged, and every lock-row check uses the row's own stream. Older readers refuse version 4. |
| Test Coverage Expert | 0 | 2 | 1 | Framing, legacy replay, promotion, frozen no-rewrite, audit and fail-closed tests are present and pass. Remote-dependency promotion is proven only at unit tier, and version 3 replay has no test. |
| Performance Expert | 0 | 2 | 1 | Steady-state installs read each tree the same number of times as before, but every check now runs SHA-256 twice. A blocked promotion can repeat its re-hash on every partial install. |
| Doc Writer | 0 | 3 | 0 | The new docs match the code and follow the public text rule. The canonical version table, the promotion fallback and the troubleshooting page still need updates; the CHANGELOG line follows the rules. |
| Devx Ux Expert | 0 | 3 | 0 | Safe upgrade, and newer clients refuse an older lock with a clear message. The one-time diff and the silent no-promotion path need a line of output, and the migration page needs the version 4 error. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 5 follow-ups
- [Python Architect] Give the run-level content-hash stream rule one owner, used by both record_package_digests and _promote_content_hashes. Call set_content_hash_stream right after from_installed_packages. Run the 'elif dep.content_hash_framed' promotion branch only when the existing lockfile is framed (supply-chain-security-expert raised the same point). -- Correctness currently depends on branch order, and legacy-digest rows are briefly marked framed. Two panelists found this independently. It is the highest-signal in-scope fold.
- [Test Coverage Expert] Add integration-tier promotion tests. Extend the legacy content-hash test in test_required_lifecycle_state_machine.py to model a real v1 lock (framed=False digest, lockfile_version '1') and assert promotion to '4'. Add promotion through build_and_save with carried remote rows: a partial install and a preserved failed download (supply-chain-security-expert). -- This is a missing test on a secure-by-default surface. Remote promotion is tested only at unit tier today, and the persona's throwaway variant passed, so this is cheap to keep in the suite.
- [Python Architect] Make framed a required keyword on compute_package_hash and verify_package_hash. Update the receipt pair (resolve.py:173, integrate.py:241) that relies on the default, and close the guard regex gaps. -- Callers that rely on the default can pick the wrong stream without any error. verify_locked_package and carried_license already require the keyword.
- [Doc Writer] Update troubleshooting/migration.md section 3 with version 4, the exact refusal message and the upgrade commands (devx-ux-expert raised the same point). Add a '4' row to the lockfile-spec.md version table and fix its Purpose line. Say that promotion is all-or-nothing and can keep the old version, in the reference page and in apm-usage. -- The migration page is where users of the previous release land when an older client refuses a v4 lockfile. The current text says every writable install promotes, which is not true when a row blocks promotion.
- [Devx Ux Expert] Print one [i] line when promotion succeeds that explains the one-time lockfile diff and the minimum CI version, with a CLI test that asserts it. Add a verbose-mode diagnostic that names the package blocking promotion and the next step. Add a remedy to the RuntimeError message. -- Users should never get an unexplained lockfile rewrite, or an unexplained missing one, from a package manager.
Architecture
classDiagram
direction LR
class content_hash {
<<SingleOwner>>
+compute_package_digests(path, exclude) PackageDigests
+compute_package_hash(path, exclude, framed) str
+verify_package_hash(path, expected, exclude, framed) bool
-_frame_entry(relative, payload, mode) bytes
}
class PackageDigests {
<<ValueObject>>
+legacy str
+framed str
+select(framed) str
}
class LockFile {
<<Aggregate>>
+framed_content_hashes bool
+set_content_hash_stream(framed)
+add_dependency(dep)
}
class LockedDependency {
+content_hash str
+content_hash_framed bool
}
class source_helpers {
<<Recorder>>
+record_package_digests(ctx, dep_key, digests) str
}
class LockfileBuilder {
<<PhaseBuilder>>
-_promote_content_hashes(lockfile)
}
class carried_license {
+verify_locked_package(root, hash, records, framed)
}
content_hash ..> PackageDigests : returns
LockFile *-- LockedDependency : rows
source_helpers ..> content_hash : digests
LockfileBuilder ..> LockFile : promotes
LockfileBuilder ..> content_hash : rehash carried rows
carried_license ..> content_hash : verify in row stream
class content_hash:::touched
class LockFile:::touched
class LockfileBuilder:::touched
classDef touched fill:#fff3b0,stroke:#d47600
flowchart TD
A["apm install"] --> B["resolve.py _load_lockfile: LockFile._from_validated_data"]
B --> C{"lockfile_version is 4?"}
C -->|yes| C1["framed_content_hashes=True; rows framed"]
C -->|"no, 1-3"| C2["framed_content_hashes=False; rows legacy"]
C1 --> D
C2 --> D
D["sources.py acquire / record_carried_package_hash"] --> E["content_hash.compute_package_digests: one read, legacy + framed"]
E --> F["record_package_digests: package_hashes in existing stream; package_framed_hashes"]
D --> V["verifiers use framed=row.content_hash_framed"]
V -->|mismatch| V1["re-download or frozen failure"]
F --> G["LockfileBuilder.build_and_save"]
G --> G2["attach content hashes, merge and carry-forward steps"]
G2 --> H["_promote_content_hashes"]
H --> H0{"frozen or dry run?"}
H0 -->|yes| H1["keep existing stream; no rewrite"]
H0 -->|no| H2{"every row has a framed digest of verified bytes?"}
H2 -->|yes| H6["rewrite content_hash; version 4"]
H2 -->|no| H4["keep version 1-3 and every recorded value"]
H1 --> I["sync_lockfile_version"]
H4 --> I
H6 --> I
I --> J["_write_if_changed: apm.lock.yaml"]
sequenceDiagram
participant U as User
participant I as apm install
participant R as record_package_digests
participant B as LockfileBuilder
participant L as apm.lock.yaml
U->>I: apm install (existing lockfile_version 3)
I->>L: read, rows flagged legacy
I->>R: digests for each fetched package
R-->>I: package_hashes legacy, package_framed_hashes framed
I->>B: build_and_save
B->>B: _promote_content_hashes, rehash carried remote rows
B->>L: write lockfile_version 4 with framed hashes
U->>I: apm install --frozen
I->>L: verify in the row stream, never promote
Recommendation
The design is sound and the tests that exist pass. Fold the in-scope follow-ups into this PR before merge, highest-signal first. First comes one owner for the stream rule plus the framed-only promotion gate, backed by integration-tier v1 and carried-row promotion tests. Next come the migration.md v4 entry and the promotion output lines, so the one-time lockfile diff is explained to users. The single-stream hashing fix belongs here because this PR introduced the cost. Move the pre-existing double tree read to its own issue. The CHANGELOG upgrade note should say that CI must run the new APM version once a lockfile is promoted.
Full per-persona findings
Python Architect
- [recommended] Make framed a required keyword on compute_package_hash / verify_package_hash, as verify_locked_package already does, instead of defaulting to True at
src/apm_cli/utils/content_hash.py:271
A verifier that forgets to pass the row's stream checks a v1-3 row against the framed stream without warning. It fails closed, but legacy users would see a false mismatch. The guard's raw-compare and record-write regexes have gaps; the receipt pair in resolve.py / integrate.py relies on the default.
Suggested: Require framed on compute_package_hash, verify_package_hash and compute_local_package_hash; pass framed=True explicitly at the receipt pair. - [recommended] The run-level stream rule is written out in two modules, and the build lockfile briefly marks legacy rows as framed at
src/apm_cli/install/phases/lockfile.py:473
Promotion is correct only because the recorded-this-run branch runs before the branch that trusts the per-row flag.
Suggested: One owner for the recording stream; call set_content_hash_stream right after from_installed_packages. - [nit] _rehash_verified_row rebuilds the verify_locked_package logic inside the lockfile phase
A sibling owner in carried_license (for example verified_framed_digest) keeps that verification logic in one place.
Supply Chain Security Expert
- [recommended] Trust the in-memory content_hash_framed flag during promotion only when the existing lockfile already uses the framed stream at
src/apm_cli/install/phases/lockfile.py:485
Today the flag is safe only because of how rows move between LockFile objects; gating the branch makes the verified-bytes-only rule independent of carry-forward mechanics.
Suggested:elif recorded_framed and dep.content_hash_framed: - [recommended] Test promotion through build_and_save for carried rows, not only on a lockfile parsed from YAML at
tests/unit/install/test_content_hash_promotion.py
The mix of fresh rows and carried legacy rows is where a carried row could be stamped without re-hashing.
Proof (missing at):tests/unit/install/test_content_hash_promotion.py-- proves: a writable install on a version 1-3 lockfile writes version 4 only after every carried remote row is re-hashed from verified bytes [secure-by-default,portability-by-manifest] - [nit] Accept bare-hex content_hash in the frozen local preflight only for lockfile versions 1-3 at
src/apm_cli/install/service.py:566
The 0.1.68 schema requires the envelope in version 4.
Test Coverage Expert
- [recommended] Remote-dependency promotion is proven only at unit tier, and the existing legacy-hash lifecycle test no longer models a legacy lockfile at
tests/integration/test_required_lifecycle_state_machine.py:2190
The only real-CLI promotion test uses a local dependency. A throwaway remote-git variant passed (v1 promoted to '4'; --frozen left bytes unchanged), so the gap is coverage only.
Proof (missing at):tests/integration/test_required_lifecycle_state_machine.py::test_required_legacy_content_hash_upgrade_preserves_skills_and_converges-- proves: upgrading APM and running install promotes git-hosted dependencies to version 4 once from verified bytes [portability-by-manifest,secure-by-default] - [recommended] No test covers version 3 replay or promoting a version 3 lockfile with replacement evidence at
tests/unit/install/test_content_hash_promotion.py
Version 3 is the one legacy version with extra state, and the reader now accepts that evidence under '3' or '4'.
Proof (missing at):tests/unit/install/test_content_hash_promotion.py-- proves: a lockfile that records source replacements keeps verifying until promotion and keeps its replacement evidence after [portability-by-manifest,governed-by-policy] - [nit] No fixed-value test confirms native plugin pin values are unchanged now that they use the shared framing helper at
tests/unit/test_native_bundle_hash.py
Proof (missing at):tests/unit/test_native_bundle_hash.py-- proves: existing native plugin pins keep verifying [portability-by-manifest,secure-by-default]
Performance Expert
- [recommended] compute_package_hash / verify_package_hash always compute both streams, so single-stream verify paths pay a second SHA-256 pass at
src/apm_cli/utils/content_hash.py:84
Measured +59% on a 300-file / 75 MB tree; small-file trees are dominated by walk and stat.
Suggested: Feed only the selected hasher; keep dual-stream only for recording pre-v4 and for promotion. - [recommended] A blocked promotion re-hashes carried remote rows before it hits the blocker, and a partial install repeats that waste on every run at
src/apm_cli/install/phases/lockfile.py:460
Suggested: Classify rows and check cheap blockers before hashing any row. - [nit] Follow-up (pre-existing): cached hits read the tree twice per install at
src/apm_cli/install/sources.py:608
Track as a separate issue.
Doc Writer
- [recommended] lockfile-spec.md has no version 4 row in the Version bumping table, and the Purpose section still says two versions at
docs/src/content/docs/reference/lockfile-spec.md:416 - [recommended] The reference page and apm-usage say every writable install promotes to version 4, but promotion is all-or-nothing at
packages/apm-guide/.apm/skills/apm-usage/dependencies.md:533 - [recommended] troubleshooting/migration.md section 3 still says the current versions are 1 and 2 at
docs/src/content/docs/troubleshooting/migration.md:60
Devx Ux Expert
- [recommended] The first writable install rewrites every content_hash row and bumps lockfile_version, but prints only 'Updated apm.lock.yaml.' at
src/apm_cli/install/phases/lockfile.py:460
Proof (missing at):tests/spec_conformance/test_lockfile_reqs.py-- proves: a user who upgrades is told why apm.lock.yaml changed on every package row [devx] - [recommended] When a carried row cannot be verified, promotion is skipped with no message at
src/apm_cli/install/phases/lockfile.py:491
Proof (passed):tests/unit/install/test_content_hash_promotion.py::test_unverified_carried_row_blocks_promotion_and_keeps_every_row-- proves: the fallback keeps the legacy lock unchanged [devx] - [recommended] APM 0.36 and earlier fail on a version 4 lock with no upgrade hint, and the troubleshooting page still lists only versions 1 and 2 at
docs/src/content/docs/troubleshooting/migration.md:60
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.
3bc3715 to
9aec162
Compare
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
d887360 to
c57ac3e
Compare
9aec162 to
3560d7f
Compare
Package content hashes use the framed stream the native plugin pin already uses, owned by utils/content_hash.py. Lockfile version 4 names the stream; versions 1-3 keep verifying with the legacy stream, and a writable install promotes once from verified bytes. --frozen, audit and read-only paths never promote. OpenAPM 0.1.68 amends req-lk-016. Fixes #4000 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The base gained an include_mode switch on the native hasher; keep the guard's required fragment on the shared framing call. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
One owner for the recording stream (records_framed_content_hashes); built rows carry it until promotion, and promotion trusts a framed row flag only from a version 4 lock. Promotion moves to install/phases/content_hash_stream.py, checks cheap blockers before hashing any tree, explains the one-time lockfile change, and names the package that holds it back. Re-hash of carried rows is owned by carried_license.verified_framed_digest. verify_package_hash requires the stream; every src hash call names it (guarded). Single-stream hashing when only one stream is needed. Bare-hex tolerance stays for versions 1-3. Docs: version table, all-or-nothing promotion, troubleshooting migration entry. Tests: v3 replay and promotion, framed-flag gating, blocker pre-pass, promotion message, native pin golden values, v1 legacy promotion in the lifecycle suite. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Version 4 is now supported; the embedded-lock gate still fails closed before any project mutation on an unknown version. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
c57ac3e to
2d129a0
Compare
Recording hashes the legacy stream only while the existing lockfile uses it. The promotion message prints after the lockfile write succeeds. Tests: legacy-stream definition and golden value, version 4 bare-hex refusal under --frozen, partial-install promotion of carried rows (intact and edited cache), recording-stream selection, and guard mutations for unnamed streams, a re-derived stream rule and the framed-flag gate. Docs: version 4 wording in the lockfile reference and registries page; the refusal sample no longer pins a version list. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
req-lk-016 requires v0.1 readers to accept a bare 64-hex content_hash. The frozen local preflight had narrowed that to versions 1-3, which refused committed lockfiles a 0.37 install had promoted. Restore it, and drop the matching envelope rule from the 0.1.68 schema so spec, schema and code agree; writers still emit the envelope. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
A package content_hash now selects lockfile_version 4, so the revision-pin and replacement lifecycles assert 4 while still checking resolved_tag and replacements. The links lifecycle pins the framed digest a version 4 lock records and keeps the cross-platform byte check through the legacy digest of the installed tree. The owner mutation matrix keeps one sorted case for the content-hash guard; its other mutations move to a dedicated parametrized test. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Pins req-lk-016 reader tolerance for promoted lockfiles so the frozen preflight is not narrowed again. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Python Architect | 0 | 1 | 2 | Prior findings fixed; asked for guard mutation tests (folded) and log-after-write (folded). |
| Supply Chain Security Expert | 0 | 1 | 1 | Trust gaps closed; partial-install carried-row promotion now has an e2e test. |
| Test Coverage Expert | 0 | 3 | 0 | Prior gaps fixed; legacy-stream golden and carried-row e2e folded; bare-hex trap now asserts acceptance. |
| Performance Expert | 0 | 1 | 1 | Recording now hashes only the needed stream; blocker pre-pass confirmed. |
| Doc Writer | 0 | 1 | 2 | Prior findings fixed; remaining stale version lines folded. |
| Devx Ux Expert | 0 | 1 | 1 | Prior findings fixed; registries page claim folded. |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 4 follow-ups
- [Performance Expert] Track the pre-existing double tree read on cached hits as its own issue. -- Not introduced here, but it is now the dominant hash-path cost on large trees.
- [Supply Chain Security Expert] Make
frameda required keyword oncompute_package_hashin a dedicated test-migration PR. -- Deferred only for the ~100 unrelated test call sites; the guard already requiresframed=on everysrccall and a miss fails closed. - [Python Architect] Replace the regex guard with an AST-based check so aliased imports are covered. -- Polish that closes the guard's one known blind spot.
- [Apm Ceo] Keep the CHANGELOG upgrade note for lockfile version 4. -- Already present under Breaking changes and upgrade notes: update CI to APM 0.37 before committing a promoted lockfile.
Recommendation
Merge once the release-train tip CI is green; that run is the integration proof, because stacked PRs run only the CLA check. Every in-scope finding is folded, and the bare-hex reversal keeps spec, schema and code aligned.
Full per-persona findings (delta)
Python Architect
- [recommended] No mutation test covered the new closed-world rules -- folded (dedicated parametrized test).
- [nit] Promotion line logged before the write -- folded (logged after
_write_if_changed). - [nit] Regex guard misses aliased imports -- deferred (polish).
Supply Chain Security Expert
- [recommended] Partial-install carried-row promotion only unit-tested -- folded (e2e, intact and edited cache).
- [nit]
compute_package_hashframed default -- deferred (test-migration scope).
Test Coverage Expert
- [recommended] Legacy stream lacked a published-definition test -- folded with a base-implementation golden.
- [recommended] No v4 bare-hex frozen trap -- resolved as an acceptance trap after the req-lk-016 reversal.
- [recommended] Carried-row promotion lacked a real-CLI test -- folded.
Performance Expert
- [recommended] Recording still hashed the legacy stream on v4 locks -- folded.
- [nit] Blocker pre-pass confirmed fixed.
Doc Writer
- [recommended] lockfile-spec and registries lines still said
"3"/"1"-- folded. - [nit] Purpose and field row should say "new or promoted" -- folded.
- [nit] Refusal sample pinned one version list -- folded.
Devx Ux Expert
- [recommended] registries.md stale claim -- folded.
- [nit] First Versioning bullet conflicted -- folded.
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 <[email protected]> # Conflicts: # tests/integration/test_architecture_owner_rule_mutations.py
The single-file matrix recomputed package content_hash with the legacy stream in three places. Replace them with one independent oracle for the lockfile version 4 stream (path, NUL, raw file digest), kept separate from the code under test. Co-authored-by: copilot-swe-agent[bot] <[email protected]>
The 0.35.1/0.36.0 upgrade lifecycles compared the first writable install against the old lock byte-for-byte outside the fields they meant to change. Since microsoft#4026 that install also promotes the lock to version 4 (hash framing hardening) and re-hashes every package row. Assert the promotion explicitly: version 4, and each untouched row's content_hash equals the framed digest of its installed tree; every other field must still match. Refs microsoft#4000 Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Steward ruling for cell (4) of the #4517 manifest_targets fix: lockfile v4 is the intended #4000/#4026 format change, so the previous release must refuse it. An opt-in cell (APM_E2E_TESTS + APM_RUN_INTEGRATION_TESTS) downloads the SHA-pinned v0.36.1 artifact, locks a 'target: claude' project with this build (v4, manifest_targets [claude]), then runs 0.36.1 install, install --frozen and audit --ci: each exits non-zero naming "Unsupported lockfile version '4'" and the project tree is byte-identical. Co-authored-by: Copilot App <[email protected]>
Description
TL;DR. Hash framing hardening for package
content_hash. The package tree digest now uses the same framed encoding the native plugin pin already uses (relative path, NUL, per-file SHA-256), and the change is versioned at the lockfile level aslockfile_version: "4". Lockfiles at versions 1–3 keep verifying unchanged; a writableapm installpromotes once, re-hashing every package row from verified bytes.--frozen,apm auditand read-only paths never promote or rewrite.Important
Upgrade note: APM 0.36.x and earlier refuse a version
"4"lockfile through the existingUnsupportedLockfileVersionError(fail closed). Update CI to APM 0.37 before committing a lockfile written by 0.37.Problem (WHY)
"2"for registry evidence,"3"for replacement state), and old readers fail closed on an unknown version.Approach (WHAT)
_frame_entry) inutils/content_hash.pyserves package and native plugin fingerprints. Values keep the plainsha256:<hex>label; no new prefix.lockfile_version: "4"names the framed stream;"1"–"3"name the legacy stream. Each lock row learns its stream from its lockfile (content_hash_framed, not serialized).verify_package_hashrequiresframed=. The legacy stream exists only to verify 1–3 lockfiles. Bare-hex reader tolerance (req-lk-016) holds in every version.apm_modulesonly after cheap checks pass for all of them and their legacy hash verifies. Otherwise the lockfile stays as written and--verbosenames the package to reinstall. A successful promotion prints one[i]line after the write.install-deployment-package-content-hashcloses the world: no second tree hasher, everysrchash call names its stream, one stream rule, one recorder, one promoter.Implementation (HOW)
utils/content_hash.py_frame_entry(shared framing),PackageDigests+compute_package_digests(one read, both streams),compute_package_hash(framed=),verify_package_hash(framed=). Native pin values are byte-identical.deps/lockfile.py"4"inSUPPORTED_LOCKFILE_VERSIONS,FRAMED_CONTENT_HASH_VERSION,records_framed_content_hashes(the one recording-stream rule),framed_content_hashesderived from the read version,set_content_hash_stream; version derivation emits"4"when a framed lock records anycontent_hash; replacement evidence accepts"3"or"4".install/source_helpers.pypackage_digests(legacy stream only while the existing lock uses it) andrecord_package_digests, the sole writer ofctx.package_hashes/ctx.package_framed_hashes.install/phases/content_hash_stream.py(new)promote_content_hashes: frozen/dry run never promote; framed row flags trusted only from a v4 lock; cheap-blocker pre-pass; diagnostics.install/phases/lockfile.pyflags built rows with the recording stream, calls it, and prints the promotion line after the write.deps/carried_license.pyverify_locked_package(framed=)andverified_framed_digest(re-hash only bytes whose legacy hash and licence copies verify)._redownload,integrate,native_plugin_admission,security/trust,legacy_plugin_compat,local_contentand the frozen local preflight ininstall/service.pypass the row's stream."4", newlockfile-v0.1.68.schema.json(adds"4"), manifest notes, CONFORMANCE regenerated. Count unchanged at 148.install-failures.md, v4 refusal), apm-usagedependencies.md, CHANGELOG upgrade note.flowchart LR A["Existing lock v1-3"] --> B{"Writable install?"} B -->|"no: --frozen, audit, read-only"| C["Verify with legacy stream, never rewrite"] B -->|yes| D{"Every row has a framed digest of verified bytes?"} D -->|yes| E["Write v4 with framed hashes"] D -->|no| F["Keep lock as written"]Legend: how a version 1–3 lockfile moves (or does not move) to version 4.
Trade-offs
apm_modules); they promote on the next install that records them.lockfile_version: "4"(they asserted the feature-derived"2"/"3"/"1") and still checkresolved_tagandreplacements; the links lifecycle pins the framed digest a v4 lock records and keeps its cross-platform byte check via the legacy digest of the installed tree; tests that named"4"as the next unsupported version now use"5".framedrequired oncompute_package_hash(≈100 unrelated test call sites; the guard already enforces it insrc), an AST-based guard, and the pre-existing double tree read on cached hits.Benefits
--frozen(cached and fresh) andapm auditnever promote or rewrite.Issue and approved scope
Issue: Fixes #4000
Human scope-approval comment: #4000 (comment) (supersedes the earlier record).
This PR completes the issue.
Type of change
Testing
Scenario evidence
tests/unit/test_content_hash.py::TestFramedPackageStream,tests/unit/test_native_bundle_hash.pytests/unit/install/test_content_hash_promotion.py::test_legacy_version_rows_verify_with_the_legacy_streamtest_writable_install_promotes_every_row_from_verified_bytes,test_unverified_carried_row_blocks_promotion_and_keeps_every_row--frozencached and fresh, andapm audit, never rewrite (v4 and v1); writable install promotes v1 to v4tests/spec_conformance/test_lockfile_reqs.py::test_frozen_consumer_accepts_equivalent_local_content_hash_encodings(5 cases, real CLI)--frozennever promotes (unit); v3 replay and promotion keep replacements; blocker pre-pass hashes nothingtests/unit/install/test_content_hash_promotion.pytests/integration/test_required_lifecycle_state_machine.py(legacy_content_hash,partial_install_promotes)content_hashreplays in v4 and v1test_frozen_consumer_accepts_equivalent_local_content_hash_encodings[version4-bare64-cached],test_frozen_local_path_lifecycle.py"4"test_a_release_without_version_4_fails_closed"4"test_lock_schema_0_1_68_*tests/integration/test_architecture_owner_rule_mutations.py(matrix case +test_package_content_hash_guard_rejects_second_streams_and_hashers)Validation commands
How to test
apm.lock.yaml, runapm install --frozenandapm audit: the lockfile is byte-identical.apm install:lockfile_versionbecomes"4"and every packagecontent_hashis re-recorded once.apm installagain: no lockfile change.Changelog
## [Unreleased]inCHANGELOG.md(Breaking changes and upgrade notes).Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated (req-lk-016 revised in place; Appendix C row unchanged because keyword, section and class are unchanged).openapm-v0.1.requirements.ymlnotes for req-lk-016.@pytest.mark.req("req-lk-016")tests added and extended.CONFORMANCE.{md,json}regenerated and committed.Co-authored-by: Copilot [email protected]