@leitwerk-dev/test-support 0.3.0 → 0.4.0

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 (60) hide show
  1. package/dist/{chunk-OE4NHDVS.js → chunk-3RWI5WJK.js} +2 -2
  2. package/dist/{chunk-5BZSJ4OO.js → chunk-DNUGHAYN.js} +37 -4
  3. package/dist/chunk-DNUGHAYN.js.map +1 -0
  4. package/dist/{chunk-P2FF4AP7.js → chunk-FDXRT6UZ.js} +57 -2
  5. package/dist/chunk-FDXRT6UZ.js.map +1 -0
  6. package/dist/{chunk-E4Y7XND5.js → chunk-WRAVDPEM.js} +16 -27
  7. package/dist/chunk-WRAVDPEM.js.map +1 -0
  8. package/dist/extension-integration-harness.d.ts +2 -2
  9. package/dist/extension-integration-harness.d.ts.map +1 -1
  10. package/dist/fixtures.js.map +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +9 -26
  14. package/dist/index.js.map +1 -1
  15. package/dist/integration-harness.d.ts +2 -0
  16. package/dist/integration-harness.d.ts.map +1 -1
  17. package/dist/integration.d.ts +1 -1
  18. package/dist/integration.d.ts.map +1 -1
  19. package/dist/integration.js +54 -101
  20. package/dist/integration.js.map +1 -1
  21. package/dist/local-git.d.ts +9 -0
  22. package/dist/local-git.d.ts.map +1 -1
  23. package/dist/local-git.js +31 -0
  24. package/dist/local-git.js.map +1 -1
  25. package/dist/model-provider-fixtures.d.ts +7 -0
  26. package/dist/model-provider-fixtures.d.ts.map +1 -1
  27. package/dist/process.d.ts +32 -2
  28. package/dist/process.d.ts.map +1 -1
  29. package/dist/process.js +24 -15
  30. package/dist/process.js.map +1 -1
  31. package/dist/server-extension-test-harness.d.ts +3 -1
  32. package/dist/server-extension-test-harness.d.ts.map +1 -1
  33. package/dist/stub-worker-entry.js +1 -1
  34. package/dist/supported-question-fixtures.d.ts.map +1 -1
  35. package/dist/worker-testing/index.d.ts +1 -1
  36. package/dist/worker-testing/index.d.ts.map +1 -1
  37. package/dist/worker-testing/index.js +7 -4
  38. package/dist/worker-testing/index.js.map +1 -1
  39. package/dist/worker-testing/schema-driven-stub-pi.d.ts.map +1 -1
  40. package/dist/worker-testing/stub-pi-tree-handle.d.ts +15 -0
  41. package/dist/worker-testing/stub-pi-tree-handle.d.ts.map +1 -1
  42. package/dist/worker-testing/worker-start-payload.d.ts.map +1 -1
  43. package/package.json +10 -10
  44. package/src/extension-integration-harness.ts +44 -139
  45. package/src/index.ts +2 -0
  46. package/src/integration-harness.ts +17 -1
  47. package/src/integration.ts +1 -0
  48. package/src/local-git.ts +34 -0
  49. package/src/model-provider-fixtures.ts +40 -0
  50. package/src/process.ts +22 -12
  51. package/src/server-extension-test-harness.ts +40 -1
  52. package/src/supported-question-fixtures.ts +0 -20
  53. package/src/worker-testing/index.ts +1 -0
  54. package/src/worker-testing/schema-driven-stub-pi.ts +11 -23
  55. package/src/worker-testing/stub-pi-tree-handle.ts +34 -1
  56. package/src/worker-testing/worker-start-payload.ts +1 -0
  57. package/dist/chunk-5BZSJ4OO.js.map +0 -1
  58. package/dist/chunk-E4Y7XND5.js.map +0 -1
  59. package/dist/chunk-P2FF4AP7.js.map +0 -1
  60. /package/dist/{chunk-OE4NHDVS.js.map → chunk-3RWI5WJK.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/extension-integration-harness.ts","../src/integration-harness.ts","../src/polling.ts","../src/process-driver.ts"],"sourcesContent":["import type { ExtensionTestCapability } from \"./test-capability.js\";\n\nexport type { ExtensionTestCapability } from \"./test-capability.js\";\n\nimport { randomUUID } from \"node:crypto\";\nimport { mkdirSync, writeFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n\tActor,\n\tExternalWriteLog,\n\tProcessInstance,\n\tProcessProject,\n\tProcessTurnRecord,\n} from \"@leitwerk-dev/domain\";\nimport { buildExtensionCatalogFromModules } from \"@leitwerk-dev/extension-runtime/testing\";\nimport {\n\tcoreHostCapabilities,\n\ttype ExtensionProcessDefinition,\n\ttype LeitwerkExtensionModule,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createAcceptedLlmTurn, prepareAcceptedFixtureStart } from \"@leitwerk-dev/server/testing\";\nimport { postImmediateLaunch } from \"./http-launch.js\";\nimport { createPersistentIntegrationFixture } from \"./integration-harness.js\";\nimport { observe, type TestObservation } from \"./observations.js\";\nimport { createProcessFixture, type ProcessFixtureOptions } from \"./process-fixtures.js\";\nimport type { QuestionRequestFixture } from \"./supported-question-fixtures.js\";\nimport { StubPiTreeHandleFactory } from \"./worker-testing/stub-pi-tree-handle.js\";\n\n/** Model-visible inputs for a scripted invocation. @public */\nexport interface IntegrationPromptObservation {\n\t/** @public */\n\tturnId: string;\n\t/** Working directory available for fixture repository edits. @public */\n\tcwd: string;\n\t/** Opaque branch-session identity for comparing execution relationships. @public */\n\tbranchId: string;\n\t/** Text inherited by the current branch. @public */\n\thistory: string;\n\t/** @public */\n\ttools: readonly {\n\t\t/** @public */\n\t\tname: string;\n\t\t/** @public */\n\t\tparameters: Record<string, unknown>;\n\t}[];\n}\n\n/** Rendered result retained at a tree leaf. @public */\nexport interface IntegrationLeafObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tleafEntryId: string;\n\t/** @public */\n\tturnRecordId: string | null;\n\t/** @public */\n\trendererId: string | null;\n\t/** @public */\n\tschemaVersion: number | null;\n\t/** @public */\n\tprops: Record<string, unknown> | null;\n\t/** @public */\n\tfallbackMarkdown: string | null;\n\t/** @public */\n\tstatus: \"ready\" | \"capture_error\";\n}\n\n/** Recorded semantic event. @public */\nexport interface IntegrationEventObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\teventType: string;\n\t/** @public */\n\tdata: Record<string, unknown>;\n\t/** @public */\n\tcreatedAt: string;\n}\n\n/** Durable annotation of process execution. @public */\nexport interface IntegrationAnnotationObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tannotationType: string;\n\t/** @public */\n\tpayload: Record<string, unknown>;\n}\n\n/** One scripted model prompt, executed through registered tools. @public */\nexport interface IntegrationTurnScript {\n\t/** @public */\n\ttools: readonly IntegrationToolCall[];\n\t/** Scripted reasoning retained by the normal worker path. @public */\n\tthinking?: readonly string[];\n\t/** Assistant markdown for turns completed by model output. @public */\n\tmarkdown?: string;\n\t/** Optional model response after an integration-tool result. @public */\n\tafterToolResult?(call: IntegrationToolCall, result: unknown): IntegrationToolCall | undefined;\n}\n\n/** @public */\nexport interface IntegrationToolCall {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\targuments: Record<string, unknown>;\n}\n\n/** Instruction delivered through the application's durable input queue. @public */\nexport interface IntegrationProcessInput {\n\t/** @public */\n\tbodyMarkdown: string;\n\t/** Target a published product branch. @public */\n\tproduct?: string;\n}\n\n/** Durable instruction delivery observations. @public */\nexport interface IntegrationInputObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tsequence: number;\n\t/** @public */\n\tsource: string;\n\t/** @public */\n\tkind: string;\n\t/** @public */\n\tbodyMarkdown: string;\n\t/** @public */\n\ttarget: {\n\t\t/** @public */\n\t\tproductName?: string;\n\t\t/** @public */\n\t\tsemanticRef?: string;\n\t} | null;\n\t/** @public */\n\tactor: Actor;\n\t/** @public */\n\treceivedAt: string;\n\t/** @public */\n\tconsumedAt: string | null;\n}\n\n/** Operator approval observations. @public */\nexport interface IntegrationApprovalObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnRecordId: string;\n\t/** @public */\n\ttoolCallId: string;\n\t/** @public */\n\ttoolName: string;\n\t/** @public */\n\targuments: Record<string, unknown>;\n\t/** @public */\n\tdestination: {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tdisplayName: string;\n\t\t/** @public */\n\t\tgroup?: string;\n\t\t/** @public */\n\t\tdescription?: string;\n\t} | null;\n\t/** @public */\n\tstatus: \"open\" | \"accepted\" | \"feedback\" | \"declined\" | \"cancelled\";\n\t/** @public */\n\trequestedAt: string;\n\t/** @public */\n\tresolvedAt: string | null;\n\t/** @public */\n\tresolvedBy: Actor | null;\n\t/** @public */\n\tfeedback: string | null;\n}\n\n/** Explicit accepted execution setup, independent of process business state. @public */\nexport interface AcceptedTurnFixture {\n\t/** @public */\n\tturnId: string;\n\t/** @public */\n\texecution:\n\t\t| {\n\t\t\t\t/** @public */\n\t\t\t\tstatus: \"running\";\n\t\t }\n\t\t| {\n\t\t\t\t/** @public */\n\t\t\t\tstatus: \"succeeded\";\n\t\t\t\t/** @public */\n\t\t\t\toutcome: string;\n\t\t\t\t/** @public */\n\t\t\t\tmarkdown: string;\n\t\t };\n}\n\n/** Detached durable observations. @public */\nexport interface ExtensionIntegrationSnapshot {\n\t/** Harness-owned process workspace. @public */\n\tworkspaceRoot: string;\n\t/** @public */\n\tevents: IntegrationEventObservation[];\n\t/** @public */\n\tannotations: IntegrationAnnotationObservation[];\n\t/** @public */\n\tleafOutcomes: IntegrationLeafObservation[];\n\n\t/** @public */\n\tprocess: ProcessInstance;\n\t/** @public */\n\tparams: unknown;\n\t/** @public */\n\tstate: unknown;\n\t/** @public */\n\tprojects: ProcessProject[];\n\t/** @public */\n\tturns: ProcessTurnRecord[];\n\t/** @public */\n\tinputs: IntegrationInputObservation[];\n\t/** @public */\n\tquestions: QuestionRequestFixture[];\n\t/** @public */\n\tapprovals: IntegrationApprovalObservation[];\n\t/** @public */\n\twriteReceipts: ExternalWriteLog[];\n}\n\n/** @public */\nexport interface ExtensionIntegrationHarnessOptions {\n\t/** Per-process watcher configuration. @public */\n\twatchers?: Readonly<Record<string, Record<string, unknown>>>;\n\t/** Advance extension provider pollers explicitly in tests. @public */\n\tpolling?: \"automatic\" | \"manual\";\n\t/** Host Docker boundary for extensions which require it. @public */\n\thostDocker?: {\n\t\t/** @public */\n\t\tpreflight(timeoutMs: number): Promise<void>;\n\t};\n\n\t/** Configuration keyed by extension manifest id. @public */\n\textensionConfig?: Readonly<Record<string, unknown>>;\n\t/** @public */\n\textensions: readonly LeitwerkExtensionModule[];\n\t/** @public */\n\tcapabilities?: readonly ExtensionTestCapability[];\n\t/** Automatic execution starts admitted work immediately. @public */\n\texecution?: \"automatic\" | \"manual\";\n\t/** Model catalog used by the supplied provider extensions. @public */\n\tmodels?: readonly {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tprovider: string;\n\t\t/** @public */\n\t\tmodelId: string;\n\t\t/** @public */\n\t\tthinkingLevel?: \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\";\n\t}[];\n\t/** Default model profile for all registered processes. @public */\n\tdefaultModel?: string;\n\t/** Model scripts for automatic execution, in prompt order per process. @public */\n\tscript?(\n\t\tinstanceId: string,\n\t\tprompt: string,\n\t\tobservation: TestObservation<IntegrationPromptObservation>,\n\t): IntegrationTurnScript | Promise<IntegrationTurnScript>;\n}\n\n/** HTTP-shaped requests without a Fastify handle. @public */\nexport interface ExtensionTestRequest {\n\t/** @public */\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\t/** @public */\n\turl: string;\n\t/** @public */\n\tpayload?: Record<string, unknown>;\n\t/** @public */\n\theaders?: Record<string, string>;\n}\n\n/** HTTP response observation. @public */\nexport interface ExtensionTestResponse {\n\t/** @public */\n\tstatusCode: number;\n\t/** @public */\n\tbody: string;\n\t/** @public */\n\tjson<T = unknown>(): T;\n}\n\n/** Accepted turn identity and optional retained result. @public */\nexport interface AcceptedTurnReference {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnId: string;\n\t/** @public */\n\tartifact: {\n\t\t/** @public */ kind: \"turn_result\";\n\t\t/** @public */\n\t\tturnRecordId: string;\n\t} | null;\n}\n\n/** One durably settled worker execution. @public */\nexport interface IntegrationTurnResult {\n\t/** @public */\n\tturn: ProcessTurnRecord | null;\n\t/** @public */\n\toutcome: string | null;\n\t/** @public */\n\tfailure: string | null;\n\t/** @public */\n\tprompts: string[];\n\t/** @public */\n\ttoolResults: {\n\t\t/** @public */ name: string;\n\t\t/** @public */\n\t\tresult: unknown;\n\t}[];\n\t/** @public */\n\tresult: AcceptedTurnReference[\"artifact\"];\n}\n\n/** Durable process commands and observations. @public */\nexport interface ExtensionIntegrationProcess {\n\t/** @public */\n\treadonly id: string;\n\t/** @public */\n\tseedAcceptedTurn(fixture: AcceptedTurnFixture): Promise<TestObservation<AcceptedTurnReference>>;\n\t/** @public */\n\tsnapshot(): TestObservation<ExtensionIntegrationSnapshot>;\n\t/** @public */\n\twaitFor(\n\t\tcondition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,\n\t\toptions?: {\n\t\t\t/** @public */ timeoutMs?: number;\n\t\t\t/** @public */\n\t\t\tdescription?: string;\n\t\t},\n\t): Promise<TestObservation<ExtensionIntegrationSnapshot>>;\n\t/** @public */\n\trunTurn(script?: IntegrationTurnScript): Promise<TestObservation<IntegrationTurnResult>>;\n\t/** @public */\n\taction(id: string, input?: Record<string, unknown>): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tretry(): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tsupplyInput(\n\t\tinput: IntegrationProcessInput,\n\t): Promise<TestObservation<ExtensionIntegrationSnapshot>>;\n\t/** @public */\n\tanswerQuestions(\n\t\tid: string,\n\t\tanswers: readonly {\n\t\t\t/** @public */\n\t\t\tselectedOptionIds: readonly string[];\n\t\t\t/** @public */\n\t\t\tfreeText: string;\n\t\t\t/** @public */\n\t\t\tcomment: string;\n\t\t}[],\n\t): Promise<ExtensionTestResponse>;\n\t/** @public */\n\trespondToApproval(\n\t\tid: string,\n\t\tresponse: {\n\t\t\t/** @public */\n\t\t\taction: \"accept\" | \"feedback\" | \"decline\";\n\t\t\t/** @public */\n\t\t\tfeedback?: string;\n\t\t},\n\t): Promise<ExtensionTestResponse>;\n}\n\n/** Disposable persistent extension test environment. @public */\nexport interface ExtensionIntegrationHarness {\n\t/** Detached processes discovered or launched by extensions. @public */\n\tprocesses(): TestObservation<ProcessInstance[]>;\n\n\t/** @public */\n\trequest(input: ExtensionTestRequest): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tprocess(id: string): ExtensionIntegrationProcess;\n\t/** @public */\n\tlaunch(id: string, input: Record<string, unknown>): Promise<ExtensionIntegrationProcess>;\n\t/** @public */\n\tcreateProcess<TParams, TState>(\n\t\tdefinition: ExtensionProcessDefinition<TParams, TState>,\n\t\tinput?: Omit<ProcessFixtureOptions<TParams, TState>, \"id\" | \"processId\"> & {\n\t\t\t/** @public */\n\t\t\tprojects?: readonly ProcessProject[];\n\t\t},\n\t): Promise<ExtensionIntegrationProcess>;\n\t/** @public */\n\trestart(options?: {\n\t\t/** Update extension wiring on the reopened server. @public */\n\t\textensionConfig?: Readonly<Record<string, unknown>>;\n\t\t/** Apply external changes while the server is offline. @public */\n\t\twhileStopped?(): void | Promise<void>;\n\t}): Promise<void>;\n\t/** @public */\n\tclose(): Promise<void>;\n}\n\n/** Own server, workers, and disposable persistent storage. @public */\nexport async function createExtensionIntegrationHarness(\n\toptions: ExtensionIntegrationHarnessOptions,\n): Promise<ExtensionIntegrationHarness> {\n\tconst catalog = await buildExtensionCatalogFromModules([\n\t\t...(options.polling === \"manual\"\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmanifest: { id: \"test-support-manual-polling\", version: \"1\" },\n\t\t\t\t\t\tsetupServer(api: import(\"@leitwerk-dev/process-sdk\").ServerExtensionAPI) {\n\t\t\t\t\t\t\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\t\t\t\t\t\t\tif (!deps || Array.isArray(deps)) throw new Error(\"Missing polling host\");\n\t\t\t\t\t\t\tdeps.polling = {\n\t\t\t\t\t\t\t\tcreate(input) {\n\t\t\t\t\t\t\t\t\treturn { poll: input.pollOnce };\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: []),\n\t\t...options.extensions,\n\t]);\n\tconst persistent = createPersistentIntegrationFixture(\"leitwerk-extension-test-\", (config) => {\n\t\tconfig.extensions = structuredClone(options.extensionConfig ?? {});\n\t\tif (options.hostDocker && config.local_worker) config.local_worker.allow_host_docker = true;\n\t\tconfig.pi.model_profiles = (options.models ?? []).map((model) => ({\n\t\t\tid: model.id,\n\t\t\tprovider: model.provider,\n\t\t\tmodel_id: model.modelId,\n\t\t\tthinking_level: model.thinkingLevel ?? \"off\",\n\t\t}));\n\t\tif (options.defaultModel) {\n\t\t\tconfig.pi.process_title_generation.model_profile = options.defaultModel;\n\t\t\tconfig.process_configs = Object.fromEntries(\n\t\t\t\t[...catalog.processes.keys()].map((id) => [\n\t\t\t\t\tid,\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault_model_profile: options.defaultModel,\n\t\t\t\t\t\tturn_configs: {},\n\t\t\t\t\t\twatchers: structuredClone(options.watchers?.[id] ?? {}),\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\t});\n\tconst manual = options.execution === \"manual\";\n\tlet closed = false;\n\tconst pending = new Map<\n\t\tstring,\n\t\t{ turnId: string; resolve(): void; reject(error: Error): void }\n\t>();\n\tconst permits = new Set<string>();\n\tconst executing = new Set<string>();\n\tconst scripts = new Map<string, IntegrationTurnScript>();\n\tconst observations = new Map<\n\t\tstring,\n\t\t{ prompts: string[]; toolResults: { name: string; result: unknown }[] }\n\t>();\n\tconst context = () => {\n\t\tif (closed) throw new Error(\"Extension integration harness is closed\");\n\t\treturn persistent.context();\n\t};\n\tasync function open() {\n\t\tconst piFactory: StubPiTreeHandleFactory = new StubPiTreeHandleFactory({\n\t\t\trecordSessionTrace: true,\n\t\t\ttoolCallScriptResolver: async (input) => {\n\t\t\t\tconst id = input.instanceId;\n\t\t\t\tif (!id) throw new Error(\"Scripted prompt has no process identity\");\n\t\t\t\tconst observation = observations.get(id) ?? { prompts: [], toolResults: [] };\n\t\t\t\tobservations.set(id, observation);\n\t\t\t\tconst prompt = input.identifiedPromptText ?? input.promptText;\n\t\t\t\tobservation.prompts.push(prompt);\n\t\t\t\tconst session = [...piFactory.sessions]\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((session) => session.treeFile === input.treeFile);\n\t\t\t\tconst history =\n\t\t\t\t\tsession\n\t\t\t\t\t\t?.getBranch()\n\t\t\t\t\t\t.map((entry) => {\n\t\t\t\t\t\t\tif (entry.type === \"custom_message\") return entry.content;\n\t\t\t\t\t\t\tif (entry.type === \"message\" && entry.message) return entry.message.content;\n\t\t\t\t\t\t\treturn \"\";\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.filter((value) => typeof value === \"string\")\n\t\t\t\t\t\t.join(\"\\n\\n\") ?? \"\";\n\t\t\t\tconst script = manual\n\t\t\t\t\t? scripts.get(id)\n\t\t\t\t\t: await options.script?.(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\tobserve({\n\t\t\t\t\t\t\t\tturnId: context().deps.processes.getById(id)?.selectedTurnId ?? \"\",\n\t\t\t\t\t\t\t\tcwd: input.sessionCwd ?? input.workspaceRoot ?? \"\",\n\t\t\t\t\t\t\t\tbranchId: session?.sessionId ?? \"\",\n\t\t\t\t\t\t\t\thistory,\n\t\t\t\t\t\t\t\ttools: input.tools.map((tool) => ({\n\t\t\t\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\tscripts.delete(id);\n\t\t\t\tif (!script || (script.tools.length === 0 && script.markdown === undefined))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Script exhausted for process '${id}' after ${observation.prompts.length} prompt(s)`,\n\t\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tthinkingChunks: script.thinking ? [...script.thinking] : undefined,\n\t\t\t\t\ttextChunks: script.markdown === undefined ? undefined : [script.markdown],\n\t\t\t\t\tcalls: script.tools.map((call) => ({\n\t\t\t\t\t\ttoolName: call.name,\n\t\t\t\t\t\targs: structuredClone(call.arguments),\n\t\t\t\t\t})),\n\t\t\t\t\tafterToolResult(call, result) {\n\t\t\t\t\t\tobservation.toolResults.push({ name: call.toolName, result: structuredClone(result) });\n\t\t\t\t\t\tconst next = script.afterToolResult?.(\n\t\t\t\t\t\t\t{ name: call.toolName, arguments: structuredClone(call.args) },\n\t\t\t\t\t\t\tstructuredClone(result),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn next ? { toolName: next.name, args: next.arguments } : undefined;\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t\tawait persistent.open({\n\t\t\tappOverrides: options.hostDocker\n\t\t\t\t? { localWorkerDockerPreflightImpl: options.hostDocker.preflight }\n\t\t\t\t: undefined,\n\t\t\textensionCatalog: catalog,\n\t\t\tpreProvidedCapabilities: options.capabilities,\n\t\t\tinProcessWorkers: {\n\t\t\t\tpiFactory,\n\t\t\t\tbeforeTurnBootstrap: manual\n\t\t\t\t\t? (id, turnId, signal) =>\n\t\t\t\t\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (permits.delete(id)) {\n\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (pending.has(id)) {\n\t\t\t\t\t\t\t\t\treject(new Error(`Conflicting pending worker for '${id}'`));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst abort = () => {\n\t\t\t\t\t\t\t\t\tpending.delete(id);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\t\t\t\t\tpending.set(id, {\n\t\t\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\t\t\tresolve() {\n\t\t\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\t\t\t\t\t\t\tpending.delete(id);\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\treject,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t});\n\t}\n\ttry {\n\t\tawait open();\n\t} catch (error) {\n\t\tawait persistent.dispose();\n\t\tthrow error;\n\t}\n\t/** @public */\n\tasync function request(input: ExtensionTestRequest) {\n\t\tconst response = await context().app.inject({ ...input, method: input.method ?? \"GET\" });\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tstatusCode: response.statusCode,\n\t\t\t/** @public */\n\t\t\tbody: response.body,\n\t\t\t/** @public */\n\t\t\tjson<T = unknown>(): T {\n\t\t\t\treturn JSON.parse(response.body) as T;\n\t\t\t},\n\t\t};\n\t}\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await request({ method: \"POST\", url, payload });\n\t\tif (response.statusCode >= 400)\n\t\t\tthrow new Error(`POST ${url}: ${response.statusCode} ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tfunction processHandle(id: string): ExtensionIntegrationProcess {\n\t\tconst prefix = `/api/processes/${encodeURIComponent(id)}`;\n\t\t/** @public */\n\t\tfunction snapshot(): TestObservation<ExtensionIntegrationSnapshot> {\n\t\t\tconst { deps } = context();\n\t\t\tconst process = deps.processes.getById(id);\n\t\t\tif (!process) throw new Error(`Unknown process '${id}'`);\n\t\t\tconst definition = catalog.processes.get(process.processId);\n\t\t\treturn observe({\n\t\t\t\tworkspaceRoot: path.join(context().config.storage.process_workspaces_dir, id),\n\t\t\t\tevents: deps.events.listByInstance(id),\n\t\t\t\tannotations: deps.turnAnnotations.listByInstance(id),\n\t\t\t\tleafOutcomes: deps.leafOutcomeSnapshots.listByInstance(id),\n\t\t\t\tprocess,\n\t\t\t\tparams: definition?.paramsCodec.parse(JSON.parse(process.paramsJson ?? \"null\")),\n\t\t\t\tstate: definition?.stateCodec.parse(JSON.parse(process.stateJson ?? \"null\")),\n\t\t\t\tprojects: deps.projects.listByInstance(id),\n\t\t\t\tturns: deps.turnRecords.listByInstance(id),\n\t\t\t\tinputs: deps.inputs.listByInstance(id),\n\t\t\t\tquestions: deps.questionRequests.listByInstance(id),\n\t\t\t\tapprovals: deps.toolApprovalRequests.listByInstance(id),\n\t\t\t\twriteReceipts: deps.externalWrites.listByInstance(id),\n\t\t\t});\n\t\t}\n\t\t/** @public */\n\t\tasync function waitFor(\n\t\t\tcondition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,\n\t\t\toptions: {\n\t\t\t\t/** @public */\n\t\t\t\ttimeoutMs?: number;\n\t\t\t\t/** @public */\n\t\t\t\tdescription?: string;\n\t\t\t} = {},\n\t\t) {\n\t\t\tconst deadline = Date.now() + (options.timeoutMs ?? 12000);\n\t\t\tfor (;;) {\n\t\t\t\tconst current = snapshot();\n\t\t\t\tif (condition(current)) return current;\n\t\t\t\tif (Date.now() >= deadline)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Timed out waiting for ${id}: ${options.description ?? \"condition\"}; ${JSON.stringify({\n\t\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t\tselectedTurnId: current.process.selectedTurnId,\n\t\t\t\t\t\t\t\tlifecycleStatus: current.process.lifecycleStatus,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tturns: current.turns.map((turn) => ({\n\t\t\t\t\t\t\t\tid: turn.id,\n\t\t\t\t\t\t\t\tturnId: turn.turnId,\n\t\t\t\t\t\t\t\tstatus: turn.status,\n\t\t\t\t\t\t\t\terror: turn.errorSummary,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tinputs: current.inputs.map((input) => ({\n\t\t\t\t\t\t\t\tid: input.id,\n\t\t\t\t\t\t\t\tconsumedAt: input.consumedAt,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tquestions: current.questions.map((question) => ({\n\t\t\t\t\t\t\t\tid: question.id,\n\t\t\t\t\t\t\t\tstatus: question.status,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tapprovals: current.approvals.map((approval) => ({\n\t\t\t\t\t\t\t\tid: approval.id,\n\t\t\t\t\t\t\t\tstatus: approval.status,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t})}`,\n\t\t\t\t\t);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tid,\n\t\t\t/** Establish correlated accepted records under exclusive server coordination. @public */\n\t\t\tasync seedAcceptedTurn(fixture: AcceptedTurnFixture) {\n\t\t\t\tconst ctx = context();\n\t\t\t\treturn ctx.deps.processOperations.runExclusive(id, async () => {\n\t\t\t\t\tconst process = ctx.deps.processes.getById(id);\n\t\t\t\t\tif (!process) throw new Error(`Unknown process '${id}'`);\n\t\t\t\t\tconst turn = catalog.processes\n\t\t\t\t\t\t.get(process.processId)\n\t\t\t\t\t\t?.turns.get(fixture.turnId)?.definition;\n\t\t\t\t\tif (!turn || (turn.kind !== \"llm\" && turn.kind !== \"automatic\"))\n\t\t\t\t\t\tthrow new Error(`Undeclared worker turn '${fixture.turnId}'`);\n\t\t\t\t\tif (process.currentExecution || ctx.deps.leases.getByInstance(id))\n\t\t\t\t\t\tthrow new Error(\"Cannot seed accepted execution while a live execution exists\");\n\t\t\t\t\tconst running = fixture.execution.status === \"running\";\n\t\t\t\t\tif (running && process.selectedTurnId !== fixture.turnId)\n\t\t\t\t\t\tthrow new Error(\"Running fixture must match the selected turn\");\n\t\t\t\t\tif (\n\t\t\t\t\t\tfixture.execution.status === \"succeeded\" &&\n\t\t\t\t\t\t!Object.hasOwn(turn.outcomes ?? {}, fixture.execution.outcome) &&\n\t\t\t\t\t\tturn.turnEnd?.outcome !== fixture.execution.outcome\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(`Undeclared outcome '${fixture.execution.outcome}'`);\n\t\t\t\t\tif (fixture.execution.status === \"succeeded\" && !fixture.execution.markdown.trim())\n\t\t\t\t\t\tthrow new Error(\"A successful accepted fixture requires non-empty result markdown\");\n\t\t\t\t\tconst prepared =\n\t\t\t\t\t\tturn.kind === \"llm\"\n\t\t\t\t\t\t\t? await prepareAcceptedFixtureStart(\n\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\tprocess,\n\t\t\t\t\t\t\t\t\tfixture.turnId,\n\t\t\t\t\t\t\t\t\tcatalog.piContributions,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\treturn ctx.deps.transaction((repos) => {\n\t\t\t\t\t\tconst turnId = `trn_${randomUUID()}`;\n\t\t\t\t\t\tconst timestamp = new Date().toISOString();\n\t\t\t\t\t\tconst input = {\n\t\t\t\t\t\t\tid: turnId,\n\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\tstatus: fixture.execution.status,\n\t\t\t\t\t\t\tattemptNumber:\n\t\t\t\t\t\t\t\tMath.max(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t...repos.turnRecords\n\t\t\t\t\t\t\t\t\t\t.listByInstance(id)\n\t\t\t\t\t\t\t\t\t\t.filter((record) => record.turnId === fixture.turnId)\n\t\t\t\t\t\t\t\t\t\t.map((record) => record.attemptNumber),\n\t\t\t\t\t\t\t\t) + 1,\n\t\t\t\t\t\t\tstartedAt: timestamp,\n\t\t\t\t\t\t\tendedAt: running ? null : timestamp,\n\t\t\t\t\t\t\tturnResultMarkdown:\n\t\t\t\t\t\t\t\tfixture.execution.status === \"succeeded\" ? fixture.execution.markdown : null,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tif (turn.kind === \"llm\") {\n\t\t\t\t\t\t\tif (!prepared) throw new Error(\"Missing fixture preparation\");\n\t\t\t\t\t\t\tconst bundleDir = path.join(\n\t\t\t\t\t\t\t\tctx.config.storage.process_workspaces_dir,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\".leitwerk\",\n\t\t\t\t\t\t\t\t\"pi-resource-bundles\",\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tmkdirSync(path.join(bundleDir, \"starts\"), { recursive: true, mode: 0o700 });\n\t\t\t\t\t\t\twriteFileSync(\n\t\t\t\t\t\t\t\tpath.join(bundleDir, `${prepared.bundle.digest}.tar`),\n\t\t\t\t\t\t\t\tprepared.bundle.bytes,\n\t\t\t\t\t\t\t\t{ mode: 0o600 },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\twriteFileSync(\n\t\t\t\t\t\t\t\tpath.join(bundleDir, \"starts\", `tsr_${turnId}.json`),\n\t\t\t\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\t\t\t\tstartRecordId: `tsr_${turnId}`,\n\t\t\t\t\t\t\t\t\tdigest: prepared.bundle.digest,\n\t\t\t\t\t\t\t\t\tpersistedAt: timestamp,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t{ mode: 0o600 },\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tcreateAcceptedLlmTurn(\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t...ctx,\n\t\t\t\t\t\t\t\t\tdeps: {\n\t\t\t\t\t\t\t\t\t\t...ctx.deps,\n\t\t\t\t\t\t\t\t\t\tprocesses: repos.processes,\n\t\t\t\t\t\t\t\t\t\tturnRecords: repos.turnRecords,\n\t\t\t\t\t\t\t\t\t\tturnStarts: repos.turnStarts,\n\t\t\t\t\t\t\t\t\t\tleases: repos.leases,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t{ ...input, turnType: \"llm\", modelProfileId: prepared.start.model.profileId },\n\t\t\t\t\t\t\t\t{ current: running, preparedStart: prepared?.start },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tconst lease = repos.leases.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tworkerId: `wkr_${randomUUID()}`,\n\t\t\t\t\t\t\t\tstate: running ? \"busy\" : \"exited\",\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tconst start = repos.turnStarts.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t\tturnType: \"automatic\",\n\t\t\t\t\t\t\t\tproposedTurnRecordId: turnId,\n\t\t\t\t\t\t\t\tstartKind: \"selected_turn\",\n\t\t\t\t\t\t\t\trecoveryTurnRecordId: null,\n\t\t\t\t\t\t\t\tcontinuation: null,\n\t\t\t\t\t\t\t\tstate: {\n\t\t\t\t\t\t\t\t\tkind: \"accepted\",\n\t\t\t\t\t\t\t\t\tstart: { kind: \"automatic\" },\n\t\t\t\t\t\t\t\t\tturnRecordId: turnId,\n\t\t\t\t\t\t\t\t\tacceptedWorkerLeaseId: lease.id,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\trepos.turnRecords.create({\n\t\t\t\t\t\t\t\t...input,\n\t\t\t\t\t\t\t\tturnType: \"automatic\",\n\t\t\t\t\t\t\t\tturnStartRecordId: start.id,\n\t\t\t\t\t\t\t\tacceptedWorkerLeaseId: lease.id,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tif (running)\n\t\t\t\t\t\t\t\trepos.processes.update(id, {\n\t\t\t\t\t\t\t\t\tcurrentExecution: { kind: \"worker_start\", id: start.id },\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\telse repos.leases.update(lease.id, { exitedAt: timestamp });\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (fixture.execution.status === \"succeeded\")\n\t\t\t\t\t\t\trepos.turnAnnotations.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tannotationType: \"turn_milestone\",\n\t\t\t\t\t\t\t\tannotationKey: `turn_milestone:${turnId}`,\n\t\t\t\t\t\t\t\treferences: [{ kind: \"turn_record\", turnRecordId: turnId, role: \"subject\" }],\n\t\t\t\t\t\t\t\tpayload: {\n\t\t\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t\t\tturnType: turn.kind,\n\t\t\t\t\t\t\t\t\tpathType: \"primary\",\n\t\t\t\t\t\t\t\t\toutcome: fixture.execution.outcome,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tif (running) repos.processes.update(id, { lifecycleStatus: \"active\" });\n\t\t\t\t\t\treturn observe({\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tid: turnId,\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\t\tartifact: running ? null : { kind: \"turn_result\" as const, turnRecordId: turnId },\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t/** Read detached durable business and execution observations. @public */\n\t\t\tsnapshot,\n\t\t\t/** Wait with a bounded deadline and final observations on failure. @public */\n\t\t\twaitFor,\n\t\t\t/** Execute one selected worker turn; resolves after durable completion or failure. @public */\n\t\t\tasync runTurn(script: IntegrationTurnScript = { tools: [] }) {\n\t\t\t\tif (!manual) throw new Error(\"runTurn requires manual execution mode\");\n\t\t\t\tif (executing.has(id)) throw new Error(`A turn is already running for '${id}'`);\n\t\t\t\tconst before = snapshot();\n\t\t\t\tconst selected = before.process.selectedTurnId;\n\t\t\t\tconst turn = selected\n\t\t\t\t\t? catalog.processes.get(before.process.processId)?.turns.get(selected)?.definition\n\t\t\t\t\t: undefined;\n\t\t\t\tif (\n\t\t\t\t\t!selected ||\n\t\t\t\t\t!turn ||\n\t\t\t\t\t(turn.kind !== \"llm\" && turn.kind !== \"automatic\") ||\n\t\t\t\t\tbefore.process.lifecycleStatus !== \"active\"\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(`Process '${id}' has no active worker turn: ${JSON.stringify(before)}`);\n\t\t\t\texecuting.add(id);\n\t\t\t\tconst previous = new Set(before.turns.map((turn) => turn.id));\n\t\t\t\tobservations.set(id, { prompts: [], toolResults: [] });\n\t\t\t\tscripts.set(id, script);\n\t\t\t\ttry {\n\t\t\t\t\tconst gate = pending.get(id);\n\t\t\t\t\tif (gate) {\n\t\t\t\t\t\tif (gate.turnId !== selected)\n\t\t\t\t\t\t\tthrow new Error(\"Pending turn does not match selected turn\");\n\t\t\t\t\t\tgate.resolve();\n\t\t\t\t\t} else permits.add(id);\n\t\t\t\t\tconst after = await waitFor(\n\t\t\t\t\t\t(current) =>\n\t\t\t\t\t\t\tcurrent.turns.some((turn) => !previous.has(turn.id) && turn.status !== \"running\") ||\n\t\t\t\t\t\t\tcurrent.process.lifecycleStatus === \"error\",\n\t\t\t\t\t\t{ description: `durable outcome of ${selected}` },\n\t\t\t\t\t);\n\t\t\t\t\tconst record = after.turns.find((turn) => !previous.has(turn.id));\n\t\t\t\t\tconst milestone = record\n\t\t\t\t\t\t? context().deps.turnAnnotations.findByKey(id, `turn_milestone:${record.id}`)\n\t\t\t\t\t\t: null;\n\t\t\t\t\treturn observe({\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tturn: record ?? null,\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\toutcome:\n\t\t\t\t\t\t\ttypeof milestone?.payload.outcome === \"string\" ? milestone.payload.outcome : null,\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tfailure:\n\t\t\t\t\t\t\trecord?.errorSummary ??\n\t\t\t\t\t\t\t(after.process.lifecycleStatus === \"error\"\n\t\t\t\t\t\t\t\t? \"Worker start failed before acceptance\"\n\t\t\t\t\t\t\t\t: null),\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tprompts: observations.get(id)?.prompts ?? [],\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\ttoolResults: observations.get(id)?.toolResults ?? [],\n\t\t\t\t\t\t/** @public */\n\t\t\t\t\t\tresult:\n\t\t\t\t\t\t\trecord?.status === \"succeeded\" && record.turnResultMarkdown\n\t\t\t\t\t\t\t\t? { kind: \"turn_result\" as const, turnRecordId: record.id }\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\texecuting.delete(id);\n\t\t\t\t\tscripts.delete(id);\n\t\t\t\t\tpermits.delete(id);\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** Execute an application action. @public */\n\t\t\taction: (actionId: string, input: Record<string, unknown> = {}) =>\n\t\t\t\tpost(`${prefix}/actions/${encodeURIComponent(actionId)}`, { input }),\n\t\t\t/** Retry the failed execution through the application command. @public */\n\t\t\tretry: () => post(`${prefix}/retry`),\n\t\t\t/** Queue an instruction using the application command and normal delivery. @public */\n\t\t\tasync supplyInput(input: IntegrationProcessInput) {\n\t\t\t\tconst result = await context().deps.processEngine.queueInputs(id, [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: \"app_steer\",\n\t\t\t\t\t\tkind: \"instruction\",\n\t\t\t\t\t\tbodyMarkdown: input.bodyMarkdown,\n\t\t\t\t\t\t...(input.product ? { target: { productName: input.product } } : {}),\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t\tif (!result.ok) throw new Error(`Input rejected: ${result.message}`);\n\t\t\t\treturn snapshot();\n\t\t\t},\n\t\t\t/** Answer an open question request. @public */\n\t\t\tanswerQuestions: (\n\t\t\t\trequestId: string,\n\t\t\t\tanswers: readonly {\n\t\t\t\t\t/** @public */\n\t\t\t\t\tselectedOptionIds: readonly string[];\n\t\t\t\t\t/** @public */\n\t\t\t\t\tfreeText: string;\n\t\t\t\t\t/** @public */\n\t\t\t\t\tcomment: string;\n\t\t\t\t}[],\n\t\t\t) =>\n\t\t\t\tpost(`${prefix}/question-requests/${encodeURIComponent(requestId)}/answers`, {\n\t\t\t\t\tdraft: answers,\n\t\t\t\t}),\n\t\t\t/** Resolve an open tool approval. @public */\n\t\t\trespondToApproval: (\n\t\t\t\trequestId: string,\n\t\t\t\tresponse: {\n\t\t\t\t\t/** @public */\n\t\t\t\t\taction: \"accept\" | \"feedback\" | \"decline\";\n\t\t\t\t\t/** @public */\n\t\t\t\t\tfeedback?: string;\n\t\t\t\t},\n\t\t\t) => post(`${prefix}/tool-approval-requests/${encodeURIComponent(requestId)}`, response),\n\t\t};\n\t}\n\treturn {\n\t\t/** Observe discovered processes. @public */\n\t\tprocesses: () => observe(context().deps.processes.listAll()),\n\t\t/** Send an HTTP-shaped request, retaining error status and body. @public */\n\t\trequest,\n\t\t/** Get a handle that remains valid across restart. @public */\n\t\tprocess: processHandle,\n\t\t/** Admit work through a registered UI launcher. @public */\n\t\tasync launch(id: string, input: Record<string, unknown>) {\n\t\t\tconst response = await postImmediateLaunch(context().config.server.base_url, id, {\n\t\t\t\tlauncherInput: input,\n\t\t\t});\n\t\t\tconst body = (await response.json()) as { process?: { id: string } };\n\t\t\tif (!response.ok || !body.process)\n\t\t\t\tthrow new Error(`Launch '${id}' failed: ${JSON.stringify(body)}`);\n\t\t\treturn processHandle(body.process.id);\n\t\t},\n\t\t/** Create validated business data and start an active position through the engine. @public */\n\t\tasync createProcess<TParams, TState>(\n\t\t\tdefinition: ExtensionProcessDefinition<TParams, TState>,\n\t\t\tinput: Omit<ProcessFixtureOptions<TParams, TState>, \"id\" | \"processId\"> & {\n\t\t\t\t/** @public */\n\t\t\t\tprojects?: readonly ProcessProject[];\n\t\t\t} = {},\n\t\t) {\n\t\t\tif (catalog.processes.get(definition.id) !== definition)\n\t\t\t\tthrow new Error(`Process '${definition.id}' must be registered by an extension`);\n\t\t\tconst fixture = createProcessFixture(input, definition);\n\t\t\tconst { deps } = context();\n\t\t\tconst process = deps.transaction((repos) => {\n\t\t\t\tconst process = repos.processes.create({\n\t\t\t\t\tprocessId: definition.id,\n\t\t\t\t\ttitle: fixture.title,\n\t\t\t\t\texternalId: fixture.externalId,\n\t\t\t\t\texternalUrl: fixture.externalUrl,\n\t\t\t\t\tmetadata: fixture.metadata,\n\t\t\t\t\tparamsJson: fixture.paramsJson,\n\t\t\t\t\tstateJson: fixture.stateJson,\n\t\t\t\t\tselectedTurnId: fixture.selectedTurnId,\n\t\t\t\t\tlifecycleStatus:\n\t\t\t\t\t\tfixture.lifecycleStatus === \"active\" ? \"waiting\" : fixture.lifecycleStatus,\n\t\t\t\t});\n\t\t\t\tif (fixture.planRevision !== 0)\n\t\t\t\t\trepos.processes.update(process.id, { planRevision: fixture.planRevision });\n\t\t\t\tfor (const project of input.projects ?? [])\n\t\t\t\t\trepos.projects.create({\n\t\t\t\t\t\tinstanceId: process.id,\n\t\t\t\t\t\tkey: project.key,\n\t\t\t\t\t\trepoLocator: project.repoLocator,\n\t\t\t\t\t\tbaseBranch: project.baseBranch,\n\t\t\t\t\t\tworkBranch: project.workBranch,\n\t\t\t\t\t\tmetadata: project.metadata,\n\t\t\t\t\t\texternalId: project.externalId,\n\t\t\t\t\t\texternalUrl: project.externalUrl,\n\t\t\t\t\t\tpipelineStatus: project.pipelineStatus,\n\t\t\t\t\t});\n\t\t\t\treturn process;\n\t\t\t});\n\t\t\tif (fixture.lifecycleStatus === \"active\" && fixture.selectedTurnId) {\n\t\t\t\tconst result = await deps.processEngine.startProcess(process.id, fixture.selectedTurnId);\n\t\t\t\tif (!result.ok) throw new Error(`Process start failed: ${result.message}`);\n\t\t\t}\n\t\t\treturn processHandle(process.id);\n\t\t},\n\t\t/** Reopen the same file-backed storage and retain existing handles. @public */\n\t\tasync restart(restartOptions = {}) {\n\t\t\tif (executing.size) throw new Error(\"Cannot restart during runTurn\");\n\t\t\tconst { deps } = context();\n\t\t\tconst paused = manual\n\t\t\t\t? deps.processes.listAll().flatMap((process) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tprocess.lifecycleStatus !== \"active\" ||\n\t\t\t\t\t\t\tprocess.currentExecution?.kind !== \"worker_start\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\tconst start = deps.turnStarts.getById(process.currentExecution.id);\n\t\t\t\t\t\treturn start?.state.kind === \"starting\"\n\t\t\t\t\t\t\t? [{ instanceId: process.id, startId: start.id }]\n\t\t\t\t\t\t\t: [];\n\t\t\t\t\t})\n\t\t\t\t: [];\n\t\t\tawait persistent.close();\n\t\t\tif (restartOptions.extensionConfig)\n\t\t\t\toptions.extensionConfig = structuredClone(restartOptions.extensionConfig);\n\t\t\tawait restartOptions.whileStopped?.();\n\t\t\tpending.clear();\n\t\t\tpermits.clear();\n\t\t\tscripts.clear();\n\t\t\tawait open();\n\t\t\tfor (const pausedStart of paused) {\n\t\t\t\tif (context().deps.processes.getById(pausedStart.instanceId)?.lifecycleStatus !== \"error\")\n\t\t\t\t\tcontinue;\n\t\t\t\tconst result = await context().deps.processEngine.retryStartup(\n\t\t\t\t\tpausedStart.instanceId,\n\t\t\t\t\tpausedStart.startId,\n\t\t\t\t);\n\t\t\t\tif (!result.ok)\n\t\t\t\t\tthrow new Error(`Cannot restore paused turn after restart: ${result.message}`);\n\t\t\t}\n\t\t},\n\t\t/** Release all resources and remove harness-owned files. @public */\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttry {\n\t\t\t\tawait persistent.dispose();\n\t\t\t} finally {\n\t\t\t\tpending.clear();\n\t\t\t\tpermits.clear();\n\t\t\t\tscripts.clear();\n\t\t\t}\n\t\t},\n\t};\n}\n","import { mkdtempSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport type { ExtensionCatalog } from \"@leitwerk-dev/extension-runtime\";\nimport type { ProvidedCapability } from \"@leitwerk-dev/process-sdk\";\nimport {\n\ttype AppContext,\n\ttype AppOptions,\n\tcreateAppContext,\n\tgetDefaultConfig,\n\ttype LeitwerkConfig,\n} from \"@leitwerk-dev/server\";\nimport {\n\tcreateInProcessWorkerSpawn,\n\ttype InProcessWorkerSpawnOptions,\n} from \"./in-process-worker.js\";\n\n/** @public */\nexport interface IntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @public */\n\tctx: AppContext;\n\t/** @public */\n\tclose(): Promise<void>;\n\t/** @internal */\n\tconfig: LeitwerkConfig;\n\t/** @public */\n\taddress: string;\n\t/** @internal */\n\tresources: TResources;\n}\n\n/** @public */\nexport interface IntegrationHarnessOptions<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @internal */\n\tconfig?: LeitwerkConfig;\n\t/** @public */\n\tconfigOverride?: (config: LeitwerkConfig) => void;\n\t/** @public */\n\tappOverrides?: Partial<AppOptions>;\n\t/** @internal */\n\tlisten?: boolean;\n\t/** Start background services when binding a listener. Defaults to true. @public */\n\tbackgroundServices?: boolean;\n\t/** @internal */\n\tinProcessWorkers?: boolean | Omit<InProcessWorkerSpawnOptions, \"extensionCatalog\">;\n\t/** @public */\n\textensionCatalog: ExtensionCatalog | Promise<ExtensionCatalog>;\n\t/** @internal */\n\tpreProvidedCapabilities?: readonly ProvidedCapability[];\n\t/** @internal */\n\tresources?: TResources;\n}\n\n/** Owns disposable file-backed storage; close retains it for the next open, dispose removes it. @internal */\nexport function createPersistentIntegrationFixture(\n\tprefix: string,\n\tconfigure?: (config: LeitwerkConfig) => void,\n) {\n\tconst root = mkdtempSync(path.join(tmpdir(), prefix));\n\tlet harness: IntegrationHarness | undefined;\n\t/** @internal */\n\tfunction createConfig() {\n\t\tconst config = getDefaultConfig();\n\t\tconfig.storage.sqlite_path = path.join(root, \"state.sqlite\");\n\t\tconfig.storage.process_workspaces_dir = path.join(root, \"workspaces\");\n\t\tconfig.storage.tree_files_dir = path.join(root, \"trees\");\n\t\tconfig.pi.agent_dir = path.join(root, \"pi\");\n\t\tconfigure?.(config);\n\t\treturn config;\n\t}\n\t/** @internal */\n\tasync function close() {\n\t\tawait harness?.close();\n\t\tharness = undefined;\n\t}\n\treturn {\n\t\t/** @internal */\n\t\troot,\n\t\t/** @internal */\n\t\tcreateConfig,\n\t\t/** @internal */\n\t\tcontext() {\n\t\t\tif (!harness) throw new Error(\"Fixture is not open\");\n\t\t\treturn harness.ctx;\n\t\t},\n\t\t/** @internal */\n\t\tasync open(options: IntegrationHarnessOptions) {\n\t\t\tharness = await createIntegrationHarness({\n\t\t\t\t...options,\n\t\t\t\tconfig: options.config ?? createConfig(),\n\t\t\t});\n\t\t\treturn harness;\n\t\t},\n\t\t/** @internal */\n\t\tclose,\n\t\t/** @internal */\n\t\tasync dispose() {\n\t\t\ttry {\n\t\t\t\tawait close();\n\t\t\t} finally {\n\t\t\t\trmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n\t\t\t}\n\t\t},\n\t};\n}\n/** @public */\nexport async function createIntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n>(opts: IntegrationHarnessOptions<TResources>): Promise<IntegrationHarness<TResources>> {\n\tconst config = opts.config ?? getDefaultConfig();\n\tif (!opts.appOverrides?.workerRunnerRuntime) {\n\t\tconfig.workers.runner = \"local\";\n\t}\n\topts.configOverride?.(config);\n\n\tconst extensionCatalog = await Promise.resolve(opts.extensionCatalog);\n\n\tconst appOpts: AppOptions = {\n\t\tlogger: false,\n\t\tconfig,\n\t\textensionCatalog,\n\t\tpreProvidedCapabilities: opts.preProvidedCapabilities,\n\t\t...opts.appOverrides,\n\t};\n\n\tif (opts.inProcessWorkers !== false && !appOpts.localWorkerSpawnImpl) {\n\t\tappOpts.localWorkerSpawnImpl = createInProcessWorkerSpawn({\n\t\t\t...(typeof opts.inProcessWorkers === \"object\" ? opts.inProcessWorkers : {}),\n\t\t\textensionCatalog,\n\t\t});\n\t}\n\tconst ctx = await createAppContext(appOpts);\n\n\tlet address = \"\";\n\ttry {\n\t\tif (opts.listen !== false) {\n\t\t\tif (opts.backgroundServices !== false) {\n\t\t\t\t({ address } = await ctx.listen({\n\t\t\t\t\thost: \"127.0.0.1\",\n\t\t\t\t\tport: 0,\n\t\t\t\t\tuseBoundAddressAsBaseUrl: true,\n\t\t\t\t}));\n\t\t\t} else {\n\t\t\t\taddress = await ctx.app.listen({ host: \"127.0.0.1\", port: 0 });\n\t\t\t\tctx.config.server.base_url = address;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait ctx.close().catch(() => {});\n\t\tthrow error;\n\t}\n\n\treturn {\n\t\tctx,\n\t\tclose: () => ctx.close(),\n\t\tconfig,\n\t\tget address() {\n\t\t\treturn address || (ctx.app.server.listening ? ctx.config.server.base_url : \"\");\n\t\t},\n\t\tresources: opts.resources ?? ({} as TResources),\n\t};\n}\n","/** @public */\nexport async function waitForValue<T>(\n\tread: () => T | Promise<T>,\n\tpredicate: (value: T) => boolean,\n\ttimeoutMs = 5_000,\n): Promise<T> {\n\tconst deadline = Date.now() + timeoutMs;\n\twhile (true) {\n\t\tconst value = await read();\n\t\tif (predicate(value)) {\n\t\t\treturn value;\n\t\t}\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\"Timed out waiting for value\");\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, 25));\n\t}\n}\n","import type { ProcessInstance } from \"@leitwerk-dev/domain\";\nimport type { AppContext } from \"@leitwerk-dev/server\";\nimport { waitForValue } from \"./polling.js\";\n\n/** Drive a running or restarted app without bypassing process HTTP actions. @public */\nexport function createProcessDriver(context: () => AppContext) {\n\t/** @public */\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await context().app.inject({ method: \"POST\", url, payload });\n\t\tif (response.statusCode !== 200)\n\t\t\tthrow new Error(`POST ${url} failed with ${response.statusCode}: ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tasync function waitForProcess(\n\t\tid: string,\n\t\tpredicate: (process: ProcessInstance) => boolean,\n\t\tdescription: string,\n\t\ttimeout = 12000,\n\t\tallowError = false,\n\t): Promise<ProcessInstance> {\n\t\ttry {\n\t\t\tconst process = await waitForValue(\n\t\t\t\t() => {\n\t\t\t\t\tconst current = context().deps.processes.getById(id);\n\t\t\t\t\tif (current?.lifecycleStatus === \"error\" && !allowError)\n\t\t\t\t\t\tthrow new Error(\"Process entered error lifecycle\");\n\t\t\t\t\treturn current;\n\t\t\t\t},\n\t\t\t\t(process) => !!process && predicate(process),\n\t\t\t\ttimeout,\n\t\t\t);\n\t\t\tif (!process) throw new Error(\"Missing process\");\n\t\t\treturn process;\n\t\t} catch (error) {\n\t\t\tconst { processes, turnRecords } = context().deps;\n\t\t\tthrow new Error(\n\t\t\t\t`Waiting for ${id}: ${description}; ${JSON.stringify({ process: processes.getById(id), turns: turnRecords.listByInstance(id) })}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\t/** @public */\n\t\tpost,\n\t\t/** @public */\n\t\twaitForProcess,\n\t\t/** @public */\n\t\twait: (id: string, turn: string | null, lifecycle = \"waiting\", timeout = 12000) =>\n\t\t\twaitForProcess(\n\t\t\t\tid,\n\t\t\t\t(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,\n\t\t\t\t`${turn}/${lifecycle}`,\n\t\t\t\ttimeout,\n\t\t\t\tlifecycle === \"error\",\n\t\t\t),\n\t\t/** @public */\n\t\taction: (id: string, action: string, input: Record<string, unknown> = {}) =>\n\t\t\tpost(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {\n\t\t\t\tinput,\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAIA,SAA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U,KAAK,SAAS,IAAI,EAAE;AACnF,WAAO;AAAA,EACR;AAEA,iBAAe,eACd,IACA,WACA,aACA,UAAU,MACV,aAAa,OACc;AAC3B,QAAI;AACH,YAAM,UAAU,MAAM;AAAA,QACrB,MAAM;AACL,gBAAM,UAAU,QAAQ,EAAE,KAAK,UAAU,QAAQ,EAAE;AACnD,cAAI,SAAS,oBAAoB,WAAW,CAAC;AAC5C,kBAAM,IAAI,MAAM,iCAAiC;AAClD,iBAAO;AAAA,QACR;AAAA,QACA,CAACC,aAAY,CAAC,CAACA,YAAW,UAAUA,QAAO;AAAA,QAC3C;AAAA,MACD;AACA,UAAI,CAAC,QAAS,OAAM,IAAI,MAAM,iBAAiB;AAC/C,aAAO;AAAA,IACR,SAAS,OAAO;AACf,YAAM,EAAE,WAAW,YAAY,IAAI,QAAQ,EAAE;AAC7C,YAAM,IAAI;AAAA,QACT,eAAe,EAAE,KAAK,WAAW,KAAK,KAAK,UAAU,EAAE,SAAS,UAAU,QAAQ,EAAE,GAAG,OAAO,YAAY,eAAe,EAAE,EAAE,CAAC,CAAC;AAAA,QAC/H,EAAE,OAAO,MAAM;AAAA,MAChB;AAAA,IACD;AAAA,EACD;AACA,SAAO;AAAA;AAAA,IAEN;AAAA;AAAA,IAEA;AAAA;AAAA,IAEA,MAAM,CAAC,IAAY,MAAqB,YAAY,WAAW,UAAU,SACxE;AAAA,MACC;AAAA,MACA,CAAC,MAAM,EAAE,mBAAmB,QAAQ,EAAE,oBAAoB;AAAA,MAC1D,GAAG,IAAI,IAAI,SAAS;AAAA,MACpB;AAAA,MACA,cAAc;AAAA,IACf;AAAA;AAAA,IAED,QAAQ,CAAC,IAAY,QAAgB,QAAiC,CAAC,MACtE,KAAK,kBAAkB,mBAAmB,EAAE,CAAC,YAAY,mBAAmB,MAAM,CAAC,IAAI;AAAA,MACtF;AAAA,IACD,CAAC;AAAA,EACH;AACD;","names":["path","session","path","options","turn","process","process"]}
