feat(tracing): instrument background worker jobs - #600
Conversation
Add masked, release-stamped Langfuse traces for embedding repair, DREAM/distill stages, and NATS message handling. Preserve provider usage metadata and record LLM-backed calls as generations.\n\nCo-Authored-By: Claude <noreply@anthropic.com>
Review swarm findings (posted before fixes, per program mandate)Opposite-family swarm at head 3cfbd75: 3 Claude Opus lanes (correctness / security / adversarial) with the freshly promoted #599 SME patterns injected, plus an independent mutation-proof re-verification. Deduplicated; lane attribution noted. No fixes have been made at the time of this comment. HIGHH1 (correctness + security + adversarial — all three lanes independently): the instrumentation is dead in BOTH production processes. Two distinct wiring gaps, same class as #599 H1 (
H2 (security): NATS trace H3 (security): global (namespace-null) DREAM/distill sweeps attach EVERY tenant's verbatim content to one job-supplied session trace. H4 (adversarial + security + correctness: the #599 H2 amplifier reproduced in the background lane): unbounded full row/candidate content in span inputs, with no projection bound, no dedup, no total-payload bound. MEDIUMM1 (correctness): unbounded per-job observation array — one distill job can build tens of thousands of observations (per-unit + per-hash) held in RAM and emitted as one synchronous loop on the poller's event loop. Cap with first-N/last-N + M2 (adversarial): vacuous tracing tests. The embedding-repair tracing test never asserts M3 (adversarial): no test proves a throwing emitter cannot fail a job — the module's central best-effort claim has zero coverage; every fixture is a recording emitter that cannot throw. Add LOW
Mutation-proof re-verification: CONFIRMED for emission, REFUTED for masking; perf test is a credible flakeIndependent reproduction at 3cfbd75: suppressing Perf test ( Verdict: not mergeable as-is. H1 defeats the purpose in both production processes; H2/H3 are trace-lane identity/isolation defects of exactly the kind this observability work exists to prevent; H4 is the measured amplifier class again. Fix lane launching next; fixes will be delta-verified before the Review Gate box is checked. |
…orker-tracing # Conflicts: # server/observability/langfuse-tracing.ts
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Fix-delta verification receipt (controller-posted) — 3cfbd75..06430efIndependent opposite-family verification against the CODE. All eight in-scope findings FIXED_VERIFIED (H1 wiring both composition roots — mutation-checked: deleting the wiring spread turns exactly the two composition-root tests red; H2 session binding after auth with the forged-key regression; H3 global sweeps emit no sessionId + per-observation namespace attribution; H4 non-size half — identifiers/hashes replace raw text everywhere named; M2 content-free regression now inspects tracing bodies with positive shape pins; M3 throwing-emitter identity-preserving tests; L1 dream.light try-scoped recorder + version guard; L2 rejection-propagation test + documented ack contract). Out-of-scope check clean: the fix delta touches nothing under BUT: mergeable = false on one NEW HIGH introduced by the trunk merge (55d701d), now being fixed: the merge's rewrite of A targeted fix lane is restoring the spans rendering with a real-sink seam test (red-then-green proof required). Merge happens only after that lands and is re-verified. |
Route retrieval spans and background observations through one parent lifecycle, and cover the real default sink with a red-then-green regression test.\n\nCo-Authored-By: Claude <noreply@anthropic.com>
H2 (trace session identity binds after auth) and H3 (global sweeps never session-joined) -> security; the trunk-merge silent-reversion catch -> gotcha-agent. Provenance: pull/600#issuecomment-5202749565 and pull/600#issuecomment-5203353650.
Summary
Part of #569
Verification
Evidence:
bunx tsc --noEmit— passed with/Users/rico/.config/open-brain/env.release-testsourcedbun test— 3,677 passed, 35 skipped, 0 failed across 239 filesOPENBRAIN_TEST_DATABASE_URLwas set by the release-test environmentBackgroundTraceRecorder.emitmade 8 emission tests fail across 6 files; restoring it returned the suite to green. This proves background emission, not masking.Critical Self-Review
prompt_tokens/total_tokens; usage degrades to omitted metadata. NATS session identity is attached only after server-side schema/auth/lane binding succeeds.OPENBRAIN_TRACING_*gate and existing release stamp, so rollback is a code revert with no stored-state cleanup.Review Gate
Contract Parity
Downstream Rollout
docs/downstream-rollout.mdNotes/evidence: