@interf/compiler 0.9.5 → 0.13.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 (214) hide show
  1. package/README.md +96 -92
  2. package/TRADEMARKS.md +2 -13
  3. package/agent-skills/interf-actions/SKILL.md +95 -36
  4. package/agent-skills/interf-actions/references/cli.md +118 -51
  5. package/builtin-methods/interf-default/README.md +3 -4
  6. package/builtin-methods/interf-default/compile/stages/shape/SKILL.md +2 -2
  7. package/builtin-methods/interf-default/compile/stages/summarize/SKILL.md +2 -1
  8. package/builtin-methods/interf-default/improve/SKILL.md +1 -1
  9. package/builtin-methods/interf-default/method.json +10 -4
  10. package/builtin-methods/interf-default/method.schema.json +0 -9
  11. package/builtin-methods/interf-default/use/query/SKILL.md +5 -5
  12. package/dist/cli/commands/compile.d.ts +8 -25
  13. package/dist/cli/commands/compile.js +75 -360
  14. package/dist/cli/commands/doctor.js +1 -1
  15. package/dist/cli/commands/login.d.ts +7 -0
  16. package/dist/cli/commands/login.js +39 -0
  17. package/dist/cli/commands/logout.d.ts +2 -0
  18. package/dist/cli/commands/logout.js +16 -0
  19. package/dist/cli/commands/method.d.ts +2 -0
  20. package/dist/cli/commands/method.js +113 -0
  21. package/dist/cli/commands/prep.d.ts +2 -0
  22. package/dist/cli/commands/prep.js +134 -0
  23. package/dist/cli/commands/reset.d.ts +8 -1
  24. package/dist/cli/commands/reset.js +47 -26
  25. package/dist/cli/commands/runs.d.ts +2 -0
  26. package/dist/cli/commands/runs.js +120 -0
  27. package/dist/cli/commands/status.d.ts +6 -1
  28. package/dist/cli/commands/status.js +68 -111
  29. package/dist/cli/commands/test.d.ts +6 -14
  30. package/dist/cli/commands/test.js +65 -181
  31. package/dist/cli/commands/web.d.ts +0 -9
  32. package/dist/cli/commands/web.js +147 -120
  33. package/dist/cli/commands/wizard.d.ts +9 -0
  34. package/dist/cli/commands/wizard.js +442 -0
  35. package/dist/cli/index.d.ts +7 -6
  36. package/dist/cli/index.js +13 -10
  37. package/dist/compiler-ui/404.html +1 -1
  38. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  39. package/dist/compiler-ui/__next._full.txt +3 -3
  40. package/dist/compiler-ui/__next._head.txt +1 -1
  41. package/dist/compiler-ui/__next._index.txt +2 -2
  42. package/dist/compiler-ui/__next._tree.txt +2 -2
  43. package/dist/compiler-ui/_next/static/chunks/{18a8f2jkv3z.c.css → 045gole2ojo3g.css} +1 -1
  44. package/dist/compiler-ui/_next/static/chunks/{177mvn4rse235.js → 17t-lulmyawg5.js} +9 -9
  45. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  46. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  47. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  48. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  49. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  50. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  51. package/dist/compiler-ui/_not-found.html +1 -1
  52. package/dist/compiler-ui/_not-found.txt +2 -2
  53. package/dist/compiler-ui/index.html +1 -1
  54. package/dist/compiler-ui/index.txt +3 -3
  55. package/dist/packages/agents/lib/shells.d.ts +1 -1
  56. package/dist/packages/agents/lib/shells.js +111 -52
  57. package/dist/packages/agents/lib/user-config.d.ts +4 -2
  58. package/dist/packages/agents/lib/user-config.js +15 -7
  59. package/dist/packages/compiler/compiled-paths.d.ts +9 -2
  60. package/dist/packages/compiler/compiled-paths.js +30 -15
  61. package/dist/packages/compiler/compiled-pipeline.js +23 -3
  62. package/dist/packages/compiler/compiled-stage-plan.js +4 -0
  63. package/dist/packages/compiler/compiled-target.d.ts +1 -1
  64. package/dist/packages/compiler/compiled-target.js +1 -1
  65. package/dist/packages/compiler/index.d.ts +1 -0
  66. package/dist/packages/compiler/index.js +1 -0
  67. package/dist/packages/compiler/lib/schema.d.ts +26 -31
  68. package/dist/packages/compiler/lib/schema.js +1 -12
  69. package/dist/packages/compiler/method-runs.d.ts +2 -3
  70. package/dist/packages/compiler/method-runs.js +2 -3
  71. package/dist/packages/compiler/reset.js +3 -1
  72. package/dist/packages/compiler/runtime-contracts.js +0 -3
  73. package/dist/packages/compiler/runtime-prompt.js +1 -1
  74. package/dist/packages/compiler/source-files.d.ts +46 -0
  75. package/dist/packages/compiler/source-files.js +149 -0
  76. package/dist/packages/compiler/state-artifacts.d.ts +3 -2
  77. package/dist/packages/compiler/state-artifacts.js +4 -3
  78. package/dist/packages/compiler/state-io.d.ts +3 -2
  79. package/dist/packages/compiler/state-io.js +11 -5
  80. package/dist/packages/compiler/state-paths.d.ts +2 -1
  81. package/dist/packages/compiler/state-paths.js +6 -3
  82. package/dist/packages/compiler/state-view.d.ts +3 -2
  83. package/dist/packages/compiler/state-view.js +18 -28
  84. package/dist/packages/compiler/state.d.ts +4 -4
  85. package/dist/packages/compiler/state.js +3 -3
  86. package/dist/packages/contracts/index.d.ts +1 -1
  87. package/dist/packages/contracts/lib/preparation-paths.d.ts +117 -0
  88. package/dist/packages/contracts/lib/preparation-paths.js +177 -0
  89. package/dist/packages/contracts/lib/schema.d.ts +85 -5
  90. package/dist/packages/contracts/lib/schema.js +46 -1
  91. package/dist/packages/execution/lib/schema.d.ts +50 -50
  92. package/dist/packages/execution/lib/schema.js +1 -1
  93. package/dist/packages/local-service/action-definitions.d.ts +14 -14
  94. package/dist/packages/local-service/action-definitions.js +27 -28
  95. package/dist/packages/local-service/action-planner.js +2 -1
  96. package/dist/packages/local-service/client.d.ts +51 -52
  97. package/dist/packages/local-service/client.js +132 -140
  98. package/dist/packages/local-service/connection-config.d.ts +38 -0
  99. package/dist/packages/local-service/connection-config.js +75 -0
  100. package/dist/packages/local-service/index.d.ts +11 -7
  101. package/dist/packages/local-service/index.js +6 -4
  102. package/dist/packages/local-service/instance-paths.d.ts +100 -0
  103. package/dist/packages/local-service/instance-paths.js +165 -0
  104. package/dist/packages/local-service/lib/schema.d.ts +405 -2297
  105. package/dist/packages/local-service/lib/schema.js +146 -62
  106. package/dist/packages/local-service/native-run-handlers.js +3 -3
  107. package/dist/packages/local-service/preparation-store.d.ts +92 -0
  108. package/dist/packages/local-service/preparation-store.js +171 -0
  109. package/dist/packages/local-service/routes.d.ts +33 -16
  110. package/dist/packages/local-service/routes.js +44 -20
  111. package/dist/packages/local-service/run-observability.js +11 -11
  112. package/dist/packages/local-service/runtime-caches.d.ts +76 -0
  113. package/dist/packages/local-service/runtime-caches.js +191 -0
  114. package/dist/packages/local-service/runtime-event-applier.d.ts +12 -0
  115. package/dist/packages/local-service/runtime-event-applier.js +177 -0
  116. package/dist/packages/local-service/runtime-persistence.d.ts +47 -0
  117. package/dist/packages/local-service/runtime-persistence.js +137 -0
  118. package/dist/packages/local-service/runtime-proposal-helpers.d.ts +35 -0
  119. package/dist/packages/local-service/runtime-proposal-helpers.js +251 -0
  120. package/dist/packages/local-service/runtime-resource-builders.d.ts +52 -0
  121. package/dist/packages/local-service/runtime-resource-builders.js +149 -0
  122. package/dist/packages/local-service/runtime.d.ts +197 -43
  123. package/dist/packages/local-service/runtime.js +800 -974
  124. package/dist/packages/local-service/server.d.ts +15 -0
  125. package/dist/packages/local-service/server.js +641 -273
  126. package/dist/packages/local-service/service-registry.d.ts +47 -0
  127. package/dist/packages/local-service/service-registry.js +137 -0
  128. package/dist/packages/method-authoring/method-authoring.d.ts +1 -1
  129. package/dist/packages/method-authoring/method-authoring.js +2 -2
  130. package/dist/packages/method-authoring/method-improvement.js +1 -1
  131. package/dist/packages/method-package/builtin-compiled-method.d.ts +4 -5
  132. package/dist/packages/method-package/builtin-compiled-method.js +8 -14
  133. package/dist/packages/method-package/context-interface.d.ts +4 -40
  134. package/dist/packages/method-package/context-interface.js +1 -23
  135. package/dist/packages/method-package/interf-method-package.d.ts +4 -4
  136. package/dist/packages/method-package/interf-method-package.js +21 -33
  137. package/dist/packages/method-package/local-methods.d.ts +10 -6
  138. package/dist/packages/method-package/local-methods.js +57 -39
  139. package/dist/packages/method-package/method-definitions.d.ts +8 -34
  140. package/dist/packages/method-package/method-definitions.js +49 -37
  141. package/dist/packages/method-package/method-helpers.d.ts +1 -13
  142. package/dist/packages/method-package/method-helpers.js +8 -42
  143. package/dist/packages/method-package/method-stage-runner.js +2 -2
  144. package/dist/packages/method-package/user-methods.d.ts +17 -0
  145. package/dist/packages/method-package/user-methods.js +77 -0
  146. package/dist/packages/project-model/index.d.ts +0 -1
  147. package/dist/packages/project-model/index.js +0 -1
  148. package/dist/packages/project-model/interf-detect.d.ts +8 -3
  149. package/dist/packages/project-model/interf-detect.js +34 -34
  150. package/dist/packages/project-model/interf-scaffold.d.ts +3 -3
  151. package/dist/packages/project-model/interf-scaffold.js +23 -32
  152. package/dist/packages/project-model/lib/schema.js +38 -1
  153. package/dist/packages/project-model/preparation-entries.d.ts +5 -5
  154. package/dist/packages/project-model/preparation-entries.js +14 -14
  155. package/dist/packages/project-model/source-config.d.ts +11 -11
  156. package/dist/packages/project-model/source-config.js +74 -46
  157. package/dist/packages/project-model/source-folders.d.ts +5 -5
  158. package/dist/packages/project-model/source-folders.js +14 -14
  159. package/dist/packages/shared/filesystem.d.ts +7 -0
  160. package/dist/packages/shared/filesystem.js +97 -10
  161. package/dist/packages/testing/lib/schema.d.ts +10 -10
  162. package/dist/packages/testing/lib/schema.js +2 -2
  163. package/dist/packages/testing/readiness-check-run.d.ts +4 -4
  164. package/dist/packages/testing/readiness-check-run.js +36 -36
  165. package/dist/packages/testing/test-execution.js +6 -6
  166. package/dist/packages/testing/test-paths.js +4 -3
  167. package/dist/packages/testing/test-sandbox.d.ts +0 -1
  168. package/dist/packages/testing/test-sandbox.js +14 -30
  169. package/dist/packages/testing/test-targets.d.ts +1 -1
  170. package/dist/packages/testing/test-targets.js +6 -6
  171. package/dist/packages/testing/test.d.ts +1 -1
  172. package/dist/packages/testing/test.js +1 -1
  173. package/package.json +3 -4
  174. package/CHANGELOG.md +0 -93
  175. package/LICENSE +0 -183
  176. package/dist/cli/commands/action-input-cli.d.ts +0 -25
  177. package/dist/cli/commands/action-input-cli.js +0 -73
  178. package/dist/cli/commands/control-path.d.ts +0 -11
  179. package/dist/cli/commands/control-path.js +0 -72
  180. package/dist/cli/commands/create-method-wizard.d.ts +0 -64
  181. package/dist/cli/commands/create-method-wizard.js +0 -434
  182. package/dist/cli/commands/create.d.ts +0 -6
  183. package/dist/cli/commands/create.js +0 -183
  184. package/dist/cli/commands/default.d.ts +0 -2
  185. package/dist/cli/commands/default.js +0 -39
  186. package/dist/cli/commands/executor-flow.d.ts +0 -29
  187. package/dist/cli/commands/executor-flow.js +0 -163
  188. package/dist/cli/commands/init.d.ts +0 -26
  189. package/dist/cli/commands/init.js +0 -771
  190. package/dist/cli/commands/list.d.ts +0 -2
  191. package/dist/cli/commands/list.js +0 -30
  192. package/dist/cli/commands/preparation-action.d.ts +0 -8
  193. package/dist/cli/commands/preparation-action.js +0 -29
  194. package/dist/cli/commands/preparation-picker.d.ts +0 -5
  195. package/dist/cli/commands/preparation-picker.js +0 -36
  196. package/dist/cli/commands/preparation-selection.d.ts +0 -6
  197. package/dist/cli/commands/preparation-selection.js +0 -11
  198. package/dist/cli/commands/service-action-flow.d.ts +0 -9
  199. package/dist/cli/commands/service-action-flow.js +0 -19
  200. package/dist/cli/commands/source-config-wizard.d.ts +0 -51
  201. package/dist/cli/commands/source-config-wizard.js +0 -670
  202. package/dist/cli/commands/verify.d.ts +0 -2
  203. package/dist/cli/commands/verify.js +0 -94
  204. package/dist/packages/compiler/raw-snapshot.d.ts +0 -49
  205. package/dist/packages/compiler/raw-snapshot.js +0 -101
  206. package/dist/packages/method-package/index.d.ts +0 -11
  207. package/dist/packages/method-package/index.js +0 -11
  208. package/dist/packages/method-package/method-stage-policy.d.ts +0 -5
  209. package/dist/packages/method-package/method-stage-policy.js +0 -31
  210. package/dist/packages/project-model/project-paths.d.ts +0 -12
  211. package/dist/packages/project-model/project-paths.js +0 -33
  212. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_buildManifest.js +0 -0
  213. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_clientMiddlewareManifest.js +0 -0
  214. /package/dist/compiler-ui/_next/static/{84FaeF3EzBF9kKTMjSEVN → C6vVfy3aeYuIO3d2AoNvC}/_ssgManifest.js +0 -0
