0010 - Taskbase Attention: Mattermost Notices and Acting in Taskbase¶
Status¶
Accepted 2026-10-04 by the owner, as written. Two earlier drafts were discussed with the owner the same day: a Mattermost bridge that turns thread replies into actions, and an installable web app with its own push notifications. The owner chose the simplest combination: Mattermost only tells people to look, and all actions happen in Taskbase. Both earlier designs are recorded below as alternatives. Builds on ADR-0003, ADR-0006, ADR-0007, ADR-0008, and ADR-0009. Tracked in Taskbase epic 29, task #364. Amended by ADR-0015 (accepted 2026-10-12, epic #54): task items gain Resolve with an agent, a context header, linked references, grouping with Requeue all, and Requeue when #n is done. The amendments are in section 3; the actions below stay.
Date¶
2026-10-04
Context¶
Agent work now runs unattended: runners claim tasks, reviewers merge, and Taskbase requeues what it can. What is left needs a person, and today the only way to notice it is to watch the Taskbase board. In one day (2026-10-03/04) that meant: ten tasks blocked on a Claude login, review rounds used up on #339, a blocked verdict waiting on migration order (#331), a review cancelled by a runner restart (#336), a runner holding Codex for a week on a stale limit, and a self-update that stayed on the old version without telling anyone. Each was found late, by someone looking.
The owner wants to be told, on the phone, when agent work needs them, and to act on it from the phone in Taskbase — requeue, answer the agent, change the model, close. No Taskbase app is to be published in, or installed from, an app store.
What exists today¶
- Mattermost 11.1.1 on hetzner-mgmt (
components/mattermost), signed in with Keycloak. Push notifications to the Mattermost mobile app are enabled (through Mattermost's push proxyhpns-de.mattermost.com), and mobile devices are signed in, so a mention reaches the phone today. Incoming webhooks are enabled and in use (three, for Kodexet). - Taskbase UI (ADR-0003): React 18 + Vite at
taskbase.skatzi.com, signs in with keycloak-js (PKCE,login-required), tokens in memory only. The board is built for a desktop screen. - Keycloak sessions in the
skatzirealm: 30 minutes idle, 10 hours maximum, no "remember me" — on a phone, opening a link from a notification usually means signing in first. - Taskbase state the notices need already exists:
dispatch_state(queued,dispatched,needs_attention), run outcomes and reasons (usage_limit,adapter_unavailable), review verdicts (approved,changes_requested,blocked), handoff digests withopen_questions(ADR-0009), runner heartbeats with adapter holds (ADR-0008). Requeue, cancel, update and assignment endpoints exist. Task comments are read-only in Taskbase: they are mirrored from the linked Gitea issue. - iOS links: a link tapped in Mattermost opens in Safari or Mattermost's in-app browser. iOS does not open links in a web app added to the home screen, so a separately installed Taskbase web app would not receive them.
Decision¶
- Taskbase posts a short notice to a Mattermost channel when something needs a person, with a link straight to that item in Taskbase, and @-mentions the people configured for the organization, so the Mattermost app notifies them. The notice carries no actions.
- Taskbase gets a phone-first "Needs attention" page (
/attention, and/attention/{event}per item) where the person sees what happened and acts, signed in as themselves. - Keycloak "Remember me" keeps people signed in on their phone, so a link opens straight to the item.
sequenceDiagram
participant API as Taskbase API
participant DB as Taskbase database
participant MM as Mattermost
participant P as Person
API->>DB: task enters needs_attention, outbox event written in the same transaction
API->>DB: notifier claims the event
API->>MM: incoming webhook, at-mention, task 331 needs attention, link
MM-->>P: push notification from the Mattermost app
P->>API: open the link in the browser, signed in as the person
P->>API: Requeue on large, with the person's own token
API->>DB: authorized with the person's grants and audited as the person
1. Events: a transactional outbox in Taskbase¶
Taskbase writes a row to a notifications outbox in the same transaction as the state change that causes it, so an event is never lost or invented by a crash. Each event has an ID, an organization, a kind, a subject (task or runner), a dedupe key, a small neutral payload (IDs, reason, verdict, model, PR URL, the first open question), a state (open, resolved) and timestamps.
v1 event kinds:
| Kind | When | Dedupe key |
|---|---|---|
task.needs_attention |
a task enters needs_attention, with the reason: run failed, review rounds exhausted, blocked verdict (with the reviewer's reason), run lost, usage-limit runs exhausted |
task + reason |
task.question |
a finished run's digest has open_questions and the task waits for a person |
task + run |
runner.offline |
a runner misses heartbeats for 10 minutes | runner |
runner.adapter_held |
an adapter is held for auth_failure (login broken) |
runner + adapter |
runner.update_failed |
a runner reports a failed self-update (agent-runner #313) | runner + version |
An event is resolved when its condition clears (task requeued, done or closed; runner back; hold lifted). Usage limits, caps and merges are not notified in v1. Delivered events are kept 30 days.
2. The Mattermost notice¶
- Transport: one Mattermost incoming webhook per organization (a channel such as
#taskbase-skatzi), configured in Taskbase per organization by an admin. The webhook URL is a secret, stored encrypted in Taskbase and never shown again after saving. One-way: Taskbase never reads Mattermost. - Content: one line and a link, e.g. "@chris31 #331 needs attention: review blocked — waiting for migration order. Open in Taskbase". Titles, reasons and IDs only — no descriptions, code, digests or secrets.
- Mentions: a per-organization list of Mattermost usernames, set by an admin in Taskbase. Mattermost's mobile app turns the mention into a phone notification; people manage sound and do-not-disturb in Mattermost.
- Grouping and limits: events with the same cause within two minutes (e.g. five tasks failing on one broken login) become one notice listing them, linking to
/attention. At most 10 notices per organization per hour; the rest are summarised in the next one. Resolution is not posted (it would double the noise); the Taskbase page shows it. - Delivery: a notifier loop in the API claims unsent events with
SELECT … FOR UPDATE SKIP LOCKED(safe with more than one replica), posts, records the result, and retries with backoff for up to 24 hours. An event resolved before it was sent is dropped. - Who sees it: everyone in the channel sees the one-line notice, so the channel's members should be the people with access to that organization in Taskbase; the admin who sets up the webhook is responsible for that. The link itself still requires signing in with Taskbase access.
3. Acting in Taskbase: the "Needs attention" page¶
A page designed for a phone first (and fine on a desktop): the open events of the organizations the person can read, newest first. Opening one shows the task, the reason, the last run (model, outcome, the summary's first lines, PR link) and any open question, with the actions — all Taskbase API calls with the person's own token, so authorization and audit are those of the web UI:
| Action | API |
|---|---|
| Requeue | POST /api/tasks/{id}/requeue (exists) |
| Requeue on another size or model | PUT /api/tasks/{id} model, then requeue (exist) |
| Answer the agent | new POST /api/tasks/{id}/comments (to the linked Gitea issue as the Taskbase bot, attributed "by |
| Assign or unassign a persona | PUT /api/tasks/{id} (exists) |
| Close | PUT /api/tasks/{id} done (exists), after a confirmation |
| Cancel a running run | POST /api/runs/{id}/cancel (exists) |
| Runner events | link to the runner on the Runners page |
Requeue when #n is done (add_dependency_and_requeue, ADR-0015) |
POST /api/tasks/{id}/requeue-after {depends_on, comment?}: add the depends_on link, post the comment, then requeue; stops at the first refused step |
Requeue all (requeue_group, ADR-0015) |
POST /api/attention/requeue {task_ids (≤ 20), model?}: requeue each task of a same-cause group that still has an open item; a result per task |
Amended by ADR-0015 (accepted 2026-10-12). Task items also have:
- Resolve with an agent, the first action on an open task item: a sheet with an
attention-helpersession that explains the item and drafts an action plan, which Taskbase runs as the person when they confirm. Runner items get no chat. - A context header: the task, its project and repository, goal (epic), assignee, and what the agent did: the last run's outcome and its pull request with its state and CI.
- Linked references:
#n,Owner/repo#n, PR and CI run URLs in the item's text, resolved to a title and state when they belong to the organization. - Grouping: open task items with the same cause (the same usage hold, runner, dependency or error) collapse into one row with Requeue all.
- Requeue when #n is done, offered when the item's text names an open task it waits for.
The actions in the table above stay; the chat is an addition.
The page also works when added to the home screen, but links from Mattermost open in the browser (see Context); that is fine, because the browser is signed in too.
4. Staying signed in on the phone¶
Enable "Remember me" in the skatzi realm, with remember-me sessions of 30 days idle and 90 days maximum; plain sign-ins keep 30 minutes / 10 hours. A person who ticks it on their phone opens notice links without signing in again. It applies to every application in the realm the person signs in to on that device with "Remember me" ticked — the owner's explicit trade of convenience over shorter sessions; sessions can be ended from Keycloak's account console. Tokens stay in memory; no refresh or offline tokens are stored in the browser.
5. Failure handling and security¶
- Mattermost down: events wait and are retried for 24 hours; the Taskbase page lists them regardless, so nothing depends on a notice arriving.
- API restarted mid-send: a claimed but unrecorded send is retried; at worst a notice appears twice.
- Stale actions: actions check current state — requeue on a task already queued answers "already queued" and does nothing.
- Webhook URL leaked: someone could post into that channel, not act in Taskbase; the admin regenerates it in Mattermost and saves the new one.
- The token-audience weakness (
SkipClientIDCheck, any realm client's token is accepted) is unaffected by this design — all actions are the person's own calls — but should be fixed independently.
Alternatives considered¶
| Option | Why not (for v1) |
|---|---|
| Mattermost bridge with actions by reply (first draft): a bot posts one thread per task; replies and signed buttons become Taskbase actions on behalf of the replying person | Needs a separate service, Mattermost-to-Keycloak identity mapping (one of three accounts did not map automatically), an on-behalf-of mode that is only safe after the audience fix, and a reply grammar. Acting on the Taskbase page gives the same result with none of these. |
| Installable web app with its own web push (second draft): Taskbase sends web push to the app on the home screen | Adds VAPID keys, device subscriptions and a push dispatcher, while the Mattermost app already notifies the phone. Kept as deferred. |
| Native iOS app | A free Apple ID install stops launching after 7 days and gets no push; a paid developer account costs 99 USD a year and means a second codebase. |
| A Mattermost bot account instead of an incoming webhook | Allows threads per task and editing a notice when it resolves, but needs a bot token, a channel membership and more code; v1 posts one-liners that do not need threads. |
| Slower and noisier than a Mattermost mention, and acting still means opening Taskbase. |
Consequences¶
- People are told within a minute through an app they already have, and resolve most blocked work from the phone in Taskbase, with no app store, sideloading or developer account.
- Taskbase gains a durable event outbox, a notifier, comment creation and a phone-first page — all reusable if a richer channel (a bot, web push) is added later.
- One webhook URL per organization to manage; longer Keycloak sessions for people who tick "Remember me".
- Mattermost channel membership has to be kept in line with Taskbase access, since notices show task titles.
What we deferred (and what would trigger adding it)¶
| Concept | Trigger to add |
|---|---|
| Acting by replying in Mattermost (the first draft's bridge) | Opening Taskbase from the notice proves too slow for common actions |
| Web push from Taskbase to an installed web app (the second draft) | People who do not use Mattermost need notifications |
| A bot with one thread per task and resolved notices | The channel gets hard to follow, or people need to see resolution in Mattermost |
| Per-person direct messages instead of one channel with mentions | Several people with different responsibilities share an organization |
| Notices for usage limits, caps and merges | Someone is surprised by a limit or misses a merge they needed to know about |
| Native iOS app | The browser experience proves unworkable on the phone |
Proposed implementation tasks¶
Created under epic 29 on acceptance, linked depends_on in this order:
- Platform — developer / small: enable "Remember me" in the
skatzirealm (remember-me sessions 30 days idle / 90 days maximum); create the#taskbase-skatzichannel and its incoming webhook (the URL is given to an admin to save in Taskbase, not committed). - Taskbase — developer / medium: the
notificationsoutbox written in the same transaction as the v1 events, resolution when conditions clear, dedupe keys, 30-day retention, andGET /api/attentionfor the page. - Taskbase — developer / medium: per-organization Mattermost settings (webhook URL stored encrypted, mention list; admin only, API and UI) and the notifier (grouping, rate limit, retries,
SKIP LOCKED). - Taskbase — developer / medium:
POST /api/tasks/{id}/comments(Gitea issue or local, attributed to the person). - Taskbase UI — developer / medium: the phone-first "Needs attention" page with the actions, and a manifest and icons so it can also sit on the home screen.
- Platform — developer / small: document notices, the page and setup in the Taskbase component docs, and record in this ADR anything that changed while building it.
Implementation notes¶
Built as tasks #365–#369 and #376 (Taskbase migrations 039, 040 and 043), extended by tasks #435, #457, #460, #464 and #580 (migrations 047, 048 and 051); documented in Taskbase — Attention. What differs from, or adds to, the decision above, checked against Taskbase main on 2026-10-06 (v1.122.1):
- More
task.needs_attentionreasons. Besides run failed, run lost, usage-limit retries exhausted,blockedverdict and review rounds exhausted, every other way a task is parked raises one too: run cancelled, runner-restart retries exhausted, an implementation run finished without a pull request in a reviewed project, a task assigned to the review persona, and a queued task no runner can claim. Two reasons are raised on a person's task, whosedispatch_stateis NULL:blocking_agent_workwhile an open agent taskdepends_onit (task #457, migration 047), anddecision_neededwhile it is an unanswered decision task (task #460, migration 048). Answering a decision on the page closes the task or hands it to an agent persona. - Resolution by a database trigger. A task's events resolve when the task is marked done or its
dispatch_statechanges to anything butneeds_attention(requeued, claimed, unassigned), through a trigger ontasks, so every code path resolves them in its own transaction. That trigger skipsblocking_agent_workanddecision_needed: they resolve by their own condition — task done, reassigned or unassigned, decision answered, link deleted, no open agent dependent left — through the triggers of migrations 047 and 048 ontasksandtask_links. - Runner events have no organization. They are listed and posted wherever the runner is visible, unless muted (see below): every organization for an instance runner, the organizations it serves for an organization runner.
runner.offlineis raised by the lease sweep only for runners seen within the last 24 hours, so long-retired runners raise nothing.- Runner-offline warnings can be muted per organization (task #580, migration 051) — an exception to "the page lists them regardless" (§5). An admin can turn off
organization_mattermost.warn_runner_offline("Warn when a runner goes offline"); norunner.offlinenotice is then queued for that organization, and its pending ones are dropped. The page hides arunner.offlineevent only once every organization that sees the runner has muted it, so a runner shared with an organization that still warns stays listed. Runner state on the Runners view and other kinds are unchanged. See Muting runner-offline warnings. runner.update_failedis raised from the runner's heartbeat report (update_error, stored onrunners) when the failed version is the runner's target, and resolved when the runner runs its target or the target changes.- Retention: resolved events are deleted 30 days after they resolve (not "delivered events are kept 30 days"); open events are kept until they resolve. The page lists resolved events for 24 hours.
- Delivery is per organization (
notification_deliveries), and the hourly limit countsorganization_notices. Retries back off from 30 seconds, doubling to at most an hour, until the event is 24 hours old. A failed post also holds back the notices after it in the same round. A group is posted once its first event is two minutes old, so notices arrive about two minutes after the event. - No backlog on a new webhook: only events raised after the webhook was set are posted.
- Encryption key: webhooks are encrypted with AES-256-GCM using a new
TASKBASE_SECRET_KEYfrom OpenBao (hetzner-mgmt/taskbase/secret-key, task #404); without it a webhook cannot be saved. Notice links usePUBLIC_BASE_URL. - "Remember me" not enabled (§4), owner's decision 2026-10-05. Signing in from a notice link on the phone is acceptable for now, so the live
skatzirealm keeps its normal sessions (30 minutes idle, 10 hours maximum).skatzi-realm.yamlcarries the remember-me settings from #365, which only take effect if the realm is imported again; turn them on in the running realm if signing in on the phone becomes a nuisance. - Encryption key in OpenBao (#404, 2026-10-05):
tasks-secret-keyintasks-devandtasks-prodis synced by ExternalSecrets fromclusters/hetzner-mgmt/taskbase/secret-key(one key for both environments). Losing or changing it means saving every organization's webhook URL again. - Settings are for global administrators (
scopeAdmin), not organization members. - Free text in notices has
@neutralised, so a task title cannot mention the channel. - Comments: the attribution line is "—
via Taskbase"; only people signed in to Keycloak may write them (agents acting for a run and API keys get 403); bodies are limited to 64 KiB. MCP gainedcreate_task_comment. - The page has no single-event endpoint:
/attention/{event}is read fromGET /api/attention, so an item resolved more than 24 hours ago is no longer shown. "Requeue on" offers the three tiers and the models the organization's runners offer. The web app manifest starts at/attention.