Something went wrong. Try again.
An agent harness for spec-driven development.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111import { describe, expect, test } from "vitest";import { buildProjectStatus, formatProjectStatus } from "../src/status.js";import type { CharterDatabaseSnapshot, SpecChange } from "../src/types.js";
function snapshot(): CharterDatabaseSnapshot { return { projectId: "misaligned", updatedAt: "2026-07-12T00:00:00.000Z", documents: {}, pathIndex: {}, events: [ { id: "event-1", type: "spec.document.upserted", documentId: "operations", path: "operations.md", occurredAt: "2026-07-12T00:00:01.000Z", authority: "human.file", }, ], workItems: { work1: { id: "work1", kind: "spec-change", status: "running", eventId: "event-1", documentId: "operations", path: "operations.md", title: "Operations", createdAt: "2026-07-12T00:00:01.000Z", updatedAt: "2026-07-12T00:00:02.000Z", authority: "human.file", attachedDocumentIds: ["operations"], matchedConsumerIds: ["implementer"], }, }, consumers: { implementer: { id: "implementer", name: "Implementer", status: "active", runnerKind: "codex", runnerConfigJson: "{}", eventTypes: ["spec.document.upserted"], documentSelectors: ["operations"], promptDocumentIds: [], defaultContextDocumentIds: ["operations"], cursorJson: "{}", createdAt: "2026-07-12T00:00:00.000Z", updatedAt: "2026-07-12T00:00:00.000Z", }, }, packets: {}, requests: {}, };}
describe("project status", () => { test("reports native local Jazz durability without pretending distributed sync is configured", () => { const changes: SpecChange[] = [ { type: "added", documentId: "operations", path: "operations.md", title: "Operations", currentSha256: "abc123", }, ]; const status = buildProjectStatus({ projectRoot: "/tmp/misaligned", specRoot: "/tmp/misaligned/spec", filesystemDocumentCount: 1, adapter: "jazz", snapshot: snapshot(), changes, generatedAt: "2026-07-12T00:00:03.000Z", });
expect(status.database).toMatchObject({ adapter: "jazz", persistentAcrossProcesses: true, distributedSyncConfigured: false, state: "native-jazz-local", }); expect(status.documents).toMatchObject({ filesystem: 1, materialized: 0, drift: { added: 1, modified: 0, deleted: 0, unchanged: 0 } }); expect(status.workItems.byStatus.running).toBe(1); expect(status.consumers.registered[0]).toMatchObject({ id: "implementer", runnerKind: "codex" }); expect(status.warnings).toContain("At least one work item is running without an executing request in the current snapshot.");
const output = formatProjectStatus(status); expect(output).toContain("Charter status"); expect(output).toContain("persistentAcrossProcesses=true"); expect(output).toContain("Registered consumers:"); expect(output).toContain("1 filesystem spec change is not materialized"); });
test("reports the JSON adapter as a local fallback", () => { const status = buildProjectStatus({ projectRoot: "/tmp/misaligned", specRoot: "/tmp/misaligned/spec", filesystemDocumentCount: 0, adapter: "json", snapshot: snapshot(), changes: [], });
expect(status.database.state).toBe("local-json-file"); expect(status.warnings[0]).toContain("local fallback/test surface"); });});