feat(inject): session-start emits synthesized prose instead of N rule lines#140
feat(inject): session-start emits synthesized prose instead of N rule lines#140
Conversation
…rose Session-start injection no longer emits per-rule [RULE:...] or cluster [CLUSTER:...] lines inside <brain-rules>. Instead it feeds the ranked lessons into prompt_synthesizer.synthesize_brain_injection, producing a single slot-grouped prose block (task → context → examples → persona → format → tone) with inline r:xxxx anchors for capture_learning attribution. The <brain-rules> wrapper tag stays so middleware, handoff, and sanitize contracts remain intact; only the body format changes. Persona baseline defaults to <brain_dir>/../domain/soul.md when present. Token budget enforced via GRADATA_SYNTH_BUDGET (default 400). Injection manifest (.last_injection.json) keeps the same schema — anchors computed by the synthesizer are the first 4 chars of the stable lesson id, matching what the manifest records. test_cluster_injection.py: migrated 9 tests that asserted the legacy line format to the new contract (anchors survive, slot labels present, no [CLUSTER:]/[RULE:] prefixes). 80 injection-adjacent tests green; full suite 3931 pass / 2 skip.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary
WalkthroughRefactored brain rules injection from simple line concatenation to synthesized XML structure. New logic filters out rules covered by meta mutex, sanitizes rule descriptions for XML, injects per-rule metadata fields ( Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
PR #136 "99.2% reduction (5513→42)" stacked legit format compressions (strip YAML/XML wrappers, dedup, compact [P:0.83]→[P83], snippet/top_k tuning) on top of 6 knob-cuts that quietly removed product behavior: - GRADATA_WISDOM_MAX_RULES default 3 → 9 (undo 0bb2de9 + 5eabc48) - GRADATA_WISDOM_FULL default 0 → 1 (undo d387de9 Active guidance strip) - JIT DEFAULT_MAX_RULES 1 → 5 (undo 4a44+9582+dfab) - JIT DEFAULT_MIN_CONFIDENCE 0.90 → 0.60 (undo 699827a) - Restore [Pxx] state+confidence prefix on JIT output (undo 50b63d1) - Restore [fb:neg,rem] implicit_feedback signal injection (undo 61b43c8) Honest milestone: d372132 (last pure-compression commit) measured 1724 weighted tokens vs 5513 baseline = 69% reduction. The further jump to 42 came from defeaturing, not compression. Post-revert measurement with synthesizer (PR #140) stacked: weighted=1179, session_once=154, per_turn=102.5 = 79% honest reduction vs 5513 baseline, all 6 features restored. Test updates: 3 implicit_feedback tests now assert returned signal strings instead of None. Co-authored-by: Gradata <noreply@gradata.ai>
Summary
Wires
prompt_synthesizer.synthesize_brain_injectioninto the session-start injection hook. Fixes the autoresearch regression where the 99.2% token optimization landed on the legacy N-rules path instead of the intended synthesizer.inject_brain_rules.py: the<brain-rules>block no longer contains per-rule[RULE:...]or cluster[CLUSTER:...]lines. It now carries a single slot-grouped prose block in Preston-Rhodes order (task → context → examples → persona → format → tone), with inliner:xxxxanchors preserved forcapture_learning.pyattribution.<brain-rules>...</brain-rules>still wraps the content, so middleware, handoff, sanitize, and MCP contracts do not break.<brain_dir>/../domain/soul.mdwhen present; otherwise empty.GRADATA_SYNTH_BUDGETenv var (default 400) drops lowest-priority slots first..last_injection.jsonstill keys by 4-char anchor; the synthesizer emits the same anchors (first 4 chars of stable lesson id).Test plan
tests/test_cluster_injection.py— 9 tests migrated from legacy line-format assertions to the new contract (anchor count, slot labels, no[CLUSTER:]/[RULE:]prefixes). 14 pass.tests/test_hooks_learning.py,tests/test_lesson_applications.py,tests/test_jit_inject.py— all pass unchanged; they test the wrapper tag, not the body.pytest tests/).Follow-up: rerun autoresearch against the synthesizer with the correct metric.
Generated with Gradata