Harden init target safety and package install verification

Merged
UN
4mo ago
+904-119

Summary

  • add explicit workspace/tracker target contracts for pm init, including executable --pm-path-scoped follow-ups
  • confine init --with-packages writes to the resolved target tracker
  • make extension load/activation failures authoritative across ok, activated, exit codes, aggregation, diagnostics, and SDK recovery guidance
  • add compact post-install verification for activation, registered commands/actions/types, target root, and blocking health
  • retain the context-evaluation runtime hardening already committed on this branch
  • normalize stale tracker sessions, close five completed canonical pm items, preserve the open canonical first-party service-collision follow-up, and regenerate CHANGELOG.md with pm-changelog 2026.7.8

Closes #488
Closes #473

Root causes

Path-target init output assumed workspace discovery and bundled installs inherited caller globals. Package installation also treated file copy as success even when runtime load or activation failed, producing contradictory result fields and a zero exit status.

Verification

  • node scripts/run-tests.mjs coverage: 270 files, 5,505 tests, exact 100/100/100/100
  • pm test-all --status in_progress --progress: 8 passed, 0 failed, 1 duplicate-safe skip
  • pnpm typecheck
  • pnpm contracts:check
  • pnpm lint: ESLint, 0 jscpd clones, static quality, token budget
  • docs/skills and context-evaluation gates
  • secret scan and dependency audit: clean
  • live CodeFactor: A+, 0 issues
  • packed npm proof: 11 bundled packages activated in target tracker, 0 caller extension files, CLI + public SDK context green, isolated doctor blocking failures = 0
  • Greptile pre-push review a05e5598-76c0-4e44-b255-a7e41fb356f2: confidence 5/5, no comments
  • pm health --check-only --summary: clean; history drift: 0

Tracker

Completed: pm-x26a, pm-3wsi, pm-yjim, pm-qt5d, pm-b3e9. Broader context work returned to open/unclaimed; no pm items remain in progress.


Summary by cubic

Hardens pm init target safety and adds compact post‑install package verification. Preserves multi‑target install diagnostics, enforces non‑zero exits on degraded/disabled verification, and serializes package probing; includes runnable, tracker‑scoped next steps (addresses GH‑488, GH‑473) and fixes a CodeQL‑reported shell‑sensitive path case.

  • New Features

    • Explicit init target contract: pm init --workspace <dir> creates <dir>/.agents/pm; a positional path keeps tracker‑root mode. Result includes target (mode, tracker_root, workspace_root?) and next_steps that carry --pm-path.
    • pm install returns a verification summary (activation, registered commands/actions/types, target root, health). ok: false or verification.status: "degraded" fails the install.
    • Next steps hint SDK recovery when activation errors mention @unbrained/pm-cli.
  • Bug Fixes

    • Confined init --with-packages and project installs to the resolved tracker; guard positional path targets from repository‑root writes.
    • Preserve activation diagnostics in multi‑target rows; treat disabled/degraded verification as failure with a non‑zero exit; doctor and aggregation match runtime.
    • Serialize package‑root probing to avoid races for concurrent SDK callers.
    • Context evaluation: ignore unknown scorer keys, require finite thresholds, and aggregate only canonical metrics.
    • Security hardening: handle repeated shell‑sensitive path characters in init target rendering (CodeQL alert).