@@ -2,7 +2,7 @@ import { type ArtifactRef, type CompileRun, type InterfRunEvent, type ProofRecor
2
2
  import { type RunEventSink } from "../execution/events.js";
3
3
  import { type ReadinessState } from "../contracts/lib/schema.js";
4
4
  import type { SourcePreparationConfig } from "../project-model/lib/schema.js";
5
- import { type ActionProposalCreateRequest, type ActionProposalPlan, type ActionProposalResource, type CompileRunCreateRequest, type CompileRunResource, type MethodResource, type LocalServiceHealth, type LocalJobEvent, type LocalJobEventAppendRequest, type LocalExecutorStatus, type LocalJobRunResource, type LocalRunHandlerResult, type PortableContextResource, type PreparationReadinessState, type PreparationResource, type ReadinessCheckDraftCreateRequest, type ReadinessCheckDraftResult, type RunObservabilityResource, type SourceFileResource, type WorkspaceFileResource, type TestRunCreateRequest, type TestRunResource, type MethodAuthoringCreateRequest, type MethodAuthoringResult, type MethodChangeResult, type PreparationChangeResult, type PreparationSetupResult, type ResetResult } from "./lib/schema.js";
5
+ import { type ActionProposalCreateRequest, type ActionProposalPlan, type ActionProposalResource, type CompileRunCreateRequest, type CompileRunResource, type MethodResource, type LocalServiceHealth, type LocalJobEvent, type LocalJobEventAppendRequest, type LocalExecutorStatus, type LocalJobRunResource, type LocalRunHandlerResult, type PortableContextResource, type PreparationResource, type ReadinessCheckDraftCreateRequest, type ReadinessCheckDraftResult, type RunObservabilityResource, type ServiceRegistryWorkspace, type SourceFileResource, type WorkspaceFileResource, type TestRunCreateRequest, type TestRunResource, type MethodAuthoringCreateRequest, type MethodAuthoringResult, type MethodChangeResult, type PreparationChangeResult, type PreparationSetupResult, type WorkspaceBootstrapResult, type ResetResult } from "./lib/schema.js";
6
6
  export interface LocalServiceCompileRunContext {
7
7
  runId: string;
8
8
  sourcePath: string;
@@ -52,63 +52,217 @@ export interface LocalServiceRuntimeOptions {
52
52
  packageVersion?: string;
53
53
  startedAt?: string;
54
54
  handlers?: Partial<LocalServiceRunHandlers>;
55
+ /**
56
+ * Per-instance bearer token. The server requires it on mutating
57
+ * requests. Optional only so test code that does not exercise auth can
58
+ * skip generating one; production startup always provides a token.
59
+ */
60
+ authToken?: string;
61
+ }
62
+ /**
63
+ * Per-workspace context tracked by the runtime. Multiple workspaces can be
64
+ * registered against one running service; each one owns its rootPath and
65
+ * activity timestamps. Routes pass the workspace explicitly to every
66
+ * runtime method that needs one, so there is no swap-state to manage.
67
+ */
68
+ export interface PreparationContext {
69
+ rootPath: string;
70
+ startedAt: string;
71
+ lastActivity: string;
55
72
  }
56
73
  export declare class LocalServiceRuntime {
57
- readonly rootPath: string;
58
74
  readonly host: string;
59
- readonly port: number;
75
+ port: number;
60
76
  readonly startedAt: string;
61
77
  readonly packageVersion?: string;
62
78
  readonly handlers: Partial<LocalServiceRunHandlers>;
79
+ /**
80
+ * The seed root path the runtime was constructed with. Used as a
81
+ * non-preparation fallback when a preparation-independent route
82
+ * (methods, action proposals, runs listings) needs an anchor to load
83
+ * shared state (user-library methods, bundled methods, etc).
84
+ */
85
+ readonly rootPath: string;
86
+ /**
87
+ * Per-instance bearer token. Mutating routes require this on the
88
+ * Authorization header. `null` means token-less mode (test harness).
89
+ */
90
+ readonly authToken: string | null;
91
+ /** Map of prepDataDir -> PreparationContext. */
92
+ private workspaces;
93
+ /** Hook called whenever a workspace is registered or deregistered. */
94
+ private onRegistryChanged;
95
+ /** In-flight runs across all workspaces. Used for `idle_for_seconds`. */
96
+ private activeRunCount;
97
+ /**
98
+ * Active compile-run cancellation handles, keyed by run id. Populated
99
+ * when a compile run is launched and cleared once the run reaches a
100
+ * terminal state. Each entry remembers where the persisted record lives
101
+ * so cancel can mark it without re-resolving the Preparation.
102
+ */
103
+ private activeCompileRuns;
104
+ /**
105
+ * Idempotency-key cache for `POST /v1/compile-runs`. Outer key is the
106
+ * resolved workspace root; inner key is the client-supplied idempotency
107
+ * value. Namespacing per workspace prevents key collisions across
108
+ * tenants on the same engine (CSO finding: a malicious workspace could
109
+ * otherwise hijack another workspace's run id by reusing its key).
110
+ * Entries expire after `IDEMPOTENCY_TTL_MS`.
111
+ */
112
+ private idempotencyKeyCache;
113
+ /**
114
+ * Read-side caches. Polling clients (Compiler UI, CLI status loops)
115
+ * hit list/get endpoints multiple times per second; without these,
116
+ * every request re-walks the filesystem and re-parses every JSON
117
+ * record through Zod. The runtime invalidates each cache on the
118
+ * matching write path. See {@link runtime-caches} for design notes.
119
+ */
120
+ private readonly compileRunCache;
121
+ private readonly testRunCache;
122
+ private readonly readinessCache;
123
+ private readonly sourceFilesCache;
124
+ private readonly methodListingCache;
63
125
  constructor(options: LocalServiceRuntimeOptions);
64
- health(): LocalServiceHealth;
65
- listPreparations(): PreparationResource[];
66
- getPreparation(preparationName: string): PreparationResource | null;
67
- listPreparationReadiness(): PreparationReadinessState[];
68
- getPreparationReadiness(preparationName: string): PreparationReadinessState | null;
69
- listReadiness(): ReadinessState[];
70
- getReadiness(preparationName: string): ReadinessState | null;
71
- computePreparationReadiness(preparation: SourcePreparationConfig): ReadinessState;
72
- listSourceFiles(preparationName?: string | null): SourceFileResource[];
73
- listWorkspaceFiles(): WorkspaceFileResource[];
74
- listMethods(): MethodResource[];
75
- getMethod(methodId: string): MethodResource | null;
76
- listJobs(): LocalJobRunResource[];
77
- getJob(runId: string): LocalJobRunResource | null;
78
- getJobEvents(runId: string): LocalJobEvent[] | null;
126
+ setBoundPort(port: number): void;
127
+ /** Set a hook that fires whenever the registered workspaces change. */
128
+ setOnRegistryChanged(handler: (() => void) | null): void;
129
+ /**
130
+ * Register a workspace with this runtime. Returns the PreparationContext.
131
+ * Idempotent: re-registering an existing workspace updates `lastActivity`.
132
+ */
133
+ registerPreparation(prepDataDir: string): PreparationContext;
134
+ /**
135
+ * Remove a workspace from the runtime. Returns true if a workspace was
136
+ * removed.
137
+ */
138
+ deregisterPreparation(prepDataDir: string): boolean;
139
+ /**
140
+ * Most recently active workspace, or the first registered if none has
141
+ * activity yet. Server code uses this as the fallback when a request
142
+ * omits the workspace header. Throws if no workspace is registered.
143
+ */
144
+ defaultPreparationDataDir(): string;
145
+ /** Look up a workspace context by rootPath. */
146
+ getPreparationContext(prepDataDir: string): PreparationContext | null;
147
+ /** All registered workspaces, ordered by registration time. */
148
+ listRegisteredPreparations(): PreparationContext[];
149
+ /** True when no workspaces are registered. */
150
+ hasNoWorkspaces(): boolean;
151
+ /** Number of registered workspaces. */
152
+ registeredPreparationCount(): number;
153
+ /** Increment in-flight run counter. Call when a long-running run starts. */
154
+ beginActiveRun(): void;
155
+ /** Decrement in-flight run counter. Pair with `beginActiveRun`. */
156
+ endActiveRun(): void;
157
+ /** Sum of in-flight runs across all workspaces. */
158
+ activeRuns(): number;
159
+ /**
160
+ * Mark the workspace as recently active. Routes call this on entry so
161
+ * `idleForSeconds` and the registry snapshots stay in sync with the
162
+ * actual request cadence.
163
+ */
164
+ touchPreparation(prepDataDir: string): void;
165
+ /** Snapshot of registered workspaces for the registry / status output. */
166
+ registeredPreparationSnapshots(): ServiceRegistryWorkspace[];
167
+ /** Seconds since the most recent workspace activity (0 if active). */
168
+ idleForSeconds(): number;
169
+ health(prepDataDir?: string): LocalServiceHealth;
170
+ listPreparations(prepDataDir: string): PreparationResource[];
171
+ getPreparation(prepDataDir: string, preparationName: string): PreparationResource | null;
172
+ listPreparationReadiness(prepDataDir: string): ReadinessState[];
173
+ getPreparationReadiness(prepDataDir: string, preparationName: string): ReadinessState | null;
174
+ listReadiness(prepDataDir: string): ReadinessState[];
175
+ getReadiness(prepDataDir: string, preparationName: string): ReadinessState | null;
176
+ computePreparationReadiness(prepDataDir: string, preparation: SourcePreparationConfig): ReadinessState;
177
+ private computePreparationReadinessUncached;
178
+ listSourceFiles(prepDataDir: string, preparationName?: string | null): SourceFileResource[];
179
+ listWorkspaceFiles(prepDataDir: string): WorkspaceFileResource[];
180
+ listMethods(prepDataDir: string): MethodResource[];
181
+ getMethod(prepDataDir: string, methodId: string): MethodResource | null;
182
+ listJobs(prepDataDir: string): LocalJobRunResource[];
183
+ getJob(prepDataDir: string, runId: string): LocalJobRunResource | null;
184
+ getJobEvents(prepDataDir: string, runId: string): LocalJobEvent[] | null;
79
185
  getExecutorStatus(): LocalExecutorStatus;
80
186
  selectExecutor(requestValue: unknown): LocalExecutorStatus;
81
- listActionProposals(): ActionProposalResource[];
82
- getActionProposal(proposalId: string): ActionProposalResource | null;
83
- createActionProposal(requestValue: unknown): Promise<ActionProposalResource>;
84
- decideActionProposal(proposalId: string, requestValue: unknown): Promise<ActionProposalResource | null>;
85
- listRunObservability(): RunObservabilityResource[];
86
- getRunObservability(runId: string): RunObservabilityResource | null;
187
+ listActionProposals(prepDataDir: string): ActionProposalResource[];
188
+ getActionProposal(prepDataDir: string, proposalId: string): ActionProposalResource | null;
189
+ createActionProposal(prepDataDir: string, requestValue: unknown): Promise<ActionProposalResource>;
190
+ decideActionProposal(prepDataDir: string, proposalId: string, requestValue: unknown): Promise<ActionProposalResource | null>;
191
+ listRunObservability(prepDataDir: string): RunObservabilityResource[];
192
+ getRunObservability(prepDataDir: string, runId: string): RunObservabilityResource | null;
87
193
  private createJobRun;
88
194
  private appendJobRunEvent;
89
- createReadinessCheckDraftRun(requestValue: unknown): Promise<LocalJobRunResource>;
90
- applyMethodChange(requestValue: unknown): MethodChangeResult;
91
- applyPreparationSetup(requestValue: unknown): PreparationSetupResult;
92
- applyPreparationChange(requestValue: unknown): PreparationChangeResult;
93
- applyReset(requestValue: unknown): ResetResult;
94
- createMethodAuthoringRun(requestValue: unknown, jobType?: "method-authoring" | "method-improvement"): Promise<LocalJobRunResource>;
95
- listPortableContexts(): PortableContextResource[];
96
- getPortableContext(preparationName: string): PortableContextResource | null;
97
- listCompileRuns(): CompileRunResource[];
98
- listCompileRunsForPreparation(preparationName: string): CompileRun[];
99
- getCompileRun(runId: string): CompileRunResource | null;
100
- getCompileRunEvents(runId: string): InterfRunEvent[] | null;
101
- getCompileRunProof(runId: string): ProofRecord[] | null;
102
- getCompileRunArtifacts(runId: string): ArtifactRef[] | null;
103
- createCompileRun(requestValue: unknown): Promise<CompileRunResource>;
104
- listTestRuns(): TestRunResource[];
105
- listTestRunsForPreparation(preparationName: string): TestRunResource[];
106
- getTestRun(runId: string): TestRunResource | null;
107
- createTestRun(requestValue: unknown): Promise<TestRunResource>;
195
+ createReadinessCheckDraftRun(prepDataDir: string, requestValue: unknown): Promise<LocalJobRunResource>;
196
+ applyMethodChange(prepDataDir: string, requestValue: unknown): MethodChangeResult;
197
+ /**
198
+ * Bootstrap the workspace's source-folder binding and seed the default
199
+ * Method. Idempotent: re-running with the same source folder preserves
200
+ * existing preparations and reports `changed: false`.
201
+ *
202
+ * The CLI calls this in place of writing `interf.json` directly, so the
203
+ * operation is recorded by the service (and visible to other clients).
204
+ */
205
+ bootstrapWorkspace(prepDataDir: string, requestValue: unknown): WorkspaceBootstrapResult;
206
+ applyPreparationSetup(prepDataDir: string, requestValue: unknown): PreparationSetupResult;
207
+ applyPreparationChange(prepDataDir: string, requestValue: unknown): PreparationChangeResult;
208
+ applyReset(prepDataDir: string, requestValue: unknown): ResetResult;
209
+ createMethodAuthoringRun(prepDataDir: string, requestValue: unknown, jobType?: "method-authoring" | "method-improvement"): Promise<LocalJobRunResource>;
210
+ listPortableContexts(prepDataDir: string): PortableContextResource[];
211
+ getPortableContext(prepDataDir: string, preparationName: string): PortableContextResource | null;
212
+ listCompileRuns(prepDataDir: string): CompileRunResource[];
213
+ listCompileRunsForPreparation(prepDataDir: string, preparationName: string): CompileRun[];
214
+ getCompileRun(prepDataDir: string, runId: string): CompileRunResource | null;
215
+ getCompileRunEvents(prepDataDir: string, runId: string): InterfRunEvent[] | null;
216
+ getCompileRunProof(prepDataDir: string, runId: string): ProofRecord[] | null;
217
+ getCompileRunArtifacts(prepDataDir: string, runId: string): ArtifactRef[] | null;
218
+ createCompileRun(prepDataDir: string, requestValue: unknown): Promise<CompileRunResource>;
219
+ /**
220
+ * Cancel an in-flight compile run. Marks the persisted record as
221
+ * `cancelled`, emits a `run.failed` event to capture the cancellation in
222
+ * the run timeline, and clears the active handle so retries may start a
223
+ * fresh run. If the run already finished, returns
224
+ * `{ cancelled: false, reason: "already finished" }` and persists nothing.
225
+ */
226
+ cancelCompileRun(runId: string): {
227
+ cancelled: boolean;
228
+ reason?: string;
229
+ };
230
+ /**
231
+ * Look up the run id previously associated with this idempotency key in
232
+ * `prepDataDir`. Returns null when the key is unknown or its TTL has
233
+ * elapsed. The workspace argument is required so that the same key in
234
+ * two different workspaces always returns two different runs.
235
+ */
236
+ findIdempotentCompileRun(prepDataDir: string, key: string): string | null;
237
+ /**
238
+ * Cache the run id created (or returned) for this idempotency key in
239
+ * `prepDataDir`. Entries expire after `IDEMPOTENCY_TTL_MS`. Pruning
240
+ * is opportunistic: the previous implementation walked every entry on
241
+ * every read AND write, which was O(N) per request. Now we only sweep
242
+ * when the cache grows past {@link IDEMPOTENCY_PRUNE_THRESHOLD}.
243
+ */
244
+ recordIdempotentCompileRun(prepDataDir: string, key: string, runId: string): void;
245
+ /** Total cached idempotency entries across all workspaces. */
246
+ private totalIdempotencyEntries;
247
+ private pruneIdempotencyKeyCache;
248
+ /**
249
+ * Test seam: force the cached entry for `key` in `prepDataDir` to be
250
+ * expired so the next lookup returns null. Returns true when an entry was
251
+ * found and expired. Tests use this in place of fake timers because the
252
+ * idempotency TTL is one hour and faking `Date.now()` would destabilize
253
+ * unrelated runtime state.
254
+ */
255
+ expireIdempotencyKeyForTesting(prepDataDir: string, key: string): boolean;
256
+ listTestRuns(prepDataDir: string): TestRunResource[];
257
+ listTestRunsForPreparation(prepDataDir: string, preparationName: string): TestRunResource[];
258
+ getTestRun(prepDataDir: string, runId: string): TestRunResource | null;
259
+ createTestRun(prepDataDir: string, requestValue: unknown): Promise<TestRunResource>;
108
260
  private runCompileInBackground;
109
261
  private runTestInBackground;
110
262
  private runReadinessCheckDraftInBackground;
263
+ private runReadinessCheckDraftInBackgroundInner;
111
264
  private runMethodAuthoringInBackground;
265
+ private runMethodAuthoringInBackgroundInner;
112
266
  private jobRunContext;
113
267
  private defaultPreparationName;
114
268
  private planActionProposal;