Skip to content

Commit 037adca

Browse files
committed
🧹 Keep the artifact's record shapes out of the runtime-neutral surface
DLC13 failed on all three runtimes. `src/artifact/types.ts` and `src/artifact/source.ts` sat in the shared tree while naming what only the Deno adapter has: the retained shapes they compose are DOFS manifests, DOFS blobs, SQLite-retained Repository, Worktree, answer and Agent-session rows, their content kinds spell `dofs-*`, and the source reader hashes with `node:crypto`. The runtime-neutral surface is not allowed to reach any of that, and the check that says so is not a style rule — it is what keeps a second adapter possible. So both modules go back under `src/deno/artifact/`, where the rows they describe live. What the provider-neutral lifecycle actually needed from them was one type: `XmdArtifactFrontier`, three strings naming which run, which final committed event and which Workspace root. That is the lifecycle's own decision rather than the container's record of it, so it is declared beside the export request and result and the container imports it. The dependency now runs container → lifecycle, and nothing is restated in two places. The published surfaces follow the same line. `mod.ts` keeps the export request, its result and the frontier; the closure types, `gitBlobIdentity` and the source reader move to `deno.ts`, and the CLI reads them from there — it only ever reaches them through its Deno host. The container's own encoding stays private on both entrypoints, which xmd-artifact.test.ts C9 still enforces. No behavior changes: the same values travel the same path. Refs #600
1 parent 3f79c4a commit 037adca

14 files changed

Lines changed: 69 additions & 47 deletions

File tree

‎packages/cli/src/workflow-source.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
*/
1717

1818
import { Ok, type Operation, type Result } from "effection";
19-
import { gitBlobIdentity } from "@executablemd/workflow";
20-
import type { XmdArtifactDefinitionClosure } from "@executablemd/workflow";
19+
import { gitBlobIdentity } from "@executablemd/workflow/deno";
20+
import type { XmdArtifactDefinitionClosure } from "@executablemd/workflow/deno";
2121
import type { WorkflowDefinition } from "@executablemd/workflow";
2222
import type { Json } from "@executablemd/durable-streams";
2323
import { loadRetainedDefinition } from "./workflow-definition.ts";

‎packages/workflow/deno.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,24 @@ export type {
3737
WorkflowRunCreation,
3838
} from "./src/lifecycle/execution.ts";
3939
export type { WorkflowLifecycleOptions } from "./src/deno/lifecycle.ts";
40+
/**
41+
* How a host reads a retained definition's Markdown back, and the closure it
42+
* returns.
43+
*
44+
* Published here rather than from the package root because these describe what
45+
* this adapter retains: a closure is checked against DOFS and SQLite rows, and
46+
* the reader is installed into this provider. The encoding stays private —
47+
* nothing that reads or writes a container is exported from any entrypoint.
48+
*/
49+
export { gitBlobIdentity } from "./src/deno/artifact/source.ts";
50+
export type { WorkflowDefinitionSourceReader } from "./src/deno/artifact/source.ts";
51+
export type {
52+
DetachedXmdArtifact,
53+
VerifiedXmdArtifact,
54+
XmdArtifactDefinitionClosure,
55+
XmdArtifactDefinitionComponent,
56+
XmdArtifactDefinitionRoot,
57+
} from "./src/deno/artifact/types.ts";
4058
export {
4159
hashRunId,
4260
workflowForkStaging,

‎packages/workflow/mod.ts‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,16 +313,14 @@ export type {
313313
WorkflowLifecycleApi,
314314
WorkflowLifecycleSnapshot,
315315
} from "./src/lifecycle/api.ts";
316-
export { gitBlobIdentity } from "./src/artifact/source.ts";
317-
export type { WorkflowExportRequest, WorkflowExportResult } from "./src/lifecycle/export.ts";
316+
// The export request, its result and the boundary it names. The retained record
317+
// shapes an artifact also carries are DOFS and SQLite rows, so they are the
318+
// Deno entrypoint's to publish rather than this one's.
318319
export type {
319-
DetachedXmdArtifact,
320-
VerifiedXmdArtifact,
321-
XmdArtifactDefinitionClosure,
322-
XmdArtifactDefinitionComponent,
323-
XmdArtifactDefinitionRoot,
320+
WorkflowExportRequest,
321+
WorkflowExportResult,
324322
XmdArtifactFrontier,
325-
} from "./src/artifact/types.ts";
323+
} from "./src/lifecycle/export.ts";
326324
export { readEventSource } from "./src/lifecycle/history.ts";
327325
export type { InheritedEventProvenance, WorkflowHistoryEntry } from "./src/lifecycle/history.ts";
328326
export { classifyForkability } from "./src/lifecycle/forkability.ts";

‎packages/workflow/src/deno/artifact-frontier.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import type {
3535
DetachedXmdArtifact,
3636
XmdArtifactDefinitionClosure,
3737
XmdArtifactJournalRow,
38-
} from "../artifact/types.ts";
38+
} from "./artifact/types.ts";
3939
import type { InheritedEventProvenance } from "../lifecycle/history.ts";
4040
import { WorkflowRequestError } from "../storage/errors.ts";
4141
import type { WorkflowRunRecord } from "../storage/record.ts";

