@cleocode/lafs 2026.3.74 → 2026.4.3

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 (143) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +97 -68
  3. package/dist/schemas/v1/agent-card.schema.json +230 -0
  4. package/dist/schemas/v1/conformance-profiles.json +0 -0
  5. package/dist/schemas/v1/context-ledger.schema.json +70 -0
  6. package/dist/schemas/v1/discovery.schema.json +132 -0
  7. package/dist/schemas/v1/envelope.schema.json +0 -0
  8. package/dist/schemas/v1/error-registry.json +0 -0
  9. package/dist/src/a2a/bindings/grpc.d.ts +118 -11
  10. package/dist/src/a2a/bindings/grpc.d.ts.map +1 -0
  11. package/dist/src/a2a/bindings/grpc.js +80 -8
  12. package/dist/src/a2a/bindings/grpc.js.map +1 -0
  13. package/dist/src/a2a/bindings/http.d.ts +131 -15
  14. package/dist/src/a2a/bindings/http.d.ts.map +1 -0
  15. package/dist/src/a2a/bindings/http.js +101 -14
  16. package/dist/src/a2a/bindings/http.js.map +1 -0
  17. package/dist/src/a2a/bindings/index.d.ts +83 -9
  18. package/dist/src/a2a/bindings/index.d.ts.map +1 -0
  19. package/dist/src/a2a/bindings/index.js +74 -6
  20. package/dist/src/a2a/bindings/index.js.map +1 -0
  21. package/dist/src/a2a/bindings/jsonrpc.d.ts +194 -9
  22. package/dist/src/a2a/bindings/jsonrpc.d.ts.map +1 -0
  23. package/dist/src/a2a/bindings/jsonrpc.js +155 -10
  24. package/dist/src/a2a/bindings/jsonrpc.js.map +1 -0
  25. package/dist/src/a2a/bridge.d.ts +237 -44
  26. package/dist/src/a2a/bridge.d.ts.map +1 -0
  27. package/dist/src/a2a/bridge.js +187 -48
  28. package/dist/src/a2a/bridge.js.map +1 -0
  29. package/dist/src/a2a/extensions.d.ts +222 -12
  30. package/dist/src/a2a/extensions.d.ts.map +1 -0
  31. package/dist/src/a2a/extensions.js +178 -13
  32. package/dist/src/a2a/extensions.js.map +1 -0
  33. package/dist/src/a2a/index.d.ts +10 -7
  34. package/dist/src/a2a/index.d.ts.map +1 -0
  35. package/dist/src/a2a/index.js +24 -27
  36. package/dist/src/a2a/index.js.map +1 -0
  37. package/dist/src/a2a/streaming.d.ts +276 -3
  38. package/dist/src/a2a/streaming.d.ts.map +1 -0
  39. package/dist/src/a2a/streaming.js +255 -11
  40. package/dist/src/a2a/streaming.js.map +1 -0
  41. package/dist/src/a2a/task-lifecycle.d.ts +341 -20
  42. package/dist/src/a2a/task-lifecycle.d.ts.map +1 -0
  43. package/dist/src/a2a/task-lifecycle.js +327 -26
  44. package/dist/src/a2a/task-lifecycle.js.map +1 -0
  45. package/dist/src/budgetEnforcement.d.ts +93 -20
  46. package/dist/src/budgetEnforcement.d.ts.map +1 -0
  47. package/dist/src/budgetEnforcement.js +146 -31
  48. package/dist/src/budgetEnforcement.js.map +1 -0
  49. package/dist/src/circuit-breaker/index.d.ts +260 -10
  50. package/dist/src/circuit-breaker/index.d.ts.map +1 -0
  51. package/dist/src/circuit-breaker/index.js +226 -14
  52. package/dist/src/circuit-breaker/index.js.map +1 -0
  53. package/dist/src/cli.d.ts +1 -0
  54. package/dist/src/cli.d.ts.map +1 -0
  55. package/dist/src/cli.js +12 -11
  56. package/dist/src/cli.js.map +1 -0
  57. package/dist/src/compliance.d.ts +180 -3
  58. package/dist/src/compliance.d.ts.map +1 -0
  59. package/dist/src/compliance.js +114 -13
  60. package/dist/src/compliance.js.map +1 -0
  61. package/dist/src/conformance.d.ts +55 -2
  62. package/dist/src/conformance.d.ts.map +1 -0
  63. package/dist/src/conformance.js +124 -76
  64. package/dist/src/conformance.js.map +1 -0
  65. package/dist/src/conformanceProfiles.d.ts +68 -1
  66. package/dist/src/conformanceProfiles.d.ts.map +1 -0
  67. package/dist/src/conformanceProfiles.js +53 -1
  68. package/dist/src/conformanceProfiles.js.map +1 -0
  69. package/dist/src/deprecationRegistry.d.ts +82 -1
  70. package/dist/src/deprecationRegistry.d.ts.map +1 -0
  71. package/dist/src/deprecationRegistry.js +58 -7
  72. package/dist/src/deprecationRegistry.js.map +1 -0
  73. package/dist/src/discovery.d.ts +347 -65
  74. package/dist/src/discovery.d.ts.map +1 -0
  75. package/dist/src/discovery.js +130 -72
  76. package/dist/src/discovery.js.map +1 -0
  77. package/dist/src/envelope.d.ts +262 -9
  78. package/dist/src/envelope.d.ts.map +1 -0
  79. package/dist/src/envelope.js +179 -15
  80. package/dist/src/envelope.js.map +1 -0
  81. package/dist/src/errorRegistry.d.ts +163 -3
  82. package/dist/src/errorRegistry.d.ts.map +1 -0
  83. package/dist/src/errorRegistry.js +119 -3
  84. package/dist/src/errorRegistry.js.map +1 -0
  85. package/dist/src/fieldExtraction.d.ts +128 -27
  86. package/dist/src/fieldExtraction.d.ts.map +1 -0
  87. package/dist/src/fieldExtraction.js +100 -27
  88. package/dist/src/fieldExtraction.js.map +1 -0
  89. package/dist/src/flagResolver.d.ts +77 -10
  90. package/dist/src/flagResolver.d.ts.map +1 -0
  91. package/dist/src/flagResolver.js +22 -5
  92. package/dist/src/flagResolver.js.map +1 -0
  93. package/dist/src/flagSemantics.d.ts +80 -4
  94. package/dist/src/flagSemantics.d.ts.map +1 -0
  95. package/dist/src/flagSemantics.js +78 -11
  96. package/dist/src/flagSemantics.js.map +1 -0
  97. package/dist/src/health/index.d.ts +103 -9
  98. package/dist/src/health/index.d.ts.map +1 -0
  99. package/dist/src/health/index.js +75 -26
  100. package/dist/src/health/index.js.map +1 -0
  101. package/dist/src/index.d.ts +34 -23
  102. package/dist/src/index.d.ts.map +1 -0
  103. package/dist/src/index.js +40 -28
  104. package/dist/src/index.js.map +1 -0
  105. package/dist/src/mviProjection.d.ts +43 -6
  106. package/dist/src/mviProjection.d.ts.map +1 -0
  107. package/dist/src/mviProjection.js +32 -5
  108. package/dist/src/mviProjection.js.map +1 -0
  109. package/dist/src/native-loader.d.ts +49 -0
  110. package/dist/src/native-loader.d.ts.map +1 -0
  111. package/dist/src/native-loader.js +56 -0
  112. package/dist/src/native-loader.js.map +1 -0
  113. package/dist/src/problemDetails.d.ts +71 -4
  114. package/dist/src/problemDetails.d.ts.map +1 -0
  115. package/dist/src/problemDetails.js +27 -3
  116. package/dist/src/problemDetails.js.map +1 -0
  117. package/dist/src/shutdown/index.d.ts +103 -9
  118. package/dist/src/shutdown/index.d.ts.map +1 -0
  119. package/dist/src/shutdown/index.js +78 -12
  120. package/dist/src/shutdown/index.js.map +1 -0
  121. package/dist/src/tokenEstimator.d.ts +98 -11
  122. package/dist/src/tokenEstimator.d.ts.map +1 -0
  123. package/dist/src/tokenEstimator.js +91 -13
  124. package/dist/src/tokenEstimator.js.map +1 -0
  125. package/dist/src/types.d.ts +477 -11
  126. package/dist/src/types.d.ts.map +1 -0
  127. package/dist/src/types.js +76 -2
  128. package/dist/src/types.js.map +1 -0
  129. package/dist/src/validateEnvelope.d.ts +61 -2
  130. package/dist/src/validateEnvelope.d.ts.map +1 -0
  131. package/dist/src/validateEnvelope.js +81 -14
  132. package/dist/src/validateEnvelope.js.map +1 -0
  133. package/dist/tsconfig.build.tsbuildinfo +1 -0
  134. package/lafs.md +3 -4
  135. package/package.json +14 -12
  136. package/schemas/v1/agent-card.schema.json +0 -0
  137. package/schemas/v1/conformance-profiles.json +0 -0
  138. package/schemas/v1/context-ledger.schema.json +0 -0
  139. package/schemas/v1/discovery.schema.json +0 -0
  140. package/schemas/v1/envelope.schema.json +0 -0
  141. package/schemas/v1/error-registry.json +0 -0
  142. package/dist/src/mcpAdapter.d.ts +0 -28
  143. package/dist/src/mcpAdapter.js +0 -281
@@ -1,15 +1,38 @@
1
- import { getTransportMapping, isRegisteredErrorCode, getRegistryCode } from "./errorRegistry.js";
2
- import { resolveOutputFormat, LAFSFlagError } from "./flagSemantics.js";
3
- import { isAgentAction, isMVILevel } from "./types.js";
4
- import { getChecksForTier } from "./conformanceProfiles.js";
5
- import { validateEnvelope } from "./validateEnvelope.js";
1
+ import { getChecksForTier } from './conformanceProfiles.js';
2
+ import { getRegistryCode, getTransportMapping, isRegisteredErrorCode } from './errorRegistry.js';
3
+ import { LAFSFlagError, resolveOutputFormat } from './flagSemantics.js';
4
+ import { isAgentAction, isMVILevel } from './types.js';
5
+ import { validateEnvelope } from './validateEnvelope.js';
6
6
  function pushCheck(checks, name, pass, detail) {
7
7
  checks.push({ name, pass, ...(detail ? { detail } : {}) });
8
8
  }
9
+ /**
10
+ * Runs the full suite of LAFS envelope conformance checks.
11
+ *
12
+ * @remarks
13
+ * Validates schema, envelope invariants, error-code registration,
14
+ * agent-action validity, transport mapping consistency, context mutation
15
+ * rules, MVI level, strict-mode behavior, pagination mode consistency,
16
+ * strict-mode enforcement, and context preservation. When a
17
+ * {@link EnvelopeConformanceOptions.tier} is specified, only checks
18
+ * belonging to that tier are included in the returned report.
19
+ *
20
+ * @param envelope - The raw value to validate as a LAFS envelope.
21
+ * @param options - Optional tier filter for the conformance checks.
22
+ * @returns A {@link ConformanceReport} with individual check results and an overall pass/fail.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const report = runEnvelopeConformance(parsedJson, { tier: 'core' });
27
+ * if (!report.ok) {
28
+ * console.error(report.checks.filter(c => !c.pass));
29
+ * }
30
+ * ```
31
+ */
9
32
  export function runEnvelopeConformance(envelope, options = {}) {
10
33
  const checks = [];
11
34
  const validation = validateEnvelope(envelope);
12
- pushCheck(checks, "envelope_schema_valid", validation.valid, validation.valid ? undefined : validation.errors.join("; "));
35
+ pushCheck(checks, 'envelope_schema_valid', validation.valid, validation.valid ? undefined : validation.errors.join('; '));
13
36
  if (!validation.valid) {
14
37
  return { ok: false, checks };
15
38
  }
@@ -21,134 +44,138 @@ export function runEnvelopeConformance(envelope, options = {}) {
21
44
  const invariant = typed.success
22
45
  ? typed.error == null // null or undefined (omitted) both valid for success
23
46
  : typed.error != null; // error must be present, result is optional
24
- pushCheck(checks, "envelope_invariants", invariant, invariant
47
+ pushCheck(checks, 'envelope_invariants', invariant, invariant
25
48
  ? undefined
26
49
  : typed.success
27
- ? "success=true but error is present and non-null"
28
- : "success=false requires error to be a non-null object");
50
+ ? 'success=true but error is present and non-null'
51
+ : 'success=false requires error to be a non-null object');
29
52
  // error_code_registered: only checked when error is present (error is optional when success=true)
30
53
  if (typed.error) {
31
54
  const registered = isRegisteredErrorCode(typed.error.code);
32
- pushCheck(checks, "error_code_registered", registered, registered ? undefined : `unregistered code: ${typed.error.code}`);
55
+ pushCheck(checks, 'error_code_registered', registered, registered ? undefined : `unregistered code: ${typed.error.code}`);
33
56
  }
34
57
  else {
35
- pushCheck(checks, "error_code_registered", true, "error field absent or null — skipped (optional when success=true)");
58
+ pushCheck(checks, 'error_code_registered', true, 'error field absent or null — skipped (optional when success=true)');
36
59
  }
37
60
  // agent_action_valid: if error.agentAction is present, it must be a valid LAFSAgentAction
38
61
  if (typed.error && typed.error.agentAction !== undefined) {
39
62
  const valid = isAgentAction(typed.error.agentAction);
40
- pushCheck(checks, "agent_action_valid", valid, valid ? undefined : `invalid agentAction: ${String(typed.error.agentAction)}`);
63
+ pushCheck(checks, 'agent_action_valid', valid, valid ? undefined : `invalid agentAction: ${String(typed.error.agentAction)}`);
41
64
  }
42
65
  else {
43
- pushCheck(checks, "agent_action_valid", true, "agentAction absent — skipped");
66
+ pushCheck(checks, 'agent_action_valid', true, 'agentAction absent — skipped');
44
67
  }
45
68
  // error_registry_agent_action: if error code is registered and agentAction is present,
46
69
  // check if it matches the registry default (warning-level, not a hard failure)
47
- if (typed.error && typed.error.agentAction !== undefined && isRegisteredErrorCode(typed.error.code)) {
70
+ if (typed.error &&
71
+ typed.error.agentAction !== undefined &&
72
+ isRegisteredErrorCode(typed.error.code)) {
48
73
  const registryEntry = getRegistryCode(typed.error.code);
49
- const registryAction = registryEntry?.["agentAction"];
74
+ const registryAction = registryEntry?.['agentAction'];
50
75
  if (registryAction) {
51
76
  const matches = typed.error.agentAction === registryAction;
52
- pushCheck(checks, "error_registry_agent_action", true, // always passes — advisory only
77
+ pushCheck(checks, 'error_registry_agent_action', true, // always passes — advisory only
53
78
  matches
54
79
  ? undefined
55
80
  : `agentAction "${typed.error.agentAction}" differs from registry default "${registryAction}" for ${typed.error.code} (advisory)`);
56
81
  }
57
82
  else {
58
- pushCheck(checks, "error_registry_agent_action", true, "registry entry has no default agentAction — skipped");
83
+ pushCheck(checks, 'error_registry_agent_action', true, 'registry entry has no default agentAction — skipped');
59
84
  }
60
85
  }
61
86
  else {
62
- pushCheck(checks, "error_registry_agent_action", true, typed.error ? "agentAction absent or code unregistered — skipped" : "no error present — skipped");
87
+ pushCheck(checks, 'error_registry_agent_action', true, typed.error
88
+ ? 'agentAction absent or code unregistered — skipped'
89
+ : 'no error present — skipped');
63
90
  }
64
91
  // transport_mapping_consistent: when an error is present, ensure the code has
65
92
  // a transport-specific mapping in the registry for the declared transport.
66
93
  if (typed.error) {
67
- if (typed._meta.transport === "sdk") {
68
- pushCheck(checks, "transport_mapping_consistent", true, "sdk transport does not require external status-code mapping");
94
+ if (typed._meta.transport === 'sdk') {
95
+ pushCheck(checks, 'transport_mapping_consistent', true, 'sdk transport does not require external status-code mapping');
69
96
  }
70
97
  else {
71
98
  const mapping = getTransportMapping(typed.error.code, typed._meta.transport);
72
99
  const mappingOk = mapping !== null;
73
- pushCheck(checks, "transport_mapping_consistent", mappingOk, mappingOk
100
+ pushCheck(checks, 'transport_mapping_consistent', mappingOk, mappingOk
74
101
  ? undefined
75
102
  : `no ${typed._meta.transport} mapping found for code ${typed.error.code}`);
76
103
  }
77
104
  }
78
105
  else {
79
- pushCheck(checks, "transport_mapping_consistent", true, "no error present — mapping check skipped");
106
+ pushCheck(checks, 'transport_mapping_consistent', true, 'no error present — mapping check skipped');
80
107
  }
81
108
  // context_mutation_failure: if the producer marks context as required for a
82
109
  // mutation operation, missing context must fail with a context error code.
83
110
  {
84
111
  const ext = (typed._extensions ?? {});
85
- const contextObj = (ext["context"] ?? {});
86
- const lafsObj = (ext["lafs"] ?? {});
87
- const contextRequired = ext["lafsContextRequired"] === true ||
88
- contextObj["required"] === true ||
89
- lafsObj["contextRequired"] === true;
112
+ const contextObj = (ext['context'] ?? {});
113
+ const lafsObj = (ext['lafs'] ?? {});
114
+ const contextRequired = ext['lafsContextRequired'] === true ||
115
+ contextObj['required'] === true ||
116
+ lafsObj['contextRequired'] === true;
90
117
  if (!contextRequired) {
91
- pushCheck(checks, "context_mutation_failure", true, "context not marked required — skipped");
118
+ pushCheck(checks, 'context_mutation_failure', true, 'context not marked required — skipped');
92
119
  }
93
120
  else {
94
121
  const hasContextIdentity = typed._meta.contextVersion > 0 || Boolean(typed._meta.sessionId);
95
122
  if (typed.success) {
96
123
  const pass = hasContextIdentity;
97
- pushCheck(checks, "context_mutation_failure", pass, pass ? undefined : "context required but missing identity (expect E_CONTEXT_MISSING)");
124
+ pushCheck(checks, 'context_mutation_failure', pass, pass ? undefined : 'context required but missing identity (expect E_CONTEXT_MISSING)');
98
125
  }
99
126
  else {
100
127
  const code = typed.error?.code;
101
- const pass = code === "E_CONTEXT_MISSING" || code === "E_CONTEXT_STALE";
102
- pushCheck(checks, "context_mutation_failure", pass, pass
128
+ const pass = code === 'E_CONTEXT_MISSING' || code === 'E_CONTEXT_STALE';
129
+ pushCheck(checks, 'context_mutation_failure', pass, pass
103
130
  ? undefined
104
131
  : `context required failures should return E_CONTEXT_MISSING or E_CONTEXT_STALE, got ${String(code)}`);
105
132
  }
106
133
  }
107
134
  }
108
135
  const mviValid = isMVILevel(typed._meta.mvi);
109
- pushCheck(checks, "meta_mvi_present", mviValid, mviValid ? undefined : `invalid mvi level: ${String(typed._meta.mvi)}`);
110
- pushCheck(checks, "meta_strict_present", typeof typed._meta.strict === "boolean");
136
+ pushCheck(checks, 'meta_mvi_present', mviValid, mviValid ? undefined : `invalid mvi level: ${String(typed._meta.mvi)}`);
137
+ pushCheck(checks, 'meta_strict_present', typeof typed._meta.strict === 'boolean');
111
138
  // strict_mode_behavior: when strict=true, the envelope MUST NOT contain
112
139
  // explicit null for optional fields that can be omitted (page, error on success).
113
140
  if (typed._meta.strict) {
114
141
  const obj = envelope;
115
- const hasExplicitNullError = typed.success && "error" in obj && obj["error"] === null;
116
- const hasExplicitNullPage = "page" in obj && obj["page"] === null;
142
+ const hasExplicitNullError = typed.success && 'error' in obj && obj['error'] === null;
143
+ const hasExplicitNullPage = 'page' in obj && obj['page'] === null;
117
144
  const strictClean = !hasExplicitNullError && !hasExplicitNullPage;
118
- pushCheck(checks, "strict_mode_behavior", strictClean, strictClean
145
+ pushCheck(checks, 'strict_mode_behavior', strictClean, strictClean
119
146
  ? undefined
120
- : "strict mode: optional fields should be omitted rather than set to null");
147
+ : 'strict mode: optional fields should be omitted rather than set to null');
121
148
  }
122
149
  // pagination_mode_consistent: when page is present and is an object, verify
123
150
  // that the fields present match the declared pagination mode.
124
- if (typed.page && typeof typed.page === "object") {
151
+ if (typed.page && typeof typed.page === 'object') {
125
152
  const page = typed.page;
126
- const mode = page["mode"];
153
+ const mode = page['mode'];
127
154
  let consistent = true;
128
155
  let detail;
129
- if (mode === "cursor") {
130
- if (page["offset"] !== undefined) {
156
+ if (mode === 'cursor') {
157
+ if (page['offset'] !== undefined) {
131
158
  consistent = false;
132
- detail = "cursor mode should not include offset field";
159
+ detail = 'cursor mode should not include offset field';
133
160
  }
134
161
  }
135
- else if (mode === "offset") {
136
- if (page["nextCursor"] !== undefined) {
162
+ else if (mode === 'offset') {
163
+ if (page['nextCursor'] !== undefined) {
137
164
  consistent = false;
138
- detail = "offset mode should not include nextCursor field";
165
+ detail = 'offset mode should not include nextCursor field';
139
166
  }
140
167
  }
141
- else if (mode === "none") {
142
- const extraFields = Object.keys(page).filter((k) => k !== "mode");
168
+ else if (mode === 'none') {
169
+ const extraFields = Object.keys(page).filter((k) => k !== 'mode');
143
170
  if (extraFields.length > 0) {
144
171
  consistent = false;
145
- detail = `none mode should only have mode field, found: ${extraFields.join(", ")}`;
172
+ detail = `none mode should only have mode field, found: ${extraFields.join(', ')}`;
146
173
  }
147
174
  }
148
- pushCheck(checks, "pagination_mode_consistent", consistent, consistent ? undefined : detail);
175
+ pushCheck(checks, 'pagination_mode_consistent', consistent, consistent ? undefined : detail);
149
176
  }
150
177
  else {
151
- pushCheck(checks, "pagination_mode_consistent", true, "page absent — skipped");
178
+ pushCheck(checks, 'pagination_mode_consistent', true, 'page absent — skipped');
152
179
  }
153
180
  // strict_mode_enforced: verify the schema enforces additional-property rules.
154
181
  // When strict=true, extra top-level properties must be rejected by validation.
@@ -157,33 +184,33 @@ export function runEnvelopeConformance(envelope, options = {}) {
157
184
  const extraPropEnvelope = { ...envelope, _unknown_extra: true };
158
185
  const extraResult = validateEnvelope(extraPropEnvelope);
159
186
  if (typed._meta.strict) {
160
- pushCheck(checks, "strict_mode_enforced", !extraResult.valid, extraResult.valid ? "strict=true but additional properties were accepted" : undefined);
187
+ pushCheck(checks, 'strict_mode_enforced', !extraResult.valid, extraResult.valid ? 'strict=true but additional properties were accepted' : undefined);
161
188
  }
162
189
  else {
163
- pushCheck(checks, "strict_mode_enforced", extraResult.valid, !extraResult.valid ? "strict=false but additional properties were rejected" : undefined);
190
+ pushCheck(checks, 'strict_mode_enforced', extraResult.valid, !extraResult.valid ? 'strict=false but additional properties were rejected' : undefined);
164
191
  }
165
192
  }
166
193
  // context_preservation_valid: validate monotonic context version behavior and
167
194
  // context-constraint integrity when a context ledger extension is present.
168
195
  {
169
196
  const ext = (typed._extensions ?? {});
170
- const ledger = (ext["contextLedger"] ?? ext["context"]);
171
- if (!ledger || typeof ledger !== "object") {
172
- pushCheck(checks, "context_preservation_valid", true, "context ledger absent — skipped");
197
+ const ledger = (ext['contextLedger'] ?? ext['context']);
198
+ if (!ledger || typeof ledger !== 'object') {
199
+ pushCheck(checks, 'context_preservation_valid', true, 'context ledger absent — skipped');
173
200
  }
174
201
  else {
175
- const version = ledger["version"];
176
- const previousVersion = ledger["previousVersion"];
177
- const removedConstraints = ledger["removedConstraints"];
178
- const hasNumericVersion = typeof version === "number";
202
+ const version = ledger['version'];
203
+ const previousVersion = ledger['previousVersion'];
204
+ const removedConstraints = ledger['removedConstraints'];
205
+ const hasNumericVersion = typeof version === 'number';
179
206
  const matchesEnvelopeVersion = hasNumericVersion && version === typed._meta.contextVersion;
180
- const monotonicFromPrevious = typeof previousVersion !== "number" || (hasNumericVersion && version >= previousVersion);
207
+ const monotonicFromPrevious = typeof previousVersion !== 'number' || (hasNumericVersion && version >= previousVersion);
181
208
  const constraintsPreserved = !Array.isArray(removedConstraints) || removedConstraints.length === 0 || !typed.success;
182
209
  let pass = matchesEnvelopeVersion && monotonicFromPrevious && constraintsPreserved;
183
210
  let detail;
184
211
  if (!hasNumericVersion) {
185
212
  pass = false;
186
- detail = "context ledger version must be numeric";
213
+ detail = 'context ledger version must be numeric';
187
214
  }
188
215
  else if (!matchesEnvelopeVersion) {
189
216
  detail = `context version mismatch: ledger=${String(version)} envelope=${typed._meta.contextVersion}`;
@@ -192,21 +219,23 @@ export function runEnvelopeConformance(envelope, options = {}) {
192
219
  detail = `non-monotonic context version: previous=${String(previousVersion)} current=${String(version)}`;
193
220
  }
194
221
  else if (!constraintsPreserved) {
195
- detail = "context constraint removal detected on successful response";
222
+ detail = 'context constraint removal detected on successful response';
196
223
  }
197
224
  // Error-path validation for stale/missing context signaling.
198
- if (!typed.success && typed.error && ledger["required"] === true) {
199
- const stale = ledger["stale"] === true;
200
- if (stale && typed.error.code !== "E_CONTEXT_STALE") {
225
+ if (!typed.success && typed.error && ledger['required'] === true) {
226
+ const stale = ledger['stale'] === true;
227
+ if (stale && typed.error.code !== 'E_CONTEXT_STALE') {
201
228
  pass = false;
202
229
  detail = `stale context should return E_CONTEXT_STALE, got ${typed.error.code}`;
203
230
  }
204
- if (!stale && typed.error.code !== "E_CONTEXT_MISSING" && typed.error.code !== "E_CONTEXT_STALE") {
231
+ if (!stale &&
232
+ typed.error.code !== 'E_CONTEXT_MISSING' &&
233
+ typed.error.code !== 'E_CONTEXT_STALE') {
205
234
  pass = false;
206
235
  detail = `required context failure should return E_CONTEXT_MISSING or E_CONTEXT_STALE, got ${typed.error.code}`;
207
236
  }
208
237
  }
209
- pushCheck(checks, "context_preservation_valid", pass, detail);
238
+ pushCheck(checks, 'context_preservation_valid', pass, detail);
210
239
  }
211
240
  }
212
241
  const tier = options.tier;
@@ -217,32 +246,51 @@ export function runEnvelopeConformance(envelope, options = {}) {
217
246
  const tierChecks = checks.filter((check) => allowed.has(check.name));
218
247
  return { ok: tierChecks.every((check) => check.pass), checks: tierChecks };
219
248
  }
249
+ /**
250
+ * Runs LAFS flag-semantics conformance checks against a set of flag inputs.
251
+ *
252
+ * @remarks
253
+ * Verifies that conflicting flags (`--human` + `--json`) are properly rejected,
254
+ * the protocol default resolves to JSON, and project/user config overrides are
255
+ * respected. Catches {@link LAFSFlagError} with code `E_FORMAT_CONFLICT` as a
256
+ * valid conformance outcome.
257
+ *
258
+ * @param flags - The flag input to validate.
259
+ * @returns A {@link ConformanceReport} with individual check results and an overall pass/fail.
260
+ *
261
+ * @example
262
+ * ```ts
263
+ * const report = runFlagConformance({ humanFlag: true, jsonFlag: false });
264
+ * console.log(report.ok); // true
265
+ * ```
266
+ */
220
267
  export function runFlagConformance(flags) {
221
268
  const checks = [];
222
269
  try {
223
270
  const resolved = resolveOutputFormat(flags);
224
- pushCheck(checks, "flag_conflict_rejected", !(flags.humanFlag && flags.jsonFlag));
271
+ pushCheck(checks, 'flag_conflict_rejected', !(flags.humanFlag && flags.jsonFlag));
225
272
  // Protocol-default check: when nothing is specified (source === "default"),
226
273
  // the protocol requires JSON as the default format.
227
- const isProtocolDefault = resolved.source === "default";
228
- pushCheck(checks, "json_protocol_default", !isProtocolDefault || resolved.format === "json", isProtocolDefault && resolved.format !== "json"
274
+ const isProtocolDefault = resolved.source === 'default';
275
+ pushCheck(checks, 'json_protocol_default', !isProtocolDefault || resolved.format === 'json', isProtocolDefault && resolved.format !== 'json'
229
276
  ? `protocol default should be json, got ${resolved.format}`
230
277
  : undefined);
231
278
  // Config-override check: when a project or user default is active,
232
279
  // the resolved format must match the config-provided value.
233
- const hasConfigOverride = resolved.source === "project" || resolved.source === "user";
234
- const expectedOverride = resolved.source === "project" ? flags.projectDefault : flags.userDefault;
235
- pushCheck(checks, "config_override_respected", !hasConfigOverride || resolved.format === expectedOverride, hasConfigOverride && resolved.format !== expectedOverride
280
+ const hasConfigOverride = resolved.source === 'project' || resolved.source === 'user';
281
+ const expectedOverride = resolved.source === 'project' ? flags.projectDefault : flags.userDefault;
282
+ pushCheck(checks, 'config_override_respected', !hasConfigOverride || resolved.format === expectedOverride, hasConfigOverride && resolved.format !== expectedOverride
236
283
  ? `config override expected ${String(expectedOverride)}, got ${resolved.format}`
237
284
  : undefined);
238
285
  }
239
286
  catch (error) {
240
- if (error instanceof LAFSFlagError && error.code === "E_FORMAT_CONFLICT") {
241
- pushCheck(checks, "flag_conflict_rejected", true);
287
+ if (error instanceof LAFSFlagError && error.code === 'E_FORMAT_CONFLICT') {
288
+ pushCheck(checks, 'flag_conflict_rejected', true);
242
289
  return { ok: checks.every((check) => check.pass), checks };
243
290
  }
244
- pushCheck(checks, "flag_resolution", false, error instanceof Error ? error.message : String(error));
291
+ pushCheck(checks, 'flag_resolution', false, error instanceof Error ? error.message : String(error));
245
292
  return { ok: false, checks };
246
293
  }
247
294
  return { ok: checks.every((check) => check.pass), checks };
248
295
  }
296
+ //# sourceMappingURL=conformance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformance.js","sourceRoot":"","sources":["../../src/conformance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,u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,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;AAC7D,CAAC"}
@@ -1,11 +1,78 @@
1
- export type ConformanceTier = "core" | "standard" | "complete";
1
+ /**
2
+ * Named conformance tier indicating the breadth of checks applied.
3
+ *
4
+ * @remarks
5
+ * Tiers are cumulative: `core` is a subset of `standard`, which is
6
+ * a subset of `complete`.
7
+ */
8
+ export type ConformanceTier = 'core' | 'standard' | 'complete';
9
+ /**
10
+ * Schema for the conformance-profiles JSON file.
11
+ *
12
+ * @remarks
13
+ * Maps each {@link ConformanceTier} to the set of check names it includes.
14
+ */
2
15
  export interface ConformanceProfiles {
16
+ /** Semantic version of the conformance-profiles schema. */
3
17
  version: string;
18
+ /** Mapping from tier name to the ordered list of check names in that tier. */
4
19
  tiers: Record<ConformanceTier, string[]>;
5
20
  }
21
+ /**
22
+ * Loads the conformance profiles from the bundled JSON schema.
23
+ *
24
+ * @remarks
25
+ * Returns the parsed `conformance-profiles.json` as a typed object.
26
+ * The profiles define which checks belong to each conformance tier.
27
+ *
28
+ * @returns The full {@link ConformanceProfiles} object.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const profiles = getConformanceProfiles();
33
+ * console.log(profiles.tiers.core);
34
+ * ```
35
+ */
6
36
  export declare function getConformanceProfiles(): ConformanceProfiles;
37
+ /**
38
+ * Returns the list of check names that belong to the given conformance tier.
39
+ *
40
+ * @remarks
41
+ * Retrieves the tier from the bundled profiles JSON. Returns an empty
42
+ * array when the tier key is not found (defensive fallback).
43
+ *
44
+ * @param tier - The conformance tier to retrieve checks for.
45
+ * @returns An array of check name strings for the specified tier.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * const coreChecks = getChecksForTier('core');
50
+ * ```
51
+ */
7
52
  export declare function getChecksForTier(tier: ConformanceTier): string[];
53
+ /**
54
+ * Validates that the conformance profiles are internally consistent and reference only known checks.
55
+ *
56
+ * @remarks
57
+ * Verifies two invariants:
58
+ * 1. Tier superset containment: every `core` check appears in `standard`,
59
+ * and every `standard` check appears in `complete`.
60
+ * 2. Known-check coverage: every check name referenced in any tier exists
61
+ * in the provided `availableChecks` list.
62
+ *
63
+ * @param availableChecks - The full list of check names implemented by the conformance runner.
64
+ * @returns An object with `valid` (true when no errors) and an `errors` array of diagnostic strings.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const result = validateConformanceProfiles(['envelope_schema_valid', 'envelope_invariants']);
69
+ * if (!result.valid) {
70
+ * console.error(result.errors);
71
+ * }
72
+ * ```
73
+ */
8
74
  export declare function validateConformanceProfiles(availableChecks: string[]): {
9
75
  valid: boolean;
10
76
  errors: string[];
11
77
  };
78
+ //# sourceMappingURL=conformanceProfiles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformanceProfiles.d.ts","sourceRoot":"","sources":["../../src/conformanceProfiles.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AAE/D;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB,8EAA8E;IAC9E,KAAK,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC,CAAC;CAC1C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,eAAe,GAAG,MAAM,EAAE,CAGhE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,2BAA2B,CAAC,eAAe,EAAE,MAAM,EAAE,GAAG;IACtE,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB,CAgCA"}
@@ -1,11 +1,62 @@
1
- import profilesJson from "../schemas/v1/conformance-profiles.json" with { type: "json" };
1
+ import profilesJson from '../schemas/v1/conformance-profiles.json' with { type: 'json' };
2
+ /**
3
+ * Loads the conformance profiles from the bundled JSON schema.
4
+ *
5
+ * @remarks
6
+ * Returns the parsed `conformance-profiles.json` as a typed object.
7
+ * The profiles define which checks belong to each conformance tier.
8
+ *
9
+ * @returns The full {@link ConformanceProfiles} object.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const profiles = getConformanceProfiles();
14
+ * console.log(profiles.tiers.core);
15
+ * ```
16
+ */
2
17
  export function getConformanceProfiles() {
3
18
  return profilesJson;
4
19
  }
20
+ /**
21
+ * Returns the list of check names that belong to the given conformance tier.
22
+ *
23
+ * @remarks
24
+ * Retrieves the tier from the bundled profiles JSON. Returns an empty
25
+ * array when the tier key is not found (defensive fallback).
26
+ *
27
+ * @param tier - The conformance tier to retrieve checks for.
28
+ * @returns An array of check name strings for the specified tier.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const coreChecks = getChecksForTier('core');
33
+ * ```
34
+ */
5
35
  export function getChecksForTier(tier) {
6
36
  const profiles = getConformanceProfiles();
7
37
  return profiles.tiers[tier] ?? [];
8
38
  }
39
+ /**
40
+ * Validates that the conformance profiles are internally consistent and reference only known checks.
41
+ *
42
+ * @remarks
43
+ * Verifies two invariants:
44
+ * 1. Tier superset containment: every `core` check appears in `standard`,
45
+ * and every `standard` check appears in `complete`.
46
+ * 2. Known-check coverage: every check name referenced in any tier exists
47
+ * in the provided `availableChecks` list.
48
+ *
49
+ * @param availableChecks - The full list of check names implemented by the conformance runner.
50
+ * @returns An object with `valid` (true when no errors) and an `errors` array of diagnostic strings.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const result = validateConformanceProfiles(['envelope_schema_valid', 'envelope_invariants']);
55
+ * if (!result.valid) {
56
+ * console.error(result.errors);
57
+ * }
58
+ * ```
59
+ */
9
60
  export function validateConformanceProfiles(availableChecks) {
10
61
  const profiles = getConformanceProfiles();
11
62
  const errors = [];
@@ -32,3 +83,4 @@ export function validateConformanceProfiles(availableChecks) {
32
83
  }
33
84
  return { valid: errors.length === 0, errors };
34
85
  }
86
+ //# sourceMappingURL=conformanceProfiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conformanceProfiles.js","sourceRoot":"","sources":["../../src/conformanceProfiles.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,yCAAyC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAwBzF;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,YAAmC,CAAC;AAC7C,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAqB;IACpD,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;IAC1C,OAAO,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,2BAA2B,CAAC,eAAyB;IAInE,MAAM,QAAQ,GAAG,sBAAsB,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAa,EAAE,CAAC;IAE5B,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAElD,KAAK,MAAM,KAAK,IAAI,IAAI,EAAE,CAAC;QACzB,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,C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