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 whenprev_tsis None)LOWER(source_repo)in (alias set)status = 'active'— pending rules aren’t yet useful- ordered by
installed_atDESC — 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.dbfor up tolimitrules whoseinstalled_atis later thanprev_ts_ms(millis since epoch) AND whosesource_repomatches one ofrepo_aliases(case-insensitive). Whenprev_ts_msisNone, the time filter is dropped and we return thelimitmost recent rules for the repo — that’s the “first session ever” case where every rule learned to date is genuinely new to the user.