@gtrabanco/agentic-workflow-schema 1.0.1 → 2.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 ADDED
@@ -0,0 +1,200 @@
1
+ # @gtrabanco/agentic-workflow-schema
2
+
3
+ > 🇬🇧 [English version](README.md)
4
+
5
+ Tipos, JSON Schema, y parser/validador para el **sobre-máquina** de
6
+ [agentic-workflow](https://github.com/gtrabanco/agentic-workflow) — el
7
+ bloque JSON fijo con el que termina un turno de agente conducido (emitido
8
+ siempre por `workflow-status`, y por cualquier otra skill cuando el driver
9
+ inyecta el fragmento canónico de system-prompt — ver el protocolo de driver
10
+ abajo), para que orquestadores externos puedan enrutar el flujo de trabajo
11
+ programáticamente (qué comando sigue, en qué nivel de modelo).
12
+
13
+ Cero dependencias en tiempo de ejecución. Fuente de verdad del contrato:
14
+ [`skills/orchestration-envelope/SKILL.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/skills/orchestration-envelope/SKILL.md);
15
+ protocolo de driver:
16
+ [`docs/workflow/ORCHESTRATION.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/docs/workflow/ORCHESTRATION.md).
17
+
18
+ ## Instalación
19
+
20
+ ```sh
21
+ npm install @gtrabanco/agentic-workflow-schema
22
+ ```
23
+
24
+ ## Uso
25
+
26
+ ```ts
27
+ import {
28
+ parseEnvelope,
29
+ isTerminal,
30
+ isRunHalt,
31
+ } from "@gtrabanco/agentic-workflow-schema";
32
+
33
+ const output = await runAgentHeadless("Follow the installed SKILL.md for: /workflow-status --json-only");
34
+
35
+ const result = parseEnvelope(output); // extracts the LAST fenced ```json block
36
+ if (!result.ok) throw new Error(result.errors.join("; "));
37
+
38
+ const env = result.envelope; // fully typed
39
+ if (isRunHalt(env)) stopEverythingAndPage(env.blockers);
40
+ else if (isTerminal(env.state)) askHuman(env);
41
+ else invokeNext(env.next.recommended, env.next.tier); // "strong" | "cheap"
42
+ ```
43
+
44
+ El contrato de parseo es exactamente lo que prometen las skills: **el
45
+ último bloque
46
+ ```` ```json ````…```` ``` ```` entre comillas del mensaje final es el
47
+ sobre**, uno por turno, todas las claves de nivel superior siempre
48
+ presentes.
49
+
50
+ También exportados: `extractLastJsonBlock(text)`, `validateEnvelope(value)`,
51
+ `ENVELOPE_STATES` (el enum de 11 estados), `TERMINAL_STATES`, y cada tipo
52
+ de campo. También se distribuye un **JSON Schema** agnóstico de lenguaje —
53
+ funciona con el mínimo de `engines.node` (>=18):
54
+
55
+ ```ts
56
+ import { createRequire } from "node:module";
57
+ const schema = createRequire(import.meta.url)("@gtrabanco/agentic-workflow-schema/envelope.schema.json");
58
+ ```
59
+
60
+ En Node 20.10+/22, la forma más nueva de import-attributes también
61
+ funciona:
62
+
63
+ ```ts
64
+ import schema from "@gtrabanco/agentic-workflow-schema/envelope.schema.json" with { type: "json" };
65
+ ```
66
+
67
+ ## El sobre, campo por campo
68
+
69
+ Cada clave de nivel superior está **siempre presente** (`required` en el
70
+ JSON Schema) — una skill que no tiene nada que reportar para una clave usa
71
+ `null` / `[]` / `0`, nunca la omite. **Cerrado** = el enum exacto de abajo
72
+ es exhaustivo (el validador rechaza cualquier otra cosa); **abierto** =
73
+ forma libre, cualquier valor del tipo indicado.
74
+
75
+ | Campo | Tipo | Valores | Significado |
76
+ |---|---|---|---|
77
+ | `skill` | string | abierto (no vacío) | Qué skill produjo este sobre. |
78
+ | `state` | enum | **cerrado** — los 11 estados de abajo | La clave de enrutamiento. Todo lo que decide un orquestador empieza aquí. |
79
+ | `summary` | string | abierto | Una frase en texto plano: qué pasó este turno. |
80
+ | `unit.type` | enum | **cerrado** — `feature` · `fix` · `docs` · `none` | Qué tipo de unidad trabajó el turno. |
81
+ | `unit.id` | string\|null | abierto | El identificador de la unidad (`NN-slug` para features, `n-topic` para fixes). |
82
+ | `unit.issue` | integer\|null | abierto | El número del issue de rastreo, cuando la unidad nace de un issue. |
83
+ | `unit.branch` | string\|null | abierto | La rama de trabajo. |
84
+ | `phase.current` | string\|null | abierto (por convención `P1`, `P2`, …) | Fase recién trabajada, para features en fases (M/L). |
85
+ | `phase.total` / `phase.completed` | integer\|null | abierto | Recuentos de fase; `null` para unidades de pase único. |
86
+ | `pr.number` / `pr.url` / `pr.head_sha` | int/str\|null | abierto | El PR de la unidad, una vez que existe. |
87
+ | `pr.state` | enum | **cerrado** — `open` · `merged` · `none` | El estado de merge vive en la forja, no en el roadmap. |
88
+ | `pr.merge_ready` | boolean\|null | abierto | `true` solo después de un veredicto MERGE-READY de `audit-pr` sobre la cabeza actual. |
89
+ | `pr.ci` | enum | **cerrado** — `green` · `red` · `pending` · `none` · `null` | `none` = el proyecto no tiene CI; `null` = no comprobado este turno. |
90
+ | `gates.verification` | enum | **cerrado** — `green` · `red` · `not-run` · `null` | La propia puerta del proyecto (chequeo de tipos + tests + build) tal como se ejecutó por última vez. |
91
+ | `gates.review_pending` / `gates.audit_pending` | boolean\|null | abierto | Si la revisión obligatoria / auditoría de merge todavía tiene que suceder. |
92
+ | `findings.fix_now[]` | array de objetos | items: `id`/`file`/`axis`/`class`/`route` (abierto), `severity` (**cerrado** — `high`·`med`·`low`), `suggested_tier` (**cerrado** — `strong`·`cheap`) | Hallazgos que deben incorporarse a la rama ACTUAL antes de que avance — un item por cada fila sin foldear del ledger de fold fix-now (`review-findings.md`) de la unidad. |
93
+ | `findings.issues_filed[]` | array de enteros | abierto | Números de issue creados/actualizados este turno. |
94
+ | `findings.untriaged` | integer ≥ 0 | abierto | Hallazgos todavía sin destino — las skills cuyo contrato enruta todo deben reportar `0`. |
95
+ | `findings.decisions_recorded` | integer ≥ 0 | abierto | Decisiones escritas en registros clase `decisions.md` este turno. |
96
+ | `blockers[].kind` | enum | **cerrado** — `dependency` · `issue` · `gate` · `merge-conflict` · `substrate` · `input` | Por qué la unidad (o la ejecución) no puede avanzar. |
97
+ | `blockers[].scope` | enum | **cerrado** — `unit` · `run` | `run` significa parar-el-mundo: nada más avanza tampoco. |
98
+ | `blockers[].id` / `blockers[].detail` | string | abierto | Qué exactamente (un slug, `#N`, un nombre de check) + una línea de contexto. |
99
+ | `dependencies.unmet[]` / `dependencies.build_order[]` | arrays de string | abierto | Referencias de roadmap/issue no cumplidas, y el orden más-profundo-primero para construirlas. |
100
+ | `recommendations.product_audit` | boolean | abierto | `true` cuando una desviación recurrente sugiere que las suposiciones fundacionales están obsoletas. |
101
+ | `recommendations.reason` | string\|null | abierto | Por qué (requerido en la práctica cuando el flag es `true`). |
102
+ | `needs_input` | object\|null | `question` (abierto) + `options[]` (abierto) | No-nulo solo en `state: NEEDS_INPUT` — la decisión humana a mostrar, con opciones concretas. Nada se adivinó. |
103
+ | `next.recommended` | string | abierto (una invocación de skill) | El único mejor comando siguiente. |
104
+ | `next.alternatives[]` | array de string | abierto | Las otras elecciones defendibles. |
105
+ | `next.tier` | enum | **cerrado** — `strong` · `cheap` | Qué clase de modelo merece el siguiente paso — juicio vs. mecánico. |
106
+ | `detail` | any | abierto (específico de la skill) | Carga útil por skill — p. ej. `workflow-status` lleva aquí el árbol completo del proyecto (`features`, `fixes`, `startable_now`, `blocked_units`, `crash_recovery`, …). |
107
+
108
+ ### La tabla de enrutamiento de `state` (cerrada — exactamente estos 11)
109
+
110
+ | `state` | Significado | Acción del orquestador |
111
+ |---|---|---|
112
+ | `OK` | La skill terminó su trabajo | Invocar `next.recommended` en `next.tier` |
113
+ | `CONTINUE` | Misma unidad, más del mismo trabajo | Reinvocar `next.recommended` (los checkpoints consultivos también aterrizan aquí — la alternativa está listada) |
114
+ | `READY_FOR_REVIEW` | Unidad terminada; revisión obligatoria a continuación | `/review-change` en un modelo fuerte, contexto nuevo |
115
+ | `READY_FOR_AUDIT` | Revisión limpia | `/audit-pr` (fuerte) |
116
+ | `MERGE_READY` | Auditoría aprobada sobre el SHA de cabeza actual | El humano fusiona — o lo hace tu política de auto-merge escrita |
117
+ | `MERGED` | Un auto-merge autorizado se ejecutó este turno | Siguiente unidad: consultar `workflow-status` |
118
+ | `NEEDS_FIXES` | `findings.fix_now` no está vacío | Incorporar en la rama (commit Y push), luego reejecutar la puerta que los emitió |
119
+ | `BLOCKED` | Dependencia no cumplida / causa externa | Seguir `dependencies.build_order`, o resolver `blockers[]` |
120
+ | `NEEDS_INPUT` | Un humano debe decidir | Mostrar `needs_input.question` + `options`; reanudar con la respuesta |
121
+ | `FAILED` | Reintentos agotados | Detener esta unidad; un humano la revisa |
122
+ | `HALT` | Descubrimiento de parar-el-mundo (`blockers[].scope: "run"`) | Detener toda la ejecución; nada avanza hasta que un humano lo despeje |
123
+
124
+ `isTerminal(state)` cubre `NEEDS_INPUT` / `FAILED` / `HALT` (+
125
+ `MERGE_READY` con puerta humana); `isRunHalt(envelope)` es la comprobación
126
+ de `HALT` / bloqueador con alcance de ejecución.
127
+
128
+ ## Orquestar con este esquema
129
+
130
+ Dos patrones, ambos consumiendo el mismo sobre. En ambos, **inyecta el
131
+ fragmento canónico de system-prompt** en cada invocación headless (las
132
+ skills no emiten el sobre por sí solas — `workflow-status` es la única
133
+ excepción):
134
+
135
+ ```text
136
+ Every turn you produce MUST end with exactly one fenced ```json block matching
137
+ the orchestration envelope schema (all top-level keys present; values only
138
+ from verified command output). Emit nothing after it.
139
+ ```
140
+
141
+ …y ejecuta el **bucle de reparación** ante un fallo de parseo — un
142
+ reintento, luego falla el paso:
143
+
144
+ ```ts
145
+ async function turn(prompt: string) {
146
+ let out = await invokeAgent(prompt, { system: SNIPPET });
147
+ let r = parseEnvelope(out);
148
+ if (!r.ok) {
149
+ out = await invokeAgent("Emit only the machine envelope for the turn above.", { resume: true });
150
+ r = parseEnvelope(out);
151
+ if (!r.ok) throw new Error(`step failed: no valid envelope (${r.errors.join("; ")})`);
152
+ }
153
+ return r.envelope;
154
+ }
155
+ ```
156
+
157
+ **Patrón 1 — bucle de driver fijo** (empieza aquí): consulta el sensor,
158
+ enruta por `state`, repite. Esqueleto completo en
159
+ [`docs/workflow/ORCHESTRATION.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/docs/workflow/ORCHESTRATION.md),
160
+ incluido el protocolo de reinicio de recuperación ante caídas (pista
161
+ `--last-envelope` + diario de sobres solo-anexar).
162
+
163
+ **Patrón 2 — flujos de trabajo dinámicos** (el patrón conductor): un
164
+ contexto conductor de larga duración *escribe y monitoriza* el plan de
165
+ trabajo; cada trabajador se ejecuta en un **contexto limpio** y solo su
166
+ sobre fluye de vuelta hacia arriba — el conductor nunca ingiere
167
+ transcripciones en bruto, que es lo que le permite mantenerse de larga
168
+ duración sin degradarse. El sobre es precisamente el "resultado
169
+ estructurado" que necesita este patrón:
170
+
171
+ ```ts
172
+ // Conductor: fan out independent units (workflow-status said they're startable
173
+ // in parallel and the project declares `worktrees`), read back only envelopes.
174
+ const status = await turn("Follow the installed SKILL.md for: /workflow-status --json-only");
175
+ const units = status.detail.startable_now as string[];
176
+
177
+ const results = await Promise.all(
178
+ units.map((u) => turn(`Follow the installed SKILL.md for: /execute-phase ${u}`))
179
+ );
180
+
181
+ for (const env of results) {
182
+ if (isRunHalt(env)) throw new Error(`HALT: ${JSON.stringify(env.blockers)}`);
183
+ if (env.state === "NEEDS_FIXES")
184
+ await turn(`Fold the fix-now findings on ${env.unit.branch}: ${JSON.stringify(env.findings.fix_now)}`);
185
+ }
186
+ // The conductor's own context grew by a few KB of envelopes — not by N transcripts.
187
+ ```
188
+
189
+ Piso de seguridad para cualquier driver, bucle fijo o dinámico: nunca
190
+ saltarse una puerta `review_pending`/`audit_pending`, nunca fusionar salvo
191
+ con un `MERGE_READY` fresco ligado al SHA de cabeza actual, y tratar
192
+ `HALT` como terminal hasta que un humano lo despeje.
193
+
194
+ ## Versionado
195
+
196
+ El semver de este paquete sigue al **contrato del sobre**, no al
197
+ repositorio: cambio disruptivo del esquema (clave eliminada/renombrada,
198
+ estado eliminado) → major; aditivo (clave opcional nueva, estado nuevo) →
199
+ minor; arreglos/docs → patch. Cuando cambia la skill
200
+ `orchestration-envelope`, este paquete cambia en el mismo PR.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @gtrabanco/agentic-workflow-schema
2
2
 