‎packages/workflow/src/deno/artifact/manifest.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import type {
3232
XmdArtifactContentEntry,
3333
XmdArtifactManifestEntryV1,
3434
XmdArtifactManifestV1,
35-
} from "../../artifact/types.ts";
35+
} from "./types.ts";
3636

3737
/** The artifact manifest version this build produces and reads. */
3838
export const XMD_ARTIFACT_MANIFEST_VERSION = 1;

‎packages/workflow/src/deno/artifact/mod.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ export type {
2222
XmdArtifactFrontier,
2323
XmdArtifactJournalRow,
2424
XmdArtifactWriteResult,
25-
} from "../../artifact/types.ts";
25+
} from "./types.ts";

‎packages/workflow/src/deno/artifact/read.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import {
6565
type XmdArtifactDefinitionClosure,
6666
type XmdArtifactEncoding,
6767
type XmdArtifactJournalRow,
68-
} from "../../artifact/types.ts";
68+
} from "./types.ts";
6969

7070
const SELECT_HEADER_VERSION = "SELECT artifact_version FROM xmd_artifact_header WHERE id = 1";
7171
const SELECT_HEADER =

‎packages/workflow/src/deno/artifact/records.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ import {
8686
} from "../workspace/manifest.ts";
8787
import { decodeDofsManifest } from "../workspace/root.ts";
8888
import type { DofsManifest } from "../workspace/root.ts";
89-
import { gitBlobIdentity } from "../../artifact/source.ts";
89+
import { gitBlobIdentity } from "./source.ts";
9090
import { canonicalJsonBytes, canonicalJsonText, entryKey } from "./manifest.ts";
9191
import type {
9292
XmdArtifactContentEntry,
@@ -97,7 +97,7 @@ import type {
9797
XmdArtifactForkLineage,
9898
XmdArtifactFrontier,
9999
XmdArtifactJournalRow,
100-
} from "../../artifact/types.ts";
100+
} from "./types.ts";
101101

102102
const encoder = new TextEncoder();
103103
const decoder = new TextDecoder("utf-8", { fatal: true });

packages/workflow/src/artifact/source.ts renamed to packages/workflow/src/deno/artifact/source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import { createHash } from "node:crypto";
1616
import type { Operation, Result } from "effection";
1717
import type { Json } from "@executablemd/durable-streams";
18-
import type { WorkflowDefinition } from "../storage/definition.ts";
18+
import type { WorkflowDefinition } from "../../storage/definition.ts";
1919
import type { XmdArtifactDefinitionClosure } from "./types.ts";
2020

2121
const encoder = new TextEncoder();

packages/workflow/src/artifact/types.ts renamed to packages/workflow/src/deno/artifact/types.ts

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,21 @@
2525
*/
2626

2727
import type { Json } from "@executablemd/durable-streams";
28-
import type { InheritedEventProvenance } from "../lifecycle/history.ts";
29-
import type { DocumentExecutionRecord, WorkflowRunRecord } from "../storage/record.ts";
30-
import type { AgentSessionRecord } from "../deno/workspace/agent-sessions.ts";
31-
import type { RetainedAnswer } from "../deno/answers.ts";
28+
import type { InheritedEventProvenance } from "../../lifecycle/history.ts";
29+
import type { DocumentExecutionRecord, WorkflowRunRecord } from "../../storage/record.ts";
30+
import type { XmdArtifactFrontier } from "../../lifecycle/export.ts";
31+
import type { AgentSessionRecord } from "../workspace/agent-sessions.ts";
32+
import type { RetainedAnswer } from "../answers.ts";
3233
import type {
3334
RetainedBlob,
3435
RetainedManifest,
3536
RetainedRepository,
3637
RetainedWorktree,
37-
} from "../deno/fork-source.ts";
38-
import type { StoredWorkspaceRoot } from "../deno/workspace/manifest.ts";
38+
} from "../fork-source.ts";
39+
import type { StoredWorkspaceRoot } from "../workspace/manifest.ts";
3940

40-
/**
41-
* The exact committed boundary this artifact records.
42-
*
43-
* The final committed event is absent for a run whose journal is empty, which
44-
* is a run that was created and never appended to. The current Workspace root
45-
* is the run's own current-root pointer at that boundary and is recorded once,
46-
* here: writing it a second time beside the roots would make one fact into two
47-
* records that a tampered file could set against each other.
48-
*/
49-
export interface XmdArtifactFrontier {
50-
readonly sourceRunId: string;
51-
readonly finalEventId?: string;
52-
readonly currentWorkspaceRootId: string;
53-
}
41+
/** The boundary the lifecycle chose, as the shape every record here is about. */
42+
export type { XmdArtifactFrontier };
5443

5544
/** The lineage of the fork the source run itself was, when it was one. */
5645
export interface XmdArtifactForkLineage {

0 commit comments

Comments
 (0)