Harden chunk map export and retire completed plans

This commit is contained in:
2026-07-23 17:38:04 +00:00
parent 06148074a2
commit b490297cde
6 changed files with 166 additions and 733 deletions

View File

@@ -234,6 +234,23 @@ func TestEncodeIncludesValidatedChunkMap(t *testing.T) {
}
}
func TestEncodePreservesChunkMapAnnotationNumbers(t *testing.T) {
artifact := acceptedChunkMapArtifactWithPlanAnnotation(t, stdjson.RawMessage(`{"decimal":1.0,"large":9007199254740993}`))
result, err := NewWithOptions(Options{IncludeChunkMap: true}).Encode(context.Background(), contracts.OutputRequest{
ChunkMap: &artifact,
})
if err != nil {
t.Fatalf("Encode() error = %v", err)
}
value, err := chunkmap.New().Decode(fileBytes(t, result.Files, chunkMapFileName))
if err != nil {
t.Fatalf("Decode(emitted chunk map) error = %v", err)
}
if got, want := string(value.PlanAnnotations["test/numbers"]), `{"decimal":1.0,"large":9007199254740993}`; got != want {
t.Fatalf("numeric annotation = %s, want %s", got, want)
}
}
func TestEncodeOmitsChunkMapWithoutAcceptedArtifact(t *testing.T) {
result, err := NewWithOptions(Options{IncludeChunkMap: true}).Encode(context.Background(), contracts.OutputRequest{
Manifest: artifacts.RunManifest{RunID: "run-1"},
@@ -544,6 +561,10 @@ func normalizeOutput(laneID string, content string) contracts.SerializedOutput {
}
func acceptedChunkMapArtifact(t *testing.T) contracts.SerializedArtifact {
return acceptedChunkMapArtifactWithPlanAnnotation(t, nil)
}
func acceptedChunkMapArtifactWithPlanAnnotation(t *testing.T, annotation stdjson.RawMessage) contracts.SerializedArtifact {
t.Helper()
document := &source.SourceDocument{
ID: "source-1",
@@ -562,6 +583,9 @@ func acceptedChunkMapArtifact(t *testing.T) contracts.SerializedArtifact {
}
document.Digest = digest
plan := source.ChunkPlan{SourceDigest: digest, Ranges: []source.ChunkRange{{StartUnitID: 1, EndUnitID: 1}}}
if annotation != nil {
plan.Annotations = source.ChunkAnnotations{"test/numbers": append(stdjson.RawMessage(nil), annotation...)}
}
chunks, err := source.MaterializeChunkPlan(document, plan)
if err != nil {
t.Fatal(err)