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
+66 -48
View File
@@ -1,4 +1,6 @@
import importlib.util
import io
from contextlib import redirect_stderr, redirect_stdout
import os
from pathlib import Path
import shutil
@@ -302,7 +304,7 @@ class DockerSetupTests(unittest.TestCase):
def test_host_verification_rejects_wrong_unconfigured_server(self):
def runner(command, **kwargs):
return subprocess.CompletedProcess(command, 0, stdout='{"ntfy":{"health":"not configured"}}', stderr="")
return subprocess.CompletedProcess(command, 0, stdout='[]', stderr="")
with patch.object(setup.shutil,"which",return_value="/fixture/go"), self.assertRaises(ValueError):
setup.Setup(".",runner=runner).verify_host_endpoint("ws://127.0.0.1:8081/connect")
@@ -491,20 +493,20 @@ fi
def test_ctrl_c_exits_cleanly_and_retains_configuration(self):
with tempfile.TemporaryDirectory() as directory:
root=Path(directory);scripts=root/"scripts";scripts.mkdir()
for name in ["setup-docker.py","lan-address.py","configure-compose.py","save-ntfy-token.py","build_metadata.py","resolve-releases.py"]:
for name in ["setup-docker.py","lan-address.py","configure-compose.py","build_metadata.py","resolve-releases.py"]:
shutil.copy2(Path(__file__).with_name(name),scripts/name)
fixture=root/"releases.json"
fixture.write_text(setup.json.dumps({"opencode":{"image":"ghcr.io/anomalyco/opencode","version":"2.0.26","digest":"sha256:"+"a"*64},"pi":{"version":"1.1.0","engine":">=22.19.0"}}))
marker=root/"waiting"
docker=root/"docker"
docker.write_text('#!/bin/sh\ncase "$*" in *" up "*) touch "'+str(marker)+'"; exec sleep 30;; *"opencode --version"*) printf "opencode=2.0.26\\npi=1.1.0\\nnode=v22.19.0\\n";; esac\n')
docker.write_text('#!/bin/sh\ncase "$*" in *" config --format json"*) touch "'+str(marker)+'"; exec sleep 30;; *"opencode --version"*) printf "opencode=2.0.26\\npi=1.1.0\\nnode=v22.19.0\\n";; esac\n')
docker.chmod(0o700)
go=root/"go";go.write_text('#!/bin/sh\nexit 0\n');go.chmod(0o700)
git=root/"git";git.write_text('#!/bin/sh\nif [ "$1" = rev-parse ]; then echo '+"a"*40+'; fi\n');git.chmod(0o700)
# The container's default home (/home/pipelines) is rejected by the
# mount guard; give the subprocess its own disposable HOME.
process=subprocess.Popen([sys.executable,str(scripts/"setup-docker.py"),
"--ntfy-url","http://192.168.1.25:8090","--bind-address","192.168.1.25","--timezone","UTC"],
"--timezone","UTC"],
env=dict(os.environ,PATH=str(root)+os.pathsep+os.environ["PATH"],
HOME=str(root/"home"),USERPROFILE=str(root/"home"),
PIPELINES_RELEASE_FIXTURE=str(fixture)),
@@ -525,16 +527,15 @@ fi
os.killpg(process.pid,signal.SIGTERM)
process.communicate(timeout=5)
def test_fresh_defaults_configure_lan_without_any_input(self):
def test_fresh_defaults_configure_without_any_input(self):
with tempfile.TemporaryDirectory() as directory, \
patch.object(setup.lan,"detect_lan",return_value="192.168.1.25"), \
patch.object(setup.configure,"host_timezone",return_value="Europe/London"), \
patch("builtins.input",side_effect=AssertionError("must not ask for network settings")):
setup.Setup(directory).settings(setup.arguments([]))
text=Path(directory,".env").read_text()
self.assertIn("NTFY_BASE_URL=http://192.168.1.25:8090\n",text)
self.assertIn("NTFY_BIND_ADDRESS=0.0.0.0\n",text)
self.assertNotIn("NTFY",text)
self.assertIn("TZ=Europe/London\n",text)
self.assertFalse(Path(directory,"secrets").exists())
def test_timezone_fallback_does_not_prompt(self):
with tempfile.TemporaryDirectory() as directory, \
@@ -544,15 +545,14 @@ fi
self.assertIn("TZ=UTC\n",Path(directory,".env").read_text())
def test_missing_lan_fails_without_partial_settings_or_prompt(self):
with tempfile.TemporaryDirectory() as directory, \
patch.object(setup.lan,"detect_lan",side_effect=ValueError("No LAN")):
with self.assertRaises(ValueError):
setup.Setup(directory).settings(setup.arguments([]))
with tempfile.TemporaryDirectory() as directory:
with self.assertRaisesRegex(ValueError, "No LAN"):
self.exercise(directory, lan_error=ValueError("No LAN"))
self.assertFalse(Path(directory,".env").exists())
def exercise(self, directory, existing=False, fail=None, confirm="yes", harness="opencode"):
def exercise(self, directory, existing=False, fail=None, confirm="yes", harness="opencode",
lan_error=None, ntfy_leftovers=False):
calls = []
token = "tk_" + "a" * 29
logged = existing
def runner(command, **kwargs):
@@ -563,6 +563,10 @@ fi
args = command[2:]
calls.append(args)
code, out = 0, ""
if ntfy_leftovers and command[:3] == ["docker", "ps", "-aq"] and "label=com.docker.compose.service=ntfy" in command:
out = "0123abcd\n"
if ntfy_leftovers and command[:3] == ["docker", "volume", "ls"]:
out = "pipelines_ntfy-data\n"
if args[-4:] == ["auth", "list", "--format", "json"]:
out = '[{"id":"fixture","connections":[{"id":"fixture"}]}]' if logged else '[]'
if "opencode models" in args[-1]:
@@ -571,10 +575,8 @@ fi
out = '{"healthy":true,"session_id":"ses_fixture"}'
if "exec opencode auth login" in args[-1] and confirm == "yes":
logged = True
if "token" in args:
out = f"token {token} created\n"
if args[-2:] == ["status", "--json"]:
out = '{"ntfy":{"health":"healthy","url":"http://192.168.1.20:8090"},"topic":"pipelines"}'
out = '{"type":"status","runs":[]}'
if args[-2:] == ["ping", "--json"]:
out = setup.json.dumps({"type": "pong", "build": {"version": "a" * 12, "commit": "a" * 40, "dirty": False}})
if args[-3:]==["harness","list","--json"]:
@@ -588,23 +590,22 @@ fi
if fail and (fail in args or (fail=="login" and "exec opencode auth login" in args[-1]) or (fail=="provider-check" and any("provider-check" in arg for arg in args))):
code, out = 9, "private provider data/token"
if fail == "host" and command[0] != "docker" and args[-2:] == ["status", "--json"]:
code, out = 9, '{"ntfy":{"health":"not configured"}}'
code, out = 9, '{}'
return subprocess.CompletedProcess(command, code, stdout=out, stderr="")
args = setup.arguments([] if existing else ["--ntfy-url", "http://192.168.1.20:8090",
"--bind-address", "192.168.1.20", "--timezone", "Europe/London"])
args = setup.arguments([] if existing else ["--timezone", "Europe/London"])
args.harness=harness
installer = setup.Setup(directory, runner=runner, prompt=lambda _: "1")
installer.resolver = lambda: {"opencode": {"image": "ghcr.io/anomalyco/opencode", "version": "2.0.26", "digest": "sha256:" + "a" * 64},
"pi": {"version": "1.1.0", "engine": ">=22.19.0"}}
installer.choose_model=lambda models, title, purpose="", step="", current="": models[0]
with patch.object(setup.lan,"detect_lan",return_value="192.168.1.20"):
with patch.object(setup.lan,"detect_lan",return_value="192.168.1.20",side_effect=lan_error):
installer.run(args)
return calls, token
return calls
def test_fresh_pi_setup_skips_opencode_login_and_generation(self):
with tempfile.TemporaryDirectory() as directory:
calls, _ = self.exercise(directory, harness="pi")
calls = self.exercise(directory, harness="pi")
setup_call = next(c for c in calls if "setup" in c and "pi" in c)
self.assertIn("--login", setup_call)
self.assertIn("--default", setup_call)
@@ -634,34 +635,53 @@ fi
for want in ("OpenCode 2.0.26", "Pi 1.1.0", "Node 22.19.0"):
self.assertIn(want, label)
def test_fresh_setup_wires_notifications_and_runs_container_login(self):
def test_fresh_setup_runs_container_login_without_ntfy(self):
with tempfile.TemporaryDirectory() as directory:
calls, token = self.exercise(directory)
calls = self.exercise(directory)
self.assertTrue(any("exec opencode auth login" in c[-1] for c in calls))
self.assertTrue(any("--force-recreate" in c for c in calls))
recreate = next(c for c in calls if "--force-recreate" in c)
# The old ntfy container is an orphan once compose.yaml drops it.
self.assertIn("--remove-orphans", recreate)
build = next(c for c in calls if "build" in c)
self.assertIn("PIPELINES_COMMIT=" + "a" * 40, build)
self.assertIn("PIPELINES_DIRTY=false", build)
self.assertEqual(Path(directory, "secrets/ntfy-token.txt").read_text(), token + "\n")
self.assertFalse(any(token in " ".join(c) for c in calls))
self.assertLess(next(i for i,c in enumerate(calls) if "token" in c), next(i for i,c in enumerate(calls) if "build" in c))
self.assertLess(next(i for i,c in enumerate(calls) if "exec opencode auth login" in c[-1]), next(i for i,c in enumerate(calls) if "--force-recreate" in c))
self.assertTrue(any("curl --config -" in " ".join(c) for c in calls))
self.assertFalse(any(c[:1] == ["up"] and "ntfy" in c for c in calls))
self.assertFalse(any(c[:1] == ["exec"] and "ntfy" in c for c in calls))
self.assertFalse(Path(directory, "secrets/ntfy-token.txt").exists())
self.assertNotIn("NTFY", Path(directory, ".env").read_text())
config = Path(os.environ["XDG_CONFIG_HOME"])/"pipelines/client.json"
self.assertEqual(setup.json.loads(config.read_text())["server_url"],"ws://127.0.0.1:8081/connect")
def test_reinstall_preserves_configuration_tokens_and_provider_setup(self):
def test_reinstall_preserves_configuration_and_provider_setup(self):
with tempfile.TemporaryDirectory() as directory:
self.exercise(directory)
files = [Path(directory, ".env"), Path(directory, "secrets/ntfy-token.txt")]
before = [p.read_bytes() for p in files]
calls, _ = self.exercise(directory, existing=True)
self.assertFalse(any("exec opencode auth login" in c[-1] or "token" in c for c in calls))
self.assertEqual(before[1],files[1].read_bytes())
self.assertEqual(files[0].read_bytes(),before[0].replace(b"NTFY_BIND_ADDRESS=192.168.1.20",b"NTFY_BIND_ADDRESS=0.0.0.0")+b"PIPELINES_BIND_ADDRESS=0.0.0.0\n")
normalized=files[0].read_bytes()
self.exercise(directory,existing=True)
self.assertEqual(normalized,files[0].read_bytes())
settings = Path(directory, ".env")
before = settings.read_bytes()
calls = self.exercise(directory, existing=True)
self.assertFalse(any("exec opencode auth login" in c[-1] for c in calls))
self.assertEqual(settings.read_bytes(), before + b"PIPELINES_BIND_ADDRESS=0.0.0.0\n")
normalized = settings.read_bytes()
self.exercise(directory, existing=True)
self.assertEqual(normalized, settings.read_bytes())
def test_reinstall_retires_the_old_ntfy_container_volume_token_and_settings(self):
with tempfile.TemporaryDirectory() as directory:
self.exercise(directory)
settings = Path(directory, ".env")
settings.write_text(settings.read_text() + "NTFY_BASE_URL=http://192.168.1.20:8090\nNTFY_BIND_ADDRESS=0.0.0.0\n")
Path(directory, "secrets").mkdir()
Path(directory, "secrets/ntfy-token.txt").write_text("tk_old\n")
with redirect_stdout(io.StringIO()) as output:
calls = self.exercise(directory, existing=True, ntfy_leftovers=True)
self.assertIn(["-f", "0123abcd"], calls)
self.assertIn(["rm", "pipelines_ntfy-data"], calls)
self.assertFalse(Path(directory, "secrets/ntfy-token.txt").exists())
self.assertNotIn("NTFY", settings.read_text())
self.assertIn("Retired the old ntfy notification server", output.getvalue())
self.assertNotIn("tk_old", output.getvalue())
# Retirement happens before anything is (re)started.
self.assertLess(calls.index(["-f", "0123abcd"]), next(i for i, c in enumerate(calls) if "--force-recreate" in c))
def test_login_failure_or_cancel_does_not_mark_complete_or_start_server(self):
for fail, confirm in [("login", "yes"), (None, "no")]:
@@ -669,7 +689,7 @@ fi
with self.assertRaises(ValueError) as raised:
self.exercise(directory, fail=fail, confirm=confirm)
self.assertNotIn("private provider", str(raised.exception))
self.assertTrue(Path(directory, "secrets/ntfy-token.txt").stat().st_size)
self.assertTrue(Path(directory, ".env").stat().st_size)
def test_status_and_publication_failures_are_not_success(self):
for failure in ["status", "sh", "provider-check", "host"]:
@@ -681,15 +701,13 @@ fi
path = Path(directory, ".env")
path.write_text("existing settings")
with self.assertRaises(ValueError):
setup.Setup(directory).settings(setup.arguments(["--ntfy-url", "https://example.com"]))
setup.Setup(directory).settings(setup.arguments(["--timezone", "UTC"]))
self.assertEqual(path.read_text(), "existing settings")
def test_existing_env_rejects_unsafe_bind_override(self):
with tempfile.TemporaryDirectory() as directory:
path=Path(directory,".env");path.write_text("NTFY_BIND_ADDRESS=127.0.0.1\n")
with self.assertRaises(ValueError):
setup.Setup(directory).settings(setup.arguments(["--bind-address","0.0.0.0\nOTHER=bad"]))
self.assertEqual(path.read_text(),"NTFY_BIND_ADDRESS=127.0.0.1\n")
def test_ntfy_flags_are_gone(self):
for flag in (["--ntfy-url", "http://192.168.1.20:8090"], ["--bind-address", "0.0.0.0"]):
with self.assertRaises(SystemExit), redirect_stderr(io.StringIO()):
setup.arguments(flag)
def test_existing_env_symlink_is_not_modified(self):
with tempfile.TemporaryDirectory() as directory: