Skip to content

refactor(regression): collapse path-placeholder clump into PlaceholderMap#759

Open
lewisjared wants to merge 3 commits into
feat/pmp-baselinesfrom
refactor/placeholder-map
Open

refactor(regression): collapse path-placeholder clump into PlaceholderMap#759
lewisjared wants to merge 3 commits into
feat/pmp-baselinesfrom
refactor/placeholder-map

Conversation

@lewisjared

@lewisjared lewisjared commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Description

Behaviour-preserving refactor stacked on #756. It collapses the regression-test path-placeholder data clump into a single PlaceholderMap value object.

Previously the placeholder set (<OUTPUT_DIR> / <TEST_DATA_DIR> / <SOFTWARE_ROOT_DIR>) was expressed three ways: loose output_dir / test_data_dir / software_root_dir parameters threaded through ~8 signatures, a private _placeholder_pairs list, and hand-built {real: token} dicts at the verification call sites. Adding the third placeholder (<SOFTWARE_ROOT_DIR>, in #756) had to be threaded through every layer, and the verification side had already drifted — it only knew two of the three tokens.

PlaceholderMap (in climate_ref_core.output_files) now owns the (token, directory) set. The configuration-stable tokens come from PlaceholderMap.for_baseline(...); the per-execution <OUTPUT_DIR> is late-bound via .with_output(...); and .sanitise() / .hydrate() / .as_replacements() replace the old free functions. The three free functions (to_placeholders, from_placeholders, _placeholder_pairs) are deleted, and every caller now passes a single placeholders argument. The verification side (RegressionValidator, plus the conftest ExecutionRegression / DiagnosticValidator) derives its replacements from the same map, so capture and verification can no longer declare different token sets and drift apart.

No behaviour change: the path rewriting, longest-match-first ordering, and float/provenance handling are identical. Verified with ruff, ruff format, mypy, and the existing unit + integration suites (241 passed, 1 skipped), plus an independent review pass.

Stacked on #756 — until that merges, this PR's base is feat/pmp-baselines, so review it on top of #756 (or retarget to main once #756 lands; the diff stays refactor-only).

Checklist

Please confirm that this pull request has done the following:

  • Tests added
  • Documentation added (where applicable)
  • Changelog item added to changelog/ (759.trivial.md)

…rMap

Introduce a frozen PlaceholderMap value object in climate_ref_core.output_files that owns the (token, directory) placeholder set. Config-stable tokens come from for_baseline(); the per-execution <OUTPUT_DIR> is late-bound via with_output(); sanitise()/hydrate()/as_replacements() replace the to_placeholders/from_placeholders/_placeholder_pairs free functions, which are removed.

Every caller now passes a single placeholders argument instead of threading output_dir/test_data_dir/software_root_dir through ~8 signatures, and the verification side (RegressionValidator, conftest ExecutionRegression/DiagnosticValidator) derives its replacements from the same map so capture and verification can no longer declare different token sets and drift apart. Behaviour-preserving.
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 376167ba-4029-491d-91c7-1df2eb7ada28

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/placeholder-map

Comment @coderabbitai help to get the list of available commands.

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