@openwop/openwop-conformance 1.123.0 → 1.125.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.
Files changed (27) hide show
  1. package/README.md +2 -2
  2. package/dist/lib/scenario-disposition.js +14 -1
  3. package/package.json +1 -1
  4. package/schemas/CORPUS-STAMP.json +2 -2
  5. package/src/lib/error-envelope.ts +77 -0
  6. package/src/lib/scenario-disposition.ts +15 -1
  7. package/src/scenarios/conformance-execution-witness.test.ts +12 -0
  8. package/src/scenarios/conversationCapabilityNegotiation.test.ts +3 -2
  9. package/src/scenarios/cross-engine-append-behavior.test.ts +26 -5
  10. package/src/scenarios/cross-host-ancestry-endpoint.test.ts +8 -4
  11. package/src/scenarios/cross-host-causation-shape.test.ts +4 -2
  12. package/src/scenarios/data-residency-admission.test.ts +6 -6
  13. package/src/scenarios/envelope-recovery-applied.test.ts +3 -2
  14. package/src/scenarios/envelope-refusal-shape.test.ts +4 -3
  15. package/src/scenarios/error-envelope-canonical-shape.test.ts +64 -0
  16. package/src/scenarios/fs-path-traversal.test.ts +3 -2
  17. package/src/scenarios/multi-agent-memory-lifecycle.test.ts +8 -4
  18. package/src/scenarios/multi-region-idempotency-behavior.test.ts +29 -7
  19. package/src/scenarios/provider-usage.test.ts +2 -2
  20. package/src/scenarios/replay-divergence-at-refusal.test.ts +12 -6
  21. package/src/scenarios/replay-observable-sequence-determinism.test.ts +4 -2
  22. package/src/scenarios/sandbox-mvp-behavior.test.ts +20 -10
  23. package/src/scenarios/table-schema-enforcement.test.ts +2 -2
  24. package/src/scenarios/voice-streamref-tenant-bound.test.ts +2 -1
  25. package/src/scenarios/voice-transcription-streaming.test.ts +2 -1
  26. package/src/scenarios/voice-transcription-unadvertised.test.ts +2 -1
  27. package/src/scenarios/workload-identity-behavior.test.ts +7 -4
@@ -88,7 +88,9 @@ export function fileDisposition(states, gateReason, assertionCount) {
88
88
  * - a zero-assertion "pass" ⇒ the file's noted reason (`softSkip` /
89
89
  * `seamAbsent`: inapplicable | skipped | blocked) or a behaviorGate reason;
90
90
  * - a zero-assertion "pass" with NO reason ⇒ `blocked` + the marker detail —
91
- * an early return can never become a pass.
91
+ * an early return can never become a pass;
92
+ * - every test `ctx.skip()`ped ⇒ the file's noted reason if it wrote one
93
+ * BEFORE skipping (`ctx.skip()` throws), else `blocked` + the marker.
92
94
  */
93
95
  export function resolveFileRecord(states, gateReason, assertionCount, noted) {
94
96
  let { disposition, detail } = fileDisposition(states, gateReason, assertionCount);
@@ -102,6 +104,17 @@ export function resolveFileRecord(states, gateReason, assertionCount, noted) {
102
104
  detail = UNCLASSIFIED_RETURN_DETAIL;
103
105
  }
104
106
  }
107
+ else if (noted !== null &&
108
+ gateReason === undefined &&
109
+ states.length > 0 &&
110
+ states.every((s) => s === 'skip')) {
111
+ // Every test called `ctx.skip()` (vitest reports them as skipped, not as
112
+ // zero-assertion passes) and the file noted why first. Note-then-skip is
113
+ // the required order: `ctx.skip()` throws, so a note written after it is
114
+ // dead code — which is how seven files carried notes the ledger never saw.
115
+ disposition = noted.kind;
116
+ detail = noted.reason;
117
+ }
105
118
  return detail === undefined ? { disposition } : { disposition, detail };
106
119
  }
107
120
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openwop/openwop-conformance",
3
- "version": "1.123.0",
3
+ "version": "1.125.0",
4
4
  "description": "Production-ready black-box conformance suite for OpenWOP v1.0 compliant servers.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "_comment": "Provenance of this vendored schemas/ copy. See conformance/README.md \u00a7\"Resolving the contract\". Compare against the stamp in your installed @openwop/openwop-conformance to detect a stale hand-copied contract.",