3
+ > 🇪🇸 [Versión en español](README.es.md)
4
+
3
5
  Types, JSON Schema, and parser/validator for the
4
6
  [agentic-workflow](https://github.com/gtrabanco/agentic-workflow) **machine
5
7
  envelope** — the fixed JSON block a driven agent turn ends with (emitted by
@@ -59,6 +61,128 @@ On Node 20.10+/22, the newer import-attributes form also works:
59
61
  import schema from "@gtrabanco/agentic-workflow-schema/envelope.schema.json" with { type: "json" };
60
62
  ```
61
63
 
64
+ ## The envelope, field by field
65
+
66
+ Every top-level key is **always present** (`required` in the JSON Schema) —
67
+ a skill that has nothing to report for a key uses `null` / `[]` / `0`, never
68
+ omits it. **Closed** = the exact enum below is exhaustive (the validator
69
+ rejects anything else); **open** = free-form, any value of the stated type.
70
+
71
+ | Field | Type | Values | Meaning |
72
+ |---|---|---|---|
73
+ | `skill` | string | open (non-empty) | Which skill produced this envelope. |
74
+ | `state` | enum | **closed** — the 11 states below | The routing key. Everything an orchestrator decides starts here. |
75
+ | `summary` | string | open | One plain-text sentence: what happened this turn. |
76
+ | `unit.type` | enum | **closed** — `feature` · `fix` · `docs` · `none` | What kind of unit the turn worked on. |
77
+ | `unit.id` | string\|null | open | The unit's identifier (`NN-slug` for features, `n-topic` for fixes). |
78
+ | `unit.issue` | integer\|null | open | The tracking issue number, when the unit is issue-born. |
79
+ | `unit.branch` | string\|null | open | The working branch. |
80
+ | `phase.current` | string\|null | open (by convention `P1`, `P2`, …) | Phase just worked, for phased (M/L) features. |
81
+ | `phase.total` / `phase.completed` | integer\|null | open | Phase counts; `null` for single-pass units. |
82
+ | `pr.number` / `pr.url` / `pr.head_sha` | int/str\|null | open | The unit's PR, once it exists. |
83
+ | `pr.state` | enum | **closed** — `open` · `merged` · `none` | Merge state lives in the forge, not the roadmap. |
84
+ | `pr.merge_ready` | boolean\|null | open | `true` only after an `audit-pr` MERGE-READY verdict on the current head. |
85
+ | `pr.ci` | enum | **closed** — `green` · `red` · `pending` · `none` · `null` | `none` = the project has no CI; `null` = not checked this turn. |
86
+ | `gates.verification` | enum | **closed** — `green` · `red` · `not-run` · `null` | The project's own gate (type-check + tests + build) as last RUN. |
87
+ | `gates.review_pending` / `gates.audit_pending` | boolean\|null | open | Whether the mandatory review / merge audit still has to happen. |
88
+ | `findings.fix_now[]` | object array | items: `id`/`file`/`axis`/`class`/`route` (open), `severity` (**closed** — `high`·`med`·`low`), `suggested_tier` (**closed** — `strong`·`cheap`) | Findings that must fold into the CURRENT branch before it advances — one item per unfolded row of the unit's `review-findings.md` fold ledger. |
89
+ | `findings.issues_filed[]` | integer array | open | Issue numbers created/updated this turn. |
90
+ | `findings.untriaged` | integer ≥ 0 | open | Findings still without a destination — skills whose contract routes everything must report `0`. |
91
+ | `findings.decisions_recorded` | integer ≥ 0 | open | Decisions written to `decisions.md`-class records this turn. |
92
+ | `blockers[].kind` | enum | **closed** — `dependency` · `issue` · `gate` · `merge-conflict` · `substrate` · `input` | Why the unit (or run) cannot proceed. |
93
+ | `blockers[].scope` | enum | **closed** — `unit` · `run` | `run` means stop-the-world: nothing else proceeds either. |
94
+ | `blockers[].id` / `blockers[].detail` | string | open | What exactly (a slug, `#N`, a check name) + one line of context. |
95
+ | `dependencies.unmet[]` / `dependencies.build_order[]` | string arrays | open | Unmet roadmap/issue refs, and the deepest-first order to build them. |
96
+ | `recommendations.product_audit` | boolean | open | `true` when recurring drift suggests the founding assumptions are stale. |
97
+ | `recommendations.reason` | string\|null | open | Why (required in practice when the flag is `true`). |
98
+ | `needs_input` | object\|null | `question` (open) + `options[]` (open) | Non-null only on `state: NEEDS_INPUT` — the human decision to surface, with concrete options. Nothing was guessed. |
99
+ | `next.recommended` | string | open (a skill invocation) | The single best next command. |
100
+ | `next.alternatives[]` | string array | open | The other defensible choices. |
101
+ | `next.tier` | enum | **closed** — `strong` · `cheap` | Which model class the next step deserves — judgment vs mechanical. |
102
+ | `detail` | any | open (skill-specific) | Per-skill payload — e.g. `workflow-status` carries the full project tree (`features`, `fixes`, `startable_now`, `blocked_units`, `crash_recovery`, …) here. |
103
+
104
+ ### The `state` routing table (closed — exactly these 11)
105
+
106
+ | `state` | Meaning | Orchestrator action |
107
+ |---|---|---|
108
+ | `OK` | Skill finished its job | Invoke `next.recommended` on `next.tier` |
109
+ | `CONTINUE` | Same unit, more of the same work | Re-invoke `next.recommended` (advisory checkpoints also land here — the alternative is listed) |
110
+ | `READY_FOR_REVIEW` | Unit finished; mandatory review next | `/review-change` on a strong model, fresh context |
111
+ | `READY_FOR_AUDIT` | Review clean | `/audit-pr` (strong) |
112
+ | `MERGE_READY` | Audit passed on the current head SHA | Human merges — or your written auto-merge policy does |
113
+ | `MERGED` | An authorized auto-merge ran this turn | Next unit: poll `workflow-status` |
114
+ | `NEEDS_FIXES` | `findings.fix_now` is non-empty | Fold on-branch (commit AND push), then re-run the gate that emitted them |
115
+ | `BLOCKED` | Unmet dependency / external cause | Follow `dependencies.build_order`, or resolve `blockers[]` |
116
+ | `NEEDS_INPUT` | A human must decide | Surface `needs_input.question` + `options`; resume with the answer |
117
+ | `FAILED` | Retries exhausted | Stop this unit; a human looks |
118
+ | `HALT` | Stop-the-world discovery (`blockers[].scope: "run"`) | Stop the whole run; nothing proceeds until a human clears it |
119
+
120
+ `isTerminal(state)` covers `NEEDS_INPUT` / `FAILED` / `HALT` (+ human-gated
121
+ `MERGE_READY`); `isRunHalt(envelope)` is the `HALT` / run-scoped-blocker check.
122
+
123
+ ## Orchestrating with this schema
124
+
125
+ Two patterns, both consuming the same envelope. In both, **inject the
126
+ canonical system-prompt snippet** into every headless invocation (skills do
127
+ not emit the envelope on their own — `workflow-status` is the one exception):
128
+
129
+ ```text
130
+ Every turn you produce MUST end with exactly one fenced ```json block matching
131
+ the orchestration envelope schema (all top-level keys present; values only
132
+ from verified command output). Emit nothing after it.
133
+ ```
134
+
135
+ …and run the **repair loop** on parse failure — one retry, then fail the step:
136
+
137
+ ```ts
138
+ async function turn(prompt: string) {
139
+ let out = await invokeAgent(prompt, { system: SNIPPET });
140
+ let r = parseEnvelope(out);
141
+ if (!r.ok) {
142
+ out = await invokeAgent("Emit only the machine envelope for the turn above.", { resume: true });
143
+ r = parseEnvelope(out);
144
+ if (!r.ok) throw new Error(`step failed: no valid envelope (${r.errors.join("; ")})`);
145
+ }
146
+ return r.envelope;
147
+ }
148
+ ```
149
+
150
+ **Pattern 1 — fixed driver loop** (start here): poll the sensor, route on
151
+ `state`, repeat. Full skeleton in
152
+ [`docs/workflow/ORCHESTRATION.md`](https://github.com/gtrabanco/agentic-workflow/blob/main/docs/workflow/ORCHESTRATION.md),
153
+ including the crash-recovery restart protocol (`--last-envelope` hint +
154
+ append-only envelope journal).
155
+
156
+ **Pattern 2 — dynamic workflows** (the conductor pattern): one long-running
157
+ conductor context *writes and monitors* the work plan; every worker runs in a
158
+ **clean context** and only its envelope flows back up — the conductor never
159
+ ingests raw transcripts, which is what lets it stay long-running without
160
+ degrading. The envelope is precisely the "structured result" this pattern
161
+ needs:
162
+
163
+ ```ts
164
+ // Conductor: fan out independent units (workflow-status said they're startable
165
+ // in parallel and the project declares `worktrees`), read back only envelopes.
166
+ const status = await turn("Follow the installed SKILL.md for: /workflow-status --json-only");
167
+ const units = status.detail.startable_now as string[];
168
+
169
+ const results = await Promise.all(
170
+ units.map((u) => turn(`Follow the installed SKILL.md for: /execute-phase ${u}`))
171
+ );
172
+
173
+ for (const env of results) {
174
+ if (isRunHalt(env)) throw new Error(`HALT: ${JSON.stringify(env.blockers)}`);
175
+ if (env.state === "NEEDS_FIXES")
176
+ await turn(`Fold the fix-now findings on ${env.unit.branch}: ${JSON.stringify(env.findings.fix_now)}`);
177
+ }
178
+ // The conductor's own context grew by a few KB of envelopes — not by N transcripts.
179
+ ```
180
+
181
+ Safety floor for any driver, fixed loop or dynamic: never skip a
182
+ `review_pending`/`audit_pending` gate, never merge on anything but a fresh
183
+ `MERGE_READY` bound to the current head SHA, and treat `HALT` as terminal
184
+ until a human clears it.
185
+
62
186
  ## Versioning
63
187
 
64
188
  This package's semver tracks the **envelope contract**, not the repo:
package/dist/index.d.ts CHANGED
@@ -45,10 +45,15 @@ export interface EnvelopeGates {
45
45
  review_pending: boolean | null;
46
46
  audit_pending: boolean | null;
47
47
  }
48
+ export type FixNowSeverity = "high" | "med" | "low";
48
49
  export interface EnvelopeFixNowFinding {
49
- ref: string;
50
- title: string;
51
- file?: string | null;
50
+ id: string;
51
+ file: string;
52
+ axis: string;
53
+ severity: FixNowSeverity;
54
+ class: string;
55
+ route: string;
56
+ suggested_tier: Tier;
52
57
  }
53
58
  export interface EnvelopeFindings {
54
59
  fix_now: EnvelopeFixNowFinding[];
package/dist/index.js CHANGED
@@ -72,6 +72,7 @@ const BLOCKER_KINDS = [
72
72
  "input",
73
73
  ];
74
74
  const BLOCKER_SCOPES = ["unit", "run"];
75
+ const FIX_NOW_SEVERITIES = ["high", "med", "low"];
75
76
  const REQUIRED_KEYS = [
76
77
  "skill",
77
78
  "state",
@@ -226,8 +227,25 @@ export function validateEnvelope(value) {
226
227
  }
227
228
  else {
228
229
  findings.fix_now.forEach((f, i) => {
229
- if (!isObj(f) || typeof f.ref !== "string" || typeof f.title !== "string") {
230
- errors.push(`findings.fix_now[${i}] must be {ref, title, file?}`);
230
+ if (!isObj(f)) {
231
+ errors.push(`findings.fix_now[${i}] must be an object`);
232
+ return;
233
+ }
234
+ if (typeof f.id !== "string")
235
+ errors.push(`findings.fix_now[${i}].id must be a string`);
236
+ if (typeof f.file !== "string")
237
+ errors.push(`findings.fix_now[${i}].file must be a string`);
238
+ if (typeof f.axis !== "string")
239
+ errors.push(`findings.fix_now[${i}].axis must be a string`);
240
+ if (!FIX_NOW_SEVERITIES.includes(f.severity)) {
241
+ errors.push(`findings.fix_now[${i}].severity must be one of ${FIX_NOW_SEVERITIES.join("|")} (got: ${String(f.severity)})`);
242
+ }
243
+ if (typeof f.class !== "string")
244
+ errors.push(`findings.fix_now[${i}].class must be a string`);
245
+ if (typeof f.route !== "string")
246
+ errors.push(`findings.fix_now[${i}].route must be a string`);
247
+ if (f.suggested_tier !== "strong" && f.suggested_tier !== "cheap") {
248
+ errors.push(`findings.fix_now[${i}].suggested_tier must be strong|cheap (got: ${String(f.suggested_tier)})`);
231
249
  }
232
250
  });
233
251
  }
@@ -85,11 +85,15 @@
85
85
  "type": "array",
86
86
  "items": {
87
87
  "type": "object",
88
- "required": ["ref", "title"],
88
+ "required": ["id", "file", "axis", "severity", "class", "route", "suggested_tier"],
89
89
  "properties": {
90
- "ref": { "type": "string" },
91
- "title": { "type": "string" },
92
- "file": { "type": ["string", "null"] }
90
+ "id": { "type": "string" },
91
+ "file": { "type": "string" },
92
+ "axis": { "type": "string" },
93
+ "severity": { "enum": ["high", "med", "low"] },
94
+ "class": { "type": "string" },
95
+ "route": { "type": "string" },
96
+ "suggested_tier": { "enum": ["strong", "cheap"] }
93
97
  }
94
98
  }
95
99
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gtrabanco/agentic-workflow-schema",
3
- "version": "1.0.1",
3
+ "version": "2.0.0",
4
4
  "description": "Types, JSON Schema, and parser/validator for the agentic-workflow machine envelope — the fixed JSON block a driven agent turn ends with (workflow-status always; other skills under the driver-injected snippet), for programmatic orchestration.",
5
5
  "keywords": [
6
6
  "agentic-workflow",
@@ -32,6 +32,7 @@
32
32
  "dist",
33
33
  "envelope.schema.json",
34
34
  "README.md",
35
+ "README.es.md",
35
36
  "LICENSE"
36
37
  ],
37
38
  "engines": {