Single-source + sweep-safe cost-port naming: intern cost[k].<port>, not per-build leak #152

Closed
opened 2026-06-28 22:03:30 +02:00 by Brummel · 1 comment
Owner

Context

Cycle 0084 (#148) extracted the cost-graph wiring into cost_graph in
aura-composites. The 0084 architect drift review flagged two coupled [medium]
items around the cost[k].<port> port-name mechanism. Both are harmless on the
current run-only cost path but become real on the deferred sweep-cost cycle.

The two coupled concerns

  1. Per-build .leak() vs. interning (latent allocation regression).
    cost_graph (crates/aura-composites/src/lib.rs:185,190) .leak()s its
    runtime-computed port names (cost[k].<port>, cost[k].<field>) to satisfy
    NodeHandle::input/output's &'static str bound. This is acceptable today:
    cost is run-path-only (sweep/walkforward/mc pass None), so cost_graph is
    built once per run — a one-shot leak, exactly like the test-only pattern at
    tests/risk_executor.rs:72/165/197. But the deliberate production pattern
    for reused builders is the COL_PORTS LazyLock intern
    (crates/aura-cli/src/main.rs:2606, used on the reduce path at :2719/:2867/:2982);
    the deleted COST_SUM_PORTS interned for the same reason. When cost reaches the
    per-member sweep/MC path, cost_graph is rebuilt per member, and the
    per-build leak accumulates unboundedly across the sweep. (The 0084 commit's
    "risk_executor precedent" provenance was imprecise — that .leak() lives in
    risk_executor's test, not its production builder; corrected in the 0084
    audit-close.)

  2. cost[k].<port> namespacing restated across three crates.
    The index-namespacing format is restated at crates/aura-std/src/cost_sum.rs:45
    (CostSum input ports), crates/aura-composites/src/lib.rs:184,190 (cost_graph
    role + agg-input), and crates/aura-cli/src/main.rs:2753 (the CLI feeding the vol
    node's extra). A compiler-unlinked lockstep — the same class 0082 flagged and
    0083 collapsed for the 3-field names (via COST_FIELD_NAMES). Build-validated
    (a divergent name fails loudly at g.build() resolution, NOT the silent
    positional-join risk 0083 fixed), so no correctness risk in the interim.

The fix (one deliberate unit)

A single-source, sweep-safe cost-port-name contract in the cost module
(aura-std/src/cost.rs): one helper producing the cost[k].<port> /
cost[k].<field> names, interned (process-global, dedup'd) rather than
.leak()ed per build, read by CostSum, cost_graph, and the CLI. Splitting
this into a now-helper (still leaking) + a later-intern would churn the same
surface twice, so it is best built with the sweep-cost cycle, when the
per-member interning requirement is concrete and testable.

depends on: the deferred sweep-path / OOS-pooling cost cycle (#148)
context: 0084 audit drift items (architect review); harmless on the current
run-only cost path, a prerequisite before cost reaches the per-member sweep path.

## Context Cycle 0084 (#148) extracted the cost-graph wiring into `cost_graph` in aura-composites. The 0084 architect drift review flagged two coupled [medium] items around the `cost[k].<port>` port-name mechanism. Both are harmless on the current run-only cost path but become real on the deferred **sweep-cost** cycle. ## The two coupled concerns 1. **Per-build `.leak()` vs. interning (latent allocation regression).** `cost_graph` (crates/aura-composites/src/lib.rs:185,190) `.leak()`s its runtime-computed port names (`cost[k].<port>`, `cost[k].<field>`) to satisfy `NodeHandle::input`/`output`'s `&'static str` bound. This is acceptable today: cost is run-path-only (sweep/walkforward/mc pass `None`), so `cost_graph` is built **once** per run — a one-shot leak, exactly like the test-only pattern at `tests/risk_executor.rs:72/165/197`. But the deliberate **production** pattern for reused builders is the `COL_PORTS` `LazyLock` intern (crates/aura-cli/src/main.rs:2606, used on the reduce path at :2719/:2867/:2982); the deleted `COST_SUM_PORTS` interned for the same reason. When cost reaches the **per-member sweep/MC path**, `cost_graph` is rebuilt per member, and the per-build leak accumulates unboundedly across the sweep. (The 0084 commit's "risk_executor precedent" provenance was imprecise — that `.leak()` lives in risk_executor's *test*, not its production builder; corrected in the 0084 audit-close.) 2. **`cost[k].<port>` namespacing restated across three crates.** The index-namespacing format is restated at crates/aura-std/src/cost_sum.rs:45 (`CostSum` input ports), crates/aura-composites/src/lib.rs:184,190 (`cost_graph` role + agg-input), and crates/aura-cli/src/main.rs:2753 (the CLI feeding the vol node's extra). A compiler-unlinked lockstep — the same class 0082 flagged and 0083 collapsed for the 3-field names (via `COST_FIELD_NAMES`). Build-validated (a divergent name fails loudly at `g.build()` resolution, NOT the silent positional-join risk 0083 fixed), so no correctness risk in the interim. ## The fix (one deliberate unit) A single-source, sweep-safe cost-port-name contract in the cost module (`aura-std/src/cost.rs`): one helper producing the `cost[k].<port>` / `cost[k].<field>` names, **interned** (process-global, dedup'd) rather than `.leak()`ed per build, read by `CostSum`, `cost_graph`, and the CLI. Splitting this into a now-helper (still leaking) + a later-intern would churn the same surface twice, so it is best built **with the sweep-cost cycle**, when the per-member interning requirement is concrete and testable. depends on: the deferred sweep-path / OOS-pooling cost cycle (#148) context: 0084 audit drift items (architect review); harmless on the current run-only cost path, a prerequisite before cost reaches the per-member sweep path.
Brummel added the idea label 2026-06-28 22:03:30 +02:00
Author
Owner

Triage 2026-07-09 (tree at 68317ec) — scope note; the deferral stands but the surface shrank:

  • The leaks are still there: crates/aura-composites/src/lib.rs:187/:192 (.leak() for the extra-port and cost[k]. names; the doc comment at :152-156 references this issue); the format!("cost[{k}].{field}") twin lives at crates/aura-std/src/cost_sum.rs:45. No interning helper exists.
  • Shrunk: #221 (b5ad53d) removed the CLI's dead single-run cost branch, so the restatement sites are two, not three, and cost_graph currently has no production caller (the campaign runner carries no cost leg, crates/aura-cli/src/campaign_run.rs:583).
  • The milestone this issue deferred to (#148, cost-model graph) is closed; no open issue tracks the sweep-cost cycle itself yet. Folding this in as that cycle's first task remains the plan of record.
Triage 2026-07-09 (tree at 68317ec) — scope note; the deferral stands but the surface shrank: - The leaks are still there: crates/aura-composites/src/lib.rs:187/:192 (`.leak()` for the extra-port and cost[k].<field> names; the doc comment at :152-156 references this issue); the `format!("cost[{k}].{field}")` twin lives at crates/aura-std/src/cost_sum.rs:45. No interning helper exists. - Shrunk: #221 (b5ad53d) removed the CLI's dead single-run cost branch, so the restatement sites are two, not three, and cost_graph currently has no production caller (the campaign runner carries no cost leg, crates/aura-cli/src/campaign_run.rs:583). - The milestone this issue deferred to (#148, cost-model graph) is closed; no open issue tracks the sweep-cost cycle itself yet. Folding this in as that cycle's first task remains the plan of record.
Brummel added this to the Real-project readiness — role-complete research loop (no freeze) milestone 2026-07-10 17:16:15 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Brummel/Aura#152