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
67 changes: 49 additions & 18 deletions .github/scripts/package_publication_candidate_activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,38 +114,47 @@ def record_command(command: str, commands: list[dict[str, object]], stdout: str
)


def replace_once(path: Path, old: str, new: str) -> None:
def replace_once_if_needed(path: Path, old: str, new: str) -> None:
text = path.read_text(encoding="utf-8")
if old not in text:
raise RuntimeError(f"expected text not found in {path}: {old}")
path.write_text(text.replace(old, new, 1), encoding="utf-8")
if old in text:
path.write_text(text.replace(old, new, 1), encoding="utf-8")
return
if new in text:
return
raise RuntimeError(f"expected source or activated text not found in {path}: {old}")


def rewrite_candidate_lockfile(workspace: Path) -> None:
lockfile = workspace / "Cargo.lock"
text = lockfile.read_text(encoding="utf-8")
if 'name = "ethos-core"' not in text:
raise RuntimeError("expected ethos-core package entry in candidate Cargo.lock")
lockfile.write_text(text.replace("ethos-core", CORE_PACKAGE), encoding="utf-8")
if 'name = "ethos-core"' in text:
lockfile.write_text(text.replace("ethos-core", CORE_PACKAGE), encoding="utf-8")
return
if 'name = "ethos-doc-core"' in text:
return
raise RuntimeError("expected core package entry in candidate Cargo.lock")


def materialize_candidate_workspace(workspace: Path) -> None:
shutil.copytree(ROOT, workspace, ignore=should_ignore)

