Add lockfile-and-compatibility, approvals-and-executables and migration-0-28-to-0-39 topics; update installation, cli-reference, the prompt, hooks and instructions topics for 0.39.x behaviour; label the remaining 0.28.0 observations by version. Sources: the v0.39.3 source, CHANGELOG and docs; Context7 was unavailable. Refs #265 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
7.4 KiB
topic, source_keys
| topic | source_keys | |||
|---|---|---|---|---|
| lockfile-and-compatibility |
|
Lockfile format, cross-version compatibility, frozen installs and ref resolution as of apm 0.39.3. Read from the v0.39.3 source, its CHANGELOG and its docs. Nothing here was run against a real project. Each claim is marked source (read in code) or doc (docs or CHANGELOG only).
Lockfile versions
- Source: the supported versions are
"1"to"4". Anything else is refused before any file changes, withUnsupported lockfile version '<v>'; supported versions: 1, 2, 3, 4plus aapm self-updatehint. - Doc: the bump depends on content:
"4"when any package records acontent_hash;- else
"3"when a rootreplacementstable exists; - else
"2"for registry or semver evidence; - else
"1".
- Doc: v4 adds no fields. It only changes how
content_hashis computed. Each file, in sorted path order, contributes its path, a NUL byte and the SHA-256 of its raw bytes; v1-v3 keep the older stream. Source: both digests exist and are selected per lock version. - Doc: 0.37+ verifies a v1-v3 lock as written:
- A writable
apm installpromotes the lock to"4"once every package re-hashes from verified bytes. apm install --frozen,apm auditand other read-only commands never promote or rewrite it.
- A writable
- Doc: a lockfile with invalid YAML, a non-mapping root or malformed rows fails closed.
- Doc (0.39.0): the lock is parsed with libyaml, so a hand-edited lockfile with nonstandard YAML may now be rejected. Regenerate it with
apm install.
Which apm reads which lock
| Lock | Refused by | Read by |
|---|---|---|
| v1-v3 written by 0.28.0 | nothing current | 0.37+ reads as written; a writable install promotes to v4 |
| v4 written by 0.37.0-0.39.1 | 0.36.1 and older | 0.37.0+ |
| v4 rewritten by 0.39.2+ | 0.36.1 and older, and 0.37.0-0.39.1 (they refuse any lock from a newer apm) | 0.39.2+ |
Practical rule: once a lock written by 0.39.2 or later is committed, every machine that runs install or audit on it needs 0.39.2 or later. Upgrade CI and update bots first.
The 0.39.2 compatibility promise (doc, warning text confirmed in source)
From 0.39.2, the lockfile_version decides compatibility, not apm_version.
- A lock written by a newer apm in a format this apm reads runs normally. The only difference is one
[!]line on stderr per process:apm.lock.yaml was written by APM <x>, newer than this APM <y>. Its format (lockfile_version 4) is supported, so APM continues and keeps fields it does not know. - Unknown fields survive a rewrite, with exceptions:
- A dependency row's unknown fields are dropped when its commit, hash, version,
content_hashorsource_digestchanged. - A deployment row's unknown fields are dropped when its
content_hashor owner changed. - Top-level unknown fields are dropped when any dependency changed.
x-*top-level keys are always kept.
- A dependency row's unknown fields are dropped when its commit, hash, version,
- Refused with exit 1 before any change:
- an unsupported
lockfile_version; - an unknown deployment
kind; - an unknown value in a known enum field (
exec_status,host_type); - a duplicated
apm_versionorlockfile_versionkey.
- an unsupported
- No-op runs leave the lockfile byte-identical, and apm never switches its own version.
- Read support for a new format ships at least eight weeks before any release writes it.
apm audit --ci is stricter than install. It fails with exit 1 when the lock records fields this apm does not know (other than x- keys): 'apm audit --ci' cannot certify apm.lock.yaml: it was written by APM <x>, newer than this APM <y>, and it records fields this APM does not know: <names>. Nothing was changed. In JSON or SARIF output this is a failed check named lockfile-fields-certifiable. Plain apm audit only warns. Consequence: the apm that runs audit --ci must be at least as new as the newest apm that writes the lock.
Minimum-version advice (doc)
apm has no manifest field for a required or minimum apm version. The upstream advice is to "pin a minimum APM in CI, not an exact one". The minimum should be a release that reads the lock format: 0.39.2 or later in the docs' own example. Version pinning therefore lives outside apm.yml, in whatever installs apm.
apm install --frozen
- Doc: requires
apm.lock.yaml, replays its pins, and never writes the lock (since 0.34.0). - Doc: in CI (env
CIset to anything but empty,0orfalse),apm installwith a committed lock behaves like--frozen(0.37.0).--no-frozenopts out, and is the recommended form for update bots. - Doc: mutually exclusive with
--update, positional package additions and--mcp. Passing--frozen --updateis a usage error (exit 2). - Doc: fails (exit 1) before the pipeline on:
- a missing lock (a no-op when nothing is declared);
- a direct dependency missing from the lock;
- changed refs or commit pins;
- a host, provider or transport mismatch;
- MCP declaration mismatches;
- an MCP server the lock admits but
apm.ymldoes not approve; - hook approval pin mismatches.
- Doc: hash enforcement:
- Since 0.36.0, every deployed file is compared with its locked hash, and since 0.37.0 this happens before anything deploys. A mismatch exits 1.
- Since 0.39.x, it also fails when an apm-managed entry inside a merged hook config, such as
.claude/settings.json, was edited. - Recovery: restore or delete the edited file or entry, run
apm installwithout--frozen, and commit. To keep edits made to a dependency's files, export them first withapm export-patch.
- Doc: after the pipeline,
--frozenalso checks for unrecorded files, missing files, a stale executables decision, and hash drift.generated_atandapm_versionare excluded from the comparison.
Exact dependency refs (0.39.0, #4970)
- Source: a dependency
refresolves only torefs/heads/<ref>orrefs/tags/<ref>, or to itself when spelled out in full under one of those. There is no tail match and no fallback, so a ref that only partly matches a branch or tag name is refused.- When a ref names both a branch and a tag, the error says it is ambiguous; spell it as
refs/heads/<name>orrefs/tags/<name>. - When it names neither:
it is not a branch or tag of the origin. - An abbreviated SHA the host cannot expand is refused. Use the full 40 characters.
- When a ref names both a branch and a tag, the error says it is ambiguous; spell it as
- Source: a pinned commit, whether a
#sharef or a locked commit, is admitted only if an origin branch or tag reaches it. A commit reachable only from a PR or a fork is refused.- The fast path is a branch or tag tip, found with one
ls-remote. Otherwise apm does a commits-only fetch of heads and tags. - The verdict is cached in local state, never in the lockfile, so later replays work offline.
- The fast path is a branch or tag tip, found with one
- Source/doc: the first install of a pinned commit needs the network. Offline, it fails closed with
the first install of a pinned commit needs network access once. - Source: Artifactory routes are exempt and resolve by name.
Commit verdicts after an upgrade (0.39.0, #5173)
Source: reachability verdicts live in a new cache namespace (verified-v2), and verdicts recorded by earlier builds are never read. After upgrading, run each install online once before relying on offline or locked replays.
Helper tools resolve from PATH (0.39.0)
Doc: apm's helper tools (git, az, npm and others) and the setup scripts it runs resolve programs only from PATH entries outside the project. This does not affect your own scripts.