Remove ntfy: notifications go only through the app notification stream

Server: drop ntfy publishing (stage hooks, run outbox, chat attention, chat
tool notify, auto-switch and schedule notices), the chat push outbox (its
table is dropped at startup), ntfy status/endpoints and PIPELINES_NTFY_*.
The app_notifications stream, subscribe/clear and kinds are unchanged.
Notification settings keep run_finished/chat_needs_you/chat_reply_finished;
ntfy_enabled is accepted and ignored and its stored row is never read.

Stage type=ntfy is rejected: "ntfy stages were removed; notifications go to
the Pipelines apps — use the stage notify hook". The notify hook remains.

Installer: no ntfy build, accounts, config or supervisor child; manifest
gets top-level "mode" (legacy ntfy.mode still read). Reinstall retires an
old ntfy (safe PID-file stop, deletes binary, config, data dir, token, log,
with a note in logs/install.log); uninstall cleans leftovers.

App: ntfy settings section replaced by "Notification events"; texts updated.
Docs: docs/ntfy.md folded into docs/notifications.md; install, docker, cli,
author skill references updated; security review M1 marked resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 23:24:24 +00:00
parent 806b5eca46
commit fc7dbb0ac0
138 changed files with 1958 additions and 4651 deletions
+142 -57
View File
@@ -152,12 +152,10 @@ class ManageNativeTests(unittest.TestCase):
config = self.config(root)
if role is not None:
config["allow_authoring"] = role
ntfy, server = MagicMock(), MagicMock()
ntfy.poll.return_value = None
server = MagicMock()
server.poll.return_value = 0
server.returncode = 0
with patch.object(manage, "ntfy_start", return_value=ntfy), \
patch.object(manage, "wait_health"), patch.object(manage.signal, "signal"), \
with patch.object(manage.signal, "signal"), \
patch.object(manage.subprocess, "Popen", return_value=server) as popen:
manage.supervise(config)
command = popen.call_args_list[0].args[0]
@@ -178,13 +176,10 @@ class ManageNativeTests(unittest.TestCase):
(root / "lib/app-web").mkdir(parents=True, exist_ok=True)
(root / "lib/app-web/index.html").write_text("app")
return {
"format": 1, "prefix": str(root), "python": "python3", "server_port": 8080,
"ntfy_port": 8090, "opencode": "opencode", "opencode_env": {}, "path": "",
"topic": "pipelines", "public_url": "http://192.168.1.20:8090", "username": "phone-reader",
"format": 1, "mode": mode, "prefix": str(root), "python": "python3", "server_port": 8080,
"opencode": "opencode", "opencode_env": {}, "path": "",
"workspace": str(root), "launcher": str(root / "bin/pipelines"), "registration": None,
"label": "net.a-wan.pipelines", "docker": "docker", "project": "pipelines", "timezone": "UTC",
"ntfy": {"mode": mode, "bin": str(root / "bin/ntfy"),
"config": str(root / "data/ntfy/server.yml"), "base_url": "http://192.168.1.20:8090"},
"web": {"node": "/bin/node", "script": str(root / "lib/web/serve.mjs"), "host": "127.0.0.1",
"port": 8082, "auth_file": str(root / "auth.json"), "root": str(root / "lib/app-web")},
}
@@ -205,11 +200,94 @@ class ManageNativeTests(unittest.TestCase):
run.assert_not_called()
popen.assert_not_called()
def test_mode_selection_defaults_to_docker(self):
self.assertEqual(manage.ntfy_mode({}), "docker")
self.assertEqual(manage.ntfy_mode({"ntfy": {}}), "docker")
self.assertEqual(manage.ntfy_mode({"ntfy": {"mode": "native"}}), "native")
self.assertEqual(manage.ntfy_health_url({"ntfy_port": 8090}), "http://127.0.0.1:8090/v1/health")
def legacy_config(self, root):
"""A manifest written while Pipelines still ran ntfy."""
config = self.config(root)
config.pop("mode")
config.update(ntfy_port=8090, topic="pipelines", public_url="http://192.168.1.20:8090",
username="phone-reader",
ntfy={"mode": "native", "bin": str(root / "bin/ntfy"), "version": "v2.38.1",
"config": str(root / "data/ntfy/server.yml"), "base_url": "http://192.168.1.20:8090"})
return config
def legacy_files(self, root):
for name in ("bin", "logs", "secrets", "data/ntfy/attachments"):
(root / name).mkdir(parents=True, exist_ok=True)
for name in ("bin/ntfy", "logs/ntfy.log", "secrets/publisher-token", "data/ntfy/server.yml",
"data/ntfy/auth.db", "data/ntfy/cache.db"):
(root / name).write_text("x")
(root / "ntfy.pid").write_text("4321")
def test_install_mode_reads_top_level_mode_and_legacy_ntfy_mode(self):
self.assertEqual(manage.install_mode({}), "docker")
self.assertEqual(manage.install_mode({"mode": "native"}), "native")
self.assertEqual(manage.install_mode({"mode": "docker"}), "docker")
self.assertEqual(manage.install_mode({"ntfy": {}}), "docker")
self.assertEqual(manage.install_mode({"ntfy": {"mode": "native"}}), "native")
self.assertEqual(manage.install_mode({"mode": "native", "ntfy": {"mode": "docker"}}), "native")
def test_native_service_accepts_a_legacy_ntfy_mode_manifest(self):
with tempfile.TemporaryDirectory() as directory:
config = self.legacy_config(Path(directory))
# Without any native marker it is not a native install...
with self.assertRaisesRegex(ValueError, "No native installer login service"):
manage.service_command(dict(config, ntfy={}), ["status"])
# ...while the legacy ntfy.mode marker passes the native check.
config["registration"] = str(Path(directory) / "elsewhere.service")
with patch.object(manage.platform, "system", return_value="Linux"), \
self.assertRaisesRegex(ValueError, "unexpected native service definition"):
manage.service_command(config, ["status"])
def test_legacy_ntfy_is_signalled_only_when_its_command_line_matches(self):
cases = {"managed": "{root}/bin/ntfy serve --config {root}/data/ntfy/server.yml",
"other program": "/usr/bin/vim notes.txt",
"other ntfy": "/usr/bin/ntfy serve",
"not serving": "{root}/bin/ntfy user list",
"gone": None}
for name, command in cases.items():
with self.subTest(name), tempfile.TemporaryDirectory() as directory:
root = Path(directory)
self.legacy_files(root)
config = self.config(root)
line = command.format(root=root) if command else None
running = [line]
killed = []
def fake_kill(pid, sig):
killed.append((pid, sig))
running[0] = None
with patch.object(manage, "process_command", side_effect=lambda pid: running[0]), \
patch.object(manage.os, "kill", side_effect=fake_kill):
stopped = manage.stop_legacy_ntfy(config)
self.assertEqual(killed, [(4321, signal.SIGTERM)] if name == "managed" else [])
self.assertEqual(stopped, name == "managed")
self.assertFalse((root / "ntfy.pid").exists())
def test_retire_ntfy_removes_its_files_and_notes_them_once(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
self.legacy_files(root)
(root / "bin/pipelines-server").write_text("keep")
(root / "data/pipelines.db").write_text("keep")
(root / "secrets/other").write_text("keep")
config = self.legacy_config(root)
notes = []
with patch.object(manage, "process_command", return_value=None), \
patch.object(manage.os, "kill", side_effect=AssertionError("signalled a non-ntfy PID")), \
patch.object(manage, "compose", side_effect=AssertionError("compose used for native")):
removed = manage.retire_ntfy(config, note=notes.append)
self.assertEqual(len(removed), 5)
for path in manage.legacy_ntfy_paths(root):
self.assertFalse(path.exists(), path)
for name in ("bin/pipelines-server", "data/pipelines.db", "secrets/other"):
self.assertTrue((root / name).exists(), name)
self.assertEqual(len(notes), 1)
self.assertIn("v2.38.1", notes[0])
self.assertIn(str(root / "bin/ntfy"), notes[0])
# Idempotent: nothing left, nothing noted, with the new manifest.
self.assertEqual(manage.retire_ntfy(self.config(root), note=notes.append), [])
self.assertEqual(len(notes), 1)
def test_registered_start_commands_on_both_platforms(self):
for system in ("Darwin", "Linux"):
@@ -304,13 +382,13 @@ class ManageNativeTests(unittest.TestCase):
"host": "0.0.0.0", "port": 8082, "auth_file": "/private/auth.json",
"server_token_file": "/private/server-token",
"root": str(root / "lib/app-web"), "updates": "/prefix/lib/app-updates"}
ntfy, server, web = MagicMock(), MagicMock(), MagicMock()
ntfy.poll.return_value = None
server, web = MagicMock(), MagicMock()
server.poll.return_value = None
web.poll.side_effect = [1, None]
with patch.object(manage, "ntfy_start", return_value=ntfy), \
patch.object(manage, "wait_health"), patch.object(manage.signal, "signal"), \
patch.dict(os.environ, {"PIPELINES_WEB_AUTH": "disabled"}), \
with patch.object(manage.signal, "signal"), \
patch.dict(os.environ, {"PIPELINES_WEB_AUTH": "disabled",
"PIPELINES_NTFY_URL": "http://127.0.0.1:8090/pipelines",
"PIPELINES_NTFY_TOKEN_FILE": "/old/token"}), \
patch.object(manage.subprocess, "Popen", side_effect=[server, web]) as popen:
with self.assertRaisesRegex(RuntimeError, "web proxy exited"):
manage.supervise(config)
@@ -327,7 +405,29 @@ class ManageNativeTests(unittest.TestCase):
self.assertEqual(manage.server_token_env({"web": None}), {})
web.terminate.assert_called_once()
server.terminate.assert_called_once()
ntfy.terminate.assert_called_once()
def test_supervisor_no_longer_starts_ntfy_or_passes_its_settings(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "logs").mkdir()
self.legacy_files(root)
# Even an old manifest still on disk starts only the server and web proxy.
config = self.legacy_config(root)
server, web = MagicMock(), MagicMock()
server.poll.return_value = 0
server.returncode = 0
web.poll.return_value = None
with patch.object(manage.signal, "signal"), \
patch.object(manage, "process_command", return_value=None), \
patch.object(manage, "compose", side_effect=AssertionError("compose used for ntfy")), \
patch.dict(os.environ, {"PIPELINES_NTFY_PUBLIC_URL": "http://x:8090"}), \
patch.object(manage.subprocess, "Popen", side_effect=[server, web]) as popen:
manage.supervise(config)
self.assertEqual(len(popen.call_args_list), 2)
for spawned in popen.call_args_list:
self.assertNotIn("ntfy", " ".join(spawned.args[0]))
self.assertFalse([key for key in spawned.kwargs["env"] if key.startswith("PIPELINES_NTFY_")])
self.assertFalse((root / "ntfy.pid").exists())
def test_start_checks_web_login_readiness(self):
with tempfile.TemporaryDirectory() as directory:
@@ -349,47 +449,13 @@ class ManageNativeTests(unittest.TestCase):
self.assertEqual(manage.server_address({"server_port": 8080}), "127.0.0.1:8080")
self.assertEqual(manage.server_address({"server_port": 8080, "bind_address": ""}), "127.0.0.1:8080")
def test_ntfy_start_launches_binary_with_generated_config(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "bin").mkdir()
(root / "logs").mkdir()
config = self.config(root)
with patch.object(manage.subprocess, "Popen", return_value=FakeProcess(pid=4321)) as popen:
child = manage.ntfy_start(config)
self.assertEqual(popen.call_args[0][0], [config["ntfy"]["bin"], "serve", "--config", config["ntfy"]["config"]])
self.assertEqual(child.pid, 4321)
self.assertEqual((root / "ntfy.pid").read_text(), "4321")
def test_ntfy_stop_terminates_managed_process_and_removes_pid(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
(root / "bin").mkdir()
(root / "bin/ntfy").write_text("")
(root / "ntfy.pid").write_text(str(os.getpid()))
config = self.config(root)
killed = []
def fake_kill(pid, sig):
if sig == 0:
raise ProcessLookupError
killed.append((pid, sig))
with patch.object(manage.subprocess, "check_output",
return_value=str(root / "bin/ntfy") + " serve --config x"), \
patch.object(manage.os, "kill", side_effect=fake_kill), \
patch.object(manage, "compose", side_effect=AssertionError("compose used for native ntfy")):
manage.ntfy_stop(config)
self.assertIn((os.getpid(), signal.SIGTERM), killed)
self.assertFalse((root / "ntfy.pid").exists())
def test_native_stop_never_calls_compose(self):
with tempfile.TemporaryDirectory() as directory:
config = self.config(Path(directory))
with patch.object(manage, "registration", return_value=None), \
patch.object(manage, "managed_pid", return_value=None), \
patch.object(manage, "ntfy_stop") as stop, \
patch.object(manage, "compose", side_effect=AssertionError("compose used for native ntfy")):
patch.object(manage, "stop_legacy_ntfy") as stop, \
patch.object(manage, "compose", side_effect=AssertionError("compose used for native")):
manage.stop(config)
stop.assert_called_once_with(config)
@@ -400,10 +466,29 @@ class ManageNativeTests(unittest.TestCase):
config = self.config(root)
with patch.object(manage, "stop"), \
patch.object(manage, "registration", return_value=None), \
patch.object(manage, "compose", side_effect=AssertionError("compose used for native ntfy")):
patch.object(manage, "compose", side_effect=AssertionError("compose used for native")):
manage.uninstall(config, purge=False, yes=True)
self.assertTrue((root / manage.MARKER).is_file())
def test_uninstall_removes_leftover_ntfy_even_without_a_manifest_entry(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
self.legacy_files(root)
(root / "data/pipelines.db").write_text("keep")
config = self.config(root)
killed = []
with patch.object(manage, "stop"), \
patch.object(manage, "registration", return_value=None), \
patch.object(manage, "process_command",
side_effect=lambda pid: None if killed else f"{root}/bin/ntfy serve --config c"), \
patch.object(manage.os, "kill", side_effect=lambda pid, sig: killed.append((pid, sig))), \
patch.object(manage, "compose", side_effect=AssertionError("compose used for native")):
manage.uninstall(config, purge=False, yes=True)
self.assertEqual(killed, [(4321, signal.SIGTERM)])
for path in manage.legacy_ntfy_paths(root):
self.assertFalse(path.exists(), path)
self.assertTrue((root / "data/pipelines.db").exists())
if __name__ == "__main__":
unittest.main()