Expand description
First-run auto-scan behavior for bugbot (PM-34).
When bugbot detects no prior state (.bugbot/state.db does not exist),
it automatically runs a lightweight scan to establish baselines. This scan
builds:
- Project call graph (cached for daemon)
- Per-file complexity and maintainability baselines
- Clone fragment index
- Temporal pattern database
Budget: <10s for a 50K LOC project (one-time cost). Runs ONCE, transparently,
on first bugbot check invocation.
§Baseline Policy
For files with no git history (new project, or new files in a monorepo), delta engines treat the “before” as empty:
- All current smells, clones, and complexity are “new” (reported)
- All current contracts are the baseline (no regression possible)
- Guard-removed and contract-regression produce no findings (no prior state)
§Progress Indication
Prints "Building initial baselines... (one-time, ~8s)" so users understand
why the first run is slow.
Structs§
- Baseline
Call Graph Meta - Metadata for a cached baseline call graph.
- Bugbot
State - Persisted state for bugbot across runs.
- First
RunResult - Result of a first-run baseline scan.
Enums§
- First
RunStatus - Result of checking whether this is a first run.
Functions§
- bugbot_
dir - Returns the path to the
.bugbot/directory for a given project root. - create_
state_ db - Create the
.bugbot/directory and write the initialstate.dbfile. - detect_
first_ run - Detect whether this is a first run by checking for
.bugbot/state.db. - load_
cached_ baseline_ call_ graph - Load a cached baseline call graph if the cache exists and was built from the expected commit.
- resolve_
git_ ref - Resolve a git ref (e.g. “HEAD”, “main”, “origin/main”) to a full commit hash.
- run_
first_ run_ scan - Run the first-run baseline scan.
- save_
baseline_ call_ graph - Save a baseline call graph to
.bugbot/baseline_call_graph.json. - state_
db_ path - Returns the path to the state database file for a given project root.