Files
Holocron/plugins/kyberforge/docs/research/docs/microsoft-apm/lockfile-and-compatibility.md
T
Defame1297andClaude Opus 5.5 5ca2056046 docs(research): refresh apm reference set to 0.39.3 (#265)
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
2026-12-01 21:46:06 +00:00

7.4 KiB

topic, source_keys
topic source_keys
lockfile-and-compatibility
apm-v0-39-3-source
apm-v0-39-3-changelog
apm-v0-39-3-docs

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, with Unsupported lockfile version '<v>'; supported versions: 1, 2, 3, 4 plus a apm self-update hint.
  • Doc: the bump depends on content:
    • "4" when any package records a content_hash;
    • else "3" when a root replacements table exists;
    • else "2" for registry or semver evidence;
    • else "1".
  • Doc: v4 adds no fields. It only changes how content_hash is 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 install promotes the lock to "4" once every package re-hashes from verified bytes.
    • apm install --frozen, apm audit and other read-only commands never promote or rewrite it.
  • 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_hash or source_digest changed.
    • A deployment row's unknown fields are dropped when its content_hash or owner changed.
    • Top-level unknown fields are dropped when any dependency changed.
    • x-* top-level keys are always kept.
  • 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_version or lockfile_version key.
  • 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 CI set to anything but empty, 0 or false), apm install with a committed lock behaves like --frozen (0.37.0). --no-frozen opts out, and is the recommended form for update bots.
  • Doc: mutually exclusive with --update, positional package additions and --mcp. Passing --frozen --update is 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.yml does 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 install without --frozen, and commit. To keep edits made to a dependency's files, export them first with apm export-patch.
  • Doc: after the pipeline, --frozen also checks for unrecorded files, missing files, a stale executables decision, and hash drift. generated_at and apm_version are excluded from the comparison.

Exact dependency refs (0.39.0, #4970)

  • Source: a dependency ref resolves only to refs/heads/<ref> or refs/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> or refs/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.
  • Source: a pinned commit, whether a #sha ref 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.
  • 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.