Remove prompt version selectors
This commit is contained in:
@@ -12,23 +12,20 @@ import (
|
||||
)
|
||||
|
||||
type requirementInspectionPromptRepository struct {
|
||||
definition *domain.PromptDefinition
|
||||
snapshot prompt.RequirementSnapshot
|
||||
lookupErr error
|
||||
snapshotFound bool
|
||||
lookupCalls int
|
||||
snapshotCalls int
|
||||
lookupID string
|
||||
lookupVersion string
|
||||
snapshotID string
|
||||
snapshotVersion string
|
||||
definition *domain.PromptDefinition
|
||||
snapshot prompt.RequirementSnapshot
|
||||
lookupErr error
|
||||
snapshotFound bool
|
||||
lookupCalls int
|
||||
snapshotCalls int
|
||||
lookupID string
|
||||
snapshotID string
|
||||
}
|
||||
|
||||
type requirementPromptMetadataRepository struct {
|
||||
*requirementInspectionPromptRepository
|
||||
inspection domain.PromptInspection
|
||||
lookupID string
|
||||
lookupVersion string
|
||||
inspection domain.PromptInspection
|
||||
lookupID string
|
||||
}
|
||||
|
||||
type inspectionProfileIdentityRepository struct {
|
||||
@@ -51,7 +48,6 @@ func (repository *inspectionProfileIdentityRepository) GetProfileIdentity(
|
||||
func (repository *requirementInspectionPromptRepository) GetPromptDefinition(
|
||||
context.Context,
|
||||
string,
|
||||
string,
|
||||
) (*domain.PromptDefinition, error) {
|
||||
return repository.definition, repository.lookupErr
|
||||
}
|
||||
@@ -59,10 +55,8 @@ func (repository *requirementInspectionPromptRepository) GetPromptDefinition(
|
||||
func (repository *requirementPromptMetadataRepository) GetPromptInspection(
|
||||
_ context.Context,
|
||||
id string,
|
||||
version string,
|
||||
) (*domain.PromptInspection, error) {
|
||||
repository.lookupID = id
|
||||
repository.lookupVersion = version
|
||||
inspection := repository.inspection
|
||||
inspection.Inputs = append([]domain.PromptInput(nil), inspection.Inputs...)
|
||||
return &inspection, nil
|
||||
@@ -71,21 +65,17 @@ func (repository *requirementPromptMetadataRepository) GetPromptInspection(
|
||||
func (repository *requirementInspectionPromptRepository) GetPromptSnapshot(
|
||||
_ context.Context,
|
||||
id string,
|
||||
version string,
|
||||
) (*domain.PromptDefinition, string, error) {
|
||||
repository.lookupCalls++
|
||||
repository.lookupID = id
|
||||
repository.lookupVersion = version
|
||||
return repository.definition, "captured-hash", repository.lookupErr
|
||||
}
|
||||
|
||||
func (repository *requirementInspectionPromptRepository) GetRequirementSnapshot(
|
||||
id string,
|
||||
version string,
|
||||
) (prompt.RequirementSnapshot, bool) {
|
||||
repository.snapshotCalls++
|
||||
repository.snapshotID = id
|
||||
repository.snapshotVersion = version
|
||||
return repository.snapshot, repository.snapshotFound
|
||||
}
|
||||
|
||||
@@ -111,16 +101,16 @@ func TestRunnerInspectRequirementsUsesCapturedSelectionWithoutExecutionWork(t *t
|
||||
}}
|
||||
runner := &Runner{promptDefs: repository, profiles: profiles}
|
||||
inspection, err := runner.InspectRequirements(context.Background(), RequirementInspectionRequest{
|
||||
PromptID: " requested ", PromptVersion: " exact-version ", ProfileID: "partial-profile",
|
||||
PromptID: " requested ", ProfileID: "partial-profile",
|
||||
Vars: map[string]string{"caller": ""}, SessionID: " direct-session ",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("inspect requirements: %v", err)
|
||||
}
|
||||
if repository.lookupCalls != 1 || repository.lookupID != " requested " || repository.lookupVersion != " exact-version " ||
|
||||
repository.snapshotCalls != 1 || repository.snapshotID != definition.ID || repository.snapshotVersion != definition.Version {
|
||||
t.Fatalf("selection lookup=(%d,%q,%q), snapshot=(%d,%q,%q)", repository.lookupCalls, repository.lookupID,
|
||||
repository.lookupVersion, repository.snapshotCalls, repository.snapshotID, repository.snapshotVersion)
|
||||
if repository.lookupCalls != 1 || repository.lookupID != " requested " ||
|
||||
repository.snapshotCalls != 1 || repository.snapshotID != definition.ID {
|
||||
t.Fatalf("selection lookup=(%d,%q), snapshot=(%d,%q)", repository.lookupCalls, repository.lookupID,
|
||||
repository.snapshotCalls, repository.snapshotID)
|
||||
}
|
||||
if profiles.calls != 1 || profiles.id != "partial-profile" || inspection.PromptID != definition.ID ||
|
||||
inspection.PromptVersion != definition.Version || inspection.ProfileID != "partial-profile" || !inspection.Complete ||
|
||||
@@ -158,19 +148,18 @@ func TestRunnerInspectRequirementsUsesPromptMetadataAndExactRequirementSnapshot(
|
||||
}
|
||||
inspection, err := (&Runner{promptDefs: promptRepository, profiles: profiles}).InspectRequirements(
|
||||
context.Background(), RequirementInspectionRequest{
|
||||
PromptID: " requested-id ", PromptVersion: " requested-version ",
|
||||
Vars: map[string]string{"caller": "Ada"}, SessionID: " direct-session ",
|
||||
PromptID: " requested-id ",
|
||||
Vars: map[string]string{"caller": "Ada"}, SessionID: " direct-session ",
|
||||
},
|
||||
)
|
||||
if err != nil || promptRepository.lookupID != " requested-id " || promptRepository.lookupVersion != " requested-version " ||
|
||||
baseRepository.snapshotID != "captured-id" || baseRepository.snapshotVersion != "captured-version" ||
|
||||
if err != nil || promptRepository.lookupID != " requested-id " ||
|
||||
baseRepository.snapshotID != "captured-id" ||
|
||||
profiles.identityID != "default-profile" || inspection.PromptID != "captured-id" ||
|
||||
inspection.PromptVersion != "captured-version" || inspection.ProfileID != "default-profile" ||
|
||||
!inspection.Complete || len(inspection.Inputs) != 1 || inspection.Inputs[0].Name != "message-input" ||
|
||||
len(inspection.Variables) != 1 || inspection.Variables[0].Name != "caller" || !inspection.Variables[0].Supplied {
|
||||
t.Fatalf("metadata-based requirement inspection=(%+v, %v), prompt lookup=(%q,%q), snapshot=(%q,%q), profile=%q",
|
||||
inspection, err, promptRepository.lookupID, promptRepository.lookupVersion,
|
||||
baseRepository.snapshotID, baseRepository.snapshotVersion, profiles.identityID)
|
||||
t.Fatalf("metadata-based requirement inspection=(%+v, %v), prompt lookup=%q, snapshot=%q, profile=%q",
|
||||
inspection, err, promptRepository.lookupID, baseRepository.snapshotID, profiles.identityID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,12 +311,12 @@ func TestRunnerInspectRequirementsClassifiesSelectionAndSnapshotFailures(t *test
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("ambiguous prompt selection", func(t *testing.T) {
|
||||
ambiguous := errors.New("ambiguous omitted version")
|
||||
repository := &requirementInspectionPromptRepository{lookupErr: ambiguous}
|
||||
t.Run("prompt lookup failure", func(t *testing.T) {
|
||||
lookupFailure := errors.New("prompt lookup failed")
|
||||
repository := &requirementInspectionPromptRepository{lookupErr: lookupFailure}
|
||||
_, err := (&Runner{promptDefs: repository}).InspectRequirements(context.Background(), RequirementInspectionRequest{PromptID: "selected"})
|
||||
if !errors.Is(err, ErrPromptLoad) || !errors.Is(err, ambiguous) || repository.lookupVersion != "" {
|
||||
t.Fatalf("ambiguous selection error=%v version=%q", err, repository.lookupVersion)
|
||||
if !errors.Is(err, ErrPromptLoad) || !errors.Is(err, lookupFailure) {
|
||||
t.Fatalf("prompt lookup error=%v", err)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user