AI/Tasks/PromptingUpgrades/Prompting_Phase03_OutputContractEnvelopeValidation_Implementation.txt
|
PHASE 03 IMPLEMENTATION PROMPT - OUTPUT CONTRACT AND ENVELOPE VALIDATION
Goal: Implement typed response contracts and deterministic envelope/finalAnswer validation outside prompt text. Inputs: - AI/Tasks/PromptingUpgrades/Prompting_Phase03_OutputContractEnvelopeValidation_Strict.txt - Outputs from Phases 01-02 Required code work: - Implement ResponseContract.cs with ContractType enum: Markdown, PlainText, Json. - Define exact envelope schema: required fields, allowed optional fields, nullability, and unknown-field behavior. - Implement deterministic validators for: - envelope shape - contract declaration - finalAnswer type/content per contract - contract drift between declared and actual response - Clarify outer-envelope vs inner-JSON rules and enforce them mechanically. - Generate formatting instructions only for contracts that require additional formatting guidance. - Add bounded, redacted diagnostics with distinct error codes/categories for envelope vs contract vs finalAnswer vs drift failures. Implementation constraints: - Keep recovery/repair ownership in Phase 06; this phase validates and classifies, it does not perform broad repair strategy. - Do not expand into section typing, authorization, or budgeting logic. - Preserve safety boundaries and fail deterministically. Minimum tests to add/update: - Envelope schema acceptance/rejection matrix tests. - finalAnswer contract-type validation tests for Markdown/PlainText/Json. - Malformed JSON and trailing-token rejection tests. - Unknown-field and missing-field behavior tests. - Contract drift classification tests. Validation commands: - dotnet build src/TechToolbox.Agent/TechToolbox.Agent.csproj -c Release - dotnet test src/TechToolbox.Agent/Tests/TechToolbox.Agent.Tests.csproj -c Release --filter "Contract|Envelope|Json|FinalAnswer|Validation|Strict" Deliverable: Return contract schema, validation rules, error taxonomy, and deterministic failure proof from tests. |