3
- "suiteVersion": "1.123.0",
4
- "corpusCommit": "9eb52572cde5f5406ad6ed21a62bb6932cb6bae9"
3
+ "suiteVersion": "1.125.0",
4
+ "corpusCommit": "13ab2a545d4e2a30c8da66354e39d4db7233acae"
5
5
  }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * The canonical HTTP error envelope (`schemas/error-envelope.schema.json`,
3
+ * `rest-endpoints.md` §"Error envelope") is FLAT:
4
+ *
5
+ * { "error": "<code>", "message": "<text>", "details"?: { … } }
6
+ *
7
+ * `additionalProperties: false`; `retriable`, `retryAfter`, `correlationId`,
8
+ * `supported`, `requested`, … live under `details`. Every conforming host,
9
+ * the TypeScript SDK's `ErrorEnvelope`, and the v1 lock all agree on this.
10
+ *
11
+ * Between 2026-06 and 2026-08 a NESTED shape — `{ error: { code, retriable } }`
12
+ * — crept into a few code-list entries of `rest-endpoints.md`, four
13
+ * `host-sample-test-seams.md` seam contracts (§19/§20/§22/§23) and ~15
14
+ * scenarios that read `body.error.code` off an HTTP response (S22, decided
15
+ * 2026-08-16: flat wins — the schema is authoritative and re-shaping `error`
16
+ * from string to object would break every conforming host under
17
+ * COMPATIBILITY.md §2.2). Three OTHER error objects are legitimately nested and
18
+ * are NOT this envelope: `RunSnapshot.error { code, message, retriable? }`
19
+ * (run-level), bulk-result items `{ ok:false, error:{ code } }`, and JSON-RPC
20
+ * bodies (MCP / A2A `{ error: { code, message } }`).
21
+ *
22
+ * These helpers read the CODE and the retriable hint from a canonical (flat)
23
+ * envelope, and — for a deprecation window ending with the first suite minor
24
+ * after 2026-11-10 — tolerate the legacy nested shape a seam may still emit,
25
+ * so a host is not made red for a shape the catalog itself prescribed until
26
+ * today. `assertCanonicalErrorEnvelope` is the strict form for legs that check
27
+ * the envelope's shape rather than only its code.
28
+ */
29
+
30
+ export interface CanonicalErrorEnvelope {
31
+ readonly error: string;
32
+ readonly message: string;
33
+ readonly details?: Readonly<Record<string, unknown>>;
34
+ }
35
+
36
+ /** The error code from a canonical envelope; the legacy nested `error.code` is tolerated (deprecation window). */
37
+ export function readErrorCode(body: unknown): string | undefined {
38
+ if (body === null || typeof body !== 'object') return undefined;
39
+ const e = (body as { error?: unknown }).error;
40
+ if (typeof e === 'string') return e;
41
+ if (e !== null && typeof e === 'object') {
42
+ const code = (e as { code?: unknown }).code;
43
+ return typeof code === 'string' ? code : undefined;
44
+ }
45
+ return undefined;
46
+ }
47
+
48
+ /** `details.retriable` from a canonical envelope; legacy nested `error.retriable` tolerated. */
49
+ export function readRetriable(body: unknown): boolean | undefined {
50
+ if (body === null || typeof body !== 'object') return undefined;
51
+ const d = (body as { details?: unknown }).details;
52
+ if (d !== null && typeof d === 'object' && typeof (d as { retriable?: unknown }).retriable === 'boolean') {
53
+ return (d as { retriable: boolean }).retriable;
54
+ }
55
+ const e = (body as { error?: unknown }).error;
56
+ if (e !== null && typeof e === 'object' && typeof (e as { retriable?: unknown }).retriable === 'boolean') {
57
+ return (e as { retriable: boolean }).retriable;
58
+ }
59
+ return undefined;
60
+ }
61
+
62
+ /** True iff the body is the legacy nested `{ error: { code } }` shape (for reporting, never for asserting a pass). */
63
+ export function isLegacyNestedEnvelope(body: unknown): boolean {
64
+ if (body === null || typeof body !== 'object') return false;
65
+ const e = (body as { error?: unknown }).error;
66
+ return e !== null && typeof e === 'object' && typeof (e as { code?: unknown }).code === 'string';
67
+ }
68
+
69
+ /** Strict shape check: flat, `error` + `message` strings, only the three top-level keys. */
70
+ export function isCanonicalErrorEnvelope(body: unknown): body is CanonicalErrorEnvelope {
71
+ if (body === null || typeof body !== 'object' || Array.isArray(body)) return false;
72
+ const b = body as Record<string, unknown>;
73
+ if (typeof b['error'] !== 'string' || b['error'].length === 0) return false;
74
+ if (typeof b['message'] !== 'string' || b['message'].length === 0) return false;
75
+ for (const k of Object.keys(b)) if (k !== 'error' && k !== 'message' && k !== 'details') return false;
76
+ return b['details'] === undefined || (b['details'] !== null && typeof b['details'] === 'object');
77
+ }
@@ -94,7 +94,9 @@ export function fileDisposition(
94
94
  * - a zero-assertion "pass" ⇒ the file's noted reason (`softSkip` /
95
95
  * `seamAbsent`: inapplicable | skipped | blocked) or a behaviorGate reason;
96
96
  * - a zero-assertion "pass" with NO reason ⇒ `blocked` + the marker detail —