replace_once(
replace_once_if_needed(
workspace / "Cargo.toml",
'ethos-core = { path = "crates/ethos-core", version = "0.1.0", default-features = false }',
'ethos-core = { package = "ethos-doc-core", path = "crates/ethos-core", version = "0.1.0", default-features = false }',
)
with (workspace / "Cargo.toml").open("a", encoding="utf-8") as handle:
handle.write(
'\n[patch.crates-io]\n'
'ethos-doc-core = { path = "crates/ethos-core" }\n'
)
root_manifest = workspace / "Cargo.toml"
root_text = root_manifest.read_text(encoding="utf-8")
if 'ethos-doc-core = { path = "crates/ethos-core" }' not in root_text:
with root_manifest.open("a", encoding="utf-8") as handle:
handle.write(
'\n[patch.crates-io]\n'
'ethos-doc-core = { path = "crates/ethos-core" }\n'
)

core_manifest = workspace / "crates/ethos-core/Cargo.toml"
replace_once(core_manifest, 'name = "ethos-core"', 'name = "ethos-doc-core"')
replace_once(
replace_once_if_needed(core_manifest, 'name = "ethos-core"', 'name = "ethos-doc-core"')
replace_once_if_needed(
core_manifest,
"authors.workspace = true\n\n[package.metadata.ethos_publication]",
'authors.workspace = true\n\n[lib]\nname = "ethos_core"\n\n[package.metadata.ethos_publication]',
Expand Down Expand Up @@ -529,18 +538,39 @@ def validate_packaged_manifests(artifacts: list[dict[str, str]]) -> dict[str, ob
return checks


def source_manifests_have_activation_shape() -> bool:
workspace = (ROOT / "Cargo.toml").read_text(encoding="utf-8")
core = (ROOT / "crates/ethos-core/Cargo.toml").read_text(encoding="utf-8")
verify = (ROOT / "crates/ethos-verify/Cargo.toml").read_text(encoding="utf-8")
pdf = (ROOT / "crates/ethos-pdf/Cargo.toml").read_text(encoding="utf-8")
lockfile = (ROOT / "Cargo.lock").read_text(encoding="utf-8")
return all(
[
'ethos-core = { package = "ethos-doc-core", path = "crates/ethos-core", version = "0.1.0", default-features = false }'
in workspace,
'name = "ethos-doc-core"' in core,
'[lib]\nname = "ethos_core"' in core,
'ethos-core = { workspace = true, features = ["grounding", "verify-types"] }' in verify,
'ethos-core = { workspace = true, features = ["full"] }' in pdf,
'name = "ethos-doc-core"' in lockfile,
'name = "ethos-core"' not in lockfile,
]
)


def source_manifests_are_still_blocked() -> bool:
core = (ROOT / "crates/ethos-core/Cargo.toml").read_text(encoding="utf-8")
verify = (ROOT / "crates/ethos-verify/Cargo.toml").read_text(encoding="utf-8")
pdf = (ROOT / "crates/ethos-pdf/Cargo.toml").read_text(encoding="utf-8")
return all(
[
'name = "ethos-core"' in core,
source_manifests_have_activation_shape(),
"publish = false" in core,
"publish = false" in verify,
"publish = false" in pdf,
'package = "ethos-doc-core"' not in verify,
'package = "ethos-doc-core"' not in pdf,
'publication_status = "blocked"' in core,
'publication_status = "blocked"' in verify,
'publication_status = "blocked"' in pdf,
not (ROOT / ".cargo/config.toml").exists(),
not (ROOT / "target/package-registry").exists(),
]
Expand Down Expand Up @@ -584,6 +614,7 @@ def run_candidate_activation(workspace: Path) -> dict[str, object]:
for artifact in artifacts
],
"registry_equivalent_consumer_check": "pass",
"source_manifest_activation_applied": source_manifests_have_activation_shape(),
"source_manifests_remain_blocked": source_manifests_are_still_blocked(),
"package_publication_approved": False,
"public_installation_approved": False,
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/test_determinism_workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def test_contract_vectors_run_on_every_matrix_os(self) -> None:
text = workflow_text()

self.assertIn("runs-on: ${{ matrix.os }}", text)
self.assertIn("cargo test --locked -p ethos-core --all-features", text)
self.assertIn("cargo test --locked -p ethos-doc-core --all-features", text)

def test_pdfium_corpus_step_remains_explicitly_configured(self) -> None:
text = workflow_text()
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/test_milestone_d_crop_element_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def test_target_composes_contract_gates(self) -> None:
block = target_block("milestone-d-crop-element-contract")

required = [
"cargo test --locked -p ethos-core crop_element",
"cargo test --locked -p ethos-doc-core crop_element",
"cargo test --locked -p ethos-cli --test verify "
"native_verify_crop_dir_writes_deterministic_crop_descriptors",
"cargo test --locked -p ethos-cli --test verify crop_element_cli",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_target_composes_contract_gates(self) -> None:
block = target_block("milestone-d-grounding-source-contract")

required = [
"cargo test --locked -p ethos-core grounding",
"cargo test --locked -p ethos-doc-core grounding",
"cargo test --locked -p ethos-cli --test verify native_ethos_verify_produces_non_empty_checks",
"cargo test --locked -p ethos-cli --test verify opendataloader_verify_adapter_produces_capability_aware_report",
"$(PYTHON) schemas/validate_examples.py",
Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/test_milestone_d_internal_contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"inventory": "examples/verify/grounding_source_v1_contract.json",
"schema": "schemas/ethos-grounding-source-contract.schema.json",
"commands": [
"cargo test --locked -p ethos-core grounding",
"cargo test --locked -p ethos-doc-core grounding",
"cargo test --locked -p ethos-cli --test verify native_ethos_verify_produces_non_empty_checks",
"cargo test --locked -p ethos-cli --test verify opendataloader_verify_adapter_produces_capability_aware_report",
]
Expand Down Expand Up @@ -166,7 +166,7 @@
"inventory": "examples/crop/crop_element_v1_contract.json",
"schema": "schemas/ethos-crop-element-contract.schema.json",
"commands": [
"cargo test --locked -p ethos-core crop_element",
"cargo test --locked -p ethos-doc-core crop_element",
"cargo test --locked -p ethos-cli --test verify native_verify_crop_dir_writes_deterministic_crop_descriptors",
"cargo test --locked -p ethos-cli --test verify crop_element_cli",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_current_manifests_tags_and_registry_state_stay_unactivated(self) -> Non
for value in packet["candidate_package_tag_names"]:
tag = value.split(": ", maxsplit=1)[1].split(";", maxsplit=1)[0]
self.assertEqual("", git("tag", "--list", tag))
self.assertIn('name = "ethos-core"', core_manifest)
self.assertIn('name = "ethos-doc-core"', core_manifest)
self.assertIn("publish = false", core_manifest)
self.assertIn("publish = false", verify_manifest)
self.assertIn("publish = false", pdf_manifest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def test_current_manifests_tags_and_registry_state_stay_unactivated(self) -> Non
for value in prep["package_publication_decision_input_packet"]["candidate_package_tag_names"]:
tag = value.split(": ", maxsplit=1)[1].split(";", maxsplit=1)[0]
self.assertEqual("", git("tag", "--list", tag))
self.assertIn('name = "ethos-core"', core_manifest)
self.assertIn('name = "ethos-doc-core"', core_manifest)
self.assertIn("publish = false", core_manifest)
self.assertIn("publish = false", verify_manifest)
self.assertIn("publish = false", pdf_manifest)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_current_manifests_tags_and_registry_state_stay_unactivated(self) -> Non
for value in packet["candidate_package_tag_names"]:
tag = value.split(": ", maxsplit=1)[1].split(";", maxsplit=1)[0]
self.assertEqual("", git("tag", "--list", tag))
self.assertIn('name = "ethos-core"', core_manifest)
self.assertIn('name = "ethos-doc-core"', core_manifest)
self.assertIn("publish = false", core_manifest)
self.assertIn("publish = false", verify_manifest)
self.assertIn("publish = false", pdf_manifest)
Expand Down
Loading
Loading