{"record":{"id":"ff0f6d156610ae80","repo":"gastownhall/beads","slug":"failed-to-verify-eligibility-w","errorCode":null,"errorMessage":"failed to verify eligibility: %w","messagePattern":"failed to verify eligibility: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compact/compactor.go","lineNumber":96,"sourceCode":"\t}\n\n\treturn &Compactor{\n\t\tstore:      store,\n\t\tsummarizer: haiClient,\n\t\tconfig:     config,\n\t}, nil\n}\n\n// CompactTier1 compacts a single issue at Tier 1 (basic summarization).\nfunc (c *Compactor) CompactTier1(ctx context.Context, issueID string) error {\n\tif ctx.Err() != nil {\n\t\treturn ctx.Err()\n\t}\n\n\t// Check eligibility before fetching issue (fail fast)\n\teligible, reason, err := c.store.CheckEligibility(ctx, issueID, 1)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to verify eligibility: %w\", err)\n\t}\n\tif !eligible {\n\t\tif reason != \"\" {\n\t\t\treturn fmt.Errorf(\"issue %s is not eligible for Tier 1 compaction: %s\", issueID, reason)\n\t\t}\n\t\treturn fmt.Errorf(\"issue %s is not eligible for Tier 1 compaction\", issueID)\n\t}\n\n\tissue, err := c.store.GetIssue(ctx, issueID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to fetch issue: %w\", err)\n\t}\n\n\t// Calculate original size\n\toriginalSize := len(issue.Description) + len(issue.Design) + len(issue.Notes) + len(issue.AcceptanceCriteria)\n\n\tif c.config.DryRun {\n\t\treturn fmt.Errorf(\"dry-run: would compact %s (original size: %d bytes)\", issueID, originalSize)","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/compact/compactor.go#L78-L114","documentation":"CompactTier1 first asks the store whether the issue can be compacted via CheckEligibility. If that store call itself returns an error (not an 'ineligible' verdict), the compaction is aborted with this wrapped error. It signals a storage/backend failure, not a policy rejection.","triggerScenarios":"store.CheckEligibility(ctx, issueID, 1) returns a non-nil error — e.g. database connection failure, the issues table is missing, the issue ID lookup itself errored at the storage layer, or the context is cancelled mid-query.","commonSituations":"Dolt/SQLite database not initialized or corrupted; running `bd compact` before `bd init`; network/database outage; context deadline exceeded during the eligibility query.","solutions":["Inspect the wrapped error for the storage-layer root cause","Verify the database exists and is reachable (bd doctor / check .beads directory)","Retry after the database/connection recovers","Check the context passed in has not already timed out"],"exampleFix":"// before\nif err := c.CompactTier1(ctx, id); err != nil { log.Fatal(err) }\n// after\nif err := ctx.Err(); err != nil { return err }\nif err := c.CompactTier1(ctx, id); err != nil {\n    if errors.Is(err, sql.ErrConnDone) || ctx.Err() != nil { /* retry or abort cleanly */ }\n    return err\n}","handlingStrategy":"retry","validationCode":"if err := ctx.Err(); err != nil { return err }\nif _, err := os.Stat(\".beads\"); err != nil { return fmt.Errorf(\"database not initialized\") }","typeGuard":null,"tryCatchPattern":"err := c.CompactTier1(ctx, id)\nif err != nil && strings.Contains(err.Error(), \"failed to verify eligibility\") {\n    // storage-layer issue: retry after backoff\n    time.Sleep(time.Second)\n    err = c.CompactTier1(ctx, id)\n}\nreturn err","preventionTips":["Run `bd doctor` before batch compaction to verify database health","Ensure the database is initialized and reachable before compacting","Use a context with a sane deadline, not one already near expiry","Retry eligibility errors with backoff — they are usually transient storage faults"],"tags":["go","storage","database","precondition-check"],"backgroundTag":"storage-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}