/** * Commit-message claim extractor — v0.4 Step 4 (Stream A). * * Extends the v0.3 docstring extraction pattern to commit messages * as a third claim source alongside ADRs (v0.1) + docstrings (v0.3). * Architectural-intent claims found in git commit messages augment * the atlas's intent registry without requiring curated ADRs. * * Architectural pattern (per Step 4 design lock): ADR-style * attribution, NOT docstring-style. Commit messages are free-form * prose claims about architectural decisions. `symbol_candidates` * extracted via existing `EXTRACTION_PROMPT` and resolved via * `resolveCandidates` against the symbol inventory — same code path * as ADR claims. There is no "documented symbol provenance" channel * because commits have no a priori symbol anchor. * * Filter discipline (per OQ5 lock; default conservative): prefix- * match anchoring requires architectural-intent keyword AT START of * subject. `design: ...` matches; `Implement design for ...` does * not. False-positives are worse than false-negatives — a non- * architectural commit yielding a non-architectural claim pollutes * the atlas. * * Idempotency (per Q5 lock): keyed on commit SHA via `source_shas` * table. Re-running extraction skips commits already in * `source_shas`. EXTRACTION_PROMPT changes during development will * NOT retroactively update old commits' claims; explicit force-re- * extract flag is v0.5+ scope. * * NOT in v0.4: `extraction.commit_message_max` config field for * huge-repo budget gating; force-re-extract flag. Both v0.5+ * candidates. * * Per [`v0.4-SCOPE.md`](../../v0.4-SCOPE.md) Stream A commit-message * extraction subsection. Bimodal-aware Q3 threshold (≥30/repo on at * least 2 of 3 repos AND any single repo above 50) determines atlas * integration vs deferral per Step 5 re-extraction outcomes. */ import type { DatabaseInstance } from "../storage/db.js"; import type { ContextAtlasConfig } from "../types.js"; import { type ExtractionClient } from "./anthropic-client.js"; import { type UsageInfo } from "./pricing.js"; import { type SymbolInventory } from "./resolver.js"; /** * Predicate filtering commits to those carrying architectural-intent * signal. `subject` is the first line; `body` is everything after * (which may be empty). */ export type CommitFilter = (subject: string, body: string) => boolean; /** * Raw commit metadata as parsed from `git log` invocation. */ export interface CommitMetadata { readonly sha: string; readonly date: string; readonly author: string; readonly subject: string; readonly body: string; } /** * Subject-prefix-anchored patterns. Match if any fires against the * commit subject's leading text. Optional `(scope)` accommodates * conventional-commits style: `arch(api): extract user service`. * * Scope-doc OQ5 default-conservative discipline: short list, * prefix-anchored, no greedy keywords. Keywords like `feat` and * `fix` deliberately excluded — too noisy; conventional-commits * `feat:` rarely carries architectural intent. */ export declare const DEFAULT_SUBJECT_PREFIX_PATTERNS: readonly RegExp[]; /** * Body-anywhere patterns. The conventional-commits `BREAKING * CHANGE:` footer typically appears at body END (after a blank * line), per spec — first-200-char prefix scan would miss it. This * pattern scans the full body. * * Two-tier matching (per Q3 lock): subject prefix-match for the 6 * default patterns + whole-body scan for `BREAKING CHANGE:` * footer. */ export declare const DEFAULT_BODY_ANYWHERE_PATTERNS: readonly RegExp[]; /** * Build a CommitFilter from default patterns + user-augmented * patterns (per scope-doc Q5: augment-only semantics; user * patterns ADD to defaults rather than replacing). * * User patterns are tested against the subject + the first 200 * characters of the body — same surface as ADR-style intent * detection. Future replace-mode flag is a v0.5+ candidate. */ export declare function makeDefaultCommitFilter(userPatterns?: readonly string[]): CommitFilter; /** * Invoke `git log` and parse the output. Filter is applied to each * commit; non-matching commits are dropped before return. * * Edge cases: * - Empty repo (no commits): returns `[]`. * - Non-git directory: throws an actionable error. * - Shallow clone: returns whatever git log surfaces (the visible * subset). Documented limitation — atlas will see only the * shallow window's commits. * * `--no-merges` skips merge commits, which usually inherit body * text from a PR rather than carrying architectural-intent prose * directly. */ export declare function parseCommitLog(repoRoot: string, filter: CommitFilter): CommitMetadata[]; /** * Build the prose body fed to `EXTRACTION_PROMPT` for a commit. * Concatenates subject + body with a blank line separator. The * extraction-prompt path already prepends its own header; this * helper just produces the raw commit text. * * Empty body is fine (single-line commits are common); the prompt * then sees just the subject. */ export declare function buildCommitExtractionBody(commit: CommitMetadata): string; /** * Per-run summary stats from `extractCommitMessagesForRepo`. */ export interface CommitExtractionResult { /** Total commits returned by `git log --no-merges`. */ readonly commitsTotal: number; /** Commits that passed the architectural-intent filter. */ readonly commitsFiltered: number; /** Commits actually fed to the extraction client (skips idempotent). */ readonly commitsExtracted: number; /** Commits skipped because their SHA was already in source_shas. */ readonly commitsSkippedIdempotent: number; /** Total claims written (sum across all extracted commits). */ readonly claimsWritten: number; /** Claims with at least one resolved symbol candidate. */ readonly claimsWithSymbols: number; /** Cumulative API usage across all extraction calls. */ readonly totalUsage: UsageInfo; /** Per-commit errors (extraction client throws or malformed responses). */ readonly errors: ReadonlyArray<{ readonly sha: string; readonly error: string; }>; } /** * Extract architectural-intent claims from filtered git commit * messages and persist as `source: "commit:"` claims. * * Idempotency: each commit's SHA is keyed in `source_shas` after * successful extraction. Re-running this function skips commits * already recorded — re-extraction with a changed `EXTRACTION_PROMPT` * will NOT update old commits' claims; explicit force-re-extract * is v0.5+ scope (Q5 lock). * * Symbol attribution (per Q1 lock) follows the ADR-style pattern: * `symbol_candidates` come from the LLM's parse of the commit text; * `resolveCandidates` against the inventory yields concrete * `symbolIds`. Claims with zero resolved candidates are still * written with `symbolIds: []` — same fallback as ADR claims with * no resolved candidates. */ export declare function extractCommitMessagesForRepo(db: DatabaseInstance, repoRoot: string, config: Pick, inventory: SymbolInventory, anthropicClient: ExtractionClient): Promise; //# sourceMappingURL=commit-message-extractor.d.ts.map