Skip to content

feat: harnesspm doctor checks that local files stay out of git - #5

Merged
tenphi merged 14 commits into
mainfrom
claude/scope-gpookh
Nov 13, 2026
Merged

tenphi merged 14 commits into
mainfrom
claude/scope-gpookh

Conversation

@tenphi

@tenphi tenphi commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

This pull request has three changes:

  1. harnesspm doctor, a new command. It checks that a repository is ready for harnesses, its own and a person's, and that no per-machine file can reach a commit.
  2. A release-flow fix. The version PR now refreshes harnesspm.lock.json, so main stays valid after a release. doctor found this bug on its first run.
  3. A telemetry delivery fix. A handler that exits without reading its event is logged with its exit code, not as EPIPE. CI hit this race on this PR.

1. harnesspm doctor

Why

harnesspm keeps per-machine files out of git through .git/info/exclude, but only while sync writes them. Nothing checked them afterwards:

  • A file that is already tracked stays tracked: an exclude only hides untracked files. sync warned about two such files, and only while writing them.
  • A file someone creates by hand, such as an opt-out harnesspm.local.json, was unprotected until the next sync.
  • .git/info/exclude belongs to one clone. On a fresh clone, a git add -A before the first sync commits everything.

What it checks

It changes nothing. Each problem names the command that fixes it. It exits 1 when a check fails; warnings do not fail.

Group Check Fails when
🔒 Local files Every per-machine file on disk is ignored by git and not tracked. It checks the files in harnesspm's sections of .git/info/exclude, plus harnesspm.local.json, CLAUDE.local.md, .claude/settings.local.json and a telemetry file. A file is tracked (fix: git rm --cached), or not ignored (fix: sync for a file harnesspm writes, otherwise a .gitignore entry). If a ! pattern in .gitignore brings back an excluded file, it says so. Outside a git repository it only warns.
➕ Harnesses of your own The clone's exclude file can be written. Each added harness is on this machine. Either is not true.
📦 Outputs Committed outputs are up to date, as sync --check checks. Per-machine links and generated files are in place. A committed output or the lock is out of date. Missing per-machine outputs only warn, because sync writes them.
🛡️ Trust Entries that wait for trust or for a person, and a held telemetry handler. Never: these are warnings (spec 10.4).

Git answers. git check-ignore and git ls-files decide, so .gitignore, .git/info/exclude and a global excludes file all count. harnesspm still never edits .gitignore.

$ npx harnesspm doctor
🔒 Local files
  ❌ CLAUDE.local.md is tracked by git, so a commit can include this machine's files, and harnesspm writes no added harnesses into it. Run `git rm --cached CLAUDE.local.md` and commit.
➕ Harnesses of your own
  ✅ .git/info/exclude can be written, so harnesspm keeps per-machine files out of git
  ✅ Added: alex (github:alex/harness, user)
📦 Outputs
  ✅ Committed outputs are up to date
  ✅ 14 per-machine outputs in place
🛡️  Trust
  ✅ Nothing waits for trust

❌ 1 problem. Each line above says how to fix it.

Where it shows up

  • status points to it when a per-machine file has a problem: 🩺 local files 1 problem. Run \npx harnesspm doctor`.`
  • The harnesspm-import skill runs it after add, and asks the user before untracking a file.

Spec

  • Scenario S16: "A person checks that a repository is ready for a harness of their own, and that no per-machine file can reach a commit."
  • 10.5 Doctor (new section): the checks, an example, and what it never does (edit .gitignore, untrack a file, write outputs).
  • One sentence each in 4.1 (rule 3) and 7.6.

Left out on purpose

  • --fix. sync already writes the excludes, and git rm --cached should be a person's choice.
  • A check for the user-level SessionStart hook. add --no-hook turns it off on purpose, and harnesspm does not record that choice, so a check would warn wrongly.
  • A Node version check. If doctor runs, Node is new enough.

2. The release flow refreshes the lock

The lock records the version of this repository's own harness. The version PR (#4) raised version in package.json to 0.2.0, but the lock stayed at 0.1.1:

version-packages now runs npm run sync after changeset version. The release job has CI=true, so sync skips added harnesses and writes only the committed outputs. This PR also refreshes the lock to 0.2.0. AGENTS.md (Releasing) says what the version PR now changes.

3. Telemetry: a handler that does not read its event

CI on this PR failed in the telemetry test "a command handler gets each event as JSON on stdin" (from #3):

AssertionError: The input did not match /handler `exit 7` exited with 7/. Input:
'… handler `exit 7`: spawnSync /bin/sh EPIPE\n'
  • Root cause. exit 7 ends before reading stdin, so writing the event fails with EPIPE. deliver.ts logged that error and skipped the exit code. Whether the shell exits before the write is a race, so it passed before.
  • Fix. Node still reports the exit status with EPIPE. EPIPE alone is no longer a delivery failure: the exit code decides, as for any handler.
  • Test. A new test sends a 90 KB event, larger than a pipe buffer, to exit 7, which makes the race certain (200 of 200 runs locally). It fails before the fix with the CI error, and passes after.
  • Changeset: patch.

Verified

  • npm run typecheck, npm test (74 tests: 8 new for doctor, 1 for the EPIPE race), npm run check and npm run sync pass.
  • Tests for doctor: a synced project is ready; a tracked CLAUDE.local.md fails with its git rm --cached fix; a hand-made harnesspm.local.json fails until sync lists it, and status points to doctor meanwhile; .claude/settings.local.json that harnesspm did not write needs a .gitignore entry; a ! pattern that brings a file back is named; an out-of-date lock fails; a missing added harness fails; outside git it only warns.
  • The built CLI (dist/cli.js doctor) on this repository: ✅ ready, with 8 per-machine files checked.
  • Changesets: minor for doctor, patch for the telemetry fix. The release fix needs none (CI only).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV

- ci.yml: typecheck, tests and `npm run check` on Node 24, and the built
  CLI (`--help`, `check`, `sync --check`) on Node 20 for `engines`.
- release.yml: every PR publishes `0.0.0-snapshot.<sha>` under
  `pr_<number>` with a sticky comment; pushes to main open the version PR
  or publish with provenance, a `v<version>` tag and a GitHub Release.
  Both jobs use npm trusted publishing in the `release` environment.
- Changesets replace the hand-written "Unreleased" line; AGENTS.md
  describes the new flow. The 0.1.0 notes stay in CHANGELOG.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
npm refuses a provenance statement from a private repository (E422), and
with trusted publishing it adds one by itself once the repository is
public. Also print the real OIDC availability in the publish jobs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
A re-run builds the same commit, so it got the same snapshot version, and
npm never accepts a version twice. Add the attempt number on a re-run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
…ions

`harnesspm why` found only rules, skills and docs, so it answered "No unit"
for the script IDs the managed block prints. It now finds every unit kind,
shows its source file, the command that runs a script, and whether the
package of an executable unit is trusted. Test fixtures use `alex`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
A team turns on `telemetry` in harnesspm.json: which events, and a handler
that gets them, a command (JSON on stdin) or a JSON Lines file. harnesspm
sends events for script runs, MCP server starts, sync and why. With agent
events on, a person's sync writes harnesspm's own async hooks: Claude Code
reports reads of harness files, skills it loads and file-scoped rules it
loads by itself; Claude Code and Codex report session starts. The hook runs
the local binary (`track`), maps the path to a unit with an index that sync
writes, hands the event off and exits 0.

Events never hold arguments, file contents, prompts or absolute paths, and
cover only the dependency and project layers. Sending never waits or fails a
command: a command handler runs in a detached process with a 10 s limit.

A handler gets events only as a person's sync recorded it in the lock. A
model run keeps the recorded handler, so one an agent adds stays held until
a person syncs. A person opts out with DO_NOT_TRACK=1 or "telemetry": false
in harnesspm.local.json or ~/.harnesspm/config.json.

Spec: new chapter 14 (with a rule template for reporting harness problems),
terms and scenarios S14 and S15, 3.7, 4.3, 5.1, 6, 10, 11, and removed
options in 13.12. Research: hook payloads and async hooks for both agents,
from the docs, Codex source and a headless Claude Code probe.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
When a package's `extends` names a package that is not installed, sync
warns. A package can now list an extends target as an optional peer
dependency (`optional: true` in `peerDependenciesMeta`): projects that
install it get its harness through the package, and projects that do not
see no warning on every sync. Any other missing extends still warns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
Claude Code matches a `paths` pattern without a leading `/` at any depth.
So `harness/**` loaded harnesspm's config rule whenever an agent only read
a dependency's harness files in node_modules. A probe with Claude Code
2.1.323 showed that `/harness/**` loads for the project's own folder only,
both as a plain file and as a symlink in .claude/rules/.

- harnesspm-config: `/harnesspm.json`, `/harnesspm.local.json`, `/harness/**`
- pointer lines show patterns without the leading `/`
- spec 2.5 and the export skill say how to anchor a pattern
- research: the probe result

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
The lock records the version of this repository's own harness. The
version PR raised `version` in package.json but left the lock at the old
version, so `sync --check` failed on main after every release, and the
next pull request had to carry the lock change. `version-packages` now
runs `npm run sync` after `changeset version`.

Also refreshes the lock to 0.2.0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
`harnesspm doctor` answers one question: can a person work here with
harnesses, the repository's and their own, without per-machine files
reaching a commit? It changes nothing, and each problem names its fix.

- Local files: every per-machine file on disk (the ones in harnesspm's
  sections of .git/info/exclude, plus harnesspm.local.json,
  CLAUDE.local.md, .claude/settings.local.json and a telemetry file) is
  ignored by git and not tracked. Git answers through `git check-ignore`
  and `git ls-files`, so .gitignore, .git/info/exclude and a global
  excludes file all count.
- Harnesses of your own: the exclude file can be written, and each added
  harness is on this machine.
- Outputs: committed outputs are up to date (as `sync --check`), and
  per-machine links and files are in place.
- Trust: pending and held entries, and a held telemetry handler, as
  warnings.

Exits 1 when a check fails. `status` points to it when a per-machine
file has a problem. Spec: scenario S16 and section 10.5.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📦 Snapshot release

Published 0.0.0-snapshot.fe3417f.

npx @tenphi/[email protected] --help
npm install -D @tenphi/[email protected]

…vent

A command handler that exits before reading its event closes stdin, so
writing the event fails with EPIPE. `deliver` logged that error instead
of the handler's exit code. Node still reports the exit status, so EPIPE
alone is no longer treated as a delivery failure.

CI hit this race in "a command handler gets each event as JSON on stdin".
A new test sends a 90 KB event, larger than a pipe buffer, to `exit 7`,
which makes the race certain: it fails before this fix and passes after.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Gr8S7Ed6WF7j8cpXBKzCuV
@tenphi
tenphi merged commit 40154b6 into main Nov 13, 2026
4 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 13, 2026

This branch was previously deployed

1 inactive deployment
release — d57982dd Deployed Nov 13, 2026 by tenphi via Snapshot release #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants