Skip to main content

Module query

Module query 

Source
Expand description

SQL for “new rules since prev_ts, scoped to this repo”.

Reads canonical rules from ~/.difflore/data.db (the global rule ledger; per-project context indexes are a separate concern that the banner doesn’t need). We filter source_repo against the current repo’s aliases so a user in acme/billing doesn’t get spammed with rules learned in acme/notifier.

The query is deliberately narrow:

  • installed_at > prev_ts (or all rows when prev_ts is None)
  • LOWER(source_repo) in (alias set)
  • status = 'active' — pending rules aren’t yet useful
  • ordered by installed_at DESC — most recent first
  • LIMIT ? — banner shape ceiling

created_at in the rule_events stream is one floor lower (it captures every state change); for “new since last session” the right grain is rule creation, which lives on skills.installed_at. Using rule_events would surface confidence-bumps as “new rules” and make the banner noisy.

Structs§

NewRule
One row in the banner. Title + provenance fragment (“from PR review by alice”, “from PR merge signature”, “manual difflore rules add”). The render module is free to truncate either field — both are passed through verbatim from the DB and may be long.

Functions§

new_rules_since
Query data.db for up to limit rules whose installed_at is later than prev_ts_ms (millis since epoch) AND whose source_repo matches one of repo_aliases (case-insensitive). When prev_ts_ms is None, the time filter is dropped and we return the limit most recent rules for the repo — that’s the “first session ever” case where every rule learned to date is genuinely new to the user.