From 0d5e13c7a960182fa61192ed8b04d1dfd4522f5e Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Sun, 22 Nov 2026 20:58:10 +0000 Subject: [PATCH] Adopt PromptKit usage and backend evidence --- docs/roadmap/implementation.md | 6 +++ integrations/ckprompt/README.md | 7 +++ integrations/ckprompt/docs/oss/attribution.md | 6 +-- integrations/ckprompt/go.mod | 2 +- integrations/ckprompt/go.sum | 2 + .../ckprompt/resource_inspection_test.go | 3 +- integrations/ckprompt/smoke_command.go | 4 +- integrations/ckprompt/smoke_report.go | 28 ++++++++++ integrations/ckprompt/smoke_report_test.go | 52 +++++++++++++++++++ 9 files changed, 103 insertions(+), 7 deletions(-) diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index 8771ca1..cd49e34 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -264,6 +264,12 @@ part of this work. ## Stage 5: Adopt PromptKit v0.25.0 and preserve existing report evidence +**Complete.** Selected the published module and checked its license notice; +ckprompt forwards provider and explicit false zero-cost inspection data. Smoke +projection/render tests cover reasoning, absent and zero ratios, percentages, +and retained single/aggregate evidence in text, YAML, and JSON. The affected +Go 1.27.4 workspace suite passes. + 1. Select the published PromptKit v0.25.0 in ckprompt's module files; use no sibling replacement. Preserve ConfigKit v1.4.0 and unrelated dependency selections. Check the selected upstream notices and update the PromptKit attribution entry diff --git a/integrations/ckprompt/README.md b/integrations/ckprompt/README.md index 4014d0c..0b8409d 100644 --- a/integrations/ckprompt/README.md +++ b/integrations/ckprompt/README.md @@ -41,3 +41,10 @@ This module is licensed under the [GNU Lesser General Public License v3.0 or later](COPYRIGHT). The accompanying [LICENSE](LICENSE) contains the full LGPL v3 and GPL v3 texts. See [third-party attribution](docs/oss/attribution.md) for incorporated and dependency notices. + +Smoke-test reports default to text; use `--format yaml` or `--format json` for +structured output. Reports preserve native reasoning-token and cache-hit evidence. +Backend provider conventions are selected explicitly in PromptKit configuration; +for example, application-defined OpenRouter backends need `provider: openrouter`. +See the [PromptKit backend format](https://forge.maximumdirect.net/base-layer/promptkit/src/tag/v0.25.0/docs/formats.md#backend-definitions) +for provider and zero-cost settings. diff --git a/integrations/ckprompt/docs/oss/attribution.md b/integrations/ckprompt/docs/oss/attribution.md index 8882f63..6e7b32e 100644 --- a/integrations/ckprompt/docs/oss/attribution.md +++ b/integrations/ckprompt/docs/oss/attribution.md @@ -2,16 +2,16 @@ ## PromptKit -Selected module: `go.maximumdirect.net/promptkit` at `v0.24.0`. +Selected module: `go.maximumdirect.net/promptkit` at `v0.25.0`. Copyright (C) 2026 Eric Rakestraw SPDX-License-Identifier: LGPL-3.0-or-later License and notices: [LGPL v3.0](../../LICENSE) | -[LICENSE](https://forge.maximumdirect.net/base-layer/promptkit/src/commit/5ea60e9b96651fd7dfcbc7d05b6f43d131df358f/LICENSE). +[LICENSE](https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d/LICENSE). -[Source](https://forge.maximumdirect.net/base-layer/promptkit/src/commit/5ea60e9b96651fd7dfcbc7d05b6f43d131df358f). +[Source](https://forge.maximumdirect.net/base-layer/promptkit/src/commit/207677e9948dc5699073a4d6620d21139033c72d). ## ConfigKit diff --git a/integrations/ckprompt/go.mod b/integrations/ckprompt/go.mod index 0fe85d1..2498391 100644 --- a/integrations/ckprompt/go.mod +++ b/integrations/ckprompt/go.mod @@ -6,7 +6,7 @@ require ( go.maximumdirect.net/ckconfig v0.10.0 go.maximumdirect.net/commandkit v0.7.0 go.maximumdirect.net/configkit v1.4.0 - go.maximumdirect.net/promptkit v0.24.0 + go.maximumdirect.net/promptkit v0.25.0 go.yaml.in/yaml/v4 v4.0.0 ) diff --git a/integrations/ckprompt/go.sum b/integrations/ckprompt/go.sum index 8eeb1e7..9d5de5f 100644 --- a/integrations/ckprompt/go.sum +++ b/integrations/ckprompt/go.sum @@ -19,6 +19,8 @@ go.maximumdirect.net/configkit v1.4.0 h1:TfOupZbQ23/ZMs+xt5lmyukCF11ekqKep8KbmFQ go.maximumdirect.net/configkit v1.4.0/go.mod h1:ewu6blSokUDCMovy8JBXAdXRikGmlHXAQpFghnPWRfs= go.maximumdirect.net/promptkit v0.24.0 h1:C6UFY8WgW10PIEuXQN2Z0qi0at5mD3/GQoPul6alYHo= go.maximumdirect.net/promptkit v0.24.0/go.mod h1:o2axdkV11KTPDgk81i2vrJ66dtcedXRhau/Ko3YSZ4A= +go.maximumdirect.net/promptkit v0.25.0 h1:vJOfxauwASllOSDceR2oypJ4NEwIh2s6F8dDexEzdM8= +go.maximumdirect.net/promptkit v0.25.0/go.mod h1:o2axdkV11KTPDgk81i2vrJ66dtcedXRhau/Ko3YSZ4A= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw= go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0= diff --git a/integrations/ckprompt/resource_inspection_test.go b/integrations/ckprompt/resource_inspection_test.go index a3d5588..5ccbe0c 100644 --- a/integrations/ckprompt/resource_inspection_test.go +++ b/integrations/ckprompt/resource_inspection_test.go @@ -38,7 +38,8 @@ func TestResourceInspectionsForwardNativeReports(t *testing.T) { extra := map[string]any{} prompt := &promptkit.PromptInspection{PromptID: "p", PromptHash: "hash", Description: &empty, Inputs: &inputs, Messages: []promptkit.PromptMessageInspection{{Role: "user", Content: "captured {{.topic}}"}}} profile := &promptkit.ProfileInspection{ProfileID: "p", Temperature: nil, MaxTokens: &zero, APIKeyRequired: &no, ExtraParams: &extra} - backend := &promptkit.BackendInspection{BackendID: "b", Endpoint: "https://example.invalid", QueueCapacity: &zero, ExtraParams: &extra} + provider := "vllm" + backend := &promptkit.BackendInspection{BackendID: "b", Provider: &provider, ZeroCost: &no, Endpoint: "https://example.invalid", QueueCapacity: &zero, ExtraParams: &extra} var selections []ckconfig.Selection calls := 0 suite := Suite[struct{}, struct{}]{ diff --git a/integrations/ckprompt/smoke_command.go b/integrations/ckprompt/smoke_command.go index 1eca8d0..936b798 100644 --- a/integrations/ckprompt/smoke_command.go +++ b/integrations/ckprompt/smoke_command.go @@ -121,7 +121,7 @@ func runSmokeTest[I, S any](invocation commandkit.Invocation, suite Suite[I, S], return definitionFailure(invocation.Context, smokeFailureMessage(input.kind), acquired.Explanation, operationErr) } - _ = invocation.Reporter().Report(commandkit.Report{Value: smokeReportFromNative(acquired.Value)}) + _ = invocation.Reporter().Report(commandkit.Report{Value: smokeReportFromNative(acquired.Value), TextTemplate: smokeTextTemplate}) if operationErr != nil { return definitionFailure(invocation.Context, smokeFailureMessage(input.kind), acquired.Explanation, operationErr) } @@ -184,7 +184,7 @@ func runSmokeAggregate[I, S any](invocation commandkit.Invocation, suite Suite[I if len(results) == 0 { return definitionFailure(invocation.Context, "PromptKit aggregate smoke testing did not produce any results.", combineSmokeExplanations(explanations), errors.Join(operationErrors...)) } - _ = invocation.Reporter().Report(commandkit.Report{Value: smokeResultsReport(results)}) + _ = invocation.Reporter().Report(commandkit.Report{Value: smokeResultsReport(results), TextTemplate: smokeAggregateTextTemplate}) if len(operationErrors) > 0 { return definitionFailure(invocation.Context, "One or more PromptKit smoke tests failed.", combineSmokeExplanations(explanations), errors.Join(operationErrors...)) } diff --git a/integrations/ckprompt/smoke_report.go b/integrations/ckprompt/smoke_report.go index cab2b37..f20ab87 100644 --- a/integrations/ckprompt/smoke_report.go +++ b/integrations/ckprompt/smoke_report.go @@ -1,6 +1,10 @@ package ckprompt import ( + "bytes" + "text/template" + + commandkit "go.maximumdirect.net/commandkit" "time" promptkit "go.maximumdirect.net/promptkit" @@ -88,6 +92,8 @@ type smokeAttemptDTO struct { type smokeUsageDTO struct { PromptTokens smokeTokenCount `json:"prompt_tokens"` CompletionTokens smokeTokenCount `json:"completion_tokens"` + ReasoningTokens smokeTokenCount `json:"reasoning_tokens"` + CacheHitRatio *float64 `json:"cache_hit_ratio"` TotalTokens smokeTokenCount `json:"total_tokens"` CachedTokens smokeTokenCount `json:"cached_tokens"` CacheWriteTokens smokeTokenCount `json:"cache_write_tokens"` @@ -222,11 +228,33 @@ func durationString(duration *time.Duration) *string { } func smokeUsageFromNative(usage promptkit.ObservedTokenUsage) smokeUsageDTO { + var ratio *float64 + if value, ok := usage.CacheHitRatio(); ok { + ratio = &value + } return smokeUsageDTO{ PromptTokens: smokeTokenCount(usage.PromptTokens), CompletionTokens: smokeTokenCount(usage.CompletionTokens), + ReasoningTokens: smokeTokenCount(usage.ReasoningTokens), + CacheHitRatio: ratio, TotalTokens: smokeTokenCount(usage.TotalTokens), CachedTokens: smokeTokenCount(usage.CachedTokens), CacheWriteTokens: smokeTokenCount(usage.CacheWriteTokens), } } + +// The text view retains the full structured evidence and adds readable ratios. +var smokeTemplateFuncs = template.FuncMap{ + "smokeEvidence": func(value any) (string, error) { + var b bytes.Buffer + err := commandkit.RenderReport(&b, commandkit.Report{Value: value}, commandkit.FormatYAML) + return b.String(), err + }, + "percent": func(value *float64) float64 { return *value * 100 }, +} +var smokeTextTemplate = template.Must(commandkit.ParseTextTemplate("smoke", `{{smokeEvidence .}}{{with .Usage.CacheHitRatio}}# Cache hit ratio: {{printf "%.1f" (percent .)}}% +{{end}}{{range $index, $attempt := .Attempts}}{{with $attempt.Usage.CacheHitRatio}}# Attempt {{$index}} cache hit ratio: {{printf "%.1f" (percent .)}}% +{{end}}{{end}}`, smokeTemplateFuncs)) +var smokeAggregateTextTemplate = template.Must(commandkit.ParseTextTemplate("smoke aggregate", `{{smokeEvidence .}}{{range .Tests}}{{with .Report}}{{with .Usage.CacheHitRatio}}# Cache hit ratio: {{printf "%.1f" (percent .)}}% +{{end}}{{range $index, $attempt := .Attempts}}{{with $attempt.Usage.CacheHitRatio}}# Attempt {{$index}} cache hit ratio: {{printf "%.1f" (percent .)}}% +{{end}}{{end}}{{end}}{{end}}`, smokeTemplateFuncs)) diff --git a/integrations/ckprompt/smoke_report_test.go b/integrations/ckprompt/smoke_report_test.go index fbf8730..135c05a 100644 --- a/integrations/ckprompt/smoke_report_test.go +++ b/integrations/ckprompt/smoke_report_test.go @@ -1,8 +1,12 @@ package ckprompt import ( + "bytes" "errors" + commandkit "go.maximumdirect.net/commandkit" + "strings" "testing" + "text/template" "time" promptkit "go.maximumdirect.net/promptkit" @@ -215,3 +219,51 @@ func containsSmokeKey(value any, want string) bool { } return false } + +func TestSmokeUsageReasoningAndCacheRatioRepresentations(t *testing.T) { + known := func(n int) promptkit.ObservedTokenCount { + return promptkit.ObservedTokenCount{Value: n, Known: true, Complete: true} + } + usage := promptkit.ObservedTokenUsage{PromptTokens: known(8), CachedTokens: known(1), ReasoningTokens: known(3)} + projected := smokeUsageFromNative(usage) + if projected.CacheHitRatio == nil || *projected.CacheHitRatio != 0.125 || projected.ReasoningTokens.Value != 3 { + t.Fatalf("usage=%#v", projected) + } + usage.CachedTokens = known(0) + zero := smokeUsageFromNative(usage) + if zero.CacheHitRatio == nil || *zero.CacheHitRatio != 0 { + t.Fatalf("zero ratio=%#v", zero) + } + usage.PromptTokens = promptkit.ObservedTokenCount{} + if smokeUsageFromNative(usage).CacheHitRatio != nil { + t.Fatal("unknown ratio is present") + } + report := smokeReportDTO{Kind: promptkit.SmokeTestAuthentication, Supported: true, Usage: projected, Attempts: []smokeAttemptDTO{{Usage: zero}}} + for _, tc := range []struct { + name string + value any + tmpl *template.Template + }{ + {"single", report, smokeTextTemplate}, + {"aggregate", smokeAggregateDTO{Tests: []smokeResultDTO{{Kind: promptkit.SmokeTestAuthentication, Report: &report}}}, smokeAggregateTextTemplate}, + } { + t.Run(tc.name, func(t *testing.T) { + for _, format := range []commandkit.Format{commandkit.FormatText, commandkit.FormatYAML, commandkit.FormatJSON} { + var out bytes.Buffer + if err := commandkit.RenderReport(&out, commandkit.Report{Value: tc.value, TextTemplate: tc.tmpl}, format); err != nil { + t.Fatal(err) + } + text := out.String() + if !strings.Contains(text, "reasoning_tokens") || !strings.Contains(text, "cache_hit_ratio") || !strings.Contains(text, "attempts") || !strings.Contains(text, "supported") { + t.Fatalf("missing evidence: %s", text) + } + if format == commandkit.FormatText && (!strings.Contains(text, "12.5%") || !strings.Contains(text, "0.0%")) { + t.Fatalf("ratios: %s", text) + } + if format != commandkit.FormatText && !strings.Contains(text, "0.125") { + t.Fatalf("raw ratio: %s", text) + } + } + }) + } +}