Files
wehub-resource-sync 426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
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) Waiting to run
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) Waiting to run
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) Waiting to run
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) Waiting to run
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) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
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
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00

288 lines
8.9 KiB
TypeScript

/**
* Regression coverage for the durable commitments/obligations ledger. The
* extractor is deliberately conservative and deterministic here; live model
* extraction trajectories belong to the scenario lane once credentials are
* available.
*/
import { afterEach, describe, expect, it } from "vitest";
import {
buildCommitmentRegretAudit,
createDocumentObligationLedgerRecord,
createLifeOpsCommitmentLedgerRecord,
extractCommitmentLedgerRecords,
LifeOpsRepository,
trackDocumentObligationArtifact,
} from "../src/lifeops/index.js";
import {
createLifeOpsTestRuntime,
type RealTestRuntimeResult,
} from "./helpers/runtime.ts";
const AGENT_ID = "00000000-0000-0000-0000-000000001864";
const OBSERVED_AT = "2026-07-06T15:00:00.000Z";
describe("commitment ledger extraction and audit", () => {
it("extracts a concrete sent-mail promise with a due date", () => {
const rows = extractCommitmentLedgerRecords({
agentId: AGENT_ID,
source: "sent_mail",
sourceKey: "gmail:msg-1",
observedAt: OBSERVED_AT,
counterparty: "Mira",
text: "I'll send the deck Friday and include the pricing appendix.",
});
expect(rows).toHaveLength(1);
expect(rows[0]).toMatchObject({
source: "sent_mail",
sourceKey: "gmail:msg-1",
kind: "commitment",
counterparty: "Mira",
dueAt: "2026-07-10T17:00:00.000Z",
status: "open",
scheduledTaskId: null,
});
expect(rows[0]?.summary).toContain("send the deck Friday");
});
it("does not create rows for speculative chit-chat", () => {
const rows = extractCommitmentLedgerRecords({
agentId: AGENT_ID,
source: "chat",
sourceKey: "thread:loose",
observedAt: OBSERVED_AT,
text: "Yeah maybe sometime we could send something over.",
});
expect(rows).toHaveLength(0);
});
it("ranks orphaned near-term obligations ahead of tracked or completed rows", () => {
const orphan = createLifeOpsCommitmentLedgerRecord({
agentId: AGENT_ID,
source: "sent_mail",
sourceKey: "gmail:deck",
kind: "commitment",
summary: "I'll send the deck Friday",
counterparty: "Mira",
dueAt: "2026-07-10T17:00:00.000Z",
confidence: 0.74,
metadata: {},
createdAt: "2026-07-06T15:00:00.000Z",
});
const tracked = createLifeOpsCommitmentLedgerRecord({
agentId: AGENT_ID,
source: "document",
sourceKey: "contract:acme",
kind: "renewal",
summary: "Renewal notice for Acme contract",
counterparty: "Acme",
dueAt: "2026-07-12T17:00:00.000Z",
confidence: 0.9,
status: "tracked",
scheduledTaskId: "st_acme_renewal",
metadata: {},
createdAt: "2026-07-06T16:00:00.000Z",
});
const completed = createLifeOpsCommitmentLedgerRecord({
agentId: AGENT_ID,
source: "chat",
sourceKey: "thread:done",
kind: "commitment",
summary: "I will send the notes",
counterparty: null,
dueAt: "2026-07-07T17:00:00.000Z",
confidence: 0.8,
status: "completed",
metadata: {},
createdAt: "2026-07-06T17:00:00.000Z",
});
const audit = buildCommitmentRegretAudit([tracked, completed, orphan], {
nowIso: "2026-07-09T12:00:00.000Z",
horizonDays: 7,
});
expect(audit.items.map((item) => item.record.id)).toEqual([
orphan.id,
tracked.id,
]);
expect(audit.items[0]?.reasons).toContain("no scheduled tracker");
expect(audit.items[0]?.reasons).toContain("due inside audit horizon");
});
it("normalizes document contract deadlines as tracked renewal obligations", () => {
const record = createDocumentObligationLedgerRecord({
agentId: AGENT_ID,
documentId: "doc-acme-sow",
title: "Acme vendor SOW contract renewal",
deadline: "2026-09-01T17:00:00.000Z",
observedAt: OBSERVED_AT,
counterparty: "Acme",
scheduledTaskId: "task-renewal-60d",
metadata: { documentKind: "approval" },
});
expect(record).toMatchObject({
source: "document",
sourceKey: "doc-acme-sow",
kind: "renewal",
summary: "Acme vendor SOW contract renewal deadline",
counterparty: "Acme",
dueAt: "2026-09-01T17:00:00.000Z",
confidence: 0.9,
status: "tracked",
scheduledTaskId: "task-renewal-60d",
});
});
it("normalizes warranty documents without inventing a tracker", () => {
const record = createDocumentObligationLedgerRecord({
agentId: AGENT_ID,
documentId: "doc-laptop-warranty",
title: "Laptop warranty return window",
deadline: "2026-07-31T17:00:00.000Z",
observedAt: OBSERVED_AT,
});
expect(record).toMatchObject({
kind: "warranty",
status: "open",
scheduledTaskId: null,
});
});
});
describe("commitment ledger repository", () => {
let runtimeResult: RealTestRuntimeResult | null = null;
afterEach(async () => {
await runtimeResult?.cleanup();
runtimeResult = null;
});
it("persists extracted obligations through the LifeOps schema", async () => {
runtimeResult = await createLifeOpsTestRuntime();
const { runtime } = runtimeResult;
await LifeOpsRepository.bootstrapSchema(runtime);
const repo = new LifeOpsRepository(runtime);
const record = extractCommitmentLedgerRecords({
agentId: runtime.agentId,
source: "sent_mail",
sourceKey: "gmail:msg-commitment",
observedAt: OBSERVED_AT,
counterparty: "Mira",
text: "I'll send the deck Friday and include the pricing appendix.",
})[0];
if (!record) {
throw new Error("Expected commitment extraction to produce one record.");
}
await repo.upsertCommitmentLedgerRecord(record);
const reloaded = new LifeOpsRepository(runtime);
const rows = await reloaded.listCommitmentLedgerRecords(runtime.agentId, {
statuses: ["open"],
dueBeforeIso: "2026-07-11T00:00:00.000Z",
});
expect(rows).toHaveLength(1);
expect(rows[0]).toMatchObject({
id: record.id,
source: "sent_mail",
sourceKey: "gmail:msg-commitment",
counterparty: "Mira",
dueAt: "2026-07-10T17:00:00.000Z",
scheduledTaskId: null,
});
await reloaded.upsertCommitmentLedgerRecord({
...record,
status: "tracked",
scheduledTaskId: "st_deck_followup",
updatedAt: "2026-07-06T18:00:00.000Z",
});
const tracked = await reloaded.getCommitmentLedgerRecord(
runtime.agentId,
record.id,
);
expect(tracked).toMatchObject({
status: "tracked",
scheduledTaskId: "st_deck_followup",
});
});
it("tracks a standing document guarantee with one ledger row and one watcher", async () => {
runtimeResult = await createLifeOpsTestRuntime();
const { runtime } = runtimeResult;
await LifeOpsRepository.bootstrapSchema(runtime);
const repo = new LifeOpsRepository(runtime);
const first = await trackDocumentObligationArtifact(runtime, {
agentId: runtime.agentId,
documentId: "doc-acme-msa",
title: "Acme MSA contract renewal",
deadline: "2026-09-01T17:00:00.000Z",
observedAt: OBSERVED_AT,
counterparty: "Acme",
note: "Renewal notice must go out 60 days before term end.",
metadata: { standingGuaranteeId: "guarantee-renewals" },
});
expect(first.record).toMatchObject({
source: "document",
sourceKey: "doc-acme-msa",
kind: "renewal",
status: "tracked",
scheduledTaskId: first.task.taskId,
});
expect(first.task).toMatchObject({
kind: "watcher",
trigger: { kind: "once", atIso: "2026-09-01T17:00:00.000Z" },
subject: { kind: "document", id: "doc-acme-msa" },
idempotencyKey:
"commitment-ledger:document:doc-acme-msa:deadline:2026-09-01T17:00:00.000Z",
});
const replay = await trackDocumentObligationArtifact(runtime, {
agentId: runtime.agentId,
documentId: "doc-acme-msa",
title: "Acme MSA contract renewal",
deadline: "2026-09-01T17:00:00.000Z",
observedAt: OBSERVED_AT,
counterparty: "Acme",
note: "Renewal notice must go out 60 days before term end.",
metadata: { standingGuaranteeId: "guarantee-renewals" },
});
expect(replay.task.taskId).toBe(first.task.taskId);
expect(replay.record.id).toBe(first.record.id);
const rows = await repo.listCommitmentLedgerRecords(runtime.agentId, {
source: "document",
statuses: ["tracked"],
});
expect(rows).toHaveLength(1);
expect(rows[0]).toMatchObject({
id: first.record.id,
scheduledTaskId: first.task.taskId,
metadata: {
standingGuaranteeId: "guarantee-renewals",
},
});
const persistedTask = await repo.getScheduledTask(
runtime.agentId,
first.task.taskId,
);
expect(persistedTask).toMatchObject({
idempotencyKey:
"commitment-ledger:document:doc-acme-msa:deadline:2026-09-01T17:00:00.000Z",
metadata: {
commitmentLedgerId: first.record.id,
standingGuarantee: true,
},
});
});
});