diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 221bc58..1b9310b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -154,7 +154,7 @@ repos: # serve one. A gate that can never go green is not a gate. Revisit if # this repo ever gains a policy source apm can actually reach. # - # Takes about 70 s for the root plus every plugin through `uv run` on + # Takes 70-90 s for the root plus every plugin through `uv run` on # apm 0.39.3 (about 0.5 s per package on 0.28.0). Needs no network ONCE # `uv sync --frozen` and `uv run --frozen apm install` have each run # once -- the root marketplace has no remote package diff --git a/AGENTS.md b/AGENTS.md index b0729e4..cca8d20 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,10 +28,10 @@ Fall back to raw shell only when no skill covers it. ## Session rules - **Do not add repo-owned keys to `.claude/settings.json`.** apm treats it as its own deployed artifact and `apm audit --ci` replays the install and diffs, so anything apm would not have written is permanent drift that fails the `apm-audit-ci` pre-push hook. A hook you want here is authored in `plugins//.apm/hooks/` and deployed by apm, never hand-written into that file. The `SessionStart` entry already in it is exactly that: kyberforge authors it in `plugins/kyberforge/.apm/hooks/hooks.json` and apm merges it in, so it is apm's own output, it is what the replay expects, and it belongs in the commit — do not strip it (ADR-0019). Machine-specific settings go in the gitignored `.claude/settings.local.json`; shared enforcement goes in `.pre-commit-config.yaml`. -- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. Before writing the lock with apm 0.39 in a checkout whose `apm_modules/` apm 0.28 populated, move `apm_modules/` aside and run `uv run --frozen apm install`, or the lock loses its third-party `carried_licenses` entries (`docs/spec/gates.md`, "apm-audit-ci"). +- **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. +- **`apm.lock.yaml` turning up modified is expected, not a bug.** kyberforge's `SessionStart` hook keeps the install current on launch: it runs `uv run --frozen apm update --yes` and rewrites the lock in the process (ADR-0019). On `main`, commit or discard it deliberately. On a feature branch, discard it (`git checkout -- apm.lock.yaml`, then `uv run --frozen apm install`). This keeps unrelated lock churn out of the branch diff and keeps `apm pack --check-clean` consistent with the committed lock. The session then runs the older `main` that the lock records, which is accepted on a branch, and the next session start refreshes again. A checkout that apm 0.28 deployed or populated needs one-time migration steps, and its first session-start rewrite of the lock can be wrong: see `docs/spec/gates.md`, "apm-audit-ci". - **A `.apm/` edit is not live until it is on the remote's `main`.** Root `apm.yml`'s first-party dependencies resolve from the holocron remote, unpinned against the default branch, so pushing a feature branch does not deploy it (ADR-0019). `uv run --frozen apm install` deploys from the lock; `uv run --frozen apm update` is what re-resolves refs. -- **Run apm only as `uv run --frozen apm …`.** The root `pyproject.toml` and `uv.lock` pin apm 0.39.3 (ADR-0034). A bare `apm` reaches the machine-global 0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. -- **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. A checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by 0.28 moves those three directories aside before its first 0.39 install, or apm refuses with "no trustworthy local deployment baseline" (`docs/spec/gates.md`, "Pushing without a network"). +- **No pre-push hook needs the network — once the two one-time online steps have run.** A new checkout runs `uv sync --frozen`, then `uv run --frozen apm install`, each online once. Root `apm.yml`'s marketplace has no remote package entries, so every hook then resolves locally. The guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set: on a fresh clone `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` install-replays have no cache to replay from and clone from the remote. (`docs/spec/gates.md`, "Pushing without a network"). - **A plugin `version:` bump that has merged to `main` gets its release tag.** Run `git fetch origin --tags`, then `scripts/tag-plugin-releases.sh`; exit 1 means a tag is missing, and `--apply` creates it locally and prints the push command. The script reads local tags only, so OK means present locally, not published: confirm with `git ls-remote --tags origin '-v*'` before calling it done. A tag push is an irreversible publish, not a free Propose-tier push (ADR-0032): show the maintainer the exact tags and that command, and only on their explicit yes in this conversation run exactly it yourself (named tags, never `--tags` or other refs). Agents cut release tags only with the script, which never moves or deletes one; exit 2 means stop and report it to the maintainer, never hand-fix, move or delete a tag (ADR-0033). - **This repo and Gitea are the only source of truth.** All project state, decisions, and working conventions live here. Do not use an external memory system for this project — cached state diverges from the repo and you get a split brain. Before answering any design or architecture question, check `docs/adr/` for an existing decision. diff --git a/LESSONS.md b/LESSONS.md index d164a3a..ebb4fcb 100644 --- a/LESSONS.md +++ b/LESSONS.md @@ -154,4 +154,4 @@ Under the `run-tests` pre-push hook, git exported `GIT_DIR` to the hook, so a ba ## 2026-11-26 — A hook's GIT_DIR leaks through any tool that runs git -#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. *2026-12-02 (#272):* apm 0.39.3 strips `GIT_DIR` and the other repo-locating vars from its own git calls (`git_subprocess_env` in `apm_cli/utils/git_env.py`). The leak was not reproduced again on 0.39.3, and the scrub stays, because the rule is about the hook, not about one tool version. +#204: pushing from a linked worktree left the shared `.git/config` with `core.bare=true` and the worktree on a detached HEAD at the lock-pinned commit. git exports an absolute `GIT_DIR` to hooks run from a linked worktree. `apm-audit-ci` ran `apm audit --ci`, and its drift replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an env copied from `os.environ`. The inherited `GIT_DIR` won, so both operations hit this repo instead of the temp dir. The 2026-11-13 fix did not cover this: it scrubbed the env only inside `tests/run-tests.sh`, and the apm hooks never pass through that file. Fix: `scripts/lib/clean-git-env.sh` unsets the repo-locating vars, and both `scripts/apm-audit-ci.sh` and the new `scripts/apm-pack-check-clean.sh` source it before calling apm. `tests/test-apm-hooks-git-env.sh` reproduces the leak with a stub `apm`. Rule: any hook that shells out to a tool that runs git must scrub `GIT_*` first. Scrubbing one entry point does not protect the others. *2026-12-02 (#272):* apm 0.39.3's `apm_cli/utils/git_env.py` provides `git_subprocess_env`, which strips `GIT_DIR` and the other repo-locating vars. The leak was not re-tested on 0.39.3, and the scrub stays, because the rule is about the hook, not about one tool version. diff --git a/README.md b/README.md index cab902c..adb9fe1 100644 --- a/README.md +++ b/README.md @@ -61,15 +61,15 @@ uv run --frozen apm install pre-commit install -t pre-commit -t commit-msg -t pre-push ``` -**`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`. Every apm command in this repo runs as `uv run --frozen apm ...`. +**`uv sync --frozen`** installs the apm that `uv.lock` pins into `.venv/`. **`uv run --frozen apm install`** deploys the plugins root `apm.yml` lists into `.claude/skills/` and `.claude/agents/`. Both are gitignored install output, *not* authoring source — `plugins//.apm/` remains the only place to edit. Steps 1 and 2 each need the network once per checkout; the first apm 0.39 install also records commit-reachability verdicts. The install materializes `apm_modules/` (which stays gitignored). -**Run apm only through `uv run --frozen apm`.** A bare `apm` reaches whatever is on `PATH`; on a machine with the global pipx apm 0.28.0, that one is not used in this repo and refuses the v4 `apm.lock.yaml`. +**Run apm only through `uv run --frozen apm`.** A bare `apm` reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. The global pipx apm 0.28.0 some machines carry is not used in this repo. **An existing checkout deployed by apm 0.28 needs one more step before step 2.** Move `.claude/skills`, `.claude/agents` and `.claude/commands` aside (or delete them if they hold no edits), then run `uv run --frozen apm install`. Without that, apm 0.39 refuses to replace the 0.28-deployed files with "no trustworthy local deployment baseline", because 0.28 recorded no deployment evidence for them. apm's own message suggests a bare `apm install`; use the `uv run --frozen` form instead. -**Writing the lock from a checkout whose `apm_modules/` apm 0.28 populated needs a clean cache first.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an install that changes the lock), move `apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era third-party copies and writes a lock without their `carried_licenses` entries, which a fresh install then contradicts. Consuming the committed lock is unaffected and needs only the two setup steps above. +**Writing the lock from a checkout whose `apm_modules/` apm 0.28 populated needs a clean cache first.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an install that changes the lock), move `apm_modules/` aside and run `uv run --frozen apm install`. Otherwise apm reuses the 0.28-era third-party copies and writes a lock without their `carried_licenses` entries, which a fresh install then contradicts. kyberforge's `SessionStart` hook is such a writer: it runs `uv run --frozen apm update --yes` at session start, so it can write the bad lock before you read this. To recover, discard it with `git checkout -- apm.lock.yaml`, move `apm_modules/` aside, then run `uv run --frozen apm install`. Consuming the committed lock is unaffected and needs only the two setup steps above. **Git hooks** must be wired for **all three stages**. This repo's `.pre-commit-config.yaml` has no `default_install_hook_types`, so a plain `pre-commit install` silently skips `commit-msg` (Conventional Commits) and `pre-push` (the full gate) — the `-t` flags above are not optional. The `pc-run` skill handles this and the troubleshooting around it, if you would rather not remember the flags. @@ -103,7 +103,7 @@ pre-commit run --hook-stage pre-push --all-files See [`docs/spec/gates.md`](docs/spec/gates.md) for what each hook enforces and why. -**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `uv run --frozen apm install` have each run once, online** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on. +**Offline?** No pre-push hook needs the network **once `uv sync --frozen` and `uv run --frozen apm install` have each run once, online** (ADR-0034). Root `apm.yml`'s marketplace has no remote package entries (the last one, `mattpocock-skills`, was removed), so `apm-pack-check-clean` resolves everything from local sources, and `apm-audit-ci`'s install-replay is cache-only against a populated install. On a **fresh clone** there is no cache: `apm-audit-ci`'s `deployed-files-present` fails outright, and its `drift` and `config-consistency` checks clone from the holocron remote. The offline guarantee is a property of a synced `.venv/` and a populated `apm_modules/`, not of the hook set — run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it holds from then on. ## Editing plugin content @@ -146,7 +146,8 @@ releases, run `git ls-remote --tags https://git.rkdr.net/Mortis/Holocron.git '

