@gtrabanco/agentic-workflow-schema 4.0.0 → 4.1.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 CHANGED
@@ -272,6 +272,8 @@ a un cambio en lo que fue aprobado.
272
272
  | `digestPreExecutionArtifactSnapshot(snapshot)` | SHA-256 hexadecimal en minúsculas |
273
273
  | `canonicalizePreExecutionReviewReceipt(receipt)` / `digestPreExecutionReviewReceipt(receipt)` | el mismo par para recibos |
274
274
  | `comparePreExecutionReceiptToSnapshot(receipt, reviewed, current, policyVersion)` | decisión de frescura |
275
+ | `isImpossibleReceiptTimeline({ finishedAt, sourceCommitDate, skewMs })` | predicado puro — devuelve `true` cuando el finish de un recibo predice la fecha de commit de su revisión fuente más allá del skew publicado; `false` cuando honesto; `null` con entrada no parseable (fail-open) |
276
+ | `VERDICTS_BY_STAGE` | mapa de veredictos por etapa: `spec: ["spec-review-pass", "spec-review-fail", "needs-design"]`, `plan: ["plan-review-pass", "plan-review-fail"]` — estrecha qué veredictos puede emitir cada etapa (el `PRE_EXECUTION_VERDICTS` plano mantiene todos los valores) |
275
277
 
276
278
  Toda entrada acepta `unknown`, nunca lanza con entrada hostil y responde con el
277
279
  vocabulario cerrado y redactado `PRE_EXECUTION_DIAGNOSTIC_CODES`: solo códigos y
@@ -298,6 +300,7 @@ conductor pueda mostrar las garantías que el schema no puede expresar.
298
300
  | --- | --- |
299
301
  | `PRE_EXECUTION_STAGES` | `spec` · `plan` — Las dos etapas de revisión. Define el conjunto de artefactos requerido y la matriz de veredictos. |
300
302
  | `PRE_EXECUTION_UNIT_KINDS` | `feature` · `fix` — Una unidad `fix` no tiene mitad de Producto, así que no tiene snapshot de etapa SPEC. |
303
+ | `PRE_EXECUTION_POLICY_VERSION` | `v1` — La versión de política de revisión a la que se ata un receipt. Un cambio de política rota el eje `stale-policy`, así que un receipt revisado bajo otra versión ya no bendice un veredicto. La única autoridad que el CLI de snapshot lee en lugar de un literal hardcodeado. |
301
304
  | `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
305
  | `PRE_EXECUTION_SELECTORS` | `whole-file` · `spec-product-v1` — Cómo se eligieron los bytes atados dentro del archivo. |
303
306
  | `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. |
@@ -311,7 +314,8 @@ conductor pueda mostrar las garantías que el schema no puede expresar.
311
314
  | `PRE_EXECUTION_PARENT_ROLES` | `critic` · `synthesis` · `arbitration` — Qué fue el recibo padre — no hay quórum sobre ellos. |
312
315
  | `PRE_EXECUTION_AUTHOR_EXCLUSIONS` | `enforced` · `not-enforceable` — Si el runtime puede probar que el revisor no creó el conjunto de artefactos. |
313
316
  | `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. |
317
+ | `PRE_EXECUTION_FRESHNESS_CODES` | `invalid-stage` · `invalid-unit` · `stale-policy` · `impossible-timeline` · `stale-context` · `stale-source-revision` · `stale-parent` · `stale-artifact-revision` · `stale-artifact-content` · `missing-receipt-snapshot` — Precedencia ordenada: ver Frescura. |
318
+ | `PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS` | `300000` — La tolerancia de deriva de reloj publicada (±5 min) para el chequeo `impossible-timeline`, de modo que el sensor respaldado por git no pueda desviarse del contrato. |
315
319
  | `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
320
 
317
321
  ### Qué ata el snapshot
@@ -389,7 +393,9 @@ material sin resolver, y `modelDiversity` es una etiqueta veraz
389
393
 
