@stigmer/runner 3.14.0-dev.20260910084630 → 3.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/__test-utils__/hermetic-activity.d.ts +245 -0
  3. package/dist/__test-utils__/hermetic-activity.js +369 -0
  4. package/dist/__test-utils__/hermetic-activity.js.map +1 -0
  5. package/dist/__test-utils__/mock-client.d.ts +13 -0
  6. package/dist/__test-utils__/mock-client.js +45 -0
  7. package/dist/__test-utils__/mock-client.js.map +1 -0
  8. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +172 -0
  9. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +331 -0
  10. package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -0
  11. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +167 -0
  12. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +239 -0
  13. package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -0
  14. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +97 -0
  15. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +132 -0
  16. package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -0
  17. package/dist/harness/capabilities.d.ts +71 -0
  18. package/dist/harness/capabilities.js +36 -0
  19. package/dist/harness/capabilities.js.map +1 -0
  20. package/dist/harness/registry.d.ts +67 -0
  21. package/dist/harness/registry.js +112 -0
  22. package/dist/harness/registry.js.map +1 -0
  23. package/dist/harness/types.d.ts +268 -0
  24. package/dist/harness/types.js +55 -0
  25. package/dist/harness/types.js.map +1 -0
  26. package/package.json +4 -4
  27. package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +229 -0
  28. package/src/__test-utils__/config-fixture.ts +63 -0
  29. package/src/__test-utils__/harness-contract/contract.ts +536 -0
  30. package/src/__test-utils__/harness-contract/recording-sink.ts +96 -0
  31. package/src/__test-utils__/harness-contract/scripted-adapter.ts +289 -0
  32. package/src/__test-utils__/harness-contract/types.ts +100 -0
  33. package/src/__test-utils__/hermetic-activity.ts +477 -0
  34. package/src/__test-utils__/proto-helpers.ts +25 -0
  35. package/src/__tests__/harness-contract.test.ts +25 -0
  36. package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +422 -0
  37. package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +342 -0
  38. package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +166 -0
  39. package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +228 -0
  40. package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +180 -0
  41. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.status.json +55 -0
  42. package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.status.json +77 -0
  43. package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.status.json +126 -0
  44. package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +45 -0
  45. package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.status.json +48 -0
  46. package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.status.json +53 -0
  47. package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.status.json +68 -0
  48. package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +47 -0
  49. package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +201 -0
  50. package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +171 -0
  51. package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +156 -0
  52. package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +137 -0
  53. package/src/harness/__tests__/registry.test.ts +167 -0
  54. package/src/harness/capabilities.ts +75 -0
  55. package/src/harness/registry.ts +123 -0
  56. package/src/harness/types.ts +278 -0
