426e9eeabd
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
Chat shell gestures / Chat shell gesture + parity e2e (push) Has been cancelled
Cloud Gateway Discord / Test (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Has been cancelled
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Has been cancelled
Build Agent Image / build-and-push (push) Has been cancelled
Dev Smoke / bun run dev onboarding chat (push) Has been cancelled
Dev Smoke / Vite HMR dependency-level smoke (push) Has been cancelled
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Has been cancelled
Publish @elizaos/example-code / check_npm (push) Has been cancelled
Publish @elizaos/example-code / publish_npm (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / verify_version (push) Has been cancelled
Publish @elizaos/plugin-elizacloud / publish_npm (push) Has been cancelled
Sandbox Live Smoke / Sandbox live smoke (push) Has been cancelled
Snap Build & Test / Build Snap (amd64) (push) Has been cancelled
Snap Build & Test / Build Snap (arm64) (push) Has been cancelled
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Has been cancelled
Cloud Gateway Webhook / Test (push) Has been cancelled
Cloud Tests / lint-and-types (push) Has been cancelled
Cloud Tests / unit-tests (push) Has been cancelled
Cloud Tests / integration-tests (push) Has been cancelled
Cloud Tests / e2e-tests (push) Has been cancelled
CodeQL Advanced / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Apps Worker (Product 2) / Determine environment (push) Has been cancelled
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Has been cancelled
Deploy Eliza Provisioning Worker / Determine environment (push) Has been cancelled
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Has been cancelled
Dev Smoke / Classify changed paths (push) Has been cancelled
supply-chain / sbom (push) Has been cancelled
supply-chain / vulnerability-scan (push) Has been cancelled
Build, Push & Deploy to Phala Cloud / build-and-push (push) Has been cancelled
Test Packaging / Validate Packaging Configs (push) Has been cancelled
Test Packaging / Build & Test PyPI Package (push) Has been cancelled
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Has been cancelled
Test Packaging / Pack & Test JS Tarballs (push) Has been cancelled
UI Fixture E2E / ui-fixture-e2e (push) Has been cancelled
UI Fixture E2E / fixture-e2e (push) Has been cancelled
UI Story Gate / story-gate (push) Has been cancelled
vault-ci / test (macos-latest) (push) Has been cancelled
vault-ci / test (ubuntu-latest) (push) Has been cancelled
vault-ci / test (windows-latest) (push) Has been cancelled
vault-ci / app-core wiring tests (push) Has been cancelled
verify-patches / verify patches/CHECKSUMS.sha256 (push) Has been cancelled
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Has been cancelled
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Has been cancelled
Voice Benchmark Smoke / voice bench smoke summary (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Has been cancelled
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Has been cancelled
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Has been cancelled
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Has been cancelled
173 lines
5.6 KiB
TypeScript
173 lines
5.6 KiB
TypeScript
/**
|
|
* Verifies parseCompletionEnvelope (#8895).
|
|
* Deterministic unit test of pure helpers; no runtime, no live model.
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
import {
|
|
COMPLETION_ENVELOPE_INSTRUCTION,
|
|
type CompletionEnvelope,
|
|
envelopeCorrection,
|
|
parseCompletionEnvelope,
|
|
summarizeEnvelope,
|
|
} from "../../src/services/completion-envelope.js";
|
|
|
|
function validEnvelope(): CompletionEnvelope {
|
|
return {
|
|
diffSummary: "added the thing",
|
|
filesChanged: ["src/a.ts"],
|
|
testResults: [{ command: "bun test", exitCode: 0, summary: "12 passed" }],
|
|
screenshotPaths: [],
|
|
acceptanceCriteriaStatus: [
|
|
{ criterion: "tests pass", met: true, evidence: "bun test exit 0" },
|
|
],
|
|
residualRisks: [],
|
|
};
|
|
}
|
|
|
|
function fenced(obj: unknown): string {
|
|
return `Done!\n\n\`\`\`json\n${JSON.stringify(obj, null, 2)}\n\`\`\``;
|
|
}
|
|
|
|
describe("parseCompletionEnvelope (#8895)", () => {
|
|
it("returns present:false when there is no envelope (heuristic fallback)", () => {
|
|
expect(parseCompletionEnvelope("I finished the task.")).toEqual({
|
|
present: false,
|
|
});
|
|
});
|
|
|
|
it("parses a valid fenced envelope", () => {
|
|
const res = parseCompletionEnvelope(fenced(validEnvelope()));
|
|
expect(res.present).toBe(true);
|
|
expect(res.ok).toBe(true);
|
|
if (res.present && res.ok) {
|
|
expect(res.envelope.diffSummary).toBe("added the thing");
|
|
expect(res.envelope.testResults[0].exitCode).toBe(0);
|
|
expect(res.envelope.acceptanceCriteriaStatus[0].met).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("carries the real workdir and disk-verified changed files", () => {
|
|
const res = parseCompletionEnvelope(
|
|
fenced({
|
|
...validEnvelope(),
|
|
realWorkdir: "/workspace/task-real",
|
|
verifiedChangedFiles: [
|
|
{
|
|
path: "src/a.ts",
|
|
exists: true,
|
|
absolutePath: "/workspace/task-real/src/a.ts",
|
|
sizeBytes: 12,
|
|
},
|
|
],
|
|
artifactsVerified: true,
|
|
missingArtifacts: [],
|
|
}),
|
|
);
|
|
expect(res.present).toBe(true);
|
|
expect(res.ok).toBe(true);
|
|
if (res.present && res.ok) {
|
|
expect(res.envelope.realWorkdir).toBe("/workspace/task-real");
|
|
expect(res.envelope.verifiedChangedFiles?.[0]).toMatchObject({
|
|
path: "src/a.ts",
|
|
exists: true,
|
|
});
|
|
expect(res.envelope.artifactsVerified).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("marks missing artifacts as unverified", () => {
|
|
const res = parseCompletionEnvelope(
|
|
fenced({
|
|
...validEnvelope(),
|
|
realWorkdir: "/workspace/task-real",
|
|
verifiedChangedFiles: [{ path: "index.html", exists: false }],
|
|
artifactsVerified: false,
|
|
missingArtifacts: ["index.html"],
|
|
}),
|
|
);
|
|
expect(res.present).toBe(true);
|
|
expect(res.ok).toBe(true);
|
|
if (res.present && res.ok) {
|
|
expect(res.envelope.artifactsVerified).toBe(false);
|
|
expect(res.envelope.missingArtifacts).toEqual(["index.html"]);
|
|
expect(summarizeEnvelope(res.envelope)).toContain("UNVERIFIED missing");
|
|
}
|
|
});
|
|
|
|
it("flags a present-but-incomplete envelope (missing testResults)", () => {
|
|
const { testResults, ...partial } = validEnvelope();
|
|
void testResults;
|
|
const res = parseCompletionEnvelope(fenced(partial));
|
|
expect(res).toMatchObject({ present: true, ok: false });
|
|
if (res.present && !res.ok) {
|
|
expect(res.errors.join(" ")).toContain("testResults");
|
|
}
|
|
});
|
|
|
|
it("flags malformed test rows + bad criteria shapes", () => {
|
|
const bad = {
|
|
...validEnvelope(),
|
|
testResults: [{ command: "x" }],
|
|
acceptanceCriteriaStatus: [{ criterion: "c" }],
|
|
};
|
|
const res = parseCompletionEnvelope(fenced(bad));
|
|
expect(res).toMatchObject({ present: true, ok: false });
|
|
if (res.present && !res.ok) {
|
|
expect(res.errors.some((e) => e.includes("testResults[0]"))).toBe(true);
|
|
expect(
|
|
res.errors.some((e) => e.includes("acceptanceCriteriaStatus[0]")),
|
|
).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("treats a fenced-but-unparseable block as a broken attempt (not absent)", () => {
|
|
const res = parseCompletionEnvelope("```json\n{not json}\n```");
|
|
expect(res).toMatchObject({ present: true, ok: false });
|
|
});
|
|
|
|
it("reads the LAST fenced block when several are present", () => {
|
|
const earlier = fenced({ diffSummary: "draft" });
|
|
const final = fenced(validEnvelope());
|
|
const res = parseCompletionEnvelope(`${earlier}\n\nthen\n\n${final}`);
|
|
expect(res.ok).toBe(true);
|
|
});
|
|
|
|
it("accepts a bare JSON object with no fence", () => {
|
|
const res = parseCompletionEnvelope(JSON.stringify(validEnvelope()));
|
|
expect(res.ok).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe("summarizeEnvelope + envelopeCorrection (#8895)", () => {
|
|
it("summarizes met/unmet criteria + test results", () => {
|
|
const env = validEnvelope();
|
|
env.acceptanceCriteriaStatus.push({
|
|
criterion: "lint clean",
|
|
met: false,
|
|
evidence: "biome found 2 issues",
|
|
});
|
|
const s = summarizeEnvelope(env);
|
|
expect(s).toContain("bun test → exit 0");
|
|
expect(s).toContain("1/2 met");
|
|
expect(s).toContain("unmet: lint clean");
|
|
});
|
|
|
|
it("builds a correction listing the parse errors", () => {
|
|
const c = envelopeCorrection(["testResults must be an array"]);
|
|
expect(c).toContain("did not include a valid CompletionEnvelope");
|
|
expect(c).toContain("testResults must be an array");
|
|
});
|
|
|
|
it("the spawn instruction names every required key", () => {
|
|
for (const key of [
|
|
"diffSummary",
|
|
"filesChanged",
|
|
"testResults",
|
|
"acceptanceCriteriaStatus",
|
|
"residualRisks",
|
|
]) {
|
|
expect(COMPLETION_ENVELOPE_INSTRUCTION).toContain(key);
|
|
}
|
|
});
|
|
});
|