Skip to content

refactor(operator-trend): data-driven payload emitter + collapse first 2 ladder tiers (T3-2 phase 8c)#99

Merged
saagpatel merged 1 commit into
mainfrom
refactor/godfn-payload-emitter-base
Jun 20, 2026
Merged

refactor(operator-trend): data-driven payload emitter + collapse first 2 ladder tiers (T3-2 phase 8c)#99
saagpatel merged 1 commit into
mainfrom
refactor/godfn-payload-emitter-base

Conversation

@saagpatel

Copy link
Copy Markdown
Owner

What

Introduces _emit_resolution_payload_entries — a generic, data-driven emitter that rebuilds the recovery-tier payload keys from a (out_key, source_name, is_ternary) spec table — and converts the first two ladder tiers (reset_reentry + reset_reentry_rebuild, 71 contiguous entries) to it. This is the validate-the-mechanism PR; the remaining ~245 entries collapse the same way in the follow-up.

The pattern

A conformance proof over all 320 payload entries found 316 are exactly two patterns, with only 4 OTHER (the 3 summary-fn calls + bare decision_memory_map):

  • Ternary: primary_target.get(<out_key sans 'primary_target_'>, value) if primary_target else value
  • Plain: sources[source_name][out_key]

So the load-bearing string contract becomes an auditable data table + a 14-line loop, instead of ~1,600 lines of hand-written ternaries.

def _emit_resolution_payload_entries(payload, *, primary_target, sources, entries):
    for out_key, source_name, is_ternary in entries:
        value = sources[source_name][out_key]
        if is_ternary:
            payload[out_key] = (
                primary_target.get(out_key.removeprefix("primary_target_"), value)
                if primary_target else value
            )
        else:
            payload[out_key] = value

Faithfulness

Byte-identical by construction — the conformance proof verified every converted entry matches the emitter's patterns (get-key included), so the emitter regenerates the identical expression. The 7 now-dead tier source-unpacks are pruned (computed precisely: they were referenced only by the moved entries; tier-3 bridges from different sources).

Proof

  • Characterization net (tests/test_resolution_trend_golden_contract.py) → byte-identical green
  • uv run pytest -q2541 passed, 2 skipped
  • ruff check src/ tests/ → clean (no F841) · mypy → clean
  • Net −304 lines for 2 tiers; the follow-up sweep removes ~1,000 more.

Next

PR-B converts the remaining 5 ladder tiers + the early-region A/B entries and deletes the re-derivation preamble — the full ~1,300-line collapse, under this same green net.

…ad keys; collapse first 2 ladder tiers (T3-2 phase 8c)

Introduces _emit_resolution_payload_entries: a generic emitter that rebuilds the
per-target/per-class recovery-tier payload keys from a (out_key, source_name,
is_ternary) spec table. Ternary entries reproduce the primary_target override
(primary_target.get(out_key sans 'primary_target_', value) if primary_target else
value); plain entries pass through sources[source_name][out_key].

Converts the first two ladder tiers (reset_reentry + reset_reentry_rebuild, 71
contiguous A/B entries) to the table and prunes their now-dead source unpacks.
Byte-identical by construction (every converted entry matched the emitter's two
patterns, get-key included) and proven by the characterization net. The remaining
~245 A/B entries collapse the same way in the follow-up.

Verify: net byte-identical; ruff + mypy clean; 2541 passed, 2 skipped. Net -304 lines.
@saagpatel saagpatel merged commit 058c794 into main Jun 20, 2026
2 checks passed
@saagpatel saagpatel deleted the refactor/godfn-payload-emitter-base branch June 20, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant