Repository navigation
feat: add --json --samples N for bounded one-shot NDJSON (v1.6.5) - #50
Merged
Merged
Conversation
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.
Summary
Agent/script one-shots against
--jsonpreviously had to kill the process after reading a record — the NDJSON stream runs until interrupted. This adds--json --samples N: emit exactly N snapshot records then exit 0.actop/actop.py: new--samples Nargument (validated >= 0; 0 = current infinite-stream default) forwarded from_run_exporttorun_json_stream(max_samples=...)— the function already hadmax_samples, it was just never exposed on the CLI.tests/test_export.py:test_json_samples_limits_records_and_exits_zero— spawns the real CLI with--json --samples 2 --interval 1, asserts exactly 2 records and returncode 0 (without the wiring it streams forever and trips the subprocess timeout).Why this is safe/useful for agents
The first
--jsonrecord already carries real deltas —Monitorprimes the baseline at construction (api.py), so--json --samples 1is a clean single-snapshot tool call (~2s, exit 0, no kill required). Verified manually:--samples 2emitted exactly 2 records, exit 0.Validation
.venv/bin/ruff check --fix ./.venv/bin/ruff format .clean..venv/bin/pytest -q -m "not local"→ 91 passed.pytest tests/test_export.py::test_json_samples_limits_records_and_exits_zero→ passed (Apple Silicon local)..venv/bin/python -m actop.actop --json --samples 2 --interval 1→ 2 NDJSON records, exit 0, empty stderr.