handoff-check 0.1.0 → 0.3.0

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.0
4
+
5
+ - Show the expected active-rule count in every text verification summary.
6
+ - Mark valid zero-rule checks as PASS (EMPTY), with an explicit scope/time notice.
7
+ - Add activeConstraintCount to v2 JSON while preserving legacy default JSON shape.
8
+ - Add opt-in --require-active with a global NO_ACTIVE_CONSTRAINTS finding and exit 1.
9
+
10
+ ## 0.2.0
11
+
12
+ - Detect same-ID rule edits through revision and canonical SHA-256 references.
13
+ - Add v2 manifest/handoff schemas and CHANGED findings with expected/reported data.
14
+ - Add snapshot capture with exclusive new-file output and explicit scope/time.
15
+ - Preserve legacy v1 ID checks; add --require-content for explicit enforcement.
16
+ - Use v2 starters and content-aware agent/CI guidance with a reviewed migration path.
17
+
3
18
  ## 0.1.0
4
19
 
5
20
  - Establish English contributor and coding-agent guidance and project policies.
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.1.0.**
6
+ **Version: 0.3.0.**
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.
@@ -18,8 +18,8 @@ Source references are review metadata and are never fetched.
18
18
  Once the npm package is published, run in the repository where your agent works:
19
19
 
20
20
  ```sh
21
- npx handoff-check@0.1.0 init --scope staging --agent both --dry-run
22
- npx handoff-check@0.1.0 init --scope staging --agent both
21
+ npx handoff-check@0.3.0 init --scope staging --agent both --dry-run
22
+ npx handoff-check@0.3.0 init --scope staging --agent both
23
23
  ```
24
24
 
25
25
  This creates `.handoff-check.json`, starter `constraints.json` and `handoff.json`,
@@ -27,12 +27,13 @@ installs skills for Codex and Claude Code, and appends managed instruction block
27
27
  to `AGENTS.md` and `CLAUDE.md`. Choose `--agent codex`, `claude`, or `none` to limit
28
28
  integrations. Scope is explicit; choose the intended environment.
29
29
 
30
- Starters intentionally contain zero rules. Add reviewed constraints and update
31
- the handoff's `activeConstraints` before relying on a successful verification.
30
+ Starters intentionally contain zero rules. Add reviewed constraints (v2 rules need
31
+ a positive `revision`), then capture a baseline as described below before relying
32
+ on verification. Revisions and hashes detect edits under an unchanged rule ID.
32
33
  Ask a resuming agent to use the installed skill, or run:
33
34
 
34
35
  ```sh
35
- npx handoff-check@0.1.0 verify --format json
36
+ npx handoff-check@0.3.0 verify --format json --require-content
36
37
  ```
37
38
 
38
39
  The saved config supplies paths and scope. `init --ci` also creates a pinned GitHub
@@ -42,7 +43,83 @@ Neither checks whether the agent obeys a rule's meaning.
42
43
 
43
44
  Until publication, use a local package via the [setup guide](docs/agent-integration.md).
44
45
  Node.js 22+ is required; end users do not need Bun. After publication, global
45
- installation is also available: `npm install --global handoff-check@0.1.0`.
46
+ installation is also available: `npm install --global handoff-check@0.3.0`.
47
+
48
+ ## See how many rules were checked
49
+
50
+ Every text summary includes the expected active-rule count:
51
+
52
+ ```text
53
+ PASS 7 active constraints checked | 0 findings | scope staging | ...
54
+ PASS (EMPTY) 0 active constraints checked | 0 findings | ... | No active constraints apply to this scope and time
55
+ ```
56
+
57
+ This counts active selected/global rules, not reported IDs or total manifest
58
+ entries. Missing active rules count too. Zero may mean a starter, another scope,
59
+ or inactive rules; it does not prove the manifest is empty. Empty checks exit 0 by
60
+ default but are explicitly marked. Unexpected reported IDs still fail.
61
+
62
+ To require actual active rules, opt in:
63
+
64
+ ```sh
65
+ npx handoff-check@0.3.0 verify --require-content --require-active --format json
66
+ ```
67
+
68
+ A zero active set produces global NO_ACTIVE_CONSTRAINTS (no fake ID), mismatch
69
+ status and exit 1. Other findings remain. Invalid inputs still exit 2. V2 JSON
70
+ includes activeConstraintCount; legacy default JSON exposes the expected set in
71
+ expectedConstraints without changing its fields.
72
+
73
+ The policy is not automatically enabled in starter CI. After adding real rules,
74
+ append --require-active to the generated workflow command. It is verify-only;
75
+ init and snapshot reject it. See the
76
+ [empty verification contract](docs/decisions/0003-empty-verification.md).
77
+
78
+ ## Catch rule edits between sessions
79
+
80
+ After reviewing rules at handoff creation, capture a new baseline:
81
+
82
+ ```sh
83
+ npx handoff-check@0.3.0 snapshot --task "Resume migration review" --output handoff.next.json
84
+ npx handoff-check@0.3.0 verify --handoff handoff.next.json --require-content --format json
85
+ ```
86
+
87
+ Snapshot creates a new file exclusively. Review it before deliberately replacing
88
+ the configured handoff file with it. On resume, verify the SAVED handoff first;
89
+ never regenerate it just to clear findings.
90
+
91
+ V2 references record each rule's ID, revision and canonical SHA-256 content hash.
92
+ An edit under the same ID is detected even if revision was not incremented.
93
+ Revision changes (including decreases) are compared separately.
94
+
95
+ ```text
96
+ CHANGED C-07 Review changed constraint: ...; handoff revision 1, current revision 1; content hash differs
97
+ ```
98
+
99
+ JSON findings include expected/reported revision and hash. This detects a change;
100
+ it does not show a text diff or authenticate either file. Source reference text is
101
+ hashed, but referenced documents are not fetched or checked.
102
+
103
+ See the [v2 handoff schema](schemas/handoff.v2.schema.json),
104
+ [v2 manifest schema](schemas/constraints.v2.schema.json), and
105
+ [canonicalization contract](docs/decisions/0002-content-aware-handoffs.md).
106
+ The [changed-rule example](examples/changed-rule/handoff.json) captures the original
107
+ manifest; its current manifest edits the description without bumping revision.
108
+
109
+ ## Upgrade from 0.1
110
+
111
+ V1 handoffs remain supported in ID-only mode with unchanged v1 JSON result fields.
112
+ They cannot detect content edits. `--require-content` rejects them instead of
113
+ silently falling back. V2 handoffs work with either v1 manifests (implicit revision `1`)
114
+ or revisioned v2 manifests. Scope must match the v2 handoff's saved scope.
115
+
116
+ Review current rules, capture a new v2 baseline, and deliberately update the saved
117
+ handoff. Existing inputs are preserved by init, not silently upgraded. Review
118
+ installed skills, instruction blocks and CI commands to update their pinned
119
+ version to 0.3.0 and add `--require-content`. Init refuses to overwrite differing
120
+ integrations; compare them with the new packaged templates and update reviewed
121
+ copies explicitly. Never refresh before checking resumed work or reuse capturedAt
122
+ as the clock for real resumed work.
46
123
 
47
124
  ## Configuration and initialization
48
125
 
@@ -99,7 +176,7 @@ The synthetic Friday freeze has expired and the migration review rule is missing
99
176
  ```text
100
177
  EXPIRED C-02 Remove expired constraint: Staging freeze ended Friday at 18:00 UTC
101
178
  MISSING C-07 Include active constraint: Require review before applying migrations
102
- FAIL 2 findings | scope staging | as of 2026-11-23T09:00:00.000Z
179
+ FAIL 1 active constraints checked | 2 findings | scope staging | as of 2026-11-23T09:00:00.000Z | IDs only; content changes not checked
103
180
  ```
104
181
 
105
182
  This command intentionally exits with code 1. Use the corrected handoff to pass:
@@ -109,7 +186,7 @@ bun run dev verify --constraints examples/stale-handoff/constraints.json --hando
109
186
  ```
110
187
 
111
188
  ```text
112
- PASS 0 findings | scope staging | as of 2026-11-23T09:00:00.000Z
189
+ PASS 1 active constraints checked | 0 findings | scope staging | as of 2026-11-23T09:00:00.000Z | IDs only; content changes not checked
113
190
  ```
114
191
 
115
192
  For the built CLI, run `bun run build`, then replace `bun run dev` with
@@ -178,8 +255,8 @@ include global rules even when no scope-specific rules exist.
178
255
  | 1 | Rule mismatch; inspect findings |
179
256
  | 2 | Invalid arguments, invalid input, or unreadable input file |
180
257
 
181
- Findings are `MISSING`, `EXPIRED`, `REVOKED`, `SUPERSEDED`, `OUT_OF_SCOPE`, or
182
- `UNKNOWN`, ordered by ID. A reported ID receives one primary finding according to
258
+ Per-rule findings include `MISSING`, `EXPIRED`, `REVOKED`, `SUPERSEDED`, `OUT_OF_SCOPE`,
259
+ `UNKNOWN`, and (for v2) `CHANGED`, ordered by ID. A reported ID receives one primary finding according to
183
260
  the precedence in the lifecycle ADR.
184
261
 
185
262
  `--format json` writes a versioned result with `status`, `scope`, `asOf`,
package/dist/cli.js CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/cli.ts
4
+ import { open as open2 } from "node:fs/promises";
4
5
  import { resolve as resolve3 } from "node:path";
5
6
  import { parseArgs } from "node:util";
6
7
  // package.json
7
8
  var package_default = {
8
9
  name: "handoff-check",
9
- version: "0.1.0",
10
+ version: "0.3.0",
10
11
  description: "A deterministic, local CLI that verifies active constraints before a coding agent resumes work.",
11
12
  type: "module",
12
13
  packageManager: "bun@1.2.10",
@@ -114,8 +115,13 @@ function timestamp(value, path) {
114
115
  return millis;
115
116
  }
116
117
  function version(value, path) {
117
- if (value.schemaVersion !== 1)
118
- fail(`${path}.schemaVersion: expected 1`);
118
+ if (value.schemaVersion !== 1 && value.schemaVersion !== 2)
119
+ fail(`${path}.schemaVersion: expected 1 or 2`);
120
+ }
121
+ function revision(value, path) {
122
+ if (!Number.isSafeInteger(value) || value < 1)
123
+ fail(`${path}: expected a positive safe integer`);
124
+ return value;
119
125
  }
120
126
  function unique(values, path) {
121
127
  const seen = new Set;
@@ -142,7 +148,8 @@ function parseManifest(input) {
142
148
  "expiresAt",
143
149
  "revokedAt",
144
150
  "replacedBy",
145
- "supersededAt"
151
+ "supersededAt",
152
+ ...root.schemaVersion === 2 ? ["revision"] : []
146
153
  ], path);
147
154
  const parsed = {
148
155
  id: identifier(rule.id, `${path}.id`),
@@ -150,6 +157,8 @@ function parseManifest(input) {
150
157
  description: string(rule.description, `${path}.description`),
151
158
  source: string(rule.source, `${path}.source`)
152
159
  };
160
+ if (root.schemaVersion === 2)
161
+ parsed.revision = revision(rule.revision, `${path}.revision`);
153
162
  for (const field of ["expiresAt", "revokedAt", "supersededAt"]) {
154
163
  if (Object.hasOwn(rule, field)) {
155
164
  timestamp(rule[field], `${path}.${field}`);
@@ -188,15 +197,45 @@ function parseManifest(input) {
188
197
  for (const id of path)
189
198
  completed.add(id);
190
199
  }
191
- return { schemaVersion: 1, constraints };
200
+ return { schemaVersion: root.schemaVersion, constraints };
192
201
  }
193
202
  function parseHandoff(input) {
194
203
  const root = object(input, "handoff");
195
- keys(root, ["schemaVersion", "task", "activeConstraints"], "handoff");
196
204
  version(root, "handoff");
205
+ keys(root, [
206
+ "schemaVersion",
207
+ "task",
208
+ "activeConstraints",
209
+ ...root.schemaVersion === 2 ? ["scope", "capturedAt"] : []
210
+ ], "handoff");
197
211
  const task = string(root.task, "handoff.task");
198
212
  if (!Array.isArray(root.activeConstraints))
199
213
  fail("handoff.activeConstraints: expected an array");
214
+ if (root.schemaVersion === 2) {
215
+ const scope = identifier(root.scope, "handoff.scope");
216
+ timestamp(root.capturedAt, "handoff.capturedAt");
217
+ const activeConstraints2 = root.activeConstraints.map((entry, index) => {
218
+ const path = `handoff.activeConstraints[${index}]`;
219
+ const ref = object(entry, path);
220
+ keys(ref, ["id", "revision", "contentHash"], path);
221
+ const contentHash = string(ref.contentHash, `${path}.contentHash`);
222
+ if (!/^sha256:[a-f0-9]{64}(?![\s\S])/.test(contentHash))
223
+ fail(`${path}.contentHash: expected sha256 followed by 64 lowercase hex digits`);
224
+ return {
225
+ id: identifier(ref.id, `${path}.id`),
226
+ revision: revision(ref.revision, `${path}.revision`),
227
+ contentHash
228
+ };
229
+ });
230
+ unique(activeConstraints2.map((ref) => ref.id), "handoff.activeConstraints");
231
+ return {
232
+ schemaVersion: 2,
233
+ task,
234
+ scope,
235
+ capturedAt: root.capturedAt,
236
+ activeConstraints: activeConstraints2
237
+ };
238
+ }
200
239
  const activeConstraints = root.activeConstraints.map((id, index) => identifier(id, `handoff.activeConstraints[${index}]`));
201
240
  unique(activeConstraints, "handoff.activeConstraints");
202
241
  return { schemaVersion: 1, task, activeConstraints };
@@ -268,7 +307,7 @@ Before resuming a handoff or continuing after a context reset, use the handoff-c
268
307
  skill and run the configured verifier from this repository root:
269
308
 
270
309
  \`\`\`sh
271
- npx --yes handoff-check@${package_default.version} verify --format json
310
+ npx --yes handoff-check@${package_default.version} verify --format json --require-content
272
311
  \`\`\`
273
312
 
274
313
  Use .handoff-check.json for paths and scope. If no scope is configured, request the
@@ -277,6 +316,8 @@ Resolve exit 1 mismatches or exit 2 input errors before resuming the affected ta
277
316
  Do not change the manifest merely to obtain a pass. Empty rules verify no policy;
278
317
  author and review real project constraints before relying on this check. A pass
279
318
  checks declared IDs only and does not grant authorization or interpret summaries.
319
+ Capture a snapshot only at handoff creation or after explicitly reviewing changes;
320
+ never refresh the baseline before verifying it when resuming work.
280
321
  ${end}
281
322
  `;
282
323
  async function inspect(root, path) {
@@ -331,15 +372,17 @@ async function initialize(root, options) {
331
372
  [
332
373
  "constraints",
333
374
  "constraints.json",
334
- { schemaVersion: 1, constraints: [] },
375
+ { schemaVersion: 2, constraints: [] },
335
376
  parseManifest
336
377
  ],
337
378
  [
338
379
  "handoff",
339
380
  "handoff.json",
340
381
  {
341
- schemaVersion: 1,
382
+ schemaVersion: 2,
342
383
  task: "Describe the task being handed off",
384
+ scope,
385
+ capturedAt: new Date().toISOString(),
343
386
  activeConstraints: []
344
387
  },
345
388
  parseHandoff
@@ -405,7 +448,7 @@ jobs:
405
448
  - uses: actions/setup-node@v4
406
449
  with:
407
450
  node-version: 22
408
- - run: npx --yes handoff-check@${package_default.version} verify --format json
451
+ - run: npx --yes handoff-check@${package_default.version} verify --format json --require-content
409
452
  `;
410
453
  const old = await inspect(root, path);
411
454
  if (old !== undefined && old !== content)
@@ -457,7 +500,28 @@ jobs:
457
500
  action: file.action,
458
501
  ...file.action === "preserve" ? {} : { content: file.content }
459
502
  })),
460
- notice: "Starter files may contain zero rules. Add reviewed project constraints and update the handoff before relying on verification."
503
+ notice: "Starter files may contain zero rules. Add reviewed project constraints, then capture a v2 snapshot. Existing v1 handoffs are preserved but cannot satisfy --require-content until explicitly migrated. Never refresh a baseline before verifying it on resume."
504
+ };
505
+ }
506
+
507
+ // src/content.ts
508
+ import { createHash } from "node:crypto";
509
+ function reference(rule) {
510
+ const instant = (value) => value === undefined ? null : new Date(value).toISOString();
511
+ const content = JSON.stringify({
512
+ id: rule.id,
513
+ scope: rule.scope,
514
+ description: rule.description,
515
+ source: rule.source,
516
+ expiresAt: instant(rule.expiresAt),
517
+ revokedAt: instant(rule.revokedAt),
518
+ replacedBy: rule.replacedBy ?? null,
519
+ supersededAt: instant(rule.supersededAt)
520
+ });
521
+ return {
522
+ id: rule.id,
523
+ revision: rule.revision ?? 1,
524
+ contentHash: `sha256:${createHash("sha256").update(content, "utf8").digest("hex")}`
461
525
  };
462
526
  }
463
527
 
@@ -476,12 +540,15 @@ function inactive(rule, scope, time) {
476
540
  return "EXPIRED";
477
541
  return;
478
542
  }
479
- function verify(manifest, handoff, scope, asOf) {
543
+ function verify(manifest, handoff, scope, asOf, options = {}) {
480
544
  identifier(scope, "scope");
545
+ if (handoff.schemaVersion === 2 && handoff.scope !== scope)
546
+ throw new InputError(`Handoff scope '${handoff.scope}' does not match selected scope '${scope}'`);
481
547
  const time = timestamp(asOf, "asOf");
482
548
  const byId = new Map(manifest.constraints.map((rule) => [rule.id, rule]));
483
549
  const expectedConstraints = manifest.constraints.filter((rule) => inactive(rule, scope, time) === undefined).map((rule) => rule.id).sort(compare);
484
- const reportedConstraints = [...handoff.activeConstraints].sort(compare);
550
+ const refs = new Map(handoff.schemaVersion === 2 ? handoff.activeConstraints.map((ref) => [ref.id, ref]) : []);
551
+ const reportedConstraints = (handoff.schemaVersion === 1 ? [...handoff.activeConstraints] : handoff.activeConstraints.map((ref) => ref.id)).sort(compare);
485
552
  const reported = new Set(reportedConstraints);
486
553
  const findings = [];
487
554
  for (const id of expectedConstraints) {
@@ -502,11 +569,39 @@ function verify(manifest, handoff, scope, asOf) {
502
569
  id,
503
570
  message: `Remove ${code.toLowerCase().replaceAll("_", "-")} constraint${detail}${rule ? `: ${rule.description}` : ""}`
504
571
  });
572
+ } else if (rule && handoff.schemaVersion === 2) {
573
+ const current = reference(rule);
574
+ const previous = refs.get(id);
575
+ if (previous && (current.revision !== previous.revision || current.contentHash !== previous.contentHash)) {
576
+ findings.push({
577
+ code: "CHANGED",
578
+ id,
579
+ message: `Review changed constraint: ${rule.description}; handoff revision ${previous.revision}, current revision ${current.revision}${current.contentHash !== previous.contentHash ? "; content hash differs" : ""}`,
580
+ expected: {
581
+ revision: current.revision,
582
+ contentHash: current.contentHash
583
+ },
584
+ reported: {
585
+ revision: previous.revision,
586
+ contentHash: previous.contentHash
587
+ }
588
+ });
589
+ }
505
590
  }
506
591
  }
507
- 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));
508
599
  return {
509
- schemaVersion: 1,
600
+ schemaVersion: handoff.schemaVersion,
601
+ ...handoff.schemaVersion === 2 ? {
602
+ tracking: "content",
603
+ activeConstraintCount: expectedConstraints.length
604
+ } : {},
510
605
  status: findings.length ? "mismatch" : "verified",
511
606
  scope,
512
607
  asOf: new Date(time).toISOString(),
@@ -515,12 +610,26 @@ function verify(manifest, handoff, scope, asOf) {
515
610
  findings
516
611
  };
517
612
  }
613
+ function snapshot(manifest, task, scope, asOf) {
614
+ if (!task.trim())
615
+ throw new InputError("--task: expected a non-empty task");
616
+ const result = verify(manifest, { schemaVersion: 1, task, activeConstraints: [] }, scope, asOf);
617
+ const byId = new Map(manifest.constraints.map((rule) => [rule.id, rule]));
618
+ return {
619
+ schemaVersion: 2,
620
+ task,
621
+ scope,
622
+ capturedAt: result.asOf,
623
+ activeConstraints: result.expectedConstraints.map((id) => reference(byId.get(id)))
624
+ };
625
+ }
518
626
 
519
627
  // src/cli.ts
520
628
  var help = `Handoff Check
521
629
 
522
630
  Usage: handoff-check verify --scope <scope> [options]
523
631
  handoff-check init --scope <scope> [--agent both] [--dry-run] [--ci]
632
+ handoff-check snapshot --task <task> [--output <new-file>] [options]
524
633
 
525
634
  Options:
526
635
  --constraints <path> Manifest file (default: constraints.json)
@@ -528,6 +637,10 @@ Options:
528
637
  --scope <scope> Selected scope, including global constraints
529
638
  --config <path> Project config (default: cwd/.handoff-check.json)
530
639
  --as-of <UTC time> Fixed evaluation time (default: current time)
640
+ --require-content verify: require a v2 content-aware handoff
641
+ --require-active verify: fail if no constraints apply to scope/time
642
+ --task <task> snapshot: task description (required)
643
+ --output <path> snapshot: create a new baseline file, never overwrite
531
644
  --format text|json Output format (default: text)
532
645
  --agent <agent> init: codex, claude, both (default), or none
533
646
  --dry-run init: preview files and instruction changes without writes
@@ -535,7 +648,7 @@ Options:
535
648
  --version Show package version
536
649
  --help Show this help
537
650
 
538
- Exit codes: 0 verified, 1 rule mismatch, 2 invalid input
651
+ Exit codes: 0 verified, 1 rule/policy mismatch, 2 invalid input
539
652
  `;
540
653
  function terminalText(value) {
541
654
  return Array.from(value, (character) => {
@@ -564,7 +677,11 @@ async function main() {
564
677
  version: { type: "boolean" },
565
678
  agent: { type: "string" },
566
679
  "dry-run": { type: "boolean" },
567
- ci: { type: "boolean" }
680
+ ci: { type: "boolean" },
681
+ "require-content": { type: "boolean" },
682
+ "require-active": { type: "boolean" },
683
+ task: { type: "string" },
684
+ output: { type: "string" }
568
685
  }
569
686
  });
570
687
  format = values.format;
@@ -579,13 +696,22 @@ async function main() {
579
696
  `);
580
697
  return 0;
581
698
  }
582
- if (positionals.length !== 1 || !["verify", "init"].includes(positionals[0] ?? ""))
583
- throw new InputError("Expected command: verify or init (use --help for usage)");
699
+ if (positionals.length !== 1 || !["verify", "init", "snapshot"].includes(positionals[0] ?? ""))
700
+ throw new InputError("Expected command: verify, snapshot or init (use --help for usage)");
584
701
  const cwd = process.cwd();
585
702
  if (positionals[0] === "init") {
586
- for (const key of ["constraints", "handoff", "config", "as-of"])
703
+ for (const key of [
704
+ "constraints",
705
+ "handoff",
706
+ "config",
707
+ "as-of",
708
+ "require-content",
709
+ "require-active",
710
+ "task",
711
+ "output"
712
+ ])
587
713
  if (values[key] !== undefined)
588
- throw new InputError(`--${key} is only supported by verify`);
714
+ throw new InputError(`--${key} is not supported by init`);
589
715
  const result2 = await initialize(cwd, {
590
716
  ...values.scope === undefined ? {} : { scope: values.scope },
591
717
  agent: values.agent ?? "both",
@@ -625,17 +751,62 @@ ${result2.notice}
625
751
  if (values[key] !== undefined && !values[key].trim())
626
752
  throw new InputError(`--${key}: expected a non-empty path`);
627
753
  const manifest = parseManifest(await readJson(values.constraints !== undefined ? resolve3(cwd, values.constraints) : resolve3(directory, config.constraints ?? "constraints.json")));
754
+ if (positionals[0] === "snapshot") {
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");
757
+ if (values.task === undefined)
758
+ throw new InputError("snapshot requires --task");
759
+ const captured = snapshot(manifest, values.task, scope, asOf);
760
+ const content = `${JSON.stringify(captured, null, 2)}
761
+ `;
762
+ if (values.output === undefined)
763
+ process.stdout.write(content);
764
+ else {
765
+ if (!values.output.trim())
766
+ throw new InputError("--output: expected a non-empty path");
767
+ const path = resolve3(cwd, values.output);
768
+ let handle;
769
+ try {
770
+ handle = await open2(path, "wx", 420);
771
+ } catch {
772
+ throw new InputError(`Cannot create snapshot '${path}'; choose a new file with an existing parent directory`);
773
+ }
774
+ try {
775
+ await handle.writeFile(content, "utf8");
776
+ } finally {
777
+ await handle.close();
778
+ }
779
+ const saved = {
780
+ schemaVersion: 1,
781
+ status: "captured",
782
+ path,
783
+ constraints: captured.activeConstraints.length
784
+ };
785
+ process.stdout.write(format === "json" ? `${JSON.stringify(saved)}
786
+ ` : `CAPTURED ${terminalText(path)}
787
+ `);
788
+ }
789
+ return 0;
790
+ }
791
+ if (values.task !== undefined || values.output !== undefined)
792
+ throw new InputError("--task and --output are only supported by snapshot");
628
793
  const handoff = parseHandoff(await readJson(values.handoff !== undefined ? resolve3(cwd, values.handoff) : resolve3(directory, config.handoff ?? "handoff.json")));
629
- const result = verify(manifest, handoff, scope, asOf);
794
+ if (values["require-content"] && handoff.schemaVersion !== 2)
795
+ throw new InputError("Content tracking requires a schemaVersion 2 handoff; review current rules and capture a snapshot before resuming");
796
+ const result = verify(manifest, handoff, scope, asOf, {
797
+ requireActive: values["require-active"] ?? false
798
+ });
630
799
  if (format === "json") {
631
800
  process.stdout.write(`${JSON.stringify(result, null, 2)}
632
801
  `);
633
802
  } else {
634
803
  for (const finding of result.findings) {
635
- 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)}
636
805
  `);
637
806
  }
638
- process.stdout.write(`${result.status === "verified" ? "PASS" : "FAIL"} ${result.findings.length} findings | scope ${scope} | as of ${result.asOf}
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" : ""}
639
810
  `);
640
811
  }
641
812
  return result.status === "verified" ? 0 : 1;
@@ -9,8 +9,8 @@ infers rules from a summary.
9
9
  After the npm release is published, from the consuming repository root:
10
10
 
11
11
  ```sh
12
- npx handoff-check@0.1.0 init --scope staging --agent both --dry-run
13
- npx handoff-check@0.1.0 init --scope staging --agent both
12
+ npx handoff-check@0.3.0 init --scope staging --agent both --dry-run
13
+ npx handoff-check@0.3.0 init --scope staging --agent both
14
14
  ```
15
15
 
16
16
  Choose `codex`, `claude`, `both` (default), or `none`. Generated integrations:
@@ -38,8 +38,8 @@ npm pack
38
38
  From a separate consuming project, substitute the actual absolute tarball path:
39
39
 
40
40
  ```sh
41
- npx --offline --yes --package=/absolute/path/handoff-check-0.1.0.tgz handoff-check init --scope staging --agent both
42
- npx --offline --yes --package=/absolute/path/handoff-check-0.1.0.tgz handoff-check verify --format json
41
+ npx --offline --yes --package=/absolute/path/handoff-check-0.3.0.tgz handoff-check init --scope staging --agent both
42
+ npx --offline --yes --package=/absolute/path/handoff-check-0.3.0.tgz handoff-check verify --format json --require-content
43
43
  ```
44
44
 
45
45
  Bun is not required for these consumer commands. Generated agent commands use the
@@ -58,6 +58,18 @@ The agent checks IDs and reads active rule descriptions. Exit 1 means mismatch;
58
58
  exit 2 means invalid inputs/arguments. Resolve either before resuming affected work.
59
59
  A pass does not authorize an action or interpret the task summary.
60
60
 
61
+ In 0.2, skills and generated instructions require content-aware v2 handoffs.
62
+ At handoff creation, review current rules and run the configured CLI's
63
+ `snapshot --task "Resume the task" --output handoff.next.json`. Review that file
64
+ before explicitly promoting it to the configured handoff. On resume, verify the
65
+ saved baseline first; do not regenerate it to hide a CHANGED finding. Snapshot
66
+ records revisions/hashes, not old text, and capturedAt is not the evaluation clock.
67
+
68
+ Existing v1 inputs are preserved. Review/capture a v2 handoff and explicitly update
69
+ old skill/managed-block/CI pins before relying on content tracking. Existing v1
70
+ manifests use implicit revision 1; v2 manifests make revisions explicit.
71
+ See [upgrade instructions](../README.md#upgrade-from-01).
72
+
61
73
  Skill discovery depends on the host agent. Skills/instructions are guidance, not
62
74
  guaranteed hooks. `init --ci` adds `.github/workflows/handoff-check.yml` pinned to
63
75
  the installed version and using saved config. This checks committed IDs on push/PR,
@@ -66,6 +78,13 @@ events and context-reset behavior differ.
66
78
 
67
79
  ## Upgrades and contributor instructions
68
80
 
81
+ In 0.3, verification reports how many selected/global rules are active. V2 JSON
82
+ includes activeConstraintCount. Empty checks remain valid by default but text
83
+ clearly says PASS (EMPTY). Agents must not present this as real policy coverage.
84
+ Teams can explicitly add --require-active to verify/CI after authoring rules;
85
+ zero then exits 1 with a global NO_ACTIVE_CONSTRAINTS finding. New starter CI does
86
+ not enable this policy automatically. V1 default JSON remains unchanged.
87
+
69
88
  Matching integrations are preserved on repeated init. If a skill or managed block
70
89
  differs, compare it to the new package and review/update explicitly; there is no
71
90
  force-overwrite mode. Commands stay pinned until a reviewed upgrade.
@@ -0,0 +1,82 @@
1
+ # ADR 0002: Content-aware handoffs
2
+
3
+ Status: accepted for 0.2.0.
4
+
5
+ ## Formats and compatibility
6
+
7
+ Manifest v1 and handoff v1 keep their existing schemas. A v1 handoff still checks
8
+ IDs only against either manifest format. Its JSON result stays schemaVersion 1
9
+ with the existing fields. Text output explicitly identifies ID-only checking.
10
+
11
+ Manifest v2 adds required `revision` to each constraint: a positive safe integer
12
+ (1 through 9007199254740991). Handoff v2 records `task`, `scope`, `capturedAt`, and
13
+ `activeConstraints` objects containing `id`, `revision`, and `contentHash`.
14
+ IDs remain unique. Unknown fields, malformed hashes, and invalid revisions fail
15
+ as invalid input. Both input formats are versioned independently.
16
+
17
+ A v2 handoff works with either manifest. Manifest v1 rules have implicit revision
18
+ 1, so an existing manifest can adopt content tracking without being rewritten.
19
+ A revisioned v2 manifest works with v1 handoffs in ID-only mode. `--require-content`
20
+ rejects a v1 handoff with exit 2 instead of silently falling back. New skills and
21
+ generated CI use this option; old integrations must be upgraded explicitly.
22
+
23
+ ## Canonical content algorithm v1
24
+
25
+ Serialize the following object, in exactly this field order, using ECMAScript
26
+ `JSON.stringify` without indentation, then encode as UTF-8 and compute SHA-256:
27
+
28
+ 1. `id`
29
+ 2. `scope`
30
+ 3. `description`
31
+ 4. `source`
32
+ 5. `expiresAt`
33
+ 6. `revokedAt`
34
+ 7. `replacedBy`
35
+ 8. `supersededAt`
36
+
37
+ Required strings are preserved exactly, with no trimming or Unicode normalization.
38
+ Absent optional fields are represented as JSON null in this canonical object;
39
+ explicit null in input remains invalid. Timestamps normalize through
40
+ `Date.toISOString()` to UTC milliseconds. Revision is excluded from the hash and
41
+ compared separately. The stored syntax is `sha256:` plus 64 lowercase hex digits.
42
+ Reordering JSON properties, formatting JSON, or using equivalent UTC fractional
43
+ representations does not change the hash. Changing any hashed string does.
44
+
45
+ This algorithm is part of the v2 contract. Any incompatible canonicalization
46
+ change requires a new contract version, not silent rehashing. A golden fixture
47
+ independently verifies the hash contract in tests.
48
+
49
+ Only literal source-reference text is hashed. Referenced documents are never
50
+ fetched or hashed. These hashes are change detectors, not signatures or proof of
51
+ authorization; someone who controls both files can replace both values.
52
+
53
+ ## Capture and verification
54
+
55
+ `snapshot --task <text>` reads the manifest and captures the selected/global rules
56
+ that apply at the explicit or once-captured current clock. It does not read the
57
+ existing handoff, rewrite the manifest, or infer constraints from task prose.
58
+ Default stdout is a complete v2 JSON handoff. `--output <new-path>` creates a new
59
+ file exclusively and refuses existing paths; write failures return exit 2 and may
60
+ leave a partial newly created file, which must be inspected before retrying.
61
+
62
+ `capturedAt` is normalized metadata, not the evaluation clock, an activation rule,
63
+ or authenticated history. Verification uses current time unless --as-of is
64
+ explicit. A fixed evaluation time may predate capturedAt; that describes the
65
+ supplied files at the chosen instant, not a reconstructed historical Git version.
66
+ Selected scope must equal the v2 handoff scope or verification returns exit 2.
67
+
68
+ For an active reported ID, a revision OR content-hash difference produces one
69
+ CHANGED finding. Both differences are reported together with expected/reported
70
+ revision and hash. Missing rules remain MISSING. Unknown, out-of-scope, revoked,
71
+ superseded, and expired primary findings retain lifecycle precedence over CHANGED.
72
+ Adding a future lifecycle timestamp is CHANGED immediately while the rule is
73
+ active; once the timestamp takes effect its lifecycle finding wins.
74
+
75
+ V2 results use schemaVersion 2 and `tracking: "content"`; ID lists remain sorted,
76
+ and findings remain ordered by ID then code. Revision decreases are differences
77
+ too; monotonic revision history is not verified. Old text is not stored, so the
78
+ tool does not show a textual diff.
79
+
80
+ Capture at handoff creation or after an explicit review of changed rules. Never
81
+ recapture a baseline automatically before checking a resumed task: that would hide
82
+ the changes the check is intended to find. Verification and CI remain read-only.
@@ -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.
package/docs/releasing.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Releasing
2
2
 
3
3
  The npm package name is `handoff-check`; the binary is `handoff-check` and the
4
- initial version is 0.1.0. A registry lookup is not proof that a name can be claimed.
4
+ current version is 0.3.0. A registry lookup is not proof that a name can be claimed.
5
5
  Confirm ownership during the authenticated first publication.
6
6
 
7
- ## First release
7
+ ## Release a reviewed version
8
8
 
9
9
  1. Merge reviewed changes into main and wait for all Linux/macOS/Windows checks,
10
10
  including packed offline npx onboarding, to pass on the merged commit.
@@ -13,14 +13,18 @@ Confirm ownership during the authenticated first publication.
13
13
  built tarball as `npm-package`.
14
14
  3. Download that tarball, inspect its file list and checksum, and test it in a
15
15
  separate consumer directory using offline npx with an absolute tarball path.
16
- 4. Authenticate using `npm login` in the maintainer's own terminal. Never commit or
17
- send credentials. Publish the reviewed artifact with
18
- `npm publish /absolute/path/handoff-check-0.1.0.tgz --ignore-scripts --access public`.
19
- Complete any npm two-factor authentication directly with npm.
16
+ 4. Prefer trusted publishing: dispatch the same main commit/version with
17
+ `publish: true` and the reviewed tarball's SHA256 in the `sha256` input. The
18
+ workflow refuses publication if the rebuilt artifact differs. Download the
19
+ publish-run artifact and compare it before claiming artifact continuity.
20
+ For first-publication bootstrap or an explicitly chosen manual release, use
21
+ `npm login` and publish the reviewed tarball directly with
22
+ `npm publish /absolute/path/handoff-check-0.3.0.tgz --ignore-scripts --access public`.
23
+ Complete interactive two-factor authentication directly with npm.
20
24
  5. Verify registry name, version, binary and integrity, then test
21
- `npx --yes handoff-check@0.1.0 --version` and fresh-project init/verify using a
25
+ `npx --yes handoff-check@0.3.0 --version` and fresh-project init/verify using a
22
26
  new package cache and the public registry, rather than the local tarball.
23
- 6. Create tag `v0.1.0` and a GitHub release on the reviewed main commit, attach the
27
+ 6. Create tag `v0.3.0` and a GitHub release on the reviewed main commit, attach the
24
28
  same tarball, and describe features, requirements and known limits.
25
29
 
26
30
  Publishing is immutable for a given npm name/version. Fix failed candidates on a
package/docs/roadmap.md CHANGED
@@ -30,7 +30,15 @@
30
30
 
31
31
  ## Following releases
32
32
 
33
+ Implemented in 0.3.0: active-rule counts, explicit empty-check summaries and optional
34
+ nonempty verification policy, with v1 default JSON compatibility.
35
+
36
+ Implemented in 0.2.0: revisioned v2 manifests, content-aware handoff snapshots,
37
+ canonical SHA-256 comparison, CHANGED findings, explicit --require-content,
38
+ legacy compatibility and reviewed migration guidance. No automatic baseline refresh.
39
+
33
40
  - Incorporate feedback from real repositories before expanding the contract.
41
+ - Consider optional old-content storage for textual diffs in a later version.
34
42
  - Consider host-specific enforcement hooks separately from the portable skill;
35
43
  neither skill discovery nor agent instructions guarantee execution.
36
44
 
@@ -0,0 +1,12 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "constraints": [
4
+ {
5
+ "id": "C-07",
6
+ "revision": 1,
7
+ "scope": "staging",
8
+ "description": "Require two reviewers before applying migrations",
9
+ "source": "decision:review"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "task": "Resume migration review",
4
+ "scope": "staging",
5
+ "capturedAt": "2026-11-24T10:00:00.000Z",
6
+ "activeConstraints": [
7
+ {
8
+ "id": "C-07",
9
+ "revision": 1,
10
+ "contentHash": "sha256:2e1217c01957cd82f81d2bdc47397e00d7c56399606f38545384bdab07ee1b3d"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "schemaVersion": 2,
3
+ "constraints": [
4
+ {
5
+ "id": "C-07",
6
+ "revision": 1,
7
+ "scope": "staging",
8
+ "description": "Review migrations",
9
+ "source": "decision:review"
10
+ }
11
+ ]
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "handoff-check",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
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",
@@ -0,0 +1,75 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Handoff Check revisioned constraint manifest v2",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": ["schemaVersion", "constraints"],
7
+ "properties": {
8
+ "schemaVersion": {
9
+ "const": 2
10
+ },
11
+ "constraints": {
12
+ "type": "array",
13
+ "items": {
14
+ "$ref": "#/$defs/constraint"
15
+ },
16
+ "description": "IDs must be unique. Replacement references must exist, share scope, and form an acyclic graph; these checks are enforced by the CLI."
17
+ }
18
+ },
19
+ "$defs": {
20
+ "identifier": {
21
+ "type": "string",
22
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*(?![\\s\\S])"
23
+ },
24
+ "text": {
25
+ "type": "string",
26
+ "pattern": "\\S"
27
+ },
28
+ "timestamp": {
29
+ "type": "string",
30
+ "format": "date-time",
31
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,3})?Z$",
32
+ "description": "UTC only; real calendar dates required. The CLI also rejects leap seconds and rollover dates."
33
+ },
34
+ "constraint": {
35
+ "type": "object",
36
+ "additionalProperties": false,
37
+ "required": ["id", "scope", "description", "source", "revision"],
38
+ "dependentRequired": {
39
+ "replacedBy": ["supersededAt"],
40
+ "supersededAt": ["replacedBy"]
41
+ },
42
+ "properties": {
43
+ "id": {
44
+ "$ref": "#/$defs/identifier"
45
+ },
46
+ "scope": {
47
+ "$ref": "#/$defs/identifier"
48
+ },
49
+ "description": {
50
+ "$ref": "#/$defs/text"
51
+ },
52
+ "source": {
53
+ "$ref": "#/$defs/text"
54
+ },
55
+ "expiresAt": {
56
+ "$ref": "#/$defs/timestamp"
57
+ },
58
+ "revokedAt": {
59
+ "$ref": "#/$defs/timestamp"
60
+ },
61
+ "replacedBy": {
62
+ "$ref": "#/$defs/identifier"
63
+ },
64
+ "supersededAt": {
65
+ "$ref": "#/$defs/timestamp"
66
+ },
67
+ "revision": {
68
+ "type": "integer",
69
+ "minimum": 1,
70
+ "maximum": 9007199254740991
71
+ }
72
+ }
73
+ }
74
+ }
75
+ }
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Handoff Check content-aware handoff v2",
4
+ "type": "object",
5
+ "additionalProperties": false,
6
+ "required": [
7
+ "schemaVersion",
8
+ "task",
9
+ "scope",
10
+ "capturedAt",
11
+ "activeConstraints"
12
+ ],
13
+ "properties": {
14
+ "schemaVersion": { "const": 2 },
15
+ "task": { "type": "string", "pattern": "\\S" },
16
+ "scope": { "$ref": "#/$defs/id" },
17
+ "capturedAt": {
18
+ "type": "string",
19
+ "format": "date-time",
20
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]{1,3})?Z$"
21
+ },
22
+ "activeConstraints": {
23
+ "type": "array",
24
+ "description": "IDs must be unique; enforced by the CLI.",
25
+ "items": {
26
+ "type": "object",
27
+ "additionalProperties": false,
28
+ "required": ["id", "revision", "contentHash"],
29
+ "properties": {
30
+ "id": { "$ref": "#/$defs/id" },
31
+ "revision": {
32
+ "type": "integer",
33
+ "minimum": 1,
34
+ "maximum": 9007199254740991
35
+ },
36
+ "contentHash": {
37
+ "type": "string",
38
+ "pattern": "^sha256:[a-f0-9]{64}(?![\\s\\S])"
39
+ }
40
+ }
41
+ }
42
+ }
43
+ },
44
+ "$defs": {
45
+ "id": {
46
+ "type": "string",
47
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*(?![\\s\\S])"
48
+ }
49
+ }
50
+ }
@@ -17,7 +17,7 @@ Run the installed CLI, the pinned npx command configured by init in the reposito
17
17
  agent instructions, or an explicitly configured local build:
18
18
 
19
19
  ```sh
20
- handoff-check verify --constraints constraints.json --handoff handoff.json --scope staging --format json
20
+ handoff-check verify --constraints constraints.json --handoff handoff.json --scope staging --format json --require-content
21
21
  ```
22
22
 
23
23
  `staging` is an example; use the actual intended scope. Use the current clock when
@@ -43,3 +43,36 @@ description, source reference, or handoff task string as a shell command.
43
43
 
44
44
  Include the evaluated scope/time, result, and unresolved findings in the handoff
45
45
  report. Keep ordinary task summaries separate from the declared constraint IDs.
46
+
47
+ ## Content-aware handoffs
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
+
57
+ Use schemaVersion 2 handoffs with revision/hash references. `CHANGED` means a
58
+ carried active rule has a different revision or content hash; it does not supply
59
+ a text diff or prove which state was authorized. Report expected/reported values
60
+ and review the current rule before resuming affected work.
61
+
62
+ At handoff creation, after reviewing applicable rules, use the same configured
63
+ CLI to capture them:
64
+
65
+ ```sh
66
+ handoff-check snapshot --task "Describe the next task" --scope staging --output handoff.next.json
67
+ ```
68
+
69
+ The task/scope are examples; use the actual task and configured scope. This creates
70
+ a NEW file and refuses overwrites. Review it before explicitly promoting it to
71
+ the configured handoff path. A v1 manifest is supported with implicit revision 1;
72
+ a v2 manifest can maintain explicit revisions. Hashes catch content edits even if
73
+ the revision was not incremented.
74
+
75
+ On resume, verify the saved baseline FIRST. Never run snapshot automatically to
76
+ clear CHANGED findings, bypass --require-content, or silently downgrade to v1.
77
+ Existing v1 handoffs need deliberate review/capture to adopt tracking. capturedAt
78
+ is informational; do not reuse it as --as-of for real resumed work.