feat(runtime)!: make capture retention and workload budgets explicit - #476
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 689414a36d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ("stdout", sink.stdout_path, sink.stdout_bytes), | ||
| ("stderr", sink.stderr_path, sink.stderr_bytes), | ||
| ): | ||
| digest, size = sha256_file(path) |
There was a problem hiding this comment.
Cap console hashing at the settled byte count
When a workload leaves a detached process running, that process can derive the request directory from a provider artifact path and continuously append to console-*/stdout after the broker closes its sink. This unbounded sha256_file(path) then follows the growing file indefinitely, outside the workload deadline and while run_in_request holds the runtime-wide lock, blocking every subsequent MCP operation. Hash only up to expected_size (and reject any extra byte) so settled console validation remains bounded.
AGENTS.md reference: AGENTS.md:L33-L41
Useful? React with 👍 / 👎.
| "returncode": True, | ||
| "status": True, | ||
| "failure_code": True, | ||
| "limit": True, |
There was a problem hiding this comment.
Project the target execution limit alongside oracle limits
For a preserved capture whose target hits the new RSS budget, the MCP evidence resource exposes failure_code: LIMIT_EXCEEDED and the requested budget but omits the target execution's limit receipt, even though this projection now retains that field for semantic oracles. After restart, an agent therefore cannot distinguish a memory-budget termination from output, writable-growth, or storage-reserve termination or inspect the observed value without leaving MCP and reading the private manifest. Include the top-level limit in this safe projection so the preserved execution provenance remains actionable.
AGENTS.md reference: AGENTS.md:L33-L34
Useful? React with 👍 / 👎.
| shutil.copyfile( | ||
| Path(__file__).with_name("pytest_capture.py"), | ||
| Path(directory) / "_flameox_pytest_capture.py", |
There was a problem hiding this comment.
Exclude the copied pytest plugin from artifact growth
When pytest capture is run with a lowered max_output_bytes (for example 1 KiB), this 5.5 KiB Flameox-owned plugin is copied into the capture's monitored writable root after the broker records its baseline. The resource observer consequently attributes the internal support file to workload artifact growth and can terminate an otherwise tiny pytest capture with WRITABLE_LIMIT_EXCEEDED. Materialize the plugin before the baseline is measured, or place it outside the provider output root, so request-lowered limits apply only to generated capture artifacts.
AGENTS.md reference: AGENTS.md:L46-L48
Useful? React with 👍 / 👎.
Summary
Make capture retention explicit and keep completed native evidence recoverable when immediate analysis fails.
Fixes #470, fixes #471, fixes #472, fixes #473, fixes #474, fixes #475.
Problem and expected behavior
Real Slime investigations exposed captures lost to decoder limits, verbose console output treated as a universal disk-storage requirement, delayed MCP cancellation, and incorrect provider coverage or execution-success reporting. A completed capture should remain available for analysis retry; bounded diagnostics must disclose omissions rather than imply complete logs.
Change
Suggested review order
runtime_contracts.py,stateless.py.execution.py.evidence_models.py,repository.py,mcp/server.py.Contract and boundary impact
target.console_output, optionaltarget.budget, CLI--console-output/--workload-budget/--limits; 49 generated tools.Example target options:
{"console_output":"full","budget":{"timeout_seconds":600,"max_memory_bytes":8589934592}}Both budget fields otherwise default to null. A decoder-limit failure now returns
isError: true,code: LIMIT_EXCEEDEDanddetails.partial_evidence, rather than losing the completed capture.Evidence and regression coverage
Executed real Slime scheduling, CUDA correctness, profiling and recovery workloads on Linux. A 1 KiB analysis-input limit reproduced capture loss before the recovery fix; afterward the native Memray profile survived and a fresh server reanalyzed it without rerunning Slime. Coverage.py regressions additionally check exact preserved bytes and source mappings.
Tests cover diagnostic omissions, full-output/oracle retention, cancellation, concurrent requests, explicit budgets, native rejection and external symlink sentinel survival. Existing investigation records distinguish measured observations from inferred conclusions; native workload artifacts remain local and are not included in this PR.
Remaining proof gaps: representative inference-server exports, broader platform/GPU coverage and a dedicated special-file rejection workload. Shared storage admission and native-artifact budget separation remain unfinished; this PR does not claim the investigation is exhausted.
Validation
On
689414a:uv run pytest -q— 349 passed, 192 deselected.uv run pytest tests/test_native_capture_recovery.py tests/test_workload_budgets.py tests/test_cli_stateless.py -q -o addopts=''— 50 passed.uv run ruff check src tests tools— passed.uv run mypy src tests tools— passed, 134 files.uv run ruff format --check src tests tools— passed, 134 files.git diff origin/main...HEAD --check— passed.Before the release-metadata-only merge, the broader capture/runtime/CLI run passed 183 tests with one skip and unraisable warnings treated as errors. Source and test contents are unchanged by that merge.
Compatibility and safety
Behavior changes are intentional: callers needing previous workload ceilings must explicitly set a budget; callers needing complete console evidence must select full retention unless the tool or oracle requires it. New failure manifests may require this reader version. Existing native storage safeguards remain; there is no claim of unlimited artifact storage, strict filesystem quotas or complete cross-platform validation.
Review checklist