From abb60d456aeda8f4c0fca18d39c2b55cd872e10e Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Fri, 31 Jul 2026 10:35:28 -0400 Subject: [PATCH] Move local tracing out of the harness into src/tracing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The local trace spool (writer, reader, retention), the zero-config local OTel runtime, and the agent span capture (provider, content attributes, trace-state store, span-processor router) are a tracing subsystem, not harness internals — the harness only feeds them instrumentation events. They move to src/tracing, importable as #tracing/*. The harness keeps the instrumentation vocabulary the tool loop owns (lifecycle events, hooks, the AI SDK bridge, the runtime registry); tracing depends on that surface and nothing depends back. Guard rule 15's workflow-import ban now covers src/tracing alongside channel and harness. No behavior change. Signed-off-by: Chad Hietala --- .changeset/tracing-module-move.md | 5 +++++ .../eve/src/cli/commands/trace.integration.test.ts | 2 +- packages/eve/src/cli/commands/trace.ts | 4 ++-- .../cli/dev/tui/traces/trace-conversation.test.ts | 2 +- .../src/cli/dev/tui/traces/trace-conversation.ts | 4 ++-- packages/eve/src/cli/dev/tui/traces/trace-store.ts | 6 +++--- .../eve/src/cli/dev/tui/traces/trace-view.test.ts | 2 +- packages/eve/src/cli/dev/tui/traces/trace-view.ts | 4 ++-- .../dev/tui/traces/trace-viewer-session.test.ts | 2 +- .../cli/dev/tui/traces/trace-viewer-state.test.ts | 2 +- .../src/cli/dev/tui/traces/trace-viewer-state.ts | 2 +- .../src/execution/dispatch-runtime-actions-step.ts | 2 +- packages/eve/src/execution/workflow-steps.ts | 2 +- .../nitro/host/local-tracing-runtime-plugin.ts | 2 +- .../agent-otel-content.test.ts | 2 +- .../src/{harness => tracing}/agent-otel-content.ts | 0 .../agent-otel-provider.test.ts | 2 +- .../{harness => tracing}/agent-otel-provider.ts | 2 +- .../agent-trace-context-store.test.ts | 2 +- .../agent-trace-context-store.ts | 2 +- .../agent-trace-span-processor.test.ts | 2 +- .../agent-trace-span-processor.ts | 0 ...strumentation-runtime-conflict.scenario.test.ts | 2 +- .../local-instrumentation-runtime.scenario.test.ts | 6 +++--- .../local-instrumentation-runtime.ts | 10 +++++----- .../src/{harness => tracing}/local-trace-reader.ts | 2 +- .../local-trace-retention.integration.test.ts | 4 ++-- .../local-trace-retention.test.ts | 2 +- .../{harness => tracing}/local-trace-retention.ts | 2 +- .../local-trace-span-processor.ts | 0 scripts/guard-invariants.mjs | 14 ++++++++------ 31 files changed, 51 insertions(+), 44 deletions(-) create mode 100644 .changeset/tracing-module-move.md rename packages/eve/src/{harness => tracing}/agent-otel-content.test.ts (98%) rename packages/eve/src/{harness => tracing}/agent-otel-content.ts (100%) rename packages/eve/src/{harness => tracing}/agent-otel-provider.test.ts (99%) rename packages/eve/src/{harness => tracing}/agent-otel-provider.ts (99%) rename packages/eve/src/{harness => tracing}/agent-trace-context-store.test.ts (98%) rename packages/eve/src/{harness => tracing}/agent-trace-context-store.ts (99%) rename packages/eve/src/{harness => tracing}/agent-trace-span-processor.test.ts (98%) rename packages/eve/src/{harness => tracing}/agent-trace-span-processor.ts (100%) rename packages/eve/src/{harness => tracing}/local-instrumentation-runtime-conflict.scenario.test.ts (93%) rename packages/eve/src/{harness => tracing}/local-instrumentation-runtime.scenario.test.ts (97%) rename packages/eve/src/{harness => tracing}/local-instrumentation-runtime.ts (91%) rename packages/eve/src/{harness => tracing}/local-trace-reader.ts (99%) rename packages/eve/src/{harness => tracing}/local-trace-retention.integration.test.ts (98%) rename packages/eve/src/{harness => tracing}/local-trace-retention.test.ts (96%) rename packages/eve/src/{harness => tracing}/local-trace-retention.ts (99%) rename packages/eve/src/{harness => tracing}/local-trace-span-processor.ts (100%) diff --git a/.changeset/tracing-module-move.md b/.changeset/tracing-module-move.md new file mode 100644 index 000000000..9a2427695 --- /dev/null +++ b/.changeset/tracing-module-move.md @@ -0,0 +1,5 @@ +--- +"eve": patch +--- + +The local tracing subsystem (spool writer/reader, retention, the zero-config local OTel runtime, and agent span capture) moved from `src/harness` into its own `src/tracing` module; no behavior change. diff --git a/packages/eve/src/cli/commands/trace.integration.test.ts b/packages/eve/src/cli/commands/trace.integration.test.ts index 33f3b3ce3..7ab0f464b 100644 --- a/packages/eve/src/cli/commands/trace.integration.test.ts +++ b/packages/eve/src/cli/commands/trace.integration.test.ts @@ -4,7 +4,7 @@ import { join } from "node:path"; import { afterEach, describe, expect, it } from "vitest"; -import { listLocalTraces } from "#harness/local-trace-reader.js"; +import { listLocalTraces } from "#tracing/local-trace-reader.js"; import { resolveLocalTraces, runTraceListCommand, runTraceShowCommand } from "./trace.js"; diff --git a/packages/eve/src/cli/commands/trace.ts b/packages/eve/src/cli/commands/trace.ts index eb0d0b033..b85484af7 100644 --- a/packages/eve/src/cli/commands/trace.ts +++ b/packages/eve/src/cli/commands/trace.ts @@ -2,12 +2,12 @@ import { basename } from "node:path"; import { formatElapsed } from "#cli/format-elapsed.js"; import { createCliTheme, renderCliSection, sanitizeForTerminal } from "#cli/ui/output.js"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import { compareLocalTraceSpans, describeLocalTraceSpan, listLocalTraces, -} from "#harness/local-trace-reader.js"; +} from "#tracing/local-trace-reader.js"; const TRACE_DISPLAY_DIRECTORY = ".eve/traces/v1"; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts b/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts index 9b9cbb246..c85825246 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-conversation.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import { stripAnsi, visibleLength } from "#cli/ui/terminal-text.js"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import { createTheme } from "../theme.js"; import { buildConversationItems, renderConversationItem } from "./trace-conversation.js"; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts b/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts index 56d4fb031..41897adcc 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-conversation.ts @@ -14,8 +14,8 @@ import { visibleLength, wrapVisibleLine, } from "#cli/ui/terminal-text.js"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; -import { compareLocalTraceSpans } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; +import { compareLocalTraceSpans } from "#tracing/local-trace-reader.js"; import { formatCompactTokenCount } from "../stream-format.js"; import type { Theme } from "../theme.js"; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-store.ts b/packages/eve/src/cli/dev/tui/traces/trace-store.ts index e22f6e3f4..f61c4ed91 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-store.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-store.ts @@ -10,12 +10,12 @@ import { readdir, readFile, stat } from "node:fs/promises"; import { join } from "node:path"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; -import { assembleLocalTrace, parseLocalTraceSegment } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; +import { assembleLocalTrace, parseLocalTraceSegment } from "#tracing/local-trace-reader.js"; import { resolveLocalTraceSchemaDirectory, resolveLocalTraceSegmentsDirectory, -} from "#harness/local-trace-span-processor.js"; +} from "#tracing/local-trace-span-processor.js"; const TRACE_ID_PATTERN = /^[0-9a-f]{32}$/u; const SPAN_FILE_PATTERN = /^[0-9a-f]{16}\.otlp\.json$/u; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-view.test.ts b/packages/eve/src/cli/dev/tui/traces/trace-view.test.ts index ab8608d19..8c058c1b2 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-view.test.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-view.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from "vitest"; import { stripAnsi, visibleLength } from "#cli/ui/terminal-text.js"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import { createTheme } from "../theme.js"; import { diff --git a/packages/eve/src/cli/dev/tui/traces/trace-view.ts b/packages/eve/src/cli/dev/tui/traces/trace-view.ts index 83abd9d06..82473800c 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-view.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-view.ts @@ -15,8 +15,8 @@ import { visibleLength, wrapVisibleLine, } from "#cli/ui/terminal-text.js"; -import type { LocalTraceSpan } from "#harness/local-trace-reader.js"; -import { describeLocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTraceSpan } from "#tracing/local-trace-reader.js"; +import { describeLocalTraceSpan } from "#tracing/local-trace-reader.js"; import type { Theme } from "../theme.js"; import { formatAttributeContent } from "./trace-content.js"; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-viewer-session.test.ts b/packages/eve/src/cli/dev/tui/traces/trace-viewer-session.test.ts index 012fda7fd..bef133ebb 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-viewer-session.test.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-viewer-session.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import { createTheme } from "../theme.js"; import type { TraceStore } from "./trace-store.js"; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.test.ts b/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.test.ts index 3f1badd46..5262376fb 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.test.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import type { TraceStoreEntry } from "./trace-store.js"; import type { TerminalKey } from "../stream-format.js"; diff --git a/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.ts b/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.ts index 6a20a6ca0..bbd38d24d 100644 --- a/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.ts +++ b/packages/eve/src/cli/dev/tui/traces/trace-viewer-state.ts @@ -7,7 +7,7 @@ * viewer without losing the user's selection. */ -import type { LocalTrace, LocalTraceSpan } from "#harness/local-trace-reader.js"; +import type { LocalTrace, LocalTraceSpan } from "#tracing/local-trace-reader.js"; import type { ConversationItem } from "#cli/dev/tui/traces/trace-conversation.js"; import { diff --git a/packages/eve/src/execution/dispatch-runtime-actions-step.ts b/packages/eve/src/execution/dispatch-runtime-actions-step.ts index 35145513c..3c6443250 100644 --- a/packages/eve/src/execution/dispatch-runtime-actions-step.ts +++ b/packages/eve/src/execution/dispatch-runtime-actions-step.ts @@ -46,7 +46,7 @@ import { buildSubagentRunInput, type SubagentInputSource } from "#execution/suba import { createWorkflowRuntime, workflowEntryReference } from "#execution/workflow-runtime.js"; import { createLogger, logError } from "#internal/logging.js"; import { toErrorMessage } from "#shared/errors.js"; -import { readSessionTraceContext } from "#harness/agent-trace-context-store.js"; +import { readSessionTraceContext } from "#tracing/agent-trace-context-store.js"; import { resolveSubagentDepth } from "#harness/subagent-depth.js"; const log = createLogger("execution.dispatch-runtime-actions"); diff --git a/packages/eve/src/execution/workflow-steps.ts b/packages/eve/src/execution/workflow-steps.ts index b7a37bf14..3517aec08 100644 --- a/packages/eve/src/execution/workflow-steps.ts +++ b/packages/eve/src/execution/workflow-steps.ts @@ -19,7 +19,7 @@ import { BundleKey, ChannelKey } from "#runtime/sessions/runtime-context-keys.js import { runStep } from "#context/run-step.js"; import { deserializeContext, serializeContext } from "#context/serialize.js"; import { getHarnessEmissionState } from "#harness/emission.js"; -import { preserveSerializedAgentTraceState } from "#harness/agent-trace-context-store.js"; +import { preserveSerializedAgentTraceState } from "#tracing/agent-trace-context-store.js"; import { readTurnSleepDurationMs } from "#harness/turn-sleep.js"; import { isTurnCancellation, throwIfTurnAborted } from "#harness/turn-cancellation.js"; import { setChannelContext } from "#execution/channel-context.js"; diff --git a/packages/eve/src/internal/nitro/host/local-tracing-runtime-plugin.ts b/packages/eve/src/internal/nitro/host/local-tracing-runtime-plugin.ts index af0ca6d37..fe9833763 100644 --- a/packages/eve/src/internal/nitro/host/local-tracing-runtime-plugin.ts +++ b/packages/eve/src/internal/nitro/host/local-tracing-runtime-plugin.ts @@ -1,6 +1,6 @@ import { basename } from "node:path"; -import { installLocalInstrumentationRuntime } from "#harness/local-instrumentation-runtime.js"; +import { installLocalInstrumentationRuntime } from "#tracing/local-instrumentation-runtime.js"; import { resolveInstalledPackageInfo } from "#internal/application/package.js"; import { DEVELOPMENT_WORKER_APP_ROOT_ENV } from "#internal/workflow/development-world-protocol.js"; diff --git a/packages/eve/src/harness/agent-otel-content.test.ts b/packages/eve/src/tracing/agent-otel-content.test.ts similarity index 98% rename from packages/eve/src/harness/agent-otel-content.test.ts rename to packages/eve/src/tracing/agent-otel-content.test.ts index b49595c72..0984747d6 100644 --- a/packages/eve/src/harness/agent-otel-content.test.ts +++ b/packages/eve/src/tracing/agent-otel-content.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest"; import { CONTENT_ATTRIBUTE_LIMIT, toolResultsContentAttribute, -} from "#harness/agent-otel-content.js"; +} from "#tracing/agent-otel-content.js"; describe("toolResultsContentAttribute", () => { it("returns the full payload when it fits", () => { diff --git a/packages/eve/src/harness/agent-otel-content.ts b/packages/eve/src/tracing/agent-otel-content.ts similarity index 100% rename from packages/eve/src/harness/agent-otel-content.ts rename to packages/eve/src/tracing/agent-otel-content.ts diff --git a/packages/eve/src/harness/agent-otel-provider.test.ts b/packages/eve/src/tracing/agent-otel-provider.test.ts similarity index 99% rename from packages/eve/src/harness/agent-otel-provider.test.ts rename to packages/eve/src/tracing/agent-otel-provider.test.ts index 9cd394feb..3019fe046 100644 --- a/packages/eve/src/harness/agent-otel-provider.test.ts +++ b/packages/eve/src/tracing/agent-otel-provider.test.ts @@ -12,7 +12,7 @@ import { createAgentOtelInstrumentation, InMemoryAgentTraceStateStore, SESSION_WINDOW_TURN_LIMIT, -} from "#harness/agent-otel-provider.js"; +} from "#tracing/agent-otel-provider.js"; import { createInstrumentationHooks, type InstrumentationAttemptScope, diff --git a/packages/eve/src/harness/agent-otel-provider.ts b/packages/eve/src/tracing/agent-otel-provider.ts similarity index 99% rename from packages/eve/src/harness/agent-otel-provider.ts rename to packages/eve/src/tracing/agent-otel-provider.ts index 06d9b32dc..73ac55810 100644 --- a/packages/eve/src/harness/agent-otel-provider.ts +++ b/packages/eve/src/tracing/agent-otel-provider.ts @@ -15,7 +15,7 @@ import { systemPromptAttribute, textContentAttribute, toolResultsContentAttribute, -} from "#harness/agent-otel-content.js"; +} from "#tracing/agent-otel-content.js"; import type { InstrumentationAttemptMetadataEvent, InstrumentationAttemptScope, diff --git a/packages/eve/src/harness/agent-trace-context-store.test.ts b/packages/eve/src/tracing/agent-trace-context-store.test.ts similarity index 98% rename from packages/eve/src/harness/agent-trace-context-store.test.ts rename to packages/eve/src/tracing/agent-trace-context-store.test.ts index f95856b3e..66e2d5d2d 100644 --- a/packages/eve/src/harness/agent-trace-context-store.test.ts +++ b/packages/eve/src/tracing/agent-trace-context-store.test.ts @@ -6,7 +6,7 @@ import { ContextAgentTraceStateStore, preserveSerializedAgentTraceState, readSessionTraceContext, -} from "#harness/agent-trace-context-store.js"; +} from "#tracing/agent-trace-context-store.js"; describe("ContextAgentTraceStateStore", () => { it("restores serializable session and turn context", async () => { diff --git a/packages/eve/src/harness/agent-trace-context-store.ts b/packages/eve/src/tracing/agent-trace-context-store.ts similarity index 99% rename from packages/eve/src/harness/agent-trace-context-store.ts rename to packages/eve/src/tracing/agent-trace-context-store.ts index 8fa4e24d1..1efee94d8 100644 --- a/packages/eve/src/harness/agent-trace-context-store.ts +++ b/packages/eve/src/tracing/agent-trace-context-store.ts @@ -6,7 +6,7 @@ import type { AgentSessionTraceState, AgentTraceStateStore, AgentTurnTraceState, -} from "#harness/agent-otel-provider.js"; +} from "#tracing/agent-otel-provider.js"; interface AgentTraceContextState { readonly sessions: Readonly>; diff --git a/packages/eve/src/harness/agent-trace-span-processor.test.ts b/packages/eve/src/tracing/agent-trace-span-processor.test.ts similarity index 98% rename from packages/eve/src/harness/agent-trace-span-processor.test.ts rename to packages/eve/src/tracing/agent-trace-span-processor.test.ts index 4aa5d788d..1287deba0 100644 --- a/packages/eve/src/harness/agent-trace-span-processor.test.ts +++ b/packages/eve/src/tracing/agent-trace-span-processor.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it, vi } from "vitest"; -import { AgentTraceSpanProcessor } from "#harness/agent-trace-span-processor.js"; +import { AgentTraceSpanProcessor } from "#tracing/agent-trace-span-processor.js"; describe("AgentTraceSpanProcessor", () => { it("routes an agent trace and releases it at session terminal", () => { diff --git a/packages/eve/src/harness/agent-trace-span-processor.ts b/packages/eve/src/tracing/agent-trace-span-processor.ts similarity index 100% rename from packages/eve/src/harness/agent-trace-span-processor.ts rename to packages/eve/src/tracing/agent-trace-span-processor.ts diff --git a/packages/eve/src/harness/local-instrumentation-runtime-conflict.scenario.test.ts b/packages/eve/src/tracing/local-instrumentation-runtime-conflict.scenario.test.ts similarity index 93% rename from packages/eve/src/harness/local-instrumentation-runtime-conflict.scenario.test.ts rename to packages/eve/src/tracing/local-instrumentation-runtime-conflict.scenario.test.ts index 359100af2..5db09a7c8 100644 --- a/packages/eve/src/harness/local-instrumentation-runtime-conflict.scenario.test.ts +++ b/packages/eve/src/tracing/local-instrumentation-runtime-conflict.scenario.test.ts @@ -6,7 +6,7 @@ import { trace } from "@opentelemetry/api"; import { BasicTracerProvider } from "@opentelemetry/sdk-trace-base"; import { afterEach, describe, expect, it } from "vitest"; -import { installLocalInstrumentationRuntime } from "#harness/local-instrumentation-runtime.js"; +import { installLocalInstrumentationRuntime } from "#tracing/local-instrumentation-runtime.js"; let appRoot: string | undefined; diff --git a/packages/eve/src/harness/local-instrumentation-runtime.scenario.test.ts b/packages/eve/src/tracing/local-instrumentation-runtime.scenario.test.ts similarity index 97% rename from packages/eve/src/harness/local-instrumentation-runtime.scenario.test.ts rename to packages/eve/src/tracing/local-instrumentation-runtime.scenario.test.ts index 56795d413..2e655a620 100644 --- a/packages/eve/src/harness/local-instrumentation-runtime.scenario.test.ts +++ b/packages/eve/src/tracing/local-instrumentation-runtime.scenario.test.ts @@ -8,10 +8,10 @@ import { afterEach, describe, expect, it } from "vitest"; import { ContextContainer, contextStorage } from "#context/container.js"; import { createAiSdkHookBridge } from "#harness/ai-sdk-hook-bridge.js"; -import { listLocalTraces } from "#harness/local-trace-reader.js"; +import { listLocalTraces } from "#tracing/local-trace-reader.js"; import type { InstrumentationAttemptScope } from "#harness/instrumentation-lifecycle.js"; -import { installLocalInstrumentationRuntime } from "#harness/local-instrumentation-runtime.js"; -import { LocalTraceSpanProcessor } from "#harness/local-trace-span-processor.js"; +import { installLocalInstrumentationRuntime } from "#tracing/local-instrumentation-runtime.js"; +import { LocalTraceSpanProcessor } from "#tracing/local-trace-span-processor.js"; const temporaryDirectories: string[] = []; diff --git a/packages/eve/src/harness/local-instrumentation-runtime.ts b/packages/eve/src/tracing/local-instrumentation-runtime.ts similarity index 91% rename from packages/eve/src/harness/local-instrumentation-runtime.ts rename to packages/eve/src/tracing/local-instrumentation-runtime.ts index ce59ad1db..e0fb3a2ff 100644 --- a/packages/eve/src/harness/local-instrumentation-runtime.ts +++ b/packages/eve/src/tracing/local-instrumentation-runtime.ts @@ -1,9 +1,9 @@ import { context, trace } from "#compiled/@opentelemetry/api/index.js"; import { registerOTel } from "#compiled/@vercel/otel/index.js"; -import { ContextAgentTraceStateStore } from "#harness/agent-trace-context-store.js"; -import { createAgentOtelInstrumentation } from "#harness/agent-otel-provider.js"; -import { AgentTraceSpanProcessor } from "#harness/agent-trace-span-processor.js"; +import { ContextAgentTraceStateStore } from "#tracing/agent-trace-context-store.js"; +import { createAgentOtelInstrumentation } from "#tracing/agent-otel-provider.js"; +import { AgentTraceSpanProcessor } from "#tracing/agent-trace-span-processor.js"; import { createInstrumentationHooks, type InstrumentationProviderDefinition, @@ -16,8 +16,8 @@ import { import { requestLocalTraceStorePrune, resolveLocalTraceRetentionSettings, -} from "#harness/local-trace-retention.js"; -import { LocalTraceSpanProcessor } from "#harness/local-trace-span-processor.js"; +} from "#tracing/local-trace-retention.js"; +import { LocalTraceSpanProcessor } from "#tracing/local-trace-span-processor.js"; /** Installs the zero-config local OTel runtime once in an `eve dev` worker. */ export function installLocalInstrumentationRuntime(input: { diff --git a/packages/eve/src/harness/local-trace-reader.ts b/packages/eve/src/tracing/local-trace-reader.ts similarity index 99% rename from packages/eve/src/harness/local-trace-reader.ts rename to packages/eve/src/tracing/local-trace-reader.ts index aa8e8de3f..bfc775a7b 100644 --- a/packages/eve/src/harness/local-trace-reader.ts +++ b/packages/eve/src/tracing/local-trace-reader.ts @@ -11,7 +11,7 @@ import { readdir, readFile, stat } from "node:fs/promises"; import { join } from "node:path"; -import { resolveLocalTraceSchemaDirectory } from "#harness/local-trace-span-processor.js"; +import { resolveLocalTraceSchemaDirectory } from "#tracing/local-trace-span-processor.js"; const TRACE_ID_PATTERN = /^[0-9a-f]{32}$/u; const SPAN_FILE_PATTERN = /^([0-9a-f]{16})\.otlp\.json$/u; diff --git a/packages/eve/src/harness/local-trace-retention.integration.test.ts b/packages/eve/src/tracing/local-trace-retention.integration.test.ts similarity index 98% rename from packages/eve/src/harness/local-trace-retention.integration.test.ts rename to packages/eve/src/tracing/local-trace-retention.integration.test.ts index 7efc963e5..acd2e2e2c 100644 --- a/packages/eve/src/harness/local-trace-retention.integration.test.ts +++ b/packages/eve/src/tracing/local-trace-retention.integration.test.ts @@ -3,11 +3,11 @@ import { join } from "node:path"; import { describe, expect, it } from "vitest"; -import { pruneLocalTraceStore } from "#harness/local-trace-retention.js"; +import { pruneLocalTraceStore } from "#tracing/local-trace-retention.js"; import { resolveLocalTraceSchemaDirectory, resolveLocalTraceSegmentsDirectory, -} from "#harness/local-trace-span-processor.js"; +} from "#tracing/local-trace-span-processor.js"; import { useTemporaryDirectories } from "#internal/testing/use-temporary-app-roots.js"; const createScratchDirectory = useTemporaryDirectories(); diff --git a/packages/eve/src/harness/local-trace-retention.test.ts b/packages/eve/src/tracing/local-trace-retention.test.ts similarity index 96% rename from packages/eve/src/harness/local-trace-retention.test.ts rename to packages/eve/src/tracing/local-trace-retention.test.ts index 691befa26..b2b2cd531 100644 --- a/packages/eve/src/harness/local-trace-retention.test.ts +++ b/packages/eve/src/tracing/local-trace-retention.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; -import { resolveLocalTraceRetentionSettings } from "#harness/local-trace-retention.js"; +import { resolveLocalTraceRetentionSettings } from "#tracing/local-trace-retention.js"; const SEVEN_DAYS_MS = 7 * 24 * 60 * 60 * 1_000; const FIVE_HUNDRED_TWELVE_MIB = 512 * 1024 * 1024; diff --git a/packages/eve/src/harness/local-trace-retention.ts b/packages/eve/src/tracing/local-trace-retention.ts similarity index 99% rename from packages/eve/src/harness/local-trace-retention.ts rename to packages/eve/src/tracing/local-trace-retention.ts index 21ccbe6f3..04779410e 100644 --- a/packages/eve/src/harness/local-trace-retention.ts +++ b/packages/eve/src/tracing/local-trace-retention.ts @@ -5,7 +5,7 @@ import { join } from "node:path"; import { resolveLocalTraceSchemaDirectory, resolveLocalTraceSegmentsDirectory, -} from "#harness/local-trace-span-processor.js"; +} from "#tracing/local-trace-span-processor.js"; import { createLogger, formatError } from "#internal/logging.js"; const log = createLogger("harness.local-trace-retention"); diff --git a/packages/eve/src/harness/local-trace-span-processor.ts b/packages/eve/src/tracing/local-trace-span-processor.ts similarity index 100% rename from packages/eve/src/harness/local-trace-span-processor.ts rename to packages/eve/src/tracing/local-trace-span-processor.ts diff --git a/scripts/guard-invariants.mjs b/scripts/guard-invariants.mjs index b89abc581..9405c2835 100644 --- a/scripts/guard-invariants.mjs +++ b/scripts/guard-invariants.mjs @@ -16,10 +16,10 @@ * rule 13 — No spread-ternary object composition * (`...(c ? {} : { k: v })`). (Rationale: hard to read, easy * to mistype; declare the object then assign optional keys.) - * rule 15 — No `@workflow/*` imports inside `src/channel/**` or - * `src/harness/**`. Channels and harnesses must stay - * workflow-agnostic — only runtime/execution code touches - * workflow primitives. + * rule 15 — No `@workflow/*` imports inside `src/channel/**`, + * `src/harness/**`, or `src/tracing/**`. Channels, harnesses, + * and tracing must stay workflow-agnostic — only + * runtime/execution code touches workflow primitives. * rule 19 — No `new AsyncLocalStorage()` outside the two allowlisted * files. All ambient runtime state flows through a single * `EveContext`. @@ -240,7 +240,9 @@ const WORKFLOW_IMPORT_RE = /from ["']@workflow\b/; */ function isChannelOrHarness(posix) { return ( - posix.startsWith("packages/eve/src/channel/") || posix.startsWith("packages/eve/src/harness/") + posix.startsWith("packages/eve/src/channel/") || + posix.startsWith("packages/eve/src/harness/") || + posix.startsWith("packages/eve/src/tracing/") ); } @@ -257,7 +259,7 @@ function checkRule15(posix, lines, violations) { rule: 15, file: posix, line: idx + 1, - message: `imports from "@workflow/*". Channel and harness code must stay workflow-agnostic. Move the workflow primitive call into src/runtime/ or src/execution/ and have the channel/harness call a thin runtime helper instead.`, + message: `imports from "@workflow/*". Channel, harness, and tracing code must stay workflow-agnostic. Move the workflow primitive call into src/runtime/ or src/execution/ and have the caller use a thin runtime helper instead.`, }); } });