Skip to content

feat: add --json --samples N for bounded one-shot NDJSON (v1.6.5) - #50

Merged
binlecode merged 1 commit into
mainfrom
fix/export-samples
Aug 9, 2026
Merged

binlecode merged 1 commit into
mainfrom
fix/export-samples

Conversation

@binlecode

Copy link
Copy Markdown
Owner

Summary

Agent/script one-shots against --json previously 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 N argument (validated >= 0; 0 = current infinite-stream default) forwarded from _run_export to run_json_stream(max_samples=...) — the function already had max_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).
  • Version bump 1.6.4 → 1.6.5 + CHANGELOG.

Why this is safe/useful for agents

The first --json record already carries real deltas — Monitor primes the baseline at construction (api.py), so --json --samples 1 is a clean single-snapshot tool call (~2s, exit 0, no kill required). Verified manually: --samples 2 emitted 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).
  • Manual: .venv/bin/python -m actop.actop --json --samples 2 --interval 1 → 2 NDJSON records, exit 0, empty stderr.

@binlecode
binlecode merged commit 7f9d553 into main Aug 9, 2026
5 checks passed
@binlecode
binlecode deleted the fix/export-samples branch August 9, 2026 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant