@agent-blueprint-protocol/verifier 0.7.1 → 0.8.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/CHANGELOG.md +79 -0
- package/README.md +41 -4
- package/dist/kit/cli.mjs +2 -1
- package/dist/release-metadata.json +1 -0
- package/dist/verifier/cli.js +10 -4
- package/dist/verifier/corpus.d.ts +1 -0
- package/dist/verifier/corpus.js +63 -2
- package/dist/verifier/self_checks.js +133 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,85 @@
|
|
|
2
2
|
|
|
3
3
|
All notable public changes to `agent_blueprint_protocol` are documented here.
|
|
4
4
|
|
|
5
|
+
## [0.8.0] — 2026-09-24
|
|
6
|
+
|
|
7
|
+
### Added — the release-identity consumer contract
|
|
8
|
+
|
|
9
|
+
- `priv/release-metadata.json` is now a versioned public contract
|
|
10
|
+
(`manifest_version: 2`; additive-only within a version). New fields:
|
|
11
|
+
the manifest version, `verification_semantics_version` (the
|
|
12
|
+
semantics/census split — unchanged at 1), the `digest_identity` label
|
|
13
|
+
(RFC 8785 JCS + SHA-256 + domain separation + unpadded base64url —
|
|
14
|
+
unchanged across every release), `protocol_revisions_supported`, the
|
|
15
|
+
certified compatibility matrix `prior_census_verdicts` (the prior
|
|
16
|
+
census `sha-256:sg6Fo7…` is certified `equivalent` by replay), and
|
|
17
|
+
the verifier-kit identity derived from `package.json`. The npm kit
|
|
18
|
+
embeds the manifest byte-identically (agreement-gated).
|
|
19
|
+
- `priv/release-history.json`: the append-only retroactive mapping —
|
|
20
|
+
one row per manifest-era release, every PRIOR release's row verified
|
|
21
|
+
against derived state (the corpus digest recomputed from the loaded
|
|
22
|
+
census bytes, the registry digest from the census index, the
|
|
23
|
+
specification digest recomputed over the tag's tree); the current
|
|
24
|
+
release's row is asserted against the live manifest and gains its
|
|
25
|
+
tag verification at the next release. Semantics version 1 spans the
|
|
26
|
+
whole manifest era through this release: the prior census replays
|
|
27
|
+
case-perfect (observed under the preceding package on 2026-09-23;
|
|
28
|
+
this release's gate re-establishes it mechanically on every run), so
|
|
29
|
+
exact-pinned consumers upgrading between any of these releases keep
|
|
30
|
+
historical replays green when they bind the semantics identity. The record also shows the specification
|
|
31
|
+
digest moved at 0.4.0 and 0.4.1 — movement the changelog prose of
|
|
32
|
+
those releases never stated.
|
|
33
|
+
- `mix compatibility.replay` (quality battery): certifies the
|
|
34
|
+
compatibility claims and the history from live repository state —
|
|
35
|
+
every manifest-era census loads through the new prior-census loader
|
|
36
|
+
mode and replays under the current Runner (each PRIOR census also
|
|
37
|
+
through the TS verifier, byte-compared; the current census's TS
|
|
38
|
+
agreement is the verifier.agreement gate's duty); an
|
|
39
|
+
`equivalent` claim with any disagreement reds, a registry-explained
|
|
40
|
+
divergence class is gated by the registry diff, an unclaimed census,
|
|
41
|
+
stale claim, or tampered history row reds, and a tag-less checkout
|
|
42
|
+
refuses (a named override exists and is never a green claim).
|
|
43
|
+
Self-proving seeded reds fire every run: four claim flips (including
|
|
44
|
+
a self-contradictory `not_equivalent` claim), a tampered census file,
|
|
45
|
+
a tampered history row, and both tag-absent refusal arms. The prior-census loader mode
|
|
46
|
+
(`Corpus.load_prior_census/1`, mirrored in the TS verifier's
|
|
47
|
+
`--prior-corpus`) suspends exactly the two current-state couplings —
|
|
48
|
+
the compiled registry digest and the compiled applicability floor —
|
|
49
|
+
because a released census was certified against the registry and
|
|
50
|
+
floor of its release; the ordinary loader's couplings are unchanged
|
|
51
|
+
and correct for conformance runs.
|
|
52
|
+
- The Evolution clause gains the normative semantics/census law and the
|
|
53
|
+
immutability policy (released identities are never edited in place;
|
|
54
|
+
corrections are new releases); the upgrading guide gains the
|
|
55
|
+
exact-pinned consumer partition — replay identity versus provenance
|
|
56
|
+
metadata — and the fail-closed enumeration guidance; the decision
|
|
57
|
+
record `docs/adr/release-identity-semantics.md` ships with the
|
|
58
|
+
`no-versioning-rule` axis amendment (precedence: the wire revision,
|
|
59
|
+
the semantics version, and the release identity are independent
|
|
60
|
+
axes). Answering an inbound consumer request for input
|
|
61
|
+
(bounded_authority, 2026-09-23) in full.
|
|
62
|
+
- `docs/consumer-evidence.md` (repository-level, deliberately NOT
|
|
63
|
+
shipped): the unverified third-party consumer-rehearsal lane, its
|
|
64
|
+
first entry reserved for the bounded_authority rehearsal.
|
|
65
|
+
|
|
66
|
+
The correction the record now states plainly: the 0.6.0 corpus change
|
|
67
|
+
was not purely additive at the byte level — the golden vectors' fixture
|
|
68
|
+
signature rotated on unchanged covered bytes (`content_digest`
|
|
69
|
+
identical), verdict-neutral and replay-proven, but the 0.6.0 entry's
|
|
70
|
+
"grows 94 → 96" prose under-recorded it.
|
|
71
|
+
|
|
72
|
+
The public-history privacy scan's budget grows with the repository
|
|
73
|
+
(the scan is O(tracked files × commits)); its ceiling moves 960s →
|
|
74
|
+
1920s on the same evidence as every prior raise — a borderline clip on
|
|
75
|
+
this release's tree, a timeout there being a flake, never a privacy
|
|
76
|
+
finding.
|
|
77
|
+
|
|
78
|
+
The test suite is 924 tests (59 properties) at 100% coverage. Corpus:
|
|
79
|
+
96 cases, digest
|
|
80
|
+
`sha-256:vMyREM8ggUqVvGG0y2e4Gf-KmpksJjnx2eF8UjtpVP8`; registry
|
|
81
|
+
`sha-256:FG2f38K0hba8tTP7iUaw7vHjgcnN_5F5Mp0v4G6UDVs`; specification
|
|
82
|
+
digest `sha-256:yC0gV-zIn8J8bXI5gV0dQyPmgEQgVsH6k7YOlkis37Q`.
|
|
83
|
+
|
|
5
84
|
## [0.7.1] — 2026-09-16
|
|
6
85
|
|
|
7
86
|
### Changed — the toolchain enforces itself (hygiene release)
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Agent Blueprint Protocol is a portable, non-authorizing contract for describing
|
|
|
8
8
|
an agent capability and binding one immutable release to an execution
|
|
9
9
|
environment.
|
|
10
10
|
|
|
11
|
-
The public package is the reference implementation for
|
|
11
|
+
The public package is the reference implementation for three
|
|
12
12
|
language-neutral artifacts:
|
|
13
13
|
|
|
14
14
|
- **Blueprint Core** — stable identity, typed ports, logical capability
|
|
@@ -16,6 +16,11 @@ language-neutral artifacts:
|
|
|
16
16
|
- **Deployment Manifest** — environment-local tool, principal, data,
|
|
17
17
|
authority, effect, evaluation, and exact-build bindings for one Blueprint
|
|
18
18
|
release digest.
|
|
19
|
+
- **Federation TaskEnvelope** — the cross-protocol task record: 23 members
|
|
20
|
+
carrying task identity, terminal state, and signed terminal commitments
|
|
21
|
+
over A2A and MCP transports, with receipt-equivocation denial. The
|
|
22
|
+
blueprint rides IN those transports; the envelope is how a task's
|
|
23
|
+
verifiable record travels between them.
|
|
19
24
|
|
|
20
25
|
Protocol validity never grants authority. A consuming host remains responsible
|
|
21
26
|
for identity, tenancy, policy, live authorization, effect ownership, execution,
|
|
@@ -26,7 +31,7 @@ and evidence retention.
|
|
|
26
31
|
```elixir
|
|
27
32
|
def deps do
|
|
28
33
|
[
|
|
29
|
-
{:agent_blueprint_protocol, "~> 0.
|
|
34
|
+
{:agent_blueprint_protocol, "~> 0.8.0"}
|
|
30
35
|
]
|
|
31
36
|
end
|
|
32
37
|
```
|
|
@@ -96,12 +101,15 @@ Semantics:
|
|
|
96
101
|
Tooling: `mix conformance.verify` executes the shipped 96-case corpus;
|
|
97
102
|
`mix conformance.mutations` re-proves the corpus catches named implementation
|
|
98
103
|
breaks; `mix verifier.agreement` byte-agrees the Elixir runner with the
|
|
99
|
-
independent TypeScript verifier.
|
|
104
|
+
independent TypeScript verifier; `mix compatibility.replay` certifies the
|
|
105
|
+
release's compatibility claims — every prior release's census replays under
|
|
106
|
+
the current verifier in both languages, and the release history verifies
|
|
107
|
+
against its tags' actual trees.
|
|
100
108
|
|
|
101
109
|
## Status
|
|
102
110
|
|
|
103
111
|
The protocol API, schemas, canonicalization profile, extension registry,
|
|
104
|
-
and conformance corpus are implemented and gated:
|
|
112
|
+
and conformance corpus are implemented and gated: 924 tests
|
|
105
113
|
(59 properties) at 100% coverage, zero Dialyzer errors, `--strict`
|
|
106
114
|
Credo clean, a 96-case conformance corpus with a mutation gate, and a
|
|
107
115
|
byte-agreement gate against an independent second-language verifier.
|
|
@@ -110,6 +118,13 @@ ships in the Hex archive. The full gate battery and every gate's
|
|
|
110
118
|
recorded red proof are public in this repository under
|
|
111
119
|
[`docs/design/requirement-map.md`](https://github.com/baselabs/agent_blueprint_protocol/blob/main/docs/design/requirement-map.md).
|
|
112
120
|
|
|
121
|
+
Since 0.8.0 the release identity is a versioned public contract: the
|
|
122
|
+
manifest (`manifest_version`, additive-only) splits verification
|
|
123
|
+
semantics from census, certifies the compatibility matrix per prior
|
|
124
|
+
census, and the append-only release history maps every release — so
|
|
125
|
+
exact-pinned consumers upgrade pins without breaking historical
|
|
126
|
+
replays ([upgrading guide](documentation/upgrading.md)).
|
|
127
|
+
|
|
113
128
|
The 0.x series is the public pre-1.0 line: shipped contracts may
|
|
114
129
|
change within 0.x under pre-1.0 conventions, and every contract change
|
|
115
130
|
lands with a red-capable test.
|
|
@@ -196,6 +211,28 @@ The agreement gate is part of `mix quality`: the two implementations must
|
|
|
196
211
|
produce byte-identical JCS reports over the same corpus, and node ≥ 24 is a
|
|
197
212
|
hard prerequisite of the gate.
|
|
198
213
|
|
|
214
|
+
## Documentation
|
|
215
|
+
|
|
216
|
+
Every guide ships in the package and renders on HexDocs:
|
|
217
|
+
|
|
218
|
+
- Start here: [getting started](documentation/getting-started.md) ·
|
|
219
|
+
[quickstart](documentation/quickstart.md) ·
|
|
220
|
+
[TypeScript quickstart](documentation/typescript.md)
|
|
221
|
+
- Concepts: [what a blueprint is](documentation/what-a-blueprint-is.md) ·
|
|
222
|
+
[what a deployment is](documentation/what-a-deployment-is.md) ·
|
|
223
|
+
[portability](documentation/portability.md) ·
|
|
224
|
+
[federation](documentation/federation.md)
|
|
225
|
+
- By role: [producing artifacts](documentation/producer.md) ·
|
|
226
|
+
[authoring extensions](documentation/extension-author.md) ·
|
|
227
|
+
[host integration](documentation/host-integration.md) ·
|
|
228
|
+
[operations](documentation/operations.md)
|
|
229
|
+
- Reference: [the 74-code error guide](documentation/errors.md) ·
|
|
230
|
+
[evidence commitments](documentation/evidence-commitments.md) ·
|
|
231
|
+
[the extension registry](documentation/registry.md) ·
|
|
232
|
+
[upgrading and stability](documentation/upgrading.md) ·
|
|
233
|
+
[FAQ](documentation/faq.md) · [examples](documentation/examples.md)
|
|
234
|
+
- The normative contract: [`spec/protocol.md`](spec/protocol.md)
|
|
235
|
+
|
|
199
236
|
## Security
|
|
200
237
|
|
|
201
238
|
See [`SECURITY.md`](SECURITY.md). A successful verifier result is
|
package/dist/kit/cli.mjs
CHANGED
|
@@ -15,8 +15,9 @@ const embedded = join(here, "..", "corpus");
|
|
|
15
15
|
|
|
16
16
|
const args = process.argv.slice(2);
|
|
17
17
|
const hasCorpus = args.includes("--corpus");
|
|
18
|
+
const hasPriorCorpus = args.includes("--prior-corpus");
|
|
18
19
|
const hasArtifact = args.includes("--artifact");
|
|
19
|
-
if (!hasCorpus && !hasArtifact) {
|
|
20
|
+
if (!hasCorpus && !hasPriorCorpus && !hasArtifact) {
|
|
20
21
|
args.push("--corpus", embedded);
|
|
21
22
|
}
|
|
22
23
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"archive_is_publication_authorization":false,"corpus_digest":"sha-256:vMyREM8ggUqVvGG0y2e4Gf-KmpksJjnx2eF8UjtpVP8","digest_identity":"rfc8785-jcs+sha-256+domain-separated+base64url-unpadded","format":"agent-blueprint-protocol-release-metadata","index_sha256_base64url":"ZEe27WOwznbBF0X1hRXHLsA3-sdmpSN6uzRhuV5HmxY","manifest_version":2,"package":"agent_blueprint_protocol","package_version":"0.8.0","prior_census_verdicts":{"sha-256:sg6Fo7p8nZpJDzxFn4dXHBWgbGvEvtOk-7t3m7OT7Yo":"equivalent"},"protocol_revisions_supported":[1],"registry_digest":"sha-256:FG2f38K0hba8tTP7iUaw7vHjgcnN_5F5Mp0v4G6UDVs","spec_digest":"sha-256:yC0gV-zIn8J8bXI5gV0dQyPmgEQgVsH6k7YOlkis37Q","verification_semantics_version":1,"verifier_kit":{"name":"@agent-blueprint-protocol/verifier","registry":"npm","version":"0.8.0"},"verifier_runtime":"node>=24"}
|
package/dist/verifier/cli.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// into "disagreement").
|
|
9
9
|
import { readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
10
10
|
import { join } from "node:path";
|
|
11
|
-
import { load } from "./corpus.js";
|
|
11
|
+
import { load, loadPriorCensus } from "./corpus.js";
|
|
12
12
|
import { encode } from "./canonical.js";
|
|
13
13
|
import { toBytes } from "./report.js";
|
|
14
14
|
import { run } from "./runner.js";
|
|
@@ -16,13 +16,19 @@ import { decode as decodeBlueprint } from "./blueprint.js";
|
|
|
16
16
|
import { decode as decodeDeployment } from "./deployment.js";
|
|
17
17
|
import { decode as decodeEnvelope } from "./federation.js";
|
|
18
18
|
import { obj, str } from "./value.js";
|
|
19
|
-
const USAGE = "usage: node verifier/cli.ts --corpus <dir> | --artifact <file>";
|
|
19
|
+
const USAGE = "usage: node verifier/cli.ts --corpus <dir> | --prior-corpus <dir> | --artifact <file>";
|
|
20
20
|
const BYTE_CAP = 5_000_000;
|
|
21
21
|
function main(argv) {
|
|
22
22
|
if (argv.length === 2 && argv[0] === "--artifact" && argv[1] !== "" && typeof argv[1] === "string") {
|
|
23
23
|
return verifyArtifact(argv[1]);
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
// --prior-corpus: the compatibility-replay entry (a RELEASED census under
|
|
26
|
+
// a newer verifier — the registry/floor couplings suspended by the
|
|
27
|
+
// loader's prior-census mode). The report and exit contract are identical
|
|
28
|
+
// to --corpus; the compatibility gate byte-compares this output against
|
|
29
|
+
// the Elixir side's in-process report.
|
|
30
|
+
const prior = argv.length === 2 && argv[0] === "--prior-corpus" && argv[1] !== "" && typeof argv[1] === "string";
|
|
31
|
+
if (!(prior || (argv.length === 2 && argv[0] === "--corpus" && argv[1] !== "" && typeof argv[1] === "string"))) {
|
|
26
32
|
process.stderr.write(USAGE + "\n");
|
|
27
33
|
return 2;
|
|
28
34
|
}
|
|
@@ -35,7 +41,7 @@ function main(argv) {
|
|
|
35
41
|
process.stderr.write("corpus unreadable: a file is missing, unreadable, or over the byte ceiling\n");
|
|
36
42
|
return 2;
|
|
37
43
|
}
|
|
38
|
-
const corpus = load(map);
|
|
44
|
+
const corpus = prior ? loadPriorCensus(map) : load(map);
|
|
39
45
|
if (!corpus.ok) {
|
|
40
46
|
// Value-free by construction: the code names the corpus's own state.
|
|
41
47
|
// The ":" prefix mirrors the escript's inspect(error.code) formatting.
|
|
@@ -36,6 +36,7 @@ type LoadResult = {
|
|
|
36
36
|
e: string;
|
|
37
37
|
};
|
|
38
38
|
export declare function load(map: Map<string, Buffer>): LoadResult;
|
|
39
|
+
export declare function loadPriorCensus(map: Map<string, Buffer>): LoadResult;
|
|
39
40
|
export declare function member(container: Value, key: string): Value | null;
|
|
40
41
|
export declare function memberString(container: Value, key: string): string | null;
|
|
41
42
|
export declare function memberNumber(container: Value, key: string): number | null;
|
package/dist/verifier/corpus.js
CHANGED
|
@@ -225,6 +225,16 @@ const FLOOR = {
|
|
|
225
225
|
const indexInvalid = () => ({ ok: false, e: "corpus_index_invalid" });
|
|
226
226
|
const caseInvalid = () => ({ ok: false, e: "corpus_case_invalid" });
|
|
227
227
|
export function load(map) {
|
|
228
|
+
return loadWithMode(map, false);
|
|
229
|
+
}
|
|
230
|
+
// The compatibility-replay mode (the Elixir load_prior_census twin): the
|
|
231
|
+
// two CURRENT-STATE couplings (registry digest, applicability totality
|
|
232
|
+
// against the compiled floor) are suspended; every census-RELATIVE
|
|
233
|
+
// integrity check stays. The compatibility gate owns divergence.
|
|
234
|
+
export function loadPriorCensus(map) {
|
|
235
|
+
return loadWithMode(map, true);
|
|
236
|
+
}
|
|
237
|
+
function loadWithMode(map, priorCensus) {
|
|
228
238
|
const indexBytes = map.get("index.json");
|
|
229
239
|
if (indexBytes === undefined)
|
|
230
240
|
return indexInvalid();
|
|
@@ -241,7 +251,7 @@ export function load(map) {
|
|
|
241
251
|
const corpusDigestOk = verifyCorpusDigest(index);
|
|
242
252
|
if (!corpusDigestOk.ok)
|
|
243
253
|
return corpusDigestOk;
|
|
244
|
-
if (memberString(index, "registry_digest") !== registryDigest()) {
|
|
254
|
+
if (!priorCensus && memberString(index, "registry_digest") !== registryDigest()) {
|
|
245
255
|
return indexInvalid();
|
|
246
256
|
}
|
|
247
257
|
const totalCases = memberNumber(index, "total_cases");
|
|
@@ -268,7 +278,9 @@ export function load(map) {
|
|
|
268
278
|
const validity = verifyCaseValidity(loaded.v.cases);
|
|
269
279
|
if (!validity.ok)
|
|
270
280
|
return validity;
|
|
271
|
-
const applicability =
|
|
281
|
+
const applicability = priorCensus
|
|
282
|
+
? verifyApplicabilityCensus(index, loaded.v.cases)
|
|
283
|
+
: verifyApplicability(index, loaded.v.cases);
|
|
272
284
|
if (!applicability.ok)
|
|
273
285
|
return applicability;
|
|
274
286
|
const rawBindings = verifyRawBindings(loaded.v.cases, loaded.v.raws);
|
|
@@ -627,6 +639,55 @@ function verifyApplicability(index, cases) {
|
|
|
627
639
|
}
|
|
628
640
|
return { ok: true };
|
|
629
641
|
}
|
|
642
|
+
// Prior-census applicability: the census's own map checked against the
|
|
643
|
+
// census's own cases, both directions (a released census was authored
|
|
644
|
+
// against the floor of its release, not this build's).
|
|
645
|
+
function verifyApplicabilityCensus(index, cases) {
|
|
646
|
+
const applicabilityError = () => ({ ok: false, e: "corpus_applicability_incomplete" });
|
|
647
|
+
const applicability = member(index, "applicability");
|
|
648
|
+
if (applicability.t !== "obj")
|
|
649
|
+
return applicabilityError();
|
|
650
|
+
const leavesBySurface = new Map();
|
|
651
|
+
for (const [surface, leaves] of applicability.v) {
|
|
652
|
+
if (leaves.t !== "obj")
|
|
653
|
+
return applicabilityError();
|
|
654
|
+
leavesBySurface.set(surface, new Map(leaves.v));
|
|
655
|
+
}
|
|
656
|
+
const observed = new Map();
|
|
657
|
+
for (const file of cases) {
|
|
658
|
+
for (const caseObj of file.cases) {
|
|
659
|
+
const key = caseObj.surface + "\u0000" + caseObj.klass;
|
|
660
|
+
observed.set(key, (observed.get(key) ?? 0) + 1);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
for (const [surface, leaves] of leavesBySurface) {
|
|
664
|
+
for (const [klass, leaf] of leaves) {
|
|
665
|
+
const observedCount = observed.get(surface + "\u0000" + klass) ?? 0;
|
|
666
|
+
if (leaf.t === "int") {
|
|
667
|
+
if (observedCount !== leaf.v)
|
|
668
|
+
return applicabilityError();
|
|
669
|
+
}
|
|
670
|
+
else if (leaf.t === "obj") {
|
|
671
|
+
const reason = memberString(leaf, "n_a");
|
|
672
|
+
if (typeof reason !== "string" || reason === "" || observedCount !== 0) {
|
|
673
|
+
return applicabilityError();
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
else {
|
|
677
|
+
return applicabilityError();
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
for (const key of observed.keys()) {
|
|
682
|
+
const separator = key.indexOf("\u0000");
|
|
683
|
+
const surface = key.slice(0, separator);
|
|
684
|
+
const klass = key.slice(separator + 1);
|
|
685
|
+
const leaves = leavesBySurface.get(surface);
|
|
686
|
+
if (leaves === undefined || !leaves.has(klass))
|
|
687
|
+
return applicabilityError();
|
|
688
|
+
}
|
|
689
|
+
return { ok: true };
|
|
690
|
+
}
|
|
630
691
|
// ---- raw bindings -----------------------------------------------------------------------------
|
|
631
692
|
function verifyRawBindings(cases, raws) {
|
|
632
693
|
for (const file of cases) {
|
|
@@ -13,6 +13,7 @@ import { encode } from "./canonical.js";
|
|
|
13
13
|
import * as b64 from "./b64url.js";
|
|
14
14
|
import { member, memberString } from "./corpus.js";
|
|
15
15
|
import { verify as sigVerify, toCompact, signingInput, usableEd25519Key } from "./signature.js";
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
16
17
|
import { readFileSync } from "node:fs";
|
|
17
18
|
import { join } from "node:path";
|
|
18
19
|
import { createPrivateKey, createPublicKey, sign as cryptoSign, verify as cryptoVerify } from "node:crypto";
|
|
@@ -304,6 +305,138 @@ function flipSignatureByte(entry) {
|
|
|
304
305
|
const r3 = boundsAlgebra.intersect(base({}), base({}), widenedAuthority, "acknowledge");
|
|
305
306
|
check("obligation meet: acknowledged clamp emitted", r3.ok ? `clamps=${r3.v.clamps.length}` : r3.e, "clamps=1");
|
|
306
307
|
}
|
|
308
|
+
// ---- prior-census loader mode (the compatibility-replay anchors) -----------------
|
|
309
|
+
//
|
|
310
|
+
// A synthetic prior-shaped census — corpus-independent, exactly as this
|
|
311
|
+
// battery requires — proving the TS prior-census mode's red arms: the
|
|
312
|
+
// ordinary loader still binds the registry digest; the prior mode
|
|
313
|
+
// suspends exactly that binding (and the compiled-floor totality) while
|
|
314
|
+
// keeping the census's OWN integrity chain. Mirrors the Elixir
|
|
315
|
+
// corpus_test prior-census describe block.
|
|
316
|
+
import { load, loadPriorCensus } from "./corpus.js";
|
|
317
|
+
import * as digest from "./digest.js";
|
|
318
|
+
import { arr, int, obj, str } from "./value.js";
|
|
319
|
+
function sha256B64Of(bytes) {
|
|
320
|
+
return createHash("sha256").update(bytes).digest("base64url");
|
|
321
|
+
}
|
|
322
|
+
// Builds a one-case census bound to a FOREIGN registry digest, with an
|
|
323
|
+
// applicability map covering only its own cells (a prior floor's shape).
|
|
324
|
+
function priorCensusFixture(overrides) {
|
|
325
|
+
const klass = overrides?.caseClass ?? "valid";
|
|
326
|
+
const caseFile = obj([
|
|
327
|
+
["format", str("agent-blueprint-protocol-conformance-cases")],
|
|
328
|
+
[
|
|
329
|
+
"cases",
|
|
330
|
+
arr([
|
|
331
|
+
obj([
|
|
332
|
+
["id", str("prior-json-" + klass)],
|
|
333
|
+
["surface", str("json.decode")],
|
|
334
|
+
["class", str(klass)],
|
|
335
|
+
["input", obj([["text", str("{}")]])],
|
|
336
|
+
[
|
|
337
|
+
"expected",
|
|
338
|
+
obj([
|
|
339
|
+
["verdict", str("valid")],
|
|
340
|
+
["value", str("{}")],
|
|
341
|
+
]),
|
|
342
|
+
],
|
|
343
|
+
]),
|
|
344
|
+
]),
|
|
345
|
+
],
|
|
346
|
+
]);
|
|
347
|
+
const caseBytes = encode(caseFile);
|
|
348
|
+
if (!caseBytes.ok)
|
|
349
|
+
throw new Error("fixture: case file must encode");
|
|
350
|
+
const caseBytesUtf8 = caseBytes.v;
|
|
351
|
+
const foreignRegistry = "sha-256:" + "A".repeat(43);
|
|
352
|
+
const applicability = overrides?.applicability ??
|
|
353
|
+
obj([
|
|
354
|
+
[
|
|
355
|
+
"json.decode",
|
|
356
|
+
obj([
|
|
357
|
+
["valid", int(1)],
|
|
358
|
+
["unknown_member", obj([["n_a", str("not required at this floor")]])],
|
|
359
|
+
]),
|
|
360
|
+
],
|
|
361
|
+
]);
|
|
362
|
+
const baseMembers = [
|
|
363
|
+
["format", str("agent-blueprint-protocol-conformance-corpus-index")],
|
|
364
|
+
["protocol_revision", int(1)],
|
|
365
|
+
[
|
|
366
|
+
"files",
|
|
367
|
+
arr([
|
|
368
|
+
obj([
|
|
369
|
+
["path", str("cases/json-decode.json")],
|
|
370
|
+
["sha256_base64url", str(sha256B64Of(caseBytesUtf8))],
|
|
371
|
+
["cases", int(1)],
|
|
372
|
+
]),
|
|
373
|
+
]),
|
|
374
|
+
],
|
|
375
|
+
["total_cases", int(1)],
|
|
376
|
+
["public_key_fingerprints", arr([])],
|
|
377
|
+
["applicability", applicability],
|
|
378
|
+
["registry_digest", str(foreignRegistry)],
|
|
379
|
+
];
|
|
380
|
+
const withoutDigest = encode(obj(baseMembers));
|
|
381
|
+
if (!withoutDigest.ok)
|
|
382
|
+
throw new Error("fixture: index must encode");
|
|
383
|
+
const corpusDigest = digest.toTagged(digest.hash("corpus_index", Buffer.from(withoutDigest.v, "utf8")));
|
|
384
|
+
const indexBytes = encode(obj([...baseMembers, ["corpus_digest", str(corpusDigest)]]));
|
|
385
|
+
if (!indexBytes.ok)
|
|
386
|
+
throw new Error("fixture: index must re-encode");
|
|
387
|
+
const map = new Map();
|
|
388
|
+
map.set("index.json", Buffer.from(indexBytes.v, "utf8"));
|
|
389
|
+
map.set("cases/json-decode.json", Buffer.from(caseBytesUtf8, "utf8"));
|
|
390
|
+
return { map, corpusDigest };
|
|
391
|
+
}
|
|
392
|
+
{
|
|
393
|
+
const fixture = priorCensusFixture();
|
|
394
|
+
const ordinary = load(fixture.map);
|
|
395
|
+
check("prior census: ordinary loader binds the registry digest (red arm)", ordinary.ok ? "ok" : ordinary.e, "corpus_index_invalid");
|
|
396
|
+
const prior = loadPriorCensus(fixture.map);
|
|
397
|
+
check("prior census: prior mode loads a foreign-registry census", prior.ok ? "ok" : prior.e, "ok");
|
|
398
|
+
if (prior.ok) {
|
|
399
|
+
check("prior census: identity is the recomputed corpus digest", prior.v.identity, fixture.corpusDigest);
|
|
400
|
+
}
|
|
401
|
+
// Tamper the file's BYTES while keeping it decodable (the id string),
|
|
402
|
+
// so the per-file hash is the check that fires.
|
|
403
|
+
const tampered = new Map(fixture.map);
|
|
404
|
+
tampered.set("cases/json-decode.json", Buffer.from(fixture.map.get("cases/json-decode.json").toString("utf8").replace("prior-json-valid", "tampered-case-id"), "utf8"));
|
|
405
|
+
const hashRed = loadPriorCensus(tampered);
|
|
406
|
+
check("prior census: own per-file hashes still red", hashRed.ok ? "ok" : hashRed.e, "corpus_hash_mismatch");
|
|
407
|
+
const shrunkFloor = priorCensusFixture({ caseClass: "a_class_the_current_floor_dropped" });
|
|
408
|
+
const classRed = loadPriorCensus(shrunkFloor.map);
|
|
409
|
+
check("prior census: a case outside the compiled class set still denies", classRed.ok ? "ok" : classRed.e, "corpus_case_invalid");
|
|
410
|
+
// The census's OWN applicability, self-inconsistent: the "valid" cell is
|
|
411
|
+
// marked n_a while the case sits in it.
|
|
412
|
+
const inconsistent = priorCensusFixture({
|
|
413
|
+
applicability: obj([
|
|
414
|
+
[
|
|
415
|
+
"json.decode",
|
|
416
|
+
obj([
|
|
417
|
+
["valid", obj([["n_a", str("wrongly marked")]])],
|
|
418
|
+
["unknown_member", obj([["n_a", str("not required at this floor")]])],
|
|
419
|
+
]),
|
|
420
|
+
],
|
|
421
|
+
]),
|
|
422
|
+
});
|
|
423
|
+
const applicabilityRed = loadPriorCensus(inconsistent.map);
|
|
424
|
+
check("prior census: an n_a cell carrying a case reds", applicabilityRed.ok ? "ok" : applicabilityRed.e, "corpus_applicability_incomplete");
|
|
425
|
+
// The other census-relative direction: an observed case whose cell is
|
|
426
|
+
// absent from the census's own applicability map (a dropped leaf).
|
|
427
|
+
const unmarked = priorCensusFixture({
|
|
428
|
+
applicability: obj([
|
|
429
|
+
[
|
|
430
|
+
"json.decode",
|
|
431
|
+
obj([
|
|
432
|
+
["unknown_member", obj([["n_a", str("not required at this floor")]])],
|
|
433
|
+
]),
|
|
434
|
+
],
|
|
435
|
+
]),
|
|
436
|
+
});
|
|
437
|
+
const unmarkedRed = loadPriorCensus(unmarked.map);
|
|
438
|
+
check("prior census: a case whose cell is absent from applicability reds", unmarkedRed.ok ? "ok" : unmarkedRed.e, "corpus_applicability_incomplete");
|
|
439
|
+
}
|
|
307
440
|
// ---- summary --------------------------------------------------------------------
|
|
308
441
|
if (failures.length > 0) {
|
|
309
442
|
process.stderr.write(`self-checks FAILED (${failures.length}/${checks}):\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-blueprint-protocol/verifier",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Installable verifier for the Agent Blueprint Protocol: canonical-bytes, digest, signature, bounds, and conformance-corpus verification. Non-authorizing \u2014 evidence, never a decision.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|