feat: capture reviewed authoring evidence

This commit is contained in:
lda
2026-07-13 21:38:21 +07:00 Verified
parent 7966c54b63
commit 47161eade7
2 changed files with 200 additions and 0 deletions
@@ -0,0 +1,60 @@
import { describe, expect, it } from "vitest";
import { reviewedAuthoringEvidenceFor } from "./reviewed-authoring-evidence.js";
import type { PreparedLifecycleStepId } from "./authoring-projection.js";
describe("reviewed authoring evidence", () => {
it("projects the six prepared lifecycle steps into reviewed evidence kinds", () => {
const steps: readonly PreparedLifecycleStepId[] = [
"discover",
"draft",
"diagnose",
"repair",
"artifact",
"deployment",
];
expect(steps.map((step) => reviewedAuthoringEvidenceFor(step).kind)).toEqual([
"inventory",
"draft",
"diagnostic",
"repair",
"artifact",
"deployment",
]);
});
it("pins the reviewed diagnostic and repair facts", () => {
expect(reviewedAuthoringEvidenceFor("diagnose")).toMatchObject({
kind: "diagnostic",
workspaceId: "lda_report_workflow",
revision: 3,
status: "invalid",
diagnostic: {
code: "missing_outcome_edge",
path: "nodes[analyze]",
message: "reachable node is missing edges for outcomes ['ok']",
},
});
expect(reviewedAuthoringEvidenceFor("repair")).toMatchObject({
kind: "repair",
fromRevision: 3,
toRevision: 4,
command: "wf draft set-route lda_report_workflow --revision 3 --step analyze --outcome ok --to __end__",
status: "valid",
diagnosticCount: 0,
});
});
it("does not serialize disposable or obsolete evidence language", () => {
const serialized = JSON.stringify(
["discover", "draft", "diagnose", "repair", "artifact", "deployment"].map(
(step) => reviewedAuthoringEvidenceFor(step as PreparedLifecycleStepId),
),
);
expect(serialized).not.toContain("presentation_diag_probe");
expect(serialized).not.toContain("missing output projection");
expect(serialized).not.toContain("no state projection");
});
});
@@ -0,0 +1,140 @@
import type { PreparedLifecycleStepId } from "./authoring-projection.js";
export type ReviewedAuthoringEvidence =
| {
readonly kind: "inventory";
readonly sourceCount: 6;
readonly sources: readonly string[];
readonly capability: {
readonly name: string;
readonly inputs: readonly string[];
readonly outputs: readonly string[];
readonly outcomes: readonly string[];
};
}
| {
readonly kind: "draft";
readonly workspaceId: "lda_report_workflow";
readonly revision: 2;
readonly status: "valid";
readonly stepCount: 2;
readonly routeCount: 2;
readonly steps: readonly string[];
readonly routes: readonly string[];
}
| {
readonly kind: "diagnostic";
readonly workspaceId: "lda_report_workflow";
readonly revision: 3;
readonly status: "invalid";
readonly diagnostic: {
readonly code: "missing_outcome_edge";
readonly path: "nodes[analyze]";
readonly message: string;
readonly explanation: string;
};
}
| {
readonly kind: "repair";
readonly fromRevision: 3;
readonly toRevision: 4;
readonly command: string;
readonly status: "valid";
readonly diagnosticCount: 0;
}
| {
readonly kind: "artifact";
readonly artifactId: "lda_report_case_study";
readonly version: 1;
readonly immutable: true;
readonly requiredSources: readonly string[];
}
| {
readonly kind: "deployment";
readonly deploymentId: "lda_report_case_study.default";
readonly status: "runnable";
readonly bindings: readonly {
readonly requirement: string;
readonly source: string;
}[];
};
export type ReviewedAuthoringStep = {
readonly step: PreparedLifecycleStepId;
readonly evidence: ReviewedAuthoringEvidence;
};
const localSourceIds = [
"local.lda_docs",
"local.lda_report",
"local.issue_board",
] as const;
// This catalog is static by design: presentation playback uses reviewed CLI facts,
// rather than invoking authoring or exposing disposable probe workspace IDs.
const reviewedAuthoringEvidence: Readonly<
Record<PreparedLifecycleStepId, ReviewedAuthoringEvidence>
> = {
discover: {
kind: "inventory",
sourceCount: 6,
sources: localSourceIds,
capability: {
name: "local.lda_report.analyze_documents",
inputs: ["documents"],
outputs: ["analysis"],
outcomes: ["ok"],
},
},
draft: {
kind: "draft",
workspaceId: "lda_report_workflow",
revision: 2,
status: "valid",
stepCount: 2,
routeCount: 2,
steps: ["read_documents", "analyze"],
routes: ["read_documents.ok -> analyze", "analyze.ok -> __end__"],
},
diagnose: {
kind: "diagnostic",
workspaceId: "lda_report_workflow",
revision: 3,
status: "invalid",
diagnostic: {
code: "missing_outcome_edge",
path: "nodes[analyze]",
message: "reachable node is missing edges for outcomes ['ok']",
explanation: "The workflow cannot prove where execution goes next.",
},
},
repair: {
kind: "repair",
fromRevision: 3,
toRevision: 4,
command:
"wf draft set-route lda_report_workflow --revision 3 --step analyze --outcome ok --to __end__",
status: "valid",
diagnosticCount: 0,
},
artifact: {
kind: "artifact",
artifactId: "lda_report_case_study",
version: 1,
immutable: true,
requiredSources: localSourceIds,
},
deployment: {
kind: "deployment",
deploymentId: "lda_report_case_study.default",
status: "runnable",
bindings: localSourceIds.map((source) => ({
requirement: source,
source,
})),
},
};
export const reviewedAuthoringEvidenceFor = (
step: PreparedLifecycleStepId,
): ReviewedAuthoringEvidence => reviewedAuthoringEvidence[step];