···205 for num := range jobs {
206 path := filepath.Join(m.config.BundleDir, fmt.Sprintf("%06d.jsonl.zst", num))
207208- // Load and process bundle
209- ops, err := m.operations.LoadBundle(path)
210- if err != nil {
211- results <- bundleResult{index: num, err: err}
212- continue
213- }
214-215- // Use the FAST method (cursor will be set later in sequential phase)
216- meta, err := m.CalculateBundleMetadataFast(num, path, ops, "")
217 if err != nil {
218 results <- bundleResult{index: num, err: err}
219 continue
···205 for num := range jobs {
206 path := filepath.Join(m.config.BundleDir, fmt.Sprintf("%06d.jsonl.zst", num))
207208+ // ✅ NEW: Stream metadata WITHOUT loading all operations
209+ meta, err := m.CalculateMetadataStreaming(num, path)
0000000210 if err != nil {
211 results <- bundleResult{index: num, err: err}
212 continue
+4
internal/didindex/builder.go
···50 return fmt.Errorf("no bundles to index")
51 }
52000053 // Create temporary shard files
54 tempShards := make([]*os.File, DID_SHARD_COUNT)
55 for i := 0; i < DID_SHARD_COUNT; i++ {
···50 return fmt.Errorf("no bundles to index")
51 }
5253+ if err := os.MkdirAll(dim.shardDir, 0755); err != nil {
54+ return fmt.Errorf("failed to create shard directory: %w", err)
55+ }
56+57 // Create temporary shard files
58 tempShards := make([]*os.File, DID_SHARD_COUNT)
59 for i := 0; i < DID_SHARD_COUNT; i++ {
+57-7
internal/storage/storage.go
···8990// LoadBundle loads a compressed bundle
91func (op *Operations) LoadBundle(path string) ([]plcclient.PLCOperation, error) {
92- // 1. Read the entire compressed file into memory.
93- compressed, err := os.ReadFile(path)
94 if err != nil {
95- return nil, fmt.Errorf("failed to read file: %w", err)
96 }
09798- // This is the key: The one-shot Decompress function is designed to correctly
99- // handle a byte slice containing one or more concatenated frames.
100- decompressed, err := gozstd.Decompress(nil, compressed)
000101 if err != nil {
102 return nil, fmt.Errorf("failed to decompress: %w", err)
103 }
104105- // 3. Parse the fully decompressed JSONL data.
106 return op.ParseJSONL(decompressed)
107}
108···571572 return results, nil
573}
0000000000000000000000000000000000000000000000