@inventarch/compliance 3.0.0 → 3.1.1

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 (80) hide show
  1. package/README.md +92 -4
  2. package/SPEC.md +44 -27
  3. package/dist/catalog.d.ts +1 -1
  4. package/dist/catalog.js +1 -1
  5. package/dist/conformance/bind.d.ts +42 -0
  6. package/dist/conformance/bind.d.ts.map +1 -0
  7. package/dist/conformance/bind.js +129 -0
  8. package/dist/conformance/bind.js.map +1 -0
  9. package/dist/conformance/corpus.d.ts +13 -0
  10. package/dist/conformance/corpus.d.ts.map +1 -0
  11. package/dist/conformance/corpus.js +43 -0
  12. package/dist/conformance/corpus.js.map +1 -0
  13. package/dist/conformance/evidence-fixtures.d.ts +5 -0
  14. package/dist/conformance/evidence-fixtures.d.ts.map +1 -0
  15. package/dist/conformance/evidence-fixtures.js +257 -0
  16. package/dist/conformance/evidence-fixtures.js.map +1 -0
  17. package/dist/conformance/evidence.d.ts +52 -0
  18. package/dist/conformance/evidence.d.ts.map +1 -0
  19. package/dist/conformance/evidence.js +96 -0
  20. package/dist/conformance/evidence.js.map +1 -0
  21. package/dist/conformance/inventory.d.ts +36 -0
  22. package/dist/conformance/inventory.d.ts.map +1 -0
  23. package/dist/conformance/inventory.generated.d.ts +4 -0
  24. package/dist/conformance/inventory.generated.d.ts.map +1 -0
  25. package/dist/conformance/inventory.generated.js +2230 -0
  26. package/dist/conformance/inventory.generated.js.map +1 -0
  27. package/dist/conformance/inventory.js +15 -0
  28. package/dist/conformance/inventory.js.map +1 -0
  29. package/dist/conformance/refusals.d.ts +5 -0
  30. package/dist/conformance/refusals.d.ts.map +1 -0
  31. package/dist/conformance/refusals.js +372 -0
  32. package/dist/conformance/refusals.js.map +1 -0
  33. package/dist/conformance/verify-kernel.d.ts +9 -0
  34. package/dist/conformance/verify-kernel.d.ts.map +1 -0
  35. package/dist/conformance/verify-kernel.js +49 -0
  36. package/dist/conformance/verify-kernel.js.map +1 -0
  37. package/dist/conformance/verify.d.ts +15 -0
  38. package/dist/conformance/verify.d.ts.map +1 -0
  39. package/dist/conformance/verify.js +170 -0
  40. package/dist/conformance/verify.js.map +1 -0
  41. package/dist/evidence.d.ts +5 -5
  42. package/dist/evidence.js +5 -5
  43. package/dist/graph-checks.d.ts +9 -6
  44. package/dist/graph-checks.d.ts.map +1 -1
  45. package/dist/graph-checks.js +9 -6
  46. package/dist/graph-checks.js.map +1 -1
  47. package/dist/host-plugin.js +2 -2
  48. package/dist/host-plugin.js.map +1 -1
  49. package/dist/index.d.ts +5 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/kernel.d.ts +25 -0
  54. package/dist/kernel.d.ts.map +1 -0
  55. package/dist/kernel.js +290 -0
  56. package/dist/kernel.js.map +1 -0
  57. package/dist/obligations.d.ts +2 -2
  58. package/dist/obligations.d.ts.map +1 -1
  59. package/dist/obligations.js +2 -2
  60. package/dist/obligations.js.map +1 -1
  61. package/dist/profiles.d.ts +1 -1
  62. package/dist/profiles.js +1 -1
  63. package/dist/report.d.ts +8 -3
  64. package/dist/report.d.ts.map +1 -1
  65. package/dist/report.js +28 -7
  66. package/dist/report.js.map +1 -1
  67. package/dist/schema.d.ts +4 -1
  68. package/dist/schema.d.ts.map +1 -1
  69. package/dist/schema.js +11 -10
  70. package/dist/schema.js.map +1 -1
  71. package/dist/types.d.ts +5 -0
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/types.js.map +1 -1
  74. package/dist/values.d.ts +2 -2
  75. package/dist/values.d.ts.map +1 -1
  76. package/dist/values.js +2 -2
  77. package/dist/values.js.map +1 -1
  78. package/fixtures/loop/.ia/src/systems/workspace-system/schemas/distribution.schema.ia +11 -0
  79. package/fixtures/refusals.ts +2 -470
  80. package/package.json +3 -3
@@ -1,470 +1,2 @@
1
- /** Executable boundary fixtures over the actual native corpus. These mutate
2
- * typed products to exercise refusal APIs; they are not substitute providers. */
3
- import { KERNEL_DIGEST, LANGUAGE_VERSION } from '@inventarch/language';
4
- import type { CompiledRecord, FrozenRegistry, SchemaField } from '@inventarch/language';
5
- import {
6
- GraphUsageError,
7
- canonicalRoot,
8
- load,
9
- resolve,
10
- traverse,
11
- validateCoordinate,
12
- variants,
13
- } from '@inventarch/graph';
14
- import type { Graph, Node, RevisionSource } from '@inventarch/graph';
15
- import {
16
- validateAdoption,
17
- validateCheck,
18
- validateCoverage,
19
- validateFragments,
20
- validateParse,
21
- validateSchema,
22
- validateSelectors,
23
- validateSystems,
24
- validateVariants,
25
- runLanguageFixture,
26
- } from '../src/index.js';
27
- import type { AdoptionEvaluators, Finding, FixtureResult, SystemFolder } from '../src/index.js';
28
- import { assess } from '../src/types.js';
29
-
30
- export function runRefusalFixtures(
31
- graph: Graph,
32
- inputs: readonly RevisionSource[],
33
- folders: readonly SystemFolder[],
34
- ): readonly FixtureResult[] {
35
- const records = [...graph.nodes.values()],
36
- registry = graph.registry;
37
- const agent = records.find((r) => r.discriminator === 'agent')!,
38
- method = records.find((r) => r.name === 'sample-procedure')!;
39
- const law = records.find((r) => r.discriminator === 'law')!,
40
- contract = records.find((r) => r.name === 'foundation-authoring-contract')!,
41
- check = records.find((r) => r.discriminator === 'check')!,
42
- mandate = records.find((r) => r.discriminator === 'mandate' && r.name === 'sample-mandate')!;
43
- const ambiguous: Node = {
44
- ...law,
45
- variants: [
46
- {
47
- key: 'requires',
48
- value: { kind: 'string', text: 'one' },
49
- condition: [{ axis: 'phase', value: 'act' }],
50
- span: { line: 10, endLine: 10 },
51
- },
52
- {
53
- key: 'requires',
54
- value: { kind: 'string', text: 'two' },
55
- condition: [{ axis: 'primitive', value: 'Memory' }],
56
- span: { line: 11, endLine: 11 },
57
- },
58
- ],
59
- };
60
- const rebuild = (changed: readonly CompiledRecord[] = records, vocabulary: FrozenRegistry = registry) =>
61
- load(changed, vocabulary, {
62
- sources: inputs,
63
- languageVersion: LANGUAGE_VERSION,
64
- kernelDigest: KERNEL_DIGEST,
65
- location: '',
66
- });
67
- const schemaFindings = (changed: CompiledRecord = agent, vocabulary = registry) =>
68
- validateSchema(changed, vocabulary, records).findings;
69
- const systemFindings = (changed = folders, vocabulary = registry, pool: readonly CompiledRecord[] = records) =>
70
- validateSystems(changed, vocabulary, pool).flatMap((a) => a.findings);
71
- const rule = {
72
- predicate: 'cite' as const,
73
- direction: 'out' as const,
74
- spelling: 'cite',
75
- target: 'playbook',
76
- must: true,
77
- cardinality: 'one' as const,
78
- span: { line: 1, endLine: 1 },
79
- };
80
- const schemas = new Map(registry.schemas);
81
- schemas.set('agent', { ...schemas.get('agent')!, edges: [rule] });
82
- // W0 narrowing rows: the agent's `meaning.says` value re-typed, and its schema re-declared to narrow that one field.
83
- const saying = (value: CompiledRecord['head'][number]['value']): CompiledRecord => ({
84
- ...agent,
85
- sections: agent.sections.map((s) =>
86
- s.name !== 'meaning'
87
- ? s
88
- : { ...s, fields: s.fields.map((f) => ('key' in f && f.key === 'says' ? { ...f, value } : f)) },
89
- ),
90
- });
91
- const narrowed = (field: Partial<SchemaField>): FrozenRegistry => {
92
- const declared = new Map(registry.schemas),
93
- original = declared.get('agent')!;
94
- declared.set('agent', {
95
- ...original,
96
- fields: [{ section: 'meaning', key: 'says', type: 'text', must: true, span: original.span, ...field }],
97
- });
98
- return { ...registry, schemas: declared };
99
- };
100
- const edge = {
101
- predicate: 'cite' as const,
102
- direction: 'out' as const,
103
- spelling: 'cite',
104
- reference: { kind: 'ref' as const, discriminator: 'playbook', name: 'missing' },
105
- target: null,
106
- span: agent.source,
107
- };
108
- /** Lane D, D5: the sample mandate with its stated move list emptied, which admission refuses (compliance C05). */
109
- const unmoved: CompiledRecord = {
110
- ...mandate,
111
- sections: mandate.sections.map((s) =>
112
- s.name !== 'authority'
113
- ? s
114
- : {
115
- ...s,
116
- fields: s.fields.map((f) =>
117
- 'key' in f && f.key === 'moves' ? { ...f, value: { kind: 'list' as const, items: [] } } : f,
118
- ),
119
- },
120
- ),
121
- };
122
- /** One boundary per code, and a labelled second one where a code has a second refusal to show. */
123
- const examples: readonly (readonly [Finding['code'], () => readonly Finding[], string?])[] = [
124
- [
125
- 'IA-GRAPH-IDENTITY-TIE',
126
- () => rebuild([...records, { ...method, source: { ...method.source, line: 1000 } }]).diagnostics,
127
- ],
128
- ['IA-GRAPH-TARGET-MISSING', () => rebuild(records.filter((r) => r.identity !== contract.identity)).diagnostics],
129
- [
130
- 'IA-GRAPH-TARGET-AMBIGUOUS',
131
- () => {
132
- const result = resolve(
133
- { kind: 'ref', discriminator: method.discriminator, name: method.name },
134
- [method, { ...method, source: { ...method.source, line: 1000 } }],
135
- registry,
136
- );
137
- return result.ok
138
- ? []
139
- : [
140
- {
141
- code: result.code,
142
- path: method.source.path,
143
- line: 1,
144
- severity: 'error',
145
- message: 'Ambiguous boundary reference',
146
- },
147
- ];
148
- },
149
- ],
150
- ['IA-GRAPH-EDGE-UNCONSENTED', () => rebuild(records, { ...registry, consent: new Map() }).diagnostics],
151
- [
152
- 'IA-GRAPH-DIMENSION-UNKNOWN',
153
- () =>
154
- rebuild(
155
- records.map((r) =>
156
- r !== method
157
- ? r
158
- : { ...r, head: [{ key: 'artifact-set', value: { kind: 'scalar', text: 'unknown' }, span: r.source }] },
159
- ),
160
- ).diagnostics,
161
- ],
162
- [
163
- 'IA-GRAPH-COORDINATE-VALUE-UNKNOWN',
164
- () => {
165
- validateCoordinate({ phase: 'unknown' });
166
- return [];
167
- },
168
- ],
169
- [
170
- 'IA-GRAPH-VERB-UNKNOWN',
171
- () => {
172
- traverse(graph, { start: [], follow: ['imagines'] });
173
- return [];
174
- },
175
- ],
176
- [
177
- 'IA-GRAPH-TRAVERSAL-INVALID',
178
- () => {
179
- traverse(graph, { start: [], depth: 9 });
180
- return [];
181
- },
182
- ],
183
- ['IA-GRAPH-VARIANT-AMBIGUOUS', () => variants(ambiguous, { phase: 'act', primitive: 'Memory' }).diagnostics],
184
- [
185
- 'IA-GRAPH-SCOPE-INVALID',
186
- () => {
187
- canonicalRoot('../escape');
188
- return [];
189
- },
190
- ],
191
- ['IA-COMP-SCHEMA-MISSING', () => schemaFindings(agent, { ...registry, schemas: new Map() })],
192
- ['IA-COMP-SCHEMA-KIND-MISMATCH', () => schemaFindings({ ...agent, kind: 'definition' })],
193
- [
194
- 'IA-COMP-SECTION-MISSING',
195
- () => schemaFindings({ ...agent, sections: agent.sections.filter((s) => s.name !== 'meaning') }),
196
- ],
197
- [
198
- 'IA-COMP-SECTION-UNKNOWN',
199
- () =>
200
- schemaFindings({
201
- ...agent,
202
- sections: [...agent.sections, { name: 'unknown', span: agent.source, fields: [] }],
203
- }),
204
- ],
205
- [
206
- 'IA-COMP-FIELD-MISSING',
207
- () =>
208
- schemaFindings({
209
- ...agent,
210
- sections: agent.sections.map((s) => (s.name !== 'meaning' ? s : { ...s, fields: [] })),
211
- }),
212
- ],
213
- [
214
- 'IA-COMP-FIELD-DUPLICATE',
215
- () =>
216
- schemaFindings({
217
- ...agent,
218
- sections: agent.sections.map((s) =>
219
- s.name !== 'meaning'
220
- ? s
221
- : { ...s, fields: [...s.fields, ...s.fields.filter((f) => 'key' in f && f.key === 'says')] },
222
- ),
223
- }),
224
- ],
225
- [
226
- 'IA-COMP-FIELD-UNKNOWN',
227
- () =>
228
- schemaFindings({
229
- ...agent,
230
- sections: agent.sections.map((s) =>
231
- s.name !== 'meaning'
232
- ? s
233
- : {
234
- ...s,
235
- fields: [...s.fields, { key: 'ready', value: { kind: 'scalar', text: 'true' }, span: agent.source }],
236
- },
237
- ),
238
- }),
239
- ],
240
- [
241
- 'IA-COMP-FIELD-TYPE',
242
- () =>
243
- schemaFindings({
244
- ...agent,
245
- sections: agent.sections.map((s) =>
246
- s.name !== 'meaning'
247
- ? s
248
- : {
249
- ...s,
250
- fields: s.fields.map((f) =>
251
- 'key' in f && f.key === 'says' ? { ...f, value: { kind: 'list', items: [] } } : f,
252
- ),
253
- },
254
- ),
255
- }),
256
- ],
257
- [
258
- 'IA-COMP-FIELD-VALUE',
259
- () => schemaFindings(saying({ kind: 'scalar', text: 'nope' }), narrowed({ type: 'id', values: ['yes'] })),
260
- ],
261
- [
262
- 'IA-COMP-FIELD-REF-TARGET',
263
- () =>
264
- schemaFindings(
265
- saying({ kind: 'ref', discriminator: 'playbook', name: 'sample-procedure' }),
266
- narrowed({ type: 'ref', target: 'agent' }),
267
- ),
268
- ],
269
- [
270
- 'IA-COMP-FIELD-REF-MISSING',
271
- () =>
272
- schemaFindings(
273
- saying({ kind: 'ref', discriminator: 'playbook', name: 'missing' }),
274
- narrowed({ type: 'ref', target: 'playbook' }),
275
- ),
276
- ],
277
- ['IA-COMP-FIELD-VALUE', () => schemaFindings(unmoved), 'mandate-moves-empty'],
278
- ['IA-COMP-FIELD-FORM', () => schemaFindings(agent, narrowed({ type: 'text', form: 'iso-date' }))],
279
- ['IA-COMP-EDGE-CARDINALITY', () => schemaFindings(agent, { ...registry, schemas })],
280
- ['IA-COMP-EDGE-UNRESOLVED', () => schemaFindings({ ...agent, edges: [edge] }, { ...registry, schemas })],
281
- ['IA-COMP-SYSTEM-MALFORMED', () => systemFindings([{ name: 'empty', path: 'empty', sources: [], records: [] }])],
282
- [
283
- 'IA-COMP-DISCRIMINATOR-FOREIGN',
284
- () =>
285
- systemFindings(folders.map((f) => (f.name !== 'agent-system' ? f : { ...f, records: [...f.records, method] }))),
286
- ],
287
- ['IA-COMP-BOOTSTRAP-ORDER', () => systemFindings(folders, { ...registry, order: [...registry.order].reverse() })],
288
- [
289
- 'IA-COMP-STEWARD-MISSING',
290
- () =>
291
- systemFindings(
292
- folders,
293
- registry,
294
- records.filter((r) => r.discriminator !== 'agent'),
295
- ),
296
- ],
297
- [
298
- 'IA-COMP-CONSENT-EMPTY',
299
- () =>
300
- systemFindings(folders, {
301
- ...registry,
302
- systems: new Map([...registry.systems].map(([key, value]) => [key, { ...value, consent: [] }])),
303
- }),
304
- ],
305
- [
306
- 'IA-COMP-SCHEMA-UNREFERENCED',
307
- () =>
308
- systemFindings(folders, {
309
- ...registry,
310
- registrations: new Map([...registry.registrations].filter(([key]) => key !== 'agent')),
311
- }),
312
- ],
313
- [
314
- 'IA-COMP-SCHEMA-MULTIPLE',
315
- () =>
316
- systemFindings(folders, {
317
- ...registry,
318
- registrations: new Map([
319
- ...registry.registrations,
320
- ['duplicate', { ...registry.registrations.get('agent')!, keyword: 'duplicate' }],
321
- ]),
322
- }),
323
- ],
324
- [
325
- 'IA-COMP-FRAGMENT-MISSING',
326
- () =>
327
- validateFragments(
328
- rebuild(
329
- records.map((r) =>
330
- r.discriminator !== 'case'
331
- ? r
332
- : {
333
- ...r,
334
- edges: r.edges.map((e) => ({
335
- ...e,
336
- fragment: 'REQ-MISSING',
337
- reference: { ...e.reference, fragment: 'REQ-MISSING' },
338
- })),
339
- },
340
- ),
341
- ),
342
- ).findings,
343
- ],
344
- [
345
- 'IA-COMP-COVERAGE-MISSING',
346
- () => {
347
- const g = rebuild(records.filter((r) => r.name !== 'valid-native-record'));
348
- return validateCoverage(g.nodes.get(contract.identity)!, g).findings;
349
- },
350
- ],
351
- [
352
- 'IA-COMP-COVERAGE-KIND',
353
- () => {
354
- const g = rebuild(
355
- records.map((r) =>
356
- r.discriminator !== 'case'
357
- ? r
358
- : {
359
- ...r,
360
- sections: r.sections.map((s) =>
361
- s.name !== 'scenario'
362
- ? s
363
- : {
364
- ...s,
365
- fields: s.fields.map((f) =>
366
- 'key' in f && f.key === 'kind' ? { ...f, value: { kind: 'scalar', text: 'success' } } : f,
367
- ),
368
- },
369
- ),
370
- },
371
- ),
372
- );
373
- return validateCoverage(g.nodes.get(contract.identity)!, g).findings;
374
- },
375
- ],
376
- [
377
- 'IA-COMP-SELECTOR-INVALID',
378
- () => validateSelectors({ ...method, selectors: [[{ axis: 'phase', value: 'unknown' }]] }).findings,
379
- ],
380
- ['IA-COMP-CHECK-UNKNOWN', () => validateCheck({ ...check, sections: [] }).findings],
381
- [
382
- 'IA-COMP-CHECK-CONFLICT',
383
- () =>
384
- validateCheck({
385
- ...check,
386
- sections: check.sections.map((s) =>
387
- s.name !== 'check'
388
- ? s
389
- : {
390
- ...s,
391
- fields: [
392
- ...s.fields,
393
- { key: 'implementation', value: { kind: 'string', text: 'fixture-other-evaluator' }, span: s.span },
394
- ],
395
- },
396
- ),
397
- }).findings,
398
- ],
399
- ['IA-COMP-VARIANT-AMBIGUOUS', () => validateVariants(ambiguous).findings],
400
- [
401
- 'IA-COMP-ADOPTION-FAILED',
402
- () => {
403
- const evaluators: AdoptionEvaluators = new Map([
404
- [
405
- contract.identity,
406
- new Map(
407
- contract.requirements.map((r) => [
408
- r.id,
409
- () => ({ outcome: 'fail' as const, message: 'Fixture rejects the structural claim' }),
410
- ]),
411
- ),
412
- ],
413
- ]);
414
- return validateAdoption(graph, evaluators).flatMap((a) => a.findings);
415
- },
416
- ],
417
- ['IA-COMP-NOT-EVALUATED', () => validateParse(undefined).findings],
418
- [
419
- 'IA-COMP-FIXTURE-MISMATCH',
420
- () =>
421
- runLanguageFixture({
422
- path: 'fixture.ia',
423
- clause: 'parser',
424
- mode: 'fail',
425
- source: '#! ia 1.0\n',
426
- diagnostics: [],
427
- }).assessment.findings,
428
- ],
429
- ];
430
- return Object.freeze(
431
- examples.map(([code, run, label]): FixtureResult => {
432
- let observed: readonly Finding[];
433
- let unexpected = false;
434
- try {
435
- observed = run();
436
- } catch (error) {
437
- if (error instanceof GraphUsageError)
438
- observed = [{ code: error.code, path: '', line: 1, severity: 'error', message: error.message }];
439
- else {
440
- unexpected = true;
441
- observed = [
442
- {
443
- code: 'IA-COMP-FIXTURE-MISMATCH',
444
- path: '',
445
- line: 1,
446
- severity: 'error',
447
- message: `Boundary fixture threw: ${error instanceof Error ? error.message : String(error)}`,
448
- },
449
- ];
450
- }
451
- }
452
- const findings: Finding[] =
453
- !unexpected && observed.some((d) => d.code === code)
454
- ? []
455
- : [
456
- {
457
- code: 'IA-COMP-FIXTURE-MISMATCH',
458
- path: '',
459
- line: 1,
460
- severity: 'error',
461
- message: `${code} boundary fixture produced ${observed.map((d) => `${d.code}: ${d.message}`).join(', ')}`,
462
- },
463
- ];
464
- return Object.freeze({
465
- assessment: assess('COMP-FIXTURES', `boundary/${code}${label === undefined ? '' : `/${label}`}`, findings),
466
- observedCodes: Object.freeze([...new Set(observed.map((d) => d.code))].sort()),
467
- });
468
- }),
469
- );
470
- }
1
+ /** Moved to compiled package code (C31); this path re-exports it for the repository tool and its tests. */
2
+ export { runRefusalFixtures } from '../src/conformance/refusals.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inventarch/compliance",
3
- "version": "3.0.0",
3
+ "version": "3.1.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -96,8 +96,8 @@
96
96
  "LANGUAGE.md"
97
97
  ],
98
98
  "dependencies": {
99
- "@inventarch/language": "3.0.0",
100
- "@inventarch/graph": "3.0.0"
99
+ "@inventarch/language": "3.1.1",
100
+ "@inventarch/graph": "3.1.1"
101
101
  },
102
102
  "devDependencies": {
103
103
  "@types/node": "^22.19.0",