handoff-check 0.7.0 → 0.8.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 +9 -0
- package/README.md +42 -18
- package/dist/cli.js +174 -27
- package/docs/agent-integration.md +4 -4
- package/docs/architecture.md +7 -0
- package/docs/decisions/0008-verified-command-runner.md +30 -0
- package/docs/development-plan.md +14 -3
- package/docs/explainability.md +4 -4
- package/docs/first-check.md +6 -6
- package/docs/lifecycle.md +15 -4
- package/docs/project-context.md +6 -6
- package/docs/releasing.md +4 -4
- package/docs/roadmap.md +5 -1
- package/docs/snapshot-diff-and-setup.md +5 -5
- package/docs/verified-commands.md +104 -0
- package/package.json +1 -1
- package/skills/handoff-check/SKILL.md +15 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
- Add run to verify current content-aware, nonempty constraints before starting an explicit command.
|
|
6
|
+
- Preserve config/profile/project/scope selection using the existing pure verifier.
|
|
7
|
+
- Require an explicit argv separator, pass arguments without an implicit shell, and inherit process streams/cwd/environment.
|
|
8
|
+
- Keep wrapper diagnostics on stderr and preserve child exit codes with direct-child signal forwarding.
|
|
9
|
+
- Refuse nonregular run inputs and bound stalled asynchronous preflight reads without limiting command runtime.
|
|
10
|
+
- Preserve existing verify, snapshot, setup, diff and lifecycle contracts; never refresh baselines automatically.
|
|
11
|
+
|
|
3
12
|
## 0.7.0
|
|
4
13
|
|
|
5
14
|
- Add explicit two-snapshot diff with added, removed, changed and unchanged counts.
|
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.
|
|
6
|
+
**Version: 0.8.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
|
Run in the repository where your agent works:
|
|
19
19
|
|
|
20
20
|
```sh
|
|
21
|
-
npx handoff-check@0.
|
|
22
|
-
npx handoff-check@0.
|
|
21
|
+
npx handoff-check@0.8.0 init --scope staging --agent both --dry-run
|
|
22
|
+
npx handoff-check@0.8.0 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.
|
|
36
|
+
npx handoff-check@0.8.0 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
|
|
@@ -42,7 +42,7 @@ 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
44
|
Node.js 22+ is required; end users do not need Bun. Global installation is also
|
|
45
|
-
available: `npm install --global handoff-check@0.
|
|
45
|
+
available: `npm install --global handoff-check@0.8.0`. For contributor builds or
|
|
46
46
|
offline package testing, see the [setup guide](docs/agent-integration.md).
|
|
47
47
|
|
|
48
48
|
For a complete first-rule walkthrough, including a passing baseline and a detected
|
|
@@ -65,7 +65,7 @@ default but are explicitly marked. Unexpected reported IDs still fail.
|
|
|
65
65
|
To require actual active rules, opt in:
|
|
66
66
|
|
|
67
67
|
```sh
|
|
68
|
-
npx handoff-check@0.
|
|
68
|
+
npx handoff-check@0.8.0 verify --require-content --require-active --format json
|
|
69
69
|
```
|
|
70
70
|
|
|
71
71
|
A zero active set produces global NO_ACTIVE_CONSTRAINTS (no fake ID), mismatch
|
|
@@ -83,8 +83,8 @@ init and snapshot reject it. See the
|
|
|
83
83
|
After reviewing rules at handoff creation, capture a new baseline:
|
|
84
84
|
|
|
85
85
|
```sh
|
|
86
|
-
npx handoff-check@0.
|
|
87
|
-
npx handoff-check@0.
|
|
86
|
+
npx handoff-check@0.8.0 snapshot --task "Resume migration review" --output handoff.next.json
|
|
87
|
+
npx handoff-check@0.8.0 verify --handoff handoff.next.json --require-content --format json
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
Snapshot creates a new file exclusively. Review it before deliberately replacing
|
|
@@ -106,9 +106,9 @@ hashed, but referenced documents are not fetched or checked.
|
|
|
106
106
|
## Explain rules and review field changes
|
|
107
107
|
|
|
108
108
|
```sh
|
|
109
|
-
npx handoff-check@0.
|
|
110
|
-
npx handoff-check@0.
|
|
111
|
-
npx handoff-check@0.
|
|
109
|
+
npx handoff-check@0.8.0 explain --format markdown
|
|
110
|
+
npx handoff-check@0.8.0 snapshot --task "Review migration" --include-content --output handoff.reviewed.json
|
|
111
|
+
npx handoff-check@0.8.0 verify --handoff handoff.reviewed.json --require-content --format markdown
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
`explain` shows every manifest rule's applicability for the selected scope/time,
|
|
@@ -153,14 +153,29 @@ or revisioned v2 manifests. Scope must match the v2 handoff's saved scope.
|
|
|
153
153
|
Review current rules, capture a new v2 baseline, and deliberately update the saved
|
|
154
154
|
handoff. Existing inputs are preserved by init, not silently upgraded. Review
|
|
155
155
|
installed skills, instruction blocks and CI commands to update their pinned
|
|
156
|
-
version to 0.
|
|
156
|
+
version to 0.8.0 and add `--require-content`. Init refuses to overwrite differing
|
|
157
157
|
integrations; compare them with the new packaged templates and update reviewed
|
|
158
158
|
copies explicitly. Never refresh before checking resumed work or reuse capturedAt
|
|
159
159
|
as the clock for real resumed work.
|
|
160
160
|
|
|
161
|
+
## Verify before running a command
|
|
162
|
+
|
|
163
|
+
```sh
|
|
164
|
+
npx handoff-check@0.8.0 run --profile production -- node scripts/preflight-demo.js
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Use the intended configured profile and an explicitly chosen program. `run`
|
|
168
|
+
requires a content-aware handoff and at least one active constraint, checks the
|
|
169
|
+
current clock, and starts the command only after verification passes. All args
|
|
170
|
+
after `--` are passed literally with no implicit shell. Diagnostics use stderr;
|
|
171
|
+
the child inherits stdout/stdin/environment/cwd and its exit code is preserved.
|
|
172
|
+
The read-only verifier stays unchanged; the supplied program can have side effects.
|
|
173
|
+
This is one preflight, not a sandbox or authorization grant, and inputs may change
|
|
174
|
+
after the check. See [verified commands](docs/verified-commands.md).
|
|
175
|
+
|
|
161
176
|
## Snapshot diff and guided setup
|
|
162
177
|
|
|
163
|
-
Run `npx handoff-check@0.
|
|
178
|
+
Run `npx handoff-check@0.8.0 setup` in a terminal to create a new project-bound
|
|
164
179
|
configuration with explicit environments and one real rule you author. Review
|
|
165
180
|
the exact retained baselines before typing `yes`; existing files are never replaced.
|
|
166
181
|
No agent integrations or dependencies are installed. Use `--dry-run` to preview.
|
|
@@ -177,8 +192,8 @@ See [the guide](docs/snapshot-diff-and-setup.md).
|
|
|
177
192
|
reproducibility metadata. Existing unbound files/default JSON stay compatible.
|
|
178
193
|
|
|
179
194
|
```sh
|
|
180
|
-
npx handoff-check@0.
|
|
181
|
-
npx handoff-check@0.
|
|
195
|
+
npx handoff-check@0.8.0 verify --profile stage --require-content --report --format json
|
|
196
|
+
npx handoff-check@0.8.0 doctor --profile stage
|
|
182
197
|
```
|
|
183
198
|
|
|
184
199
|
These commands require an explicitly authored config v2 profile. Bound manifest
|
|
@@ -188,12 +203,12 @@ record the exact input/config bytes parsed, package version and policies; Git is
|
|
|
188
203
|
read only with separate --git-context. They are not signed attestations or proof
|
|
189
204
|
of compliance. See [setup, migration and examples](docs/project-context.md).
|
|
190
205
|
|
|
191
|
-
For read-only installation diagnostics, run `npx handoff-check@0.
|
|
206
|
+
For read-only installation diagnostics, run `npx handoff-check@0.8.0 doctor`.
|
|
192
207
|
`doctor --format json` reports paths, supported input versions and managed
|
|
193
208
|
integration pins. Its exit codes are 0 healthy, 1 attention and 2 invalid invocation;
|
|
194
209
|
it does not verify a handoff or prove a host ran the integration.
|
|
195
210
|
|
|
196
|
-
`npx handoff-check@0.
|
|
211
|
+
`npx handoff-check@0.8.0 hook-config --host claude` emits an opt-in advisory
|
|
197
212
|
SessionStart snippet to merge manually into existing settings. It never overwrites
|
|
198
213
|
settings, and requires a pinned project-local package. The local adapter uses the
|
|
199
214
|
same verifier without network/model calls; startup/resume/clear/compact checks
|
|
@@ -336,6 +351,10 @@ handoff-check diff --before <snapshot> --after <snapshot>
|
|
|
336
351
|
|
|
337
352
|
handoff-check setup [--dry-run]
|
|
338
353
|
|
|
354
|
+
handoff-check run
|
|
355
|
+
[--config <path>] [--profile <name> | --scope <scope>]
|
|
356
|
+
[--constraints <path>] [--handoff <path>] -- <executable> [arguments...]
|
|
357
|
+
|
|
339
358
|
handoff-check init --scope <scope>
|
|
340
359
|
[--agent codex|claude|both|none] [--dry-run] [--ci] [--format text|json]
|
|
341
360
|
|
|
@@ -347,7 +366,7 @@ handoff-check hook-config --host claude [--require-active]
|
|
|
347
366
|
handoff-check hook --host claude --config <absolute-path> [--require-active]
|
|
348
367
|
```
|
|
349
368
|
|
|
350
|
-
Verify/snapshot/explain/doctor/hook/hook-config accept explicit `--profile`;
|
|
369
|
+
Verify/snapshot/explain/doctor/hook/hook-config/run accept explicit `--profile`;
|
|
351
370
|
init does not. Profile selection rejects scope/input-path overrides, but permits
|
|
352
371
|
--config. Verify-only --report requires JSON or Markdown; --git-context additionally
|
|
353
372
|
requires --report and Git with an existing commit. No reports are saved automatically.
|
|
@@ -370,6 +389,11 @@ include global rules even when no scope-specific rules exist.
|
|
|
370
389
|
| 1 | Rule or active-set policy mismatch; inspect findings |
|
|
371
390
|
| 2 | Invalid arguments, invalid input, or unreadable input file |
|
|
372
391
|
|
|
392
|
+
`run` returns 1 for a blocked preflight or 2 for invalid input/launch error.
|
|
393
|
+
After launch it preserves the child's exit code, including 1/2, or maps an
|
|
394
|
+
unhandled signal to 128 + the OS signal number. Read stderr phases to distinguish
|
|
395
|
+
blocked verification from a failed program. Run has no format/policy/time override.
|
|
396
|
+
|
|
373
397
|
Per-rule findings include `MISSING`, `EXPIRED`, `REVOKED`, `SUPERSEDED`, `OUT_OF_SCOPE`,
|
|
374
398
|
`UNKNOWN`, and (for v2) `CHANGED`, ordered by ID. A reported ID receives one primary finding according to
|
|
375
399
|
the precedence in the lifecycle ADR.
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli.ts
|
|
4
|
-
import { open as
|
|
5
|
-
import { resolve as
|
|
4
|
+
import { open as open4 } from "node:fs/promises";
|
|
5
|
+
import { resolve as resolve7 } from "node:path";
|
|
6
6
|
import { parseArgs } from "node:util";
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "handoff-check",
|
|
10
|
-
version: "0.
|
|
10
|
+
version: "0.8.0",
|
|
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",
|
|
@@ -68,7 +68,8 @@ var package_default = {
|
|
|
68
68
|
|
|
69
69
|
// src/config.ts
|
|
70
70
|
import { createHash as createHash2 } from "node:crypto";
|
|
71
|
-
import {
|
|
71
|
+
import { constants } from "node:fs";
|
|
72
|
+
import { open, readFile } from "node:fs/promises";
|
|
72
73
|
import { dirname, resolve } from "node:path";
|
|
73
74
|
|
|
74
75
|
// src/content.ts
|
|
@@ -315,10 +316,22 @@ function selectProfile(config, profile) {
|
|
|
315
316
|
function digest(bytes) {
|
|
316
317
|
return `sha256:${createHash2("sha256").update(bytes).digest("hex")}`;
|
|
317
318
|
}
|
|
318
|
-
async function
|
|
319
|
+
async function readBytes(path, regularOnly) {
|
|
320
|
+
if (!regularOnly)
|
|
321
|
+
return readFile(path);
|
|
322
|
+
const handle = await open(path, constants.O_RDONLY | (constants.O_NONBLOCK ?? 0));
|
|
323
|
+
try {
|
|
324
|
+
if (!(await handle.stat()).isFile())
|
|
325
|
+
throw new InputError(`Expected a regular input file: '${path}'`);
|
|
326
|
+
return await handle.readFile();
|
|
327
|
+
} finally {
|
|
328
|
+
await handle.close();
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
async function readJsonRecord(path, regularOnly = false) {
|
|
319
332
|
let bytes;
|
|
320
333
|
try {
|
|
321
|
-
bytes = await
|
|
334
|
+
bytes = await readBytes(path, regularOnly);
|
|
322
335
|
} catch {
|
|
323
336
|
throw new InputError(`Cannot read input file '${path}'`);
|
|
324
337
|
}
|
|
@@ -330,8 +343,8 @@ async function readJsonRecord(path) {
|
|
|
330
343
|
}
|
|
331
344
|
return { input, path, sha256: digest(bytes) };
|
|
332
345
|
}
|
|
333
|
-
async function readJson(path) {
|
|
334
|
-
return (await readJsonRecord(path)).input;
|
|
346
|
+
async function readJson(path, regularOnly = false) {
|
|
347
|
+
return (await readJsonRecord(path, regularOnly)).input;
|
|
335
348
|
}
|
|
336
349
|
function parseConfig(input) {
|
|
337
350
|
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
@@ -384,11 +397,11 @@ function parseConfig(input) {
|
|
|
384
397
|
}
|
|
385
398
|
return config;
|
|
386
399
|
}
|
|
387
|
-
async function loadConfig(cwd, explicit) {
|
|
400
|
+
async function loadConfig(cwd, explicit, regularOnly = false) {
|
|
388
401
|
const path = resolve(cwd, explicit ?? ".handoff-check.json");
|
|
389
402
|
let input;
|
|
390
403
|
try {
|
|
391
|
-
input = await
|
|
404
|
+
input = await readBytes(path, regularOnly);
|
|
392
405
|
} catch (error) {
|
|
393
406
|
if (explicit === undefined && error.code === "ENOENT")
|
|
394
407
|
return { config: { schemaVersion: 1 }, directory: cwd };
|
|
@@ -1117,8 +1130,8 @@ async function doctor(cwd, options) {
|
|
|
1117
1130
|
}
|
|
1118
1131
|
|
|
1119
1132
|
// src/initialize.ts
|
|
1120
|
-
import { constants } from "node:fs";
|
|
1121
|
-
import { lstat as lstat2, mkdir, open, readFile as readFile3 } from "node:fs/promises";
|
|
1133
|
+
import { constants as constants2 } from "node:fs";
|
|
1134
|
+
import { lstat as lstat2, mkdir, open as open2, readFile as readFile3 } from "node:fs/promises";
|
|
1122
1135
|
import { dirname as dirname3, isAbsolute as isAbsolute2, relative as relative2, resolve as resolve4, sep as sep2 } from "node:path";
|
|
1123
1136
|
var begin = "<!-- handoff-check:begin -->";
|
|
1124
1137
|
var end = "<!-- handoff-check:end -->";
|
|
@@ -1297,8 +1310,8 @@ jobs:
|
|
|
1297
1310
|
throw new InputError("Target changed after planning");
|
|
1298
1311
|
await mkdir(dirname3(file.path), { recursive: true });
|
|
1299
1312
|
await inspect(root, file.path);
|
|
1300
|
-
const flags = file.action === "create" ?
|
|
1301
|
-
const handle = await
|
|
1313
|
+
const flags = file.action === "create" ? constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL : constants2.O_WRONLY | constants2.O_APPEND | (constants2.O_NOFOLLOW ?? 0);
|
|
1314
|
+
const handle = await open2(file.path, flags, 420);
|
|
1302
1315
|
try {
|
|
1303
1316
|
await handle.writeFile(file.content, "utf8");
|
|
1304
1317
|
} finally {
|
|
@@ -1376,9 +1389,123 @@ function reportMarkdown(report) {
|
|
|
1376
1389
|
`);
|
|
1377
1390
|
}
|
|
1378
1391
|
|
|
1379
|
-
// src/
|
|
1380
|
-
import {
|
|
1392
|
+
// src/run.ts
|
|
1393
|
+
import { spawn } from "node:child_process";
|
|
1394
|
+
import { constants as constants3 } from "node:os";
|
|
1381
1395
|
import { resolve as resolve5 } from "node:path";
|
|
1396
|
+
async function runVerified(cwd, options, argv) {
|
|
1397
|
+
const executable = argv[0];
|
|
1398
|
+
if (!executable?.trim())
|
|
1399
|
+
throw new InputError("run requires -- <executable> [arguments...]");
|
|
1400
|
+
if (options.profile !== undefined && [options.scope, options.constraints, options.handoff].some((v) => v !== undefined))
|
|
1401
|
+
throw new InputError("--profile cannot be combined with --scope, --constraints or --handoff");
|
|
1402
|
+
for (const key of ["config", "constraints", "handoff"])
|
|
1403
|
+
if (options[key] !== undefined && !options[key].trim())
|
|
1404
|
+
throw new InputError(`--${key}: expected a non-empty path`);
|
|
1405
|
+
let child;
|
|
1406
|
+
const signalCode = (signal) => 128 + (constants3.signals[signal] ?? 1);
|
|
1407
|
+
const forward = (signal) => {
|
|
1408
|
+
if (!child) {
|
|
1409
|
+
process.stderr.write(`RUN CANCELLED before command launch
|
|
1410
|
+
`);
|
|
1411
|
+
process.exit(signalCode(signal));
|
|
1412
|
+
}
|
|
1413
|
+
if (child && child.exitCode === null && child.signalCode === null) {
|
|
1414
|
+
process.stderr.write(`RUN SIGNAL ${signal}: forwarding to direct child
|
|
1415
|
+
`);
|
|
1416
|
+
try {
|
|
1417
|
+
child.kill(signal);
|
|
1418
|
+
} catch {
|
|
1419
|
+
process.stderr.write(`RUN SIGNAL ${signal}: direct-child forwarding failed
|
|
1420
|
+
`);
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
};
|
|
1424
|
+
const interrupt = () => forward("SIGINT");
|
|
1425
|
+
const terminate = () => forward("SIGTERM");
|
|
1426
|
+
process.on("SIGINT", interrupt);
|
|
1427
|
+
process.on("SIGTERM", terminate);
|
|
1428
|
+
const deadline = setTimeout(() => {
|
|
1429
|
+
process.stderr.write(`RUN INVALID: preflight exceeded 5 seconds; command not started
|
|
1430
|
+
`);
|
|
1431
|
+
process.exit(2);
|
|
1432
|
+
}, 5000);
|
|
1433
|
+
process.stderr.write(`RUN CHECKING: current-clock content/nonempty preflight
|
|
1434
|
+
`);
|
|
1435
|
+
try {
|
|
1436
|
+
const loaded = await loadConfig(cwd, options.config, true);
|
|
1437
|
+
const config = selectProfile(loaded.config, options.profile);
|
|
1438
|
+
const scope = identifier(options.scope ?? config.scope, "--scope (or config.scope)");
|
|
1439
|
+
const manifest = parseManifest(await readJson(options.constraints !== undefined ? resolve5(cwd, options.constraints) : resolve5(loaded.directory, config.constraints ?? "constraints.json"), true));
|
|
1440
|
+
const handoff = parseHandoff(await readJson(options.handoff !== undefined ? resolve5(cwd, options.handoff) : resolve5(loaded.directory, config.handoff ?? "handoff.json"), true));
|
|
1441
|
+
if (handoff.schemaVersion === 1)
|
|
1442
|
+
throw new InputError("run requires a content-aware v2/v3/v4 handoff; review and capture a baseline explicitly");
|
|
1443
|
+
const result = verify(manifest, handoff, scope, new Date().toISOString(), {
|
|
1444
|
+
requireActive: true,
|
|
1445
|
+
...config.projectId === undefined ? {} : { projectId: config.projectId }
|
|
1446
|
+
});
|
|
1447
|
+
clearTimeout(deadline);
|
|
1448
|
+
if (result.status !== "verified") {
|
|
1449
|
+
for (const finding of result.findings)
|
|
1450
|
+
process.stderr.write(`RUN BLOCKED ${finding.code}${finding.id ? ` ${finding.id}` : ""}
|
|
1451
|
+
`);
|
|
1452
|
+
process.stderr.write(`RUN BLOCKED: command not started | ${result.expectedConstraints.length} active constraints | scope ${scope} | as of ${result.asOf}${result.projectId ? ` | project ${result.projectId}` : ""}${options.profile ? ` | profile ${options.profile}` : ""}
|
|
1453
|
+
`);
|
|
1454
|
+
return 1;
|
|
1455
|
+
}
|
|
1456
|
+
process.stderr.write(`RUN VERIFIED: ${result.expectedConstraints.length} active constraints | content tracked | scope ${scope} | as of ${result.asOf}${result.projectId ? ` | project ${result.projectId}` : ""}${options.profile ? ` | profile ${options.profile}` : ""}
|
|
1457
|
+
`);
|
|
1458
|
+
return await new Promise((done) => {
|
|
1459
|
+
let launchFailed = false;
|
|
1460
|
+
let started = false;
|
|
1461
|
+
try {
|
|
1462
|
+
child = spawn(executable, argv.slice(1), {
|
|
1463
|
+
cwd,
|
|
1464
|
+
env: process.env,
|
|
1465
|
+
shell: false,
|
|
1466
|
+
stdio: "inherit"
|
|
1467
|
+
});
|
|
1468
|
+
} catch {
|
|
1469
|
+
process.stderr.write(`RUN LAUNCH ERROR: command could not be started
|
|
1470
|
+
`);
|
|
1471
|
+
done(2);
|
|
1472
|
+
return;
|
|
1473
|
+
}
|
|
1474
|
+
child.on("error", (error) => {
|
|
1475
|
+
if (started) {
|
|
1476
|
+
process.stderr.write(`RUN PROCESS ERROR: ${terminalText(error.code ?? "UNKNOWN")} | waiting for direct child
|
|
1477
|
+
`);
|
|
1478
|
+
return;
|
|
1479
|
+
}
|
|
1480
|
+
launchFailed = true;
|
|
1481
|
+
process.stderr.write(`RUN LAUNCH ERROR: ${terminalText(error.code ?? "UNKNOWN")} | command could not be started
|
|
1482
|
+
`);
|
|
1483
|
+
done(2);
|
|
1484
|
+
});
|
|
1485
|
+
child.once("spawn", () => {
|
|
1486
|
+
started = true;
|
|
1487
|
+
process.stderr.write(`RUN STARTED: verification passed; waiting for command
|
|
1488
|
+
`);
|
|
1489
|
+
});
|
|
1490
|
+
child.once("close", (code, signal) => {
|
|
1491
|
+
if (launchFailed)
|
|
1492
|
+
return;
|
|
1493
|
+
const exitCode = code ?? (signal ? signalCode(signal) : 2);
|
|
1494
|
+
process.stderr.write(`RUN EXIT: ${exitCode}${signal ? ` | signal ${signal}` : ""}
|
|
1495
|
+
`);
|
|
1496
|
+
done(exitCode);
|
|
1497
|
+
});
|
|
1498
|
+
});
|
|
1499
|
+
} finally {
|
|
1500
|
+
clearTimeout(deadline);
|
|
1501
|
+
process.removeListener("SIGINT", interrupt);
|
|
1502
|
+
process.removeListener("SIGTERM", terminate);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
// src/setup.ts
|
|
1507
|
+
import { lstat as lstat3, open as open3, readdir } from "node:fs/promises";
|
|
1508
|
+
import { resolve as resolve6 } from "node:path";
|
|
1382
1509
|
import { createInterface } from "node:readline/promises";
|
|
1383
1510
|
function setupPlan(answers, asOf) {
|
|
1384
1511
|
const projectId = identifier(answers.projectId, "Project ID");
|
|
@@ -1425,7 +1552,7 @@ async function assertSetupTargets(root, files) {
|
|
|
1425
1552
|
if (existing.has(file.path.normalize("NFC").toLowerCase()))
|
|
1426
1553
|
throw new InputError(`Setup requires new files; target already exists: '${file.path}'.`);
|
|
1427
1554
|
try {
|
|
1428
|
-
await lstat3(
|
|
1555
|
+
await lstat3(resolve6(root, file.path));
|
|
1429
1556
|
} catch (error) {
|
|
1430
1557
|
if (error.code === "ENOENT")
|
|
1431
1558
|
continue;
|
|
@@ -1439,7 +1566,7 @@ async function writeSetup(root, files) {
|
|
|
1439
1566
|
const written = [];
|
|
1440
1567
|
for (const file of files) {
|
|
1441
1568
|
try {
|
|
1442
|
-
const handle = await
|
|
1569
|
+
const handle = await open3(resolve6(root, file.path), "wx", 420);
|
|
1443
1570
|
try {
|
|
1444
1571
|
await handle.writeFile(file.content, "utf8");
|
|
1445
1572
|
} finally {
|
|
@@ -1521,6 +1648,7 @@ Edit and review constraints before relying on them. Never refresh a baseline bef
|
|
|
1521
1648
|
var help = `Handoff Check
|
|
1522
1649
|
|
|
1523
1650
|
Usage: handoff-check verify --scope <scope> [options]
|
|
1651
|
+
handoff-check run [--profile <name> | --scope <scope>] [--config <path>] -- <executable> [args...]
|
|
1524
1652
|
handoff-check diff --before <snapshot> --after <snapshot> [--format text|json|markdown]
|
|
1525
1653
|
handoff-check setup [--dry-run]
|
|
1526
1654
|
handoff-check init --scope <scope> [--agent both] [--dry-run] [--ci]
|
|
@@ -1555,14 +1683,20 @@ Options:
|
|
|
1555
1683
|
--help Show this help
|
|
1556
1684
|
|
|
1557
1685
|
Exit codes: verify 0 verified / 1 mismatch; diff 0 unchanged / 1 different; doctor 0 healthy / 1 attention.
|
|
1686
|
+
Run: mandatory content/nonempty/current-clock preflight; 1 blocked / 2 invalid or launch error.
|
|
1687
|
+
After launch run returns the child exit code (or 128 + signal); diagnostics use stderr.
|
|
1558
1688
|
Hook 0 means advisory response delivered (may report FAIL/INVALID), not verified.
|
|
1559
1689
|
Invalid invocation/input returns 2; explain/init/snapshot/hook-config succeed with 0.
|
|
1560
1690
|
`;
|
|
1561
1691
|
async function main() {
|
|
1562
1692
|
let format = "text";
|
|
1563
1693
|
try {
|
|
1694
|
+
const rawArgs = process.argv.slice(2);
|
|
1695
|
+
const runCommand = rawArgs[0] === "run";
|
|
1696
|
+
const separator = rawArgs.indexOf("--");
|
|
1697
|
+
const wrapperArgs = runCommand && separator >= 0 ? rawArgs.slice(0, separator) : rawArgs;
|
|
1564
1698
|
const { values, positionals } = parseArgs({
|
|
1565
|
-
args:
|
|
1699
|
+
args: wrapperArgs,
|
|
1566
1700
|
allowPositionals: true,
|
|
1567
1701
|
strict: true,
|
|
1568
1702
|
options: {
|
|
@@ -1611,11 +1745,24 @@ async function main() {
|
|
|
1611
1745
|
"hook",
|
|
1612
1746
|
"hook-config",
|
|
1613
1747
|
"diff",
|
|
1614
|
-
"setup"
|
|
1748
|
+
"setup",
|
|
1749
|
+
"run"
|
|
1615
1750
|
].includes(positionals[0] ?? ""))
|
|
1616
|
-
throw new InputError("Expected command: verify, snapshot, explain, init, setup, diff, doctor, hook or hook-config (use --help for usage)");
|
|
1751
|
+
throw new InputError("Expected command: verify, snapshot, explain, init, setup, diff, run, doctor, hook or hook-config (use --help for usage)");
|
|
1617
1752
|
const cwd = process.cwd();
|
|
1618
1753
|
const command = positionals[0];
|
|
1754
|
+
if (command === "run") {
|
|
1755
|
+
if (!runCommand || separator < 0)
|
|
1756
|
+
throw new InputError("Use run as the first argument and include -- <executable> [arguments...]");
|
|
1757
|
+
const allowed = ["config", "profile", "scope", "constraints", "handoff"];
|
|
1758
|
+
for (const key of Object.keys(values)) {
|
|
1759
|
+
if (key === "format" && !wrapperArgs.some((arg) => arg === "--format" || arg.startsWith("--format=")))
|
|
1760
|
+
continue;
|
|
1761
|
+
if (!allowed.includes(key))
|
|
1762
|
+
throw new InputError(`--${key} is not supported by run; content/nonempty checks and the current clock are mandatory`);
|
|
1763
|
+
}
|
|
1764
|
+
return await runVerified(cwd, values, rawArgs.slice(separator + 1));
|
|
1765
|
+
}
|
|
1619
1766
|
if (command === "diff" || command === "setup") {
|
|
1620
1767
|
const allowed = command === "diff" ? ["before", "after", "format"] : ["dry-run"];
|
|
1621
1768
|
for (const key of Object.keys(values)) {
|
|
@@ -1630,8 +1777,8 @@ async function main() {
|
|
|
1630
1777
|
}
|
|
1631
1778
|
if (!values.before?.trim() || !values.after?.trim())
|
|
1632
1779
|
throw new InputError("diff requires --before <snapshot> and --after <snapshot>");
|
|
1633
|
-
const before = parseHandoff((await readJsonRecord(
|
|
1634
|
-
const after = parseHandoff((await readJsonRecord(
|
|
1780
|
+
const before = parseHandoff((await readJsonRecord(resolve7(cwd, values.before))).input);
|
|
1781
|
+
const after = parseHandoff((await readJsonRecord(resolve7(cwd, values.after))).input);
|
|
1635
1782
|
const result2 = diffSnapshots(before, after);
|
|
1636
1783
|
process.stdout.write(format === "json" ? `${JSON.stringify(result2, null, 2)}
|
|
1637
1784
|
` : diffText(result2, format === "markdown"));
|
|
@@ -1782,7 +1929,7 @@ ${result2.notice}
|
|
|
1782
1929
|
for (const key of ["constraints", "handoff", "config"])
|
|
1783
1930
|
if (values[key] !== undefined && !values[key].trim())
|
|
1784
1931
|
throw new InputError(`--${key}: expected a non-empty path`);
|
|
1785
|
-
const manifestRecord = await readJsonRecord(values.constraints !== undefined ?
|
|
1932
|
+
const manifestRecord = await readJsonRecord(values.constraints !== undefined ? resolve7(cwd, values.constraints) : resolve7(directory, config.constraints ?? "constraints.json"));
|
|
1786
1933
|
const manifest = parseManifest(manifestRecord.input);
|
|
1787
1934
|
checkProject(manifest, undefined, config.projectId);
|
|
1788
1935
|
if (command === "explain") {
|
|
@@ -1807,10 +1954,10 @@ ${result2.notice}
|
|
|
1807
1954
|
else {
|
|
1808
1955
|
if (!values.output.trim())
|
|
1809
1956
|
throw new InputError("--output: expected a non-empty path");
|
|
1810
|
-
const path =
|
|
1957
|
+
const path = resolve7(cwd, values.output);
|
|
1811
1958
|
let handle;
|
|
1812
1959
|
try {
|
|
1813
|
-
handle = await
|
|
1960
|
+
handle = await open4(path, "wx", 420);
|
|
1814
1961
|
} catch {
|
|
1815
1962
|
throw new InputError(`Cannot create snapshot '${path}'; choose a new file with an existing parent directory`);
|
|
1816
1963
|
}
|
|
@@ -1833,7 +1980,7 @@ ${result2.notice}
|
|
|
1833
1980
|
}
|
|
1834
1981
|
if (values.task !== undefined || values.output !== undefined)
|
|
1835
1982
|
throw new InputError("--task and --output are only supported by snapshot");
|
|
1836
|
-
const handoffRecord = await readJsonRecord(values.handoff !== undefined ?
|
|
1983
|
+
const handoffRecord = await readJsonRecord(values.handoff !== undefined ? resolve7(cwd, values.handoff) : resolve7(directory, config.handoff ?? "handoff.json"));
|
|
1837
1984
|
const handoff = parseHandoff(handoffRecord.input);
|
|
1838
1985
|
if (values["require-content"] && handoff.schemaVersion === 1)
|
|
1839
1986
|
throw new InputError("Content tracking requires a schemaVersion 2, 3 or 4 handoff; review current rules and capture a snapshot before resuming");
|
|
@@ -9,8 +9,8 @@ infers rules from a summary.
|
|
|
9
9
|
From the consuming repository root:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npx handoff-check@0.
|
|
13
|
-
npx handoff-check@0.
|
|
12
|
+
npx handoff-check@0.8.0 init --scope staging --agent both --dry-run
|
|
13
|
+
npx handoff-check@0.8.0 init --scope staging --agent both
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
Choose `codex`, `claude`, `both` (default), or `none`. Generated integrations:
|
|
@@ -39,8 +39,8 @@ npm pack
|
|
|
39
39
|
From a separate consuming project, substitute the actual absolute tarball path:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
npx --offline --yes --package=/absolute/path/handoff-check-0.
|
|
43
|
-
npx --offline --yes --package=/absolute/path/handoff-check-0.
|
|
42
|
+
npx --offline --yes --package=/absolute/path/handoff-check-0.8.0.tgz handoff-check init --scope staging --agent both
|
|
43
|
+
npx --offline --yes --package=/absolute/path/handoff-check-0.8.0.tgz handoff-check verify --format json --require-content
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Bun is not required for these consumer commands. Generated agent commands use the
|
package/docs/architecture.md
CHANGED
|
@@ -35,6 +35,13 @@ lifecycle inference. Setup authors new bound files from explicit answers using
|
|
|
35
35
|
the existing parsers and snapshot core, previews exact bytes, and creates files
|
|
36
36
|
exclusively only after adoption. Existing init remains stable. See ADR 0007.
|
|
37
37
|
|
|
38
|
+
Run is an opt-in CLI process adapter: it reads regular local inputs through the
|
|
39
|
+
same selectors/parsers, requires current-clock content/nonempty verification,
|
|
40
|
+
then spawns explicit argv with shell false only on success. Child stdio/cwd/env
|
|
41
|
+
are inherited and exit codes preserved. It never expands the pure verifier into
|
|
42
|
+
an execution engine. See ADR 0008 for cancellation, time-of-check/time-of-use and
|
|
43
|
+
platform limits; the supplied program's side effects are outside verification.
|
|
44
|
+
|
|
38
45
|
Exit codes: 0 for verified IDs, 1 for rule mismatches, 2 for invalid input or an
|
|
39
46
|
unreadable input file. JSON output is intended for agent adapters and automation.
|
|
40
47
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# ADR 0008: current-clock verification before an explicit command
|
|
2
|
+
|
|
3
|
+
Status: accepted for 0.8.0.
|
|
4
|
+
|
|
5
|
+
Session-start checks become stale before later operations. Add an opt-in `run`
|
|
6
|
+
CLI adapter that uses existing config/profile selectors, strict input parsers
|
|
7
|
+
and the same pure verifier immediately before spawning one explicit executable.
|
|
8
|
+
Require content-aware input, a nonempty active set and the current clock; offer
|
|
9
|
+
no as-of/force/skip/policy override. Read each input once; never refresh a baseline.
|
|
10
|
+
No new manifest/handoff or verification result schema is needed.
|
|
11
|
+
|
|
12
|
+
Require `run` first and an explicit `--` boundary. Parse only preceding wrapper
|
|
13
|
+
options, pass the trailing executable/argv as an array with shell false, and
|
|
14
|
+
inherit cwd/environment/stdio. Do not infer the command from config or rules.
|
|
15
|
+
Keep stdout available for the child and emit phase diagnostics to shared stderr.
|
|
16
|
+
Block mismatch with 1, invalid preflight/launch with 2; preserve all child exit
|
|
17
|
+
codes after launch. Signal forwarding is best-effort to a direct child only;
|
|
18
|
+
there is no descendant supervision, forced termination or command timeout.
|
|
19
|
+
Cancel preflight without launch and bound stalled asynchronous reads with an
|
|
20
|
+
event-loop watchdog removed before spawning. Document platform and timing limits.
|
|
21
|
+
|
|
22
|
+
This narrows the gap between a declared-rule check and an explicitly requested
|
|
23
|
+
operation. It is not atomic with file changes, a model compliance check, an
|
|
24
|
+
authorization boundary, or a sandbox. The chosen program retains ordinary access
|
|
25
|
+
and may itself interpret commands or perform multiple actions. Existing verify,
|
|
26
|
+
init, snapshot, diff, setup and advisory lifecycle behavior stay unchanged.
|
|
27
|
+
|
|
28
|
+
Owner/review-by metadata and explicit source-file checks remain separate future
|
|
29
|
+
work: overdue review must not silently deactivate rules, and source edits do not
|
|
30
|
+
prove semantic policy changes. Do not bundle them into the command gate.
|
package/docs/development-plan.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Development plan
|
|
2
2
|
|
|
3
|
-
Status:
|
|
4
|
-
0.6 project/profile/report support is also implemented; later milestones proposed.
|
|
3
|
+
Status: milestones through 0.8 are implemented; later milestones remain proposed.
|
|
5
4
|
Research reviewed: 2026-11-24. Version labels below are targets, not release promises.
|
|
6
5
|
|
|
7
6
|
## Product direction
|
|
@@ -135,7 +134,16 @@ and optional retained field details; terminal-only new-project setup with exact
|
|
|
135
134
|
preview and affirmative adoption of one real global rule. Existing init/verify
|
|
136
135
|
contracts stay unchanged. See [usage](snapshot-diff-and-setup.md).
|
|
137
136
|
|
|
138
|
-
##
|
|
137
|
+
## 0.8: fresh verification before critical commands (implemented)
|
|
138
|
+
|
|
139
|
+
Implemented under [ADR 0008](decisions/0008-verified-command-runner.md): opt-in
|
|
140
|
+
run wraps one explicit executable with current-clock content/nonempty checks
|
|
141
|
+
using the existing verifier. Invalid/mismatched preflight never starts the child;
|
|
142
|
+
successful launch inherits process context and preserves results. It is not a
|
|
143
|
+
sandbox, permission grant, atomic transaction or enforcement outside the wrapper.
|
|
144
|
+
See [usage and limits](verified-commands.md). Existing contracts remain compatible.
|
|
145
|
+
|
|
146
|
+
## 0.9 candidate: rule maintenance, gated by pilot demand
|
|
139
147
|
|
|
140
148
|
Priority: medium. Keep source inspection separate from normal verify semantics.
|
|
141
149
|
|
|
@@ -144,6 +152,9 @@ Priority: medium. Keep source inspection separate from normal verify semantics.
|
|
|
144
152
|
rule's meaning changed. Decide full-file versus section binding deliberately.
|
|
145
153
|
- Consider owner/review-by metadata. Overdue review is distinct from rule expiry;
|
|
146
154
|
it must not silently deactivate a restriction.
|
|
155
|
+
- Decide whether review metadata belongs in a separate versioned registry or a
|
|
156
|
+
new content contract before implementation. Keep existing canonical hashes and
|
|
157
|
+
baseline meaning stable; provide migration and independent maintenance output.
|
|
147
158
|
- Consider explicitly declared relationships such as conflicts/requires. Validate
|
|
148
159
|
these deterministically; defer free-text contradiction inference.
|
|
149
160
|
|
package/docs/explainability.md
CHANGED
|
@@ -6,8 +6,8 @@ No service, model call or API key is needed.
|
|
|
6
6
|
## Understand the active set
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
npx handoff-check@0.
|
|
10
|
-
npx handoff-check@0.
|
|
9
|
+
npx handoff-check@0.8.0 explain --format json
|
|
10
|
+
npx handoff-check@0.8.0 explain --scope production --format markdown
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Explain reads the manifest but not the handoff. Every rule has an applicability
|
|
@@ -20,8 +20,8 @@ exits 0 even with zero active rules: use verify to compare a handoff.
|
|
|
20
20
|
At a reviewed handoff creation, after upgrading all consumers to 0.4+:
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
|
-
npx handoff-check@0.
|
|
24
|
-
npx handoff-check@0.
|
|
23
|
+
npx handoff-check@0.8.0 snapshot --task "Review staging migrations" --include-content --output handoff.reviewed.json
|
|
24
|
+
npx handoff-check@0.8.0 verify --handoff handoff.reviewed.json --require-content --require-active --format markdown
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Review the new file before explicitly adopting it in config. Snapshot never
|
package/docs/first-check.md
CHANGED
|
@@ -8,8 +8,8 @@ Bun, API keys, and GitHub Actions are not required. All rules below are syntheti
|
|
|
8
8
|
```sh
|
|
9
9
|
mkdir handoff-check-demo
|
|
10
10
|
cd handoff-check-demo
|
|
11
|
-
npx handoff-check@0.
|
|
12
|
-
npx handoff-check@0.
|
|
11
|
+
npx handoff-check@0.8.0 init --scope staging --agent none
|
|
12
|
+
npx handoff-check@0.8.0 verify --require-content
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
The starter passes with `PASS (EMPTY)` and `0 active constraints checked`.
|
|
@@ -41,7 +41,7 @@ does not fetch it or check the contents of a referenced document.
|
|
|
41
41
|
Before capturing a baseline, run:
|
|
42
42
|
|
|
43
43
|
```sh
|
|
44
|
-
npx handoff-check@0.
|
|
44
|
+
npx handoff-check@0.8.0 verify --require-content --require-active
|
|
45
45
|
```
|
|
46
46
|
|
|
47
47
|
Expect `MISSING MIGRATION-REVIEW`, one active constraint, and exit 1. The old
|
|
@@ -50,8 +50,8 @@ starter handoff does not include the new rule yet.
|
|
|
50
50
|
## Capture and verify a reviewed baseline
|
|
51
51
|
|
|
52
52
|
```sh
|
|
53
|
-
npx handoff-check@0.
|
|
54
|
-
npx handoff-check@0.
|
|
53
|
+
npx handoff-check@0.8.0 snapshot --task "Review staging migration" --output handoff.reviewed.json
|
|
54
|
+
npx handoff-check@0.8.0 verify --handoff handoff.reviewed.json --require-content --require-active
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
Review the generated file before relying on it. The verification command should
|
|
@@ -70,7 +70,7 @@ In `constraints.json`, change the description to
|
|
|
70
70
|
handoff unchanged, then run:
|
|
71
71
|
|
|
72
72
|
```sh
|
|
73
|
-
npx handoff-check@0.
|
|
73
|
+
npx handoff-check@0.8.0 verify --handoff handoff.reviewed.json --require-content --require-active --format json
|
|
74
74
|
```
|
|
75
75
|
|
|
76
76
|
Expect `status: "mismatch"`, `activeConstraintCount: 1`, a `CHANGED` finding, and
|
package/docs/lifecycle.md
CHANGED
|
@@ -6,8 +6,8 @@ calls, source fetches, API keys or transcript access.
|
|
|
6
6
|
## Diagnose the intended repository/worktree root
|
|
7
7
|
|
|
8
8
|
```sh
|
|
9
|
-
npx handoff-check@0.
|
|
10
|
-
npx handoff-check@0.
|
|
9
|
+
npx handoff-check@0.8.0 doctor --format json
|
|
10
|
+
npx handoff-check@0.8.0 doctor --host claude
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
Doctor reports resolved input paths/versions, managed integrations/pins and
|
|
@@ -22,10 +22,10 @@ host settings and effective trust are not comprehensively inspected.
|
|
|
22
22
|
|
|
23
23
|
1. Initialize/review inputs and deliberately adopt a content-aware baseline.
|
|
24
24
|
2. Install the exact package in the consuming project. For npm:
|
|
25
|
-
`npm install --save-dev --save-exact handoff-check@0.
|
|
25
|
+
`npm install --save-dev --save-exact handoff-check@0.8.0`. Installation uses
|
|
26
26
|
the registry; the hook later uses only this local package. Temporary npx caches
|
|
27
27
|
and global installs do not meet that prerequisite.
|
|
28
|
-
3. Run `npx handoff-check@0.
|
|
28
|
+
3. Run `npx handoff-check@0.8.0 hook-config --host claude` and inspect the JSON.
|
|
29
29
|
4. In an editor, merge the returned SessionStart entries into the existing
|
|
30
30
|
`.claude/settings.json` hooks object. Preserve other events, handlers,
|
|
31
31
|
permissions and settings. Do not replace the whole file or blindly redirect
|
|
@@ -66,6 +66,17 @@ enterprise policies can disable hooks or require review.
|
|
|
66
66
|
|
|
67
67
|
## Critical actions need a fresh check
|
|
68
68
|
|
|
69
|
+
From 0.8.0, use the dedicated command wrapper with the reviewed local package:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
node ./node_modules/handoff-check/dist/cli.js run --profile production -- node scripts/preflight-demo.js
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Choose a configured profile and explicit reviewed program. The wrapper requires
|
|
76
|
+
nonempty content-aware inputs and the current clock, then preserves the child
|
|
77
|
+
result. It blocks only commands invoked through it, not other agent actions.
|
|
78
|
+
See [verified commands](verified-commands.md) for timing, process and platform limits.
|
|
79
|
+
|
|
69
80
|
In Bash with the project-local package already installed:
|
|
70
81
|
|
|
71
82
|
```sh
|
package/docs/project-context.md
CHANGED
|
@@ -56,10 +56,10 @@ Author `.handoff-check.json` as config v2:
|
|
|
56
56
|
```
|
|
57
57
|
|
|
58
58
|
```sh
|
|
59
|
-
npx handoff-check@0.
|
|
60
|
-
npx handoff-check@0.
|
|
61
|
-
npx handoff-check@0.
|
|
62
|
-
npx handoff-check@0.
|
|
59
|
+
npx handoff-check@0.8.0 explain --profile stage
|
|
60
|
+
npx handoff-check@0.8.0 snapshot --profile stage --task "Review staging work" --output handoffs/staging.reviewed.json
|
|
61
|
+
npx handoff-check@0.8.0 verify --profile stage --require-content
|
|
62
|
+
npx handoff-check@0.8.0 doctor --profile stage
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
These assume you deliberately adopted a baseline at the configured handoff path;
|
|
@@ -83,8 +83,8 @@ bindings produce NOT VERIFIED context; hook transport success is not a pass.
|
|
|
83
83
|
## Record exactly what was checked
|
|
84
84
|
|
|
85
85
|
```sh
|
|
86
|
-
npx handoff-check@0.
|
|
87
|
-
npx handoff-check@0.
|
|
86
|
+
npx handoff-check@0.8.0 verify --profile stage --require-content --report --format json
|
|
87
|
+
npx handoff-check@0.8.0 verify --profile stage --require-content --report --git-context --format markdown
|
|
88
88
|
```
|
|
89
89
|
|
|
90
90
|
--report is optional and verify-only. It adds package version, requested policies,
|
package/docs/releasing.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.
|
|
4
|
+
current version is 0.8.0. The package is already published; subsequent releases
|
|
5
5
|
use the configured trusted publisher and the reviewed-artifact process below.
|
|
6
6
|
|
|
7
7
|
## Release a reviewed version
|
|
@@ -19,12 +19,12 @@ use the configured trusted publisher and the reviewed-artifact process below.
|
|
|
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.
|
|
22
|
+
`npm publish /absolute/path/handoff-check-0.8.0.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.
|
|
25
|
+
`npx --yes handoff-check@0.8.0 --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.
|
|
27
|
+
6. Create tag `v0.8.0` 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,9 @@
|
|
|
1
1
|
# Roadmap
|
|
2
2
|
|
|
3
|
+
Implemented in 0.8.0: explicit current-clock verification before a supplied
|
|
4
|
+
command, with mandatory content/nonempty checks and preserved child results.
|
|
5
|
+
See [verified commands](verified-commands.md).
|
|
6
|
+
|
|
3
7
|
Implemented in 0.7.0: explicit saved-snapshot diff and guided new-project setup.
|
|
4
8
|
See [snapshot diff and setup](snapshot-diff-and-setup.md).
|
|
5
9
|
|
|
@@ -12,7 +16,7 @@ and configuration snippet, host matrix and critical-action recipes.
|
|
|
12
16
|
See [lifecycle setup](lifecycle.md). Codex/Cursor adapters remain unshipped.
|
|
13
17
|
|
|
14
18
|
See the [development plan](development-plan.md) for research evidence, proposed
|
|
15
|
-
|
|
19
|
+
milestones, dependencies, pilot validation, and acceptance criteria.
|
|
16
20
|
The plan distinguishes implemented releases from proposed milestones and dates.
|
|
17
21
|
|
|
18
22
|
Implemented in 0.4.0: shared-lifecycle explain, opt-in retained-content v3
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
With Node.js 22 or newer, run in the intended project root:
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npx handoff-check@0.
|
|
8
|
+
npx handoff-check@0.8.0 setup
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Enter a portable project ID, comma-separated environments, a rule ID, a real rule
|
|
@@ -31,7 +31,7 @@ For environments `staging,production`, setup creates `.handoff-check.json`,
|
|
|
31
31
|
is no default profile. Choose the intended environment explicitly:
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
|
-
npx handoff-check@0.
|
|
34
|
+
npx handoff-check@0.8.0 verify --profile staging --require-content --require-active
|
|
35
35
|
```
|
|
36
36
|
|
|
37
37
|
Add environment-specific rules later through deliberate review and capture;
|
|
@@ -44,9 +44,9 @@ portable skill. Do not use setup as a migration or baseline-repair command.
|
|
|
44
44
|
## Compare two saved snapshots
|
|
45
45
|
|
|
46
46
|
```sh
|
|
47
|
-
npx handoff-check@0.
|
|
48
|
-
npx handoff-check@0.
|
|
49
|
-
npx handoff-check@0.
|
|
47
|
+
npx handoff-check@0.8.0 diff --before handoff.saved.json --after handoff.next.json
|
|
48
|
+
npx handoff-check@0.8.0 diff --before handoff.saved.json --after handoff.next.json --format json
|
|
49
|
+
npx handoff-check@0.8.0 diff --before handoff.saved.json --after handoff.next.json --format markdown
|
|
50
50
|
```
|
|
51
51
|
|
|
52
52
|
Both operands are strictly validated handoff files. Unbound v2/v3 can be compared
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Verify immediately before a command
|
|
2
|
+
|
|
3
|
+
`run` performs a current-clock verification and starts an explicitly supplied
|
|
4
|
+
executable only after a nonempty, content-aware handoff passes. It calls the same
|
|
5
|
+
verifier as `verify`; the pure core and existing input formats are unchanged.
|
|
6
|
+
|
|
7
|
+
With Node.js 22 or newer, use an existing reviewed project configuration:
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npx handoff-check@0.8.0 run --profile production -- node scripts/preflight-demo.js
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The profile is an example: select the intended configured profile, or use
|
|
14
|
+
`--scope <scope>` with optional `--constraints <path>`/`--handoff <path>`.
|
|
15
|
+
`--config <path>` selects an explicit config. Config paths resolve relative to
|
|
16
|
+
that config, CLI input paths relative to the invocation directory. The child
|
|
17
|
+
always inherits the invocation working directory, environment and stdin/stdout/
|
|
18
|
+
stderr; selecting a config elsewhere does not move the child. Project/scope
|
|
19
|
+
binding and profile override restrictions are identical to verify.
|
|
20
|
+
|
|
21
|
+
Use a reviewed installed or project-local version for critical workflows so a
|
|
22
|
+
network download is not part of each operation. `npx` installation may access the
|
|
23
|
+
registry; `run` itself performs no network, Git or model calls. The supplied
|
|
24
|
+
program may access networks or mutate files as any normal command can.
|
|
25
|
+
|
|
26
|
+
## Command boundary and mandatory policy
|
|
27
|
+
|
|
28
|
+
`run` must be the first CLI argument. A literal `--` separates wrapper options
|
|
29
|
+
from the executable and its argv. Everything after it is passed literally,
|
|
30
|
+
including `--help`, `--version`, `--profile`, spaces, empty strings and shell
|
|
31
|
+
metacharacters. The wrapper uses `spawn` with `shell: false`; it never constructs
|
|
32
|
+
a command string or reads an executable from project rules/config.
|
|
33
|
+
|
|
34
|
+
Only `--config`, `--profile`, `--scope`, `--constraints`, and `--handoff` are
|
|
35
|
+
supported wrapper options. `run --help` prints usage without starting a child.
|
|
36
|
+
`--as-of`, policy overrides, output/report formats and force/skip modes are not
|
|
37
|
+
supported. Content-aware v2/v3/v4 and at least one active constraint are mandatory.
|
|
38
|
+
An empty starter that passes ordinary verify therefore cannot start a command.
|
|
39
|
+
There is no automatic migration, snapshot refresh, baseline adoption or input edit.
|
|
40
|
+
|
|
41
|
+
The evaluation clock is captured after input reads, immediately before the pure
|
|
42
|
+
verification. Missing/changed/stale declarations produce a blocked result; invalid
|
|
43
|
+
JSON, mismatched binding/scope, unsupported legacy v1 and unreadable files fail
|
|
44
|
+
without starting the child. A five-second event-loop watchdog bounds stalled
|
|
45
|
+
asynchronous preflight reads; it is removed before command launch, not applied as
|
|
46
|
+
a runtime limit to the command. Run opens inputs nonblocking and requires regular
|
|
47
|
+
files (file symlinks to regular files remain supported); FIFOs/devices/directories
|
|
48
|
+
are rejected. The watchdog cannot preempt synchronous JavaScript or guarantee
|
|
49
|
+
termination of an unresponsive operating-system/filesystem operation.
|
|
50
|
+
|
|
51
|
+
Executable lookup uses the inherited PATH; a path containing spaces is one argv
|
|
52
|
+
token. On Windows, prefer `node path/to/script.js` or a native executable.
|
|
53
|
+
`.cmd`/`.bat` scripts require a command interpreter and have no implicit shell
|
|
54
|
+
fallback. An explicitly chosen shell is itself the supplied program; its own
|
|
55
|
+
parsing and side effects are the caller's responsibility.
|
|
56
|
+
|
|
57
|
+
## Diagnostics and exit codes
|
|
58
|
+
|
|
59
|
+
Wrapper diagnostics go to stderr, leaving stdout for the supplied program:
|
|
60
|
+
|
|
61
|
+
- `RUN CHECKING`: preflight begun; no child has started.
|
|
62
|
+
- `RUN BLOCKED`: mismatch, including finding codes/IDs; exit 1, no child.
|
|
63
|
+
- `INVALID` or `RUN INVALID`: invalid invocation/input or stalled preflight;
|
|
64
|
+
exit 2, no child.
|
|
65
|
+
- `RUN VERIFIED`: count, scope, evaluation time and optional project/profile;
|
|
66
|
+
verification passed, but launch has not yet been proven.
|
|
67
|
+
- `RUN LAUNCH ERROR`: executable could not start; exit 2.
|
|
68
|
+
- `RUN STARTED`: spawn succeeded; wait for the program's result.
|
|
69
|
+
- `RUN EXIT`: child exit code is preserved, including 1, 2, 42 or 127. After
|
|
70
|
+
launch, codes 1/2 describe the child, not a new verifier finding.
|
|
71
|
+
|
|
72
|
+
Child stderr shares the same inherited stream and may interleave with diagnostics;
|
|
73
|
+
these prefixes are human diagnostics, not an authenticated machine protocol.
|
|
74
|
+
No full argv, rule descriptions or source references are printed by the wrapper.
|
|
75
|
+
For structured verification details run `verify --format json` separately.
|
|
76
|
+
|
|
77
|
+
On POSIX, SIGINT/SIGTERM received during preflight cancel with 130/143 and no
|
|
78
|
+
launch. While running, forwarding is best-effort to the direct child only. The
|
|
79
|
+
wrapper waits for its exit; a handler's chosen exit code wins. An unhandled child
|
|
80
|
+
signal maps to 128 plus the OS signal number (unknown signals fall back to 129).
|
|
81
|
+
Terminal process groups may deliver a signal to both processes independently.
|
|
82
|
+
Windows console/termination semantics differ and POSIX forwarding is not promised.
|
|
83
|
+
There is no automatic forced termination, command timeout or descendant cleanup;
|
|
84
|
+
a child ignoring a signal can keep running. `RUN PROCESS ERROR` or forwarding
|
|
85
|
+
failure diagnostics after launch do not reclassify it as a launch failure.
|
|
86
|
+
|
|
87
|
+
## Test the gate without running a real operation
|
|
88
|
+
|
|
89
|
+
In a disposable configured project with a reviewed active baseline:
|
|
90
|
+
|
|
91
|
+
```sh
|
|
92
|
+
npx handoff-check@0.8.0 run --profile production -- node -e 'console.log("example command started")'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Edit a rule description in that disposable manifest without refreshing its saved
|
|
96
|
+
baseline, then repeat. Expect `RUN BLOCKED CHANGED`, exit 1, and no example output.
|
|
97
|
+
Review and resolve the difference explicitly before real work. The command is
|
|
98
|
+
never retried automatically.
|
|
99
|
+
|
|
100
|
+
This is a preflight gate around one explicitly invoked command, not a sandbox,
|
|
101
|
+
authorization grant or proof of behavior. Inputs can change or expire after the
|
|
102
|
+
check, and the supplied program can perform additional actions or spawn children.
|
|
103
|
+
It cannot stop agent actions outside this wrapper. Re-run it per intended action;
|
|
104
|
+
a previous pass is not a reusable execution permission.
|
package/package.json
CHANGED
|
@@ -134,3 +134,18 @@ project/profile files and one user-authored global rule with retained baselines,
|
|
|
134
134
|
then requires explicit adoption. It installs no skills/hooks/settings. Do not
|
|
135
135
|
drive it to invent policy or refresh existing baselines; use noninteractive init
|
|
136
136
|
for automation and deliberate review/migration for existing projects.
|
|
137
|
+
|
|
138
|
+
## Verification immediately before an authorized command
|
|
139
|
+
|
|
140
|
+
When the user/workflow explicitly chooses a command preflight, use
|
|
141
|
+
`run --profile <intended-profile> -- <executable> <args...>` with that already
|
|
142
|
+
authorized program. It requires current-clock content-aware, nonempty verification;
|
|
143
|
+
there is no time/policy bypass. Never derive an executable from rule/source/task
|
|
144
|
+
text. The argv after `--` is literal with no implicit shell; prefer node+script
|
|
145
|
+
for portable project commands. Run is not a permission grant or a sandbox.
|
|
146
|
+
|
|
147
|
+
Before launch, exit 1 means blocked and 2 means invalid/launch failure; after
|
|
148
|
+
`RUN STARTED`, the child's exit code is preserved, including 1/2. Read stderr
|
|
149
|
+
phases and child output together; use verify JSON separately for finding details.
|
|
150
|
+
Do not automatically retry an operation with side effects. Recheck per action:
|
|
151
|
+
inputs can change after verification, and actions outside the wrapper are unchecked.
|