Research
Plastic Embedding Substrate
The Plastic Embedding Substrate (pes) is a typed-graph code retriever. Instead of ranking by embedding cosine similarity, it ranks by effective resistance, a spectral distance, from a focus set on a typed code graph. Observer attention deposits mass that deforms the distance field as the agent works, so the substrate is the working index, not a stale separate one.
| Hit@5 over BM25 | +10pp |
|---|---|
| Router vs RAG, 20-seed | +8.60pp ± 6.19pp |
| Agent cost vs bare LLM | −31.6% |
| License | MIT + Commons Clause |
What ships
- Typed-edge code graph, parsed via tree-sitter and jedi resolution: file, class, function, and method nodes, connected by contains, imports, inherits, calls, and refs edges.
- Substrate retrieval. Effective-resistance distance from a focus set, not embedding cosine. Observer attention deposits mass that deforms the distance field.
- Two substrate flavors. An L+ scalar substrate (production default) and a per-concept (R, K) signed tensor substrate (research-side, variable-rank under nuclear-norm regularization, not yet validated downstream).
- Compositional router. A per-task contextual bandit over channels, depth, body-injection, and RAG, with a k-NN fallback so it can't lose to the best historically-seen action on similar tasks.
- Claude Code hooks.
user_prompt_submitinjects substrate-ranked context before the model's turn;post_tool_usedeposits observer mass on read, grep, and edit.
Scalar substrate vs BM25
10 real post-cutoff bug-fix tasks, uncontaminated (the model has not seen the fixes), gold-patch file required in the retriever's top K. No router, no seed noise.
| Retriever | Hit@K=5 | MRR |
|---|---|---|
| BM25 over file contents | 30% | 0.225 |
| pes scalar substrate | 40% | 0.270 |
+10pp hit rate, +20% MRR over BM25 on the same tasks. Bare LLM is not in the table because it does not retrieve; it greps until something works.
Tensor substrate, per slice
Same 10 tasks, using the tensor substrate's per-relation rankings: K=5 distinct geometries, one per edge type.
| Retriever | Hit@K=5 | MRR |
|---|---|---|
| tensor union (all K=5 slices) | 40% | 0.190 |
| tensor slice 1 (imports) alone | 40% | 0.240 |
| tensor slices 0 / 2 / 3 / 4 alone | 0% | 0.000 |
On bug-fix tasks only the imports slice has signal. Refactor and type-system tasks should exercise the other slices, but the 10-task set does not cover them yet.
Router on SWE-bench
707 SWE-bench-Lite + Verified tasks times 193 public-system predictions. Trained on leave-one-repo-out cross-validation across 12 repos. Per-repo resolution rate against the always-best-single-action baseline.
| Repo | Router | Baseline (~RAG) | Δ |
|---|---|---|---|
| scikit-learn | 73.9% | 32.6% | +41.3pp |
| requests | 69.2% | 38.5% | +30.8pp |
| pallets/flask | 25.0% | 0.0% | +25.0pp |
| sphinx-doc | 29.8% | 5.3% | +24.6pp |
| pydata/xarray | 26.9% | 3.8% | +23.1pp |
| pylint-dev | 40.0% | 20.0% | +20.0pp |
| astropy | 37.5% | 20.8% | +16.7pp |
| django | 36.8% | 21.5% | +15.2pp |
| sympy | 37.7% | 23.8% | +13.8pp |
Per-repo wins are single-seed. 20-seed task-held-out cross-validation gives +8.60pp ± 6.19pp (the router wins 19 of 20 seeds, never loses; median +6.67pp).
Agent cost
claude-opus-4-7 on 6 psf/requests SWE-bench tasks. Total cost across all 6 tasks; every configuration resolved all 6.
| Config | Total cost | vs bare |
|---|---|---|
| bare LLM (no injection) | $4.19 | baseline |
| aider RepoMap (RAG) | $3.38 | −19.3% |
| pes scalar substrate (hooks default) | $2.87 | −31.6% |
6 tasks is small: single repo, Opus-only, all from before the model's training cutoff, so the model may have seen the fixes. Treat this as directional, not definitive.
Modules
| Module | What it does |
|---|---|
codegraph | Python source to typed-edge graph via tree-sitter and jedi resolution. File, class, function, and method nodes; contains, imports, inherits, calls, refs relations. |
substrate / observer / plasticity / encoder | L+ scalar substrate primitives. The scalar field that beats RAG in the default configuration. |
tensor_substrate / tensor_encoder / sequential_observer | Per-concept (R, K) signed bilinear edges, signed effective resistance, variable-rank emergence under nuclear-norm regularization. Research-side; not yet validated downstream. |
substrate_session / tensor_session | High-level session adapters for both substrate flavors. |
compositional_router / task_featurizer | Per-task contextual bandit over channels, depth, body-inject, and RAG, with a k-NN fallback against historically-seen actions on similar tasks. |
hooks.user_prompt_submit / hooks.post_tool_use | Claude Code hooks: substrate-ranked context injection before the model's turn, and observer-mass deposit on read, grep, and edit. |
Access
Confidential, access by request. The Plastic Embedding Substrate isn't publicly available. Get in touch with your use case and we'll follow up about access to the code and a guided substrate session.