Semantic Graph PoC 0.1
Goal
Test whether a program can be automatically lowered from source syntax into a new symbolic/graph representation, then executed from that representation without reading the original source again.
Experiment A — control flow
Original behavior contains arithmetic, an intermediate local value, a conditional branch, and two returns.
Pipeline:
Python source
-> Python AST
-> anonymous slots + semantic operation nodes + branch blocks
-> JSON semantic graph
-> graph-only runtime
Test vectors: 6 All matched: True
作者: Neo.K
機構: EveMissLab/一言諾科技有限公司
日期: 2026-10-08(整理日期;原稿未標註日期)
版本: 0.1
Experiment B — real RepoLumen function
Target: repo_semantic/historical_timeline.py::_transition_id
Original semantic behavior:
two ordered inputs
-> concatenate with NUL separator
-> UTF-8 encode
-> SHA-256
-> hexadecimal digest
-> first 24 characters
-> prefix with `hist_`
Automatically produced semantic ops:
arg -> to_str -> const -> arg -> to_str -> concat_many -> utf8_encode -> const -> slot -> sha256 -> hex_digest -> const -> slice -> add
Test vectors: 5 All matched: True
Source-language decoupling check
The canonical graph deliberately removes local/source identifiers.
{
"branch_graph_contains_original_var_x": false,
"branch_graph_contains_original_var_y": false,
"branch_graph_contains_original_var_base": false,
"transition_graph_contains_from_snapshot_id": false,
"transition_graph_contains_to_snapshot_id": false,
"transition_graph_contains_hashlib_name": false,
"transition_graph_contains_hexdigest_name": false,
"transition_graph_contains_encode_name": false
}
All values above should be false.
The graph retains only:
- ordered argument positions;
- anonymous local slots;
- constants that affect behavior;
- semantic operations;
- control-flow structure.
Graph-only process
A separate script, runtime_only.py, loads only the JSON graphs and the generic semantic runtime.
It does not contain the original functions.
Observed output:
branch graph: 10
RepoLumen transition graph: hist_4aa9461975c271a428d60476
Result
Within the supported subset, the experiment establishes:
- source syntax is not required after lowering;
- original variable names are not required;
- a program can be represented as typed semantic nodes plus control-flow structure;
- the same graph can be executed by a generic graph runtime;
- a real RepoLumen function can be canonicalized from source-specific spellings such as
.encode("utf-8"),hashlib.sha256(...), and.hexdigest()intoutf8_encode,sha256, andhex_digestsemantic operations.
This is not yet a proof that arbitrary Python or arbitrary binaries can be losslessly lifted. The difficult next layers are mutation/aliasing, exceptions, generators/coroutines, dynamic dispatch, reflection, external effects, concurrency, C/ABI memory, and runtime-generated code.
Files
semantic_ir.py— compiler + graph runtimeexperiment.py— compiler/equivalence experimentruntime_only.py— graph-only executiongraph_branch.json— control-flow graph representationgraph_repolumen_transition.json— RepoLumen function semantic graphrun_results.json— equivalence results
Stronger isolation / property test
A physically separate runtime directory contains only:
- graph_branch.json
- graph_repolumen_transition.json
- graph_runtime.py
- isolated_runtime_only.py
It contains no compiler and no original function source.
Isolated execution result:
10
hist_4aa9461975c271a428d60476
Random equivalence testing:
- arithmetic/control-flow graph: 10,000 / 10,000 matched
- RepoLumen
_transition_idgraph: 1,000 / 1,000 matched - compiler/source present in isolated runtime directory: False
Therefore the semantic representation remains operationally executable after the source-language compiler and original source are absent.