Module knowledge_islands
Expand description
knowledge-islands analysis — automatic bus-factor / knowledge-loss
detection per file.
§What this signal tells you
For each currently-live file, surfaces the highest-risk
knowledge-loss cases: files where the primary author (by LoC added)
has effectively departed (--departed-threshold-days, default 90)
AND no other contributor owns a substantial share (default 10%).
These are the files that would become unmaintainable if you needed
to ship a fix tomorrow — the people who could fix them have already
left.
§Why this is CodeLore’s strategic differentiator
Industry behavioural-code-analysis tools have two of the three ingredients for this signal:
CodeScene’s Knowledge Distribution + Bus Factor: identifies primary owners but requires you to manually mark each “Ex-Developer” in a list. Maintaining that list is organisational labour — and dashboards stay wrong until someone updates them after every offboard.code-maat: has none of the three (no departure detection, no bus-factor analysis).GitHub Insights: shows contributor counts but no risk modeling.
CodeLore ships all three automatically:
- Primary-author detection (existing
ownershipanalysis logic — author with max LoC added per file). - Departed-author detection (new —
commits.canonical_authorgrouped byMAX(commits.date)falloff >--departed-threshold-days). - Substantial-other-owner check (new —
n_substantial_others= count of authors with ≥ 10% LoC share on the file, excluding the main author).
§Output columns (modern default)
entity— the file path (or canonical-lineage entity under--use-canonical-lineage).main_author— author with max LoC added on the file (alphabetical-first tiebreak; deterministic).ownership_pct—main_authorLoC share of the file (0–100, two decimals).days_since_main_active— days sincemain_author’s most-recent commit anywhere in the repo (not just on this file).last_main_author_commit— calendar date (YYYY-MM-DD) of that most-recent commit.n_substantial_others— count of other authors with ≥ 10% LoC share on this file. Zero is the actionable signal.total_loc— total LoC across all (non-bot) authors on this path, theownership_pctdenominator. Lets a consumer judge whether e.g.ownership_pct: 100.0comes from a thin sample.
Sort: ownership_pct DESC, days_since_main_active DESC, entity ASC.
Highest-concentration-then-longest-departed first — exactly the
triage order a tech lead wants.
§Practitioner heuristics
ownership_pct > 80+n_substantial_others = 0+is_departed = true: red flag. Find someone to learn this file BEFORE you need to ship a fix.ownership_pct < 50: ownership is genuinely diffuse; bus factor is healthy regardless of any one departure.days_since_main_activebetween 60 and 90: gray zone. May be sabbatical / between projects rather than permanent departure. Lower--departed-threshold-daysto see these flagged.
Research basis: see docs/research-foundations.md entry
“knowledge-islands” (Bird et al., FSE 2011 — original n-authors risk
indicator; Avelino et al., SANER 2016 — Truck Factor estimation;
Cosentino et al., CHASE 2015 — bus-factor measurement; CodeScene
— productisation reference with the modernise-don’t-migrate
improvement of automatic departure detection).
Structs§
- Knowledge
Island Row - Owner
Activity - Un-thresholded per-path owner-activity snapshot — the same
ownership/activity primitive behind
KnowledgeIslandRow, but returned for every requested path regardless of how recently the main author committed. Callers (e.g. the agent-loop pre-write briefing) decide what counts as “departed” by comparingdays_since_main_activeagainst their own threshold.
Functions§
- count_
live_ files - Count files present at HEAD — the live-tree prevalence denominator.
- owner_
activity_ for_ paths - Batched, un-thresholded owner-activity lookup for an arbitrary set of
paths: the same ownership/activity primitive
run_knowledge_islandscomputes internally, but returned for every path with LoC-attributable ownership — not just the ones already pastdeparted_threshold_days. The caller (e.g. a pre-write briefing) comparesdays_since_main_activeto its own threshold. - run_
knowledge_ islands