Skip to content

feat(itmux): reusable observability exporter primitive#256

Draft
NeuralEmpowerment wants to merge 126 commits into
feat/itmux-run-contractfrom
feat/observability-exporter-primitive
Draft

feat(itmux): reusable observability exporter primitive#256
NeuralEmpowerment wants to merge 126 commits into
feat/itmux-run-contractfrom
feat/observability-exporter-primitive

Conversation

@NeuralEmpowerment

@NeuralEmpowerment NeuralEmpowerment commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds the reusable observability primitive on top of the itmux run contract and finalizes the LangFuse integration boundary after the ADR-039 pivot.

Current code in this PR provides:

  • typed ObservabilityExporter fanout with active file and syntropic_jsonl backends
  • ObservabilityBundle exporter reports with status, event counts, targets, links, and errors
  • itmux run, itmux codex-exec, and itmux claude-transcript local observability export paths
  • itmux run --codex-mode exec for Codex recipes that need structured tool/token/cost telemetry through the standard run surface
  • Codex exec observer with model-aware usage telemetry
  • Claude hook/transcript observer with redacted tool spans, usage generations, and live workspace drain
  • agent-facing itmux langfuse-trace summaries, including compact generation-level cost breakdowns and --output summary
  • agent-facing itmux langfuse-traces discovery for recent runs with harness/provider/model/cost/observation counts
  • agent-facing itmux langfuse-score / itmux langfuse-scores feedback write/read for trace-scoped learning-loop scores
  • itmux langfuse-trace --include-scores for one-call trace telemetry plus feedback-score retrospectives
  • local LangFuse Docker Compose bootstrap/readiness path for MacBook now, Mac mini/VPS later
  • setup doctor for Claude/Codex official plugin readiness without printing secrets
  • ADR-039, setup guide, and runbook documenting that official LangFuse Claude/Codex plugins are canonical for rich traces

Important boundary: this PR no longer contains a native Rust LangFuse OTLP write exporter. Historical experiments in this branch proved why the direct Rust OTLP path was not the right rich-trace UX. ADR-039 supersedes that path. LangFuse writes for Claude/Codex rich traces happen through LangFuse's official Claude Code and Codex plugins; Agentic Primitives owns local JSONL/Syntropic fanout plus LangFuse query/score/readiness tooling.

Current Evidence

Current local proof is centered on the official-plugin path and agent query/readiness tooling:

  • official Claude trace 0e553fc833c71639acd03be9807eb616
  • official Codex trace b3d2561d7c0557c12fd427c02a16e2f3
  • itmux langfuse-trace can query both traces and expose harness/provider/model/tool/cost summaries
  • the agentic-langfuse MCP server can query the same summaries for learning-loop use
  • scripts/langfuse-local.sh smoke loads ignored local env and runs the setup/readiness doctor
  • scripts/langfuse-observability-doctor.sh reports Claude/Codex official plugin readiness, runtime env set/missing state, local JSONL/Syntropic fanout support, MCP presence, and confirms the direct writer is removed

Historical evidence that remains useful but is no longer the active public setup path:

  • old langfuse_otlp and --observability-langfuse experiments under experiments/2026-07-07--langfuse-*
  • local receiver / OTLP shape experiments that informed ADR-039
  • old direct-writer LangFuse traces that demonstrated low-value generic spans compared with official plugins

Current Boundary

.6 is represented by the reusable observability substrate in this PR:

  • normalized event fanout
  • file exporter
  • Syntropic137 projection exporter
  • backend-independent exporter reports
  • Codex exec observer
  • recipe-driven Codex exec mode
  • Claude hook/transcript observer
  • stock image packaging
  • setup/readiness doctor
  • official-plugin setup docs/runbook
  • CI coverage

.9 is not closed by this PR. It is unblocked for target deployment work:

  • stand up a durable LangFuse server on Mac mini or VPS
  • reach it over Tailscale or HTTPS
  • provision LangFuse project credentials outside the repo
  • point MacBook, VPS, and isolated Docker workspaces at that server
  • produce real Claude and Codex official-plugin traces against the centralized backend
  • verify LangFuse UI plus itmux langfuse-* and MCP learning-loop reads

Codex and Claude both have rich observability paths now:

  • Claude rich LangFuse traces: official LangFuse Claude Code plugin
  • Codex rich LangFuse traces: official LangFuse Codex plugin
  • Agentic Primitives local evidence: --observability-file and --observability-syntropic-file
  • Agentic Primitives learning loops: itmux langfuse-trace(s), itmux langfuse-score(s), and agentic-langfuse MCP

This PR remains draft because it is stacked on feat/itmux-run-contract / PR #247 rather than directly on main.

Validation

