mercury-agent 0.24.3 → 0.24.4-beta.1
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.
- package/README.md +1 -1
- package/container/Dockerfile +6 -1
- package/container/agent-package.json +1 -1
- package/docs/auth/dashboard.md +46 -18
- package/docs/behavior-layers.md +4 -1
- package/docs/configuration.md +31 -4
- package/docs/container-lifecycle.md +2 -2
- package/docs/dashboard.md +3 -3
- package/docs/goals/conversation-review/goal.md +5 -0
- package/docs/goals/whatsapp-bot-hardening/archive/handoff-2026-08-09.md +1 -1
- package/docs/goals/whatsapp-bot-hardening/archive/message-author-attribution.md +1 -1
- package/docs/goals/whatsapp-bot-hardening/archive/setup-plan-2026-08-06.md +5 -5
- package/docs/pending-verification.md +72 -7
- package/docs/setup-whatsapp.md +6 -5
- package/examples/extensions/archive/gc.ts +60 -14
- package/examples/extensions/archive/inflight.ts +36 -3
- package/examples/extensions/archive/manifest.ts +19 -1
- package/examples/extensions/archive/queue.ts +26 -6
- package/examples/extensions/feed-watch/feeds.ts +5 -4
- package/examples/extensions/feed-watch/watch.ts +46 -9
- package/examples/extensions/longview/hook.ts +15 -10
- package/examples/extensions/pinchtab/skill/SKILL.md +12 -35
- package/examples/extensions/web-search/skill/references/zap.md +4 -0
- package/package.json +1 -1
- package/resources/skills/context/SKILL.md +9 -0
- package/resources/skills/spaces/SKILL.md +8 -0
- package/resources/templates/AGENTS.md +1 -1
- package/src/adapters/whatsapp-db-lookups.ts +23 -0
- package/src/adapters/whatsapp-egress.ts +40 -0
- package/src/adapters/whatsapp-media.ts +2 -0
- package/src/adapters/whatsapp-offline.ts +114 -18
- package/src/adapters/whatsapp.ts +504 -42
- package/src/agent/container-entry.ts +9 -2
- package/src/agent/container-env.ts +23 -11
- package/src/agent/container-runner.ts +6 -1
- package/src/agent/image-contract.ts +31 -59
- package/src/bridges/telegram.ts +243 -53
- package/src/bridges/whatsapp.ts +58 -9
- package/src/cli/mercury.ts +95 -50
- package/src/cli/upgrade.ts +374 -9
- package/src/cli/whatsapp-auth.ts +100 -8
- package/src/config-file.ts +64 -3
- package/src/config.ts +15 -0
- package/src/core/alive-stamp.ts +100 -0
- package/src/core/bidi.ts +49 -0
- package/src/core/commands.ts +9 -1
- package/src/core/dashboard-session.ts +197 -0
- package/src/core/global-admin.ts +1 -1
- package/src/core/handler.ts +7 -3
- package/src/core/media.ts +46 -18
- package/src/core/operator-alerts.ts +376 -92
- package/src/core/reply-context.ts +21 -6
- package/src/core/routes/config-builtin.ts +66 -12
- package/src/core/routes/config.ts +29 -37
- package/src/core/routes/connections.ts +151 -50
- package/src/core/routes/console.ts +45 -24
- package/src/core/routes/dashboard.ts +142 -19
- package/src/core/routes/spaces.ts +8 -5
- package/src/core/runtime.ts +147 -90
- package/src/core/space-delete.ts +40 -0
- package/src/core/system-messages.ts +121 -28
- package/src/core/task-scheduler.ts +133 -5
- package/src/dashboard/index.html +25 -1
- package/src/env-dump/build-deps.ts +2 -0
- package/src/env-dump/build.ts +3 -5
- package/src/env-dump/deps.ts +7 -0
- package/src/env-dump/manifest.ts +1 -0
- package/src/extensions/builtin-config-namespaces.ts +34 -0
- package/src/extensions/catalog.ts +2 -2
- package/src/extensions/config-registry.ts +12 -1
- package/src/extensions/installer.ts +4 -0
- package/src/extensions/loader.ts +20 -0
- package/src/extensions/reserved.ts +10 -2
- package/src/extensions/types.ts +4 -1
- package/src/log-redact.ts +114 -0
- package/src/logger.ts +11 -3
- package/src/main.ts +27 -4
- package/src/preflight/checks/credential.ts +21 -2
- package/src/preflight/checks/extensions.ts +60 -3
- package/src/preflight/checks/image-contract.ts +143 -29
- package/src/server.ts +180 -25
- package/src/smoke/boot.ts +23 -8
- package/src/smoke/cli.ts +2 -0
- package/src/storage/db.ts +232 -6
- package/src/storage/pi-auth.ts +95 -10
package/README.md
CHANGED
|
@@ -468,7 +468,7 @@ Auto-create isolated spaces for each user who DMs your bot. Each user gets their
|
|
|
468
468
|
dm_auto_space:
|
|
469
469
|
enabled: true
|
|
470
470
|
admin_ids: # platform IDs — auto-link to "main" space
|
|
471
|
-
- "
|
|
471
|
+
- "90000000000002" # WhatsApp LID, Telegram user ID, etc.
|
|
472
472
|
default_system_prompt: "You are a helpful assistant."
|
|
473
473
|
default_member_permissions: "prompt,prefs.get" # restrict users to chat only
|
|
474
474
|
|
package/container/Dockerfile
CHANGED
|
@@ -60,7 +60,12 @@ RUN echo '{"args":["--no-sandbox"]}' > /home/mercury/.puppeteerrc.json
|
|
|
60
60
|
ENV CHROMIUM_FLAGS="--no-sandbox"
|
|
61
61
|
|
|
62
62
|
# Install CLIs
|
|
63
|
-
|
|
63
|
+
# Exact, never a range: this is the `pi` on PATH, and its CLI bundles the pi-ai
|
|
64
|
+
# provider code it runs. A `~` here let every rebuild take the newest patch,
|
|
65
|
+
# which no test had seen. Equal to container/agent-package.json and to the
|
|
66
|
+
# host's resolved pi-ai/pi-coding-agent — tests/core-tool-snippets.test.ts and
|
|
67
|
+
# tests/pi-auth-provider-env-vars.test.ts hold all three together.
|
|
68
|
+
RUN bun add -g @earendil-works/pi-coding-agent@0.87.1
|
|
64
69
|
|
|
65
70
|
WORKDIR /app
|
|
66
71
|
|
package/docs/auth/dashboard.md
CHANGED
|
@@ -1,28 +1,56 @@
|
|
|
1
1
|
# Dashboard Authentication
|
|
2
2
|
|
|
3
|
-
The Mercury dashboard (`/dashboard/*`) is protected by `MERCURY_API_SECRET`.
|
|
3
|
+
The Mercury dashboard (`/`, `/dashboard` and `/dashboard/*`) is protected by `MERCURY_API_SECRET`. A browser signs in once with the secret and gets a **session**; the secret itself is never stored in the browser. Scripts can skip the session and send `Authorization: Bearer <MERCURY_API_SECRET>` on every request.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
With no secret configured, every dashboard path answers 503: there is no unauthenticated mode.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Signing in
|
|
8
8
|
|
|
9
|
-
`GET /dashboard/login
|
|
9
|
+
`GET /dashboard/login` serves a small form. It `POST`s the secret to `/dashboard/login`, so the secret stays out of the URL, the browser history and the reverse proxy's access log.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
- On success: sets `mercury_token` HttpOnly cookie and redirects to `/dashboard`
|
|
13
|
-
- On failure: returns `401 Invalid or missing token`
|
|
14
|
-
- Not protected by the dashboard auth middleware (it's the login endpoint itself)
|
|
11
|
+
On a correct secret the server:
|
|
15
12
|
|
|
16
|
-
|
|
13
|
+
- mints a random 256-bit session id and keeps only its SHA-256 in memory;
|
|
14
|
+
- sets `mercury_token=<id>; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=43200` (`Secure` only over HTTPS, see below);
|
|
15
|
+
- redirects to `/dashboard`.
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
User navigates to https://<host>:<port>/dashboard/login?token=<MERCURY_API_SECRET>
|
|
20
|
-
→ agent sets mercury_token HttpOnly cookie
|
|
21
|
-
→ 302 /dashboard
|
|
22
|
-
→ dashboard loads, htmx requests include cookie ✅
|
|
23
|
-
```
|
|
17
|
+
The cookie keeps its pre-F19 name, `mercury_token`, though it now holds a session id instead of the secret. The Tagula console's dashboard `init` route checks a login by finding a non-empty `mercury_token=` in the response (tagula-agents `src/app/api/proxy/dashboard/[id]/init/route.ts`), and `tests/api-chat-auth.test.ts` pins that. A login also overwrites a browser's old secret-valued cookie.
|
|
24
18
|
|
|
25
|
-
|
|
19
|
+
A wrong secret gets `401 Invalid or missing token`.
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
`GET /dashboard/login?token=<secret>` still works: the console's `init` route uses it, server-side. In a browser prefer the form, since a token in a URL lands in history and proxy logs.
|
|
22
|
+
|
|
23
|
+
## Sessions
|
|
24
|
+
|
|
25
|
+
- **Expiry.** 12 hours from sign-in (`SESSION_TTL_MS`, `src/core/dashboard-session.ts`), not extended by use.
|
|
26
|
+
- **Restart.** Sessions live in memory, so a Mercury restart (including the nightly updater) signs everyone out.
|
|
27
|
+
- **Sign out.** The **Sign out** button in the header `POST`s to `/dashboard/logout`, which revokes the session on the server and clears the cookie. A copy of the cookie taken before sign-out stops working too.
|
|
28
|
+
- **When a session ends** the page goes to the login form by itself: htmx calls get `HX-Redirect: /dashboard/login`, and when the live-update stream fails the page checks `GET /dashboard/session` (204 while signed in, 401 after).
|
|
29
|
+
- **The secret is not a cookie.** A `mercury_token=<secret>` cookie from before F19 is an unknown session id and is refused.
|
|
30
|
+
|
|
31
|
+
## HTTPS
|
|
32
|
+
|
|
33
|
+
The session cookie is `Secure` when the sign-in request came over HTTPS: the request URL is `https:`, or the connection comes from a loopback proxy (the fleet's Caddy) that sends `X-Forwarded-Proto: https`. A client's own `X-Forwarded-Proto` is ignored.
|
|
34
|
+
|
|
35
|
+
Over plain HTTP (`http://localhost:8787`, or a LAN address) the cookie is not `Secure`, because the browser would drop it. Over plain HTTP the secret itself also crosses the network in clear at sign-in, so reach a remote box only through TLS or an SSH tunnel.
|
|
36
|
+
|
|
37
|
+
## Failed-secret throttle
|
|
38
|
+
|
|
39
|
+
Every request to a secret-gated path (`/`, `/dashboard*`, `/api*`, `/chat*`, `/pre-build-ext-image`, `/auth/whatsapp`) that **offers a secret** (an `Authorization` header, or a token to the login route) and is refused counts against the client's address. After 10 refusals in 10 minutes (`SECRET_FAILURE_LIMIT`, `SECRET_FAILURE_WINDOW_MS`), secret-bearing requests from that address get `429` with `Retry-After` until the oldest refusal leaves the window. A correct secret is refused too while the lock holds; otherwise the lock would not stop guessing.
|
|
40
|
+
|
|
41
|
+
What does not count, and is never blocked:
|
|
42
|
+
|
|
43
|
+
- requests offering no secret (a scanner with no credential, a browser with an expired session);
|
|
44
|
+
- a signed-in session's requests, so an operator stays signed in while their address is locked;
|
|
45
|
+
- a container's `x-mercury-token` requests (a per-turn HMAC token, not a guessable secret);
|
|
46
|
+
- webhooks, whose 401s are platform signature failures.
|
|
47
|
+
|
|
48
|
+
**Client address.** The TCP listener passes the peer address to the app. When the peer is loopback (the fleet's Caddy), the address is the **last** `X-Forwarded-For` hop, the one the proxy appended; earlier hops are whatever the client sent. From any other peer the header is ignored. A request whose address is unknown shares one bucket, `unknown`; it is never exempt.
|
|
49
|
+
|
|
50
|
+
Each refusal logs `Secret check refused` with `clientAddress`, `path` and `status`; the refusal that engages a lock logs `Failed-secret throttle engaged for client address`.
|
|
51
|
+
|
|
52
|
+
## What this does not do
|
|
53
|
+
|
|
54
|
+
- One shared secret, no per-operator accounts and no MFA. Everyone who signs in is the same operator.
|
|
55
|
+
- Sessions do not survive a restart, and there is no list of active sessions. Rotating `MERCURY_API_SECRET` does not end existing sessions; a restart does.
|
|
56
|
+
- The `/api` operator credential still asserts identity through `x-mercury-caller` / `x-mercury-space` headers.
|
package/docs/behavior-layers.md
CHANGED
|
@@ -36,7 +36,9 @@ the repo, after a pi upgrade.
|
|
|
36
36
|
"a bot-check page is a block, never a pass")
|
|
37
37
|
## Delivery ("[reply] … [/reply] — only the span inside is sent";
|
|
38
38
|
pi-jsonl-parser.ts extractReplyEnvelope honours it,
|
|
39
|
-
a reply with no markers is sent whole
|
|
39
|
+
a reply with no markers is sent whole;
|
|
40
|
+
a slip is fixed by a new envelope — the
|
|
41
|
+
last one wins — never "… sorry, …" in-line)
|
|
40
42
|
## Staying silent ("asked not to reply → the whole reply is
|
|
41
43
|
NO_UPDATE; never explain the silence" — unconditional,
|
|
42
44
|
chat and scheduled runs; SILENCE_REPLY, pinned to the
|
|
@@ -199,6 +201,7 @@ Everything else is opt-in by instruction.
|
|
|
199
201
|
|---|---|---|
|
|
200
202
|
| Who the bot is in this space, register, what it covers, sourcing and accuracy standard, formats, when it stays silent | space `AGENTS.md` | preferences (500-char blocks in the user prompt, no structure, easy to contradict) |
|
|
201
203
|
| How the bot stays silent (the `NO_UPDATE` reply, and never explaining the silence) | the platform block (`## Staying silent`, layer 2) | space `AGENTS.md` (opt-in per space: the 26 spaces that never named it explained their silence to the group) |
|
|
204
|
+
| How a slip noticed mid-reply is fixed (write the whole message again in a new `[reply]` pair — the last one is sent — never "… sorry, …" in-line) | the platform block (`## Delivery`, layer 2) | space `AGENTS.md` (`football-reporter` still carries an older copy with a different mechanism: parked as `football-profile-duplicates-the-platform-self-correction-rule`) |
|
|
202
205
|
| A procedure: when it runs, what it produces, where it goes | the task prompt (`tasks/*.md` in a space profile) | `AGENTS.md` (a task prompt never repeats an editorial rule; `AGENTS.md` never describes a schedule) |
|
|
203
206
|
| Which language a reply is written in by default (the message's own) | the platform block (`## Reply language`, layer 2) + the host's `<reply_language>` tag | the Bot Character (left out of `persona.exclusive` spaces and absent on a deployment with none: 0 of 392 Tagula prompts carried it) |
|
|
204
207
|
| A one-line behavioural setting a space admin may change from chat (`language`, `timezone`) | preference | `AGENTS.md` (would need a deploy to change) |
|
package/docs/configuration.md
CHANGED
|
@@ -101,9 +101,17 @@ is treated as `skip`: a daily digest two days late is no longer the digest
|
|
|
101
101
|
anyone asked for. `catch_up` applies to cron tasks only — an `at` task has one
|
|
102
102
|
occurrence and is deleted after it, so there is nothing to make up.
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
104
|
+
A make-up run that is **cut off** — the host dies under it, as twice on
|
|
105
|
+
2026-10-16/17 — is no longer dropped in silence. The next boot finds the task's
|
|
106
|
+
newest ledger row `interrupted` on its off-grid make-up attempt and reports it:
|
|
107
|
+
"the make-up run for 09:00 was cut off by a restart". It is made again only
|
|
108
|
+
while the occurrence it was for is still inside `catch_up_window_ms`; past it,
|
|
109
|
+
the report names the next scheduled run instead. A cut-off *retry* (attempt 2
|
|
110
|
+
or later) is not relabelled.
|
|
111
|
+
|
|
112
|
+
The report itself waits for `alerts.settle_ms` (below) and is persisted until
|
|
113
|
+
delivery takes it (a send that then fails is logged, not retried), so a boot that dies sooner owes it to the next one, which sends one
|
|
114
|
+
merged report per task.
|
|
107
115
|
|
|
108
116
|
### Interrupted is not missed
|
|
109
117
|
|
|
@@ -252,12 +260,31 @@ switch gates the missed-run reports described above.
|
|
|
252
260
|
alerts:
|
|
253
261
|
enabled: true # default: true
|
|
254
262
|
cooldown_ms: 21600000 # 60000 – 604800000 (default: 6h)
|
|
263
|
+
settle_ms: 60000 # 0 – 600000 (default: 60 s)
|
|
255
264
|
recipients: # optional; extra audiences, in addition to the admins
|
|
256
265
|
- ops-team # a space id: every conversation linked to it
|
|
266
|
+
- "972500000000" # a person id — quote numbers
|
|
257
267
|
```
|
|
258
268
|
|
|
269
|
+
`alerts.recipients` and `dm_auto_space.admin_ids` also accept a single value or
|
|
270
|
+
a comma-separated string (`recipients: ops-team, staff`), and an unquoted
|
|
271
|
+
number. Quote phone numbers anyway: YAML reads `0501234567` as `501234567` and
|
|
272
|
+
`+972501234567` as `972501234567`, dropping the leading zero or `+`. A number
|
|
273
|
+
above 9007199254740991 cannot be held exactly, so Mercury refuses it at startup
|
|
274
|
+
and asks for the quoted form.
|
|
275
|
+
|
|
259
276
|
Env equivalents: **`MERCURY_ALERTS_ENABLED`**, **`MERCURY_ALERTS_COOLDOWN_MS`**,
|
|
260
|
-
**`MERCURY_ALERTS_RECIPIENTS`** (comma-separated).
|
|
277
|
+
**`MERCURY_ALERTS_SETTLE_MS`**, **`MERCURY_ALERTS_RECIPIENTS`** (comma-separated).
|
|
278
|
+
|
|
279
|
+
- **`settle_ms`** is how long a boot must last before it tells anyone the bot
|
|
280
|
+
is back: the missed-run report and the WhatsApp "please resend" notice both
|
|
281
|
+
wait for it. On 2026-10-16/17 a backup's `wsl.exe` woke the box for 25 s,
|
|
282
|
+
twice, inside a 44 h outage, and each blip told the owner the bot was back.
|
|
283
|
+
What a shorter boot owed is kept in the database (`pending_missed_run_reports`,
|
|
284
|
+
`pending_offline_notices`) and sent, merged, by the first boot that lasts. A
|
|
285
|
+
settled boot also stamps `host_state.last_alive` every minute; the next boot's
|
|
286
|
+
WhatsApp notice reports the outage from that stamp until it reconnected,
|
|
287
|
+
rather than the times of the dropped messages. `0` sends at once.
|
|
261
288
|
|
|
262
289
|
- **Recipients** are the ids listed in `permissions.admins` (`MERCURY_ADMINS`)
|
|
263
290
|
and `dm_auto_space.admin_ids` (`MERCURY_DM_AUTO_SPACE_ADMIN_IDS`), plus every
|
|
@@ -256,7 +256,7 @@ while something is wrong; rolling an upgrade back over one would be wrong.
|
|
|
256
256
|
| `sandbox.runsc-host-uds` | blocked | `probeRunscHostUds` — the boot probe, on demand |
|
|
257
257
|
| `image.contract` | blocked | every `container/Dockerfile` `COPY` target is in the image, and the version the build stamped into `/app/image-manifest.json` equals the host's |
|
|
258
258
|
| `container.mrctl-roundtrip` | blocked | a container on the production launch shape runs `mrctl whoami` and comes back as the caller preflight asserted — by minted token where a caller-token key is configured, by identity header where none is (evidence `callerAuth`; see below). On runsc the host API socket is connect-tested first, so a stopped service blocks with the service remedy and no container is created |
|
|
259
|
-
| `credential.first-leg` | blocked | the chain's first leg (or `--space`'s pinned leg) resolves a credential the way a spawn resolves it |
|
|
259
|
+
| `credential.first-leg` | blocked | the chain's first leg (or `--space`'s pinned leg) resolves a credential the way a spawn resolves it. A pass proves **presence, not acceptance** — no provider call is made, so a revoked key still passes (`evidence.acceptance`) |
|
|
260
260
|
| `host.pi` | warn | `pi` is on the host when napkin or longview is loaded, and its `--version` satisfies the pi range in `container/agent-package.json` |
|
|
261
261
|
| `host.timezone` | warn | no active cron task carries `timezone: null` — a zoneless cron is parsed as UTC on every host, so the host's own zone is evidence, not the condition |
|
|
262
262
|
| `host.swap` | warn | a host of ≤ 4 GiB has swap |
|
|
@@ -476,7 +476,7 @@ RUN curl -fsSL https://bun.sh/install | bash
|
|
|
476
476
|
ENV PATH="/home/mercury/.bun/bin:$PATH"
|
|
477
477
|
|
|
478
478
|
# Install required CLIs
|
|
479
|
-
RUN bun add -g @earendil-works/pi-coding-agent
|
|
479
|
+
RUN bun add -g @earendil-works/pi-coding-agent@0.87.1 # the exact pin in container/agent-package.json
|
|
480
480
|
|
|
481
481
|
# Optional: install Playwright/Chromium if your extensions need browser automation
|
|
482
482
|
RUN bunx playwright install chromium
|
package/docs/dashboard.md
CHANGED
|
@@ -4,13 +4,13 @@ Mercury ships with a web dashboard at `http://localhost:8787/dashboard` (or whic
|
|
|
4
4
|
|
|
5
5
|
## Access & Authentication
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
The dashboard requires `MERCURY_API_SECRET` (auto-generated by `mercury setup`); without it every dashboard path answers 503. Open:
|
|
8
8
|
|
|
9
9
|
```
|
|
10
|
-
http://localhost:8787/dashboard/login
|
|
10
|
+
http://localhost:8787/dashboard/login
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
and enter the secret. That starts a 12-hour session; **Sign out** in the header ends it. Off the box, reach the dashboard only over HTTPS or an SSH tunnel: over plain HTTP the secret crosses the network in clear. Ten wrong secrets from one address in ten minutes lock that address out for the rest of the window. Details: [auth/dashboard.md](auth/dashboard.md).
|
|
14
14
|
|
|
15
15
|
## Pages
|
|
16
16
|
|
|
@@ -148,3 +148,8 @@ The triage those reviews used becomes the report's schema:
|
|
|
148
148
|
- classification is re-derived at intake;
|
|
149
149
|
- rejected false positives are not re-raised;
|
|
150
150
|
- recall is measured weekly.
|
|
151
|
+
|
|
152
|
+
## Input notes (not decisions)
|
|
153
|
+
|
|
154
|
+
- **2026-10-18, a shared monitoring group.** Folded in from the closed idea `one-monitoring-group-for-all-client-spaces`, from a Tagula team member's request in the 2026-10-18 scan. The ask is one WhatsApp group the team sits in, where findings from **all** client spaces land: errors (a failed run, a dead connection), anomalies (a space suddenly silent, a refused or looping reply) and unserved requests. Later, each finding becomes a GitHub issue automatically (the bot has opened one itself already, tagula-ai/mercury#143). The owner's note: findings are filed automatically, by the bot or by periodic scans. What this goal lacks for it is a live, shared destination for its findings. When it is planned, reconcile it with `docs/backlog/operator-alert-ping-mirror.md` (alerts off the box), `docs/backlog/healthchecks-whatsapp-relay.md` and `docs/ideas/daily-ops-digest-via-telegram.md`. Cross-client content in one group is the same risk as the open bug `alert-recipient-space-receives-every-spaces-client-identifiers`.
|
|
155
|
+
|
|
@@ -221,7 +221,7 @@ model glitch.
|
|
|
221
221
|
(`adapters/whatsapp.ts:82`) looks names up in `pushNames` (`whatsapp.ts:169`) — an
|
|
222
222
|
**in-memory** map, empty after every restart — and canonicalizes sync-only (no async LID
|
|
223
223
|
lookup). Real row currently in the greece2026 DB:
|
|
224
|
-
`<reply_to name="
|
|
224
|
+
`<reply_to name="900000000000003" jid="900000000000003@lid" …>`
|
|
225
225
|
|
|
226
226
|
**Good news:** the identity data already exists and is clean. `space_roles.display_name`
|
|
227
227
|
is fully populated, correctly keyed by canonical phone JID (26 members), e.g.
|
|
@@ -30,7 +30,7 @@ attributed from day one.
|
|
|
30
30
|
- As a group member, I want the bot to know who said what so that "who said X?"
|
|
31
31
|
gets the right answer.
|
|
32
32
|
- As a group member, I want quoted replies to show real names even after the
|
|
33
|
-
service restarts, not `
|
|
33
|
+
service restarts, not `900000000000003@lid`.
|
|
34
34
|
|
|
35
35
|
## MVP Scope
|
|
36
36
|
|
|
@@ -461,9 +461,9 @@ form you have.
|
|
|
461
461
|
|
|
462
462
|
| | |
|
|
463
463
|
|---|---|
|
|
464
|
-
| Bot account | `
|
|
465
|
-
| Bot LID | `
|
|
466
|
-
| Admin (you) | `whatsapp:
|
|
464
|
+
| Bot account | `972599000002:1@s.whatsapp.net` — "ויצ דה בוט" |
|
|
465
|
+
| Bot LID | `900000000000003:1@lid` |
|
|
466
|
+
| Admin (you) | `whatsapp:972599000007@s.whatsapp.net` |
|
|
467
467
|
|
|
468
468
|
> **`mercury doctor`'s "No AI credentials configured" is a false positive on any
|
|
469
469
|
> non-Anthropic provider.** `src/cli/mercury.ts:513-516` checks only
|
|
@@ -480,10 +480,10 @@ form you have.
|
|
|
480
480
|
A WhatsApp DM to the bot number gets a reply. Confirmed round trip:
|
|
481
481
|
|
|
482
482
|
```
|
|
483
|
-
Message from: whatsapp:
|
|
483
|
+
Message from: whatsapp:972599000007@s.whatsapp.net (<admin name>)
|
|
484
484
|
Container started spaceId=main
|
|
485
485
|
Container exited exitCode=0 durationMs=6773
|
|
486
|
-
WhatsApp outbound chatJid=
|
|
486
|
+
WhatsApp outbound chatJid=972599000007@s.whatsapp.net
|
|
487
487
|
```
|
|
488
488
|
|
|
489
489
|
**~7 s per turn** — Mercury starts a fresh container for every message.
|
|
@@ -9,6 +9,21 @@ once every line under it is ticked.
|
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
+
## anchor task runs without a logon 2026-10-18 — reboot drill deferred
|
|
13
|
+
|
|
14
|
+
`Start Mercury WSL` was switched to `LogonType: Password` with an at-startup
|
|
15
|
+
trigger and no run-time limit on 2026-10-18 13:08 IDT (verified from the
|
|
16
|
+
installed task; first run 13:10:10 ended `0`). Deferred by the owner until no
|
|
17
|
+
sessions are open (`docs/notes/2026-10-18-windows-update-restart-outage.md`, Phase 0).
|
|
18
|
+
|
|
19
|
+
- [ ] Restart Windows outside 08:55–09:15 and do not log on; 5–7 min later the
|
|
20
|
+
`mercury-anchor` check shows a fresh ping and the bot answers a DM.
|
|
21
|
+
If not: `install-anchor-task.ps1 -Direct` (elevated), then repeat.
|
|
22
|
+
- [ ] After logging on: `Get-ScheduledTaskInfo 'Start Mercury WSL'` shows
|
|
23
|
+
`LastTaskResult 0`, and there is one anchor `wsl.exe` pair, created before the logon.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
12
27
|
## history window cap 2026-09-03 — deploy-gated re-measure
|
|
13
28
|
|
|
14
29
|
`context.history_max_chars` (default 2,000) clips older messages in the
|
|
@@ -147,7 +162,7 @@ addendum first). Second-order cost levers are ideas: `isolated-verify-task-runs.
|
|
|
147
162
|
| **longview publishes the daily article** | `extension_state` longview/`recent`: 10 consecutive pages 08-21 → 08-31, newest `chars=6028`, `publishedAt 2026-08-31T06:04:29Z`. The `messages` row keeps the pre-send body; the link is added at send |
|
|
148
163
|
| the `main` space (flag off) still answers with the global character | msg 3965, 2026-08-31 09:12:28 — "I'm Wiz, a personal assistant on WhatsApp…", pulled via `mrctl character get` as the check allows |
|
|
149
164
|
| "cover United less" is not silently applied | msg 3967 — the bot says there is no feed watch in `main`, offers to set a space preference, and claims nothing. No preference was written |
|
|
150
|
-
| admin adds a watch term, read-modify-write holds | `feed-watch.terms` 18 → **20** at 09:14:18, `updated_by=whatsapp:
|
|
165
|
+
| admin adds a watch term, read-modify-write holds | `feed-watch.terms` 18 → **20** at 09:14:18, `updated_by=whatsapp:972599000007`. All 18 originals intact and in order; it appended the Hebrew **and** English forms unprompted, matching the list convention |
|
|
151
166
|
| dashboard prefs panel shows no `club-coverage` / `push-rules` | owner's dashboard export 2026-08-31 12:17: the prefs panel lists exactly `language` and `timezone`. Same export confirms `persona.exclusive = true` and the new watch term |
|
|
152
167
|
| article task timezone / next run | task 24, `Asia/Jerusalem`, next run 2026-09-01 06:00Z. The **26 Oct 2026** DST re-check stays open by definition |
|
|
153
168
|
|
|
@@ -488,7 +503,7 @@ task 28 is still active on `0 0,12,15,18,21`.
|
|
|
488
503
|
- [x] 4. Loaded: `Loaded extension: feed-watch` / `Installed skill: feed-watch` / `Started interval job job=feed-watch:poll intervalMs=180000`, all at 2026-08-25 17:10:46 IDT. Eight profile-owned keys present in `space_config` (`batch_minutes`, `digest_max_items`, `exclude`, `max_per_hour`, `quiet_hours`, `sources`, `terms`, `timezone`).
|
|
489
504
|
- [x] 5. All eight `feed-watch.*` keys are stamped `updated_by=space-profile`, and `enabled` is **not** — exactly the split the step demanded.
|
|
490
505
|
- [x] 6. Task 28 is gone. `SELECT id … FROM tasks` returns **one** row for the space: task 24, `0 9 * * *`, `Asia/Jerusalem`, `last_status=ok` (2026-09-01).
|
|
491
|
-
- [x] 7. `feed-watch.enabled = true`, `updated_by=whatsapp:
|
|
506
|
+
- [x] 7. `feed-watch.enabled = true`, `updated_by=whatsapp:972599000007@s.whatsapp.net` — a named admin, not `space-profile`.
|
|
492
507
|
- [x] 8. `feed-watch: seeded, no run opened … seeded=527 buffered=173 fetched=14 failed=0` at 2026-08-25 17:17:56.
|
|
493
508
|
|
|
494
509
|
### Then, over two days
|
|
@@ -501,7 +516,7 @@ task 28 is still active on `0 0,12,15,18,21`.
|
|
|
501
516
|
- [x] **PASSED** — `~/whatsapp-bot/.mercury/spaces/football-friends/knowledge/feed-digest.md` present, mtime 2026-09-01 16:17. ⚠️ It is now **838 KB** (564 KB on 08-31, so still growing unbounded — disk only, it is not in recent prompts). `feed-digest-window.md` (11.7 KB) is alongside it as the post-fix whole-window file.
|
|
502
517
|
- [x] **PASSED** — task 24: `cron='0 9 * * *'`, `timezone='Asia/Jerusalem'`, `active=1`, `last_status='ok'`, next run 2026-09-01 06:00Z (read 2026-09-01). It is the space's **only** task row.
|
|
503
518
|
- [ ] **Future-dated, cannot pass yet:** on **26 Oct 2026** verify task 24 fired at 07:00Z, not 06:00Z (Israel leaves DST). Split out of the row above so it stops holding a passed check open.
|
|
504
|
-
- [x] **PASSED as written, but the result did not survive** — 2026-08-31 09:14:18 an admin's request took `feed-watch.terms` 18 → **20**, stamped `updated_by=whatsapp:
|
|
519
|
+
- [x] **PASSED as written, but the result did not survive** — 2026-08-31 09:14:18 an admin's request took `feed-watch.terms` 18 → **20**, stamped `updated_by=whatsapp:972599000007`, all 18 originals intact and in order, Hebrew *and* English forms appended unprompted. The read-modify-write is proven. ⚠️ **The two added terms are gone.** As of 2026-09-01 the key holds **18** entries, byte-identical to `examples/profiles/football-reporter/config.yaml:109-114`, stamped `updated_by=space-profile`, `updated_at=2026-08-31T09:34:29.088Z` (= 12:34 IDT). The doc's own timeline brackets it: added 09:14 IDT, still present in the 12:17 IDT dashboard export, gone by 12:34 IDT — a `space-profile apply` wrote the repo list back over it. The check passes; the clobber is a separate defect and is **not** tracked anywhere yet.
|
|
505
520
|
- [x] Ask as a member → refused with the who-can line, terms unchanged. *(2026-09-15 bench: "תוסיף את ליברפול לרשימת המעקב" → "זה משהו שסהר צריך לאשר"; `feed-watch.terms` byte-identical before and after.)*
|
|
506
521
|
- [x] **FAILED 2026-08-31 — $15.92–19.75/day, 08-26→08-30.** A week of ledger spend for the space is **below** the $7.19–$7.53/day the project ran at on 08-19 / 08-20. M2 checkpoint target direction — reported, not gated. **Cause fixed and verified on demand the same day** (see the table row above); the ceiling is now config-bounded at ≈ $4.5 expected / $9.5 worst per day. Ticked as *verified*, not as *observed for a week* — the week is a monitoring read, not a check.
|
|
507
522
|
- [x] No source sits in permanent backoff (2026-08-31: 5 failed, 5 recovered, 1:1): grep the logs for `source failed` with no matching `source recovered`.
|
|
@@ -1263,8 +1278,8 @@ LID-addressed members; none can be asserted from a test, because what is being
|
|
|
1263
1278
|
checked is whether a phone buzzes.
|
|
1264
1279
|
|
|
1265
1280
|
- [x] Someone @-tags two people in the group and the agent's reply names them
|
|
1266
|
-
in words rather than echoing `@
|
|
1267
|
-
digits never reach the model. *(2026-09-15: runnable in the test group after all — the run prompt's `<members>` block lists 9 members, so two friends can be tagged there at the cost of buzzing them once; owner's call.)* *(2026-09-15 13:05 IDT, bench on a fresh snapshot — the friends are no longer in the group, so this ran as a synthetic member event with two `mentionedJids`: the prompt reads `תגיד ל-@
|
|
1281
|
+
in words rather than echoing `@900000000000001`. The prompt half: the raw
|
|
1282
|
+
digits never reach the model. *(2026-09-15: runnable in the test group after all — the run prompt's `<members>` block lists 9 members, so two friends can be tagged there at the cost of buzzing them once; owner's call.)* *(2026-09-15 13:05 IDT, bench on a fresh snapshot — the friends are no longer in the group, so this ran as a synthetic member event with two `mentionedJids`: the prompt reads `תגיד ל-@Member-A ול-@Member-B🦖 …` with 0 raw digits (trace `mercury-1789466664077-1.jsonl`); the reply opens `@Member-A @Member-B🦖 בעובדות: …`; the wire carries both names as tags with 4 `mentions` (PN + LID per person). The notify half is the L1268 pattern the owner confirmed at 12:43. Side note: the reply spells Mbappé `מבאפה` against the glossary — the L1639 drift reaches chat too.)*
|
|
1268
1283
|
- [x] The agent writes `@<a member's name>` and that member's phone actually
|
|
1269
1284
|
notifies, highlighted rather than plain text. The wire half — a tag that
|
|
1270
1285
|
renders and does not notify is the original defect wearing a new face. *(2026-09-15 12:43 IDT, "תייג אותי" from the owner: model wrote `@סהר` (trace `mercury-1789465371240-10.jsonl`, no digits in the prompt), wire `יאללה @<lid>, תיוג בוצע 👊` with `mentionCount=2` (LID + PN jids). This was the first tag reply after the 10:47 restart, so it doubles as the cold-start line below. Owner's phone-side read (highlighted name, buzz) recorded in the session; tick on their word.)* **Owner, 13:05 IDT: highlighted name and a buzz — ticked.**
|
|
@@ -1685,7 +1700,7 @@ record of why.
|
|
|
1685
1700
|
Host-side; needs the restart of deploy 2 (`src/` moved, nothing baked) and the longview snapshot refresh that restart performs. Every line reads the box.
|
|
1686
1701
|
|
|
1687
1702
|
- [x] MANUAL-VERIFY(2026-09-12): **the migration ran and old rows are space-level.** `sqlite3 -readonly ~/whatsapp-bot/.mercury/state.db "PRAGMA table_info(messages)"` lists a `conversation` column, and `select count(*) from messages where conversation is not null` is 0 immediately after the restart and grows only with chat rows written after it (`select conversation, count(*) from messages where conversation is not null group by 1` — one key per linked group, never a scheduled post: `select count(*) from messages where source='scheduler' and conversation is not null` stays 0). *(Ticked 2026-09-12 21:30 IDT: `conversation` column present; non-null count 0 at 21:16, then 3 — all from this session's two `mercury chat` probes, stamped `api:api:cli:user`; scheduler rows with a conversation: 0. The doubled `api:` prefix is filed: `docs/bugs/api-chat-conversation-key-doubles-its-platform-prefix.md`.)*
|
|
1688
|
-
- [x] MANUAL-VERIFY(2026-09-12): **a chat turn in the test group is stamped with its thread id.** From the owner's phone, one question in the test group; then `select conversation from messages where role='user' order by id desc limit 1` is `whatsapp:<the test group's jid>` — the same string `getSpaceConversations` renders for that row (`select platform||':'||external_id from conversations where space_id='football-friends'`). *(2026-09-15: the owner's 09-13/09-14 probes (rows 5184, 5188, 5230, 5232) carry `whatsapp:
|
|
1703
|
+
- [x] MANUAL-VERIFY(2026-09-12): **a chat turn in the test group is stamped with its thread id.** From the owner's phone, one question in the test group; then `select conversation from messages where role='user' order by id desc limit 1` is `whatsapp:<the test group's jid>` — the same string `getSpaceConversations` renders for that row (`select platform||':'||external_id from conversations where space_id='football-friends'`). *(2026-09-15: the owner's 09-13/09-14 probes (rows 5184, 5188, 5230, 5232) carry `whatsapp:120363900000000001@g.us:120363900000000001@g.us`, byte-equal to `platform||':'||external_id`.)*
|
|
1689
1704
|
- [ ] MANUAL-VERIFY(2026-09-12): **after the real group is linked, a reply there does not see the test chatter.** With both groups linked, run `mercury trace` (or read the newest trace under `~/whatsapp-bot/.mercury/traces/`) for a member's question in the real group: the `<history>` block holds the space's scheduled posts and rows of the real group only — no line of the owner's test-group probes. The mirror check from the test group: a probe there does not see the real group's turns. A one-conversation space (`main`) is unchanged: its trace shows every turn as before.
|
|
1690
1705
|
- [ ] MANUAL-VERIFY(2026-09-12): **the article run in a two-group space reads no group's chatter.** The first `Scheduled run finished` for task 24 after the link: its trace's `<history>` holds only assistant rows with `source=scheduler` (and any pre-migration rows) — no member question from either group (D-027).
|
|
1691
1706
|
- [ ] MANUAL-VERIFY(2026-09-12): **a feed-watch failure reaches the owner's DM and not the group.** The next `Scheduled task handler failed … attempt=2` line for a task whose `name` is `feed-watch` (journal) is followed by `Task failure routed to the operator channel` and `Operator alerted … recipientThreadId=whatsapp:<owner jid>`, the owner's DM shows the ⚠️ "Reported here rather than in the space" message, and `select count(*) from messages where space_id='football-friends' and content like '%נכשלה ולא הפיקה%' and created_at > <restart epoch ms>` is 0. Two such failures happened in the week of 09-04→09-11 on their own; if none happens in the first live week, keep the line open rather than forcing one.
|
|
@@ -2452,7 +2467,7 @@ Image rebuild (`src/agent/container-entry.ts` is baked), then restart; the host
|
|
|
2452
2467
|
## Plan monitoring-1005 / S9 — messages sent while the bot was offline are answered or noticed (added 2026-10-12, deploy-gated: restart)
|
|
2453
2468
|
|
|
2454
2469
|
- [ ] MANUAL-VERIFY(2026-10-12): After the restart (in a gap), send the bot a DM from another phone within a minute of the restart. It should be answered, and the journal should show `WhatsApp offline message admitted` (or `WhatsApp inbound` if it arrived live).
|
|
2455
|
-
- [ ] MANUAL-VERIFY(2026-10-12): Next real outage longer than 15 minutes (do not cause one): the journal should show one `WhatsApp offline message dropped: too old to answer` line per missed message and one `WhatsApp offline notice sent` per DM chat, and that chat should get one "I was
|
|
2470
|
+
- [ ] MANUAL-VERIFY(2026-10-12): Next real outage longer than 15 minutes (do not cause one): the journal should show one `WhatsApp offline message dropped: too old to answer` line per missed message and one `WhatsApp offline notice sent` per DM chat, and that chat should get one "I was unavailable from … to …" (Hebrew: "הבוט לא היה זמין מ-… עד …") message. (Wording changed 2026-10-19 by `outage-notices-claim-recovery-on-a-blip-and-misstate-the-window`; see below.)
|
|
2456
2471
|
|
|
2457
2472
|
## Plan tagula-predeploy-1014 / S1 — public Google Docs links are read without gws (added 2026-10-14, deploy-gated: image rebuild)
|
|
2458
2473
|
|
|
@@ -2467,3 +2482,53 @@ Image rebuild (`src/agent/container-entry.ts` is baked), then restart; the host
|
|
|
2467
2482
|
|
|
2468
2483
|
- [ ] MANUAL-VERIFY(2026-10-14): After beta.4 is deployed to the Tagula box, `docker run --rm --entrypoint grep <the derived mercury-agent-ext image> -c _pinchtab_await_instance /usr/local/bin/pinchtab_ensure` prints a number above 0. Grep the image, not the repo.
|
|
2469
2484
|
- [ ] MANUAL-VERIFY(2026-10-14): Over the next week of Tagula traces, no `Error 409` `no_current_tab` right after a run's first `pinchtab_ensure`. If a navigation does fail, `pinchtab_nav` prints `the navigation to … FAILED`, not a silent exit 0.
|
|
2485
|
+
|
|
2486
|
+
## Plan open-bugs-2026-10 / S68
|
|
2487
|
+
|
|
2488
|
+
zap extractor reads one-store cards labelled `למפרט טכני` (restart-deployed: extension skill, copied to `.mercury/global/skills/` at startup)
|
|
2489
|
+
|
|
2490
|
+
- [ ] MANUAL-VERIFY(2026-10-18): After the restart, `grep -c -F 'לא צוינה' ~/whatsapp-bot/.mercury/global/skills/web-search/references/zap.md` → prints at least `1`. Then DM `main` "כמה עולה מכונת כביסה 8 קילו בזאפ?". In the trace, the 1,000–1,500 ₪ listing's step-3 line shows `rows` equal to `cards` (on 2026-10-18 the patched block printed `rows: 25 cards: 25` on that page). This is the re-run that closes the open 2026-10-02 "rows equal to cards" item in the web-search section.
|
|
2491
|
+
|
|
2492
|
+
## Plan open-bugs-2026-10 / S39 — `mercury auth whatsapp` on logged-out creds (added 2026-10-18, deploy-gated: new CLI release)
|
|
2493
|
+
|
|
2494
|
+
- [ ] MANUAL-VERIFY(2026-10-18): Do not unlink the live device to test this. The next time WhatsApp really logs the bot out: plain `mercury auth whatsapp` in the project prints "already holds registered WhatsApp creds … mercury auth whatsapp --reset" and exits 2 (`echo $?`), not "Already authenticated". Then, with the service stopped, `mercury auth whatsapp --reset` prints `moving … -> ….logged-out-<timestamp>`, shows a QR, and after the scan the old creds sit in the `.logged-out-*` dir; starting the service brings the bot back.
|
|
2495
|
+
|
|
2496
|
+
## Plan open-bugs-2026-10 / S20 — space page rows for three builtin keys (added 2026-10-18, deploy-gated: restart)
|
|
2497
|
+
|
|
2498
|
+
- [ ] MANUAL-VERIFY(2026-10-18): After the restart, open the dashboard page of a group space. A new panel "Messages, debounce & sensitive connections" shows a `messages.locale` row (hover shows the description), a `debounce.idle_timeout_ms` row, and a read-only `security.sensitive_connections_allowed` row with no Save button. Set locale to `he` there, Save: the page reloads with `messages.locale=he (this space)`. Press Reset to put it back.
|
|
2499
|
+
|
|
2500
|
+
## Plan open-bugs-2026-10 / S64 — Telegram reply to media (added 2026-10-18, deploy-gated: new release + restart)
|
|
2501
|
+
|
|
2502
|
+
- [ ] MANUAL-VERIFY(2026-10-18): Only if a Telegram space is live. Send the bot a voice note with no caption, then reply to it "what did I say?". The bot answers about the voice note, and the trace prompt holds `<reply_to platform="telegram" … media_type="voice" media_mime="audio/ogg">` with `[voice note]` as its body.
|
|
2503
|
+
|
|
2504
|
+
## reply-corrects-itself-in-text-instead-of-being-rewritten (added 2026-10-19, deploy-gated: image rebuild)
|
|
2505
|
+
|
|
2506
|
+
- [ ] MANUAL-VERIFY(2026-10-19): After `container/build.sh` and the restart, `docker run --rm --entrypoint grep mercury-agent:<version> -c -F 'Only the last pair is sent' /app/src/agent/container-entry.ts` prints `1`. Two weeks later, search the stored bot replies for a mid-message "... סליחה," or "… sorry," (the shape of message 9715): none newer than the rebuild.
|
|
2507
|
+
|
|
2508
|
+
## outage-notices-claim-recovery-on-a-blip-and-misstate-the-window (added 2026-10-19, deploy-gated: restart)
|
|
2509
|
+
|
|
2510
|
+
- [ ] MANUAL-VERIFY(2026-10-19): Stop the service, have another phone DM the bot, wait 20 minutes, start it again in a gap. No "please resend" message should arrive in the first minute after the start. After that, exactly one should arrive, saying the bot was unavailable from about the time you stopped it until the restart (not the time of the DM). The journal should show `WhatsApp offline notice sent`.
|
|
2511
|
+
- [ ] MANUAL-VERIFY(2026-10-19): After the first restart on this code, `sqlite3 ~/whatsapp-bot/.mercury/state.db "SELECT key, datetime(value/1000,'unixepoch') FROM host_state"` (adjust the DB path if it differs) should show a `last_alive` row less than two minutes old.
|
|
2512
|
+
|
|
2513
|
+
## Plan open-bugs-2026-10 / S11 — archive reconcile collects the bytes of failed forgets (added 2026-10-19, deploy-gated: archive extension update + restart)
|
|
2514
|
+
|
|
2515
|
+
- [ ] MANUAL-VERIFY(2026-10-19): After the first weekly `archive-reconcile` on a Drive-backed box, `journalctl -u mercury | grep 'reconcile refused'` (or `mercury service logs`). No line is good. Each line now says `N unexplained orphan(s) and M tombstoned blob(s)`: if N is 0 that would be this bug, so tell me. If N > 0, compare that space's orphan list against its manifest before deleting anything.
|
|
2516
|
+
|
|
2517
|
+
## Plan open-bugs-2026-10 / S27 — preflight names an expected extension that is not installed (added 2026-10-19, deploy-gated: new release, then set an env var)
|
|
2518
|
+
|
|
2519
|
+
- [ ] MANUAL-VERIFY(2026-10-19): On the box, add `MERCURY_EXPECTED_EXTENSIONS=web-search,gws,pdf` (the extensions it must carry) to `~/whatsapp-bot/.env`, then run `mercury preflight`. `extensions.load-report` should pass and say `all 3 expected present`. Add a made-up name (e.g. `,nope`) and re-run: it should warn `1 expected extension(s) not installed: nope`. Remove the made-up name afterwards. No restart is needed for this — preflight reads `.env` itself.
|
|
2520
|
+
|
|
2521
|
+
## Plan open-bugs-2026-10 / S35 — the image pins pi exactly (added 2026-10-19, deploy-gated: image rebuild + restart)
|
|
2522
|
+
|
|
2523
|
+
- [ ] MANUAL-VERIFY(2026-10-19): After the image rebuild, `docker run --rm --entrypoint pi mercury-agent:<version> --version` prints `0.87.1`, and `docker run --rm --entrypoint sh mercury-agent:<version> -c 'grep -h "\"version\"" /home/mercury/.bun/install/global/node_modules/@earendil-works/pi-ai/package.json /app/node_modules/@earendil-works/pi-ai/package.json'` prints `0.87.1` twice. Anything else means pi still floats in the image.
|
|
2524
|
+
|
|
2525
|
+
## Issue #143 / F19 — dashboard sessions and the failed-secret throttle (added 2026-10-19, deploy-gated: new release + restart)
|
|
2526
|
+
|
|
2527
|
+
- [ ] MANUAL-VERIFY(2026-10-19): Open `https://<box>/dashboard/login` in a private window. A password form should appear, not the dashboard. Enter the secret: the dashboard opens, the URL has no `token=`, and the browser's cookie list for the site shows `mercury_token` marked Secure, with a value that is not the secret.
|
|
2528
|
+
- [ ] MANUAL-VERIFY(2026-10-19): Click **Sign out** at the top right. You should land on the login form, and reloading `/dashboard` should bring you back to it.
|
|
2529
|
+
- [ ] MANUAL-VERIFY(2026-10-19): From a laptop, run `for i in $(seq 11); do curl -s -o /dev/null -w "%{http_code} " -H "Authorization: Bearer wrong" https://<box>/api/spaces; done`. You should see ten `401` then `429`. The journal should show `Secret check refused` lines with your real IP as `clientAddress` (not 127.0.0.1) and one `Failed-secret throttle engaged`. Wait 10 minutes before using the secret from that IP again.
|
|
2530
|
+
- [ ] MANUAL-VERIFY(2026-10-19): In the Tagula console, open this box's embedded dashboard. It should load and update live, with no "Assistant login did not return a session" error (the console's `init` login still uses `?token=` and looks for a `mercury_token` cookie).
|
|
2531
|
+
|
|
2532
|
+
## Issue #143 / F14 — deleting a space removes all of it (added 2026-10-19, deploy-gated: new release + restart)
|
|
2533
|
+
|
|
2534
|
+
- [ ] MANUAL-VERIFY(2026-10-19): Create a throwaway space, link a test group to it, send a message, then delete it from chat with `/spaces delete <id>` and answer `yes`. The reply should say it removed its files. On the box, `ls ~/whatsapp-bot/.mercury/spaces/<id>` should say "No such file", and `sqlite3 ~/whatsapp-bot/.mercury/state.db "SELECT COUNT(*) FROM conversations WHERE observed_title LIKE '%<group name>%'"` should print 0. Adjust the paths if the project lives elsewhere.
|
package/docs/setup-whatsapp.md
CHANGED
|
@@ -67,21 +67,22 @@ mercury link <id> <space-name>
|
|
|
67
67
|
|
|
68
68
|
## Session Lifecycle
|
|
69
69
|
|
|
70
|
-
WhatsApp linked device sessions last **~14–20 days** before requiring re-authentication. When expired:
|
|
70
|
+
WhatsApp linked device sessions last **~14–20 days** before requiring re-authentication. When expired (the service logs `WhatsApp logged out` and `/health` shows `"whatsappNeedsRepair": true`):
|
|
71
71
|
|
|
72
72
|
```bash
|
|
73
73
|
mercury service uninstall
|
|
74
|
-
|
|
75
|
-
mercury auth whatsapp
|
|
74
|
+
mercury auth whatsapp --reset # renames the auth dir to <dir>.logged-out-<timestamp>, then pairs
|
|
76
75
|
mercury service install
|
|
77
76
|
```
|
|
78
77
|
|
|
78
|
+
Plain `mercury auth whatsapp` on a dir that already holds registered creds exits non-zero and names this command: the creds file still says `registered` after a logout, and the command will not connect to check, because a second client on a live session evicts the running bot. `--reset` never deletes — remove the old `.logged-out-*` dir yourself once the new pairing works.
|
|
79
|
+
|
|
79
80
|
## Troubleshooting
|
|
80
81
|
|
|
81
82
|
| Problem | Solution |
|
|
82
83
|
|---------|----------|
|
|
83
84
|
| QR code not showing | Run `mercury auth whatsapp` separately, not `mercury run` |
|
|
84
|
-
| "
|
|
85
|
+
| "already holds registered WhatsApp creds" but the bot is not connected | `mercury auth whatsapp --reset`, then restart the service |
|
|
85
86
|
| QR code expires too fast | Use `--pairing-code` mode instead |
|
|
86
87
|
| Messages not arriving | Check `MERCURY_ENABLE_WHATSAPP=true` and re-auth |
|
|
87
88
|
| Old messages appear on startup | Normal — Mercury ignores pre-connection messages |
|
|
@@ -90,7 +91,7 @@ mercury service install
|
|
|
90
91
|
|
|
91
92
|
WhatsApp non-deterministically identifies the same person by either their
|
|
92
93
|
phone-number JID (`972501234567@s.whatsapp.net`) or an anonymized LID
|
|
93
|
-
(`
|
|
94
|
+
(`90000000000002@lid`). Mercury canonicalizes every inbound identity to the
|
|
94
95
|
phone form whenever the mapping is known, so a person always resolves to one
|
|
95
96
|
caller id, one conversation, and one DM auto-space.
|
|
96
97
|
|
|
@@ -20,12 +20,20 @@
|
|
|
20
20
|
* read as an orphan. Two bounds now refuse that shape whatever its cause: no
|
|
21
21
|
* manifest at all, or more orphans than a crash leaves. Post-mortem:
|
|
22
22
|
* docs/debug/major/2026-10-08-shadow-rehearsal-archive-reconcile-deletes-live-drive-files.md
|
|
23
|
+
*
|
|
24
|
+
* Orphans come in two kinds, and only one is evidence against the manifest. A
|
|
25
|
+
* hash the manifest itself tombstoned (a `forgetItem` whose blob delete failed)
|
|
26
|
+
* is an erasure still owed — *condemned*, not unexplained — so it never counts
|
|
27
|
+
* toward the crash-debris bound. Counting it let one Drive outage during a few
|
|
28
|
+
* forgets refuse every later sweep, and the erased bytes stayed forever.
|
|
29
|
+
* Post-mortem: docs/debug/moderate/2026-10-19-archive-reconcile-bound-strands-bytes-of-failed-forgets.md
|
|
23
30
|
*/
|
|
24
31
|
|
|
25
32
|
import type { ArchiveBackend } from "./backends/types.js";
|
|
26
33
|
import { beginDelete, endDelete } from "./inflight.js";
|
|
27
34
|
import {
|
|
28
35
|
appendLine,
|
|
36
|
+
erasedAdds,
|
|
29
37
|
hashStillReferenced,
|
|
30
38
|
liveAdds,
|
|
31
39
|
MANIFEST_VERSION,
|
|
@@ -118,8 +126,11 @@ export async function forgetItem(
|
|
|
118
126
|
if (target === undefined) return null;
|
|
119
127
|
|
|
120
128
|
// Tombstone first. If the blob delete fails, the item is still erased from
|
|
121
|
-
// every reader's point of view and the bytes become
|
|
122
|
-
//
|
|
129
|
+
// every reader's point of view and the bytes become a *condemned* orphan:
|
|
130
|
+
// reconcile collects it without counting it toward the crash-debris bound,
|
|
131
|
+
// and holds it only when that bound refuses the whole sweep (the manifest is
|
|
132
|
+
// then not a credible witness, for its tombstones either). The failure
|
|
133
|
+
// direction that does not leave data reachable.
|
|
123
134
|
appendLine(dataDir, spaceId, {
|
|
124
135
|
v: MANIFEST_VERSION,
|
|
125
136
|
id: newId(),
|
|
@@ -151,13 +162,21 @@ export interface ReconcileResult {
|
|
|
151
162
|
/**
|
|
152
163
|
* Orphan candidates left in place because a sanity bound refused the sweep.
|
|
153
164
|
* Zero when the sweep ran. Never silently non-zero: a refusal logs at error.
|
|
165
|
+
* Includes `erasuresHeld`.
|
|
154
166
|
*/
|
|
155
167
|
orphansRefused: number;
|
|
168
|
+
/**
|
|
169
|
+
* Of `orphansRefused`, the hashes this manifest tombstoned — erasures a user
|
|
170
|
+
* asked for that a refused sweep left on the backend. Reported separately so
|
|
171
|
+
* a refusal never hides an unkept erasure inside one orphan count.
|
|
172
|
+
*/
|
|
173
|
+
erasuresHeld: number;
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
/**
|
|
159
|
-
*
|
|
160
|
-
* append leaves one per in-flight file, so a handful is the normal
|
|
177
|
+
* Unexplained orphans a sweep may always delete. A crash between `put` and the
|
|
178
|
+
* manifest append leaves one per in-flight file, so a handful is the normal
|
|
179
|
+
* ceiling. Tombstoned (condemned) hashes are not counted against it.
|
|
161
180
|
*/
|
|
162
181
|
export const ORPHAN_ALLOWANCE = 3;
|
|
163
182
|
|
|
@@ -186,6 +205,7 @@ export async function reconcileSpace(
|
|
|
186
205
|
missingBlobs: 0,
|
|
187
206
|
live: 0,
|
|
188
207
|
orphansRefused: 0,
|
|
208
|
+
erasuresHeld: 0,
|
|
189
209
|
};
|
|
190
210
|
|
|
191
211
|
const lines = readLines(dataDir, spaceId, (_raw, lineNumber) => {
|
|
@@ -233,25 +253,49 @@ export async function reconcileSpace(
|
|
|
233
253
|
const present = new Set(stored.map((o) => o.sha256));
|
|
234
254
|
const orphans = stored.filter((o) => !wanted.has(o.sha256));
|
|
235
255
|
|
|
256
|
+
// A hash this manifest tombstoned and no live line still names is an erasure
|
|
257
|
+
// owed (a forget whose blob delete failed), not evidence that the manifest
|
|
258
|
+
// describes some other archive. `wanted` already spares a hash a live line
|
|
259
|
+
// or the spool still needs, so refcounting holds without a second check.
|
|
260
|
+
const erased = new Set(
|
|
261
|
+
erasedAdds(lines)
|
|
262
|
+
.map((l) => l.sha256)
|
|
263
|
+
.filter((h): h is string => typeof h === "string"),
|
|
264
|
+
);
|
|
265
|
+
const condemned = orphans.filter((o) => erased.has(o.sha256));
|
|
266
|
+
const unexplained = orphans.length - condemned.length;
|
|
267
|
+
// Tombstoned hashes leave the denominator too: otherwise every failed forget
|
|
268
|
+
// would raise how many unexplained orphans a sweep may delete.
|
|
269
|
+
const unaccounted = stored.length - condemned.length;
|
|
270
|
+
|
|
236
271
|
// Absence denies: a manifest with no readable line at all says nothing about
|
|
237
|
-
// what the backend should hold, so it cannot condemn anything in it. And
|
|
238
|
-
//
|
|
239
|
-
// describing the same archive
|
|
240
|
-
//
|
|
272
|
+
// what the backend should hold, so it cannot condemn anything in it. And
|
|
273
|
+
// more unexplained orphans than crash debris means the manifest and the
|
|
274
|
+
// backend are not describing the same archive — a witness that fails there
|
|
275
|
+
// fails for its tombstones too, so the condemned hashes are held with the
|
|
276
|
+
// rest. Both refuse the whole sweep, loudly, and the missing-bytes report
|
|
277
|
+
// below still runs.
|
|
241
278
|
const refusal =
|
|
242
279
|
orphans.length === 0
|
|
243
280
|
? null
|
|
244
281
|
: lines.length === 0
|
|
245
282
|
? `the manifest for ${spaceId} is missing or empty while the backend holds ${stored.length} object(s)`
|
|
246
|
-
:
|
|
247
|
-
|
|
248
|
-
? `${
|
|
283
|
+
: unexplained > ORPHAN_ALLOWANCE &&
|
|
284
|
+
unexplained > unaccounted * MAX_ORPHAN_FRACTION
|
|
285
|
+
? `${unexplained} of ${unaccounted} stored object(s) in ${spaceId} (not counting ${condemned.length} tombstoned) have no manifest entry — more than crash debris`
|
|
249
286
|
: null;
|
|
250
287
|
if (refusal !== null) {
|
|
251
288
|
result.orphansRefused = orphans.length;
|
|
289
|
+
result.erasuresHeld = condemned.length;
|
|
252
290
|
log.error(
|
|
253
|
-
`[archive] reconcile refused to delete orphans: ${refusal}. Nothing was deleted.
|
|
254
|
-
{
|
|
291
|
+
`[archive] reconcile refused to delete orphans: ${refusal}. Nothing was deleted: ${unexplained} unexplained orphan(s) and ${condemned.length} tombstoned blob(s) (erasures still owed) held. Either another instance (a shadow, a copy of this data dir) shares this archive backend, or this manifest is truncated or restored from elsewhere — compare the orphan list against this manifest before deleting anything by hand.`,
|
|
292
|
+
{
|
|
293
|
+
spaceId,
|
|
294
|
+
orphans: orphans.length,
|
|
295
|
+
unexplained,
|
|
296
|
+
erasuresHeld: condemned.length,
|
|
297
|
+
stored: stored.length,
|
|
298
|
+
},
|
|
255
299
|
);
|
|
256
300
|
}
|
|
257
301
|
|
|
@@ -268,7 +312,9 @@ export async function reconcileSpace(
|
|
|
268
312
|
// record of what it already removed, not only a final count it never
|
|
269
313
|
// reached.
|
|
270
314
|
log.info(
|
|
271
|
-
`[archive] reconcile ${spaceId}: deleted
|
|
315
|
+
`[archive] reconcile ${spaceId}: deleted ${
|
|
316
|
+
erased.has(object.sha256) ? "tombstoned" : "orphan"
|
|
317
|
+
} blob ${object.sha256.slice(0, 12)}`,
|
|
272
318
|
);
|
|
273
319
|
} catch (err) {
|
|
274
320
|
log.error(
|