Remove obsolete prompt version reports
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
# PromptKit v0.18.0 implementation plan
|
# PromptKit v0.18.0 implementation plan
|
||||||
|
|
||||||
Status: Stage 1 complete; Stages 2–7 remain.
|
Status: Stages 1–2 complete; Stages 3–7 remain.
|
||||||
|
|
||||||
## Authority and execution
|
## Authority and execution
|
||||||
|
|
||||||
@@ -88,6 +88,8 @@ expected until subsequent stages. No dependency replacement is needed.
|
|||||||
|
|
||||||
## Stage 2: Adapt production reports and their projection tests
|
## Stage 2: Adapt production reports and their projection tests
|
||||||
|
|
||||||
|
**Complete.** Focused catalog, prompt, requirements, and smoke projection tests pass on Go 1.27.0; native fixtures remain for migration.
|
||||||
|
|
||||||
1. In `command.go`, remove the `PromptVersion` members from
|
1. In `command.go`, remove the `PromptVersion` members from
|
||||||
`promptInspectionReport` and `requirementsInspectionReport`, their projection
|
`promptInspectionReport` and `requirementsInspectionReport`, their projection
|
||||||
assignments, and the prompt text formatter's version line. Remove `Version`
|
assignments, and the prompt text formatter's version line. Remove `Version`
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"testing/fstest"
|
"testing/fstest"
|
||||||
|
|
||||||
configkit "go.maximumdirect.net/configkit"
|
|
||||||
promptkit "go.maximumdirect.net/promptkit"
|
|
||||||
"go.maximumdirect.net/ckconfig"
|
"go.maximumdirect.net/ckconfig"
|
||||||
commandkit "go.maximumdirect.net/commandkit"
|
commandkit "go.maximumdirect.net/commandkit"
|
||||||
|
configkit "go.maximumdirect.net/configkit"
|
||||||
|
promptkit "go.maximumdirect.net/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
const adapterPrompt = `prompts:
|
const adapterPrompt = `prompts:
|
||||||
@@ -467,7 +467,7 @@ func TestFromEnginePassesRequestsAndRetainsNilLoaderIssue(t *testing.T) {
|
|||||||
})
|
})
|
||||||
selection := ckconfig.Selection{Overlay: commandkit.Supplied[string]{Value: "overlay.yml", Set: true}}
|
selection := ckconfig.Selection{Overlay: commandkit.Supplied[string]{Value: "overlay.yml", Set: true}}
|
||||||
prompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
prompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
||||||
if err != nil || prompt.Value == nil || prompt.Value.PromptID != "briefing" || prompt.Value.PromptVersion == nil || *prompt.Value.PromptVersion != "1" || loaderCalls != 1 {
|
if err != nil || prompt.Value == nil || prompt.Value.PromptID != "briefing" || loaderCalls != 1 {
|
||||||
t.Fatalf("prompt inspection = (%#v, %v), calls=%d", prompt, err, loaderCalls)
|
t.Fatalf("prompt inspection = (%#v, %v), calls=%d", prompt, err, loaderCalls)
|
||||||
}
|
}
|
||||||
secondPrompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
secondPrompt, err := suite.InspectPrompt(wantContext, PromptRequest{Selection: selection, ID: "briefing"}, wantInput, wantState)
|
||||||
@@ -529,7 +529,7 @@ func TestFromEngineInspectsRequirementsWithNativeRequest(t *testing.T) {
|
|||||||
if err != nil || acquired.Value == nil || !reflect.DeepEqual(acquired.Value, want) || loaderCalls != 1 {
|
if err != nil || acquired.Value == nil || !reflect.DeepEqual(acquired.Value, want) || loaderCalls != 1 {
|
||||||
t.Fatalf("requirements inspection = (%#v, %v), calls=%d; want native result %#v", acquired, err, loaderCalls, want)
|
t.Fatalf("requirements inspection = (%#v, %v), calls=%d; want native result %#v", acquired, err, loaderCalls, want)
|
||||||
}
|
}
|
||||||
if acquired.Value.PromptID != "briefing" || acquired.Value.PromptVersion == nil || *acquired.Value.PromptVersion != "1" || acquired.Value.ProfileID != "default" {
|
if acquired.Value.PromptID != "briefing" || acquired.Value.ProfileID != "default" {
|
||||||
t.Fatalf("requirements selection = %#v", acquired.Value)
|
t.Fatalf("requirements selection = %#v", acquired.Value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
promptkit "go.maximumdirect.net/promptkit"
|
|
||||||
"go.maximumdirect.net/ckconfig"
|
"go.maximumdirect.net/ckconfig"
|
||||||
commandkit "go.maximumdirect.net/commandkit"
|
commandkit "go.maximumdirect.net/commandkit"
|
||||||
|
promptkit "go.maximumdirect.net/promptkit"
|
||||||
"go.yaml.in/yaml/v4"
|
"go.yaml.in/yaml/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -486,7 +486,6 @@ type promptOutputContractReport struct {
|
|||||||
|
|
||||||
type promptInspectionReport struct {
|
type promptInspectionReport struct {
|
||||||
PromptID string `yaml:"prompt_id"`
|
PromptID string `yaml:"prompt_id"`
|
||||||
PromptVersion *string `yaml:"version,omitempty"`
|
|
||||||
PromptHash string `yaml:"prompt_hash"`
|
PromptHash string `yaml:"prompt_hash"`
|
||||||
DefaultProfileID string `yaml:"default_profile_id"`
|
DefaultProfileID string `yaml:"default_profile_id"`
|
||||||
Inputs []promptInputReport `yaml:"inputs"`
|
Inputs []promptInputReport `yaml:"inputs"`
|
||||||
@@ -495,7 +494,6 @@ type promptInspectionReport struct {
|
|||||||
|
|
||||||
type requirementsInspectionReport struct {
|
type requirementsInspectionReport struct {
|
||||||
PromptID string `yaml:"prompt_id"`
|
PromptID string `yaml:"prompt_id"`
|
||||||
PromptVersion *string `yaml:"version,omitempty"`
|
|
||||||
ProfileID string `yaml:"profile_id"`
|
ProfileID string `yaml:"profile_id"`
|
||||||
Complete bool `yaml:"complete"`
|
Complete bool `yaml:"complete"`
|
||||||
Inputs []requirementInputReport `yaml:"inputs"`
|
Inputs []requirementInputReport `yaml:"inputs"`
|
||||||
@@ -549,7 +547,6 @@ type profileInspectionReport struct {
|
|||||||
func promptReportFromInspection(inspection *promptkit.PromptInspection) promptInspectionReport {
|
func promptReportFromInspection(inspection *promptkit.PromptInspection) promptInspectionReport {
|
||||||
report := promptInspectionReport{
|
report := promptInspectionReport{
|
||||||
PromptID: inspection.PromptID,
|
PromptID: inspection.PromptID,
|
||||||
PromptVersion: inspection.PromptVersion,
|
|
||||||
PromptHash: inspection.PromptHash,
|
PromptHash: inspection.PromptHash,
|
||||||
DefaultProfileID: inspection.DefaultProfileID,
|
DefaultProfileID: inspection.DefaultProfileID,
|
||||||
Inputs: make([]promptInputReport, 0, len(inspection.Inputs)),
|
Inputs: make([]promptInputReport, 0, len(inspection.Inputs)),
|
||||||
@@ -569,7 +566,6 @@ func promptReportFromInspection(inspection *promptkit.PromptInspection) promptIn
|
|||||||
func requirementsReportFromInspection(inspection *promptkit.RequirementInspection) requirementsInspectionReport {
|
func requirementsReportFromInspection(inspection *promptkit.RequirementInspection) requirementsInspectionReport {
|
||||||
report := requirementsInspectionReport{
|
report := requirementsInspectionReport{
|
||||||
PromptID: inspection.PromptID,
|
PromptID: inspection.PromptID,
|
||||||
PromptVersion: inspection.PromptVersion,
|
|
||||||
ProfileID: inspection.ProfileID,
|
ProfileID: inspection.ProfileID,
|
||||||
Complete: inspection.Complete,
|
Complete: inspection.Complete,
|
||||||
Inputs: make([]requirementInputReport, 0, len(inspection.Inputs)),
|
Inputs: make([]requirementInputReport, 0, len(inspection.Inputs)),
|
||||||
@@ -703,9 +699,6 @@ func renderPreparedPromptReport(invocation commandkit.Invocation, explanation co
|
|||||||
func formatPromptText(report promptInspectionReport) string {
|
func formatPromptText(report promptInspectionReport) string {
|
||||||
var output strings.Builder
|
var output strings.Builder
|
||||||
fmt.Fprintf(&output, "Prompt ID: %s\n", strconv.Quote(report.PromptID))
|
fmt.Fprintf(&output, "Prompt ID: %s\n", strconv.Quote(report.PromptID))
|
||||||
if report.PromptVersion != nil {
|
|
||||||
fmt.Fprintf(&output, "Prompt version: %s\n", strconv.Quote(*report.PromptVersion))
|
|
||||||
}
|
|
||||||
fmt.Fprintf(&output, "Prompt hash: %s\n", strconv.Quote(report.PromptHash))
|
fmt.Fprintf(&output, "Prompt hash: %s\n", strconv.Quote(report.PromptHash))
|
||||||
fmt.Fprintf(&output, "Default profile ID: %s\n", strconv.Quote(report.DefaultProfileID))
|
fmt.Fprintf(&output, "Default profile ID: %s\n", strconv.Quote(report.DefaultProfileID))
|
||||||
output.WriteString("Inputs:\n")
|
output.WriteString("Inputs:\n")
|
||||||
@@ -747,13 +740,12 @@ func encodePromptYAML(writer io.Writer, value any) error {
|
|||||||
|
|
||||||
type promptCatalogEntry struct {
|
type promptCatalogEntry struct {
|
||||||
ID string `yaml:"id"`
|
ID string `yaml:"id"`
|
||||||
Version *string `yaml:"version,omitempty"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func encodePromptCatalog(prompts []promptkit.PromptIdentity) ([]byte, error) {
|
func encodePromptCatalog(prompts []promptkit.PromptIdentity) ([]byte, error) {
|
||||||
entries := make([]promptCatalogEntry, len(prompts))
|
entries := make([]promptCatalogEntry, len(prompts))
|
||||||
for index, prompt := range prompts {
|
for index, prompt := range prompts {
|
||||||
entries[index] = promptCatalogEntry{ID: prompt.ID, Version: prompt.Version}
|
entries[index] = promptCatalogEntry{ID: prompt.ID}
|
||||||
}
|
}
|
||||||
return encodePromptYAMLBytes(entries)
|
return encodePromptYAMLBytes(entries)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,13 +6,12 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
promptkit "go.maximumdirect.net/promptkit"
|
|
||||||
"go.maximumdirect.net/ckconfig"
|
"go.maximumdirect.net/ckconfig"
|
||||||
commandkit "go.maximumdirect.net/commandkit"
|
commandkit "go.maximumdirect.net/commandkit"
|
||||||
|
promptkit "go.maximumdirect.net/promptkit"
|
||||||
"go.yaml.in/yaml/v4"
|
"go.yaml.in/yaml/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -347,7 +346,7 @@ func TestDiscoveryCommandsForwardFiltersAndRenderCollections(t *testing.T) {
|
|||||||
ListPrompts: func(_ context.Context, request CatalogRequest, _, _ struct{}) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
ListPrompts: func(_ context.Context, request CatalogRequest, _, _ struct{}) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
||||||
providers++
|
providers++
|
||||||
promptRequest = request
|
promptRequest = request
|
||||||
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "team/briefing", Version: testStringPointer("")}}}, nil
|
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "team/briefing"}}}, nil
|
||||||
},
|
},
|
||||||
ListProfiles: func(_ context.Context, request CatalogRequest, _, _ struct{}) (commandkit.Acquired[[]string], error) {
|
ListProfiles: func(_ context.Context, request CatalogRequest, _, _ struct{}) (commandkit.Acquired[[]string], error) {
|
||||||
providers++
|
providers++
|
||||||
@@ -387,7 +386,7 @@ func TestDiscoveryCommandsForwardFiltersAndRenderCollections(t *testing.T) {
|
|||||||
t.Fatalf("prompt list outcome/request = (%#v, %#v), output=%q", outcome, promptRequest, output)
|
t.Fatalf("prompt list outcome/request = (%#v, %#v), output=%q", outcome, promptRequest, output)
|
||||||
}
|
}
|
||||||
var promptRows []map[string]any
|
var promptRows []map[string]any
|
||||||
if err := yaml.Unmarshal([]byte(output), &promptRows); err != nil || len(promptRows) != 1 || promptRows[0]["id"] != "team/briefing" || promptRows[0]["version"] != "" {
|
if err := yaml.Unmarshal([]byte(output), &promptRows); err != nil || len(promptRows) != 1 || promptRows[0]["id"] != "team/briefing" || len(promptRows[0]) != 1 {
|
||||||
t.Fatalf("prompt catalog YAML = %#v, error=%v, output=%q", promptRows, err, output)
|
t.Fatalf("prompt catalog YAML = %#v, error=%v, output=%q", promptRows, err, output)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +455,7 @@ func TestCatalogListUsesPreparedInputAndPreflightsFormat(t *testing.T) {
|
|||||||
ListPrompts: func(_ context.Context, request CatalogRequest, value input, gotState state) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
ListPrompts: func(_ context.Context, request CatalogRequest, value input, gotState state) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
||||||
providerCalls++
|
providerCalls++
|
||||||
received, receivedSelection, receivedState = value, request.Selection, gotState
|
received, receivedSelection, receivedState = value, request.Selection, gotState
|
||||||
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "briefing", Version: testStringPointer("1")}}}, nil
|
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "briefing"}}}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
app := newPromptTestApp(t, Command(suite))
|
app := newPromptTestApp(t, Command(suite))
|
||||||
@@ -594,9 +593,9 @@ func TestCatalogNilFactoriesSupplyZeroValues(t *testing.T) {
|
|||||||
|
|
||||||
func TestCatalogCommandsRenderNativeValuesAndEmptySequences(t *testing.T) {
|
func TestCatalogCommandsRenderNativeValuesAndEmptySequences(t *testing.T) {
|
||||||
prompts := []promptkit.PromptIdentity{
|
prompts := []promptkit.PromptIdentity{
|
||||||
{ID: "later", Version: testStringPointer("1.10")},
|
{ID: "later"},
|
||||||
{ID: "001", Version: testStringPointer(" 03 ")},
|
{ID: "001"},
|
||||||
{ID: "a: true", Version: testStringPointer("yes")},
|
{ID: "a: true"},
|
||||||
{ID: "without-version"},
|
{ID: "without-version"},
|
||||||
}
|
}
|
||||||
profiles := []string{"later", "001", "a: true", "later"}
|
profiles := []string{"later", "001", "a: true", "later"}
|
||||||
@@ -626,13 +625,8 @@ func TestCatalogCommandsRenderNativeValuesAndEmptySequences(t *testing.T) {
|
|||||||
if !idOK || id != prompts[index].ID {
|
if !idOK || id != prompts[index].ID {
|
||||||
t.Errorf("prompt entry %d = %#v, want ID %q", index, entry, prompts[index].ID)
|
t.Errorf("prompt entry %d = %#v, want ID %q", index, entry, prompts[index].ID)
|
||||||
}
|
}
|
||||||
version, versionExists := entry["version"]
|
if _, exists := entry["version"]; exists || len(entry) != 1 {
|
||||||
if prompts[index].Version == nil {
|
t.Errorf("prompt entry %d contains unexpected fields: %#v", index, entry)
|
||||||
if versionExists || len(entry) != 1 {
|
|
||||||
t.Errorf("prompt entry %d emitted absent version: %#v", index, entry)
|
|
||||||
}
|
|
||||||
} else if !versionExists || version != *prompts[index].Version || len(entry) != 2 {
|
|
||||||
t.Errorf("prompt entry %d version = %#v, want %q", index, version, *prompts[index].Version)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,7 +721,7 @@ func TestCatalogFailureReportsWarningAndNativeExplanationSeparately(t *testing.T
|
|||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
canceled := newPromptTestApp(t, Command(Suite[struct{}, struct{}]{ListPrompts: func(context.Context, CatalogRequest, struct{}, struct{}) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
canceled := newPromptTestApp(t, Command(Suite[struct{}, struct{}]{ListPrompts: func(context.Context, CatalogRequest, struct{}, struct{}) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
||||||
cancel()
|
cancel()
|
||||||
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "briefing", Version: testStringPointer("1")}}, Diagnostics: []commandkit.Diagnostic{diagnostic}}, nil
|
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "briefing"}}, Diagnostics: []commandkit.Diagnostic{diagnostic}}, nil
|
||||||
}}))
|
}}))
|
||||||
output.Reset()
|
output.Reset()
|
||||||
diagnosticOutput.Reset()
|
diagnosticOutput.Reset()
|
||||||
@@ -747,7 +741,7 @@ func TestCatalogFailureReportsWarningAndNativeExplanationSeparately(t *testing.T
|
|||||||
} {
|
} {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
writerApp := newPromptTestApp(t, Command(Suite[struct{}, struct{}]{ListPrompts: func(context.Context, CatalogRequest, struct{}, struct{}) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
writerApp := newPromptTestApp(t, Command(Suite[struct{}, struct{}]{ListPrompts: func(context.Context, CatalogRequest, struct{}, struct{}) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
|
||||||
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "briefing", Version: testStringPointer("1")}}, Diagnostics: []commandkit.Diagnostic{diagnostic}}, nil
|
return commandkit.Acquired[[]promptkit.PromptIdentity]{Value: []promptkit.PromptIdentity{{ID: "briefing"}}, Diagnostics: []commandkit.Diagnostic{diagnostic}}, nil
|
||||||
}}))
|
}}))
|
||||||
outcome := writerApp.Execute(context.Background(), []string{"promptkit", "list", "prompts"}, commandkit.Streams{Out: test.writer, Err: io.Discard})
|
outcome := writerApp.Execute(context.Background(), []string{"promptkit", "list", "prompts"}, commandkit.Streams{Out: test.writer, Err: io.Discard})
|
||||||
if outcome.Kind != commandkit.OutcomeOperational || !errors.Is(outcome.Presentation.Output.WriteError, test.want) || outcome.Presentation.Output.State != commandkit.DeliveryIncomplete {
|
if outcome.Kind != commandkit.OutcomeOperational || !errors.Is(outcome.Presentation.Output.WriteError, test.want) || outcome.Presentation.Output.State != commandkit.DeliveryIncomplete {
|
||||||
@@ -948,6 +942,9 @@ func TestDefinitionReportsRetainNativeFieldsAndSafeCredentialReferences(t *testi
|
|||||||
if err := yaml.Unmarshal(output.Bytes(), &prompt); err != nil {
|
if err := yaml.Unmarshal(output.Bytes(), &prompt); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
if _, exists := prompt["version"]; exists {
|
||||||
|
t.Fatalf("prompt version emitted: %#v", prompt)
|
||||||
|
}
|
||||||
inputs := prompt["inputs"].([]any)
|
inputs := prompt["inputs"].([]any)
|
||||||
if len(inputs) != 2 || inputs[0].(map[string]any)["name"] != "topic" || inputs[1].(map[string]any)["name"] != "audience" || prompt["prompt_hash"] == "" {
|
if len(inputs) != 2 || inputs[0].(map[string]any)["name"] != "topic" || inputs[1].(map[string]any)["name"] != "audience" || prompt["prompt_hash"] == "" {
|
||||||
t.Fatalf("prompt fields/order = %#v", prompt)
|
t.Fatalf("prompt fields/order = %#v", prompt)
|
||||||
@@ -959,7 +956,7 @@ func TestDefinitionReportsRetainNativeFieldsAndSafeCredentialReferences(t *testi
|
|||||||
|
|
||||||
output.Reset()
|
output.Reset()
|
||||||
outcome = app.Execute(context.Background(), []string{"promptkit", "show", "prompt", "briefing"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
outcome = app.Execute(context.Background(), []string{"promptkit", "show", "prompt", "briefing"}, commandkit.Streams{Out: &output, Err: io.Discard})
|
||||||
if outcome.Kind != commandkit.OutcomeSuccess || loadCalls != 2 || !strings.Contains(output.String(), "Prompt version: \"1\"") || !strings.Contains(output.String(), `- name: "topic"`) {
|
if outcome.Kind != commandkit.OutcomeSuccess || loadCalls != 2 || strings.Contains(output.String(), "Prompt version:") || !strings.Contains(output.String(), `- name: "topic"`) {
|
||||||
t.Fatalf("default text prompt report = (%#v, calls=%d, %s)", outcome, loadCalls, output.String())
|
t.Fatalf("default text prompt report = (%#v, calls=%d, %s)", outcome, loadCalls, output.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1002,72 +999,21 @@ func TestDefinitionReportsRetainNativeFieldsAndSafeCredentialReferences(t *testi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestOptionalPromptVersionsPreserveAbsenceAndEmptyValues(t *testing.T) {
|
func TestPromptReportOmitsRemovedVersion(t *testing.T) {
|
||||||
empty := ""
|
report := promptReportFromInspection(&promptkit.PromptInspection{PromptID: "briefing", PromptHash: "hash"})
|
||||||
label := "release-1"
|
encoded, err := encodePromptYAMLBytes(report)
|
||||||
for _, test := range []struct {
|
|
||||||
name string
|
|
||||||
version *string
|
|
||||||
present bool
|
|
||||||
want string
|
|
||||||
}{
|
|
||||||
{name: "absent"},
|
|
||||||
{name: "present empty", version: &empty, present: true, want: ""},
|
|
||||||
{name: "nonempty", version: &label, present: true, want: "release-1"},
|
|
||||||
} {
|
|
||||||
t.Run(test.name, func(t *testing.T) {
|
|
||||||
prompt := promptReportFromInspection(&promptkit.PromptInspection{PromptID: "briefing", PromptVersion: test.version})
|
|
||||||
promptBytes, err := encodePromptYAMLBytes(prompt)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
var promptReport map[string]any
|
var document map[string]any
|
||||||
if err := yaml.Unmarshal(promptBytes, &promptReport); err != nil {
|
if err := yaml.Unmarshal(encoded, &document); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
assertOptionalVersion(t, promptReport, test.present, test.want)
|
if _, exists := document["version"]; exists || document["prompt_id"] != "briefing" || document["prompt_hash"] != "hash" {
|
||||||
text := formatPromptText(prompt)
|
t.Fatalf("prompt report = %#v", document)
|
||||||
if test.present && !strings.Contains(text, "Prompt version: "+strconv.Quote(test.want)+"\n") {
|
|
||||||
t.Errorf("text omitted present version %q: %q", test.want, text)
|
|
||||||
}
|
}
|
||||||
if !test.present && strings.Contains(text, "Prompt version:") {
|
if text := formatPromptText(report); strings.Contains(text, "Prompt version:") || !strings.Contains(text, `Prompt hash: "hash"`) {
|
||||||
t.Errorf("text emitted absent version: %q", text)
|
t.Fatalf("prompt text = %q", text)
|
||||||
}
|
|
||||||
|
|
||||||
requirementsBytes, err := encodePromptYAMLBytes(requirementsReportFromInspection(&promptkit.RequirementInspection{PromptID: "briefing", PromptVersion: test.version}))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
var requirementsReport map[string]any
|
|
||||||
if err := yaml.Unmarshal(requirementsBytes, &requirementsReport); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
assertOptionalVersion(t, requirementsReport, test.present, test.want)
|
|
||||||
|
|
||||||
catalogBytes, err := encodePromptCatalog([]promptkit.PromptIdentity{{ID: "briefing", Version: test.version}})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
var catalog []map[string]any
|
|
||||||
if err := yaml.Unmarshal(catalogBytes, &catalog); err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if len(catalog) != 1 || catalog[0]["id"] != "briefing" {
|
|
||||||
t.Fatalf("catalog = %#v", catalog)
|
|
||||||
}
|
|
||||||
assertOptionalVersion(t, catalog[0], test.present, test.want)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func assertOptionalVersion(t *testing.T, report map[string]any, present bool, want string) {
|
|
||||||
t.Helper()
|
|
||||||
version, found := report["version"]
|
|
||||||
if found != present {
|
|
||||||
t.Fatalf("version presence = %t in %#v, want %t", found, report, present)
|
|
||||||
}
|
|
||||||
if present && version != want {
|
|
||||||
t.Errorf("version = %#v, want %q", version, want)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1165,9 +1111,9 @@ func TestProfileTextUsesCredentialNamesAndExplicitEmptyExtraParams(t *testing.T)
|
|||||||
|
|
||||||
func TestPromptCatalogYAMLPreservesSchemaStringsAndOrder(t *testing.T) {
|
func TestPromptCatalogYAMLPreservesSchemaStringsAndOrder(t *testing.T) {
|
||||||
want := []promptkit.PromptIdentity{
|
want := []promptkit.PromptIdentity{
|
||||||
{ID: " briefing ", Version: testStringPointer(" 03 ")},
|
{ID: " briefing "},
|
||||||
{ID: "001", Version: testStringPointer("1.10")},
|
{ID: "001"},
|
||||||
{ID: " briefing ", Version: testStringPointer(" 03 ")},
|
{ID: " briefing "},
|
||||||
}
|
}
|
||||||
output, err := encodePromptCatalog(want)
|
output, err := encodePromptCatalog(want)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1181,13 +1127,12 @@ func TestPromptCatalogYAMLPreservesSchemaStringsAndOrder(t *testing.T) {
|
|||||||
t.Fatalf("catalog entry count = %d, want %d: %q", len(decoded), len(want), output)
|
t.Fatalf("catalog entry count = %d, want %d: %q", len(decoded), len(want), output)
|
||||||
}
|
}
|
||||||
for index, entry := range decoded {
|
for index, entry := range decoded {
|
||||||
if len(entry) != 2 {
|
if len(entry) != 1 {
|
||||||
t.Errorf("entry %d fields = %#v, want only id and version", index, entry)
|
t.Errorf("entry %d fields = %#v, want only id", index, entry)
|
||||||
}
|
}
|
||||||
id, idOK := entry["id"].(string)
|
id, idOK := entry["id"].(string)
|
||||||
version, versionOK := entry["version"].(string)
|
if !idOK || id != want[index].ID {
|
||||||
if !idOK || !versionOK || id != want[index].ID || want[index].Version == nil || version != *want[index].Version {
|
t.Errorf("entry %d = %#v, want id %q", index, entry, want[index].ID)
|
||||||
t.Errorf("entry %d = %#v, want id/version %q/%#v", index, entry, want[index].ID, want[index].Version)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1273,7 +1218,6 @@ func TestRequirementsReportPreservesNativeFieldsAndMetadata(t *testing.T) {
|
|||||||
contentType := "true"
|
contentType := "true"
|
||||||
inspection := &promptkit.RequirementInspection{
|
inspection := &promptkit.RequirementInspection{
|
||||||
PromptID: "true",
|
PromptID: "true",
|
||||||
PromptVersion: testStringPointer("001"),
|
|
||||||
ProfileID: "null",
|
ProfileID: "null",
|
||||||
Complete: true,
|
Complete: true,
|
||||||
Inputs: []promptkit.InputRequirement{
|
Inputs: []promptkit.InputRequirement{
|
||||||
@@ -1303,10 +1247,13 @@ func TestRequirementsReportPreservesNativeFieldsAndMetadata(t *testing.T) {
|
|||||||
if err := yaml.Unmarshal(output, &report); err != nil {
|
if err := yaml.Unmarshal(output, &report); err != nil {
|
||||||
t.Fatalf("decode requirements report %q: %v", output, err)
|
t.Fatalf("decode requirements report %q: %v", output, err)
|
||||||
}
|
}
|
||||||
if report["complete"] != complete || report["prompt_id"] != "true" || report["version"] != "001" || report["profile_id"] != "null" {
|
if report["complete"] != complete || report["prompt_id"] != "true" || report["profile_id"] != "null" {
|
||||||
t.Fatalf("selected context or completeness = %#v", report)
|
t.Fatalf("selected context or completeness = %#v", report)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, exists := report["version"]; exists {
|
||||||
|
t.Fatalf("requirements version emitted: %#v", report)
|
||||||
|
}
|
||||||
inputs, ok := report["inputs"].([]any)
|
inputs, ok := report["inputs"].([]any)
|
||||||
if !ok || len(inputs) != 2 {
|
if !ok || len(inputs) != 2 {
|
||||||
t.Fatalf("inputs = %#v", report["inputs"])
|
t.Fatalf("inputs = %#v", report["inputs"])
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ type smokeTargetDTO struct {
|
|||||||
BackendID string `yaml:"backend_id"`
|
BackendID string `yaml:"backend_id"`
|
||||||
ProfileID string `yaml:"profile_id"`
|
ProfileID string `yaml:"profile_id"`
|
||||||
PromptID string `yaml:"prompt_id"`
|
PromptID string `yaml:"prompt_id"`
|
||||||
PromptVersion *string `yaml:"version,omitempty"`
|
|
||||||
DefaultSourceBackendID string `yaml:"default_source_backend_id"`
|
DefaultSourceBackendID string `yaml:"default_source_backend_id"`
|
||||||
SelectionSource string `yaml:"selection_source"`
|
SelectionSource string `yaml:"selection_source"`
|
||||||
Endpoint string `yaml:"endpoint"`
|
Endpoint string `yaml:"endpoint"`
|
||||||
@@ -158,7 +157,6 @@ func smokeReportFromNative(report *promptkit.SmokeTestReport) *smokeReportDTO {
|
|||||||
BackendID: target.BackendID,
|
BackendID: target.BackendID,
|
||||||
ProfileID: target.ProfileID,
|
ProfileID: target.ProfileID,
|
||||||
PromptID: target.PromptID,
|
PromptID: target.PromptID,
|
||||||
PromptVersion: target.PromptVersion,
|
|
||||||
DefaultSourceBackendID: target.DefaultSourceBackendID,
|
DefaultSourceBackendID: target.DefaultSourceBackendID,
|
||||||
SelectionSource: target.SelectionSource,
|
SelectionSource: target.SelectionSource,
|
||||||
Endpoint: target.Endpoint,
|
Endpoint: target.Endpoint,
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ func TestSmokeReportYAMLProjectsNativeFieldsAndPresence(t *testing.T) {
|
|||||||
textReturned := false
|
textReturned := false
|
||||||
zero := time.Duration(0)
|
zero := time.Duration(0)
|
||||||
retryDelay := 1500 * time.Millisecond
|
retryDelay := 1500 * time.Millisecond
|
||||||
version := ""
|
|
||||||
httpStatus := 201
|
httpStatus := 201
|
||||||
started := time.Date(2026, time.October, 17, 12, 30, 0, 0, time.UTC)
|
started := time.Date(2026, time.October, 17, 12, 30, 0, 0, time.UTC)
|
||||||
report := &promptkit.SmokeTestReport{
|
report := &promptkit.SmokeTestReport{
|
||||||
@@ -29,7 +28,6 @@ func TestSmokeReportYAMLProjectsNativeFieldsAndPresence(t *testing.T) {
|
|||||||
BackendID: "local",
|
BackendID: "local",
|
||||||
ProfileID: "default",
|
ProfileID: "default",
|
||||||
PromptID: "team/briefing",
|
PromptID: "team/briefing",
|
||||||
PromptVersion: &version,
|
|
||||||
DefaultSourceBackendID: "fallback",
|
DefaultSourceBackendID: "fallback",
|
||||||
SelectionSource: "prompt",
|
SelectionSource: "prompt",
|
||||||
Endpoint: "https://example.invalid/v1",
|
Endpoint: "https://example.invalid/v1",
|
||||||
@@ -98,9 +96,12 @@ func TestSmokeReportYAMLProjectsNativeFieldsAndPresence(t *testing.T) {
|
|||||||
t.Fatalf("report scalar values = %#v", document)
|
t.Fatalf("report scalar values = %#v", document)
|
||||||
}
|
}
|
||||||
target := document["target"].(map[string]any)
|
target := document["target"].(map[string]any)
|
||||||
if target["prompt_id"] != "team/briefing" || target["version"] != "" || target["selection_source"] != "prompt" {
|
if target["prompt_id"] != "team/briefing" || target["selection_source"] != "prompt" {
|
||||||
t.Fatalf("target values = %#v", target)
|
t.Fatalf("target values = %#v", target)
|
||||||
}
|
}
|
||||||
|
if _, exists := target["version"]; exists {
|
||||||
|
t.Fatalf("target version emitted: %#v", target)
|
||||||
|
}
|
||||||
settings := target["effective_settings"].(map[string]any)
|
settings := target["effective_settings"].(map[string]any)
|
||||||
if settings["model"] != "example-model" || settings["temperature"] != 0 || settings["api_key_env"] != "PROMPTKIT_KEY" {
|
if settings["model"] != "example-model" || settings["temperature"] != 0 || settings["api_key_env"] != "PROMPTKIT_KEY" {
|
||||||
t.Fatalf("effective settings = %#v", settings)
|
t.Fatalf("effective settings = %#v", settings)
|
||||||
|
|||||||
Reference in New Issue
Block a user