Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3ccb7bd
test: attribute failure journals to declaring cases
taras Nov 16, 2026
41946db
test: capture failure journals for Testing document cases
taras Nov 16, 2026
0a1f45e
test: capture failure journals for live WebForm cases
taras Nov 16, 2026
e9aef6f
test: capture failure journals for held Core hosts
taras Nov 16, 2026
72a360f
test: retain the ORC12 child journal for parent failures
taras Nov 16, 2026
d6398b9
test: attribute journals in ordinary Git execution cases
taras Nov 16, 2026
78360b8
test: attribute journals in direct Core document cases
taras Nov 16, 2026
2c56e87
test: attribute failure journals for live synthetic REPL entries
taras Nov 16, 2026
a633714
test: attribute guarded ACP and TestAgent execution journals
taras Nov 16, 2026
1be6fa0
test: attribute safe Agent and nested Testing execution journals
taras Nov 16, 2026
576f139
test: attribute fresh REPL observation entry journals
taras Nov 16, 2026
7de6ad0
test: capture additional direct Core execution journals
taras Nov 16, 2026
e9d5c7f
test: attribute fresh workflow observation journals
taras Nov 16, 2026
a12074a
test: attribute fresh CLI and Testing execution journals
taras Nov 16, 2026
5003c32
test: attribute fresh Git issue scenario journals
taras Nov 16, 2026
81ef099
test: retain separate CLI assembly journals for parent failures
taras Nov 16, 2026
88cc32c
test: attribute guarded CLI host and upgrade journals
taras Nov 16, 2026
3409f1d
test: attribute guarded Agent provider and usage journals
taras Nov 16, 2026
da0ecf3
test: attribute fresh Answers, Elicit and Fail fixture journals
taras Nov 16, 2026
468000c
test: attribute fresh TestAgent component and launch journals
taras Nov 16, 2026
adb9c60
test: capture fresh inline REPL selection journals
taras Nov 16, 2026
113b89c
test: capture guarded Glob fixture journals
taras Nov 16, 2026
3421bee
test: attribute guarded Agent function component journals
taras Nov 16, 2026
1143a70
test: retain separate journals for Testing session siblings
taras Nov 16, 2026
b310585
test: capture guarded Core prop evaluation journals
taras Nov 16, 2026
dbb0571
test: preserve independently bounded subprocess journals
taras Nov 16, 2026
b8aa8db
Expose the shared test journal resource
taras Nov 17, 2026
dd651ac
Adopt shared journals in Core evaluator tests
taras Nov 17, 2026
fa56f41
Adopt shared journal resource in Each tests
taras Nov 17, 2026
6d8c9a5
Use shared failure journal package in evaluator cases
taras Nov 17, 2026
6cf50a4
Migrate Core cases to shared journal resource
taras Nov 17, 2026
2261675
test: adopt shared journal resource in #1356 consumers
taras Nov 17, 2026
b32a928
Integrate #1356 shared journal consumers
taras Nov 17, 2026
103aee9
Use package journal entry in Core stream tests
taras Nov 17, 2026
40c725b
Complete shared journal imports in #1356
taras Nov 17, 2026
00e78f8
merge signed failure journal foundation into #1357
taras Nov 17, 2026
71a0581
migrate #1357 ordinary journal cases to shared fixtures
taras Nov 17, 2026
c076e76
merge complete #1356 candidate into #1357
taras Nov 17, 2026
2cb79b2
Format #1356 shared journal tests
taras Nov 17, 2026
3e7ae5a
Integrate Luna formatting correction for #1356
taras Nov 17, 2026
b782964
merge formatter-corrected #1356 parent into #1357
taras Nov 17, 2026
0fd285d
Restore direct it registration in Core held-host tests
Nov 17, 2026
53cb39c
Migrate assert throws journal ownership
taras Nov 17, 2026
c79ae82
Migrate testing boundary journal owner
taras Nov 17, 2026
c76ed7a
Restore direct test declarations in Agent, REPL and Web
taras Nov 17, 2026
2892509
Migrate testing boundary contract cases
taras Nov 17, 2026
a93742e
Migrate test component journal cases
taras Nov 17, 2026
49427d0
Migrate use testing journal cases
taras Nov 17, 2026
80c758d
Keep ordinary test declarations in two Testing suites
taras Nov 17, 2026
d33f642
Migrate workflow generated observation cases
taras Nov 17, 2026
27f6e4a
Remove unused journal case registrar
taras Nov 17, 2026
9a44b71
Integrate direct declarations in Testing and Workflow
taras Nov 17, 2026
4e12648
Remove unused testing case registrar
taras Nov 17, 2026
f7b8ea0
Restore direct it registration in Git tests
Nov 17, 2026
b9a7acf
Restore direct test declarations throughout the base journal PR
taras Nov 17, 2026
8dfb8a6
Restore direct Glob and TestAgent test declarations
taras Nov 17, 2026
6f2c313
Carry direct test declarations into the bounded journal PR
taras Nov 17, 2026
d3d0213
Expose the shared test journal resource
taras Nov 17, 2026
ee5eb2d
Adopt shared journals in Core evaluator tests
taras Nov 17, 2026
9f04b2c
Use shared failure journal package in evaluator cases
taras Nov 17, 2026
51102a8
Integrate #1356 shared journal consumers
taras Nov 17, 2026
3cf19ef
Complete shared journal imports in #1356
taras Nov 17, 2026
55c53bd
Integrate Luna formatting correction for #1356
taras Nov 17, 2026
848ccee
Restore direct test declarations in Agent, REPL and Web
taras Nov 17, 2026
f1ce214
Keep ordinary test declarations in two Testing suites
taras Nov 17, 2026
36597a8
Integrate direct declarations in Testing and Workflow
taras Nov 17, 2026
321e082
Remove unused testing case registrar
taras Nov 17, 2026
abacea6
Restore direct test declarations throughout the base journal PR
taras Nov 17, 2026
3029093
Preserve bounded subprocess scope after rebasing #1356
taras Nov 17, 2026
cfe06c4
Reconcile #1357 with squash-merged #1356
taras Nov 17, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 42 additions & 26 deletions packages/agent/tests/agent-function-components.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
* what a document gets.
*/

