@fraczak/k 6.10.5 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/CLAUDE.md +1 -1
- package/DOCS/BIG_PICTURE.md +156 -172
- package/DOCS/BINARY_CODEC_STATUS_AND_TODO.md +3 -3
- package/DOCS/CODEC_ARCHITECTURE.md +2 -2
- package/DOCS/DICTIONARY.md +243 -250
- package/DOCS/DIVERGENCE_DETECTION.md +0 -1
- package/DOCS/FILE_FORMATS.md +5 -5
- package/DOCS/KIR_SPECIALIZATION_DESIGN.md +1 -1
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +12 -12
- package/DOCS/PATTERNS.md +17 -17
- package/DOCS/PATTERNS_AND_TYPED_VALUES.md +1 -1
- package/DOCS/REPL.md +9 -19
- package/DOCS/TYPE_DERIVATION.md +2 -8
- package/DOCS/WEB_REPL_REQUIREMENTS.md +8 -8
- package/DOCS/book/01-introduction.md +8 -11
- package/DOCS/book/02-syntax-and-values.md +19 -20
- package/DOCS/book/03-types-as-finite-automata.md +42 -43
- package/DOCS/book/04-partial-functions-and-composition.md +2 -3
- package/DOCS/book/05-typing-filters-and-normalization.md +44 -46
- package/DOCS/book/06-values-in-memory.md +10 -10
- package/DOCS/book/08-operational-semantics-and-execution.md +21 -26
- package/DOCS/book/09-compiler-architecture.md +11 -11
- package/DOCS/book/10-from-ast-to-intermediate-representation.md +6 -7
- package/DOCS/book/14-canonical-serialization.md +2 -2
- package/DOCS/book/appendix-b-incorporating-external-predefined-types-and-functions.md +17 -17
- package/DOCS/book.md +5 -5
- package/Examples/arithmetics.k +49 -153
- package/Examples/bnat.k +13 -13
- package/Examples/byte.k +2 -50
- package/Examples/ieee.k +408 -423
- package/Examples/karatsuba-mult.k +30 -34
- package/Examples/nat.k +5 -6
- package/README.md +54 -49
- package/TODO.md +13 -18
- package/browser/repl-browser.mjs +40 -22
- package/browser/shims/fs.mjs +7 -10
- package/browser/vfs-data.mjs +12 -12
- package/codecs/BINARY_FORMAT.md +4 -4
- package/codecs/POLYMORPHIC_BINARY_FORMAT.md +4 -4
- package/codecs/README.md +6 -6
- package/codecs/ieee.mjs +15 -11
- package/codecs/int.mjs +9 -5
- package/codecs/string-codec.mjs +46 -47
- package/core.k +124 -175
- package/object.mjs +0 -7
- package/package.json +5 -2
- package/parser.jison +2 -41
- package/parser.mjs +55 -95
- package/pretty.mjs +11 -4
- package/repl.mjs +8 -63
- package/scripts/build-repl-html.mjs +18 -49
- package/tests/code-derivation/blowup.mjs +2 -4
- package/tests/code-derivation/bnat.mjs +2 -3
- package/tests/code-derivation/dot.mjs +5 -11
- package/tests/code-derivation/nat.mjs +2 -2
- package/tests/code-derivation/not-not.mjs +6 -6
- package/tests/code-derivation/pattern-envelope.mjs +4 -6
- package/tests/code-derivation/product.mjs +3 -6
- package/tests/code-derivation/rlz.mjs +4 -5
- package/tests/test-codecs.mjs +1 -1
- package/tests/test-fingerprint.mjs +36 -41
- package/tests/test-hash-normalization.mjs +4 -6
- package/tests/test-ieee-arithmetic.mjs +6 -7
- package/tests/test-k-object.mjs +11 -15
- package/tests/test-kir.mjs +0 -1
- package/tests/test-kvm-polymorphic.mjs +1 -2
- package/tests/test-kvm.mjs +8 -11
- package/tests/test-repl-html.mjs +86 -9
- package/tests/test-repl.mjs +38 -53
- package/tests/test.mjs +2 -3
package/DOCS/DICTIONARY.md
CHANGED
|
@@ -14,75 +14,79 @@ target execution.
|
|
|
14
14
|
- Use semantic names for all externally visible concepts.
|
|
15
15
|
- Distinguish a concept from its serialized representation.
|
|
16
16
|
- Distinguish source syntax from the semantic object represented by that syntax.
|
|
17
|
-
- Distinguish a mathematical
|
|
17
|
+
- Distinguish a mathematical relation from the compiler artifacts used to
|
|
18
18
|
compile or execute it.
|
|
19
|
-
-
|
|
20
|
-
|
|
19
|
+
- Use `schema` for data shapes (algebraic tree automata), `contract` for
|
|
20
|
+
relational signatures, `filter` for partial identity guards and inductive
|
|
21
|
+
witnesses, and `(schema, payload)` for framed runtime values.
|
|
21
22
|
|
|
22
23
|
## Source-Level Concepts
|
|
23
24
|
|
|
24
25
|
### k Source
|
|
25
26
|
|
|
26
|
-
`k source` is the textual language read by the parser. It
|
|
27
|
-
partial
|
|
27
|
+
`k source` is the textual language read by the parser. It defines relations
|
|
28
|
+
(including schemas defined as partial identities/filters) and an optional
|
|
29
|
+
entry expression.
|
|
28
30
|
|
|
29
31
|
Use this term for source text before compiler passes have resolved names,
|
|
30
|
-
canonicalized
|
|
32
|
+
canonicalized schemas, or derived relational contracts.
|
|
31
33
|
|
|
32
34
|
### Expression
|
|
33
35
|
|
|
34
36
|
An `expression` is a source-level program fragment that denotes a partial
|
|
35
|
-
|
|
37
|
+
relation over framed values.
|
|
36
38
|
|
|
37
39
|
Expressions include identity, composition, projection, variant introduction,
|
|
38
|
-
product construction, ordered union,
|
|
39
|
-
|
|
40
|
+
product construction, ordered union, filters, and references to named
|
|
41
|
+
relations or intrinsics.
|
|
40
42
|
|
|
41
|
-
### Partial
|
|
43
|
+
### Partial Relation
|
|
42
44
|
|
|
43
|
-
A partial
|
|
45
|
+
A `partial relation` maps an input framed payload to an output framed payload
|
|
44
46
|
when it is defined. If it is not defined for the input, execution fails normally.
|
|
45
47
|
This failure is part of the language semantics, not a system exception.
|
|
46
48
|
|
|
47
|
-
Mathematically, a k program denotes a deterministic partial
|
|
49
|
+
Mathematically, a k program denotes a deterministic partial relation
|
|
50
|
+
(partial function).
|
|
48
51
|
|
|
49
|
-
###
|
|
52
|
+
### Schema
|
|
50
53
|
|
|
51
|
-
A `
|
|
52
|
-
built from products and tagged unions.
|
|
54
|
+
A `schema` describes a set of labeled tree payloads accepted by a finite tree
|
|
55
|
+
automaton. Schemas are built from products and tagged unions. A schema can be
|
|
56
|
+
*closed* (all constructors determined) or *open* (containing schema parameters
|
|
57
|
+
$X, Y$).
|
|
53
58
|
|
|
54
|
-
Use "
|
|
55
|
-
when the meaning is
|
|
59
|
+
Use "schema" for the semantic concept. Avoid using "code" or "type pattern" by
|
|
60
|
+
itself in public docs when the meaning is a schema.
|
|
56
61
|
|
|
57
|
-
###
|
|
62
|
+
### Canonical Schema
|
|
58
63
|
|
|
59
|
-
A `
|
|
64
|
+
A `canonical schema` is the deterministic, hashable normal form of a schema
|
|
65
|
+
automaton. Its canonical textual syntax is its primary universal identity in the
|
|
66
|
+
schema registry; its `@hash` is a fixed-width indexing digest.
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
representation.
|
|
68
|
+
### Filter
|
|
63
69
|
|
|
64
|
-
|
|
70
|
+
A `filter` is an expression `?schema` that constrains the input payload to a
|
|
71
|
+
schema and otherwise behaves like identity.
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Source syntax may present this operation as a filter expression. The semantic
|
|
70
|
-
operation is a pattern guard.
|
|
73
|
+
In recursive relations, filters also serve as **inductive termination witnesses**,
|
|
74
|
+
ensuring contract derivation converges.
|
|
71
75
|
|
|
72
76
|
### Canonical Content-Addressed Hash (`@hash`)
|
|
73
77
|
|
|
74
78
|
A `canonical content-addressed hash` is the immutable, unique identifier
|
|
75
79
|
derived from the normalized AST of a relation or the minimal deterministic
|
|
76
|
-
tree automaton of a
|
|
80
|
+
tree automaton of a schema.
|
|
77
81
|
|
|
78
82
|
In `k`, there is no global symbol namespace. Every compiled relation and
|
|
79
|
-
|
|
83
|
+
schema is identified globally and uniquely by its `@hash`.
|
|
80
84
|
|
|
81
85
|
### Local Alias
|
|
82
86
|
|
|
83
87
|
A `local alias` is a human-readable identifier (such as `plus`, `int`,
|
|
84
88
|
or `5`) mapped to a canonical hash in object metadata (`relAlias`,
|
|
85
|
-
`
|
|
89
|
+
`schemaAliases`).
|
|
86
90
|
|
|
87
91
|
Aliases are local to their compilation scope. When loading libraries
|
|
88
92
|
with `--lib`, canonical definitions are available by their `@hash`, but
|
|
@@ -93,120 +97,109 @@ unless explicitly mapped with `--export`.
|
|
|
93
97
|
|
|
94
98
|
In `k`, there are no primitive numerical types or built-in integer
|
|
95
99
|
literals. Numerical identifiers such as `5` or `10` are nullary
|
|
96
|
-
relations (constants) mapping the unit
|
|
97
|
-
|
|
100
|
+
relations (constants) mapping the unit `{}` to bit trees of contract
|
|
101
|
+
`{} -> bits`. Operations on signed integers (`int`) require
|
|
98
102
|
converting bit trees via the `int` constructor (`5 int`).
|
|
99
103
|
|
|
100
|
-
## Values,
|
|
101
|
-
|
|
102
|
-
### Value Tree
|
|
104
|
+
## Values, Schemas, And Contracts
|
|
103
105
|
|
|
104
|
-
|
|
106
|
+
### Payload Tree (or Payload)
|
|
105
107
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
contexts.
|
|
108
|
+
A `payload tree` (or `payload`) is the product/variant tree part of a value during
|
|
109
|
+
execution.
|
|
109
110
|
|
|
110
|
-
|
|
111
|
+
By itself, a raw payload tree is not self-describing at a binary or polymorphic
|
|
112
|
+
boundary. The same tree is meaningful only when framed by a schema.
|
|
111
113
|
|
|
112
|
-
|
|
113
|
-
represented by source filter syntax and by the pattern graphs carried through
|
|
114
|
-
compilation and execution.
|
|
114
|
+
### Schema
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
A `schema` describes a set of possible payload trees accepted by an algebraic
|
|
117
|
+
automaton. It is the semantic object represented by source filter syntax and by the
|
|
118
|
+
schema graphs carried through compilation and execution.
|
|
119
119
|
|
|
120
|
-
Examples of
|
|
120
|
+
Examples of schema kinds include:
|
|
121
121
|
|
|
122
|
-
-
|
|
122
|
+
- unconstrained schema parameter (`X`, `?X`);
|
|
123
123
|
- open product;
|
|
124
124
|
- closed product;
|
|
125
125
|
- open union;
|
|
126
126
|
- closed union;
|
|
127
|
-
-
|
|
128
|
-
|
|
129
|
-
### Pattern Graph
|
|
130
|
-
|
|
131
|
-
A `pattern graph` is the graph representation of a type pattern. Nodes describe
|
|
132
|
-
pattern kind and openness. Edges describe required product fields or union tags.
|
|
133
|
-
|
|
134
|
-
Pattern graph node identity matters: if two positions point to the same pattern
|
|
135
|
-
node, they must share the same type context.
|
|
127
|
+
- closed schema derived from concrete definitions.
|
|
136
128
|
|
|
137
|
-
|
|
138
|
-
constraint it represents.
|
|
129
|
+
### Schema Graph
|
|
139
130
|
|
|
140
|
-
|
|
131
|
+
A `schema graph` is the graph representation of a schema. Nodes describe
|
|
132
|
+
schema kind and openness. Edges describe required product fields or union tags.
|
|
141
133
|
|
|
142
|
-
|
|
143
|
-
|
|
134
|
+
Schema graph node identity matters: if two positions point to the same schema
|
|
135
|
+
node, they share the exact same schema structure.
|
|
144
136
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
be `envelope`.
|
|
137
|
+
Use "schema graph" for the representation, and "schema" for the semantic
|
|
138
|
+
language it defines.
|
|
148
139
|
|
|
149
|
-
###
|
|
140
|
+
### Framed Value `(schema, payload)`
|
|
150
141
|
|
|
151
|
-
|
|
142
|
+
A `framed value` (formerly called an enveloped value) is a pair:
|
|
152
143
|
|
|
153
144
|
```text
|
|
154
|
-
(
|
|
145
|
+
(schema, payload)
|
|
155
146
|
```
|
|
156
147
|
|
|
157
|
-
Structural operations propagate or refine the
|
|
148
|
+
Structural operations propagate or refine the framing schema:
|
|
158
149
|
|
|
159
|
-
- projection selects a
|
|
160
|
-
- product construction builds a closed product
|
|
161
|
-
- variant introduction builds an open union
|
|
162
|
-
-
|
|
150
|
+
- projection selects a subschema;
|
|
151
|
+
- product construction builds a closed product schema from field schemas;
|
|
152
|
+
- variant introduction builds an open union schema for the introduced tag;
|
|
153
|
+
- filters intersect the active schema with a static schema constraint.
|
|
163
154
|
|
|
164
|
-
The
|
|
165
|
-
boundaries. A
|
|
155
|
+
The schema is part of the semantic value at compilation and execution
|
|
156
|
+
boundaries. A payload tree without a framing schema is incomplete at those boundaries.
|
|
166
157
|
|
|
167
|
-
###
|
|
158
|
+
### Contract
|
|
168
159
|
|
|
169
|
-
A `
|
|
170
|
-
expression or
|
|
160
|
+
A `contract` is the derived $(input, output)$ linked schema graph attached to an
|
|
161
|
+
expression or relation:
|
|
171
162
|
|
|
172
163
|
```text
|
|
173
|
-
input
|
|
164
|
+
input schema -> output schema
|
|
174
165
|
```
|
|
175
166
|
|
|
176
|
-
|
|
177
|
-
|
|
167
|
+
Contracts are compiler facts. Unlike independent types, a contract is a single
|
|
168
|
+
connected schema graph where shared vertices ($=X$) prove structure preservation:
|
|
169
|
+
input substructures flow through to the output without destruction or rebuilding.
|
|
170
|
+
Contracts guide diagnostics, REPL output, binary serialization, and optimizations.
|
|
178
171
|
|
|
179
172
|
### Domain
|
|
180
173
|
|
|
181
174
|
Use "domain" carefully.
|
|
182
175
|
|
|
183
|
-
The input
|
|
184
|
-
necessarily the exact mathematical domain of the
|
|
185
|
-
be undefined for some
|
|
176
|
+
The input schema of a relation is a static constraint, not
|
|
177
|
+
necessarily the exact mathematical domain of the relation. A relation may still
|
|
178
|
+
be undefined for some payload trees that fit its input schema.
|
|
186
179
|
|
|
187
180
|
Prefer:
|
|
188
181
|
|
|
189
|
-
- "input
|
|
190
|
-
- "accepted
|
|
182
|
+
- "input schema";
|
|
183
|
+
- "accepted schema";
|
|
191
184
|
- "static input constraint".
|
|
192
185
|
|
|
193
186
|
Use "domain" only when referring to the actual set of inputs for which the
|
|
194
|
-
partial
|
|
187
|
+
partial relation is defined.
|
|
195
188
|
|
|
196
189
|
## Serialization And Boundaries
|
|
197
190
|
|
|
198
191
|
### Wire Stream
|
|
199
192
|
|
|
200
|
-
A `wire stream` is the binary transport representation of
|
|
193
|
+
A `wire stream` is the binary transport representation of a framed value `(schema, payload)`.
|
|
201
194
|
|
|
202
195
|
The active format is:
|
|
203
196
|
|
|
204
197
|
```text
|
|
205
|
-
encoded
|
|
198
|
+
encoded schema, followed by payload bits encoded under that schema
|
|
206
199
|
```
|
|
207
200
|
|
|
208
|
-
Use "wire stream" or "
|
|
209
|
-
boundaries. Use "
|
|
201
|
+
Use "wire stream" or "schema+payload wire stream" for external transport
|
|
202
|
+
boundaries. Use "framed value" for the semantic object used during
|
|
210
203
|
execution.
|
|
211
204
|
|
|
212
205
|
### Codec
|
|
@@ -214,26 +207,26 @@ execution.
|
|
|
214
207
|
A `codec` converts between an external representation and a k wire stream.
|
|
215
208
|
|
|
216
209
|
Examples include the unit, JSON, integer, IEEE, UTF-8, and UTF-16 codecs. A
|
|
217
|
-
codec must preserve the
|
|
218
|
-
|
|
219
|
-
works with a universal representation that can infer a suitable
|
|
210
|
+
codec must preserve the schema/payload relationship: it either supplies a
|
|
211
|
+
schema for parsing, decodes the schema from the stream for printing, or
|
|
212
|
+
works with a universal representation that can infer a suitable schema.
|
|
220
213
|
|
|
221
|
-
### Input
|
|
214
|
+
### Input Schema
|
|
222
215
|
|
|
223
|
-
An `input
|
|
216
|
+
An `input schema` is the schema framing the input payload at a program or
|
|
224
217
|
execution boundary.
|
|
225
218
|
|
|
226
|
-
Execution targets use the input
|
|
227
|
-
The input
|
|
219
|
+
Execution targets use the input schema to specialize or validate execution.
|
|
220
|
+
The input schema can be provided explicitly, derived from a filter expression, or
|
|
228
221
|
decoded from a wire stream.
|
|
229
222
|
|
|
230
|
-
### Output
|
|
223
|
+
### Output Schema
|
|
231
224
|
|
|
232
|
-
An `output
|
|
225
|
+
An `output schema` is the schema attached to the output payload after execution.
|
|
233
226
|
|
|
234
|
-
A correct runner must emit both the output
|
|
235
|
-
Rendered values can hide
|
|
236
|
-
|
|
227
|
+
A correct runner must emit both the output schema and the output payload bits.
|
|
228
|
+
Rendered values can hide schema differences, so conformance checks must compare
|
|
229
|
+
schemas whenever schema identity matters.
|
|
237
230
|
|
|
238
231
|
## Compiler Stages
|
|
239
232
|
|
|
@@ -242,43 +235,43 @@ envelopes whenever envelope identity matters.
|
|
|
242
235
|
The `parsed AST` is the direct parser output. It keeps source-shaped expression
|
|
243
236
|
nodes, source names, source ranges, and filter syntax.
|
|
244
237
|
|
|
245
|
-
Use this term only for the representation before
|
|
246
|
-
|
|
238
|
+
Use this term only for the representation before schema registration,
|
|
239
|
+
relation canonicalization, and contract derivation.
|
|
247
240
|
|
|
248
|
-
###
|
|
241
|
+
### Contract-Annotated Core
|
|
249
242
|
|
|
250
|
-
`
|
|
243
|
+
`Contract-annotated core` is the first semantic compiler artifact after parsing.
|
|
251
244
|
|
|
252
245
|
It keeps the expression structure close to k source, but it has:
|
|
253
246
|
|
|
254
|
-
- registered canonical
|
|
255
|
-
- resolved
|
|
256
|
-
-
|
|
257
|
-
- canonical aliases for
|
|
258
|
-
- a
|
|
259
|
-
- a
|
|
260
|
-
-
|
|
247
|
+
- registered canonical schemas;
|
|
248
|
+
- resolved schema references to canonical schema names;
|
|
249
|
+
- relation dependency information;
|
|
250
|
+
- canonical aliases for relations;
|
|
251
|
+
- a schema graph for each relation;
|
|
252
|
+
- a contract on each expression;
|
|
253
|
+
- contract-derivation convergence status.
|
|
261
254
|
|
|
262
255
|
The key product is still a k-shaped core expression graph, now annotated by
|
|
263
|
-
|
|
256
|
+
schema contract facts. This stage is a semantic artifact; it does not imply a
|
|
264
257
|
particular serialized format.
|
|
265
258
|
|
|
266
|
-
### Ahead-Of-Time (AOT)
|
|
259
|
+
### Ahead-Of-Time (AOT) Contract Checking
|
|
267
260
|
|
|
268
|
-
`Ahead-of-time (AOT)
|
|
269
|
-
where parsing, relation expansion, structural
|
|
261
|
+
`Ahead-of-time (AOT) contract checking` refers to the compilation phase
|
|
262
|
+
where parsing, relation expansion, structural contract derivation, and
|
|
270
263
|
fixed-point constraint convergence are solved in advance.
|
|
271
264
|
|
|
272
265
|
The resulting compiled artifacts (`.ko`, `.klib`, `.kvm`) store fully
|
|
273
|
-
derived principal
|
|
274
|
-
execution or linking to skip cold-start
|
|
266
|
+
derived principal schema contracts and interned schemas, allowing downstream
|
|
267
|
+
execution or linking to skip cold-start derivation entirely.
|
|
275
268
|
|
|
276
269
|
### k Object
|
|
277
270
|
|
|
278
271
|
A `k object` is a compiled semantic object.
|
|
279
272
|
|
|
280
|
-
It stores canonical
|
|
281
|
-
|
|
273
|
+
It stores canonical schemas, relations, aliases, metadata,
|
|
274
|
+
schema graphs, and contract-derivation status.
|
|
282
275
|
|
|
283
276
|
An executable object (`.ko`) has an execution entrypoint (`main:
|
|
284
277
|
"__main__"`). A library object (`.klib`) contains reusable definitions
|
|
@@ -289,66 +282,66 @@ but no selected main relation (`main: null`).
|
|
|
289
282
|
The `k` toolchain defines four primary file formats (for comprehensive
|
|
290
283
|
details and workflows, see [`DOCS/FILE_FORMATS.md`](FILE_FORMATS.md)):
|
|
291
284
|
|
|
292
|
-
- **Source File (`.k`):** Plain UTF-8 source text defining algebraic
|
|
293
|
-
|
|
294
|
-
- **Executable Object (`.ko`):** AOT
|
|
295
|
-
with binary header `KOBJ\n` and JSON payload containing
|
|
285
|
+
- **Source File (`.k`):** Plain UTF-8 source text defining algebraic
|
|
286
|
+
schemas, relations, and expressions.
|
|
287
|
+
- **Executable Object (`.ko`):** AOT contract-checked executable artifact
|
|
288
|
+
with binary header `KOBJ\n` and JSON payload containing schemas, relations,
|
|
296
289
|
and entrypoint `main: "__main__"`. Executable directly via `k.mjs`,
|
|
297
290
|
WebAssembly, or LLVM.
|
|
298
|
-
- **Library Object (`.klib`):** AOT
|
|
291
|
+
- **Library Object (`.klib`):** AOT contract-checked library container stored
|
|
299
292
|
as plain UTF-8 JSON without an entrypoint (`main: null`). Provides
|
|
300
|
-
reusable pre-converged relations and
|
|
293
|
+
reusable pre-converged relations and schema graphs for downstream linking.
|
|
301
294
|
- **Polymorphic kVM Template (`.kvm`):** Register-IR bytecode template
|
|
302
|
-
(`format: "k-vm"`, `layer: "KVM-P"`) carrying principal
|
|
295
|
+
(`format: "k-vm"`, `layer: "KVM-P"`) carrying principal contracts.
|
|
303
296
|
Specialized on-the-fly at runtime (`specializeKVM`) against concrete
|
|
304
|
-
input
|
|
297
|
+
input schemas $(v, S_v)$ without re-running type inference.
|
|
305
298
|
|
|
306
299
|
### Stream Transformer vs. Closed Constant Relation
|
|
307
300
|
|
|
308
|
-
- A **stream transformer** is a relation with an open
|
|
301
|
+
- A **stream transformer** is a relation with an open input schema (e.g. `{() x,
|
|
309
302
|
5 int y} plus`) that consumes external data arriving from a binary
|
|
310
303
|
stream or standard input.
|
|
311
304
|
- A **closed constant relation** is a relation with no free inputs (such
|
|
312
|
-
as `{10 int x, 5 int y} plus`). Its
|
|
305
|
+
as `{10 int x, 5 int y} plus`). Its input schema is the unit `{}`,
|
|
313
306
|
requiring an empty unit `{}` when executed as a standalone script.
|
|
314
307
|
|
|
315
308
|
### KIR-P
|
|
316
309
|
|
|
317
310
|
`KIR-P` is the portable, polymorphic K Intermediate Representation.
|
|
318
311
|
|
|
319
|
-
It is a stable artifact contract over k objects. It preserves
|
|
320
|
-
semantics while normalizing names, expression opcodes, and
|
|
312
|
+
It is a stable artifact contract over k objects. It preserves schema-carrying
|
|
313
|
+
semantics while normalizing names, expression opcodes, and schema graph node IDs
|
|
321
314
|
so consumers do not depend on parser-shaped fields or object encoding details.
|
|
322
315
|
|
|
323
316
|
Use KIR-P as the shared semantic contract between k objects and lower-level
|
|
324
317
|
execution artifacts.
|
|
325
318
|
|
|
326
|
-
###
|
|
319
|
+
### Schema-Specialized KIR-P
|
|
327
320
|
|
|
328
|
-
`
|
|
321
|
+
`Schema-specialized KIR-P` is KIR-P rebuilt for a concrete input schema.
|
|
329
322
|
|
|
330
|
-
|
|
323
|
+
Schema-specialization:
|
|
331
324
|
|
|
332
325
|
- takes a KIR-P object or k object;
|
|
333
|
-
- takes an input
|
|
334
|
-
- re-runs
|
|
335
|
-
|
|
336
|
-
- derives the corresponding output
|
|
337
|
-
- emits ordinary KIR-P for the specialized entry
|
|
326
|
+
- takes an input schema;
|
|
327
|
+
- re-runs contract derivation as if the entry expression were filtered by that
|
|
328
|
+
schema;
|
|
329
|
+
- derives the corresponding output schema;
|
|
330
|
+
- emits ordinary KIR-P for the specialized entry relation.
|
|
338
331
|
|
|
339
332
|
### KIR-M
|
|
340
333
|
|
|
341
|
-
`KIR-M` is a materialized execution layer after
|
|
334
|
+
`KIR-M` is a materialized execution layer after schema-specialized KIR-P.
|
|
342
335
|
|
|
343
336
|
It should contain layout and ABI decisions such as field offsets, tag dispatch,
|
|
344
|
-
call-site specialization, and
|
|
337
|
+
call-site specialization, and schema-free execution assumptions.
|
|
345
338
|
|
|
346
339
|
### Lowered Execution Model
|
|
347
340
|
|
|
348
341
|
A `lowered execution model` is an executable middle layer.
|
|
349
342
|
|
|
350
|
-
It lowers KIR-P
|
|
351
|
-
explicit partial failure,
|
|
343
|
+
It lowers KIR-P relation bodies into a small instruction model with
|
|
344
|
+
explicit partial failure, filters, projections, construction, calls, and
|
|
352
345
|
returns.
|
|
353
346
|
It is an execution contract that a lower-level compiler or executor can
|
|
354
347
|
consume. It is not defined by a particular byte encoding.
|
|
@@ -357,69 +350,69 @@ consume. It is not defined by a particular byte encoding.
|
|
|
357
350
|
|
|
358
351
|
### Lowered Execution Artifact
|
|
359
352
|
|
|
360
|
-
A `lowered execution artifact` is a post-
|
|
353
|
+
A `lowered execution artifact` is a post-schema-specialization execution
|
|
361
354
|
artifact.
|
|
362
355
|
|
|
363
356
|
It is produced by taking a source or object program, specializing it against a
|
|
364
|
-
concrete input
|
|
365
|
-
model, and wrapping the entry metadata and
|
|
357
|
+
concrete input schema, lowering the resulting KIR-P to a lowered execution
|
|
358
|
+
model, and wrapping the entry metadata and relations. It is not the same thing
|
|
366
359
|
as a general k object.
|
|
367
360
|
|
|
368
361
|
## Execution Concepts
|
|
369
362
|
|
|
370
|
-
###
|
|
363
|
+
### Schema-Aware Execution
|
|
371
364
|
|
|
372
|
-
`
|
|
365
|
+
`Schema-aware execution` carries framing schemas through inner operations.
|
|
373
366
|
|
|
374
367
|
This mode matches the reference execution and codec model. It is the safest
|
|
375
|
-
semantic baseline because values keep their
|
|
368
|
+
semantic baseline because values keep their schema framing throughout execution.
|
|
376
369
|
|
|
377
|
-
###
|
|
370
|
+
### Schema-Free Execution
|
|
378
371
|
|
|
379
|
-
`
|
|
380
|
-
compiled
|
|
372
|
+
`Schema-free execution` uses static layout and schema information inside the
|
|
373
|
+
compiled relation and attaches the derived output schema only at the boundary.
|
|
381
374
|
|
|
382
|
-
This is valid only when
|
|
383
|
-
needed
|
|
375
|
+
This is valid only when schema-specialization and contract derivation prove the
|
|
376
|
+
needed schema contexts.
|
|
384
377
|
|
|
385
378
|
### Partial Failure
|
|
386
379
|
|
|
387
|
-
`Partial failure` is the normal result when a partial
|
|
388
|
-
its input.
|
|
380
|
+
`Partial failure` is the normal result when a partial relation is undefined for
|
|
381
|
+
its input payload.
|
|
389
382
|
|
|
390
383
|
In high-level execution this is represented as absence of an output value. In
|
|
391
384
|
lower-level execution contracts it may be represented explicitly as a failed
|
|
392
|
-
result. It is distinct from a `
|
|
385
|
+
result. It is distinct from a `contract violation`, malformed artifacts, system
|
|
393
386
|
failures, and host exceptions.
|
|
394
387
|
|
|
395
|
-
### Type Error
|
|
388
|
+
### Contract Violation (Type Error)
|
|
396
389
|
|
|
397
|
-
A `type error` is a semantic contradiction indicating
|
|
398
|
-
|
|
399
|
-
|
|
390
|
+
A `contract violation` (or `type error`) is a semantic contradiction indicating
|
|
391
|
+
that the schema of a payload or expression does not conform to the expected
|
|
392
|
+
input schema of the relation to which it is applied.
|
|
400
393
|
|
|
401
|
-
A
|
|
394
|
+
A contract violation is fundamentally distinct from `partial failure`:
|
|
402
395
|
|
|
403
396
|
- `Partial failure` is a normal, valid semantic outcome representing mathematical
|
|
404
397
|
undefinedness for an input value that nonetheless conforms to the expected
|
|
405
|
-
input
|
|
398
|
+
input schema (for example, failing a condition in an inner branch, which in
|
|
406
399
|
an ordered union allows subsequent branches to be evaluated).
|
|
407
|
-
- A `
|
|
400
|
+
- A `contract violation` represents a contract contradiction or boundary contract
|
|
408
401
|
violation. It is not an ordinary execution result and cannot be recovered by
|
|
409
402
|
branching constructs like ordered union.
|
|
410
403
|
|
|
411
|
-
A
|
|
412
|
-
|
|
413
|
-
1. **Compilation time (
|
|
414
|
-
`
|
|
415
|
-
unified with, or does not satisfy, the required input
|
|
416
|
-
it is passed to (such as disjoint
|
|
417
|
-
This causes compilation or
|
|
418
|
-
2. **Runtime (Evaluation Boundary)**: Triggered when
|
|
419
|
-
an `input
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
404
|
+
A contract violation can occur at two distinct stages:
|
|
405
|
+
|
|
406
|
+
1. **Compilation time (Contract Derivation)**: Triggered during
|
|
407
|
+
`contract-derivation` when an expression's schema cannot be
|
|
408
|
+
unified with, or does not satisfy, the required input schema of a relation
|
|
409
|
+
it is passed to (such as disjoint schemas or unsatisfiable filters).
|
|
410
|
+
This causes compilation or contract derivation to fail with a diagnostic.
|
|
411
|
+
2. **Runtime (Evaluation Boundary)**: Triggered when a `framed value` carries
|
|
412
|
+
an `input schema` that does not match or conform to the expected input
|
|
413
|
+
schema of the relation being executed (for example, passing an incompatible
|
|
414
|
+
schema to an entry relation or target executable). At runtime, a
|
|
415
|
+
contract violation halts execution with a fatal diagnostic or error code (such as exit
|
|
423
416
|
status 5 in compiled targets) rather than producing partial failure.
|
|
424
417
|
|
|
425
418
|
### Intrinsic
|
|
@@ -427,8 +420,8 @@ A type error can occur at two distinct stages:
|
|
|
427
420
|
An `intrinsic` is a predefined operation supplied by the execution environment and
|
|
428
421
|
known to the compiler.
|
|
429
422
|
|
|
430
|
-
Intrinsics need explicit
|
|
431
|
-
can participate in ordinary
|
|
423
|
+
Intrinsics need explicit schema and lowering rules. Pure identity-like intrinsics
|
|
424
|
+
can participate in ordinary relation semantics. Effectful or host-only
|
|
432
425
|
intrinsics require explicit ordering constraints or must be excluded from pure
|
|
433
426
|
lowering targets.
|
|
434
427
|
|
|
@@ -449,8 +442,8 @@ The diagrams use a Petri-net-like convention:
|
|
|
449
442
|
|
|
450
443
|
### Whole-System Artifact Graph
|
|
451
444
|
|
|
452
|
-
This graph starts with a
|
|
453
|
-
|
|
445
|
+
This graph starts with a relation definition in k syntax and an input
|
|
446
|
+
framed value `(schema, payload)`. It ends with an output framed value. Lowering paths branch
|
|
454
447
|
after the k object.
|
|
455
448
|
|
|
456
449
|
```mermaid
|
|
@@ -467,8 +460,8 @@ flowchart TB
|
|
|
467
460
|
Src["k source<br/>program"]:::artifact
|
|
468
461
|
Parse["source<br/>parsing"]:::transform
|
|
469
462
|
AST["parsed<br/>AST"]:::artifact
|
|
470
|
-
Annotate["
|
|
471
|
-
Core["
|
|
463
|
+
Annotate["contract<br/>derivation"]:::transform
|
|
464
|
+
Core["contract-annotated<br/>core"]:::artifact
|
|
472
465
|
Package["object<br/>packaging"]:::transform
|
|
473
466
|
Object["k<br/>object"]:::artifact
|
|
474
467
|
Src --> Parse --> AST --> Annotate --> Core --> Package --> Object
|
|
@@ -476,18 +469,18 @@ flowchart TB
|
|
|
476
469
|
|
|
477
470
|
subgraph Input["prepare the input value"]
|
|
478
471
|
direction LR
|
|
479
|
-
InputValue["input<br/>
|
|
480
|
-
ExtractEnvelope["input-
|
|
481
|
-
InputEnvelope["input<br/>
|
|
472
|
+
InputValue["input framed value<br/>(schema, payload)"]:::value
|
|
473
|
+
ExtractEnvelope["input-schema<br/>extraction"]:::transform
|
|
474
|
+
InputEnvelope["input<br/>schema"]:::artifact
|
|
482
475
|
InputValue --> ExtractEnvelope --> InputEnvelope
|
|
483
476
|
end
|
|
484
477
|
|
|
485
|
-
subgraph Reference["reference
|
|
478
|
+
subgraph Reference["reference schema-aware execution"]
|
|
486
479
|
direction LR
|
|
487
480
|
Select["entry<br/>selection"]:::transform
|
|
488
|
-
EntryFunction["entry
|
|
481
|
+
EntryFunction["entry<br/>relation"]:::artifact
|
|
489
482
|
ReferenceRun["reference<br/>evaluation"]:::transform
|
|
490
|
-
OutputValue["output<br/>
|
|
483
|
+
OutputValue["output framed value<br/>(schema, payload)"]:::result
|
|
491
484
|
Select --> EntryFunction --> ReferenceRun --> OutputValue
|
|
492
485
|
end
|
|
493
486
|
|
|
@@ -495,9 +488,9 @@ flowchart TB
|
|
|
495
488
|
direction LR
|
|
496
489
|
ExportKIR["KIR-P<br/>export"]:::transform
|
|
497
490
|
KIRP["KIR-P"]:::artifact
|
|
498
|
-
Specialize["
|
|
499
|
-
SpecializedKIRP["
|
|
500
|
-
OutputEnvelope["output<br/>
|
|
491
|
+
Specialize["schema<br/>specialization"]:::transform
|
|
492
|
+
SpecializedKIRP["schema-specialized<br/>KIR-P"]:::artifact
|
|
493
|
+
OutputEnvelope["output<br/>schema"]:::artifact
|
|
501
494
|
ExportKIR --> KIRP --> Specialize --> SpecializedKIRP
|
|
502
495
|
Specialize --> OutputEnvelope
|
|
503
496
|
end
|
|
@@ -533,8 +526,8 @@ flowchart TB
|
|
|
533
526
|
### Reference Execution Graph
|
|
534
527
|
|
|
535
528
|
The reference path is the semantic baseline. It can run directly from source or
|
|
536
|
-
from a loaded k object. It stays
|
|
537
|
-
through projections, constructors,
|
|
529
|
+
from a loaded k object. It stays schema-aware: the value keeps its schema framing
|
|
530
|
+
through projections, constructors, filters, and relation calls.
|
|
538
531
|
|
|
539
532
|
```mermaid
|
|
540
533
|
%%{init: {"flowchart": {"htmlLabels": true, "nodeSpacing": 42, "rankSpacing": 50}, "themeVariables": {"fontSize": "18px"}} }%%
|
|
@@ -544,16 +537,16 @@ flowchart LR
|
|
|
544
537
|
classDef value fill:#e8f7ee,stroke:#16a34a,stroke-width:1.5px,color:#052e16;
|
|
545
538
|
classDef result fill:#fff1f2,stroke:#e11d48,stroke-width:1.5px,color:#4c0519;
|
|
546
539
|
|
|
547
|
-
Source["
|
|
548
|
-
Input["input<br/>
|
|
540
|
+
Source["relation<br/>definition in k syntax"]:::artifact
|
|
541
|
+
Input["input framed value<br/>(schema, payload)"]:::value
|
|
549
542
|
Parse["source<br/>parsing"]:::transform
|
|
550
543
|
AST["parsed<br/>AST"]:::artifact
|
|
551
|
-
Annotate["
|
|
552
|
-
Core["
|
|
544
|
+
Annotate["contract<br/>derivation"]:::transform
|
|
545
|
+
Core["contract-annotated<br/>core"]:::artifact
|
|
553
546
|
Select["entry<br/>selection"]:::transform
|
|
554
|
-
Transform["
|
|
547
|
+
Transform["relation with<br/>contract"]:::artifact
|
|
555
548
|
Run["reference<br/>evaluation"]:::transform
|
|
556
|
-
Output["output<br/>
|
|
549
|
+
Output["output framed value<br/>(schema, payload)"]:::result
|
|
557
550
|
|
|
558
551
|
Source --> Parse --> AST --> Annotate --> Core --> Select --> Transform
|
|
559
552
|
Transform --> Run
|
|
@@ -563,8 +556,8 @@ flowchart LR
|
|
|
563
556
|
|
|
564
557
|
### Lowering Preparation Graph
|
|
565
558
|
|
|
566
|
-
The lowering preparation path starts from a k object and an input
|
|
567
|
-
specializes the program for that
|
|
559
|
+
The lowering preparation path starts from a k object and an input schema. It
|
|
560
|
+
specializes the program for that schema, derives the output schema, lowers
|
|
568
561
|
to a lowered execution artifact, and may then lower to a concrete execution
|
|
569
562
|
target.
|
|
570
563
|
|
|
@@ -576,12 +569,12 @@ flowchart LR
|
|
|
576
569
|
classDef lowered fill:#f3e8ff,stroke:#7e22ce,stroke-width:1.5px,color:#2e1065;
|
|
577
570
|
|
|
578
571
|
Object["k<br/>object"]:::artifact
|
|
579
|
-
InputEnvelope["input<br/>
|
|
572
|
+
InputEnvelope["input<br/>schema"]:::artifact
|
|
580
573
|
Export["KIR-P<br/>export"]:::transform
|
|
581
574
|
KIRP["KIR-P"]:::artifact
|
|
582
|
-
Specialize["
|
|
583
|
-
Specialized["
|
|
584
|
-
OutputEnvelope["output<br/>
|
|
575
|
+
Specialize["schema<br/>specialization"]:::transform
|
|
576
|
+
Specialized["schema-specialized<br/>KIR-P"]:::artifact
|
|
577
|
+
OutputEnvelope["output<br/>schema"]:::artifact
|
|
585
578
|
LowerModel["execution-model<br/>lowering"]:::transform
|
|
586
579
|
Lowered["lowered execution<br/>artifact"]:::lowered
|
|
587
580
|
TargetLowering["target<br/>lowering"]:::transform
|
|
@@ -599,7 +592,7 @@ flowchart LR
|
|
|
599
592
|
### Wire Boundary Graph
|
|
600
593
|
|
|
601
594
|
The wire boundary is separate from program compilation. It converts between a
|
|
602
|
-
binary
|
|
595
|
+
binary schema+payload stream and the in-memory framed value that execution
|
|
603
596
|
uses.
|
|
604
597
|
|
|
605
598
|
```mermaid
|
|
@@ -611,9 +604,9 @@ flowchart LR
|
|
|
611
604
|
|
|
612
605
|
InputWire["input wire<br/>stream"]:::value
|
|
613
606
|
Decode["wire<br/>decoding"]:::transform
|
|
614
|
-
InputValue["input<br/>
|
|
607
|
+
InputValue["input framed value<br/>(schema, payload)"]:::value
|
|
615
608
|
Execute["reference/target<br/>execution"]:::transform
|
|
616
|
-
OutputValue["output<br/>
|
|
609
|
+
OutputValue["output framed value<br/>(schema, payload)"]:::result
|
|
617
610
|
Encode["wire<br/>encoding"]:::transform
|
|
618
611
|
OutputWire["output wire<br/>stream"]:::result
|
|
619
612
|
|
|
@@ -629,7 +622,7 @@ Use noun phrases ending in the operation kind:
|
|
|
629
622
|
- `Parsing` for syntax to AST.
|
|
630
623
|
- `Registration` for assigning canonical identities.
|
|
631
624
|
- `Construction` for building semantic tables from parsed material.
|
|
632
|
-
- `Derivation` for computing
|
|
625
|
+
- `Derivation` for computing schema contracts.
|
|
633
626
|
- `Canonicalization` for stable names and hashes.
|
|
634
627
|
- `Packaging` for serializable artifacts.
|
|
635
628
|
- `Loading` for reconstructing semantic objects from artifacts.
|
|
@@ -637,7 +630,7 @@ Use noun phrases ending in the operation kind:
|
|
|
637
630
|
- `Evaluation` for executing a semantic or lowered execution artifact.
|
|
638
631
|
- `Extraction` for reading a component from an artifact without changing it.
|
|
639
632
|
- `Export` for a stable inspection or interchange view.
|
|
640
|
-
- `Specialization` for rewriting an artifact for a concrete
|
|
633
|
+
- `Specialization` for rewriting an artifact for a concrete input schema.
|
|
641
634
|
- `Lowering` for moving to a lower-level execution contract.
|
|
642
635
|
- `Encoding` and `Decoding` for wire boundaries.
|
|
643
636
|
- `Rendering` for human or external presentation.
|
|
@@ -651,24 +644,24 @@ names.
|
|
|
651
644
|
| Identifier | Preferred name | Inputs | Outputs |
|
|
652
645
|
| --- | --- | --- | --- |
|
|
653
646
|
| `source-parsing` | Source Parsing | k source program | parsed AST |
|
|
654
|
-
| `
|
|
655
|
-
| `
|
|
656
|
-
| `
|
|
657
|
-
| `
|
|
658
|
-
| `object-packaging` | Object Packaging |
|
|
647
|
+
| `schema-registration` | Schema Registration | parsed AST | canonical schema table |
|
|
648
|
+
| `relation-table-construction` | Relation Table Construction | parsed AST, canonical schema table | source relation table |
|
|
649
|
+
| `contract-derivation` | Contract Derivation | source relation table, canonical schema table | contract-annotated core |
|
|
650
|
+
| `relation-canonicalization` | Relation Canonicalization | contract-annotated core | canonical relation aliases |
|
|
651
|
+
| `object-packaging` | Object Packaging | contract-annotated core, canonical relation aliases | k object |
|
|
659
652
|
| `object-loading` | Object Loading | k object | loaded k object |
|
|
660
|
-
| `entry-selection` | Entry Selection |
|
|
661
|
-
| `reference-evaluation` | Reference Evaluation | entry
|
|
662
|
-
| `input-
|
|
653
|
+
| `entry-selection` | Entry Selection | contract-annotated core or loaded k object | entry relation |
|
|
654
|
+
| `reference-evaluation` | Reference Evaluation | entry relation, input framed value | output framed value or partial failure |
|
|
655
|
+
| `input-schema-extraction` | Input-Schema Extraction | input framed value | input schema |
|
|
663
656
|
| `kir-p-export` | KIR-P Export | k object | KIR-P |
|
|
664
|
-
| `
|
|
665
|
-
| `execution-model-lowering` | Execution-Model Lowering |
|
|
666
|
-
| `lowered-evaluation` | Lowered Evaluation | lowered execution artifact, input
|
|
657
|
+
| `schema-specialization` | Schema Specialization | KIR-P or k object, input schema | schema-specialized KIR-P, output schema |
|
|
658
|
+
| `execution-model-lowering` | Execution-Model Lowering | schema-specialized KIR-P | lowered execution artifact |
|
|
659
|
+
| `lowered-evaluation` | Lowered Evaluation | lowered execution artifact, input framed value | output framed value or partial failure |
|
|
667
660
|
| `target-lowering` | Target Lowering | lowered execution artifact | target artifact |
|
|
668
|
-
| `target-execution` | Target Execution | target artifact, input
|
|
669
|
-
| `wire-decoding` | Wire Decoding | input wire stream | input
|
|
670
|
-
| `wire-encoding` | Wire Encoding | output
|
|
671
|
-
| `external-rendering` | External Rendering | output wire stream or output
|
|
661
|
+
| `target-execution` | Target Execution | target artifact, input framed value or input wire stream | output framed value or output wire stream |
|
|
662
|
+
| `wire-decoding` | Wire Decoding | input wire stream | input framed value |
|
|
663
|
+
| `wire-encoding` | Wire Encoding | output framed value | output wire stream |
|
|
664
|
+
| `external-rendering` | External Rendering | output wire stream or output framed value | external text, JSON, or host value |
|
|
672
665
|
|
|
673
666
|
### Abstract Transformation Contracts
|
|
674
667
|
|
|
@@ -1189,13 +1182,13 @@ Independent tests:
|
|
|
1189
1182
|
### Transformation Notes
|
|
1190
1183
|
|
|
1191
1184
|
- Compilation transformations do not need an input value until
|
|
1192
|
-
|
|
1193
|
-
- Reference execution can use the
|
|
1185
|
+
schema-specialization or execution.
|
|
1186
|
+
- Reference execution can use the contract-annotated core directly; target
|
|
1194
1187
|
execution goes through KIR-P and a lowered execution artifact.
|
|
1195
|
-
-
|
|
1196
|
-
transformation driven by the input
|
|
1197
|
-
- The output
|
|
1198
|
-
preserved at binary boundaries even when printed
|
|
1188
|
+
- Schema-specialization is not a new source language feature. It is a compiler
|
|
1189
|
+
transformation driven by the input schema.
|
|
1190
|
+
- The output schema is an artifact of execution or specialization. It must be
|
|
1191
|
+
preserved at binary boundaries even when printed payload trees look identical.
|
|
1199
1192
|
- Partial failure is an ordinary result of execution transformations. It should
|
|
1200
1193
|
not be modeled as a malformed artifact.
|
|
1201
1194
|
|
|
@@ -1206,10 +1199,10 @@ Use this pipeline in high-level docs:
|
|
|
1206
1199
|
```text
|
|
1207
1200
|
k source
|
|
1208
1201
|
-> parsed AST
|
|
1209
|
-
->
|
|
1202
|
+
-> contract-annotated core
|
|
1210
1203
|
-> k object
|
|
1211
1204
|
-> KIR-P
|
|
1212
|
-
->
|
|
1205
|
+
-> schema-specialized KIR-P
|
|
1213
1206
|
-> lowered execution artifact
|
|
1214
1207
|
-> target artifact
|
|
1215
1208
|
```
|
|
@@ -1217,23 +1210,23 @@ k source
|
|
|
1217
1210
|
For the execution and codec boundary:
|
|
1218
1211
|
|
|
1219
1212
|
```text
|
|
1220
|
-
wire stream <->
|
|
1213
|
+
wire stream <-> framed value (schema, payload) <-> partial relation <-> framed value (schema, payload) <-> wire stream
|
|
1221
1214
|
```
|
|
1222
1215
|
|
|
1223
1216
|
## Terminology Rules
|
|
1224
1217
|
|
|
1225
1218
|
These rules are normative for this specification:
|
|
1226
1219
|
|
|
1227
|
-
- Use "partial
|
|
1228
|
-
|
|
1229
|
-
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1220
|
+
- Use "relation" or "partial relation" as the dominant public term.
|
|
1221
|
+
- Keep "contract-annotated core" as the name for the normalized,
|
|
1222
|
+
contract-annotated AST stage.
|
|
1223
|
+
- Use "schema-specialized KIR-P" for KIR-P rebuilt under a concrete input
|
|
1224
|
+
schema.
|
|
1225
|
+
- Use "canonical schema" for the deterministic representation of a schema,
|
|
1226
|
+
and "schema" for the semantic language of payload trees.
|
|
1227
|
+
- Use "contract" for the connected $(input, output)$ schema graph derived
|
|
1228
|
+
for relations, capturing structural preservation ($=X$).
|
|
1229
|
+
- Use "framed value `(schema, payload)`" for the self-describing value
|
|
1230
|
+
at execution and wire boundaries.
|
|
1231
|
+
- Use "filter" for the syntactic expression `?schema` that constrains
|
|
1232
|
+
payloads and acts as inductive termination witness.
|