Skip to content

Commit 5c40839

Browse files
authored
Restack journal migration #1374 on main (#1374)
1 parent 95a27ce commit 5c40839

3 files changed

Lines changed: 27 additions & 18 deletions

File tree

‎packages/core/tests/loop.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -883,11 +883,12 @@ describe("Tier LOOP — document execution", () => {
883883
* final iteration, and an empty body from an immediate `<Break>`.
884884
*/
885885
describe("Tier LOOP — execution records", () => {
886+
beforeEach(journalBeforeEach("packages/core/tests/loop.test.ts"));
886887
beforeAll(() => useTempFileCompiler());
887888

888889
function runDoc(doc: string, files: Record<string, string> = {}) {
889890
return scoped(function* () {
890-
const stream = new InMemoryStream();
891+
const stream = yield* useJournalStream("test.md");
891892
yield* useHostFiles();
892893
yield* useStubFs({ "test.md": doc, ...files });
893894
yield* useEchoExec();

‎packages/core/tests/sample-component.test.ts‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function stubProvider(componentName: string): string {
9494
}
9595

9696
describe("Tier SC — Sample component", () => {
97+
beforeEach(journalBeforeEach("packages/core/tests/sample-component.test.ts"));
9798
beforeAll(() => useTempFileCompiler());
9899
// SC1: Self-closing with prompt — prompt sent to Sample Api
99100
it("SC1: self-closing with prompt — response in output", function* () {
@@ -116,7 +117,7 @@ describe("Tier SC — Sample component", () => {
116117
].join("\n"),
117118
});
118119

119-
const stream = new InMemoryStream();
120+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
120121
const output = yield* collect(
121122
yield* execute({
122123
path: path.join(tmpDir, "doc.md"),
@@ -162,7 +163,7 @@ describe("Tier SC — Sample component", () => {
162163
].join("\n"),
163164
});
164165

165-
const stream = new InMemoryStream();
166+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
166167
const output = yield* collect(
167168
yield* execute({
168169
path: path.join(tmpDir, "doc.md"),
@@ -203,7 +204,7 @@ describe("Tier SC — Sample component", () => {
203204
].join("\n"),
204205
});
205206

206-
const stream = new InMemoryStream();
207+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
207208
const output = yield* collect(
208209
yield* execute({
209210
path: path.join(tmpDir, "doc.md"),
@@ -230,7 +231,7 @@ describe("Tier SC — Sample component", () => {
230231
"doc.md": '<Sample prompt="no provider" />',
231232
});
232233

233-
const stream = new InMemoryStream();
234+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
234235
const execution = yield* execute({
235236
path: path.join(tmpDir, "doc.md"),
236237
stream,
@@ -310,7 +311,7 @@ describe("Tier SC — Sample component", () => {
310311
].join("\n"),
311312
});
312313

313-
const stream = new InMemoryStream();
314+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
314315
const output = yield* collect(
315316
yield* execute({
316317
path: path.join(tmpDir, "doc.md"),
@@ -349,7 +350,7 @@ describe("Tier SC — Sample component", () => {
349350
].join("\n"),
350351
});
351352

352-
const stream = new InMemoryStream();
353+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
353354
const output = yield* collect(
354355
yield* execute({
355356
path: path.join(tmpDir, "doc.md"),
@@ -396,7 +397,7 @@ describe("Tier SC — Sample component", () => {
396397
].join("\n"),
397398
});
398399

399-
const stream = new InMemoryStream();
400+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
400401
const output = yield* collect(
401402
yield* execute({
402403
path: path.join(tmpDir, "doc.md"),
@@ -706,6 +707,7 @@ describe("Tier RC — renderChildren and render closures", () => {
706707
});
707708

708709
describe("Tier IN — Instruction component", () => {
710+
beforeEach(journalBeforeEach("packages/core/tests/sample-component.test.ts"));
709711
beforeAll(() => useTempFileCompiler());
710712
// IN1: Instruction enriches Sample context with instructions
711713
it("IN1: Instruction enriches Sample context", function* () {
@@ -733,7 +735,7 @@ describe("Tier IN — Instruction component", () => {
733735
].join("\n"),
734736
});
735737

736-
const stream = new InMemoryStream();
738+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
737739
const output = yield* collect(
738740
yield* execute({
739741
path: path.join(tmpDir, "doc.md"),
@@ -766,7 +768,7 @@ describe("Tier IN — Instruction component", () => {
766768
].join("\n"),
767769
});
768770

769-
const stream = new InMemoryStream();
771+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
770772
const output = yield* collect(
771773
yield* execute({
772774
path: path.join(tmpDir, "doc.md"),
@@ -808,7 +810,7 @@ describe("Tier IN — Instruction component", () => {
808810
].join("\n"),
809811
});
810812

811-
const stream = new InMemoryStream();
813+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
812814
const output = yield* collect(
813815
yield* execute({
814816
path: path.join(tmpDir, "doc.md"),
@@ -840,7 +842,7 @@ describe("Tier IN — Instruction component", () => {
840842
].join("\n"),
841843
});
842844

843-
const stream = new InMemoryStream();
845+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
844846
const output = yield* collect(
845847
yield* execute({
846848
path: path.join(tmpDir, "doc.md"),
@@ -855,6 +857,7 @@ describe("Tier IN — Instruction component", () => {
855857
});
856858

857859
describe("Tier AG — Agent component pattern", () => {
860+
beforeEach(journalBeforeEach("packages/core/tests/sample-component.test.ts"));
858861
beforeAll(() => useTempFileCompiler());
859862
// AG1: Agent component installs instruction middleware + Content
860863
it("AG1: agent component with instruction middleware", function* () {
@@ -899,7 +902,7 @@ describe("Tier AG — Agent component pattern", () => {
899902
].join("\n"),
900903
});
901904

902-
const stream = new InMemoryStream();
905+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
903906
const output = yield* collect(
904907
yield* execute({
905908
path: path.join(tmpDir, "doc.md"),
@@ -979,7 +982,7 @@ describe("Tier AG — Agent component pattern", () => {
979982
].join("\n"),
980983
});
981984

982-
const stream = new InMemoryStream();
985+
const stream = yield* useJournalStream(path.join(tmpDir, "doc.md"));
983986
const output = yield* collect(
984987
yield* execute({
985988
path: path.join(tmpDir, "doc.md"),

‎packages/core/tests/workflow-component-bundle.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
* `execute()` has none and behaves exactly as it always did.
2222
*/
2323

24-
import { describe, it } from "@executablemd/test-support/bdd";
24+
import { beforeEach, describe, it } from "@executablemd/test-support/bdd";
2525
import { expect } from "@executablemd/test-support/expect";
26+
import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal";
2627
import { ensure, scoped, spawn, until } from "effection";
2728
import type { Operation } from "effection";
2829
import { rm, writeTextFile } from "@effectionx/fs";
@@ -76,8 +77,9 @@ function* run(
7677
source: string,
7778
components: readonly WorkflowBundleComponent[] = BUNDLE,
7879
extra: readonly ExecutionInstallation[] = [],
79-
stream: InMemoryStream = new InMemoryStream(),
80+
suppliedStream?: InMemoryStream,
8081
): Operation<Json> {
82+
const stream = suppliedStream ?? (yield* useJournalStream(ROOT_PATH));
8183
return yield* collect(
8284
yield* executeInstalled({ ...retainedSource(ROOT_PATH, source), stream, includes: [] }, [
8385
installation(components),
@@ -124,10 +126,11 @@ function* attempted(
124126
source: string,
125127
components: readonly WorkflowBundleComponent[] = BUNDLE,
126128
): Operation<{ readonly failure: string; readonly output: string }> {
129+
const stream = yield* useJournalStream(ROOT_PATH);
127130
const execution = yield* executeInstalled(
128131
{
129132
...retainedSource(ROOT_PATH, source),
130-
stream: new InMemoryStream(),
133+
stream,
131134
includes: [],
132135
},
133136
[installation(components)],
@@ -151,6 +154,7 @@ function* refusal(operation: Operation<unknown>): Operation<string> {
151154
}
152155

153156
describe("Tier WB — a bundled name resolves to its pinned source", () => {
157+
beforeEach(journalBeforeEach("packages/core/tests/workflow-component-bundle.test.ts"));
154158
it("WB1: a declared name resolves with no component search path", function* () {
155159
expect(yield* run("<Discovery />\n")).toContain("Discovery ran.");
156160
});
@@ -263,6 +267,7 @@ describe("Tier WB — a bundled name resolves to its pinned source", () => {
263267
});
264268

265269
describe("Tier WB — public import middleware cannot widen a bundle", () => {
270+
beforeEach(journalBeforeEach("packages/core/tests/workflow-component-bundle.test.ts"));
266271
/** A document that renders a marker after the invocation under test. */
267272
const AFTER = "<Discovery />\n\nafter\n";
268273

@@ -503,7 +508,7 @@ describe("Tier WB — public import middleware cannot widen a bundle", () => {
503508
return yield* collect(
504509
yield* execute({
505510
...retainedSource(ROOT_PATH, "<Anything />\n"),
506-
stream: new InMemoryStream(),
511+
stream: yield* useJournalStream(ROOT_PATH),
507512
includes: [],
508513
}),
509514
);

0 commit comments

Comments
 (0)