Skip to content

Complete UK exact-K release parity and make the runtime country-neutral #898

Description

@anth-volk

Context

PR #896 now contains only UK staging-data work. It deliberately does not add exact-household-count calibration.

PR #877 added a separate UK implementation in microcosm.build.uk_runtime.dataset_size. The US implementation remains in microcosm.build.us_runtime.exact_k_ladder. The UK code reuses lower-level calibration and fixed-size sampling functions, but it is not an extraction of the US end-to-end implementation.

PR #893 does not extract or otherwise implement the shared exact-count workflow. It adds a grouped upper-bound calibration mode in the shared solver, and that new mode explicitly rejects L0 or target_records exact-count selection. It does not modify either current exact-count module.

Required design

Implement one shared end-to-end function

  • Extract the complete country-neutral exact-household-count workflow into one public function in a shared microcosm.build module.
  • Make both US and UK call that function. Country modules may prepare inputs and apply country-specific release rules, but they must not duplicate dense calibration, target validation, selection, refitting, count validation, or evidence construction.
  • Preserve the US command interface: --exact-k K|N, --exact-k-pi-hi, and --seed.
  • Support N as an explicit full-pool run and positive integer K as a reduced fixed-size run without clamping the requested count.
  • Preserve a temporary import compatibility path for the current US module if downstream callers require it.

The shared function must provide the complete behavior, not merely expose common utility functions. Its result must include the calibrated frame, selected full-pool row indices, aligned inclusion probabilities, the strict selection receipt, refit-baseline diagnostics, and the information required to construct release evidence.

Combine the strongest current US and UK behavior

  • Run or accept one aligned dense full-pool calibration against a fixed target matrix.
  • Reject every nonzero target that has no supporting household, identifying the unsupported targets.
  • Require at least one selected household that supports each nonzero target; fail before the draw if the requested count cannot contain all required households.
  • Search the L0 penalty against the inclusion-probability mass needed for a feasible fixed-size draw, rather than using a fixed country-specific penalty.
  • Freeze the compiled target matrix for the reduced-support refit so population-dependent measures are not recomputed on the subset.
  • Use an explicit selection seed and preserve deterministic checkpoint/restart behavior for the expensive dense solve and selection search.
  • Draw exactly K households, retain full-pool row identities, and refit from normalized original weights divided by inclusion probabilities.
  • Assert the realized household count after refitting.

Resolve the current UK full-pool inconsistency as part of this work: an N run must have one documented, tested behavior through selection, refitting, checkpointing, evidence construction, and release assembly.

Use one strict evidence builder

  • Construct the selection receipt in the shared function and require exactly these six fields: k, pi_hi, seed, certainty_count, boundary_pool_size, and design.
  • Reject requested-count, realized-count, seed, pool-identity, or target-surface inconsistencies before writing release artifacts.
  • Record the same exact-count evidence in calibration diagnostics, calibration build records, certification evidence, and release manifests.
  • Require an authenticated complete-pool manifest and record its identity and content digests.
  • Require and record the frozen target-surface digest.
  • Require digest-pinned incumbent diagnostics produced against the same target surface and loss definition.
  • Require the candidate to improve on the incumbent under the declared comparison rule, and record both results.

Define UK naming and publication behavior

  • Define the permitted UK exact-count release identifiers and whether UK has approved fixed counts in addition to N.
  • Include the requested count in release identifiers and published artifact metadata.
  • Decide whether exact-count candidates may update the default-dataset pointer or must publish under count-specific identifiers.
  • Reject publication when naming, count, pool identity, target identity, comparison evidence, or exact-count evidence disagree.

Acceptance criteria

  • US and UK invoke the same shared end-to-end function; tests fail if either country replaces it with duplicated orchestration.
  • Identical shared inputs and settings produce identical selection, refit, and evidence outputs regardless of the country caller.
  • Tests cover N, reduced numeric K, unsupported targets, infeasible required-household counts, deterministic restart, malformed receipts, count mismatch, target or pool mismatch, incumbent comparison failure, UK release naming, and publication behavior.
  • Existing US release behavior and evidence validation remain compatible unless a documented migration is included.
  • UK release manifests contain authenticated pool, frozen target-surface, incumbent-comparison, requested-count, realized-count, and strict receipt evidence.

Related work

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions