Skip to content

feat(telemetry): bug_causality table + reconstruction job (bo-s1kb)#26

Merged
scbrown merged 1 commit into
mainfrom
bo-s1kb-bug-causality
Jun 27, 2026
Merged

feat(telemetry): bug_causality table + reconstruction job (bo-s1kb)#26
scbrown merged 1 commit into
mainfrom
bo-s1kb-bug-causality

Conversation

@scbrown

@scbrown scbrown commented Jun 27, 2026

Copy link
Copy Markdown
Owner

bo-s1kb — bug_causality table + caused_by reconstruction job (telemetry Phase 0)

Adds the supervised signal for "risky change" in the feature↔code↔bug reconcile/predict loop (GH#9): a bug_causality table reconstructing which prior commit most likely introduced the bug a later bead fixed.

Changes

  • New table bug_causality (bug_id, culprit_sha, culprit_bead_id, file, confidence, created_at) with UNIQUE(bug_id, culprit_sha, file) for idempotent re-runs.
  • New CLI bobbin bead reconstruct-causality [--bug <id>] [--limit N]. For each bug bead: gather the files its fix touched, find the most-recent prior commit touching each file (candidate culprit), and score confidence by how much of the fix's changeset that commit overlaps (concentrated blame ⇒ higher confidence). Upserts one row per (bug, culprit_sha, file).
  • Store methods: prior_lineage_touching_files (json_each over touched_files), record_bug_causality (upsert), list_bug_causality, distinct_lineage_bead_ids (bug discovery via the lineage bead_type column, falling back to bd show).
  • Docs: new cli/bead.md page documenting the whole bead command family (link / auto-link / reconstruct-causality / history) + SUMMARY entry.

Test

  • cargo test --bin bobbin green (852 tests).
  • Pure reconstruct_culprits heuristic unit-tested (most-recent wins, confidence scales with overlap, unrelated files / empty sha ignored).
  • Store path tested end-to-end against sqlite: json_each lookup, upsert idempotency (re-record refreshes confidence, no dup), distinct_lineage_bead_ids.

Scope / design call for dearing

v1 is the recency + file-overlap heuristic over bead_lineage. Two parts of the original AC are deliberately deferred:

  1. Git-blame sharpening to the exact introducing commit (blame removed lines of the fix) — a confidence refinement, not required for the signal.
  2. change_events outcome labeling (introduced_bug label + time-to-first-bug) — change_events has no table anywhere in the codebase yet; this needs a schema decision before it can be built.

Neither blocks the supervised signal this table provides. Flagging #2 as a design call.

Depends on bo-xrsy (#23, merged) for the lineage numstat/symbol fields.

CI Style check (Vale) failure is pre-existing doc debt, unrelated (per #22#25).

🤖 Generated with Claude Code

Adds the supervised "risky change" signal for the reconcile/predict loop
(GH#9). New bug_causality(bug_id, culprit_sha, culprit_bead_id, file,
confidence, created_at) table, populated by a new CLI job.

- `bobbin bead reconstruct-causality [--bug <id>] [--limit N]`: for each
  bug bead, gather the files its fix touched, find the most-recent prior
  commit touching each file (the candidate culprit), and score confidence
  by how much of the fix's changeset that commit overlaps. Upserts one row
  per (bug, culprit_sha, file).
- Idempotent via UNIQUE(bug_id, culprit_sha, file) — periodic re-runs
  refresh confidence rather than duplicate.
- Store methods: prior_lineage_touching_files (json_each over
  touched_files), record_bug_causality (upsert), list_bug_causality,
  distinct_lineage_bead_ids (bug discovery).
- Pure reconstruct_culprits heuristic is unit-tested; store path tested
  end-to-end against sqlite (json_each, upsert idempotency).
- Documents the bead command family in a new cli/bead.md page.

SCOPE: v1 is the recency+overlap heuristic. Git-blame sharpening of the
exact introducing commit and change_events outcome-labeling
(time-to-first-bug) are deferred — change_events has no table yet; flagged
to dearing as a design call. Neither blocks the supervised signal.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011y4bHA4rPftj9dPSwi7FvH
@scbrown
scbrown merged commit ac6afce into main Jun 27, 2026
4 of 5 checks passed
@scbrown
scbrown deleted the bo-s1kb-bug-causality branch June 27, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant