Evidence

harvest_pairs()

Harvests incorrect-edit/correction pairs around anchor.

Usage

Source

harvest_pairs(
    activity,
    anchor,
    *,
    lookback_turns=40,
    lookahead_turns=120,
    max_candidates=12,
    repo=None
)

Takes up to max_candidates edits before the anchor, newest first, and pairs each with its best session correction. When repo is given and a candidate has no session correction, falls back to git pickaxe on the candidate’s most distinctive hunk.

Returns

CandidatePair

One pair per candidate, newest candidate first. An empty tuple is the

legitimate no-code outcome — the anchor’s window contains no edits —

tuple[CandidatePair, …]
distinct from ~cc_transcript.discovery.TranscriptExpiredError.

match_corrections()

Session corrections for edit, ranked by overlap descending.

Usage

Source

match_corrections(activity, edit, *, lookahead_turns)

Scans same-file edits after edit within lookahead_turns and keeps only candidates whose old side overlaps what edit wrote (overlap > 0).

git_corrections()

Corrections to hunk found in repo’s git history.

Usage

Source

git_corrections(repo, hunk, *, path, since, max_commits=5)

Pickaxes (git log -S) for the longest non-empty line of hunk.new in path since since, then parses each hit’s git show unified diff into hunks. Read-only by construction — rev-parse, log, and show only. Discovery-level failures — rev-parse or log failing, git being absent, or a timeout — yield (); a failed show skips just that commit and keeps the rest.

record_harvest()

Records pairs harvested around anchor into the shared ledger.

Usage

Source

record_harvest(log, activity, anchor, pairs, *, source)

Lowers each CandidatePair to a ~cc_transcript.corrections.Correction — resolving the incorrect edit’s raw tool call to the cross-language incorrect_digest — and appends it. Idempotent: re-recording the same harvest writes nothing new.

Returns

int
The number of corrections appended this call.

CandidatePair

One incorrect-edit candidate and its best-matching correction.

Usage

Source

CandidatePair(incorrect, correction, overlap)

Provenance is read off the correction’s type: an ~cc_transcript.activity.Edit came from the session, a GitFix from git history, and None means no correction was found.

Attributes

incorrect: Edit

The candidate edit under suspicion.

correction: Edit | GitFix | None

The best-matching correction, if any.

overlap: float
The hunk-overlap score linking the two; 0.0 when correction is None.

GitFix

A correction found in git history rather than the session.

Usage

Source

GitFix(file_path, hunks, commit, committed_at)

Deliberately not an ~cc_transcript.activity.Edit — a commit has no honest EventRef or turn coordinates.

Attributes

file_path: str

The file the commit touched.

hunks: tuple[Hunk, …]

The commit’s before/after hunks for that file.

commit: str

The full commit hash.

committed_at: datetime
The commit time, timezone-aware.