Move native debug accounting into the CLI capture lifecycle

This commit is contained in:
2026-11-23 02:35:19 +00:00
parent 051a91e397
commit 88ebdbd819
5 changed files with 64 additions and 58 deletions

View File

@@ -58,7 +58,8 @@ func TestRunnerCapturesActualArtifactsAndNoExecutionOnReuse(t *testing.T) {
for _, reuse := range []bool{false, true} {
evidence := &nativeEvidence{}
var group promptkit.ExecutionGroup
output, err := New().Run(context.Background(), RunInput{Prepared: prepared, RawInput: []byte("input"), Cache: store, Debug: evidence, Executions: &group, Workers: 1})
ctx := promptkit.WithExecutionObserver(context.Background(), group.Observe)
output, err := New().Run(ctx, RunInput{Prepared: prepared, RawInput: []byte("input"), Cache: store, Debug: evidence, Workers: 1})
if err != nil || output.FallbackCount != 0 || calls != 1 {
t.Fatalf("run: %#v %v, calls=%d", output, err, calls)
}
@@ -82,10 +83,10 @@ func TestRunnerCapturesActualArtifactsAndNoExecutionOnReuse(t *testing.T) {
if reuse && nativeEvidenceCount(evidence, "/cache/hit-artifact.json") != 1 {
t.Fatal("reused artifact bytes not retained")
}
var snapshot promptkit.ExecutionGroupSummary
if err := json.Unmarshal(evidence.files["executions.json"], &snapshot); err != nil {
t.Fatal(err)
if _, ok := evidence.files["executions.json"]; ok {
t.Fatal("runner wrote a consumer-owned execution summary")
}
snapshot := group.Snapshot()
if len(snapshot.Members) != map[bool]int{false: 1, true: 0}[reuse] || !snapshot.TerminalCoverageComplete {
t.Fatalf("incorrect current-run totals: %#v", snapshot)
}

View File

@@ -4,7 +4,6 @@ import (
"context"
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"mime"
"path"
@@ -16,7 +15,6 @@ import (
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
"gitea.maximumdirect.net/eric/notarius/internal/framework/chunkmap"
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
"go.maximumdirect.net/promptkit"
)
type Registries struct {
@@ -47,18 +45,15 @@ type RunInput struct {
// on a hit. Shared observers must synchronize concurrent calls.
ObserveCache func(context.Context, contracts.DiagnosticOrigin, contracts.CacheObservation) error
Execution contracts.ExecutionOptions
// Executions is the invocation's native group. The runner enrolls its
// requests; callers may use Snapshot without maintaining copied totals.
Executions *promptkit.ExecutionGroup
Prepared *PreparedPipeline
SourceID string
Path string
RawInput []byte
SessionID string
RunID string
StartedAt time.Time
Metadata map[string]any
Diagnostics []contracts.ProducerDiagnostic
Prepared *PreparedPipeline
SourceID string
Path string
RawInput []byte
SessionID string
RunID string
StartedAt time.Time
Metadata map[string]any
Diagnostics []contracts.ProducerDiagnostic
Debug DebugRecorder
// Workers bounds ready extraction and lane-completion jobs together.
@@ -115,18 +110,6 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
}
debugRecorder = synchronizedDebugRecorder(debugRecorder)
input.Debug = debugRecorder
if input.Executions == nil {
input.Executions = &promptkit.ExecutionGroup{}
}
input.Execution.Observer = promptkit.ComposeObservers(input.Execution.Observer, input.Executions.Observe)
defer func() {
if debugRecorder.Enabled() {
if captureErr := debugRecorder.WriteJSON("executions.json", input.Executions.Snapshot()); captureErr != nil {
err = errors.Join(err, &contracts.CaptureError{Cause: captureErr})
output = failOutput(output)
}
}
}()
inputDiagnostics, diagnosticErr := promoteProducerDiagnostics(input.Diagnostics, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageReferences}, nil)
if diagnosticErr != nil {
return failOutput(output), fmt.Errorf("promote input diagnostics: %w", diagnosticErr)