Local checks for the latest head include:

  • bash -n scripts/langfuse-local.sh scripts/langfuse-observability-doctor.sh
  • git diff --check
  • cargo test --manifest-path providers/workspaces/interactive-tmux/driver-rs/Cargo.toml
  • scripts/langfuse-local.sh smoke

GitHub checks are green for the latest head 150b65e, including:

  • QA Success
  • Plugin Validation
  • Plugin Version Check
  • Python Events / Isolation / Logging / Hooks & Unit Tests
  • Consumer Contract Tests
  • Rust itmux (fmt, clippy, test)
  • Integration Gate: claude-cli
  • Build: claude-cli
  • Build: interactive-tmux

Known caveat: cargo may print pre-existing APSS template {{slug}} package-name diagnostics before compiling; those diagnostics are non-fatal.

Review Notes

A delegated review correctly flagged that the old PR body overstated the current code by claiming an active langfuse_otlp writer backend and real native Rust OTLP export. That claim is stale and has been corrected here. The current code intentionally has only file and syntropic_jsonl write exporters in the active run contract.

@NeuralEmpowerment

Copy link
Copy Markdown
Contributor Author

Finish-line refresh pushed in 150b65e.

What changed:

  • Removed the direct Rust LangFuse writer from the active public run path/schema/CLI surface.
  • Kept local file JSONL + Syntropic JSONL fanout and agent-facing langfuse query/score commands.
  • Codified official LangFuse Claude/Codex plugins as the canonical rich-trace path in ADR/docs.
  • Added docs/runbooks/langfuse-observability.md for local MacBook/Mac mini, centralized Mac mini/VPS, Tailscale, and isolated Docker workspace setup.
  • Updated scripts/langfuse-local.sh so first init writes NEXTAUTH_URL from LANGFUSE_BASE_URL for centralized hosts.

Local validation before push:

  • bash -n scripts/langfuse-local.sh scripts/langfuse-observability-doctor.sh
  • git diff --check
  • cargo test --manifest-path providers/workspaces/interactive-tmux/driver-rs/Cargo.toml
  • scripts/langfuse-local.sh smoke -> claude_ready=true, codex_ready=true, runtime_ready=true, direct_langfuse_writer_removed=true, focused tests pass

Notes:

  • docs/handoffs/ remains untracked and intentionally not part of this PR.
  • .9 remains target deployment work: Mac mini/VPS LangFuse, credential provisioning, clients over Tailscale/HTTPS, then centralized CLI/MCP trace-query proof.

@NeuralEmpowerment

Copy link
Copy Markdown
Contributor Author

Acknowledging delegated review finding: the prior PR body overstated the current code by describing an active langfuse_otlp / native Rust OTLP write exporter. That is not present after the ADR-039 pivot and is intentionally removed from the active public run path. I updated the PR body to match the code: active write exporters are file and syntropic_jsonl; rich LangFuse writes for Claude/Codex come from the official LangFuse plugins; Agentic Primitives provides local fanout plus itmux langfuse-* query/score/readiness tooling. .9 remains centralized LangFuse deployment/proof work, not native Rust OTLP writer work.

@NeuralEmpowerment

Copy link
Copy Markdown
Contributor Author

Refactor follow-up for the main.rs size finding is pushed in 5a2589d. The LangFuse read/score CLI implementation and tests are now in providers/workspaces/interactive-tmux/driver-rs/src/langfuse.rs; main.rs is back down to CLI declarations/dispatch plus the workspace/run flows. Validation: cargo fmt, git diff --check, and cargo test --manifest-path providers/workspaces/interactive-tmux/driver-rs/Cargo.toml all passed locally. Cargo still prints the pre-existing APS template-manifest warnings from the dependency checkout before compiling, but itmux compiled and all tests passed.

@NeuralEmpowerment

Copy link
Copy Markdown
Contributor Author

Follow-up pushed in 2f5d96e.\n\nChanges:\n- Fixed LangFuse score readback robustness: Rust CLI and MCP direct fallback now send one narrowing backend filter, then enforce trace/name/score-id/type locally. This fixes the live local case where trace_id+name returned zero even though trace-only/name-only/score-id reads worked.\n- Added coverage for single-backend-filter score URL behavior.\n- Added scripts/langfuse-local.sh health for central-server reachability checks.\n- Updated the runbook with a concrete Mac mini/Tailscale pattern using tag:langfuse and tag:agents, plus client health check command.\n\nValidation:\n- live local combined score readback now returns the expected Codex score\n- git diff --check\n- full cargo test --manifest-path providers/workspaces/interactive-tmux/driver-rs/Cargo.toml\n- python3 -m py_compile plugins/observability/mcp/langfuse_server.py\n- python3 plugins/observability/mcp/langfuse_server.py --self-test\n- bash -n scripts/langfuse-local.sh scripts/langfuse-observability-doctor.sh\n- scripts/langfuse-local.sh health

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant