@moonglade/provenance
v2.7.0
Published
Local-first cryptographic proof for markdown files and agentic AI memory substrates.
Maintainers
Readme
@moonglade/provenance 2.7.0
Ed25519 signatures, canonical file hashes, RFC 3161 timestamp checks and Merkle inclusion proofs for Node 22 and 24.
Installation
Install directly from npm:
npm install @moonglade/provenanceOr install globally for the CLI and MCP tools:
npm install -g @moonglade/provenanceBuild from source
Run these commands from the repository root:
npm ci
npm testRun the built-in self-test with provenance test (no file argument; add --json for a machine-readable report). It exits non-zero on any failure. Programmatic access: require("@moonglade/provenance/self-test") exposes runSelfTests and printSelfTestReport. The WASM core is available as require("@moonglade/provenance/wasm"). provenance install-hooks [--pre-commit] [--mcp-verify-read] [--mcp-auto-seal] [--force] installs only what you select (it asks per option in a terminal, and does nothing without flags otherwise). An existing pre-commit hook that this tool did not install is never overwritten: the command refuses, and with --force first copies it to <hook>.bak-<UTC timestamp>. A hook counts as ours only if its whole content equals a known hook generated by this tool (including an unmodified 2.6.1 hook, which updates cleanly in place); an edited copy of it, or any other hook that merely mentions the tool, is refused (and backed up under --force). An existing .provenance-hooks.json that is not in the tool's own shape is backed up before it is rewritten, and MCP choices recorded earlier are kept. The generated hook needs bash. It reads NUL-delimited staged names, so names with spaces or non-ASCII characters are verified, and it blocks the commit if the staged list cannot be read. --mcp-verify-read and --mcp-auto-seal only record your choice in .provenance-hooks.json (npx -y --package=@moonglade/provenance provenance-gate) and print an MCP configuration snippet; nothing in this package reads that file yet. The hooks directory is resolved by git rev-parse --git-path hooks, so linked worktrees and core.hooksPath work. A hook installed from one linked worktree applies to every worktree of that repository, because they share one hooks directory. If core.hooksPath points at a shared or global directory, the hook is written there and affects every repository that uses it; the command prints the path it wrote. Ending input (Ctrl-D) at a prompt cancels with a non-zero exit and changes nothing.
Upgrading from 2.6.x to 2.7.0
- Package namespace: Retained as canonical
@moonglade/provenance. - Scoped
npxMCP binary selection: Because the default bin of@moonglade/provenanceisprovenance(dist/artifact-cli.js), always start the MCP server vianpx -y --package=@moonglade/provenance provenance-gaterather thannpx -y @moonglade/provenance provenance-gate. - Hook upgrades: Unmodified 2.6.1 pre-commit hooks upgrade cleanly in place on
provenance install-hooks --pre-commitwithout leaving backup files; customized hooks refuse cleanly unless--forceis supplied. - Protocol draft baseline: Documentation and v3 JCS specification references track
docs/draft-ottley-agentic-epistemic-provenance-01-mg2.7.0.md.
WASM core provenance & boundaries
wasm/ is generated from the Rust crate mgc-wasm (with mgc-core) in the private Moonglade monorepo at frozen source commit 1188ed841b5831bc743e4f23ccd505a08b108ee7, using rustc 1.98.1, wasm-bindgen 0.2.129, and wasm-bindgen --target nodejs (no wasm-opt pass). In this staging snapshot, wasm/ hashes and bindings await local wasm-bindgen --target nodejs generation from that frozen source archive prior to final release publishing and TypeScript test execution.
In addition to canonicalization and claims JSON helpers, the 2.7.0 mgc-wasm target exports:
parse_openpgp_armored_signature_hex(armored_asc): structural extraction only for RFC 4880 ASCII-armored V4 public-key algorithm22(EdDSALegacy, RFC 9580) detached signature packets (<= 1024decoded bytes); does NOT verify Ed25519 signatures or construct OpenPGP V4 hash trailers.verify_rfc3161_timestamp(tsr_bytes, expected_digest): structural DERTimeStampRespandmessageImprintcomparator ({28, 32, 48, 64}-byte digests); does NOT verify CMS signatures, X.509 certificates, EKU,ESSCertID/ESSCertIDv2, or trust anchors, does NOT bindMessageImprint.hashAlgorithmOID to digest length, ignores non-TSTInfotrailing inner DER bytes, and in frozen1188ed8rejects tokens containing an optionalTSTInfo.accuracysequence withERR_TSR_DER_UNEXPECTED_TAG. Always use top-levelverifyTimeStampTokenwithtrustAnchors(orProvenanceEngine.verifyDocumentwithtimestampTrustAnchors) for cryptographic TSA trust.
Sign and verify
const { ProvenanceEngine } = require('@moonglade/provenance');
// Supply your own Ed25519 keys. Never use the release root key for artifacts.
async function example(file, privateKey, publicKey, root) {
await ProvenanceEngine.sealDocument(file, privateKey, 'example-signer', 'local', { vaultRoot: root });
return ProvenanceEngine.verifyDocument(file, publicKey, {
expectedScope: ProvenanceEngine.scopeFor(file, root),
requiredSigners: ['example-signer']
});
}Get trusted public keys through a channel you trust. An editable sidecar cannot establish a signer's identity. A valid signature establishes possession of a key and integrity of the signed payload. It does not prove the content is correct, identify its actual author, or grant the signer authority.
Supply expectedScope to bind verification to an expected location or namespace. Use requiredSigners when particular signatures are required. The low-level verifier does not infer either policy.
Canonicalization
For text, the engine removes one leading UTF-8 BOM, converts CRLF to LF and applies Unicode NFC. Bare CR is preserved. Invalid UTF-8 is rejected.
Known binary formats keep their exact bytes. For unknown extensions, a NUL in the first 1024 bytes selects binary handling; otherwise the engine requires valid UTF-8 text. Text integrity follows these normalization rules rather than raw byte identity.
Verification results
SEALED requires a verified Ed25519 signature. With no key supplied (options.publicKeyPem omitted in getArtifactBadge), a matching recorded hash is shown in amber as HASH_ONLY (⚠️ [HASH-ONLY · UNVERIFIED]). The sidecar is editable, so HASH_ONLY and formatHtmlBadge outputs built without a trusted public key provide structural/digest display only — zero cryptographic signature assurance — and MUST NOT be used for access control or authorization decisions. Malformed sidecars cannot produce a seal.
Timestamp results are separate: ABSENT, INVALID, INTEGRITY_ONLY or ANCHORED. Time comes from the verified token, never an unsigned sidecar field. ANCHORED requires caller-supplied CA certificates, chain validation at token time, ESSCertIDv2 and a critical timestamp-only EKU. Certificate revocation is not checked. Without anchors, a valid self-signed TSA token can provide integrity-only evidence. Network or host-clock observations without tokens do not become RFC 3161 attestations.
CLI
The installed names are provenance, provenance-artifact and provenance-gate. The last starts the MCP server. CLI commands are:
provenance --help
provenance --version
provenance verify <file>
provenance badge <file>
provenance observe <file>
provenance seal-provisional <file>
provenance move <source> <destination>
provenance install-hooks [--pre-commit] [--mcp-verify-read] [--mcp-auto-seal] [--force]
provenance test [--json]Set MOONGLADE_PUBLIC_KEY_PEM for verification. Provisional sealing requires MOONGLADE_PRIVATE_KEY_PEM and MOONGLADE_SIGNER. The verification root is MOONGLADE_ROOT, or the current directory when unset. MOONGLADE_REQUIRED_SIGNERS is an optional comma-separated list.
Failed verification and refused sealing return a nonzero exit code. Move refuses destination collisions and any source sidecar. To relocate an attested artifact, copy it, explicitly reseal and verify the destination, then retire the original separately. Existing signatures keep their original scope.
MCP and filesystem access
The read-only MCP server exposes verify_artifact_provenance, audit_vault_merkle_root and assert_gate_status. It has no signing or hook tools. Each supplied path authorizes a local read under the operator's filesystem permissions. The process is not a sandbox. Connect it only to principals allowed that access.
Gate assertions check the supplied signature and policy; they do not establish human approval or signer authority. Input frames are limited to 1 MiB. File reads reject symlinks and have a 64 MiB limit; sidecars are limited to 1 MiB, and timestamp tokens and responses to 512 KiB. Protect workspace permissions. Concurrent hostile filesystem writers are outside the supported trust model.
API and limits
dist/index.d.ts declares the public exports: the engine, vault, verification policy, canonicalization and bounded reads; Merkle helpers; timestamp parsing, verification and acquisition; badge helpers; artifact and envelope utilities; read-only MCP tools and self-test.
When an openpgp or ssh-ed25519 attestation accompanies a declared Moonglade Ed25519 attestation, verifyDocument returns status: 'INDETERMINATE' (verified: false); bundles containing only openpgp or ssh-ed25519 return verified: false without a status field. The legacy library OpenPGP signing helper is not covered by the default test suite; its keyring selection is caller-controlled. Platform keystores and sibling packages are excluded. The optional hook installer (provenance install-hooks) installs only a git pre-commit verification gate and writes a manifest of the options you chose (using npx -y --package=@moonglade/provenance provenance-gate). Usage is described in the build section above.
See SPEC.md, TIMESTAMP.md, NOTICE.md and trust/README.md. GPG checks the OpenPGP release identity separately. Artifact verification uses raw Ed25519 SPKI PEM keys. Candidate documentation is intentionally unsealed. The root release key is not an agent key.
