feat(jit): per-call rule injection hook with draft-relevance ranking#68
feat(jit): per-call rule injection hook with draft-relevance ranking#68
Conversation
SessionStart injection picks top-N rules once for the whole session. JIT flips the axis: on every user prompt, score each graduated rule against the draft with a cheap Jaccard on word-unigrams and inject only the top-k that match THIS draft. Saves context budget, tightens per-prompt relevance. Gated by env var GRADATA_JIT_ENABLED (default false) so existing SessionStart behavior is unchanged for anyone who hasn't opted in. When both are active they complement: SessionStart = broad priors, JIT = tight per-prompt overlay. Emits JIT_INJECTION events to brain/events.jsonl for telemetry. Rule must clear both confidence floor (0.60 default) and similarity floor (0.05 default); rather inject zero rules than noise, same philosophy as the PR #45 source-filter gate. Hook wired as an additional UserPromptSubmit entry alongside context_inject so the two complement rather than collide. Co-Authored-By: Gradata <noreply@gradata.ai>
Division by len(a|b) already yields 0.0 when intersection is empty. The early return was dead code. Co-Authored-By: Gradata <noreply@gradata.ai>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 16 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Deploying gradata-dashboard with
|
| Latest commit: |
8fa9a7e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9d566286.gradata-dashboard.pages.dev |
| Branch Preview URL: | https://wt-jit-rule-injection.gradata-dashboard.pages.dev |
Summary
Just-in-time rule injection as opt-in alternative to session-start bulk injection. Hooks
UserPromptSubmit(composes with existingcontext_inject), ranks rules by Jaccard similarity to the draft, injects only top-k relevant rules.Files
src/gradata/hooks/jit_inject.py(new) —<brain-rules-jit>output, configurable via envtests/test_jit_inject.py— 32 testshooks/hooks.json— registers newUserPromptSubmitentryConfig
GRADATA_JIT_ENABLED(default false)GRADATA_JIT_MAX_RULES(5)GRADATA_JIT_MIN_CONFIDENCE(0.60)GRADATA_JIT_MIN_SIMILARITY(0.05)Tests
2289 pass (+32), ruff clean.
Commits
5758ef3feat(jit): per-call rule injection hook with draft-relevance ranking8fa9a7erefactor(jit): drop redundant zero-intersection branch in_jaccardFollow-up
Shared
parse_lessonshelper withinject_brain_rules.py— blocked by PR #45 NO-TOUCH, unblocks now that #45 is merged.Co-Authored-By: Gradata noreply@gradata.ai