handoff-check 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.1
4
+
5
+ - Replace obsolete pre-publication onboarding instructions with registry usage.
6
+ - Document all commands, verification policies, and rule/policy exit semantics.
7
+ - Add a reproducible first-rule walkthrough with a passing snapshot and CHANGED failure.
8
+ - Record the research-backed development plan with priorities and acceptance gates.
9
+ - Keep verifier behavior and input/output contracts unchanged.
10
+
11
+ ## 0.3.0
12
+
13
+ - Show the expected active-rule count in every text verification summary.
14
+ - Mark valid zero-rule checks as PASS (EMPTY), with an explicit scope/time notice.
15
+ - Add activeConstraintCount to v2 JSON while preserving legacy default JSON shape.
16
+ - Add opt-in --require-active with a global NO_ACTIVE_CONSTRAINTS finding and exit 1.
17
+
3
18
  ## 0.2.0
4
19
 
5
20
  - Detect same-ID rule edits through revision and canonical SHA-256 references.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  A deterministic, local CLI that verifies active constraints before a coding agent
4
4
  resumes work.
5
5
 
6
- **Version: 0.2.0.**
6
+ **Version: 0.3.1.**
7
7
 
8
8
  A task summary may preserve the goal while losing an active rule, carrying an
9
9
  expired restriction, or moving a staging-only instruction into production.
@@ -15,11 +15,11 @@ Source references are review metadata and are never fetched.
15
15
 
16
16
  ## Quick start
17
17
 
18
- Once the npm package is published, run in the repository where your agent works:
18
+ Run in the repository where your agent works:
19
19
 
20
20
  ```sh
21
- npx handoff-check@0.2.0 init --scope staging --agent both --dry-run
22
- npx handoff-check@0.2.0 init --scope staging --agent both
21
+ npx handoff-check@0.3.1 init --scope staging --agent both --dry-run
22
+ npx handoff-check@0.3.1 init --scope staging --agent both
23
23
  ```
24
24
 
25
25
  This creates `.handoff-check.json`, starter `constraints.json` and `handoff.json`,
@@ -33,7 +33,7 @@ on verification. Revisions and hashes detect edits under an unchanged rule ID.
33
33
  Ask a resuming agent to use the installed skill, or run:
34
34
 
35
35
  ```sh
36
- npx handoff-check@0.2.0 verify --format json --require-content
36
+ npx handoff-check@0.3.1 verify --format json --require-content
37
37
  ```
38
38
 
39
39
  The saved config supplies paths and scope. `init --ci` also creates a pinned GitHub
@@ -41,17 +41,50 @@ Actions verification workflow. Skill/instruction installation does not guarantee
41
41
  agent execution; CI enforces the declared-ID comparison when its workflow runs.
42
42
  Neither checks whether the agent obeys a rule's meaning.
43
43
 
44
- Until publication, use a local package via the [setup guide](docs/agent-integration.md).
45
- Node.js 22+ is required; end users do not need Bun. After publication, global
46
- installation is also available: `npm install --global handoff-check@0.2.0`.
44
+ Node.js 22+ is required; end users do not need Bun. Global installation is also
45
+ available: `npm install --global handoff-check@0.3.1`. For contributor builds or
46
+ offline package testing, see the [setup guide](docs/agent-integration.md).
47
+
48
+ For a complete first-rule walkthrough, including a passing baseline and a detected
49
+ edit, see [your first real check](docs/first-check.md).
50
+
51
+ ## See how many rules were checked
52
+
53
+ Every text summary includes the expected active-rule count:
54
+
55
+ ```text
56
+ PASS 7 active constraints checked | 0 findings | scope staging | ...
57
+ PASS (EMPTY) 0 active constraints checked | 0 findings | ... | No active constraints apply to this scope and time
58
+ ```
59
+
60
+ This counts active selected/global rules, not reported IDs or total manifest
61
+ entries. Missing active rules count too. Zero may mean a starter, another scope,
62
+ or inactive rules; it does not prove the manifest is empty. Empty checks exit 0 by
63
+ default but are explicitly marked. Unexpected reported IDs still fail.
64
+
65
+ To require actual active rules, opt in:
66
+
67
+ ```sh
68
+ npx handoff-check@0.3.1 verify --require-content --require-active --format json
69
+ ```
70
+
71
+ A zero active set produces global NO_ACTIVE_CONSTRAINTS (no fake ID), mismatch
72
+ status and exit 1. Other findings remain. Invalid inputs still exit 2. V2 JSON
73
+ includes activeConstraintCount; legacy default JSON exposes the expected set in
74
+ expectedConstraints without changing its fields.
75
+
76
+ The policy is not automatically enabled in starter CI. After adding real rules,
77
+ append --require-active to the generated workflow command. It is verify-only;
78
+ init and snapshot reject it. See the
79
+ [empty verification contract](docs/decisions/0003-empty-verification.md).
47
80
 
48
81
  ## Catch rule edits between sessions
49
82
 
50
83
  After reviewing rules at handoff creation, capture a new baseline:
