Clarify usage reporting boundaries and core API design checkpoint

This commit is contained in:
2026-11-22 20:00:43 +00:00
parent d9df7e2d6b
commit e2ffe82324

View File

@@ -51,9 +51,16 @@ when requested.
For an enabled invocation, ckprompt will create one native PromptKit
`ExecutionGroup` and attach its observer through `WithExecutionObserver` to the
invocation context. This will happen after successful input/preflight validation
and before execution-time initialization, acquisition callbacks, and the handler.
PromptKit work during acquisition will therefore participate alongside handler
work.
through `CheckInput` and before the selected command's `Run` callback. Integration
state initialization and acquisition within `Run` will therefore participate
alongside application handler work. Input construction and `CheckInput` remain
outside observation.
Validation performed inside an application handler is execution for this
purpose. A failure there will still produce the requested summary; core does not
identify or move arbitrary application validation. The composition hook must
respect the `CheckInput`/`Run` boundary rather than wrap the entire prepared
execution, which currently includes `CheckInput`.
Calls using that context will participate through PromptKit's public observation
boundaries, including nested and concurrent calls, multiple engines, prepared
@@ -101,17 +108,19 @@ The summary will present native invocation totals with the following detail:
| Content | Presentation |
| --- | --- |
| Prompts | Total number of prompts, using the native group's observed run count. |
| Prompts | Number of observed prompt executions, using the native group's observed run count. |
| Repair calls | A detail beneath the prompt total, shown only when nonzero. |
| Tokens | Aggregate prompt, completion, and total tokens, with reasoning, cached, and cache-write tokens as details. |
| Cache-hit ratio | The native `Usage.CacheHitRatio()` result when available, displayed as a percentage with one decimal place. |
| Cost | Available USD cost with its native source, displayed with six significant digits. |
| Availability and completeness | Clear indications of unknown values, incomplete subtotals, and incomplete terminal coverage. |
Attempts and transient retries will not be separate display counts or additional
prompts. Reasoning and cache figures will not be added to total tokens. Cache-hit
ratio will use the native aggregate helper rather than an average of per-run
ratios or an independently derived value.
The prompt count measures executions, not distinct prompt definitions or provider
requests. Repeated execution of one prompt increases the count; transient retries
and repairs within an execution do not. Attempts and transient retries will not
be separate display counts. Reasoning and cache figures will not be added to
total tokens. Cache-hit ratio will use the native aggregate helper rather than
an average of per-run ratios or an independently derived value.
Cost will appear automatically when available, without a separate accounting
opt-in. Preserve provider/injected-client reports, configured-zero evidence,
@@ -128,6 +137,12 @@ usage will retain their unknown state rather than being converted to zeros.
Known zeros, incomplete subtotals, and terminal coverage will retain their
distinct meanings after failures as well as successes.
Label the summary as usage from observed PromptKit executions. For smoke
commands, state that smoke-test usage is reported separately in the command's
main report. Retain the standard empty-group summary when no ordinary executions
were observed; its zeros must not be presented as measured smoke-test usage or
cost.
## Upstream and Current Baseline
The target dependency is `go.maximumdirect.net/promptkit v0.25.0`, released at
@@ -168,6 +183,22 @@ not verification of the unimplemented usage feature.
## Required Work
### Core API design checkpoint
The first design checkpoint in the subsequent implementation plan will present
a small proposed public core API and a short ckprompt wiring example before
committing to the abstraction. Demonstrate captured invocation-wide flags,
context decoration at the `CheckInput`/`Run` boundary, and final presentation
through the existing reporter. Show how both ordinary installation paths support
application commands registered before and after ckprompt without application
accounting callbacks.
Start with a per-invocation closure retaining integration-owned state, such as
the execution group, and assess whether it satisfies these needs directly. Avoid
introducing a public state registry, lifecycle object hierarchy, or configurable
middleware framework for this feature. Exact Go declarations and internal
factoring remain work for that checkpoint; this roadmap does not select them.
### Core composition and reporting
Add the narrow, library-neutral public composition capability needed to capture
@@ -175,7 +206,14 @@ invocation-wide flags, decorate context at the selected execution boundary,
retain private invocation state, and submit final presentation before reporting
closes. Include the generic reporting support needed for requested summaries to
be visible in ordinary mode; ordinary Info messages are hidden without verbose
mode and cannot provide the selected behavior alone.
mode and cannot provide the selected behavior alone. Reuse the existing `Report`
handoff, text templates, rendering, and presentation-failure handling for
requested diagnostic reports. Keep existing Info visibility and Progress
controls unchanged; neither provides the requested summary's visibility policy.
Use the existing reporter finalization sequence to deliver the summary after
deferred messages and before terminal explanations. Core owns this timing and
delivery; ckprompt supplies the content and template.
Validate captured flags and lifecycle behavior with the installation batch so a
failed registration leaves no partial installation. Apply the capability to
@@ -263,9 +301,11 @@ failure or cancellation. Verify preserved application outcomes and supported
error identity.
Verify help, completion, version, and routing/parsing/preflight failures without
usage summaries or acquisition for reporting. Verify explicit-observer
coexistence, smoke reasoning and ratio adaptation, and preservation of explicit
provider/zero-cost inspection evidence.
usage summaries or acquisition for reporting. Distinguish failed `CheckInput`
from validation failures returned inside `Run`, which retain the requested
summary. Verify explicit-observer coexistence, smoke reasoning and ratio
adaptation, clear separation of smoke usage from ordinary execution summaries,
and preservation of explicit provider/zero-cost inspection evidence.
Keep checks offline and test CommandKit-owned integration behavior. A real
upstream engine can support representative consumer evidence; PromptKit retains