Skip to content

feat(mine): ADR-candidate mining from local git history (kb mine, slice 1)#30

Merged
v0ropaev merged 1 commit into
masterfrom
feat/adr-mining
Jul 7, 2026
Merged

feat(mine): ADR-candidate mining from local git history (kb mine, slice 1)#30
v0ropaev merged 1 commit into
masterfrom
feat/adr-mining

Conversation

@v0ropaev

@v0ropaev v0ropaev commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What

New key-gated LLM pass kb mine (kb.extract.semantic.mine, mirror of kb describe): walks the local first-parent history from the latest indexed commit (--sha / --max-commits / --force) and extracts the decision each commit records from its message plus its changed code — the last substantive roadmap item before more-languages, slice 1 (local git only).

The D5 bridge (the design core)

DESIGN said both "ADRs are NOT extractable from code" (§4) and "no artifact without ≥ 1 code span" (D5, LOCKED) — unresolved until now. The bridge: a decision artifact is grounded on the spans its source commit changed (changed_span_ids(C, parent); role changed; root commits mine against the empty tree). The commit message is stored verbatim in the payload as a fact — immutable, pinned by the sha in the deterministic decision:{sha} key — context, never grounding. Claims pass the same deterministic validate_claims floor as describe: fabricated claims dropped, no survivors → nothing stored, confidence = kept/(kept+dropped), trust stays LOW.

Behavior

  • Merge commits skipped (their prose belongs to the future PR-mining slice); unindexed commits skipped; docs-only commits never pay an LLM call.
  • Oversized grounding sets capped at 40 spans with a retro-flag (grounding_capped + total_changed_spans) — bounded, never silent.
  • One transaction per commit (crash-safe); re-runs skip already-mined commits (LLM-cost idempotency); --force re-mines but content-addressing keeps the ids.
  • No schema migration: the sha pins the immutable message, so the payload carries it.

Gates

New HARD gate adr_mining_test (stub LLM, offline): grounded claim kept / adversarial fabricated claim dropped; provenance limited to the commit's touched files; root grounded on the whole initial tree; a commit whose changed code backs no claim stores nothing; docs-only provably skips the LLM (call counter); merges skipped; re-mining idempotent (same artifact ids). Headline HARD gates: fourteen → fifteen. make_git_repo fixtures accept per-commit messages (backwards-compatible).

Local: ruff clean, mypy --strict clean, pytest -q → 109 passed, 1 skipped.

Next

PR-description mining (network slice); release cut later per cadence.

…ce 1)

Resolves the DESIGN tension between D5 (>= 1 code-span grounding,
LOCKED) and "ADRs are not extractable from code": a decision artifact
is grounded on the spans its source commit CHANGED (present at the
commit, absent at its first parent; role "changed"; root commits mine
against the empty tree), so prose-born knowledge still points at exact
code spans. The commit message is stored verbatim in the payload as a
fact - immutable, pinned by the sha in the deterministic logical key
(decision:{sha}) - context, never grounding.

kb mine is a separate key-gated LLM pass (mirror of kb describe):
first-parent walk from the latest indexed commit, merge commits
skipped (PR mining is a future network slice), unindexed commits
skipped, docs-only commits never pay an LLM call, oversized grounding
sets capped with a retro-flag, one transaction per commit (crash-safe),
re-runs skip already-mined commits. Claims pass the same deterministic
validate_claims floor; no survivors -> nothing stored;
confidence = kept/(kept+dropped); trust stays LOW.

New HARD gate adr_mining_test (stub LLM, offline): grounded claim kept,
fabricated claim dropped, provenance limited to touched files, root
grounded on the whole initial tree, no-claim commit stores nothing,
merge skipped, re-mining idempotent. Headline HARD gates: fourteen ->
fifteen. make_git_repo fixtures accept per-commit messages.
@v0ropaev v0ropaev merged commit 0a9d2ff into master Jul 7, 2026
4 checks passed
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