Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,9 @@ each build into its own folder, and no release publishes with tags. The US
side of this holds from the US repository's switch commit: Microcosm's US
change (microcosm#1570) merges straight after that commit.

**Each build is published into its own folder.** The UK national, dense and
local-area releases and the US releases below
**Each build is published into its own folder.** The UK national and dense
releases, each UK local-area release that the registry names, and the US
releases below
(`microcosm.data.contract.publishes_to_build_folder`) hand each build to the
separately installed emitter, whose release writer puts it in
`releases/<release>/<build>/` and records it in the repository's
Expand Down
1 change: 1 addition & 0 deletions changelog.d/1586-uk-local-k-registered.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`publishes_to_build_folder` admits a UK local-area release (`microcosm-uk-2024-25-local-k<N>`) only when a dataset registry entry names it as its `release`. The registry names none today, so no local-area release publishes yet: the release validators refuse every layout of an unregistered name, and neither publisher takes one. The pull request that authorizes a `k`'s first publication adds its entry.
24 changes: 14 additions & 10 deletions docs/agent-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,17 @@ validator, the publication commands and the loaders enforce today, and what
version 1 (ARCH-1, cos d1160) asks of every country's releases. Change it, its
golden fixtures (`tools/generate_release_contract_fixtures.py`) and the code
that enforces it in the same pull request. The US national golden freezes the
manifests that the US fiscal-refresh tool's `_build_manifests` writes when it
gets only its required arguments and a staging block: an empty `timing`, a null
`ledger_artifact` and only the four gate entries that the function always
writes. A real build adds its own timing, its ledger provenance and the
optional gate blocks its run produces, and the golden freezes none of them. A
pull request that changes what `_build_manifests` always writes, such as
`US_RELEASE_GATE_EVIDENCE_FILES` or `US_DOCUMENTED_ABSENT_INPUTS`, or the
layout that `rewrite_release_dir` gives it, regenerates the fixtures too.
manifests that the US fiscal-refresh tool's `_build_manifests` writes when the
generator replaces four of the builder's globals and passes only the required
arguments and a staging block: an empty `timing`, a null `ledger_artifact` and
only the four gate entries that the function always writes. A real build adds
its own timing, its ledger provenance, the optional gate blocks and the other
optional blocks its run passes (`base_pool` and `post_export_scoring`, for
example), and the blocks that its gate-evidence files bind, and the golden
freezes none of them. A pull request that changes what
`_build_manifests` always writes, such as `US_RELEASE_GATE_EVIDENCE_FILES` or
`US_DOCUMENTED_ABSENT_INPUTS`, or the layout that `rewrite_release_dir` gives
it, regenerates the fixtures too.

PR CI never receives external writer credentials or touches restricted
microdata. Same-repository runs may receive the optional read-only
Expand All @@ -365,8 +368,9 @@ no secret. Green PR checks mean the code contracts hold — they do **not**
certify data artifacts.
Builds, calibrations, and releases run outside PR CI, need gated Hugging Face
data and credentials, and cannot run from forks. Release publication is a
deliberate human step. The UK national, dense and local-area releases and the
US releases (`microcosm-us-2024-national`, the US default, `-local`,
deliberate human step. The UK national and dense releases, each UK local-area
release that the dataset registry names, and the US releases
(`microcosm-us-2024-national`, the US default, `-local`,
`-receipt-donor`, `-evidence` and `-annual`) publish each build into its own folder
through the emitter (`microcosm-publish-release-build`, from
`microcosm.build.release_publication`), which records it in the repository's
Expand Down
39 changes: 21 additions & 18 deletions docs/release-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,12 @@ repository that has no `releases.json`.
- **The releases.** `publishes_to_build_folder` names the releases that
publish into build folders: the UK national release
`microcosm-uk-2024-25-national`, the dense release
`microcosm-uk-2024-25-dense`, the local-area releases
`microcosm-uk-2024-25-local-k<N>`, and the five US releases in
`US_RELEASES`. The function matches a local-area name by pattern
(`_UK_LOCAL_LINE_RELEASE_ID_RE`), so it admits every positive `N`.
`microcosm-uk-2024-25-dense`, each local-area release
`microcosm-uk-2024-25-local-k<N>` that a UK registry entry names as its
`release`, and the five US releases in `US_RELEASES`. The function reads
the registry on each call. `validate_release_dir` and
`validate_evidence_release_dir` refuse every layout of a local-area name
that no entry names, and neither publisher takes one (microcosm#1586).
`microcosm-us-2024-national` holds every national build:
calibrated builds, SPM source enrichments, compatibility recertifications
and exact-k builds. `microcosm-us-2024-local` holds the ACS local-area
Expand Down Expand Up @@ -1022,7 +1024,8 @@ work.
`evidence` is a registered line on the retire list. A UK local-area release
takes the name `microcosm-uk-2024-25-local-k<N>` for each `N` that the
registry names, and the pull request that authorizes a k's first
publication adds its registry entry. On 2026-11-12 the registry names no UK
publication adds its registry entry. `publishes_to_build_folder` admits a
local-area name from that entry on. On 2026-11-12 the registry names no UK
local-area release, so the UK list holds no `local-k<N>` line yet. Legacy
ids, `populace-uk-2023` among them, stay on C1's frozen list. Version 1
fixes no grammar for build names. A build's name must pass the emitter
Expand All @@ -1035,23 +1038,23 @@ work.
release joins `publishes_to_build_folder` and the registry in the pull
request that authorizes its first publication. The gaps on 2026-11-12:
- *A new country's tagged publish.* Nothing refuses it: the tagged
publisher accepts any release outside `publishes_to_build_folder`, into a
repository without `releases.json`. M3's refusal of unknown countries
closes the gap, under M3's owners.
publisher accepts any release outside `publishes_to_build_folder`, except
a UK local-area name that the registry does not name, into a repository
without `releases.json`. M3's refusal of unknown countries closes the gap,
under M3's owners.
- *The NZ, AM and BE declarations.* Each country's `release_contract.json`
(under `packages/microcosm-build/src/microcosm/build/`) names
`latest.json` in its boundary. Each country's owner changes its file
before that country's first publication.
- *The UK local-area pattern.* `publishes_to_build_folder` admits
`microcosm-uk-2024-25-local-k<N>` for every positive `N`, through
`_UK_LOCAL_LINE_RELEASE_ID_RE`, while the registry names no UK local-area
release. The function therefore admits a `k` that no pull request
registered. `test_release_contract_keying.py` pins today's admission with
`microcosm-uk-2024-25-local-k55000`, which the registry does not name.
microcosm#1586 plans to narrow the function to the k's that the registry
names, which flips that case; Max's session owns that change as a code
pull request. Under that plan `line_for_release_id` keeps the pattern,
because the pointer reader still calls it.
- *The first build of a new UK `k`* (2026-11-13). `validate_release_dir`
refuses every layout of a local-area release until a registry entry names
it, and `build_folder_identity` and `microcosm-publish-release-build`
refuse its name. A new `k`'s registry entry therefore lands before its
first build validates. Until that build publishes, the registry names a
release with no published build: `available_variants()` lists the entry,
and `load` raises because `releases.json` does not list the release.
`line_for_release_id` keeps its pattern, because the pointer reader still
calls it.
- *The tagged publisher.* `microcosm-publish-release` and
`tools/publish_release.sh` stay installed and sit on the
[retire list](#retire-list-as-of-2026-10-15). Their removal waits on the
Expand Down
31 changes: 16 additions & 15 deletions packages/microcosm-build/src/microcosm/build/release_publication.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""Publish a release build into its own folder through the emitter.

A release whose builds can publish into their own folders (the UK
national, dense and local-area releases and the US releases, which
A release whose builds can publish into their own folders (the UK national
and dense releases, each UK local-area release that the dataset registry
names, and the US releases, which
``microcosm.data.contract.publishes_to_build_folder`` names) is handed to the
separately installed emitter with the interface's ``publish_release`` call.
Microcosm decides what the build contains and checks it with the release
Expand Down Expand Up @@ -91,6 +92,7 @@
TAGGED_RELEASE_ADVICE,
BuildFolderRelease,
build_folder_identity,
not_a_build_folder_release_reason,
prepare_build_folder_release,
)
from microcosm.data.releases_record import RELEASES_RECORD_PATH
Expand Down Expand Up @@ -200,12 +202,14 @@ def collector_provenance(release: str, build: str) -> CollectorProvenance | None

It names the publication's own release and build, as the interface
requires, since the collector refuses a build folder whose provenance
names another. A UK build (the national, dense and local-area releases)
used licensed microdata, so the collector keeps its Orrery outputs
private; a US build is published in the public US repository, so it used
none whose licence keeps its outputs private. None for a release whose
builds do not publish into their own folders. The interface raises
``ValueError`` for a build ID it does not accept.
names another. A UK build (the national and dense releases, and each
local-area release that the dataset registry names) used licensed
microdata, so the collector keeps its Orrery outputs private; a US build
is published in the public US repository, so it used none whose licence
keeps its outputs private. None for a release whose builds do not publish
into their own folders, a UK local-area release that the registry does
not name among them. The interface raises ``ValueError`` for a build ID
it does not accept.
"""
if not publishes_to_build_folder(release):
return None
Expand Down Expand Up @@ -610,9 +614,9 @@ def _parser() -> argparse.ArgumentParser:
prog="microcosm-publish-release-build",
description=(
"Publish a build of a release whose builds publish into their own "
"folders (the UK national, dense and local-area releases and the US "
"releases) through the emitter, or make a published build current. "
+ TAGGED_RELEASE_ADVICE
"folders (the UK national and dense releases, each UK local-area "
"release the dataset registry names, and the US releases) through "
"the emitter, or make a published build current. " + TAGGED_RELEASE_ADVICE
),
)
parser.add_argument("release_dir", type=Path, help="The local release directory.")
Expand Down Expand Up @@ -707,10 +711,7 @@ def main(argv: list[str] | None = None) -> int:
args = parser.parse_args(argv)
release_dir: Path = args.release_dir
if not publishes_to_build_folder(release_dir.name):
parser.error(
f"release {release_dir.name!r} does not publish into build folders. "
+ TAGGED_RELEASE_ADVICE
)
parser.error(not_a_build_folder_release_reason(release_dir.name))
try:
return _run(args)
except (ValueError, FileNotFoundError) as error:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
sha256,
uk_repository,
)
from test_support.microcosm_data.build_folders import register_uk_local_release

#: The stable release the June 2023 build moves into, when it moves.
JUNE_2023_RELEASE = "populace-uk-2023"
Expand Down Expand Up @@ -1098,6 +1099,31 @@ def test_delete_old_layout_reports_a_deleted_folder_no_tag_names(hub, capsys):
assert report.get("untagged_folders") == [untagged]


def test_delete_old_layout_reports_a_local_area_folder_the_registry_does_not_name(
hub, capsys, monkeypatch
):
"""A folder named by a UK local-area release held copies of tagged builds
only if the registry names the release. Until it does, no build of that
name has published, so the report lists a folder no tag names."""
switched(hub, capsys)
release = "microcosm-uk-2024-25-local-k55000"
folder = f"releases/{release}"
hub.seed({f"{folder}/release_manifest.json": b"{}"}, date=LATER)

exit_code, report, error_output = run_step(hub, capsys, DELETE_STEP)

assert exit_code == 0, error_output
assert f"{folder}/release_manifest.json" in report["delete"]
assert folder in report["untagged_folders"]

register_uk_local_release(monkeypatch, release)
exit_code, report, error_output = run_step(hub, capsys, DELETE_STEP)

assert exit_code == 0, error_output
assert f"{folder}/release_manifest.json" in report["delete"]
assert folder not in report["untagged_folders"]


def test_delete_old_layout_refuses_an_invalid_releases_json(hub, capsys):
switched(hub, capsys)
hub.seed({"releases.json": b"{"}, date=LATER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
from microcosm.data import release as release_module
from microcosm.data.releases_record import parse_releases_record
from test_support.microcosm_build.emitter import FakeEmitterClient
from test_support.microcosm_data.build_folders import UK_NATIONAL_BUILD
from test_support.microcosm_data.build_folders import (
UK_NATIONAL_BUILD,
register_uk_local_release,
)
from test_support.microcosm_data.release import (
_as_uk_national_build_folder_release,
_as_uk_national_line_release,
Expand Down Expand Up @@ -195,7 +198,12 @@ def test_a_publication_names_its_build_for_the_collector(
"microcosm-uk-2024-25-local-k12",
],
)
def test_every_uk_release_names_its_builds_as_licensed_uk_builds(release) -> None:
def test_every_uk_release_names_its_builds_as_licensed_uk_builds(
release, monkeypatch
) -> None:
if "-local-k" in release:
register_uk_local_release(monkeypatch, release)

assert release_publication.collector_provenance(
release, UK_NATIONAL_BUILD
) == CollectorProvenance(
Expand All @@ -206,6 +214,17 @@ def test_every_uk_release_names_its_builds_as_licensed_uk_builds(release) -> Non
)


def test_a_uk_local_area_release_the_registry_does_not_name_names_no_build() -> None:
"""It does not publish into build folders, and ``prepare_build_folder_release``
refuses its name before a publication asks for its provenance."""
assert (
release_publication.collector_provenance(
"microcosm-uk-2024-25-local-k12", UK_NATIONAL_BUILD
)
is None
)


def test_a_release_that_publishes_with_tags_names_no_build() -> None:
assert (
release_publication.collector_provenance(
Expand Down Expand Up @@ -1047,6 +1066,22 @@ def test_the_command_says_the_other_uk_releases_take_no_new_builds(
assert "take no new builds" in capsys.readouterr().err


def test_the_command_refuses_a_uk_local_area_release_the_registry_does_not_name(
tmp_path: Path, capsys
) -> None:
"""The registry names no UK local-area release, so the command refuses the
name and points to the registry instead of to the tagged publisher."""
unregistered = tmp_path / "microcosm-uk-2024-25-local-k55000"
unregistered.mkdir()

with pytest.raises(SystemExit):
release_publication.main([str(unregistered)])

err = capsys.readouterr().err
assert "names no UK local-area release with this k" in err
assert "take no new builds" not in err


def test_the_command_refuses_a_build_whose_staging_never_arrived(
national: Path,
artifact_root: Path, # noqa: F811
Expand Down
2 changes: 1 addition & 1 deletion packages/microcosm-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ it as its only and current build. An entry whose repository has no
`latest-<name>.json`) and reads the manifest at the build's tag; no
registered entry's repository is still in that state. `available()` lists
the default-variant `(country, year)` pairs (the ones a bare ``load(country, year)``
resolves); `available_variants()` lists every published
resolves); `available_variants()` lists every registered
`(country, year, variant)`, non-default lines included.

The old mutable-root behavior is an unsafe escape hatch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
ReleaseContractError,
publishes_to_build_folder,
release_artifact_role,
unregistered_uk_local_release,
)

__all__ = [
Expand Down Expand Up @@ -162,6 +163,14 @@ def rewrite_release_dir(release_dir: Path | str, *, build: str) -> Path:
"""
release_dir = Path(release_dir)
release = release_dir.name
if unregistered_uk_local_release(release):
raise _refuse(
release,
f"{release_dir} is named {release!r}, a UK local-area release that "
"the dataset registry (microcosm.data.registry.REGISTRY) does not "
"name, so it does not publish into build folders; the pull request "
"that authorizes a k's first publication adds its registry entry",
)
if not publishes_to_build_folder(release):
raise _refuse(
release,
Expand Down
Loading
Loading