97
- * an early return can never become a pass.
97
+ * an early return can never become a pass;
98
+ * - every test `ctx.skip()`ped ⇒ the file's noted reason if it wrote one
99
+ * BEFORE skipping (`ctx.skip()` throws), else `blocked` + the marker.
98
100
  */
99
101
  export function resolveFileRecord(
100
102
  states: readonly FileTestState[],
@@ -111,6 +113,18 @@ export function resolveFileRecord(
111
113
  disposition = 'blocked';
112
114
  detail = UNCLASSIFIED_RETURN_DETAIL;
113
115
  }
116
+ } else if (
117
+ noted !== null &&
118
+ gateReason === undefined &&
119
+ states.length > 0 &&
120
+ states.every((s) => s === 'skip')
121
+ ) {
122
+ // Every test called `ctx.skip()` (vitest reports them as skipped, not as
123
+ // zero-assertion passes) and the file noted why first. Note-then-skip is
124
+ // the required order: `ctx.skip()` throws, so a note written after it is
125
+ // dead code — which is how seven files carried notes the ledger never saw.
126
+ disposition = noted.kind;
127
+ detail = noted.reason;
114
128
  }
115
129
  return detail === undefined ? { disposition } : { disposition, detail };
116
130
  }
@@ -51,6 +51,18 @@ describe('RFC 0148 §A — conformance-execution-witness: the runner record', ()
51
51
  expect(resolveFileRecord(['pass'], undefined, 0, { kind: 'skipped', reason: 'operator opt-out' })).toEqual({ disposition: 'skipped', detail: 'operator opt-out' });
52
52
  });
53
53
 
54
+ it('every test ctx.skip()ped takes the noted reason when one was written before the skip, else stays the blocked marker', () => {
55
+ // `ctx.skip()` throws — a `softSkip(...)` AFTER it is dead code. Seven files
56
+ // carried exactly that dead note and reported as unclassified for a suite minor.
57
+ expect(resolveFileRecord(['skip', 'skip'], undefined, 0, { kind: 'inapplicable', reason: 'sandbox not advertised' })).toEqual({ disposition: 'inapplicable', detail: 'sandbox not advertised' });
58
+ expect(resolveFileRecord(['skip'], undefined, 0, { kind: 'blocked', reason: 'simulator seam 404' })).toEqual({ disposition: 'blocked', detail: 'simulator seam 404' });
59
+ const bare = resolveFileRecord(['skip', 'skip'], undefined, 0, null);
60
+ expect(bare.disposition).toBe('blocked');
61
+ expect(bare.detail).toMatch(/every test skipped with no recorded reason/);
62
+ // A behaviorGate reason still wins over a note — the gate is the more specific record.
63
+ expect(resolveFileRecord(['skip'], 'inapplicable', 0, { kind: 'blocked', reason: 'x' }).disposition).toBe('inapplicable');
64
+ });
65
+
54
66
  it('a behaviorGate reason resolves a zero-assertion pass to inapplicable/skipped; a note outranks nothing but never a witnessed pass', () => {
55
67
  expect(resolveFileRecord(['pass'], 'inapplicable', 0, null).disposition).toBe('inapplicable');
56
68
  expect(resolveFileRecord(['pass'], 'skipped', 0, null).disposition).toBe('skipped');
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import { describe, it, expect } from 'vitest';
20
+ import { readErrorCode } from '../lib/error-envelope.js';
20
21
  import { driver } from '../lib/driver.js';
21
22
  import { isFixtureAdvertised } from '../lib/fixtures.js';
22
23
  import { isConversationPrimitiveSupported } from '../lib/multi-agent-capabilities.js';
@@ -33,8 +34,8 @@ describe.skipIf(SKIP)('conversationCapabilityNegotiation: refusal contract', ()
33
34
  // or at run-create (400). What MUST NOT happen is a successful
34
35
  // 201 followed by silent fallback.
35
36
  expect([400, 404, 422]).toContain(create.status);
36
- const body = create.json as { error?: { code?: string }; code?: string };
37
- const code = body.error?.code ?? body.code ?? '';
37
+ const body = create.json as { code?: string };
38
+ const code = readErrorCode(create.json) ?? body.code ?? '';
38
39
  expect(typeof code).toBe('string');
39
40
  });
40
41
  });
@@ -29,7 +29,8 @@
29
29
  */
30
30
 
31
31
  import { describe, it, expect } from 'vitest';
32
- import { softSkip } from '../lib/soft-skip.js';
32
+ import { softSkip, seamAbsent } from '../lib/soft-skip.js';
33
+ import { capabilityFamily } from '../lib/discovery-capabilities.js';
33
34
  import { driver } from '../lib/driver.js';
34
35
 
35
36
  const HTTP_SKIP = !process.env.OPENWOP_BASE_URL;
@@ -69,12 +70,29 @@ async function resetLog(): Promise<number> {
69
70
  return res.status;
70
71
  }
71
72
 
73
+ /**
74
+ * The cross-engine harness seam answered 404. Whether that is `blocked` (the host
75
+ * advertises `eventLog.crossEngineOrdering.supported: true` and so made a claim
76
+ * this file cannot check) or `inapplicable` (no such advertisement) depends on
77
+ * discovery — record the honest one (RFC 0148 §A).
78
+ */
79
+ async function noteHarnessAbsent(): Promise<void> {
80
+ const disco = await driver.get('/.well-known/openwop');
81
+ const el = capabilityFamily<{ crossEngineOrdering?: { supported?: unknown } }>(disco.json, 'eventLog');
82
+ if (el?.crossEngineOrdering?.supported === true) {
83
+ seamAbsent('host advertises `eventLog.crossEngineOrdering.supported: true` but `POST /v1/host/sample/test/cross-engine/reset` answered 404 — the ordering claim is unobservable (host-sample-test-seams.md)');
84
+ } else {
85
+ softSkip('inapplicable', 'optional advertisement — `eventLog.crossEngineOrdering` not advertised by this host, and the cross-engine harness seam is absent (RFC 0036 §B)');
86
+ }
87
+ }
88
+
72
89
  describe.skipIf(HTTP_SKIP)('cross-engine-append-behavior: §B cross-engine ordering (RFC 0036)', () => {
73
90
  it('interleaved appends from two engines converge to a single globally-ordered sequence', async (ctx) => {
74
91
  const resetStatus = await resetLog();
75
92
  if (resetStatus === 404) {
93
+ await noteHarnessAbsent();
76
94
  ctx.skip(); // host doesn't expose the cross-engine harness seam
77
- return softSkip('blocked', 'precondition not met — `resetStatus === 404` returned early (seam, prior step, or fixture unavailable)');
95
+ return;
78
96
  }
79
97
  expect(resetStatus).toBe(200);
80
98
 
@@ -125,8 +143,9 @@ describe.skipIf(HTTP_SKIP)('cross-engine-append-behavior: §B cross-engine order
125
143
  it('lamport clocks monotonically advance across engines', async (ctx) => {
126
144
  const resetStatus = await resetLog();
127
145
  if (resetStatus === 404) {
146
+ await noteHarnessAbsent();
128
147
  ctx.skip();
129
- return softSkip('blocked', 'precondition not met — `resetStatus === 404` returned early (seam, prior step, or fixture unavailable)');
148
+ return;
130
149
  }
131
150
  expect(resetStatus).toBe(200);
132
151
 
@@ -153,8 +172,9 @@ describe.skipIf(HTTP_SKIP)('cross-engine-append-behavior: §B cross-engine order
153
172
  it('lamport hint from engine A advances engine B past it', async (ctx) => {
154
173
  const resetStatus = await resetLog();
155
174
  if (resetStatus === 404) {
175
+ await noteHarnessAbsent();
156
176
  ctx.skip();
157
- return softSkip('blocked', 'precondition not met — `resetStatus === 404` returned early (seam, prior step, or fixture unavailable)');
177
+ return;
158
178
  }
159
179
  expect(resetStatus).toBe(200);
160
180
 
@@ -180,8 +200,9 @@ describe.skipIf(HTTP_SKIP)('cross-engine-append-behavior: §B cross-engine order
180
200
  it('linearization is deterministic — same appends → same total order', async (ctx) => {
181
201
  const resetStatus = await resetLog();
182
202
  if (resetStatus === 404) {
203
+ await noteHarnessAbsent();
183
204
  ctx.skip();
184
- return softSkip('blocked', 'precondition not met — `resetStatus === 404` returned early (seam, prior step, or fixture unavailable)');
205
+ return;
185
206
  }
186
207
  expect(resetStatus).toBe(200);
187
208
 
@@ -69,8 +69,9 @@ describe.skipIf(HTTP_SKIP)('cross-host-ancestry-endpoint: behavioral (RFC 0040
69
69
  const d = await readDiscovery();
70
70
  const chc = capabilityFamily<{ executionModel?: { [k: string]: unknown; crossHostCausation?: Record<string, unknown>; replayDeterminism?: Record<string, unknown> } }>(d, 'multiAgent')?.executionModel?.crossHostCausation;
71
71
  if (chc?.ancestryEndpointSupported !== true) {
72
+ softSkip('inapplicable', 'capability or profile not advertised by this host — gate `chc?.ancestryEndpointSupported !== true` returned early');
72
73
  ctx.skip();
73
- return softSkip('inapplicable', 'capability or profile not advertised by this host — gate `chc?.ancestryEndpointSupported !== true` returned early');
74
+ return;
74
75
  }
75
76
 
76
77
  // Create a fresh top-level run via the host's conformance-dispatch-loop
@@ -78,8 +79,9 @@ describe.skipIf(HTTP_SKIP)('cross-host-ancestry-endpoint: behavioral (RFC 0040
78
79
  // depend on the specific workflow).
79
80
  const create = await driver.post('/v1/runs', { workflowId: 'conformance-dispatch-loop' });
80
81
  if (create.status !== 201) {
82
+ softSkip('blocked', 'precondition not met — `create.status !== 201` returned early (seam, prior step, or fixture unavailable)');
81
83
  ctx.skip();
82
- return softSkip('blocked', 'precondition not met — `create.status !== 201` returned early (seam, prior step, or fixture unavailable)');
84
+ return;
83
85
  }
84
86
  const runId = (create.json as { runId: string }).runId;
85
87
 
@@ -116,12 +118,14 @@ describe.skipIf(HTTP_SKIP)('cross-host-ancestry-endpoint: behavioral (RFC 0040
116
118
  const d = await readDiscovery();
117
119
  const chc = capabilityFamily<{ executionModel?: { [k: string]: unknown; crossHostCausation?: Record<string, unknown>; replayDeterminism?: Record<string, unknown> } }>(d, 'multiAgent')?.executionModel?.crossHostCausation;
118
120
  if (chc?.supported !== true) {
121
+ softSkip('inapplicable', 'capability or profile not advertised by this host — gate `chc?.supported !== true` returned early');
119
122
  ctx.skip();
120
- return softSkip('inapplicable', 'capability or profile not advertised by this host — gate `chc?.supported !== true` returned early');
123
+ return;
121
124
  }
122
125
  if (chc.ancestryEndpointSupported === true) {
126
+ softSkip('inapplicable', 'capability or profile not advertised by this host — gate `chc.ancestryEndpointSupported === true` returned early');
123
127
  ctx.skip(); // covered by the test above
124
- return softSkip('inapplicable', 'capability or profile not advertised by this host — gate `chc.ancestryEndpointSupported === true` returned early');
128
+ return;
125
129
  }
126
130
 
127
131
  // Use any runId — even a synthetic non-existent one. The endpoint should
@@ -62,13 +62,15 @@ describe.skipIf(HTTP_SKIP)('cross-host-causation-shape: advertisement shape (RFC
62
62
  it('crossHostCausation (when present) conforms to RFC 0040 §D', async (ctx) => {
63
63
  const d = await readDiscovery();
64
64
  if (d === null) {
65
+ softSkip('blocked', 'precondition not met — `d === null` returned early (seam, prior step, or fixture unavailable)');
65
66
  ctx.skip();
66
- return softSkip('blocked', 'precondition not met — `d === null` returned early (seam, prior step, or fixture unavailable)');
67
+ return;
67
68
  }
68
69
  const chc = capabilityFamily<{ executionModel?: { [k: string]: unknown; crossHostCausation?: Record<string, unknown>; replayDeterminism?: Record<string, unknown> } }>(d, 'multiAgent')?.executionModel?.crossHostCausation;
69
70
  if (chc === undefined) {
71
+ softSkip('inapplicable', 'optional advertisement — `multiAgent.executionModel.crossHostCausation` not advertised by this host (RFC 0040 §D)');
70
72
  ctx.skip(); // host doesn't advertise — soft-skip
71
- return softSkip('blocked', 'precondition not met — `chc === undefined` returned early (seam, prior step, or fixture unavailable)');
73
+ return;
72
74
  }
73
75
 
74
76
  expect(
@@ -36,6 +36,7 @@
36
36
  */
37
37
 
38
38
  import { describe, it, expect } from 'vitest';
39
+ import { readErrorCode } from '../lib/error-envelope.js';
39
40
  import { readFileSync } from 'node:fs';
40
41
  import { join } from 'node:path';
41
42
  import Ajv2020 from 'ajv/dist/2020.js';
@@ -96,12 +97,11 @@ describe.skipIf(HTTP_SKIP)('data-residency: admission control (capability-gated,
96
97
  // A host may legitimately reject the probe workflow for reasons unrelated to
97
98
  // residency (e.g. unknown workflowId) — but it MUST NOT reject an ADVERTISED
98
99
  // region with residency_unavailable. That specific pairing is the violation.
99
- const okBody = ok.json as { error?: { code?: string } } | undefined;
100
100
  expect(
101
- okBody?.error?.code !== 'residency_unavailable',
101
+ readErrorCode(ok.json) !== 'residency_unavailable',
102
102
  driver.describe(
103
103
  'capabilities.md §dataResidency / RFC 0129 §3',
104
- `an ADVERTISED region ("${advertised}") MUST NOT be rejected with residency_unavailable (accept iff advertised) — got ${ok.status} ${JSON.stringify(okBody?.error)}`,
104
+ `an ADVERTISED region ("${advertised}") MUST NOT be rejected with residency_unavailable (accept iff advertised) — got ${ok.status} ${JSON.stringify(ok.json).slice(0, 200)}`,
105
105
  ),
106
106
  ).toBe(true);
107
107
 
@@ -114,7 +114,7 @@ describe.skipIf(HTTP_SKIP)('data-residency: admission control (capability-gated,
114
114
  inputs: {},
115
115
  residency: { region: bogus },
116
116
  });
117
- const rejBody = rej.json as { error?: { code?: string }; runId?: string } | undefined;
117
+ const rejBody = rej.json as { runId?: string } | undefined;
118
118
 
119
119
  expect(
120
120
  rej.status === 400 || rej.status === 404 || rej.status === 422,
@@ -124,10 +124,10 @@ describe.skipIf(HTTP_SKIP)('data-residency: admission control (capability-gated,
124
124
  ),
125
125
  ).toBe(true);
126
126
  expect(
127
- rejBody?.error?.code === 'residency_unavailable',
127
+ readErrorCode(rej.json) === 'residency_unavailable',
128
128
  driver.describe(
129
129
  'RFC 0129 §3',
130
- `an unadvertised region MUST be rejected with error code "residency_unavailable" (MUST NOT silently accept-and-ignore) — got ${JSON.stringify(rejBody?.error)}`,
130
+ `an unadvertised region MUST be rejected with error code "residency_unavailable" (MUST NOT silently accept-and-ignore) — got ${JSON.stringify(rej.json).slice(0, 200)}`,
131
131
  ),
132
132
  ).toBe(true);
133
133
  expect(
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import { describe, it, expect } from 'vitest';
20
+ import { readErrorCode } from '../lib/error-envelope.js';
20
21
  import { driver } from '../lib/driver.js';
21
22
 
22
23
  const HTTP_SKIP = !process.env.OPENWOP_BASE_URL;
@@ -83,7 +84,7 @@ describe.skipIf(HTTP_SKIP)('envelope-recovery-applied: SECURITY invariant envelo
83
84
  'envelope.recovery.applied payload MUST NOT carry pre-recovery output substrings; only the canonical {nodeId, path, byteOffset?} keys per RFC 0032 §B.6 + §G — the recovered content rides on downstream RunEventDoc, not on the recovery event',
84
85
  ),
85
86
  ).toBe(400);
86
- expect(r.body.error?.code).toBe('envelope_recovery_content_leak');
87
+ expect(readErrorCode(r.body)).toBe('envelope_recovery_content_leak');
87
88
  });
88
89
 
89
90
  it('rejects payloads carrying any extra field outside {nodeId, path, byteOffset}', async () => {
@@ -104,7 +105,7 @@ describe.skipIf(HTTP_SKIP)('envelope-recovery-applied: SECURITY invariant envelo
104
105
  'envelope.recovery.applied has additionalProperties: false on the payload — any extra field MUST be rejected to prevent regression carriers for pre-recovery output (defense-in-depth on top of envelope-recovery-no-content-leak)',
105
106
  ),
106
107
  ).toBe(400);
107
- expect(r.body.error?.code).toBe('envelope_recovery_content_leak');
108
+ expect(readErrorCode(r.body)).toBe('envelope_recovery_content_leak');
108
109
  });
109
110
  });
110
111
 
@@ -27,6 +27,7 @@
27
27
  */
28
28
 
29
29
  import { describe, it, expect } from 'vitest';
30
+ import { readErrorCode } from '../lib/error-envelope.js';
30
31
  import { driver } from '../lib/driver.js';
31
32
 
32
33
  const HTTP_SKIP = !process.env.OPENWOP_BASE_URL;
@@ -115,7 +116,7 @@ describe.skipIf(HTTP_SKIP)('envelope-refusal-shape: seam emission (RFC 0032 §B.
115
116
  'envelope.refusal.refusalText MUST be passed through the host BYOK redaction harness; seam refuses payloads carrying secret-canary-* substrings (defense-in-depth CI gate per RFC 0032 §B.3 + §G)',
116
117
  ),
117
118
  ).toBe(400);
118
- expect(r.body.error?.code).toBe('envelope_reliability_credential_leak');
119
+ expect(readErrorCode(r.body)).toBe('envelope_reliability_credential_leak');
119
120
  });
120
121
 
121
122
  it('rejects payloads with a top-level `credentialRef` field', async () => {
@@ -131,7 +132,7 @@ describe.skipIf(HTTP_SKIP)('envelope-refusal-shape: seam emission (RFC 0032 §B.
131
132
  });
132
133
  if (r.status === 404) return;
133
134
  expect(r.status).toBe(400);
134
- expect(r.body.error?.code).toBe('envelope_reliability_credential_leak');
135
+ expect(readErrorCode(r.body)).toBe('envelope_reliability_credential_leak');
135
136
  });
136
137
 
137
138
  it('rejects payloads missing required `provider` field', async () => {
@@ -146,7 +147,7 @@ describe.skipIf(HTTP_SKIP)('envelope-refusal-shape: seam emission (RFC 0032 §B.
146
147
  });
147
148
  if (r.status === 404) return;
148
149
  expect(r.status).toBe(400);
149
- expect(r.body.error?.code).toBe('invalid_argument');
150
+ expect(readErrorCode(r.body)).toBe('invalid_argument');
150
151
  });
151
152
  });
152
153
 
@@ -0,0 +1,64 @@
1
+ /**
2
+ * S22 (2026-08-16) — the HTTP error envelope is FLAT, and the suite reads it
3
+ * through one helper.
4
+ *
5
+ * `rest-endpoints.md` §"Error response shape" and `schemas/error-envelope.schema.json`
6
+ * lock `{ error: <string code>, message, details? }` with `additionalProperties:
7
+ * false`. A nested `{ error: { code, retriable } }` shape had crept into three
8
+ * code-list entries, four seam contracts and ~15 scenarios; this scenario pins
9
+ * the decision at the three places it lives — the schema, the helper that every
10
+ * HTTP-envelope leg now reads through, and the prose — so it cannot re-open
11
+ * quietly. Server-free, always-on.
12
+ */
13
+
14
+ import { describe, it, expect } from 'vitest';
15
+ import { readFileSync } from 'node:fs';
16
+ import { join } from 'node:path';
17
+ import Ajv2020 from 'ajv/dist/2020.js';
18
+ import { SCHEMAS_DIR, V1_DIR } from '../lib/paths.js';
19
+ import { readErrorCode, readRetriable, isCanonicalErrorEnvelope, isLegacyNestedEnvelope } from '../lib/error-envelope.js';
20
+
21
+ export const HOST_CALLBACK_NOT_REQUIRED = 'server-free: pins the flat error-envelope decision against the schema, the helper and the prose';
22
+
23
+ describe('S22 — the canonical HTTP error envelope is flat', () => {
24
+ const schema = JSON.parse(readFileSync(join(SCHEMAS_DIR, 'error-envelope.schema.json'), 'utf8')) as Record<string, unknown>;
25
+ const validate = new Ajv2020({ allErrors: true, strict: false }).compile(schema);
26
+
27
+ it('the schema says `error` is a string, requires `message`, and forbids other top-level keys', () => {
28
+ expect(validate({ error: 'runner_unavailable', message: 'no runner', details: { retriable: true } })).toBe(true);
29
+ expect(validate({ error: { code: 'runner_unavailable', retriable: true } })).toBe(false);
30
+ expect(validate({ error: 'x', message: 'y', retriable: true })).toBe(false); // top-level retriable is illegal
31
+ expect(validate({ error: 'x' })).toBe(false); // message required
32
+ });
33
+
34
+ it('readErrorCode / readRetriable read the canonical shape, and tolerate the legacy nested shape only as legacy', () => {
35
+ const flat = { error: 'interop_version_unsupported', message: 'peer offers 0.3', details: { retriable: false, protocol: 'a2a' } };
36
+ expect(readErrorCode(flat)).toBe('interop_version_unsupported');
37
+ expect(readRetriable(flat)).toBe(false);
38
+ expect(isCanonicalErrorEnvelope(flat)).toBe(true);
39
+ expect(isLegacyNestedEnvelope(flat)).toBe(false);
40
+ const nested = { error: { code: 'runner_unavailable', retriable: true } };
41
+ expect(readErrorCode(nested)).toBe('runner_unavailable');
42
+ expect(readRetriable(nested)).toBe(true);
43
+ expect(isCanonicalErrorEnvelope(nested)).toBe(false);
44
+ expect(isLegacyNestedEnvelope(nested)).toBe(true);
45
+ expect(readErrorCode({ message: 'no code' })).toBeUndefined();
46
+ expect(readErrorCode(null)).toBeUndefined();
47
+ expect(readRetriable({ error: 'x', message: 'y' })).toBeUndefined();
48
+ });
49
+
50
+ it.skipIf(V1_DIR === null)('rest-endpoints.md states the precedence, the details.retriable convention, and carries no nested code-list entry', () => {
51
+ const prose = readFileSync(join(V1_DIR as string, 'rest-endpoints.md'), 'utf8');
52
+ expect(prose).toContain('flat** shape above');
53
+ expect(prose).toContain('### `details.retriable` convention');
54
+ // the three formerly-nested code-list entries are flat now
55
+ for (const code of ['runner_unavailable', 'residency_unavailable', 'interop_version_unsupported']) {
56
+ const line = prose.split('\n').find((l) => l.startsWith('- `' + code + '`')) ?? '';
57
+ expect(line, code + ' code-list entry MUST exist').not.toBe('');
58
+ expect(line, code + ' MUST NOT be described with the nested envelope').not.toMatch(/\{\s*"error"\s*:\s*\{/);
59
+ }
60
+ // the seam catalog too
61
+ const seams = readFileSync(join(V1_DIR as string, 'host-sample-test-seams.md'), 'utf8');
62
+ expect(seams).not.toMatch(/"error":\s*\{\s*"code"/);
63
+ });
64
+ });
@@ -26,6 +26,7 @@
26
26
  */
27
27
 
28
28
  import { describe, it, expect } from 'vitest';
29
+ import { readErrorCode } from '../lib/error-envelope.js';
29
30
  import { driver } from '../lib/driver.js';
30
31
  import { capabilityFamily } from '../lib/discovery-capabilities.js';
31
32
 
@@ -97,7 +98,7 @@ describe('fs-path-traversal: MUST-NOT escape sandboxRoot (RFC 0014 §C)', () =>
97
98
  'absolute paths outside sandboxRoot MUST be rejected with a 4xx envelope',
98
99
  ),
99
100
  ).toBeGreaterThanOrEqual(400);
100
- const code = (res.json as { error?: { code?: string } } | undefined)?.error?.code;
101
+ const code = readErrorCode(res.json);
101
102
  expect(
102
103
  code !== undefined && PATH_REJECTION_CODES.has(code),
103
104
  driver.describe(
@@ -113,7 +114,7 @@ describe('fs-path-traversal: MUST-NOT escape sandboxRoot (RFC 0014 §C)', () =>
113
114
  const res = await driver.post('/v1/host/sample/fs/read', { path: '../../etc/passwd' });
114
115
  if (res.status === 404) return;
115
116
  expect(res.status).toBeGreaterThanOrEqual(400);
116
- const code = (res.json as { error?: { code?: string } } | undefined)?.error?.code;
117
+ const code = readErrorCode(res.json);
117
118
  expect(
118
119
  code !== undefined && PATH_REJECTION_CODES.has(code),
119
120
  driver.describe(
@@ -80,13 +80,15 @@ describe.skipIf(HTTP_SKIP)('multi-agent-memory-lifecycle: advertisement shape (R
80
80
  it('crossChildMemoryConcurrency (when advertised) MUST be one of {strict, advisory}', async (ctx) => {
81
81
  const d = await readDiscovery();
82
82
  if (d === null) {
83
+ softSkip('blocked', 'precondition not met — `d === null` returned early (seam, prior step, or fixture unavailable)');
83
84
  ctx.skip();
84
- return softSkip('blocked', 'precondition not met — `d === null` returned early (seam, prior step, or fixture unavailable)');
85
+ return;
85
86
  }
86
87
  const ccmc = capabilityFamily<{ executionModel?: { [k: string]: unknown; crossHostCausation?: Record<string, unknown>; replayDeterminism?: Record<string, unknown> } }>(d, 'multiAgent')?.executionModel?.crossChildMemoryConcurrency;
87
88
  if (ccmc === undefined) {
89
+ softSkip('inapplicable', 'optional advertisement — `multiAgent.executionModel.crossChildMemoryConcurrency` not advertised by this host');
88
90
  ctx.skip(); // optional advertisement — host hasn't opted in
89
- return softSkip('blocked', 'precondition not met — `ccmc === undefined` returned early (seam, prior step, or fixture unavailable)');
91
+ return;
90
92
  }
91
93
  expect(
92
94
  ccmc === 'strict' || ccmc === 'advisory',
@@ -134,16 +136,18 @@ describe.skipIf(HTTP_SKIP)('multi-agent-memory-lifecycle: behavioral (RFC 0039
134
136
  it('MAE-3 replay snapshot refusal: fork mode:replay against a past-retention runId MUST return 422 replay_memory_snapshot_unavailable with documented envelope; silent substitution is non-conformant', async (ctx) => {
135
137
  const d = await readDiscovery();
136
138
  if (d === null) {
139
+ softSkip('blocked', 'precondition not met — `d === null` returned early (seam, prior step, or fixture unavailable)');
137
140
  ctx.skip();
138
- return softSkip('blocked', 'precondition not met — `d === null` returned early (seam, prior step, or fixture unavailable)');
141
+ return;
139
142
  }
140
143
  const v = capabilityFamily<{ executionModel?: { [k: string]: unknown; crossHostCausation?: Record<string, unknown>; replayDeterminism?: Record<string, unknown> } }>(d, 'multiAgent')?.executionModel?.version;
141
144
  const memorySupported = capabilityFamily<{ supported?: unknown }>(d, 'memory')?.supported;
142
145
  const phase2OrLater = typeof v === 'number' && v >= 2;
143
146
  const expiredRunId = process.env.OPENWOP_TEST_EXPIRED_REPLAY_RUN_ID;
144
147
  if (!phase2OrLater || memorySupported !== true || !expiredRunId) {
148
+ softSkip('inapplicable', 'capability or profile not advertised by this host — gate `!phase2OrLater || memorySupported !== true || !expiredRunId` returned early');
145
149
  ctx.skip();
146
- return softSkip('inapplicable', 'capability or profile not advertised by this host — gate `!phase2OrLater || memorySupported !== true || !expiredRunId` returned early');
150
+ return;
147
151
  }
148
152
 
149
153
  const fromSeq = 0;