Skip to content

Commit cd63c80

Browse files
authored
refactor: rename workflow store surface
Refs #209
1 parent 1459960 commit cd63c80

6 files changed

Lines changed: 15 additions & 12 deletions

File tree

autoresearch.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,15 @@ function runtimeAutoresearchProbe() {
302302
import { access, mkdtemp, rm } from "node:fs/promises";
303303
import os from "node:os";
304304
import path from "node:path";
305-
import { FileKapiStore } from "./src/adapters/file-store.ts";
305+
import { FileWorkflowStore } from "./src/adapters/file-store.ts";
306306
import { KapiService } from "./src/application/workflow-service.ts";
307307
async function exists(file) {
308308
try { await access(file); return true; } catch { return false; }
309309
}
310310
async function main() {
311311
const workspace = await mkdtemp(path.join(os.tmpdir(), "kapi-runtime-autoresearch-"));
312312
try {
313-
const service = new KapiService(new FileKapiStore());
313+
const service = new KapiService(new FileWorkflowStore());
314314
const result = await service.startWorkflow({ workspace, workflowId: "kapi-autoresearch", slug: "runtime-contract", task: "Optimize a metric" });
315315
const names = new Set(result.state.artifacts.map((artifact) => artifact.name));
316316
const requiredNames = ["state.json", "events.jsonl", "snapshot.json", "contract.md", "benchmark.sh", "checks.sh", "ledger.jsonl", "ideas.md"];
@@ -343,7 +343,7 @@ function runtimeModeProbe(workflowId) {
343343
import { access, mkdtemp, readFile, rm } from "node:fs/promises";
344344
import os from "node:os";
345345
import path from "node:path";
346-
import { FileKapiStore } from "./src/adapters/file-store.ts";
346+
import { FileWorkflowStore } from "./src/adapters/file-store.ts";
347347
import { KapiService } from "./src/application/workflow-service.ts";
348348
async function exists(file) { try { await access(file); return true; } catch { return false; } }
349349
async function parseJsonFile(file) { try { JSON.parse(await readFile(file, "utf8")); return true; } catch { return false; } }
@@ -359,7 +359,7 @@ function runtimeModeProbe(workflowId) {
359359
async function main() {
360360
const workspace = await mkdtemp(path.join(os.tmpdir(), "kapi-runtime-mode-"));
361361
try {
362-
const service = new KapiService(new FileKapiStore());
362+
const service = new KapiService(new FileWorkflowStore());
363363
const result = await service.startWorkflow({ workspace, workflowId: ${JSON.stringify(workflowId)}, slug: "runtime-contract", task: "Probe runtime contract" });
364364
const filesPass = (await Promise.all(result.state.artifacts.map((artifact) => exists(artifact.path)))).every(Boolean);
365365
const rootPass = result.state.artifactRoot.includes(".ilchul/workflows/");

docs/product-name-audit.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ git grep -n -i -E 'kapi|ilchul' -- ':!package-lock.json' ':!node_modules'
2121
| Storage/config | `.ilchul`, `~/.ilchul`, `.kapi` historical references, and `ILCHUL_*` environment variables appear in docs/tests/runtime setup. | storage/config namespace | `.ilchul` is active storage; `.kapi` is legacy evidence only and must not be deleted by this issue. |
2222
| GitHub review integration | `kapi-agent`, `kapi-agent/review`, and `kapi-review` remain literal external integration names. | external integration | Keep literal names while the GitHub App and required checks use them. |
2323
| Documentation/history | README, policy docs, references, and historical explanations still mention Kapi and Ilchul. | documentation/history | New public runtime examples should use `ilchul`; internal implementation examples may use `runctl` / `runtime`; historical and compatibility prose may keep product names with context. |
24-
| Core/domain/application identifiers | The registry entry type now uses `WorkflowRegistryEntry`; exported classes such as `KapiService` and `KapiStore` remain product-prefixed. The local factory export is now `createLocalWorkflowService`. | known reusable-code leakage reduced by bounded slices | Follow-up slices should rename remaining service/store identifiers by boundary (`WorkflowService`, `WorkflowStore`, etc.) with compatibility exports where safe. |
24+
| Core/domain/application identifiers | The registry entry type now uses `WorkflowRegistryEntry`; the store interface/class now use `WorkflowStore` / `FileWorkflowStore`; exported service class `KapiService` remains product-prefixed. The local factory export is now `createLocalWorkflowService`. | known reusable-code leakage reduced by bounded slices | Follow-up slices should rename the remaining service identifier by boundary (`WorkflowService`) with compatibility exports where safe. |
2525
| Application service filenames | The service implementation and factory now use semantic filenames: `src/application/workflow-service.ts` and `src/adapters/workflow-service-factory.ts`. | internal semantic implementation | Keep imports on the semantic service paths; exported class/function names are intentionally left for a smaller follow-up compatibility slice. |
2626
| CLI worker/runtime helper filenames | Worker event, runtime observation, and GitHub issue context helpers now use semantic filenames: `src/cli/worker-events.ts`, `src/cli/worker-runtime.ts`, and `src/cli/github-issue-context.ts`. | internal semantic implementation | Keep imports on the semantic helper paths; remaining worker event payload names such as `kapi.worker.*` are external event contracts, not filenames. |
2727

@@ -35,6 +35,7 @@ git grep -n -i -E 'kapi|ilchul' -- ':!package-lock.json' ':!node_modules'
3535
- Presentation helper exports use semantic workflow/tool names for generic helpers (`WorkflowToolDefinition`, `shouldBlockWorkflowToolCall`, `formatWorkflowError`).
3636
- PR review state helpers use generic pull-request / agent-review names (`PullRequestReviewState`, `PullRequestReviewView`, `latestAgentReview`, `reviewCheckConclusion`).
3737
- Registry entry types now use the semantic `WorkflowRegistryEntry` name across the domain, adapter, CLI, presentation, and tests.
38+
- Store abstractions now use semantic `WorkflowStore` / `FileWorkflowStore` names across application ports, adapters, and runtime probe scripts; a temporary compatibility export keeps existing tests and external imports working for follow-up slices.
3839

3940
## Residual scan after service filename rename
4041

src/adapters/file-store.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { KapiStore } from "../application/ports.js";
1+
import type { WorkflowStore } from "../application/ports.js";
22
import { workflowDocumentState } from "../application/state-artifacts.js";
33
import type { WorkflowState } from "../domain/types.js";
44
import { fs, isNotFoundError, path, withNotFoundFallback } from "./fs-path.js";
@@ -10,7 +10,7 @@ interface ActiveIndex {
1010
updatedAt: string;
1111
}
1212

13-
export class FileKapiStore implements KapiStore {
13+
export class FileWorkflowStore implements WorkflowStore {
1414
async saveWorkflow(state: WorkflowState): Promise<void> {
1515
const file = path.join(state.artifactRoot, "state.json");
1616
await this.prepareWritableKapiFile(state.workspace, file);
@@ -388,3 +388,5 @@ export class FileKapiStore implements KapiStore {
388388
return `# specs/\n\nKapi workflow: ${state.command}\nTask: ${state.task}\nStatus: ${state.status}\nPhase: ${state.phase}\nUpdated: ${state.updatedAt}\n\nRalph-specific specs live in this directory. The generic Kapi artifact API intentionally rejects artifact names with path separators, so specs are tracked through the required \`specs\` directory artifact and concrete files under \`specs/*\`.\n`;
389389
}
390390
}
391+
392+
export { FileWorkflowStore as FileKapiStore };

src/adapters/workflow-service-factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { KapiService } from "../application/workflow-service.js";
22
import { ChildRpcDeepInterviewReviewer } from "./deep-interview-child-rpc.js";
3-
import { FileKapiStore } from "./file-store.js";
3+
import { FileWorkflowStore } from "./file-store.js";
44
import { FileProjectContextProvider } from "./project-context.js";
55
import { LocalWorkerCapabilityProvider, LocalWorkerWorkspacePreparer } from "./worker-substrate.js";
66

@@ -9,7 +9,7 @@ export function createLocalWorkflowService(): KapiService {
99
const workerAdapters = [workerSubstrate, workerSubstrate, workerSubstrate, workerSubstrate] as const;
1010
const deepInterviewReviewer = process.env.KAPI_DEEP_INTERVIEW_JUDGE === "child-rpc" ? new ChildRpcDeepInterviewReviewer() : undefined;
1111
return new KapiService(
12-
new FileKapiStore(),
12+
new FileWorkflowStore(),
1313
undefined,
1414
new FileProjectContextProvider(),
1515
new LocalWorkerCapabilityProvider(),

src/application/ports.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface WorkerCapability {
88
reason?: string;
99
}
1010

11-
export interface KapiStore {
11+
export interface WorkflowStore {
1212
saveWorkflow(state: WorkflowState): Promise<void>;
1313
loadWorkflow(workspace: string, workflowId: WorkflowId, slug: string): Promise<WorkflowState | undefined>;
1414
loadActive(workspace: string): Promise<WorkflowState | undefined>;

src/application/workflow-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { unsafeArtifacts, validateHandoffDocument, validateProgressDocument, wit
44
import { AUTHORED_METADATA_ARTIFACTS, syncAuthoredArtifactMetadata } from "./authored-artifact-metadata.js";
55
import { scanAutoresearchAntiGaming, type AntiGamingFlag } from "./autoresearch-loop.js";
66
import { validateExperimentContract } from "./autoresearch-contract.js";
7-
import type { Clock, CompleteWorkflowInput, DispatchWorkerTaskInput, EvidenceInput, FailWorkflowInput, KapiStore, PlanWorkerInput, PlannedWorkerStrategy, PrepareWorkerInput, ProjectContextProvider, ReadArtifactInput, RefreshWorkerStatusInput, StartWorkflowInput, UpdateWorkflowInput, WorkerCapability, WorkerCapabilityProvider, WorkerKind, WorkerMonitor, WorkerPrepareResult, WorkerStatusSnapshot, WorkerTaskDispatcher, WorkerTaskDispatchResult, WorkerWorkspaceCloser, WorkerWorkspacePreparer, WriteArtifactInput, WriteArtifactsInput } from "./ports.js";
7+
import type { Clock, CompleteWorkflowInput, DispatchWorkerTaskInput, EvidenceInput, FailWorkflowInput, WorkflowStore, PlanWorkerInput, PlannedWorkerStrategy, PrepareWorkerInput, ProjectContextProvider, ReadArtifactInput, RefreshWorkerStatusInput, StartWorkflowInput, UpdateWorkflowInput, WorkerCapability, WorkerCapabilityProvider, WorkerKind, WorkerMonitor, WorkerPrepareResult, WorkerStatusSnapshot, WorkerTaskDispatcher, WorkerTaskDispatchResult, WorkerWorkspaceCloser, WorkerWorkspacePreparer, WriteArtifactInput, WriteArtifactsInput } from "./ports.js";
88
import { EmptyProjectContextProvider, EmptyWorkerCapabilityProvider, SystemClock } from "./service-defaults.js";
99
import { addEvidence, assertCompletionEvidence, compactGeneratedSlug, createWorkflowState, getWorkflowDefinition, isTerminalStatus, planWorkerStrategy, renderRunContractPrompt, slugify, transitionWorkflow, validateWorkflowState, WORKFLOW_DEFINITIONS, type WorkflowDefinition, type WorkflowId, type WorkflowState, type WorkflowTransitionRequest, type WorkflowValidationReport } from "./service-domain.js";
1010
import { buildDeepInterviewSnapshot } from "./deep-interview/snapshot.js";
@@ -19,7 +19,7 @@ const execFileAsync = promisify(execFile);
1919

2020
export class KapiService {
2121
constructor(
22-
private readonly store: KapiStore,
22+
private readonly store: WorkflowStore,
2323
private readonly clock: Clock = new SystemClock(),
2424
private readonly projectContext: ProjectContextProvider = new EmptyProjectContextProvider(),
2525
private readonly workers: WorkerCapabilityProvider = new EmptyWorkerCapabilityProvider(),

0 commit comments

Comments
 (0)