1
+ {"version":3,"sources":["../src/extension-integration-harness.ts","../src/integration-harness.ts","../src/polling.ts","../src/process-driver.ts"],"sourcesContent":["import type { ExtensionTestCapability } from \"./test-capability.js\";\n\nexport type { ExtensionTestCapability } from \"./test-capability.js\";\n\nimport { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport type {\n\tActor,\n\tExternalWriteLog,\n\tLaunchModelConfigInput,\n\tProcessInstance,\n\tProcessProject,\n\tProcessTurnRecord,\n} from \"@leitwerk-dev/domain\";\nimport { buildExtensionCatalogFromModules } from \"@leitwerk-dev/extension-runtime/testing\";\nimport {\n\tcoreHostCapabilities,\n\ttype ExtensionProcessDefinition,\n\ttype LeitwerkExtensionModule,\n} from \"@leitwerk-dev/process-sdk\";\nimport {\n\tcreateAcceptedWorkerTurn,\n\tprepareAcceptedFixtureStart,\n} from \"@leitwerk-dev/server/testing\";\nimport { persistPiResourceBundleForStart } from \"@leitwerk-dev/worker\";\nimport { postImmediateLaunch } from \"./http-launch.js\";\nimport { createPersistentIntegrationFixture } from \"./integration-harness.js\";\nimport { observe, type TestObservation } from \"./observations.js\";\nimport { createProcessFixture, type ProcessFixtureOptions } from \"./process-fixtures.js\";\nimport type { QuestionRequestFixture } from \"./supported-question-fixtures.js\";\nimport { formatBranchText, StubPiTreeHandleFactory } from \"./worker-testing/stub-pi-tree-handle.js\";\n\n/** Model-visible inputs for a scripted invocation. @public */\nexport interface IntegrationPromptObservation {\n\t/** @public */\n\tturnId: string;\n\t/** Working directory available for fixture repository edits. @public */\n\tcwd: string;\n\t/** Opaque branch-session identity for comparing execution relationships. @public */\n\tbranchId: string;\n\t/** Text inherited by the current branch. @public */\n\thistory: string;\n\t/** @public */\n\ttools: readonly {\n\t\t/** @public */\n\t\tname: string;\n\t\t/** @public */\n\t\tparameters: Record<string, unknown>;\n\t}[];\n}\n\n/** Rendered result retained at a tree leaf. @public */\nexport interface IntegrationLeafObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tleafEntryId: string;\n\t/** @public */\n\tturnRecordId: string | null;\n\t/** @public */\n\trendererId: string | null;\n\t/** @public */\n\tschemaVersion: number | null;\n\t/** @public */\n\tprops: Record<string, unknown> | null;\n\t/** @public */\n\tfallbackMarkdown: string | null;\n\t/** @public */\n\tstatus: \"ready\" | \"capture_error\";\n}\n\n/** Recorded semantic event. @public */\nexport interface IntegrationEventObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\teventType: string;\n\t/** @public */\n\tdata: Record<string, unknown>;\n\t/** @public */\n\tcreatedAt: string;\n}\n\n/** Durable annotation of process execution. @public */\nexport interface IntegrationAnnotationObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tannotationType: string;\n\t/** @public */\n\tpayload: Record<string, unknown>;\n}\n\n/** One scripted model prompt, executed through registered tools. @public */\nexport interface IntegrationTurnScript {\n\t/** @public */\n\ttools: readonly IntegrationToolCall[];\n\t/** Scripted reasoning retained by the normal worker path. @public */\n\tthinking?: readonly string[];\n\t/** Assistant markdown for turns completed by model output. @public */\n\tmarkdown?: string;\n\t/** Optional model response after an integration-tool result. @public */\n\tafterToolResult?(call: IntegrationToolCall, result: unknown): IntegrationToolCall | undefined;\n}\n\n/** @public */\nexport interface IntegrationToolCall {\n\t/** @public */\n\tname: string;\n\t/** @public */\n\targuments: Record<string, unknown>;\n}\n\n/** Instruction delivered through the application's durable input queue. @public */\nexport interface IntegrationProcessInput {\n\t/** @public */\n\tbodyMarkdown: string;\n\t/** Target a published product branch. @public */\n\tproduct?: string;\n}\n\n/** Durable instruction delivery observations. @public */\nexport interface IntegrationInputObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tsequence: number;\n\t/** @public */\n\tsource: string;\n\t/** @public */\n\tkind: string;\n\t/** @public */\n\tbodyMarkdown: string;\n\t/** @public */\n\ttarget: {\n\t\t/** @public */\n\t\tproductName?: string;\n\t\t/** @public */\n\t\tsemanticRef?: string;\n\t} | null;\n\t/** @public */\n\tactor: Actor;\n\t/** @public */\n\treceivedAt: string;\n\t/** @public */\n\tconsumedAt: string | null;\n}\n\n/** Operator approval observations. @public */\nexport interface IntegrationApprovalObservation {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnRecordId: string;\n\t/** @public */\n\ttoolCallId: string;\n\t/** @public */\n\ttoolName: string;\n\t/** @public */\n\targuments: Record<string, unknown>;\n\t/** @public */\n\tdestination: {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tdisplayName: string;\n\t\t/** @public */\n\t\tgroup?: string;\n\t\t/** @public */\n\t\tdescription?: string;\n\t} | null;\n\t/** @public */\n\tstatus: \"open\" | \"accepted\" | \"feedback\" | \"declined\" | \"cancelled\";\n\t/** @public */\n\trequestedAt: string;\n\t/** @public */\n\tresolvedAt: string | null;\n\t/** @public */\n\tresolvedBy: Actor | null;\n\t/** @public */\n\tfeedback: string | null;\n}\n\n/** Explicit accepted execution setup, independent of process business state. @public */\nexport interface AcceptedTurnFixture {\n\t/** @public */\n\tturnId: string;\n\t/** @public */\n\texecution:\n\t\t| {\n\t\t\t\t/** @public */\n\t\t\t\tstatus: \"running\";\n\t\t }\n\t\t| {\n\t\t\t\t/** @public */\n\t\t\t\tstatus: \"succeeded\";\n\t\t\t\t/** @public */\n\t\t\t\toutcome: string;\n\t\t\t\t/** @public */\n\t\t\t\tmarkdown: string;\n\t\t };\n}\n\n/** Detached durable observations. @public */\nexport interface ExtensionIntegrationSnapshot {\n\t/** Harness-owned process workspace. @public */\n\tworkspaceRoot: string;\n\t/** @public */\n\tevents: IntegrationEventObservation[];\n\t/** @public */\n\tannotations: IntegrationAnnotationObservation[];\n\t/** @public */\n\tleafOutcomes: IntegrationLeafObservation[];\n\n\t/** @public */\n\tprocess: ProcessInstance;\n\t/** @public */\n\tparams: unknown;\n\t/** @public */\n\tstate: unknown;\n\t/** @public */\n\tprojects: ProcessProject[];\n\t/** @public */\n\tturns: ProcessTurnRecord[];\n\t/** @public */\n\tinputs: IntegrationInputObservation[];\n\t/** @public */\n\tquestions: QuestionRequestFixture[];\n\t/** @public */\n\tapprovals: IntegrationApprovalObservation[];\n\t/** @public */\n\twriteReceipts: ExternalWriteLog[];\n}\n\n/** @public */\nexport interface ExtensionIntegrationHarnessOptions {\n\t/** Per-process watcher configuration. @public */\n\twatchers?: Readonly<Record<string, Record<string, unknown>>>;\n\t/** Advance extension provider pollers explicitly in tests. @public */\n\tpolling?: \"automatic\" | \"manual\";\n\t/** Host Docker boundary for extensions which require it. @public */\n\thostDocker?: {\n\t\t/** @public */\n\t\tpreflight(timeoutMs: number): Promise<void>;\n\t};\n\n\t/** Configuration keyed by extension manifest id. @public */\n\textensionConfig?: Readonly<Record<string, unknown>>;\n\t/** @public */\n\textensions: readonly LeitwerkExtensionModule[];\n\t/** @public */\n\tcapabilities?: readonly ExtensionTestCapability[];\n\t/** Automatic execution starts admitted work immediately. @public */\n\texecution?: \"automatic\" | \"manual\";\n\t/** Model catalog used by the supplied provider extensions. @public */\n\tmodels?: readonly {\n\t\t/** @public */\n\t\tid: string;\n\t\t/** @public */\n\t\tprovider: string;\n\t\t/** @public */\n\t\tmodelId: string;\n\t\t/** @public */\n\t\tthinkingLevel?: \"off\" | \"minimal\" | \"low\" | \"medium\" | \"high\" | \"xhigh\";\n\t}[];\n\t/** Default model profile for all registered processes. @public */\n\tdefaultModel?: string;\n\t/** Model scripts for automatic execution, in prompt order per process. @public */\n\tscript?(\n\t\tinstanceId: string,\n\t\tprompt: string,\n\t\tobservation: TestObservation<IntegrationPromptObservation>,\n\t): IntegrationTurnScript | Promise<IntegrationTurnScript>;\n}\n\n/** HTTP-shaped requests without a Fastify handle. @public */\nexport interface ExtensionTestRequest {\n\t/** @public */\n\tmethod?: \"GET\" | \"POST\" | \"PUT\" | \"PATCH\" | \"DELETE\";\n\t/** @public */\n\turl: string;\n\t/** @public */\n\tpayload?: Record<string, unknown>;\n\t/** @public */\n\theaders?: Record<string, string>;\n}\n\n/** HTTP response observation. @public */\nexport interface ExtensionTestResponse {\n\t/** @public */\n\tstatusCode: number;\n\t/** @public */\n\tbody: string;\n\t/** @public */\n\tjson<T = unknown>(): T;\n}\n\n/** Accepted turn identity and optional retained result. @public */\nexport interface AcceptedTurnReference {\n\t/** @public */\n\tid: string;\n\t/** @public */\n\tinstanceId: string;\n\t/** @public */\n\tturnId: string;\n\t/** @public */\n\tartifact: {\n\t\t/** @public */ kind: \"turn_result\";\n\t\t/** @public */\n\t\tturnRecordId: string;\n\t} | null;\n}\n\n/** One durably settled worker execution. @public */\nexport interface IntegrationTurnResult {\n\t/** @public */\n\tturn: ProcessTurnRecord | null;\n\t/** @public */\n\toutcome: string | null;\n\t/** @public */\n\tfailure: string | null;\n\t/** @public */\n\tprompts: string[];\n\t/** @public */\n\ttoolResults: {\n\t\t/** @public */ name: string;\n\t\t/** @public */\n\t\tresult: unknown;\n\t}[];\n\t/** @public */\n\tresult: AcceptedTurnReference[\"artifact\"];\n}\n\n/** Durable process commands and observations. @public */\nexport interface ExtensionIntegrationProcess {\n\t/** @public */\n\treadonly id: string;\n\t/** @public */\n\tseedAcceptedTurn(fixture: AcceptedTurnFixture): Promise<TestObservation<AcceptedTurnReference>>;\n\t/** @public */\n\tsnapshot(): TestObservation<ExtensionIntegrationSnapshot>;\n\t/** @public */\n\twaitFor(\n\t\tcondition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,\n\t\toptions?: {\n\t\t\t/** @public */ timeoutMs?: number;\n\t\t\t/** @public */\n\t\t\tdescription?: string;\n\t\t},\n\t): Promise<TestObservation<ExtensionIntegrationSnapshot>>;\n\t/** @public */\n\trunTurn(script?: IntegrationTurnScript): Promise<TestObservation<IntegrationTurnResult>>;\n\t/** @public */\n\taction(id: string, input?: Record<string, unknown>): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tretry(): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tsupplyInput(\n\t\tinput: IntegrationProcessInput,\n\t): Promise<TestObservation<ExtensionIntegrationSnapshot>>;\n\t/** @public */\n\tanswerQuestions(\n\t\tid: string,\n\t\tanswers: readonly {\n\t\t\t/** @public */\n\t\t\tselectedOptionIds: readonly string[];\n\t\t\t/** @public */\n\t\t\tfreeText: string;\n\t\t\t/** @public */\n\t\t\tcomment: string;\n\t\t}[],\n\t): Promise<ExtensionTestResponse>;\n\t/** @public */\n\trespondToApproval(\n\t\tid: string,\n\t\tresponse: {\n\t\t\t/** @public */\n\t\t\taction: \"accept\" | \"feedback\" | \"decline\";\n\t\t\t/** @public */\n\t\t\tfeedback?: string;\n\t\t},\n\t): Promise<ExtensionTestResponse>;\n}\n\n/** Disposable persistent extension test environment. @public */\nexport interface ExtensionIntegrationHarness {\n\t/** Detached processes discovered or launched by extensions. @public */\n\tprocesses(): TestObservation<ProcessInstance[]>;\n\n\t/** @public */\n\trequest(input: ExtensionTestRequest): Promise<ExtensionTestResponse>;\n\t/** @public */\n\tprocess(id: string): ExtensionIntegrationProcess;\n\t/** @public */\n\tlaunch(\n\t\tid: string,\n\t\tinput: Record<string, unknown>,\n\t\tmodelConfig?: LaunchModelConfigInput,\n\t): Promise<ExtensionIntegrationProcess>;\n\t/** @public */\n\tcreateProcess<TParams, TState>(\n\t\tdefinition: ExtensionProcessDefinition<TParams, TState>,\n\t\tinput?: Omit<ProcessFixtureOptions<TParams, TState>, \"id\" | \"processId\"> & {\n\t\t\t/** @public */\n\t\t\tprojects?: readonly ProcessProject[];\n\t\t},\n\t): Promise<ExtensionIntegrationProcess>;\n\t/** @public */\n\trestart(options?: {\n\t\t/** Update extension wiring on the reopened server. @public */\n\t\textensionConfig?: Readonly<Record<string, unknown>>;\n\t\t/** Apply external changes while the server is offline. @public */\n\t\twhileStopped?(): void | Promise<void>;\n\t}): Promise<void>;\n\t/** @public */\n\tclose(): Promise<void>;\n}\n\n/** Own server, workers, and disposable persistent storage. @public */\nexport async function createExtensionIntegrationHarness(\n\toptions: ExtensionIntegrationHarnessOptions,\n): Promise<ExtensionIntegrationHarness> {\n\tconst catalog = await buildExtensionCatalogFromModules([\n\t\t...(options.polling === \"manual\"\n\t\t\t? [\n\t\t\t\t\t{\n\t\t\t\t\t\tmanifest: { id: \"test-support-manual-polling\", version: \"1\" },\n\t\t\t\t\t\tsetupServer(api: import(\"@leitwerk-dev/process-sdk\").ServerExtensionAPI) {\n\t\t\t\t\t\t\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\t\t\t\t\t\t\tif (!deps || Array.isArray(deps)) throw new Error(\"Missing polling host\");\n\t\t\t\t\t\t\tdeps.polling = {\n\t\t\t\t\t\t\t\tcreate(input) {\n\t\t\t\t\t\t\t\t\treturn { poll: input.pollOnce };\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t]\n\t\t\t: []),\n\t\t...options.extensions,\n\t]);\n\tconst persistent = createPersistentIntegrationFixture(\"leitwerk-extension-test-\", (config) => {\n\t\tconfig.extensions = structuredClone(options.extensionConfig ?? {});\n\t\tif (options.hostDocker && config.local_worker) config.local_worker.allow_host_docker = true;\n\t\tconfig.pi.model_profiles = (options.models ?? []).map((model) => ({\n\t\t\tid: model.id,\n\t\t\tprovider: model.provider,\n\t\t\tmodel_id: model.modelId,\n\t\t\tthinking_level: model.thinkingLevel ?? \"off\",\n\t\t}));\n\t\tif (options.defaultModel) {\n\t\t\tconfig.pi.default_model_profile = options.defaultModel;\n\t\t\tconfig.pi.process_title_generation.model_profile = options.defaultModel;\n\t\t\tconfig.process_configs = Object.fromEntries(\n\t\t\t\t[...catalog.processes.keys()].map((id) => [\n\t\t\t\t\tid,\n\t\t\t\t\t{\n\t\t\t\t\t\tdefault_model_profile: options.defaultModel,\n\t\t\t\t\t\tturn_configs: {},\n\t\t\t\t\t\twatchers: structuredClone(options.watchers?.[id] ?? {}),\n\t\t\t\t\t},\n\t\t\t\t]),\n\t\t\t);\n\t\t}\n\t});\n\tconst manual = options.execution === \"manual\";\n\tlet closed = false;\n\tconst pending = new Map<string, { turnId: string; resolve(): void }>();\n\tconst permits = new Set<string>();\n\tconst executing = new Set<string>();\n\tconst scripts = new Map<string, IntegrationTurnScript>();\n\tconst observations = new Map<\n\t\tstring,\n\t\t{ prompts: string[]; toolResults: { name: string; result: unknown }[] }\n\t>();\n\tconst context = () => {\n\t\tif (closed) throw new Error(\"Extension integration harness is closed\");\n\t\treturn persistent.context();\n\t};\n\tasync function open() {\n\t\tconst piFactory: StubPiTreeHandleFactory = new StubPiTreeHandleFactory({\n\t\t\trecordSessionTrace: true,\n\t\t\ttoolCallScriptResolver: async (input) => {\n\t\t\t\tconst id = input.instanceId;\n\t\t\t\tif (!id) throw new Error(\"Scripted prompt has no process identity\");\n\t\t\t\tconst observation = observations.get(id) ?? { prompts: [], toolResults: [] };\n\t\t\t\tobservations.set(id, observation);\n\t\t\t\tconst prompt = input.identifiedPromptText ?? input.promptText;\n\t\t\t\tobservation.prompts.push(prompt);\n\t\t\t\tconst session = [...piFactory.sessions]\n\t\t\t\t\t.reverse()\n\t\t\t\t\t.find((session) => session.treeFile === input.treeFile);\n\t\t\t\tconst history = formatBranchText(session?.getBranch(), \"\");\n\t\t\t\tconst script = manual\n\t\t\t\t\t? scripts.get(id)\n\t\t\t\t\t: await options.script?.(\n\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\tprompt,\n\t\t\t\t\t\t\tobserve({\n\t\t\t\t\t\t\t\tturnId: context().deps.processes.getById(id)?.selectedTurnId ?? \"\",\n\t\t\t\t\t\t\t\tcwd: input.sessionCwd ?? input.workspaceRoot ?? \"\",\n\t\t\t\t\t\t\t\tbranchId: session?.sessionId ?? \"\",\n\t\t\t\t\t\t\t\thistory,\n\t\t\t\t\t\t\t\ttools: input.tools.map((tool) => ({\n\t\t\t\t\t\t\t\t\tname: tool.name,\n\t\t\t\t\t\t\t\t\tparameters: tool.parameters,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\tscripts.delete(id);\n\t\t\t\tif (!script || (script.tools.length === 0 && script.markdown === undefined))\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Script exhausted for process '${id}' after ${observation.prompts.length} prompt(s)`,\n\t\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tthinkingChunks: script.thinking ? [...script.thinking] : undefined,\n\t\t\t\t\ttextChunks: script.markdown === undefined ? undefined : [script.markdown],\n\t\t\t\t\tcalls: script.tools.map((call) => ({\n\t\t\t\t\t\ttoolName: call.name,\n\t\t\t\t\t\targs: structuredClone(call.arguments),\n\t\t\t\t\t})),\n\t\t\t\t\tafterToolResult(call, result) {\n\t\t\t\t\t\tobservation.toolResults.push({ name: call.toolName, result: structuredClone(result) });\n\t\t\t\t\t\tconst next = script.afterToolResult?.(\n\t\t\t\t\t\t\t{ name: call.toolName, arguments: structuredClone(call.args) },\n\t\t\t\t\t\t\tstructuredClone(result),\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn next ? { toolName: next.name, args: next.arguments } : undefined;\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t},\n\t\t});\n\t\tawait persistent.open({\n\t\t\tappOverrides: options.hostDocker\n\t\t\t\t? { localWorkerDockerPreflightImpl: options.hostDocker.preflight }\n\t\t\t\t: undefined,\n\t\t\textensionCatalog: catalog,\n\t\t\tpreProvidedCapabilities: options.capabilities,\n\t\t\tinProcessWorkers: {\n\t\t\t\tpiFactory,\n\t\t\t\tbeforeTurnBootstrap: manual\n\t\t\t\t\t? (id, turnId, signal) =>\n\t\t\t\t\t\t\tnew Promise<void>((resolve, reject) => {\n\t\t\t\t\t\t\t\tif (signal.aborted) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (permits.delete(id)) {\n\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (pending.has(id)) {\n\t\t\t\t\t\t\t\t\treject(new Error(`Conflicting pending worker for '${id}'`));\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tconst abort = () => {\n\t\t\t\t\t\t\t\t\tpending.delete(id);\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tsignal.addEventListener(\"abort\", abort, { once: true });\n\t\t\t\t\t\t\t\tpending.set(id, {\n\t\t\t\t\t\t\t\t\tturnId,\n\t\t\t\t\t\t\t\t\tresolve() {\n\t\t\t\t\t\t\t\t\t\tsignal.removeEventListener(\"abort\", abort);\n\t\t\t\t\t\t\t\t\t\tpending.delete(id);\n\t\t\t\t\t\t\t\t\t\tresolve();\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t})\n\t\t\t\t\t: undefined,\n\t\t\t},\n\t\t});\n\t}\n\ttry {\n\t\tawait open();\n\t} catch (error) {\n\t\tawait persistent.dispose();\n\t\tthrow error;\n\t}\n\t/** @public */\n\tasync function request(input: ExtensionTestRequest) {\n\t\tconst response = await context().app.inject({ ...input, method: input.method ?? \"GET\" });\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tstatusCode: response.statusCode,\n\t\t\t/** @public */\n\t\t\tbody: response.body,\n\t\t\t/** @public */\n\t\t\tjson<T = unknown>(): T {\n\t\t\t\treturn JSON.parse(response.body) as T;\n\t\t\t},\n\t\t};\n\t}\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await request({ method: \"POST\", url, payload });\n\t\tif (response.statusCode >= 400)\n\t\t\tthrow new Error(`POST ${url}: ${response.statusCode} ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tfunction processHandle(id: string): ExtensionIntegrationProcess {\n\t\tconst prefix = `/api/processes/${encodeURIComponent(id)}`;\n\t\t/** @public */\n\t\tfunction snapshot(): TestObservation<ExtensionIntegrationSnapshot> {\n\t\t\tconst { deps } = context();\n\t\t\tconst process = deps.processes.getById(id);\n\t\t\tif (!process) throw new Error(`Unknown process '${id}'`);\n\t\t\tconst definition = catalog.processes.get(process.processId);\n\t\t\treturn observe({\n\t\t\t\tworkspaceRoot: path.join(context().config.storage.process_workspaces_dir, id),\n\t\t\t\tevents: deps.events.listByInstance(id),\n\t\t\t\tannotations: deps.turnAnnotations.listByInstance(id),\n\t\t\t\tleafOutcomes: deps.leafOutcomeSnapshots.listByInstance(id),\n\t\t\t\tprocess,\n\t\t\t\tparams: definition?.paramsCodec.parse(JSON.parse(process.paramsJson ?? \"null\")),\n\t\t\t\tstate: definition?.stateCodec.parse(JSON.parse(process.stateJson ?? \"null\")),\n\t\t\t\tprojects: deps.projects.listByInstance(id),\n\t\t\t\tturns: deps.turnRecords.listByInstance(id),\n\t\t\t\tinputs: deps.inputs.listByInstance(id),\n\t\t\t\tquestions: deps.questionRequests.listByInstance(id),\n\t\t\t\tapprovals: deps.toolApprovalRequests.listByInstance(id),\n\t\t\t\twriteReceipts: deps.externalWrites.listByInstance(id),\n\t\t\t});\n\t\t}\n\t\t/** @public */\n\t\tasync function waitFor(\n\t\t\tcondition: (snapshot: TestObservation<ExtensionIntegrationSnapshot>) => boolean,\n\t\t\toptions: Parameters<ExtensionIntegrationProcess[\"waitFor\"]>[1] = {},\n\t\t) {\n\t\t\tconst deadline = Date.now() + (options.timeoutMs ?? 12000);\n\t\t\tfor (;;) {\n\t\t\t\tconst current = snapshot();\n\t\t\t\tif (condition(current)) return current;\n\t\t\t\tif (Date.now() >= deadline)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Timed out waiting for ${id}: ${options.description ?? \"condition\"}; ${JSON.stringify({\n\t\t\t\t\t\t\tposition: {\n\t\t\t\t\t\t\t\tselectedTurnId: current.process.selectedTurnId,\n\t\t\t\t\t\t\t\tlifecycleStatus: current.process.lifecycleStatus,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tturns: current.turns.map((turn) => ({\n\t\t\t\t\t\t\t\tid: turn.id,\n\t\t\t\t\t\t\t\tturnId: turn.turnId,\n\t\t\t\t\t\t\t\tstatus: turn.status,\n\t\t\t\t\t\t\t\terror: turn.errorSummary,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tinputs: current.inputs.map((input) => ({\n\t\t\t\t\t\t\t\tid: input.id,\n\t\t\t\t\t\t\t\tconsumedAt: input.consumedAt,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tquestions: current.questions.map((question) => ({\n\t\t\t\t\t\t\t\tid: question.id,\n\t\t\t\t\t\t\t\tstatus: question.status,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\tapprovals: current.approvals.map((approval) => ({\n\t\t\t\t\t\t\t\tid: approval.id,\n\t\t\t\t\t\t\t\tstatus: approval.status,\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t})}`,\n\t\t\t\t\t);\n\t\t\t\tawait new Promise((resolve) => setTimeout(resolve, 10));\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tid,\n\t\t\t/** Establish correlated accepted records under exclusive server coordination. @public */\n\t\t\tasync seedAcceptedTurn(fixture) {\n\t\t\t\tconst ctx = context();\n\t\t\t\treturn ctx.deps.processOperations.runExclusive(id, async () => {\n\t\t\t\t\tconst process = ctx.deps.processes.getById(id);\n\t\t\t\t\tif (!process) throw new Error(`Unknown process '${id}'`);\n\t\t\t\t\tconst turn = catalog.processes\n\t\t\t\t\t\t.get(process.processId)\n\t\t\t\t\t\t?.turns.get(fixture.turnId)?.definition;\n\t\t\t\t\tif (!turn || (turn.kind !== \"llm\" && turn.kind !== \"automatic\"))\n\t\t\t\t\t\tthrow new Error(`Undeclared worker turn '${fixture.turnId}'`);\n\t\t\t\t\tif (process.currentExecution || ctx.deps.leases.getByInstance(id))\n\t\t\t\t\t\tthrow new Error(\"Cannot seed accepted execution while a live execution exists\");\n\t\t\t\t\tconst running = fixture.execution.status === \"running\";\n\t\t\t\t\tif (running && process.selectedTurnId !== fixture.turnId)\n\t\t\t\t\t\tthrow new Error(\"Running fixture must match the selected turn\");\n\t\t\t\t\tif (\n\t\t\t\t\t\tfixture.execution.status === \"succeeded\" &&\n\t\t\t\t\t\t!Object.hasOwn(turn.outcomes ?? {}, fixture.execution.outcome) &&\n\t\t\t\t\t\tturn.turnEnd?.outcome !== fixture.execution.outcome\n\t\t\t\t\t)\n\t\t\t\t\t\tthrow new Error(`Undeclared outcome '${fixture.execution.outcome}'`);\n\t\t\t\t\tif (fixture.execution.status === \"succeeded\" && !fixture.execution.markdown.trim())\n\t\t\t\t\t\tthrow new Error(\"A successful accepted fixture requires non-empty result markdown\");\n\t\t\t\t\tconst prepared =\n\t\t\t\t\t\tturn.kind === \"llm\"\n\t\t\t\t\t\t\t? await prepareAcceptedFixtureStart(\n\t\t\t\t\t\t\t\t\tctx,\n\t\t\t\t\t\t\t\t\tprocess,\n\t\t\t\t\t\t\t\t\tfixture.turnId,\n\t\t\t\t\t\t\t\t\tcatalog.piContributions,\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t: null;\n\t\t\t\t\tconst turnId = `trn_${randomUUID()}`;\n\t\t\t\t\tif (prepared)\n\t\t\t\t\t\tawait persistPiResourceBundleForStart({\n\t\t\t\t\t\t\tbundlesDir: path.join(\n\t\t\t\t\t\t\t\tctx.config.storage.process_workspaces_dir,\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\".leitwerk\",\n\t\t\t\t\t\t\t\t\"pi-resource-bundles\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tstartRecordId: `tsr_${turnId}`,\n\t\t\t\t\t\t\tdigest: prepared.bundle.digest,\n\t\t\t\t\t\t\tdeliveredBundle: prepared.bundle.bytes,\n\t\t\t\t\t\t});\n\t\t\t\t\treturn ctx.deps.transaction((repos) => {\n\t\t\t\t\t\tconst timestamp = new Date().toISOString();\n\t\t\t\t\t\tconst input = {\n\t\t\t\t\t\t\tid: turnId,\n\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\tstatus: fixture.execution.status,\n\t\t\t\t\t\t\tattemptNumber:\n\t\t\t\t\t\t\t\tMath.max(\n\t\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\t\t...repos.turnRecords\n\t\t\t\t\t\t\t\t\t\t.listByInstance(id)\n\t\t\t\t\t\t\t\t\t\t.filter((record) => record.turnId === fixture.turnId)\n\t\t\t\t\t\t\t\t\t\t.map((record) => record.attemptNumber),\n\t\t\t\t\t\t\t\t) + 1,\n\t\t\t\t\t\t\tstartedAt: timestamp,\n\t\t\t\t\t\t\tendedAt: running ? null : timestamp,\n\t\t\t\t\t\t\tturnResultMarkdown:\n\t\t\t\t\t\t\t\tfixture.execution.status === \"succeeded\" ? fixture.execution.markdown : null,\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcreateAcceptedWorkerTurn(\n\t\t\t\t\t\t\t{ deps: repos },\n\t\t\t\t\t\t\t{ ...input, turnType: turn.kind, modelProfileId: prepared?.start.model.profileId },\n\t\t\t\t\t\t\t{ current: running, preparedStart: prepared?.start },\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (fixture.execution.status === \"succeeded\")\n\t\t\t\t\t\t\trepos.turnAnnotations.create({\n\t\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\t\tannotationType: \"turn_milestone\",\n\t\t\t\t\t\t\t\tannotationKey: `turn_milestone:${turnId}`,\n\t\t\t\t\t\t\t\treferences: [{ kind: \"turn_record\", turnRecordId: turnId, role: \"subject\" }],\n\t\t\t\t\t\t\t\tpayload: {\n\t\t\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\t\t\tturnType: turn.kind,\n\t\t\t\t\t\t\t\t\tpathType: \"primary\",\n\t\t\t\t\t\t\t\t\toutcome: fixture.execution.outcome,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tif (running) repos.processes.update(id, { lifecycleStatus: \"active\" });\n\t\t\t\t\t\treturn observe({\n\t\t\t\t\t\t\tid: turnId,\n\t\t\t\t\t\t\tinstanceId: id,\n\t\t\t\t\t\t\tturnId: fixture.turnId,\n\t\t\t\t\t\t\tartifact: running ? null : { kind: \"turn_result\" as const, turnRecordId: turnId },\n\t\t\t\t\t\t});\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t},\n\t\t\t/** Read detached durable business and execution observations. @public */\n\t\t\tsnapshot,\n\t\t\t/** Wait with a bounded deadline and final observations on failure. @public */\n\t\t\twaitFor,\n\t\t\t/** Execute one selected worker turn; resolves after durable completion or failure. @public */\n\t\t\tasync runTurn(script = { tools: [] }) {\n\t\t\t\tif (!manual) throw new Error(\"runTurn requires manual execution mode\");\n\t\t\t\tif (executing.has(id)) throw new Error(`A turn is already running for '${id}'`);\n\t\t\t\tconst before = snapshot();\n\t\t\t\tconst selected = before.process.selectedTurnId;\n\t\t\t\tconst turn = selected\n\t\t\t\t\t? catalog.processes.get(before.process.processId)?.turns.get(selected)?.definition\n\t\t\t\t\t: undefined;\n\t\t\t\tif (\n\t\t\t\t\t!selected ||\n\t\t\t\t\t!turn ||\n\t\t\t\t\t(turn.kind !== \"llm\" && turn.kind !== \"automatic\") ||\n\t\t\t\t\tbefore.process.lifecycleStatus !== \"active\"\n\t\t\t\t)\n\t\t\t\t\tthrow new Error(`Process '${id}' has no active worker turn: ${JSON.stringify(before)}`);\n\t\t\t\texecuting.add(id);\n\t\t\t\tconst previous = new Set(before.turns.map((turn) => turn.id));\n\t\t\t\tobservations.set(id, { prompts: [], toolResults: [] });\n\t\t\t\tscripts.set(id, script);\n\t\t\t\ttry {\n\t\t\t\t\tconst gate = pending.get(id);\n\t\t\t\t\tif (gate) {\n\t\t\t\t\t\tif (gate.turnId !== selected)\n\t\t\t\t\t\t\tthrow new Error(\"Pending turn does not match selected turn\");\n\t\t\t\t\t\tgate.resolve();\n\t\t\t\t\t} else permits.add(id);\n\t\t\t\t\tconst after = await waitFor(\n\t\t\t\t\t\t(current) =>\n\t\t\t\t\t\t\tcurrent.turns.some((turn) => !previous.has(turn.id) && turn.status !== \"running\") ||\n\t\t\t\t\t\t\tcurrent.process.lifecycleStatus === \"error\",\n\t\t\t\t\t\t{ description: `durable outcome of ${selected}` },\n\t\t\t\t\t);\n\t\t\t\t\tconst record = after.turns.find((turn) => !previous.has(turn.id));\n\t\t\t\t\tconst milestone = record\n\t\t\t\t\t\t? context().deps.turnAnnotations.findByKey(id, `turn_milestone:${record.id}`)\n\t\t\t\t\t\t: null;\n\t\t\t\t\treturn observe({\n\t\t\t\t\t\tturn: record ?? null,\n\t\t\t\t\t\toutcome:\n\t\t\t\t\t\t\ttypeof milestone?.payload.outcome === \"string\" ? milestone.payload.outcome : null,\n\t\t\t\t\t\tfailure:\n\t\t\t\t\t\t\trecord?.errorSummary ??\n\t\t\t\t\t\t\t(after.process.lifecycleStatus === \"error\"\n\t\t\t\t\t\t\t\t? \"Worker start failed before acceptance\"\n\t\t\t\t\t\t\t\t: null),\n\t\t\t\t\t\tprompts: observations.get(id)?.prompts ?? [],\n\t\t\t\t\t\ttoolResults: observations.get(id)?.toolResults ?? [],\n\t\t\t\t\t\tresult:\n\t\t\t\t\t\t\trecord?.status === \"succeeded\" && record.turnResultMarkdown\n\t\t\t\t\t\t\t\t? { kind: \"turn_result\" as const, turnRecordId: record.id }\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t});\n\t\t\t\t} finally {\n\t\t\t\t\texecuting.delete(id);\n\t\t\t\t\tscripts.delete(id);\n\t\t\t\t\tpermits.delete(id);\n\t\t\t\t}\n\t\t\t},\n\t\t\t/** Execute an application action. @public */\n\t\t\taction: (actionId, input = {}) =>\n\t\t\t\tpost(`${prefix}/actions/${encodeURIComponent(actionId)}`, { input }),\n\t\t\t/** Retry the failed execution through the application command. @public */\n\t\t\tretry: () => post(`${prefix}/retry`),\n\t\t\t/** Queue an instruction using the application command and normal delivery. @public */\n\t\t\tasync supplyInput(input) {\n\t\t\t\tconst result = await context().deps.processEngine.queueInputs(id, [\n\t\t\t\t\t{\n\t\t\t\t\t\tsource: \"app_steer\",\n\t\t\t\t\t\tkind: \"instruction\",\n\t\t\t\t\t\tbodyMarkdown: input.bodyMarkdown,\n\t\t\t\t\t\t...(input.product ? { target: { productName: input.product } } : {}),\n\t\t\t\t\t},\n\t\t\t\t]);\n\t\t\t\tif (!result.ok) throw new Error(`Input rejected: ${result.message}`);\n\t\t\t\treturn snapshot();\n\t\t\t},\n\t\t\t/** Answer an open question request. @public */\n\t\t\tanswerQuestions: (requestId, answers) =>\n\t\t\t\tpost(`${prefix}/question-requests/${encodeURIComponent(requestId)}/answers`, {\n\t\t\t\t\tdraft: answers,\n\t\t\t\t}),\n\t\t\t/** Resolve an open tool approval. @public */\n\t\t\trespondToApproval: (requestId, response) =>\n\t\t\t\tpost(`${prefix}/tool-approval-requests/${encodeURIComponent(requestId)}`, response),\n\t\t};\n\t}\n\treturn {\n\t\t/** Observe discovered processes. @public */\n\t\tprocesses: () => observe(context().deps.processes.listAll()),\n\t\t/** Send an HTTP-shaped request, retaining error status and body. @public */\n\t\trequest,\n\t\t/** Get a handle that remains valid across restart. @public */\n\t\tprocess: processHandle,\n\t\t/** Admit work through a registered UI launcher. @public */\n\t\tasync launch(id, input, modelConfig) {\n\t\t\tconst response = await postImmediateLaunch(context().config.server.base_url, id, {\n\t\t\t\tlauncherInput: input,\n\t\t\t\t...(modelConfig ? { modelConfig } : {}),\n\t\t\t});\n\t\t\tconst body = (await response.json()) as { process?: { id: string } };\n\t\t\tif (!response.ok || !body.process)\n\t\t\t\tthrow new Error(`Launch '${id}' failed: ${JSON.stringify(body)}`);\n\t\t\treturn processHandle(body.process.id);\n\t\t},\n\t\t/** Create validated business data and start an active position through the engine. @public */\n\t\tasync createProcess(definition, input = {}) {\n\t\t\tif (catalog.processes.get(definition.id) !== definition)\n\t\t\t\tthrow new Error(`Process '${definition.id}' must be registered by an extension`);\n\t\t\tconst fixture = createProcessFixture(input, definition);\n\t\t\tconst { deps } = context();\n\t\t\tconst process = deps.transaction((repos) => {\n\t\t\t\tconst process = repos.processes.create({\n\t\t\t\t\tprocessId: definition.id,\n\t\t\t\t\ttitle: fixture.title,\n\t\t\t\t\texternalId: fixture.externalId,\n\t\t\t\t\texternalUrl: fixture.externalUrl,\n\t\t\t\t\tmetadata: fixture.metadata,\n\t\t\t\t\tparamsJson: fixture.paramsJson,\n\t\t\t\t\tstateJson: fixture.stateJson,\n\t\t\t\t\tselectedTurnId: fixture.selectedTurnId,\n\t\t\t\t\tlifecycleStatus:\n\t\t\t\t\t\tfixture.lifecycleStatus === \"active\" ? \"waiting\" : fixture.lifecycleStatus,\n\t\t\t\t});\n\t\t\t\tif (fixture.planRevision !== 0)\n\t\t\t\t\trepos.processes.update(process.id, { planRevision: fixture.planRevision });\n\t\t\t\tfor (const project of input.projects ?? [])\n\t\t\t\t\trepos.projects.create({\n\t\t\t\t\t\tinstanceId: process.id,\n\t\t\t\t\t\tkey: project.key,\n\t\t\t\t\t\trepoLocator: project.repoLocator,\n\t\t\t\t\t\tbaseBranch: project.baseBranch,\n\t\t\t\t\t\tworkBranch: project.workBranch,\n\t\t\t\t\t\tmetadata: project.metadata,\n\t\t\t\t\t\texternalId: project.externalId,\n\t\t\t\t\t\texternalUrl: project.externalUrl,\n\t\t\t\t\t\tpipelineStatus: project.pipelineStatus,\n\t\t\t\t\t});\n\t\t\t\treturn process;\n\t\t\t});\n\t\t\tif (fixture.lifecycleStatus === \"active\" && fixture.selectedTurnId) {\n\t\t\t\tconst result = await deps.processEngine.startProcess(process.id, fixture.selectedTurnId);\n\t\t\t\tif (!result.ok) throw new Error(`Process start failed: ${result.message}`);\n\t\t\t}\n\t\t\treturn processHandle(process.id);\n\t\t},\n\t\t/** Reopen the same file-backed storage and retain existing handles. @public */\n\t\tasync restart(restartOptions = {}) {\n\t\t\tif (executing.size) throw new Error(\"Cannot restart during runTurn\");\n\t\t\tconst { deps } = context();\n\t\t\tconst paused = manual\n\t\t\t\t? deps.processes.listAll().flatMap((process) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tprocess.lifecycleStatus !== \"active\" ||\n\t\t\t\t\t\t\tprocess.currentExecution?.kind !== \"worker_start\"\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn [];\n\t\t\t\t\t\tconst start = deps.turnStarts.getById(process.currentExecution.id);\n\t\t\t\t\t\treturn start?.state.kind === \"starting\"\n\t\t\t\t\t\t\t? [{ instanceId: process.id, startId: start.id }]\n\t\t\t\t\t\t\t: [];\n\t\t\t\t\t})\n\t\t\t\t: [];\n\t\t\tawait persistent.close();\n\t\t\tif (restartOptions.extensionConfig)\n\t\t\t\toptions.extensionConfig = structuredClone(restartOptions.extensionConfig);\n\t\t\tawait restartOptions.whileStopped?.();\n\t\t\tpending.clear();\n\t\t\tpermits.clear();\n\t\t\tscripts.clear();\n\t\t\tawait open();\n\t\t\tfor (const pausedStart of paused) {\n\t\t\t\tif (context().deps.processes.getById(pausedStart.instanceId)?.lifecycleStatus !== \"error\")\n\t\t\t\t\tcontinue;\n\t\t\t\tconst result = await context().deps.processEngine.retryStartup(\n\t\t\t\t\tpausedStart.instanceId,\n\t\t\t\t\tpausedStart.startId,\n\t\t\t\t);\n\t\t\t\tif (!result.ok)\n\t\t\t\t\tthrow new Error(`Cannot restore paused turn after restart: ${result.message}`);\n\t\t\t}\n\t\t},\n\t\t/** Release all resources and remove harness-owned files. @public */\n\t\tasync close() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\ttry {\n\t\t\t\tawait persistent.dispose();\n\t\t\t} finally {\n\t\t\t\tpending.clear();\n\t\t\t\tpermits.clear();\n\t\t\t\tscripts.clear();\n\t\t\t}\n\t\t},\n\t};\n}\n","import { mkdtempSync, rmSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport type { ExtensionCatalog } from \"@leitwerk-dev/extension-runtime\";\nimport { buildExtensionCatalogFromModules } from \"@leitwerk-dev/extension-runtime/testing\";\nimport type { ProvidedCapability } from \"@leitwerk-dev/process-sdk\";\nimport {\n\ttype AppContext,\n\ttype AppOptions,\n\tcreateAppContext,\n\tgetDefaultConfig,\n\ttype LeitwerkConfig,\n} from \"@leitwerk-dev/server\";\nimport {\n\tcreateInProcessWorkerSpawn,\n\ttype InProcessWorkerSpawnOptions,\n} from \"./in-process-worker.js\";\nimport { withDefaultModelFixture } from \"./model-provider-fixtures.js\";\n\n/** Server fixture with an explicit synthetic model when the test supplies no model catalog. @internal */\nexport async function createTestAppContext(options: AppOptions = {}): Promise<AppContext> {\n\tconst config = options.config ?? getDefaultConfig();\n\tconst catalog = await (options.extensionCatalog ?? buildExtensionCatalogFromModules([]));\n\treturn createAppContext({\n\t\t...options,\n\t\tconfig,\n\t\textensionCatalog: withDefaultModelFixture(config, catalog),\n\t});\n}\n\n/** @public */\nexport interface IntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @public */\n\tctx: AppContext;\n\t/** @public */\n\tclose(): Promise<void>;\n\t/** @internal */\n\tconfig: LeitwerkConfig;\n\t/** @public */\n\taddress: string;\n\t/** @internal */\n\tresources: TResources;\n}\n\n/** @public */\nexport interface IntegrationHarnessOptions<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n> {\n\t/** @internal */\n\tconfig?: LeitwerkConfig;\n\t/** @public */\n\tconfigOverride?: (config: LeitwerkConfig) => void;\n\t/** @public */\n\tappOverrides?: Partial<AppOptions>;\n\t/** @internal */\n\tlisten?: boolean;\n\t/** Start background services when binding a listener. Defaults to true. @public */\n\tbackgroundServices?: boolean;\n\t/** @internal */\n\tinProcessWorkers?: boolean | Omit<InProcessWorkerSpawnOptions, \"extensionCatalog\">;\n\t/** @public */\n\textensionCatalog: ExtensionCatalog | Promise<ExtensionCatalog>;\n\t/** @internal */\n\tpreProvidedCapabilities?: readonly ProvidedCapability[];\n\t/** @internal */\n\tresources?: TResources;\n}\n\n/** Owns disposable file-backed storage; close retains it for the next open, dispose removes it. @internal */\nexport function createPersistentIntegrationFixture(\n\tprefix: string,\n\tconfigure?: (config: LeitwerkConfig) => void,\n) {\n\tconst root = mkdtempSync(path.join(tmpdir(), prefix));\n\tlet harness: IntegrationHarness | undefined;\n\t/** @internal */\n\tfunction createConfig() {\n\t\tconst config = getDefaultConfig();\n\t\tconfig.storage.sqlite_path = path.join(root, \"state.sqlite\");\n\t\tconfig.storage.process_workspaces_dir = path.join(root, \"workspaces\");\n\t\tconfig.storage.tree_files_dir = path.join(root, \"trees\");\n\t\tconfig.pi.agent_dir = path.join(root, \"pi\");\n\t\tconfigure?.(config);\n\t\treturn config;\n\t}\n\t/** @internal */\n\tasync function close() {\n\t\tawait harness?.close();\n\t\tharness = undefined;\n\t}\n\treturn {\n\t\t/** @internal */\n\t\troot,\n\t\t/** @internal */\n\t\tcreateConfig,\n\t\t/** @internal */\n\t\tcontext() {\n\t\t\tif (!harness) throw new Error(\"Fixture is not open\");\n\t\t\treturn harness.ctx;\n\t\t},\n\t\t/** @internal */\n\t\tasync open(options: IntegrationHarnessOptions) {\n\t\t\tharness = await createIntegrationHarness({\n\t\t\t\t...options,\n\t\t\t\tconfig: options.config ?? createConfig(),\n\t\t\t});\n\t\t\treturn harness;\n\t\t},\n\t\t/** @internal */\n\t\tclose,\n\t\t/** @internal */\n\t\tasync dispose() {\n\t\t\ttry {\n\t\t\t\tawait close();\n\t\t\t} finally {\n\t\t\t\trmSync(root, { recursive: true, force: true, maxRetries: 5, retryDelay: 100 });\n\t\t\t}\n\t\t},\n\t};\n}\n/** @public */\nexport async function createIntegrationHarness<\n\tTResources extends Record<string, unknown> = Record<string, never>,\n>(opts: IntegrationHarnessOptions<TResources>): Promise<IntegrationHarness<TResources>> {\n\tconst config = opts.config ?? getDefaultConfig();\n\tif (!opts.appOverrides?.workerRunnerRuntime) {\n\t\tconfig.workers.runner = \"local\";\n\t}\n\topts.configOverride?.(config);\n\n\tconst extensionCatalog = withDefaultModelFixture(\n\t\tconfig,\n\t\tawait Promise.resolve(opts.extensionCatalog),\n\t);\n\n\tconst appOpts: AppOptions = {\n\t\tlogger: false,\n\t\tconfig,\n\t\textensionCatalog,\n\t\tpreProvidedCapabilities: opts.preProvidedCapabilities,\n\t\t...opts.appOverrides,\n\t};\n\n\tif (opts.inProcessWorkers !== false && !appOpts.localWorkerSpawnImpl) {\n\t\tappOpts.localWorkerSpawnImpl = createInProcessWorkerSpawn({\n\t\t\t...(typeof opts.inProcessWorkers === \"object\" ? opts.inProcessWorkers : {}),\n\t\t\textensionCatalog,\n\t\t});\n\t}\n\tconst ctx = await createAppContext(appOpts);\n\n\tlet address = \"\";\n\ttry {\n\t\tif (opts.listen !== false) {\n\t\t\tif (opts.backgroundServices !== false) {\n\t\t\t\t({ address } = await ctx.listen({\n\t\t\t\t\thost: \"127.0.0.1\",\n\t\t\t\t\tport: 0,\n\t\t\t\t\tuseBoundAddressAsBaseUrl: true,\n\t\t\t\t}));\n\t\t\t} else {\n\t\t\t\taddress = await ctx.app.listen({ host: \"127.0.0.1\", port: 0 });\n\t\t\t\tctx.config.server.base_url = address;\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tawait ctx.close().catch(() => {});\n\t\tthrow error;\n\t}\n\n\treturn {\n\t\tctx,\n\t\tclose: () => ctx.close(),\n\t\tconfig,\n\t\tget address() {\n\t\t\treturn address || (ctx.app.server.listening ? ctx.config.server.base_url : \"\");\n\t\t},\n\t\tresources: opts.resources ?? ({} as TResources),\n\t};\n}\n","/** @public */\nexport async function waitForValue<T>(\n\tread: () => T | Promise<T>,\n\tpredicate: (value: T) => boolean,\n\ttimeoutMs = 5_000,\n): Promise<T> {\n\tconst deadline = Date.now() + timeoutMs;\n\twhile (true) {\n\t\tconst value = await read();\n\t\tif (predicate(value)) {\n\t\t\treturn value;\n\t\t}\n\t\tif (Date.now() >= deadline) {\n\t\t\tthrow new Error(\"Timed out waiting for value\");\n\t\t}\n\t\tawait new Promise((resolve) => setTimeout(resolve, 25));\n\t}\n}\n","import type { ProcessInstance } from \"@leitwerk-dev/domain\";\nimport type { AppContext } from \"@leitwerk-dev/server\";\nimport { waitForValue } from \"./polling.js\";\n\n/** Drive a running or restarted app without bypassing process HTTP actions. @public */\nexport function createProcessDriver(context: () => AppContext) {\n\t/** @public */\n\tasync function post(url: string, payload: Record<string, unknown> = {}) {\n\t\tconst response = await context().app.inject({ method: \"POST\", url, payload });\n\t\tif (response.statusCode !== 200)\n\t\t\tthrow new Error(`POST ${url} failed with ${response.statusCode}: ${response.body}`);\n\t\treturn response;\n\t}\n\t/** @public */\n\tasync function waitForProcess(\n\t\tid: string,\n\t\tpredicate: (process: ProcessInstance) => boolean,\n\t\tdescription: string,\n\t\ttimeout = 12000,\n\t\tallowError = false,\n\t): Promise<ProcessInstance> {\n\t\ttry {\n\t\t\tconst process = await waitForValue(\n\t\t\t\t() => {\n\t\t\t\t\tconst current = context().deps.processes.getById(id);\n\t\t\t\t\tif (current?.lifecycleStatus === \"error\" && !allowError)\n\t\t\t\t\t\tthrow new Error(\"Process entered error lifecycle\");\n\t\t\t\t\treturn current;\n\t\t\t\t},\n\t\t\t\t(process) => !!process && predicate(process),\n\t\t\t\ttimeout,\n\t\t\t);\n\t\t\tif (!process) throw new Error(\"Missing process\");\n\t\t\treturn process;\n\t\t} catch (error) {\n\t\t\tconst { processes, turnRecords } = context().deps;\n\t\t\tthrow new Error(\n\t\t\t\t`Waiting for ${id}: ${description}; ${JSON.stringify({ process: processes.getById(id), turns: turnRecords.listByInstance(id) })}`,\n\t\t\t\t{ cause: error },\n\t\t\t);\n\t\t}\n\t}\n\treturn {\n\t\t/** @public */\n\t\tpost,\n\t\t/** @public */\n\t\twaitForProcess,\n\t\t/** @public */\n\t\twait: (id: string, turn: string | null, lifecycle = \"waiting\", timeout = 12000) =>\n\t\t\twaitForProcess(\n\t\t\t\tid,\n\t\t\t\t(p) => p.selectedTurnId === turn && p.lifecycleStatus === lifecycle,\n\t\t\t\t`${turn}/${lifecycle}`,\n\t\t\t\ttimeout,\n\t\t\t\tlifecycle === \"error\",\n\t\t\t),\n\t\t/** @public */\n\t\taction: (id: string, action: string, input: Record<string, unknown> = {}) =>\n\t\t\tpost(`/api/processes/${encodeURIComponent(id)}/actions/${encodeURIComponent(action)}`, {\n\t\t\t\tinput,\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAIA,SAAS,kBAAkB;AAC3B,OAAOA,WAAU;AASjB,SAAS,oCAAAC,yCAAwC;AACjD;AAAA,EACC;AAAA,OAGM;AACP;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,uCAAuC;;;ACxBhD,SAAS,aAAa,cAAc;AACpC,SAAS,cAAc;AACvB,OAAO,UAAU;AAEjB,SAAS,wCAAwC;AAEjD;AAAA,EAGC;AAAA,EACA;AAAA,OAEM;AAQP,eAAsB,qBAAqB,UAAsB,CAAC,GAAwB;AACzF,QAAM,SAAS,QAAQ,UAAU,iBAAiB;AAClD,QAAM,UAAU,OAAO,QAAQ,oBAAoB,iCAAiC,CAAC,CAAC;AACtF,SAAO,iBAAiB;AAAA,IACvB,GAAG;AAAA,IACH;AAAA,IACA,kBAAkB,wBAAwB,QAAQ,OAAO;AAAA,EAC1D,CAAC;AACF;AA2CO,SAAS,mCACf,QACA,WACC;AACD,QAAM,OAAO,YAAY,KAAK,KAAK,OAAO,GAAG,MAAM,CAAC;AACpD,MAAI;AAEJ,WAAS,eAAe;AACvB,UAAM,SAAS,iBAAiB;AAChC,WAAO,QAAQ,cAAc,KAAK,KAAK,MAAM,cAAc;AAC3D,WAAO,QAAQ,yBAAyB,KAAK,KAAK,MAAM,YAAY;AACpE,WAAO,QAAQ,iBAAiB,KAAK,KAAK,MAAM,OAAO;AACvD,WAAO,GAAG,YAAY,KAAK,KAAK,MAAM,IAAI;AAC1C,gBAAY,MAAM;AAClB,WAAO;AAAA,EACR;AAEA,iBAAe,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AAI,SAAS;AAAA,MACpB;AAAA,MACA,cAAc;AAAA,IACf;AAAA;AAAA,IAED,QAAQ,CAAC,IAAY,QAAgB,QAAiC,CAAC,MACtE,KAAK,kBAAkB,mBAAmB,EAAE,CAAC,YAAY,mBAAmB,MAAM,CAAC,IAAI;AAAA,MACtF;AAAA,IACD,CAAC;AAAA,EACH;AACD;","names":["path","buildExtensionCatalogFromModules","buildExtensionCatalogFromModules","session","path","options","turn","process","process"]}
@@ -17,6 +17,15 @@ export interface LocalRepositorySeed {
17
17
  /** @internal */
18
18
  signoff?: boolean;
19
19
  }
20
+ /** Copies immutable bare seeds into independent test fixtures. @internal */
21
+ export declare class LocalGitSeedCache {
22
+ private root;
23
+ private readonly templates;
24
+ /** Seed options select the template; an existing destination is never overwritten. @internal */
25
+ copy(git: LocalGit, seed: LocalRepositorySeed): string;
26
+ /** Release templates after the suite; copied repositories remain usable. @internal */
27
+ close(): void;
28
+ }
20
29
  /** Reject escaping paths and symlinks, including a not-yet-created file's parents. @public */
21
30
  export declare function localPath(root: string, relative: string): string;
22
31
  /** @public */
@@ -1 +1 @@
1
- {"version":3,"file":"local-git.d.ts","sourceRoot":"","sources":["../src/local-git.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAI/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,cAAc;AACd,MAAM,WAAW,mBAAmB;IACnC,cAAc;IACd,KAAK,EAAE,MAAM,CAAC;IACd,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc;IACd,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;I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;IAChB,YAAY,CACX,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,GACV;QACF,gBAAgB;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,gBAAgB;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,gBAAgB;QAChB,eAAe,EAAE,MAAM,CAAC;KACxB;IAeD,gBAAgB;IAChB,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAoB5D,gBAAgB;IAChB,IAAI,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAChC,gBAAgB;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,gBAAgB;QAChB,MAAM,EAAE,MAAM,CAAC;KACf;CA2CD"}
package/dist/local-git.js CHANGED
@@ -1,14 +1,18 @@
1
1
  // src/local-git.ts
2
2
  import { execFileSync } from "child_process";
3
3
  import {
4
+ cpSync,
4
5
  existsSync,
5
6
  lstatSync,
6
7
  mkdirSync,
8
+ mkdtempSync,
7
9
  readFileSync,
8
10
  realpathSync,
9
11
  renameSync,
12
+ rmSync,
10
13
  writeFileSync
11
14
  } from "fs";
15
+ import { tmpdir } from "os";
12
16
  import path from "path";
13
17
 
14
18
  // src/test-diagnostics.ts
@@ -78,6 +82,32 @@ function traceTestSubprocess(operation, run) {
78
82
  }
79
83
 
80
84
  // src/local-git.ts
85
+ var LocalGitSeedCache = class {
86
+ root;
87
+ templates = /* @__PURE__ */ new Map();
88
+ /** Seed options select the template; an existing destination is never overwritten. @internal */
89
+ copy(git, seed) {
90
+ const key = JSON.stringify(seed);
91
+ let template = this.templates.get(key);
92
+ if (!template) {
93
+ this.root ??= mkdtempSync(path.join(tmpdir(), "leitwerk-git-seeds-"));
94
+ const directory = mkdtempSync(path.join(this.root, "seed-"));
95
+ template = new LocalGit(directory).seed(seed).bare;
96
+ this.templates.set(key, template);
97
+ }
98
+ const destination = localPath(git.root, `repositories/${path.basename(template)}`);
99
+ if (existsSync(destination)) throw new Error("Git seed destination already exists");
100
+ mkdirSync(path.dirname(destination), { recursive: true });
101
+ cpSync(template, destination, { recursive: true, force: false, errorOnExist: true });
102
+ return destination;
103
+ }
104
+ /** Release templates after the suite; copied repositories remain usable. @internal */
105
+ close() {
106
+ if (this.root) rmSync(this.root, { recursive: true, force: true });
107
+ this.root = void 0;
108
+ this.templates.clear();
109
+ }
110
+ };
81
111
  function localPath(root, relative) {
82
112
  if (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())
83
113
  throw new Error("Local provider storage must not contain symlinks");
@@ -419,6 +449,7 @@ var LocalGit = class {
419
449
  export {
420
450
  LocalForgeStore,
421
451
  LocalGit,
452
+ LocalGitSeedCache,
422
453
  LocalProviderStore,
423
454
  createTestDiagnostics,
424
455
  localPath,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/local-git.ts","../src/test-diagnostics.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport {\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\treadFileSync,\n\trealpathSync,\n\trenameSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport path from \"node:path\";\nimport type { RepositoryFeedbackItem, RepositoryPullRequest } from \"@leitwerk-dev/process-sdk\";\nimport { traceTestSubprocess } from \"./test-diagnostics.js\";\n\n// Internal operational tests retain subprocess diagnostics.\nexport { createTestDiagnostics } from \"./test-diagnostics.js\";\n\n/** @public */\nexport interface LocalRepositorySeed {\n\t/** @public */\n\towner: string;\n\t/** @public */\n\tname: string;\n\t/** @internal */\n\tdefaultBranch?: string;\n\t/** @public */\n\tfiles?: Record<string, string>;\n\t/** Retain a pre-existing sandbox checkout layout. @internal */\n\tdirectoryName?: string;\n\t/** @internal */\n\tcommitMessage?: string;\n\t/** @internal */\n\tsignoff?: boolean;\n}\n\n/** Reject escaping paths and symlinks, including a not-yet-created file's parents. @public */\nexport function localPath(root: string, relative: string): string {\n\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\tconst base = realpathSync(root);\n\tconst target = path.resolve(base, relative);\n\tif (!target.startsWith(`${base}${path.sep}`))\n\t\tthrow new Error(\"Path escapes local provider storage\");\n\tlet current = base;\n\tfor (const part of path.relative(base, target).split(path.sep)) {\n\t\tcurrent = path.join(current, part);\n\t\tif (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\t}\n\treturn target;\n}\n\n/** @public */\nexport function readLocalJson<\n\tT extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t},\n>(root: string, file: string, initial: T): T {\n\tconst target = localPath(root, file);\n\tif (!existsSync(target)) return structuredClone(initial);\n\tconst value = JSON.parse(readFileSync(target, \"utf8\")) as T;\n\tif (!value || value.version !== initial.version)\n\t\tthrow new Error(`Unsupported local state version in ${file}`);\n\treturn value;\n}\n\n/** @public */\nexport function writeLocalJson(root: string, file: string, value: unknown): void {\n\tconst target = localPath(root, file);\n\tconst temporary = localPath(root, `${file}.tmp`);\n\twriteFileSync(temporary, `${JSON.stringify(value, null, 2)}\\n`, { mode: 0o600 });\n\trenameSync(temporary, target);\n}\n\n/** Persist local adapter state with a shared clock and monotonically increasing ids. @public */\nexport class LocalProviderStore<\n\tS extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tsequence: number;\n\t},\n\tO extends {\n\t\t/** @internal */\n\t\troot: string;\n\t\t/** @internal */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tnextId?: () => number;\n\t},\n> {\n\t/** @public */\n\treadonly git: LocalGit;\n\t/** @public */\n\tstate: S;\n\t/** @public */\n\tconstructor(\n\t\t/** @public */\n\t\treadonly options: O,\n\t\tprivate readonly file: string,\n\t\tinitial: S,\n\t) {\n\t\tthis.git = new LocalGit(options.root);\n\t\tthis.state = readLocalJson(options.root, file, initial);\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteLocalJson(this.options.root, this.file, this.state);\n\t}\n\t/** @internal */\n\tid() {\n\t\tthis.state.sequence = Math.max(this.state.sequence + 1, this.options.nextId?.() ?? 0);\n\t\treturn this.state.sequence;\n\t}\n\t/** @internal */\n\ttimestamp() {\n\t\treturn new Date(this.options.now?.() ?? Date.now()).toISOString();\n\t}\n}\n\n/** @public */\ntype LocalPullRequest = Pick<\n\tRepositoryPullRequest,\n\t\"number\" | \"title\" | \"body\" | \"state\" | \"merged\" | \"merge_commit_sha\" | \"head\" | \"base\"\n>;\n/** @public */\ninterface LocalPullRequestRepository<P extends LocalPullRequest> {\n\t/** @public */\n\trepository: {\n\t\t/** @internal */\n\t\tssh_url: string;\n\t};\n\t/** @public */\n\tpulls: P[];\n}\n\n/** Common PR operations; adapters retain their provider-specific state and clients. @public */\nexport class LocalForgeStore<\n\tS extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tsequence: number;\n\t},\n\tO extends {\n\t\t/** @internal */\n\t\troot: string;\n\t\t/** @internal */\n\t\tbaseUrl: string;\n\t\t/** @internal */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tnextId?: () => number;\n\t},\n> extends LocalProviderStore<S, O> {\n\t/** @public */\n\tnewRepository(seed: LocalRepositorySeed) {\n\t\tconst { bare, branch } = this.git.seed(seed);\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tid: this.id(),\n\t\t\t/** @public */\n\t\t\towner: {\n\t\t\t\t/** @internal */\n\t\t\t\tlogin: seed.owner,\n\t\t\t},\n\t\t\t/** @public */\n\t\t\tname: seed.name,\n\t\t\t/** @public */\n\t\t\tfull_name: `${seed.owner}/${seed.name}`,\n\t\t\t/** @public */\n\t\t\tssh_url: bare,\n\t\t\t/** @public */\n\t\t\thtml_url: `${this.options.baseUrl}/__local`,\n\t\t\t/** @public */\n\t\t\tdefault_branch: branch,\n\t\t};\n\t}\n\t/** @internal */\n\tpullRequestClient<P extends LocalPullRequest>(\n\t\trepo: (owner: string, name: string) => LocalPullRequestRepository<P>,\n\t\tmissing = \"Unknown local pull request\",\n\t) {\n\t\tconst pull = (owner: string, name: string, number: number) => {\n\t\t\tconst pr = repo(owner, name).pulls.find((p) => p.number === number);\n\t\t\tif (!pr) throw new Error(missing);\n\t\t\treturn pr;\n\t\t};\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tgetPullRequest: async (owner: string, name: string, number: number) =>\n\t\t\t\tthis.refresh(repo(owner, name), pull(owner, name, number)),\n\t\t\t/** @internal */\n\t\t\tlistPullRequests: async (owner: string, name: string, state = \"open\") => {\n\t\t\t\tconst r = repo(owner, name);\n\t\t\t\treturn r.pulls\n\t\t\t\t\t.filter((p) => state === \"all\" || p.state === state)\n\t\t\t\t\t.map((p) => this.refresh(r, p));\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tupdatePullRequest: async (\n\t\t\t\towner: string,\n\t\t\t\tname: string,\n\t\t\t\tnumber: number,\n\t\t\t\tpatch: Record<string, unknown>,\n\t\t\t) => {\n\t\t\t\tconst pr = pull(owner, name, number);\n\t\t\t\tfor (const key of [\"title\", \"body\", \"state\"] as const)\n\t\t\t\t\tif (typeof patch[key] === \"string\") pr[key] = patch[key];\n\t\t\t\tthis.save();\n\t\t\t\treturn this.refresh(repo(owner, name), pr);\n\t\t\t},\n\t\t};\n\t}\n\t/** @public */\n\trefresh<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, pr: P): P {\n\t\tif (pr.state === \"open\") {\n\t\t\tconst { headSha, baseSha, ...mergeability } = this.git.mergeability(\n\t\t\t\trepo.repository.ssh_url,\n\t\t\t\tpr.head.ref,\n\t\t\t\tpr.base.ref,\n\t\t\t);\n\t\t\tpr.head.sha = headSha;\n\t\t\tpr.base.sha = baseSha;\n\t\t\tObject.assign(pr, mergeability);\n\t\t}\n\t\treturn structuredClone(pr);\n\t}\n\t/** @public */\n\tmerge<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, number: number): P {\n\t\tconst pr = repo.pulls.find((p) => p.number === number);\n\t\tif (!pr || pr.state !== \"open\") throw new Error(\"Pull request is not open\");\n\t\tthis.refresh(repo, pr);\n\t\tpr.merge_commit_sha = this.git.merge(repo.repository.ssh_url, pr.head.ref, pr.base.ref);\n\t\tpr.merged = true;\n\t\tpr.state = \"closed\";\n\t\tthis.save();\n\t\treturn structuredClone(pr);\n\t}\n\t/** @public */\n\taddFeedback<F extends RepositoryFeedbackItem>(\n\t\trepo: {\n\t\t\t/** @public */\n\t\t\tpulls: Array<{\n\t\t\t\t/** @internal */\n\t\t\t\tnumber: number;\n\t\t\t}>;\n\t\t\t/** @public */\n\t\t\tfeedback: Record<string, F[]>;\n\t\t},\n\t\tnumber: number,\n\t\tinput: Omit<F, \"id\" | \"createdAt\">,\n\t): F {\n\t\tif (!repo.pulls.some((p) => p.number === number)) throw new Error(\"Unknown PR\");\n\t\tconst value = { ...input, id: this.id(), createdAt: this.timestamp() } as F;\n\t\trepo.feedback[number] ??= [];\n\t\trepo.feedback[number].push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tnewComment(body: string) {\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tid: this.id(),\n\t\t\t/** @internal */\n\t\t\tbody,\n\t\t\t/** @public */\n\t\t\tuser: {\n\t\t\t\t/** @public */\n\t\t\t\tlogin: \"leitwerk-bot\",\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tcreated_at: this.timestamp(),\n\t\t};\n\t}\n\t/** @internal */\n\tnewPullRequest(\n\t\trepo: {\n\t\t\t/** @internal */\n\t\t\trepository: {\n\t\t\t\t/** @internal */\n\t\t\t\tssh_url: string;\n\t\t\t};\n\t\t},\n\t\tinput: {\n\t\t\t/** @internal */\n\t\t\ttitle: string;\n\t\t\t/** @internal */\n\t\t\tbody: string;\n\t\t\t/** @internal */\n\t\t\thead: string;\n\t\t\t/** @internal */\n\t\t\tbase: string;\n\t\t},\n\t) {\n\t\tconst number = this.id();\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tnumber,\n\t\t\t/** @internal */\n\t\t\ttitle: input.title,\n\t\t\t/** @internal */\n\t\t\tbody: input.body,\n\t\t\t/** @internal */\n\t\t\tstate: \"open\",\n\t\t\t/** @internal */\n\t\t\tmerged: false,\n\t\t\t/** @internal */\n\t\t\tmerge_commit_sha: null,\n\t\t\t/** @internal */\n\t\t\thtml_url: `${this.options.baseUrl}/__local#pr-${number}`,\n\t\t\t/** @internal */\n\t\t\thead: {\n\t\t\t\t/** @internal */\n\t\t\t\tref: input.head,\n\t\t\t\t/** @internal */\n\t\t\t\tsha: this.git.head(repo.repository.ssh_url, input.head),\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tbase: {\n\t\t\t\t/** @internal */\n\t\t\t\tref: input.base,\n\t\t\t\t/** @internal */\n\t\t\t\tsha: this.git.head(repo.repository.ssh_url, input.base),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** Real Git with file-only transport and no ambient credentials or hooks. @public */\nexport class LocalGit {\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t) {\n\t\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local Git root must not be a symlink\");\n\t\tmkdirSync(root, { recursive: true, mode: 0o700 });\n\t}\n\t/** @public */\n\trun(directory: string, args: string[]): string {\n\t\tconst base = realpathSync(this.root);\n\t\tconst directoryPath = path.resolve(directory);\n\t\tconst relative = path.relative(\n\t\t\tdirectoryPath.startsWith(`${base}${path.sep}`) ? base : path.resolve(this.root),\n\t\t\tdirectoryPath,\n\t\t);\n\t\tconst cwd = localPath(this.root, relative);\n\t\treturn traceTestSubprocess(`git ${args[0] ?? \"\"}`, () =>\n\t\t\texecFileSync(\n\t\t\t\t\"git\",\n\t\t\t\t[\"-c\", \"protocol.file.allow=always\", \"-c\", \"core.hooksPath=/dev/null\", ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: \"utf8\",\n\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\tenv: {\n\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\tHOME: this.root,\n\t\t\t\t\t\tGIT_CONFIG_NOSYSTEM: \"1\",\n\t\t\t\t\t\tGIT_CONFIG_GLOBAL: \"/dev/null\",\n\t\t\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t\t\t\tGIT_ALLOW_PROTOCOL: \"file\",\n\t\t\t\t\t\tGIT_AUTHOR_NAME: \"Sandbox Developer\",\n\t\t\t\t\t\tGIT_AUTHOR_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\t\tGIT_COMMITTER_NAME: \"Sandbox Developer\",\n\t\t\t\t\t\tGIT_COMMITTER_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t).trim(),\n\t\t);\n\t}\n\t/** @public */\n\thead(directory: string, ref: string): string {\n\t\tif (!/^[a-zA-Z0-9_./-]+$/.test(ref) || ref.startsWith(\"-\")) throw new Error(\"Invalid Git ref\");\n\t\treturn this.run(directory, [\"rev-parse\", \"--verify\", `${ref}^{commit}`]);\n\t}\n\t/** @internal */\n\tisAncestor(directory: string, ancestor: string, descendant: string): boolean {\n\t\treturn this.isAncestorCommit(\n\t\t\tdirectory,\n\t\t\tthis.head(directory, ancestor),\n\t\t\tthis.head(directory, descendant),\n\t\t);\n\t}\n\tprivate isAncestorCommit(directory: string, ancestor: string, descendant: string): boolean {\n\t\tif (ancestor === descendant) return true;\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-base\", \"--is-ancestor\", ancestor, descendant]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\t/** @internal */\n\tmergeability(\n\t\tdirectory: string,\n\t\thead: string,\n\t\tbase: string,\n\t): {\n\t\t/** @internal */\n\t\theadSha: string;\n\t\t/** @internal */\n\t\tbaseSha: string;\n\t\t/** @internal */\n\t\tmergeable: boolean;\n\t\t/** @internal */\n\t\tmergeable_state: string;\n\t} {\n\t\tconst headSha = this.head(directory, head),\n\t\t\tbaseSha = this.head(directory, base);\n\t\tconst revisions = { headSha, baseSha };\n\t\tif (this.isAncestorCommit(directory, baseSha, headSha))\n\t\t\treturn { ...revisions, mergeable: true, mergeable_state: \"clean\" };\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-tree\", \"--write-tree\", baseSha, headSha]);\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1)\n\t\t\t\treturn { ...revisions, mergeable: false, mergeable_state: \"dirty\" };\n\t\t\tthrow error;\n\t\t}\n\t\treturn { ...revisions, mergeable: true, mergeable_state: \"behind\" };\n\t}\n\t/** @internal */\n\tmerge(directory: string, head: string, base: string): string {\n\t\tconst h = this.head(directory, head),\n\t\t\tb = this.head(directory, base);\n\t\tlet commit = h;\n\t\tif (!this.isAncestorCommit(directory, b, h)) {\n\t\t\tconst tree = this.run(directory, [\"merge-tree\", \"--write-tree\", b, h]).split(\"\\n\")[0];\n\t\t\tcommit = this.run(directory, [\n\t\t\t\t\"commit-tree\",\n\t\t\t\ttree,\n\t\t\t\t\"-p\",\n\t\t\t\tb,\n\t\t\t\t\"-p\",\n\t\t\t\th,\n\t\t\t\t\"-m\",\n\t\t\t\t\"Merge local pull request\",\n\t\t\t]);\n\t\t}\n\t\tthis.run(directory, [\"update-ref\", `refs/heads/${base}`, commit, b]);\n\t\treturn commit;\n\t}\n\t/** @internal */\n\tseed(seed: LocalRepositorySeed): {\n\t\t/** @internal */\n\t\tbare: string;\n\t\t/** @internal */\n\t\tworktree: string;\n\t\t/** @internal */\n\t\tbranch: string;\n\t} {\n\t\tfor (const value of [seed.owner, seed.name, seed.directoryName ?? seed.name])\n\t\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value))\n\t\t\t\tthrow new Error(\"Invalid local repository name\");\n\t\tconst name = seed.directoryName ?? `${seed.owner}--${seed.name}`;\n\t\tconst bare = localPath(this.root, `repositories/${name}.git`);\n\t\tconst worktree = localPath(this.root, `seeds/${name}`);\n\t\tconst branch = seed.defaultBranch ?? \"main\";\n\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9_./-]*$/.test(branch)) throw new Error(\"Invalid default branch\");\n\t\tmkdirSync(bare, { recursive: true });\n\t\tmkdirSync(worktree, { recursive: true });\n\t\tif (!existsSync(path.join(bare, \"HEAD\")))\n\t\t\tthis.run(bare, [\"init\", \"--bare\", `--initial-branch=${branch}`]);\n\t\ttry {\n\t\t\tthis.head(bare, branch);\n\t\t\treturn { bare, worktree, branch };\n\t\t} catch {\n\t\t\t/* Resume an interrupted seed. */\n\t\t}\n\t\tif (!existsSync(path.join(worktree, \".git\")))\n\t\t\tthis.run(worktree, [\"init\", `--initial-branch=${branch}`]);\n\t\tfor (const [name, contents] of Object.entries(\n\t\t\tseed.files ?? { \"README.md\": `# ${seed.name}\\n` },\n\t\t)) {\n\t\t\tif (name.split(/[\\\\/]/).includes(\".git\"))\n\t\t\t\tthrow new Error(\"Seed must not write Git configuration\");\n\t\t\tconst target = localPath(worktree, name);\n\t\t\tmkdirSync(path.dirname(target), { recursive: true });\n\t\t\twriteFileSync(target, contents);\n\t\t}\n\t\tthis.run(worktree, [\"add\", \".\"]);\n\t\tthis.run(worktree, [\n\t\t\t\"commit\",\n\t\t\t\"--allow-empty\",\n\t\t\t...(seed.signoff ? [\"--signoff\"] : []),\n\t\t\t\"-m\",\n\t\t\tseed.commitMessage ?? \"chore: seed local repository\",\n\t\t]);\n\t\tif (!this.run(worktree, [\"remote\"]).split(\"\\n\").includes(\"origin\"))\n\t\t\tthis.run(worktree, [\"remote\", \"add\", \"origin\", bare]);\n\t\tthis.run(worktree, [\"push\", bare, `HEAD:refs/heads/${branch}`]);\n\t\treturn { bare, worktree, branch };\n\t}\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { threadId } from \"node:worker_threads\";\n\nconst active = new AsyncLocalStorage<ReturnType<typeof createTestDiagnostics>>();\n\n/** @internal Bounded, in-memory trace. Call report from onTestFailed; successful tests stay quiet. */\nexport function createTestDiagnostics(label: string) {\n\tconst started = performance.now();\n\tconst events: Record<string, unknown>[] = [];\n\tlet dropped = 0;\n\tconst mark = (stage: string, details: Record<string, unknown> = {}) => {\n\t\tif (events.length === 512) {\n\t\t\tevents.shift();\n\t\t\tdropped++;\n\t\t}\n\t\tevents.push({\n\t\t\t...details,\n\t\t\tstage,\n\t\t\tat: new Date().toISOString(),\n\t\t\telapsedMs: Math.round(performance.now() - started),\n\t\t});\n\t};\n\tconst diagnostics = {\n\t\t/** @internal */\n\t\tmark,\n\t\t/** @internal */\n\t\trun<T>(fn: () => T): T {\n\t\t\treturn active.run(diagnostics, fn);\n\t\t},\n\t\t/** @internal */\n\t\tformat() {\n\t\t\treturn JSON.stringify({ label, pid: process.pid, threadId, dropped, events }, null, 2);\n\t\t},\n\t\t/** @internal */\n\t\treport() {\n\t\t\tmark(\"diagnostics.report\");\n\t\t\tconsole.error(diagnostics.format());\n\t\t},\n\t};\n\tmark(\"test.start\");\n\treturn diagnostics;\n}\n\n/** @internal Logs only the operation name and exit metadata, never arguments, output or environment. */\nexport function traceTestSubprocess<T>(operation: string, run: () => T): T {\n\tconst trace = active.getStore();\n\tif (!trace) return run();\n\tconst started = performance.now();\n\ttrace.mark(\"subprocess.start\", { operation });\n\ttry {\n\t\tconst result = run();\n\t\ttrace.mark(\"subprocess.exit\", {\n\t\t\toperation,\n\t\t\tstatus: 0,\n\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t});\n\t\treturn result;\n\t} catch (error) {\n\t\tconst details = error as { status?: unknown; signal?: unknown; code?: unknown } | null;\n\t\ttrace.mark(\"subprocess.exit\", {\n\t\t\toperation,\n\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t\tstatus: typeof details?.status === \"number\" ? details.status : null,\n\t\t\tsignal: typeof details?.signal === \"string\" ? details.signal : null,\n\t\t\tcode: typeof details?.code === \"string\" ? details.code : null,\n\t\t});\n\t\tthrow error;\n\t}\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,UAAU;;;ACVjB,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAEzB,IAAM,SAAS,IAAI,kBAA4D;AAGxE,SAAS,sBAAsB,OAAe;AACpD,QAAM,UAAU,YAAY,IAAI;AAChC,QAAM,SAAoC,CAAC;AAC3C,MAAI,UAAU;AACd,QAAM,OAAO,CAAC,OAAe,UAAmC,CAAC,MAAM;AACtE,QAAI,OAAO,WAAW,KAAK;AAC1B,aAAO,MAAM;AACb;AAAA,IACD;AACA,WAAO,KAAK;AAAA,MACX,GAAG;AAAA,MACH;AAAA,MACA,KAAI,oBAAI,KAAK,GAAE,YAAY;AAAA,MAC3B,WAAW,KAAK,MAAM,YAAY,IAAI,IAAI,OAAO;AAAA,IAClD,CAAC;AAAA,EACF;AACA,QAAM,cAAc;AAAA;AAAA,IAEnB;AAAA;AAAA,IAEA,IAAO,IAAgB;AACtB,aAAO,OAAO,IAAI,aAAa,EAAE;AAAA,IAClC;AAAA;AAAA,IAEA,SAAS;AACR,aAAO,KAAK,UAAU,EAAE,OAAO,KAAK,QAAQ,KAAK,UAAU,SAAS,OAAO,GAAG,MAAM,CAAC;AAAA,IACtF;AAAA;AAAA,IAEA,SAAS;AACR,WAAK,oBAAoB;AACzB,cAAQ,MAAM,YAAY,OAAO,CAAC;AAAA,IACnC;AAAA,EACD;AACA,OAAK,YAAY;AACjB,SAAO;AACR;AAGO,SAAS,oBAAuB,WAAmB,KAAiB;AAC1E,QAAM,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ACD,QAAI,CAAC,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,EAAE,SAAS,QAAQ;AAChE,WAAK,IAAI,UAAU,CAAC,UAAU,OAAO,UAAU,IAAI,CAAC;AACrD,SAAK,IAAI,UAAU,CAAC,QAAQ,MAAM,mBAAmB,MAAM,EAAE,CAAC;AAC9D,WAAO,EAAE,MAAM,UAAU,OAAO;AAAA,EACjC;AACD;","names":["name"]}
1
+ {"version":3,"sources":["../src/local-git.ts","../src/test-diagnostics.ts"],"sourcesContent":["import { execFileSync } from \"node:child_process\";\nimport {\n\tcpSync,\n\texistsSync,\n\tlstatSync,\n\tmkdirSync,\n\tmkdtempSync,\n\treadFileSync,\n\trealpathSync,\n\trenameSync,\n\trmSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport type { RepositoryFeedbackItem, RepositoryPullRequest } from \"@leitwerk-dev/process-sdk\";\nimport { traceTestSubprocess } from \"./test-diagnostics.js\";\n\n// Internal operational tests retain subprocess diagnostics.\nexport { createTestDiagnostics } from \"./test-diagnostics.js\";\n\n/** @public */\nexport interface LocalRepositorySeed {\n\t/** @public */\n\towner: string;\n\t/** @public */\n\tname: string;\n\t/** @internal */\n\tdefaultBranch?: string;\n\t/** @public */\n\tfiles?: Record<string, string>;\n\t/** Retain a pre-existing sandbox checkout layout. @internal */\n\tdirectoryName?: string;\n\t/** @internal */\n\tcommitMessage?: string;\n\t/** @internal */\n\tsignoff?: boolean;\n}\n\n/** Copies immutable bare seeds into independent test fixtures. @internal */\nexport class LocalGitSeedCache {\n\tprivate root: string | undefined;\n\tprivate readonly templates = new Map<string, string>();\n\n\t/** Seed options select the template; an existing destination is never overwritten. @internal */\n\tcopy(git: LocalGit, seed: LocalRepositorySeed): string {\n\t\tconst key = JSON.stringify(seed);\n\t\tlet template = this.templates.get(key);\n\t\tif (!template) {\n\t\t\tthis.root ??= mkdtempSync(path.join(tmpdir(), \"leitwerk-git-seeds-\"));\n\t\t\tconst directory = mkdtempSync(path.join(this.root, \"seed-\"));\n\t\t\ttemplate = new LocalGit(directory).seed(seed).bare;\n\t\t\tthis.templates.set(key, template);\n\t\t}\n\t\tconst destination = localPath(git.root, `repositories/${path.basename(template)}`);\n\t\tif (existsSync(destination)) throw new Error(\"Git seed destination already exists\");\n\t\tmkdirSync(path.dirname(destination), { recursive: true });\n\t\tcpSync(template, destination, { recursive: true, force: false, errorOnExist: true });\n\t\treturn destination;\n\t}\n\n\t/** Release templates after the suite; copied repositories remain usable. @internal */\n\tclose(): void {\n\t\tif (this.root) rmSync(this.root, { recursive: true, force: true });\n\t\tthis.root = undefined;\n\t\tthis.templates.clear();\n\t}\n}\n\n/** Reject escaping paths and symlinks, including a not-yet-created file's parents. @public */\nexport function localPath(root: string, relative: string): string {\n\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\tconst base = realpathSync(root);\n\tconst target = path.resolve(base, relative);\n\tif (!target.startsWith(`${base}${path.sep}`))\n\t\tthrow new Error(\"Path escapes local provider storage\");\n\tlet current = base;\n\tfor (const part of path.relative(base, target).split(path.sep)) {\n\t\tcurrent = path.join(current, part);\n\t\tif (lstatSync(current, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local provider storage must not contain symlinks\");\n\t}\n\treturn target;\n}\n\n/** @public */\nexport function readLocalJson<\n\tT extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t},\n>(root: string, file: string, initial: T): T {\n\tconst target = localPath(root, file);\n\tif (!existsSync(target)) return structuredClone(initial);\n\tconst value = JSON.parse(readFileSync(target, \"utf8\")) as T;\n\tif (!value || value.version !== initial.version)\n\t\tthrow new Error(`Unsupported local state version in ${file}`);\n\treturn value;\n}\n\n/** @public */\nexport function writeLocalJson(root: string, file: string, value: unknown): void {\n\tconst target = localPath(root, file);\n\tconst temporary = localPath(root, `${file}.tmp`);\n\twriteFileSync(temporary, `${JSON.stringify(value, null, 2)}\\n`, { mode: 0o600 });\n\trenameSync(temporary, target);\n}\n\n/** Persist local adapter state with a shared clock and monotonically increasing ids. @public */\nexport class LocalProviderStore<\n\tS extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tsequence: number;\n\t},\n\tO extends {\n\t\t/** @internal */\n\t\troot: string;\n\t\t/** @internal */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tnextId?: () => number;\n\t},\n> {\n\t/** @public */\n\treadonly git: LocalGit;\n\t/** @public */\n\tstate: S;\n\t/** @public */\n\tconstructor(\n\t\t/** @public */\n\t\treadonly options: O,\n\t\tprivate readonly file: string,\n\t\tinitial: S,\n\t) {\n\t\tthis.git = new LocalGit(options.root);\n\t\tthis.state = readLocalJson(options.root, file, initial);\n\t}\n\t/** @public */\n\tsave() {\n\t\twriteLocalJson(this.options.root, this.file, this.state);\n\t}\n\t/** @internal */\n\tid() {\n\t\tthis.state.sequence = Math.max(this.state.sequence + 1, this.options.nextId?.() ?? 0);\n\t\treturn this.state.sequence;\n\t}\n\t/** @internal */\n\ttimestamp() {\n\t\treturn new Date(this.options.now?.() ?? Date.now()).toISOString();\n\t}\n}\n\n/** @public */\ntype LocalPullRequest = Pick<\n\tRepositoryPullRequest,\n\t\"number\" | \"title\" | \"body\" | \"state\" | \"merged\" | \"merge_commit_sha\" | \"head\" | \"base\"\n>;\n/** @public */\ninterface LocalPullRequestRepository<P extends LocalPullRequest> {\n\t/** @public */\n\trepository: {\n\t\t/** @internal */\n\t\tssh_url: string;\n\t};\n\t/** @public */\n\tpulls: P[];\n}\n\n/** Common PR operations; adapters retain their provider-specific state and clients. @public */\nexport class LocalForgeStore<\n\tS extends {\n\t\t/** @internal */\n\t\tversion: number;\n\t\t/** @internal */\n\t\tsequence: number;\n\t},\n\tO extends {\n\t\t/** @internal */\n\t\troot: string;\n\t\t/** @internal */\n\t\tbaseUrl: string;\n\t\t/** @internal */\n\t\tnow?: () => number;\n\t\t/** @internal */\n\t\tnextId?: () => number;\n\t},\n> extends LocalProviderStore<S, O> {\n\t/** @public */\n\tnewRepository(seed: LocalRepositorySeed) {\n\t\tconst { bare, branch } = this.git.seed(seed);\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tid: this.id(),\n\t\t\t/** @public */\n\t\t\towner: {\n\t\t\t\t/** @internal */\n\t\t\t\tlogin: seed.owner,\n\t\t\t},\n\t\t\t/** @public */\n\t\t\tname: seed.name,\n\t\t\t/** @public */\n\t\t\tfull_name: `${seed.owner}/${seed.name}`,\n\t\t\t/** @public */\n\t\t\tssh_url: bare,\n\t\t\t/** @public */\n\t\t\thtml_url: `${this.options.baseUrl}/__local`,\n\t\t\t/** @public */\n\t\t\tdefault_branch: branch,\n\t\t};\n\t}\n\t/** @internal */\n\tpullRequestClient<P extends LocalPullRequest>(\n\t\trepo: (owner: string, name: string) => LocalPullRequestRepository<P>,\n\t\tmissing = \"Unknown local pull request\",\n\t) {\n\t\tconst pull = (owner: string, name: string, number: number) => {\n\t\t\tconst pr = repo(owner, name).pulls.find((p) => p.number === number);\n\t\t\tif (!pr) throw new Error(missing);\n\t\t\treturn pr;\n\t\t};\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tgetPullRequest: async (owner: string, name: string, number: number) =>\n\t\t\t\tthis.refresh(repo(owner, name), pull(owner, name, number)),\n\t\t\t/** @internal */\n\t\t\tlistPullRequests: async (owner: string, name: string, state = \"open\") => {\n\t\t\t\tconst r = repo(owner, name);\n\t\t\t\treturn r.pulls\n\t\t\t\t\t.filter((p) => state === \"all\" || p.state === state)\n\t\t\t\t\t.map((p) => this.refresh(r, p));\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tupdatePullRequest: async (\n\t\t\t\towner: string,\n\t\t\t\tname: string,\n\t\t\t\tnumber: number,\n\t\t\t\tpatch: Record<string, unknown>,\n\t\t\t) => {\n\t\t\t\tconst pr = pull(owner, name, number);\n\t\t\t\tfor (const key of [\"title\", \"body\", \"state\"] as const)\n\t\t\t\t\tif (typeof patch[key] === \"string\") pr[key] = patch[key];\n\t\t\t\tthis.save();\n\t\t\t\treturn this.refresh(repo(owner, name), pr);\n\t\t\t},\n\t\t};\n\t}\n\t/** @public */\n\trefresh<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, pr: P): P {\n\t\tif (pr.state === \"open\") {\n\t\t\tconst { headSha, baseSha, ...mergeability } = this.git.mergeability(\n\t\t\t\trepo.repository.ssh_url,\n\t\t\t\tpr.head.ref,\n\t\t\t\tpr.base.ref,\n\t\t\t);\n\t\t\tpr.head.sha = headSha;\n\t\t\tpr.base.sha = baseSha;\n\t\t\tObject.assign(pr, mergeability);\n\t\t}\n\t\treturn structuredClone(pr);\n\t}\n\t/** @public */\n\tmerge<P extends LocalPullRequest>(repo: LocalPullRequestRepository<P>, number: number): P {\n\t\tconst pr = repo.pulls.find((p) => p.number === number);\n\t\tif (!pr || pr.state !== \"open\") throw new Error(\"Pull request is not open\");\n\t\tthis.refresh(repo, pr);\n\t\tpr.merge_commit_sha = this.git.merge(repo.repository.ssh_url, pr.head.ref, pr.base.ref);\n\t\tpr.merged = true;\n\t\tpr.state = \"closed\";\n\t\tthis.save();\n\t\treturn structuredClone(pr);\n\t}\n\t/** @public */\n\taddFeedback<F extends RepositoryFeedbackItem>(\n\t\trepo: {\n\t\t\t/** @public */\n\t\t\tpulls: Array<{\n\t\t\t\t/** @internal */\n\t\t\t\tnumber: number;\n\t\t\t}>;\n\t\t\t/** @public */\n\t\t\tfeedback: Record<string, F[]>;\n\t\t},\n\t\tnumber: number,\n\t\tinput: Omit<F, \"id\" | \"createdAt\">,\n\t): F {\n\t\tif (!repo.pulls.some((p) => p.number === number)) throw new Error(\"Unknown PR\");\n\t\tconst value = { ...input, id: this.id(), createdAt: this.timestamp() } as F;\n\t\trepo.feedback[number] ??= [];\n\t\trepo.feedback[number].push(value);\n\t\tthis.save();\n\t\treturn value;\n\t}\n\t/** @public */\n\tnewComment(body: string) {\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tid: this.id(),\n\t\t\t/** @internal */\n\t\t\tbody,\n\t\t\t/** @public */\n\t\t\tuser: {\n\t\t\t\t/** @public */\n\t\t\t\tlogin: \"leitwerk-bot\",\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tcreated_at: this.timestamp(),\n\t\t};\n\t}\n\t/** @internal */\n\tnewPullRequest(\n\t\trepo: {\n\t\t\t/** @internal */\n\t\t\trepository: {\n\t\t\t\t/** @internal */\n\t\t\t\tssh_url: string;\n\t\t\t};\n\t\t},\n\t\tinput: {\n\t\t\t/** @internal */\n\t\t\ttitle: string;\n\t\t\t/** @internal */\n\t\t\tbody: string;\n\t\t\t/** @internal */\n\t\t\thead: string;\n\t\t\t/** @internal */\n\t\t\tbase: string;\n\t\t},\n\t) {\n\t\tconst number = this.id();\n\t\treturn {\n\t\t\t/** @internal */\n\t\t\tnumber,\n\t\t\t/** @internal */\n\t\t\ttitle: input.title,\n\t\t\t/** @internal */\n\t\t\tbody: input.body,\n\t\t\t/** @internal */\n\t\t\tstate: \"open\",\n\t\t\t/** @internal */\n\t\t\tmerged: false,\n\t\t\t/** @internal */\n\t\t\tmerge_commit_sha: null,\n\t\t\t/** @internal */\n\t\t\thtml_url: `${this.options.baseUrl}/__local#pr-${number}`,\n\t\t\t/** @internal */\n\t\t\thead: {\n\t\t\t\t/** @internal */\n\t\t\t\tref: input.head,\n\t\t\t\t/** @internal */\n\t\t\t\tsha: this.git.head(repo.repository.ssh_url, input.head),\n\t\t\t},\n\t\t\t/** @internal */\n\t\t\tbase: {\n\t\t\t\t/** @internal */\n\t\t\t\tref: input.base,\n\t\t\t\t/** @internal */\n\t\t\t\tsha: this.git.head(repo.repository.ssh_url, input.base),\n\t\t\t},\n\t\t};\n\t}\n}\n\n/** Real Git with file-only transport and no ambient credentials or hooks. @public */\nexport class LocalGit {\n\t/** @public */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly root: string,\n\t) {\n\t\tif (lstatSync(root, { throwIfNoEntry: false })?.isSymbolicLink())\n\t\t\tthrow new Error(\"Local Git root must not be a symlink\");\n\t\tmkdirSync(root, { recursive: true, mode: 0o700 });\n\t}\n\t/** @public */\n\trun(directory: string, args: string[]): string {\n\t\tconst base = realpathSync(this.root);\n\t\tconst directoryPath = path.resolve(directory);\n\t\tconst relative = path.relative(\n\t\t\tdirectoryPath.startsWith(`${base}${path.sep}`) ? base : path.resolve(this.root),\n\t\t\tdirectoryPath,\n\t\t);\n\t\tconst cwd = localPath(this.root, relative);\n\t\treturn traceTestSubprocess(`git ${args[0] ?? \"\"}`, () =>\n\t\t\texecFileSync(\n\t\t\t\t\"git\",\n\t\t\t\t[\"-c\", \"protocol.file.allow=always\", \"-c\", \"core.hooksPath=/dev/null\", ...args],\n\t\t\t\t{\n\t\t\t\t\tcwd,\n\t\t\t\t\tencoding: \"utf8\",\n\t\t\t\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t\t\t\t\tenv: {\n\t\t\t\t\t\tPATH: process.env.PATH,\n\t\t\t\t\t\tHOME: this.root,\n\t\t\t\t\t\tGIT_CONFIG_NOSYSTEM: \"1\",\n\t\t\t\t\t\tGIT_CONFIG_GLOBAL: \"/dev/null\",\n\t\t\t\t\t\tGIT_TERMINAL_PROMPT: \"0\",\n\t\t\t\t\t\tGIT_ALLOW_PROTOCOL: \"file\",\n\t\t\t\t\t\tGIT_AUTHOR_NAME: \"Sandbox Developer\",\n\t\t\t\t\t\tGIT_AUTHOR_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\t\tGIT_COMMITTER_NAME: \"Sandbox Developer\",\n\t\t\t\t\t\tGIT_COMMITTER_EMAIL: \"developer@sandbox.invalid\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t).trim(),\n\t\t);\n\t}\n\t/** @public */\n\thead(directory: string, ref: string): string {\n\t\tif (!/^[a-zA-Z0-9_./-]+$/.test(ref) || ref.startsWith(\"-\")) throw new Error(\"Invalid Git ref\");\n\t\treturn this.run(directory, [\"rev-parse\", \"--verify\", `${ref}^{commit}`]);\n\t}\n\t/** @internal */\n\tisAncestor(directory: string, ancestor: string, descendant: string): boolean {\n\t\treturn this.isAncestorCommit(\n\t\t\tdirectory,\n\t\t\tthis.head(directory, ancestor),\n\t\t\tthis.head(directory, descendant),\n\t\t);\n\t}\n\tprivate isAncestorCommit(directory: string, ancestor: string, descendant: string): boolean {\n\t\tif (ancestor === descendant) return true;\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-base\", \"--is-ancestor\", ancestor, descendant]);\n\t\t\treturn true;\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1) return false;\n\t\t\tthrow error;\n\t\t}\n\t}\n\t/** @internal */\n\tmergeability(\n\t\tdirectory: string,\n\t\thead: string,\n\t\tbase: string,\n\t): {\n\t\t/** @internal */\n\t\theadSha: string;\n\t\t/** @internal */\n\t\tbaseSha: string;\n\t\t/** @internal */\n\t\tmergeable: boolean;\n\t\t/** @internal */\n\t\tmergeable_state: string;\n\t} {\n\t\tconst headSha = this.head(directory, head),\n\t\t\tbaseSha = this.head(directory, base);\n\t\tconst revisions = { headSha, baseSha };\n\t\tif (this.isAncestorCommit(directory, baseSha, headSha))\n\t\t\treturn { ...revisions, mergeable: true, mergeable_state: \"clean\" };\n\t\ttry {\n\t\t\tthis.run(directory, [\"merge-tree\", \"--write-tree\", baseSha, headSha]);\n\t\t} catch (error) {\n\t\t\tif ((error as { status?: number }).status === 1)\n\t\t\t\treturn { ...revisions, mergeable: false, mergeable_state: \"dirty\" };\n\t\t\tthrow error;\n\t\t}\n\t\treturn { ...revisions, mergeable: true, mergeable_state: \"behind\" };\n\t}\n\t/** @internal */\n\tmerge(directory: string, head: string, base: string): string {\n\t\tconst h = this.head(directory, head),\n\t\t\tb = this.head(directory, base);\n\t\tlet commit = h;\n\t\tif (!this.isAncestorCommit(directory, b, h)) {\n\t\t\tconst tree = this.run(directory, [\"merge-tree\", \"--write-tree\", b, h]).split(\"\\n\")[0];\n\t\t\tcommit = this.run(directory, [\n\t\t\t\t\"commit-tree\",\n\t\t\t\ttree,\n\t\t\t\t\"-p\",\n\t\t\t\tb,\n\t\t\t\t\"-p\",\n\t\t\t\th,\n\t\t\t\t\"-m\",\n\t\t\t\t\"Merge local pull request\",\n\t\t\t]);\n\t\t}\n\t\tthis.run(directory, [\"update-ref\", `refs/heads/${base}`, commit, b]);\n\t\treturn commit;\n\t}\n\t/** @internal */\n\tseed(seed: LocalRepositorySeed): {\n\t\t/** @internal */\n\t\tbare: string;\n\t\t/** @internal */\n\t\tworktree: string;\n\t\t/** @internal */\n\t\tbranch: string;\n\t} {\n\t\tfor (const value of [seed.owner, seed.name, seed.directoryName ?? seed.name])\n\t\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/.test(value))\n\t\t\t\tthrow new Error(\"Invalid local repository name\");\n\t\tconst name = seed.directoryName ?? `${seed.owner}--${seed.name}`;\n\t\tconst bare = localPath(this.root, `repositories/${name}.git`);\n\t\tconst worktree = localPath(this.root, `seeds/${name}`);\n\t\tconst branch = seed.defaultBranch ?? \"main\";\n\t\tif (!/^[a-zA-Z0-9][a-zA-Z0-9_./-]*$/.test(branch)) throw new Error(\"Invalid default branch\");\n\t\tmkdirSync(bare, { recursive: true });\n\t\tmkdirSync(worktree, { recursive: true });\n\t\tif (!existsSync(path.join(bare, \"HEAD\")))\n\t\t\tthis.run(bare, [\"init\", \"--bare\", `--initial-branch=${branch}`]);\n\t\ttry {\n\t\t\tthis.head(bare, branch);\n\t\t\treturn { bare, worktree, branch };\n\t\t} catch {\n\t\t\t/* Resume an interrupted seed. */\n\t\t}\n\t\tif (!existsSync(path.join(worktree, \".git\")))\n\t\t\tthis.run(worktree, [\"init\", `--initial-branch=${branch}`]);\n\t\tfor (const [name, contents] of Object.entries(\n\t\t\tseed.files ?? { \"README.md\": `# ${seed.name}\\n` },\n\t\t)) {\n\t\t\tif (name.split(/[\\\\/]/).includes(\".git\"))\n\t\t\t\tthrow new Error(\"Seed must not write Git configuration\");\n\t\t\tconst target = localPath(worktree, name);\n\t\t\tmkdirSync(path.dirname(target), { recursive: true });\n\t\t\twriteFileSync(target, contents);\n\t\t}\n\t\tthis.run(worktree, [\"add\", \".\"]);\n\t\tthis.run(worktree, [\n\t\t\t\"commit\",\n\t\t\t\"--allow-empty\",\n\t\t\t...(seed.signoff ? [\"--signoff\"] : []),\n\t\t\t\"-m\",\n\t\t\tseed.commitMessage ?? \"chore: seed local repository\",\n\t\t]);\n\t\tif (!this.run(worktree, [\"remote\"]).split(\"\\n\").includes(\"origin\"))\n\t\t\tthis.run(worktree, [\"remote\", \"add\", \"origin\", bare]);\n\t\tthis.run(worktree, [\"push\", bare, `HEAD:refs/heads/${branch}`]);\n\t\treturn { bare, worktree, branch };\n\t}\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { threadId } from \"node:worker_threads\";\n\nconst active = new AsyncLocalStorage<ReturnType<typeof createTestDiagnostics>>();\n\n/** @internal Bounded, in-memory trace. Call report from onTestFailed; successful tests stay quiet. */\nexport function createTestDiagnostics(label: string) {\n\tconst started = performance.now();\n\tconst events: Record<string, unknown>[] = [];\n\tlet dropped = 0;\n\tconst mark = (stage: string, details: Record<string, unknown> = {}) => {\n\t\tif (events.length === 512) {\n\t\t\tevents.shift();\n\t\t\tdropped++;\n\t\t}\n\t\tevents.push({\n\t\t\t...details,\n\t\t\tstage,\n\t\t\tat: new Date().toISOString(),\n\t\t\telapsedMs: Math.round(performance.now() - started),\n\t\t});\n\t};\n\tconst diagnostics = {\n\t\t/** @internal */\n\t\tmark,\n\t\t/** @internal */\n\t\trun<T>(fn: () => T): T {\n\t\t\treturn active.run(diagnostics, fn);\n\t\t},\n\t\t/** @internal */\n\t\tformat() {\n\t\t\treturn JSON.stringify({ label, pid: process.pid, threadId, dropped, events }, null, 2);\n\t\t},\n\t\t/** @internal */\n\t\treport() {\n\t\t\tmark(\"diagnostics.report\");\n\t\t\tconsole.error(diagnostics.format());\n\t\t},\n\t};\n\tmark(\"test.start\");\n\treturn diagnostics;\n}\n\n/** @internal Logs only the operation name and exit metadata, never arguments, output or environment. */\nexport function traceTestSubprocess<T>(operation: string, run: () => T): T {\n\tconst trace = active.getStore();\n\tif (!trace) return run();\n\tconst started = performance.now();\n\ttrace.mark(\"subprocess.start\", { operation });\n\ttry {\n\t\tconst result = run();\n\t\ttrace.mark(\"subprocess.exit\", {\n\t\t\toperation,\n\t\t\tstatus: 0,\n\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t});\n\t\treturn result;\n\t} catch (error) {\n\t\tconst details = error as { status?: unknown; signal?: unknown; code?: unknown } | null;\n\t\ttrace.mark(\"subprocess.exit\", {\n\t\t\toperation,\n\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t\tstatus: typeof details?.status === \"number\" ? details.status : null,\n\t\t\tsignal: typeof details?.signal === \"string\" ? details.signal : null,\n\t\t\tcode: typeof details?.code === \"string\" ? details.code : null,\n\t\t});\n\t\tthrow error;\n\t}\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AACvB,OAAO,UAAU;;;ACdjB,SAAS,yBAAyB;AAClC,SAAS,gBAAgB;AAEzB,IAAM,SAAS,IAAI,kBAA4D;AAGxE,SAAS,sBAAsB,OAAe;AACpD,QAAM,UAAU,YAAY,IAAI;AAChC,QAAM,SAAoC,CAAC;AAC3C,MAAI,UAAU;AACd,QAAM,OAAO,CAAC,OAAe,UAAmC,CAAC,MAAM;AACtE,QAAI,OAAO,WAAW,KAAK;AAC1B,aAAO,MAAM;AACb;AAAA,IACD;AACA,WAAO,KAAK;AAAA,MACX,GAAG;AAAA,MACH;AAAA,MACA,KAAI,oBAAI,KAAK,GAAE,YAAY;AAAA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AAC;AAC/B,SAAK,IAAI,UAAU;AAAA,MAClB;AAAA,MACA;AAAA,MACA,GAAI,KAAK,UAAU,CAAC,WAAW,IAAI,CAAC;AAAA,MACpC;AAAA,MACA,KAAK,iBAAiB;AAAA,IACvB,CAAC;AACD,QAAI,CAAC,KAAK,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,EAAE,SAAS,QAAQ;AAChE,WAAK,IAAI,UAAU,CAAC,UAAU,OAAO,UAAU,IAAI,CAAC;AACrD,SAAK,IAAI,UAAU,CAAC,QAAQ,MAAM,mBAAmB,MAAM,EAAE,CAAC;AAC9D,WAAO,EAAE,MAAM,UAAU,OAAO;AAAA,EACjC;AACD;","names":["name"]}
@@ -1,4 +1,9 @@
1
+ import type { ExtensionCatalog } from "@leitwerk-dev/extension-runtime";
1
2
  import { defineModelProviders } from "@leitwerk-dev/process-sdk";
3
+ import type { ConfigSnapshot } from "@leitwerk-dev/protocol";
4
+ import type { ExtensionIntegrationHarnessOptions } from "./extension-integration-harness.js";
5
+ /** @internal */
6
+ export declare const fixtureModelProfiles: NonNullable<ExtensionIntegrationHarnessOptions["models"]>;
2
7
  /** @public */
3
8
  export type FixtureModelProviderSet = ReturnType<typeof defineModelProviders>;
4
9
  /** @public */
@@ -12,4 +17,6 @@ export declare function fixtureModelProviders(...models: {
12
17
  /** @public */
13
18
  server?: boolean;
14
19
  }[]): FixtureModelProviderSet;
20
+ /** Explicit model wiring for server tests that do not exercise an LLM. @internal */
21
+ export declare function withDefaultModelFixture(config: ConfigSnapshot, catalog: ExtensionCatalog): ExtensionCatalog;
15
22
  //# sourceMappingURL=model-provider-fixtures.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"model-provider-fixtures.d.ts","sourceRoot":"","sources":["../src/model-provider-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;AAEnC,cAAc;AACd,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE9E,cAAc;AACd,wBAAgB,qBAAqB,CACpC,GAAG,MAAM,EAAE;IACV,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EAAE,GACD,uBAAuB,CAczB"}
1
+ {"version":3,"file":"model-provider-fixtures.d.ts","sourceRoot":"","sources":["../src/model-provider-fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAGN,oBAAoB,EACpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,oCAAoC,CAAC;AAE7F,gBAAgB;AAChB,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,kCAAkC,CAAC,QAAQ,CAAC,CAQ1F,CAAC;AAEF,cAAc;AACd,MAAM,MAAM,uBAAuB,GAAG,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE9E,cAAc;AACd,wBAAgB,qBAAqB,CACpC,GAAG,MAAM,EAAE;IACV,cAAc;IACd,EAAE,EAAE,MAAM,CAAC;IACX,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB,EAAE,GACD,uBAAuB,CAczB;AAED,oFAAoF;AACpF,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE,gBAAgB,GACvB,gBAAgB,CAoBlB"}