Skip to main content

Module session_mined

Module session_mined 

Source
Expand description

Session-mined candidate rules.

The local worker turns session transcripts into candidate rules:

  1. A SessionEnd / Stop / N-turn watermark fires the local worker (see difflore-cli/src/session_mine/).
  2. The worker pulls the last few user-prompt / assistant-text pairs from the platform transcript, strips tool calls + thinking blocks, and hands them to a small LLM gate (Haiku-class).
  3. The gate verdict is either KEEP (a brand-new reusable rule) or MERGE: (an extension of an existing rule). In either case the worker enqueues a SessionMinedCandidate on cloud_outbox with kind = "session_mined_candidate".
  4. The cloud clusters those rows into draft candidate_rules with origin = 'session_mined' and requires_human_approval = true.

Structs§

SessionMinedCandidate
Wire format for one session-mined candidate. Serialised verbatim into cloud_outbox.payload_json under kind = "session_mined_candidate".
SessionMinedCandidateArgs
Builder bundle accepted by SessionMinedCandidate::try_new. Kept as a struct (rather than a long argument list) so future fields can be added without breaking call sites.

Enums§

CandidateError
Errors a SessionMinedCandidate can fail validation with. Returned by the constructor / validate so the worker can swallow invalid candidates without retrying through the outbox.

Constants§

BODY_MAX_CHARS
Cap on body (chars, not bytes). 2 KB is enough for a 3-5 sentence rule body with a snippet; anything longer is almost certainly the raw transcript text the gate failed to compress.
MAX_FILE_PATTERNS
Maximum number of file glob patterns we will accept from the gate. 1-3 is the sweet spot: a single broad glob is too noisy, more than three usually means the gate failed to localise the rule.
ORIGIN
Stable origin tag for the candidate-rule pipeline.
TITLE_MAX_CHARS
Cap on title (chars, not bytes). Matches the existing Observation::title convention so cloud-side renderers can share truncation logic.

Functions§

compute_content_hash
sha256(source_repo|title|body)[:16] as lowercase hex. Mirrors the 16-char convention used by Observation::content_hash and remember_rule so cloud-side dedup logic doesn’t need a separate hash family.