51
84
 
52
85
  ```sh
53
- npx handoff-check@0.2.0 snapshot --task "Resume migration review" --output handoff.next.json
54
- npx handoff-check@0.2.0 verify --handoff handoff.next.json --require-content --format json
86
+ npx handoff-check@0.3.1 snapshot --task "Resume migration review" --output handoff.next.json
87
+ npx handoff-check@0.3.1 verify --handoff handoff.next.json --require-content --format json
55
88
  ```
56
89
 
57
90
  Snapshot creates a new file exclusively. Review it before deliberately replacing
@@ -86,7 +119,7 @@ or revisioned v2 manifests. Scope must match the v2 handoff's saved scope.
86
119
  Review current rules, capture a new v2 baseline, and deliberately update the saved
87
120
  handoff. Existing inputs are preserved by init, not silently upgraded. Review
88
121
  installed skills, instruction blocks and CI commands to update their pinned
89
- version to 0.2.0 and add `--require-content`. Init refuses to overwrite differing
122
+ version to 0.3.1 and add `--require-content`. Init refuses to overwrite differing
90
123
  integrations; compare them with the new packaged templates and update reviewed
91
124
  copies explicitly. Never refresh before checking resumed work or reuse capturedAt
92
125
  as the clock for real resumed work.
@@ -131,7 +164,8 @@ bun run check
131
164
  ```
132
165
 
133
166
  Bun 1.2.10 is used in CI. Build output runs on Node.js 22 or newer. The package
134
- name is `handoff-check`; claiming it requires authenticated npm publication.
167
+ name is `handoff-check`; release operations use reviewed artifacts and trusted
168
+ publishing as described in [the release guide](docs/releasing.md).
135
169
 
136
170
  ## Try the reproducible demo
137
171
 
@@ -146,7 +180,7 @@ The synthetic Friday freeze has expired and the migration review rule is missing
146
180
  ```text
147
181
  EXPIRED C-02 Remove expired constraint: Staging freeze ended Friday at 18:00 UTC
148
182
  MISSING C-07 Include active constraint: Require review before applying migrations
149
- FAIL 2 findings | scope staging | as of 2026-11-23T09:00:00.000Z
183
+ FAIL 1 active constraints checked | 2 findings | scope staging | as of 2026-11-23T09:00:00.000Z | IDs only; content changes not checked
150
184
  ```
151
185
 
152
186
  This command intentionally exits with code 1. Use the corrected handoff to pass:
@@ -156,7 +190,7 @@ bun run dev verify --constraints examples/stale-handoff/constraints.json --hando
156
190
  ```
157
191
 
158
192
  ```text
159
- PASS 0 findings | scope staging | as of 2026-11-23T09:00:00.000Z
193
+ PASS 1 active constraints checked | 0 findings | scope staging | as of 2026-11-23T09:00:00.000Z | IDs only; content changes not checked
160
194
  ```
161
195
 
162
196
  For the built CLI, run `bun run build`, then replace `bun run dev` with
@@ -211,8 +245,22 @@ handoff-check verify --scope <scope>
211
245
  [--handoff <path>] default: handoff.json
212
246
  [--as-of <UTC time>] default: current time, captured once
213
247
  [--format text|json] default: text
248
+ [--require-content] require a v2 content-aware handoff
249
+ [--require-active] fail when no active constraints apply
250
+
251
+ handoff-check snapshot --task <task>
252
+ [--config <path>] [--constraints <path>] [--scope <scope>]
253
+ [--as-of <UTC time>] [--output <new-file>] [--format text|json]
254
+
255
+ handoff-check init --scope <scope>
256
+ [--agent codex|claude|both|none] [--dry-run] [--ci] [--format text|json]
214
257
  ```
215
258
 
259
+ Snapshot writes v2 JSON to stdout unless `--output` creates a new file. Its
260
+ `--format` option controls the saved-file acknowledgement when an output path is
261
+ used. The two `--require-*` policies and `--handoff` are verify-only. Run
262
+ `handoff-check --help` for the complete option list.
263
+
216
264
  The same inputs, scope, and time produce the same output. Use `--as-of` for
217
265
  reproducible CI checks. Explicit CLI paths resolve from the current working directory;
218
266
  configured paths resolve from the config file's directory.
@@ -221,11 +269,11 @@ include global rules even when no scope-specific rules exist.
221
269
 
222
270
  | Exit code | Meaning |
223
271
  | --------- | ---------------------------------------------------------- |
224
- | 0 | Declared IDs match the active manifest rules |
225
- | 1 | Rule mismatch; inspect findings |
272
+ | 0 | Verification succeeded, including requested policies |
273
+ | 1 | Rule or active-set policy mismatch; inspect findings |
226
274
  | 2 | Invalid arguments, invalid input, or unreadable input file |
227
275
 
228
- Findings include `MISSING`, `EXPIRED`, `REVOKED`, `SUPERSEDED`, `OUT_OF_SCOPE`,
276
+ Per-rule findings include `MISSING`, `EXPIRED`, `REVOKED`, `SUPERSEDED`, `OUT_OF_SCOPE`,
229
277
  `UNKNOWN`, and (for v2) `CHANGED`, ordered by ID. A reported ID receives one primary finding according to
230
278
  the precedence in the lifecycle ADR.
231
279
 
package/dist/cli.js CHANGED
@@ -7,7 +7,7 @@ import { parseArgs } from "node:util";
7
7
  // package.json
8
8
  var package_default = {
9
9
  name: "handoff-check",
10
- version: "0.2.0",
10
+ version: "0.3.1",
11
11
  description: "A deterministic, local CLI that verifies active constraints before a coding agent resumes work.",
12
12
  type: "module",
13
13
  packageManager: "bun@1.2.10",
@@ -540,7 +540,7 @@ function inactive(rule, scope, time) {
540
540
  return "EXPIRED";
541
541
  return;
542
542
  }
543
- function verify(manifest, handoff, scope, asOf) {
543
+ function verify(manifest, handoff, scope, asOf, options = {}) {
544
544
  identifier(scope, "scope");
545
545
  if (handoff.schemaVersion === 2 && handoff.scope !== scope)
546
546
  throw new InputError(`Handoff scope '${handoff.scope}' does not match selected scope '${scope}'`);
@@ -589,10 +589,19 @@ function verify(manifest, handoff, scope, asOf) {
589
589
  }
590
590
  }
591
591
  }
592
- findings.sort((a, b) => compare(a.id, b.id) || compare(a.code, b.code));
592
+ if (options.requireActive && expectedConstraints.length === 0) {
593
+ findings.push({
594
+ code: "NO_ACTIVE_CONSTRAINTS",
595
+ message: "No active constraints apply to the selected scope and time; --require-active requires at least one"
596
+ });
597
+ }
598
+ findings.sort((a, b) => compare(a.id ?? "", b.id ?? "") || compare(a.code, b.code));
593
599
  return {
594
600
  schemaVersion: handoff.schemaVersion,
595
- ...handoff.schemaVersion === 2 ? { tracking: "content" } : {},
601
+ ...handoff.schemaVersion === 2 ? {
602
+ tracking: "content",
603
+ activeConstraintCount: expectedConstraints.length
604
+ } : {},
596
605
  status: findings.length ? "mismatch" : "verified",
597
606
  scope,
598
607
  asOf: new Date(time).toISOString(),
@@ -629,6 +638,7 @@ Options:
629
638
  --config <path> Project config (default: cwd/.handoff-check.json)
630
639
  --as-of <UTC time> Fixed evaluation time (default: current time)
631
640
  --require-content verify: require a v2 content-aware handoff
641
+ --require-active verify: fail if no constraints apply to scope/time
632
642
  --task <task> snapshot: task description (required)
633
643
  --output <path> snapshot: create a new baseline file, never overwrite
634
644
  --format text|json Output format (default: text)
@@ -638,7 +648,7 @@ Options:
638
648
  --version Show package version
639
649
  --help Show this help
640
650
 
641
- Exit codes: 0 verified, 1 rule mismatch, 2 invalid input
651
+ Exit codes: 0 verified, 1 rule/policy mismatch, 2 invalid input
642
652
  `;