import { beforeAll, describe, it } from "@executablemd/test-support/bdd";
import { journalBeforeEach, useJournalStream } from "@executablemd/test-support/failure-journal";

import { beforeAll, beforeEach, describe, it } from "@executablemd/test-support/bdd";
import { expect } from "@executablemd/test-support/expect";
import { InMemoryStream, serializeDurableEvent } from "@executablemd/durable-streams";
import type { DurableEvent } from "@executablemd/durable-streams";
Expand Down Expand Up @@ -373,6 +375,7 @@ interface RunOptions {
function* runDoc(
doc: string,
options: RunOptions = {},
sharedJournal = false,
): Operation<{ output: string; result: Result<Json>; trace: Trace; events: DurableEvent[] }> {
const trace: Trace = options.trace ?? { prompts: [], agentLookups: [], timeouts: [] };
const dir = path.join(os.tmpdir(), `xmd-af-test-${randomUUID()}`);
Expand Down Expand Up @@ -427,7 +430,7 @@ function* runDoc(

// `<Session>` names durable work after its own invocation, so the host
// declares it to the execution rather than registering it.
const stream = new InMemoryStream();
const stream = sharedJournal ? yield* useJournalStream(docPath) : new InMemoryStream();
const execution = yield* executeInstalled(
{
path: docPath,
Expand All @@ -451,11 +454,18 @@ function* runDoc(
});
}

const OWNER = "packages/agent/tests/agent-function-components.test.ts";

function* run(doc: string, options?: RunOptions): ReturnType<typeof runDoc> {
return yield* runDoc(doc, options, true);
}

describe("Tier AF — the engine owns props", () => {
beforeEach(journalBeforeEach(OWNER));
beforeAll(() => useTempFileCompiler());

it("AF1: an expression prop resolves, where the claimed handler rejected it", function* () {
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
["```js eval", 'const who = "hello";', "```", "", "<Prompt text={who} />", ""].join("\n"),
);

Expand All @@ -464,7 +474,7 @@ describe("Tier AF — the engine owns props", () => {
});

it("AF2: a boolean expression prop resolves", function* () {
const { result } = yield* runDoc(
const { result } = yield* run(
[
"```js eval",
"const strict = false;",
Expand All @@ -480,7 +490,7 @@ describe("Tier AF — the engine owns props", () => {

it("AF3: an expression resolving to the wrong type is a schema printed error, and nothing runs", function* () {
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
const { result } = yield* runDoc(
const { result } = yield* run(
["```js eval", "const who = 42;", "```", "", "<Prompt text={who} />", ""].join("\n"),
{ trace },
);
Expand All @@ -496,7 +506,7 @@ describe("Tier AF — the engine owns props", () => {

it("AF4: an unknown prop is rejected before the component performs anything", function* () {
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
'<AgentProvider name="stub" nope="x">body</AgentProvider>\n',
{ trace },
);
Expand All @@ -511,6 +521,7 @@ describe("Tier AF — the engine owns props", () => {
});

describe("Tier AF — the engine owns `as`", () => {
beforeEach(journalBeforeEach(OWNER));
it("AF: live child input notices contribute neither Prompt capture nor durable Prompt fields", function* () {
let delivered = 0;
const notices: AgentPromptEvent[] = [
Expand Down Expand Up @@ -570,7 +581,7 @@ describe("Tier AF — the engine owns `as`", () => {
});

it("AF5: the returned string is captured once and not also emitted", function* () {
const { output, result } = yield* runDoc('<Prompt text="hi" as="answer" />\n\nGot: {answer}\n');
const { output, result } = yield* run('<Prompt text="hi" as="answer" />\n\nGot: {answer}\n');

expect(result.ok).toBe(true);
expect(output).toContain("Got: [hi]");
Expand All @@ -579,7 +590,7 @@ describe("Tier AF — the engine owns `as`", () => {

it("AF6: an invalid `as` prevents every component effect", function* () {
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
const { result } = yield* runDoc('<Prompt text="hi" as="not an identifier" />\n', { trace });
const { result } = yield* run('<Prompt text="hi" as="not an identifier" />\n', { trace });

expect(result.ok).toBe(false);
expect(result.ok ? "" : result.error.message).toContain('Prop "as" on <Prompt />');
Expand All @@ -589,9 +600,10 @@ describe("Tier AF — the engine owns `as`", () => {
});

describe("Tier AF — a prompt does nothing before its content renders", () => {
beforeEach(journalBeforeEach(OWNER));
it("AF7: a failing wrapper performs no lookup, no prompt and no journal entry", function* () {
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
const { result } = yield* runDoc("<Prompt>\n<Missing />\n</Prompt>\n", { trace });
const { result } = yield* run("<Prompt>\n<Missing />\n</Prompt>\n", { trace });

expect(result.ok).toBe(false);
expect(result.ok ? "" : result.error.message).toContain("Failed to import component Missing");
Expand All @@ -601,15 +613,16 @@ describe("Tier AF — a prompt does nothing before its content renders", () => {

it("AF8: an empty wrapper still overrides the text prop", function* () {
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
yield* runDoc('<Prompt text="fallback"></Prompt>\n', { trace });
yield* run('<Prompt text="fallback"></Prompt>\n', { trace });

expect(trace.prompts).toEqual([""]);
});
});

describe("Tier AF — failures that end the document", () => {
beforeEach(journalBeforeEach(OWNER));
it("AF9: an unavailable agent stops the document, nested in another wrapper", function* () {
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
[
"BEFORE",
"",
Expand All @@ -630,7 +643,7 @@ describe("Tier AF — failures that end the document", () => {
});

it("AF10: a throwOnError prompt inside <Agent> still ends the document", function* () {
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
[
"BEFORE",
"",
Expand All @@ -652,7 +665,7 @@ describe("Tier AF — failures that end the document", () => {
});

it("AF11: the same holds two wrappers deep", function* () {
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
[
"BEFORE",
"",
Expand All @@ -674,7 +687,7 @@ describe("Tier AF — failures that end the document", () => {
});

it("AF12: it survives a repository component projecting the prompt as content", function* () {
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
[
"BEFORE",
"",
Expand All @@ -698,6 +711,7 @@ describe("Tier AF — failures that end the document", () => {
});

describe("Tier AF — registered defaults a document can replace", () => {
beforeEach(journalBeforeEach(OWNER));
const names = ["AgentProvider", "Agent", "Prompt", "ApproveAll", "AskPermission"];

it("AF24: a Session hands the exact value it was issued to every nested Prompt", function* () {
Expand All @@ -706,7 +720,7 @@ describe("Tier AF — registered defaults a document can replace", () => {
// object — a provider decides whether a session may be acted on by
// identity, and a rebuilt look-alike was issued by nobody.
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
const { result } = yield* runDoc(
const { result } = yield* run(
[
'<Session name="review">',
' <Prompt text="first" />',
Expand All @@ -728,7 +742,7 @@ describe("Tier AF — registered defaults a document can replace", () => {

it("AF25: a self-closing Session resolves one and renders nothing", function* () {
const trace: Trace = { prompts: [], agentLookups: [], timeouts: [] };
const { output, result } = yield* runDoc(
const { output, result } = yield* run(
["BEFORE", "", '<Session name="review" />', "", "AFTER", ""].join("\n"),
{ trace },
);
Expand Down Expand Up @@ -786,16 +800,17 @@ describe("Tier AF — registered defaults a document can replace", () => {
});

describe("Tier AF — the scoped prompt-failure policy", () => {
beforeEach(journalBeforeEach(OWNER));
it("AF16: without a policy a failing prompt is collected, not fatal", function* () {
const { output, result } = yield* runDoc('<Prompt text="hi" />\n\nAFTER\n', { fail: true });
const { output, result } = yield* run('<Prompt text="hi" />\n\nAFTER\n', { fail: true });

expect(result.ok).toBe(false); // aggregated at completion, as always
expect(output).toContain("AFTER"); // but the document ran on
});

it("AF17: a policy that says yes ends the document at the prompt", function* () {
let asked = 0;
const { output } = yield* runDoc('<Prompt text="hi" />\n\nAFTER\n', {
const { output } = yield* run('<Prompt text="hi" />\n\nAFTER\n', {
fail: true,
// deno-lint-ignore require-yield
policy: function* () {
Expand All @@ -810,7 +825,7 @@ describe("Tier AF — the scoped prompt-failure policy", () => {

it("AF18: an explicit throwOnError wins without consulting the policy", function* () {
let asked = 0;
const { output } = yield* runDoc('<Prompt text="hi" throwOnError={true} />\n\nAFTER\n', {
const { output } = yield* run('<Prompt text="hi" throwOnError={true} />\n\nAFTER\n', {
fail: true,
// deno-lint-ignore require-yield
policy: function* () {
Expand All @@ -824,7 +839,7 @@ describe("Tier AF — the scoped prompt-failure policy", () => {
});

it("AF19: a policy that says no leaves the prompt collected", function* () {
const { output } = yield* runDoc('<Prompt text="hi" />\n\nAFTER\n', {
const { output } = yield* run('<Prompt text="hi" />\n\nAFTER\n', {
fail: true,
// deno-lint-ignore require-yield
policy: function* () {
Expand All @@ -837,7 +852,7 @@ describe("Tier AF — the scoped prompt-failure policy", () => {

it("AF20: a repository Prompt never consults the policy", function* () {
let asked = 0;
const { output } = yield* runDoc("<Prompt />\n\nAFTER\n", {
const { output } = yield* run("<Prompt />\n\nAFTER\n", {
fail: true,
files: { "Prompt.md": "LOCAL\n" },
// deno-lint-ignore require-yield
Expand All @@ -854,30 +869,31 @@ describe("Tier AF — the scoped prompt-failure policy", () => {
});

describe("Tier AF — prompt timeouts", () => {
beforeEach(journalBeforeEach(OWNER));
it("AF21: a prompt nobody bounded carries no timeout", function* () {
const { trace } = yield* runDoc('<Prompt text="one" />\n');
const { trace } = yield* run('<Prompt text="one" />\n');
expect(trace.timeouts).toEqual([undefined]);
});

it("AF22a: a prompt inherits the subtree default an <AgentProvider timeout> installs", function* () {
const { trace } = yield* runDoc('<Prompt text="one" />\n', { promptTimeout: 500 });
const { trace } = yield* run('<Prompt text="one" />\n', { promptTimeout: 500 });
expect(trace.timeouts).toEqual([500]);
});

it("AF22b: a prompt's own timeout outranks the inherited one", function* () {
const { trace } = yield* runDoc('<Prompt text="one" timeout="250ms" />\n', {
const { trace } = yield* run('<Prompt text="one" timeout="250ms" />\n', {
promptTimeout: 500,
});
expect(trace.timeouts).toEqual([250]);
});

it("AF22: a prompt's own timeout is the duration it declares", function* () {
const { trace } = yield* runDoc('<Prompt text="one" timeout="250ms" />\n');
const { trace } = yield* run('<Prompt text="one" timeout="250ms" />\n');
expect(trace.timeouts).toEqual([250]);
});

it("AF23: a malformed prompt timeout refuses instead of prompting", function* () {
const { result, trace } = yield* runDoc('<Prompt text="one" timeout="soon" />\n');
const { result, trace } = yield* run('<Prompt text="one" timeout="soon" />\n');
expect(result.ok).toBe(false);
expect(result.ok === false && result.error.message).toContain("must be a duration");
expect(trace.timeouts).toEqual([]);
Expand Down
Loading
Loading