Repository navigation
feat(display): unified per-platform proactive-push opt-out gate (cron + review + kanban + restart) + TUI parity #59364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sam7894604
wants to merge
5
commits into
NousResearch:main
Choose a base branch
from
sam7894604:feat/per-platform-proactive-push-gate-upstream
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f77fe30
feat(display): add per-platform proactive_push key + register memory_…
sam7894604 d0e950c
feat(cron): honour per-platform proactive-push opt-out in delivery
sam7894604 db99b79
feat(gateway): gate background-review memory notifications by proacti…
sam7894604 87b6231
feat(gateway): apply proactive-push gate to kanban + restart notifica…
sam7894604 f80e561
fix(tui): resolve memory_notifications per-platform for parity
sam7894604 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| """Cron delivery honours the per-platform proactive-push opt-out gate.""" | ||
|
|
||
| import pytest | ||
|
|
||
| from cron.scheduler import _filter_proactive_push_optout, _resolve_delivery_targets | ||
|
|
||
|
|
||
| def _cfg(mp, config): | ||
| mp.setattr("hermes_cli.config.load_config", lambda: config) | ||
|
|
||
|
|
||
| # -- filter helper (unit) ---------------------------------------------------- | ||
|
|
||
| def test_optout_platform_dropped_others_kept(monkeypatch): | ||
| _cfg(monkeypatch, {"display": {"platforms": {"line": {"proactive_push": False}}}}) | ||
| targets = [ | ||
| {"platform": "line", "chat_id": "U1", "thread_id": None}, | ||
| {"platform": "telegram", "chat_id": "T1", "thread_id": None}, | ||
| ] | ||
| kept = _filter_proactive_push_optout(targets, {"id": "j1"}) | ||
| assert [t["platform"] for t in kept] == ["telegram"] # line dropped, telegram kept | ||
|
|
||
|
|
||
| def test_deliver_all_still_respects_optout(monkeypatch): | ||
| # An explicit multi-target (deliver=all expands to many) still skips opt-out. | ||
| _cfg(monkeypatch, {"display": {"platforms": {"line": {"proactive_push": False}}}}) | ||
| targets = [ | ||
| {"platform": "line", "chat_id": "U1"}, | ||
| {"platform": "discord", "chat_id": "D1"}, | ||
| {"platform": "slack", "chat_id": "S1"}, | ||
| ] | ||
| kept = _filter_proactive_push_optout(targets, {"id": "j2"}) | ||
| assert {t["platform"] for t in kept} == {"discord", "slack"} | ||
|
|
||
|
|
||
| def test_global_optout_drops_all(monkeypatch): | ||
| _cfg(monkeypatch, {"display": {"proactive_push": False}}) | ||
| targets = [{"platform": "line", "chat_id": "U1"}, {"platform": "telegram", "chat_id": "T1"}] | ||
| assert _filter_proactive_push_optout(targets, {"id": "j3"}) == [] | ||
|
|
||
|
|
||
| def test_no_optout_keeps_everything(monkeypatch): | ||
| _cfg(monkeypatch, {"display": {}}) | ||
| targets = [{"platform": "line", "chat_id": "U1"}, {"platform": "telegram", "chat_id": "T1"}] | ||
| assert len(_filter_proactive_push_optout(targets, {"id": "j4"})) == 2 | ||
|
|
||
|
|
||
| def test_fail_open_on_config_error(monkeypatch): | ||
| def boom(): | ||
| raise RuntimeError("config unreadable") | ||
| monkeypatch.setattr("hermes_cli.config.load_config", boom) | ||
| targets = [{"platform": "line", "chat_id": "U1"}] | ||
| # Fail-open: deliver as before rather than silently dropping. | ||
| assert _filter_proactive_push_optout(targets, {"id": "j5"}) == targets | ||
|
|
||
|
|
||
| def test_skip_is_logged(monkeypatch, caplog): | ||
| import logging | ||
| _cfg(monkeypatch, {"display": {"platforms": {"line": {"proactive_push": False}}}}) | ||
| with caplog.at_level(logging.INFO): | ||
| _filter_proactive_push_optout([{"platform": "line", "chat_id": "U1"}], {"id": "jlog"}) | ||
| assert any("opted out of proactive push" in r.message and "jlog" in r.message | ||
| for r in caplog.records) | ||
|
|
||
|
|
||
| # -- integration through _resolve_delivery_targets --------------------------- | ||
|
|
||
| def test_resolve_targets_filters_optout_origin(monkeypatch): | ||
| _cfg(monkeypatch, {"display": {"platforms": {"line": {"proactive_push": False}}}}) | ||
| job = { | ||
| "id": "sync", "deliver": "origin", | ||
| "origin": {"platform": "line", "chat_id": "Uddf", "thread_id": None}, | ||
| } | ||
| # deliver=origin resolves to line:Uddf, then the gate drops it → no targets. | ||
| assert _resolve_delivery_targets(job) == [] | ||
|
|
||
|
|
||
| def test_resolve_targets_keeps_non_optout_origin(monkeypatch): | ||
| _cfg(monkeypatch, {"display": {"platforms": {"line": {"proactive_push": False}}}}) | ||
| job = { | ||
| "id": "tg", "deliver": "origin", | ||
| "origin": {"platform": "telegram", "chat_id": "T1", "thread_id": None}, | ||
| } | ||
| targets = _resolve_delivery_targets(job) | ||
| assert [t["platform"] for t in targets] == ["telegram"] |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This covers only the post-boot
_send_restart_notification()path._notify_active_sessions_of_shutdown()still sends shutdown/restart notices to active sessions and home channels without this gate; apply the same resolver there orproactive_push: falsedoes not suppress all restart-related unsolicited notifications.