Developer notes
On this page

Tensor engine consolidation plan

ProposalDesign proposalproposal

Plan of record for one contraction engine on a borrowed structural network layer: Feynman-rule application, contraction and materialization as separate steps, aliased tensor expressions as results, rules and tensors certified once, a small public verb set, and the internal duplicates from both audits retired under measured gates.

View the source note

Lifecycle
proposal
Owner
Ownership decision required
Review
2026-09-27 · a27ca81d8958
Freshness
reviewed
Evidence
Not an evidence record
Verified scopes
No verified code scopes recorded

Lifecycle: Consolidated implementation at a correctness checkpoint; see validation scope and remaining limitation. The evidence below is historical, taken on 2026-09-27 against an unpublished local revision. Saved M0/M1 measurements and later qualification records are separate artifacts; these tables are not claims about the final implementation. The R5 audit adds the correctness gates recorded below. The optional alias design discussed here is preserved in an unpublished local snapshot; the current API always returns TensorExpression and creates no tensor aliases.

Scope: the index-contraction and simplification stack shared by spenso, idenso and spynso3 (TensorExpression), and the way gammalooprs consumes it. Concrete tensor-component execution stays with Spenso’s tensor libraries and is touched only where it must consume the new result type.

Inputs: the API audit of TensorExpression and its production callers, the gluon-ladder and gamma-trace comparisons with FORM, the keep-the-rest probes, the partial-parse and network cost measurements, the factor-graph contraction prototype, and the internal-path audit of the second agent working on this stack (reproduced in the register below).

Decision in one paragraph

There will be one contraction engine, and it will run on the network. The network’s structural layer becomes cheap (borrowed leaves, owned incidence, port overrides) and total (every factor it does not own is an opaque leaf that passes through unchanged). Feynman-rule application, contraction and materialization become three separately timed steps: rules are applied by Symbolica on the factorized expression, contraction expands one factor at a time and pushes its index structure into the still-factorized neighbours while merging states whose remaining factors are identical, and the result is an aliased tensor expression, a DAG whose nodes are typed tensor aliases, materialized to a polynomial or a plain atom only on demand. Rules and tensors carry the interface facts established by their shared owners. Reuse those facts while the sealed payload is unchanged; dynamic rule bindings and callback-produced results still require their actual interface checks. The public surface shrinks to a small set of verbs, and the internal duplicates identified by both audits are retired under the existing regression suites.

Evidence

All timings: release wheels, medians of alternating rounds where noted, one host; FORM 5.0.0 as the external reference. “Module” is the fused replace-and-contract route ported in the tensor-module change; it is a stepping stone and is superseded by this plan.

Gluon ladder (8 three-gluon vertices, 11 dummies, scalar result of 9,652 terms)

RouteOriginal orderReverse orderWhat it measures
typed accumulator (notebook)2.71 s—replace, multiply, expand, contract per vertex
replace_tensor + expand + schoonschip0.94 s0.35 smaterialize generated terms, re-parse
replace_tensor + collector (expand_contracted_sums)0.84 s0.29 scurrent fast route
scalar Symbolica recipe (control)0.86 s0.32 spure Symbolica replacement rules
module replace_tensor(contract=True)0.54 s0.21 sno materialized intermediate
FORM0.73 s0.17 sreference
factor-graph DP, contraction only, Python prototype1.05 s0.107 s1,730 edge expansions in reverse order
factor-graph DP, Feynman rules for all vertices at once0.4 ms0.4 msreplace_multiple, factorized
factor-graph DP, polynomial forward pass to the expanded result—0.10 sonly when the polynomial is wanted

Generated versus retained terms in the expanded routes: 50,684 / 10,947 at stage 6, 92,341 / 23,937 at stage 7, 186,516 / 9,652 at stage 8. The DP performs 17,515 edge expansions in the original order and 1,730 in the reverse order, with 1,320 and 105 peak live states, and its result is a 59 KB DAG against a 1.9 MB polynomial. All routes agree with the FORM-certified polynomial.

Gamma traces

The Dirac algebra is at parity with or ahead of FORM (4D free 12 and 14 gammas: 3.1 and 25 ms against trace4 3.5 and 21 ms; D-dimensional: 2.1 and 45 ms against tracen 5.1 and 65 ms). FORM’s expanded output costs six to fifteen times more only because expand() materializes every term at four to seven microseconds each. Streaming that expansion through the collector is correct and not faster; there is nothing to merge.

Cost of discovering that there is nothing to do

Idempotent call on a contracted stage output6,069 terms23,937 terms9,652 scalar terms
schoonschip()64 ms124 ms15 ms
simplify_metrics()35 ms74 ms15 ms
TensorExpression(expr) from a bare atom205 ms231 ms116 ms
module admission and traversal, no match6 ms22 ms9 ms

A no-op pass costs as much as the productive pass that produced its input, because every call re-classifies every leaf. Production works on bare atoms (audited production-only counts at the fixed base: simplify_metrics 13, to_dots 8, normalize_dots 5, simplify_algebra 4 plus one settings call, simplify_algebra 6 plus nine settings calls, replace_multiple 96, and schoonschip_net 1), so this is paid on every call. Tests are excluded from these counts. simplify_metrics also disables rank-one handling, which bypasses every collector fast path.

Network versus collector, per ladder-shaped term (Rust, release)

Stepidempotentproductive
collector schoonschip(), whole pass5.7 µs6.3 µs
partial symbolic parse (depth_limit 1, opaque fast inference)23.3 µs28.4 µs
symbolic parse without depth limit65.8 µs71.4 µs
schoonschip_net() = parse, execute, normalize169 µs186 µs
canonize (graph canonization)430–520 µs—

The parse is 15% of the network route and already four times the collector’s whole pass; execution is 85%, spent multiplying opaque leaves into one result tensor even when nothing contracts. The whole-sum figures previously quoted for schoonschip_net (0.7–0.9 ms per term) were dominated by an O(n²) accumulation in its driver, not by parsing.

Keep-the-rest conformance

simplify_algebra, simplify_algebra, simplify_metrics, schoonschip and the collector route keep (1+x)·(A + f(z)·B) factored and pass foreign factors through; the current fast route even keeps disconnected components factored. The module distributes scalar spectators and refuses any foreign factor. One defect: a metric contracting into a gamma with AUTO spinor indices fails in simplify_metrics and simplify_algebra while explicit indices work.

Work in flight on the second agent’s line

Landed on the shared base at the time of writing: reuse of contraction state across Schoonschip normalization stages, preserved diagram indices and scoped tensor indices, tensor-library membership resolution, edge denominators and shared propagator metadata, and MiTeX rendering of model parameter names. In flight and uncommitted at the time of writing (about 4,700 lines across examples/notebooks, examples/reproducers and docs/products/idenso): the multi-loop FORM comparison — a massless three-loop propagator with a fermionic outer ring, then four-loop fermionic and gluonic ladders with physical momentum routing and a metric projection of the external indices — with a shared benchmark driver (fermion_ladder.py, gluon_ladder.py), native FORM programs, staged timing records and an exact check battery (polynomial equality with FORM, D → 4 specialization, 72 exact HEP-component comparisons).

Their routes matter to this plan. The gluonic case already works outside-in: tensor-safe vertex replacement, local Schoonschip contraction and contraction against the remaining opaque vertices in a measured order (1,2,8,3,7,4,6,5 against FORM’s 5,4,6,3,7,2,8,1), without expanding the product of eight vertices first. The fermionic route runs the typed gamma simplifier to a scalar trace, converts once to a polynomial, substitutes momenta group by group with a collect after each, and emits one Atom at the end; against the previous simultaneous-substitution driver this gave paired CPU reductions of 27.5% (three-loop D), 18.2% (four-loop 4D) and 53.9% (four-loop D).

NumeratorDim.Idenso, earlierFORMRatioIdenso, currentFORMRatio
Three-loop fermion4D1.0270.5052.03×0.6120.3561.72×
Three-loop fermionD4.4142.5601.72×2.8792.2311.29×
Four-loop fermion4D13.0328.8751.47×6.5236.5830.99×
Four-loop fermionD231.90860.2503.85×133.25771.5001.86×
Four-loop gluon4D664.375622.0001.07×773.030778.0000.99×
Four-loop gluonD1,068.2511,089.0000.98×1,410.7281,479.0000.95×

Median CPU milliseconds of the complete algebra (trace or vertex replacement, contraction, momentum routing, final scalar collection), five alternating warm batches on one pinned CPU, FORM 5.0.0; ratios divide medians. “Earlier” is the cohort reported during the working session, “current” the cohort in the notebook text dated 2026-09-27 after the routing change; the gluonic algorithm did not change between them, so its rows show the host’s drift.

The remaining gap is the four-loop D-dimensional fermion trace. Their single-call diagnostic splits it into 88.6 ms tracing (including collection of the trace into scalar form), 8.8 ms converting to a polynomial, 29.7 ms substituting momenta and 7.4 ms emitting the final scalar.

