-
Notifications
You must be signed in to change notification settings - Fork 1
feat(maintenance): add immutable live-proof receipts #3879
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dec47d1
feat(maintenance): add immutable live-proof receipts
Sinity 7ec146b
fix(maintenance): bind every archive tier in live proofs
Sinity ecdc196
fix(maintenance): reject failed apply proof inputs
Sinity 9379415
fix(maintenance): harden live-proof evidence bindings
Sinity 5b8d02e
fix(maintenance): protect external archive generation outputs
Sinity 6068926
test(maintenance): cover normalized live-proof inputs
Sinity dc51e99
test(maintenance): cover archive-root alias binding
Sinity 968c241
test(maintenance): validate aliased live-proof receipts
Sinity 1fbd133
test(maintenance): redact aliased proof paths
Sinity f908901
fix(maintenance): harden live-proof freshness and storage safety
Sinity 9e67d5e
fix(maintenance): preserve live proof safety across promotion
Sinity 02e3ac9
docs(maintenance): name the live proof apply route
Sinity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """``maintenance live-proof``: collect one fixed, immutable evidence receipt.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
|
|
||
| import click | ||
|
|
||
| from polylogue.paths import archive_root | ||
|
|
||
|
|
||
| def _is_under_any(path: Path, roots: tuple[Path, ...]) -> bool: | ||
| return any(path == root or root in path.parents for root in roots) | ||
|
|
||
|
|
||
| @click.command("live-proof") | ||
| @click.option("--proof-id", required=True, help="One registered live-proof id.") | ||
| @click.option("--candidate-generation", type=str, help="Inactive generation id for the candidate proof route only.") | ||
| @click.option( | ||
| "--apply-receipt", | ||
| type=click.Path(path_type=Path, file_okay=True, dir_okay=False, readable=True), | ||
| help="Existing immutable apply receipt for the existing-apply route only.", | ||
| ) | ||
| @click.option( | ||
| "--output", | ||
| type=click.Path(path_type=Path, file_okay=True, dir_okay=False, writable=True), | ||
| required=True, | ||
| help="New receipt path outside the archive. Existing files are refused.", | ||
| ) | ||
| def live_proof_command( | ||
| proof_id: str, | ||
| candidate_generation: str | None, | ||
| apply_receipt: Path | None, | ||
| output: Path, | ||
| ) -> None: | ||
| """Collect one registered proof without mutating archive or daemon state.""" | ||
|
|
||
| from polylogue.maintenance.live_proof import ( | ||
| LiveProofError, | ||
| archive_owned_storage_roots, | ||
| collect_live_proof, | ||
| write_live_proof_receipt, | ||
| ) | ||
|
|
||
| root = archive_root().resolve() | ||
| target = output.expanduser().resolve() | ||
| try: | ||
| owned_roots = archive_owned_storage_roots(root) | ||
| if _is_under_any(target, owned_roots): | ||
| raise click.BadParameter("receipt output must be outside archive-owned storage", param_hint="--output") | ||
| receipt = collect_live_proof( | ||
| proof_id, | ||
| root, | ||
| candidate_generation_id=candidate_generation, | ||
| apply_receipt_path=apply_receipt, | ||
| ) | ||
| write_live_proof_receipt(target, receipt) | ||
| except LiveProofError as exc: | ||
| raise click.ClickException(str(exc)) from exc | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| except OSError as exc: | ||
| raise click.ClickException("live-proof receipt output could not be written") from exc | ||
| click.echo(json.dumps(receipt.to_document(), indent=2, sort_keys=True)) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
.index-active-pointeris malformed,ArchiveLocation.resolve()raisesArchiveLocationError, which is aRuntimeError; this call occurs inside a handler that catches onlyLiveProofErrorandOSError. The maintenance command therefore escapes through Click with an uncaught exception instead of reporting a normal actionable failure, even though the later binding collector already normalizes archive-location failures. Catch and translateArchiveLocationErrorhere or havearchive_owned_storage_roots()wrap it asLiveProofError.Useful? React with 👍 / 👎.