Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

1.3 KB
Raw Blame
Act as a backend programmer on Harness. Build a Python 3 standard-library-only command-line tool named logscope.py for newline-delimited JSON logs. Read a file or stdin. Records contain level, service, and latency_ms. Print deterministic JSON with total valid rows, malformed rows, counts per level and service, and p50/p95 latency using nearest-rank percentiles. A malformed row should be counted and skipped, not crash. Negative or non-numeric latency is ignored for percentile calculations but the row remains valid. Empty input is valid. Add --level filtering. Create realistic fixtures and at least six meaningful unittest cases covering normal input, malformed input, empty input, percentile calculation, filtering, and stdin. Run python3 -m unittest discover -v and fix failures. Include a short README with terminal examples. Do not install dependencies. Work only in this project. Do the work now; do not ask questions or delegate to subagents.
Use these exact JSON result keys: total, malformed, levels, services, p50, p95. total counts valid records after any level filter. Null percentiles represent no eligible latencies. --level filters valid rows before counting and percentile calculation. The command is python3 logscope.py [--level LEVEL] [FILE]; without FILE it reads stdin.