feat(ultraplan-local): add stats event-emit for autonomy lifecycle events
Step 6 of plan-v2 (ultra-pipeline-speedup).
lib/stats/event-emit.mjs (NEW)
Atomic JSONL append to ${CLAUDE_PLUGIN_DATA}/ultraexecute-stats.jsonl.
Every record carries:
ts : ISO-8601 timestamp (REQUIRED per SC4)
event : caller-supplied name
known_event : true for { brief-approved, main-merge-gate, user_input },
false for everything else (still emitted — audit-complete)
payload : caller object (defaults to {})
Stats failures NEVER block workflow: missing CLAUDE_PLUGIN_DATA, missing
dir, mkdir failure, append failure → all return { written: false, reason }
without throwing.
CLI shim:
node lib/stats/event-emit.mjs --event NAME [--payload JSON]
Always exits 0 (telemetry is best-effort).
Tests: 12 (record-build + ISO-8601 ts + known/unknown distinction + silent
skip + dir-on-demand + CLI shim happy-path + bad-payload tolerance +
concurrent-append smoke).
[skip-docs]