@gtrabanco/agentic-workflow-schema 4.1.2 → 4.3.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.md +24 -4
- package/dist/continuation-vectors.d.ts +22 -0
- package/dist/continuation-vectors.js +28 -0
- package/dist/continuation.d.ts +117 -0
- package/dist/continuation.js +260 -0
- package/dist/index.d.ts +29 -1
- package/dist/index.js +46 -1
- package/dist/pre-execution-contract.d.ts +8 -1
- package/dist/pre-execution-contract.js +18 -2
- package/dist/pre-execution.d.ts +4 -1
- package/dist/pre-execution.js +9 -2
- package/dist/verification-contract.d.ts +6 -0
- package/dist/verification-contract.js +2 -1
- package/envelope.schema.json +36 -0
- package/package.json +1 -1
- package/pre-execution-review-receipt.schema.json +8 -1
package/README.md
CHANGED
|
@@ -195,6 +195,25 @@ It refuses a nonzero issue count without identities, an unmatched unit id, and
|
|
|
195
195
|
unstructured prose. The compatibility diagnostics make every repair visible to
|
|
196
196
|
the driver.
|
|
197
197
|
|
|
198
|
+
### Additive guarantee — `next.continuation` (feature 59, 4.2.0)
|
|
199
|
+
|
|
200
|
+
Envelope v2's `next` gains an **optional** `continuation` object:
|
|
201
|
+
`{ argv, rendering?, preconditions, evidence?, convergence }`. `argv` is the
|
|
202
|
+
command of record; `rendering` is display-only and derivable from `argv` per
|
|
203
|
+
platform family; `preconditions` carry the emitter's at-emit evaluation;
|
|
204
|
+
`evidence` is a receiver-verifiable `{ artifact, digest }` token; `convergence`
|
|
205
|
+
names the envelope/state field the command advances.
|
|
206
|
+
|
|
207
|
+
**Envelopes without `next.continuation` stay valid** — the field is additive,
|
|
208
|
+
so every 4.1.x consumer keeps validating and reading the same documents, and no
|
|
209
|
+
release here is a major bump. Omission is the absence semantics: the field is
|
|
210
|
+
never `null` and never defaulted. The public surface is `emitContinuation`
|
|
211
|
+
(pure, fail-closed), `CONTINUATION_REFUSALS` (the closed four-code refusal
|
|
212
|
+
vocabulary), `deriveContinuationRendering`, `parseContinuationArgv`,
|
|
213
|
+
`validateContinuation`, `canonicalizeContinuation`,
|
|
214
|
+
`verifyContinuationEvidence`, and the frozen `CONTINUATION_CANONICAL_VECTORS`.
|
|
215
|
+
Nothing is persisted by any of them.
|
|
216
|
+
|
|
198
217
|
## Workflow transition decider
|
|
199
218
|
|
|
200
219
|
Export `decideWorkflowAction(input)` — a pure, deterministic function that
|
|
@@ -293,7 +312,7 @@ display the guarantees the schema cannot state.
|
|
|
293
312
|
| `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. |
|
|
294
313
|
| `PRE_EXECUTION_CONTEXT_PRESENCE` | `present` · `absent` — `absent` is a recorded fact, never a skipped field. |
|
|
295
314
|
| `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. |
|
|
296
|
-
| `PRE_EXECUTION_FINDING_SEVERITIES` | `info` · `low` · `medium` · `high` · `critical` — `info`
|
|
315
|
+
| `PRE_EXECUTION_FINDING_SEVERITIES` | `info` · `low` · `medium` · `high` · `critical` — material = `medium` and above; `low` is a persisted report-note and `info` is immaterial, so neither blocks a PASS on its own merits. |
|
|
297
316
|
| `PRE_EXECUTION_FINDING_CLASSES` | `product` · `plan` · `source` · `environment` · `runtime` — Which contract layer the finding is about. |
|
|
298
317
|
| `PRE_EXECUTION_FINDING_VERIFICATION` | `verified` · `unverified` — Only `verified` material findings can support a PASS. |
|
|
299
318
|
| `PRE_EXECUTION_FINDING_RESOLUTIONS` | `open` · `resolved` · `dismissed` — `dismissed` requires recorded counter-evidence. |
|
|
@@ -358,7 +377,7 @@ validator to refuse an unordered snapshot.
|
|
|
358
377
|
`verdict` ∈ `spec-review-pass | spec-review-fail | plan-review-pass |
|
|
359
378
|
plan-review-fail | needs-design`, and the verdict must match the snapshot stage.
|
|
360
379
|
A finding is `{ id, severity, class, claim, evidenceRefs, verification,
|
|
361
|
-
resolution, resolutionEvidence }` with `severity` ∈ `info | low | medium | high
|
|
380
|
+
resolution, resolutionEvidence, reproducer? }` with `severity` ∈ `info | low | medium | high
|
|
362
381
|
| critical`, `class` ∈ `product | plan | source | environment | runtime`,
|
|
363
382
|
`verification` ∈ `verified | unverified`, and `resolution` ∈ `open | resolved |
|
|
364
383
|
dismissed`. Every finding carries at least one evidence reference, and a
|
|
@@ -366,7 +385,8 @@ dismissal requires recorded counter-evidence.
|
|
|
366
385
|
|
|
367
386
|
`validatePreExecutionReceiptAgainstSnapshot` is the only entry that can bless a
|
|
368
387
|
PASS. It refuses a PASS while any material finding is open or unverified
|
|
369
|
-
(`info
|
|
388
|
+
(material = `medium` and above; `low`/`info` report-notes never block on their
|
|
389
|
+
own merits), while the receipt
|
|
370
390
|
binds a different snapshot, while the policy version differs, when the claimed
|
|
371
391
|
author exclusion is violated under `enforced`, or when the reviewer's own
|
|
372
392
|
identity authored the artifact set (`invalid-author`). Parent receipts model a
|
|
@@ -398,7 +418,7 @@ other families):
|
|
|
398
418
|
artifacts 32 · contexts 16 · findings 64 · evidencePerFinding 8
|
|
399
419
|
parentReceipts 8 · receiptDiagnostics 8 · diagnostics 50
|
|
400
420
|
unitIdChars 128 · revisionIdChars 128 · idChars 128 · identifierChars 160
|
|
401
|
-
pathChars 1024 · claimChars 2048 · evidenceChars 1024
|
|
421
|
+
pathChars 1024 · claimChars 2048 · reproducerChars 1024 · evidenceChars 1024
|
|
402
422
|
resolutionEvidenceChars 2048 · policyChars 64 · diagnosticChars 512
|
|
403
423
|
artifactBytes 4194304 · snapshotBytes 32768 · receiptBytes 65536
|
|
404
424
|
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Published canonical vectors for the continuation object.
|
|
3
|
+
*
|
|
4
|
+
* Each entry pins the EXACT lowercase SHA-256 digest of one fixture document
|
|
5
|
+
* (`test/fixtures/continuation-vectors.mjs`, kept in sync by name), canonicalized
|
|
6
|
+
* with `canonicalizeContinuation` (sorted keys, compact separators). The payloads
|
|
7
|
+
* are written as literal JSON documents — not produced by the emitter — so a change
|
|
8
|
+
* to the canonical serializer or the field projection shifts a digest here and the
|
|
9
|
+
* suite fails instead of silently re-blessing new bytes.
|
|
10
|
+
*
|
|
11
|
+
* A digest change is a contract change: it is reviewed, versioned, and recorded in
|
|
12
|
+
* `CHANGELOG.md`, never regenerated to make a test pass.
|
|
13
|
+
*/
|
|
14
|
+
/** Contract identifier for the continuation object (owned by `continuation.ts`). */
|
|
15
|
+
export declare const CONTINUATION_VECTOR_CONTRACT = "agentic-workflow/continuation@1";
|
|
16
|
+
export interface ContinuationCanonicalVector {
|
|
17
|
+
readonly contract: string;
|
|
18
|
+
readonly description: string;
|
|
19
|
+
readonly digest: string;
|
|
20
|
+
}
|
|
21
|
+
/** The two shipped vectors: minimal and full (with evidence). */
|
|
22
|
+
export declare const CONTINUATION_CANONICAL_VECTORS: readonly ContinuationCanonicalVector[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Published canonical vectors for the continuation object.
|
|
3
|
+
*
|
|
4
|
+
* Each entry pins the EXACT lowercase SHA-256 digest of one fixture document
|
|
5
|
+
* (`test/fixtures/continuation-vectors.mjs`, kept in sync by name), canonicalized
|
|
6
|
+
* with `canonicalizeContinuation` (sorted keys, compact separators). The payloads
|
|
7
|
+
* are written as literal JSON documents — not produced by the emitter — so a change
|
|
8
|
+
* to the canonical serializer or the field projection shifts a digest here and the
|
|
9
|
+
* suite fails instead of silently re-blessing new bytes.
|
|
10
|
+
*
|
|
11
|
+
* A digest change is a contract change: it is reviewed, versioned, and recorded in
|
|
12
|
+
* `CHANGELOG.md`, never regenerated to make a test pass.
|
|
13
|
+
*/
|
|
14
|
+
/** Contract identifier for the continuation object (owned by `continuation.ts`). */
|
|
15
|
+
export const CONTINUATION_VECTOR_CONTRACT = "agentic-workflow/continuation@1";
|
|
16
|
+
/** The two shipped vectors: minimal and full (with evidence). */
|
|
17
|
+
export const CONTINUATION_CANONICAL_VECTORS = Object.freeze([
|
|
18
|
+
Object.freeze({
|
|
19
|
+
contract: CONTINUATION_VECTOR_CONTRACT,
|
|
20
|
+
description: "minimal valid continuation (status-refresh class)",
|
|
21
|
+
digest: "2cfdfc3e95af4e277786b1b696017c5938fd666a7a4121c4c61011259409ecb2",
|
|
22
|
+
}),
|
|
23
|
+
Object.freeze({
|
|
24
|
+
contract: CONTINUATION_VECTOR_CONTRACT,
|
|
25
|
+
description: "full continuation with evidence (planning-gate class)",
|
|
26
|
+
digest: "08d10a797abf9d0dc7b8629aa82eca47b54409865a6591c18ccbbddf7699913c",
|
|
27
|
+
}),
|
|
28
|
+
]);
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Envelope v2 `next.continuation` — the executable hand-off object (feature 59).
|
|
3
|
+
*
|
|
4
|
+
* One deterministic emitter, many quoters. This module owns the frozen shape,
|
|
5
|
+
* the closed refusal vocabulary, the argv parser, the per-platform rendering
|
|
6
|
+
* derivation, the emitter, the validator, and the receiver-side evidence check.
|
|
7
|
+
* It fabricates nothing and persists nothing: every member it emits comes from
|
|
8
|
+
* an already-resolved command string plus the caller's unit context, and every
|
|
9
|
+
* failure path returns a typed refusal from `CONTINUATION_REFUSALS` instead of
|
|
10
|
+
* a guessed command (SPEC D-59-4/D-59-5/D-59-8, AC1, AC4, AC5).
|
|
11
|
+
*
|
|
12
|
+
* `argv` is the command of record; `rendering` is display-only and derivable
|
|
13
|
+
* from `argv` per platform family, so a caller may re-render for its own shell
|
|
14
|
+
* without ever changing the command. The whole field is optional: an Envelope
|
|
15
|
+
* without it stays valid (additive minor).
|
|
16
|
+
*/
|
|
17
|
+
/** Contract identifier for the continuation object. */
|
|
18
|
+
export declare const CONTINUATION_CONTRACT_ID = "agentic-workflow/continuation@1";
|
|
19
|
+
/**
|
|
20
|
+
* The closed refusal vocabulary (≤ 4 codes). A continuation that cannot be
|
|
21
|
+
* checked or rendered becomes one of these; extending the set is a SPEC change
|
|
22
|
+
* (D-59-5), never an emitter extension.
|
|
23
|
+
*/
|
|
24
|
+
export declare const CONTINUATION_REFUSALS: readonly ["precondition-uncheckable", "rendering-failed", "no-decision-available", "sensor-degraded"];
|
|
25
|
+
export type ContinuationRefusalCode = (typeof CONTINUATION_REFUSALS)[number];
|
|
26
|
+
/**
|
|
27
|
+
* Rendering families the derivation understands. v1 *emits* the POSIX-shell
|
|
28
|
+
* rendering (E-59-5); the Windows family is derivable by the same rule and is
|
|
29
|
+
* pinned by the rendering tests, but is not emitted until a SPEC change extends
|
|
30
|
+
* the family set (B-02).
|
|
31
|
+
*/
|
|
32
|
+
export declare const CONTINUATION_PLATFORM_FAMILIES: readonly ["posix", "windows"];
|
|
33
|
+
export type ContinuationPlatformFamily = (typeof CONTINUATION_PLATFORM_FAMILIES)[number];
|
|
34
|
+
/** One emit-time-checked precondition. `satisfied` is the emitter's evaluation. */
|
|
35
|
+
export interface ContinuationPrecondition {
|
|
36
|
+
id: string;
|
|
37
|
+
check: string;
|
|
38
|
+
satisfied: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Receiver-verifiable evidence token: `digest` is lowercase SHA-256 of `artifact`. */
|
|
41
|
+
export interface ContinuationEvidence {
|
|
42
|
+
artifact: string;
|
|
43
|
+
digest: string;
|
|
44
|
+
}
|
|
45
|
+
/** The frozen `next.continuation` shape (all members required unless marked `?`). */
|
|
46
|
+
export interface EnvelopeContinuation {
|
|
47
|
+
argv: string[];
|
|
48
|
+
/** Display-only, derived from `argv`; never alters the command of record. */
|
|
49
|
+
rendering?: string;
|
|
50
|
+
preconditions: ContinuationPrecondition[];
|
|
51
|
+
evidence?: ContinuationEvidence;
|
|
52
|
+
/** The envelope/state field that must measurably advance when the command runs. */
|
|
53
|
+
convergence: string;
|
|
54
|
+
}
|
|
55
|
+
/** Emitter input: the already-resolved command plus the unit context. */
|
|
56
|
+
export interface EmitContinuationInput {
|
|
57
|
+
/** Already-resolved command string (e.g. `next.recommended`). Never re-derived here. */
|
|
58
|
+
command: string;
|
|
59
|
+
/** The field the command advances (per-class, frozen in the SPEC's class table). */
|
|
60
|
+
convergence: string;
|
|
61
|
+
/** At-emit evaluation rows. Absent means "no preconditions declared". */
|
|
62
|
+
preconditions?: readonly ContinuationPrecondition[];
|
|
63
|
+
/** Optional evidence token; its digest is not recomputed here (see the verifier). */
|
|
64
|
+
evidence?: ContinuationEvidence;
|
|
65
|
+
/** Sensor input: `false` when no decision is available → `no-decision-available`. */
|
|
66
|
+
decisionAvailable?: boolean;
|
|
67
|
+
/** Sensor input: `true` when forge/git state is unavailable → `sensor-degraded`. */
|
|
68
|
+
sensorDegraded?: boolean;
|
|
69
|
+
/** Rendering family to emit. Defaults to `posix` (E-59-5). */
|
|
70
|
+
platform?: ContinuationPlatformFamily;
|
|
71
|
+
}
|
|
72
|
+
export type EmitContinuationResult = {
|
|
73
|
+
ok: true;
|
|
74
|
+
continuation: EnvelopeContinuation;
|
|
75
|
+
} | {
|
|
76
|
+
ok: false;
|
|
77
|
+
refusal: ContinuationRefusalCode;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Parse a resolved command string into argv by whitespace splitting, honoring
|
|
81
|
+
* single and double quotes so a quoted argument stays one token. Throws on an
|
|
82
|
+
* unterminated quote; the emitter maps that to `rendering-failed`.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parseContinuationArgv(command: string): string[];
|
|
85
|
+
/**
|
|
86
|
+
* Derive the display rendering from `argv` for a platform family. Pure: it
|
|
87
|
+
* never mutates `argv`, so re-rendering cannot change the command of record.
|
|
88
|
+
*/
|
|
89
|
+
export declare function deriveContinuationRendering(argv: readonly string[], family?: ContinuationPlatformFamily): string;
|
|
90
|
+
/**
|
|
91
|
+
* The pure, deterministic, fail-closed emitter (AC1/AC2/AC5).
|
|
92
|
+
*
|
|
93
|
+
* Input is the already-resolved command string plus the unit context; this
|
|
94
|
+
* function does NOT re-derive the decision. It parses argv, validates and copies
|
|
95
|
+
* the preconditions, derives the rendering, and returns the continuation. Every
|
|
96
|
+
* failure path returns `{ ok: false, refusal }`:
|
|
97
|
+
*
|
|
98
|
+
* - `sensor-degraded` — the caller reports forge/git state unavailable;
|
|
99
|
+
* - `no-decision-available`— empty command, empty convergence, or no decision flag;
|
|
100
|
+
* - `rendering-failed` — the command cannot be parsed to argv or rendered;
|
|
101
|
+
* - `precondition-uncheckable` — a precondition/evidence row is not checkable.
|
|
102
|
+
*/
|
|
103
|
+
export declare function emitContinuation(input: EmitContinuationInput): EmitContinuationResult;
|
|
104
|
+
/**
|
|
105
|
+
* Validate a `next.continuation` value. Returns typed error strings (empty when
|
|
106
|
+
* valid); the envelope validator folds these into its own error list so an
|
|
107
|
+
* invalid shape fails closed instead of validating silently.
|
|
108
|
+
*/
|
|
109
|
+
export declare function validateContinuation(value: unknown): string[];
|
|
110
|
+
/** Canonical serialization of a continuation value (sorted keys, compact). */
|
|
111
|
+
export declare function canonicalizeContinuation(value: unknown): string;
|
|
112
|
+
/**
|
|
113
|
+
* Receiver-side evidence check (AC4). Re-derives the SHA-256 of `artifactText`
|
|
114
|
+
* and compares it with the token's digest. Nothing is persisted; a mismatch is a
|
|
115
|
+
* plain `false`, never a repair.
|
|
116
|
+
*/
|
|
117
|
+
export declare function verifyContinuationEvidence(continuation: EnvelopeContinuation | null | undefined, artifactText: string): boolean;
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Envelope v2 `next.continuation` — the executable hand-off object (feature 59).
|
|
3
|
+
*
|
|
4
|
+
* One deterministic emitter, many quoters. This module owns the frozen shape,
|
|
5
|
+
* the closed refusal vocabulary, the argv parser, the per-platform rendering
|
|
6
|
+
* derivation, the emitter, the validator, and the receiver-side evidence check.
|
|
7
|
+
* It fabricates nothing and persists nothing: every member it emits comes from
|
|
8
|
+
* an already-resolved command string plus the caller's unit context, and every
|
|
9
|
+
* failure path returns a typed refusal from `CONTINUATION_REFUSALS` instead of
|
|
10
|
+
* a guessed command (SPEC D-59-4/D-59-5/D-59-8, AC1, AC4, AC5).
|
|
11
|
+
*
|
|
12
|
+
* `argv` is the command of record; `rendering` is display-only and derivable
|
|
13
|
+
* from `argv` per platform family, so a caller may re-render for its own shell
|
|
14
|
+
* without ever changing the command. The whole field is optional: an Envelope
|
|
15
|
+
* without it stays valid (additive minor).
|
|
16
|
+
*/
|
|
17
|
+
import { canonicalJSONValue } from "./canonical-json.js";
|
|
18
|
+
import { sha256HexSync } from "./sha256.js";
|
|
19
|
+
/** Contract identifier for the continuation object. */
|
|
20
|
+
export const CONTINUATION_CONTRACT_ID = "agentic-workflow/continuation@1";
|
|
21
|
+
/**
|
|
22
|
+
* The closed refusal vocabulary (≤ 4 codes). A continuation that cannot be
|
|
23
|
+
* checked or rendered becomes one of these; extending the set is a SPEC change
|
|
24
|
+
* (D-59-5), never an emitter extension.
|
|
25
|
+
*/
|
|
26
|
+
export const CONTINUATION_REFUSALS = Object.freeze([
|
|
27
|
+
"precondition-uncheckable",
|
|
28
|
+
"rendering-failed",
|
|
29
|
+
"no-decision-available",
|
|
30
|
+
"sensor-degraded",
|
|
31
|
+
]);
|
|
32
|
+
/**
|
|
33
|
+
* Rendering families the derivation understands. v1 *emits* the POSIX-shell
|
|
34
|
+
* rendering (E-59-5); the Windows family is derivable by the same rule and is
|
|
35
|
+
* pinned by the rendering tests, but is not emitted until a SPEC change extends
|
|
36
|
+
* the family set (B-02).
|
|
37
|
+
*/
|
|
38
|
+
export const CONTINUATION_PLATFORM_FAMILIES = Object.freeze(["posix", "windows"]);
|
|
39
|
+
const DIGEST_RE = /^[0-9a-f]{64}$/;
|
|
40
|
+
function isPlainObject(value) {
|
|
41
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Parse a resolved command string into argv by whitespace splitting, honoring
|
|
45
|
+
* single and double quotes so a quoted argument stays one token. Throws on an
|
|
46
|
+
* unterminated quote; the emitter maps that to `rendering-failed`.
|
|
47
|
+
*/
|
|
48
|
+
export function parseContinuationArgv(command) {
|
|
49
|
+
if (typeof command !== "string") {
|
|
50
|
+
throw new TypeError("continuation command must be a string");
|
|
51
|
+
}
|
|
52
|
+
const tokens = [];
|
|
53
|
+
let current = "";
|
|
54
|
+
let quote = null;
|
|
55
|
+
let started = false;
|
|
56
|
+
for (const ch of command) {
|
|
57
|
+
if (quote !== null) {
|
|
58
|
+
if (ch === quote)
|
|
59
|
+
quote = null;
|
|
60
|
+
else
|
|
61
|
+
current += ch;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (ch === "'" || ch === '"') {
|
|
65
|
+
quote = ch;
|
|
66
|
+
started = true;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (/\s/.test(ch)) {
|
|
70
|
+
if (started) {
|
|
71
|
+
tokens.push(current);
|
|
72
|
+
current = "";
|
|
73
|
+
started = false;
|
|
74
|
+
}
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
current += ch;
|
|
78
|
+
started = true;
|
|
79
|
+
}
|
|
80
|
+
if (quote !== null) {
|
|
81
|
+
throw new TypeError("continuation command has an unterminated quote");
|
|
82
|
+
}
|
|
83
|
+
if (started)
|
|
84
|
+
tokens.push(current);
|
|
85
|
+
return tokens;
|
|
86
|
+
}
|
|
87
|
+
const POSIX_SAFE = /^[A-Za-z0-9_@%+=:,./-]+$/;
|
|
88
|
+
function posixQuote(token) {
|
|
89
|
+
if (token.length > 0 && POSIX_SAFE.test(token))
|
|
90
|
+
return token;
|
|
91
|
+
return `'${token.replace(/'/g, "'\\''")}'`;
|
|
92
|
+
}
|
|
93
|
+
function windowsQuote(token) {
|
|
94
|
+
if (token.length > 0 && !/[\s"]/.test(token))
|
|
95
|
+
return token;
|
|
96
|
+
return `"${token.replace(/"/g, '""')}"`;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Derive the display rendering from `argv` for a platform family. Pure: it
|
|
100
|
+
* never mutates `argv`, so re-rendering cannot change the command of record.
|
|
101
|
+
*/
|
|
102
|
+
export function deriveContinuationRendering(argv, family = "posix") {
|
|
103
|
+
if (!Array.isArray(argv) || argv.length === 0 || !argv.every((token) => typeof token === "string")) {
|
|
104
|
+
throw new TypeError("continuation argv must be a non-empty array of strings");
|
|
105
|
+
}
|
|
106
|
+
if (family === "posix")
|
|
107
|
+
return argv.map(posixQuote).join(" ");
|
|
108
|
+
if (family === "windows")
|
|
109
|
+
return argv.map(windowsQuote).join(" ");
|
|
110
|
+
throw new TypeError(`unknown continuation platform family: ${String(family)}`);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The pure, deterministic, fail-closed emitter (AC1/AC2/AC5).
|
|
114
|
+
*
|
|
115
|
+
* Input is the already-resolved command string plus the unit context; this
|
|
116
|
+
* function does NOT re-derive the decision. It parses argv, validates and copies
|
|
117
|
+
* the preconditions, derives the rendering, and returns the continuation. Every
|
|
118
|
+
* failure path returns `{ ok: false, refusal }`:
|
|
119
|
+
*
|
|
120
|
+
* - `sensor-degraded` — the caller reports forge/git state unavailable;
|
|
121
|
+
* - `no-decision-available`— empty command, empty convergence, or no decision flag;
|
|
122
|
+
* - `rendering-failed` — the command cannot be parsed to argv or rendered;
|
|
123
|
+
* - `precondition-uncheckable` — a precondition/evidence row is not checkable.
|
|
124
|
+
*/
|
|
125
|
+
export function emitContinuation(input) {
|
|
126
|
+
if (!isPlainObject(input))
|
|
127
|
+
return { ok: false, refusal: "no-decision-available" };
|
|
128
|
+
if (input.sensorDegraded === true)
|
|
129
|
+
return { ok: false, refusal: "sensor-degraded" };
|
|
130
|
+
if (input.decisionAvailable === false)
|
|
131
|
+
return { ok: false, refusal: "no-decision-available" };
|
|
132
|
+
const command = typeof input.command === "string" ? input.command.trim() : "";
|
|
133
|
+
if (command.length === 0)
|
|
134
|
+
return { ok: false, refusal: "no-decision-available" };
|
|
135
|
+
const convergence = typeof input.convergence === "string" ? input.convergence.trim() : "";
|
|
136
|
+
if (convergence.length === 0)
|
|
137
|
+
return { ok: false, refusal: "no-decision-available" };
|
|
138
|
+
let argv;
|
|
139
|
+
try {
|
|
140
|
+
argv = parseContinuationArgv(command);
|
|
141
|
+
}
|
|
142
|
+
catch {
|
|
143
|
+
return { ok: false, refusal: "rendering-failed" };
|
|
144
|
+
}
|
|
145
|
+
if (argv.length === 0 || argv.some((token) => token.length === 0)) {
|
|
146
|
+
return { ok: false, refusal: "no-decision-available" };
|
|
147
|
+
}
|
|
148
|
+
const preconditions = [];
|
|
149
|
+
const rawPreconditions = input.preconditions ?? [];
|
|
150
|
+
if (!Array.isArray(rawPreconditions))
|
|
151
|
+
return { ok: false, refusal: "precondition-uncheckable" };
|
|
152
|
+
for (const row of rawPreconditions) {
|
|
153
|
+
if (!isPlainObject(row)
|
|
154
|
+
|| typeof row.id !== "string" || row.id.length === 0
|
|
155
|
+
|| typeof row.check !== "string" || row.check.length === 0
|
|
156
|
+
|| typeof row.satisfied !== "boolean") {
|
|
157
|
+
return { ok: false, refusal: "precondition-uncheckable" };
|
|
158
|
+
}
|
|
159
|
+
preconditions.push({ id: row.id, check: row.check, satisfied: row.satisfied });
|
|
160
|
+
}
|
|
161
|
+
let evidence;
|
|
162
|
+
if (input.evidence !== undefined) {
|
|
163
|
+
if (!isPlainObject(input.evidence)
|
|
164
|
+
|| typeof input.evidence.artifact !== "string" || input.evidence.artifact.length === 0
|
|
165
|
+
|| typeof input.evidence.digest !== "string" || !DIGEST_RE.test(input.evidence.digest)) {
|
|
166
|
+
return { ok: false, refusal: "precondition-uncheckable" };
|
|
167
|
+
}
|
|
168
|
+
evidence = { artifact: input.evidence.artifact, digest: input.evidence.digest };
|
|
169
|
+
}
|
|
170
|
+
let rendering;
|
|
171
|
+
try {
|
|
172
|
+
rendering = deriveContinuationRendering(argv, input.platform ?? "posix");
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return { ok: false, refusal: "rendering-failed" };
|
|
176
|
+
}
|
|
177
|
+
const continuation = { argv, rendering, preconditions, convergence };
|
|
178
|
+
if (evidence !== undefined)
|
|
179
|
+
continuation.evidence = evidence;
|
|
180
|
+
return { ok: true, continuation };
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Validate a `next.continuation` value. Returns typed error strings (empty when
|
|
184
|
+
* valid); the envelope validator folds these into its own error list so an
|
|
185
|
+
* invalid shape fails closed instead of validating silently.
|
|
186
|
+
*/
|
|
187
|
+
export function validateContinuation(value) {
|
|
188
|
+
if (!isPlainObject(value))
|
|
189
|
+
return ["next.continuation must be an object"];
|
|
190
|
+
const errors = [];
|
|
191
|
+
const allowed = new Set(["argv", "rendering", "preconditions", "evidence", "convergence"]);
|
|
192
|
+
for (const key of Object.keys(value)) {
|
|
193
|
+
if (!allowed.has(key))
|
|
194
|
+
errors.push(`next.continuation has an unexpected key: ${key}`);
|
|
195
|
+
}
|
|
196
|
+
if (!Array.isArray(value.argv)
|
|
197
|
+
|| value.argv.length === 0
|
|
198
|
+
|| !value.argv.every((token) => typeof token === "string" && token.length > 0)) {
|
|
199
|
+
errors.push("next.continuation.argv must be a non-empty array of non-empty strings");
|
|
200
|
+
}
|
|
201
|
+
if (typeof value.convergence !== "string" || value.convergence.trim().length === 0) {
|
|
202
|
+
errors.push("next.continuation.convergence must be a non-empty string");
|
|
203
|
+
}
|
|
204
|
+
if (!Array.isArray(value.preconditions)) {
|
|
205
|
+
errors.push("next.continuation.preconditions must be an array");
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
value.preconditions.forEach((row, i) => {
|
|
209
|
+
if (!isPlainObject(row)) {
|
|
210
|
+
errors.push(`next.continuation.preconditions[${i}] must be an object`);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (typeof row.id !== "string" || row.id.length === 0) {
|
|
214
|
+
errors.push(`next.continuation.preconditions[${i}].id must be a non-empty string`);
|
|
215
|
+
}
|
|
216
|
+
if (typeof row.check !== "string" || row.check.length === 0) {
|
|
217
|
+
errors.push(`next.continuation.preconditions[${i}].check must be a non-empty string`);
|
|
218
|
+
}
|
|
219
|
+
if (typeof row.satisfied !== "boolean") {
|
|
220
|
+
errors.push(`next.continuation.preconditions[${i}].satisfied must be a boolean`);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
if (value.rendering !== undefined && (typeof value.rendering !== "string" || value.rendering.length === 0)) {
|
|
225
|
+
errors.push("next.continuation.rendering must be a non-empty string when present");
|
|
226
|
+
}
|
|
227
|
+
if (value.evidence !== undefined) {
|
|
228
|
+
if (!isPlainObject(value.evidence)) {
|
|
229
|
+
errors.push("next.continuation.evidence must be an object when present");
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
if (typeof value.evidence.artifact !== "string" || value.evidence.artifact.length === 0) {
|
|
233
|
+
errors.push("next.continuation.evidence.artifact must be a non-empty string");
|
|
234
|
+
}
|
|
235
|
+
if (typeof value.evidence.digest !== "string" || !DIGEST_RE.test(value.evidence.digest)) {
|
|
236
|
+
errors.push("next.continuation.evidence.digest must be a lowercase 64-hex SHA-256 string");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return errors;
|
|
241
|
+
}
|
|
242
|
+
/** Canonical serialization of a continuation value (sorted keys, compact). */
|
|
243
|
+
export function canonicalizeContinuation(value) {
|
|
244
|
+
return canonicalJSONValue(value);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Receiver-side evidence check (AC4). Re-derives the SHA-256 of `artifactText`
|
|
248
|
+
* and compares it with the token's digest. Nothing is persisted; a mismatch is a
|
|
249
|
+
* plain `false`, never a repair.
|
|
250
|
+
*/
|
|
251
|
+
export function verifyContinuationEvidence(continuation, artifactText) {
|
|
252
|
+
if (!continuation || !isPlainObject(continuation.evidence))
|
|
253
|
+
return false;
|
|
254
|
+
const { digest } = continuation.evidence;
|
|
255
|
+
if (typeof digest !== "string" || !DIGEST_RE.test(digest))
|
|
256
|
+
return false;
|
|
257
|
+
if (typeof artifactText !== "string")
|
|
258
|
+
return false;
|
|
259
|
+
return sha256HexSync(artifactText) === digest;
|
|
260
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* take the LAST fenced ```json block of the assistant's final message;
|
|
9
9
|
* exactly one envelope per turn; all top-level keys always present.
|
|
10
10
|
*/
|
|
11
|
+
import { type EnvelopeContinuation } from "./continuation.js";
|
|
11
12
|
import { VERIFICATION_COMMAND_STATUSES, VERIFICATION_COST_CLASSES, VERIFICATION_DIAGNOSTIC_CODES, VERIFICATION_LIMITS, VERIFICATION_PLAN_CONTRACT_ID, VERIFICATION_RECEIPT_CONTRACT_ID, VERIFICATION_STAGES, VERIFICATION_VERDICTS, WORKING_DIRECTORY_POLICIES, type VerificationDiagnosticCodeV1, type VerificationDiagnosticV1 } from "./verification-contract.js";
|
|
12
13
|
export declare const ENVELOPE_STATES: readonly ["OK", "CONTINUE", "READY_FOR_REVIEW", "READY_FOR_AUDIT", "MERGE_READY", "MERGED", "NEEDS_FIXES", "BLOCKED", "NEEDS_INPUT", "FAILED", "HALT"];
|
|
13
14
|
export type EnvelopeState = (typeof ENVELOPE_STATES)[number];
|
|
@@ -91,6 +92,12 @@ export interface EnvelopeNext {
|
|
|
91
92
|
tier: Tier;
|
|
92
93
|
/** Optional trigger-attributed suggestions (workflow-status only). */
|
|
93
94
|
suggested?: EnvelopeSuggestion[];
|
|
95
|
+
/**
|
|
96
|
+
* Optional executable hand-off (feature 59). Present when the deterministic
|
|
97
|
+
* side could emit one; absent on every refusal path — omission IS the absence
|
|
98
|
+
* semantics, never `null` (D-59-8). Shape owned by `continuation.ts`.
|
|
99
|
+
*/
|
|
100
|
+
continuation?: EnvelopeContinuation;
|
|
94
101
|
}
|
|
95
102
|
export interface Envelope {
|
|
96
103
|
skill: string;
|
|
@@ -178,7 +185,7 @@ export declare const WORKFLOW_INTENTS: readonly WorkflowIntent[];
|
|
|
178
185
|
export declare const WORKFLOW_DECISION_SENSE_CODES: readonly ["sense-initial", "sense-stale-revision", "sense-missing-evidence", "sense-unknown-state", "sense-unlisted-transition"];
|
|
179
186
|
export type WorkflowDecisionSenseReason = (typeof WORKFLOW_DECISION_SENSE_CODES)[number];
|
|
180
187
|
/** Stop reason codes: the transition is explicitly blocked or must terminate. */
|
|
181
|
-
export declare const WORKFLOW_DECISION_STOP_CODES: readonly ["stop-blocked", "stop-needs-input", "stop-failed", "stop-contradiction", "stop-policy-denied", "stop-forbidden-transition"];
|
|
188
|
+
export declare const WORKFLOW_DECISION_STOP_CODES: readonly ["stop-blocked", "stop-needs-input", "stop-failed", "stop-contradiction", "stop-policy-denied", "stop-forbidden-transition", "stop-review-loop-cap"];
|
|
182
189
|
export type WorkflowDecisionStopReason = (typeof WORKFLOW_DECISION_STOP_CODES)[number];
|
|
183
190
|
/** Invoke reason codes: transition is proven and allowed. */
|
|
184
191
|
export declare const WORKFLOW_DECISION_INVOKE_CODES: readonly ["invoke-proven-transition"];
|
|
@@ -201,6 +208,16 @@ export interface WorkflowDecisionInput {
|
|
|
201
208
|
readonly lastOutcomeSourceRevision: string | null;
|
|
202
209
|
/** Closed caller policy governing what transitions are permitted. */
|
|
203
210
|
readonly policy: WorkflowDecisionPolicy;
|
|
211
|
+
/**
|
|
212
|
+
* Consecutive unconverged review→repair→re-review cycles per pre-execution
|
|
213
|
+
* stage, derived by the consumer from the unit's persisted stage receipts (the
|
|
214
|
+
* count of consecutive FAIL-verdict receipts since that stage's last PASS
|
|
215
|
+
* receipt; a stage with no receipt reads 0). Absent reads as zero.
|
|
216
|
+
*/
|
|
217
|
+
readonly reviewLoopCycles?: {
|
|
218
|
+
readonly spec?: number;
|
|
219
|
+
readonly plan?: number;
|
|
220
|
+
};
|
|
204
221
|
}
|
|
205
222
|
/** Intent values that may be directly invoked (excludes non-invocation intents). */
|
|
206
223
|
export type WorkflowInvocableIntent = Exclude<WorkflowIntent, "status" | "ask-human" | "stop" | "none">;
|
|
@@ -890,3 +907,14 @@ export declare const VERIFICATION_CANONICAL_VECTORS: ReadonlyArray<Readonly<Cano
|
|
|
890
907
|
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
908
|
export { VERDICTS_BY_STAGE } from "./pre-execution-contract.js";
|
|
892
909
|
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";
|
|
910
|
+
/**
|
|
911
|
+
* Re-exported so a consumer imports ONE package root for every contract family.
|
|
912
|
+
* The implementation lives in `continuation.ts`; the frozen shape stays a single
|
|
913
|
+
* definition that `EnvelopeNext.continuation` references.
|
|
914
|
+
*/
|
|
915
|
+
export { CONTINUATION_CONTRACT_ID, CONTINUATION_PLATFORM_FAMILIES, CONTINUATION_REFUSALS, canonicalizeContinuation, deriveContinuationRendering, emitContinuation, parseContinuationArgv, validateContinuation, verifyContinuationEvidence, } from "./continuation.js";
|
|
916
|
+
export { CONTINUATION_CANONICAL_VECTORS, CONTINUATION_VECTOR_CONTRACT } from "./continuation-vectors.js";
|
|
917
|
+
/** The digest surface the evidence token is bound through (feature 59, D-59-9). */
|
|
918
|
+
export { sha256Hex, sha256HexSync } from "./sha256.js";
|
|
919
|
+
export type { ContinuationEvidence, ContinuationPlatformFamily, ContinuationPrecondition, ContinuationRefusalCode, EmitContinuationInput, EmitContinuationResult, EnvelopeContinuation, } from "./continuation.js";
|
|
920
|
+
export type { ContinuationCanonicalVector } from "./continuation-vectors.js";
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { canonicalizeContractInput, canonicalJSONValue, utf8Bytes, utf8ByteCompare, } from "./canonical-json.js";
|
|
12
12
|
import { sha256Hex } from "./sha256.js";
|
|
13
|
+
import { validateContinuation } from "./continuation.js";
|
|
13
14
|
import { VERIFICATION_COMMAND_STATUSES, VERIFICATION_CONTRACT, VERIFICATION_COST_CLASSES, VERIFICATION_DIAGNOSTIC_CODES, VERIFICATION_LIMITS, VERIFICATION_PLAN_CONTRACT_ID, VERIFICATION_RECEIPT_CONTRACT_ID, VERIFICATION_STAGES, VERIFICATION_VERDICTS, createVerificationDiagnosticSink, captureVerificationInput, validateStructure, } from "./verification-contract.js";
|
|
14
15
|
// ---------------------------------------------------------------------------
|
|
15
16
|
// Types (source of truth: this package; the internal skill carries policy only)
|
|
@@ -293,6 +294,9 @@ export function validateEnvelope(value) {
|
|
|
293
294
|
});
|
|
294
295
|
}
|
|
295
296
|
}
|
|
297
|
+
if (value.next.continuation !== undefined) {
|
|
298
|
+
errors.push(...validateContinuation(value.next.continuation));
|
|
299
|
+
}
|
|
296
300
|
}
|
|
297
301
|
if (value.needs_input !== null && value.needs_input !== undefined) {
|
|
298
302
|
if (!isObj(value.needs_input) ||
|
|
@@ -390,12 +394,24 @@ function rejectUnexpectedEnvelopeKeys(value, errors) {
|
|
|
390
394
|
if (value.needs_input !== null) {
|
|
391
395
|
rejectUnexpectedKeys(value.needs_input, "needs_input", ["question", "options"], errors);
|
|
392
396
|
}
|
|
393
|
-
rejectUnexpectedKeys(value.next, "next", ["recommended", "alternatives", "tier", "suggested"], errors);
|
|
397
|
+
rejectUnexpectedKeys(value.next, "next", ["recommended", "alternatives", "tier", "suggested", "continuation"], errors);
|
|
394
398
|
if (isObj(value.next) && Array.isArray(value.next.suggested)) {
|
|
395
399
|
value.next.suggested.forEach((suggestion, index) => {
|
|
396
400
|
rejectUnexpectedKeys(suggestion, `next.suggested[${index}]`, ["command", "trigger", "source_skill"], errors);
|
|
397
401
|
});
|
|
398
402
|
}
|
|
403
|
+
if (isObj(value.next)) {
|
|
404
|
+
const continuation = value.next.continuation;
|
|
405
|
+
if (isObj(continuation)) {
|
|
406
|
+
rejectUnexpectedKeys(continuation, "next.continuation", ["argv", "rendering", "preconditions", "evidence", "convergence"], errors);
|
|
407
|
+
if (Array.isArray(continuation.preconditions)) {
|
|
408
|
+
continuation.preconditions.forEach((row, index) => {
|
|
409
|
+
rejectUnexpectedKeys(row, `next.continuation.preconditions[${index}]`, ["id", "check", "satisfied"], errors);
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
rejectUnexpectedKeys(continuation.evidence, "next.continuation.evidence", ["artifact", "digest"], errors);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
399
415
|
}
|
|
400
416
|
/**
|
|
401
417
|
* Validates the documented v2 shape at a driver boundary.
|
|
@@ -483,6 +499,7 @@ export const WORKFLOW_DECISION_STOP_CODES = Object.freeze([
|
|
|
483
499
|
"stop-contradiction",
|
|
484
500
|
"stop-policy-denied",
|
|
485
501
|
"stop-forbidden-transition",
|
|
502
|
+
"stop-review-loop-cap",
|
|
486
503
|
]);
|
|
487
504
|
/** Invoke reason codes: transition is proven and allowed. */
|
|
488
505
|
export const WORKFLOW_DECISION_INVOKE_CODES = Object.freeze([
|
|
@@ -833,6 +850,22 @@ export function decideWorkflowAction(input) {
|
|
|
833
850
|
const proposal = input.lastOutcome.next.intent;
|
|
834
851
|
const targets = input.lastOutcome.next.targets || [];
|
|
835
852
|
const lastSkill = input.lastOutcome.skill;
|
|
853
|
+
// Derived review-loop cap (feature 31): a third consecutive unconverged review
|
|
854
|
+
// invocation stops and asks the human. The count is consumer-derived from the
|
|
855
|
+
// persisted receipts (never written here); a PASS reset leaves it below 2, so
|
|
856
|
+
// the next cycle is allowed. Checked before the transition-table match.
|
|
857
|
+
if ((proposal === "review-spec" || proposal === "review-plan") && input.reviewLoopCycles) {
|
|
858
|
+
const stage = proposal === "review-spec" ? "spec" : "plan";
|
|
859
|
+
const cycles = input.reviewLoopCycles[stage];
|
|
860
|
+
if (typeof cycles === "number" && cycles >= 2) {
|
|
861
|
+
return {
|
|
862
|
+
kind: "stop", intent: "ask-human", targets,
|
|
863
|
+
reasonCode: "stop-review-loop-cap",
|
|
864
|
+
evidenceRefs: [],
|
|
865
|
+
detail: `${proposal} refused: ${cycles} consecutive unconverged ${stage} cycle(s) (cap 2) · route to design-feature`,
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
}
|
|
836
869
|
const entry = WORKFLOW_TRANSITION_TABLE.find((r) => r.key === lastSkill);
|
|
837
870
|
if (entry === undefined) {
|
|
838
871
|
return { kind: "sense", intent: "status", targets: [], reasonCode: "sense-unlisted-transition", evidenceRefs: [], detail: `unlisted transition: ${lastSkill}` };
|
|
@@ -2869,3 +2902,15 @@ export const VERIFICATION_CANONICAL_VECTORS = Object.freeze([
|
|
|
2869
2902
|
*/
|
|
2870
2903
|
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
2904
|
export { VERDICTS_BY_STAGE } from "./pre-execution-contract.js";
|
|
2905
|
+
// ---------------------------------------------------------------------------
|
|
2906
|
+
// next.continuation — the executable hand-off object (feature 59)
|
|
2907
|
+
// ---------------------------------------------------------------------------
|
|
2908
|
+
/**
|
|
2909
|
+
* Re-exported so a consumer imports ONE package root for every contract family.
|
|
2910
|
+
* The implementation lives in `continuation.ts`; the frozen shape stays a single
|
|
2911
|
+
* definition that `EnvelopeNext.continuation` references.
|
|
2912
|
+
*/
|
|
2913
|
+
export { CONTINUATION_CONTRACT_ID, CONTINUATION_PLATFORM_FAMILIES, CONTINUATION_REFUSALS, canonicalizeContinuation, deriveContinuationRendering, emitContinuation, parseContinuationArgv, validateContinuation, verifyContinuationEvidence, } from "./continuation.js";
|
|
2914
|
+
export { CONTINUATION_CANONICAL_VECTORS, CONTINUATION_VECTOR_CONTRACT } from "./continuation-vectors.js";
|
|
2915
|
+
/** The digest surface the evidence token is bound through (feature 59, D-59-9). */
|
|
2916
|
+
export { sha256Hex, sha256HexSync } from "./sha256.js";
|
|
@@ -53,7 +53,13 @@ export declare const PRE_EXECUTION_CONTEXT_KINDS: readonly ["roadmap-row", "gove
|
|
|
53
53
|
export declare const PRE_EXECUTION_CONTEXT_PRESENCE: readonly ["present", "absent"];
|
|
54
54
|
/** The five public review verdicts. There is no generic "approve" verb. */
|
|
55
55
|
export declare const PRE_EXECUTION_VERDICTS: readonly ["spec-review-pass", "spec-review-fail", "plan-review-pass", "plan-review-fail", "needs-design"];
|
|
56
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Severities mirror the candidate-review ladder on the planning materiality
|
|
58
|
+
* line: material = `medium` and above, so a PASS may coexist with an
|
|
59
|
+
* open/unverified `low` row and is refused while any open/unverified `medium`+
|
|
60
|
+
* row exists. `low` is a persisted report-note the stage author resolves
|
|
61
|
+
* without a re-review; `info` is immaterial.
|
|
62
|
+
*/
|
|
57
63
|
export declare const PRE_EXECUTION_FINDING_SEVERITIES: readonly ["info", "low", "medium", "high", "critical"];
|
|
58
64
|
/** The five root-cause owners a finding can be routed to (SPEC Design §4). */
|
|
59
65
|
export declare const PRE_EXECUTION_FINDING_CLASSES: readonly ["product", "plan", "source", "environment", "runtime"];
|
|
@@ -92,6 +98,7 @@ export declare const PRE_EXECUTION_LIMITS: Readonly<{
|
|
|
92
98
|
readonly pathChars: 1024;
|
|
93
99
|
readonly identifierChars: 160;
|
|
94
100
|
readonly claimChars: 2048;
|
|
101
|
+
readonly reproducerChars: 1024;
|
|
95
102
|
readonly evidenceChars: 1024;
|
|
96
103
|
readonly resolutionEvidenceChars: 2048;
|
|
97
104
|
readonly policyChars: 64;
|
|
@@ -78,7 +78,13 @@ export const PRE_EXECUTION_VERDICTS = Object.freeze([
|
|
|
78
78
|
"plan-review-fail",
|
|
79
79
|
"needs-design",
|
|
80
80
|
]);
|
|
81
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Severities mirror the candidate-review ladder on the planning materiality
|
|
83
|
+
* line: material = `medium` and above, so a PASS may coexist with an
|
|
84
|
+
* open/unverified `low` row and is refused while any open/unverified `medium`+
|
|
85
|
+
* row exists. `low` is a persisted report-note the stage author resolves
|
|
86
|
+
* without a re-review; `info` is immaterial.
|
|
87
|
+
*/
|
|
82
88
|
export const PRE_EXECUTION_FINDING_SEVERITIES = Object.freeze([
|
|
83
89
|
"info", "low", "medium", "high", "critical",
|
|
84
90
|
]);
|
|
@@ -131,6 +137,7 @@ export const PRE_EXECUTION_LIMITS = Object.freeze({
|
|
|
131
137
|
pathChars: 1024,
|
|
132
138
|
identifierChars: 160,
|
|
133
139
|
claimChars: 2048,
|
|
140
|
+
reproducerChars: 1024,
|
|
134
141
|
evidenceChars: 1024,
|
|
135
142
|
resolutionEvidenceChars: 2048,
|
|
136
143
|
policyChars: 64,
|
|
@@ -417,7 +424,7 @@ const FINDING_SPEC = {
|
|
|
417
424
|
description: "One structured review finding.",
|
|
418
425
|
fields: [
|
|
419
426
|
opaqueId("id", "Stable finding identity, unique inside the receipt."),
|
|
420
|
-
{ key: "severity", type: "enum", enum: PRE_EXECUTION_FINDING_SEVERITIES, description: "Severity ladder shared with candidate review
|
|
427
|
+
{ key: "severity", type: "enum", enum: PRE_EXECUTION_FINDING_SEVERITIES, description: "Severity ladder shared with candidate review on the planning materiality line: material = `medium` and above, `low` is a persisted report-note, `info` immaterial." },
|
|
421
428
|
{ key: "class", type: "enum", enum: PRE_EXECUTION_FINDING_CLASSES, description: "Root-cause owner the finding routes to." },
|
|
422
429
|
{
|
|
423
430
|
key: "claim",
|
|
@@ -447,6 +454,15 @@ const FINDING_SPEC = {
|
|
|
447
454
|
nulFree: true,
|
|
448
455
|
description: "Counter-evidence or repair pointer. Required to dismiss or resolve a finding.",
|
|
449
456
|
},
|
|
457
|
+
{
|
|
458
|
+
key: "reproducer",
|
|
459
|
+
type: "string",
|
|
460
|
+
minLength: 1,
|
|
461
|
+
maxLength: PRE_EXECUTION_LIMITS.reproducerChars,
|
|
462
|
+
nulFree: true,
|
|
463
|
+
optional: true,
|
|
464
|
+
description: `Concrete reproduction for the finding; at most ${PRE_EXECUTION_LIMITS.reproducerChars} characters. Optional, so a receipt whose findings carry none stays valid.`,
|
|
465
|
+
},
|
|
450
466
|
],
|
|
451
467
|
rules: [
|
|
452
468
|
{
|
package/dist/pre-execution.d.ts
CHANGED
|
@@ -128,6 +128,8 @@ export interface PreExecutionFinding {
|
|
|
128
128
|
readonly verification: PreExecutionFindingVerification;
|
|
129
129
|
readonly resolution: PreExecutionFindingResolution;
|
|
130
130
|
readonly resolutionEvidence: string | null;
|
|
131
|
+
/** Optional concrete reproduction; absent means the producer recorded none. */
|
|
132
|
+
readonly reproducer?: string;
|
|
131
133
|
}
|
|
132
134
|
/** One optional parent receipt: topology, never a vote. */
|
|
133
135
|
export interface PreExecutionParentReceipt {
|
|
@@ -344,7 +346,8 @@ export declare function validatePreExecutionReviewReceiptV1(value: unknown): Pre
|
|
|
344
346
|
* 3. `contextClean` is mandatory for a PASS and never for a FAIL: a contaminated
|
|
345
347
|
* reviewer may still report what it found;
|
|
346
348
|
* 4. a PASS may not carry a material finding that is still open or unverified
|
|
347
|
-
* (`verdict-mismatch`) — `
|
|
349
|
+
* (`verdict-mismatch`) — material is `medium` and above, so a PASS may
|
|
350
|
+
* coexist with an open/unverified `low` or `info` report-note.
|
|
348
351
|
*
|
|
349
352
|
* The parent-topology rule (parents require a critic/synthesizer/arbiter role,
|
|
350
353
|
* `invalid-topology`) is part of the canonical definition itself — the shared
|
package/dist/pre-execution.js
CHANGED
|
@@ -667,6 +667,12 @@ export function validatePreExecutionReviewReceiptV1(value) {
|
|
|
667
667
|
return refused(collector);
|
|
668
668
|
return accepted("receipt", document);
|
|
669
669
|
}
|
|
670
|
+
/**
|
|
671
|
+
* The material line (E-D31-8): `medium` and above block a PASS; `low` and
|
|
672
|
+
* `info` are report-notes. One closed set, so a future severity cannot become
|
|
673
|
+
* material through a negated comparison.
|
|
674
|
+
*/
|
|
675
|
+
const MATERIAL_FINDING_SEVERITIES = new Set(["medium", "high", "critical"]);
|
|
670
676
|
/**
|
|
671
677
|
* The ONLY authority that blesses a pre-execution verdict (feature 28 AC1/AC2).
|
|
672
678
|
*
|
|
@@ -683,7 +689,8 @@ export function validatePreExecutionReviewReceiptV1(value) {
|
|
|
683
689
|
* 3. `contextClean` is mandatory for a PASS and never for a FAIL: a contaminated
|
|
684
690
|
* reviewer may still report what it found;
|
|
685
691
|
* 4. a PASS may not carry a material finding that is still open or unverified
|
|
686
|
-
* (`verdict-mismatch`) — `
|
|
692
|
+
* (`verdict-mismatch`) — material is `medium` and above, so a PASS may
|
|
693
|
+
* coexist with an open/unverified `low` or `info` report-note.
|
|
687
694
|
*
|
|
688
695
|
* The parent-topology rule (parents require a critic/synthesizer/arbiter role,
|
|
689
696
|
* `invalid-topology`) is part of the canonical definition itself — the shared
|
|
@@ -736,7 +743,7 @@ export function validatePreExecutionReceiptAgainstSnapshot(receipt, snapshot, po
|
|
|
736
743
|
if (isPassVerdict(bound.verdict)) {
|
|
737
744
|
for (let i = 0; i < bound.findings.length; i++) {
|
|
738
745
|
const finding = bound.findings[i];
|
|
739
|
-
const material = finding.severity
|
|
746
|
+
const material = MATERIAL_FINDING_SEVERITIES.has(finding.severity);
|
|
740
747
|
if (material && (finding.resolution === "open" || finding.verification === "unverified")) {
|
|
741
748
|
collector.add("verdict-mismatch", `/findings/${i}`);
|
|
742
749
|
}
|
|
@@ -35,6 +35,12 @@ export interface VerificationFieldSpec {
|
|
|
35
35
|
readonly maxLength?: number;
|
|
36
36
|
/** Reject values containing NUL. */
|
|
37
37
|
readonly nulFree?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* The key is declared but not required: an object omitting it stays valid.
|
|
40
|
+
* Default `false` — every field is required unless it opts out. Projected as
|
|
41
|
+
* "present in `properties`, absent from `required`".
|
|
42
|
+
*/
|
|
43
|
+
readonly optional?: boolean;
|
|
38
44
|
/** Single pattern a valid string must match (digest/timestamp shapes). */
|
|
39
45
|
readonly pattern?: string;
|
|
40
46
|
readonly minimum?: number;
|
|
@@ -872,7 +872,8 @@ function validateStructureFields(contract, spec, value, path, sink) {
|
|
|
872
872
|
for (const field of spec.fields) {
|
|
873
873
|
const fieldPath = at(field.key);
|
|
874
874
|
if (!Object.prototype.hasOwnProperty.call(value, field.key)) {
|
|
875
|
-
|
|
875
|
+
if (field.optional !== true)
|
|
876
|
+
sink.push("missing-field", fieldPath);
|
|
876
877
|
continue;
|
|
877
878
|
}
|
|
878
879
|
const raw = value[field.key];
|
package/envelope.schema.json
CHANGED
|
@@ -178,6 +178,42 @@
|
|
|
178
178
|
"source_skill": { "type": "string" }
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
|
+
},
|
|
182
|
+
"continuation": {
|
|
183
|
+
"type": "object",
|
|
184
|
+
"additionalProperties": false,
|
|
185
|
+
"required": ["argv", "preconditions", "convergence"],
|
|
186
|
+
"properties": {
|
|
187
|
+
"argv": {
|
|
188
|
+
"type": "array",
|
|
189
|
+
"minItems": 1,
|
|
190
|
+
"items": { "type": "string", "minLength": 1 }
|
|
191
|
+
},
|
|
192
|
+
"rendering": { "type": "string", "minLength": 1 },
|
|
193
|
+
"preconditions": {
|
|
194
|
+
"type": "array",
|
|
195
|
+
"items": {
|
|
196
|
+
"type": "object",
|
|
197
|
+
"additionalProperties": false,
|
|
198
|
+
"required": ["id", "check", "satisfied"],
|
|
199
|
+
"properties": {
|
|
200
|
+
"id": { "type": "string", "minLength": 1 },
|
|
201
|
+
"check": { "type": "string", "minLength": 1 },
|
|
202
|
+
"satisfied": { "type": "boolean" }
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"evidence": {
|
|
207
|
+
"type": "object",
|
|
208
|
+
"additionalProperties": false,
|
|
209
|
+
"required": ["artifact", "digest"],
|
|
210
|
+
"properties": {
|
|
211
|
+
"artifact": { "type": "string", "minLength": 1 },
|
|
212
|
+
"digest": { "type": "string", "pattern": "^[0-9a-f]{64}$" }
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
"convergence": { "type": "string", "minLength": 1 }
|
|
216
|
+
}
|
|
181
217
|
}
|
|
182
218
|
}
|
|
183
219
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gtrabanco/agentic-workflow-schema",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.3.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",
|
|
@@ -333,7 +333,7 @@
|
|
|
333
333
|
"high",
|
|
334
334
|
"critical"
|
|
335
335
|
],
|
|
336
|
-
"description": "Severity ladder shared with candidate review
|
|
336
|
+
"description": "Severity ladder shared with candidate review on the planning materiality line: material = `medium` and above, `low` is a persisted report-note, `info` immaterial."
|
|
337
337
|
},
|
|
338
338
|
"class": {
|
|
339
339
|
"type": "string",
|
|
@@ -393,6 +393,13 @@
|
|
|
393
393
|
}
|
|
394
394
|
],
|
|
395
395
|
"description": "Counter-evidence or repair pointer. Required to dismiss or resolve a finding."
|
|
396
|
+
},
|
|
397
|
+
"reproducer": {
|
|
398
|
+
"type": "string",
|
|
399
|
+
"minLength": 1,
|
|
400
|
+
"maxLength": 1024,
|
|
401
|
+
"pattern": "^[^\\0]*$",
|
|
402
|
+
"description": "Concrete reproduction for the finding; at most 1024 characters. Optional, so a receipt whose findings carry none stays valid."
|
|
396
403
|
}
|
|
397
404
|
},
|
|
398
405
|
"allOf": [
|