End-to-end: ``python -m orchestrator --target-pid <pid> --duration N`` now
writes a complete episode directory matching docs/data-model.md, with phase
labels, events, and a 10 Hz host /proc telemetry stream. No VM yet — pid is
arbitrary so we can validate the loop against e.g. ``sleep 5`` while the lab
side comes up.
collectors/proc_qemu.py — parses /proc/<pid>/{stat,io,status} (handles parens
in comm), single-shot collect_once(), and a stop-event-driven run_loop()
that ticks at a fixed cadence and exits when the pid disappears. Tagged
``available_in_deployment: false`` per the threat-model doc.
orchestrator/episode.py — EpisodeRunner: creates data/episodes/<ulid>/,
atomic meta.json, events.jsonl + labels.jsonl writers, drives the collector
in a thread for duration_s, writes done.marker last so the shipper never
sees a half-finished episode.
orchestrator/ulid.py — tiny 26-char Crockford-base32 ULID generator.
Time-sortable, no third-party dep.
orchestrator/__main__.py — CLI entry point.
Tests (15 new, 28 total green):
- proc_qemu: real-ish stat with parens-in-comm, missing /proc/<pid>/io,
missing pid, run_loop cadence, run_loop terminates when pid disappears.
- episode: full directory shape against os.getpid(), id override,
done.marker written after meta.json finalize.
- ulid: length+alphabet, 2000-burst uniqueness, time-sortability.
Smoke-tested against ``sleep 10``: 16 rows over 1.5s at 100ms cadence,
monotonic clock, RSS stable at ~3.5 MiB as expected for an idle sleep.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20 lines
514 B
Python
20 lines
514 B
Python
from __future__ import annotations
|
|
|
|
from orchestrator.ulid import new_ulid
|
|
|
|
|
|
def test_ulid_length_and_alphabet() -> None:
|
|
u = new_ulid()
|
|
assert len(u) == 26
|
|
assert all(c in "0123456789ABCDEFGHJKMNPQRSTVWXYZ" for c in u)
|
|
|
|
|
|
def test_ulid_uniqueness_burst() -> None:
|
|
seen = {new_ulid() for _ in range(2000)}
|
|
assert len(seen) == 2000
|
|
|
|
|
|
def test_ulid_time_sortable() -> None:
|
|
earlier = new_ulid(now_ms=1_700_000_000_000)
|
|
later = new_ulid(now_ms=1_700_000_001_000)
|
|
assert earlier < later
|