390
394
  `comparePreExecutionReceiptToSnapshot` responde `{ fresh: true }` o
391
395
  `{ fresh: false, reasonCode }` desde el vocabulario cerrado
392
- `PRE_EXECUTION_FRESHNESS_CODES`, con esta precedencia fija: `stale-policy` →
396
+ `PRE_EXECUTION_FRESHNESS_CODES`, con esta precedencia fija: `stale-policy` → [`impossible-timeline` — la línea
397
+ temporal de fin/commit registrada en el propio receipt solo puede juzgarla un
398
+ caller respaldado por git; el comparador puro la deja sin evaluar (fail-open)] →
393
399
  `stale-context` → `stale-source-revision` → `stale-parent` →
394
400
  `stale-artifact-content` → `stale-artifact-revision` → `missing-receipt-snapshot`,
395
401
  y `invalid-stage` / `invalid-unit` se rechazan antes de comparar. Como una reversión
package/README.md CHANGED
@@ -261,6 +261,8 @@ change in what was approved.
261
261
  | `digestPreExecutionArtifactSnapshot(snapshot)` | lowercase SHA-256 hex |
262
262
  | `canonicalizePreExecutionReviewReceipt(receipt)` / `digestPreExecutionReviewReceipt(receipt)` | same pair for receipts |
263
263
  | `comparePreExecutionReceiptToSnapshot(receipt, reviewed, current, policyVersion)` | freshness decision |
264
+ | `isImpossibleReceiptTimeline({ finishedAt, sourceCommitDate, skewMs })` | pure predicate — returns true when a receipt's finish predates its source revision's commit date beyond the published skew; false when honest; null on unparsable input (fail-open) |
265
+ | `VERDICTS_BY_STAGE` | per-stage verdict map: spec, plan narrowings — the flat PRE_EXECUTION_VERDICTS keeps all values |
264
266
 
265
267
  Every entry accepts `unknown`, never throws on hostile input, and answers the
266
268
  closed, redacted diagnostic vocabulary `PRE_EXECUTION_DIAGNOSTIC_CODES` — codes
@@ -287,6 +289,7 @@ display the guarantees the schema cannot state.
287
289
  | --- | --- |
288
290
  | `PRE_EXECUTION_STAGES` | `spec` · `plan` — The two review stages. Drives the required artifact set and the verdict matrix. |
289
291
  | `PRE_EXECUTION_UNIT_KINDS` | `feature` · `fix` — `fix` has no Product half, so it has no SPEC-stage snapshot. |
292
+ | `PRE_EXECUTION_POLICY_VERSION` | `v1` — The review-policy version a receipt is bound to. A policy bump rotates the `stale-policy` axis, so a receipt reviewed under a different version no longer blesses a verdict. The one authority the snapshot CLI reads instead of a hardcoded literal. |
290
293
  | `PRE_EXECUTION_ARTIFACT_KINDS` | `spec` · `acceptance` · `plan` · `tasks` · `testing` · `decisions` · `architecture-notes` · `planning-evidence` · `obligations` — Roles a bound document may play. |
291
294
  | `PRE_EXECUTION_SELECTORS` | `whole-file` · `spec-product-v1` — How bound bytes were chosen out of a file. |
292
295
  | `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. |
@@ -300,7 +303,8 @@ display the guarantees the schema cannot state.
300
303
  | `PRE_EXECUTION_PARENT_ROLES` | `critic` · `synthesis` · `arbitration` — What a parent receipt was — there is no quorum over them. |
301
304
  | `PRE_EXECUTION_AUTHOR_EXCLUSIONS` | `enforced` · `not-enforceable` — Whether the runtime can prove the reviewer did not author the artifact set. |
302
305
  | `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. |