What this plan takes from their work:

  • The M0 harness is their driver extended with the ladder, trace and keep-the-rest cases, not a new one; the four-loop D fermion case is its headline, and their exact check battery is the correctness gate of every milestone.
  • The 46 ms after the trace are materialization steps this plan makes on-demand: with an aliased result the routing substitutions act on alias definitions and the polynomial is built once, if at all.
  • The tracing step includes collecting the trace into expanded scalar form; the Dirac algebra itself measured at parity with tracen in this session. The aliased result type lets the trace stay factored into the routing step.
  • Their outside-in gluonic route and the DP contraction differ only in merging states by remaining forms; R5 is measured against their gluonic numbers as well as the historical ladder.

Principles

  1. Keep the rest. A verb acts on the structure it owns and returns everything else exactly as found: scalar spectators and factored sums stay factored, foreign tensors pass through, disconnected components are never multiplied out. Declining is acceptable for malformed input only, never for unfamiliar input. Colour and gamma simplification never require a full expansion.
  2. Three steps, three clocks, and no internal expansion. Rule application (Symbolica, factorized), contraction (the engine) and materialization (polynomial, atom, evaluator) are separate operations with separate benchmarks. expand() is called only by the user, for example to compare with FORM; no verb, option or internal step expands an expression, neither as its output form nor as an intermediate (decision D5, item R17).
  3. Own once. Source atoms are borrowed for the life of an operation; rule outputs are owned once per distinct binding; the graph is owned and arena-reused; atoms are created at emission, one per distinct variable, and never per generated term.
  4. Trust established facts. Rule construction validates wildcard closure and caches a structural proof when the pattern has a fixed interface. Dynamic shapes and callback right-hand sides require checks after binding; they cannot claim a once-only template proof. A sealed tensor carries facts for its exact payload and logical interface. A certified aliased contraction can reuse the same allocation on a default rerun. Bare atoms pay admission at construction. The callback counterexample remains decisive: contracting g(a,b)*T(a) may normalize T(b) to a scalar, so the actual callback output must be checked, including when replacement caching is enabled.
  5. One graph. The partial parser’s structure is the only graph. Contraction, interface inference, canonization, component partition, dummy allocation and dot conversion read it; nothing re-walks atoms to rediscover it.
  6. Results are aliased tensor expressions. The engine returns a root plus typed alias definitions. Expansion is a method, not a side effect.
  7. No new frameworks. Extend SymbolicTensor, SlotMatcher, InterfaceInference, Spenso’s Network and Symbolica’s AliasedAtom; do not add another tensor type or a generic transformation layer.

Target architecture

Symbolica

  • Matching, conditions, wildcard binding and right-hand-side instantiation are Symbolica’s and remain so. replace as an expression rewriter is used for rule application on the factorized expression; it is not used to drive contraction, because its output is a tree that must be expanded and re-parsed.
  • AliasedAtom (root, alias table, nested definitions, register_alias, fused arithmetic, into_inner, evaluator_multiple via EvaluatorBuilder::add_aliases) is the result container. It needs one extension: parametric aliases, where a handle with slot arguments resolves by pattern rather than by literal atom equality, so a tensor alias used with relabeled or vector-filled ports resolves to its definition with the corresponding substitution. Until that lands, the engine registers one literal alias per distinct use-labelling.
  • Requested upstream, not blocking: a streaming replace/expand that hands generated terms to a consumer without assembling the sum.

Spenso: the structural network layer

  • A borrowed structural graph: leaves are AtomViews (into the source or into the owned right-hand-side arena) with a port list from the fast syntactic inference and an incidence table; the graph is arena-allocated and reused across terms and operations. Parse settings are the existing partial ones (depth_limit: Some(1), ShorthandParsing::Opaque, precontract_scalars: true); the strict tensor filter decides which heads are leaves.
  • Two kinds of leaves. Library leaves (metric, identity, tagged vectors) have algebra; every other leaf, including gammas and colour structures in a metric pass and alias handles everywhere, is opaque. Contraction rewrites only edges with a library endpoint. An opaque leaf’s ports may be relabeled or receive a compact vector (a port override); its content is never read and a new atom for it is built once, at emission.
  • Execution semantics are outside-in and local: replacing a leaf splices the right-hand-side template port by port and contracts only the edges the splice exposed. There is no reduction to a single result tensor and no global scheduling; the caller’s replacement order plus the contraction graph decide the order.
  • Materialization is the existing owned Network and NetworkStore, built from the structural graph when component data are needed. The scalar-store aliases already produced there become the same alias handles the engine emits.
  • Returned inference results keep logical port ordering (second audit, item 2), and dummy names are reserved once per operation.

Idenso: the engine

  • Rule application. All rules of a stage at once, on the factorized expression, through certified TensorRule objects (pattern compiled once, wildcard closure checked once, pattern right-hand sides certified structurally once, callback right-hand sides certified per distinct output and cached by binding).
  • Contraction. Read the contraction graph off the factors; choose an order from it; expand one factor at a time; push each term’s metric and vector structure into the neighbours by port override; resolve a contraction that becomes internal to one factor with the per-term reducer; merge states whose remaining factors are identical, adding their coefficients. The per-term reducer is the collector’s reduce_components logic on the structural graph; the collector’s tape, distributor and coefficient-list emitter remain the expansion-on-demand path.
  • Emission. One alias per state, one definition per alias, a root handle; opaque leaves with port overrides materialized once per distinct variable.
  • Other passes. Gamma, colour and epsilon keep their algebra and run on the same graph; they alias what they do not own instead of expanding around it; shared orchestration carries observations between passes and invalidates them on change (second audit, item 4).

Spynso3: the surface

  • TensorExpression stays the typed atom. The optional alias result was proposed: root TensorExpression, aliases as (handle, body) pairs of TensorExpressions whose interfaces match, with to_expression() (resolve), expand() (polynomial forward pass), evaluator(...), map_aliases(f), and the supported contraction, replacement, domain passes, and dot toggles acting on the root and reachable definitions with handles opaque. canonize() is the ordinary TensorExpression operation; callers explicitly resolve an aliased value at that boundary. No alias definition is guessed from a shared head after an index relabelling. The rank-zero case is the scalar AliasedExpression; no separate wrapper.
  • TensorRule is exposed so a rule is built once and applied many times.
  • Transformation policy (identity results, typed zeros, inference, lost interfaces) has one Rust owner in SymbolicTensor; the bindings convert, describe, wrap and translate errors (second audit, item 6).

Public verbs

Target surface of TensorExpression for index algebra, with the current names each one absorbs. Per decision D1 there is no compatibility layer: the renames land in one change together with every caller.

VerbMeaningAbsorbs
replace(rule | rules)tensor-safe rule application, factorized output, construction checks and binding-dependent interface checksreplace_tensor, replace_multiple for tensor leaves, contract= flag
contract(settings=None)metric, identity and optional rank-one contraction on the structural graph; returns aliases, with separate explicit materializationschoonschip, schoonschip_net, simplify_metrics
simplify_algebra(AlgebraSettings(gamma=settings))unchanged algebra, aliases foreign structuresimplify_gamma0, simplify_gamma_conjugate become settings; collect_gamma_chains becomes output="chains"
simplify_algebra(AlgebraSettings(color=settings))unchanged algebra, aliases foreign structureremove unused coefficient-splitting helpers; retain required local colour algebra in this owner
simplify_algebra(AlgebraSettings(epsilon=True))unchanged—
canonize()graph canonization on the shared graphwrap_dummies, wrap_indices where they only served canonization
to_dots() / undo_dots()representation toggles; distinct paths by designnormalize_dots, metric_shorthand_to_dot; unused undo wrappers are removed
expand() / evaluator()materialization, explicit—

Binary positional contraction is contract_ports; it is not an overload of unary index contraction. The unused expand_metrics, expand_mink, expand_bis, expand_mink_bis and expand_in_patterns coefficient-list methods are removed. Python exposes undo_dots, undo_chain, and undo_trace as independent notation conversions; aggregate undo pipelines are removed. Production callers that relied on to_dots to contract rank-one tensors use contract() before to_dots(). canonize, simplify_algebra and undo_dots are target verbs even if their current callers are tests only.

Spenso’s explicit filtered collect/expand operations remain available, with one shared helper returning AliasedAtom before optional resolution. Remove only the eight unused forwarding methods. These operations also own raw frontend ingress where a local rewrite must still see the original physical slot spelling, such as Vakint input; typed domain passes use the shared structural engine after admission. They are not a second implicit expansion path in tensor simplification.

Retained as distinct because they handle different situations (second audit): intrinsic g normalization, nested-vector normalization and product contraction; the bulk collector and the callback-sensitive fallback; sparse and factored trace outputs (the sparse trace emitter is a test oracle); a network’s semantic expression, materialized indices and component data. Verbs with no caller outside tests and the notebook (about a quarter of the current ninety-odd methods) are removed in the same change unless a product doc deliberately specifies their semantics. A generated stub, a historical performance report, or a bare name inventory is not such a claim. The supported construction/indexing/presentation operations are explicitly specified in the Idenso API page. The target verbs canonize, simplify_algebra and undo_dots are retained regardless of current caller counts. The unused expand_metrics, expand_mink, expand_bis, expand_mink_bis and expand_in_patterns return structure/coefficient lists; remove them rather than treating them as contraction aliases.

Old to_dots performs rank-one contraction before converting representation. Callers that rely on that behavior must explicitly call contract first. The shared typed expand_dots() is an explicit finite-component boundary and returns an Atom, not another symbolic tensor. It differs from symbolic undo_dots(): it realizes only selected finite dots through the existing Spenso component executor, including callback-created contractions, while unsupported symbolic dimensions remain unchanged. Intrinsic dots may share construction; callback-sensitive dots preserve their original parse/execute and enclosing normalization order. No whole numerator is realized. A caller that needs prior index contraction requests contract() explicitly. No simplification verb receives an implicit expansion setting (decision D5).

Consolidation register

Items are grouped by the milestone that delivers them. “Second audit” marks findings of the other agent; their line references are to crates/spynso3/src/network.rs (multiply_network), crates/idenso/src/tensor/inference.rs (fallback inference), crates/idenso/src/tensor/replacement.rs (Signature::observe), crates/spynso3/src/expression.rs (simplify_algebra pipeline, from_transformed_atom), crates/idenso/src/color/simplify.rs (rewrite_terms, ProductView) and crates/idenso/src/shorthands/schoonschip/normalize_dots.rs (preflight).

IdItemSourceMilestone
R1O(n²) sum += accumulation in the network schoonschip drivermeasuredM0
R2metric into gamma with AUTO spinor indices failsmeasuredM0
R3benchmark harness: ladder, traces, keep-the-rest probe, idempotent cost, production-derived numerator; alternating interpreters, medians, FORM referencethis planM0
R4Optional alias result and TensorRule types; parametric aliases in Symbolica or literal-per-labelling fallbackthis historical planM1
R5factor-graph DP contraction in Rust over the existing collector graph, contract()prototypeM1
R6colour rewrite_terms and ProductView rebuild sums and products by repeated binary operations; colour retries a failed root rewritesecond audit, 5M1
R7dot-normalization preflight constructs a replacement the rewrite constructs againsecond audit, 5M1
R8borrowed structural layer in Spenso: leaf views, ports, incidence, port overrides, component partition, arena reuse; materialization to the owned networkthis planM2
R9Spenso returns logical port ordering; Idenso stops rescanning arguments; dummy names reserved oncesecond audit, 2M2
R10one product plan and one batched relabel for composition; logical composition in SymbolicTensor, graph and store maintenance in Spensosecond audit, 1M2
R11Signature::observe and scope validation share one traversal through InterfaceInference; certified rules and carried certificates make the per-call source proof disappearsecond audit, 3; this planM3
R12engine on the structural layer: rules, DP contraction, shared component reducer, emission. Cover metric-only inputs in that reducer and keep ordered substitution for callback-sensitive inputs. Migrate the production integrated-UV schoonschip_net caller before deleting the network route, its strategies and duplicate metric collector; retire per-dot networks from the metric APIthis plan; production auditM3
R13shared Rust orchestration of passes with carried observations and invalidation; Python pipeline stops nesting cleanup loops; gamma and Schoonschip stop rescanning unchanged inputsecond audit, 4M3
R14one owner for transformation policy (from_transformed_atom duplicates SymbolicTensor’s decisions)second audit, 6M3
R15public verbs: renames and removals in one change with every caller, .pyi and product docs regenerated; no compatibility aliasesaudit; decision D1M4
R16gammalooprs moves from simplify_metrics on bare atoms to certified contract with aliased output; evaluator consumes aliased results; UV profile re-measuredauditM5
R17no internal expansion: inventory every production expand, expand_num, expand_via_poly and expand_in_patterns call in idenso and spenso (network driver, colour coefficient collection, trace emission, collector output) and replace each with term iteration that builds no atoms; the options expand_traces and expand_contracted_sums godecision D5M0 inventory; M1–M3 removal
R18standalone rust-script and Python reproducers under examples/reproducers/symbolica-aliases/ showing why each Symbolica request is needed: parametric aliases, streaming replace/expand, evaluators from aliased atoms in Pythondecision D4M0

Milestones and gates

Every milestone lands under the existing exact-identity and HEP-library regression suites plus the M0 harness. Correctness and API gates remain required. The user’s 2026-09-28 steering removes performance limits as completion gates: finish the implementation and consolidation first, then measure the complete result against the saved baseline and FORM. Historical timing targets below remain useful reference points, not reasons to delay functional completion. On 2026-09-29 the user requested a cleaned, validated checkpoint and deferred further performance improvements. The closing work therefore focuses on correctness, caller migration, formatting, documentation and reproducible FORM/HEP checks; it does not introduce another optimization campaign. Ownership: the second agent’s line is the base; parser and collector files under their edit land first, and R8 and R12 are designed with them before code is written. Workflow (decision D3): every register item is its own jj change created with jj new default@- when the item starts, so its parent is the second agent’s last completed change and does not move while the item is in progress.

  1. M0 — measure and stop the bleeding. R1, R2, R3, R17 (inventory), R18. Gates: the AUTO reproducer passes; the harness preserves baseline inputs and modes; the expansion inventory names an owner and replacement for every call site; each Symbolica reproducer runs and prints its limitation. Measure whole-sum versus single-term cost after completion.
  2. M1 — the result type and the algorithm, on today’s graph. R4, R5, R6, R7. Gates: contract() on the ladder equals the FORM-certified polynomial after explicit materialization; colour and dot changes are behaviour-preserving on their suites. Include an independent FORM or HEP-component oracle that contracts before expanding, particularly powers of sums containing internal dummy pairs. Squares and cubes with metric cycles, surviving open ports and disjoint spectators must pass without expanding the input first. Budget exhaustion must remain visible and cannot acquire a completion certificate. Report contraction time, alias size and materialization time afterward (historical targets: 50 ms, 100 KB and 150 ms respectively).
  3. M2 — the structural layer. R8, R9, R10. Gates: partial structural parse preserves graph incidence and logical port order; interface inference and canonize read the graph without a second walk; composition builds one plan. Measure parse cost against the collector afterward (historical target: 2× per ladder-shaped term).
  4. M3 — one engine. R11, R12, R13, R14. Gates: contract on an already-contracted certified input is O(1); no verb calls another verb’s full pass on unchanged input; the slot engine’s strategies and graph code are deleted; every keep-the-rest probe passes, including foreign factors and factored sums inside the fused replace-and-contract path.
  5. M4 — the surface. R15. Gates: the public-API test lists the target verbs and nothing else; every caller in production, notebooks and tests uses them; docs and stubs regenerate cleanly.
  6. M5 — production. R16. Gates: gammalooprs numerator pipelines use certified rules and aliased results and preserve the aa→aa three-loop smoke and UV correctness checks. Measure the completed pipelines afterward.

The tensor-module change is not merged; its tests for fused replace-and-contract carry over to replace(...).contract() in M1, and its trace-specific sparse emitter remains a test-only oracle. Explicit expansion uses the common alias materializer, without a second trace dispatcher.

contraction_complete reports the shared default metric/vector contractor’s certificate, not completion of a milestone, concrete component evaluation, or removal of arbitrary repeated tensor indices. false covers an exact retained frontier and a result not yet certified; a fresh metric-only contraction with rank_one=False does not claim default completion. Reusing an already complete sealed result preserves its stronger certificate. Materialization is separate.

The milestone paragraphs are acceptance requirements. Historical M0/M1 records and isolated passing checks do not certify the final combined API, production callers or completion state; the composed source must pass those checks.

Decisions

Taken on 2026-09-27 unless marked open.

  • Direction and order. Accepted with the answers below: one engine on the network, aliased tensor expressions as results, the DP contraction, M0 to M5 in order, the second agent’s line as the base.
  • D1 — old Python names: no compatibility layer. The renames land in one change together with every caller: the production sites (production-only audited counts: simplify_metrics 13, to_dots 8, normalize_dots 5, simplify_algebra 4 plus one settings call, simplify_algebra 6 plus nine settings calls, schoonschip_net 1, and the tensor-leaf uses among 96 replace_multiple), the notebooks, tests, and generated stubs and docs. Nothing is kept for compatibility.
  • D2 — TensorNetwork retains component graphs. Execution and rendering remain its primary use. Keep graph composition, indexing, and permutation because these operate on stored component data and library bindings; a symbolic descriptor cannot replace them. Rename its binary contract to contract_ports, matching TensorExpression. There is no network simplification method and no compatibility alias.
  • D3 — separate changes on a fixed base. Every register item is its own jj change created with jj new default@- when the item starts: its parent is the second agent’s last completed change, not their working copy, so the base does not move while the item is in progress. This plan change is rebased onto that base.
  • D4 — Symbolica requests come with reproducers. Each request is accompanied by a standalone rust-script or Python minimal example under examples/reproducers/symbolica-aliases/ that shows the limitation and why the engine needs the change: parametric aliases, streaming replace/expand, evaluators from aliased atoms in Python (R18).
  • D5 — expansion is the user’s, never the engine’s. expand() is called only by the user, for example to compare with FORM. No verb, option or internal step expands an expression, neither as its output form nor as an intermediate; R17 removes the existing internal expansions.

