Repository navigation
Check recorded run conditions; limit run output; hash inputs once - #48
Merged
Merged
Conversation
The three P3s from the review of main at a986152. - Run conditions: ledger_transaction (and so record_run and record_parser_run) compares every stated RunConditions field with the limits the backend reported applying (SandboxResult.telemetry.limits, from #27): device against "gpu", memory, cpus, pids_limit against "pids", timeout_seconds. A mismatch, or a condition the backend does not report, raises ProvenanceError before anything is recorded. The RunConditions docstring no longer claims callers cannot assert them without that check existing. - Output limits: SandboxConfig.max_output_bytes (default 4 GiB) and max_output_files (default 100,000) are checked when the output is collected, before anything is stored in the archive. A run over either fails with the new FailureReason.OUTPUT_LIMIT and its output is removed, like an unsafe artifact. Writes during the run remain bounded only by the host filesystem; the docs say so. - Snapshots: snapshot_staged_input already verifies every blob as it stores it (expected_digest hashes new bytes and re-verifies a stored copy), so it now publishes the record through the archive's private _record_snapshot instead of put_snapshot, which hashed the whole input a second time. put_snapshot itself still re-hashes everything. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QRK7hqAaNLkH2JhWanY5VM
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes the three P3s from the review of main at a986152. The P1 and P2 from that review were fixed in #44.
Recorded run conditions weren't checked against the run
record_parser_runbuildsRunConditionsfrom the run itself, so it was trustworthy. Butledger_transactionandrecord_runaccepted anyRunConditionsa caller passed, even though theRunConditionsdocstring said they were "never asserted by a caller". A replay runs the parser under the recorded conditions, so a wrong value made the replay fail or report a misleading difference.#27 made every backend report the limits it applied, in
SandboxResult.telemetry.limits.ledger_transactionnow compares each stated condition with them:devicegpumemorymemorycpuscpuspids_limitpidstimeout_secondstimeout_secondsA mismatch, or a condition the backend doesn't report, raises
ProvenanceErrorbefore anything is recorded. The docstring now describes the check.Parser output on disk had no size limit
SandboxConfiggainsmax_output_bytes(default 4 GiB) andmax_output_files(default 100,000).FailureReason.OUTPUT_LIMIT, and its output is removed, the same way unsafe output is handled.artifact_dir.docs/containment.mdsays so and recommends a volume sized for the parsers you run. Enforcing a quota during the run would need a per-backend mechanism, which this PR doesn't add.Staged inputs were hashed twice (a cost #35 added)
snapshot_staged_inputstores every blob withexpected_digest, which already verifies it: new bytes are hashed while they're written, and a copy already in the store is re-hashed. It then calledput_snapshot, which hashed the whole input again.It now publishes the record through the archive's private
_record_snapshot. The publicput_snapshotstill re-hashes everything.Tests
tests/test_parsers.py:FakeBackendnow reports its limits likeOciBackend.tests/test_run_faults.py:OUTPUT_LIMIT, is removed, and nothing reaches the archive.tests/test_archive.py:put_snapshotstill does.🤖 Generated with Claude Code
https://claude.ai/code/session_01QRK7hqAaNLkH2JhWanY5VM
Generated by Claude Code