From 5e63bba00c9fc15158f94310cd6424161aad8215 Mon Sep 17 00:00:00 2001 From: Adam Getchell Date: Mon, 16 Nov 2026 18:01:36 -0800 Subject: [PATCH] fix(release): pin candidate review and refresh validation tooling - Revalidate the same release commit and saved acceptance throughout staging and dispatch. Report successful capture after registration succeeds. - Consolidate LDLT pivot diagnostics and exact determinant overflow coverage. - Scope the frozen Criterion Gitleaks exception and strengthen scanner and native evidence fixtures. - Refresh managed Cargo tools and locked Rust and Python dependencies. --- .gitleaks.toml | 12 +++++ Cargo.lock | 8 ++-- pyproject.toml | 4 +- src/exact.rs | 37 ++++----------- src/ldlt.rs | 31 +++++-------- tests/tooling/support_evidence.py | 2 +- tests/tooling/test_candidate_transfer.py | 37 +++++++++++++-- tests/tooling/test_release_context.py | 27 +++++++++-- tests/tooling/test_security_integration.py | 53 ++++++++++++++++++++-- tooling/release_candidate.py | 49 ++++++++++++-------- uv.lock | 12 ++--- 11 files changed, 179 insertions(+), 93 deletions(-) diff --git a/.gitleaks.toml b/.gitleaks.toml index 7372c3b..cf79919 100644 --- a/.gitleaks.toml +++ b/.gitleaks.toml @@ -12,3 +12,15 @@ condition = "AND" paths = [ '''(?:^|[/\\])scripts[/\\]bench_compare\.py$''' ] regexTarget = "line" regexes = [ '''^\s*_V0_4_3_API_COMPATIBILITY\s*=\s*V0_4_3_API_COMPATIBILITY\s*$''' ] + +# This immutable run retains base64-encoded Criterion Tukey fences (four +# floating-point statistics), both directly and in its complete-run payload. +# Match only the Tukey field token, including after payload decoding, in this +# exact historical artifact. Keep other fields and default detectors active. +# Gitleaks can end a scan chunk within the token, before its closing quote. +[[rules.allowlists]] +description = "Frozen Criterion Tukey statistics" +condition = "AND" +paths = [ '''(?:^|[/\\])docs[/\\]performance-runs[/\\]runs[/\\]2e55909621d0aacbfa7670f678574ae750311ba29353e6e9ebb11461414876a2[/\\]run\.json$''' ] +regexTarget = "match" +regexes = [ '''^tukey\.json":\s*"[A-Za-z0-9+/]+={0,2}"?$''' ] diff --git a/Cargo.lock b/Cargo.lock index 2a59897..a23988c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.6.7" +version = "4.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946" +checksum = "ac230478587d0269d8d6998b82ae69ea51509d55df66d9e92edd1f986904cd4a" dependencies = [ "clap_builder", ] @@ -227,9 +227,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c133bc6a41be0d194c306b5506d15e6feeea7b1d6604bd3f8310dfb2ca96486" +checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79" [[package]] name = "core_detect" diff --git a/pyproject.toml b/pyproject.toml index 285aea2..7fd55bf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -142,10 +142,10 @@ osv-scanner = "2.7.1" [tool.research-repo-tools.toolchain.cargo] cargo-edit = "0.13.14" cargo-llvm-cov = "0.9.1" -cargo-machete = "0.9.2" +cargo-machete = "0.10.1" cargo-nextest = "0.9.152" clippy-sarif = "0.8.0" -dprint = "0.64.3" +dprint = "0.65.0" git-cliff = "2.14.2" rumdl = "0.3.4" sarif-fmt = "0.8.0" diff --git a/src/exact.rs b/src/exact.rs index 7ad5249..cab8008 100644 --- a/src/exact.rs +++ b/src/exact.rs @@ -2599,16 +2599,18 @@ mod tests { } #[test] - fn det_sign_exact_overflow_determinant_finite_entries() { - // Entries near f64::MAX are finite, but the f64 determinant overflows - // to infinity. The fast filter is inconclusive and the direct `BigInt` - // expansion computes the correct positive sign. + fn overflowing_determinant_has_exact_sign_but_no_finite_f64_conversion() { + // The exact determinant is big² > 0, beyond the binary64 range. let big = f64::MAX / 2.0; - assert!(big.is_finite()); let m = Matrix::<3>::try_from_rows([[0.0, 0.0, 1.0], [big, 0.0, 1.0], [0.0, big, 1.0]]) .unwrap(); - // det = big^2 > 0 assert_eq!(m.det_sign_exact(), DeterminantSign::Positive); + assert_unrepresentable(&m.det_exact_f64(), None, UnrepresentableReason::NotFinite); + assert_unrepresentable( + &m.det_exact_rounded_f64(), + None, + UnrepresentableReason::NotFinite, + ); } // ----------------------------------------------------------------------- @@ -2696,29 +2698,6 @@ mod tests { assert!((det - (-2.0)).abs() <= f64::EPSILON); } - #[test] - fn det_exact_f64_overflow_returns_err() { - // Entries near f64::MAX produce a determinant too large for f64. - let big = f64::MAX / 2.0; - let m = Matrix::<3>::try_from_rows([[0.0, 0.0, 1.0], [big, 0.0, 1.0], [0.0, big, 1.0]]) - .unwrap(); - // det = big^2, which overflows f64. - assert_unrepresentable(&m.det_exact_f64(), None, UnrepresentableReason::NotFinite); - } - - #[test] - fn det_exact_rounded_f64_overflow_returns_err() { - let big = f64::MAX / 2.0; - let m = Matrix::<3>::try_from_rows([[0.0, 0.0, 1.0], [big, 0.0, 1.0], [0.0, big, 1.0]]) - .unwrap(); - - assert_unrepresentable( - &m.det_exact_rounded_f64(), - None, - UnrepresentableReason::NotFinite, - ); - } - #[test] fn det_exact_f64_underflow_returns_err_for_nonzero_exact_result() { let tiny = f64::from_bits(1); diff --git a/src/ldlt.rs b/src/ldlt.rs index e218d2c..33152c8 100644 --- a/src/ldlt.rs +++ b/src/ldlt.rs @@ -208,30 +208,23 @@ impl Ldlt { pivot_col, ); } - if pivot < 0.0 { - return Self::non_finite_factor_error(rows) - .unwrap_or_else(|| LaError::not_positive_semidefinite_negative(pivot_col, pivot)); - } - if pivot == 0.0 { - return Self::zero_pivot_failure(rows, pivot_col, tolerance); - } - Self::non_finite_factor_error(rows).unwrap_or_else(|| { - LaError::singular_numerical(pivot_col, FactorizationKind::Ldlt, pivot, tolerance) - }) - } - - /// Classify a zero pivot after checking factor storage and every coupling. - fn zero_pivot_failure(rows: &[[f64; D]; D], pivot_col: usize, tolerance: f64) -> LaError { if let Some(error) = Self::non_finite_factor_error(rows) { return error; } - for (row, values) in rows.iter().enumerate().skip(pivot_col + 1) { - let coupling = values[pivot_col]; - if coupling != 0.0 { - return LaError::not_positive_semidefinite_zero_coupling(pivot_col, row, coupling); + if pivot < 0.0 { + return LaError::not_positive_semidefinite_negative(pivot_col, pivot); + } + if pivot == 0.0 { + for (row, values) in rows.iter().enumerate().skip(pivot_col + 1) { + let coupling = values[pivot_col]; + if coupling != 0.0 { + return LaError::not_positive_semidefinite_zero_coupling( + pivot_col, row, coupling, + ); + } } } - LaError::singular_numerical(pivot_col, FactorizationKind::Ldlt, 0.0, tolerance) + LaError::singular_numerical(pivot_col, FactorizationKind::Ldlt, pivot.abs(), tolerance) } /// Determinant of the original matrix. diff --git a/tests/tooling/support_evidence.py b/tests/tooling/support_evidence.py index 7293311..4dfe39f 100644 --- a/tests/tooling/support_evidence.py +++ b/tests/tooling/support_evidence.py @@ -107,7 +107,7 @@ def __init__(self, root: Path) -> None: "head_sha": COMMIT, "status": "completed", "conclusion": "success", - "labels": NATIVE_RUNNERS.get(name, ["ubuntu-latest"]), + "labels": NATIVE_RUNNERS.get(name, ["ubuntu-latest"]).copy(), "steps": [{"number": number, "name": step, "status": "completed", "conclusion": "success"} for number, step in enumerate(steps, 1)], } for name, steps, identifier in gates diff --git a/tests/tooling/test_candidate_transfer.py b/tests/tooling/test_candidate_transfer.py index 5686232..30ee98d 100644 --- a/tests/tooling/test_candidate_transfer.py +++ b/tests/tooling/test_candidate_transfer.py @@ -212,7 +212,7 @@ def test_staging_retry_keeps_original_draft_before_any_upload(tmp_path: Path, mo (final / name).write_bytes(name.encode()) for name in ("publication.json", "acquisition.sha256", "publication.sha256"): (owner / name).write_bytes(b"a" * 64) - monkeypatch.setattr(candidate, "verify", lambda *_args: final / "acceptance.json") + monkeypatch.setattr(candidate, "verify", lambda *_args, **_kwargs: final / "acceptance.json") monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) monkeypatch.setattr(candidate, "archive", lambda *_args: final / "archive.tar.gz") monkeypatch.setattr(candidate, "parse_candidate_policy", lambda *_args: SimpleNamespace(tag=TAG)) @@ -255,7 +255,7 @@ def test_staging_rejects_malformed_owner_digest_before_provider_access(tmp_path: prepared = tmp_path / "target.json" prepared.write_bytes(serialize_release_target(ReleaseTarget(candidate.REPOSITORY, TAG, 42, SHA, TAG))) monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) - monkeypatch.setattr(candidate, "verify", lambda *_args: pytest.fail("invalid assertions must stop before revalidation")) + monkeypatch.setattr(candidate, "verify", lambda *_args, **_kwargs: pytest.fail("invalid assertions must stop before revalidation")) monkeypatch.setattr(candidate, "revalidate_release_target", lambda *_args, **_kwargs: pytest.fail("invalid assertions must stop before provider access")) with pytest.raises(ValueError, match="full SHA-256 assertions"): candidate.stage(root, owner, "reviewed", prepared) @@ -275,7 +275,7 @@ def test_shared_batch_retains_domain_transfer_and_original_asset_ids(tmp_path: P target = ReleaseTarget(candidate.REPOSITORY, TAG, 42, SHA, TAG) prepared = tmp_path / "target.json" prepared.write_bytes(serialize_release_target(target)) - monkeypatch.setattr(candidate, "verify", lambda *_args: final / "acceptance.json") + monkeypatch.setattr(candidate, "verify", lambda *_args, **_kwargs: final / "acceptance.json") monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) monkeypatch.setattr(candidate, "archive", lambda *_args: final / "archive.tar.gz") monkeypatch.setattr(candidate, "parse_candidate_policy", lambda *_args: SimpleNamespace(tag=TAG)) @@ -339,7 +339,7 @@ def test_initial_stage_requires_the_exact_prepared_target(tmp_path: Path, monkey owner.mkdir() final = candidate.final_directory(owner, SHA, "reviewed") final.mkdir(parents=True) - monkeypatch.setattr(candidate, "verify", lambda *_args: final / "acceptance.json") + monkeypatch.setattr(candidate, "verify", lambda *_args, **_kwargs: final / "acceptance.json") monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) monkeypatch.setattr(candidate, "archive", lambda *_args: final / "archive.tar.gz") monkeypatch.setattr(candidate, "parse_candidate_policy", lambda *_args: SimpleNamespace(tag=TAG)) @@ -474,3 +474,32 @@ def shared(arguments: list[str]) -> int: assert first.read_bytes() == b"reviewed" assert second.read_bytes() == b"retry-2" assert ["--acceptance" in arguments for arguments in requests] == [False, True, False] + + +def test_existing_review_pins_one_commit_and_its_acceptance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + root, owner = tmp_path / "checkout", tmp_path / "owner" + root.mkdir() + other_commit = "c" * 40 + accepted = candidate.final_directory(owner, SHA, "reviewed") / "acceptance.json" + accepted.parent.mkdir(parents=True) + previous = b"original reviewed acceptance\r\n" + accepted.write_bytes(previous) + for name in ("acquisition.sha256", "publication.sha256"): + (owner / name).write_bytes(b"a" * 64) + + revisions = iter((SHA, other_commit)) + monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: next(revisions)) + + def shared(arguments: list[str]) -> int: + assert arguments[arguments.index("--commit") + 1] == SHA + assert Path(arguments[arguments.index("--output") + 1]) == accepted + expected = Path(arguments[arguments.index("--acceptance") + 1]) + assert expected != accepted + assert expected.read_bytes() == previous + return 0 + + monkeypatch.setattr(candidate, "shared_main", shared) + assert candidate.verify_existing(root, owner, "reviewed") == accepted + assert accepted.read_bytes() == previous + assert next(revisions) == other_commit + assert not candidate.final_directory(owner, other_commit, "reviewed").exists() diff --git a/tests/tooling/test_release_context.py b/tests/tooling/test_release_context.py index 51f3b88..0bbc0e7 100644 --- a/tests/tooling/test_release_context.py +++ b/tests/tooling/test_release_context.py @@ -257,7 +257,8 @@ def test_registry_dispatch_sends_only_the_existing_reviewed_snapshot(tmp_path: P monkeypatch.setattr(candidate, "record_path", lambda *_args: publication) verified: list[Path] = [] - def verify(*_args: object) -> Path: + def verify(_root: Path, _owner: Path, _selection: str, *, commit: str) -> Path: + assert commit == SHA verified.append(accepted) assert accepted.read_bytes() == reviewed if failure == "changed-review": @@ -313,12 +314,32 @@ def test_downstream_checks_never_create_missing_review(tmp_path: Path, monkeypat root.mkdir() owner.mkdir() monkeypatch.setattr(candidate, "resolve_revision", lambda *_args: SHA) - monkeypatch.setattr(candidate, "verify", lambda *_args: pytest.fail("tagging or publication must not create a new review")) + monkeypatch.setattr(candidate, "shared_main", lambda *_args: pytest.fail("tagging or publication must not create a new review")) with pytest.raises(FileNotFoundError, match=r"acceptance\.json"): candidate.verify_existing(root, owner, "reviewed") assert list(owner.iterdir()) == [] +def test_capture_cli_reports_success_only_after_owner_registration( + owner_record: tuple[Path, Path], monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str] +) -> None: + root, owner = owner_record + candidate.remember_owner(root, owner) + other = owner.parent / "other owner" + other.mkdir() + for source in owner.iterdir(): + (other / source.name).write_bytes(source.read_bytes()) + monkeypatch.chdir(root) + monkeypatch.setattr(sys, "argv", ["release_candidate.py", "capture", str(other)]) + monkeypatch.setattr(candidate, "capture", lambda *_args, **_kwargs: {"owner_directory": str(other)}) + + with pytest.raises(ValueError, match="immutable output differs"): + candidate.main() + + assert capsys.readouterr().out == "" + assert candidate.selected_owner(root) == owner.resolve() + + @pytest.mark.parametrize("owner_argument", [[], [""]]) def test_cli_recovers_the_registered_owner_without_shell_context( owner_record: tuple[Path, Path], monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str], owner_argument: list[str] @@ -369,7 +390,7 @@ def test_publish_recipe_requires_review_before_reaching_publication(tmp_path: Pa "from tooling import release_candidate as candidate\n" f"candidate.resolve_revision = lambda *_args: {SHA!r}\n" 'def unexpected(*_args):\n raise RuntimeError("attempted to create a new review")\n' - "candidate.verify = unexpected\ncandidate.main()\n", + "candidate.shared_main = unexpected\ncandidate.main()\n", encoding="utf-8", newline="\n", ) diff --git a/tests/tooling/test_security_integration.py b/tests/tooling/test_security_integration.py index 58eabba..6048373 100644 --- a/tests/tooling/test_security_integration.py +++ b/tests/tooling/test_security_integration.py @@ -1,20 +1,28 @@ """Check that the consumer Gitleaks exception preserves secret detection.""" +import base64 import hashlib +import json from pathlib import Path +from typing import TYPE_CHECKING import pytest from research_repo_tools.process import run_command +if TYPE_CHECKING: + import subprocess + REPO_ROOT = Path(__file__).resolve().parents[2] +FROZEN_RUN = "docs/performance-runs/runs/2e55909621d0aacbfa7670f678574ae750311ba29353e6e9ebb11461414876a2/run.json" +LEAK_FOUND = 3 @pytest.mark.parametrize( ("relative", "credential", "status"), [ ("scripts/bench_compare.py", False, 0), - ("scripts/bench_compare.py", True, 1), - ("scripts/other.py", False, 1), + ("scripts/bench_compare.py", True, LEAK_FOUND), + ("scripts/other.py", False, LEAK_FOUND), ], ) def test_historical_alias_exception_is_limited_to_its_assignment_and_path(tmp_path: Path, relative: str, *, credential: bool, status: int) -> None: @@ -27,7 +35,41 @@ def test_historical_alias_exception_is_limited_to_its_assignment_and_path(tmp_pa token = hashlib.sha256(b"public Gitleaks regression fixture").hexdigest() contents += "api_" + f'key = "{token}"\n' source.write_text(contents, encoding="utf-8") - result = run_command( + result = scan_secrets(tmp_path) + assert result.returncode == status, result.stderr + + +@pytest.mark.parametrize("representation", ["direct", "chunk", "payload"]) +@pytest.mark.parametrize( + ("relative", "credential", "status"), + [(FROZEN_RUN, False, 0), (FROZEN_RUN, True, LEAK_FOUND), ("docs/performance-runs/other.json", False, LEAK_FOUND)], +) +def test_frozen_statistics_exception_preserves_other_secret_detection( + tmp_path: Path, representation: str, relative: str, *, credential: bool, status: int +) -> None: + """Only the frozen run's encoded numerical fields are exempted.""" + fences = b"[23.01652962024839,23.323939759650607,24.143700131389842,24.451110270792054]" + encoded = base64.b64encode(fences).decode("ascii") + record = {} + if credential: + record["api_" + "key"] = hashlib.sha256(b"public Gitleaks regression fixture").hexdigest() + record["tukey.json"] = encoded + if representation == "payload": + payload = json.dumps({"raw_files": record}).encode("utf-8") + record = {"payload": base64.b64encode(payload).decode("ascii")} + source = tmp_path / relative + source.parent.mkdir(parents=True, exist_ok=True) + contents = json.dumps(record, indent=2) + "\n" + if representation == "chunk": + contents = contents.removesuffix('"\n}\n') + source.write_text(contents, encoding="utf-8", newline="\n") + result = scan_secrets(tmp_path) + assert result.returncode == status, result.stderr + + +def scan_secrets(root: Path) -> subprocess.CompletedProcess[str]: + """Exercise the installed scanner with the real consumer policy.""" + return run_command( "uv", [ "run", @@ -42,10 +84,11 @@ def test_historical_alias_exception_is_limited_to_its_assignment_and_path(tmp_pa "--config", str(REPO_ROOT / ".gitleaks.toml"), "--redact", + "--exit-code", + str(LEAK_FOUND), "--ignore-gitleaks-allow", - str(tmp_path), + str(root), ], cwd=REPO_ROOT, check=False, ) - assert result.returncode == status diff --git a/tooling/release_candidate.py b/tooling/release_candidate.py index bb825b4..ff45ecb 100644 --- a/tooling/release_candidate.py +++ b/tooling/release_candidate.py @@ -67,8 +67,10 @@ def selection_directory(root: Path) -> Path: def owner_directory(root: Path, checkpoint: str, selected: Path | None = None) -> Path: """Keep the operator's immutable record outside candidate-controlled files.""" root = root.resolve() - identity = hashlib.sha256(str((root / checkpoint).resolve()).encode("utf-8")).hexdigest() - directory = (selected if selected is not None else Path.home() / ".local/state/la-stack/acquisitions" / release_tag(root) / identity).expanduser().resolve() + if selected is None: + identity = hashlib.sha256(str((root / checkpoint).resolve()).encode("utf-8")).hexdigest() + selected = Path.home() / ".local/state/la-stack/acquisitions" / release_tag(root) / identity + directory = selected.expanduser().resolve() if directory.is_relative_to(root) or root.is_relative_to(directory): message = "acquisition owner directory must be separate from the checkout" raise ValueError(message) @@ -227,11 +229,18 @@ def final_directory(owner: Path, commit: str, selection: str) -> Path: return owner / "final" / commit / selection -def verify(root: Path, owner: Path, selection: str = "reviewed") -> Path: +def verify(root: Path, owner: Path, selection: str = "reviewed", *, commit: str | None = None, require_existing: bool = False) -> Path: """Bind the separately trusted record to clean HEAD and signed native CI.""" - commit = resolve_revision(root, "HEAD") + if commit is None: + commit = resolve_revision(root, "HEAD") final = final_directory(owner, commit, selection) accepted = final / "acceptance.json" + try: + previous = accepted.read_bytes() + except FileNotFoundError: + if require_existing: + raise + previous = None arguments = [ "--root", str(root), @@ -263,25 +272,23 @@ def verify(root: Path, owner: Path, selection: str = "reviewed") -> Path: "summary", ] with tempfile.TemporaryDirectory(prefix="la-stack-candidate-verification-") as temporary: - if accepted.exists(): + if previous is not None: # RRT keeps input assertions distinct from its atomic destinations. expected = Path(temporary).resolve() / "acceptance.json" - expected.write_bytes(accepted.read_bytes()) + expected.write_bytes(previous) arguments.extend(("--acceptance", str(expected))) status = shared_main(arguments) if status: raise RuntimeError(f"candidate verification failed with exit {status}") + if previous is not None and accepted.read_bytes() != previous: + message = "reviewed acceptance changed; repeat explicit release-evidence review" + raise ValueError(message) return accepted -def verify_existing(root: Path, owner: Path, selection: str) -> Path: +def verify_existing(root: Path, owner: Path, selection: str, *, commit: str | None = None) -> Path: """Revalidate an already reviewed commit without silently creating a selection.""" - accepted = final_directory(owner, resolve_revision(root, "HEAD"), selection) / "acceptance.json" - expected = accepted.read_bytes() - if verify(root, owner, selection).read_bytes() != expected: - message = "reviewed acceptance changed; repeat explicit release-evidence review" - raise ValueError(message) - return accepted + return verify(root, owner, selection, commit=commit, require_existing=True) def archive(owner: Path, commit: str, selection: str = "reviewed") -> Path: @@ -292,7 +299,7 @@ def archive(owner: Path, commit: str, selection: str = "reviewed") -> Path: message = "selected candidate policy differs from the independently selected commit" raise ValueError(message) prefix = final.relative_to(owner).as_posix() - output = f"{prefix}/la-stack-{policy.tag}-criterion-baseline.tar.gz" + output = f"{prefix}/{archive_name(policy.tag)}" publish_publication(plan_candidate_archive(owner, "run.json", "evidence.json", f"{prefix}/policy.json", f"{prefix}/acceptance.json", output)) verify_candidate_archive(owner / output, policy, (final / "acceptance.json").read_bytes()) return owner / output @@ -464,9 +471,10 @@ def serialize_transfer(transfer: Transfer) -> bytes: return json.dumps(record, sort_keys=True).encode("utf-8") + b"\n" -def preparation_target(root: Path, owner: Path, selection: str) -> Path: +def preparation_target(root: Path, owner: Path, selection: str, *, commit: str | None = None) -> Path: """Retrieve the original authenticated target through the installed supplier.""" - commit = resolve_revision(root, "HEAD") + if commit is None: + commit = resolve_revision(root, "HEAD") require_release_checkout(root, commit) output = final_directory(owner, commit, selection) / "preparation" status = shared_main( @@ -494,12 +502,12 @@ def stage(root: Path, owner: Path, selection: str, prepared_target: Path | None """Upload inert original records, retaining dispatch assertions independently.""" acquisition = transfer_digest((owner / "acquisition.sha256").read_text(encoding="ascii").strip()) publication = transfer_digest((owner / "publication.sha256").read_text(encoding="ascii").strip()) - accepted = verify_existing(root, owner, selection) commit = resolve_revision(root, "HEAD") + accepted = verify_existing(root, owner, selection, commit=commit) final = final_directory(owner, commit, selection) policy = parse_candidate_policy((final / "policy.json").read_bytes()) target_path = final / "target.json" - target = parse_release_target((prepared_target or preparation_target(root, owner, selection)).read_bytes()) + target = parse_release_target((prepared_target or preparation_target(root, owner, selection, commit=commit)).read_bytes()) if (target.repository, target.tag, target.commit, target.expected_title) != (REPOSITORY, policy.tag, commit, policy.tag): message = "staging target differs from the accepted candidate" raise ValueError(message) @@ -585,7 +593,7 @@ def upload_dispatch(root: Path, owner: Path, selection: str, tag: str) -> None: transfer = require_publication_transfer(parse_transfer(transfer_bytes)) accepted = publication.parent / "acceptance.json" expected = accepted.read_bytes() # Missing review must never create a new selection. - if verify_existing(root, owner, selection).read_bytes() != expected: + if verify_existing(root, owner, selection, commit=transfer.original.target.commit).read_bytes() != expected: message = "reviewed acceptance changed before publication dispatch" raise ValueError(message) check_published_transfer(root, transfer) @@ -839,8 +847,9 @@ def run_owner_operation(root: Path, options: argparse.Namespace) -> None: """Route operations after resolving their independent acquisition owner.""" owner = selected_owner(root, options.owner_directory) if options.operation == "capture": - print(json.dumps(capture(root, owner, retained_scratch=options.retained_scratch))) + assertions = capture(root, owner, retained_scratch=options.retained_scratch) remember_owner(root, owner) + print(json.dumps(assertions)) elif options.operation == "verify": accepted = verify(root, owner, options.selection) print(json.dumps({"acceptance": str(accepted), "sha256": hashlib.sha256(accepted.read_bytes()).hexdigest()})) diff --git a/uv.lock b/uv.lock index 7f0f776..13365a2 100644 --- a/uv.lock +++ b/uv.lock @@ -193,14 +193,14 @@ wheels = [ [[package]] name = "click-option-group" -version = "0.5.9" +version = "0.5.10" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "click" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/ef/ff/d291d66595b30b83d1cb9e314b2c9be7cfc7327d4a0d40a15da2416ea97b/click_option_group-0.5.9.tar.gz", hash = "sha256:f94ed2bc4cf69052e0f29592bd1e771a1789bd7bfc482dd0bc482134aff95823", size = 22222, upload-time = "2025-10-09T09:38:01.474Z" } +sdist = { url = "https://files.pythonhosted.org/packages/1d/03/454dafcda21ca579bfa3d3583edd91f283cf6fb7b9a63d00a3212e8e2d4c/click_option_group-0.5.10.tar.gz", hash = "sha256:22d6a7d102b4ead6a0b8601d577386d390deae91038662f2bd1d013806184ab7", size = 22876, upload-time = "2026-11-16T13:46:42.161Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/75/45/54bb2d8d4138964a94bef6e9afe48b0be4705ba66ac442ae7d8a8dc4ffef/click_option_group-0.5.9-py3-none-any.whl", hash = "sha256:ad2599248bd373e2e19bec5407967c3eec1d0d4fc4a5e77b08a0481e75991080", size = 11553, upload-time = "2025-10-09T09:38:00.066Z" }, + { url = "https://files.pythonhosted.org/packages/ac/fc/cdebdc2595700ebc9a57890360750bcc8ae1bfa1863c028db5be5652f23a/click_option_group-0.5.10-py3-none-any.whl", hash = "sha256:667f9dafdbe15f69c7e877e14c94175ab2e16b6a1ab4b7ffac51513ed624a8dc", size = 11531, upload-time = "2026-11-16T13:46:40.911Z" }, ] [[package]] @@ -905,11 +905,11 @@ wheels = [ [[package]] name = "python-multipart" -version = "0.0.33" +version = "0.0.34" source = { registry = "https://pypi.org/simple" } -sdist = { url = "https://files.pythonhosted.org/packages/9f/b7/15b905f6142a9a8a68f66900788da1a32e4d4254452783b37ad1eccb0506/python_multipart-0.0.33.tar.gz", hash = "sha256:b8112424a6abd162ec08d390565dd113ad699f2fe6fef3c987b8bbcbfe9e390d", size = 50499, upload-time = "2026-10-31T14:23:47.461Z" } +sdist = { url = "https://files.pythonhosted.org/packages/7e/c0/c753d487a83d873f6946cee6cbc26cea3fe59a476ad0de99a14938a2fbd8/python_multipart-0.0.34.tar.gz", hash = "sha256:b998ae90ca6e1e363261ce2e0e230281b8af53867b757970abd69ee9edcd843a", size = 52456, upload-time = "2026-11-16T10:40:38.261Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/dd/1b/6b1b4164ec734cac911460ab599bfbe46afedd42c5c9627fe4235942c314/python_multipart-0.0.33-py3-none-any.whl", hash = "sha256:8f16c07b36add9da6b2ee87d3efcaf0a45a6de9c3d0a5dd94e9ccf7675a7bc45", size = 32253, upload-time = "2026-10-31T14:23:46.33Z" }, + { url = "https://files.pythonhosted.org/packages/f5/0e/090c52b122d8ec5fa37942c1410fea9cf04ce98bca0c84dde7f0aa11594d/python_multipart-0.0.34-py3-none-any.whl", hash = "sha256:ebacd224bd686eee2f9aa1066a657affe07435a185834e05e5235e2e59173e91", size = 32585, upload-time = "2026-11-16T10:40:37.119Z" }, ] [[package]]