#-v` does not work on this host. apm reads `plugins/` as part of the repository path, so a real install tries to clone -`.../Holocron/plugins/.git` and fails with "Not found". `apm install --dry-run` does not catch +`.../Holocron/plugins/.git` and fails because no such repository exists (on apm 0.39.3: +"Repository Mortis/Holocron/plugins/ not found on git.rkdr.net"). `apm install --dry-run` does not catch this. Use the object form. ### Automated updates diff --git a/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md b/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md index 52a7b30..a13a7ad 100644 --- a/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md +++ b/docs/adr/0033-plugin-releases-are-tagged-plugin-v-version.md @@ -6,14 +6,14 @@ check in Context and the apm behaviour in consequence 3) are pending re-verification on 0.39.3 under #265, once apm is pinned per repo (ADR-0034). The Decision is unchanged.* -*Amended 2026-12-02 (holocron#272): re-checked on apm 0.39.3.* -- *The tag pattern holds in source: `apm_cli/marketplace/tag_pattern.py` still lists - `{name}-v{version}`. The synthetic-repo `apm outdated` run was not repeated.* -- *Consequence 3's shorthand failure holds. A scratch install of - `git.rkdr.net/Mortis/Holocron/plugins/lint#` fails with `Repository - Mortis/Holocron/plugins/lint not found on git.rkdr.net`. The tag in that run did not exist, but - the failure comes at repository resolution, before any ref is read.* -- *The `rstrip(".git")` bug is fixed in 0.39.3, which uses `removesuffix(".git")`.* +> **Amendment (2026-12-02, holocron#272) — the 0.28.0 claims re-checked on apm 0.39.3.** +> - The tag pattern holds in source: `apm_cli/marketplace/tag_pattern.py` still lists +> `{name}-v{version}`. The synthetic-repo `apm outdated` run was not repeated. +> - Consequence 3's shorthand failure holds. A scratch install of +> `git.rkdr.net/Mortis/Holocron/plugins/lint#` fails with `Repository +> Mortis/Holocron/plugins/lint not found on git.rkdr.net`. The tag in that run did not exist, but +> the failure comes at repository resolution, before any ref is read. +> - The `rstrip(".git")` bug is fixed in 0.39.3, which uses `removesuffix(".git")`. ## Context diff --git a/docs/spec/gates.md b/docs/spec/gates.md index 8e42e94..462087c 100644 --- a/docs/spec/gates.md +++ b/docs/spec/gates.md @@ -1162,9 +1162,8 @@ plugin packages under `plugins/` — because the root-only invocation audits the **nothing else**, and `apm-pack-check-clean` does not parse plugin `dependencies:` blocks either. Verified: a malformed dependency entry passes `apm pack --check-versions --check-clean --dry-run` and fails `apm audit --ci` in that package's -directory. The whole hook, the root plus every plugin package, takes about 70 s through `uv run` on -apm 0.39.3 (measured 70-90 s, about 20 s of it the root audit). On apm 0.28.0 it cost about 0.5 s -per package. +directory. The whole hook, the root plus every plugin package, takes 70-90 s through `uv run` on +apm 0.39.3, about 20 s of it the root audit. On apm 0.28.0 it cost about 0.5 s per package. **Both apm hooks run the repo-pinned apm.** They source `scripts/lib/apm.sh`, the one place the invocation is spelled: `uv run --project --frozen apm` (ADR-0034). `--project` comes @@ -1180,16 +1179,16 @@ pins the command, the `--project` root, the scrub and the version floor with a f `scripts/lib/clean-git-env.sh` before anything calls `apm`, which unsets `GIT_DIR`, `GIT_WORK_TREE`, `GIT_INDEX_FILE`, `GIT_OBJECT_DIRECTORY`, `GIT_COMMON_DIR`, `GIT_PREFIX` and `GIT_IMPLICIT_WORK_TREE`. It deliberately keeps the config-passing vars (`GIT_CONFIG_PARAMETERS`, -`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: `git push` from a **linked worktree** exports an -absolute `GIT_DIR=

/.git/worktrees/` to its hooks, and from the main checkout it exports -none. `drift`'s install replay (apm 0.28.0) runs `git init` and `git checkout` in a temp dir with an -env copied from `os.environ`, so the inherited `GIT_DIR` wins. The `init` wrote `core.bare=true` into -the shared `.git/config`, and the `checkout` moved the worktree's HEAD to the lock-pinned commit -(issue #204). Pre-commit runs hooks from the worktree root, so once the vars are gone plain -discovery finds the right repo. *2026-12-02 (holocron#272):* apm 0.39.3 builds the env for its own -git calls through `git_subprocess_env` in `apm_cli/utils/git_env.py`, which strips `GIT_DIR` and the -other repo-locating vars. The leak was not reproduced again on 0.39.3, and the scrub stays as -defence in depth. `tests/test-apm-hooks-git-env.sh` pins this for both hooks. +`GIT_CONFIG_COUNT`), because they carry `git -c` overrides apm's remote clones may need. The reason: +`git push` from a **linked worktree** exports an absolute `GIT_DIR=
/.git/worktrees/` to +its hooks, and from the main checkout it exports none. `drift`'s install replay (apm 0.28.0) runs +`git init` and `git checkout` in a temp dir with an env copied from `os.environ`, so the inherited +`GIT_DIR` wins. The `init` wrote `core.bare=true` into the shared `.git/config`, and the `checkout` +moved the worktree's HEAD to the lock-pinned commit (issue #204). Pre-commit runs hooks from the +worktree root, so once the vars are gone plain discovery finds the right repo. *2026-12-02 +(holocron#272):* apm 0.39.3's `apm_cli/utils/git_env.py` provides `git_subprocess_env`, which strips +`GIT_DIR` and the other repo-locating vars. The leak was not re-tested on 0.39.3, and the scrub +stays as defence in depth. `tests/test-apm-hooks-git-env.sh` pins this for both hooks. **What it actually runs is asymmetric**, and the two manifest classes are not comparable. Verified by running `apm audit --ci` (apm 0.39.3, holocron#272; first done on 0.28.0) at the repo root and in @@ -1204,19 +1203,21 @@ are `lockfile-targets-current`, `native-mcp-ownership`, `local-bundle-hooks`, `h and `exec-status-current`. On each **plugin** manifest, **2 checks**: `lockfile-exists` and `content-integrity` (0.28.0 ran -only `lockfile-exists`). The plugin-level `content-integrity` row scans no package source: on -0.39.3 it still passed with a bidi override planted in a scratch copy of `plugins/lint`. When -`lockfile-exists` fails, the table holds that one row alone. `lockfile-exists` is conditional, and vacuous while every -plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No dependencies declared --- lockfile not required`. An earlier revision of this section said it would arm the moment one did -not. **It has armed.** `plugins/onedev` was the first plugin package to declare a real dependency — it -pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on 2026-11-11; `plugins/mattpocock` -carries the same shape (pinned third-party skills, no primitives of its own) and the check fires on -it for real. Everything else in the root list is root-only, because it is the -root install that has a lockfile, a deployment ledger and deployed files to check. +only `lockfile-exists`). The plugin-level `content-integrity` row scans no package source: on 0.39.3 +it still passed with a bidi override planted in a scratch copy of `plugins/lint`. When +`lockfile-exists` fails, the table holds that one row alone. `lockfile-exists` is conditional, and +vacuous while every plugin `apm.yml` declared `dependencies: {apm: [], mcp: []}` — it reports `No +dependencies declared -- lockfile not required`. An earlier revision of this section said it would +arm the moment one did not. **It has armed.** `plugins/onedev` was the first plugin package to +declare a real dependency — it pinned `code.onedev.io/onedev/tod#v4.3.4` — and was removed on +2026-11-11; `plugins/mattpocock` carries the same shape (pinned third-party skills, no primitives of +its own) and the check fires on it for real. Everything else in the root list is root-only, because +it is the root install that has a lockfile, a deployment ledger and deployed files to check. **A plugin package that declares dependencies has no green state, so the hook waives exactly one -failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the same for any package that declares dependencies), and again on apm 0.39.3 in a scratch copy of `plugins/mattpocock` (holocron#272): +failure.** Verified against apm 0.28.0 in `plugins/onedev/` (since removed; the behaviour is the +same for any package that declares dependencies), and again on apm 0.39.3 in a scratch copy of +`plugins/mattpocock` (holocron#272): - **Without a package `apm.lock.yaml`**, `lockfile-exists` fails — `apm.yml declares dependencies but apm.lock.yaml is absent` — reported as `1 of 1 check(s) failed`. Unchanged on 0.39.3. @@ -1233,14 +1234,14 @@ and nothing else, and only for a non-root manifest: it asserts the string `1 of so any second failing check changes the count and the run fails normally, and output it does not recognise fails closed. The root manifest is never waived. Recorded as ADR-0026. -**Dropping `--ci` for package directories was considered and rejected.** It is the smaller change and -it is wrong. Verified on apm 0.28.0, and again on 0.39.3 (holocron#272), against a scratch package -whose dependency entry carried no `git`/`path`/`registry` field: `apm audit --ci` exits 1 naming the -field, while plain `apm audit` exits 0. Plain `apm audit` printed `No apm.lock.yaml found -- nothing -to scan` on 0.28.0 and prints `No recognized deployed primitives found -- nothing to scan` on 0.39.3. Malformed-dependency detection is the -reason this section gives for auditing packages at all, and a package *with* dependencies is the only -kind that can carry a malformed dependency entry — so dropping `--ci` would discard the check -precisely where it earns its keep. +**Dropping `--ci` for package directories was considered and rejected.** It is the smaller change +and it is wrong. Verified on apm 0.28.0, and again on 0.39.3 (holocron#272), against a scratch +package whose dependency entry carried no `git`/`path`/`registry` field: `apm audit --ci` exits 1 +naming the field, while plain `apm audit` exits 0. Plain `apm audit` printed `No apm.lock.yaml found +-- nothing to scan` on 0.28.0 and prints `No recognized deployed primitives found -- nothing to +scan` on 0.39.3. Malformed-dependency detection is the reason this section gives for auditing +packages at all, and a package *with* dependencies is the only kind that can carry a malformed +dependency entry — so dropping `--ci` would discard the check precisely where it earns its keep. **Known weak point: the waiver matches on apm's stdout.** An apm upgrade that rewords either line turns the waiver off. That fails the push rather than hiding a defect; re-verify against the new @@ -1259,11 +1260,12 @@ disk, so on a fresh clone it fails with ` deployed file(s) missing` (303 on 0 follows the lock) and takes the push with it. That is not a defect in the gate; it is the gate correctly reporting that nothing has been installed yet. Before the first push from a new checkout, run `uv sync --frozen` and then `uv run --frozen apm install`, each once and online. Without the -first, the hooks' plain `uv run --frozen` performs that sync itself, which needs the network. An older checkout -whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by apm 0.28 moves those -three directories aside before that first 0.39 install. Otherwise apm refuses to replace the files -with `no trustworthy local deployment baseline`, because 0.28 recorded no deployment evidence for -them. apm's message suggests a bare `apm install`; run the `uv run --frozen` form instead. +first, the hooks' plain `uv run --frozen` performs that sync itself, which needs the network. An +older checkout whose `.claude/skills`, `.claude/agents` and `.claude/commands` were deployed by apm +0.28 moves those three directories aside before that first 0.39 install. Otherwise apm refuses to +replace the files with `no trustworthy local deployment baseline`, because 0.28 recorded no +deployment evidence for them. apm's message suggests a bare `apm install`; run the `uv run --frozen` +form instead. **A lock written over a 0.28-populated `apm_modules/` is wrong, and this gate family catches it late.** Before any 0.39 command that writes `apm.lock.yaml` (`uv run --frozen apm update`, or an @@ -1273,7 +1275,11 @@ third-party copies and writes a lock without their `carried_licenses` entries. A adds the LICENSE files, the cached content hash no longer matches the lock, and `apm-pack-check-clean` fails with `does not match the content hash recorded in apm.lock.yaml` (found under #272, fixed on #271 by regenerating the lock from a fresh install). Only writing the -lock is affected: consuming the committed lock needs only the two setup steps. +lock is affected: consuming the committed lock needs only the two setup steps. kyberforge's +`SessionStart` hook is such a writer: it runs `uv run --frozen apm update --yes` at session start, +so in a checkout apm 0.28 populated it can write the bad lock before anyone reads this. To recover, +discard it with `git checkout -- apm.lock.yaml`, move `apm_modules/` aside, then run +`uv run --frozen apm install`. It does **not** enforce an org policy. apm discovers one from the git remote and only understands github.com and Azure DevOps, so against this repo's self-hosted Gitea remote it prints: @@ -1418,10 +1424,10 @@ replay the install to diff scratch against the working tree, and that replay is `[>] Replaying install (cache-only)` — which is exactly why it costs no network here. On a **fresh clone** there is no cache to replay from, so the replay clones from the holocron remote and those two checks fail offline, with `deployed-files-present` already failing for the same reason (see -`apm-audit-ci` above). The offline guarantee is a property of a populated `apm_modules/`, not of the -hook set: run `uv sync --frozen` and `uv run --frozen apm install` once on a new checkout and it -holds from then on. Run apm only in that pinned form here: a bare `apm` reaches the machine-global -0.28.0, which this repo does not use and which refuses the v4 `apm.lock.yaml`. +`apm-audit-ci` above). The offline guarantee is a property of a synced `.venv/` and a populated +`apm_modules/`, not of the hook set: run `uv sync --frozen` and `uv run --frozen apm install` once +on a new checkout and it holds from then on. Run apm only in that pinned form here: a bare `apm` +reaches whatever is on `PATH`, possibly an older apm that refuses the v4 `apm.lock.yaml`. ## Plugin release tags are not a gate diff --git a/tests/test-apm-hooks-git-env.sh b/tests/test-apm-hooks-git-env.sh index 78074dc..87513cd 100644 --- a/tests/test-apm-hooks-git-env.sh +++ b/tests/test-apm-hooks-git-env.sh @@ -7,10 +7,10 @@ # drift replay runs `git init` / `git checkout` in a temp dir with an env copied # from os.environ, so the inherited GIT_DIR wins: `git init` wrote # core.bare=true into the shared .git/config, and a later checkout moved the -# worktree's HEAD to the lock-pinned commit. apm 0.39.3 strips GIT_DIR from -# its own git calls (git_subprocess_env, apm_cli/utils/git_env.py); the leak -# was not reproduced again there, and this suite keeps the hooks' own scrub -# pinned as defence in depth (#272). +# worktree's HEAD to the lock-pinned commit. apm 0.39.3's +# apm_cli/utils/git_env.py provides git_subprocess_env, which strips GIT_DIR +# and the other repo-locating vars; the leak was not re-tested on 0.39.3, and +# this suite keeps the hooks' own scrub pinned as defence in depth (#272). # # The stub `apm` below reproduces that pattern -- record GIT_DIR, then `git init` # and `git checkout` inside a fresh `mktemp -d` -- and each hook script is run