Keep raw runtime parameters out of early capture

This commit is contained in:
2026-11-28 16:12:52 +00:00
parent 63cdd7a7c5
commit 95d46c7da3
6 changed files with 127 additions and 3 deletions

View File

@@ -7,6 +7,7 @@ import (
"slices"
"strconv"
"strings"
"time"
"gitea.maximumdirect.net/eric/notarius/internal/core/config"
frameworkdebug "gitea.maximumdirect.net/eric/notarius/internal/framework/debug"
@@ -15,6 +16,30 @@ import (
"go.maximumdirect.net/promptkit"
)
// Target-aware native evidence retains effective parameters with their secret
// marks. Early context records presence only, before a target is available.
func captureInvocationContext(recorder *frameworkdebug.Recorder, input pipelineRunInput, version, runID string, startedAt time.Time) error {
if !recorder.Enabled() {
return nil
}
execution := input.Overrides.Execution
extraParamsSupplied := false
if execution.Execution != nil {
extraParamsSupplied = execution.Execution.ExtraParams != nil
execution.Execution = captureExecutionOverride(execution.Execution)
}
return recorder.WriteJSON("context.json", map[string]any{"application_version": version, "pipeline": input.PipelineID, "input_path": input.InputFile.Value, "run_id": runID, "started_at": startedAt, "lanes": input.Lanes, "references": input.References, "unbinds": input.Unbinds, "resources": input.Overrides.Resources, "execution_overrides": execution, "extra_params_supplied": extraParamsSupplied})
}
func captureExecutionOverride(execution *promptkit.ExecutionTargetOverride) *promptkit.ExecutionTargetOverride {
if execution == nil {
return nil
}
copy := *execution
copy.ExtraParams = nil
return &copy
}
// captureRunConfiguration inspects the original, frozen application load. It
// neither reloads resources nor serializes typed settings containing credentials.
// Shared loaders remain independent of run storage.
@@ -107,6 +132,9 @@ func newRunEvidenceRecorder(recorder *frameworkdebug.Recorder, result *configkit
func (writer *runEvidenceRecorder) WriteJSON(name string, payload any) error {
switch value := payload.(type) {
case promptkit.RunRequest:
value.Execution = captureExecutionOverride(value.Execution)
payload = value
case *promptkit.PreparedRun:
copy := *value
copy.EffectiveModelParams = writer.target(copy.EffectiveModelParams, copy.SelectedProfileID, copy.SelectedBackendID)