kohakunode 0.2.1__tar.gz
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.
- kohakunode-0.2.1/LICENSE +201 -0
- kohakunode-0.2.1/PKG-INFO +478 -0
- kohakunode-0.2.1/README.md +446 -0
- kohakunode-0.2.1/pyproject.toml +68 -0
- kohakunode-0.2.1/rust/Cargo.lock +624 -0
- kohakunode-0.2.1/rust/Cargo.toml +34 -0
- kohakunode-0.2.1/rust/README.md +72 -0
- kohakunode-0.2.1/rust/rustfmt.toml +2 -0
- kohakunode-0.2.1/rust/src/api.rs +304 -0
- kohakunode-0.2.1/rust/src/bindings/mod.rs +6 -0
- kohakunode-0.2.1/rust/src/bindings/python.rs +136 -0
- kohakunode-0.2.1/rust/src/bindings/wasm.rs +52 -0
- kohakunode-0.2.1/rust/src/check/checker.rs +466 -0
- kohakunode-0.2.1/rust/src/check/mod.rs +5 -0
- kohakunode-0.2.1/rust/src/compiler.rs +60 -0
- kohakunode-0.2.1/rust/src/errors.rs +60 -0
- kohakunode-0.2.1/rust/src/flow/cfg.rs +326 -0
- kohakunode-0.2.1/rust/src/flow/mod.rs +4 -0
- kohakunode-0.2.1/rust/src/flow/order.rs +86 -0
- kohakunode-0.2.1/rust/src/graph/from_graph.rs +662 -0
- kohakunode-0.2.1/rust/src/graph/mod.rs +7 -0
- kohakunode-0.2.1/rust/src/graph/to_graph.rs +864 -0
- kohakunode-0.2.1/rust/src/lib.rs +21 -0
- kohakunode-0.2.1/rust/src/lower/each.rs +90 -0
- kohakunode-0.2.1/rust/src/lower/inline.rs +152 -0
- kohakunode-0.2.1/rust/src/lower/mod.rs +8 -0
- kohakunode-0.2.1/rust/src/lower/passes.rs +149 -0
- kohakunode-0.2.1/rust/src/lower/versions.rs +132 -0
- kohakunode-0.2.1/rust/src/sig/env.rs +168 -0
- kohakunode-0.2.1/rust/src/sig/files.rs +182 -0
- kohakunode-0.2.1/rust/src/sig/mod.rs +11 -0
- kohakunode-0.2.1/rust/src/sig/model.rs +74 -0
- kohakunode-0.2.1/rust/src/sig/std.rs +79 -0
- kohakunode-0.2.1/rust/src/sig/types.rs +142 -0
- kohakunode-0.2.1/rust/src/syntax/ast.rs +286 -0
- kohakunode-0.2.1/rust/src/syntax/indenter.rs +375 -0
- kohakunode-0.2.1/rust/src/syntax/kir.pest +143 -0
- kohakunode-0.2.1/rust/src/syntax/mod.rs +13 -0
- kohakunode-0.2.1/rust/src/syntax/parser.rs +563 -0
- kohakunode-0.2.1/rust/src/syntax/strlit.rs +298 -0
- kohakunode-0.2.1/rust/src/syntax/unicode_names.rs +1187 -0
- kohakunode-0.2.1/rust/src/syntax/value.rs +185 -0
- kohakunode-0.2.1/rust/src/syntax/writer.rs +222 -0
- kohakunode-0.2.1/rust/src/util/json.rs +448 -0
- kohakunode-0.2.1/rust/src/util/mod.rs +4 -0
- kohakunode-0.2.1/rust/src/util/pyfmt.rs +236 -0
- kohakunode-0.2.1/rust/tests/golden.rs +83 -0
- kohakunode-0.2.1/rust/tests/parity/parity.py +651 -0
- kohakunode-0.2.1/rust/tests/wasm/golden.cjs +58 -0
- kohakunode-0.2.1/src/kohakunode/__init__.py +45 -0
- kohakunode-0.2.1/src/kohakunode/check/__init__.py +5 -0
- kohakunode-0.2.1/src/kohakunode/check/checker.py +293 -0
- kohakunode-0.2.1/src/kohakunode/cli/__init__.py +1 -0
- kohakunode-0.2.1/src/kohakunode/cli/main.py +223 -0
- kohakunode-0.2.1/src/kohakunode/comfyui/__init__.py +5 -0
- kohakunode-0.2.1/src/kohakunode/comfyui/convert.py +107 -0
- kohakunode-0.2.1/src/kohakunode/compiler.py +68 -0
- kohakunode-0.2.1/src/kohakunode/errors.py +45 -0
- kohakunode-0.2.1/src/kohakunode/flow/__init__.py +6 -0
- kohakunode-0.2.1/src/kohakunode/flow/cfg.py +234 -0
- kohakunode-0.2.1/src/kohakunode/flow/order.py +69 -0
- kohakunode-0.2.1/src/kohakunode/graph/__init__.py +6 -0
- kohakunode-0.2.1/src/kohakunode/graph/from_graph.py +401 -0
- kohakunode-0.2.1/src/kohakunode/graph/to_graph.py +564 -0
- kohakunode-0.2.1/src/kohakunode/lower/__init__.py +5 -0
- kohakunode-0.2.1/src/kohakunode/lower/each.py +61 -0
- kohakunode-0.2.1/src/kohakunode/lower/inline.py +107 -0
- kohakunode-0.2.1/src/kohakunode/lower/passes.py +166 -0
- kohakunode-0.2.1/src/kohakunode/lower/versions.py +103 -0
- kohakunode-0.2.1/src/kohakunode/lsp/__init__.py +1 -0
- kohakunode-0.2.1/src/kohakunode/lsp/analysis.py +216 -0
- kohakunode-0.2.1/src/kohakunode/lsp/server.py +138 -0
- kohakunode-0.2.1/src/kohakunode/run/__init__.py +5 -0
- kohakunode-0.2.1/src/kohakunode/run/interpreter.py +373 -0
- kohakunode-0.2.1/src/kohakunode/sig/__init__.py +24 -0
- kohakunode-0.2.1/src/kohakunode/sig/env.py +105 -0
- kohakunode-0.2.1/src/kohakunode/sig/files.py +107 -0
- kohakunode-0.2.1/src/kohakunode/sig/library.py +122 -0
- kohakunode-0.2.1/src/kohakunode/sig/model.py +52 -0
- kohakunode-0.2.1/src/kohakunode/sig/std.py +157 -0
- kohakunode-0.2.1/src/kohakunode/sig/types.py +155 -0
- kohakunode-0.2.1/src/kohakunode/syntax/__init__.py +6 -0
- kohakunode-0.2.1/src/kohakunode/syntax/ast.py +240 -0
- kohakunode-0.2.1/src/kohakunode/syntax/kir.lark +135 -0
- kohakunode-0.2.1/src/kohakunode/syntax/parser.py +423 -0
- kohakunode-0.2.1/src/kohakunode/syntax/writer.py +194 -0
kohakunode-0.2.1/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Shih-Ying Yeh (aka KohakuBlueLeaf, KBlueLeaf)
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kohakunode
|
|
3
|
+
Version: 0.2.1
|
|
4
|
+
Classifier: Programming Language :: Python :: 3
|
|
5
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
6
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
7
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
10
|
+
Classifier: Programming Language :: Rust
|
|
11
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Software Development :: Compilers
|
|
14
|
+
Requires-Dist: lark>=1.2
|
|
15
|
+
Requires-Dist: pytest>=8 ; extra == 'dev'
|
|
16
|
+
Requires-Dist: ruff ; extra == 'dev'
|
|
17
|
+
Requires-Dist: black ; extra == 'dev'
|
|
18
|
+
Requires-Dist: pygls>=2 ; extra == 'dev'
|
|
19
|
+
Requires-Dist: maturin>=1.8,<2 ; extra == 'dev'
|
|
20
|
+
Requires-Dist: pygls>=2 ; extra == 'lsp'
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Provides-Extra: lsp
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Summary: KIR: a text IR for node graphs, with a sequential meaning per job
|
|
25
|
+
Author-email: "Shih-Ying Yeh(KohakuBlueLeaf)" <apolloyeh0123@gmail.com>
|
|
26
|
+
License: Apache-2.0
|
|
27
|
+
Requires-Python: >=3.10
|
|
28
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
29
|
+
Project-URL: Homepage, https://kblueleaf.net/
|
|
30
|
+
Project-URL: Repository, https://github.com/KohakuBlueleaf/KohakuNodeIR
|
|
31
|
+
|
|
32
|
+
<h1 align="center">KohakuNodeIR</h1>
|
|
33
|
+
<p align="center">
|
|
34
|
+
<strong>A text IR for node graphs: what an editor draws, a person reads, and a machine runs, as one program.</strong>
|
|
35
|
+
</p>
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="https://img.shields.io/badge/python-3.10%2B-blue" alt="Python 3.10+">
|
|
38
|
+
<img src="https://img.shields.io/badge/license-Apache--2.0-green" alt="License: Apache-2.0">
|
|
39
|
+
<img src="https://img.shields.io/pypi/v/kohakunode" alt="PyPI version">
|
|
40
|
+
<a href="https://github.com/KohakuBlueleaf/KohakuNodeIR"><img src="https://img.shields.io/github/stars/KohakuBlueleaf/KohakuNodeIR?style=social" alt="GitHub stars"></a>
|
|
41
|
+
</p>
|
|
42
|
+
<p align="center">
|
|
43
|
+
<a href="docs/spec/README.md"><strong>Specification</strong></a> ·
|
|
44
|
+
<a href="docs/architecture.md"><strong>Architecture</strong></a> ·
|
|
45
|
+
<a href="examples/README.md"><strong>Examples</strong></a> ·
|
|
46
|
+
<a href="https://discord.gg/xWYrkyvJ2s"><strong>Discord</strong></a>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Is this for you?
|
|
52
|
+
|
|
53
|
+
**You probably want KIR if** you build node-based tools (an image pipeline, an
|
|
54
|
+
agent workflow, a captioning graph) and want the graph to be a real program:
|
|
55
|
+
diffable text, loops and branches as explicit control flow, typed nodes from
|
|
56
|
+
signature files, a reference interpreter that defines the result, and an
|
|
57
|
+
executor that is free to run whatever the wires allow in parallel.
|
|
58
|
+
|
|
59
|
+
**You probably don't if** a plain DAG of tasks covers everything you need (a
|
|
60
|
+
workflow scheduler already does that well), or you want a general-purpose
|
|
61
|
+
scripting language. KIR has no expressions: every computation is a node, and
|
|
62
|
+
nodes are written in your host language.
|
|
63
|
+
|
|
64
|
+
## What KIR is
|
|
65
|
+
|
|
66
|
+
KIR describes **one job** as a node graph. Nodes are joined by two kinds of
|
|
67
|
+
wire: **control** wires ("then", top and bottom ports) and **data** wires
|
|
68
|
+
(values, side ports). The text is that graph written line by line:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
(inputs)node(outputs) a node; data wires are the names
|
|
72
|
+
label: a namespace, entered only by a builtin
|
|
73
|
+
(cond)branch(`yes`, `no`) control flow is explicit: branch, switch, jump, parallel, each
|
|
74
|
+
@dataflow: a block ordered by data alone
|
|
75
|
+
@def (x: int)double(y: int): a subgraph, called like any node
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
A complete program ([examples/tour/01_each.kir](examples/tour/01_each.kir)):
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
image = "photo"
|
|
82
|
+
boxes = [1, 2, 3, 4]
|
|
83
|
+
nodes = []
|
|
84
|
+
(boxes)each(box, i, `body`)
|
|
85
|
+
body:
|
|
86
|
+
(box)is_new(fresh)
|
|
87
|
+
(fresh)branch(`new_box`, `known_box`)
|
|
88
|
+
new_box:
|
|
89
|
+
(image, box)crop(c)
|
|
90
|
+
(c)entity(node)
|
|
91
|
+
known_box:
|
|
92
|
+
node = None
|
|
93
|
+
(nodes, node)append(nodes)
|
|
94
|
+
(nodes)summarize(summary)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
**A job means its sequential run.** Statements run top to bottom, namespaces
|
|
98
|
+
are entered only by builtins, and a name holds the value last written to it.
|
|
99
|
+
|
|
100
|
+
**Parallel by default.** Nodes talk only through their wires, so an executor
|
|
101
|
+
may run any two nodes in either order or at once unless a data wire, the
|
|
102
|
+
control path, or a node flag (`mutates`, `ordered`) orders them. Nothing in a
|
|
103
|
+
program has to say what may run in parallel, the way a CPU issues several
|
|
104
|
+
instructions of one thread at once while the program order still defines the
|
|
105
|
+
result. `parallel` exists, but it states intent only.
|
|
106
|
+
|
|
107
|
+
**One language, many forms.** A program can be shown as a graph (for editors)
|
|
108
|
+
or as text (for people and tools). Optimization passes rewrite it into simpler
|
|
109
|
+
programs in the same language, down to a form an interpreter runs directly.
|
|
110
|
+
Nothing in the text marks which form it is in; every form is KIR, and every
|
|
111
|
+
form runs.
|
|
112
|
+
|
|
113
|
+
## Where it fits
|
|
114
|
+
|
|
115
|
+
| | Graph is the program | Text form | Control flow | Typed nodes | Parallel by default |
|
|
116
|
+
|--|--|--|--|--|--|
|
|
117
|
+
| Node editor save files (e.g. ComfyUI workflow JSON) | yes | JSON only | no | per editor | executor-specific |
|
|
118
|
+
| Visual scripting (Blueprints, Scratch) | yes | no | yes | yes | no |
|
|
119
|
+
| Workflow DAGs (task schedulers) | yes | code or YAML | limited | no | yes |
|
|
120
|
+
| **KIR** | **yes** | **yes, line per node** | **yes, as wires** | **yes, signature files** | **yes** |
|
|
121
|
+
|
|
122
|
+
KIR sits between editors and executors. An editor (the example in
|
|
123
|
+
`apps/kir-editor`, a ComfyUI import, a Python builder, or a person with a text
|
|
124
|
+
editor) produces KIR; a machine receives KIR plus engines that implement its
|
|
125
|
+
nodes and never needs to know how the KIR was made.
|
|
126
|
+
|
|
127
|
+
## Key features
|
|
128
|
+
|
|
129
|
+
- **Text and graph are the same program.** `kir graph` / `kir text` convert
|
|
130
|
+
both ways; canonical text survives the round trip byte for byte, and
|
|
131
|
+
behaviour is always preserved.
|
|
132
|
+
- **Explicit control flow as wires.** `branch`, `switch`, `jump`, `parallel`,
|
|
133
|
+
`each` and `@try` / `@except` each have a node shape, so loops and branches
|
|
134
|
+
are visible in the graph, not hidden in node code.
|
|
135
|
+
- **Optimization passes over one language.** `order_dataflow`, `inline`,
|
|
136
|
+
`expand_each`, `version`, `group`, `strip_meta`. Any prefix of the list is a
|
|
137
|
+
valid program with the same behaviour; a tool picks the form it wants
|
|
138
|
+
(`kir lower --passes ...`, `compile_source(..., passes=[...])`).
|
|
139
|
+
- **Signatures and `@use`.** Node libraries export `.kirsig.json` files
|
|
140
|
+
(ports, types, defaults, flags), so the checker, editors and the language
|
|
141
|
+
server never import node code. `@use "gbc" as g` makes a library callable.
|
|
142
|
+
- **A static checker.** Undefined reads on any path, wrong port counts, type
|
|
143
|
+
mismatches, ambiguous names, bad labels, dataflow cycles: one code per rule
|
|
144
|
+
([checks.md](docs/spec/checks.md)).
|
|
145
|
+
- **Program hashes.** A semantic hash (ignores `@meta` and `@hint`) to key
|
|
146
|
+
caches and reproducibility, and a full hash that also covers hints.
|
|
147
|
+
- **Hints that never change results.** `@hint lane="vlm"` tells a scheduler
|
|
148
|
+
something; deleting every hint leaves every result unchanged.
|
|
149
|
+
- **A reference interpreter with a call hook**, so a machine can replay its
|
|
150
|
+
recorded node results and check that it computed what the program means.
|
|
151
|
+
- **Editing support.** A tree-sitter grammar, a VS Code extension, and a
|
|
152
|
+
language server (`kir-lsp`: diagnostics, hover, completion, go-to-definition,
|
|
153
|
+
formatting).
|
|
154
|
+
- **ComfyUI import / export.** Both the UI workflow and the API prompt.
|
|
155
|
+
- **A Rust core** (PyO3 module and WASM build) that reproduces the Python
|
|
156
|
+
reference byte for byte on the shared golden corpus.
|
|
157
|
+
|
|
158
|
+
## Quick start
|
|
159
|
+
|
|
160
|
+
> **Python** 3.10 or newer. At run time `kohakunode` depends only on `lark`.
|
|
161
|
+
|
|
162
|
+
### 1. Install
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pip install kohakunode # the Python reference, the Rust core (kohakunode._rs), `kir`
|
|
166
|
+
pip install "kohakunode[lsp]" # plus the language server `kir-lsp`
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
From source (builds the Rust core, so a Rust toolchain is needed):
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
git clone https://github.com/KohakuBlueleaf/KohakuNodeIR.git
|
|
173
|
+
cd KohakuNodeIR
|
|
174
|
+
pip install -e ".[dev]" # pytest, ruff, black, pygls, maturin
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### 2. Write nodes
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
# my_nodes.py
|
|
181
|
+
from kohakunode import NodeLibrary
|
|
182
|
+
|
|
183
|
+
lib = NodeLibrary("my_nodes")
|
|
184
|
+
|
|
185
|
+
@lib.node(outputs=["sum"])
|
|
186
|
+
def add(a: int, b: int) -> int:
|
|
187
|
+
return a + b
|
|
188
|
+
|
|
189
|
+
@lib.node(outputs=["graph"], mutates=["graph"]) # changes its input in place
|
|
190
|
+
def attach(graph: list, node: str) -> list:
|
|
191
|
+
graph.append(node)
|
|
192
|
+
return graph
|
|
193
|
+
|
|
194
|
+
@lib.node(ordered=True) # touches the outside world
|
|
195
|
+
def log(message: str) -> None:
|
|
196
|
+
print(message)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
A node may depend only on its inputs and affect the job only through its
|
|
200
|
+
outputs; the two flags declare the exceptions once, in the registry
|
|
201
|
+
([writing nodes](docs/guides/writing-nodes.md)).
|
|
202
|
+
|
|
203
|
+
### 3. Export signatures for tools that should not import your code
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
kir sig export my_nodes -o sigs/ # writes sigs/my_nodes.kirsig.json
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Programs then say `@use "my_nodes"`; the tools find the file on `--sig-path`
|
|
210
|
+
or `KIR_SIG_PATH`.
|
|
211
|
+
|
|
212
|
+
### 4. Use the toolchain
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
kir check prog.kir --lib my_nodes # diagnostics with codes (checks.md)
|
|
216
|
+
kir fmt prog.kir -w # canonical text, in place
|
|
217
|
+
kir lower prog.kir --lib my_nodes # after every pass
|
|
218
|
+
kir lower prog.kir --passes order_dataflow,inline --hash
|
|
219
|
+
kir graph prog.kir -o prog.kirgraph # text -> graph view (--data variables: name -> node -> name)
|
|
220
|
+
kir text prog.kirgraph # graph view -> canonical text (--no-meta to drop ids/positions)
|
|
221
|
+
kir run prog.kir --lib my_nodes # the reference run; prints final values
|
|
222
|
+
kir-lsp # language server on stdio
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
`--lib` imports a Python module that defines a `NodeLibrary`; `--sig-path`
|
|
226
|
+
adds directories of signature files.
|
|
227
|
+
|
|
228
|
+
## Core mental model
|
|
229
|
+
|
|
230
|
+
### Two kinds of wire
|
|
231
|
+
|
|
232
|
+
```text
|
|
233
|
+
control in
|
|
234
|
+
|
|
|
235
|
+
+--------v--------+
|
|
236
|
+
a -->| |--> sum data wires: values, by name
|
|
237
|
+
b -->| (a, b)add |
|
|
238
|
+
+--------+--------+
|
|
239
|
+
|
|
|
240
|
+
control out control wires: "then"
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
A call node has control ports on top and bottom and data ports on its sides.
|
|
244
|
+
`branch` has one control output per label, `merge` joins control paths (a
|
|
245
|
+
labelled merge is a loop entry), `each` has `body` / `done` outputs and a
|
|
246
|
+
`next` input its body returns to. The full list of node kinds and ports is in
|
|
247
|
+
[graph.md](docs/spec/graph.md).
|
|
248
|
+
|
|
249
|
+
### Namespaces and continuation
|
|
250
|
+
|
|
251
|
+
```
|
|
252
|
+
(is_big)branch(`big`, `small`)
|
|
253
|
+
big:
|
|
254
|
+
(x)shrink(x)
|
|
255
|
+
small:
|
|
256
|
+
(x)grow(x)
|
|
257
|
+
(x)log() # both paths continue here, after the namespace definitions
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
A namespace is skipped when reached in sequence and entered only by a builtin.
|
|
261
|
+
When its body ends, execution continues after the namespace's definition; an
|
|
262
|
+
`each` body returns to its `each`; `parallel` arms run one after another;
|
|
263
|
+
`@dataflow:` and `@try` bodies continue after their statement. `jump` is the
|
|
264
|
+
only way back, so a loop is a namespace entered by a `jump` from before it and
|
|
265
|
+
re-entered by a `jump` from inside it.
|
|
266
|
+
|
|
267
|
+
### The pass pipeline
|
|
268
|
+
|
|
269
|
+
```text
|
|
270
|
+
.kirgraph (editor) <-> canonical .kir text
|
|
271
|
+
|
|
|
272
|
+
check (E/W codes)
|
|
273
|
+
|
|
|
274
|
+
order_dataflow -> inline -> expand_each -> version -> group -> strip_meta
|
|
275
|
+
(every intermediate program is valid KIR and runs)
|
|
276
|
+
|
|
|
277
|
+
+------------------+------------------+
|
|
278
|
+
| |
|
|
279
|
+
reference interpreter machines (parallel,
|
|
280
|
+
(sequential, defines the result) as if sequential)
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
After every pass, each `@dataflow:` block is a straight run whose dependence
|
|
284
|
+
graph a machine computes once: every write has its own version `x__n`, and a
|
|
285
|
+
name written on several paths gets a home version `x__0`. Control statements
|
|
286
|
+
between blocks choose what runs next; a job's state is its position plus its
|
|
287
|
+
values ([passes.md](docs/spec/passes.md)).
|
|
288
|
+
|
|
289
|
+
## Toolchain
|
|
290
|
+
|
|
291
|
+
| Piece | Where | What |
|
|
292
|
+
|---|---|---|
|
|
293
|
+
| Python reference | `src/kohakunode/` | parser, writer, checker, passes, hashes, graph view, interpreter, CLI, ComfyUI, language server; the ground truth |
|
|
294
|
+
| Rust core | `rust/` | the same parse, write, check, passes, hashes and graph conversion; shipped in the wheel as `kohakunode._rs`, plus a WASM build |
|
|
295
|
+
| tree-sitter grammar | `editors/tree-sitter-kir/` | highlighting and structure for any tree-sitter editor |
|
|
296
|
+
| VS Code extension | `editors/vscode/` | highlighting, snippets, folding, and a client for `kir-lsp` |
|
|
297
|
+
| Example node editor | `apps/kir-editor/` | Vue 3 + Vue Flow + elkjs + CodeMirror: nodes, flowchart, sequence, blocks and text views of one program |
|
|
298
|
+
|
|
299
|
+
### Rust core
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
maturin develop --release # from the repo root: kohakunode with kohakunode._rs, into the active venv
|
|
303
|
+
python rust/tests/parity/parity.py # the Rust core against the Python reference
|
|
304
|
+
cd rust && cargo test # unit tests + golden corpus, byte for byte
|
|
305
|
+
|
|
306
|
+
# WASM for browsers
|
|
307
|
+
rustup target add wasm32-unknown-unknown
|
|
308
|
+
cargo install wasm-bindgen-cli --version 0.2.129 # must match wasm-bindgen in Cargo.lock
|
|
309
|
+
cargo build --release --target wasm32-unknown-unknown --features wasm
|
|
310
|
+
wasm-bindgen --target web --out-dir pkg target/wasm32-unknown-unknown/release/kohakunode_rs.wasm
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
`kohakunode._rs` takes and returns text: `format`, `parse_to_json`, `check`,
|
|
314
|
+
`lower(passes=None)`, `hashes`, `to_graph`, `from_graph`, `std_signatures`;
|
|
315
|
+
signatures come as `.kirsig.json` texts and, for `check` / `lower` / `hashes` /
|
|
316
|
+
`to_graph`, through `base=` and `sig_path=` the way `@use` resolves them. The
|
|
317
|
+
WASM build exposes the same functions to browsers (signature texts only). `\N{...}` string escapes use the default
|
|
318
|
+
`unicode-names` feature; `--no-default-features --features wasm` builds a
|
|
319
|
+
smaller WASM file without it.
|
|
320
|
+
|
|
321
|
+
### VS Code
|
|
322
|
+
|
|
323
|
+
```bash
|
|
324
|
+
pip install -e ".[lsp]"
|
|
325
|
+
cd editors/vscode && npm install
|
|
326
|
+
ln -s "$(pwd)" ~/.vscode/extensions/kir-language
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
Settings `kir.server.path`, `kir.server.args` and `kir.sigPath` choose the
|
|
330
|
+
server command and the signature directories ([editors/vscode](editors/vscode/README.md)).
|
|
331
|
+
|
|
332
|
+
### Example node editor
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
pip install fastapi uvicorn
|
|
336
|
+
cd apps/kir-editor/backend && python -m uvicorn kir_editor.app:app --port 48888
|
|
337
|
+
cd apps/kir-editor/frontend && npm install && npm run dev # http://localhost:5173
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Five views of one program: nodes (ComfyUI / Blender / UE style, with data as
|
|
341
|
+
variables or wires and control as exec wires or frames), a classic ROBO Pro
|
|
342
|
+
flowchart, an EV3-style sequence, Scratch blocks, and text; any two side by
|
|
343
|
+
side. A palette built from signature files, an inspector, undo / redo, and
|
|
344
|
+
Problems / Run / Lowered panels with per-pass toggles
|
|
345
|
+
([apps/kir-editor](apps/kir-editor/README.md)).
|
|
346
|
+
|
|
347
|
+
## Python API
|
|
348
|
+
|
|
349
|
+
```python
|
|
350
|
+
from kohakunode import (
|
|
351
|
+
parse, write, # text <-> AST; parse(write(p)) == p
|
|
352
|
+
check, # diagnostics
|
|
353
|
+
compile_source, compile_file, # env + check + passes + hashes in one call
|
|
354
|
+
Interpreter, # the sequential reference run, with a call hook
|
|
355
|
+
NodeLibrary, # the node registry
|
|
356
|
+
)
|
|
357
|
+
from kohakunode.graph import to_graph, from_graph # graph view
|
|
358
|
+
from kohakunode.comfyui import from_comfyui, to_api # ComfyUI
|
|
359
|
+
from kohakunode.lower import PASSES, run_passes # individual passes
|
|
360
|
+
|
|
361
|
+
compiled = compile_source(text, [lib], passes=["order_dataflow", "expand_each"])
|
|
362
|
+
compiled.program # the checked program as written
|
|
363
|
+
compiled.lowered # after the chosen passes (all of them when passes=None)
|
|
364
|
+
compiled.diagnostics # warnings; errors raise KirCheckError
|
|
365
|
+
compiled.semantic_hash, compiled.full_hash
|
|
366
|
+
|
|
367
|
+
graph = to_graph(compiled.program, compiled.env) # .kirgraph dict
|
|
368
|
+
text = write(from_graph(graph, with_meta=False)) # canonical text
|
|
369
|
+
|
|
370
|
+
def replay(name, inputs, call): # a machine's recorded results
|
|
371
|
+
return recorded[(name, key(inputs))]
|
|
372
|
+
|
|
373
|
+
Interpreter(compiled.lowered, compiled.env, hook=replay).run()
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
## Codebase map
|
|
377
|
+
|
|
378
|
+
```text
|
|
379
|
+
src/kohakunode/
|
|
380
|
+
syntax/ kir.lark grammar, parser, AST, canonical writer
|
|
381
|
+
sig/ NodeLibrary, .kirsig.json files, @use resolution, types, kir.std
|
|
382
|
+
flow/ control-flow graph, reaching definitions, dataflow ordering
|
|
383
|
+
check/ every rule of docs/spec/checks.md
|
|
384
|
+
lower/ the optimization passes and program hashes
|
|
385
|
+
run/ the sequential reference interpreter
|
|
386
|
+
graph/ text <-> graph view
|
|
387
|
+
comfyui/ ComfyUI workflow / API prompt import and export
|
|
388
|
+
lsp/ the language server (kir-lsp)
|
|
389
|
+
cli/ the kir command
|
|
390
|
+
compiler.py compile_source / compile_program / compile_file
|
|
391
|
+
rust/ the Rust core, PyO3 and WASM bindings
|
|
392
|
+
editors/ tree-sitter-kir, vscode
|
|
393
|
+
apps/ kir-editor (example node editor)
|
|
394
|
+
examples/ basics (v1 programs), tour (one file per feature), gbc, comfyui
|
|
395
|
+
tests/ unit tests, the v1 reference corpus, the golden corpus
|
|
396
|
+
docs/ spec/, guides/, architecture.md, plan/
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
## Documentation map
|
|
400
|
+
|
|
401
|
+
### Specification
|
|
402
|
+
[Overview](docs/spec/README.md) · [Language](docs/spec/language.md) · [Semantics](docs/spec/semantics.md) · [Signatures and `@use`](docs/spec/signatures.md) · [Graph view](docs/spec/graph.md) · [Optimization passes](docs/spec/passes.md) · [Checks](docs/spec/checks.md)
|
|
403
|
+
|
|
404
|
+
### Guides
|
|
405
|
+
[Writing nodes](docs/guides/writing-nodes.md) · [Running KIR on a machine](docs/guides/machines.md) · [Examples](examples/README.md)
|
|
406
|
+
|
|
407
|
+
### Internals
|
|
408
|
+
[Architecture](docs/architecture.md) · [v2 work plan](docs/plan/v2.md)
|
|
409
|
+
|
|
410
|
+
## Testing
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
pytest # the Python reference: unit tests, golden corpus, v1 parity, generated programs
|
|
414
|
+
cd rust && cargo test # the Rust core against the same golden corpus
|
|
415
|
+
cd apps/kir-editor/frontend && npm run test:e2e # one browser smoke run of the example editor
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
The golden corpus (`tests/corpus/golden`) holds the canonical text, the fully
|
|
419
|
+
optimized text, the graph view and the hashes of every case; the Python
|
|
420
|
+
reference and the Rust core must both reproduce it byte for byte. The v1
|
|
421
|
+
corpus (`tests/corpus/v1`) records what the v1 implementation printed for
|
|
422
|
+
every v1 program; v2 reproduces it except for listed, deliberate differences.
|
|
423
|
+
|
|
424
|
+
## Releases
|
|
425
|
+
|
|
426
|
+
`kohakunode` is one wheel: the Python reference plus the Rust core as the
|
|
427
|
+
extension module `kohakunode._rs`. The version is `rust/Cargo.toml`'s
|
|
428
|
+
(`pyproject.toml` reads it dynamically). Publishing a GitHub release, or
|
|
429
|
+
pushing a `v*` tag, runs `release.yml`: wheels for CPython 3.10–3.14 on Linux
|
|
430
|
+
x86_64 / aarch64 (manylinux 2_28), Windows x64 and macOS arm64, Android wheels
|
|
431
|
+
(arm64, x86_64; Python 3.13) and the sdist, all uploaded to PyPI and to the
|
|
432
|
+
GitHub release.
|
|
433
|
+
|
|
434
|
+
## Coming from v1
|
|
435
|
+
|
|
436
|
+
v2 keeps v1's model (sequential meaning, namespaces entered by builtins,
|
|
437
|
+
`jump` loops, `@dataflow:`, `@def`) and every program v1 parsed still parses. New:
|
|
438
|
+
`@use`, `each`, `@try` / `@except err`, typed `@def` parameters and outputs,
|
|
439
|
+
`@hint`, node flags, the graph view with control ports, and optimization
|
|
440
|
+
passes in place of fixed levels. The v1 implementation is in the git history
|
|
441
|
+
(commit `1abda17`).
|
|
442
|
+
|
|
443
|
+
## License
|
|
444
|
+
|
|
445
|
+
[Apache-2.0](LICENSE)
|
|
446
|
+
|
|
447
|
+
Copyright 2026 Shih-Ying Yeh (KohakuBlueLeaf) and contributors.
|
|
448
|
+
|
|
449
|
+
## Community
|
|
450
|
+
|
|
451
|
+
- Discord: https://discord.gg/xWYrkyvJ2s
|
|
452
|
+
- Issues: https://github.com/KohakuBlueleaf/KohakuNodeIR/issues
|
|
453
|
+
|
|
454
|
+
## FAQ
|
|
455
|
+
|
|
456
|
+
**Does a program have to say what runs in parallel?**
|
|
457
|
+
No. A job means its sequential run, and an executor may overlap anything the
|
|
458
|
+
wires, the control path and node flags allow. `parallel` states intent only.
|
|
459
|
+
|
|
460
|
+
**Why is there no expression syntax?**
|
|
461
|
+
Every computation is a node, so the graph and the text stay the same thing.
|
|
462
|
+
`kir.std` provides the small pure nodes most programs need (`add`, `less`,
|
|
463
|
+
`len`, `append`, `to_str`, ...).
|
|
464
|
+
|
|
465
|
+
**What does an executor need besides the text?**
|
|
466
|
+
Implementations of the nodes the program calls. Signature files describe them
|
|
467
|
+
to tools; executors map node names to implementations themselves.
|
|
468
|
+
|
|
469
|
+
**How do I know a machine computed the right thing?**
|
|
470
|
+
Run sample jobs on the machine and on the reference interpreter with a call
|
|
471
|
+
hook that replays the machine's node results, then compare final values
|
|
472
|
+
([machines.md](docs/guides/machines.md)).
|
|
473
|
+
|
|
474
|
+
**Which pass output should a machine run?**
|
|
475
|
+
Its choice. The fully optimized program is the simplest to schedule; a machine
|
|
476
|
+
that schedules `each` itself can stop before `expand_each`. Every form means
|
|
477
|
+
the same thing.
|
|
478
|
+
|