Skip to content

feat(jit): per-call rule injection hook with draft-relevance ranking#68

Merged
Gradata merged 2 commits intomainfrom
wt-jit-rule-injection
Apr 15, 2026
Merged

feat(jit): per-call rule injection hook with draft-relevance ranking#68
Gradata merged 2 commits intomainfrom
wt-jit-rule-injection

Conversation

@Gradata
Copy link
Copy Markdown
Owner

@Gradata Gradata commented Apr 15, 2026

Summary

Just-in-time rule injection as opt-in alternative to session-start bulk injection. Hooks UserPromptSubmit (composes with existing context_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 env
  • tests/test_jit_inject.py — 32 tests
  • hooks/hooks.json — registers new UserPromptSubmit entry

Config

  • 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

  • 5758ef3 feat(jit): per-call rule injection hook with draft-relevance ranking
  • 8fa9a7e refactor(jit): drop redundant zero-intersection branch in _jaccard

Follow-up

Shared parse_lessons helper with inject_brain_rules.py — blocked by PR #45 NO-TOUCH, unblocks now that #45 is merged.

Co-Authored-By: Gradata noreply@gradata.ai

Gradata and others added 2 commits April 15, 2026 00:15
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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

@Gradata has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 9 minutes and 16 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 07427c4d-7d53-485b-86fe-f0d2db036415

📥 Commits

Reviewing files that changed from the base of the PR and between 5fd7215 and 8fa9a7e.

📒 Files selected for processing (3)
  • hooks/hooks.json
  • src/gradata/hooks/jit_inject.py
  • tests/test_jit_inject.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch wt-jit-rule-injection

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gradata has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying gradata-dashboard with  Cloudflare Pages  Cloudflare Pages

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

View logs

@Gradata Gradata merged commit 689ebe3 into main Apr 15, 2026
9 of 16 checks passed
@Gradata Gradata deleted the wt-jit-rule-injection branch April 17, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant