206445df

By: Lucien Huber <im@lcnbr.ch>

complete Python Idenso API parity

User request:

PLEASE IMPLEMENT THIS PLAN:
# Complete Python Idenso API parity with Rust

## API shape

Expose every applicable Idenso operation in two forms:

```python
from symbolica.community import idenso

result = idenso.simplify_gamma(expression, settings=...)
result = tensor_expression.simplify_gamma(settings=...)
```

- Module-level functions accept ordinary Symbolica `Expression` and return ordinary `Expression` or the operation’s natural non-expression result.
- Matching methods live on `TensorExpression` and retain tensor-aware behavior.
- Do not monkey-patch methods onto the base Symbolica `Expression`.
- Module functions remain the explicit escape hatch for users who want tensor-aware dispatch dropped.
- `TensorExpression` methods delegate to the same Rust Idenso implementations; do not duplicate algorithms.
- Since `spynso3` already depends on `idenso`, implement the structured method adapters there without introducing a dependency cycle.

Examples of paired APIs:

```python
idenso.simplify_gamma(expr, settings=...)
tensor_expr.simplify_gamma(settings=...)

idenso.simplify_color(expr, settings=...)
tensor_expr.simplify_color(settings=...)

idenso.to_color_casimir(
    expr,
    fundamental=cof,
    adjoint=coad,
    settings=...,
)
tensor_expr.to_color_casimir(
    fundamental=cof,
    adjoint=coad,
    settings=...,
)

idenso.cook(expr, settings=...)
tensor_expr.cook(settings=...)
```

- Single-expression methods that preserve valid tensor syntax return `TensorExpression` with the re-inferred interface.
- Operations intentionally producing ordinary symbolic encodings return `Expression`.
- Selective expansion methods return `(structure, coefficient)` expression pairs.
- Aliasing and network operations return their existing natural alias/network types.
- Stubs document these return types explicitly.

## Idenso surface coverage

Use the current Rust Idenso implementation as the source of truth. Treat `7d87d16a` only as optional historical inspiration.

Add paired function/method coverage for:

- Gamma, gamma-chain, gamma-conjugation, gamma-zero, epsilon, metric, and color simplification.
- Gamma/color collection, color-constant collection, wrapping, Casimir conversion, and cof-dimension conversion.
- General and representation-specific selective expansion.
- Canonization, subtensor aliasing, Spenso conjugation, conjugate transpose, and Dirac adjoint.
- Cook/uncook operations, source filters, tag filters, modes, and output-tag policies.
- Schoonschip expression/network execution, traversal, contraction ordering, and settings.
- Dot expansion/normalization, metric-to-dot conversion, chain collection/normalization, chainification, and undo operations.

Expose the associated public settings and enums:

```text
GammaChainOrdering
GammaSimplifySettings
ColorSimplifySettings
ColorCasimirSettings
CookMode
CookTagFilter
CookSourceFilter
CookSettings
SchoonschipMode
SchoonschipTraversal
SchoonschipContractionOrder
SchoonschipSettings
```

- Use immutable keyword constructors covering current Rust settings fields.
- Match current Rust defaults.
- Add named presets where Rust defines meaningful standard configurations.
- Keep Rust builders, traits, registries, macros, and internal pipeline stages private.
- Translate fallible Rust operations into specific Python exceptions.

## Representation and color support

Add representation-owned scalar helpers:

```python
rep.dimension
rep.casimir(degree=2)
rep.dynkin_index(degree=2)
rep.gram(degree, other=None)
```

These return ordinary `Expression`.

Provide representation-aware Casimir rewriting as one part of the wider color API:

- Receive `fundamental` and `adjoint` as required function keywords or method keywords.
- Rewrite the exact supplied adjoint dimension using:

```text
dA → dF * CF / TF
```

- Match only scalar coefficient positions; never rewrite representation atoms or tensor interfaces.
- Keep optional settings for \(d_F=C_A\) and \(T_F=1/2\).
- Do not globally replace concrete numbers such as `8`.

Remove legacy `NA` handling:

- Remove the registered symbol, evaluator, initialization, settings, documentation, and name-based rewrites.
- Do not merge `fix-color-adjoint-dimension`.
- Do not expose global color constants or `TensorName` invariant builders.
- Require typed color structures with explicit dimensions.
- Reject structured `f(a,b,c)` and remove the implicit `Nc²-1` fallback.
- Continue supporting explicitly supplied concrete or symbolic dimensions.

## Initialization, stubs, and verification

- Keep initialization automatic and private; expose neither `initialize` nor `initialize_module`.
- Generate module functions, settings, enums, and `TensorExpression` methods through native stub annotations.
- Verify every module function has the intended matching `TensorExpression` method.
- Verify base `Expression` has not been extended or monkey-patched.
- Require exact runtime/stub export, signature, and return-type parity.
- Generate, format, parse, and type-check all stubs twice and require byte-identical output.
- Assert removed legacy and prototype names are absent.
- Test every capability through both its module function and `TensorExpression` method.
- Verify interface preservation, natural non-expression return types, settings defaults, exceptions, representation-aware color rewriting, and absence of special `NA` behavior.
- Keep the 29-case color comparison at 29/29.
- Run direct licensed runtime and Community integration checks in separate `.envrc` processes.
- Preserve the existing working-copy changes and deliver on `simplify-spenso-api`.
GitHub
Time to Start Worker time Duration Time to finish Idle
Config 1s 8s 8s 10s 1s
Eval 7s 59s 59s 1m07s 0s
Build 1m00s 7h03m21s 2h50m35s 2h51m36s 3m39s
Test 14m11s 16m01s 2h41m15s 2h55m26s 0s
Deploy - - - - 23m12s
Suite 1s 7h20m30s - - 26m54s

Timeline

Config Eval Build Test Failed Retried Compressed gap
0s1m2m3m4m5m6m7m8m9m10m11m12m13m14m15m16m17m18m19m20m21m22m23m24m25m26m27m28m29m30m31m32m33m34m35m36m37m38m39m40m41m42m43m44m45m46m47m48m49m50m51m52m53m54m55m56m57m58m59m1h0m1h1m1h2m1h3m1h4m1h5m1h6m1h7m1h8m1h9m1h10m1h11m1h12m1h13m1h14m1h15m1h16m1h17m1h21m1h22m1h23m1h24m1h25m1h26m1h27m1h28m1h29m1h30m1h31m1h32m1h33m1h34m1h35m1h36m1h37m1h38m1h39m1h40m1h41m1h42m1h43m1h44m1h45m1h46m1h47m1h48m1h49m1h50m1h51m1h52m1h53m1h54m1h55m1h56m1h57m1h58m1h59m2h0m2h1m2h2m2h3m2h4m2h5m2h6m2h7m2h8m2h9m2h10m2h11m2h12m2h13m2h14m2h15m2h16m2h17m2h18m2h19m2h20m2h21m2h22m2h23m2h24m2h25m2h26m2h28m2h29m2h30m2h31m2h32m2h33m2h34m2h35m2h36m2h37m2h38m2h39m2h40m2h41m2h42m2h43m2h44m2h45m2h46m2h47m2h48m2h49m2h50m2h51m2h52m2h53m2h54m2h55m