@altopelago/aeos-core 0.9.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 (82) hide show
  1. package/README.md +143 -0
  2. package/dist/bin/aeos-validator.d.ts +16 -0
  3. package/dist/bin/aeos-validator.d.ts.map +1 -0
  4. package/dist/bin/aeos-validator.js +77 -0
  5. package/dist/bin/aeos-validator.js.map +1 -0
  6. package/dist/diag/codes.d.ts +55 -0
  7. package/dist/diag/codes.d.ts.map +1 -0
  8. package/dist/diag/codes.js +69 -0
  9. package/dist/diag/codes.js.map +1 -0
  10. package/dist/diag/emit.d.ts +34 -0
  11. package/dist/diag/emit.d.ts.map +1 -0
  12. package/dist/diag/emit.js +45 -0
  13. package/dist/diag/emit.js.map +1 -0
  14. package/dist/diag/index.d.ts +6 -0
  15. package/dist/diag/index.d.ts.map +1 -0
  16. package/dist/diag/index.js +6 -0
  17. package/dist/diag/index.js.map +1 -0
  18. package/dist/index.d.ts +31 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +31 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/rules/index.d.ts +10 -0
  23. package/dist/rules/index.d.ts.map +1 -0
  24. package/dist/rules/index.js +10 -0
  25. package/dist/rules/index.js.map +1 -0
  26. package/dist/rules/numericForm.d.ts +29 -0
  27. package/dist/rules/numericForm.d.ts.map +1 -0
  28. package/dist/rules/numericForm.js +74 -0
  29. package/dist/rules/numericForm.js.map +1 -0
  30. package/dist/rules/presence.d.ts +20 -0
  31. package/dist/rules/presence.d.ts.map +1 -0
  32. package/dist/rules/presence.js +29 -0
  33. package/dist/rules/presence.js.map +1 -0
  34. package/dist/rules/referenceForm.d.ts +17 -0
  35. package/dist/rules/referenceForm.d.ts.map +1 -0
  36. package/dist/rules/referenceForm.js +78 -0
  37. package/dist/rules/referenceForm.js.map +1 -0
  38. package/dist/rules/schemaIndex.d.ts +34 -0
  39. package/dist/rules/schemaIndex.d.ts.map +1 -0
  40. package/dist/rules/schemaIndex.js +167 -0
  41. package/dist/rules/schemaIndex.js.map +1 -0
  42. package/dist/rules/stringForm.d.ts +48 -0
  43. package/dist/rules/stringForm.d.ts.map +1 -0
  44. package/dist/rules/stringForm.js +96 -0
  45. package/dist/rules/stringForm.js.map +1 -0
  46. package/dist/rules/typeCheck.d.ts +29 -0
  47. package/dist/rules/typeCheck.d.ts.map +1 -0
  48. package/dist/rules/typeCheck.js +99 -0
  49. package/dist/rules/typeCheck.js.map +1 -0
  50. package/dist/types/aes.d.ts +14 -0
  51. package/dist/types/aes.d.ts.map +1 -0
  52. package/dist/types/aes.js +8 -0
  53. package/dist/types/aes.js.map +1 -0
  54. package/dist/types/envelope.d.ts +47 -0
  55. package/dist/types/envelope.d.ts.map +1 -0
  56. package/dist/types/envelope.js +29 -0
  57. package/dist/types/envelope.js.map +1 -0
  58. package/dist/types/index.d.ts +10 -0
  59. package/dist/types/index.d.ts.map +1 -0
  60. package/dist/types/index.js +10 -0
  61. package/dist/types/index.js.map +1 -0
  62. package/dist/types/schema.d.ts +81 -0
  63. package/dist/types/schema.d.ts.map +1 -0
  64. package/dist/types/schema.js +41 -0
  65. package/dist/types/schema.js.map +1 -0
  66. package/dist/types/spans.d.ts +28 -0
  67. package/dist/types/spans.d.ts.map +1 -0
  68. package/dist/types/spans.js +16 -0
  69. package/dist/types/spans.js.map +1 -0
  70. package/dist/util/digits.d.ts +34 -0
  71. package/dist/util/digits.d.ts.map +1 -0
  72. package/dist/util/digits.js +66 -0
  73. package/dist/util/digits.js.map +1 -0
  74. package/dist/util/index.d.ts +5 -0
  75. package/dist/util/index.d.ts.map +1 -0
  76. package/dist/util/index.js +5 -0
  77. package/dist/util/index.js.map +1 -0
  78. package/dist/validate.d.ts +46 -0
  79. package/dist/validate.d.ts.map +1 -0
  80. package/dist/validate.js +633 -0
  81. package/dist/validate.js.map +1 -0
  82. package/package.json +33 -0
