Share prompt instructions and simplify validation helpers
This commit is contained in:
@@ -25,6 +25,9 @@ func TestEmbeddedDefinitionsPrepareThroughPromptKit(t *testing.T) {
|
||||
"SectionJSON": "{\"text\":\"fixture-section\"}",
|
||||
"PayloadJSON": "[{\"text\":\"fixture-correction\"}]",
|
||||
}
|
||||
for key, value := range SharedVariables() {
|
||||
vars[key] = value
|
||||
}
|
||||
for _, tc := range []struct{ id, instruction, schema, payload string }{
|
||||
{PromptIDModuleGlossaryProposal, "strongly supported by the glossary", "correction_set.v1.json", "fixture-section"},
|
||||
{PromptIDModuleHomophonesProposal, "homophone correction assistant", "correction_set.v1.json", "fixture-section"},
|
||||
@@ -54,6 +57,24 @@ func TestEmbeddedDefinitionsPrepareThroughPromptKit(t *testing.T) {
|
||||
if strings.HasPrefix(tc.id, "modules.") && !strings.Contains(rendered, "fixture-glossary") {
|
||||
t.Error("missing glossary context")
|
||||
}
|
||||
contract := "ValidationContract"
|
||||
if strings.HasPrefix(tc.id, "modules.") {
|
||||
contract = "ProposalContract"
|
||||
}
|
||||
for _, line := range strings.Split(strings.TrimSpace(vars[contract]), "\n") {
|
||||
if strings.Count(rendered, line) != 1 {
|
||||
t.Errorf("shared instruction missing or duplicated: %q", line)
|
||||
}
|
||||
}
|
||||
for id, guidance := range map[string]string{
|
||||
PromptIDModuleGlossaryProposal: "every literal occurrence",
|
||||
PromptIDModuleSpokenWordProposal: "Accidental repetition of a protected name may be reduced",
|
||||
PromptIDModuleGrammarProposal: "whole-word article",
|
||||
} {
|
||||
if tc.id == id && !strings.Contains(rendered, guidance) {
|
||||
t.Errorf("missing module guidance: %s", guidance)
|
||||
}
|
||||
}
|
||||
missing := map[string]string{"HardeningPolicy": HardeningText()}
|
||||
if _, err := engine.Prepare(context.Background(), pk.RunRequest{PromptID: tc.id, PromptVersion: VersionV1, ProfileID: "fixture", Vars: missing}); err == nil {
|
||||
t.Error("missing variables accepted")
|
||||
|
||||
Reference in New Issue
Block a user