// 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 "./contrib.fsm.js"; import * as playbook from "./contrib.playbook.js"; const CONTRACT = [ { "state": "implement", "sourceItem": "CONTRIB-1", "player": "", "role": "contributor", "reads": [ "bossReply", "callerInput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "" ] }, { "state": "reviewImplementation", "sourceItem": "CONTRIB-2", "player": "", "role": "maintainer", "reads": [ "bossReply", "branch", "callerInput", "contributorOutput", "latestCommit", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "branch": [ "branch" ], "latestCommit": [ "latestCommit" ], "contributorOutput": [ "contributorOutput" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "", "", "", "" ] }, { "state": "addressFindings", "sourceItem": "CONTRIB-3", "player": "", "role": "contributor", "reads": [ "bossReply", "branch", "callerInput", "maintainerOutput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "branch": [ "branch" ], "maintainerOutput": [ "maintainerOutput" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "", "", "" ] }, { "state": "reviewFix", "sourceItem": "CONTRIB-4", "player": "", "role": "maintainer", "reads": [ "bossReply", "branch", "callerInput", "contributorOutput", "latestCommit", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "branch": [ "branch" ], "latestCommit": [ "latestCommit" ], "contributorOutput": [ "contributorOutput" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "", "", "", "" ] }, { "state": "reviewRejection", "sourceItem": "CONTRIB-5", "player": "", "role": "maintainer", "reads": [ "bossReply", "branch", "callerInput", "contributorOutput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "branch": [ "branch" ], "contributorOutput": [ "contributorOutput" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "", "", "" ] }, { "state": "openPullRequest", "sourceItem": "CONTRIB-6", "player": "", "role": "contributor", "reads": [ "bossReply", "branch", "callerInput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "branch": [ "branch" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "", "" ] }, { "state": "openDraftPullRequest", "sourceItem": "CONTRIB-7", "player": "", "role": "contributor", "reads": [ "bossReply", "branch", "callerInput", "maintainerOutput", "pendingBossQuestion" ], "wires": { "callerInput": [ "callerInput" ], "branch": [ "branch" ], "maintainerOutput": [ "maintainerOutput" ], "pendingBossQuestion": [ "pendingBossQuestion" ], "bossReply": [ "bossReply" ] }, "placeholders": [ "", "", "" ] } ] as const; const SCHEMA_FINDINGS: readonly string[] = []; describe("contrib: 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 = { "implement": [ "" ], "reviewImplementation": [ "", "", "", "" ], "addressFindings": [ "", "", "" ], "reviewFix": [ "", "", "", "" ], "reviewRejection": [ "", "", "" ], "openPullRequest": [ "", "" ], "openDraftPullRequest": [ "", "", "" ] } 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); }); });