package/README.md ADDED
@@ -0,0 +1,143 @@
1
+ # @altopelago/aeos-core
2
+
3
+ **AEOS™** (Another Easy Object Schema) — validates Assignment Event Streams (AES) against AEOS schemas.
4
+
5
+ Implementation docs:
6
+
7
+ - [`docs/implementations/typescript/api/aeos.md`](../../../../docs/implementations/typescript/api/aeos.md)
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pnpm add @altopelago/aeos-core
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```ts
18
+ import { validate } from '@altopelago/aeos-core';
19
+ import { compile } from '@altopelago/aeon-core';
20
+
21
+ const compiled = compile('port = 8080');
22
+ if (compiled.errors.length > 0) throw new Error('compile failed');
23
+
24
+ const schema = {
25
+ rules: [
26
+ { path: '$.port', constraints: { type: 'IntegerLiteral' } }
27
+ ]
28
+ };
29
+
30
+ const result = validate(compiled.events, schema);
31
+
32
+ if (result.ok) {
33
+ console.log('Valid!');
34
+ } else {
35
+ console.log('Errors:', result.errors);
36
+ }
37
+ ```
38
+
39
+ ## What AEOS Does
40
+
41
+ AEOS answers: "Is this AES structurally and representationally valid?"
42
+
43
+ AEOS does not:
44
+
45
+ - coerce values
46
+ - resolve references
47
+ - compare numeric magnitudes unless the rule explicitly requires it
48
+ - inject defaults
49
+ - reinterpret Core-owned reference-legality failures as schema errors
50
+
51
+ ## Common Patterns
52
+
53
+ ### Compile first, then validate
54
+
55
+ AEOS consumes AES, not raw AEON source text.
56
+ The usual pipeline is:
57
+
58
+ 1. `compile(input)` with `@altopelago/aeon-core`
59
+ 2. `validate(events, schema)` with `@altopelago/aeos-core`
60
+
61
+ ### Read the result envelope
62
+
63
+ `validate()` returns a result envelope with:
64
+
65
+ - `ok`
66
+ - `errors`
67
+ - `warnings`
68
+ - `guarantees`
69
+
70
+ ### Indexed child paths
71
+
72
+ AEOS validates AES paths, including synthetic indexed child events emitted by Core.
73
+
74
+ That means schemas can target list elements, tuple elements, and node children directly:
75
+
76
+ ```ts
77
+ const schema = {
78
+ rules: [
79
+ { path: '$.page', constraints: { type: 'NodeLiteral' } },
80
+ { path: '$.page[0]', constraints: { type: 'NumberLiteral' } },
81
+ ]
82
+ };
83
+ ```
84
+
85
+ For example, this AEON source:
86
+
87
+ ```aeon
88
+ page:node = <page(:int32 = 3)>
89
+ ```
90
+
91
+ produces AES paths including `$.page` and `$.page[0]`.
92
+
93
+ ### Attribute-aware constraints
94
+
95
+ AEOS now validates attribute payload contents through:
96
+
97
+ - `constraints.attributes`
98
+ - `closed_attributes`
99
+
100
+ This applies to ordinary binding attributes and anonymous child attributes on
101
+ indexed AES events.
102
+
103
+ Example:
104
+
105
+ ```ts
106
+ const schema = {
107
+ rules: [
108
+ {
109
+ path: '$.values[0]',
110
+ constraints: {
111
+ type: 'NumberLiteral',
112
+ attributes: {
113
+ unit: {
114
+ required: true,
115
+ type: 'StringLiteral',
116
+ datatype: 'string',
117
+ },
118
+ },
119
+ closed_attributes: true,
120
+ },
121
+ },
122
+ ],
123
+ };
124
+ ```
125
+
126
+ Attribute entries continue to travel in AES metadata, but AEOS now exposes a
127
+ first-class schema surface for validating them.
128
+
129
+ ## API
130
+
131
+ ### `validate(aes, schema, options?)`
132
+
133
+ Validates an AES against an AEOS schema.
134
+
135
+ **Returns:** `ResultEnvelope`
136
+ ```ts
137
+ {
138
+ ok: boolean;
139
+ errors: Diag[];
140
+ warnings: Diag[];
141
+ guarantees: Record<string, string[]>;
142
+ }
143
+ ```
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @altopelago/aeos-core - CTS Validator Adapter
4
+ *
5
+ * CTS-compatible CLI entry point for the AEOS validator.
6
+ *
7
+ * Protocol (CLI Protocol v1):
8
+ * - Invoked as: aeos-validator --cts-validate
9
+ * - Reads JSON from stdin: { aes, schema, options }
10
+ * - Writes JSON to stdout: ResultEnvelope
11
+ * - Logs may go to stderr
12
+ *
13
+ * This adapter is READ-ONLY and does not alter validator behavior.
14
+ */
15
+ export {};
16
+ //# sourceMappingURL=aeos-validator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aeos-validator.d.ts","sourceRoot":"","sources":["../../src/bin/aeos-validator.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;GAYG"}
@@ -0,0 +1,77 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * @altopelago/aeos-core - CTS Validator Adapter
4
+ *
5
+ * CTS-compatible CLI entry point for the AEOS validator.
6
+ *
7
+ * Protocol (CLI Protocol v1):
8
+ * - Invoked as: aeos-validator --cts-validate
9
+ * - Reads JSON from stdin: { aes, schema, options }
10
+ * - Writes JSON to stdout: ResultEnvelope
11
+ * - Logs may go to stderr
12
+ *
13
+ * This adapter is READ-ONLY and does not alter validator behavior.
14
+ */
15
+ import { validate } from '../index.js';
16
+ /**
17
+ * Read all stdin as a string
18
+ */
19
+ async function readStdin() {
20
+ const chunks = [];
21
+ for await (const chunk of process.stdin) {
22
+ chunks.push(new Uint8Array(chunk));
23
+ }
24
+ return Buffer.concat(chunks).toString('utf8');
25
+ }
26
+ /**
27
+ * Main CTS adapter entry point
28
+ */
29
+ async function main() {
30
+ const args = process.argv.slice(2);
31
+ // Check for --cts-validate flag
32
+ if (!args.includes('--cts-validate')) {
33
+ console.error('Usage: aeos-validator --cts-validate');
34
+ console.error('Reads JSON from stdin, writes ResultEnvelope to stdout.');
35
+ process.exit(1);
36
+ }
37
+ try {
38
+ // Read input from stdin
39
+ const input = await readStdin();
40
+ if (!input.trim()) {
41
+ console.error('Error: Empty input');
42
+ process.exit(1);
43
+ }
44
+ // Parse input
45
+ let parsed;
46
+ try {
47
+ parsed = JSON.parse(input);
48
+ }
49
+ catch {
50
+ console.error('Error: Invalid JSON input');
51
+ process.exit(1);
52
+ }
53
+ // Validate required fields
54
+ if (!parsed.aes || !Array.isArray(parsed.aes)) {
55
+ console.error('Error: Missing or invalid "aes" field');
56
+ process.exit(1);
57
+ }
58
+ if (!parsed.schema || typeof parsed.schema !== 'object') {
59
+ console.error('Error: Missing or invalid "schema" field');
60
+ process.exit(1);
61
+ }
62
+ // Run validation (read-only, does not mutate inputs)
63
+ const result = validate(parsed.aes, parsed.schema, parsed.options ?? {});
64
+ // Output result envelope to stdout
65
+ // MUST NOT include 'aes' in output (enforced by validate())
66
+ console.log(JSON.stringify(result));
67
+ }
68
+ catch (err) {
69
+ console.error('Error:', err instanceof Error ? err.message : String(err));
70
+ process.exit(1);
71
+ }
72
+ }
73
+ main().catch((err) => {
74
+ console.error('Fatal error:', err);
75
+ process.exit(1);
76
+ });
77
+ //# sourceMappingURL=aeos-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"aeos-validator.js","sourceRoot":"","sources":["../../src/bin/aeos-validator.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @altopelago/aeos-core - Diagnostics: Error Codes
3
+ *
4
+ * Centralized error code registry.
5
+ *
6
+ * Standard codes are lowercase with underscores.
7
+ * Vendor-prefixed codes use format: vendor:code (e.g., mycompany:custom_check)
8
+ */
9
+ /**
10
+ * Standard AEOS v1 error codes
11
+ */
12
+ export declare const ErrorCodes: {
13
+ readonly DUPLICATE_BINDING: "duplicate_binding";
14
+ readonly INVALID_FORWARD_REFERENCE: "invalid_forward_reference";
15
+ readonly MISSING_REFERENCE_TARGET: "missing_reference_target";
16
+ readonly RULE_MISSING_PATH: "rule_missing_path";
17
+ readonly DUPLICATE_RULE_PATH: "duplicate_rule_path";
18
+ readonly UNKNOWN_CONSTRAINT_KEY: "unknown_constraint_key";
19
+ readonly INVALID_REFERENCE_CONSTRAINT: "invalid_reference_constraint";
20
+ readonly MISSING_REQUIRED_FIELD: "missing_required_field";
21
+ readonly UNEXPECTED_BINDING: "unexpected_binding";
22
+ readonly UNEXPECTED_ATTRIBUTE_ENTRY: "unexpected_attribute_entry";
23
+ readonly TYPE_MISMATCH: "type_mismatch";
24
+ readonly REFERENCE_REQUIRED: "reference_required";
25
+ readonly REFERENCE_FORBIDDEN: "reference_forbidden";
26
+ readonly REFERENCE_KIND_MISMATCH: "reference_kind_mismatch";
27
+ readonly REFERENCE_TARGET_MISMATCH: "reference_target_mismatch";
28
+ readonly WRONG_CONTAINER_KIND: "WRONG_CONTAINER_KIND";
29
+ readonly TUPLE_ARITY_MISMATCH: "TUPLE_ARITY_MISMATCH";
30
+ readonly TUPLE_ELEMENT_TYPE_MISMATCH: "TUPLE_ELEMENT_TYPE_MISMATCH";
31
+ readonly VERSION_GATE_MISSING: "version_gate_missing";
32
+ readonly INVALID_INDEX_FORMAT: "invalid_index_format";
33
+ readonly NUMERIC_FORM_VIOLATION: "numeric_form_violation";
34
+ readonly STRING_LENGTH_VIOLATION: "string_length_violation";
35
+ readonly PATTERN_MISMATCH: "pattern_mismatch";
36
+ readonly DATATYPE_ALLOWLIST_REJECT: "datatype_allowlist_reject";
37
+ readonly TRAILING_SEPARATOR_DELIMITER: "trailing_separator_delimiter";
38
+ readonly CONSTRAINT_INAPPLICABLE: "constraint_inapplicable";
39
+ };
40
+ /**
41
+ * Error code type
42
+ */
43
+ export type ErrorCode = typeof ErrorCodes[keyof typeof ErrorCodes];
44
+ /**
45
+ * Check if a code is a vendor-prefixed code
46
+ */
47
+ export declare function isVendorCode(code: string): boolean;
48
+ /**
49
+ * Parse a vendor code into namespace and code
50
+ */
51
+ export declare function parseVendorCode(code: string): {
52
+ namespace: string;
53
+ code: string;
54
+ } | null;
55
+ //# sourceMappingURL=codes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/diag/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8Cb,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,OAAO,UAAU,CAAC,MAAM,OAAO,UAAU,CAAC,CAAC;AAEnE;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASxF"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @altopelago/aeos-core - Diagnostics: Error Codes
3
+ *
4
+ * Centralized error code registry.
5
+ *
6
+ * Standard codes are lowercase with underscores.
7
+ * Vendor-prefixed codes use format: vendor:code (e.g., mycompany:custom_check)
8
+ */
9
+ /**
10
+ * Standard AEOS v1 error codes
11
+ */
12
+ export const ErrorCodes = {
13
+ // Baseline invariants (Phase 2)
14
+ DUPLICATE_BINDING: 'duplicate_binding',
15
+ INVALID_FORWARD_REFERENCE: 'invalid_forward_reference',
16
+ // Reference errors (Phase 2)
17
+ MISSING_REFERENCE_TARGET: 'missing_reference_target',
18
+ // Schema errors (Phase 3)
19
+ RULE_MISSING_PATH: 'rule_missing_path',
20
+ DUPLICATE_RULE_PATH: 'duplicate_rule_path',
21
+ UNKNOWN_CONSTRAINT_KEY: 'unknown_constraint_key',
22
+ INVALID_REFERENCE_CONSTRAINT: 'invalid_reference_constraint',
23
+ // Presence checks (Phase 4)
24
+ MISSING_REQUIRED_FIELD: 'missing_required_field',
25
+ UNEXPECTED_BINDING: 'unexpected_binding',
26
+ UNEXPECTED_ATTRIBUTE_ENTRY: 'unexpected_attribute_entry',
27
+ // Type checks (Phase 5)
28
+ TYPE_MISMATCH: 'type_mismatch',
29
+ REFERENCE_REQUIRED: 'reference_required',
30
+ REFERENCE_FORBIDDEN: 'reference_forbidden',
31
+ REFERENCE_KIND_MISMATCH: 'reference_kind_mismatch',
32
+ REFERENCE_TARGET_MISMATCH: 'reference_target_mismatch',
33
+ WRONG_CONTAINER_KIND: 'WRONG_CONTAINER_KIND',
34
+ TUPLE_ARITY_MISMATCH: 'TUPLE_ARITY_MISMATCH',
35
+ TUPLE_ELEMENT_TYPE_MISMATCH: 'TUPLE_ELEMENT_TYPE_MISMATCH',
36
+ // Core v1 indexed addressing checks
37
+ VERSION_GATE_MISSING: 'version_gate_missing',
38
+ INVALID_INDEX_FORMAT: 'invalid_index_format',
39
+ // Numeric form (Phase 6)
40
+ NUMERIC_FORM_VIOLATION: 'numeric_form_violation',
41
+ // String form (Phase 7)
42
+ STRING_LENGTH_VIOLATION: 'string_length_violation',
43
+ PATTERN_MISMATCH: 'pattern_mismatch',
44
+ // Datatype allow-list enforcement (Phase 8)
45
+ DATATYPE_ALLOWLIST_REJECT: 'datatype_allowlist_reject',
46
+ TRAILING_SEPARATOR_DELIMITER: 'trailing_separator_delimiter',
47
+ // General
48
+ CONSTRAINT_INAPPLICABLE: 'constraint_inapplicable',
49
+ };
50
+ /**
51
+ * Check if a code is a vendor-prefixed code
52
+ */
53
+ export function isVendorCode(code) {
54
+ return code.includes(':');
55
+ }
56
+ /**
57
+ * Parse a vendor code into namespace and code
58
+ */
59
+ export function parseVendorCode(code) {
60
+ const colonIndex = code.indexOf(':');
61
+ if (colonIndex === -1) {
62
+ return null;
63
+ }
64
+ return {
65
+ namespace: code.slice(0, colonIndex),
66
+ code: code.slice(colonIndex + 1),
67
+ };
68
+ }
69
+ //# sourceMappingURL=codes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codes.js","sourceRoot":"","sources":["../../src/diag/codes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,gCAAgC;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,yBAAyB,EAAE,2BAA2B;IAEtD,6BAA6B;IAC7B,wBAAwB,EAAE,0BAA0B;IAEpD,0BAA0B;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,mBAAmB,EAAE,qBAAqB;IAC1C,sBAAsB,EAAE,wBAAwB;IAChD,4BAA4B,EAAE,8BAA8B;IAE5D,4BAA4B;IAC5B,sBAAsB,EAAE,wBAAwB;IAChD,kBAAkB,EAAE,oBAAoB;IACxC,0BAA0B,EAAE,4BAA4B;IAExD,wBAAwB;IACxB,aAAa,EAAE,eAAe;IAC9B,kBAAkB,EAAE,oBAAoB;IACxC,mBAAmB,EAAE,qBAAqB;IAC1C,uBAAuB,EAAE,yBAAyB;IAClD,yBAAyB,EAAE,2BAA2B;IACtD,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAC5C,2BAA2B,EAAE,6BAA6B;IAE1D,oCAAoC;IACpC,oBAAoB,EAAE,sBAAsB;IAC5C,oBAAoB,EAAE,sBAAsB;IAE5C,yBAAyB;IACzB,sBAAsB,EAAE,wBAAwB;IAEhD,wBAAwB;IACxB,uBAAuB,EAAE,yBAAyB;IAClD,gBAAgB,EAAE,kBAAkB;IAEpC,4CAA4C;IAC5C,yBAAyB,EAAE,2BAA2B;IACtD,4BAA4B,EAAE,8BAA8B;IAE5D,UAAU;IACV,uBAAuB,EAAE,yBAAyB;CAC5C,CAAC;AAOX;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACrC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IACxC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACrC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO;QACH,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC;QACpC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;KACnC,CAAC;AACN,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * @altopelago/aeos-core - Diagnostics: Emit
3
+ *
4
+ * Helper functions for creating diagnostic entries.
5
+ */
6
+ import type { Diag, Span } from '../types/index.js';
7
+ /**
8
+ * Create a diagnostic entry
9
+ */
10
+ export declare function createDiag(path: string, span: Span, message: string, code: string): Diag;
11
+ /**
12
+ * Diagnostic collector context
13
+ */
14
+ export interface DiagContext {
15
+ readonly errors: Diag[];
16
+ readonly warnings: Diag[];
17
+ }
18
+ /**
19
+ * Create a new diagnostic context
20
+ */
21
+ export declare function createDiagContext(): DiagContext;
22
+ /**
23
+ * Emit an error to the context
24
+ */
25
+ export declare function emitError(ctx: DiagContext, diag: Diag): void;
26
+ /**
27
+ * Emit a warning to the context
28
+ */
29
+ export declare function emitWarning(ctx: DiagContext, diag: Diag): void;
30
+ /**
31
+ * Check if context has any errors for a specific path
32
+ */
33
+ export declare function hasErrorForPath(errors: readonly Diag[], path: string): boolean;
34
+ //# sourceMappingURL=emit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/diag/emit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEpD;;GAEG;AACH,wBAAgB,UAAU,CACtB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GACb,IAAI,CAQN;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAK/C;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAE5D;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAE9D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAE9E"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @altopelago/aeos-core - Diagnostics: Emit
3
+ *
4
+ * Helper functions for creating diagnostic entries.
5
+ */
6
+ /**
7
+ * Create a diagnostic entry
8
+ */
9
+ export function createDiag(path, span, message, code) {
10
+ return {
11
+ path,
12
+ span,
13
+ message,
14
+ phase: 'schema_validation',
15
+ code,
16
+ };
17
+ }
18
+ /**
19
+ * Create a new diagnostic context
20
+ */
21
+ export function createDiagContext() {
22
+ return {
23
+ errors: [],
24
+ warnings: [],
25
+ };
26
+ }
27
+ /**
28
+ * Emit an error to the context
29
+ */
30
+ export function emitError(ctx, diag) {
31
+ ctx.errors.push(diag);
32
+ }
33
+ /**
34
+ * Emit a warning to the context
35
+ */
36
+ export function emitWarning(ctx, diag) {
37
+ ctx.warnings.push(diag);
38
+ }
39
+ /**
40
+ * Check if context has any errors for a specific path
41
+ */
42
+ export function hasErrorForPath(errors, path) {
43
+ return errors.some(e => e.path === path);
44
+ }
45
+ //# sourceMappingURL=emit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emit.js","sourceRoot":"","sources":["../../src/diag/emit.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,UAAU,UAAU,CACtB,IAAY,EACZ,IAAU,EACV,OAAe,EACf,IAAY;IAEZ,OAAO;QACH,IAAI;QACJ,IAAI;QACJ,OAAO;QACP,KAAK,EAAE,mBAAmB;QAC1B,IAAI;KACP,CAAC;AACN,CAAC;AAUD;;GAEG;AACH,MAAM,UAAU,iBAAiB;IAC7B,OAAO;QACH,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;KACf,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,GAAgB,EAAE,IAAU;IAClD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,GAAgB,EAAE,IAAU;IACpD,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB,EAAE,IAAY;IACjE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @altopelago/aeos-core - Diagnostics Index
3
+ */
4
+ export * from './codes.js';
5
+ export * from './emit.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/diag/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @altopelago/aeos-core - Diagnostics Index
3
+ */
4
+ export * from './codes.js';
5
+ export * from './emit.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/diag/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @altopelago/aeos-core - AEOS™ Schema Validation Engine
3
+ *
4
+ * AEOS™ (Another Easy Object Schema) — the canonical entry point for validation.
5
+ *
6
+ * Usage:
7
+ * ```ts
8
+ * import { validate } from '@altopelago/aeos-core';
9
+ *
10
+ * const result = validate(aes, schema);
11
+ * if (result.ok) {
12
+ * console.log('Validation passed');
13
+ * } else {
14
+ * console.log('Errors:', result.errors);
15
+ * }
16
+ * ```
17
+ *
18
+ * AEOS answers: "Is this AES structurally and representationally valid?"
19
+ * It does NOT answer: "What does this mean?"
20
+ */
21
+ export { validate } from './validate.js';
22
+ export type { ValidateOptions } from './validate.js';
23
+ export type { ResultEnvelope, Diag } from './types/envelope.js';
24
+ export type { Span } from './types/spans.js';
25
+ export { createPassingEnvelope, createFailingEnvelope } from './types/envelope.js';
26
+ export { spanToTuple } from './types/spans.js';
27
+ export type { SchemaV1, SchemaRule, ConstraintsV1 } from './types/schema.js';
28
+ export type { AES, AssignmentEvent } from './types/aes.js';
29
+ export { ErrorCodes } from './diag/codes.js';
30
+ export type { ErrorCode } from './diag/codes.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAMH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAOrD,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAChE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAG7E,YAAY,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @altopelago/aeos-core - AEOS™ Schema Validation Engine
3
+ *
4
+ * AEOS™ (Another Easy Object Schema) — the canonical entry point for validation.
5
+ *
6
+ * Usage:
7
+ * ```ts
8
+ * import { validate } from '@altopelago/aeos-core';
9
+ *
10
+ * const result = validate(aes, schema);
11
+ * if (result.ok) {
12
+ * console.log('Validation passed');
13
+ * } else {
14
+ * console.log('Errors:', result.errors);
15
+ * }
16
+ * ```
17
+ *
18
+ * AEOS answers: "Is this AES structurally and representationally valid?"
19
+ * It does NOT answer: "What does this mean?"
20
+ */
21
+ // =============================================================================
22
+ // PUBLIC API
23
+ // =============================================================================
24
+ export { validate } from './validate.js';
25
+ export { createPassingEnvelope, createFailingEnvelope } from './types/envelope.js';
26
+ export { spanToTuple } from './types/spans.js';
27
+ // =============================================================================
28
+ // DIAGNOSTICS
29
+ // =============================================================================
30
+ export { ErrorCodes } from './diag/codes.js';
31
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,gFAAgF;AAChF,aAAa;AACb,gFAAgF;AAEhF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAUzC,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AACnF,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @altopelago/aeos-core - Rules Index
3
+ */
4
+ export * from './schemaIndex.js';
5
+ export * from './presence.js';
6
+ export * from './typeCheck.js';
7
+ export * from './referenceForm.js';
8
+ export * from './numericForm.js';
9
+ export * from './stringForm.js';
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @altopelago/aeos-core - Rules Index
3
+ */
4
+ export * from './schemaIndex.js';
5
+ export * from './presence.js';
6
+ export * from './typeCheck.js';
7
+ export * from './referenceForm.js';
8
+ export * from './numericForm.js';
9
+ export * from './stringForm.js';
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rules/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * @altopelago/aeos-core - Rules: Numeric Form
3
+ *
4
+ * Phase 6: Numeric form constraints (sign, digit count).
5
+ */
6
+ import type { DiagContext } from '../diag/emit.js';
7
+ import type { Span } from '../types/spans.js';
8
+ import type { RuleIndex } from './schemaIndex.js';
9
+ /**
10
+ * Event value with type, raw representation, and span
11
+ */
12
+ interface NumericValue {
13
+ type: string;
14
+ raw: string;
15
+ span: Span;
16
+ }
17
+ /**
18
+ * Check numeric form constraints for events matching schema rules.
19
+ *
20
+ * For each event with numeric form constraints (sign, min_digits, max_digits),
21
+ * verify the literal's lexical representation satisfies the constraints.
22
+ *
23
+ * @param ruleIndex - Schema rule index (path → rule)
24
+ * @param events - Map of path → numeric value info
25
+ * @param ctx - Diagnostic context
26
+ */
27
+ export declare function checkNumericForm(ruleIndex: RuleIndex, events: ReadonlyMap<string, NumericValue>, ctx: DiagContext): void;
28
+ export {};
29
+ //# sourceMappingURL=numericForm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numericForm.d.ts","sourceRoot":"","sources":["../../src/rules/numericForm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD;;GAEG;AACH,UAAU,YAAY;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,IAAI,CAAC;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC5B,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,YAAY,CAAC,EACzC,GAAG,EAAE,WAAW,GACjB,IAAI,CA0FN"}