refactor(mcp): make analysis states unrepresentable (#468)
* refactor(config): parse capability settings into exact states * refactor(runtime): encode replay and process outcomes exactly * refactor: make analysis states unrepresentable * refactor(mcp): register canonical schemas with SDK * fix: preserve capability and catalog invariants * fix(build): remove stale compiled modules * fix(replay): update real verifier policy dependency * fix(package): verify the complete MCP catalog * fix(test): supply complete replay reload policy * refactor(contracts): centralize output schema lookup * refactor(mcp): delegate protocol boundaries to SDK * fix(browser): approve real source capture * fix(mcp): preserve catalog guidance
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { traceJavaScriptSemanticsRequestSchema } from "../../../src/contracts/applicationWorkflowInputContracts.js";
|
||||
import { buildCapabilityInventory } from "../../../src/application/CapabilityInventory.js";
|
||||
import {
|
||||
artifactInspectionInputSchema,
|
||||
artifactInventoryInputSchema,
|
||||
@@ -19,7 +20,10 @@ import {
|
||||
annotationsFromEffects,
|
||||
toolContractMetadata,
|
||||
} from "../../../src/contracts/toolEffects.js";
|
||||
import { requireOutputSchema } from "../../../src/contracts/toolOutputSchemaPrimitives.js";
|
||||
import {
|
||||
requireOutputSchema,
|
||||
toolAvailability,
|
||||
} from "../../../src/contracts/toolOutputSchemaPrimitives.js";
|
||||
import { JAVASCRIPT_FEATURE_TRACE_FULL_EVIDENCE_EXAMPLE } from "../../../src/contracts/javascriptApplicationWorkflowExamples.js";
|
||||
|
||||
const EVIDENCE_ID = `ev_${"a".repeat(64)}`;
|
||||
@@ -80,6 +84,17 @@ describe("contract validation boundaries", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts each complete managed application Evidence source", () => {
|
||||
for (const input of [
|
||||
{ managed_artifact_evidence_id: EVIDENCE_ID },
|
||||
{ managed_members_evidence_id: EVIDENCE_ID },
|
||||
{ managed_native_boundaries_evidence_id: EVIDENCE_ID },
|
||||
])
|
||||
expect(
|
||||
managedApplicationGraphReferenceInputSchema.safeParse(input).success,
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it("requires explicit approval for record-and-continue artifact inspection", () => {
|
||||
const input = {
|
||||
integrity_policy: "record-and-continue" as const,
|
||||
@@ -89,6 +104,30 @@ describe("contract validation boundaries", () => {
|
||||
expect(artifactInspectionInputSchema.safeParse(input).success).toBe(false);
|
||||
});
|
||||
|
||||
it("rejects contradictory tool availability states", () => {
|
||||
const inventory = buildCapabilityInventory(
|
||||
{ open: false, capabilities: [] },
|
||||
{
|
||||
processCaptureEnabled: false,
|
||||
evidenceFileRoots: 0,
|
||||
investigationInputRoots: 0,
|
||||
},
|
||||
);
|
||||
const unavailable = inventory.find(({ available }) => !available);
|
||||
expect(unavailable).toBeDefined();
|
||||
expect(toolAvailability.safeParse(unavailable).success).toBe(true);
|
||||
expect(
|
||||
toolAvailability.safeParse({ ...unavailable, available: true }).success,
|
||||
).toBe(false);
|
||||
expect(
|
||||
toolAvailability.safeParse({
|
||||
...unavailable,
|
||||
available: false,
|
||||
reason: "available",
|
||||
}).success,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it("covers deterministic contract rendering and defensive helper errors", () => {
|
||||
const rendered = renderGuidedPrompt(PROMPT_CONTRACTS[0], {
|
||||
zulu: "last",
|
||||
|
||||
Reference in New Issue
Block a user