chore: wire dormant rules.injected emit + gitignore S105 orphans#88
Merged
chore: wire dormant rules.injected emit + gitignore S105 orphans#88
Conversation
(c) Wire dormant emitter ------------------------ SessionHistory in integrations/session_history.py subscribes to `rules.injected` but nothing in the codebase ever emits it — grep of the whole tree shows only the subscriber. That leaves its per-session rule effectiveness tracking (compute_effectiveness / on_session_ended) silently dead. brain.apply_brain_rules() now fires the event on the in-memory bus after format_rules_for_prompt(applied). Cache hits skip the emit intentionally: SessionHistory dedups via a set, the cache is per scope, and every fresh scope hits the compute path. The other two events SessionHistory subscribes to (correction.created, session.ended) already have emitters — checked at _core.py:138, 574, 854. So this is the one missing wire. Regression test: test_apply_brain_rules_emits_rules_injected — seeds a graduated TONE rule through a real correct() loop, subscribes a SessionHistory to the brain's bus, calls apply_brain_rules, asserts the injected set is populated. (b) Gitignore on-disk orphans ----------------------------- Three untracked leftovers from the S105 repo splits keep showing up in `git status` and sometimes get accidentally re-added: - /cloud/ moved to private Gradata/gradata-cloud (#76) - /sdk/ superseded by the flattened layout (#65) - /railway.toml now lives in gradata-cloud/cloud/railway.toml Also added apollo-leads-*.csv since sales exports have leaked into the repo root before and belong in brain/leads/, not the SDK tree. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
|
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 (3)
📝 Walkthrough
WalkthroughThe changes add event emission to rule application in the Brain class when rules are successfully applied, update gitignore to exclude additional orphaned artifacts and stale config files, and introduce a regression test to verify the new event is properly emitted and observed by SessionHistory. Changes
Sequence DiagramsequenceDiagram
participant Test
participant Brain
participant Bus
participant SessionHistory
Test->>Brain: apply_brain_rules("write an email")
activate Brain
Brain->>Brain: format & apply rules
Note over Brain: applied is non-empty
Brain->>Bus: emit("rules.injected",<br/>{"rules": [...], "task": ...})
deactivate Brain
Bus->>SessionHistory: rules.injected event
activate SessionHistory
SessionHistory->>SessionHistory: update injected_this_session
deactivate SessionHistory
Test->>SessionHistory: assert injected_this_session<br/>has rule IDs
SessionHistory-->>Test: ✓ verified
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Gradata
added a commit
that referenced
this pull request
Apr 15, 2026
#88 landed at the same time as #86 and #87 shipping from a parallel session. The merges didn't conflict line-wise, but the diffs overlap: - brain.py:apply_brain_rules — #86 already wired `rules.injected` with a richer payload (id + category + confidence + state + scope) and try/except guard. #88 added a second thinner emit after the cache.put. Result: double-fire on fresh compute. Harmless in practice — SessionHistory dedups via a set — but clearly wrong. Removing #88's emit, keeping #86's. - .gitignore — #87 already added `/cloud/` and `/sdk/`. #88's re-adds are duplicates. Removing; keeping `/railway.toml` and `apollo-leads-*.csv` which are genuinely new from #88. The regression test in tests/test_session_history.py stays — it asserts the emit fires end-to-end from a real Brain + correct() loop, complementing #86's test_wiring_compound.py coverage of payload shape. Both pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Gradata
added a commit
that referenced
this pull request
Apr 15, 2026
#88 landed at the same time as #86 and #87 shipping from a parallel session. The merges didn't conflict line-wise, but the diffs overlap: - brain.py:apply_brain_rules — #86 already wired `rules.injected` with a richer payload (id + category + confidence + state + scope) and try/except guard. #88 added a second thinner emit after the cache.put. Result: double-fire on fresh compute. Harmless in practice — SessionHistory dedups via a set — but clearly wrong. Removing #88's emit, keeping #86's. - .gitignore — #87 already added `/cloud/` and `/sdk/`. #88's re-adds are duplicates. Removing; keeping `/railway.toml` and `apollo-leads-*.csv` which are genuinely new from #88. The regression test in tests/test_session_history.py stays — it asserts the emit fires end-to-end from a real Brain + correct() loop, complementing #86's test_wiring_compound.py coverage of payload shape. Both pass. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups to the Railway fix (gradata-cloud#1, #2, 54f2841 direct-to-main) — the (b) and (c) in our audit plan.
(c) Wire dormant rules.injected emit
integrations/session_history.py subscribes to three events:
Result: SessionHistory.compute_effectiveness() is silently dead. Rules get injected every call but nothing records which ones, so per-session effectiveness tracking never runs.
Fix: brain.apply_brain_rules() now emits rules.injected on the in-memory bus after format_rules_for_prompt(applied). Cache hits skip intentionally — SessionHistory dedups via a set, the rule cache is per-scope, fresh scopes hit the compute path.
(b) Gitignore on-disk orphans
Tests
Follow-ups not here
🤖 Generated with Claude Code