Migrate HTTP and process fixtures without changing wire formats
This commit is contained in:
@@ -68,7 +68,7 @@ func TestProcessSignalCancellation(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
config := filepath.Join(root, "app.yml")
|
config := filepath.Join(root, "app.yml")
|
||||||
if err := os.WriteFile(config, []byte(fmt.Sprintf("promptkit:\n configuration: %q\ntransient_retries: 0\n", framework)), 0600); err != nil {
|
if err := os.WriteFile(config, []byte("config: {imports: [{path: framework.yml, destination: [promptkit]}]}\ntransient_retries: 0\n"), 0600); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
executable, err := os.Executable()
|
executable, err := os.Executable()
|
||||||
|
|||||||
@@ -440,6 +440,13 @@ installed through ckprompt, not reimplemented to satisfy these tests.
|
|||||||
|
|
||||||
## Stage 8 — Migrate HTTP, Report, And Process Fixtures Without Wire Expansion
|
## Stage 8 — Migrate HTTP, Report, And Process Fixtures Without Wire Expansion
|
||||||
|
|
||||||
|
**Status: Complete.** Mounted wrapperless HTTP/report fixtures at the native
|
||||||
|
settings path and migrated the signal-process fixture to shared imports. Added
|
||||||
|
checks that new native reasoning, cost, ratio, and hash fields do not expand
|
||||||
|
the existing HTTP/report projections. The HTTP, report, and entrypoint package
|
||||||
|
tests pass offline on Go 1.27.4, including existing capacity, cancellation,
|
||||||
|
artifact policy, and process-signal coverage. Production HTTP code is unchanged.
|
||||||
|
|
||||||
**Files:** `internal/adapter/http/*_test.go`, `internal/report/*_test.go`,
|
**Files:** `internal/adapter/http/*_test.go`, `internal/report/*_test.go`,
|
||||||
`cmd/scriptorium/*_test.go`, and test fixtures/helpers reached by those tests.
|
`cmd/scriptorium/*_test.go`, and test fixtures/helpers reached by those tests.
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ func TestHandlerExecutionReportOptInAndResultShapes(t *testing.T) {
|
|||||||
if req.Observer != nil {
|
if req.Observer != nil {
|
||||||
req.Observer(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "observed", Outcome: outcome, Failure: promptkit.ExecutionFailureNone, Attempts: 2})
|
req.Observer(promptkit.ExecutionEvent{Kind: promptkit.ExecutionFinished, RunID: "observed", Outcome: outcome, Failure: promptkit.ExecutionFailureNone, Attempts: 2})
|
||||||
}
|
}
|
||||||
return &promptkit.RunResult{Artifact: promptkit.Artifact{Body: []byte("body")}, Validation: promptkit.ValidationResult{Status: status}, Usage: promptkit.TokenUsage{PromptTokens: 7}}, nil
|
return &promptkit.RunResult{Artifact: promptkit.Artifact{Body: []byte("body")}, Validation: promptkit.ValidationResult{Status: status}, Usage: promptkit.TokenUsage{PromptTokens: 7, ReasoningTokens: 3}, CostUSD: promptkit.ObservedCost{Value: 0.25, Known: true}}, nil
|
||||||
})
|
})
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
NewHandler(runner).ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(tc.body)))
|
NewHandler(runner).ServeHTTP(w, httptest.NewRequest(http.MethodPost, "/v1/runs", strings.NewReader(tc.body)))
|
||||||
@@ -93,6 +93,9 @@ func TestHandlerExecutionReportOptInAndResultShapes(t *testing.T) {
|
|||||||
if response["metadata"].(map[string]any)["usage"].(map[string]any)["prompt_tokens"] != float64(7) {
|
if response["metadata"].(map[string]any)["usage"].(map[string]any)["prompt_tokens"] != float64(7) {
|
||||||
t.Fatalf("metadata usage changed: %#v", response["metadata"])
|
t.Fatalf("metadata usage changed: %#v", response["metadata"])
|
||||||
}
|
}
|
||||||
|
if strings.Contains(w.Body.String(), "reasoning_tokens") || strings.Contains(w.Body.String(), "cost_usd") || strings.Contains(w.Body.String(), "message_content_hash") {
|
||||||
|
t.Fatalf("unexpected expanded HTTP fields: %s", w.Body.String())
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1903,9 +1906,15 @@ func newHandlerEngineFromDirectories(t *testing.T, promptDir, profileDir string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("load profile inputs: %v", err)
|
t.Fatalf("load profile inputs: %v", err)
|
||||||
}
|
}
|
||||||
|
for index := range promptInputs {
|
||||||
|
promptInputs[index].Destination = configkit.Keys("promptkit")
|
||||||
|
}
|
||||||
|
for index := range profileInputs {
|
||||||
|
profileInputs[index].Destination = configkit.Keys("promptkit")
|
||||||
|
}
|
||||||
underlays := []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}}
|
underlays := []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}}
|
||||||
if backend != nil {
|
if backend != nil {
|
||||||
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{Source: promptkit.BackendSource("test backend", []promptkit.BackendConfig{*backend})}}})
|
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{promptkit.SettingsInput(promptkit.BackendSource("test backend", []promptkit.BackendConfig{*backend}))}})
|
||||||
}
|
}
|
||||||
|
|
||||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
|||||||
PromptTokens: promptkit.ObservedTokenCount{Value: 0, Known: true, Complete: true},
|
PromptTokens: promptkit.ObservedTokenCount{Value: 0, Known: true, Complete: true},
|
||||||
CompletionTokens: promptkit.ObservedTokenCount{Value: 0, Known: false, Complete: false},
|
CompletionTokens: promptkit.ObservedTokenCount{Value: 0, Known: false, Complete: false},
|
||||||
TotalTokens: promptkit.ObservedTokenCount{Value: 11, Known: true, Complete: false},
|
TotalTokens: promptkit.ObservedTokenCount{Value: 11, Known: true, Complete: false},
|
||||||
|
ReasoningTokens: promptkit.ObservedTokenCount{Value: 3, Known: true, Complete: true},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
collector.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionRetryDelay, Attempts: 50})
|
collector.Observe(promptkit.ExecutionEvent{Kind: promptkit.ExecutionRetryDelay, Attempts: 50})
|
||||||
@@ -70,6 +71,9 @@ func TestCollectorProjectsOnlyTerminalAggregates(t *testing.T) {
|
|||||||
t.Fatalf("report exposed %q: %s", forbidden, encoded)
|
t.Fatalf("report exposed %q: %s", forbidden, encoded)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if strings.Contains(string(encoded), "reasoning_tokens") || strings.Contains(string(encoded), "cost_usd") || strings.Contains(string(encoded), "cache_hit_ratio") {
|
||||||
|
t.Fatalf("unexpected report expansion: %s", encoded)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCollectorHandlesUnknownValuesAndKeepsInvocationsSeparate(t *testing.T) {
|
func TestCollectorHandlesUnknownValuesAndKeepsInvocationsSeparate(t *testing.T) {
|
||||||
@@ -129,6 +133,12 @@ func TestCollectorReceivesRealEngineTerminalEvent(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
for index := range promptInputs {
|
||||||
|
promptInputs[index].Destination = configkit.Keys("promptkit")
|
||||||
|
}
|
||||||
|
for index := range profileInputs {
|
||||||
|
profileInputs[index].Destination = configkit.Keys("promptkit")
|
||||||
|
}
|
||||||
engine, err := promptkit.NewEngine(promptkit.Config{
|
engine, err := promptkit.NewEngine(promptkit.Config{
|
||||||
Sources: promptkit.ConfigurationSources{Underlays: []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}}},
|
Sources: promptkit.ConfigurationSources{Underlays: []configkit.Underlay{{Inputs: promptInputs}, {Inputs: profileInputs}}},
|
||||||
}, promptkit.WithLLMClient(localClient{}))
|
}, promptkit.WithLLMClient(localClient{}))
|
||||||
|
|||||||
Reference in New Issue
Block a user