643
653
  function terminalText(value) {
644
654
  return Array.from(value, (character) => {
@@ -669,6 +679,7 @@ async function main() {
669
679
  "dry-run": { type: "boolean" },
670
680
  ci: { type: "boolean" },
671
681
  "require-content": { type: "boolean" },
682
+ "require-active": { type: "boolean" },
672
683
  task: { type: "string" },
673
684
  output: { type: "string" }
674
685
  }
@@ -695,6 +706,7 @@ async function main() {
695
706
  "config",
696
707
  "as-of",
697
708
  "require-content",
709
+ "require-active",
698
710
  "task",
699
711
  "output"
700
712
  ])
@@ -740,8 +752,8 @@ ${result2.notice}
740
752
  throw new InputError(`--${key}: expected a non-empty path`);
741
753
  const manifest = parseManifest(await readJson(values.constraints !== undefined ? resolve3(cwd, values.constraints) : resolve3(directory, config.constraints ?? "constraints.json")));
742
754
  if (positionals[0] === "snapshot") {
743
- if (values.handoff !== undefined || values["require-content"] !== undefined)
744
- throw new InputError("--handoff and --require-content are only supported by verify");
755
+ if (values.handoff !== undefined || values["require-content"] !== undefined || values["require-active"] !== undefined)
756
+ throw new InputError("--handoff, --require-content and --require-active are only supported by verify");
745
757
  if (values.task === undefined)
746
758
  throw new InputError("snapshot requires --task");
747
759
  const captured = snapshot(manifest, values.task, scope, asOf);
@@ -781,16 +793,20 @@ ${result2.notice}
781
793
  const handoff = parseHandoff(await readJson(values.handoff !== undefined ? resolve3(cwd, values.handoff) : resolve3(directory, config.handoff ?? "handoff.json")));
782
794
  if (values["require-content"] && handoff.schemaVersion !== 2)
783
795
  throw new InputError("Content tracking requires a schemaVersion 2 handoff; review current rules and capture a snapshot before resuming");
784
- const result = verify(manifest, handoff, scope, asOf);
796
+ const result = verify(manifest, handoff, scope, asOf, {
797
+ requireActive: values["require-active"] ?? false
798
+ });
785
799
  if (format === "json") {
786
800
  process.stdout.write(`${JSON.stringify(result, null, 2)}
787
801
  `);
788
802
  } else {
789
803
  for (const finding of result.findings) {
790
- process.stdout.write(`${finding.code.padEnd(12)} ${finding.id} ${terminalText(finding.message)}
804
+ process.stdout.write(`${finding.code.padEnd(12)} ${finding.id === undefined ? "" : `${finding.id} `}${terminalText(finding.message)}
791
805
  `);
792
806
  }
793
- process.stdout.write(`${result.status === "verified" ? "PASS" : "FAIL"} ${result.findings.length} findings | scope ${scope} | as of ${result.asOf}${handoff.schemaVersion === 1 ? " | IDs only; content changes not checked" : " | content tracked"}
807
+ const count = result.expectedConstraints.length;
808
+ const label = result.status === "verified" ? count === 0 ? "PASS (EMPTY)" : "PASS" : "FAIL";
809
+ process.stdout.write(`${label} ${count} active constraints checked | ${result.findings.length} findings | scope ${scope} | as of ${result.asOf}${handoff.schemaVersion === 1 ? " | IDs only; content changes not checked" : " | content tracked"}${count === 0 ? " | No active constraints apply to this scope and time" : ""}
794
810
  `);
795
811
  }
796
812
  return result.status === "verified" ? 0 : 1;
@@ -6,11 +6,11 @@ infers rules from a summary.
6
6
 
7
7
  ## Registry installation
8
8
 
9
- After the npm release is published, from the consuming repository root:
9
+ From the consuming repository root:
10
10
 
11
11
  ```sh
12
- npx handoff-check@0.2.0 init --scope staging --agent both --dry-run
13
- npx handoff-check@0.2.0 init --scope staging --agent both
12
+ npx handoff-check@0.3.1 init --scope staging --agent both --dry-run
13
+ npx handoff-check@0.3.1 init --scope staging --agent both
14
14
  ```
15
15
 
16
16
  Choose `codex`, `claude`, `both` (default), or `none`. Generated integrations:
@@ -23,9 +23,10 @@ Choose `codex`, `claude`, `both` (default), or `none`. Generated integrations:
23
23
  Review and commit generated files. `--dry-run` previews all changes. Existing valid
24
24
  inputs and surrounding instruction text are preserved; conflicts fail before
25
25
  writes. Starters have zero rules: author reviewed constraints and populate handoff
26
- IDs before relying on verification.
26
+ references through a reviewed snapshot before relying on verification. Follow
27
+ [your first real check](first-check.md) for a complete example.
27
28
 
28
- ## Local package before publication
29
+ ## Local contributor package
29
30
 
30
31
  From this source checkout, with Bun installed:
31
32
 
@@ -38,12 +39,12 @@ npm pack
38
39
  From a separate consuming project, substitute the actual absolute tarball path:
39
40
 
40
41
  ```sh
41
- npx --offline --yes --package=/absolute/path/handoff-check-0.2.0.tgz handoff-check init --scope staging --agent both
42
- npx --offline --yes --package=/absolute/path/handoff-check-0.2.0.tgz handoff-check verify --format json --require-content
42
+ npx --offline --yes --package=/absolute/path/handoff-check-0.3.1.tgz handoff-check init --scope staging --agent both
43
+ npx --offline --yes --package=/absolute/path/handoff-check-0.3.1.tgz handoff-check verify --format json --require-content
43
44
  ```
44
45
 
45
46
  Bun is not required for these consumer commands. Generated agent commands use the
46
- pinned registry package. Before publication, use the same tarball invocation or
47
+ pinned registry package. To test an unpublished contributor build, use the same tarball invocation or
47
48
  `node /absolute/path/Handoff-Check/dist/cli.js` in your local agent test prompt.
48
49
  A local tarball does not make its npm name available in the public registry.
49
50
 
@@ -78,6 +79,13 @@ events and context-reset behavior differ.
78
79
 
79
80
  ## Upgrades and contributor instructions
80
81
 
82
+ In 0.3, verification reports how many selected/global rules are active. V2 JSON
83
+ includes activeConstraintCount. Empty checks remain valid by default but text
84
+ clearly says PASS (EMPTY). Agents must not present this as real policy coverage.
85
+ Teams can explicitly add --require-active to verify/CI after authoring rules;
86
+ zero then exits 1 with a global NO_ACTIVE_CONSTRAINTS finding. New starter CI does
87
+ not enable this policy automatically. V1 default JSON remains unchanged.
88
+
81
89
  Matching integrations are preserved on repeated init. If a skill or managed block
82
90
  differs, compare it to the new package and review/update explicitly; there is no
83
91
  force-overwrite mode. Commands stay pinned until a reviewed upgrade.
@@ -0,0 +1,55 @@
1
+ # ADR 0003: Make empty verification explicit
2
+
3
+ Status: accepted for 0.3.0.
4
+
5
+ ## Counts and empty results
6
+
7
+ The active count is the size of the expected set: rules applicable to the selected
8
+ scope plus global rules, after expiry, revocation and supersession. It is not the
9
+ number of reported IDs, successful matches, findings, or manifest entries. Missing
10
+ active rules still count. Globals count once. Fixed-time behavior stays stable.
11
+
12
+ Text always reports the count. A verified result with zero active rules is labeled
13
+ PASS (EMPTY) and says no active constraints apply to scope/time. It still exits 0
14
+ by default: an empty set is valid, but verifies no real active rule. Zero may also
15
+ mean all rules are inactive or in other scopes; do not infer an empty starter.
16
+
17
+ If unexpected IDs remain in a handoff with zero expected rules, the result stays
18
+ FAIL with those findings. Every zero-count text result has the scope/time notice.
19
+
20
+ ## Machine-readable compatibility
21
+
22
+ V2 JSON adds numeric activeConstraintCount, equal to expectedConstraints.length
23
+ regardless of success/mismatch. Existing fields and input schemas stay unchanged;
24
+ consumers should allow additive metadata. Legacy v1 JSON keeps its exact default
25
+ shape; derive its count from expectedConstraints. No snapshot/hash changes occur.
26
+
27
+ ## Optional nonempty policy
28
+
29
+ `verify --require-active` requires at least one expected active rule. This is an
30
+ explicit policy, not input validation: valid files with zero active rules return
31
+ mismatch and exit 1, rather than invalid input/exit 2. The core receives an explicit
32
+ optional policy parameter and never reads flags or files.
33
+
34
+ The zero set adds one global finding:
35
+
36
+ ```json
37
+ {
38
+ "code": "NO_ACTIVE_CONSTRAINTS",
39
+ "message": "No active constraints apply to the selected scope and time; --require-active requires at least one"
40
+ }
41
+ ```
42
+
43
+ It has no invented ID or revision/hash fields. Global findings sort before per-ID
44
+ findings. Existing stale/unknown findings remain; per-ID lifecycle/content
45
+ precedence and ID/code ordering stay unchanged. A nonempty expected set yields
46
+ the same result with or without this policy.
47
+
48
+ The option applies to both handoff formats. Legacy strict mode introduces the
49
+ documented opt-in finding but no v2 count metadata. Init and snapshot reject it;
50
+ capturing a reviewed empty set remains possible.
51
+
52
+ Skills and generated CI do not silently enable this policy. Starters have zero
53
+ rules and some scopes intentionally have none. Teams add --require-active after
54
+ authoring/reviewing constraints. Agents should report zero without presenting it
55
+ as validation of real policy. --require-content is independently combinable.
@@ -0,0 +1,146 @@
1
+ # Development plan
2
+
3
+ Status: proposed after 0.3.0; documentation/onboarding work ships in 0.3.1.
4
+ Research reviewed: 2026-11-24. Version labels below are targets, not release promises.
5
+
6
+ ## Product direction
7
+
8
+ Make it clear and repeatable that current declared constraints were checked for
9
+ the intended project, scope, and time before a coding agent resumes affected work.
10
+ Keep the verifier local, deterministic, read-only, and independent of a model or
11
+ agent host. A verified declaration does not prove behavioral compliance.
12
+
13
+ ## Evidence and confidence
14
+
15
+ Public issue reports are qualitative evidence, not prevalence measurements or
16
+ proof that every current version has the reported defect. Closed/duplicate reports
17
+ remain historical evidence only. Proposed features below are product hypotheses.
18
+
19
+ | Signal | Primary source | Implication |
20
+ | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
21
+ | Compaction can lose behavioral instructions; historical report closed as duplicate | [Claude Code #4517](https://github.com/anthropics/claude-code/issues/4517) | Resume checks should not depend only on an agent remembering a skill. |
22
+ | Long-running agents lose continuity and can declare completion prematurely | [Anthropic: effective harnesses](https://www.anthropic.com/research/effective-harnesses-for-long-running-agents) | Preserve explicit artifacts and distinguish declarations from verified execution. |
23
+ | Current instructions may compete with stale memory | [Codex #39223](https://github.com/openai/codex/issues/39223) | Explain changes; do not claim that detecting stale declarations ensures model adherence. |
24
+ | Worktree sessions can lack skills/rules or target another workspace | [Claude Code #28041](https://github.com/anthropics/claude-code/issues/28041), [#36182](https://github.com/anthropics/claude-code/issues/36182) | Diagnose resolved paths/integrations and consider explicit project binding. |
25
+ | Users request duplication/conflict/instruction-budget diagnostics | [Claude Code #85477](https://github.com/anthropics/claude-code/issues/85477) | Test demand for rule-maintenance tooling without promising semantic conflict detection. |
26
+ | Hooks support lifecycle automation independently of model command selection | [Claude Code hooks guide](https://code.claude.com/docs/en/hooks-guide) | Build separately tested host adapters around the existing CLI. |
27
+ | Rule layers and precedence differ across hosts | [Cursor rules](https://prod.cursor.com/help/customization/rules) | Declare adapter capabilities and limitations explicitly. |
28
+
29
+ Maintainer-supplied community feedback additionally asked for changed-rule detail,
30
+ staging/production separation, and the number of rules behind a passing check.
31
+ These are paraphrased conversation inputs, not independently measured demand.
32
+ 0.3.0 addresses the active-count/empty-pass distinction already.
33
+
34
+ ## 0.3.1: onboarding clarity
35
+
36
+ Priority: immediate. No verifier or schema changes.
37
+
38
+ - Remove obsolete pre-publication instructions and align version pins.
39
+ - Document verify policies, snapshot/init usage, and policy exit semantics.
40
+ - Provide a disposable first-rule walkthrough: empty pass, missing rule, reviewed
41
+ baseline pass, and same-ID changed-rule failure.
42
+ - Preserve a clear distinction between snapshot creation and baseline adoption.
43
+
44
+ Acceptance: execute the walkthrough using a built package from a separate consumer
45
+ directory; observe expected statuses/codes and verify that verification does not
46
+ rewrite the saved baseline. Check documented flags against actual CLI behavior.
47
+
48
+ ## 0.4: explainable verification
49
+
50
+ Priority: high. Dependencies: an ADR for snapshot evolution and privacy/storage choices.
51
+
52
+ 1. Add an `explain` command showing scope/global selection and lifecycle decisions
53
+ using the same pure evaluation logic, with explicit evaluation time.
54
+ 2. Design opt-in retention of canonical old rule content for field-level diffs.
55
+ Hash-only snapshots cannot reconstruct old text. Preserve existing snapshot
56
+ support and clearly report when old content is unavailable.
57
+ 3. Offer a deterministic Markdown report for local review and CI artifacts/job
58
+ summaries, with scope, time, active count, tracking mode, policies, and findings.
59
+
60
+ Acceptance:
61
+
62
+ - Explain output agrees with verify at lifecycle boundaries and for global rules.
63
+ - Added/removed/changed fields are readable when old content exists; older
64
+ snapshots still detect CHANGED without invented old values.
65
+ - Terminal/Markdown output safely renders untrusted rule text.
66
+ - Reports and verification never silently recapture or adopt a baseline.
67
+ - Evaluate storage size and sensitive-content exposure before choosing defaults.
68
+
69
+ ## 0.5: automatic checks and installation diagnostics
70
+
71
+ Priority: high, after explainability. No second verification engine.
72
+
73
+ 1. Add read-only `doctor` diagnostics for resolved config/input paths, supported
74
+ schema versions, installed managed integrations, and package pins.
75
+ 2. Add opt-in Claude Code lifecycle adapters for startup/resume/compaction where
76
+ current host documentation and executable tests support them.
77
+ 3. Publish a capability matrix for each host. Investigate Codex and Cursor
78
+ integrations against their actual supported interfaces before promising parity.
79
+ 4. Document critical-action integration recipes that re-run verification near the
80
+ action instead of reusing an hours-old session-start result.
81
+
82
+ Acceptance:
83
+
84
+ - Adapter fixtures cover supported event payloads, timeouts, invalid inputs,
85
+ mismatch results, worktree paths, and existing user configuration preservation.
86
+ - Distinguish advisory context injection from actual action blocking; a lifecycle
87
+ notification must never be described as a deployment permission boundary.
88
+ - Missing integrations and unsupported hosts are explicit, actionable diagnostics.
89
+ - No automatic baseline refresh, silent policy opt-in, or hook installation overwrite.
90
+ - No claim that doctor can see every instruction or hidden host memory.
91
+
92
+ ## 0.6: project and environment correctness
93
+
94
+ Priority: medium/high; validate with worktree and multi-environment pilots first.
95
+
96
+ 1. Design opt-in project identity binding in a versioned contract. Use a portable
97
+ explicit identity rather than treating an absolute folder path as identity.
98
+ 2. Explore named environment profiles selecting an explicit scope and input paths.
99
+ Never infer production authorization from a branch name or directory.
100
+ 3. Include reproducibility metadata in an optional report: input digests, selected
101
+ policies, package version, evaluation time, and explicitly requested Git context.
102
+
103
+ Acceptance:
104
+
105
+ - Configured cross-project and scope mismatches fail with actionable diagnostics.
106
+ - Worktrees retain project identity while resolving their own configured inputs.
107
+ - Existing unbound inputs remain supported under documented compatibility rules.
108
+ - Reports are described as local records, not authenticated attestations or proof
109
+ of agent compliance. Revalidate changed inputs rather than trusting old reports.
110
+
111
+ ## Later: rule maintenance, gated by pilot demand
112
+
113
+ Priority: medium. Keep source inspection separate from normal verify semantics.
114
+
115
+ - Explore explicit local source bindings and a separate read-only source-check
116
+ command. A referenced file edit can signal review needed; it does not prove the
117
+ rule's meaning changed. Decide full-file versus section binding deliberately.
118
+ - Consider owner/review-by metadata. Overdue review is distinct from rule expiry;
119
+ it must not silently deactivate a restriction.
120
+ - Consider explicitly declared relationships such as conflicts/requires. Validate
121
+ these deterministically; defer free-text contradiction inference.
122
+
123
+ Acceptance: each addition has a versioned schema/ADR, migration guidance,
124
+ deterministic tests, and no implicit network fetches, arbitrary command execution,
125
+ or autonomous manifest edits. Optional file reads belong in the CLI adapter.
126
+
127
+ ## Pilot validation and release gates
128
+
129
+ Recruit at least five consenting repositories across single-agent, multi-agent/
130
+ worktree, and staging/production workflows. Recruitment and interviews have not
131
+ yet happened; do not present this desk research as user validation.
132
+
133
+ Track installation-to-first-meaningful-check time, ability to explain a failure,
134
+ time to resolve changed-rule findings, skipped checks, and unnecessary warnings.
135
+ Use synthetic or voluntarily redacted examples; no default telemetry or transcript
136
+ collection. Establish a baseline before claiming improvement percentages.
137
+
138
+ For each milestone: reproduce a real problem, agree on semantics in an ADR,
139
+ implement focused PRs, run local checks and packed consumer tests, review/merge,
140
+ then use the existing reviewed-artifact release process. Changes affecting host
141
+ adapters require host-specific tests as well as the platform matrix.
142
+
143
+ Defer hosted dashboards, a general memory platform, automatic prose-to-rule
144
+ extraction, arbitrary policy scripts, and claims of universal agent enforcement.
145
+ Reprioritize this plan based on pilot evidence rather than adding all features
146
+ to a single release.
@@ -0,0 +1,93 @@
1
+ # Your first real check
2
+
3
+ Use a new disposable directory for this walkthrough. Node.js 22+ is required;
4
+ Bun, API keys, and GitHub Actions are not required. All rules below are synthetic.
5
+
6
+ ## Initialize and inspect the empty starter
7
+
8
+ ```sh
9
+ mkdir handoff-check-demo
10
+ cd handoff-check-demo
11
+ npx handoff-check@0.3.1 init --scope staging --agent none
12
+ npx handoff-check@0.3.1 verify --require-content
13
+ ```
14
+
15
+ The starter passes with `PASS (EMPTY)` and `0 active constraints checked`.
16
+ This confirms valid inputs, not meaningful rule coverage. Adding `--require-active`
17
+ now would produce `NO_ACTIVE_CONSTRAINTS` and exit 1.
18
+
19
+ ## Add one reviewed rule
20
+
21
+ Replace the starter `constraints.json` with this exact JSON:
22
+
23
+ ```json
24
+ {
25
+ "schemaVersion": 2,
26
+ "constraints": [
27
+ {
28
+ "id": "MIGRATION-REVIEW",
29
+ "scope": "staging",
30
+ "revision": 1,
31
+ "description": "Require review before applying staging migrations",
32
+ "source": "docs/migration-policy.md"
33
+ }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ `source` is review metadata; this synthetic path need not exist. Verification
39
+ does not fetch it or check the contents of a referenced document.
40
+
41
+ Before capturing a baseline, run:
42
+
43
+ ```sh
44
+ npx handoff-check@0.3.1 verify --require-content --require-active
45
+ ```
46
+
47
+ Expect `MISSING MIGRATION-REVIEW`, one active constraint, and exit 1. The old
48
+ starter handoff does not include the new rule yet.
49
+
50
+ ## Capture and verify a reviewed baseline
51
+
52
+ ```sh
53
+ npx handoff-check@0.3.1 snapshot --task "Review staging migration" --output handoff.reviewed.json
54
+ npx handoff-check@0.3.1 verify --handoff handoff.reviewed.json --require-content --require-active
55
+ ```
56
+
57
+ Review the generated file before relying on it. The verification command should
58
+ report `PASS`, `1 active constraints checked`, `0 findings`, and exit 0.
59
+ Snapshot refuses to overwrite an existing output path; use a new filename when
60
+ deliberately capturing another reviewed baseline.
61
+
62
+ This example passes the baseline explicitly. For subsequent agent/CI use, review
63
+ and edit `.handoff-check.json` so `handoff` points to `handoff.reviewed.json`.
64
+ Otherwise commands without `--handoff` still use the original starter file.
65
+
66
+ ## Detect a rule change
67
+
68
+ In `constraints.json`, change the description to
69
+ `Require two reviewers before applying staging migrations`. Leave the saved
70
+ handoff unchanged, then run:
71
+
72
+ ```sh
73
+ npx handoff-check@0.3.1 verify --handoff handoff.reviewed.json --require-content --require-active --format json
74
+ ```
75
+
76
+ Expect `status: "mismatch"`, `activeConstraintCount: 1`, a `CHANGED` finding, and
77
+ exit 1. The content hash catches the edit even if revision remains 1. For a
78
+ deliberate policy update, also increment its revision during review.
79
+
80
+ Do not recapture a baseline just to make a resumed check pass. Review the changed
81
+ rule and resolve affected work first; only then deliberately capture and adopt a
82
+ new baseline. Current snapshots detect changes but do not retain old descriptions
83
+ or display textual diffs.
84
+
85
+ ## Interpret the result correctly
86
+
87
+ - Exit 0: the declared rules match for the selected scope/time and requested policies.
88
+ - Exit 1: rule mismatch or an empty set rejected by `--require-active`.
89
+ - Exit 2: invalid arguments, invalid data, or unreadable inputs.
90
+
91
+ A pass does not prove the agent obeyed the rule or grant permission to apply a
92
+ migration. Installing a skill does not guarantee it runs; generated CI checks
93
+ committed inputs when its workflow executes, not every agent action.
package/docs/releasing.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Releasing
2
2
 
3
3
  The npm package name is `handoff-check`; the binary is `handoff-check` and the
4
- current version is 0.2.0. A registry lookup is not proof that a name can be claimed.
5
- Confirm ownership during the authenticated first publication.
4
+ current version is 0.3.1. The package is already published; subsequent releases
5
+ use the configured trusted publisher and the reviewed-artifact process below.
6
6
 
7
7
  ## Release a reviewed version
8
8
 
@@ -19,12 +19,12 @@ Confirm ownership during the authenticated first publication.
19
19
  publish-run artifact and compare it before claiming artifact continuity.
20
20
  For first-publication bootstrap or an explicitly chosen manual release, use
21
21
  `npm login` and publish the reviewed tarball directly with
22
- `npm publish /absolute/path/handoff-check-0.2.0.tgz --ignore-scripts --access public`.
22
+ `npm publish /absolute/path/handoff-check-0.3.1.tgz --ignore-scripts --access public`.
23
23
  Complete interactive two-factor authentication directly with npm.
24
24
  5. Verify registry name, version, binary and integrity, then test
25
- `npx --yes handoff-check@0.2.0 --version` and fresh-project init/verify using a
25
+ `npx --yes handoff-check@0.3.1 --version` and fresh-project init/verify using a
26
26
  new package cache and the public registry, rather than the local tarball.
27
- 6. Create tag `v0.2.0` and a GitHub release on the reviewed main commit, attach the
27
+ 6. Create tag `v0.3.1` and a GitHub release on the reviewed main commit, attach the
28
28
  same tarball, and describe features, requirements and known limits.
29
29
 
30
30
  Publishing is immutable for a given npm name/version. Fix failed candidates on a
package/docs/roadmap.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Roadmap
2
2
 
3
+ See the [development plan](development-plan.md) for research evidence, proposed
4
+ 0.4–0.6 milestones, dependencies, pilot validation, and acceptance criteria.
5
+ These are proposed milestones, not implemented features or promised dates.
6
+
7
+ 0.3.1 improves published-package onboarding and CLI reference accuracy, and adds
8
+ a [first-rule walkthrough](first-check.md). Verifier behavior is unchanged.
9
+
3
10
  ## Implemented in the initial MVP
4
11
 
5
12
  - Versioned manifest and handoff contracts, with strict local validation.
@@ -30,6 +37,9 @@
30
37
 
31
38
  ## Following releases
32
39
 
40
+ Implemented in 0.3.0: active-rule counts, explicit empty-check summaries and optional
41
+ nonempty verification policy, with v1 default JSON compatibility.
42
+
33
43
  Implemented in 0.2.0: revisioned v2 manifests, content-aware handoff snapshots,
34
44
  canonical SHA-256 comparison, CHANGED findings, explicit --require-content,
35
45
  legacy compatibility and reviewed migration guidance. No automatic baseline refresh.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handoff-check",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "A deterministic, local CLI that verifies active constraints before a coding agent resumes work.",
5
5
  "type": "module",
6
6
  "packageManager": "bun@1.2.10",
@@ -46,6 +46,14 @@ report. Keep ordinary task summaries separate from the declared constraint IDs.
46
46
 
47
47
  ## Content-aware handoffs
48
48
 
49
+ Report the active-rule count as well as findings. V2 JSON exposes
50
+ `activeConstraintCount`; legacy JSON exposes `expectedConstraints.length`.
51
+ A zero count is not evidence that real active rules were checked. It may mean a
52
+ starter, another scope, or only inactive rules. Text marks this as PASS (EMPTY)
53
+ when there are no mismatches. If the project explicitly requires a nonempty set,
54
+ add `--require-active`: zero then produces global NO_ACTIVE_CONSTRAINTS and exit 1.
55
+ Do not enable this policy silently or invent rules to satisfy it.
56
+
49
57
  Use schemaVersion 2 handoffs with revision/hash references. `CHANGED` means a
50
58
  carried active rule has a different revision or content hash; it does not supply
51
59
  a text diff or prove which state was authorized. Report expected/reported values