@gtrabanco/agentic-workflow-schema 3.4.0 → 4.0.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/README.es.md +294 -0
- package/README.md +290 -0
- package/dist/canonical-json.d.ts +60 -0
- package/dist/canonical-json.js +119 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +105 -169
- package/dist/pre-execution-contract.d.ts +175 -0
- package/dist/pre-execution-contract.js +676 -0
- package/dist/pre-execution-vectors.d.ts +19 -0
- package/dist/pre-execution-vectors.js +35 -0
- package/dist/pre-execution.d.ts +363 -0
- package/dist/pre-execution.js +838 -0
- package/dist/sha256.d.ts +43 -0
- package/dist/sha256.js +189 -0
- package/dist/verification-contract.d.ts +77 -10
- package/dist/verification-contract.js +128 -10
- package/package.json +12 -3
- package/pre-execution-artifact-snapshot.schema.json +383 -0
- package/pre-execution-review-receipt.schema.json +457 -0
- package/skill-outcome.schema.json +1 -1
package/README.es.md
CHANGED
|
@@ -8,6 +8,13 @@ mantiene el envelope establecido de `workflow-status`, pero ofrece a los
|
|
|
8
8
|
drivers headless un resultado menor para las skills de trabajo y estado
|
|
9
9
|
determinista compilado desde documentos.
|
|
10
10
|
|
|
11
|
+
Esa afirmación tiene una forma exacta, y es la forma empaquetada:
|
|
12
|
+
`package.json` no declara `dependencies` y ningún módulo de `src/` lleva un
|
|
13
|
+
especificador estático de builtin (`from "node:…"`), de modo que el mismo código
|
|
14
|
+
se carga en Node, Bun y un navegador. El paquete igualmente usa el SHA-256 del
|
|
15
|
+
host cuando el host lo ofrece, de forma oportunista y en cada llamada: ver
|
|
16
|
+
«Forma canónica y vectores».
|
|
17
|
+
|
|
11
18
|
## Instalación
|
|
12
19
|
|
|
13
20
|
```sh
|
|
@@ -232,6 +239,293 @@ intento no reconocido, y cualquier transición no en la tabla cerrada.
|
|
|
232
239
|
Consulta el [SPEC](../features/24-workflow-transition-decider/SPEC.md) para el
|
|
233
240
|
diseño completo, tablas de transición y vocabulario de códigos de razón.
|
|
234
241
|
|
|
242
|
+
## Revisión pre-ejecución con base en evidencia (feature 28)
|
|
243
|
+
|
|
244
|
+
Dos contratos versionados que permiten que un revisor demuestre *qué bytes* juzgó,
|
|
245
|
+
antes de que exista código:
|
|
246
|
+
|
|
247
|
+
- `PreExecutionArtifactSnapshot v1`
|
|
248
|
+
(`agentic-workflow/pre-execution-artifact-snapshot@1`) — el conjunto exacto de
|
|
249
|
+
artefactos y los contextos autoritativos en los que la revisión pudo apoyarse,
|
|
250
|
+
en una revisión de fuente y una revisión causal de artefactos.
|
|
251
|
+
- `PreExecutionReviewReceipt v1` (`agentic-workflow/pre-execution-review-receipt@1`)
|
|
252
|
+
— el veredicto de un revisor sobre un snapshot, con hallazgos estructurados,
|
|
253
|
+
identidad de autor opaca y una topología de padres opcional.
|
|
254
|
+
|
|
255
|
+
Son contratos **pre-ejecución**. Son distintos de
|
|
256
|
+
`CandidateSnapshotV1`/`ReviewReceiptV1` (que atan un candidato construido) y de
|
|
257
|
+
`VerificationPlanV1`/`VerificationReceiptV1` (que atan la ejecución de comandos).
|
|
258
|
+
Ningún contrato de esta familia sustituye a otro: un recibo de candidato o de
|
|
259
|
+
verificación nunca valida como recibo pre-ejecución, y ninguna aprobación sobrevive
|
|
260
|
+
a un cambio en lo que fue aprobado.
|
|
261
|
+
|
|
262
|
+
### Entradas públicas
|
|
263
|
+
|
|
264
|
+
| Entrada | Contrato |
|
|
265
|
+
| --- | --- |
|
|
266
|
+
| `validatePreExecutionArtifactSnapshotV1(value)` | `{ ok, snapshot?, diagnostics, truncated }` |
|
|
267
|
+
| `validatePreExecutionReviewReceiptV1(value)` | `{ ok, receipt?, diagnostics, truncated }` |
|
|
268
|
+
| `validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, policyVersion)` | la única autoridad de PASS |
|
|
269
|
+
| `buildPreExecutionArtifactSnapshot(input)` | constructor del conjunto por etapa sobre bytes del llamante |
|
|
270
|
+
| `selectSpecProduct(text)` | proyección determinista `spec-product-v1` |
|
|
271
|
+
| `canonicalizePreExecutionArtifactSnapshot(snapshot)` | JSON canónico |
|
|
272
|
+
| `digestPreExecutionArtifactSnapshot(snapshot)` | SHA-256 hexadecimal en minúsculas |
|
|
273
|
+
| `canonicalizePreExecutionReviewReceipt(receipt)` / `digestPreExecutionReviewReceipt(receipt)` | el mismo par para recibos |
|
|
274
|
+
| `comparePreExecutionReceiptToSnapshot(receipt, reviewed, current, policyVersion)` | decisión de frescura |
|
|
275
|
+
|
|
276
|
+
Toda entrada acepta `unknown`, nunca lanza con entrada hostil y responde con el
|
|
277
|
+
vocabulario cerrado y redactado `PRE_EXECUTION_DIAGNOSTIC_CODES`: solo códigos y
|
|
278
|
+
punteros de campo, jamás un valor enviado.
|
|
279
|
+
|
|
280
|
+
### Identificadores de contrato
|
|
281
|
+
|
|
282
|
+
Los dos discriminantes `contract` se exportan como
|
|
283
|
+
`PRE_EXECUTION_SNAPSHOT_CONTRACT_ID` y
|
|
284
|
+
`PRE_EXECUTION_RECEIPT_CONTRACT_ID`; el nombre de la proyección de Producto en la
|
|
285
|
+
etapa SPEC es `PRE_EXECUTION_SNAPSHOT_SELECTOR` (`spec-product-v1`). Compáralos por
|
|
286
|
+
igualdad de cadenas — un snapshot o recibo cuyo `contract` sea cualquier otro valor
|
|
287
|
+
se rechaza con `invalid-value`, y así un documento de candidato, de verificación o
|
|
288
|
+
de una versión futura no se confunde con esta familia.
|
|
289
|
+
|
|
290
|
+
### Vocabularios cerrados
|
|
291
|
+
|
|
292
|
+
Cada valor siguiente se exporta como array congelado; nada fuera de ellos valida.
|
|
293
|
+
`PRE_EXECUTION_RUNTIME_RULES` publica la misma división que describe la prosa —
|
|
294
|
+
`{ snapshot: [...], receipt: [...] }`, cada fila `{ id, claim }` — para que un
|
|
295
|
+
conductor pueda mostrar las garantías que el schema no puede expresar.
|
|
296
|
+
|
|
297
|
+
| Export | Values and meaning |
|
|
298
|
+
| --- | --- |
|
|
299
|
+
| `PRE_EXECUTION_STAGES` | `spec` · `plan` — Las dos etapas de revisión. Define el conjunto de artefactos requerido y la matriz de veredictos. |
|
|
300
|
+
| `PRE_EXECUTION_UNIT_KINDS` | `feature` · `fix` — Una unidad `fix` no tiene mitad de Producto, así que no tiene snapshot de etapa SPEC. |
|
|
301
|
+
| `PRE_EXECUTION_ARTIFACT_KINDS` | `spec` · `acceptance` · `plan` · `tasks` · `testing` · `decisions` · `architecture-notes` · `planning-evidence` · `obligations` — Los roles que un documento atado puede desempeñar. |
|
|
302
|
+
| `PRE_EXECUTION_SELECTORS` | `whole-file` · `spec-product-v1` — Cómo se eligieron los bytes atados dentro del archivo. |
|
|
303
|
+
| `PRE_EXECUTION_CONTEXT_KINDS` | `roadmap-row` · `governing-issue` · `normalized-repository-state` · `architectural-invariants` · `dependency-unit` · `project-guide` — Autoridades en las que el revisor pudo apoyarse. |
|
|
304
|
+
| `PRE_EXECUTION_CONTEXT_PRESENCE` | `present` · `absent` — `absent` es un hecho registrado, no un campo omitido. |
|
|
305
|
+
| `PRE_EXECUTION_VERDICTS` | `spec-review-pass` · `spec-review-fail` · `plan-review-pass` · `plan-review-fail` · `needs-design` — Cada veredicto nombra la etapa donde es legal. |
|
|
306
|
+
| `PRE_EXECUTION_FINDING_SEVERITIES` | `info` · `low` · `medium` · `high` · `critical` — `info` nunca bloquea un PASS por sí solo. |
|
|
307
|
+
| `PRE_EXECUTION_FINDING_CLASSES` | `product` · `plan` · `source` · `environment` · `runtime` — A qué capa del contrato pertenece el hallazgo. |
|
|
308
|
+
| `PRE_EXECUTION_FINDING_VERIFICATION` | `verified` · `unverified` — Solo los hallazgos materiales `verified` pueden sostener un PASS. |
|
|
309
|
+
| `PRE_EXECUTION_FINDING_RESOLUTIONS` | `open` · `resolved` · `dismissed` — `dismissed` exige contrarevidencia registrada. |
|
|
310
|
+
| `PRE_EXECUTION_REVIEW_ROLES` | `reviewer` · `critic` · `synthesizer` · `arbiter` — Qué es este recibo dentro de la topología. |
|
|
311
|
+
| `PRE_EXECUTION_PARENT_ROLES` | `critic` · `synthesis` · `arbitration` — Qué fue el recibo padre — no hay quórum sobre ellos. |
|
|
312
|
+
| `PRE_EXECUTION_AUTHOR_EXCLUSIONS` | `enforced` · `not-enforceable` — Si el runtime puede probar que el revisor no creó el conjunto de artefactos. |
|
|
313
|
+
| `PRE_EXECUTION_MODEL_DIVERSITY` | `same-model` · `cross-model` · `not-applicable` — Una etiqueta veraz, nunca un umbral. |
|
|
314
|
+
| `PRE_EXECUTION_FRESHNESS_CODES` | `invalid-stage` · `invalid-unit` · `stale-policy` · `stale-context` · `stale-source-revision` · `stale-parent` · `stale-artifact-revision` · `stale-artifact-content` · `missing-receipt-snapshot` — Precedencia ordenada: ver Frescura. |
|
|
315
|
+
| `PRE_EXECUTION_DIAGNOSTIC_CODES` | `invalid-type` · `missing-field` · `unknown-field` · `invalid-value` · `limit-exceeded` · `duplicate-id` · `unknown-command` · `invalid-order` · `invalid-stage` · `invalid-exit-state` · `invalid-evidence` · `invalid-skip` · `invalid-fail-fast` · `digest-mismatch` · `verdict-mismatch` · `budget-exceeded` · `missing-artifact-kind` · `invalid-artifact-set` · `invalid-selector` · `invalid-author` · `invalid-context` · `invalid-topology` · `stale-snapshot` · `stale-policy` — Redactado: solo códigos y punteros, jamás un valor enviado. |
|
|
316
|
+
|
|
317
|
+
### Qué ata el snapshot
|
|
318
|
+
|
|
319
|
+
`contract`, `stage` (`spec | plan`), `unitKind` (`feature | fix`), `unitId`,
|
|
320
|
+
`sourceRevision` (object id git de 40 o 64 hex), `artifactRevisionId` (la revisión
|
|
321
|
+
causal — una rotación deliberada aunque el contenido revierta), `artifacts[]`,
|
|
322
|
+
`contexts[]` y `parentSpecSnapshotDigest` (null si y solo si `stage === "spec"`).
|
|
323
|
+
|
|
324
|
+
Cada fila de artefacto es `{ kind, path, selector, byteLength, digest }`:
|
|
325
|
+
|
|
326
|
+
- `kind` ∈ `PRE_EXECUTION_ARTIFACT_KINDS` (`spec`, `acceptance`, `plan`, `tasks`,
|
|
327
|
+
`testing`, `decisions`, `architecture-notes`, `planning-evidence`,
|
|
328
|
+
`obligations`).
|
|
329
|
+
- `path` es relativo al repositorio y normalizado — se rechazan las rutas
|
|
330
|
+
absolutas, las de letra de unidad, las barras invertidas, los segmentos `.`/`..`,
|
|
331
|
+
los separadores finales y los segmentos vacíos.
|
|
332
|
+
- `selector` ∈ `whole-file | spec-product-v1`. La etapa SPEC ata su fila `spec`
|
|
333
|
+
con `spec-product-v1` y con nada más; la etapa Plan ata archivos completos.
|
|
334
|
+
- `byteLength`/`digest` describen la **selección**, no el archivo.
|
|
335
|
+
|
|
336
|
+
Los conjuntos requeridos dependen de la etapa: SPEC = exactamente la fila `spec`
|
|
337
|
+
proyectada; Plan = `spec` + `acceptance`, más lo que exista para el tamaño de la
|
|
338
|
+
unidad (`plan`, `tasks`, `testing`, `decisions`, `architecture-notes`,
|
|
339
|
+
`planning-evidence`, `obligations`). Una unidad `fix` no tiene mitad de Producto, así
|
|
340
|
+
que no tiene snapshot de etapa SPEC — la revisión de Plan es su gate pre-ejecución.
|
|
341
|
+
|
|
342
|
+
Cada fila de contexto es `{ kind, identifier, presence, digest }` con `kind` ∈
|
|
343
|
+
`roadmap-row | governing-issue | normalized-repository-state |
|
|
344
|
+
architectural-invariants | dependency-unit | project-guide`. `presence` es
|
|
345
|
+
`present | absent`; una autoridad presente lleva su digest de 64 hex y una ausente
|
|
346
|
+
ata exactamente `null`. La ausencia es un hecho registrado, no un campo omitido.
|
|
347
|
+
|
|
348
|
+
Las filas tienen un orden canónico — artefactos por bytes UTF-8 de la ruta,
|
|
349
|
+
contextos por `kind` y luego `identifier` — y las identidades son únicas en cada lista.
|
|
350
|
+
|
|
351
|
+
### Las reglas de colección viven en el runtime, no en el schema
|
|
352
|
+
|
|
353
|
+
Las proyecciones publicadas
|
|
354
|
+
([`pre-execution-artifact-snapshot.schema.json`](./pre-execution-artifact-snapshot.schema.json),
|
|
355
|
+
[`pre-execution-review-receipt.schema.json`](./pre-execution-review-receipt.schema.json))
|
|
356
|
+
se generan de la misma definición interna que aplica el runtime, así que nunca
|
|
357
|
+
pueden contradecirla. Draft 07 no tiene forma de expresar propiedades **de una
|
|
358
|
+
colección** (orden por bytes de ruta, unicidad por ruta/`kind`, la matriz
|
|
359
|
+
etapa↔selector, unicidad de identidades de contexto), por lo que esas reglas —
|
|
360
|
+
`artifact-rows-ordered`, `artifact-kinds-unique`, `artifact-paths-unique`,
|
|
361
|
+
`context-rows-ordered`, `context-identities-unique`,
|
|
362
|
+
`spec-artifact-uses-product-selector`, `stage-selector-matrix` — las aplica solo este
|
|
363
|
+
paquete. Valídalas aquí; no confíes en un validador draft-07 de terceros para
|
|
364
|
+
rechazar un snapshot desordenado.
|
|
365
|
+
|
|
366
|
+
### Veredictos, hallazgos y la autoridad del PASS
|
|
367
|
+
|
|
368
|
+
`verdict` ∈ `spec-review-pass | spec-review-fail | plan-review-pass |
|
|
369
|
+
plan-review-fail | needs-design`, y el veredicto debe coincidir con la etapa del
|
|
370
|
+
snapshot. Un hallazgo es `{ id, severity, class, claim, evidenceRefs, verification,
|
|
371
|
+
resolution, resolutionEvidence }` con `severity` ∈ `info | low | medium | high |
|
|
372
|
+
critical`, `class` ∈ `product | plan | source | environment | runtime`,
|
|
373
|
+
`verification` ∈ `verified | unverified` y `resolution` ∈ `open | resolved |
|
|
374
|
+
dismissed`. Todo hallazgo lleva al menos una referencia de evidencia, y un
|
|
375
|
+
descarte exige contrarevidencia registrada.
|
|
376
|
+
|
|
377
|
+
`validatePreExecutionReceiptAgainstSnapshot` es la única entrada que puede bendecir
|
|
378
|
+
un PASS. Lo rechaza mientras algún hallazgo material esté abierto o sin verificar
|
|
379
|
+
(los de severidad `info` nunca bloquean por sí solos), mientras el recibo ate otro
|
|
380
|
+
snapshot, mientras la versión de política difiera, cuando la exclusión de autor
|
|
381
|
+
declarada se viole bajo `enforced`, o cuando la identidad del revisor haya creado
|
|
382
|
+
el conjunto de artefactos (`invalid-author`). Los recibos padres modelan una topología
|
|
383
|
+
critic/synthesis/arbitration acotada (`role` ∈ `critic | synthesis | arbitration`,
|
|
384
|
+
`receiptDigest` único) — **no hay quórum**: los votos nunca borran un hallazgo
|
|
385
|
+
material sin resolver, y `modelDiversity` es una etiqueta veraz
|
|
386
|
+
(`same-model | cross-model | not-applicable`), nunca un umbral.
|
|
387
|
+
|
|
388
|
+
### Frescura
|
|
389
|
+
|
|
390
|
+
`comparePreExecutionReceiptToSnapshot` responde `{ fresh: true }` o
|
|
391
|
+
`{ fresh: false, reasonCode }` desde el vocabulario cerrado
|
|
392
|
+
`PRE_EXECUTION_FRESHNESS_CODES`, con esta precedencia fija: `stale-policy` →
|
|
393
|
+
`stale-context` → `stale-source-revision` → `stale-parent` →
|
|
394
|
+
`stale-artifact-content` → `stale-artifact-revision` → `missing-receipt-snapshot`,
|
|
395
|
+
y `invalid-stage` / `invalid-unit` se rechazan antes de comparar. Como una reversión
|
|
396
|
+
que rota `artifactRevisionId` sigue cambiando el digest del snapshot, un PASS antigo
|
|
397
|
+
no puede resucitar editando un documento de vuelta a sus bytes anteriores.
|
|
398
|
+
|
|
399
|
+
### Límites publicados
|
|
400
|
+
|
|
401
|
+
`PRE_EXECUTION_LIMITS` (todos los topes exactos; un único sumidero de diagnósticos
|
|
402
|
+
compartido con las otras familias):
|
|
403
|
+
|
|
404
|
+
```
|
|
405
|
+
artifacts 32 · contexts 16 · findings 64 · evidencePerFinding 8
|
|
406
|
+
parentReceipts 8 · receiptDiagnostics 8 · diagnostics 50
|
|
407
|
+
unitIdChars 128 · revisionIdChars 128 · idChars 128 · identifierChars 160
|
|
408
|
+
pathChars 1024 · claimChars 2048 · evidenceChars 1024
|
|
409
|
+
resolutionEvidenceChars 2048 · policyChars 64 · diagnosticChars 512
|
|
410
|
+
artifactBytes 4194304 · snapshotBytes 32768 · receiptBytes 65536
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### Forma canónica y vectores
|
|
414
|
+
|
|
415
|
+
La canonicalización ordena las claves de los objetos, preserva el orden declarado de
|
|
416
|
+
los arrays, emite UTF-8 sin espacios y rechaza hojas fuera del modelo de datos JSON.
|
|
417
|
+
Los digests son SHA-256 en minúsculas sobre esos bytes canónicos. Cuatro payloads se
|
|
418
|
+
publican en `PRE_EXECUTION_CANONICAL_VECTORS` (ambas etapas × ambos contratos); la
|
|
419
|
+
suite reproduce cada digest desde su fixture de forma independiente con `node:crypto`,
|
|
420
|
+
así que un cambio en el serializador rompe un test en lugar de mover en silencio la
|
|
421
|
+
linaje de un consumidor.
|
|
422
|
+
|
|
423
|
+
El digest síncrono (`sha256HexSync`, que usa el constructor de artefactos) responde
|
|
424
|
+
desde el SHA-256 nativo del host siempre que el host exponga uno mediante
|
|
425
|
+
`globalThis.process?.getBuiltinModule?.("crypto")` —Node v22.3.0 y v20.16.0 o
|
|
426
|
+
posteriores, y Bun; los navegadores no exponen ese binding— y desde el núcleo puro
|
|
427
|
+
de JavaScript FIPS 180-4 del paquete en todo lo demás. El binding se busca en cada
|
|
428
|
+
llamada y nunca se cachea, así que un bundle que cambia de host no puede quedar
|
|
429
|
+
anclado a un veredicto viejo, y un digest nunca lanza un error porque un builtin del
|
|
430
|
+
host haya fallado. Ambos caminos devuelven un único digest idéntico, SHA-256 en
|
|
431
|
+
minúsculas de 64 caracteres, para bytes idénticos; el caso de tres caminos en
|
|
432
|
+
`test/pre-execution-canonical.test.mjs` enfrenta nativo, JS puro y WebCrypto
|
|
433
|
+
asíncrono, y `npm run probe:sha256-paths` imprime los digests y el coste por camino
|
|
434
|
+
en tu host (solo verificación: no escribe nada).
|
|
435
|
+
|
|
436
|
+
```bash
|
|
437
|
+
npm run gate:pre-execution # tests + drift de schemas + checks de paquete + pack
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
### Ejemplo de uso
|
|
441
|
+
|
|
442
|
+
```ts
|
|
443
|
+
import {
|
|
444
|
+
buildPreExecutionArtifactSnapshot,
|
|
445
|
+
comparePreExecutionReceiptToSnapshot,
|
|
446
|
+
digestPreExecutionArtifactSnapshot,
|
|
447
|
+
selectSpecProduct,
|
|
448
|
+
validatePreExecutionReceiptAgainstSnapshot,
|
|
449
|
+
} from "@gtrabanco/agentic-workflow-schema";
|
|
450
|
+
|
|
451
|
+
const POLICY_VERSION = "2026-08-30";
|
|
452
|
+
|
|
453
|
+
// The caller reads the documents: this package never touches Git or the filesystem.
|
|
454
|
+
const spec = [
|
|
455
|
+
"# Toy feature", "", "## Goal", "", "Ship one usable slice.", "",
|
|
456
|
+
"## Branch", "", "`feat/toy`", "", "## Size", "", "`S`", "",
|
|
457
|
+
"## Dependencies", "", "- none", "", "## Product half", "", "### Scope", "",
|
|
458
|
+
"- **S1:** the slice.", "", "## Design status", "", "`designed`", "",
|
|
459
|
+
].join("\n");
|
|
460
|
+
|
|
461
|
+
/** 1. Freeze the exact bytes a reviewer may rely on, at one causal revision. */
|
|
462
|
+
async function freeze(artifactRevisionId: string) {
|
|
463
|
+
const built = buildPreExecutionArtifactSnapshot({
|
|
464
|
+
stage: "spec",
|
|
465
|
+
unitKind: "feature",
|
|
466
|
+
unitId: "toy",
|
|
467
|
+
sourceRevision: "8ab22ea6c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6",
|
|
468
|
+
artifactRevisionId,
|
|
469
|
+
files: [{ kind: "spec", path: "docs/features/toy/SPEC.md", content: spec }],
|
|
470
|
+
contexts: [{ kind: "governing-issue", identifier: "#146", content: "the issue body" }],
|
|
471
|
+
});
|
|
472
|
+
const snapshot = built.ok ? built.snapshot : undefined;
|
|
473
|
+
if (!snapshot) throw new Error(JSON.stringify(built.diagnostics));
|
|
474
|
+
return snapshot;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
const snapshot = await freeze("rev-0001");
|
|
478
|
+
|
|
479
|
+
// 2. A reviewer records a verdict bound to that digest, never to the mutable file.
|
|
480
|
+
const receipt = {
|
|
481
|
+
contract: "agentic-workflow/pre-execution-review-receipt@1",
|
|
482
|
+
id: "review-0001",
|
|
483
|
+
stage: snapshot.stage,
|
|
484
|
+
snapshotDigest: digestPreExecutionArtifactSnapshot(snapshot),
|
|
485
|
+
verdict: "spec-review-pass",
|
|
486
|
+
findings: [],
|
|
487
|
+
reviewer: "reviewer-7",
|
|
488
|
+
sessionId: "session-7",
|
|
489
|
+
reviewerRole: "reviewer",
|
|
490
|
+
authorId: "author-3",
|
|
491
|
+
authorExclusion: "enforced",
|
|
492
|
+
contextClean: true,
|
|
493
|
+
modelDiversity: "cross-model",
|
|
494
|
+
policyVersion: POLICY_VERSION,
|
|
495
|
+
startedAt: "2026-08-30T00:00:00Z",
|
|
496
|
+
finishedAt: "2026-08-30T00:04:00Z",
|
|
497
|
+
parentReceipts: [],
|
|
498
|
+
diagnostics: [],
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
// 3. Only this entry can bless a PASS; it answers with codes, never submitted values.
|
|
502
|
+
const blessed = validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, POLICY_VERSION);
|
|
503
|
+
if (!blessed.ok) throw new Error(JSON.stringify(blessed.diagnostics));
|
|
504
|
+
|
|
505
|
+
// 4. Before executing, freeze again: unchanged authority stays fresh.
|
|
506
|
+
const fresh = comparePreExecutionReceiptToSnapshot(
|
|
507
|
+
receipt, snapshot, await freeze("rev-0001"), POLICY_VERSION,
|
|
508
|
+
);
|
|
509
|
+
if (fresh.fresh !== true) throw new Error(JSON.stringify(fresh));
|
|
510
|
+
|
|
511
|
+
// 5. Edit, revert, and rotate the revision anyway and the PASS is void: a stale
|
|
512
|
+
// approval can never be resurrected by restoring the previous bytes.
|
|
513
|
+
const stale = comparePreExecutionReceiptToSnapshot(
|
|
514
|
+
receipt, snapshot, await freeze("rev-0002"), POLICY_VERSION,
|
|
515
|
+
);
|
|
516
|
+
if (stale.fresh === true || stale.reasonCode !== "stale-artifact-revision") {
|
|
517
|
+
throw new Error(JSON.stringify(stale));
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// 6. The projection is why a plan-side write cannot erase Product lineage: the
|
|
521
|
+
// selector never saw anything outside the named Product headings.
|
|
522
|
+
const projection = selectSpecProduct(`${spec}\n## Engineering half\n\n### Phases\n\n- P1\n`);
|
|
523
|
+
if (projection.ok !== true) throw new Error(JSON.stringify(projection.errors));
|
|
524
|
+
if (projection.content.includes("Engineering half")) throw new Error("the projection leaked");
|
|
525
|
+
|
|
526
|
+
console.log("review bound", projection.byteLength, receipt.snapshotDigest.slice(0, 12), fresh, stale);
|
|
527
|
+
```
|
|
528
|
+
|
|
235
529
|
## Contratos de Verificación por Etapas (feature 26)
|
|
236
530
|
|
|
237
531
|
Dos contratos wire versionados para verificación por etapas:
|
package/README.md
CHANGED
|
@@ -8,6 +8,12 @@ keeps the established `workflow-status` envelope while giving headless drivers
|
|
|
8
8
|
a smaller result for working skills and deterministic state compiled from
|
|
9
9
|
documents.
|
|
10
10
|
|
|
11
|
+
That claim has an exact shape, and it is the shipped shape: `package.json`
|
|
12
|
+
declares no `dependencies`, and no module under `src/` carries a static built-in
|
|
13
|
+
specifier (`from "node:…"`) — so the same code loads in Node, Bun and a browser.
|
|
14
|
+
The package still takes the host's own SHA-256 when the host happens to offer
|
|
15
|
+
one, opportunistically and per call: see "Canonical form and vectors".
|
|
16
|
+
|
|
11
17
|
## Install
|
|
12
18
|
|
|
13
19
|
```sh
|
|
@@ -222,6 +228,290 @@ fixes are patch releases. See
|
|
|
222
228
|
[programmatic orchestration](../../docs/workflow/ORCHESTRATION.md) for the
|
|
223
229
|
driver protocol.
|
|
224
230
|
|
|
231
|
+
## Evidence-Grounded Pre-Execution Review (feature 28)
|
|
232
|
+
|
|
233
|
+
Two versioned wire contracts that let a reviewer prove *which bytes* it judged,
|
|
234
|
+
before any code exists:
|
|
235
|
+
|
|
236
|
+
- `PreExecutionArtifactSnapshot v1`
|
|
237
|
+
(`agentic-workflow/pre-execution-artifact-snapshot@1`) — the exact artifact set
|
|
238
|
+
and authoritative contexts a review was allowed to rely on, at one source
|
|
239
|
+
revision and one causal artifact revision.
|
|
240
|
+
- `PreExecutionReviewReceipt v1` (`agentic-workflow/pre-execution-review-receipt@1`)
|
|
241
|
+
— one reviewer's verdict over one snapshot, with structured findings, opaque
|
|
242
|
+
author identity, and an optional parent topology.
|
|
243
|
+
|
|
244
|
+
These are **pre-execution** contracts. They are distinct from
|
|
245
|
+
`CandidateSnapshotV1`/`ReviewReceiptV1` (which bind a built candidate) and from
|
|
246
|
+
`VerificationPlanV1`/`VerificationReceiptV1` (which bind command execution). No
|
|
247
|
+
contract in this family substitutes for another: a candidate or verification
|
|
248
|
+
receipt never validates as a pre-execution receipt, and no approval survives a
|
|
249
|
+
change in what was approved.
|
|
250
|
+
|
|
251
|
+
### Public entries
|
|
252
|
+
|
|
253
|
+
| Entry | Contract |
|
|
254
|
+
| --- | --- |
|
|
255
|
+
| `validatePreExecutionArtifactSnapshotV1(value)` | `{ ok, snapshot?, diagnostics, truncated }` |
|
|
256
|
+
| `validatePreExecutionReviewReceiptV1(value)` | `{ ok, receipt?, diagnostics, truncated }` |
|
|
257
|
+
| `validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, policyVersion)` | the only PASS authority |
|
|
258
|
+
| `buildPreExecutionArtifactSnapshot(input)` | stage-aware set builder over caller-supplied bytes |
|
|
259
|
+
| `selectSpecProduct(text)` | deterministic `spec-product-v1` projection |
|
|
260
|
+
| `canonicalizePreExecutionArtifactSnapshot(snapshot)` | canonical JSON string |
|
|
261
|
+
| `digestPreExecutionArtifactSnapshot(snapshot)` | lowercase SHA-256 hex |
|
|
262
|
+
| `canonicalizePreExecutionReviewReceipt(receipt)` / `digestPreExecutionReviewReceipt(receipt)` | same pair for receipts |
|
|
263
|
+
| `comparePreExecutionReceiptToSnapshot(receipt, reviewed, current, policyVersion)` | freshness decision |
|
|
264
|
+
|
|
265
|
+
Every entry accepts `unknown`, never throws on hostile input, and answers the
|
|
266
|
+
closed, redacted diagnostic vocabulary `PRE_EXECUTION_DIAGNOSTIC_CODES` — codes
|
|
267
|
+
and field pointers only, never a submitted value.
|
|
268
|
+
|
|
269
|
+
### Contract identifiers
|
|
270
|
+
|
|
271
|
+
The two `contract` discriminators are exported as
|
|
272
|
+
`PRE_EXECUTION_SNAPSHOT_CONTRACT_ID` and
|
|
273
|
+
`PRE_EXECUTION_RECEIPT_CONTRACT_ID`; the SPEC-stage Product projection name is
|
|
274
|
+
`PRE_EXECUTION_SNAPSHOT_SELECTOR` (`spec-product-v1`). Compare them by string
|
|
275
|
+
equality — a snapshot or receipt whose `contract` is anything else is refused with
|
|
276
|
+
`invalid-value`, which is what keeps a candidate, verification, or future-version
|
|
277
|
+
document from being mistaken for one of these.
|
|
278
|
+
|
|
279
|
+
### Closed vocabularies
|
|
280
|
+
|
|
281
|
+
Every value below is exported as a frozen array; nothing outside them validates.
|
|
282
|
+
`PRE_EXECUTION_RUNTIME_RULES` publishes the same split the prose describes —
|
|
283
|
+
`{ snapshot: [...], receipt: [...] }`, each row `{ id, claim }` — so a driver can
|
|
284
|
+
display the guarantees the schema cannot state.
|
|
285
|
+
|
|
286
|
+
| Export | Values and meaning |
|
|
287
|
+
| --- | --- |
|
|
288
|
+
| `PRE_EXECUTION_STAGES` | `spec` · `plan` — The two review stages. Drives the required artifact set and the verdict matrix. |
|
|
289
|
+
| `PRE_EXECUTION_UNIT_KINDS` | `feature` · `fix` — `fix` has no Product half, so it has no SPEC-stage snapshot. |
|
|
290
|
+
| `PRE_EXECUTION_ARTIFACT_KINDS` | `spec` · `acceptance` · `plan` · `tasks` · `testing` · `decisions` · `architecture-notes` · `planning-evidence` · `obligations` — Roles a bound document may play. |
|
|
291
|
+
| `PRE_EXECUTION_SELECTORS` | `whole-file` · `spec-product-v1` — How bound bytes were chosen out of a file. |
|
|
292
|
+
| `PRE_EXECUTION_CONTEXT_KINDS` | `roadmap-row` · `governing-issue` · `normalized-repository-state` · `architectural-invariants` · `dependency-unit` · `project-guide` — Authorities a reviewer was allowed to rely on. |
|
|
293
|
+
| `PRE_EXECUTION_CONTEXT_PRESENCE` | `present` · `absent` — `absent` is a recorded fact, never a skipped field. |
|
|
294
|
+
| `PRE_EXECUTION_VERDICTS` | `spec-review-pass` · `spec-review-fail` · `plan-review-pass` · `plan-review-fail` · `needs-design` — Each verdict names the stage it is legal on. |
|
|
295
|
+
| `PRE_EXECUTION_FINDING_SEVERITIES` | `info` · `low` · `medium` · `high` · `critical` — `info` never blocks a PASS on its own merits. |
|
|
296
|
+
| `PRE_EXECUTION_FINDING_CLASSES` | `product` · `plan` · `source` · `environment` · `runtime` — Which contract layer the finding is about. |
|
|
297
|
+
| `PRE_EXECUTION_FINDING_VERIFICATION` | `verified` · `unverified` — Only `verified` material findings can support a PASS. |
|
|
298
|
+
| `PRE_EXECUTION_FINDING_RESOLUTIONS` | `open` · `resolved` · `dismissed` — `dismissed` requires recorded counter-evidence. |
|
|
299
|
+
| `PRE_EXECUTION_REVIEW_ROLES` | `reviewer` · `critic` · `synthesizer` · `arbiter` — What this receipt is in the topology. |
|
|
300
|
+
| `PRE_EXECUTION_PARENT_ROLES` | `critic` · `synthesis` · `arbitration` — What a parent receipt was — there is no quorum over them. |
|
|
301
|
+
| `PRE_EXECUTION_AUTHOR_EXCLUSIONS` | `enforced` · `not-enforceable` — Whether the runtime can prove the reviewer did not author the artifact set. |
|
|
302
|
+
| `PRE_EXECUTION_MODEL_DIVERSITY` | `same-model` · `cross-model` · `not-applicable` — A truthful label, never a threshold. |
|
|
303
|
+
| `PRE_EXECUTION_FRESHNESS_CODES` | `invalid-stage` · `invalid-unit` · `stale-policy` · `stale-context` · `stale-source-revision` · `stale-parent` · `stale-artifact-revision` · `stale-artifact-content` · `missing-receipt-snapshot` — Ordered precedence: see Freshness. |
|
|
304
|
+
| `PRE_EXECUTION_DIAGNOSTIC_CODES` | `invalid-type` · `missing-field` · `unknown-field` · `invalid-value` · `limit-exceeded` · `duplicate-id` · `unknown-command` · `invalid-order` · `invalid-stage` · `invalid-exit-state` · `invalid-evidence` · `invalid-skip` · `invalid-fail-fast` · `digest-mismatch` · `verdict-mismatch` · `budget-exceeded` · `missing-artifact-kind` · `invalid-artifact-set` · `invalid-selector` · `invalid-author` · `invalid-context` · `invalid-topology` · `stale-snapshot` · `stale-policy` — Redacted: codes and pointers only, never a submitted value. |
|
|
305
|
+
|
|
306
|
+
### What the snapshot binds
|
|
307
|
+
|
|
308
|
+
`contract`, `stage` (`spec | plan`), `unitKind` (`feature | fix`), `unitId`,
|
|
309
|
+
`sourceRevision` (40- or 64-hex git object id), `artifactRevisionId` (the causal
|
|
310
|
+
revision — a deliberate rotation even when content reverts), `artifacts[]`,
|
|
311
|
+
`contexts[]`, and `parentSpecSnapshotDigest` (null iff `stage === "spec"`).
|
|
312
|
+
|
|
313
|
+
Each artifact row is `{ kind, path, selector, byteLength, digest }`:
|
|
314
|
+
|
|
315
|
+
- `kind` ∈ `PRE_EXECUTION_ARTIFACT_KINDS` (`spec`, `acceptance`, `plan`, `tasks`,
|
|
316
|
+
`testing`, `decisions`, `architecture-notes`, `planning-evidence`,
|
|
317
|
+
`obligations`).
|
|
318
|
+
- `path` is normalized repository-relative — absolute, drive-letter, backslash,
|
|
319
|
+
`.`/`..` segments, trailing separators, and empty segments are refused.
|
|
320
|
+
- `selector` ∈ `whole-file | spec-product-v1`. The SPEC stage binds its SPEC row
|
|
321
|
+
with `spec-product-v1` and nothing else; the Plan stage binds whole files.
|
|
322
|
+
- `byteLength`/`digest` describe the **selection**, not the file.
|
|
323
|
+
|
|
324
|
+
Required sets are stage-driven: SPEC = exactly the projected `spec` row;
|
|
325
|
+
Plan = `spec` + `acceptance`, plus whichever of `plan`, `tasks`, `testing`,
|
|
326
|
+
`decisions`, `architecture-notes`, `planning-evidence`, `obligations` exist for
|
|
327
|
+
that unit size. A `fix` unit has no Product half, so it has no SPEC-stage
|
|
328
|
+
snapshot — Plan review is its pre-execution gate.
|
|
329
|
+
|
|
330
|
+
Each context row is `{ kind, identifier, presence, digest }` with `kind` ∈
|
|
331
|
+
`roadmap-row | governing-issue | normalized-repository-state |
|
|
332
|
+
architectural-invariants | dependency-unit | project-guide`. `presence` is
|
|
333
|
+
`present | absent`; a present authority carries its 64-hex digest, an absent one
|
|
334
|
+
binds exactly `null`. Absence is a recorded fact, never a skipped field.
|
|
335
|
+
|
|
336
|
+
Rows are canonically ordered — artifacts by UTF-8 path bytes, contexts by kind
|
|
337
|
+
then identifier — and identities are unique within each list.
|
|
338
|
+
|
|
339
|
+
### Collection rules live in the runtime, not the schema
|
|
340
|
+
|
|
341
|
+
The published projections
|
|
342
|
+
([`pre-execution-artifact-snapshot.schema.json`](./pre-execution-artifact-snapshot.schema.json),
|
|
343
|
+
[`pre-execution-review-receipt.schema.json`](./pre-execution-review-receipt.schema.json))
|
|
344
|
+
are rendered from the same internal definition the runtime enforces, so they can
|
|
345
|
+
never contradict it. Draft 07 has no form for properties **of a collection**
|
|
346
|
+
(path-byte ordering, per-kind/per-path uniqueness, the stage↔selector matrix,
|
|
347
|
+
context identity uniqueness), so those five-plus rules —
|
|
348
|
+
`artifact-rows-ordered`, `artifact-kinds-unique`, `artifact-paths-unique`,
|
|
349
|
+
`context-rows-ordered`, `context-identities-unique`,
|
|
350
|
+
`spec-artifact-uses-product-selector`, `stage-selector-matrix` — are enforced by
|
|
351
|
+
this package only. Validate them here; do not trust a third-party draft-07
|
|
352
|
+
validator to refuse an unordered snapshot.
|
|
353
|
+
|
|
354
|
+
### Verdicts, findings, and the PASS authority
|
|
355
|
+
|
|
356
|
+
`verdict` ∈ `spec-review-pass | spec-review-fail | plan-review-pass |
|
|
357
|
+
plan-review-fail | needs-design`, and the verdict must match the snapshot stage.
|
|
358
|
+
A finding is `{ id, severity, class, claim, evidenceRefs, verification,
|
|
359
|
+
resolution, resolutionEvidence }` with `severity` ∈ `info | low | medium | high
|
|
360
|
+
| critical`, `class` ∈ `product | plan | source | environment | runtime`,
|
|
361
|
+
`verification` ∈ `verified | unverified`, and `resolution` ∈ `open | resolved |
|
|
362
|
+
dismissed`. Every finding carries at least one evidence reference, and a
|
|
363
|
+
dismissal requires recorded counter-evidence.
|
|
364
|
+
|
|
365
|
+
`validatePreExecutionReceiptAgainstSnapshot` is the only entry that can bless a
|
|
366
|
+
PASS. It refuses a PASS while any material finding is open or unverified
|
|
367
|
+
(`info`-severity findings never block on their own merits), while the receipt
|
|
368
|
+
binds a different snapshot, while the policy version differs, when the claimed
|
|
369
|
+
author exclusion is violated under `enforced`, or when the reviewer's own
|
|
370
|
+
identity authored the artifact set (`invalid-author`). Parent receipts model a
|
|
371
|
+
bounded critic/synthesis/arbitration topology (`role` ∈ `critic | synthesis |
|
|
372
|
+
arbitration`, unique `receiptDigest`) — there is **no quorum**: votes never erase
|
|
373
|
+
an unresolved material finding, and `modelDiversity` is a truthful label
|
|
374
|
+
(`same-model | cross-model | not-applicable`), never a threshold.
|
|
375
|
+
|
|
376
|
+
### Freshness
|
|
377
|
+
|
|
378
|
+
`comparePreExecutionReceiptToSnapshot` answers `{ fresh: true }` or
|
|
379
|
+
`{ fresh: false, reasonCode }` from the closed `PRE_EXECUTION_FRESHNESS_CODES`,
|
|
380
|
+
in this fixed precedence: `stale-policy` → `stale-context` →
|
|
381
|
+
`stale-source-revision` → `stale-parent` → `stale-artifact-content` →
|
|
382
|
+
`stale-artifact-revision` → `missing-receipt-snapshot`, with `invalid-stage` and
|
|
383
|
+
`invalid-unit` refused before any comparison. Because a revert that rotates
|
|
384
|
+
`artifactRevisionId` still changes the snapshot digest, an old PASS cannot be
|
|
385
|
+
resurrected by editing a document back to its previous bytes.
|
|
386
|
+
|
|
387
|
+
### Published limits
|
|
388
|
+
|
|
389
|
+
`PRE_EXECUTION_LIMITS` (all exact ceilings, one diagnostic sink shared with the
|
|
390
|
+
other families):
|
|
391
|
+
|
|
392
|
+
```
|
|
393
|
+
artifacts 32 · contexts 16 · findings 64 · evidencePerFinding 8
|
|
394
|
+
parentReceipts 8 · receiptDiagnostics 8 · diagnostics 50
|
|
395
|
+
unitIdChars 128 · revisionIdChars 128 · idChars 128 · identifierChars 160
|
|
396
|
+
pathChars 1024 · claimChars 2048 · evidenceChars 1024
|
|
397
|
+
resolutionEvidenceChars 2048 · policyChars 64 · diagnosticChars 512
|
|
398
|
+
artifactBytes 4194304 · snapshotBytes 32768 · receiptBytes 65536
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### Canonical form and vectors
|
|
402
|
+
|
|
403
|
+
Canonicalization sorts object keys, preserves declared array order, emits UTF-8
|
|
404
|
+
with no whitespace, and refuses leaves outside the JSON data model. Digests are
|
|
405
|
+
lowercase SHA-256 over those canonical bytes. Four payloads are published in
|
|
406
|
+
`PRE_EXECUTION_CANONICAL_VECTORS` (both stages × both contracts); the suite
|
|
407
|
+
reproduces every digest from its fixture independently through `node:crypto`, so
|
|
408
|
+
a serializer change breaks a test instead of silently moving a consumer's lineage.
|
|
409
|
+
|
|
410
|
+
The synchronous digest (`sha256HexSync`, used by the artifact builder) answers
|
|
411
|
+
from the host's native SHA-256 wherever the host exposes one through
|
|
412
|
+
`globalThis.process?.getBuiltinModule?.("crypto")` — Node v22.3.0 and v20.16.0
|
|
413
|
+
and later, and Bun; browsers expose no such binding — and from this package's
|
|
414
|
+
pure-JS FIPS 180-4 core everywhere else. The binding is looked up on every call
|
|
415
|
+
and never cached, so a bundle that moves between hosts cannot strand a stale
|
|
416
|
+
verdict, and a digest never throws because a host builtin did. Both paths return
|
|
417
|
+
one identical lowercase 64-hex digest for identical bytes; the three-path case in
|
|
418
|
+
`test/pre-execution-canonical.test.mjs` pins native, pure JS and async WebCrypto
|
|
419
|
+
against each other, and `npm run probe:sha256-paths` prints the digests and the
|
|
420
|
+
per-path cost of each on your host (check-only: it writes nothing).
|
|
421
|
+
|
|
422
|
+
```bash
|
|
423
|
+
npm run gate:pre-execution # tests + schema drift + package checks + pack
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### Consumer example
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
import {
|
|
430
|
+
buildPreExecutionArtifactSnapshot,
|
|
431
|
+
comparePreExecutionReceiptToSnapshot,
|
|
432
|
+
digestPreExecutionArtifactSnapshot,
|
|
433
|
+
selectSpecProduct,
|
|
434
|
+
validatePreExecutionReceiptAgainstSnapshot,
|
|
435
|
+
} from "@gtrabanco/agentic-workflow-schema";
|
|
436
|
+
|
|
437
|
+
const POLICY_VERSION = "2026-08-30";
|
|
438
|
+
|
|
439
|
+
// The caller reads the documents: this package never touches Git or the filesystem.
|
|
440
|
+
const spec = [
|
|
441
|
+
"# Toy feature", "", "## Goal", "", "Ship one usable slice.", "",
|
|
442
|
+
"## Branch", "", "`feat/toy`", "", "## Size", "", "`S`", "",
|
|
443
|
+
"## Dependencies", "", "- none", "", "## Product half", "", "### Scope", "",
|
|
444
|
+
"- **S1:** the slice.", "", "## Design status", "", "`designed`", "",
|
|
445
|
+
].join("\n");
|
|
446
|
+
|
|
447
|
+
/** 1. Freeze the exact bytes a reviewer may rely on, at one causal revision. */
|
|
448
|
+
async function freeze(artifactRevisionId: string) {
|
|
449
|
+
const built = buildPreExecutionArtifactSnapshot({
|
|
450
|
+
stage: "spec",
|
|
451
|
+
unitKind: "feature",
|
|
452
|
+
unitId: "toy",
|
|
453
|
+
sourceRevision: "8ab22ea6c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f6",
|
|
454
|
+
artifactRevisionId,
|
|
455
|
+
files: [{ kind: "spec", path: "docs/features/toy/SPEC.md", content: spec }],
|
|
456
|
+
contexts: [{ kind: "governing-issue", identifier: "#146", content: "the issue body" }],
|
|
457
|
+
});
|
|
458
|
+
const snapshot = built.ok ? built.snapshot : undefined;
|
|
459
|
+
if (!snapshot) throw new Error(JSON.stringify(built.diagnostics));
|
|
460
|
+
return snapshot;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const snapshot = await freeze("rev-0001");
|
|
464
|
+
|
|
465
|
+
// 2. A reviewer records a verdict bound to that digest, never to the mutable file.
|
|
466
|
+
const receipt = {
|
|
467
|
+
contract: "agentic-workflow/pre-execution-review-receipt@1",
|
|
468
|
+
id: "review-0001",
|
|
469
|
+
stage: snapshot.stage,
|
|
470
|
+
snapshotDigest: digestPreExecutionArtifactSnapshot(snapshot),
|
|
471
|
+
verdict: "spec-review-pass",
|
|
472
|
+
findings: [],
|
|
473
|
+
reviewer: "reviewer-7",
|
|
474
|
+
sessionId: "session-7",
|
|
475
|
+
reviewerRole: "reviewer",
|
|
476
|
+
authorId: "author-3",
|
|
477
|
+
authorExclusion: "enforced",
|
|
478
|
+
contextClean: true,
|
|
479
|
+
modelDiversity: "cross-model",
|
|
480
|
+
policyVersion: POLICY_VERSION,
|
|
481
|
+
startedAt: "2026-08-30T00:00:00Z",
|
|
482
|
+
finishedAt: "2026-08-30T00:04:00Z",
|
|
483
|
+
parentReceipts: [],
|
|
484
|
+
diagnostics: [],
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// 3. Only this entry can bless a PASS; it answers with codes, never submitted values.
|
|
488
|
+
const blessed = validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, POLICY_VERSION);
|
|
489
|
+
if (!blessed.ok) throw new Error(JSON.stringify(blessed.diagnostics));
|
|
490
|
+
|
|
491
|
+
// 4. Before executing, freeze again: unchanged authority stays fresh.
|
|
492
|
+
const fresh = comparePreExecutionReceiptToSnapshot(
|
|
493
|
+
receipt, snapshot, await freeze("rev-0001"), POLICY_VERSION,
|
|
494
|
+
);
|
|
495
|
+
if (fresh.fresh !== true) throw new Error(JSON.stringify(fresh));
|
|
496
|
+
|
|
497
|
+
// 5. Edit, revert, and rotate the revision anyway and the PASS is void: a stale
|
|
498
|
+
// approval can never be resurrected by restoring the previous bytes.
|
|
499
|
+
const stale = comparePreExecutionReceiptToSnapshot(
|
|
500
|
+
receipt, snapshot, await freeze("rev-0002"), POLICY_VERSION,
|
|
501
|
+
);
|
|
502
|
+
if (stale.fresh === true || stale.reasonCode !== "stale-artifact-revision") {
|
|
503
|
+
throw new Error(JSON.stringify(stale));
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
// 6. The projection is why a plan-side write cannot erase Product lineage: the
|
|
507
|
+
// selector never saw anything outside the named Product headings.
|
|
508
|
+
const projection = selectSpecProduct(`${spec}\n## Engineering half\n\n### Phases\n\n- P1\n`);
|
|
509
|
+
if (projection.ok !== true) throw new Error(JSON.stringify(projection.errors));
|
|
510
|
+
if (projection.content.includes("Engineering half")) throw new Error("the projection leaked");
|
|
511
|
+
|
|
512
|
+
console.log("review bound", projection.byteLength, receipt.snapshotDigest.slice(0, 12), fresh, stale);
|
|
513
|
+
```
|
|
514
|
+
|
|
225
515
|
## Staged Verification Contracts (feature 26)
|
|
226
516
|
|
|
227
517
|
Two versioned wire contracts for staged verification:
|