Share source evidence through the selected capture sink
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
# ADR-0024: Publish artifacts with native reports and debug evidence
|
||||
|
||||
**Status:** Accepted; the requirement for one native invocation ExecutionGroup is
|
||||
partially superseded by [ADR-0025](0025-use-consumer-owned-execution-observation.md).
|
||||
partially superseded by [ADR-0025](0025-use-consumer-owned-execution-observation.md),
|
||||
and whole-source evidence representation by [ADR-0027](0027-share-whole-source-capture-evidence.md).
|
||||
All other decisions remain accepted.
|
||||
**Date:** 2026-11-22
|
||||
|
||||
|
||||
39
docs/adr/0027-share-whole-source-capture-evidence.md
Normal file
39
docs/adr/0027-share-whole-source-capture-evidence.md
Normal file
@@ -0,0 +1,39 @@
|
||||
# ADR-0027: Share whole-source capture evidence
|
||||
|
||||
**Status:** Accepted
|
||||
**Date:** 2026-11-25
|
||||
|
||||
## Context
|
||||
|
||||
Requested evidence repeated the original input and complete parsed source in
|
||||
many operation records. This made larger bundles harder to navigate without
|
||||
improving the availability of chunk-level context or native request history.
|
||||
|
||||
## Decision
|
||||
|
||||
Record original input and validated parsed source once at logical bundle-root
|
||||
paths in the selected evidence sink. Operation and run records identify those
|
||||
records with explicitly labeled bundle-root references. An explicit execution
|
||||
writer takes precedence over an enabled debug recorder; shared records and their
|
||||
consumers use the same selected sink. Available evidence remains on failure.
|
||||
|
||||
Chunks, selections, references, incoming artifacts, and native prepared
|
||||
messages, responses, and exchanges remain directly readable. No symlinks,
|
||||
filesystem-root assumptions, or reconstruction tool are required. Requested
|
||||
capture remains required work; no sanitization, retention, or access-policy
|
||||
guarantee is added. This narrowly supersedes the whole-source duplication choice
|
||||
in [ADR-0024](0024-publish-artifacts-with-native-reports-and-debug-evidence.md).
|
||||
|
||||
## Alternatives considered
|
||||
|
||||
- Repeat the entire source in every operation: convenient in isolation, but
|
||||
needlessly duplicates run-wide context.
|
||||
- Replace all repeated content with references: makes ordinary operation and
|
||||
native request inspection less convenient than selected.
|
||||
|
||||
## Consequences
|
||||
|
||||
A complete bundle provides source context without each operation directory
|
||||
being self-contained. Logical references are private evidence representation,
|
||||
not a new durable reporting protocol. Operators continue to own access and
|
||||
retention of potentially sensitive evidence.
|
||||
@@ -153,6 +153,8 @@ details cheaply during callbacks, then write at normal boundaries. Cache paths
|
||||
reuse existing details; debug never triggers a second preparation or model call.
|
||||
Shared callback state is synchronized. Available result-less failure facts and
|
||||
unassessed undelivered responses remain distinguishable.
|
||||
Native messages and exchanges stay inline; run-wide source records are shared
|
||||
as described in [State Internals](state.md#native-and-application-evidence).
|
||||
|
||||
[Run capture](../../internal/cli/run_capture.go) uses secret-aware configuration
|
||||
views and exact marked-secret omissions, while native snapshots preserve credential
|
||||
|
||||
@@ -141,8 +141,11 @@ fallback directory. Available files are retained.
|
||||
## Native And Application Evidence
|
||||
|
||||
[Run capture](../../internal/cli/run_capture.go) snapshots the original secret-aware
|
||||
application/PromptKit configuration and source evidence. Scoped pipeline capture
|
||||
records source/reference/incoming artifacts, normalization originals/mappings/
|
||||
application/PromptKit configuration. The runner selects the explicit evidence
|
||||
writer when provided, otherwise enabled debug, and writes original and parsed
|
||||
source once to that sink. Scoped operation inputs refer to these records by
|
||||
labeled bundle-root paths; chunks, references, and incoming artifacts stay inline.
|
||||
Scoped pipeline capture also records normalization originals/mappings/
|
||||
proposals, candidates, complete findings/guidance, fallback/deterministic outcomes,
|
||||
and cache selection/current artifact bytes.
|
||||
|
||||
|
||||
@@ -258,6 +258,10 @@ Exact files, nesting, and serialized shapes are private diagnostic choices,
|
||||
not public contracts or exhaustive provider transcripts. Debug never prepares
|
||||
or executes another request just to capture it.
|
||||
|
||||
Whole-source input and parsed-source evidence are recorded once per run; scoped
|
||||
operation records refer to them while retaining chunks and native messages inline.
|
||||
An isolated operation directory therefore need not contain the complete source.
|
||||
|
||||
Requested capture is required work. Allocation/link failure stops before model
|
||||
work, recording errors surface at normal boundaries, and finalization failure
|
||||
fails the invocation even after publication. Available evidence and primary/
|
||||
|
||||
@@ -20,8 +20,8 @@ The [Core And Integration API Roadmap](../core-integration-api.md) established
|
||||
the core/integration boundary. The reassessment below distinguishes its completed
|
||||
work from the remaining audit remediation.
|
||||
|
||||
The **45 original finding entries** reduce to **20 outstanding catalog entries
|
||||
and fourteen resolved entries**. Repeated responsibility findings are
|
||||
The **45 original finding entries** reduce to **19 outstanding catalog entries
|
||||
and fifteen resolved entries**. Repeated responsibility findings are
|
||||
merged. Regression gaps are attached to the defects they protect rather than
|
||||
counted as additional runtime bugs. In particular, TEST-001, TEST-002, and
|
||||
TEST-004 each cover several distinct defects; TEST-003's native-fixture oracle
|
||||
@@ -66,23 +66,20 @@ context; they are not one universal severity scale. No audit establishes a P1
|
||||
incident or a measured end-to-end production speedup.
|
||||
|
||||
CAT-001, CAT-002, CAT-003, CAT-004, CAT-005, CAT-007, CAT-011, CAT-012, CAT-013, CAT-015,
|
||||
CAT-016, CAT-027, CAT-032, and CAT-034 are resolved;
|
||||
CAT-016, CAT-024, CAT-027, CAT-032, and CAT-034 are resolved;
|
||||
the other entries remain outstanding. The original reports and their baseline
|
||||
observations are historical.
|
||||
"Refactoring" denotes a maintenance opportunity, not a confirmed runtime
|
||||
failure. CAT-024 explicitly requires revisiting an existing evidence-convenience
|
||||
choice. Related entries
|
||||
failure. Related entries
|
||||
may share files without representing the same underlying issue; they should be
|
||||
coordinated rather than silently treated as duplicates.
|
||||
|
||||
**Migration overlap:** Lazy [operation evidence](../../../internal/framework/pipeline/operation.go)
|
||||
and guarded run-wide projections resolve CAT-003. Core operation
|
||||
ownership and the [internal guides](../../internal/modules.md) clarify portions
|
||||
of CAT-014/017/018/022/025/032, without completing their broader layout,
|
||||
of CAT-014/017/018/022/025, without completing their broader layout,
|
||||
copying, runner, writer-obligation, or package-cohesion work. CAT-006/008/009
|
||||
and CAT-023 remain separate lifetime, failure-diagnostic, and CLI concerns;
|
||||
CAT-024's full-source representation is unchanged. These overlaps do not resolve
|
||||
any of those findings.
|
||||
and CAT-023 remain separate lifetime, failure-diagnostic, and CLI concerns.
|
||||
|
||||
## Prioritized Findings
|
||||
|
||||
@@ -485,6 +482,12 @@ do not introduce another command framework or result envelope.
|
||||
**Assessment:** Capacity/convenience design opportunity; original P3; requires
|
||||
deliberate review of the existing evidence representation.
|
||||
|
||||
**Status:** Resolved. The selected evidence sink receives one original and one
|
||||
parsed source record, with bundle-root references in run and operation inputs.
|
||||
Tests cover explicit/debug/distinct sinks, multiple jobs, cache hits, and source
|
||||
write and parse failures. [ADR-0027](../../adr/0027-share-whole-source-capture-evidence.md)
|
||||
records the selected representation.
|
||||
|
||||
**Source:** [RES-003](05-resources.md#res-003--enabled-capture-repeats-the-full-source-for-every-extraction-job).
|
||||
|
||||
Each extraction operation serializes the full source again, multiplying debug
|
||||
@@ -499,7 +502,7 @@ required-capture failures visible. No silent truncation, quotas, or deletion.
|
||||
selects sharing original input and complete parsed source once per run through
|
||||
the operation capture destination. Operation-specific inputs, selected references,
|
||||
and convenient native evidence remain directly inspectable. General deduplication
|
||||
is out of scope; implementation remains pending.
|
||||
is out of scope.
|
||||
|
||||
### CAT-025 — Extension Concurrency And Capture Obligations Are Implicit
|
||||
|
||||
|
||||
@@ -418,6 +418,14 @@ Comment subtle deferred ownership; record all inspected boundaries in catalog.
|
||||
|
||||
## Stage 13 — Share Source Evidence At The Effective Sink
|
||||
|
||||
**Completed.** The runner selects the explicit writer or enabled debug sink once,
|
||||
records original input before parsing and validated source afterward, and passes
|
||||
labeled bundle-root references through run, chunk, lane, and operation inputs.
|
||||
Chunk and native request evidence remain inline. Tests cover multiple jobs,
|
||||
cache hits, each sink selection, both shared-write failures, and parse failure;
|
||||
the prescribed suites and targeted pipeline race checks pass. ADR-0027 records
|
||||
the narrow source-representation decision. No follow-up remains for this work.
|
||||
|
||||
**Coverage:** CAT-024. **Prerequisites:** Stages 11–12.
|
||||
|
||||
Implement selected sink, shared source records, and descriptor passing through
|
||||
|
||||
@@ -20,6 +20,12 @@ type DebugRecorder interface {
|
||||
|
||||
type noopDebugRecorder struct{}
|
||||
|
||||
// evidenceDebugRecorder adapts the selected caller-owned evidence sink without
|
||||
// adding synchronization; explicit writers own their concurrent-call safety.
|
||||
type evidenceDebugRecorder struct{ contracts.EvidenceWriter }
|
||||
|
||||
func (evidenceDebugRecorder) Enabled() bool { return true }
|
||||
|
||||
func NoopDebugRecorder() DebugRecorder { return noopDebugRecorder{} }
|
||||
|
||||
func (noopDebugRecorder) Enabled() bool { return false }
|
||||
@@ -110,7 +116,10 @@ func writeDebugTimed(recorder DebugRecorder, name string, envelope debugTimedEnv
|
||||
if envelope.DurationMS == 0 {
|
||||
envelope.DurationMS = envelope.CompletedAt.Sub(envelope.StartedAt).Milliseconds()
|
||||
}
|
||||
return recorder.WriteJSON(name, envelope)
|
||||
if err := recorder.WriteJSON(name, envelope); err != nil {
|
||||
return &contracts.CaptureError{Cause: err}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func debugContentEnvelope(content []byte, mediaType string, metadata map[string]any, _ any) debugBinaryEnvelope {
|
||||
|
||||
@@ -3,9 +3,31 @@ package pipeline
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
)
|
||||
|
||||
// References are logical paths at the selected evidence sink's root.
|
||||
type sourceEvidenceDescriptor struct {
|
||||
Input string
|
||||
Parsed string
|
||||
}
|
||||
|
||||
func (s *sourceEvidenceDescriptor) inputReference() any {
|
||||
return map[string]string{"bundle_root_path": s.Input}
|
||||
}
|
||||
|
||||
func (s *sourceEvidenceDescriptor) parsedReference() any {
|
||||
return map[string]string{"bundle_root_path": s.Parsed}
|
||||
}
|
||||
|
||||
func sourceCaptureProjection(descriptor *sourceEvidenceDescriptor, doc *source.SourceDocument) any {
|
||||
if descriptor == nil {
|
||||
return debugSourceDocumentEnvelope(doc)
|
||||
}
|
||||
return descriptor.parsedReference()
|
||||
}
|
||||
|
||||
func captureOperationInputs(execution contracts.ExecutionOptions, target typedValidationTarget, binding ModuleBinding, incoming []contracts.SerializedArtifact) error {
|
||||
if execution.Capture == nil {
|
||||
return nil
|
||||
@@ -26,9 +48,21 @@ func captureOperationInputs(execution contracts.ExecutionOptions, target typedVa
|
||||
if target.chunk != nil {
|
||||
chunk = debugSourceChunkEnvelope(*target.chunk)
|
||||
}
|
||||
var sourceValue, sourceInput any
|
||||
if target.sourceEvidence != nil {
|
||||
sourceValue = target.sourceEvidence.parsedReference()
|
||||
if target.chunk == nil {
|
||||
sourceInput = target.sourceEvidence.inputReference()
|
||||
}
|
||||
} else {
|
||||
sourceValue = sourceCaptureProjection(nil, target.source)
|
||||
}
|
||||
if sourceInput == nil {
|
||||
sourceInput = debugContentEnvelope(target.sourceInput.Content, target.sourceInput.MediaType, nil, nil)
|
||||
}
|
||||
return execution.RecordEvidence("inputs.json", map[string]any{
|
||||
"source": debugSourceDocumentEnvelope(target.source),
|
||||
"source_input": debugContentEnvelope(target.sourceInput.Content, target.sourceInput.MediaType, nil, nil),
|
||||
"source": sourceValue,
|
||||
"source_input": sourceInput,
|
||||
"chunk": chunk, "chunks": debugSourceChunkEnvelopes(target.chunks), "references": references,
|
||||
"incoming_artifacts": inputs, "module": binding.Module, "llm_profile": binding.LLMProfile, "metadata": target.metadata,
|
||||
})
|
||||
|
||||
@@ -14,6 +14,13 @@ import (
|
||||
|
||||
func (*nativeEvidence) Enabled() bool { return true }
|
||||
|
||||
type failingCaptureInput struct{ cause error }
|
||||
|
||||
func (f failingCaptureInput) Key() string { return "failing-input" }
|
||||
func (f failingCaptureInput) Parse(context.Context, contracts.ParseRequest) (*source.SourceDocument, error) {
|
||||
return nil, f.cause
|
||||
}
|
||||
|
||||
func TestOperationInputsRetainSourceReferencesAndIncomingCodecBytes(t *testing.T) {
|
||||
evidence := &nativeEvidence{}
|
||||
text := strings.Repeat("sk-ordinary-source-content ", 500)
|
||||
@@ -44,6 +51,123 @@ func TestOperationInputsRetainSourceReferencesAndIncomingCodecBytes(t *testing.T
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerSharesSourceEvidenceAtSelectedSink(t *testing.T) {
|
||||
for _, mode := range []string{"explicit", "debug", "distinct"} {
|
||||
t.Run(mode, func(t *testing.T) {
|
||||
prepared := preparedConcurrentPipeline(t, 2)
|
||||
selected, other := &nativeEvidence{}, &nativeEvidence{}
|
||||
input := RunInput{Prepared: prepared, RawInput: []byte("unique original input"), Workers: 2}
|
||||
switch mode {
|
||||
case "explicit":
|
||||
input.Execution.Capture = selected
|
||||
case "debug":
|
||||
input.Debug = selected
|
||||
case "distinct":
|
||||
input.Execution.Capture, input.Debug = selected, other
|
||||
}
|
||||
if _, err := New().Run(context.Background(), input); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(other.files) != 0 {
|
||||
t.Fatalf("unselected sink received records: %v", other.files)
|
||||
}
|
||||
if !strings.Contains(string(selected.files["source/input.json"]), "unique original input") || !strings.Contains(string(selected.files["source/output.json"]), "text-1") {
|
||||
t.Fatal("shared source records are missing their original content")
|
||||
}
|
||||
inputs := 0
|
||||
laneInputs := 0
|
||||
for name, content := range selected.files {
|
||||
if name == "chunk/input.json" || strings.HasPrefix(name, "extract/") && strings.HasSuffix(name, "/input.json") {
|
||||
var envelope struct {
|
||||
Payload struct {
|
||||
Source struct {
|
||||
BundleRootPath string `json:"bundle_root_path"`
|
||||
} `json:"source"`
|
||||
} `json:"payload"`
|
||||
}
|
||||
if err := json.Unmarshal(content, &envelope); err != nil || envelope.Payload.Source.BundleRootPath != "source/output.json" || len(selected.files[envelope.Payload.Source.BundleRootPath]) == 0 {
|
||||
t.Fatalf("unresolvable run input source in %s: %s, %v", name, content, err)
|
||||
}
|
||||
laneInputs++
|
||||
}
|
||||
if !strings.HasPrefix(name, "operations/") || !strings.HasSuffix(name, "/inputs.json") {
|
||||
continue
|
||||
}
|
||||
inputs++
|
||||
var payload map[string]json.RawMessage
|
||||
if err := json.Unmarshal(content, &payload); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var link struct {
|
||||
BundleRootPath string `json:"bundle_root_path"`
|
||||
}
|
||||
if err := json.Unmarshal(payload["source"], &link); err != nil || link.BundleRootPath != "source/output.json" || len(selected.files[link.BundleRootPath]) == 0 {
|
||||
t.Fatalf("unresolvable source link in %s: %s, %v", name, payload["source"], err)
|
||||
}
|
||||
if !strings.Contains(name, "/extract/") {
|
||||
link.BundleRootPath = ""
|
||||
if err := json.Unmarshal(payload["source_input"], &link); err != nil || link.BundleRootPath != "source/input.json" || len(selected.files[link.BundleRootPath]) == 0 {
|
||||
t.Fatalf("unresolvable original input link in %s: %s, %v", name, payload["source_input"], err)
|
||||
}
|
||||
} else if !strings.Contains(string(payload["chunk"]), "text-1") && !strings.Contains(string(payload["chunk"]), "text-2") {
|
||||
t.Fatalf("chunk content missing from %s: %s", name, payload["chunk"])
|
||||
}
|
||||
if strings.Contains(string(content), "unique original input") {
|
||||
t.Fatalf("full input duplicated in %s", name)
|
||||
}
|
||||
}
|
||||
if inputs < 4 || laneInputs < 3 {
|
||||
t.Fatalf("operation inputs = %d, run inputs = %d; want chunk and multiple lanes", inputs, laneInputs)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerFailsBeforeParsingWhenSharedSourceCaptureFails(t *testing.T) {
|
||||
prepared := preparedConcurrentPipeline(t, 1)
|
||||
adapter := &countingInputAdapter{InputAdapter: prepared.input}
|
||||
prepared.input = adapter
|
||||
cause := errors.New("source evidence failure")
|
||||
writer := &nativeEvidence{fail: func(name string) error {
|
||||
if name == "source/input.json" {
|
||||
return cause
|
||||
}
|
||||
return nil
|
||||
}}
|
||||
_, err := New().Run(context.Background(), RunInput{Prepared: prepared, RawInput: []byte("input"), Execution: contracts.ExecutionOptions{Capture: writer}})
|
||||
var captureErr *contracts.CaptureError
|
||||
if !errors.Is(err, cause) || !errors.As(err, &captureErr) || adapter.calls.Load() != 0 {
|
||||
t.Fatalf("Run() error = %v, parses = %d", err, adapter.calls.Load())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerKeepsOnlyAvailableSourceEvidenceOnParseFailure(t *testing.T) {
|
||||
prepared := preparedConcurrentPipeline(t, 1)
|
||||
cause := errors.New("parse failure")
|
||||
prepared.input = failingCaptureInput{cause: cause}
|
||||
writer := &nativeEvidence{}
|
||||
_, err := New().Run(context.Background(), RunInput{Prepared: prepared, RawInput: []byte("original"), Execution: contracts.ExecutionOptions{Capture: writer}})
|
||||
if !errors.Is(err, cause) || len(writer.files["source/input.json"]) == 0 || len(writer.files["source/output.json"]) != 0 {
|
||||
t.Fatalf("Run() error = %v, files = %v", err, writer.files)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerStopsWhenParsedSourceCaptureFails(t *testing.T) {
|
||||
prepared := preparedConcurrentPipeline(t, 1)
|
||||
cause := errors.New("parsed source evidence failure")
|
||||
writer := &nativeEvidence{fail: func(name string) error {
|
||||
if name == "source/output.json" {
|
||||
return cause
|
||||
}
|
||||
return nil
|
||||
}}
|
||||
_, err := New().Run(context.Background(), RunInput{Prepared: prepared, RawInput: []byte("original"), Execution: contracts.ExecutionOptions{Capture: writer}})
|
||||
var captureErr *contracts.CaptureError
|
||||
if !errors.Is(err, cause) || !errors.As(err, &captureErr) || len(writer.files["source/input.json"]) == 0 || len(writer.files["source/output.json"]) != 0 || len(writer.files["chunk/input.json"]) != 0 {
|
||||
t.Fatalf("Run() error = %v, files = %v", err, writer.files)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRunnerCapturesActualArtifactsAndNoExecutionOnReuse(t *testing.T) {
|
||||
_, store := filesystemProducerCache(t)
|
||||
calls := 0
|
||||
@@ -66,6 +190,14 @@ func TestRunnerCapturesActualArtifactsAndNoExecutionOnReuse(t *testing.T) {
|
||||
if nativeEvidenceCount(evidence, "/inputs.json") != 4 || nativeEvidenceCount(evidence, "/outcome.json") != 4 {
|
||||
t.Fatal("missing chunk/extract/merge/normalization boundaries")
|
||||
}
|
||||
if len(evidence.files["source/input.json"]) == 0 || len(evidence.files["source/output.json"]) == 0 {
|
||||
t.Fatal("source records missing during extraction or cache reuse")
|
||||
}
|
||||
for name, content := range evidence.files {
|
||||
if strings.HasPrefix(name, "operations/") && strings.HasSuffix(name, "/inputs.json") && !strings.Contains(string(content), `"bundle_root_path": "source/output.json"`) {
|
||||
t.Fatalf("source link missing from %s: %s", name, content)
|
||||
}
|
||||
}
|
||||
if nativeEvidenceCount(evidence, "/result.json") != map[bool]int{false: 1, true: 0}[reuse] {
|
||||
t.Fatal("cache reuse fabricated a native execution")
|
||||
}
|
||||
|
||||
@@ -66,7 +66,8 @@ type RunInput struct {
|
||||
references map[referenceTargetKey]contracts.ReferenceSet
|
||||
referenceReuseEligibility map[referenceTargetKey]bool
|
||||
// Shared read-only by extraction jobs and cache decoders for this run.
|
||||
sourceIndex *source.DocumentIndex
|
||||
sourceIndex *source.DocumentIndex
|
||||
sourceEvidence *sourceEvidenceDescriptor
|
||||
}
|
||||
|
||||
type RunOutput struct {
|
||||
@@ -103,12 +104,17 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
||||
input.pipeline = input.Prepared.resolved
|
||||
|
||||
sessionID := strings.TrimSpace(input.SessionID)
|
||||
debugRecorder := input.Debug
|
||||
if debugRecorder == nil {
|
||||
debugRecorder = NoopDebugRecorder()
|
||||
var debugRecorder DebugRecorder = NoopDebugRecorder()
|
||||
if input.Execution.Capture != nil {
|
||||
debugRecorder = evidenceDebugRecorder{input.Execution.Capture}
|
||||
} else if input.Debug != nil && input.Debug.Enabled() {
|
||||
debugRecorder = synchronizedDebugRecorder(input.Debug)
|
||||
input.Execution.Capture = debugRecorder
|
||||
}
|
||||
debugRecorder = synchronizedDebugRecorder(debugRecorder)
|
||||
input.Debug = debugRecorder
|
||||
if input.Execution.Capture != nil {
|
||||
input.sourceEvidence = &sourceEvidenceDescriptor{Input: "source/input.json", Parsed: "source/output.json"}
|
||||
}
|
||||
inputDiagnostics, diagnosticErr := promoteProducerDiagnostics(input.Diagnostics, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageReferences}, nil)
|
||||
if diagnosticErr != nil {
|
||||
return failOutput(output), fmt.Errorf("promote input diagnostics: %w", diagnosticErr)
|
||||
@@ -195,8 +201,8 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
||||
StartedAt: chunkStarted,
|
||||
Payload: map[string]any{
|
||||
"cache_mode": input.pipeline.ChunkControls.Cache,
|
||||
"source": debugSourceDocumentEnvelope(doc),
|
||||
"source_input": debugContentEnvelope(sourceInput.Content, sourceInput.MediaType, nil, nil),
|
||||
"source": input.sourceEvidence.parsedReference(),
|
||||
"source_input": input.sourceEvidence.inputReference(),
|
||||
"metadata": input.Metadata,
|
||||
},
|
||||
}); err != nil {
|
||||
|
||||
@@ -36,7 +36,7 @@ func (r *Runner) runChunkPlan(ctx context.Context, input RunInput, doc *source.S
|
||||
}
|
||||
err = captureFailure(err, execution.RecordEvidence("outcome.json", map[string]any{"outcome": result.outcome, "plan": result.plan, "chunks": debugSourceChunkEnvelopes(result.chunks), "error": errorText}))
|
||||
}()
|
||||
target := typedValidationTarget{stage: StageChunk, moduleKey: chunker.Key(), source: doc, sourceID: doc.ID, sourceInput: sourceInput.Clone(), sessionID: sessionID, references: input.pipeline.ChunkReferences.ReferenceSet, metadata: input.Metadata, execution: execution}
|
||||
target := typedValidationTarget{stage: StageChunk, moduleKey: chunker.Key(), source: doc, sourceEvidence: input.sourceEvidence, sourceID: doc.ID, sourceInput: sourceInput.Clone(), sessionID: sessionID, references: input.pipeline.ChunkReferences.ReferenceSet, metadata: input.Metadata, execution: execution}
|
||||
if err := captureOperationInputs(execution, target, input.pipeline.Chunk, nil); err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ func (r *Runner) runExtractJob(ctx context.Context, input RunInput, doc *source.
|
||||
defer func() {
|
||||
result.err = captureFailure(result.err, captureOperationResult(execution, capturedArtifact, result.outcome, result.err))
|
||||
}()
|
||||
target := typedValidationTarget{stage: StageExtract, stepID: input.stepID, laneID: lane.ID, moduleKey: lane.Extract.Module, source: doc, sourceID: doc.ID, sourceInput: chunkInputMaterial(sourceInput, chunk), sessionID: sessionID, references: references, metadata: input.Metadata, execution: execution, chunk: &chunk, ref: chunk.Ref}
|
||||
target := typedValidationTarget{stage: StageExtract, stepID: input.stepID, laneID: lane.ID, moduleKey: lane.Extract.Module, source: doc, sourceEvidence: input.sourceEvidence, sourceID: doc.ID, sourceInput: chunkInputMaterial(sourceInput, chunk), sessionID: sessionID, references: references, metadata: input.Metadata, execution: execution, chunk: &chunk, ref: chunk.Ref}
|
||||
if err := captureOperationInputs(execution, target, lane.Extract, nil); err != nil {
|
||||
result.err = err
|
||||
return result
|
||||
@@ -345,7 +345,7 @@ func (r *Runner) continueLane(ctx context.Context, input RunInput, doc *source.S
|
||||
}
|
||||
local.diagnosticGroups = append(local.diagnosticGroups, contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{Groups: results.diagnostics}).Groups...)
|
||||
if input.Debug != nil && input.Debug.Enabled() {
|
||||
if err := writeDebugTimed(input.Debug, path.Join("extract", fileio.EncodePathComponent(lane.ID), "input.json"), debugTimedEnvelope{Stage: string(StageExtract), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"source": debugSourceDocumentEnvelope(doc), "chunks": debugSourceChunkEnvelopes(chunks), "metadata": input.Metadata}}); err != nil {
|
||||
if err := writeDebugTimed(input.Debug, path.Join("extract", fileio.EncodePathComponent(lane.ID), "input.json"), debugTimedEnvelope{Stage: string(StageExtract), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"source": sourceCaptureProjection(input.sourceEvidence, doc), "chunks": debugSourceChunkEnvelopes(chunks), "metadata": input.Metadata}}); err != nil {
|
||||
return local, &laneRunError{stage: StageExtract, err: err}
|
||||
}
|
||||
if err := writeDebugTimed(input.Debug, path.Join("extract", fileio.EncodePathComponent(lane.ID), "output.json"), debugTimedEnvelope{Stage: string(StageExtract), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Extract.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"outputs": debugExtractArtifacts(results.accepted)}}); err != nil {
|
||||
|
||||
@@ -92,7 +92,7 @@ func (r *Runner) runMergeStage(ctx context.Context, input RunInput, doc *source.
|
||||
execution := operationExecution(input, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageMerge, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Merge.Module}, nil)
|
||||
var outcome contracts.ProducerOutcome
|
||||
defer func() { err = captureFailure(err, captureOperationResult(execution, state.serialized, outcome, err)) }()
|
||||
target := typedValidationTarget{stage: StageMerge, stepID: input.stepID, laneID: lane.ID, moduleKey: lane.Merge.Module, source: doc, sourceID: doc.ID, sourceInput: sourceInput.Clone(), sessionID: sessionID, references: references, metadata: input.Metadata, execution: execution}
|
||||
target := typedValidationTarget{stage: StageMerge, stepID: input.stepID, laneID: lane.ID, moduleKey: lane.Merge.Module, source: doc, sourceEvidence: input.sourceEvidence, sourceID: doc.ID, sourceInput: sourceInput.Clone(), sessionID: sessionID, references: references, metadata: input.Metadata, execution: execution}
|
||||
if execution.Capture != nil {
|
||||
incoming := make([]contracts.SerializedArtifact, len(extracts.accepted))
|
||||
for index, value := range extracts.accepted {
|
||||
@@ -148,7 +148,7 @@ func (r *Runner) runNormalizeStage(ctx context.Context, input RunInput, doc *sou
|
||||
execution := operationExecution(input, contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageNormalize, StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Normalize.Module}, nil)
|
||||
var outcome contracts.ProducerOutcome
|
||||
defer func() { err = captureFailure(err, captureOperationResult(execution, state.serialized, outcome, err)) }()
|
||||
target := typedValidationTarget{stage: StageNormalize, stepID: input.stepID, laneID: lane.ID, moduleKey: lane.Normalize.Module, source: doc, sourceID: doc.ID, sourceInput: sourceInput.Clone(), sessionID: sessionID, references: references, metadata: input.Metadata, execution: execution}
|
||||
target := typedValidationTarget{stage: StageNormalize, stepID: input.stepID, laneID: lane.ID, moduleKey: lane.Normalize.Module, source: doc, sourceEvidence: input.sourceEvidence, sourceID: doc.ID, sourceInput: sourceInput.Clone(), sessionID: sessionID, references: references, metadata: input.Metadata, execution: execution}
|
||||
if execution.Capture != nil {
|
||||
incoming, err := serializeArtifact(typed.codec, merged.Value, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -30,22 +30,23 @@ type erasedTypedResult struct {
|
||||
}
|
||||
|
||||
type typedValidationTarget struct {
|
||||
stage ModuleStage
|
||||
stepID string
|
||||
laneID string
|
||||
moduleKey string
|
||||
source *source.SourceDocument
|
||||
sourceID string
|
||||
sourceInput contracts.LLMInputMaterial
|
||||
sessionID string
|
||||
references contracts.ReferenceSet
|
||||
llmProfile string
|
||||
execution contracts.ExecutionOptions
|
||||
metadata map[string]any
|
||||
chunk *source.Chunk
|
||||
chunks []source.Chunk
|
||||
ref source.SourceRef
|
||||
value any
|
||||
stage ModuleStage
|
||||
stepID string
|
||||
laneID string
|
||||
moduleKey string
|
||||
source *source.SourceDocument
|
||||
sourceEvidence *sourceEvidenceDescriptor
|
||||
sourceID string
|
||||
sourceInput contracts.LLMInputMaterial
|
||||
sessionID string
|
||||
references contracts.ReferenceSet
|
||||
llmProfile string
|
||||
execution contracts.ExecutionOptions
|
||||
metadata map[string]any
|
||||
chunk *source.Chunk
|
||||
chunks []source.Chunk
|
||||
ref source.SourceRef
|
||||
value any
|
||||
}
|
||||
|
||||
func exactTypedValue[T any](operation string, value any) (T, error) {
|
||||
|
||||
Reference in New Issue
Block a user