notices 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- notices-0.0.2/.claude/skills/notices/SKILL.md +37 -0
- notices-0.0.2/.gitignore +120 -0
- notices-0.0.2/LICENSE +21 -0
- notices-0.0.2/PKG-INFO +135 -0
- notices-0.0.2/README.md +113 -0
- notices-0.0.2/docs/adr/0001-one-facade-for-notices.md +74 -0
- notices-0.0.2/docs/research/2026-12-05-channel-affordances.md +164 -0
- notices-0.0.2/docs/research/2026-12-05-libraries-and-plugin-patterns.md +160 -0
- notices-0.0.2/docs/research/2026-12-05-standards-and-routing.md +183 -0
- notices-0.0.2/notices/__init__.py +94 -0
- notices-0.0.2/notices/__main__.py +45 -0
- notices-0.0.2/notices/base.py +611 -0
- notices-0.0.2/notices/channels/__init__.py +84 -0
- notices-0.0.2/notices/channels/_osascript.py +101 -0
- notices-0.0.2/notices/channels/apple_calendar.py +173 -0
- notices-0.0.2/notices/channels/apple_reminders.py +260 -0
- notices-0.0.2/notices/channels/base.py +189 -0
- notices-0.0.2/notices/channels/google_calendar.py +350 -0
- notices-0.0.2/notices/channels/macos.py +84 -0
- notices-0.0.2/notices/channels/ntfy.py +211 -0
- notices-0.0.2/notices/channels/recording.py +80 -0
- notices-0.0.2/notices/channels/slack.py +253 -0
- notices-0.0.2/notices/config.py +77 -0
- notices-0.0.2/notices/inbox.py +112 -0
- notices-0.0.2/notices/ledger.py +275 -0
- notices-0.0.2/notices/model.py +374 -0
- notices-0.0.2/notices/rules.py +138 -0
- notices-0.0.2/notices/secrets.py +73 -0
- notices-0.0.2/notices/testing.py +193 -0
- notices-0.0.2/notices/tools.py +193 -0
- notices-0.0.2/pyproject.toml +183 -0
- notices-0.0.2/tests/conftest.py +9 -0
- notices-0.0.2/tests/test_apple.py +296 -0
- notices-0.0.2/tests/test_cli.py +59 -0
- notices-0.0.2/tests/test_core.py +641 -0
- notices-0.0.2/tests/test_google_calendar.py +252 -0
- notices-0.0.2/tests/test_ntfy.py +202 -0
- notices-0.0.2/tests/test_slack.py +190 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: notices
|
|
3
|
+
description: >-
|
|
4
|
+
Send, schedule, update or withdraw a notification or reminder on any channel (ntfy phone push, Apple Reminders, Apple Calendar, a macOS banner, Slack, Google Calendar) through one command, and read back what the person did (Done, Snooze). Use whenever code or an agent needs to tell a person something or remind them at a time: "notify me", "push to my phone", "put it in Apple Reminders", "add it to my calendar", "send me a Slack DM when", "remind me at", "which channel should this go to", "routing rules for notifications", "did they tap Done". Also use before writing any direct ntfy, osascript, Slack webhook or calendar API call: route it through notices instead. Not for conversations with people (email threads, chat replies): that is correspond.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# notices
|
|
8
|
+
|
|
9
|
+
One interface over notification channels. A **notice** has a stable `id`; sending it again is a no-op, sending it changed updates every copy, `retract` withdraws every copy, and `poll` returns what the person did.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
notices channels # what is configured, capabilities, setup check
|
|
15
|
+
notices route --kind errand --urgency high # which channels the rules pick (sends nothing)
|
|
16
|
+
notices send "Title" --id my-key --at 2h --reminder [--channel a,b] [--dry-run]
|
|
17
|
+
notices send "Title" --id my-key --at 3h --reminder # same id: moves every copy (snooze)
|
|
18
|
+
notices retract my-key --reason done
|
|
19
|
+
notices poll # new events: done / snooze / cancel / dismissed
|
|
20
|
+
notices tick # sends what was held back; schedule it every minute
|
|
21
|
+
notices status my-key # the notice and its copies
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Times: ISO 8601 (local if no offset) or `10m`, `2h`, `1d`. Results are JSON; read each receipt's `status` (`sent`, `scheduled`, `deferred`, `held`, `failed`) and its `notes` (what a channel dropped) before telling the person it worked.
|
|
25
|
+
|
|
26
|
+
## Rules for agents
|
|
27
|
+
|
|
28
|
+
- **Use a meaningful `--id`** (a loop id, an issue ref) whenever the notice may be updated or withdrawn later; a retry with the same id never sends twice.
|
|
29
|
+
- **`--dry-run` first** when the routing is new to you; it prints the plan per channel.
|
|
30
|
+
- **Never put secrets in a notice.** Channel secrets are references in the settings file (`env:`, `keychain:`, `file:`), never arguments.
|
|
31
|
+
- **Public relays get no content** unless `--reveal`: ntfy.sh shows "A reminder is due". Do not add `--reveal` for anything private.
|
|
32
|
+
- **The system of record decides.** `poll` returns events; apply them to the obligation in your system of record (for example openloops) and then `retract` or re-`send`. Do not treat a notice as the record.
|
|
33
|
+
- Under pytest nothing real is sent (`held`); a test opts in with `NOTICES_ALLOW_UNDER_TEST=1` and a faked transport (`notices.testing`).
|
|
34
|
+
|
|
35
|
+
## Settings
|
|
36
|
+
|
|
37
|
+
`~/.local/share/notices/config.toml` (or `$NOTICES_HOME`): `default`, `[channels.<name>]` (with `plugin`), `[[routes]]` (`match`, `channels`, `continue`, `during`), `[intervals.<name>]`, `[inbox]` (the private reply topic for buttons). The README has a full example; the design is `docs/adr/0001-one-facade-for-notices.md`.
|
notices-0.0.2/.gitignore
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
.claude/handoffs/
|
|
2
|
+
.claude/scratch/
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*$py.class
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
.DS_Store
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
# TLS certificates
|
|
15
|
+
## Ignore all PEM files anywhere
|
|
16
|
+
*.pem
|
|
17
|
+
## Also ignore any certs directory
|
|
18
|
+
certs/
|
|
19
|
+
|
|
20
|
+
# Distribution / packaging
|
|
21
|
+
.Python
|
|
22
|
+
build/
|
|
23
|
+
develop-eggs/
|
|
24
|
+
dist/
|
|
25
|
+
downloads/
|
|
26
|
+
eggs/
|
|
27
|
+
.eggs/
|
|
28
|
+
lib/
|
|
29
|
+
lib64/
|
|
30
|
+
parts/
|
|
31
|
+
sdist/
|
|
32
|
+
var/
|
|
33
|
+
wheels/
|
|
34
|
+
node_modules/
|
|
35
|
+
*.egg-info/
|
|
36
|
+
.installed.cfg
|
|
37
|
+
*.egg
|
|
38
|
+
MANIFEST
|
|
39
|
+
_build
|
|
40
|
+
|
|
41
|
+
# PyInstaller
|
|
42
|
+
# Usually these files are written by a python script from a template
|
|
43
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
44
|
+
*.manifest
|
|
45
|
+
*.spec
|
|
46
|
+
|
|
47
|
+
# Installer logs
|
|
48
|
+
pip-log.txt
|
|
49
|
+
pip-delete-this-directory.txt
|
|
50
|
+
|
|
51
|
+
# Unit test / coverage reports
|
|
52
|
+
htmlcov/
|
|
53
|
+
.tox/
|
|
54
|
+
.coverage
|
|
55
|
+
.coverage.*
|
|
56
|
+
.cache
|
|
57
|
+
nosetests.xml
|
|
58
|
+
coverage.xml
|
|
59
|
+
*.cover
|
|
60
|
+
.hypothesis/
|
|
61
|
+
.pytest_cache/
|
|
62
|
+
|
|
63
|
+
# Translations
|
|
64
|
+
*.mo
|
|
65
|
+
*.pot
|
|
66
|
+
|
|
67
|
+
# Django stuff:
|
|
68
|
+
*.log
|
|
69
|
+
local_settings.py
|
|
70
|
+
db.sqlite3
|
|
71
|
+
|
|
72
|
+
# Flask stuff:
|
|
73
|
+
instance/
|
|
74
|
+
.webassets-cache
|
|
75
|
+
|
|
76
|
+
# Scrapy stuff:
|
|
77
|
+
.scrapy
|
|
78
|
+
|
|
79
|
+
# Sphinx documentation
|
|
80
|
+
docs/_build/
|
|
81
|
+
|
|
82
|
+
# PyBuilder
|
|
83
|
+
target/
|
|
84
|
+
|
|
85
|
+
# Jupyter Notebook
|
|
86
|
+
.ipynb_checkpoints
|
|
87
|
+
|
|
88
|
+
# pyenv
|
|
89
|
+
.python-version
|
|
90
|
+
|
|
91
|
+
# celery beat schedule file
|
|
92
|
+
celerybeat-schedule
|
|
93
|
+
|
|
94
|
+
# SageMath parsed files
|
|
95
|
+
*.sage.py
|
|
96
|
+
|
|
97
|
+
# Environments
|
|
98
|
+
.env
|
|
99
|
+
.venv
|
|
100
|
+
env/
|
|
101
|
+
venv/
|
|
102
|
+
ENV/
|
|
103
|
+
env.bak/
|
|
104
|
+
venv.bak/
|
|
105
|
+
|
|
106
|
+
# Spyder project settings
|
|
107
|
+
.spyderproject
|
|
108
|
+
.spyproject
|
|
109
|
+
|
|
110
|
+
# Rope project settings
|
|
111
|
+
.ropeproject
|
|
112
|
+
|
|
113
|
+
# mkdocs documentation
|
|
114
|
+
/site
|
|
115
|
+
|
|
116
|
+
# mypy
|
|
117
|
+
.mypy_cache/
|
|
118
|
+
|
|
119
|
+
# PyCharm
|
|
120
|
+
.idea
|
notices-0.0.2/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Thor Whalen
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
notices-0.0.2/PKG-INFO
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: notices
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: One small interface for notifications and reminders over many channels (ntfy, Apple Reminders and Calendar, macOS, Slack, Google Calendar): send, schedule, update, retract, and read back what the person did. Zero dependencies in the core; channels are plugins.
|
|
5
|
+
Project-URL: Homepage, https://github.com/thorwhalen/notices
|
|
6
|
+
Project-URL: Repository, https://github.com/thorwhalen/notices
|
|
7
|
+
Project-URL: Documentation, https://thorwhalen.github.io/notices
|
|
8
|
+
Author: Thor Whalen
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,apple-reminders,facade,google-calendar,notifications,ntfy,reminders,slack
|
|
12
|
+
Requires-Python: >=3.11
|
|
13
|
+
Requires-Dist: cw<0.2,>=0.1
|
|
14
|
+
Provides-Extra: dev
|
|
15
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
16
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
17
|
+
Requires-Dist: ruff>=0.1.0; extra == 'dev'
|
|
18
|
+
Provides-Extra: docs
|
|
19
|
+
Requires-Dist: sphinx-rtd-theme>=1.0; extra == 'docs'
|
|
20
|
+
Requires-Dist: sphinx>=6.0; extra == 'docs'
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# notices
|
|
24
|
+
|
|
25
|
+
One small interface for notifications and reminders over many channels: send, schedule, update and withdraw a notice, and read back what the person did (Done, Snooze). No dependencies in the library; each channel is a plugin.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pip install notices
|
|
29
|
+
notices send "Kettle is on" --channel macos # a banner on this Mac, no setup
|
|
30
|
+
NTFY_TOPIC=my-secret-topic notices send "Back up the server" --at 2h --reminder
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
from notices import Notice, send, retract, poll
|
|
35
|
+
|
|
36
|
+
send(Notice.reminder("call-bank", "Call the bank", at="2026-12-08T09:30", due="2026-12-08T17:00"))
|
|
37
|
+
send(Notice.reminder("call-bank", "Call the bank", at="2026-12-08T11:00")) # same id: every copy moves
|
|
38
|
+
for event in poll(): # taps on Done / Snooze, completed Apple Reminders, ...
|
|
39
|
+
print(event.type, event.subject, event.data) # subject: the notice id
|
|
40
|
+
retract("call-bank") # withdraw every copy, everywhere
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## What it does
|
|
44
|
+
|
|
45
|
+
A `Notice` is what to tell someone and when: `id`, `title`, `description`, `at` (when it should reach them), `due` (a deadline), `urgency` (`min` … `urgent`), `kind`, `project` and `tags` (for routing), `url`, `actions` (Done, Snooze, Drop, Open), and `reveal` (whether a public relay may show the title).
|
|
46
|
+
|
|
47
|
+
A `Notifier` sends it to the channels the routing rules pick, and keeps a ledger of the copies:
|
|
48
|
+
|
|
49
|
+
- **Idempotent.** Sending the same notice again does nothing. Sending a changed one (same `id`) updates every copy in place where the channel can, and otherwise withdraws and re-sends.
|
|
50
|
+
- **Scheduled where the channel can hold it**, and held back otherwise: `notices tick` (run it every minute) sends what is due.
|
|
51
|
+
- **Withdrawn everywhere** with `retract(id)`.
|
|
52
|
+
- **Two-way.** Buttons publish to a private reply topic; `poll()` returns what the person did as events. Channels with their own state (Apple Reminders) are read back directly.
|
|
53
|
+
- **Honest.** Every receipt says what was dropped (a channel without buttons, a public relay that only gets "a reminder is due"), and a failed channel is a `failed` receipt, not a crash.
|
|
54
|
+
|
|
55
|
+
## Channels
|
|
56
|
+
|
|
57
|
+
| Channel | Plugin | Schedule | Update | Withdraw | Buttons | Reads back | Setup |
|
|
58
|
+
|---|---|---|---|---|---|---|---|
|
|
59
|
+
| ntfy (phone push) | `ntfy` | up to 3 days | yes | yes (see note) | up to 3 | via the reply topic | a topic name |
|
|
60
|
+
| Apple Reminders | `apple_reminders` | yes (the device fires) | yes | yes | the checkbox | completion | one macOS permission |
|
|
61
|
+
| Apple Calendar | `apple_calendar` | yes | yes | yes | no | no | one macOS permission |
|
|
62
|
+
| macOS notification | `macos` | no (held back) | no | no | no | no | none |
|
|
63
|
+
| Slack | `slack` | up to 120 days | yes | yes | yes | via the reply topic | a bot token |
|
|
64
|
+
| Google Calendar | `google_calendar` | yes | yes | yes | no | deletion | an OAuth client |
|
|
65
|
+
|
|
66
|
+
`notices channels` shows what is configured and whether each channel is set up. On ntfy.sh, a scheduled message that was cancelled may still arrive; set `schedule = "tick"` on that channel to have `notices tick` send it at the time instead.
|
|
67
|
+
|
|
68
|
+
## Settings
|
|
69
|
+
|
|
70
|
+
One TOML file, `~/.local/share/notices/config.toml` (or `$NOTICES_HOME/config.toml`). Every part is optional.
|
|
71
|
+
|
|
72
|
+
```toml
|
|
73
|
+
default = ["phone"]
|
|
74
|
+
|
|
75
|
+
[channels.phone]
|
|
76
|
+
plugin = "ntfy"
|
|
77
|
+
topic = "keychain:my-ntfy-topic" # env:NAME, keychain:SERVICE, file:PATH, or the value itself
|
|
78
|
+
|
|
79
|
+
[channels.todo]
|
|
80
|
+
plugin = "apple_reminders"
|
|
81
|
+
list = "Inbox"
|
|
82
|
+
|
|
83
|
+
[inbox] # where buttons report back; keep this topic secret
|
|
84
|
+
topic = "keychain:my-notices-inbox"
|
|
85
|
+
|
|
86
|
+
[[routes]] # first match wins; continue = true also tries the next
|
|
87
|
+
match = { kind = "errand" }
|
|
88
|
+
channels = ["todo"]
|
|
89
|
+
continue = true
|
|
90
|
+
|
|
91
|
+
[[routes]]
|
|
92
|
+
match = { urgency = ["high", "urgent"] }
|
|
93
|
+
channels = ["phone"]
|
|
94
|
+
|
|
95
|
+
[[routes]]
|
|
96
|
+
match = { project = "client-*" }
|
|
97
|
+
channels = ["slack"]
|
|
98
|
+
during = "work"
|
|
99
|
+
|
|
100
|
+
[intervals.work]
|
|
101
|
+
times = ["09:00-18:00"]
|
|
102
|
+
weekdays = ["mon", "tue", "wed", "thu", "fri"]
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`notices route --kind errand --urgency high` shows which channels a notice would reach, without sending.
|
|
106
|
+
|
|
107
|
+
## Command line
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
notices send TITLE [--at 10m|ISO] [--due ...] [--reminder] [--channel a,b] [--urgency high] [--kind ...] [--dry-run]
|
|
111
|
+
notices retract ID [--reason done|cancel]
|
|
112
|
+
notices poll # new events, as JSON
|
|
113
|
+
notices tick # send what is due; schedule it every minute
|
|
114
|
+
notices status ID # a notice and its copies
|
|
115
|
+
notices channels # configured channels, capabilities, setup check
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
## Where your data goes
|
|
119
|
+
|
|
120
|
+
- **ntfy.sh is a public relay**: anyone who knows a topic name can read it. `notices` sends a public relay only "A reminder is due" (with Done / Snooze buttons) unless you pass `reveal`. Use a long random topic, or run your own ntfy server and set `exposure = "private"` on that channel.
|
|
121
|
+
- **The reply topic acts as a password** for the buttons, and it appears inside the button links, so it travels with every push. Make it different from the push topic. A link only works for the notice it was made for.
|
|
122
|
+
- **Slack and Google Calendar** receive the full title and text (they are private to your account); Apple Reminders and Calendar keep it on your devices and in iCloud.
|
|
123
|
+
- **The ledger** (`~/.local/share/notices/`) keeps what was sent, so it can be updated or withdrawn; finished notices are pruned after 30 days.
|
|
124
|
+
- The software is provided as is (MIT), with no guarantee about any service's handling of your data.
|
|
125
|
+
|
|
126
|
+
## Writing a channel
|
|
127
|
+
|
|
128
|
+
Subclass `notices.Channel`, declare `capabilities`, implement `send` (and `update`, `retract`, `poll` if the service can), and test it with `notices.testing.ChannelContract`. Register it in your package:
|
|
129
|
+
|
|
130
|
+
```toml
|
|
131
|
+
[project.entry-points."notices.channels"]
|
|
132
|
+
telegram = "notices_telegram:TelegramChannel"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The design and its reasons are in [docs/adr/0001-one-facade-for-notices.md](docs/adr/0001-one-facade-for-notices.md); the research behind it is in [docs/research/](docs/research/).
|
notices-0.0.2/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# notices
|
|
2
|
+
|
|
3
|
+
One small interface for notifications and reminders over many channels: send, schedule, update and withdraw a notice, and read back what the person did (Done, Snooze). No dependencies in the library; each channel is a plugin.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install notices
|
|
7
|
+
notices send "Kettle is on" --channel macos # a banner on this Mac, no setup
|
|
8
|
+
NTFY_TOPIC=my-secret-topic notices send "Back up the server" --at 2h --reminder
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```python
|
|
12
|
+
from notices import Notice, send, retract, poll
|
|
13
|
+
|
|
14
|
+
send(Notice.reminder("call-bank", "Call the bank", at="2026-12-08T09:30", due="2026-12-08T17:00"))
|
|
15
|
+
send(Notice.reminder("call-bank", "Call the bank", at="2026-12-08T11:00")) # same id: every copy moves
|
|
16
|
+
for event in poll(): # taps on Done / Snooze, completed Apple Reminders, ...
|
|
17
|
+
print(event.type, event.subject, event.data) # subject: the notice id
|
|
18
|
+
retract("call-bank") # withdraw every copy, everywhere
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## What it does
|
|
22
|
+
|
|
23
|
+
A `Notice` is what to tell someone and when: `id`, `title`, `description`, `at` (when it should reach them), `due` (a deadline), `urgency` (`min` … `urgent`), `kind`, `project` and `tags` (for routing), `url`, `actions` (Done, Snooze, Drop, Open), and `reveal` (whether a public relay may show the title).
|
|
24
|
+
|
|
25
|
+
A `Notifier` sends it to the channels the routing rules pick, and keeps a ledger of the copies:
|
|
26
|
+
|
|
27
|
+
- **Idempotent.** Sending the same notice again does nothing. Sending a changed one (same `id`) updates every copy in place where the channel can, and otherwise withdraws and re-sends.
|
|
28
|
+
- **Scheduled where the channel can hold it**, and held back otherwise: `notices tick` (run it every minute) sends what is due.
|
|
29
|
+
- **Withdrawn everywhere** with `retract(id)`.
|
|
30
|
+
- **Two-way.** Buttons publish to a private reply topic; `poll()` returns what the person did as events. Channels with their own state (Apple Reminders) are read back directly.
|
|
31
|
+
- **Honest.** Every receipt says what was dropped (a channel without buttons, a public relay that only gets "a reminder is due"), and a failed channel is a `failed` receipt, not a crash.
|
|
32
|
+
|
|
33
|
+
## Channels
|
|
34
|
+
|
|
35
|
+
| Channel | Plugin | Schedule | Update | Withdraw | Buttons | Reads back | Setup |
|
|
36
|
+
|---|---|---|---|---|---|---|---|
|
|
37
|
+
| ntfy (phone push) | `ntfy` | up to 3 days | yes | yes (see note) | up to 3 | via the reply topic | a topic name |
|
|
38
|
+
| Apple Reminders | `apple_reminders` | yes (the device fires) | yes | yes | the checkbox | completion | one macOS permission |
|
|
39
|
+
| Apple Calendar | `apple_calendar` | yes | yes | yes | no | no | one macOS permission |
|
|
40
|
+
| macOS notification | `macos` | no (held back) | no | no | no | no | none |
|
|
41
|
+
| Slack | `slack` | up to 120 days | yes | yes | yes | via the reply topic | a bot token |
|
|
42
|
+
| Google Calendar | `google_calendar` | yes | yes | yes | no | deletion | an OAuth client |
|
|
43
|
+
|
|
44
|
+
`notices channels` shows what is configured and whether each channel is set up. On ntfy.sh, a scheduled message that was cancelled may still arrive; set `schedule = "tick"` on that channel to have `notices tick` send it at the time instead.
|
|
45
|
+
|
|
46
|
+
## Settings
|
|
47
|
+
|
|
48
|
+
One TOML file, `~/.local/share/notices/config.toml` (or `$NOTICES_HOME/config.toml`). Every part is optional.
|
|
49
|
+
|
|
50
|
+
```toml
|
|
51
|
+
default = ["phone"]
|
|
52
|
+
|
|
53
|
+
[channels.phone]
|
|
54
|
+
plugin = "ntfy"
|
|
55
|
+
topic = "keychain:my-ntfy-topic" # env:NAME, keychain:SERVICE, file:PATH, or the value itself
|
|
56
|
+
|
|
57
|
+
[channels.todo]
|
|
58
|
+
plugin = "apple_reminders"
|
|
59
|
+
list = "Inbox"
|
|
60
|
+
|
|
61
|
+
[inbox] # where buttons report back; keep this topic secret
|
|
62
|
+
topic = "keychain:my-notices-inbox"
|
|
63
|
+
|
|
64
|
+
[[routes]] # first match wins; continue = true also tries the next
|
|
65
|
+
match = { kind = "errand" }
|
|
66
|
+
channels = ["todo"]
|
|
67
|
+
continue = true
|
|
68
|
+
|
|
69
|
+
[[routes]]
|
|
70
|
+
match = { urgency = ["high", "urgent"] }
|
|
71
|
+
channels = ["phone"]
|
|
72
|
+
|
|
73
|
+
[[routes]]
|
|
74
|
+
match = { project = "client-*" }
|
|
75
|
+
channels = ["slack"]
|
|
76
|
+
during = "work"
|
|
77
|
+
|
|
78
|
+
[intervals.work]
|
|
79
|
+
times = ["09:00-18:00"]
|
|
80
|
+
weekdays = ["mon", "tue", "wed", "thu", "fri"]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`notices route --kind errand --urgency high` shows which channels a notice would reach, without sending.
|
|
84
|
+
|
|
85
|
+
## Command line
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
notices send TITLE [--at 10m|ISO] [--due ...] [--reminder] [--channel a,b] [--urgency high] [--kind ...] [--dry-run]
|
|
89
|
+
notices retract ID [--reason done|cancel]
|
|
90
|
+
notices poll # new events, as JSON
|
|
91
|
+
notices tick # send what is due; schedule it every minute
|
|
92
|
+
notices status ID # a notice and its copies
|
|
93
|
+
notices channels # configured channels, capabilities, setup check
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Where your data goes
|
|
97
|
+
|
|
98
|
+
- **ntfy.sh is a public relay**: anyone who knows a topic name can read it. `notices` sends a public relay only "A reminder is due" (with Done / Snooze buttons) unless you pass `reveal`. Use a long random topic, or run your own ntfy server and set `exposure = "private"` on that channel.
|
|
99
|
+
- **The reply topic acts as a password** for the buttons, and it appears inside the button links, so it travels with every push. Make it different from the push topic. A link only works for the notice it was made for.
|
|
100
|
+
- **Slack and Google Calendar** receive the full title and text (they are private to your account); Apple Reminders and Calendar keep it on your devices and in iCloud.
|
|
101
|
+
- **The ledger** (`~/.local/share/notices/`) keeps what was sent, so it can be updated or withdrawn; finished notices are pruned after 30 days.
|
|
102
|
+
- The software is provided as is (MIT), with no guarantee about any service's handling of your data.
|
|
103
|
+
|
|
104
|
+
## Writing a channel
|
|
105
|
+
|
|
106
|
+
Subclass `notices.Channel`, declare `capabilities`, implement `send` (and `update`, `retract`, `poll` if the service can), and test it with `notices.testing.ChannelContract`. Register it in your package:
|
|
107
|
+
|
|
108
|
+
```toml
|
|
109
|
+
[project.entry-points."notices.channels"]
|
|
110
|
+
telegram = "notices_telegram:TelegramChannel"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The design and its reasons are in [docs/adr/0001-one-facade-for-notices.md](docs/adr/0001-one-facade-for-notices.md); the research behind it is in [docs/research/](docs/research/).
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
status: accepted
|
|
3
|
+
date: 2026-12-05
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# ADR-0001: One small facade for notices, with channels as plugins and the obligation kept elsewhere
|
|
7
|
+
|
|
8
|
+
## Context
|
|
9
|
+
|
|
10
|
+
Programs that need to reach a person (a reminder system, a monitoring check, an agent that finished its work) each end up with their own few lines of ntfy, `osascript` or Slack webhook code. A survey of several projects found repeated ad hoc ntfy code, each copy with its own priority words, its own way of finding the secret topic and its own privacy rule. None of them could update or withdraw a notification after sending it, and none could hear back when the person tapped "Done".
|
|
11
|
+
|
|
12
|
+
The need: one interface that can send, schedule, update and withdraw a notice on several channels (ntfy, Apple Reminders, Apple Calendar, macOS notifications, Slack, Google Calendar to start), read back what the person did, and choose channels by rules. It must be light enough that someone who wants only one channel installs almost nothing. The system of record for the underlying obligation (in the first consumer, an openloops `Loop`) stays outside this package.
|
|
13
|
+
|
|
14
|
+
Research behind this decision, with references: [standards and routing](../research/2026-12-05-standards-and-routing.md), [libraries and plugin patterns](../research/2026-12-05-libraries-and-plugin-patterns.md), [channel affordances](../research/2026-12-05-channel-affordances.md).
|
|
15
|
+
|
|
16
|
+
## Decision
|
|
17
|
+
|
|
18
|
+
### 1. No single standard covers the surface; adopt one per layer
|
|
19
|
+
|
|
20
|
+
| Layer | Adopted | Where it shows |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| The notice's fields | JSCalendar (RFC 8984) names where they overlap: `title`, `description`, `due`; the notice `id` is the replace key, as Web Push's `Topic` and the Notifications API's `tag` | `notices.model.Notice` |
|
|
23
|
+
| Urgency | ntfy's five levels with neutral names: `min`, `low`, `normal`, `high`, `urgent` | `URGENCIES`; each plugin maps them |
|
|
24
|
+
| A tap coming back | A CloudEvents 1.0 shape: `id`, `source`, `type`, `subject`, `time`, `data`; `source` + `id` is the idempotency key | `notices.model.Event`, `Event.to_cloudevent()` |
|
|
25
|
+
| Routing | Prometheus Alertmanager's routing tree, one level deep: matchers, first match wins, `continue` for fan-out, named time intervals | `notices.rules.route` |
|
|
26
|
+
| Sync state | A projection record per (notice, channel), in the spirit of CalDAV sync (RFC 6578): the system of record wins; a channel may only report Done, Snooze, Drop or "dismissed" | `notices.ledger`, `Notifier.poll` |
|
|
27
|
+
|
|
28
|
+
iCalendar VTODO/VALARM (RFC 5545, RFC 9074) is the interchange form a future CalDAV channel would write; it is not the internal format. No library offers update, retract and inbound actions over several channels: Apprise, the largest multi-service sender, returns only a boolean, so at most it becomes one optional fallback channel later.
|
|
29
|
+
|
|
30
|
+
### 2. The package
|
|
31
|
+
|
|
32
|
+
- **Zero dependencies in the library.** The only dependency is `cw`, which builds the command line and is imported only by `__main__`. Every built-in channel uses the standard library (`urllib`, `osascript`), so installing `notices` costs nothing per channel. A channel that needs a heavy library (pyobjc EventKit, Slack Socket Mode) ships later as its own distribution and registers through the entry-point group `notices.channels`. No extras are declared until one is needed.
|
|
33
|
+
- **The facade (`Notifier`) is the one path.** It routes, plans, sends, updates, retracts, defers and polls. The honesty rules live there, so no entry point can skip them: real sends are held under a test run (pytest's `PYTEST_CURRENT_TEST` or `NOTICES_UNDER_TEST`, opt in with `NOTICES_ALLOW_UNDER_TEST=1`); a public relay gets a redacted copy unless the notice says `reveal`; a feature the channel lacks is dropped with a note on the receipt, never silently; a channel failure is a `failed` receipt, never an exception (configuration errors still raise, before anything is sent).
|
|
34
|
+
- **A channel only translates.** It declares `Capabilities` honestly (a subset of a fixed vocabulary: `schedule` with a `horizon`, `update`, `retract`, `reliable_retract`, `actions`, `due`, `urgency`, `lists`, `readback`, plus its `exposure`: public, private or local) and implements `send`, and optionally `update`, `retract`, `poll`, `check`. The shipped `notices.testing.ChannelContract` is the conformance suite every channel passes, with `FakeHttp`, `FakeRun` and `no_network()` so a test cannot notify anyone.
|
|
35
|
+
- **Send is idempotent and converging.** The ledger keeps, per notice id, the notice and one receipt per channel. Sending the same notice again does nothing; sending a changed one updates every live copy in place where the channel can, and otherwise withdraws and re-sends; a change also reaches copies on channels the rules no longer pick. `retract(id)` reaches every copy.
|
|
36
|
+
- **Scheduling is delegated when the channel can hold it, and kept otherwise.** A notice whose `at` is within the channel's horizon is handed to the channel (ntfy holds three days, Slack 120, Reminders and calendars without limit). Otherwise it is `deferred` in the ledger, and `notices tick` (run every minute by a scheduler such as whenthen) sends it on time. A channel setting `schedule = "tick"` forces deferral, which is the right choice for ntfy.sh, whose scheduled messages were measured (2026-11-19) to fire even after a successful DELETE.
|
|
37
|
+
- **The way back is a reply inbox, not a server.** Every action button is a link that publishes one line (`notices done <token>`) to a private ntfy topic; `GET https://ntfy.sh/<topic>/publish?message=...` publishes, as checked on 2026-12-05. ntfy's own `http` buttons, Slack URL buttons and any link share it, and `poll` reads it back. The token is a random string per notice, kept in the ledger: the notice id never travels, and `poll` accepts a line only if its token belongs to a notice that offered that action and still has a live copy. Knowing the topic is therefore not enough to close an arbitrary notice; holding one notice's link still allows acting on that notice, which is what a button is for. Channels with their own state are read directly: a completed Apple Reminder comes back as Done, a deleted calendar event as `dismissed`. Links are kept out of calendar descriptions by default, because mail and calendar scanners may open them.
|
|
38
|
+
- **The facade never decides what an event means.** `poll` returns events; the caller, which owns the obligation, applies Done or Snooze and then calls `retract` or `send` again. This keeps one system of record and makes the facade usable by callers other than openloops. `poll(commit=False)` followed by `ack()` gives at-least-once delivery for a caller that must not lose a Done.
|
|
39
|
+
- **The ledger is a cache of delivery state**, rebuildable from the system of record by sending again. It keeps the full notice because `tick` must send deferred ones and `status` shows them; it lives in the user's own data folder. Writes are atomic and flushed, a folder lock serialises read-modify-write across processes, each receipt is recorded as soon as its channel returns, and finished records are pruned after `keep` (30 days).
|
|
40
|
+
- **Nothing real happens under a test run**, and the ledger is not changed over a live copy by a held send; `poll` reads no real inbox or channel then.
|
|
41
|
+
- **Settings are one TOML file or a mapping** (`[channels.<name>]`, `[[routes]]`, `[intervals.<name>]`, `[inbox]`, `default`), under `~/.local/share/notices/` or `$NOTICES_HOME`. Secrets are references: `env:NAME`, `keychain:SERVICE[/ACCOUNT]`, `file:PATH`, or a literal.
|
|
42
|
+
- **Surfaces.** The Python API, the `notices` command (from the functions in `notices.tools`), and a shipped agent skill. The same functions can become an MCP server by string reference without the core importing MCP. No HTTP or front end.
|
|
43
|
+
|
|
44
|
+
### 3. Seams (v1 default, and the replacement that exists)
|
|
45
|
+
|
|
46
|
+
| Seam | v1 default | Replacement pointed at |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `channels` | built-in plugins by name | third-party distributions via the entry-point group |
|
|
49
|
+
| `ledger` | JSON files, one per notice | a single-writer store on an always-on server |
|
|
50
|
+
| `settings` | `config.toml` | a host's own settings section passed as a mapping |
|
|
51
|
+
| `inbox` | an ntfy topic | an HTTPS endpoint or Slack Socket Mode listener |
|
|
52
|
+
| `clock` | the system clock | a fixed clock in tests |
|
|
53
|
+
|
|
54
|
+
Not seams, written directly: each channel's message formatting, the TOML loader, the secret-reference syntax, the inbox line format.
|
|
55
|
+
|
|
56
|
+
### 4. What was not reused, and why
|
|
57
|
+
|
|
58
|
+
The library has no dependencies, which rules out importing the components a larger host would use; each was weighed:
|
|
59
|
+
|
|
60
|
+
- **Storage:** `dol` stores fit the ledger seam (`ledger=` takes any `MutableMapping`), so a host can pass one; the default `JsonFiles` is the one small store the library needs.
|
|
61
|
+
- **Credentials:** `ocracy.kit`'s credential chain and correspond's settings resolver solve the same problem for API keys. `notices.secrets` adds file and Keychain references in one string syntax (`env:`, `keychain:`, `file:`); a reference source of this kind is a candidate for the shared credential chain.
|
|
62
|
+
- **Registry:** `xdol.Registry` was the alternative for plugins; a dict of `"module:Factory"` strings plus the entry-point group keeps the same naming convention and needs nothing.
|
|
63
|
+
- **CLI:** `cw` builds the command line from `notices.tools`; it has no dependencies of its own and is imported only by `__main__`.
|
|
64
|
+
|
|
65
|
+
The dependency arrow is one-way: `notices` never imports correspond, openloops or any host; they import it.
|
|
66
|
+
|
|
67
|
+
## Consequences
|
|
68
|
+
|
|
69
|
+
- **Relation to correspond.** correspond is a general facade for conversations (read, listen, send, edit, react, identity) and stays. Notification transports are a shared kernel: correspond's send-only ntfy, macOS and Apprise paths can delegate to `notices` channels over time, and Slack stays on both sides by intent (a conversation with a person there, an alert to the person here).
|
|
70
|
+
- **Relation to openloops.** openloops keeps the `Loop` record and its lifecycle. Its `deliver=` seam gets an adapter that maps a loop to a `Notice` (`id` = loop id, `reveal`, `due`, `at` = `remind_at`, Done and Snooze actions) and its tick calls `poll()` and applies the events. The routing rules decide which channels a loop reaches.
|
|
71
|
+
- **What a channel cannot promise.** A pushed message already on a phone stays there; ntfy.sh may still deliver a cancelled scheduled message; macOS notifications have no buttons from a command line; Google Tasks has no time of day, which is why Google Calendar is the Google channel. Each is declared in the channel's capabilities and noted on receipts.
|
|
72
|
+
- **The reply topic is a secret.** Anyone who has it can mark a notice done or snooze it. It must differ from the push topic.
|
|
73
|
+
- **Known gaps, deliberately left out of v1:** quiet hours that defer rather than route away, escalation when a notice is not acknowledged, a fallback channel when one fails, recurrence (the caller re-sends), a JavaScript twin sharing a JSON Schema of the records.
|
|
74
|
+
- **Known limits of the v1 ledger:** it is per machine. A notice sent from one machine is retracted from that machine; a deferred Apple or macOS copy is sent only by a tick on the Mac. An always-on server tick with a single writer needs the `ledger=` seam to take a `Ledger` object with locking of its own (it already does) and receipts that name the host that must execute them; that is the next change to the ledger, not a change to callers.
|