···195195 bundleNum := fs.Int("bundle", 0, "bundle number to test")
196196 confidence := fs.Float64("confidence", 0.90, "minimum confidence threshold")
197197 verbose := fs.Bool("v", false, "verbose output")
198198- fs.Parse(os.Args[4:]) // ← Changed from os.Args[3:]
198198+ fs.Parse(os.Args[4:])
199199200200 if *bundleNum == 0 {
201201 fmt.Fprintf(os.Stderr, "Error: --bundle required\n")
···556556 var maxConfidence float64
557557558558 for _, det := range detectors {
559559- match, err := det.Detect(ctx, op) // ← op now has ParsedOperation set
559559+ match, err := det.Detect(ctx, op)
560560 if err != nil || match == nil || match.Confidence < minConfidence {
561561 continue
562562 }
+6-9
cmd/plcbundle/main.go
···452452 }
453453454454 config := bundle.DefaultConfig(dir)
455455- config.AutoRebuild = false // ← Disable auto-rebuild
455455+ config.AutoRebuild = false
456456 config.RebuildWorkers = *workers
457457458458 mgr, err := bundle.NewManager(config, nil)
···12701270 enableWebSocket := fs.Bool("websocket", false, "enable WebSocket endpoint for streaming records")
12711271 workers := fs.Int("workers", 4, "number of workers for auto-rebuild (0 = CPU count)")
12721272 verbose := fs.Bool("verbose", false, "verbose sync logging")
12731273- enableResolver := fs.Bool("resolver", false, "enable DID resolution endpoints (/<did>)") // ← NEW
12731273+ enableResolver := fs.Bool("resolver", false, "enable DID resolution endpoints (/<did>)")
12741274 fs.Parse(os.Args[2:])
1275127512761276 serverStartTime = time.Now()
12771277 syncInterval = *syncIntervalFlag
12781278 verboseMode = *verbose
12791279- resolverEnabled = *enableResolver // ← NEW global
12791279+ resolverEnabled = *enableResolver
1280128012811281 // Auto-detect CPU count
12821282 if *workers == 0 {
···13291329 }
13301330 defer mgr.Close()
1331133113321332- // ═══════════════════════════════════════════════════════════
13331333- // DID INDEX AUTO-BUILD LOGIC
13341334- // ═══════════════════════════════════════════════════════════
13351332 if *enableResolver {
13361333 index := mgr.GetIndex()
13371334 bundleCount := index.Count()
···13481345 // Check version
13491346 didIndex := mgr.GetDIDIndex()
13501347 if didIndex != nil {
13511351- config := didIndex.GetConfig() // ← Need to expose this
13481348+ config := didIndex.GetConfig()
13521349 if config.Version != bundle.DIDINDEX_VERSION {
13531350 needsBuild = true
13541351 reason = fmt.Sprintf("index version outdated (v%d, need v%d)",
···14321429 defer cancel()
1433143014341431 if *sync {
14351435- go runSync(ctx, mgr, syncInterval, *verbose, *enableResolver) // ← Pass resolver flag
14321432+ go runSync(ctx, mgr, syncInterval, *verbose, *enableResolver)
14361433 }
1437143414381435 server := &http.Server{
14391436 Addr: addr,
14401440- Handler: newServerHandler(mgr, *sync, *enableWebSocket, *enableResolver), // ← Pass resolver flag
14371437+ Handler: newServerHandler(mgr, *sync, *enableWebSocket, *enableResolver),
14411438 ReadTimeout: 30 * time.Second,
14421439 WriteTimeout: 30 * time.Second,
14431440 }
+1-1
cmd/plcbundle/progress.go
···8181 pb.current = pb.total
8282 pb.currentBytes = pb.totalBytes
8383 pb.print()
8484- fmt.Fprintf(os.Stderr, "\n") // ← FIXED: Use stderr
8484+ fmt.Fprintf(os.Stderr, "\n")
8585}
86868787// print renders the progress bar (must be called with lock held)
+25-7
cmd/plcbundle/server.go
···318318 mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
319319 path := r.URL.Path
320320321321- // DID Resolution - delegate to specific handler
322322- if strings.HasPrefix(path, "/did:plc:") {
321321+ // DID Resolution - only if resolver is enabled
322322+ if resolverEnabled && strings.HasPrefix(path, "/did:plc:") {
323323 handleDIDEndpoint(w, r, mgr)
324324 return
325325 }
···332332 http.NotFound(w, r)
333333 })
334334335335- // Index JSON (reload from disk each time for fresh data during rebuild)
335335+ // Index JSON
336336 mux.HandleFunc("/index.json", func(w http.ResponseWriter, r *http.Request) {
337337- // Reload index to get latest data
338338- mgr.GetIndex() // This will refresh if needed
337337+ mgr.GetIndex()
339338 handleIndexJSON(w, mgr)
340339 })
341340···373372 fmt.Fprintf(w, "\nDID Index:\n")
374373 fmt.Fprintf(w, " Cached shards: %d/%d\n", didStats["cached_shards"], didStats["cache_limit"])
375374376376- // Force GC and show again
377375 runtime.GC()
378376 runtime.ReadMemStats(&m)
379377 fmt.Fprintf(w, "\nAfter GC:\n")
···394392 })
395393 }
396394397397- return mux
395395+ return corsMiddleware(mux)
398396}
399397400398// handleWebSocket streams all records via WebSocket starting from cursor
···1234123212351233 json.NewEncoder(w).Encode(auditLog)
12361234}
12351235+12361236+// corsMiddleware adds CORS headers to all responses
12371237+func corsMiddleware(next http.Handler) http.Handler {
12381238+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
12391239+ // Set CORS headers
12401240+ w.Header().Set("Access-Control-Allow-Origin", "*")
12411241+ w.Header().Set("Access-Control-Allow-Methods", "GET, OPTIONS")
12421242+ w.Header().Set("Access-Control-Allow-Headers", "Content-Type, Authorization")
12431243+ w.Header().Set("Access-Control-Max-Age", "86400") // 24 hours
12441244+12451245+ // Handle preflight OPTIONS request
12461246+ if r.Method == "OPTIONS" {
12471247+ w.WriteHeader(http.StatusNoContent)
12481248+ return
12491249+ }
12501250+12511251+ // Call the next handler
12521252+ next.ServeHTTP(w, r)
12531253+ })
12541254+}
+1-1
detector/detector.go
···3737 BundleNumber int
3838 Position int
3939 DID string
4040- CID string // ← Add this field
4040+ CID string
4141 Match *Match // nil if no match
4242 Error error
4343 DetectorName string