@verax-ai/body 0.8.1 → 0.9.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/README.md +2 -2
- package/dist/anchor-cli.d.ts +48 -3
- package/dist/anchor-cli.js +256 -17
- package/dist/approval-signature.js +3 -3
- package/dist/auth.d.ts +14 -1
- package/dist/auth.js +25 -4
- package/dist/cli.js +77 -3
- package/dist/control-signature.js +1 -1
- package/dist/doctor.js +13 -1
- package/dist/halt.d.ts +2 -0
- package/dist/halt.js +57 -1
- package/dist/install.js +1 -1
- package/dist/reconcile-cli.js +1 -1
- package/dist/report-cli.d.ts +163 -0
- package/dist/report-cli.js +1101 -0
- package/dist/server.js +5 -1
- package/dist/verify-cli.d.ts +40 -0
- package/dist/verify-cli.js +161 -59
- package/dist/watch.js +14 -9
- package/dist/webauthn-verify.d.ts +3 -1
- package/dist/webauthn-verify.js +97 -4
- package/dist/witness.d.ts +16 -5
- package/dist/witness.js +67 -8
- package/package.json +9 -9
package/dist/cli.js
CHANGED
|
@@ -13,10 +13,11 @@ import { runDownstreamPin } from "./downstream-pin.js";
|
|
|
13
13
|
import { clearVeraxEnv, envFileJwksMissing, loadEnvFile, runInitLocal } from "./init-local.js";
|
|
14
14
|
import { clearCliCodeCheckPassed, defaultElevated, directoryAccess, doctorStateTarget, elevatedCommandCodeRefusal, linuxNodeLabelCheck, linuxSelinuxCheck, liveInstalledChecks, markCliCodeCheckPassed, runInstall, runUninstall, SystemToolError, unreadableSentence } from "./install.js";
|
|
15
15
|
import { runHalt, runResume } from "./halt.js";
|
|
16
|
-
import {
|
|
16
|
+
import { main } from "./main.js";
|
|
17
17
|
import { runOperator } from "./operator-cli.js";
|
|
18
18
|
import { runAnchor } from "./anchor-cli.js";
|
|
19
19
|
import { runReconcile } from "./reconcile-cli.js";
|
|
20
|
+
import { runReport } from "./report-cli.js";
|
|
20
21
|
import { runVerify } from "./verify-cli.js";
|
|
21
22
|
import { clearStaleLockAtStart, runUnlock } from "./unlock.js";
|
|
22
23
|
import { runWitness } from "./witness.js";
|
|
@@ -62,6 +63,9 @@ Usage: verax <command> [options]
|
|
|
62
63
|
reconcile <args> compare the ledger against a statement
|
|
63
64
|
verify <stateDir> read a ledger back without a body: signatures, chain,
|
|
64
65
|
effect binding, which key answered, and approval signatures
|
|
66
|
+
report <stateDir> --from <YYYY-MM-DD> --to <YYYY-MM-DD> [--out <file.html>] [--json]
|
|
67
|
+
period counts from the ledger offline: decisions, approvals,
|
|
68
|
+
checkpoints, and the same verification verdict as verify
|
|
65
69
|
anchor <stateDir> --service <url>
|
|
66
70
|
register each checkpoint's hash with a transparency service
|
|
67
71
|
someone else runs and keep its receipt for verify --anchor-key
|
|
@@ -87,6 +91,35 @@ VERAX_STATE_DIR and VERAX_POLICY_FILE; \`verax doctor\` names what is missing.
|
|
|
87
91
|
Records stay on this machine, under VERAX_STATE_DIR.
|
|
88
92
|
`;
|
|
89
93
|
const version = bodyVersion;
|
|
94
|
+
/**
|
|
95
|
+
* Left to run, these read a help flag as a path or as an argument: `verax
|
|
96
|
+
* witness --help` started a witness in a new directory named `--help`. verify,
|
|
97
|
+
* report, anchor and watch print their own usage.
|
|
98
|
+
*/
|
|
99
|
+
const ANSWERED_BY_HELP = new Set([
|
|
100
|
+
"approve",
|
|
101
|
+
"demo",
|
|
102
|
+
"desktop",
|
|
103
|
+
"doctor",
|
|
104
|
+
"downstream",
|
|
105
|
+
"halt",
|
|
106
|
+
"init",
|
|
107
|
+
"install",
|
|
108
|
+
"memory",
|
|
109
|
+
"operator",
|
|
110
|
+
"reconcile",
|
|
111
|
+
"resume",
|
|
112
|
+
"serve",
|
|
113
|
+
"uninstall",
|
|
114
|
+
"unlock",
|
|
115
|
+
"witness",
|
|
116
|
+
]);
|
|
117
|
+
function refusedAsOption(arg, stderr) {
|
|
118
|
+
if (!arg.startsWith("-"))
|
|
119
|
+
return false;
|
|
120
|
+
stderr.write(`unknown option: ${terminalText(arg)}\n`);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
90
123
|
function isCliEntry() {
|
|
91
124
|
const entry = process.argv[1];
|
|
92
125
|
if (!entry)
|
|
@@ -115,6 +148,10 @@ export async function runCli(argv, hooks = {}) {
|
|
|
115
148
|
stdout.write(HELP);
|
|
116
149
|
return 0;
|
|
117
150
|
}
|
|
151
|
+
if (ANSWERED_BY_HELP.has(argv[0] ?? "") && (argv.includes("--help") || argv.includes("-h"))) {
|
|
152
|
+
stdout.write(HELP);
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
118
155
|
if (argv[0] === "--version" || argv[0] === "-v") {
|
|
119
156
|
stdout.write(`${version()}\n`);
|
|
120
157
|
return 0;
|
|
@@ -210,6 +247,8 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
210
247
|
stderr.write("verax halt <stateDir>\n");
|
|
211
248
|
return 78;
|
|
212
249
|
}
|
|
250
|
+
if (refusedAsOption(stateDir, stderr))
|
|
251
|
+
return 64;
|
|
213
252
|
return runHalt(stateDir, (s) => stderr.write(s));
|
|
214
253
|
}
|
|
215
254
|
if (argv[0] === "watch") {
|
|
@@ -231,6 +270,8 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
231
270
|
stderr.write("verax resume <stateDir>\n");
|
|
232
271
|
return 78;
|
|
233
272
|
}
|
|
273
|
+
if (refusedAsOption(stateDir, stderr))
|
|
274
|
+
return 64;
|
|
234
275
|
return runResume(stateDir, (s) => stderr.write(s));
|
|
235
276
|
}
|
|
236
277
|
if (argv[0] === "unlock") {
|
|
@@ -240,6 +281,8 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
240
281
|
stderr.write("verax unlock [--force] <stateDir>\n");
|
|
241
282
|
return 78;
|
|
242
283
|
}
|
|
284
|
+
if (refusedAsOption(stateDir, stderr))
|
|
285
|
+
return 64;
|
|
243
286
|
return runUnlock(stateDir, (s) => stderr.write(s), { force });
|
|
244
287
|
}
|
|
245
288
|
if (argv[0] === "init") {
|
|
@@ -327,6 +370,9 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
327
370
|
if (argv[0] === "verify") {
|
|
328
371
|
return runVerify(argv.slice(1), (s) => stdout.write(`${s}\n`));
|
|
329
372
|
}
|
|
373
|
+
if (argv[0] === "report") {
|
|
374
|
+
return runReport(argv.slice(1), (s) => stdout.write(`${s}\n`));
|
|
375
|
+
}
|
|
330
376
|
if (argv[0] === "anchor") {
|
|
331
377
|
return runAnchor(argv.slice(1), (s) => stdout.write(`${s}\n`));
|
|
332
378
|
}
|
|
@@ -343,6 +389,8 @@ async function dispatchCli(argv, stdout, stderr, env) {
|
|
|
343
389
|
stderr.write("verax witness <stateDir>\n");
|
|
344
390
|
return 78;
|
|
345
391
|
}
|
|
392
|
+
if (refusedAsOption(stateDir, stderr))
|
|
393
|
+
return 64;
|
|
346
394
|
await runWitness(stateDir);
|
|
347
395
|
return 0;
|
|
348
396
|
}
|
|
@@ -448,13 +496,39 @@ export function uncaughtText(err) {
|
|
|
448
496
|
}
|
|
449
497
|
return `${lines.join("\n")}\n`;
|
|
450
498
|
}
|
|
499
|
+
/**
|
|
500
|
+
* process.exit cuts a pipe after ~146 KB on Linux and macOS when stdout still
|
|
501
|
+
* holds buffered writes. Wait for stdout and stderr to flush, then end with
|
|
502
|
+
* the same code. Long-running commands (serve, watch) never return here.
|
|
503
|
+
*/
|
|
504
|
+
function drainStdioStream(stream) {
|
|
505
|
+
return new Promise((resolve) => {
|
|
506
|
+
if (!stream.writable) {
|
|
507
|
+
resolve();
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
try {
|
|
511
|
+
stream.write("", (err) => {
|
|
512
|
+
void err;
|
|
513
|
+
resolve();
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
catch {
|
|
517
|
+
resolve();
|
|
518
|
+
}
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
async function exitAfterStdioDrain(code) {
|
|
522
|
+
await Promise.all([drainStdioStream(process.stdout), drainStdioStream(process.stderr)]);
|
|
523
|
+
process.exit(code);
|
|
524
|
+
}
|
|
451
525
|
if (isCliEntry()) {
|
|
452
526
|
try {
|
|
453
|
-
|
|
527
|
+
await exitAfterStdioDrain(await runCli(process.argv.slice(2)));
|
|
454
528
|
}
|
|
455
529
|
catch (err) {
|
|
456
530
|
// Replaces Node's printer, which would write the path raw and a source excerpt.
|
|
457
531
|
process.stderr.write(terminalLines(uncaughtText(err)));
|
|
458
|
-
|
|
532
|
+
await exitAfterStdioDrain(1);
|
|
459
533
|
}
|
|
460
534
|
}
|
|
@@ -204,7 +204,7 @@ export async function verifyControlSignatures(stateDir, opts = {}) {
|
|
|
204
204
|
cli,
|
|
205
205
|
file,
|
|
206
206
|
integrity,
|
|
207
|
-
line: `control signatures signed-verified ${signedVerified}
|
|
207
|
+
line: `control signatures signed-verified ${signedVerified} | signed-failed ${signedFailed} | unsigned-http ${unsignedHttp} | cli ${cli} | file ${file} | integrity ${integrity}${signedAfterRemovalSegment(signedAfterRemoval)}`,
|
|
208
208
|
trustSource: trust.trustSource,
|
|
209
209
|
trustNote: trust.trustNote,
|
|
210
210
|
};
|
package/dist/doctor.js
CHANGED
|
@@ -5,6 +5,7 @@ import { defaultElevated, readWindowsMachineRoots, SystemToolError, windowsAgent
|
|
|
5
5
|
import { readLogTail } from "./body-log.js";
|
|
6
6
|
import { indexCoverage, listPieceFiles } from "@verax-ai/proxy";
|
|
7
7
|
import { loadConfig, isLoopbackHost } from "./config.js";
|
|
8
|
+
import { resourceMetadataUrl } from "./auth.js";
|
|
8
9
|
import { parseDownstreamDocument } from "./downstream.js";
|
|
9
10
|
import { lockHolderAlive, lockState } from "@verax-ai/proxy";
|
|
10
11
|
import { readLockFile } from "./unlock.js";
|
|
@@ -36,6 +37,17 @@ export function runDoctor(env, argv, opts = {}) {
|
|
|
36
37
|
: "VERAX_ISSUER, VERAX_JWKS_URL, and VERAX_AUDIENCE are set"
|
|
37
38
|
: "one of VERAX_ISSUER, VERAX_JWKS_URL, VERAX_AUDIENCE is missing",
|
|
38
39
|
});
|
|
40
|
+
const audienceValue = env.VERAX_AUDIENCE?.trim() ?? "";
|
|
41
|
+
if (audienceValue !== "") {
|
|
42
|
+
const audienceIsUrl = resourceMetadataUrl(audienceValue) !== null;
|
|
43
|
+
checks.push({
|
|
44
|
+
id: "audience-url",
|
|
45
|
+
level: audienceIsUrl ? "ok" : "warn",
|
|
46
|
+
detail: audienceIsUrl
|
|
47
|
+
? "VERAX_AUDIENCE is an http(s) URL"
|
|
48
|
+
: "VERAX_AUDIENCE is not an http(s) URL: a 401 names no resource metadata, so an MCP client cannot discover the issuer",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
39
51
|
const loaded = loadConfig({
|
|
40
52
|
...env,
|
|
41
53
|
VERAX_STATE_DIR: env.VERAX_STATE_DIR || "placeholder",
|
|
@@ -201,7 +213,7 @@ export function runDoctor(env, argv, opts = {}) {
|
|
|
201
213
|
checks.push({
|
|
202
214
|
id: "panel-issuer",
|
|
203
215
|
level: "warn",
|
|
204
|
-
detail: `panel last-resort issuer ${panelIssuer} differs from VERAX_ISSUER ${configuredIssuer}; the session reads authorization_servers from resource metadata
|
|
216
|
+
detail: `panel last-resort issuer ${panelIssuer} differs from VERAX_ISSUER ${configuredIssuer}; the session reads authorization_servers from resource metadata; if that document is unreachable the panel will not start`,
|
|
205
217
|
});
|
|
206
218
|
}
|
|
207
219
|
const tokenScope = scopeFromDevToken(env.VERAX_DEV_TOKEN);
|
package/dist/halt.d.ts
CHANGED
|
@@ -41,6 +41,8 @@ export type HaltState = {
|
|
|
41
41
|
halted: boolean;
|
|
42
42
|
since?: HaltEvent;
|
|
43
43
|
};
|
|
44
|
+
/** The same check for `verax watch`, which halts on its own: the refusal to print, or null. */
|
|
45
|
+
export declare function notStateDir(stateDir: string): string | null;
|
|
44
46
|
/** The switch is an empty file. A folder at the path is a blocked write, not a halt. */
|
|
45
47
|
export declare function isHaltSwitchFile(stateDir: string): boolean;
|
|
46
48
|
/**
|
package/dist/halt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
2
|
+
import { closeSync, fsyncSync, mkdirSync, openSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
3
3
|
import { userInfo } from "node:os";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { canonical } from "@cedulon/core";
|
|
@@ -12,6 +12,50 @@ function oneLine(err) {
|
|
|
12
12
|
const text = err instanceof Error ? err.message : String(err);
|
|
13
13
|
return text.replace(/[\r\n]+/g, " ").slice(0, 300);
|
|
14
14
|
}
|
|
15
|
+
const STATE_DIR_ENTRIES = new Set([
|
|
16
|
+
"decisions.jsonl",
|
|
17
|
+
"effects.jsonl",
|
|
18
|
+
"starts.jsonl",
|
|
19
|
+
"heartbeat.json",
|
|
20
|
+
"ledger.lock",
|
|
21
|
+
"keys",
|
|
22
|
+
"policy.json",
|
|
23
|
+
"verax.env",
|
|
24
|
+
SWITCH,
|
|
25
|
+
HISTORY,
|
|
26
|
+
]);
|
|
27
|
+
/**
|
|
28
|
+
* An operator types this path by hand, and a body only reads the switch in its
|
|
29
|
+
* own state directory. Writing the switch anywhere else would answer `halted`
|
|
30
|
+
* while the running body keeps allowing calls. An empty directory stays
|
|
31
|
+
* allowed, since a body started on it reads the switch. A directory this
|
|
32
|
+
* process may not list is left to the write that follows, which names the
|
|
33
|
+
* permission error.
|
|
34
|
+
*/
|
|
35
|
+
function checkStateDir(stateDir) {
|
|
36
|
+
let entries;
|
|
37
|
+
try {
|
|
38
|
+
entries = readdirSync(stateDir);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
const code = err.code;
|
|
42
|
+
if (code === "ENOENT")
|
|
43
|
+
return { problem: "no such directory" };
|
|
44
|
+
if (code === "ENOTDIR")
|
|
45
|
+
return { problem: "not a directory" };
|
|
46
|
+
return { empty: false };
|
|
47
|
+
}
|
|
48
|
+
if (entries.length === 0)
|
|
49
|
+
return { empty: true };
|
|
50
|
+
return entries.some((name) => STATE_DIR_ENTRIES.has(name))
|
|
51
|
+
? { empty: false }
|
|
52
|
+
: { problem: "no ledger files there" };
|
|
53
|
+
}
|
|
54
|
+
/** The same check for `verax watch`, which halts on its own: the refusal to print, or null. */
|
|
55
|
+
export function notStateDir(stateDir) {
|
|
56
|
+
const checked = checkStateDir(stateDir);
|
|
57
|
+
return "problem" in checked ? `not-a-state-dir: ${oneLine(stateDir)}: ${checked.problem}; nothing was halted` : null;
|
|
58
|
+
}
|
|
15
59
|
/** The switch is an empty file. A folder at the path is a blocked write, not a halt. */
|
|
16
60
|
export function isHaltSwitchFile(stateDir) {
|
|
17
61
|
try {
|
|
@@ -185,6 +229,11 @@ export function runHalt(stateDir, writeErr = (s) => process.stderr.write(s)) {
|
|
|
185
229
|
writeErr("verax halt <stateDir>\n");
|
|
186
230
|
return 78;
|
|
187
231
|
}
|
|
232
|
+
const checked = checkStateDir(stateDir);
|
|
233
|
+
if ("problem" in checked) {
|
|
234
|
+
writeErr(`halt-failed: not-a-state-dir: ${oneLine(stateDir)}: ${checked.problem}; nothing was halted\n`);
|
|
235
|
+
return 1;
|
|
236
|
+
}
|
|
188
237
|
try {
|
|
189
238
|
haltBody(stateDir, cliUser(), "cli");
|
|
190
239
|
}
|
|
@@ -197,6 +246,8 @@ export function runHalt(stateDir, writeErr = (s) => process.stderr.write(s)) {
|
|
|
197
246
|
return 1;
|
|
198
247
|
}
|
|
199
248
|
writeErr("halted\n");
|
|
249
|
+
if (checked.empty)
|
|
250
|
+
writeErr("note: this directory was empty; no body has written here yet\n");
|
|
200
251
|
return 0;
|
|
201
252
|
}
|
|
202
253
|
export function runResume(stateDir, writeErr = (s) => process.stderr.write(s)) {
|
|
@@ -204,6 +255,11 @@ export function runResume(stateDir, writeErr = (s) => process.stderr.write(s)) {
|
|
|
204
255
|
writeErr("verax resume <stateDir>\n");
|
|
205
256
|
return 78;
|
|
206
257
|
}
|
|
258
|
+
const checked = checkStateDir(stateDir);
|
|
259
|
+
if ("problem" in checked) {
|
|
260
|
+
writeErr(`resume-failed: not-a-state-dir: ${oneLine(stateDir)}: ${checked.problem}; nothing was resumed\n`);
|
|
261
|
+
return 1;
|
|
262
|
+
}
|
|
207
263
|
if (isSwitchPathBlocked(stateDir)) {
|
|
208
264
|
writeErr("resume-failed: switch-path-blocked; a running body may hold the halt in memory; clear the path and use POST /api/resume\n");
|
|
209
265
|
return 1;
|
package/dist/install.js
CHANGED
|
@@ -3292,7 +3292,7 @@ async function waitHealth(port, timeoutMs, io, nonce) {
|
|
|
3292
3292
|
return true;
|
|
3293
3293
|
const elapsed = Date.now() - start;
|
|
3294
3294
|
while (elapsed >= nextMark && nextMark < timeoutMs) {
|
|
3295
|
-
io.stderr.write(`waiting for the body (${nextMark / 1000} s)
|
|
3295
|
+
io.stderr.write(`waiting for the body (${nextMark / 1000} s)...\n`);
|
|
3296
3296
|
nextMark += 10_000;
|
|
3297
3297
|
}
|
|
3298
3298
|
const left = timeoutMs - (Date.now() - start);
|
package/dist/reconcile-cli.js
CHANGED
|
@@ -242,7 +242,7 @@ export function runReconcile(argv, writeErr = (s) => process.stderr.write(s)) {
|
|
|
242
242
|
if (parsed.channel === "card") {
|
|
243
243
|
const mismatch = report.ghost.filter((g) => g.reason === "amount-mismatch").length;
|
|
244
244
|
const unknown = report.ghost.filter((g) => g.reason === "amount-unknown").length;
|
|
245
|
-
writeErr(`matched ${report.matched.length}
|
|
245
|
+
writeErr(`matched ${report.matched.length} | ghost ${report.ghost.length} | authorizedUnpaid ${report.authorizedUnpaid.length} | mismatch ${mismatch} | unknown ${unknown}\n`);
|
|
246
246
|
}
|
|
247
247
|
return 0;
|
|
248
248
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { type SignedCheckpoint } from "@cedulon/checkpoint";
|
|
2
|
+
import { type SignedDecisionRecord } from "@cedulon/core";
|
|
3
|
+
export declare const EX_USAGE = 64;
|
|
4
|
+
/** Same code `verax verify` uses for an unreadable state directory. */
|
|
5
|
+
export declare const EX_STATE_UNREADABLE = 77;
|
|
6
|
+
type DecisionCounts = {
|
|
7
|
+
allow: number;
|
|
8
|
+
deny: number;
|
|
9
|
+
defer: number;
|
|
10
|
+
};
|
|
11
|
+
export type ApprovalCounts = {
|
|
12
|
+
approved: number;
|
|
13
|
+
withOperatorSignatureFieldPresent: number;
|
|
14
|
+
withoutOperatorSignatureField: number;
|
|
15
|
+
closedWithoutAllow: number;
|
|
16
|
+
/**
|
|
17
|
+
* Defers with no hash-bound answer. Established as a fact only when no held
|
|
18
|
+
* defer could be answered by an unbound record after it; otherwise null
|
|
19
|
+
* (see heldWithoutBoundAnswer / heldPossiblyAnsweredByUnbound).
|
|
20
|
+
*/
|
|
21
|
+
stillHeld: number | null;
|
|
22
|
+
unmatched: number;
|
|
23
|
+
/** Allow/deny records in the window whose inputs are not hash-bound. */
|
|
24
|
+
terminalsWithoutBoundInputs: number;
|
|
25
|
+
/** Defers with no hash-bound answer (raw open count; always computed). */
|
|
26
|
+
heldWithoutBoundAnswer: number;
|
|
27
|
+
/**
|
|
28
|
+
* Of those held without a bound answer, how many an unbound terminal's
|
|
29
|
+
* inputs row names with matching request hash and tool.
|
|
30
|
+
*/
|
|
31
|
+
heldPossiblyAnsweredByUnbound: number;
|
|
32
|
+
};
|
|
33
|
+
export type PeriodReport = {
|
|
34
|
+
from: string;
|
|
35
|
+
to: string;
|
|
36
|
+
/** Head of the whole verified ledger. Null when the ledger does not verify. */
|
|
37
|
+
headHash: string | null;
|
|
38
|
+
/** Records in the window. Null when the ledger does not verify. */
|
|
39
|
+
recordCount: number | null;
|
|
40
|
+
firstRecordMs: number | null;
|
|
41
|
+
lastRecordMs: number | null;
|
|
42
|
+
verification: {
|
|
43
|
+
ok: boolean;
|
|
44
|
+
verdict: string;
|
|
45
|
+
problems: string[];
|
|
46
|
+
};
|
|
47
|
+
/** Why every count is null, or null when counts are available. */
|
|
48
|
+
countsUnavailableReason: string | null;
|
|
49
|
+
/** Set when approvals.jsonl is malformed. Never affects verdict or counts. */
|
|
50
|
+
unsignedApprovalsNote: string | null;
|
|
51
|
+
decisions: {
|
|
52
|
+
total: DecisionCounts | null;
|
|
53
|
+
byTool: {
|
|
54
|
+
[tool: string]: DecisionCounts;
|
|
55
|
+
} | null;
|
|
56
|
+
/**
|
|
57
|
+
* Records whose subject is empty or not a string. Null when counts are
|
|
58
|
+
* unavailable. Identity: for each kind, sum(byTool[*][kind]) +
|
|
59
|
+
* withoutSubject[kind] === total[kind].
|
|
60
|
+
*/
|
|
61
|
+
withoutSubject: DecisionCounts | null;
|
|
62
|
+
};
|
|
63
|
+
approvals: {
|
|
64
|
+
approved: number | null;
|
|
65
|
+
/** Approving records whose hash-bound inputs carry an approver signature field. Not a verification. */
|
|
66
|
+
withOperatorSignatureFieldPresent: number | null;
|
|
67
|
+
withoutOperatorSignatureField: number | null;
|
|
68
|
+
closedWithoutAllow: number | null;
|
|
69
|
+
stillHeld: number | null;
|
|
70
|
+
unmatched: number | null;
|
|
71
|
+
/** Allow/deny in the window with no hash-bound inputs. Null when counts unavailable. */
|
|
72
|
+
terminalsWithoutBoundInputs: number | null;
|
|
73
|
+
/** Defers with no hash-bound answer. Null when counts unavailable. */
|
|
74
|
+
heldWithoutBoundAnswer: number | null;
|
|
75
|
+
/** Held defers an unbound terminal's inputs row could answer. Null when counts unavailable. */
|
|
76
|
+
heldPossiblyAnsweredByUnbound: number | null;
|
|
77
|
+
/** Class only, when approvals could not be counted although the ledger verified. */
|
|
78
|
+
unavailableReason: string | null;
|
|
79
|
+
};
|
|
80
|
+
checkpoints: {
|
|
81
|
+
count: number | null;
|
|
82
|
+
/** Anchor receipts for window checkpoints that verified. Zero when anchors were not checked. */
|
|
83
|
+
withAnchorVerified: number | null;
|
|
84
|
+
/** Anchor rows for window checkpoints present but not checked (no anchor key). */
|
|
85
|
+
anchorRowsPresentNotChecked: number | null;
|
|
86
|
+
/** Class only, when anchors could not be read although the ledger verified. */
|
|
87
|
+
anchorUnavailableReason: string | null;
|
|
88
|
+
};
|
|
89
|
+
whatThisReportDoesNotShow: string;
|
|
90
|
+
};
|
|
91
|
+
/** UTC midnight for a calendar date, or null when the string is not YYYY-MM-DD. */
|
|
92
|
+
export declare function parseReportDate(raw: string): number | null;
|
|
93
|
+
/**
|
|
94
|
+
* Usable per-tool subject, or null when empty or not a string. Null subjects
|
|
95
|
+
* are counted in `withoutSubject`, not under a synthetic byTool key, so a
|
|
96
|
+
* real tool named U+001F cannot collide with the empty/missing bucket.
|
|
97
|
+
*/
|
|
98
|
+
export declare function subjectToolKey(subject: unknown): string | null;
|
|
99
|
+
/**
|
|
100
|
+
* Stable class for a verify problem line: the longest known class prefix
|
|
101
|
+
* followed by a space, a colon, or the end. Ledger detail after that prefix
|
|
102
|
+
* is dropped. Anything that is not a known class is `unclassified`.
|
|
103
|
+
*/
|
|
104
|
+
export declare function problemClass(problem: string): string;
|
|
105
|
+
/** Decision records in chain order, using the same piece listing verify's helpers use. */
|
|
106
|
+
export declare function readDecisionRecords(dir: string): SignedDecisionRecord[];
|
|
107
|
+
/**
|
|
108
|
+
* Cedulon/verify coverage is half-open `[startMs, endMs)` (see verify-ledger:
|
|
109
|
+
* `r.claims.timestampMs >= startMs && r.claims.timestampMs < endMs`). Overlap
|
|
110
|
+
* with the report window `[fromMs, toExclusive)` is therefore
|
|
111
|
+
* `start < toExclusive && fromMs < end`. A checkpoint with `start >= end`
|
|
112
|
+
* covers nothing and is never counted.
|
|
113
|
+
*/
|
|
114
|
+
export declare function checkpointInWindow(row: SignedCheckpoint, fromMs: number, toExclusive: number): boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Held-call counts from attested records only, in chain order.
|
|
117
|
+
*
|
|
118
|
+
* A defer is answered by the first terminal (allow or deny) record that
|
|
119
|
+
* follows it in chain order, whose hash-bound inputs name the defer's ref in
|
|
120
|
+
* `approver.resolves`, and that agrees with the defer on request hash and
|
|
121
|
+
* tool. A record whose decision is defer is never an answer. One answer
|
|
122
|
+
* answers one defer: each answer names at most one resolves ref, and a ref
|
|
123
|
+
* shared by two defers is unmatched, so no shared-consumption set is needed.
|
|
124
|
+
* A defer with no usable ref, a ref shared with another defer, or only
|
|
125
|
+
* disagreeing answers is unmatched.
|
|
126
|
+
*
|
|
127
|
+
* Identity (when counts are available):
|
|
128
|
+
* approved + closedWithoutAllow + unmatched + heldWithoutBoundAnswer
|
|
129
|
+
* === windowDeferCount
|
|
130
|
+
* Bound answers and unbound possibility both scan every later terminal in
|
|
131
|
+
* chain order, inside the window or not. stillHeld is heldWithoutBoundAnswer
|
|
132
|
+
* when no held defer could be answered by an unbound record after it
|
|
133
|
+
* (heldPossiblyAnsweredByUnbound === 0); otherwise null. terminalsWithoutBoundInputs
|
|
134
|
+
* still counts only unbound terminals whose time falls in the window.
|
|
135
|
+
* heldPossiblyAnsweredByUnbound never exceeds heldWithoutBoundAnswer.
|
|
136
|
+
*/
|
|
137
|
+
export declare function countApprovalsFromSigned(dir: string, all: readonly SignedDecisionRecord[], fromMs: number, toExclusive: number): ApprovalCounts;
|
|
138
|
+
/**
|
|
139
|
+
* Temp file with a random name, exclusive create, then a hard link to the
|
|
140
|
+
* final name: the link fails with EEXIST if the target exists, so an existing
|
|
141
|
+
* file is never replaced. The temp name is removed on every path.
|
|
142
|
+
* `tempPath` is for tests that plant a collision at a known name; the CLI
|
|
143
|
+
* never passes it.
|
|
144
|
+
*/
|
|
145
|
+
export declare function writeOutExclusive(outPath: string, content: string, tempPath?: string): void;
|
|
146
|
+
export declare function buildPeriodReport(dir: string, from: string, to: string, fromMs: number, toExclusive: number): Promise<PeriodReport>;
|
|
147
|
+
/**
|
|
148
|
+
* Fixed key order. The same ledger and window give the same bytes. These are
|
|
149
|
+
* the one canonical display-safe bytes: terminal-control and bidi characters
|
|
150
|
+
* are escaped here, before any digest, so stdout, the digest and the digest
|
|
151
|
+
* shown in HTML are all of this exact sequence.
|
|
152
|
+
*/
|
|
153
|
+
export declare function serializePeriodReport(report: PeriodReport): string;
|
|
154
|
+
export declare function reportDigest(jsonBytes: string): string;
|
|
155
|
+
export declare function htmlEscape(text: string): string;
|
|
156
|
+
export declare function renderReportHtml(report: PeriodReport, digest: string): string;
|
|
157
|
+
export declare function renderReportText(report: PeriodReport, digest: string): string;
|
|
158
|
+
export declare function runReport(argv: readonly string[], out?: (s: string) => void,
|
|
159
|
+
/** Test-only: force the exclusive-create temp path. Not a CLI flag. */
|
|
160
|
+
opts?: {
|
|
161
|
+
writeTempPath?: string;
|
|
162
|
+
}): Promise<number>;
|
|
163
|
+
export {};
|