Remove obsolete prompt version reports

This commit is contained in:
2026-11-06 00:57:50 +00:00
parent f933f056d7
commit 983c22be77
6 changed files with 68 additions and 128 deletions

View File

@@ -1,6 +1,6 @@
# 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
@@ -88,6 +88,8 @@ expected until subsequent stages. No dependency replacement is needed.
## 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
`promptInspectionReport` and `requirementsInspectionReport`, their projection
assignments, and the prompt text formatter's version line. Remove `Version`

View File

@@ -11,10 +11,10 @@ import (
"testing"
"testing/fstest"
configkit "go.maximumdirect.net/configkit"
promptkit "go.maximumdirect.net/promptkit"
"go.maximumdirect.net/ckconfig"
commandkit "go.maximumdirect.net/commandkit"
configkit "go.maximumdirect.net/configkit"
promptkit "go.maximumdirect.net/promptkit"
)
const adapterPrompt = `prompts:
@@ -467,7 +467,7 @@ func TestFromEnginePassesRequestsAndRetainsNilLoaderIssue(t *testing.T) {
})
selection := ckconfig.Selection{Overlay: commandkit.Supplied[string]{Value: "overlay.yml", Set: true}}
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)
}
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 {
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)
}
}

View File

@@ -9,9 +9,9 @@ import (
"strconv"
"strings"
promptkit "go.maximumdirect.net/promptkit"
"go.maximumdirect.net/ckconfig"
commandkit "go.maximumdirect.net/commandkit"
promptkit "go.maximumdirect.net/promptkit"
"go.yaml.in/yaml/v4"
)
@@ -486,7 +486,6 @@ type promptOutputContractReport struct {
type promptInspectionReport struct {
PromptID string `yaml:"prompt_id"`
PromptVersion *string `yaml:"version,omitempty"`
PromptHash string `yaml:"prompt_hash"`
DefaultProfileID string `yaml:"default_profile_id"`
Inputs []promptInputReport `yaml:"inputs"`
@@ -494,13 +493,12 @@ type promptInspectionReport struct {
}
type requirementsInspectionReport struct {
PromptID string `yaml:"prompt_id"`
PromptVersion *string `yaml:"version,omitempty"`
ProfileID string `yaml:"profile_id"`
Complete bool `yaml:"complete"`
Inputs []requirementInputReport `yaml:"inputs"`
Variables []requirementVariableReport `yaml:"variables"`
Issues []requirementIssueReport `yaml:"issues"`
PromptID string `yaml:"prompt_id"`
ProfileID string `yaml:"profile_id"`
Complete bool `yaml:"complete"`
Inputs []requirementInputReport `yaml:"inputs"`
Variables []requirementVariableReport `yaml:"variables"`
Issues []requirementIssueReport `yaml:"issues"`
}
type requirementInputReport struct {
@@ -549,7 +547,6 @@ type profileInspectionReport struct {
func promptReportFromInspection(inspection *promptkit.PromptInspection) promptInspectionReport {
report := promptInspectionReport{
PromptID: inspection.PromptID,
PromptVersion: inspection.PromptVersion,
PromptHash: inspection.PromptHash,
DefaultProfileID: inspection.DefaultProfileID,
Inputs: make([]promptInputReport, 0, len(inspection.Inputs)),
@@ -568,13 +565,12 @@ func promptReportFromInspection(inspection *promptkit.PromptInspection) promptIn
func requirementsReportFromInspection(inspection *promptkit.RequirementInspection) requirementsInspectionReport {
report := requirementsInspectionReport{
PromptID: inspection.PromptID,
PromptVersion: inspection.PromptVersion,
ProfileID: inspection.ProfileID,
Complete: inspection.Complete,
Inputs: make([]requirementInputReport, 0, len(inspection.Inputs)),
Variables: make([]requirementVariableReport, 0, len(inspection.Variables)),
Issues: make([]requirementIssueReport, 0, len(inspection.Issues)),
PromptID: inspection.PromptID,
ProfileID: inspection.ProfileID,
Complete: inspection.Complete,
Inputs: make([]requirementInputReport, 0, len(inspection.Inputs)),
Variables: make([]requirementVariableReport, 0, len(inspection.Variables)),
Issues: make([]requirementIssueReport, 0, len(inspection.Issues)),
}
for _, input := range inspection.Inputs {
report.Inputs = append(report.Inputs, requirementInputReport{
@@ -703,9 +699,6 @@ func renderPreparedPromptReport(invocation commandkit.Invocation, explanation co
func formatPromptText(report promptInspectionReport) string {
var output strings.Builder
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, "Default profile ID: %s\n", strconv.Quote(report.DefaultProfileID))
output.WriteString("Inputs:\n")
@@ -746,14 +739,13 @@ func encodePromptYAML(writer io.Writer, value any) error {
}
type promptCatalogEntry struct {
ID string `yaml:"id"`
Version *string `yaml:"version,omitempty"`
ID string `yaml:"id"`
}
func encodePromptCatalog(prompts []promptkit.PromptIdentity) ([]byte, error) {
entries := make([]promptCatalogEntry, len(prompts))
for index, prompt := range prompts {
entries[index] = promptCatalogEntry{ID: prompt.ID, Version: prompt.Version}
entries[index] = promptCatalogEntry{ID: prompt.ID}
}
return encodePromptYAMLBytes(entries)
}

View File

@@ -6,13 +6,12 @@ import (
"errors"
"io"
"reflect"
"strconv"
"strings"
"testing"
promptkit "go.maximumdirect.net/promptkit"
"go.maximumdirect.net/ckconfig"
commandkit "go.maximumdirect.net/commandkit"
promptkit "go.maximumdirect.net/promptkit"
"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) {
providers++
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) {
providers++
@@ -387,7 +386,7 @@ func TestDiscoveryCommandsForwardFiltersAndRenderCollections(t *testing.T) {
t.Fatalf("prompt list outcome/request = (%#v, %#v), output=%q", outcome, promptRequest, output)
}
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)
}
@@ -456,7 +455,7 @@ func TestCatalogListUsesPreparedInputAndPreflightsFormat(t *testing.T) {
ListPrompts: func(_ context.Context, request CatalogRequest, value input, gotState state) (commandkit.Acquired[[]promptkit.PromptIdentity], error) {
providerCalls++
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))
@@ -594,9 +593,9 @@ func TestCatalogNilFactoriesSupplyZeroValues(t *testing.T) {
func TestCatalogCommandsRenderNativeValuesAndEmptySequences(t *testing.T) {
prompts := []promptkit.PromptIdentity{
{ID: "later", Version: testStringPointer("1.10")},
{ID: "001", Version: testStringPointer(" 03 ")},
{ID: "a: true", Version: testStringPointer("yes")},
{ID: "later"},
{ID: "001"},
{ID: "a: true"},
{ID: "without-version"},
}
profiles := []string{"later", "001", "a: true", "later"}
@@ -626,13 +625,8 @@ func TestCatalogCommandsRenderNativeValuesAndEmptySequences(t *testing.T) {
if !idOK || id != prompts[index].ID {
t.Errorf("prompt entry %d = %#v, want ID %q", index, entry, prompts[index].ID)
}
version, versionExists := entry["version"]
if prompts[index].Version == nil {
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)
if _, exists := entry["version"]; exists || len(entry) != 1 {
t.Errorf("prompt entry %d contains unexpected fields: %#v", index, entry)
}
}
@@ -727,7 +721,7 @@ func TestCatalogFailureReportsWarningAndNativeExplanationSeparately(t *testing.T
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) {
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()
diagnosticOutput.Reset()
@@ -747,7 +741,7 @@ func TestCatalogFailureReportsWarningAndNativeExplanationSeparately(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) {
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})
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 {
t.Fatal(err)
}
if _, exists := prompt["version"]; exists {
t.Fatalf("prompt version emitted: %#v", prompt)
}
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"] == "" {
t.Fatalf("prompt fields/order = %#v", prompt)
@@ -959,7 +956,7 @@ func TestDefinitionReportsRetainNativeFieldsAndSafeCredentialReferences(t *testi
output.Reset()
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())
}
@@ -1002,72 +999,21 @@ func TestDefinitionReportsRetainNativeFieldsAndSafeCredentialReferences(t *testi
}
}
func TestOptionalPromptVersionsPreserveAbsenceAndEmptyValues(t *testing.T) {
empty := ""
label := "release-1"
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 {
t.Fatal(err)
}
var promptReport map[string]any
if err := yaml.Unmarshal(promptBytes, &promptReport); err != nil {
t.Fatal(err)
}
assertOptionalVersion(t, promptReport, test.present, test.want)
text := formatPromptText(prompt)
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:") {
t.Errorf("text emitted absent version: %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 TestPromptReportOmitsRemovedVersion(t *testing.T) {
report := promptReportFromInspection(&promptkit.PromptInspection{PromptID: "briefing", PromptHash: "hash"})
encoded, err := encodePromptYAMLBytes(report)
if err != nil {
t.Fatal(err)
}
}
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)
var document map[string]any
if err := yaml.Unmarshal(encoded, &document); err != nil {
t.Fatal(err)
}
if present && version != want {
t.Errorf("version = %#v, want %q", version, want)
if _, exists := document["version"]; exists || document["prompt_id"] != "briefing" || document["prompt_hash"] != "hash" {
t.Fatalf("prompt report = %#v", document)
}
if text := formatPromptText(report); strings.Contains(text, "Prompt version:") || !strings.Contains(text, `Prompt hash: "hash"`) {
t.Fatalf("prompt text = %q", text)
}
}
@@ -1165,9 +1111,9 @@ func TestProfileTextUsesCredentialNamesAndExplicitEmptyExtraParams(t *testing.T)
func TestPromptCatalogYAMLPreservesSchemaStringsAndOrder(t *testing.T) {
want := []promptkit.PromptIdentity{
{ID: " briefing ", Version: testStringPointer(" 03 ")},
{ID: "001", Version: testStringPointer("1.10")},
{ID: " briefing ", Version: testStringPointer(" 03 ")},
{ID: " briefing "},
{ID: "001"},
{ID: " briefing "},
}
output, err := encodePromptCatalog(want)
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)
}
for index, entry := range decoded {
if len(entry) != 2 {
t.Errorf("entry %d fields = %#v, want only id and version", index, entry)
if len(entry) != 1 {
t.Errorf("entry %d fields = %#v, want only id", index, entry)
}
id, idOK := entry["id"].(string)
version, versionOK := entry["version"].(string)
if !idOK || !versionOK || id != want[index].ID || want[index].Version == nil || version != *want[index].Version {
t.Errorf("entry %d = %#v, want id/version %q/%#v", index, entry, want[index].ID, want[index].Version)
if !idOK || id != want[index].ID {
t.Errorf("entry %d = %#v, want id %q", index, entry, want[index].ID)
}
}
}
@@ -1272,10 +1217,9 @@ func TestRequirementsReportPreservesNativeFieldsAndMetadata(t *testing.T) {
empty := ""
contentType := "true"
inspection := &promptkit.RequirementInspection{
PromptID: "true",
PromptVersion: testStringPointer("001"),
ProfileID: "null",
Complete: true,
PromptID: "true",
ProfileID: "null",
Complete: true,
Inputs: []promptkit.InputRequirement{
{Name: "true", Kind: promptkit.RequirementKind("123"), Declared: false, Description: &empty},
{Name: "001", Kind: promptkit.RequirementKind("future_kind"), Declared: true, ContentType: &contentType, Explanation: "false"},
@@ -1303,10 +1247,13 @@ func TestRequirementsReportPreservesNativeFieldsAndMetadata(t *testing.T) {
if err := yaml.Unmarshal(output, &report); err != nil {
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)
}
if _, exists := report["version"]; exists {
t.Fatalf("requirements version emitted: %#v", report)
}
inputs, ok := report["inputs"].([]any)
if !ok || len(inputs) != 2 {
t.Fatalf("inputs = %#v", report["inputs"])

View File

@@ -24,7 +24,6 @@ type smokeTargetDTO struct {
BackendID string `yaml:"backend_id"`
ProfileID string `yaml:"profile_id"`
PromptID string `yaml:"prompt_id"`
PromptVersion *string `yaml:"version,omitempty"`
DefaultSourceBackendID string `yaml:"default_source_backend_id"`
SelectionSource string `yaml:"selection_source"`
Endpoint string `yaml:"endpoint"`
@@ -158,7 +157,6 @@ func smokeReportFromNative(report *promptkit.SmokeTestReport) *smokeReportDTO {
BackendID: target.BackendID,
ProfileID: target.ProfileID,
PromptID: target.PromptID,
PromptVersion: target.PromptVersion,
DefaultSourceBackendID: target.DefaultSourceBackendID,
SelectionSource: target.SelectionSource,
Endpoint: target.Endpoint,

View File

@@ -16,7 +16,6 @@ func TestSmokeReportYAMLProjectsNativeFieldsAndPresence(t *testing.T) {
textReturned := false
zero := time.Duration(0)
retryDelay := 1500 * time.Millisecond
version := ""
httpStatus := 201
started := time.Date(2026, time.October, 17, 12, 30, 0, 0, time.UTC)
report := &promptkit.SmokeTestReport{
@@ -29,7 +28,6 @@ func TestSmokeReportYAMLProjectsNativeFieldsAndPresence(t *testing.T) {
BackendID: "local",
ProfileID: "default",
PromptID: "team/briefing",
PromptVersion: &version,
DefaultSourceBackendID: "fallback",
SelectionSource: "prompt",
Endpoint: "https://example.invalid/v1",
@@ -98,9 +96,12 @@ func TestSmokeReportYAMLProjectsNativeFieldsAndPresence(t *testing.T) {
t.Fatalf("report scalar values = %#v", document)
}
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)
}
if _, exists := target["version"]; exists {
t.Fatalf("target version emitted: %#v", target)
}
settings := target["effective_settings"].(map[string]any)
if settings["model"] != "example-model" || settings["temperature"] != 0 || settings["api_key_env"] != "PROMPTKIT_KEY" {
t.Fatalf("effective settings = %#v", settings)