Skip to content

feat(swing-sim): land variation execution-metadata orphaned by the slice pivot - #4529

Merged
dieterolson merged 2 commits into
mainfrom
port/swing-sim-variation-execution-metadata
Aug 18, 2026
Merged

feat(swing-sim): land variation execution-metadata orphaned by the slice pivot#4529
dieterolson merged 2 commits into
mainfrom
port/swing-sim-variation-execution-metadata

Conversation

@dieterolson

@dieterolson dieterolson commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Part of #4142

Why these files had no route in

The 34-PR variation consolidation (#4447) is being superseded piecemeal — main is absorbing that campaign as slices, so #4447 will likely never merge. That left this work stranded:

What this adds

The execution-metadata sidecar that pins what a variation plan actually ran against — resolved variable values with unit and dimension semantics, RNG algorithm and stream-derivation identity, and solver/runtime implementation identity — so a historical plan can be replayed with its reproducibility either proven or explicitly refused. Legacy plans without a sidecar resolve against the current registry behind an explicit warning rather than silently claiming reproducibility.

File LOC
variation/_execution_metadata_schema.py 75 new
variation/execution_metadata.py 477 new
variation/tests/test_execution_metadata.py 300 new

Why the scope is 9 files and not 3

The premise that this slice's dependencies were already on main was package-scoped and wrong in three ways. Each was verified against origin/main rather than assumed:

  1. variation/spec.py has no MAX_SAFE_INTEGER. execution_metadata raised ImportError at its import line — the module was not merely untested on main, it could not be loaded at all.
  2. variation/registry.py has no VariableDef.dimension, which failed 20 of 26 tests with AttributeError.
  3. The four variation_execution_document_*.json fixtures live outside the package, under src/rate_of_closure/web/src/model/__fixtures__/ — so counting the 40 variation/** files could not see them.

So spec.py (+40/−10) and registry.py (+30) come along, adding the safe-integer bound on n_runs/seed, signed-zero JSON normalisation, and the registry dimension field. This is the minimum coherent set: it was determined empirically, not guessed — adding these is exactly what turns the suite from 20 failures into 26 passes.

Dead __all__ removed

execution_metadata.py carried two __all__ assignments (an artifact of splitting the schema module out) and the second silently won, leaving the first eight-name block unreachable. Those eight names are a strict subset of the survivor, so no export changes; all 21 remaining names were verified to resolve.

Deliberately excluded

scripts/benchmark_rate_ensemble_archive.py is not in this PR. It imports ensemble_archive, ensemble_request_identity and ensemble_trace_authority — three of fifteen rate_of_closure/variation modules absent from main — and belongs to a separate ensemble-archive slice. Landing it here would add a script that cannot import.

Gates

$ python -m ruff check .
All checks passed!

$ python3 scripts/check_file_size_budget.py --max-loc 500 \
    --baseline-file scripts/monolith_baseline.txt --changed-only --base-ref origin/main
Scanning 5 changed files vs origin/main
File-size budget passed: 0 violations (max 500 LOC).

$ python -m pytest src/shared/python/swing_sim/variation/tests/test_execution_metadata.py -q --timeout=180
26 passed

No regressions from touching the two shared modules: 265 variation tests and 1183 swing_sim tests pass.

One inherited red: ruff format --check

python -m ruff format --check . reports 4 files — all src/data_processing/..., none touched here. This fails on main today, so every open PR inherits it. Addressed separately in #4525, which should merge first; this branch then goes green. My own files are clean:

$ python -m ruff format --check <the 5 python files in this PR>
5 files already formatted

tests/rate_of_closure/ also has ~8 pre-existing flaky failures (Qt/perf tests under the -n auto xdist config). Confirmed unrelated: the same failures occur on a clean main baseline, and the failing set differs run-to-run.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

…ice pivot

The 34-PR variation consolidation (#4447) is being superseded piecemeal:
main is absorbing that campaign as slices, so #4447 will likely never
merge. These files were left with no route onto main. They exist on
`consolidated/variation-morris-2026-08-13` and on two closed-unmerged
codex branches (#4428, #4431); the sibling consolidation #4466 does not
carry them.

Adds the execution-metadata sidecar that pins what a variation plan
actually ran against -- resolved variable values with unit and dimension
semantics, RNG algorithm and stream-derivation identity, and solver /
runtime implementation identity -- so a historical plan can be replayed
with its reproducibility either proven or explicitly refused.

  variation/_execution_metadata_schema.py    75 LOC (new)
  variation/execution_metadata.py           477 LOC (new)
  variation/tests/test_execution_metadata.py 300 LOC (new)

Scope is larger than the three new files because the claim that this
slice's dependencies were already on main was package-scoped and wrong.
Verified against origin/main rather than assumed:

  * variation/spec.py has no MAX_SAFE_INTEGER, so execution_metadata
    raised ImportError at its import line -- the module was not merely
    untested on main, it could not be loaded at all.
  * variation/registry.py has no VariableDef.dimension, which failed 20
    of 26 tests with AttributeError.
  * The four variation_execution_document_*.json fixtures the tests read
    live outside the package, under
    src/rate_of_closure/web/src/model/__fixtures__/, so counting the
    variation/** files could not see them.

So spec.py (+40/-10) and registry.py (+30) come along, adding the
safe-integer bound on n_runs and seed, signed-zero JSON normalisation,
and the registry dimension field.

Also removes a dead duplicate __all__ in execution_metadata.py, an
artifact of splitting the schema module out: the file carried two
assignments and the second silently won, leaving the first eight-name
block unreachable. Its names are a strict subset of the survivor, so no
export changes; all 21 remaining names verified to resolve.

scripts/benchmark_rate_ensemble_archive.py is deliberately excluded. It
imports ensemble_archive, ensemble_request_identity and
ensemble_trace_authority -- three of fifteen rate_of_closure/variation
modules absent from main -- and belongs to a separate ensemble-archive
slice.

Verified: 26 execution-metadata tests pass; 265 variation and 1183
swing_sim tests pass with no regressions from the spec/registry changes.

Part of #4142

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@dieterolson
dieterolson force-pushed the port/swing-sim-variation-execution-metadata branch from d3abcc9 to d6bb21a Compare August 18, 2026 07:22
@dieterolson
dieterolson enabled auto-merge (squash) August 18, 2026 07:31
… main

Two things, neither of them a defect in the ported code.

1. quality-gate failed at "Type Check (Mypy)" with a single error:
   `variation/registry.py:404: error: Returning Any`. That function is
   PRE-EXISTING and byte-identical on main (line 374 there) -- this PR did not
   introduce it. It surfaced only because CI runs mypy on CHANGED FILES ONLY, so
   putting registry.py into a diff exposed a latent error that main never checks.

   The cause is a delta-CI artifact rather than a real typing problem: the
   delegate `registry_mode_policy.keys_for_mode` IS annotated
   `-> tuple[str, ...]`, but it is not among the changed files, so with
   `ignore_missing_imports` its import resolves to `Any` and returning that
   directly trips `warn_return_any`. Fixed by binding to an annotated local,
   which narrows a value that genuinely has that type rather than asserting
   something untrue. Verified: zero mypy errors across all four ported files.

2. Re-synced onto main after #4527 and #4528 merged, which collided in SPEC.md's
   Change Log. Main's max is now 1.17.29, and this branch had also claimed
   1.17.28 -- a straight union produced TWO rows at 1.17.28. Renumbered this
   change to 1.17.30 and re-sorted the 2026-08-18 block version-descending;
   verified four rows, zero duplicate versions. Edited in binary mode so the
   file's CRLF endings survive (6134 CRLF, 0 bare LF).

Part of #4142

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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