// 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 "./rollout.fsm.js"; import * as playbook from "./rollout.playbook.js"; const CONTRACT = [ { "state": "writePlan", "sourceItem": "ROLLOUT-1", "player": "", "role": "releaseengineer", "reads": [ "callerInput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ] }, "placeholders": [ "" ] }, { "state": "firstReview", "sourceItem": "ROLLOUT-2", "player": "", "role": "sre", "reads": [ "callerInput", "engineerOutput", "latestCommit", "pendingBossQuestion", "planPath" ], "wires": { "callerInput": [ "callerInput" ], "planPath": [ "planPath" ], "latestCommit": [ "latestCommit" ], "engineerOutput": [ "engineerOutput" ] }, "placeholders": [ "", "", "", "" ] }, { "state": "fixFindings", "sourceItem": "ROLLOUT-3", "player": "", "role": "releaseengineer", "reads": [ "callerInput", "pendingBossQuestion", "planPath", "sreOutput" ], "wires": { "callerInput": [ "callerInput" ], "planPath": [ "planPath" ], "sreOutput": [ "sreOutput" ] }, "placeholders": [ "", "", "" ] }, { "state": "secondReview", "sourceItem": "ROLLOUT-4", "player": "", "role": "sre", "reads": [ "callerInput", "engineerOutput", "latestCommit", "pendingBossQuestion", "planPath", "sreOutput" ], "wires": { "callerInput": [ "callerInput" ], "planPath": [ "planPath" ], "latestCommit": [ "latestCommit" ], "sreOutput": [ "sreOutput" ], "engineerOutput": [ "engineerOutput" ] }, "placeholders": [ "", "", "", "", "" ] }, { "state": "confirmRollout", "sourceItem": "ROLLOUT-5", "player": "", "reads": [ "latestCommit", "pendingBossQuestion", "planPath" ], "wires": { "planPath": [ "planPath" ], "latestCommit": [ "latestCommit" ] }, "placeholders": [ "", "" ] } ] as const; const SCHEMA_FINDINGS: readonly string[] = []; describe("rollout: 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 CAPTAIN_SUBSTITUTED = { "confirmRollout": [ "", "" ] } as const; const composeCaptain = ( playbook as unknown as { _internal: { composeCaptainPrompt: (input: unknown) => string }; } )._internal.composeCaptainPrompt; it('composes Captain prompts per the link contract', () => { expect( checkPromptComposition({ config: findMachineConfig(fsm), compose: composeCaptain, actor: 'captain', artifactSchema: 3, }), ).toEqual([]); }); it('substitutes the Captain placeholders pinned at build time', () => { expect( deriveSubstitutions( findMachineConfig(fsm), composeCaptain, 'captain', ), ).toEqual(CAPTAIN_SUBSTITUTED); }); const PLAYER_SUBSTITUTED = { "writePlan": [ "" ], "firstReview": [ "", "", "", "" ], "fixFindings": [ "", "", "" ], "secondReview": [ "", "", "", "", "" ] } 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); }); });