Risks

  • The structural layer’s constant factors: the collector’s 6 µs per term is a flat incidence table with union-find; a generic graph may not reach it. Mitigation: retain the flat per-term reducer and measure the final implementation after consolidation; the historical 2× target is not a completion gate.
  • State growth in the DP with a poor order (17,515 edges against 1,730 on the ladder). Mitigation: order chosen from the contraction graph; budgets that return partial results with an incomplete status rather than certifying them.
  • Callback right-hand sides can change predicted interfaces. Mitigation: certification of actual outputs and dynamic bindings remains; only a fixed-shape rule template can carry a construction-time interface proof.
  • Alias resolution with port overrides is only correct with parametric aliases or literal-per-labelling registration. Mitigation: the latter is the M1 fallback and is tested by resolving and comparing with the expanded route.
  • Two agents editing the same files. Mitigation: D3, and R8/R12 designed jointly before code.
  • Removing every internal expansion (R17) may surface algorithms that only work on expanded input today (trace emission, colour coefficient collection, the collector’s polynomial output). Mitigation: the M0 inventory sizes each site before M1 commits to a replacement; term iteration over factorized input is the default replacement.

Audit acceptance requirements

The R5 audit extends the existing register owners rather than adding parallel types or engines:

  • R2/R14 must preserve the per-representation order of encoded Open(owner, axis) identities. A multiset match cannot certify positional AUTO axes, including in individual sum branches. Identity substitutions, typed zero and explicit-index movement retain their existing valid paths.
  • R4/R5 must admit bare-representation AUTO alias handles, preserve metadata, retain independent internal dummy scopes in powers, and propagate incomplete contraction. Materialization uses local variable sets and bulk sum construction; an already-expanded alias-free root does not enter polynomial conversion.
  • R8/R9 use the shared slot walk and borrowed graph. Cache the scope symbol in the existing symbol bundle, avoid discarded scalar pre-contraction, and retain callback order. Open markers are not wrapped as explicit indices.
  • R12 keeps the component reducer, the callback-sensitive substitution fallback and intrinsic metric normalization. Metric-only, unfamiliar tensor, scalar, sum and power factors are accepted. Retire the duplicate metric contractor, symbolic-network algebra, strategy knobs and per-dot network parsing only after migrating their production callers and capturing their inputs.
  • R13 removes materializing sector collection and repeated cleanup. Gamma chain collection is an output of simplify_algebra; scalar and foreign spectators remain opaque. Callback outputs still undergo the necessary interface checks.
  • R15 regenerates stubs and documentation from the installed bindings and removes compatibility names and obsolete coefficient-list APIs in the same change.
  • R16 measures the production numerator and UV routes. Compare colour groups independently for zero/equality, check structural equality before expansion, and avoid redundant colour/metric passes and repeated undo parsing.
  • R17 includes indirect distribution, powers, cofactor copying, trace terminal output, colour payloads, lazy network sums and materialization. Expansion-based algebra checks supplement independent factored/component oracles; they cannot establish dummy-scope correctness by themselves.

Completed intermediate changes retain their saved evidence. Follow-up fixes must requalify the combined source before it is called complete. Remove tracked compiler-output binaries and ignore benchmark archives before snapshotting; production HEP dependencies must not enable benchmark-only reference code.

Measurement protocol

Alternating interpreters per round, medians of three rounds, a pure-Symbolica scalar recipe as the control column, FORM as the external reference, release wheels only, and per-stage term or edge counts recorded next to times. The prototype scripts (factor_dp.py, factor_dp_dag.py, factor_dp_poly.py, validation_overhead.py, idempotent_cost.py, partial_parse_cost.py, keep_the_rest_probe*.py) move from the session scratchpad into the repository as the M0 harness.

Checkpoint review amendment

R5 starts each scope with one depth-one opaque parse and scalar pre-contraction. Arithmetic sum and power depth limits now apply consistently; transparent brackets respect the same boundary. DP-selected leaves are opened on demand and cached by occurrence. Closed powered bases with internal pairs contract in their own scope before exponentiation. Unselected scalar/foreign factors retain their literal payloads. The 1,000-term spectator regression asserts five parsed nodes for four factors plus their product, no leaf opening, and exact retention of the two spectator sums. This bounds graph allocation; fast interface inference and the conservative candidate scan still inspect slot syntax and are not constant-time.

Default factor order greedily minimizes the accumulated graph boundary, then prefers more closed edges. It uses the shallow graph’s incidence, without opening factors for scoring. An explicit normalized-factor permutation still overrides it. This is a heuristic, not an optimality claim. Occurrence-local bindings and Complete/Deferred/Capped remain unchanged.

