// SPDX-License-Identifier: Apache-2.0 // SPDX-FileCopyrightText: 2026 SubLang International // Generated by slc (DR-009): prompt contract. // The pinned rows were derived from the artifacts at build time; wiring, // placeholder, or composition drift fails this test. import { describe, expect, it } from 'vitest'; import { capturePromptContract, checkPromptComposition, deriveSubstitutions, findMachineConfig, } from "./.slc-verify/verify.js"; import * as fsm from "./verify.fsm.js"; import * as playbook from "./verify.playbook.js"; const CONTRACT = [ { "state": "initialVerification", "sourceItem": "VERIFY-1", "player": "", "role": "tester", "reads": [ "callerInput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ] }, "placeholders": [ "" ] }, { "state": "firstAudit", "sourceItem": "VERIFY-2", "player": "", "role": "auditor", "reads": [ "callerInput", "latestCommit", "pendingBossQuestion", "testerOutput" ], "wires": { "callerInput": [ "callerInput" ], "latestCommit": [ "latestCommit" ], "testerOutput": [ "testerOutput" ] }, "placeholders": [ "", "", "" ] }, { "state": "firstRoundFix", "sourceItem": "VERIFY-5", "player": "", "role": "tester", "reads": [ "auditorOutput", "callerInput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "auditorOutput": [ "auditorOutput" ] }, "placeholders": [ "", "" ] }, { "state": "secondAuditAfterFix", "sourceItem": "VERIFY-3", "player": "", "role": "auditor", "reads": [ "callerInput", "latestCommit", "pendingBossQuestion", "testerOutput" ], "wires": { "callerInput": [ "callerInput" ], "latestCommit": [ "latestCommit" ], "testerOutput": [ "testerOutput" ] }, "placeholders": [ "", "", "" ] }, { "state": "secondAuditAfterRebuttal", "sourceItem": "VERIFY-4", "player": "", "role": "auditor", "reads": [ "callerInput", "pendingBossQuestion", "testerOutput" ], "wires": { "callerInput": [ "callerInput" ], "testerOutput": [ "testerOutput" ] }, "placeholders": [ "", "" ] }, { "state": "secondRoundFix", "sourceItem": "VERIFY-6", "player": "", "role": "tester", "reads": [ "auditorOutput", "callerInput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "auditorOutput": [ "auditorOutput" ] }, "placeholders": [ "", "" ] } ] as const; const SCHEMA_FINDINGS: readonly string[] = []; describe("verify: prompt contract", () => { it('uses consistent artifact-schema evidence', () => { expect(SCHEMA_FINDINGS).toEqual([]); }); it('matches the prompt contract pinned at build time', () => { expect(capturePromptContract(findMachineConfig(fsm))).toEqual(CONTRACT); }); const PLAYER_SUBSTITUTED = { "initialVerification": [ "" ], "firstAudit": [ "", "", "" ], "firstRoundFix": [ "", "" ], "secondAuditAfterFix": [ "", "", "" ], "secondAuditAfterRebuttal": [ "", "" ], "secondRoundFix": [ "", "" ] } as const; const composePlayer = ( playbook as unknown as { _internal: { composePlayerPrompt: (input: unknown) => string }; } )._internal.composePlayerPrompt; it('composes player prompts per the link contract', () => { expect( checkPromptComposition({ config: findMachineConfig(fsm), compose: composePlayer, actor: 'player', artifactSchema: 3, }), ).toEqual([]); }); it('substitutes the player placeholders pinned at build time', () => { expect( deriveSubstitutions( findMachineConfig(fsm), composePlayer, 'player', ), ).toEqual(PLAYER_SUBSTITUTED); }); });