Skip debug projections when capture is disabled
This commit is contained in:
@@ -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
|
the core/integration boundary. The reassessment below distinguishes its completed
|
||||||
work from the remaining audit remediation.
|
work from the remaining audit remediation.
|
||||||
|
|
||||||
The **45 original finding entries** reduce to **21 outstanding catalog entries
|
The **45 original finding entries** reduce to **20 outstanding catalog entries
|
||||||
and thirteen resolved entries**. Repeated responsibility findings are
|
and fourteen resolved entries**. Repeated responsibility findings are
|
||||||
merged. Regression gaps are attached to the defects they protect rather than
|
merged. Regression gaps are attached to the defects they protect rather than
|
||||||
counted as additional runtime bugs. In particular, TEST-001, TEST-002, and
|
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
|
TEST-004 each cover several distinct defects; TEST-003's native-fixture oracle
|
||||||
@@ -65,7 +65,7 @@ Original P2/P3 ratings and relative refactoring priorities are retained for
|
|||||||
context; they are not one universal severity scale. No audit establishes a P1
|
context; they are not one universal severity scale. No audit establishes a P1
|
||||||
incident or a measured end-to-end production speedup.
|
incident or a measured end-to-end production speedup.
|
||||||
|
|
||||||
CAT-001, CAT-002, CAT-004, CAT-005, CAT-007, CAT-011, CAT-012, CAT-013, CAT-015,
|
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-027, CAT-032, and CAT-034 are resolved;
|
||||||
the other entries remain outstanding. The original reports and their baseline
|
the other entries remain outstanding. The original reports and their baseline
|
||||||
observations are historical.
|
observations are historical.
|
||||||
@@ -76,7 +76,7 @@ may share files without representing the same underlying issue; they should be
|
|||||||
coordinated rather than silently treated as duplicates.
|
coordinated rather than silently treated as duplicates.
|
||||||
|
|
||||||
**Migration overlap:** Lazy [operation evidence](../../../internal/framework/pipeline/operation.go)
|
**Migration overlap:** Lazy [operation evidence](../../../internal/framework/pipeline/operation.go)
|
||||||
addresses part of CAT-003, not all run-wide capture allocation. Core operation
|
and guarded run-wide projections resolve CAT-003. Core operation
|
||||||
ownership and the [internal guides](../../internal/modules.md) clarify portions
|
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/032, without completing their broader layout,
|
||||||
copying, runner, writer-obligation, or package-cohesion work. CAT-006/008/009
|
copying, runner, writer-obligation, or package-cohesion work. CAT-006/008/009
|
||||||
@@ -123,6 +123,13 @@ No new timestamp-magnitude restriction is needed.
|
|||||||
|
|
||||||
**Assessment:** Source-established resource-efficiency weakness; original P2.
|
**Assessment:** Source-established resource-efficiency weakness; original P2.
|
||||||
|
|
||||||
|
**Status:** Resolved. Guards precede source, input, chunk-plan and deferred chunk
|
||||||
|
outcome, lane, merge, normalize, output, and evidence-summary projections. The
|
||||||
|
operation input/result, candidate assessment, cache observation, and native
|
||||||
|
evaluation capture paths were inspected and already guard their projections.
|
||||||
|
Mandatory artifact encoding remains unconditional; focused tests cover lazy
|
||||||
|
evaluation and enabled, cached, fallback, and failing capture paths.
|
||||||
|
|
||||||
**Source:** [RES-001](05-resources.md#res-001--disabled-capture-still-constructs-large-evidence-payloads).
|
**Source:** [RES-001](05-resources.md#res-001--disabled-capture-still-constructs-large-evidence-payloads).
|
||||||
|
|
||||||
Ordinary runs construct text/base64, chunk, artifact, and output envelopes before
|
Ordinary runs construct text/base64, chunk, artifact, and output envelopes before
|
||||||
|
|||||||
@@ -392,6 +392,14 @@ these packages under `-race`. Update overview/LLM/state package pointers.
|
|||||||
|
|
||||||
## Stage 12 — Avoid Disabled-Capture Construction
|
## Stage 12 — Avoid Disabled-Capture Construction
|
||||||
|
|
||||||
|
**Completed.** Run-wide source, chunk, lane, artifact, output, and evidence-summary
|
||||||
|
projections are constructed only for enabled debug capture; deferred chunk
|
||||||
|
outcome projection is guarded by the operation's effective capture writer.
|
||||||
|
Existing operation-input, result, assessment, and evaluation projections were
|
||||||
|
inspected and already guard construction. Mandatory artifact serialization is
|
||||||
|
unchanged. Focused projection, pipeline, capture, and integration tests pass;
|
||||||
|
subsequent source-sharing and runner decomposition must retain these guards.
|
||||||
|
|
||||||
**Coverage:** CAT-003. **Prerequisites:** Stage 11.
|
**Coverage:** CAT-003. **Prerequisites:** Stage 11.
|
||||||
|
|
||||||
Inspect debug.go, runner.go, runner_chunk_plan.go, runner_concurrent.go,
|
Inspect debug.go, runner.go, runner_chunk_plan.go, runner_concurrent.go,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ type debugEvidenceContextSummary struct {
|
|||||||
// buildOutputEvidenceContext projects the prepared output policy from accepted
|
// buildOutputEvidenceContext projects the prepared output policy from accepted
|
||||||
// normalized artifacts. It is intentionally separate from lane execution so
|
// normalized artifacts. It is intentionally separate from lane execution so
|
||||||
// cached normalized outputs use the same reconstruction path.
|
// cached normalized outputs use the same reconstruction path.
|
||||||
func buildOutputEvidenceContext(prepared *PreparedPipeline, doc *source.SourceDocument, outputs []contracts.SerializedOutput) (*contracts.SerializedArtifact, *debugEvidenceContextSummary, error) {
|
func buildOutputEvidenceContext(prepared *PreparedPipeline, doc *source.SourceDocument, outputs []contracts.SerializedOutput, includeSummary bool) (*contracts.SerializedArtifact, *debugEvidenceContextSummary, error) {
|
||||||
if prepared == nil || prepared.evidencePlan == nil {
|
if prepared == nil || prepared.evidencePlan == nil {
|
||||||
return nil, nil, nil
|
return nil, nil, nil
|
||||||
}
|
}
|
||||||
@@ -88,6 +88,9 @@ func buildOutputEvidenceContext(prepared *PreparedPipeline, doc *source.SourceDo
|
|||||||
MediaType: evidencecontext.MediaType,
|
MediaType: evidencecontext.MediaType,
|
||||||
Content: content,
|
Content: content,
|
||||||
}
|
}
|
||||||
|
if !includeSummary {
|
||||||
|
return contracts.CloneSerializedArtifactPointer(artifact), nil, nil
|
||||||
|
}
|
||||||
summary := debugEvidenceContextSummary{
|
summary := debugEvidenceContextSummary{
|
||||||
ArtifactKind: artifact.Kind,
|
ArtifactKind: artifact.Kind,
|
||||||
MediaType: artifact.MediaType,
|
MediaType: artifact.MediaType,
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ func TestEvidenceContextOmitsUnselectedAndAbsentLanes(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
result, _, err := buildOutputEvidenceContext(prepared, doc, []contracts.SerializedOutput{{LaneID: "present", SourceID: doc.ID, Artifact: artifact}, {LaneID: "unselected", SourceID: doc.ID, Artifact: artifact}})
|
outputs := []contracts.SerializedOutput{{LaneID: "present", SourceID: doc.ID, Artifact: artifact}, {LaneID: "unselected", SourceID: doc.ID, Artifact: artifact}}
|
||||||
|
result, summary, err := buildOutputEvidenceContext(prepared, doc, outputs, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -121,6 +122,10 @@ func TestEvidenceContextOmitsUnselectedAndAbsentLanes(t *testing.T) {
|
|||||||
if err != nil || len(value) != 1 || value[0].ID != 1 {
|
if err != nil || len(value) != 1 || value[0].ID != 1 {
|
||||||
t.Fatalf("evidence=%#v %v", value, err)
|
t.Fatalf("evidence=%#v %v", value, err)
|
||||||
}
|
}
|
||||||
|
withoutSummary, absent, err := buildOutputEvidenceContext(prepared, doc, outputs, false)
|
||||||
|
if err != nil || absent != nil || summary == nil || !reflect.DeepEqual(result, withoutSummary) {
|
||||||
|
t.Fatalf("optional debug summary changed output: summary=%#v absent=%#v error=%v", summary, absent, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRunnerEvidenceContextFailurePreventsOutputEncoding(t *testing.T) {
|
func TestRunnerEvidenceContextFailurePreventsOutputEncoding(t *testing.T) {
|
||||||
@@ -170,7 +175,7 @@ func TestBuildOutputEvidenceContextRejectsIncompatibleAcceptedOutputs(t *testing
|
|||||||
if test.mutate != nil {
|
if test.mutate != nil {
|
||||||
test.mutate(&outputs[0])
|
test.mutate(&outputs[0])
|
||||||
}
|
}
|
||||||
_, _, err := buildOutputEvidenceContext(prepared, doc, outputs)
|
_, _, err := buildOutputEvidenceContext(prepared, doc, outputs, true)
|
||||||
if err == nil || !strings.Contains(err.Error(), test.want) {
|
if err == nil || !strings.Contains(err.Error(), test.want) {
|
||||||
t.Fatalf("buildOutputEvidenceContext() error = %v, want %q", err, test.want)
|
t.Fatalf("buildOutputEvidenceContext() error = %v, want %q", err, test.want)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,18 +114,18 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
|||||||
return failOutput(output), fmt.Errorf("promote input diagnostics: %w", diagnosticErr)
|
return failOutput(output), fmt.Errorf("promote input diagnostics: %w", diagnosticErr)
|
||||||
}
|
}
|
||||||
appendDiagnosticGroups(&output, inputDiagnostics)
|
appendDiagnosticGroups(&output, inputDiagnostics)
|
||||||
if err := writeDebugTimed(debugRecorder, "pipeline.json", debugTimedEnvelope{
|
|
||||||
Stage: "run",
|
|
||||||
StartedAt: startedTime(input.StartedAt),
|
|
||||||
Payload: map[string]any{
|
|
||||||
"pipeline_id": input.pipeline.ID,
|
|
||||||
"pipeline_digest": input.pipeline.Digest,
|
|
||||||
"run_id": input.RunID,
|
|
||||||
},
|
|
||||||
}); err != nil {
|
|
||||||
return failOutput(output), fmt.Errorf("write debug run artifact: %w", err)
|
|
||||||
}
|
|
||||||
if debugRecorder.Enabled() {
|
if debugRecorder.Enabled() {
|
||||||
|
if err := writeDebugTimed(debugRecorder, "pipeline.json", debugTimedEnvelope{
|
||||||
|
Stage: "run",
|
||||||
|
StartedAt: startedTime(input.StartedAt),
|
||||||
|
Payload: map[string]any{
|
||||||
|
"pipeline_id": input.pipeline.ID,
|
||||||
|
"pipeline_digest": input.pipeline.Digest,
|
||||||
|
"run_id": input.RunID,
|
||||||
|
},
|
||||||
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write debug run artifact: %w", err)
|
||||||
|
}
|
||||||
if err := debugRecorder.WriteJSON("composition.json", captureComposition(input.pipeline)); err != nil {
|
if err := debugRecorder.WriteJSON("composition.json", captureComposition(input.pipeline)); err != nil {
|
||||||
return failOutput(output), &contracts.CaptureError{Cause: err}
|
return failOutput(output), &contracts.CaptureError{Cause: err}
|
||||||
}
|
}
|
||||||
@@ -134,18 +134,20 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
|||||||
adapter := input.Prepared.input
|
adapter := input.Prepared.input
|
||||||
var doc *source.SourceDocument
|
var doc *source.SourceDocument
|
||||||
sourceStarted := time.Now().UTC()
|
sourceStarted := time.Now().UTC()
|
||||||
if err := writeDebugTimed(debugRecorder, "source/input.json", debugTimedEnvelope{
|
if debugRecorder.Enabled() {
|
||||||
Stage: "source",
|
if err := writeDebugTimed(debugRecorder, "source/input.json", debugTimedEnvelope{
|
||||||
ModuleKey: adapter.Key(),
|
Stage: "source",
|
||||||
StartedAt: sourceStarted,
|
ModuleKey: adapter.Key(),
|
||||||
Payload: debugSourceInput{
|
StartedAt: sourceStarted,
|
||||||
SourceID: input.SourceID,
|
Payload: debugSourceInput{
|
||||||
Path: input.Path,
|
SourceID: input.SourceID,
|
||||||
Raw: debugContentEnvelope(input.RawInput, sourceInputMediaType(input.Path), nil, nil),
|
Path: input.Path,
|
||||||
Metadata: input.Metadata,
|
Raw: debugContentEnvelope(input.RawInput, sourceInputMediaType(input.Path), nil, nil),
|
||||||
},
|
Metadata: input.Metadata,
|
||||||
}); err != nil {
|
},
|
||||||
return failOutput(output), fmt.Errorf("write source debug artifact: %w", err)
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write source debug artifact: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
requestMetadata, err := cloneMetadata(input.Metadata)
|
requestMetadata, err := cloneMetadata(input.Metadata)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -170,53 +172,59 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
|||||||
index := source.NewDocumentIndex(doc)
|
index := source.NewDocumentIndex(doc)
|
||||||
input.sourceIndex = &index
|
input.sourceIndex = &index
|
||||||
|
|
||||||
if err := writeDebugTimed(debugRecorder, "source/output.json", debugTimedEnvelope{
|
if debugRecorder.Enabled() {
|
||||||
Stage: "source",
|
if err := writeDebugTimed(debugRecorder, "source/output.json", debugTimedEnvelope{
|
||||||
ModuleKey: adapter.Key(),
|
Stage: "source",
|
||||||
StartedAt: sourceStarted,
|
ModuleKey: adapter.Key(),
|
||||||
Payload: map[string]any{
|
StartedAt: sourceStarted,
|
||||||
"document": debugSourceDocumentEnvelope(doc),
|
Payload: map[string]any{
|
||||||
},
|
"document": debugSourceDocumentEnvelope(doc),
|
||||||
}); err != nil {
|
},
|
||||||
return failOutput(output), fmt.Errorf("write source debug artifact: %w", err)
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write source debug artifact: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sourceInput := sourceInputMaterial(input.Path, input.RawInput)
|
sourceInput := sourceInputMaterial(input.Path, input.RawInput)
|
||||||
|
|
||||||
chunker := input.Prepared.chunker
|
chunker := input.Prepared.chunker
|
||||||
chunkStarted := time.Now().UTC()
|
chunkStarted := time.Now().UTC()
|
||||||
if err := writeDebugTimed(debugRecorder, "chunk/input.json", debugTimedEnvelope{
|
if debugRecorder.Enabled() {
|
||||||
Stage: string(StageChunk),
|
if err := writeDebugTimed(debugRecorder, "chunk/input.json", debugTimedEnvelope{
|
||||||
ModuleKey: chunker.Key(),
|
Stage: string(StageChunk),
|
||||||
StartedAt: chunkStarted,
|
ModuleKey: chunker.Key(),
|
||||||
Payload: map[string]any{
|
StartedAt: chunkStarted,
|
||||||
"cache_mode": input.pipeline.ChunkControls.Cache,
|
Payload: map[string]any{
|
||||||
"source": debugSourceDocumentEnvelope(doc),
|
"cache_mode": input.pipeline.ChunkControls.Cache,
|
||||||
"source_input": debugContentEnvelope(sourceInput.Content, sourceInput.MediaType, nil, nil),
|
"source": debugSourceDocumentEnvelope(doc),
|
||||||
"metadata": input.Metadata,
|
"source_input": debugContentEnvelope(sourceInput.Content, sourceInput.MediaType, nil, nil),
|
||||||
},
|
"metadata": input.Metadata,
|
||||||
}); err != nil {
|
},
|
||||||
return failOutput(output), fmt.Errorf("write chunk debug artifact: %w", err)
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write chunk debug artifact: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
chunkResult, err := r.runChunkPlan(ctx, input, doc, sourceInput, sessionID)
|
chunkResult, err := r.runChunkPlan(ctx, input, doc, sourceInput, sessionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return failOutput(output), err
|
return failOutput(output), err
|
||||||
}
|
}
|
||||||
appendDiagnosticGroups(&output, chunkResult.diagnostics)
|
appendDiagnosticGroups(&output, chunkResult.diagnostics)
|
||||||
chunkDebugPayload := map[string]any{
|
if debugRecorder.Enabled() {
|
||||||
"cache_mode": input.pipeline.ChunkControls.Cache,
|
chunkDebugPayload := map[string]any{
|
||||||
"accepted": chunkResult.accepted,
|
"cache_mode": input.pipeline.ChunkControls.Cache,
|
||||||
"materialized_chunks": debugSourceChunkEnvelopes(chunkResult.chunks),
|
"accepted": chunkResult.accepted,
|
||||||
}
|
"materialized_chunks": debugSourceChunkEnvelopes(chunkResult.chunks),
|
||||||
if chunkResult.plan != nil {
|
}
|
||||||
chunkDebugPayload["plan"] = debugChunkPlanEnvelope(*chunkResult.plan)
|
if chunkResult.plan != nil {
|
||||||
}
|
chunkDebugPayload["plan"] = debugChunkPlanEnvelope(*chunkResult.plan)
|
||||||
if err := writeDebugTimed(debugRecorder, "chunk/output.json", debugTimedEnvelope{
|
}
|
||||||
Stage: string(StageChunk),
|
if err := writeDebugTimed(debugRecorder, "chunk/output.json", debugTimedEnvelope{
|
||||||
ModuleKey: chunker.Key(),
|
Stage: string(StageChunk),
|
||||||
StartedAt: chunkStarted,
|
ModuleKey: chunker.Key(),
|
||||||
Payload: chunkDebugPayload,
|
StartedAt: chunkStarted,
|
||||||
}); err != nil {
|
Payload: chunkDebugPayload,
|
||||||
return failOutput(output), fmt.Errorf("write chunk debug artifact: %w", err)
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write chunk debug artifact: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var acceptedChunkMap *contracts.SerializedArtifact
|
var acceptedChunkMap *contracts.SerializedArtifact
|
||||||
@@ -267,7 +275,7 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
|||||||
return failOutput(output), err
|
return failOutput(output), err
|
||||||
}
|
}
|
||||||
outputStarted := time.Now().UTC()
|
outputStarted := time.Now().UTC()
|
||||||
evidenceArtifact, evidenceSummary, err := buildOutputEvidenceContext(input.Prepared, doc, output.normalizeOutputs)
|
evidenceArtifact, evidenceSummary, err := buildOutputEvidenceContext(input.Prepared, doc, output.normalizeOutputs, debugRecorder.Enabled())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return failOutput(output), err
|
return failOutput(output), err
|
||||||
}
|
}
|
||||||
@@ -287,20 +295,22 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
|||||||
return failOutput(output), err
|
return failOutput(output), err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outputDebugPayload := map[string]any{
|
if debugRecorder.Enabled() {
|
||||||
"normalize_outputs": debugSerializedOutputEnvelopes(output.normalizeOutputs),
|
outputDebugPayload := map[string]any{
|
||||||
"metadata": input.Metadata,
|
"normalize_outputs": debugSerializedOutputEnvelopes(output.normalizeOutputs),
|
||||||
}
|
"metadata": input.Metadata,
|
||||||
if acceptedChunkMap != nil {
|
}
|
||||||
outputDebugPayload["chunk_map"] = debugSerializedOutputEnvelope(contracts.SerializedOutput{Artifact: *acceptedChunkMap})
|
if acceptedChunkMap != nil {
|
||||||
}
|
outputDebugPayload["chunk_map"] = debugSerializedOutputEnvelope(contracts.SerializedOutput{Artifact: *acceptedChunkMap})
|
||||||
if err := writeDebugTimed(debugRecorder, "output/input.json", debugTimedEnvelope{
|
}
|
||||||
Stage: string(StageOutput),
|
if err := writeDebugTimed(debugRecorder, "output/input.json", debugTimedEnvelope{
|
||||||
ModuleKey: encoder.Key(),
|
Stage: string(StageOutput),
|
||||||
StartedAt: outputStarted,
|
ModuleKey: encoder.Key(),
|
||||||
Payload: outputDebugPayload,
|
StartedAt: outputStarted,
|
||||||
}); err != nil {
|
Payload: outputDebugPayload,
|
||||||
return failOutput(output), fmt.Errorf("write output debug artifact: %w", err)
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write output debug artifact: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return failOutput(output), err
|
return failOutput(output), err
|
||||||
@@ -320,15 +330,17 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return failOutput(output), fmt.Errorf("validate output files from encoder %q: %w", encoder.Key(), err)
|
return failOutput(output), fmt.Errorf("validate output files from encoder %q: %w", encoder.Key(), err)
|
||||||
}
|
}
|
||||||
if err := writeDebugTimed(debugRecorder, "output/output.json", debugTimedEnvelope{
|
if debugRecorder.Enabled() {
|
||||||
Stage: string(StageOutput),
|
if err := writeDebugTimed(debugRecorder, "output/output.json", debugTimedEnvelope{
|
||||||
ModuleKey: encoder.Key(),
|
Stage: string(StageOutput),
|
||||||
StartedAt: outputStarted,
|
ModuleKey: encoder.Key(),
|
||||||
Payload: map[string]any{
|
StartedAt: outputStarted,
|
||||||
"files": debugOutputFiles(files),
|
Payload: map[string]any{
|
||||||
},
|
"files": debugOutputFiles(files),
|
||||||
}); err != nil {
|
},
|
||||||
return failOutput(output), fmt.Errorf("write output debug artifact: %w", err)
|
}); err != nil {
|
||||||
|
return failOutput(output), fmt.Errorf("write output debug artifact: %w", err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err := ctx.Err(); err != nil {
|
if err := ctx.Err(); err != nil {
|
||||||
return failOutput(output), err
|
return failOutput(output), err
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ func (r *Runner) runChunkPlan(ctx context.Context, input RunInput, doc *source.S
|
|||||||
origin := contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageChunk, ModuleKey: chunker.Key()}
|
origin := contracts.DiagnosticOrigin{Stage: contracts.DiagnosticOriginStageChunk, ModuleKey: chunker.Key()}
|
||||||
execution := operationExecution(input, origin, nil)
|
execution := operationExecution(input, origin, nil)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
// Project final chunks here only when an operation capture was requested.
|
||||||
|
if execution.Capture == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
errorText := ""
|
errorText := ""
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errorText = err.Error()
|
errorText = err.Error()
|
||||||
|
|||||||
@@ -344,11 +344,13 @@ func (r *Runner) continueLane(ctx context.Context, input RunInput, doc *source.S
|
|||||||
reuseEligible: state.reuseEligible,
|
reuseEligible: state.reuseEligible,
|
||||||
}
|
}
|
||||||
local.diagnosticGroups = append(local.diagnosticGroups, contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{Groups: results.diagnostics}).Groups...)
|
local.diagnosticGroups = append(local.diagnosticGroups, contracts.CloneDiagnosticCollection(contracts.DiagnosticCollection{Groups: results.diagnostics}).Groups...)
|
||||||
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 input.Debug != nil && input.Debug.Enabled() {
|
||||||
return local, &laneRunError{stage: StageExtract, err: err}
|
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 {
|
||||||
}
|
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 {
|
}
|
||||||
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 {
|
||||||
|
return local, &laneRunError{stage: StageExtract, err: err}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(results.accepted) == 0 {
|
if len(results.accepted) == 0 {
|
||||||
return local, nil
|
return local, nil
|
||||||
|
|||||||
@@ -126,8 +126,10 @@ func (r *Runner) runMergeStage(ctx context.Context, input RunInput, doc *source.
|
|||||||
}
|
}
|
||||||
state.reuseEligible = outcome.ReuseEligible
|
state.reuseEligible = outcome.ReuseEligible
|
||||||
state.artifact = erasedMergeArtifact{LaneID: lane.ID, MergerKey: lane.Merge.Module, SourceID: doc.ID, Value: value}
|
state.artifact = erasedMergeArtifact{LaneID: lane.ID, MergerKey: lane.Merge.Module, SourceID: doc.ID, Value: value}
|
||||||
if err := writeDebugTimed(input.Debug, path.Join("merge", fileio.EncodePathComponent(lane.ID), "output.json"), debugTimedEnvelope{Stage: string(StageMerge), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Merge.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"outcome": outcome, "output": debugSerializedOutputEnvelope(contracts.SerializedOutput{StepID: input.stepID, LaneID: lane.ID, SourceID: doc.ID, Artifact: state.serialized})}}); err != nil {
|
if input.Debug != nil && input.Debug.Enabled() {
|
||||||
return state, err
|
if err := writeDebugTimed(input.Debug, path.Join("merge", fileio.EncodePathComponent(lane.ID), "output.json"), debugTimedEnvelope{Stage: string(StageMerge), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Merge.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"outcome": outcome, "output": debugSerializedOutputEnvelope(contracts.SerializedOutput{StepID: input.stepID, LaneID: lane.ID, SourceID: doc.ID, Artifact: state.serialized})}}); err != nil {
|
||||||
|
return state, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return state, nil
|
return state, nil
|
||||||
}
|
}
|
||||||
@@ -180,8 +182,10 @@ func (r *Runner) runNormalizeStage(ctx context.Context, input RunInput, doc *sou
|
|||||||
}
|
}
|
||||||
state.reuseEligible = outcome.ReuseEligible
|
state.reuseEligible = outcome.ReuseEligible
|
||||||
state.accepted = true
|
state.accepted = true
|
||||||
if err := writeDebugTimed(input.Debug, path.Join("normalize", fileio.EncodePathComponent(lane.ID), "output.json"), debugTimedEnvelope{Stage: string(StageNormalize), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Normalize.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"outcome": outcome, "output": debugSerializedOutputEnvelope(contracts.SerializedOutput{StepID: input.stepID, LaneID: lane.ID, SourceID: doc.ID, Artifact: state.serialized})}}); err != nil {
|
if input.Debug != nil && input.Debug.Enabled() {
|
||||||
return state, err
|
if err := writeDebugTimed(input.Debug, path.Join("normalize", fileio.EncodePathComponent(lane.ID), "output.json"), debugTimedEnvelope{Stage: string(StageNormalize), StepID: input.stepID, LaneID: lane.ID, ModuleKey: lane.Normalize.Module, StartedAt: time.Now().UTC(), Payload: map[string]any{"outcome": outcome, "output": debugSerializedOutputEnvelope(contracts.SerializedOutput{StepID: input.stepID, LaneID: lane.ID, SourceID: doc.ID, Artifact: state.serialized})}}); err != nil {
|
||||||
|
return state, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return state, nil
|
return state, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user