operon-langgraph-gates 0.1.0a1__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.
Files changed (30) hide show
  1. operon_langgraph_gates-0.1.0a1/.github/workflows/ci.yml +41 -0
  2. operon_langgraph_gates-0.1.0a1/.github/workflows/publish.yml +35 -0
  3. operon_langgraph_gates-0.1.0a1/.gitignore +35 -0
  4. operon_langgraph_gates-0.1.0a1/LICENSE +21 -0
  5. operon_langgraph_gates-0.1.0a1/PKG-INFO +105 -0
  6. operon_langgraph_gates-0.1.0a1/README.md +70 -0
  7. operon_langgraph_gates-0.1.0a1/docs/paper-citations.md +155 -0
  8. operon_langgraph_gates-0.1.0a1/examples/01_stagnation_breaks_loop.ipynb +243 -0
  9. operon_langgraph_gates-0.1.0a1/examples/02_integrity_catches_drift.ipynb +269 -0
  10. operon_langgraph_gates-0.1.0a1/huggingface/space-stagnation-gate/.gitignore +6 -0
  11. operon_langgraph_gates-0.1.0a1/huggingface/space-stagnation-gate/README.md +21 -0
  12. operon_langgraph_gates-0.1.0a1/huggingface/space-stagnation-gate/app.py +324 -0
  13. operon_langgraph_gates-0.1.0a1/huggingface/space-stagnation-gate/requirements.txt +9 -0
  14. operon_langgraph_gates-0.1.0a1/huggingface/space-stagnation-gate/scenarios.py +120 -0
  15. operon_langgraph_gates-0.1.0a1/pyproject.toml +78 -0
  16. operon_langgraph_gates-0.1.0a1/scripts/build_examples.py +454 -0
  17. operon_langgraph_gates-0.1.0a1/src/operon_langgraph_gates/__init__.py +20 -0
  18. operon_langgraph_gates-0.1.0a1/src/operon_langgraph_gates/_common.py +79 -0
  19. operon_langgraph_gates-0.1.0a1/src/operon_langgraph_gates/embedders.py +65 -0
  20. operon_langgraph_gates-0.1.0a1/src/operon_langgraph_gates/integrity.py +229 -0
  21. operon_langgraph_gates-0.1.0a1/src/operon_langgraph_gates/py.typed +0 -0
  22. operon_langgraph_gates-0.1.0a1/src/operon_langgraph_gates/stagnation.py +279 -0
  23. operon_langgraph_gates-0.1.0a1/tests/__init__.py +0 -0
  24. operon_langgraph_gates-0.1.0a1/tests/integration/__init__.py +0 -0
  25. operon_langgraph_gates-0.1.0a1/tests/integration/test_loop_break.py +97 -0
  26. operon_langgraph_gates-0.1.0a1/tests/test_build_examples.py +217 -0
  27. operon_langgraph_gates-0.1.0a1/tests/test_integrity_gate.py +130 -0
  28. operon_langgraph_gates-0.1.0a1/tests/test_ngram_embedder.py +68 -0
  29. operon_langgraph_gates-0.1.0a1/tests/test_space_scenarios.py +89 -0
  30. operon_langgraph_gates-0.1.0a1/tests/test_stagnation_gate.py +332 -0
