@fraczak/k 6.10.2 → 6.10.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.
- package/CHANGELOG.md +30 -0
- package/DOCS/BIG_PICTURE.md +174 -100
- package/DOCS/CODECS.md +74 -29
- package/DOCS/CODEC_ARCHITECTURE.md +87 -31
- package/DOCS/CONVERGENCE.md +42 -11
- package/DOCS/DICTIONARY.md +69 -2
- package/DOCS/FILE_FORMATS.md +385 -0
- package/DOCS/KIR_V1.md +53 -42
- package/DOCS/KVM_EXECUTION_MODEL.md +189 -147
- package/DOCS/OBJECT_FILE_AND_PATTERN.md +35 -17
- package/DOCS/PATTERNS.md +10 -6
- package/DOCS/REPL.md +100 -60
- package/DOCS/TEXTUAL_VALUES.md +24 -19
- package/DOCS/TYPE_DERIVATION.md +68 -22
- package/README.md +92 -58
- package/codecs/README.md +78 -67
- package/objects/README.md +57 -37
- package/package.json +1 -1
- package/tests/README.md +28 -17
package/objects/README.md
CHANGED
|
@@ -1,29 +1,36 @@
|
|
|
1
1
|
# objects/
|
|
2
2
|
|
|
3
|
-
CLI tools for compiling and inspecting k object files (`.ko`)
|
|
3
|
+
CLI tools for compiling and inspecting k object files (`.ko`), library
|
|
4
|
+
files (`.klib`), and polymorphic kVM template files (`.kvm`).
|
|
4
5
|
|
|
5
6
|
## Tools
|
|
6
7
|
|
|
7
8
|
### `k-compile`
|
|
8
9
|
|
|
9
|
-
Compiles `.k` source into an executable object file (`.ko`), library
|
|
10
|
-
(`.klib`), or polymorphic kVM backend artifact (`.kvm`). Output
|
|
11
|
-
inferred from the output extension, or from `--format`.
|
|
10
|
+
Compiles `.k` source into an executable object file (`.ko`), library
|
|
11
|
+
file (`.klib`), or polymorphic kVM backend artifact (`.kvm`). Output
|
|
12
|
+
format is inferred from the output extension, or from `--format`.
|
|
12
13
|
|
|
13
14
|
```bash
|
|
14
|
-
k-compile [--lib lib-file] [--export spec]...
|
|
15
|
+
k-compile [--lib lib-file] [--export spec]... \
|
|
16
|
+
[--format ko|klib|kvm] [source-snippet | input-file [output-file]]
|
|
15
17
|
```
|
|
16
18
|
|
|
17
|
-
Existing input paths are read as files. A non-existing input with `.k`,
|
|
18
|
-
or `.klib` extension is reported as a missing file; otherwise it
|
|
19
|
-
inline k source, in the same style as `k.mjs`.
|
|
19
|
+
Existing input paths are read as files. A non-existing input with `.k`,
|
|
20
|
+
`.ko`, or `.klib` extension is reported as a missing file; otherwise it
|
|
21
|
+
is compiled as inline k source, in the same style as `k.mjs`.
|
|
20
22
|
|
|
21
|
-
`.kvm` is a polymorphic kVM template artifact (`layer: "KVM-P"`). It
|
|
22
|
-
relational function definitions,
|
|
23
|
-
lowered kVM instruction streams ready for runtime specialization
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
a `--lib` dependency
|
|
23
|
+
`.kvm` is a polymorphic kVM template artifact (`layer: "KVM-P"`). It
|
|
24
|
+
carries relational function definitions, principal pattern graphs,
|
|
25
|
+
and lowered kVM instruction streams ready for runtime specialization
|
|
26
|
+
when enveloped values arrive (`specializeKVM`).
|
|
27
|
+
|
|
28
|
+
When linking a `--lib` dependency, all relations are loaded under their
|
|
29
|
+
canonical content-addressed hashes (`@hash`). To use human-readable
|
|
30
|
+
alias names in an expression or script, explicitly map them into the
|
|
31
|
+
local scope using `--export <alias>` or
|
|
32
|
+
`--export <libAlias>:<localAlias>`.
|
|
33
|
+
Alternatively, canonical `@hash` names may always be referenced directly.
|
|
27
34
|
|
|
28
35
|
### `k-decompile`
|
|
29
36
|
|
|
@@ -35,9 +42,9 @@ k-decompile [object-file [k-file]]
|
|
|
35
42
|
|
|
36
43
|
### `k-extract-aliases`
|
|
37
44
|
|
|
38
|
-
Extracts metadata aliases from a `.ko` or `.klib` as a valid k
|
|
39
|
-
snippet. Output is grouped by metadata type (`code`, then
|
|
40
|
-
alias name and `compiledAt`.
|
|
45
|
+
Extracts metadata aliases from a `.ko` or `.klib` as a valid k
|
|
46
|
+
definition snippet. Output is grouped by metadata type (`code`, then
|
|
47
|
+
`rel`), then sorted by alias name and `compiledAt`.
|
|
41
48
|
|
|
42
49
|
```bash
|
|
43
50
|
k-extract-aliases [object-file [k-file]]
|
|
@@ -45,15 +52,16 @@ k-extract-aliases [object-file [k-file]]
|
|
|
45
52
|
|
|
46
53
|
### `k-inspect-object`
|
|
47
54
|
|
|
48
|
-
Inspects a `.ko` or `.klib`. By default it prints a compact object
|
|
49
|
-
With `--kir`, it prints the current KIR-P export used by
|
|
55
|
+
Inspects a `.ko` or `.klib`. By default it prints a compact object
|
|
56
|
+
summary. With `--kir`, it prints the current KIR-P export used by
|
|
57
|
+
backend experiments.
|
|
50
58
|
|
|
51
59
|
```bash
|
|
52
60
|
k-inspect-object [--summary | --kir] [object-file]
|
|
53
61
|
```
|
|
54
62
|
|
|
55
|
-
For scripts that only need KIR-P export, `k-kir [object-file]` is the
|
|
56
|
-
exporter backed by `kir.mjs`.
|
|
63
|
+
For scripts that only need KIR-P export, `k-kir [object-file]` is the
|
|
64
|
+
direct exporter backed by `kir.mjs`.
|
|
57
65
|
|
|
58
66
|
### `k-validate-object`
|
|
59
67
|
|
|
@@ -64,29 +72,41 @@ Validates a `.ko` or `.klib` object and its derived KIR-P export. With
|
|
|
64
72
|
k-validate-object [--kir] [input-file]
|
|
65
73
|
```
|
|
66
74
|
|
|
67
|
-
The installed names are `k-` plus the source basename without `.mjs`.
|
|
68
|
-
installed object binary supports `-h` and `--help`.
|
|
75
|
+
The installed names are `k-` plus the source basename without `.mjs`.
|
|
76
|
+
Every installed object binary supports `-h` and `--help`.
|
|
69
77
|
|
|
70
78
|
## Current Format Notes
|
|
71
79
|
|
|
72
|
-
-
|
|
73
|
-
|
|
80
|
+
- For full specifications, see
|
|
81
|
+
[`DOCS/FILE_FORMATS.md`](../DOCS/FILE_FORMATS.md).
|
|
82
|
+
- Both `.ko` and `.klib` are ahead-of-time (AOT) type-checked artifacts.
|
|
83
|
+
Parsing, relation expansion, type derivation, and constraint
|
|
84
|
+
convergence are completed in advance.
|
|
85
|
+
- `.klib` files are plain UTF-8 JSON, not binary containers
|
|
86
|
+
(`main: null`).
|
|
87
|
+
- `.ko` files use the `KOBJ\n` binary header followed by a JSON payload
|
|
88
|
+
(`main: "__main__"`).
|
|
74
89
|
- There is no object payload version field in either format.
|
|
75
90
|
- `typeDerivation` belongs only to relations and currently stores only
|
|
76
91
|
`status`.
|
|
77
92
|
- Source `start` / `end` ranges live on `meta[hash].origins[]` entries.
|
|
78
|
-
- Origin entries do not have `kind`; the metadata entry has `type: "code"`
|
|
79
|
-
`type: "rel"`.
|
|
80
|
-
- Stored relation bodies do not include generated input/output
|
|
81
|
-
- KIR-P is available as an inspection/export contract; it does not change
|
|
82
|
-
stored `.ko` or `.klib` payload.
|
|
83
|
-
- `.kvm` is
|
|
84
|
-
|
|
85
|
-
and JIT specialization.
|
|
93
|
+
- Origin entries do not have `kind`; the metadata entry has `type: "code"`
|
|
94
|
+
or `type: "rel"`.
|
|
95
|
+
- Stored relation bodies do not include generated input/output filters.
|
|
96
|
+
- KIR-P is available as an inspection/export contract; it does not change
|
|
97
|
+
the stored `.ko` or `.klib` payload.
|
|
98
|
+
- `.kvm` is a polymorphic backend template artifact (`layer: "KVM-P"`),
|
|
99
|
+
lowered from KIR-P for runtime execution and JIT specialization.
|
|
86
100
|
|
|
87
101
|
## Further reading
|
|
88
102
|
|
|
89
|
-
- [DOCS/
|
|
90
|
-
|
|
91
|
-
- [DOCS/
|
|
92
|
-
|
|
103
|
+
- [DOCS/FILE_FORMATS.md](../DOCS/FILE_FORMATS.md) — guide to
|
|
104
|
+
.k, .ko, .klib, and .kvm formats
|
|
105
|
+
- [DOCS/OBJECT_FILE_AND_PATTERN.md](../DOCS/OBJECT_FILE_AND_PATTERN.md) —
|
|
106
|
+
object file format and pattern encoding
|
|
107
|
+
- [DOCS/KIR_V1.md](../DOCS/KIR_V1.md) — KIR-P inspection/export contract
|
|
108
|
+
for backends
|
|
109
|
+
- [DOCS/TYPE_DERIVATION.md](../DOCS/TYPE_DERIVATION.md) — type
|
|
110
|
+
derivation (what compilation skips when loading a `.ko`/`.klib`)
|
|
111
|
+
- [DOCS/CONVERGENCE.md](../DOCS/CONVERGENCE.md) — convergence strategies
|
|
112
|
+
for type inference
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fraczak/k",
|
|
3
|
-
"version": "6.10.
|
|
3
|
+
"version": "6.10.3",
|
|
4
4
|
"description": "k — a language for composing first-order partial functions over algebraic data types (products and tagged unions); includes runtime, type derivation, REPL, and codec toolchain",
|
|
5
5
|
"main": "index.mjs",
|
|
6
6
|
"exports": {
|
package/tests/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# k Test Suite
|
|
2
2
|
|
|
3
|
-
This directory contains
|
|
3
|
+
This directory contains automated tests, type-derivation validation
|
|
4
|
+
cases, and integration test scripts for the `k` compiler and runtime.
|
|
4
5
|
|
|
5
6
|
## Running the Tests
|
|
6
7
|
|
|
@@ -9,27 +10,37 @@ To run all core unit tests, type-derivation checks, and integration tests:
|
|
|
9
10
|
```bash
|
|
10
11
|
npm test
|
|
11
12
|
```
|
|
12
|
-
This executes `node scripts/run-tests.mjs`, which discovers and runs the
|
|
13
|
+
This executes `node scripts/run-tests.mjs`, which discovers and runs the
|
|
14
|
+
test scripts sequentially.
|
|
13
15
|
|
|
14
16
|
## Test Directory Structure
|
|
15
17
|
|
|
16
18
|
### Core Test Files
|
|
17
|
-
- **[test.mjs](
|
|
18
|
-
|
|
19
|
-
- **[test-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
- **[test-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[
|
|
19
|
+
- **[test.mjs](test.mjs)**: Verifies basic parser and runtime
|
|
20
|
+
execution behavior.
|
|
21
|
+
- **[test-kvm.mjs](test-kvm.mjs)**: Conformance testing for the kVM
|
|
22
|
+
register compiler and interpreter in envelope-aware and envelope-free
|
|
23
|
+
modes.
|
|
24
|
+
- **[test-kvm-polymorphic.mjs](test-kvm-polymorphic.mjs)**: Tests for
|
|
25
|
+
polymorphic `.kvm` templates (`layer: "KVM-P"`) and runtime input
|
|
26
|
+
envelope specialization (`specializeKVM`).
|
|
27
|
+
- **[test-ieee-arithmetic.mjs](test-ieee-arithmetic.mjs)**: Verifies
|
|
28
|
+
IEEE-754 double precision float arithmetic (`Examples/ieee.k`).
|
|
29
|
+
- **[test-repl.mjs](test-repl.mjs)**: Tests interactive REPL commands,
|
|
30
|
+
state transitions, imports, `.klib` and `.ko` exports.
|
|
31
|
+
- **[test-k-object.mjs](test-k-object.mjs)**: Tests serialization,
|
|
32
|
+
compilation, and loading of `.ko` binary objects and `.klib` libraries.
|
|
33
|
+
- **[test-fingerprint.mjs](test-fingerprint.mjs)**: Tests semantic
|
|
34
|
+
expression and relation hashing/fingerprinting (`@hash`).
|
|
35
|
+
- **[test-hash-normalization.mjs](test-hash-normalization.mjs)**:
|
|
36
|
+
Verifies consistent normalization of type pattern graphs and hashes.
|
|
37
|
+
- **[test-hash-fuzz.mjs](test-hash-fuzz.mjs)**: Fuzzes expression and
|
|
38
|
+
relation hashing to guard against collisions.
|
|
30
39
|
|
|
31
40
|
### Type Derivation Suites
|
|
32
|
-
- **[code-derivation/](
|
|
41
|
+
- **[code-derivation/](code-derivation/)**: Individual files validating
|
|
42
|
+
type-derivation convergence and pattern-envelope generation.
|
|
33
43
|
|
|
34
44
|
### Integration Scripts
|
|
35
|
-
- **[integration.sh](
|
|
45
|
+
- **[integration.sh](integration.sh)**: Shell script checking boundary
|
|
46
|
+
data pipelines (`k-parse`, `k-show`, `k-print`) against binary outputs.
|