Developer notes
On this page

CFF surface-cache ownership

ImplementedArchitecturecurrent

Shared generalized CFF recursion, standalone arenas, and explicit runtime surface boundaries.

View the source note

Lifecycle
current
Owner
Ownership decision required
Review
2026-09-16 · 2a2c9afe7417780d2102aaf5be6fb1860bb43651
Freshness
review-due
Evidence
Not an evidence record
Verified scopes
  • feynkit_cff::CffGenerator::generate_into
    crates/feynkit-cff/src/generation.rs · digest 632c8482a100
    entire file
  • feynkit_cff::CffExpression
    crates/feynkit-cff/src/expression.rs · digest 38595312c66b
    entire file
  • feynkit_cff::SurfaceCache
    crates/feynkit-cff/src/surface.rs · digest abcf5637a2a6
    entire file

Status

Implemented with one shared recursion engine in three-dimensional-reps. feynkit-cff exposes that generalized engine and adapts it to FeynKit’s standalone topology and surface APIs. GammaLoop uses the generalized engine for production expressions, including repeated poles and numerator energy dependence.

Shared generation

CffGenerationGraph::try_surface_chains owns source/sink selection, contraction, cycle rejection, and surface-chain enumeration. Its surface callback lets each consumer retain its own surface representation while using the same recursion. Fixed boundary edges retain their direction when contracted subgraphs are enumerated.

feynkit_cff::generate_3d_expression and feynkit_cff::generalized expose the generalized engine directly. The topology-only CffGenerator converts graph boundaries to that engine and reconstructs FeynKit trees from the returned chains. It does not implement a second recursion.

Standalone surface invariant

A FeynKit surface identifier is meaningful only with the SurfaceCache supplied with its expression. Consumers discover the referenced surface set from that expression’s trees; a shared arena can contain additional entries from other expressions.

CffGenerator::generate returns an expression, fresh arena, and report in CffResult. generate_into accepts a caller-owned arena for related standalone expressions. IDs remain append-only and stable. Raised-surface analysis, residues, lowering, and diagnostics resolve only the IDs used by the source expression.

Combining independent arenas requires the explicit SurfaceIdMap returned by SurfaceCache::merge and applied by CffExpression::remap_surfaces. Index coincidence is not an identity map.

Runtime surfaces

GammaLoop supplies the generalized engine with its runtime E-surface and H-surface types. These carry the numerical and threshold information needed for production integrands and UV subtraction. Runtime caches and FeynKit topology caches are separate representations; their identifiers must never be interchanged implicitly.

The shared engine owns combinatorics, while each adapter owns conversion, surface interning, and symbolic lowering. This retains main’s generalized production functionality while making it available through FeynKit.

Required checks

Tests cover stable standalone arena IDs, exact referenced surface sets, explicit remapping, fixed boundaries, selected orientations, and contracted/subgraph generation. Generalized and runtime regressions cover repeated poles, signed contours, numerator energy maps, and UV sources. Both API families must continue to use the shared recursion.

Developer architecture · documented revision cece059f4b1e