···4747 // Used for write-through caching after successful PDS mutations.
4848 UpsertWitnessRecord(ctx context.Context, did, collection, rkey, cid string, record json.RawMessage) error
49495050+ // UpsertWitnessRecordBatch inserts or updates multiple records in a single
5151+ // transaction. Used for bulk operations like refresh/backfill.
5252+ UpsertWitnessRecordBatch(ctx context.Context, records []WitnessWriteRecord) error
5353+5054 // DeleteWitnessRecord removes a record from the cache.
5155 // Used for write-through caching after successful PDS deletions.
5256 DeleteWitnessRecord(ctx context.Context, did, collection, rkey string) error
5357}
5858+5959+// WitnessWriteRecord holds the fields needed to upsert a record into the witness cache.
6060+type WitnessWriteRecord struct {
6161+ DID string
6262+ Collection string
6363+ RKey string
6464+ CID string
6565+ Record json.RawMessage
6666+}
···8383 )
8484}
85858686+// SqliteSpan starts a span for a SQLite operation with standard attributes.
8787+// Returns a no-op span if there is no parent span in ctx.
8888+func SqliteSpan(ctx context.Context, op, table string) (context.Context, trace.Span) {
8989+ if !trace.SpanFromContext(ctx).SpanContext().IsValid() {
9090+ return ctx, trace.SpanFromContext(ctx)
9191+ }
9292+ return tracer().Start(ctx, "sqlite."+op,
9393+ trace.WithAttributes(
9494+ attribute.String("db.system", "sqlite"),
9595+ attribute.String("db.operation", op),
9696+ attribute.String("db.sql.table", table),
9797+ ),
9898+ )
9999+}
100100+101101+// HandlerSpan starts a span for a logical operation within a handler.
102102+// Use this to group related work (e.g. a refresh loop) under a single span.
103103+func HandlerSpan(ctx context.Context, name string, attrs ...attribute.KeyValue) (context.Context, trace.Span) {
104104+ return tracer().Start(ctx, name, trace.WithAttributes(attrs...))
105105+}
106106+86107// EndWithError records an error on a span and sets its status.
87108// If err is nil, this is a no-op.
88109func EndWithError(span trace.Span, err error) {