306
+ | `PRE_EXECUTION_FRESHNESS_CODES` | `invalid-stage` · `invalid-unit` · `stale-policy` · `impossible-timeline` · `stale-context` · `stale-source-revision` · `stale-parent` · `stale-artifact-revision` · `stale-artifact-content` · `missing-receipt-snapshot` — Ordered precedence: see Freshness. |
307
+ | `PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS` | `300000` — The published clock-drift tolerance (±5 min) for the `impossible-timeline` check, so the git-backed sensor cannot drift from the contract. |
304
308
  | `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
309
 
306
310
  ### What the snapshot binds
@@ -377,12 +381,15 @@ an unresolved material finding, and `modelDiversity` is a truthful label
377
381
 
378
382
  `comparePreExecutionReceiptToSnapshot` answers `{ fresh: true }` or
379
383
  `{ 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.
384
+ in this fixed precedence: `stale-policy` → [`impossible-timeline` — the
385
+ receipt's own recorded finish/commit timeline is judgeable only by a git-backed
386
+ caller; the pure comparator leaves it un-evaluated (fail-open)] →
387
+ `stale-context` → `stale-source-revision` → `stale-parent` →
388
+ `stale-artifact-content` → `stale-artifact-revision` →
389
+ `missing-receipt-snapshot`, with `invalid-stage` and `invalid-unit` refused
390
+ before any comparison. Because a revert that rotates `artifactRevisionId`
391
+ still changes the snapshot digest, an old PASS cannot be resurrected by editing
392
+ a document back to its previous bytes.
386
393
 
387
394
  ### Published limits
388
395
 
package/dist/index.d.ts CHANGED
@@ -887,5 +887,6 @@ export declare const VERIFICATION_CANONICAL_VECTORS: ReadonlyArray<Readonly<Cano
887
887
  * package-internal, exactly as the verification family's does, and the generated
888
888
  * Draft-07 files are projections of it, not a second authority.
889
889
  */
890
- export { buildPreExecutionArtifactSnapshot, canonicalizePreExecutionArtifactSnapshot, canonicalizePreExecutionReviewReceipt, comparePreExecutionReceiptToSnapshot, digestPreExecutionArtifactSnapshot, digestPreExecutionReviewReceipt, selectSpecProduct, validatePreExecutionArtifactSnapshotV1, validatePreExecutionReceiptAgainstSnapshot, validatePreExecutionReviewReceiptV1, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CANONICAL_VECTORS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_DIAGNOSTIC_CODES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FRESHNESS_CODES, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_RUNTIME_RULES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_SNAPSHOT_SELECTOR, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, SPEC_PRODUCT_REQUIRED_HEADINGS, } from "./pre-execution.js";
890
+ export { buildPreExecutionArtifactSnapshot, canonicalizePreExecutionArtifactSnapshot, canonicalizePreExecutionReviewReceipt, comparePreExecutionReceiptToSnapshot, digestPreExecutionArtifactSnapshot, digestPreExecutionReviewReceipt, selectSpecProduct, validatePreExecutionArtifactSnapshotV1, validatePreExecutionReceiptAgainstSnapshot, validatePreExecutionReviewReceiptV1, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CANONICAL_VECTORS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_DIAGNOSTIC_CODES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FRESHNESS_CODES, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_POLICY_VERSION, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_RUNTIME_RULES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_SNAPSHOT_SELECTOR, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, SPEC_PRODUCT_REQUIRED_HEADINGS, isImpossibleReceiptTimeline, } from "./pre-execution.js";
891
+ export { VERDICTS_BY_STAGE } from "./pre-execution-contract.js";
891
892
  export type { PreExecutionArtifactInput, PreExecutionArtifactKind, PreExecutionArtifactRow, PreExecutionArtifactSnapshotV1, PreExecutionAuthorExclusion, PreExecutionCanonicalVector, PreExecutionContextBinding, PreExecutionContextInput, PreExecutionContextKind, PreExecutionContextPresence, PreExecutionDiagnostic, PreExecutionDiagnosticCode, PreExecutionFinding, PreExecutionFindingClass, PreExecutionFindingResolution, PreExecutionFindingSeverity, PreExecutionFindingVerification, PreExecutionFreshnessCode, PreExecutionFreshnessResult, PreExecutionModelDiversity, PreExecutionParentReceipt, PreExecutionParentRole, PreExecutionReceiptValidationResult, PreExecutionReviewReceiptV1, PreExecutionReviewerRole, PreExecutionSelector, PreExecutionSnapshotBuildInput, PreExecutionSnapshotValidationResult, PreExecutionStage, PreExecutionUnitKind, PreExecutionVerdict, SpecProductSelection, SpecProductSelectorError, } from "./pre-execution.js";
package/dist/index.js CHANGED
@@ -2867,4 +2867,5 @@ export const VERIFICATION_CANONICAL_VECTORS = Object.freeze([
2867
2867
  * package-internal, exactly as the verification family's does, and the generated
2868
2868
  * Draft-07 files are projections of it, not a second authority.
2869
2869
  */
2870
- export { buildPreExecutionArtifactSnapshot, canonicalizePreExecutionArtifactSnapshot, canonicalizePreExecutionReviewReceipt, comparePreExecutionReceiptToSnapshot, digestPreExecutionArtifactSnapshot, digestPreExecutionReviewReceipt, selectSpecProduct, validatePreExecutionArtifactSnapshotV1, validatePreExecutionReceiptAgainstSnapshot, validatePreExecutionReviewReceiptV1, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CANONICAL_VECTORS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_DIAGNOSTIC_CODES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FRESHNESS_CODES, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_RUNTIME_RULES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_SNAPSHOT_SELECTOR, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, SPEC_PRODUCT_REQUIRED_HEADINGS, } from "./pre-execution.js";
2870
+ export { buildPreExecutionArtifactSnapshot, canonicalizePreExecutionArtifactSnapshot, canonicalizePreExecutionReviewReceipt, comparePreExecutionReceiptToSnapshot, digestPreExecutionArtifactSnapshot, digestPreExecutionReviewReceipt, selectSpecProduct, validatePreExecutionArtifactSnapshotV1, validatePreExecutionReceiptAgainstSnapshot, validatePreExecutionReviewReceiptV1, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CANONICAL_VECTORS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_DIAGNOSTIC_CODES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FRESHNESS_CODES, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_POLICY_VERSION, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_RUNTIME_RULES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_SNAPSHOT_SELECTOR, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, SPEC_PRODUCT_REQUIRED_HEADINGS, isImpossibleReceiptTimeline, } from "./pre-execution.js";
2871
+ export { VERDICTS_BY_STAGE } from "./pre-execution-contract.js";
@@ -30,6 +30,13 @@ export declare const PRE_EXECUTION_SELECTORS: readonly ["whole-file", "spec-prod
30
30
  export declare const PRE_EXECUTION_STAGES: readonly ["spec", "plan"];
31
31
  /** The unit family the snapshot belongs to. */
32
32
  export declare const PRE_EXECUTION_UNIT_KINDS: readonly ["feature", "fix"];
33
+ /**
34
+ * The review-policy version a receipt is bound to. A policy bump rotates the
35
+ * `stale-policy` axis: a receipt produced under a different version no longer
36
+ * blesses a verdict. This is the ONE authority the pre-execution snapshot CLI
37
+ * reads instead of a hardcoded literal (known-issue 24 / review finding F49).
38
+ */
39
+ export declare const PRE_EXECUTION_POLICY_VERSION: "v1";
33
40
  /**
34
41
  * The artifact roles a pre-execution snapshot may bind. Deliberately excludes
35
42
  * execution progress (`progress.md`), raw exploration history, and findings
@@ -32,6 +32,13 @@ export const PRE_EXECUTION_SELECTORS = Object.freeze(["whole-file", "spec-produc
32
32
  export const PRE_EXECUTION_STAGES = Object.freeze(["spec", "plan"]);
33
33
  /** The unit family the snapshot belongs to. */
34
34
  export const PRE_EXECUTION_UNIT_KINDS = Object.freeze(["feature", "fix"]);
35
+ /**
36
+ * The review-policy version a receipt is bound to. A policy bump rotates the
37
+ * `stale-policy` axis: a receipt produced under a different version no longer
38
+ * blesses a verdict. This is the ONE authority the pre-execution snapshot CLI
39
+ * reads instead of a hardcoded literal (known-issue 24 / review finding F49).
40
+ */
41
+ export const PRE_EXECUTION_POLICY_VERSION = "v1";
35
42
  /**
36
43
  * The artifact roles a pre-execution snapshot may bind. Deliberately excludes
37
44
  * execution progress (`progress.md`), raw exploration history, and findings
@@ -93,7 +100,11 @@ export const PRE_EXECUTION_AUTHOR_EXCLUSIONS = Object.freeze(["enforced", "not-e
93
100
  /** Which verdicts belong to which stage. There is no generic "approve". */
94
101
  export const VERDICTS_BY_STAGE = Object.freeze({
95
102
  spec: ["spec-review-pass", "spec-review-fail", "needs-design"],
96
- plan: ["plan-review-pass", "plan-review-fail", "needs-design"],
103
+ // fix/162 Decision 11: the machine map no longer sanctions a plan-stage
104
+ // needs-design — ONLY review-spec may emit it. The flat PRE_EXECUTION_VERDICTS
105
+ // keeps the token (review-spec still emits it), and no persisted plan-stage
106
+ // needs-design receipt exists, so the narrowing invalidates nothing historical.
107
+ plan: ["plan-review-pass", "plan-review-fail"],
97
108
  });
98
109
  export const PRE_EXECUTION_MODEL_DIVERSITY = Object.freeze([
99
110
  "same-model", "cross-model", "not-applicable",
@@ -23,9 +23,9 @@
23
23
  * Feature 28, phase P1. Diagnostics follow the package's D16 rule: a frozen code
24
24
  * plus an RFC 6901 pointer, never the submitted value.
25
25
  */
26
- import { PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_STAGES, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS } from "./pre-execution-contract.js";
26
+ import { PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_POLICY_VERSION, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_STAGES, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS } from "./pre-execution-contract.js";
27
27
  import { PRE_EXECUTION_CANONICAL_VECTORS, type PreExecutionCanonicalVector } from "./pre-execution-vectors.js";
28
- export { PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_VERDICTS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_LIMITS, PRE_EXECUTION_CANONICAL_VECTORS, };
28
+ export { PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_VERDICTS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_LIMITS, PRE_EXECUTION_POLICY_VERSION, PRE_EXECUTION_CANONICAL_VECTORS, };
29
29
  export type { PreExecutionCanonicalVector };
30
30
  export { PRE_EXECUTION_RUNTIME_RULES } from "./pre-execution-contract.js";
31
31
  /** The one selector a SPEC-stage snapshot may bind: the Product projection (D2). */
@@ -64,8 +64,31 @@ export interface PreExecutionDiagnostic {
64
64
  * Exactly one fires per call, in the documented precedence, and the comparison
65
65
  * never throws: an input it cannot read is answered with a code.
66
66
  */
67
- export declare const PRE_EXECUTION_FRESHNESS_CODES: readonly ["invalid-stage", "invalid-unit", "stale-policy", "stale-context", "stale-source-revision", "stale-parent", "stale-artifact-revision", "stale-artifact-content", "missing-receipt-snapshot"];
67
+ export declare const PRE_EXECUTION_FRESHNESS_CODES: readonly ["invalid-stage", "invalid-unit", "stale-policy", "impossible-timeline", "stale-context", "stale-source-revision", "stale-parent", "stale-artifact-revision", "stale-artifact-content", "missing-receipt-snapshot"];
68
68
  export type PreExecutionFreshnessCode = (typeof PRE_EXECUTION_FRESHNESS_CODES)[number];
69
+ /**
70
+ * The published clock-drift tolerance for the `impossible-timeline` check.
71
+ * 5 minutes absorbs cross-machine clock drift while staying three orders of
72
+ * magnitude below the field case's ~20 h contradiction (fix/162, PE-010).
73
+ * Published from the schema so the git-backed sensor cannot drift from the
74
+ * contract it prints.
75
+ */
76
+ export declare const PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS = 300000;
77
+ /**
78
+ * The `impossible-timeline` pure predicate: is the receipt's own recorded
79
+ * timeline physically impossible? A finish that predates its recorded source
80
+ * revision's commit date by more than the published skew cannot be honest —
81
+ * the review claiming it would have finished before the bytes it reviewed were
82
+ * committed. Fail-open: an input it cannot read (a missing or unparsable
83
+ * stamp, or an invalid skew) answers `null`, never throws, and never flags a
84
+ * receipt it cannot judge. Git-backed callers evaluate this at the documented
85
+ * comparator slot; the pure comparator (which has no git access) is unchanged.
86
+ */
87
+ export declare function isImpossibleReceiptTimeline({ finishedAt, sourceCommitDate, skewMs, }: {
88
+ finishedAt: unknown;
89
+ sourceCommitDate: unknown;
90
+ skewMs?: unknown;
91
+ }): boolean | null;
69
92
  /** The Product-half headings the selector binds, in required order. */
70
93
  export declare const SPEC_PRODUCT_REQUIRED_HEADINGS: readonly ["Goal", "Branch", "Size", "Dependencies", "Product half", "Design status"];
71
94
  /** One artifact bound into a snapshot, by the exact bytes the reviewer read. */
@@ -343,17 +366,21 @@ export declare function validatePreExecutionReceiptAgainstSnapshot(receipt: unkn
343
366
  * 2. `invalid-stage` / `invalid-unit` — the two snapshots are not the same review
344
367
  * target, which no content comparison can repair;
345
368
  * 3. `stale-policy` — the review policy moved under the approval;
346
- * 4. `stale-context` — an authority the reviewer relied on changed;
347
- * 5. `stale-source-revision` — the repository revision the artifacts were read at
369
+ * 4. `impossible-timeline` — evaluated by git-backed callers at this slot; the
370
+ * pure comparator leaves it un-evaluated (fail-open), because it has no git
371
+ * access and the receipt's own recorded finish/commit timeline is only
372
+ * judgeable against the recorded revision's commit date;
373
+ * 5. `stale-context` — an authority the reviewer relied on changed;
374
+ * 6. `stale-source-revision` — the repository revision the artifacts were read at
348
375
  * changed;
349
- * 6. `stale-parent` — the Product snapshot a Plan approval descends from changed
376
+ * 7. `stale-parent` — the Product snapshot a Plan approval descends from changed
350
377
  * (lineage, so a Product rewrite erases the descendant approval);
351
- * 7. `stale-artifact-content` — a bound artifact's bytes changed;
352
- * 8. `stale-artifact-revision` — the authoring revision rotated with identical
378
+ * 8. `stale-artifact-content` — a bound artifact's bytes changed;
379
+ * 9. `stale-artifact-revision` — the authoring revision rotated with identical
353
380
  * bytes, which is why content is checked first: a mutate-then-revert with a
354
381
  * rotated `artifactRevisionId` still lands here and an older PASS never
355
382
  * resurrects (S6);
356
- * 9. otherwise `{ fresh: true }`.
383
+ * 10. otherwise `{ fresh: true }`.
357
384
  *
358
385
  * Every dimension is reported alone because a caller routes on it: a stale context
359
386
  * asks a sensor to re-read, a stale artifact asks the reviewer to re-read, and a
@@ -24,14 +24,14 @@
24
24
  * plus an RFC 6901 pointer, never the submitted value.
25
25
  */
26
26
  import { VERIFICATION_DIAGNOSTIC_CODES, applyCrossRule, assertCrossRuleVocabulary, captureVerificationInput, createVerificationDiagnosticSink, validateStructure, } from "./verification-contract.js";
27
- import { PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_CONTRACT, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_STAGES, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, } from "./pre-execution-contract.js";
27
+ import { PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_CONTRACT, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_LIMITS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_POLICY_VERSION, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_STAGES, PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_VERDICTS, } from "./pre-execution-contract.js";
28
28
  import { PRE_EXECUTION_CANONICAL_VECTORS, } from "./pre-execution-vectors.js";
29
29
  import { canonicalizeContractInput, canonicalJSONValue, utf8Bytes, utf8ByteCompare, } from "./canonical-json.js";
30
30
  import { sha256HexSync } from "./sha256.js";
31
31
  // ---------------------------------------------------------------------------
32
32
  // Published identities, vocabularies, and types
33
33
  // ---------------------------------------------------------------------------
34
- export { PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_VERDICTS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_LIMITS, PRE_EXECUTION_CANONICAL_VECTORS, };
34
+ export { PRE_EXECUTION_SNAPSHOT_CONTRACT_ID, PRE_EXECUTION_RECEIPT_CONTRACT_ID, PRE_EXECUTION_STAGES, PRE_EXECUTION_UNIT_KINDS, PRE_EXECUTION_SELECTORS, PRE_EXECUTION_ARTIFACT_KINDS, PRE_EXECUTION_CONTEXT_KINDS, PRE_EXECUTION_CONTEXT_PRESENCE, PRE_EXECUTION_VERDICTS, PRE_EXECUTION_FINDING_SEVERITIES, PRE_EXECUTION_FINDING_CLASSES, PRE_EXECUTION_FINDING_VERIFICATION, PRE_EXECUTION_FINDING_RESOLUTIONS, PRE_EXECUTION_REVIEW_ROLES, PRE_EXECUTION_PARENT_ROLES, PRE_EXECUTION_AUTHOR_EXCLUSIONS, PRE_EXECUTION_MODEL_DIVERSITY, PRE_EXECUTION_LIMITS, PRE_EXECUTION_POLICY_VERSION, PRE_EXECUTION_CANONICAL_VECTORS, };
35
35
  export { PRE_EXECUTION_RUNTIME_RULES } from "./pre-execution-contract.js";
36
36
  /** The one selector a SPEC-stage snapshot may bind: the Product projection (D2). */
37
37
  export const PRE_EXECUTION_SNAPSHOT_SELECTOR = "spec-product-v1";
@@ -66,6 +66,7 @@ export const PRE_EXECUTION_FRESHNESS_CODES = Object.freeze([
66
66
  "invalid-stage",
67
67
  "invalid-unit",
68
68
  "stale-policy",
69
+ "impossible-timeline",
69
70
  "stale-context",
70
71
  "stale-source-revision",
71
72
  "stale-parent",
@@ -73,6 +74,41 @@ export const PRE_EXECUTION_FRESHNESS_CODES = Object.freeze([
73
74
  "stale-artifact-content",
74
75
  "missing-receipt-snapshot",
75
76
  ]);
77
+ /**
78
+ * The published clock-drift tolerance for the `impossible-timeline` check.
79
+ * 5 minutes absorbs cross-machine clock drift while staying three orders of
80
+ * magnitude below the field case's ~20 h contradiction (fix/162, PE-010).
81
+ * Published from the schema so the git-backed sensor cannot drift from the
82
+ * contract it prints.
83
+ */
84
+ export const PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS = 300_000;
85
+ /**
86
+ * The `impossible-timeline` pure predicate: is the receipt's own recorded
87
+ * timeline physically impossible? A finish that predates its recorded source
88
+ * revision's commit date by more than the published skew cannot be honest —
89
+ * the review claiming it would have finished before the bytes it reviewed were
90
+ * committed. Fail-open: an input it cannot read (a missing or unparsable
91
+ * stamp, or an invalid skew) answers `null`, never throws, and never flags a
92
+ * receipt it cannot judge. Git-backed callers evaluate this at the documented
93
+ * comparator slot; the pure comparator (which has no git access) is unchanged.
94
+ */
95
+ export function isImpossibleReceiptTimeline({ finishedAt, sourceCommitDate, skewMs = PRE_EXECUTION_RECEIPT_TIMELINE_SKEW_MS, }) {
96
+ const finish = parseStamp(finishedAt);
97
+ const commit = parseStamp(sourceCommitDate);
98
+ const skew = typeof skewMs === "number" && Number.isFinite(skewMs) && skewMs >= 0 ? skewMs : null;
99
+ if (finish === null || commit === null || skew === null)
100
+ return null;
101
+ return finish < commit - skew;
102
+ }
103
+ /** Parse a timestamp-like value to epoch ms, or `null` when it cannot be read. */
104
+ function parseStamp(value) {
105
+ if (typeof value === "number")
106
+ return Number.isFinite(value) ? value : null;
107
+ if (typeof value !== "string" || value.trim() === "")
108
+ return null;
109
+ const ms = Date.parse(value.trim());
110
+ return Number.isNaN(ms) ? null : ms;
111
+ }
76
112
  /** The Product-half headings the selector binds, in required order. */
77
113
  export const SPEC_PRODUCT_REQUIRED_HEADINGS = Object.freeze([
78
114
  "Goal",
@@ -728,17 +764,21 @@ function stale(reasonCode) {
728
764
  * 2. `invalid-stage` / `invalid-unit` — the two snapshots are not the same review
729
765
  * target, which no content comparison can repair;
730
766
  * 3. `stale-policy` — the review policy moved under the approval;
731
- * 4. `stale-context` — an authority the reviewer relied on changed;
732
- * 5. `stale-source-revision` — the repository revision the artifacts were read at
767
+ * 4. `impossible-timeline` — evaluated by git-backed callers at this slot; the
768
+ * pure comparator leaves it un-evaluated (fail-open), because it has no git
769
+ * access and the receipt's own recorded finish/commit timeline is only
770
+ * judgeable against the recorded revision's commit date;
771
+ * 5. `stale-context` — an authority the reviewer relied on changed;
772
+ * 6. `stale-source-revision` — the repository revision the artifacts were read at
733
773
  * changed;
734
- * 6. `stale-parent` — the Product snapshot a Plan approval descends from changed
774
+ * 7. `stale-parent` — the Product snapshot a Plan approval descends from changed
735
775
  * (lineage, so a Product rewrite erases the descendant approval);
736
- * 7. `stale-artifact-content` — a bound artifact's bytes changed;
737
- * 8. `stale-artifact-revision` — the authoring revision rotated with identical
776
+ * 8. `stale-artifact-content` — a bound artifact's bytes changed;
777
+ * 9. `stale-artifact-revision` — the authoring revision rotated with identical
738
778
  * bytes, which is why content is checked first: a mutate-then-revert with a
739
779
  * rotated `artifactRevisionId` still lands here and an older PASS never
740
780
  * resurrects (S6);
741
- * 9. otherwise `{ fresh: true }`.
781
+ * 10. otherwise `{ fresh: true }`.
742
782
  *
743
783
  * Every dimension is reported alone because a caller routes on it: a stale context
744
784
  * asks a sensor to re-read, a stale artifact asks the reviewer to re-read, and a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtrabanco/agentic-workflow-schema",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Versioned machine contracts, JSON Schemas, parsers, and deterministic document snapshots for agentic-workflow orchestration.",
5
5
  "keywords": [
6
6
  "agentic-workflow",
@@ -242,8 +242,7 @@
242
242
  "verdict": {
243
243
  "enum": [
244
244
  "plan-review-pass",
245
- "plan-review-fail",
246
- "needs-design"
245
+ "plan-review-fail"
247
246
  ]
248
247
  }
249
248
  }