The shared tokenizer accepts `ms` for the simulation windows, and without a
per-caller unit set that grammar leaked into --expire: `--expire 500ms` was
a usage error before the parsers were unified and became silently rounded to
a 1h / 1s link after.
tokenizeDuration now takes an allowed-unit set; the expire flags pass
EXPIRE_UNITS (d/h/m/s) while parseDurationMs keeps the full set. Adds a
regression test asserting sub-second input stays exit 2 on both flags.
Two findings from reviewing the outbound-push extraction:
The verify poll compared `record.sourceDocumentSN === sn` with `sn` optional,
so a caller that only knows the flowId compared against `undefined` and
matched any record lacking an SN — reporting an unrelated run as the one this
push created, with its id and taskMode in the response. Guard the needle:
an absent SN matches nothing. This class did not exist on the deploy path
before (it compared against flowId only), so it was introduced by the merge.
The replay help text also never listed --sign-key even though the channel
resolves the target integration through it, and selectHoseIntegration now
errors on an ambiguous list with "请通过 --sign-key 指定" — pointing at a
flag the user could not discover from `help approval-runs`.
Adds direct tests for replay-safety.ts (the exit-14 wording, the next action,
and that --force is the only override), which previously had none.
The two --expire flags each carried a byte-identical copy of the same regex
and unit-conversion switch, and a third parser (parseDurationMs) lived in
capabilities/helpers.ts with yet another regex. Because the copies were
independent, --expire 300 could be read differently on each path without
anyone noticing.
core/duration.ts now owns the grammar (tokenizeDuration) and the unitless
heuristic (expireSeconds: a bare number <= 168 reads as hours, larger as
seconds). Each flag keeps only what genuinely differs: Seal delegation links
floor to whole hours and cap at 168h, Hose links round to seconds, simulation
windows are milliseconds and fall back instead of failing the batch.
Adds a cross-flag regression test asserting both --expire parsers read the
same literal the same way.
The deploy capability and the cross-tenant replay each carried their own
copy of the same outbound pipeline: integration selection, the assisted-only
gate, payload/URL construction, and push-then-verify. A change to the wire
contract could drift into one path and not the other.
Move the shared parts into domains/seal/outbound-push.ts and return the raw
CloseAPI messageLog query to the hose domain (domains/hose/close/outbound.ts),
leaving only the replay-specific log matching on the seal side. The
production-target guard is now one implementation (replay-safety.ts) shared
by the corp-pair resolver and the channel validator; both call sites are
kept deliberately as defense in depth.
Behavior note: replay used to silently pick the first integration when the
target had several and no --sign-key was given. It now errors and lists the
available signKeys, matching what deploy already did — pushing a message to
the wrong outbound channel should not depend on array order.
The report previously could not compute human accuracy because upstream only
says whether AI and human agree, never who was right. This adds an append-only
local store so a reviewer judges each (typically diverged) document across
weekly passes, and report monthly folds those judgments back in.
- review-store.ts: JSONL per tenant+month (~/.config/seal-use/reviews/
<corpId>-<YYYY-MM>.jsonl), append-only (weekly passes never rewrite), one
record per SN; last write wins on re-adjudication. Verdicts: ai_correct,
human_correct, both_correct, both_wrong, undecided. Env-overridable root
(SEAL_USE_REVIEWS_DIR) for tests; corrupt lines skipped.
- collect.ts: load the store, join verdicts onto fetched blocks, compute
humanAccuracy = (human_right / reviewed) * 100 over adjudicated samples,
expose reviewedCount/divergedCount, and flip humanAccuracyAvailable. No
reviews -> honest gap (still unavailable), never fabricated.
- render.ts: when available, fill the §1.2 human row with real accuracy and
replace the gap warning with a coverage note; when not, keep the warning.
- CLI: `report review set/list --month ... [--sn --verdict --note
--reviewed-by]` (set writes local store, list reads it). Help registers
both as separate commands; read-only list vs mutating set classified
accordingly. Prefix help (`report review --help`) now lists subcommands
instead of erroring.
- parser: register --template/--report-id/--max-runs/--verdict/--reviewed-by
(the first three were previously rejected as unknown, breaking report
monthly's own flags); reviewed-by moves to VALUE_FLAGS so it consumes its
argument.
- SKILL.md: document the adjudication workflow and storage semantics.
Verified: 639 tests (6 new review tests incl. tenant/month isolation, corrupt
line skip, join + accuracy math, honest no-review gap, render coverage note),
tsc clean, oxlint 0 warnings.
Eats in the ai-audit-report-template as a module. The template is the mutable
skin: describeTemplate() infers per-section data demands from ##/### headings
(keyword rules), so editing/renaming/reordering sections does not require
touching collect or render code.
- src/domains/seal/reports/: describe (heading to demand), collect (performance/
risk blocks/template groups, fetched only for declared demands), render (fills
tables by section+column signature, rewrites narrative by structure not line
number), monthly (orchestrator returning content + per-section completeness +
notes).
- report-templates/: the template body, assets, example, and downstream
validate.py/render.py (not bundled; next.validate/render in the result point
at them).
- Capability sealReportMonthlyGet (read-only, allow-listed) + CLI
"seal-use report monthly --month <YYYY-MM>" + help + KNOWN_FLAGS month +
read-only report:monthly.
- SKILL.md: routing row + a section stating the two hard rules: the template is
swappable, and metrics with no upstream source keep template sample values
with a warning note instead of fabricated numbers.
Template-path resolution branches on isCompiledBinary() (dev: module-relative to
repo root; compiled: cwd), matching how rules lint --file resolves paths, since
templates are not embedded.
Verified: bun test 633 pass (6 new reports tests), tsc clean, oxlint 0 warnings.
Live smoke: 2026-08 report for a real corp fills real accuracy/counts/distribution
and marks human-accuracy + mismatch-classification + section-6 sample rows with
gap notes.
README documented commands the dispatcher no longer accepts: `seal-use tool
<toolName>` and `seal-use tools list` were both dropped in v0.10.39 while the
README kept telling readers to run them (verified: both answer "Unknown
command"). It also described `./enterprises` as loaded by default, which a test
explicitly asserts is *not*, claimed the HTTP adapter does not serve the
OpenAPI document it serves at `/openapi.json`, described `service start` as a
stdio wrapper rather than the HTTP adapter it runs, and said the MCP server
advertises exactly one tool when it advertises two (and none without
`SEAL_USE_MCP_ENABLED`).
Each claim was rewritten against the code. The `seal-use update` paragraph now
describes all three installation modes instead of only the source-checkout one.
To keep the docs from drifting again, the suite now scans README, AGENTS.md,
SECURITY.md, the skill references, and the `.agents/rules` for `seal-use <area>`
and fails if any area is not dispatchable — it flags `tool` and `tools` on the
pre-fix README, so the check is live rather than decorative.
`runProbe` wrote its progress notes and three separate JSON blobs to stdout, so
every consumer parsing the output — `seal-use probe | jq`, the Agent Harness —
got prose interleaved with data. The command is also in the help registry, so
this was a documented command breaking its own contract.
The probe now returns one `ProbeResult` and the command prints it through
`printJson`; the `[probe] …` narration moves to stderr, which is the diagnostics
channel. The dev-script entry point keeps the same payload and its exit code.
Classified read-only too: `probe` reads tenant state and writes nothing, but
the allow-list had no entry, so the MCP read-only tool refused it. Its trailing
token is an enterprise selector rather than a verb, so the matcher accepts the
bare form and bare-plus-selector while still refusing a third token.
All 99 registry tools declare a zod schema, and not one of them was ever
parsed: `runToolResult` (every CLI command) and `executeSealTool`
(`POST /api/tool/:name` and every `/v1/*` route) handed `params` straight to the
handler. A missing required field reached the handler as `undefined` and died
as an opaque upstream error or a `Cannot read properties of undefined`, and an
out-of-range `limit` sailed through to the tenant.
Both paths now gate on `parseToolParams`, failing fast with the field path:
exit 13 on the CLI, HTTP 400 behind the adapter (structured exit codes map onto
statuses instead of collapsing every failure into 500). The HTTP tool endpoint
validates before `selectCorp`, which records usage stats to disk — a request
that can never succeed should cause no writes.
Two properties keep this a pure addition: the original params are returned
rather than zod's parsed output (handlers read undeclared keys — the configure
tool accepts `appKey` alongside `apiKey`, which the schema now says out loud),
and query strings are coerced to the declared type first, because `/v1/*`
passes `url.searchParams` where the schema wants `z.number()`.
Windows cannot rename-replace a running executable, so the win32 update path
renames the live image to `<binary>.old.<timestamp>` and never deleted it: one
full binary (tens of MB) leaked per update, forever. The same file cannot be
removed during the update that created it either — it is the executing image —
so the sweep runs at the start of every binary-mode invocation instead, which
includes the SWR background `update check --bg-save` that runs on its own.
Orphaned `.tmp-update-<ts>` staging dirs from an interrupted run are swept by
the same pass, gated on a one-hour mtime so a staging dir an update is actively
downloading into is never pulled out from under it.
Both P0s from the September bug report were fixed but had no regression
test guarding them:
- replay --sn ignored the argument and replayed the newest record. The new
test feeds a two-record search and asserts the requested (older) record is
replayed — and that a missing SN fails with a lookup error rather than
falling back to the newest.
- regression demanded --webhook but honouring it did nothing. The new test
runs the live path with two target channels: without a selector it exits 13
with guidance, with --webhook the selector error disappears (mockApiFetch
learns to serve the approval-style channel catalog).
runner.ts statically imported all 28 command modules, so `seal-use version`
paid for exceljs, archiver and the embedded skill bundle on every run:
measured 175ms against a 7ms bare-bun baseline.
Dispatch branches now load their handler with await import() on demand, and
compareSemVer/isNewerVersion move to a tiny core/semver.ts so the version
path no longer drags in the 1200-line updater. selectCorp and
createSealClient follow the same pattern. Measured after: version 37-45ms,
help 40ms, corps list 40ms. The performance contract in cli-protocol.md is
updated from an aspirational <10ms to a measured <50ms with the numbers.
update.ts's service-restart finally block is also restructured: throwing from
finally swallowed the original update error, and the previous catch/branch hid
a restart failure behind a log line.
the dead `args` parameter of handleMcpCommand goes with its caller here, so
the signature change and the call site land together.
parseArgs decided a flag's kind from whatever token followed it, so
`corps list --all now` fed "now" into --all and crashed with Invalid boolean,
a bare `--limit` was silently dropped (full dataset pull), and `--limitt` was
silently ignored with exit 0.
Add BOOLEAN_FLAGS / VALUE_FLAGS / KNOWN_FLAGS registries derived from how the
code reads each flag (booleanOption vs stringOption/numberOption). Booleans
never consume the next token, value flags must receive one, unknown flags
fail with a did-you-mean suggestion, and the three dual-use flags (f, h,
version) keep the legacy heuristic. parser.test.ts — previously zero tests on
the entry point — locks all of it plus a help.ts cross-check.
rules delete / documents delete / webhook delete all gate behind --yes, but
users delete, users reset-password and simulation clean reached the API with
no confirmation at all — a bare invocation deleted live data. Add the same
confirmationRequired gate (exit 10, no API call) the other destructive
commands use, and update the help registry plus the skill reference so the
usage lines show --yes.
loadCorpConfigs parsed every file with a bare Schema.parse, so one hand-
edited JSON aborted the whole directory: every corps/rules/webhook command
died with a raw parse error and no hint which file was at fault.
Each file now parses inside its own try/catch — bad files are skipped and
reported once per process on stderr with the offending path; the remaining
enterprises stay usable. loadGlobalConfig falls back to defaults (warning on
stderr) so config paths / corps list keep working for diagnosis. doctor gains
a config_parseability check that names unparseable files.
The classifier only matched English usage wording, so every Chinese-language
usage error, every enterprise-selection failure, and every Zod/SyntaxError
fell through to exit 1 ("upstream failure"), while environment safety guards
were reported as exit 2 or 1. Add two semantic codes:
- 13 (validationError): well-formed command, unusable value — missing --corp,
unparseable enterprise JSON, missing required parameter, ambiguous webhook
channel selection.
- 14 (safetyBlocked): the target environment forbids the action — replaying
into production, regression outside a test tenant.
classifyCliError now recognises Chinese usage wording, enterprise-selection
phrasing, local file problems, Zod issue lists (structural, not textual) and
SyntaxError; English Usage:/Unknown-command stays 2, domain failures and
quality gates stay 1. Docs (AGENTS, cli-protocol, skill cli.md) and the exit
code assertions follow.
Turn on noUnusedLocals/noUnusedParameters so the compiler keeps flagging
dead symbols, then clear the 737 findings it reports: unused imports across
src/, unused parameters, unreachable locals, and the copy-pasted 135-line
import prologues in the seal tool modules (each tool file now imports only
what it uses). Also applies the equivalent-safe lint rewrites (Array.from
instead of new Array(n).fill, non-null assertions in tests after toBeDefined,
simplified spreads, unused catch params) that oxlint will gate in a later
commit.