D1 removes the unused Python alias, raw undo, cooking, unchecked construction/reinference, chain normalization, color-basis, and alternate conjugation wrappers. The optional alias owner is now preserved separately; cooking belongs at construction/indexing; typed wrap_indices(scope, dummies_only=True) replaces raw dummy wrapping. The unused Python ColorCasimirSettings class is removed with its consumer. Rust retains cooking and local algebra needed by production. The evaluator’s invariant-only branch runs when do_algebra is false, whereas simplify_algebra runs when it is true: these are mutually exclusive, so removing the Rust-only invariant pass there would change behavior.

Retain simplify_algebra(settings) as the documented shared Rust orchestrator returning the typed expression. Retain the deliberately documented construction, indexing, composition, and presentation surface. D2 adopts the binary-method rename, preserving network component data operations.

Revalidation and measurements, 29 September 2026

The saved baseline is 78a0a22f; both release hosts use Symbolica 6a96c9d77b21. The reproduction harness is examples/notebooks/fermion_ladder.py; examples/notebooks/tensor_benchmarks.typ describes the clock boundaries, case selection and validation protocol. Machine-generated receipts are not part of the maintained source tree.

The main cohort uses three alternating fresh-process rounds on CPU 8, one fixed warmup, and identical explicit ladder orders on both sides. The following CPU milliseconds include the complete requested reduction and materialization from prepared input. The wider fresh algebra column also constructs the input and rules inside one continuous clock. FORM uses its amortized body CPU clock, excluding process startup and input declarations. These are shared-host measurements; three samples do not establish a confidence interval.

CaseCheckpointAmendmentAmendment, fresh algebraFORM body
Fermion 3L, 4D3.4643.4525.1280.320
Fermion 3L, D25.11126.25428.5671.530
Fermion 4L, 4D41.90841.63545.5265.552
Fermion 4L, D287.949289.598294.02347.800
Gluon 4L, 4D280.889283.349285.299595.000
Gluon 4L, D367.664389.005370.443874.000
Historical gluon, original order407.960397.304398.085712.000
Historical gluon, early order85.76186.00591.061155.000
Free trace, length 14, 4D1758.5661728.8131735.87619.800
Free trace, length 14, D1346.8181351.7041347.28857.250
Axial trace, length 12, 4D1276.0251263.2791268.1250.630
Captured production numerator4054.2274129.6704111.149—

The shallow parse helps when work stays opaque. With two 1,000-term scalar spectators, contract-and-resolve decreases from 3.902 to 1.372 ms; with foreign tensor spectators it decreases from 10.128 to 3.321 ms. Both cases retain the original factors exactly. The small metric/vector core changes from 0.056 to 0.061 ms. Graph allocation stays at five nodes; syntax inspection for inference and candidate detection still scales with payload size.

The supplementary order comparison prepares the same local vertex factors before timing. It measures contract() followed by explicit materialization and final routing, alternates explicit/default schedules, and verifies exact equality of their outputs. Its default-to-default CPU comparison is:

CaseCheckpoint defaultGraph defaultSpeedup
Historical gluon441.10582.6795.34×
Gluon 4L, 4D689.085226.8013.04×
Gluon 4L, D824.257290.0942.84×

For the historical case, stored coefficient definitions decrease from 1,327 to 163. These are alias definitions, a different quantity from FORM intermediate-term counts. With the same explicit order, whole-route timings stay close to the checkpoint. The default graph order therefore supplies the main ladder gain; the amendment does not improve the gamma engine. Under the fixed 4L gluon order, separate diagnostic calls attribute about 156/158 ms to contraction and 124/209 ms to materialization in 4D/D. Free and axial traces remain far slower than FORM. Additional performance work is deferred.

Validation passed: 1,262 native tests on the final source, 65 targeted power/bracket/AUTO/ scoping regressions, 28 installed Python test files, 23 documentation catalog tests, Clippy, Rust/Python formatting and generated-stub verification. The two exhaustive axial tests also passed in the optimized run before the final bracket-only correction; they were excluded from the subsequent native run. All 34 benchmark check processes and the final cross-release comparisons completed successfully. Polynomial equality is used where bases agree; finite exact HEP component checks cover the different 4D epsilon/Schouten bases. Those component samples are not general symbolic proofs. The production capture has cross-release and staged checks but no independent FORM program in this suite.

One installed test remains uncompleted: gluon-scattering color contraction exceeded 600 s on the amendment, and the checkpoint remained at the same stage after 1,038 s. The original checkpoint test, migrated checkpoint test, and amendment have byte-identical inputs at that first color pass. No assertion or physics oracle was relaxed.

Developer architecture · documented revision cece059f4b1e