@@ -1 +1 @@
1
- {"hash":"7c856383e6ad237f","builtAt":"2026-09-10T08:50:47.176Z","fileCount":293}
1
+ {"hash":"4056de20de2c1bdd","builtAt":"2026-09-11T16:01:46.462Z","fileCount":305}
@@ -0,0 +1,245 @@
1
+ /**
2
+ * Hermetic activity driver — run a REAL runner activity end to end with no
3
+ * network, no credentials, and no live Temporal worker, and read back every
4
+ * status it persisted.
5
+ *
6
+ * Why this exists: the runner's activities (`ExecuteCursor`, `ExecuteDeepAgent`)
7
+ * are the wire contract the control plane's workflow keys on — the phases they
8
+ * persist, the copy they write, whether they RETURN a slim status or THROW
9
+ * `CancelledFailure`. Refactoring them safely needs goldens recorded through the
10
+ * activity whole, not through its modules one at a time. The native harness
11
+ * tests already run their activity hermetically by mocking three modules at the
12
+ * boundary (`execute-deep-agent/__tests__/{index,hitl-*,sequential-gate-resume}.test.ts`);
13
+ * this module is that convention made reusable, harness-agnostic, and driven by
14
+ * the framework's own activity environment instead of a hand-written stand-in.
15
+ *
16
+ * What is generic here and what is not: everything an activity touches that is
17
+ * NOT the vendor SDK — the Temporal `Context`, the control-plane client, the
18
+ * runner-owned `~/.stigmer` tree, artifact storage, the model registry, the
19
+ * clock, the worker-shutdown signal — is set up here. The vendor SDK double
20
+ * belongs to the harness (`activities/execute-cursor/__test-utils__/scripted-*.ts`),
21
+ * the same split as `approval-contract/` (runner-wide kit) + each harness's
22
+ * `gateway-substrate.ts`.
23
+ *
24
+ * Three substitutions, and why each is shaped the way it is:
25
+ *
26
+ * 1. `Context.current()` — `MockActivityEnvironment` from `@temporalio/testing`,
27
+ * ONE PER INVOCATION. It gives the activity a real `Context` (real
28
+ * `cancellationSignal`, real `heartbeat()` surfaced as events, real
29
+ * `CancelledFailure` on throw). The native tests' stand-in mints a fresh
30
+ * `AbortController` on every `Context.current()` call and so cannot drive a
31
+ * pause; production hands each attempt one `Context`, and so does this. The
32
+ * environment's documented caveat — once cancelled it stays cancelled — is
33
+ * why it is per invocation and never shared.
34
+ *
35
+ * 2. `StigmerClient` — the test file mocks the module (`vi.mock` is hoisted and
36
+ * must live in the test file; see {@link hermeticStigmerClientModule}) and
37
+ * the constructor hands back whatever client {@link bindHermeticClient} bound
38
+ * for the current run. The client is `mockStigmerClient` over an
39
+ * {@link ExecutionRecord}: `updateStatus` writes back into the record the way
40
+ * the server would, so a REINVOCATION (`threadId` set) reads the transcript
41
+ * the first invocation persisted — the resume path runs on real data, not on
42
+ * a hand-built status.
43
+ *
44
+ * 3. The environment — a temp `HOME` (the runner-owned `~/.stigmer` tree,
45
+ * `platform-dir.ts` reads `process.env.HOME`), a temp workspace root, local
46
+ * artifact storage in a temp dir, and the HITL fingerprint secret pinned by
47
+ * env var (`fingerprint-secret.ts` falls back to `randomBytes` — the ONE
48
+ * source of randomness on the activity path — and memoizes on first call, so
49
+ * the pin must precede the first invocation in the process).
50
+ *
51
+ * Determinism: the clock is faked for `Date` ONLY (`vi.useFakeTimers({ toFake:
52
+ * ["Date"] })`) and TICKS — the harness double advances it a fixed quantum per
53
+ * script step through {@link ScriptedClock}. Frozen time would make
54
+ * `delta-enricher.ts`'s persist debounce (`Date.now() - lastPersistTime`) never
55
+ * elapse and silently skip the mid-stream persist path production always runs;
56
+ * a ticking clock runs the same path and lands on the same instants every run.
57
+ * Timers stay real so the periodic heartbeat and the stall watchdog behave.
58
+ *
59
+ * Not in scope: this module never edits a production module and never
60
+ * normalizes output. If a golden is not byte-stable, the volatile source is
61
+ * controlled at its origin or the surprise is escalated — never redacted here.
62
+ */
63
+ import { CancelledFailure } from "@temporalio/activity";
64
+ import { type AgentExecution, type AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
65
+ import { ApprovalAction, ExecutionPhase } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
66
+ import type { ToolCall } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
67
+ import type { Session } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
68
+ import type { Agent } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
69
+ import type { AgentInstance } from "@stigmer/protos/ai/stigmer/agentic/agentinstance/v1/api_pb";
70
+ import type { StigmerClient } from "../client/stigmer-client.js";
71
+ /**
72
+ * The four resources the activity's blueprint chain reads
73
+ * (`execution.spec.sessionId -> session.spec.agentInstanceId ->
74
+ * agentInstance.spec.agentId -> agent`) plus the status the server would hold.
75
+ */
76
+ export interface ExecutionRecordInput {
77
+ readonly execution: AgentExecution;
78
+ readonly session: Session;
79
+ readonly agentInstance: AgentInstance;
80
+ readonly agent: Agent;
81
+ }
82
+ /**
83
+ * An in-memory stand-in for the server's execution row, with the TWO merge
84
+ * rules the activity depends on and no others:
85
+ *
86
+ * - A status whose phase is UNSPECIFIED is a setup-progress report
87
+ * (`reportSetupProgress`): the server keeps `setup_progress` and leaves the
88
+ * phase and transcript alone. Modelled as: record the label, change nothing else.
89
+ * - Any other status replaces the held status wholesale (the runner is the
90
+ * writer of the transcript; the server's own field-ownership merge — approval
91
+ * fields it owns — is exercised by the test SETTING `approvalAction` on the
92
+ * record between invocations, exactly as `SubmitApproval` would).
93
+ *
94
+ * Every persisted status is also kept in order (`persisted`) so a test can
95
+ * assert the phase sequence the activity wrote, independent of the final state.
96
+ */
97
+ export declare class ExecutionRecord {
98
+ readonly execution: AgentExecution;
99
+ readonly session: Session;
100
+ readonly agentInstance: AgentInstance;
101
+ readonly agent: Agent;
102
+ /** Every `updateStatus` payload, in order, snapshotted at write time. */
103
+ readonly persisted: AgentExecutionStatus[];
104
+ /** Setup-progress labels reported before the stream started, in order. */
105
+ readonly setupProgress: string[];
106
+ /** Every `updateSession` payload, in order (the `harness_state_id` write-back). */
107
+ readonly sessionUpdates: Session[];
108
+ constructor(input: ExecutionRecordInput);
109
+ get executionId(): string;
110
+ /** The status the server would currently hold (what `getExecution` returns). */
111
+ get status(): AgentExecutionStatus | undefined;
112
+ /** The last FULL status written (phase set), or undefined if none yet. */
113
+ get lastFullStatus(): AgentExecutionStatus | undefined;
114
+ /**
115
+ * The ORDERED, DISTINCT phases the activity persisted — the deterministic
116
+ * shape of the persist cadence. The COUNT of persists depends on the
117
+ * debounce timer and is deliberately not exposed as an assertion surface.
118
+ */
119
+ get persistedPhases(): ExecutionPhase[];
120
+ /** Every tool call on the held transcript (top-level messages), in order. */
121
+ toolCalls(): ToolCall[];
122
+ /** The tool calls currently paused for a decision. */
123
+ waitingToolCalls(): ToolCall[];
124
+ /**
125
+ * What the server's `SubmitApproval` does to the row: record the decision on
126
+ * the tool call the runner wrote. The runner owns `status`; the server owns
127
+ * `approval_action` (field ownership, 005 mandate 2) — so this is the ONE
128
+ * place a test writes it, and the status stays WAITING_APPROVAL until the
129
+ * resumed turn runs the tool, exactly as in production.
130
+ */
131
+ decideWaitingToolCalls(action: ApprovalAction, decidedAt: string): number;
132
+ applyStatusUpdate(status: AgentExecutionStatus): void;
133
+ /**
134
+ * The control-plane client the activity sees: every read answers from this
135
+ * record; every write lands in it. Reads the activity makes for optional
136
+ * facets (execution context, channels, skills) answer the everyday shape —
137
+ * NOT_FOUND for the execution context (an execution with no env vars), no
138
+ * channels, no scoped token (the OSS/local posture) — so a scenario opts INTO
139
+ * a facet by overriding.
140
+ */
141
+ client(overrides?: Partial<StigmerClient>): StigmerClient;
142
+ }
143
+ /**
144
+ * Bind the client the mocked `StigmerClient` constructor hands out for the
145
+ * current run. Called by the harness driver immediately before invoking the
146
+ * activity factory (`createCursorActivities(config)` constructs its client
147
+ * inside the factory, so the bind must precede the factory call).
148
+ */
149
+ export declare function bindHermeticClient(client: StigmerClient): void;
150
+ /**
151
+ * The factory a test passes to `vi.mock(".../client/stigmer-client.js", ...)`.
152
+ * `vi.mock` is hoisted and must appear in the test file itself; the factory can
153
+ * `await import()` this module. Usage:
154
+ *
155
+ * ```ts
156
+ * vi.mock("../../../../client/stigmer-client.js", async () =>
157
+ * (await import("../../../../__test-utils__/hermetic-activity.js")).hermeticStigmerClientModule(),
158
+ * );
159
+ * ```
160
+ */
161
+ export declare function hermeticStigmerClientModule(): {
162
+ StigmerClient: new () => StigmerClient;
163
+ };
164
+ export interface HermeticEnvironment {
165
+ /** The temp `HOME` (the runner's `~/.stigmer` lands under it). */
166
+ readonly home: string;
167
+ /** The temp workspace root (`config.workspaceRootDir`). */
168
+ readonly workspaceRootDir: string;
169
+ /** The temp local artifact store (`LOCAL_ARTIFACT_PATH`). */
170
+ readonly artifactPath: string;
171
+ /** Restore every env var and remove the temp tree. Idempotent. */
172
+ dispose(): void;
173
+ }
174
+ /**
175
+ * Create the temp tree and pin the env vars. Call once per test FILE (in
176
+ * `beforeAll`) — the fingerprint secret is memoized per process on first use,
177
+ * and vitest isolates files in forks, so per-file is the natural unit.
178
+ */
179
+ export declare function createHermeticEnvironment(): HermeticEnvironment;
180
+ /**
181
+ * A deterministic, TICKING `Date`. Only `Date` is faked; timers stay real (the
182
+ * periodic heartbeat, the stall watchdog, `withTimeout` all need them). The
183
+ * harness double calls {@link ScriptedClock.tick} once per script step, so
184
+ * every `Date.now()`-based decision on the activity path (status timestamps,
185
+ * the enricher's persist debounce, cache TTLs) sees the same instants run after
186
+ * run and runs the same branches production runs.
187
+ */
188
+ export declare class ScriptedClock {
189
+ /** A fixed epoch: 2026-01-01T00:00:00.000Z. Chosen for readability in goldens. */
190
+ static readonly EPOCH_MS: number;
191
+ /** One second per step — well under any stall or cache horizon. */
192
+ static readonly STEP_MS = 1000;
193
+ private nowMs;
194
+ install(): void;
195
+ tick(ms?: number): void;
196
+ /** Back to the epoch — for a second scenario in the same file. */
197
+ reset(): void;
198
+ uninstall(): void;
199
+ }
200
+ /** How an activity invocation ended: the return value or the error it threw. */
201
+ export type ActivityOutcome = {
202
+ readonly kind: "returned";
203
+ readonly value: unknown;
204
+ } | {
205
+ readonly kind: "threw";
206
+ readonly error: unknown;
207
+ };
208
+ export interface ActivityInvocation {
209
+ readonly outcome: ActivityOutcome;
210
+ /** Heartbeat details the activity reported, in order. */
211
+ readonly heartbeats: unknown[];
212
+ /** The `taskQueue` the invocation ran on (the shutdown signal is keyed by it). */
213
+ readonly taskQueue: string;
214
+ }
215
+ /**
216
+ * Handles a scenario uses to interrupt the invocation FROM A SCRIPT STEP —
217
+ * never from a timer. `cancel()` aborts the activity's `cancellationSignal`
218
+ * (a user pause, as the workflow delivers it). `signalWorkerShutdown()` aborts
219
+ * the queue's shutdown signal first, which the activity reads to tell a worker
220
+ * drain from a user pause (`classifyTurnInterruption`).
221
+ */
222
+ export interface InvocationControls {
223
+ cancel(): void;
224
+ signalWorkerShutdown(): void;
225
+ }
226
+ export interface RunActivityOptions {
227
+ readonly taskQueue?: string;
228
+ /**
229
+ * Receives the invocation's controls before the activity starts, so a
230
+ * scenario can hand them to the harness double's `effect` steps.
231
+ */
232
+ readonly onControls?: (controls: InvocationControls) => void;
233
+ }
234
+ /**
235
+ * Run one activity function under a fresh `MockActivityEnvironment` and
236
+ * capture how it ended. `CancelledFailure` is caught like any other throw and
237
+ * reported as `{ kind: "threw" }` — the throw-vs-return table is the thing
238
+ * under test, so the driver never interprets it.
239
+ */
240
+ export declare function runActivityHermetically<A extends unknown[]>(activity: (...args: A) => Promise<unknown>, args: A, options?: RunActivityOptions): Promise<ActivityInvocation>;
241
+ /** True when the outcome is a thrown Temporal `CancelledFailure`. */
242
+ export declare function threwCancelledFailure(outcome: ActivityOutcome): outcome is {
243
+ kind: "threw";
244
+ error: CancelledFailure;
245
+ };
@@ -0,0 +1,369 @@
1
+ /**
2
+ * Hermetic activity driver — run a REAL runner activity end to end with no
3
+ * network, no credentials, and no live Temporal worker, and read back every
4
+ * status it persisted.
5
+ *
6
+ * Why this exists: the runner's activities (`ExecuteCursor`, `ExecuteDeepAgent`)
7
+ * are the wire contract the control plane's workflow keys on — the phases they
8
+ * persist, the copy they write, whether they RETURN a slim status or THROW
9
+ * `CancelledFailure`. Refactoring them safely needs goldens recorded through the
10
+ * activity whole, not through its modules one at a time. The native harness
11
+ * tests already run their activity hermetically by mocking three modules at the
12
+ * boundary (`execute-deep-agent/__tests__/{index,hitl-*,sequential-gate-resume}.test.ts`);
13
+ * this module is that convention made reusable, harness-agnostic, and driven by
14
+ * the framework's own activity environment instead of a hand-written stand-in.
15
+ *
16
+ * What is generic here and what is not: everything an activity touches that is
17
+ * NOT the vendor SDK — the Temporal `Context`, the control-plane client, the
18
+ * runner-owned `~/.stigmer` tree, artifact storage, the model registry, the
19
+ * clock, the worker-shutdown signal — is set up here. The vendor SDK double
20
+ * belongs to the harness (`activities/execute-cursor/__test-utils__/scripted-*.ts`),
21
+ * the same split as `approval-contract/` (runner-wide kit) + each harness's
22
+ * `gateway-substrate.ts`.
23
+ *
24
+ * Three substitutions, and why each is shaped the way it is:
25
+ *
26
+ * 1. `Context.current()` — `MockActivityEnvironment` from `@temporalio/testing`,
27
+ * ONE PER INVOCATION. It gives the activity a real `Context` (real
28
+ * `cancellationSignal`, real `heartbeat()` surfaced as events, real
29
+ * `CancelledFailure` on throw). The native tests' stand-in mints a fresh
30
+ * `AbortController` on every `Context.current()` call and so cannot drive a
31
+ * pause; production hands each attempt one `Context`, and so does this. The
32
+ * environment's documented caveat — once cancelled it stays cancelled — is
33
+ * why it is per invocation and never shared.
34
+ *
35
+ * 2. `StigmerClient` — the test file mocks the module (`vi.mock` is hoisted and
36
+ * must live in the test file; see {@link hermeticStigmerClientModule}) and
37
+ * the constructor hands back whatever client {@link bindHermeticClient} bound
38
+ * for the current run. The client is `mockStigmerClient` over an
39
+ * {@link ExecutionRecord}: `updateStatus` writes back into the record the way
40
+ * the server would, so a REINVOCATION (`threadId` set) reads the transcript
41
+ * the first invocation persisted — the resume path runs on real data, not on
42
+ * a hand-built status.
43
+ *
44
+ * 3. The environment — a temp `HOME` (the runner-owned `~/.stigmer` tree,
45
+ * `platform-dir.ts` reads `process.env.HOME`), a temp workspace root, local
46
+ * artifact storage in a temp dir, and the HITL fingerprint secret pinned by
47
+ * env var (`fingerprint-secret.ts` falls back to `randomBytes` — the ONE
48
+ * source of randomness on the activity path — and memoizes on first call, so
49
+ * the pin must precede the first invocation in the process).
50
+ *
51
+ * Determinism: the clock is faked for `Date` ONLY (`vi.useFakeTimers({ toFake:
52
+ * ["Date"] })`) and TICKS — the harness double advances it a fixed quantum per
53
+ * script step through {@link ScriptedClock}. Frozen time would make
54
+ * `delta-enricher.ts`'s persist debounce (`Date.now() - lastPersistTime`) never
55
+ * elapse and silently skip the mid-stream persist path production always runs;
56
+ * a ticking clock runs the same path and lands on the same instants every run.
57
+ * Timers stay real so the periodic heartbeat and the stall watchdog behave.
58
+ *
59
+ * Not in scope: this module never edits a production module and never
60
+ * normalizes output. If a golden is not byte-stable, the volatile source is
61
+ * controlled at its origin or the surprise is escalated — never redacted here.
62
+ */
63
+ import { mkdtempSync, rmSync } from "node:fs";
64
+ import { tmpdir } from "node:os";
65
+ import { join } from "node:path";
66
+ import { vi } from "vitest";
67
+ import { MockActivityEnvironment } from "@temporalio/testing";
68
+ import { CancelledFailure } from "@temporalio/activity";
69
+ import { Code, ConnectError } from "@connectrpc/connect";
70
+ import { clone, create } from "@bufbuild/protobuf";
71
+ import { AgentExecutionSchema, AgentExecutionStatusSchema, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
72
+ import { ExecutionPhase, ToolCallStatus, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
73
+ import { UpdateStatusResponseSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/io_pb";
74
+ import { registerWorkerShutdownSignal, signalWorkerShutdown, unregisterWorkerShutdownSignal, } from "../shared/worker-shutdown.js";
75
+ import { mockStigmerClient } from "./mock-client.js";
76
+ /**
77
+ * An in-memory stand-in for the server's execution row, with the TWO merge
78
+ * rules the activity depends on and no others:
79
+ *
80
+ * - A status whose phase is UNSPECIFIED is a setup-progress report
81
+ * (`reportSetupProgress`): the server keeps `setup_progress` and leaves the
82
+ * phase and transcript alone. Modelled as: record the label, change nothing else.
83
+ * - Any other status replaces the held status wholesale (the runner is the
84
+ * writer of the transcript; the server's own field-ownership merge — approval
85
+ * fields it owns — is exercised by the test SETTING `approvalAction` on the
86
+ * record between invocations, exactly as `SubmitApproval` would).
87
+ *
88
+ * Every persisted status is also kept in order (`persisted`) so a test can
89
+ * assert the phase sequence the activity wrote, independent of the final state.
90
+ */
91
+ export class ExecutionRecord {
92
+ execution;
93
+ session;
94
+ agentInstance;
95
+ agent;
96
+ /** Every `updateStatus` payload, in order, snapshotted at write time. */
97
+ persisted = [];
98
+ /** Setup-progress labels reported before the stream started, in order. */
99
+ setupProgress = [];
100
+ /** Every `updateSession` payload, in order (the `harness_state_id` write-back). */
101
+ sessionUpdates = [];
102
+ constructor(input) {
103
+ this.execution = clone(AgentExecutionSchema, input.execution);
104
+ this.session = input.session;
105
+ this.agentInstance = input.agentInstance;
106
+ this.agent = input.agent;
107
+ }
108
+ get executionId() {
109
+ return this.execution.metadata?.id ?? "";
110
+ }
111
+ /** The status the server would currently hold (what `getExecution` returns). */
112
+ get status() {
113
+ return this.execution.status;
114
+ }
115
+ /** The last FULL status written (phase set), or undefined if none yet. */
116
+ get lastFullStatus() {
117
+ for (let i = this.persisted.length - 1; i >= 0; i--) {
118
+ const s = this.persisted[i];
119
+ if (s.phase !== ExecutionPhase.EXECUTION_PHASE_UNSPECIFIED)
120
+ return s;
121
+ }
122
+ return undefined;
123
+ }
124
+ /**
125
+ * The ORDERED, DISTINCT phases the activity persisted — the deterministic
126
+ * shape of the persist cadence. The COUNT of persists depends on the
127
+ * debounce timer and is deliberately not exposed as an assertion surface.
128
+ */
129
+ get persistedPhases() {
130
+ const out = [];
131
+ for (const s of this.persisted) {
132
+ if (s.phase === ExecutionPhase.EXECUTION_PHASE_UNSPECIFIED)
133
+ continue;
134
+ if (out[out.length - 1] !== s.phase)
135
+ out.push(s.phase);
136
+ }
137
+ return out;
138
+ }
139
+ /** Every tool call on the held transcript (top-level messages), in order. */
140
+ toolCalls() {
141
+ return this.execution.status?.messages.flatMap((m) => m.toolCalls) ?? [];
142
+ }
143
+ /** The tool calls currently paused for a decision. */
144
+ waitingToolCalls() {
145
+ return this.toolCalls().filter((tc) => tc.status === ToolCallStatus.TOOL_CALL_WAITING_APPROVAL);
146
+ }
147
+ /**
148
+ * What the server's `SubmitApproval` does to the row: record the decision on
149
+ * the tool call the runner wrote. The runner owns `status`; the server owns
150
+ * `approval_action` (field ownership, 005 mandate 2) — so this is the ONE
151
+ * place a test writes it, and the status stays WAITING_APPROVAL until the
152
+ * resumed turn runs the tool, exactly as in production.
153
+ */
154
+ decideWaitingToolCalls(action, decidedAt) {
155
+ const waiting = this.waitingToolCalls();
156
+ for (const tc of waiting) {
157
+ tc.approvalAction = action;
158
+ tc.approvalDecidedAt = decidedAt;
159
+ }
160
+ return waiting.length;
161
+ }
162
+ applyStatusUpdate(status) {
163
+ const snapshot = clone(AgentExecutionStatusSchema, status);
164
+ this.persisted.push(snapshot);
165
+ if (snapshot.phase === ExecutionPhase.EXECUTION_PHASE_UNSPECIFIED) {
166
+ if (snapshot.setupProgress?.currentPhase) {
167
+ this.setupProgress.push(snapshot.setupProgress.currentPhase);
168
+ }
169
+ return;
170
+ }
171
+ this.execution.status = clone(AgentExecutionStatusSchema, snapshot);
172
+ }
173
+ /**
174
+ * The control-plane client the activity sees: every read answers from this
175
+ * record; every write lands in it. Reads the activity makes for optional
176
+ * facets (execution context, channels, skills) answer the everyday shape —
177
+ * NOT_FOUND for the execution context (an execution with no env vars), no
178
+ * channels, no scoped token (the OSS/local posture) — so a scenario opts INTO
179
+ * a facet by overriding.
180
+ */
181
+ client(overrides = {}) {
182
+ return mockStigmerClient({
183
+ getExecution: vi.fn(async () => clone(AgentExecutionSchema, this.execution)),
184
+ getSession: vi.fn(async () => this.session),
185
+ getAgentInstance: vi.fn(async () => this.agentInstance),
186
+ getAgent: vi.fn(async () => this.agent),
187
+ updateStatus: vi.fn(async (_id, status) => {
188
+ this.applyStatusUpdate(status);
189
+ // The activity reads only `.signal`; UNSPECIFIED means "keep going".
190
+ return create(UpdateStatusResponseSchema, {});
191
+ }),
192
+ updateSession: vi.fn(async (session) => {
193
+ this.sessionUpdates.push(session);
194
+ return session;
195
+ }),
196
+ getExecutionContextByExecutionId: vi.fn(async () => {
197
+ throw new ConnectError("execution context not found", Code.NotFound);
198
+ }),
199
+ ...overrides,
200
+ });
201
+ }
202
+ }
203
+ // ---------------------------------------------------------------------------
204
+ // The module-boundary seam for StigmerClient
205
+ // ---------------------------------------------------------------------------
206
+ let boundClient;
207
+ /**
208
+ * Bind the client the mocked `StigmerClient` constructor hands out for the
209
+ * current run. Called by the harness driver immediately before invoking the
210
+ * activity factory (`createCursorActivities(config)` constructs its client
211
+ * inside the factory, so the bind must precede the factory call).
212
+ */
213
+ export function bindHermeticClient(client) {
214
+ boundClient = client;
215
+ }
216
+ /**
217
+ * The factory a test passes to `vi.mock(".../client/stigmer-client.js", ...)`.
218
+ * `vi.mock` is hoisted and must appear in the test file itself; the factory can
219
+ * `await import()` this module. Usage:
220
+ *
221
+ * ```ts
222
+ * vi.mock("../../../../client/stigmer-client.js", async () =>
223
+ * (await import("../../../../__test-utils__/hermetic-activity.js")).hermeticStigmerClientModule(),
224
+ * );
225
+ * ```
226
+ */
227
+ export function hermeticStigmerClientModule() {
228
+ return {
229
+ StigmerClient: class {
230
+ constructor() {
231
+ if (!boundClient) {
232
+ throw new Error("hermetic-activity: no StigmerClient bound — call bindHermeticClient(record.client()) " +
233
+ "before constructing the activities");
234
+ }
235
+ return boundClient;
236
+ }
237
+ },
238
+ };
239
+ }
240
+ // ---------------------------------------------------------------------------
241
+ // The environment: temp HOME, temp workspace root, local artifact storage
242
+ // ---------------------------------------------------------------------------
243
+ /**
244
+ * The env-var pins a hermetic run needs, and the reason for each:
245
+ * - `HOME`: `platform-dir.ts` roots the runner-owned `~/.stigmer` tree (HITL
246
+ * gate dir, session dirs, denial ledger) on it.
247
+ * - `ARTIFACT_STORAGE_TYPE=local` + `LOCAL_ARTIFACT_PATH`: a writable local
248
+ * store so capture mode and tool-output offload run the production path
249
+ * (an absent store flips capture off — a different code path).
250
+ * - `STIGMER_RUNNER_HITL_SECRET`: the one randomness source on the activity
251
+ * path, pinned so grant tokens and fingerprints are byte-stable.
252
+ * - `CURSOR_EVENT_RECORD_DIR` cleared: never write recordings from a test.
253
+ */
254
+ const PINNED_ENV = {
255
+ ARTIFACT_STORAGE_TYPE: "local",
256
+ STIGMER_RUNNER_HITL_SECRET: "hermetic-fixture-secret-do-not-use-in-production",
257
+ };
258
+ const CLEARED_ENV = ["CURSOR_EVENT_RECORD_DIR", "STIGMER_PROXY_ENDPOINT", "STIGMER_CLOUD_API_URL"];
259
+ /**
260
+ * Create the temp tree and pin the env vars. Call once per test FILE (in
261
+ * `beforeAll`) — the fingerprint secret is memoized per process on first use,
262
+ * and vitest isolates files in forks, so per-file is the natural unit.
263
+ */
264
+ export function createHermeticEnvironment() {
265
+ const root = mkdtempSync(join(tmpdir(), "stigmer-hermetic-"));
266
+ const home = join(root, "home");
267
+ const workspaceRootDir = join(root, "workspaces");
268
+ const artifactPath = join(root, "artifacts");
269
+ const saved = new Map();
270
+ const set = (key, value) => {
271
+ if (!saved.has(key))
272
+ saved.set(key, process.env[key]);
273
+ if (value === undefined)
274
+ delete process.env[key];
275
+ else
276
+ process.env[key] = value;
277
+ };
278
+ set("HOME", home);
279
+ set("LOCAL_ARTIFACT_PATH", artifactPath);
280
+ for (const [k, v] of Object.entries(PINNED_ENV))
281
+ set(k, v);
282
+ for (const k of CLEARED_ENV)
283
+ set(k, undefined);
284
+ let disposed = false;
285
+ return {
286
+ home,
287
+ workspaceRootDir,
288
+ artifactPath,
289
+ dispose() {
290
+ if (disposed)
291
+ return;
292
+ disposed = true;
293
+ for (const [k, v] of saved) {
294
+ if (v === undefined)
295
+ delete process.env[k];
296
+ else
297
+ process.env[k] = v;
298
+ }
299
+ rmSync(root, { recursive: true, force: true });
300
+ },
301
+ };
302
+ }
303
+ // ---------------------------------------------------------------------------
304
+ // The clock
305
+ // ---------------------------------------------------------------------------
306
+ /**
307
+ * A deterministic, TICKING `Date`. Only `Date` is faked; timers stay real (the
308
+ * periodic heartbeat, the stall watchdog, `withTimeout` all need them). The
309
+ * harness double calls {@link ScriptedClock.tick} once per script step, so
310
+ * every `Date.now()`-based decision on the activity path (status timestamps,
311
+ * the enricher's persist debounce, cache TTLs) sees the same instants run after
312
+ * run and runs the same branches production runs.
313
+ */
314
+ export class ScriptedClock {
315
+ /** A fixed epoch: 2026-01-01T00:00:00.000Z. Chosen for readability in goldens. */
316
+ static EPOCH_MS = Date.UTC(2026, 0, 1, 0, 0, 0, 0);
317
+ /** One second per step — well under any stall or cache horizon. */
318
+ static STEP_MS = 1_000;
319
+ nowMs = ScriptedClock.EPOCH_MS;
320
+ install() {
321
+ vi.useFakeTimers({ toFake: ["Date"], now: this.nowMs });
322
+ }
323
+ tick(ms = ScriptedClock.STEP_MS) {
324
+ this.nowMs += ms;
325
+ vi.setSystemTime(this.nowMs);
326
+ }
327
+ /** Back to the epoch — for a second scenario in the same file. */
328
+ reset() {
329
+ this.nowMs = ScriptedClock.EPOCH_MS;
330
+ vi.setSystemTime(this.nowMs);
331
+ }
332
+ uninstall() {
333
+ vi.useRealTimers();
334
+ }
335
+ }
336
+ /**
337
+ * Run one activity function under a fresh `MockActivityEnvironment` and
338
+ * capture how it ended. `CancelledFailure` is caught like any other throw and
339
+ * reported as `{ kind: "threw" }` — the throw-vs-return table is the thing
340
+ * under test, so the driver never interprets it.
341
+ */
342
+ export async function runActivityHermetically(activity, args, options = {}) {
343
+ const taskQueue = options.taskQueue ?? "hermetic-test-queue";
344
+ const env = new MockActivityEnvironment({ taskQueue });
345
+ const heartbeats = [];
346
+ env.on("heartbeat", (details) => heartbeats.push(details));
347
+ // The worker-shutdown signal is process-global per queue; register for this
348
+ // invocation and always unregister so no state leaks into the next one.
349
+ registerWorkerShutdownSignal(taskQueue);
350
+ options.onControls?.({
351
+ cancel: () => env.cancel(),
352
+ signalWorkerShutdown: () => signalWorkerShutdown(taskQueue),
353
+ });
354
+ try {
355
+ const value = await env.run(activity, ...args);
356
+ return { outcome: { kind: "returned", value }, heartbeats, taskQueue };
357
+ }
358
+ catch (error) {
359
+ return { outcome: { kind: "threw", error }, heartbeats, taskQueue };
360
+ }
361
+ finally {
362
+ unregisterWorkerShutdownSignal(taskQueue);
363
+ }
364
+ }
365
+ /** True when the outcome is a thrown Temporal `CancelledFailure`. */
366
+ export function threwCancelledFailure(outcome) {
367
+ return outcome.kind === "threw" && outcome.error instanceof CancelledFailure;
368
+ }
369
+ //# sourceMappingURL=hermetic-activity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hermetic-activity.js","sourceRoot":"","sources":["../../src/__test-utils__/hermetic-activity.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAG3B,MAAM,6DAA6D,CAAC;AACrE,OAAO,EAEL,cAAc,EACd,cAAc,GACf,MAAM,8DAA8D,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,4DAA4D,CAAC;AAMxG,OAAO,EACL,4BAA4B,EAC5B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CAAC,CAAC;IAEpE,4EAA4E;IAC5E,wEAAwE;IACxE,4BAA4B,CAAC,SAAS,CAAC,CAAC;IACxC,OAAO,CAAC,UAAU,EAAE,CAAC;QACnB,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE;QAC1B,oBAAoB,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,SAAS,CAAC;KAC5D,CAAC,CAAC;IAEH,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACzE,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,CAAC;IACtE,CAAC;YAAS,CAAC;QACT,8BAA8B,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,qBAAqB,CAAC,OAAwB;IAC5D,OAAO,OAAO,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,KAAK,YAAY,gBAAgB,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Shared mock factory for StigmerClient used across test suites.
3
+ *
4
+ * StigmerClient is a class (not an interface), so mocks use
5
+ * `as unknown as StigmerClient` — matching the established pattern
6
+ * in grpc-retry.test.ts and connect-backfill.test.ts.
7
+ */
8
+ import type { StigmerClient } from "../client/stigmer-client.js";
9
+ type MockMethods = {
10
+ [K in keyof StigmerClient]?: StigmerClient[K];
11
+ };
12
+ export declare function mockStigmerClient(overrides?: MockMethods): StigmerClient;
13
+ export {};