User authorized lifting CURRENT FAV whole-branch merge protection on 2026-09-23. Keep FAV_DEGRADED_READ/FAV_PUBLISHER_ENABLED default false. Drop duplicate goose 00034 (local_dev already has 00036). Preserve agentx workspace admin routes and pin-export wiring.
56 lines
1.4 KiB
Go
56 lines
1.4 KiB
Go
package artifactvault
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// TerminalRow is an authoritative DB terminal fact for backfill. Workspace paths are forbidden.
|
|
type TerminalRow struct {
|
|
Facts Facts
|
|
Request PublishRequest
|
|
MissingEvidence bool
|
|
Reason string
|
|
}
|
|
|
|
type BackfillReport struct {
|
|
Created int
|
|
Reused int
|
|
Quarantine int
|
|
Excluded int
|
|
}
|
|
|
|
func Backfill(ctx context.Context, reg Registry, rows []TerminalRow, exclude map[string]string) (BackfillReport, error) {
|
|
var out BackfillReport
|
|
for _, row := range rows {
|
|
if row.MissingEvidence || len(row.Request.Payload) == 0 {
|
|
_ = reg.Quarantine(ctx, nz(row.Reason, "missing_evidence"), row.Request.LogicalResourceID)
|
|
out.Quarantine++
|
|
continue
|
|
}
|
|
if reason, ok := exclude[row.Request.LogicalResourceID]; ok && reason != "" {
|
|
out.Excluded++
|
|
continue
|
|
}
|
|
before := reg.Coverage(ctx).Required
|
|
if _, _, err := reg.Request(ctx, row.Facts, row.Request); err != nil {
|
|
_ = reg.Quarantine(ctx, err.Error(), row.Request.LogicalResourceID)
|
|
out.Quarantine++
|
|
continue
|
|
}
|
|
if reg.Coverage(ctx).Required == before {
|
|
out.Reused++
|
|
continue
|
|
}
|
|
out.Created++
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func ValidateBackfillRow(row TerminalRow) error {
|
|
if row.Request.SourceEventID == "" || row.Request.LogicalResourceID == "" {
|
|
return fmt.Errorf("artifactvault: backfill row missing source identity")
|
|
}
|
|
return nil
|
|
}
|