Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tracing-module-move.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/eve/src/cli/commands/trace.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 2 additions & 2 deletions packages/eve/src/cli/commands/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
4 changes: 2 additions & 2 deletions packages/eve/src/cli/dev/tui/traces/trace-conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
6 changes: 3 additions & 3 deletions packages/eve/src/cli/dev/tui/traces/trace-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/eve/src/cli/dev/tui/traces/trace-view.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/eve/src/cli/dev/tui/traces/trace-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion packages/eve/src/cli/dev/tui/traces/trace-viewer-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion packages/eve/src/execution/workflow-steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
systemPromptAttribute,
textContentAttribute,
toolResultsContentAttribute,
} from "#harness/agent-otel-content.js";
} from "#tracing/agent-otel-content.js";
import type {
InstrumentationAttemptMetadataEvent,
InstrumentationAttemptScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record<string, AgentSessionTraceState>>;
Expand Down
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
14 changes: 8 additions & 6 deletions scripts/guard-invariants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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/")
);
}

Expand All @@ -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.`,
});
}
});
Expand Down
Loading