@@ -0,0 +1,41 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ python-version: ["3.11", "3.13"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v5
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v6
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+ cache: pip
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install -e ".[dev]"
30
+
31
+ - name: Lint (ruff)
32
+ run: ruff check src tests
33
+
34
+ - name: Format check (ruff)
35
+ run: ruff format --check src tests
36
+
37
+ - name: Type check (mypy)
38
+ run: mypy src
39
+
40
+ - name: Test (pytest)
41
+ run: pytest -v
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish:
9
+ runs-on: ubuntu-latest
10
+ permissions:
11
+ # Explicit ``permissions`` replaces the default GITHUB_TOKEN scopes
12
+ # wholesale, so we have to name every scope we need — ``id-token:
13
+ # write`` alone would break actions/checkout on any repo/org whose
14
+ # default scopes are restricted.
15
+ contents: read
16
+ id-token: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v5
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v6
23
+ with:
24
+ python-version: "3.11"
25
+
26
+ - name: Install build dependencies
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install build
30
+
31
+ - name: Build package
32
+ run: python -m build
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,35 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ build/
8
+ dist/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # Type checker caches
18
+ .mypy_cache/
19
+ .pyright/
20
+
21
+ # Test caches
22
+ .pytest_cache/
23
+ .ruff_cache/
24
+ .coverage
25
+ htmlcov/
26
+
27
+ # Editor
28
+ .vscode/
29
+ .idea/
30
+ *.swp
31
+ .DS_Store
32
+
33
+ # Local
34
+ *.log
35
+ .env
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bogdan Banu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: operon-langgraph-gates
3
+ Version: 0.1.0a1
4
+ Summary: Reliability primitives for LangGraph — certified stagnation and integrity gates, backed by the Operon categorical framework.
5
+ Project-URL: Homepage, https://github.com/coredipper/operon-langgraph-gates
6
+ Project-URL: Documentation, https://banu.be/operon/
7
+ Project-URL: Issues, https://github.com/coredipper/operon-langgraph-gates/issues
8
+ Project-URL: Paper 4, https://github.com/coredipper/operon/blob/main/article/paper4/main.pdf
9
+ Project-URL: Paper 5, https://github.com/coredipper/operon/blob/main/article/paper5/main.pdf
10
+ Author-email: Bogdan Banu <bogdan@banu.be>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: agents,certificates,integrity,langgraph,llm,reliability,stagnation
14
+ Classifier: Development Status :: 3 - Alpha
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: langgraph<2.0,>=1.0.0
24
+ Requires-Dist: operon-ai>=0.34.4
25
+ Provides-Extra: dev
26
+ Requires-Dist: ipykernel>=6.0; extra == 'dev'
27
+ Requires-Dist: jupyter>=1.0; extra == 'dev'
28
+ Requires-Dist: mypy>=1.11; extra == 'dev'
29
+ Requires-Dist: nbconvert>=7.0; extra == 'dev'
30
+ Requires-Dist: nbformat>=5.0; extra == 'dev'
31
+ Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.6; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # operon-langgraph-gates
37
+
38
+ > Reliability primitives for LangGraph — drop-in, cert-emitting.
39
+
40
+ [LangGraph issue #6731](https://github.com/langchain-ai/langgraph/issues/6731) — *"agent infinite-loops until recursion limit, burns tokens invisibly"* — was closed as **NOT_PLANNED**. LangChain's answer: *"use tool-call limits in middleware."*
41
+
42
+ This package ships that missing native gate, plus a second one for checkpointer-write integrity. Two primitives. No framework adoption. ~10-line diff on an existing `StateGraph`.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install operon-langgraph-gates
48
+ ```
49
+
50
+ Requires `operon-ai>=0.34.4` and `langgraph>=1.0`.
51
+
52
+ ## Quickstart
53
+
54
+ ### Break infinite loops (`StagnationGate`)
55
+
56
+ ```python
57
+ from langgraph.graph import StateGraph
58
+ from operon_langgraph_gates import StagnationGate
59
+
60
+ graph = StateGraph(State)
61
+ graph.add_node("think", StagnationGate.wrap(think_fn, threshold=0.1, history=10))
62
+
63
+ # Or attach to a conditional edge (route loop-detected runs elsewhere)
64
+ graph.add_conditional_edges(
65
+ "think",
66
+ StagnationGate.edge(forward="answer", break_to="escalate", threshold=0.1),
67
+ )
68
+
69
+ # Certificates collected from the run
70
+ certs = StagnationGate.collect(graph)
71
+ ```
72
+
73
+ Backed by [Paper 4 §4.3](https://github.com/coredipper/operon/blob/main/article/paper4/main.pdf): convergence/false-stagnation accuracy **0.960** with real sentence embeddings (all-MiniLM-L6-v2, N = 300 trials). See [`docs/paper-citations.md`](./docs/paper-citations.md) for the full citation record, including the loop-detection caveat and a pointer to the archived benchmark data.
74
+
75
+ ### Catch checkpointer drift (`IntegrityGate`)
76
+
77
+ ```python
78
+ from langgraph.checkpoint.postgres import PostgresSaver
79
+ from operon_langgraph_gates import IntegrityGate
80
+
81
+ checkpointer = IntegrityGate.wrap(
82
+ PostgresSaver.from_conn_string("..."),
83
+ invariants=[MyState.__annotations__, my_schema_check],
84
+ )
85
+ graph = workflow.compile(checkpointer=checkpointer)
86
+ ```
87
+
88
+ Backed by [Paper 4 §4, Table 3](https://github.com/coredipper/operon/blob/main/article/paper4/main.pdf): *in the paper's setup*, the FULL variant (with `DNARepair`) achieves 100% detection and 100% repair of injected state corruption, vs 0%/0% for RAW and GUARDED. **This package is detection-and-certification only — it does not repair state.** It reformulates the idea as a LangGraph-native invariant gate. [Paper 5 §3](https://github.com/coredipper/operon/blob/main/article/paper5/main.pdf) establishes the preservation-under-compilation framework that the gate's certificate follows. See [`docs/paper-citations.md`](./docs/paper-citations.md) for verbatim quotes and the honest caveat.
89
+
90
+ ## Try it — HuggingFace Space
91
+
92
+ [**Operon StagnationGate Demo**](https://huggingface.co/spaces/coredipper/operon-stagnation-gate) — interactive page: pick a preset (identical, diverse, noisy, slow drift), tune the gate parameters, watch `is_stagnant` flip and the certificate appear. Deterministic text trajectories — no LLM calls.
93
+
94
+ ## Examples
95
+
96
+ - [`examples/01_stagnation_breaks_loop.ipynb`](./examples/01_stagnation_breaks_loop.ipynb) — reproduces issue #6731 pathology, then fixes it with a ten-line diff.
97
+ - [`examples/02_integrity_catches_drift.ipynb`](./examples/02_integrity_catches_drift.ipynb) — a three-node graph silently corrupts state; `IntegrityGate` catches it with replayable evidence.
98
+
99
+ ## Status
100
+
101
+ **Alpha.** API may change before `0.1.0` stable. Feedback welcome via Issues.
102
+
103
+ ## License
104
+
105
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,70 @@
1
+ # operon-langgraph-gates
2
+
3
+ > Reliability primitives for LangGraph — drop-in, cert-emitting.
4
+
5
+ [LangGraph issue #6731](https://github.com/langchain-ai/langgraph/issues/6731) — *"agent infinite-loops until recursion limit, burns tokens invisibly"* — was closed as **NOT_PLANNED**. LangChain's answer: *"use tool-call limits in middleware."*
6
+
7
+ This package ships that missing native gate, plus a second one for checkpointer-write integrity. Two primitives. No framework adoption. ~10-line diff on an existing `StateGraph`.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pip install operon-langgraph-gates
13
+ ```
14
+
15
+ Requires `operon-ai>=0.34.4` and `langgraph>=1.0`.
16
+
17
+ ## Quickstart
18
+
19
+ ### Break infinite loops (`StagnationGate`)
20
+
21
+ ```python
22
+ from langgraph.graph import StateGraph
23
+ from operon_langgraph_gates import StagnationGate
24
+
25
+ graph = StateGraph(State)
26
+ graph.add_node("think", StagnationGate.wrap(think_fn, threshold=0.1, history=10))
27
+
28
+ # Or attach to a conditional edge (route loop-detected runs elsewhere)
29
+ graph.add_conditional_edges(
30
+ "think",
31
+ StagnationGate.edge(forward="answer", break_to="escalate", threshold=0.1),
32
+ )
33
+
34
+ # Certificates collected from the run
35
+ certs = StagnationGate.collect(graph)
36
+ ```
37
+
38
+ Backed by [Paper 4 §4.3](https://github.com/coredipper/operon/blob/main/article/paper4/main.pdf): convergence/false-stagnation accuracy **0.960** with real sentence embeddings (all-MiniLM-L6-v2, N = 300 trials). See [`docs/paper-citations.md`](./docs/paper-citations.md) for the full citation record, including the loop-detection caveat and a pointer to the archived benchmark data.
39
+
40
+ ### Catch checkpointer drift (`IntegrityGate`)
41
+
42
+ ```python
43
+ from langgraph.checkpoint.postgres import PostgresSaver
44
+ from operon_langgraph_gates import IntegrityGate
45
+
46
+ checkpointer = IntegrityGate.wrap(
47
+ PostgresSaver.from_conn_string("..."),
48
+ invariants=[MyState.__annotations__, my_schema_check],
49
+ )
50
+ graph = workflow.compile(checkpointer=checkpointer)
51
+ ```
52
+
53
+ Backed by [Paper 4 §4, Table 3](https://github.com/coredipper/operon/blob/main/article/paper4/main.pdf): *in the paper's setup*, the FULL variant (with `DNARepair`) achieves 100% detection and 100% repair of injected state corruption, vs 0%/0% for RAW and GUARDED. **This package is detection-and-certification only — it does not repair state.** It reformulates the idea as a LangGraph-native invariant gate. [Paper 5 §3](https://github.com/coredipper/operon/blob/main/article/paper5/main.pdf) establishes the preservation-under-compilation framework that the gate's certificate follows. See [`docs/paper-citations.md`](./docs/paper-citations.md) for verbatim quotes and the honest caveat.
54
+
55
+ ## Try it — HuggingFace Space
56
+
57
+ [**Operon StagnationGate Demo**](https://huggingface.co/spaces/coredipper/operon-stagnation-gate) — interactive page: pick a preset (identical, diverse, noisy, slow drift), tune the gate parameters, watch `is_stagnant` flip and the certificate appear. Deterministic text trajectories — no LLM calls.
58
+
59
+ ## Examples
60
+
61
+ - [`examples/01_stagnation_breaks_loop.ipynb`](./examples/01_stagnation_breaks_loop.ipynb) — reproduces issue #6731 pathology, then fixes it with a ten-line diff.
62
+ - [`examples/02_integrity_catches_drift.ipynb`](./examples/02_integrity_catches_drift.ipynb) — a three-node graph silently corrupts state; `IntegrityGate` catches it with replayable evidence.
63
+
64
+ ## Status
65
+
66
+ **Alpha.** API may change before `0.1.0` stable. Feedback welcome via Issues.
67
+
68
+ ## License
69
+
70
+ MIT — see [LICENSE](./LICENSE).
@@ -0,0 +1,155 @@
1
+ # Paper citations and reproducibility
2
+
3
+ This file is the authoritative record for the **primary benchmark
4
+ numbers** that appear in `StagnationGate` and `IntegrityGate` docstrings
5
+ — the convergence, false-stagnation, loop accuracy figures (StagnationGate)
6
+ and the Paper 4 §4 Table 3 detection/repair percentages (IntegrityGate).
7
+ Secondary numbers that show up in prose (false-positive rates, naive
8
+ baselines for specific scenarios, scope-dependent preservation counts
9
+ like "3/3 or 5/5") are quoted from the same Paper 4 §4.3 table and
10
+ Paper 5 §3 text cited here; their exact values live in those source
11
+ documents rather than being re-tabled in this file.
12
+
13
+ ## Authoritative data
14
+
15
+ | Paper § | Authoritative artifact | Commit |
16
+ |---|---|---|
17
+ | Paper 4 §4.3 — Epiplexity (real embeddings) | `operon-ai:eval/results/benchmarks_real_embeddings/multi_model_summary.json` | `339875e` |
18
+ | Paper 4 §4.3 — Epiplexity (mock embeddings) | `operon-ai:eval/benchmarks/run_benchmarks.py --benchmark epiplexity --seed 42 --trials 100` | current `main` |
19
+ | Paper 4 §4 Table 3 — State integrity | `operon-ai:article/paper4/sections/04-results.tex` lines 306–322 | current `main` |
20
+ | Paper 4 PDF | `operon-ai:article/paper4/main.pdf` | current `main` |
21
+
22
+ Repo root for path prefixes: `https://github.com/coredipper/operon`.
23
+
24
+ ---
25
+
26
+ ## StagnationGate → Paper 4 §4.3
27
+
28
+ ### Verbatim paper quote
29
+
30
+ > "Switching to all-MiniLM-L6-v2 sentence embeddings flips the result
31
+ > on convergence discrimination. The biological monitor achieves
32
+ > 96.0% accuracy on both convergence and false-stagnation scenarios,
33
+ > versus 40.1% and 2.0% for the naive detector. The naive detector's
34
+ > false-positive rate on false stagnation reaches 98.0%—it sees similar
35
+ > outputs and screams 'stagnant' regardless of the agent's confidence
36
+ > level."
37
+ >
38
+ > — Paper 4 §4.3, "With real embeddings: biological wins on convergence."
39
+
40
+ ### Numbers cited in gate docstring
41
+
42
+ From `multi_model_summary.json` (commit `339875e`), `all-MiniLM-L6-v2`
43
+ block (N = 3 seeds × 100 trials = 300):
44
+
45
+ | Scenario | Bio | Naive |
46
+ |---|---|---|
47
+ | `convergence_bio` / `_naive` | **0.960** | 0.401 |
48
+ | `false_stagnation_bio` / `_naive` | **0.960** | 0.020 |
49
+ | `loop_bio` / `_naive` | 0.631 | **0.940** |
50
+
51
+ **Discrepancy with paper tex**: Paper 4 §4.3 Table 4 reports
52
+ `loop accuracy = 0.571` for bio with real embeddings; the authoritative
53
+ JSON reports `0.631`. The JSON is the later artifact (commit `339875e`
54
+ is a post-paper correction) and is cited as authoritative in
55
+ `StagnationGate`'s docstring.
56
+
57
+ ### Honest caveat
58
+
59
+ The gate uses `EpiplexityMonitor`'s `epiplexic_integral` directly
60
+ (sliding-window mean of epiplexity), not the monitor's built-in status
61
+ classifier. The classifier's "loop" scenario — which scores 0.631
62
+ above — requires distinguishing novelty-low + perplexity-high from
63
+ novelty-low + perplexity-low. In practice most LangGraph-side stagnation
64
+ presents as identical/near-identical outputs, which trips the integral
65
+ directly and is what the E2E test
66
+ `tests/integration/test_loop_break.py` exercises. The gate's strength
67
+ is in convergence/false-stagnation; loop scenarios specifically are
68
+ where the paper's biological design underperforms a naive baseline
69
+ and where this gate leans on its integral-based detection rather than
70
+ the classifier.
71
+
72
+ ### Reproducing the mock-embedding numbers
73
+
74
+ ```bash
75
+ cd /path/to/operon-ai
76
+ python -m eval.benchmarks.run_benchmarks --benchmark epiplexity \
77
+ --seed 42 --trials 100
78
+ ```
79
+
80
+ Produces `eval/results/benchmarks/seed_42.json` with five scenarios
81
+ (`loop`, `convergence`, `exploration`, `trophic_withdrawal`,
82
+ `false_stagnation`). Mock embeddings are SHA-256 hash-based — the
83
+ biological monitor loses to the naive detector in this regime; the
84
+ tension between mock and real embeddings is the central finding of
85
+ Paper 4 §4.3.
86
+
87
+ ### Not reproducing the real-embedding numbers
88
+
89
+ The real-embedding sweep that produced the
90
+ `multi_model_summary.json` numbers is not currently CLI-reproducible
91
+ from `operon-ai` main: `sentence-transformers` is not a declared
92
+ dependency and no runner exposes `--embedding-provider`. The numbers in
93
+ `operon-langgraph-gates` are quoted from the archived JSON with commit
94
+ SHA `339875e` for traceability. If a future release needs to re-run the
95
+ sweep, the steps are:
96
+
97
+ 1. `pip install sentence-transformers`
98
+ 2. Write a runner that loads `all-MiniLM-L6-v2`, wraps it in an
99
+ `EmbeddingProvider`-shaped object, and invokes
100
+ `run_epiplexity_bench(config, rng)` directly.
101
+ 3. Run with 3 seeds × 100 trials; aggregate per-seed results to match
102
+ the summary JSON schema.
103
+
104
+ ---
105
+
106
+ ## IntegrityGate → Paper 4 §4 Table 3
107
+
108
+ ### Verbatim paper quote
109
+
110
+ > "The FULL variant detects all four corruption sites (three gene
111
+ > drifts plus one checksum failure) injected between organism stages
112
+ > and repairs them in a single `CHECKPOINT_RESTORE` operation. The
113
+ > certificate (`state_integrity_verified`) holds after repair in all
114
+ > repetitions. RAW and GUARDED are completely blind to genome
115
+ > corruption... `DNARepair` as a pre/post-flight integrity check is
116
+ > the strongest structural guarantee in the evaluated stack."
117
+ >
118
+ > — Paper 4 §4, "State integrity: clear structural value."
119
+
120
+ ### Numbers cited in gate docstring
121
+
122
+ From Paper 4 §4, Table 3 (Integrity row):
123
+
124
+ | Variant | Det% | Rep% |
125
+ |---|---|---|
126
+ | RAW | 0 | 0 |
127
+ | GUARDED | 0 | 0 |
128
+ | **FULL** | **100** | **100** |
129
+
130
+ ### Honest caveat
131
+
132
+ `IntegrityGate` in `operon-langgraph-gates` is a thin reformulation
133
+ of the *idea* of pre-execution integrity checks — it does not reuse
134
+ `DNARepair.scan()` or the `state_integrity_verified` theorem directly.
135
+ It registers its own theorem (`langgraph_state_integrity`) with clean
136
+ LangGraph-flavored evidence params (`invariant_results`,
137
+ `failed_invariants`) so the public API honors the "no biology in the
138
+ user-facing surface" locked decision. The paper's 100/100 numbers
139
+ apply to `DNARepair` on `Genome` objects, which is the inspiration
140
+ but not the implementation here. Paper 5 §3's compile-preservation
141
+ result is what gives this gate its load-bearing claim: a structural
142
+ invariant check, defined once, verifies at every node boundary and
143
+ replays from a frozen evidence snapshot.
144
+
145
+ ---
146
+
147
+ ## Verification of the citations in code
148
+
149
+ `StagnationGate` and `IntegrityGate` docstrings quote the exact numbers
150
+ above. If a future commit weakens or changes these citations, update
151
+ this file in the same commit so the record stays consistent.
152
+
153
+ A static check that keeps docstrings and this file aligned is an
154
+ explicit non-goal for v0.1 (would be lint-theater); the commit policy
155
+ is: touch docstring → touch this file → one commit.