P1 follow-up to the per-file-hash change on PR #1265. verifyDirDistManifest only iterated
manifest.files, so extra files/symlinks in the dist dir (stale build residue, local pollution)
were never compared against the actual directory contents — verify still returned true,
ensure-agent-binaries skipped the refresh, and stagePi copied the whole directory (including
unverified extra bytes) into the installer. verify now recursively enumerates the directory and
requires the actual set to match the manifest exactly: an extra regular file, a count mismatch,
or any symlink/non-regular entry (a pollution vector writeDirDistManifest never records) fails
verification.
Adds coverage: stray top-level file, stray nested file, and recovery after removal. Full
pnpm test:unit green.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>
Two more review follow-ups on PR #1265:
- tools/shared/dir-dist-manifest.mjs: the dir-dist manifest recorded and compared only
file sizes, so a corrupted or replaced Pi executable/sibling asset of the same byte
length passed the cache/package gate used by both tools/pi/update.mjs and
scripts/ensure-agent-binaries.mjs. writeDirDistManifest now records a sha256 per file
and verifyDirDistManifest re-hashes and compares them (fail-closed: a size-only legacy
manifest is treated as untrusted and forces a re-download). Complements the archive
digest pin from the earlier fix.
- sessionTaskSummary.ts: the task-summary one-shot fallback called
getMaker().oneShot(session.agentKind, ...) directly, so a pinned Pi session threw
(PiAgent has no oneShot) and the summary was silently left unset. It now skips the
fallback for agents that can't one-shot. Extracted a shared agentSupportsOneShot()
predicate in oneShotCandidates.ts and reused it in help.ts (replacing its local set)
so both one-shot fallbacks share one source of truth.
Adds coverage: same-length tamper and size-only manifests are rejected. Full
`pnpm test:unit` green; desktop typecheck clean.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Chris <4436110+zqchris@users.noreply.github.com>