graflang 0.1.0__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.
- graflang-0.1.0/LICENSE +202 -0
- graflang-0.1.0/PKG-INFO +274 -0
- graflang-0.1.0/README.md +228 -0
- graflang-0.1.0/graflang.egg-info/PKG-INFO +274 -0
- graflang-0.1.0/graflang.egg-info/SOURCES.txt +83 -0
- graflang-0.1.0/graflang.egg-info/dependency_links.txt +1 -0
- graflang-0.1.0/graflang.egg-info/entry_points.txt +2 -0
- graflang-0.1.0/graflang.egg-info/requires.txt +30 -0
- graflang-0.1.0/graflang.egg-info/top_level.txt +1 -0
- graflang-0.1.0/graphlang/__init__.py +0 -0
- graflang-0.1.0/graphlang/__main__.py +4 -0
- graflang-0.1.0/graphlang/cli.py +28 -0
- graflang-0.1.0/graphlang/formats.py +26 -0
- graflang-0.1.0/graphlang/grafc/__init__.py +6 -0
- graflang-0.1.0/graphlang/grafc/analyzer.py +87 -0
- graflang-0.1.0/graphlang/grafc/cedar/__init__.py +0 -0
- graflang-0.1.0/graphlang/grafc/cedar/ast_nodes.py +192 -0
- graflang-0.1.0/graphlang/grafc/cedar/compiler.py +198 -0
- graflang-0.1.0/graphlang/grafc/cedar/composer.py +178 -0
- graflang-0.1.0/graphlang/grafc/cedar/errors.py +35 -0
- graflang-0.1.0/graphlang/grafc/cedar/lexer.py +145 -0
- graflang-0.1.0/graphlang/grafc/cedar/parser.py +388 -0
- graflang-0.1.0/graphlang/grafc/cedar/printer.py +139 -0
- graflang-0.1.0/graphlang/grafc/cedar/slicer.py +94 -0
- graflang-0.1.0/graphlang/grafc/cedar/tokens.py +100 -0
- graflang-0.1.0/graphlang/grafc/cedar/type_checker.py +161 -0
- graflang-0.1.0/graphlang/grafc/cedar_compiler.py +19 -0
- graflang-0.1.0/graphlang/grafc/cli.py +104 -0
- graflang-0.1.0/graphlang/grafc/compiler.py +138 -0
- graflang-0.1.0/graphlang/grafc/optimizer.py +43 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/__init__.py +0 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/codegen.py +205 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/templates/Cargo.toml.j2 +12 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/templates/cache.rs.j2 +159 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/templates/main.rs.j2 +25 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/templates/nodes.rs.j2 +14 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/templates/policies.rs.j2 +22 -0
- graflang-0.1.0/graphlang/grafc/rust_gen/templates/workflow.rs.j2 +43 -0
- graflang-0.1.0/graphlang/grafc/visualizer.py +180 -0
- graflang-0.1.0/graphlang/grafr/__init__.py +6 -0
- graflang-0.1.0/graphlang/grafr/adapters.py +97 -0
- graflang-0.1.0/graphlang/grafr/cedar_guard.py +69 -0
- graflang-0.1.0/graphlang/grafr/cli.py +182 -0
- graflang-0.1.0/graphlang/grafr/expr.py +182 -0
- graflang-0.1.0/graphlang/grafr/nodes/__init__.py +40 -0
- graflang-0.1.0/graphlang/grafr/nodes/base.py +11 -0
- graflang-0.1.0/graphlang/grafr/nodes/context.py +26 -0
- graflang-0.1.0/graphlang/grafr/nodes/evaluate.py +20 -0
- graflang-0.1.0/graphlang/grafr/nodes/generate.py +42 -0
- graflang-0.1.0/graphlang/grafr/nodes/guard.py +47 -0
- graflang-0.1.0/graphlang/grafr/nodes/loop.py +10 -0
- graflang-0.1.0/graphlang/grafr/nodes/mutate.py +10 -0
- graflang-0.1.0/graphlang/grafr/nodes/solve.py +41 -0
- graflang-0.1.0/graphlang/grafr/output.py +79 -0
- graflang-0.1.0/graphlang/grafr/procedures.py +170 -0
- graflang-0.1.0/graphlang/grafr/resolver.py +47 -0
- graflang-0.1.0/graphlang/grafr/runtime.py +550 -0
- graflang-0.1.0/graphlang/grafr/topology.py +167 -0
- graflang-0.1.0/graphlang/grafv/__init__.py +1 -0
- graflang-0.1.0/graphlang/grafv/cli.py +52 -0
- graflang-0.1.0/graphlang/grafv/engines.py +73 -0
- graflang-0.1.0/graphlang/grafv/model.py +77 -0
- graflang-0.1.0/graphlang/logging_config.py +41 -0
- graflang-0.1.0/graphlang/policies/graph_safety.cedar +25 -0
- graflang-0.1.0/graphlang/policies/mutation_safety.cedar +137 -0
- graflang-0.1.0/graphlang/schema/graflang-ir.json +86 -0
- graflang-0.1.0/graphlang/schema/graph_delta.schema.json +64 -0
- graflang-0.1.0/pyproject.toml +61 -0
- graflang-0.1.0/setup.cfg +4 -0
- graflang-0.1.0/tests/test_cedar_compiler.py +125 -0
- graflang-0.1.0/tests/test_cli_alias.py +37 -0
- graflang-0.1.0/tests/test_formats.py +82 -0
- graflang-0.1.0/tests/test_grafr_adapters.py +102 -0
- graflang-0.1.0/tests/test_grafr_expr.py +90 -0
- graflang-0.1.0/tests/test_grafr_llm_flag.py +58 -0
- graflang-0.1.0/tests/test_grafr_logging.py +128 -0
- graflang-0.1.0/tests/test_grafr_loop.py +236 -0
- graflang-0.1.0/tests/test_grafr_mutate.py +286 -0
- graflang-0.1.0/tests/test_grafr_output.py +132 -0
- graflang-0.1.0/tests/test_grafr_procedures.py +89 -0
- graflang-0.1.0/tests/test_grafr_runtime.py +191 -0
- graflang-0.1.0/tests/test_grafv.py +247 -0
- graflang-0.1.0/tests/test_install_light.py +25 -0
- graflang-0.1.0/tests/test_policy_slicer.py +145 -0
- graflang-0.1.0/tests/test_topology.py +77 -0
graflang-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
graflang-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: graflang
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: GraphLang: a physics-inspired, topologically grounded language for self-revising agentic workflows (one command line: `graf`)
|
|
5
|
+
Author: Wen Gong
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/digital-duck/graflang
|
|
8
|
+
Project-URL: Repository, https://github.com/digital-duck/graflang
|
|
9
|
+
Project-URL: Issues, https://github.com/digital-duck/graflang/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/digital-duck/graflang/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: graph-lang,agentic-ai,interaction-nets,topology,llm,cedar
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Software Development :: Interpreters
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: click>=8.1
|
|
23
|
+
Requires-Dist: ruamel.yaml>=0.18
|
|
24
|
+
Requires-Dist: networkx>=3.2
|
|
25
|
+
Requires-Dist: jsonschema>=4.20
|
|
26
|
+
Requires-Dist: cedarpy>=4.8
|
|
27
|
+
Requires-Dist: dd-llm[openai]>=0.2.0
|
|
28
|
+
Requires-Dist: rich>=13.7
|
|
29
|
+
Requires-Dist: dd-logging>=0.2.0
|
|
30
|
+
Requires-Dist: zinet>=0.2.0
|
|
31
|
+
Provides-Extra: spl
|
|
32
|
+
Requires-Dist: spl-llm>=3.4; extra == "spl"
|
|
33
|
+
Provides-Extra: anthropic
|
|
34
|
+
Requires-Dist: dd-llm[anthropic]>=0.2.0; extra == "anthropic"
|
|
35
|
+
Provides-Extra: gemini
|
|
36
|
+
Requires-Dist: dd-llm[gemini]>=0.2.0; extra == "gemini"
|
|
37
|
+
Provides-Extra: vis
|
|
38
|
+
Requires-Dist: zinet[pyvis]>=0.2.0; extra == "vis"
|
|
39
|
+
Provides-Extra: graphify
|
|
40
|
+
Requires-Dist: zinet[graphify]>=0.2.0; extra == "graphify"
|
|
41
|
+
Provides-Extra: grafc
|
|
42
|
+
Requires-Dist: jinja2>=3.1; extra == "grafc"
|
|
43
|
+
Provides-Extra: dev
|
|
44
|
+
Requires-Dist: pytest>=7.4; extra == "dev"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
# GraphLang
|
|
48
|
+
|
|
49
|
+
**A physics-inspired, topologically grounded language for self-revising agentic workflows.**
|
|
50
|
+
|
|
51
|
+
GraphLang flips the script on agentic AI. Where LangGraph and AutoGen use Python code to *describe* a graph, GraphLang treats the graph as the **primary, executable source of truth**. The topology is the program. The LLM doesn't write code — it mutates the graph.
|
|
52
|
+
|
|
53
|
+
> **Status:** Early prototype. Private development repository.
|
|
54
|
+
> **Companion:** [SPL.py](https://github.com/digital-duck/SPL.py) — the declarative workflow language that GraphLang elevates.
|
|
55
|
+
> **Paper:** *GraphLang: A Physics-Inspired, Topologically Grounded Language for Self-Revising Agentic Workflows* (in preparation; no draft in this repository yet)
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## The Paradigm Shift
|
|
60
|
+
|
|
61
|
+
| | Imperative Frameworks (LangGraph, AutoGen) | GraphLang |
|
|
62
|
+
|---|---|---|
|
|
63
|
+
| **Source of truth** | Python code that describes a graph | The graph itself |
|
|
64
|
+
| **LLM's role** | Generate text/code | Mutate the topology |
|
|
65
|
+
| **Parallelism** | `asyncio.gather` + race conditions | Interaction Nets (confluent for the deterministic core; LLM-sampling nodes and `LOOP` are not) |
|
|
66
|
+
| **Safety** | Scattered `if/else` guardrails | Declarative Cedar policies, enforced at runtime (Rust compilation planned) |
|
|
67
|
+
| **Self-revision** | Rewrite the Python file | Output a validated graph delta |
|
|
68
|
+
| **Visualization** | Lossy Mermaid translation | First-class, interactive topology |
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Two graph formats, one family
|
|
73
|
+
|
|
74
|
+
GraphLang workflows live in `*.graph.yaml` and are run, checked, compiled and drawn by the one command `graf`. They are not
|
|
75
|
+
[zinet](https://github.com/digital-duck/zinet) graphs: zinet stores a *static* dependency graph (`primitives:`, `concepts:`,
|
|
76
|
+
`applications:`), while a workflow is *executable* (typed nodes with ports, `triggers` and `binds` edges, loops and retries,
|
|
77
|
+
Cedar policies). Both are plain YAML that persists a graph, and the file name is only a convention, so `graf` tells the files
|
|
78
|
+
apart by content (`workflow:` with `nodes:` and `edges:` is a workflow) and says what a zinet or ConceptBook file is instead of
|
|
79
|
+
failing on a schema error. The two share graph code: `graf vis` draws through zinet's engines (`zinet.vis`).
|
|
80
|
+
|
|
81
|
+
## Core Innovations
|
|
82
|
+
|
|
83
|
+
### 1. Physics-Inspired Execution
|
|
84
|
+
GraphLang is grounded in **Lafont's Interaction Nets** — a mathematically proven model for deterministic, concurrent graph rewriting. Computation occurs via local rewrite rules when agents interact:
|
|
85
|
+
|
|
86
|
+
- **`GENERATE`** — probabilistic agents (LLM calls)
|
|
87
|
+
- **`SOLVE` / `ASSERT`** — deterministic agents (SymPy, Lean, Python eval)
|
|
88
|
+
- **`FORK` / `JOIN`** — explicit fan-out and barrier (parallelism without race conditions)
|
|
89
|
+
- **`LOOP`** — cyclic control flow (test-gated retry)
|
|
90
|
+
- **`MUTATE`** — the self-revising operator (LLM outputs validated graph deltas)
|
|
91
|
+
- **`GUARD`** — policy checkpoints backed by Cedar
|
|
92
|
+
|
|
93
|
+
### 2. Three-Tier Composition
|
|
94
|
+
Keep the topology clean while preserving the full expressive power of SPL:
|
|
95
|
+
|
|
96
|
+
- **Tier 1 (Inline):** Tiny prompts and expressions directly in the YAML
|
|
97
|
+
- **Tier 2 (Reference):** External `.spl` procedures, `.md` prompts, `.cedar` policies
|
|
98
|
+
- **Tier 3 (Sub-graph):** Composite nodes — a graph within a graph (e.g., a `LOOP` node encapsulating a 5-step internal topology)
|
|
99
|
+
|
|
100
|
+
### 3. Policy-Grounded Safety
|
|
101
|
+
Safety isn't an afterthought. [Cedar](https://www.cedarpolicy.com/) policies are first-class topological constructs (`GUARD` nodes) that are:
|
|
102
|
+
- Evaluated at runtime by `grafr` (dynamic, hot-reloadable)
|
|
103
|
+
- Planned: compiled to zero-cost Rust `match` statements by `grafc` (deployment; `grafc` is still a stub)
|
|
104
|
+
|
|
105
|
+
The LLM can propose mutations, but only those that pass the Cedar policy check are applied.
|
|
106
|
+
|
|
107
|
+
### 4. Compilation to Rust (Downstream)
|
|
108
|
+
**Planned; `grafc` is currently a stub.** `grafc` is meant to compile the Graph IR + Cedar policies into a memory-safe, high-performance Rust binary. This is a **downstream deployment optimization**, not the core innovation. The innovation is the topological execution model itself.
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## Quick Start
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Install the dynamic interpreter (development)
|
|
116
|
+
pip install -e ".[dev]" # `claude_cli`, `ollama`, `openai`, `openrouter` work as is; `.[anthropic]`, `.[gemini]` add SDKs
|
|
117
|
+
|
|
118
|
+
# Run a workflow (default adapter is `claude_cli`; `--adapter mock` calls no LLM)
|
|
119
|
+
graf run cookbook/code_pipeline/code_pipeline.graph.yaml \
|
|
120
|
+
--adapter ollama \
|
|
121
|
+
--param spec="Write a binary search function"
|
|
122
|
+
|
|
123
|
+
# Compile to Rust (deployment; planned, grafc is a stub)
|
|
124
|
+
# Cedar policies are referenced from the graph's `resources.policies` block
|
|
125
|
+
# (shared policies live in graphlang/policies/).
|
|
126
|
+
graf compile cookbook/code_pipeline/code_pipeline.graph.yaml \
|
|
127
|
+
--target rust \
|
|
128
|
+
-o code_pipeline
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## The Flagship Example: `code_pipeline.graph.yaml`
|
|
134
|
+
|
|
135
|
+
A neurosymbolic, self-revising code generation pipeline. This single file demonstrates the entire paradigm:
|
|
136
|
+
|
|
137
|
+
```yaml
|
|
138
|
+
version: "1.0-graph"
|
|
139
|
+
|
|
140
|
+
workflow:
|
|
141
|
+
name: "code_pipeline"
|
|
142
|
+
inputs:
|
|
143
|
+
- {name: "spec", type: "TEXT"}
|
|
144
|
+
- {name: "max_cycles", type: "INTEGER", default: 3}
|
|
145
|
+
outputs:
|
|
146
|
+
- {name: "docs", type: "TEXT"}
|
|
147
|
+
|
|
148
|
+
resources:
|
|
149
|
+
procedures:
|
|
150
|
+
analyze_spec: "./00_analyze_spec.spl"
|
|
151
|
+
generate_code: "./01_generate_code.spl"
|
|
152
|
+
review_code: "./02_review_code.spl"
|
|
153
|
+
test_code: "./04_test_code.spl"
|
|
154
|
+
# ... (8 procedures in the full file, 00-07)
|
|
155
|
+
policies:
|
|
156
|
+
mutation_safety: "../../graphlang/policies/mutation_safety.cedar"
|
|
157
|
+
|
|
158
|
+
nodes:
|
|
159
|
+
- id: "analyze"
|
|
160
|
+
type: "GENERATE"
|
|
161
|
+
config: {procedure_ref: "procedures.analyze_spec"}
|
|
162
|
+
ports: ["trigger", "complete", "in_spec", "out_analysis"]
|
|
163
|
+
|
|
164
|
+
- id: "spec_gate"
|
|
165
|
+
type: "EVALUATE"
|
|
166
|
+
config: {condition: "contains(@in_analysis, '[READY]')"} # @in_analysis is this node's own in_* port, fed by a `binds` edge
|
|
167
|
+
ports: ["trigger", "pass", "fail", "in_analysis"]
|
|
168
|
+
|
|
169
|
+
- id: "test_gated_loop"
|
|
170
|
+
type: "LOOP"
|
|
171
|
+
config:
|
|
172
|
+
# @in_max_cycles is a LOOP input port; @test_passed and @cycle are loop state
|
|
173
|
+
# (the previous iteration's outputs and the 0-based counter), not declared ports.
|
|
174
|
+
condition: "NOT @test_passed AND @cycle < @in_max_cycles"
|
|
175
|
+
subgraph:
|
|
176
|
+
nodes:
|
|
177
|
+
- {id: "gen", type: "GENERATE", config: {procedure_ref: "procedures.generate_code"}}
|
|
178
|
+
- {id: "rev", type: "GENERATE", config: {procedure_ref: "procedures.review_code"}}
|
|
179
|
+
- {id: "test", type: "SOLVE", config: {procedure_ref: "procedures.test_code"}}
|
|
180
|
+
- {id: "guard", type: "GUARD", config: {policy_ref: "policies.mutation_safety"}}
|
|
181
|
+
edges:
|
|
182
|
+
- {source: "gen.complete", target: "rev.trigger", type: "triggers"}
|
|
183
|
+
- {source: "rev.complete", target: "test.trigger", type: "triggers"}
|
|
184
|
+
- {source: "test.complete", target: "guard.trigger", type: "triggers"}
|
|
185
|
+
- {source: "guard.allow", target: "gen.trigger", type: "triggers"} # Safe retry
|
|
186
|
+
ports: ["trigger", "loop", "exit", "in_spec", "out_final_code"]
|
|
187
|
+
|
|
188
|
+
edges:
|
|
189
|
+
- {source: "analyze.complete", target: "spec_gate.trigger", type: "triggers"}
|
|
190
|
+
- {source: "analyze.out_analysis", target: "spec_gate.in_analysis", type: "binds"}
|
|
191
|
+
- {source: "spec_gate.pass", target: "test_gated_loop.trigger", type: "triggers"}
|
|
192
|
+
# ... (full file in cookbook/code_pipeline/)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**What makes this revolutionary:**
|
|
196
|
+
- The `LOOP` node is a **Tier 3 composite** — click it in the UI to see the internal 4-step topology
|
|
197
|
+
- The `GUARD` node enforces Cedar policies before allowing a retry
|
|
198
|
+
- The closure check (spec → code → spec' → judge) is a clean topological branch, not buried in `if/else`
|
|
199
|
+
- The LLM can propose mutations via `MUTATE` nodes, but only those passing Cedar are applied
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## Architecture
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
207
|
+
│ GraphLang Toolchain │
|
|
208
|
+
├─────────────────────────────────────────────────────────────┤
|
|
209
|
+
│ │
|
|
210
|
+
│ Source IR Runtime Deployment │
|
|
211
|
+
│ ────── ── ─────── ────────── │
|
|
212
|
+
│ │
|
|
213
|
+
│ *.graph.yaml ──► grafr ──► NetworkX/Python (dev) │
|
|
214
|
+
│ │ │
|
|
215
|
+
│ └──► grafc ──► Rust binary (prod) │
|
|
216
|
+
│ │
|
|
217
|
+
│ *.cedar ─────────┘ (compiled inline to Rust match) │
|
|
218
|
+
│ *.spl ───────────┘ (Tier 2 procedure references) │
|
|
219
|
+
│ │
|
|
220
|
+
└─────────────────────────────────────────────────────────────┘
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Relationship to SPL.py
|
|
226
|
+
|
|
227
|
+
[**SPL.py**](https://github.com/digital-duck/SPL.py) is the declarative workflow language that GraphLang elevates. SPL provides:
|
|
228
|
+
|
|
229
|
+
- The `GENERATE` / `EVALUATE` (probabilistic) and `SOLVE` / `ASSERT` (deterministic) vocabulary
|
|
230
|
+
- The 78-recipe cookbook and its empirical validation
|
|
231
|
+
- The neurosymbolic verifier ladder (SymPy → SageMath → Lean 4)
|
|
232
|
+
- The LLM adapters (Ollama, Claude, OpenAI, Momagrid, etc.)
|
|
233
|
+
|
|
234
|
+
GraphLang takes SPL's proven semantics and gives them a **topological execution model**. SPL workflows can be automatically ported to GraphLang via the `spl2graph` transpiler.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Roadmap
|
|
239
|
+
|
|
240
|
+
- [x] Core vocabulary design (physics-inspired, pruned from SPL)
|
|
241
|
+
- [x] JSON Schema for Graph IR (3-tier composition)
|
|
242
|
+
- [x] Cedar integration in `grafr` (`GUARD` and `MUTATE` checks via `cedarpy`)
|
|
243
|
+
- [x] Flagship example (`code_pipeline.graph.yaml`)
|
|
244
|
+
- [x] `grafr` Python interpreter (NetworkX-based topological executor)
|
|
245
|
+
- [ ] `grafc` Rust compiler (Graph IR + Cedar → Rust AST)
|
|
246
|
+
- [x] `graf vis`: read a workflow as a graph (control flow first, data edges on demand, loops that collapse to one box)
|
|
247
|
+
- [ ] Visual IDE: author and edit a workflow in the graph view (add and connect nodes and ports, edit their config, validate while you edit, write the `*.graph.yaml` with its comments kept, run from the view). Planned; the plan is in zinet's `docs/DEV/readme-todo.md`.
|
|
248
|
+
- [ ] Interactive Streamlit UI (drill-down visualization of Tier 3 composites)
|
|
249
|
+
- [ ] `spl2graph` transpiler (port all 78 SPL recipes)
|
|
250
|
+
- [ ] Paper submission (NeurIPS / ICLR)
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
Apache 2.0. See [LICENSE](./LICENSE).
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Citation
|
|
261
|
+
|
|
262
|
+
```bibtex
|
|
263
|
+
@misc{gong2026graflang,
|
|
264
|
+
title={GraphLang: A Physics-Inspired, Topologically Grounded Language for Self-Revising Agentic Workflows},
|
|
265
|
+
author={Gong, Wen},
|
|
266
|
+
year={2026},
|
|
267
|
+
howpublished={\url{https://github.com/digital-duck/graflang}},
|
|
268
|
+
note={Forthcoming paper}
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
> *"The graph is not a byproduct of the code. The graph **is** the code."*
|