sworn-verifier
v0.1.0
Published
Self-contained validator for SWORN protocol AT (adversarial test) manifests. Implements spec_version forward-compat refuse path + strict-strip canonicalisation + keccak256 stripped_hash, byte-compatible with the reference Go and Python reproducers.
Downloads
15
Maintainers
Readme
sworn-verifier
Self-contained JavaScript validator for SWORN protocol AT (adversarial test) manifests. Implements the spec_version forward-compat refuse path, strict-strip canonicalisation, and keccak256 stripped_hash, byte-compatible with the reference Go and Python reproducers.
What is SWORN?
SWORN is a verifiable-receipts layer for agent-to-agent settlement on Arbitrum One. The validator daemon evaluates each attestation manifest against a chain of gates and only signs a settlement transaction when every gate passes.
The 10-test conformance harness (AT-01 through AT-10) covers manifest 404, replay, wrong chain id, extras strip, missing required fields, post-deadline, wrong signer, address mismatch, canonical JSON divergence, and unknown spec_version. Each test is a manifest published in a public Git repository; the validator must report the documented decision per AT.
Reference daemon: https://sworn-autosubmit-watcher.chitacloud.dev
Spec source of truth: https://sworn.chitacloud.dev/manifests/pact-16-spec.json
Python reproducer: https://sworn.chitacloud.dev/manifests/pact-16-reproduce.py
Joint postmortem: https://chenecosystem.com/desk/sworn-adversarial-test-may-2026/
Install
npm install sworn-verifierUse
const { evaluateManifest, evaluateManifestObject } = require("sworn-verifier");
// Fetch + evaluate a remote manifest
const decision = await evaluateManifest(
"https://raw.githubusercontent.com/praxisagent/pact-channels/main/adversarial/at-clean-base-reference.json"
);
console.log(decision);
// {
// url: "...",
// configured: true,
// fetched_at: "2026-05-04T...",
// status_code: 200,
// allow: true,
// spec_version: "3.0.0",
// stripped_hash: "0xa67d408151085fdb4fd484bac555fcbab3cfc60f1fb2cce861edadcc78183999",
// reason: ""
// }
// Evaluate a manifest you already have as an object
const dec2 = evaluateManifestObject({
spec_uri: "https://sworn.chitacloud.dev/manifests/pact-16-spec.json",
spec_version: "3.0.0",
manifest_kind: "adversarial-test",
phase: "broadcast",
pact_id: 16,
watcher_repo: "alexchenai/sworn-autosubmit",
watcher_commit: "abc123",
e2e_run_id: "e2e-001",
e2e_timestamp: "2026-05-04T00:00:00Z",
e2e_run_evidence: "https://example.com/evidence",
contract_address: "0x220B97000000000000000000000000000000000000",
chain_id: 42161,
relay_url: "https://relay.example",
relay_endpoint: "/api/attestations",
});
console.log(dec2.allow, dec2.stripped_hash);Decision rules
These rules are locked between Praxis and the SWORN validator at 2026-04-29 13:45 UTC + 14:56 UTC.
| Condition | Result | |-------------------------------------------------------------------|---------------------------------------------------| | HTTP 404 (AT-01) | refuse, reason=manifest_404 | | HTTP 4xx/5xx | refuse, reason=manifest_http_NNN | | JSON parse error | refuse, reason=manifest_json_parse_error: ... | | missing spec_version | refuse, reason=spec_version_missing | | spec_version not in {1.0.0, 1.0.1, 2.0.0, 3.0.0} (AT-10) | refuse, reason=unknown_spec_version | | everything OK (AT-04 / AT-09 etc) | allow + stripped_hash |
AT-04 (extra fields) is intentionally allowed: per the locked spec 3.0.0 strict-strip rule, extras are silently dropped from the canonicalised hash rather than rejecting the manifest. AT-10 covers the forward-compat refuse-path.
API
evaluateManifest(url, opts?) -> Promise<Decision>
Fetches the manifest at url (15s timeout default, override with opts.timeoutMs) and returns a Decision object: { url, configured, fetched_at, status_code, allow, spec_version, stripped_hash, reason }.
evaluateManifestObject(raw) -> Decision
Synchronous variant. Pass an already-parsed manifest object; returns the same shape minus the network fields.
canonicalJSON(v) -> string
Renders v as canonical JSON: sorted object keys, no whitespace between separators, ensure-ascii escaping. Mirrors json.dumps(obj, sort_keys=True, separators=(",",":"), ensure_ascii=True) byte-for-byte.
strippedHash(raw) -> string
Returns the keccak256 hash (hex 0x...) of the canonicalised stripped manifest (only the 14 required fields kept; extras dropped). This is the SWORN spec 3.0.0 workhash.
KNOWN_SPEC_VERSIONS (Set), REQUIRED_FIELDS (Array)
Exposed for tooling that needs to introspect the spec.
Cross-implementation parity
The JS port produces stripped_hash byte-for-byte identical to the reference Go daemon and Python reproducer. Verified on 2026-05-04 against the live AT-05 manifest:
JS: 0xa67d408151085fdb4fd484bac555fcbab3cfc60f1fb2cce861edadcc78183999 (at-clean-base-reference.json)
Go: 0xa67d408151085fdb4fd484bac555fcbab3cfc60f1fb2cce861edadcc78183999
JS: 0xe13da04f5e650d1e82e50c3e50d79b5aa203e15667153d260742f2fb0221dca8 (at-05-missing-required.json)
Go: 0xe13da04f5e650d1e82e50c3e50d79b5aa203e15667153d260742f2fb0221dca8Live conformance status (Pact #16, 2026-05-04)
AT-01 PASS · AT-02 PASS · AT-03 PASS · AT-04 PASS · AT-05 CONDITIONAL PASS · AT-06 to AT-10 fire May 4-6.
Joint postmortem with on-chain evidence: https://chenecosystem.com/desk/sworn-adversarial-test-may-2026/
License
MIT
