The committed MCP bundle is the only thing that ships, but nothing checked
that it matched src/. The gate could not be added while CI ran
'bun-version: latest': that resolved to 1.4.2, and the minifier allocates
identifiers differently across Bun releases, so the runner rebuilt the
macOS/1.3.14-built bundle into different bytes — identical code, renamed
variables (N/S, A/I, q/p). Measured on #116.
Pin bun-version to 1.3.14 in both workflows, matching the local toolchain and
the @types/bun/bun-types already declared in package.json, then add the diff
gate alongside the existing boot check.
The boot check stays: a bundle that cannot start is invisible to a byte diff
when it is in sync with its broken source, which is exactly how #114 shipped.
The read-only MCP tool refused the whole `seal-use tool <name>` area, because
the 98-entry internal tool registry had no read/write classification. Now it
does: SEAL_READ_ONLY_TOOLS (66) and SEAL_MUTATING_TOOLS (32), exported from
src/domains/seal/tools.ts, with the policy delegating `tool` to them.
The two sets are exhaustive by construction — a test asserts they partition
sealTools exactly — so a newly added tool fails the suite until it is
classified, rather than silently defaulting into one bucket.
Classifying by inspection was not enough. Cross-checking mechanically (every
exported function in src/domains/seal that performs a mutating HTTP call,
mapped to the tools that invoke it) caught a real mistake shipped in #115:
`analytics analyze` was allow-listed as read-only, but it calls
seal_insight_record_analyze, which issues a POST and starts an analysis
server-side. Removed from the CLI allow-list; a comment records why it is
absent, since the name reads like a query.
`approval-runs pick` went the other way into read-only: it dispatches to
seal_approval_run_pick, which is a query over approval runs rather than a
local-state mutation.
Read-only means: reads tenant state, or writes only a local file. Anything
that creates, updates, deletes, publishes, pushes, replays, uploads, activates
or mints a credential counts as mutating. `seal_webhook_material_pack` is
mutating because push mode sends the pack even though preview mode does not;
`seal_approval_runs_export` and `seal_insight_export` are read-only because
they only write a local workbook.
CI disproved the freshness gate on the first run: an ubuntu rebuild of the
macOS-built committed dist/mcp/server.js differs, and the diff is entirely
minified identifier renaming (N->S, A->I, q->p) with identical code. The
minifier does not allocate names reproducibly across platforms and Bun
versions, so a byte-for-byte gate cannot work here without pinning the
toolchain and matching runners.
Keep the check that does hold: boot the freshly built bundle and complete an
MCP handshake. Booting is what #114 actually needed — the byte diff would not
have caught that bug either, since the broken bundle was in sync with its
broken source.
The committed bundle is the only thing that ships, but CI only checked that
it compiled — never that it matched src/, and never that it could start.
- Fail when a fresh build differs from the committed dist/mcp/server.js,
mirroring the existing dist/openapi.json gate, with the same actionable
error. This is viable now: the bundle is byte-reproducible with the current
toolchain (a rebuild of the committed file is byte-identical). Before the
#114 rebuild it was not, which is why this was previously left out.
- Keep booting the freshly built bundle through a handshake, since a bundle
that cannot start is invisible to source-level tests.
seal_cli could reach every CLI command, so its tool annotations had to be
all-or-nothing: destructiveHint true on a tool that mostly reads, which meant
clients could not auto-approve anything, and there was no way to gate the
mutating minority. Split it in two:
- seal_cli read-only, readOnlyHint true / destructiveHint false.
- seal_cli_write mutations, publishing, credential minting, self-update and
server commands; destructiveHint true.
The boundary is enforced rather than advertised. seal_cli runs only commands
on an explicit allow-list (84 entries, src/cli/read-only.ts) and fails closed
on anything unclassified, including commands added to the CLI later. Matching
reuses the CLI's own parseArgs and compares whole tokens, so a read prefix
cannot smuggle a mutation (corps listing is refused) and a bare allow-listed
command does not cover its subcommands. Refusals name seal_cli_write.
Deliberately excluded from the read-only set even though they look harmless:
anything writing local config (corps switch, config test-dir), minting or
printing credentials (auth keys, corps extract-keys), self-updating (update),
or standing up a long-running server (http, mcp, service run). seal-use
tool <name> is excluded too, since the 98-entry internal tool registry is not
itself classified.
A test asserts every allow-listed command still exists in the help registry,
so the list cannot silently rot.
Also, per the note that MCP is an optional, default-off path, the skill now
says so explicitly: the CLI is primary, a missing seal_cli* tool is the normal
default rather than a fault, and enabling it is the user's choice in the plugin
settings. Corrected skill docs that presented internal tool-registry names
(seal_webhook_get, seal_webhook_update, ...) as if they were MCP tools; the MCP
server exposes only the two seal_cli* tools.
CI: the MCP build step now boots the freshly built bundle and completes a
handshake, instead of only checking that it compiles. A bundle that cannot
start is invisible to source-level tests, which is how the previous unbootable
entry point shipped. No byte-for-byte dist diff gate here: the committed
bundle is not byte-reproducible with the current toolchain (~186 lines of drift
rebuilding the unmodified release commit), and such a gate would not have
caught that bug anyway, since the broken bundle was in sync with its source.
The plugin ships dist/mcp/server.js as its MCP entry point, and that bundle
could not start at all: it threw "TypeError: ... is not a constructor" while
loading and never answered a request. MCP defaults to off, so enabling it
produced no seal_cli tool and no visible error.
Root cause: src/server.ts is circularly entangled with the CLI command graph
(server -> cli/runner -> cli/commands/mcp -> server, and
server -> cli/runner -> cli/commands/http -> http/routes -> server). When
bun build --target=node flattened that cycle together with zod's own
core <-> classic cycle, zod's class initialisers landed after the top-level
z.lazy() call the SDK makes at import time, leaving ZodLazy undefined.
Not fixable by changing targets: --target=bun, --compile, and dropping
--minify all fail the same way. Only removing the cycles fixes it.
- Moved tokenizeCommand / normalizeCliArgs to a leaf module (src/cli/tokenize.ts)
and made the mcp command import the server lazily, removing both cycles.
- Added a test that boots the packaged bundle over stdio and completes a
handshake; the existing tests exercise source, not the shipped artifact,
which is why this went unnoticed. Verified it fails on the old bundle.
- Committed the rebuilt dist/mcp/server.js, since the previously committed
artifact is the broken one.
Also migrated the monolithic @modelcontextprotocol/sdk v1 to the v2 split
packages (@modelcontextprotocol/server for the server,
@modelcontextprotocol/client for tests):
- Low-level Server + setRequestHandler -> high-level McpServer + registerTool;
hand-written JSON Schema -> z.strictObject (still emits
additionalProperties: false).
- Added the title and annotations clients could not previously see:
readOnlyHint false, destructiveHint true, idempotentHint false,
openWorldHint true. seal_cli is a passthrough that can reach mutating verbs,
so it must not be advertised as safe to auto-run or safe to retry; the
description now names the command families needing user confirmation.
- startServer uses serveStdio, which owns protocol-era negotiation
(2025-era clients keep working) and teardown.
- .mcp.json uses the ZCode-native ${ZCODE_PLUGIN_ROOT}; verified in ZCode's
resolver that CLAUDE_PLUGIN_ROOT and ZCODE_PLUGIN_ROOT are the same alias.
Dropping the v1 SDK removes express, hono, cors and ajv from the dependency
graph (bun.lock -149 lines).
`approval-runs export` returned a bare audit-drift counter with no way to
trace it back to a document: no sourceDocumentSN, no recordId, no reason.
Interpreting it required a separate per-document `approval-runs flow`
query, and the word "drift" alone suggested the tool or the approval flow
was broken rather than a snapshot/lifecycle difference.
The drift itself is already visible in the workbook row: AI 决策「通过」
next to 人工审核「已取消」 and E人工行为「已撤回」, with the retraction
recorded in the standard formatted E人工意见 column. The aggregate carried
no information those columns do not.
`seal_approval_runs_export` never enabled flow alignment, so for MCP
consumers the field was a constant 0.
Rather than enriching the field, remove it. Per-run auditDrift and
auditDriftReason in `approval-runs flow` are unchanged.
- Clarify dataset naming as Webhook 资源包 (CLI: resource-pack, alias: pack), distinguishing from backend native simulation material pack while retaining material-pack as backward-compatible alias
- Implement exportApprovalRunsToResourcePack for exporting online approval runs and attachments into local resource pack ZIP
- Support seal-use webhook resource-pack export with record filters, docId prefix/suffix, and destination options
- Refine bidirectional directory validation to allow documents without attachments
- Update CLI runner, help definitions, and skill references
- Add comprehensive export, preview, and CLI command unit tests
- Implement hlabRuleLinter enforcing HLab SOP structure, ternary decision closure, disposal action decoupling, and false-skip prevention
- Register hlab.ts template in official templates for automatic plaintext sync
- Support hlab and aliases (hlab-sop, hlab-rules, hlab-standard) in linter loader
- Document HLab linter and detection rules in skill references
- Add comprehensive unit tests in linter.test.ts