Observability, Accounting and Reporting
Read-only projections of harness state: uh status and status –json, run reports and live run digests, the Delivery Observatory snapshot, read-only MCP server, cost tables/forecasts and runtime accounting, experience store, decision receipts, notifications, OTLP export and opt-in PostHog telemetry.
Depends on: Artifact Schemas (25), Mission Lifecycle and Artifact Store (12), Runtime Execution and Supervision (11), Runtime Adapters and In-Runtime Extensions (4), Verification, Review and Promotion (4), Run Control and Team Coordination (2)
Used by: Run Control and Team Coordination (10), CLI Entry, Build and Project Tooling (9), Runtime Execution and Supervision (6), Verification, Review and Promotion (2)
(Numbers are distinct file-to-file dependencies.)
| File | Summary | Key symbols |
|---|---|---|
src/harness/cost-forecast.ts |
History-based cost forecaster that averages token counts from past runs’ runtime.usage events and prices them with the adapter cost class, falling back to a prompt-size heuristic when no history exists. | readUsageHistory, costUsd, forecastCost |
src/harness/cost-table.ts |
Cost-class ranking helpers plus loading and lookup of the operator price table used to price complete token measurements, never guessing missing counters as zero. | compareCostClass, costClassWithinMax, loadOperatorPriceTable, operatorPriceFor, estimateOperatorCost |
src/harness/decision-receipts.ts |
Persists uh.decision-receipt.v0 records and decision.recorded events for acceptance, runtime-selection, and shadow loop-watchdog decisions, storing only composed outcomes and never raw provider inputs. | mapOutcome, recordAcceptanceDecision, recordRouteDecision, recordLoopWatchdogDecision |
src/harness/delivery-observatory/project.ts |
Builds the redacted Delivery Observatory snapshot by projecting missions, runs, team state, runtime controls, accounting, and verification artifacts under .harness into work items, agents, decisions, evidence, events, and metrics. | safeLabel, safeRouteIdentifier, readYamlArtifact, readJsonArtifact, mapOperation, countOmittedMissionFields, collectMissionProjections, projectDeliveryObservatory, … |
src/harness/experience-store.ts |
Experience store that indexes every mission and team-worker run into normalized run records with cost, usage, and efficiency data, then groups them by runtime, model, workflow, stop code, template, or tier and computes a Pareto frontier. | indexRun, indexTeamRuns, indexRuns, summarizeRuns, efficiencyMedians, paretoFrontier |
src/harness/mcp-server.ts |
Read-only MCP server exposing project status, indexed runs, run groups, and run artifacts as uh_status, uh_runs, and uh_run tools over newline-delimited JSON-RPC 2.0, serving both stateless and legacy protocol generations. | requireSafeId, rootNeedles, createMcpServer, serveMcpStdio |
src/harness/notifications.ts |
Settlement notification system that resolves user and project sinks (commands, webhooks, and presets such as Windows toasts), matches events to sinks, delivers with de-duplication, and reports what each attempt proved. | userDataDir, userNotificationsFile, windowsToastScript, expandPreset, resolveSink, loadNotificationConfig, matchesGlob, sinkMatches, … |
src/harness/otel-export.ts |
Converts a run directory’s events and runtime artifacts into an OTLP trace export with a run span and per-tool spans including token usage and error status. | parseEvents, extractUsage, exportRunToOtlp, buildToolSpan |
src/harness/otlp-push.ts |
Pushes an OTLP trace export to a normalized HTTP endpoint with timeout racing and typed ok/failed results. | normalizeEndpoint, raceTimeout, pushOtlpTraces |
src/harness/report.ts |
Implements uh report: a model-free, disk-only status report of a run built from its run digest or, for older runs, its events.ndjson, guaranteeing no absolute paths or credentials leak. |
ReportError, parseEvents, completionTimestamps, resolveReportTarget, uniqueTargets, identityFields, reportFromDigest, reportFromEvents, … |
src/harness/run-comparison.ts |
Pure statistics for comparing two run arms (e.g. session templates) by success rate with Wilson intervals and cost per success, treating unknown cost as unknown. | wilsonInterval, summarizeArm, compareArms, bestOfN, attemptsToMatch |
src/harness/run-digest.ts |
Live run digest: an incremental, bounded projection of native runtime events (tool calls, denials, usage, activity, efficiency) persisted as run-digest.json, with path relativization and credential redaction. | redactSecrets, sanitizeReportText, guardClassFromText, explicitGuardClass, containsContract, firstPathValue, callTargetInfo, collapse, … |
src/harness/runtime-accounting.ts |
Resolves per-run token usage and cost for accounting, preferring runtime-reported values, falling back to native event streams and an operator price table, and keeping unknown cost explicitly unknown. | tokenTotalsFromUsage, readRuntimeAccounting, runtimeAccountingFacts, nativeCostFactsFromEvents, readNativeCostFacts, resolveRunCost |
src/harness/status-json.ts |
LLM-less uh status --json mode (UH-78): produces a stable uh.status.v0 document of adapters, missions, recent runs and live runs read from disk without spawning subprocesses. |
getStatusJson, readPackageVersion, collectAdapters, collectMissions |
src/harness/status.ts |
Human uh status summary: counts adapters, workflows, missions, audit lines, skills, sandboxes by status, and passed or promoted missions from the harness directory. |
getStatus, listAdapters, countMissionDirs, emptySandboxStatusCounts, summarizeSandboxes, countPassedVerificationMissionDirs, countPromotedMissionDirs |
src/harness/telemetry-beacon.ts |
Self-contained detached beacon script spawned after the CLI exits that re-validates the PostHog capture endpoint (refusing loopback, private and reserved hosts and redirects) and POSTs the sanitized telemetry body read from environment variables, swallowing every failure. | refused, main |
src/harness/telemetry.ts |
Opt-in PostHog telemetry for the uh CLI: loads config from UH_TELEMETRY/UH_POSTHOG_* env vars, builds an aggregate-only payload (command, status, exit code, duration, version, platform), refuses private capture endpoints, and installs Commander hooks that fire an exit-safe detached beacon. | loadTelemetryConfig, sanitizeCommandPath, buildCapturePayload, isRefusedCaptureAddress, resolveCaptureEndpoint, captureCommandOutcome, sendBeacon, installTelemetryHooks |