mercury-agent 0.24.4 → 0.25.0-beta.0
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/container/Dockerfile +1 -1
- package/container/Dockerfile.base +1 -1
- package/container/agent-package.json +1 -1
- package/docs/configuration.md +43 -5
- package/docs/container-lifecycle.md +1 -1
- package/docs/extensions.md +38 -0
- package/docs/goals/conversation-review/decisions.md +27 -0
- package/docs/goals/deploy-in-minutes/decisions.md +61 -0
- package/docs/goals/deploy-in-minutes/goal.md +135 -0
- package/docs/goals/deploy-in-minutes/roadmap.md +99 -0
- package/docs/goals/rehearsal-bench/roadmap.md +2 -0
- package/docs/goals/release-gate/roadmap.md +1 -1
- package/docs/live-testing.md +3 -1
- package/docs/pending-verification.md +44 -1
- package/docs/plans/{search-quality-0930 → archive/2026-10-22-search-quality-0930}/plan.md +6 -4
- package/docs/plans/{watchdog-1011 → archive/2026-10-22-watchdog-1011}/decisions.md +1 -0
- package/docs/plans/{watchdog-1011 → archive/2026-10-22-watchdog-1011}/plan.md +2 -2
- package/docs/plans/{watchdog-1011 → archive/2026-10-22-watchdog-1011}/sessions/S1.md +17 -0
- package/docs/plans/archive/2026-10-25-worklist-security/briefs/S1.md +59 -0
- package/docs/plans/archive/2026-10-25-worklist-security/briefs/S2.md +60 -0
- package/docs/plans/archive/2026-10-25-worklist-security/briefs/S3.md +59 -0
- package/docs/plans/archive/2026-10-25-worklist-security/briefs/S4.md +59 -0
- package/docs/plans/archive/2026-10-25-worklist-security/briefs/S5.md +68 -0
- package/docs/plans/archive/2026-10-25-worklist-security/decisions.md +11 -0
- package/docs/plans/archive/2026-10-25-worklist-security/plan.md +132 -0
- package/docs/plans/archive/2026-10-25-worklist-security/queue.md +95 -0
- package/docs/plans/archive/2026-10-25-worklist-security/sessions/S1.md +35 -0
- package/docs/plans/archive/2026-10-25-worklist-security/sessions/S2.md +59 -0
- package/docs/plans/archive/2026-10-25-worklist-security/sessions/S3.md +72 -0
- package/docs/plans/archive/2026-10-25-worklist-security/sessions/S4.md +62 -0
- package/docs/plans/general-0928/briefs/S3.md +3 -3
- package/docs/plans/general-0928/briefs/S6.md +112 -0
- package/docs/plans/general-0928/briefs/S7.md +114 -0
- package/docs/plans/general-0928/briefs/S8.md +113 -0
- package/docs/plans/general-0928/briefs/S9.md +93 -0
- package/docs/plans/general-0928/decisions.md +2 -0
- package/docs/plans/general-0928/plan.md +147 -9
- package/docs/plans/general-0928/sessions/S1.md +43 -0
- package/docs/plans/general-0928/sessions/S3.md +49 -0
- package/docs/plans/general-0928/sessions/S4.md +46 -0
- package/docs/plans/web-access/briefs/S1.md +58 -0
- package/docs/plans/web-access/briefs/S10.md +86 -0
- package/docs/plans/web-access/briefs/S11.md +63 -0
- package/docs/plans/web-access/briefs/S12.md +63 -0
- package/docs/plans/web-access/briefs/S13.md +63 -0
- package/docs/plans/web-access/briefs/S14.md +80 -0
- package/docs/plans/web-access/briefs/S15.md +61 -0
- package/docs/plans/web-access/briefs/S2.md +97 -0
- package/docs/plans/web-access/briefs/S3.md +54 -0
- package/docs/plans/web-access/briefs/S4.md +62 -0
- package/docs/plans/web-access/briefs/S5.md +62 -0
- package/docs/plans/web-access/briefs/S6.md +54 -0
- package/docs/plans/web-access/briefs/S7.md +54 -0
- package/docs/plans/web-access/briefs/S8.md +61 -0
- package/docs/plans/web-access/briefs/S9.md +56 -0
- package/docs/plans/web-access/decisions.md +22 -0
- package/docs/plans/web-access/plan.md +306 -0
- package/docs/plans/web-access/sessions/S1.md +48 -0
- package/docs/plans/web-access/sessions/S13.md +122 -0
- package/docs/plans/web-access/sessions/S15.md +48 -0
- package/docs/plans/web-access/sessions/S3.md +44 -0
- package/docs/plans/web-access/sessions/S4.md +82 -0
- package/docs/plans/web-access/sessions/S6.md +46 -0
- package/docs/plans/web-access/sessions/S7.md +44 -0
- package/docs/plans/web-access/sessions/S8.md +137 -0
- package/docs/plans/web-access/sessions/S9.md +22 -0
- package/docs/profile-guide.md +13 -2
- package/docs/release-gate.md +1 -1
- package/docs/scheduler.md +18 -0
- package/docs/web-search.md +5 -3
- package/examples/extensions/napkin/pi-spawn.ts +3 -0
- package/examples/extensions/overview/index.ts +19 -10
- package/examples/extensions/web-search/chain.ts +193 -22
- package/examples/extensions/web-search/providers/linkup.ts +11 -5
- package/examples/extensions/web-search/providers/types.ts +6 -0
- package/examples/extensions/worklist/README.md +98 -0
- package/examples/extensions/worklist/actions.ts +804 -0
- package/examples/extensions/worklist/gate.ts +205 -0
- package/examples/extensions/worklist/index.ts +253 -0
- package/examples/extensions/worklist/space-skill/SKILL.md +166 -0
- package/examples/extensions/yahoo-mail/lib/ymail.ts +3 -1
- package/examples/profiles/_template/README.md +4 -4
- package/package.json +16 -12
- package/resources/pi-extensions/subagent/spawn.ts +3 -0
- package/src/agent/container-env.ts +7 -0
- package/src/agent/container-runner.ts +7 -0
- package/src/config-file.ts +18 -1
- package/src/config.ts +23 -0
- package/src/core/api-idle-timeout.ts +20 -0
- package/src/core/api-types.ts +6 -0
- package/src/core/api.ts +4 -0
- package/src/core/caller-token.ts +31 -3
- package/src/core/operator-alerts.ts +315 -26
- package/src/core/routes/capability.ts +2 -2
- package/src/core/routes/dashboard.ts +1 -1
- package/src/core/runtime.ts +33 -6
- package/src/core/system-messages.ts +10 -0
- package/src/core/task-scheduler.ts +189 -5
- package/src/core/task-sender.ts +17 -3
- package/src/core/workspace-write.ts +221 -0
- package/src/env-dump/manifest.ts +1 -0
- package/src/extensions/catalog.ts +2 -4
- package/src/extensions/types.ts +7 -0
- package/src/main.ts +8 -0
- package/src/preflight/checks/roundtrip.ts +7 -1
- package/src/storage/pi-auth.ts +2 -1
- package/docs/plans/search-quality-0930/briefs/S12.md +0 -69
- package/docs/plans/search-quality-0930/briefs/S9.md +0 -68
- package/examples/profiles/tel-aviv-flat-search/AGENTS.md +0 -323
- package/examples/profiles/tel-aviv-flat-search/README.md +0 -166
- package/examples/profiles/tel-aviv-flat-search/config.yaml +0 -85
- package/examples/profiles/tel-aviv-flat-search/seed/MEMORY.md +0 -41
- package/examples/profiles/tel-aviv-flat-search/seed/napkin-distill.md +0 -27
- package/examples/profiles/tel-aviv-flat-search/seed/viewing-checklist.md +0 -34
- package/examples/profiles/tel-aviv-flat-search/tasks/morning-status.md +0 -37
- /package/docs/plans/{search-quality-0930 → archive/2026-10-22-search-quality-0930}/briefs/S7.md +0 -0
- /package/docs/plans/{search-quality-0930 → archive/2026-10-22-search-quality-0930}/decisions.md +0 -0
- /package/docs/plans/{search-quality-0930 → archive/2026-10-22-search-quality-0930}/sessions/S7.md +0 -0
- /package/docs/plans/{watchdog-1011 → archive/2026-10-22-watchdog-1011}/briefs/S1.md +0 -0
- /package/examples/extensions/overview/{skill → space-skill}/SKILL.md +0 -0
package/container/Dockerfile
CHANGED
|
@@ -65,7 +65,7 @@ ENV CHROMIUM_FLAGS="--no-sandbox"
|
|
|
65
65
|
# which no test had seen. Equal to container/agent-package.json and to the
|
|
66
66
|
# host's resolved pi-ai/pi-coding-agent — tests/core-tool-snippets.test.ts and
|
|
67
67
|
# tests/pi-auth-provider-env-vars.test.ts hold all three together.
|
|
68
|
-
RUN bun add -g @earendil-works/pi-coding-agent@
|
|
68
|
+
RUN bun add -g @earendil-works/pi-coding-agent@1.3.0
|
|
69
69
|
|
|
70
70
|
WORKDIR /app
|
|
71
71
|
|
|
@@ -42,7 +42,7 @@ RUN echo '{"args":["--no-sandbox"]}' > /home/mercury/.puppeteerrc.json
|
|
|
42
42
|
ENV CHROMIUM_FLAGS="--no-sandbox"
|
|
43
43
|
|
|
44
44
|
# Install CLIs
|
|
45
|
-
RUN bun add -g @earendil-works/pi-coding-agent
|
|
45
|
+
RUN bun add -g @earendil-works/pi-coding-agent@1.3.0
|
|
46
46
|
|
|
47
47
|
WORKDIR /app
|
|
48
48
|
|
package/docs/configuration.md
CHANGED
|
@@ -264,6 +264,8 @@ alerts:
|
|
|
264
264
|
recipients: # optional; extra audiences, in addition to the admins
|
|
265
265
|
- ops-team # a space id: every conversation linked to it
|
|
266
266
|
- "972500000000" # a person id — quote numbers
|
|
267
|
+
full_detail: # optional; recipient spaces that see client ids in full
|
|
268
|
+
- ops-team
|
|
267
269
|
```
|
|
268
270
|
|
|
269
271
|
`alerts.recipients` and `dm_auto_space.admin_ids` also accept a single value or
|
|
@@ -274,7 +276,8 @@ above 9007199254740991 cannot be held exactly, so Mercury refuses it at startup
|
|
|
274
276
|
and asks for the quoted form.
|
|
275
277
|
|
|
276
278
|
Env equivalents: **`MERCURY_ALERTS_ENABLED`**, **`MERCURY_ALERTS_COOLDOWN_MS`**,
|
|
277
|
-
**`MERCURY_ALERTS_SETTLE_MS`**, **`MERCURY_ALERTS_RECIPIENTS`**
|
|
279
|
+
**`MERCURY_ALERTS_SETTLE_MS`**, **`MERCURY_ALERTS_RECIPIENTS`** and
|
|
280
|
+
**`MERCURY_ALERTS_FULL_DETAIL`** (both comma-separated).
|
|
278
281
|
|
|
279
282
|
- **`settle_ms`** is how long a boot must last before it tells anyone the bot
|
|
280
283
|
is back: the missed-run report and the WhatsApp "please resend" notice both
|
|
@@ -298,14 +301,38 @@ Env equivalents: **`MERCURY_ALERTS_ENABLED`**, **`MERCURY_ALERTS_COOLDOWN_MS`**,
|
|
|
298
301
|
is told once, through the space. With nothing reachable the alert has nowhere
|
|
299
302
|
to go — Mercury logs that fact at ERROR and leaves the cooldown unclaimed, so
|
|
300
303
|
the next failure tries again.
|
|
304
|
+
- **A recipient space must hold only staff conversations.** It receives the
|
|
305
|
+
operational detail of **every** space, through every conversation linked to
|
|
306
|
+
it now or later: which client conversations missed a scheduled post, the raw
|
|
307
|
+
error text of any space's failed task, and every client's `/problem` card. A
|
|
308
|
+
space recipient gets conversation ids and a client's DM space id in a short
|
|
309
|
+
form (`whatsapp:…4567`, `dm-…4567`; the full id stays in the host log), but
|
|
310
|
+
the error text is quoted as it is, and a `/problem` card names the space by
|
|
311
|
+
its display name, which for a DM space can be the person's number. So
|
|
312
|
+
never list `main`, and re-check the space after linking anything to it. At
|
|
313
|
+
boot Mercury logs `Operator alert recipient space "<id>" may not be
|
|
314
|
+
staff-only` at WARN when a recipient space is `main` or holds a DM of a
|
|
315
|
+
person who is not an admin. A client group linked by mistake cannot be told
|
|
316
|
+
from a staff group, so no warning covers that case.
|
|
317
|
+
- **`full_detail`** lists the recipient spaces that get client conversation
|
|
318
|
+
and DM space ids in full, as an admin's own DM does, for a staff group that
|
|
319
|
+
needs to contact the client straight from the alert. It is opt-in per space:
|
|
320
|
+
a space added to `recipients` later, or by mistake, still gets the short
|
|
321
|
+
form. A full id sent to a WhatsApp group stays on every member's phone and in
|
|
322
|
+
their backups, so list only a space whose membership you control. The boot
|
|
323
|
+
warning above says `IN FULL` for such a space, and an entry that names no
|
|
324
|
+
reachable recipient space is logged at WARN as having no effect. An admin
|
|
325
|
+
whose DM is linked to a recipient space is told through the space (see
|
|
326
|
+
Recipients), so they read that space's form: list the space here to keep
|
|
327
|
+
full ids for them.
|
|
301
328
|
- **Client problem reports.** The same recipients receive the card for every
|
|
302
329
|
`/problem` (alias `/בעיה`) a client sends, with the client's own description
|
|
303
330
|
of the problem, the space name and the caller's role (never a phone number or
|
|
304
331
|
name). `alerts.enabled: false` does not stop these cards: a report is the
|
|
305
332
|
client's request to reach the team, not an operator alert. The reporting
|
|
306
333
|
space is never sent its own card. A recipient space that also holds people
|
|
307
|
-
who are not staff therefore sees every client's description too (
|
|
308
|
-
|
|
334
|
+
who are not staff therefore sees every client's description too (see the
|
|
335
|
+
staff-only rule above).
|
|
309
336
|
- **Startup check.** At boot Mercury logs `Operator alerts will reach no one: …`
|
|
310
337
|
at ERROR when no configured admin or recipient resolves to a deliverable
|
|
311
338
|
conversation, so the gap shows up before the first outage rather than during it.
|
|
@@ -328,7 +355,16 @@ Env equivalents: **`MERCURY_ALERTS_ENABLED`**, **`MERCURY_ALERTS_COOLDOWN_MS`**,
|
|
|
328
355
|
(`system`, the console, `space-profile`) — reports to the operators above
|
|
329
356
|
instead, and its space hears nothing, even when no operator is reachable
|
|
330
357
|
(then the only record is the ERROR log line). No cooldown: a final failure is
|
|
331
|
-
already once per due cycle.
|
|
358
|
+
already once per due cycle. A person's task whose space has **no linked
|
|
359
|
+
conversation** cannot be told there either, so its notice comes to the
|
|
360
|
+
operators too, saying why.
|
|
361
|
+
- **Scheduled runs skipped because the space has no linked conversation**
|
|
362
|
+
(`scheduling.skip_unlinked`, on by default) report to the operators once per
|
|
363
|
+
unlinked space, naming every task the skip applies to. It counts as told only
|
|
364
|
+
once it reached an operator (otherwise it is offered again, at most hourly). A
|
|
365
|
+
restart does not repeat it; a month later it is repeated; a due task that
|
|
366
|
+
finds the space linked ends the episode. See `docs/scheduler.md`, "Spaces with no linked
|
|
367
|
+
conversation".
|
|
332
368
|
- **Scheduled runs skipped by the sensitive-connection deny** (a group space
|
|
333
369
|
without `security.sensitive_connections_allowed: true`) report to the
|
|
334
370
|
operators above, one message per skip, never to the space. The same
|
|
@@ -521,7 +557,9 @@ shadow inherits the live `.env`'s key. **`up --beside-live`** (always used by
|
|
|
521
557
|
`shadow rehearse`) turns a live run and a due task into warnings and refuses
|
|
522
558
|
`credential-shared-chain` instead: that is, when the shadow would run on a
|
|
523
559
|
rotating credential it shares with the live bot (an env blob, or `auth.json`
|
|
524
|
-
OAuth).
|
|
560
|
+
OAuth). That refusal can only fire on an install still on such a login: with a
|
|
561
|
+
long-lived token on both sides (as on our boxes since 2026-10-21) nothing
|
|
562
|
+
refreshes and there is no chain to share. A shadow's unit runs at `CPUWeight=20`/`Nice=10`, and its containers
|
|
525
563
|
get `--cpu-shares 256 --memory 2g`. Live containers keep Docker's default CPU shares and are not memory-capped on runc (on runsc both arms already carry `--memory=2g`).
|
|
526
564
|
|
|
527
565
|
**`POST /api/shadow/simulate`** (goal `rehearsal-bench` M2.2b) exists only on
|
|
@@ -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@1.3.0 # 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/extensions.md
CHANGED
|
@@ -350,6 +350,14 @@ mercury.capability("rooms", async (req, ctx) => {
|
|
|
350
350
|
throws at load. A read that has a side effect elsewhere (an IMAP fetch that
|
|
351
351
|
sets `\Seen`, a preview that issues something) is not read-only — leave it
|
|
352
352
|
out. On a live process the declaration changes nothing.
|
|
353
|
+
- **What a handler can trust on `req`.** `callerId` and `spaceId` come from the
|
|
354
|
+
verified per-turn caller token, never from a header the container sets.
|
|
355
|
+
`runKey` names the run (absent on the operator credential). `messageId` is
|
|
356
|
+
the platform id of the inbound message that started the run (a WhatsApp
|
|
357
|
+
message id), signed into the same token — absent on a scheduled run and on
|
|
358
|
+
the operator credential, so a handler that keys idempotency on it must refuse
|
|
359
|
+
when it is missing. `body` is the agent's JSON: untrusted, build any outbound
|
|
360
|
+
request from an allow-list of its fields.
|
|
353
361
|
|
|
354
362
|
### `mercury.store`
|
|
355
363
|
|
|
@@ -629,6 +637,36 @@ Two things the broker owns rather than the skill:
|
|
|
629
637
|
`unknown`, which alerts once and never says "re-login" for something a login
|
|
630
638
|
cannot fix.
|
|
631
639
|
|
|
640
|
+
## Team worklist (`worklist`)
|
|
641
|
+
|
|
642
|
+
`examples/extensions/worklist/` is Mercury's WhatsApp surface onto the team's
|
|
643
|
+
task service (`tagula-worklist`), built against that repo's
|
|
644
|
+
`docs/api/mercury-seam.md` (seam 2). From **one** space a mapped team member
|
|
645
|
+
adds, lists, looks at, claims, releases, edits, closes and reopens tasks by
|
|
646
|
+
talking to the bot; every write is recorded as that person, never as the bot.
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
mercury add ./examples/extensions/worklist
|
|
650
|
+
MERCURY_WORKLIST_TOKEN=... # hostOnly — the worklist's `mercury` principal token
|
|
651
|
+
MERCURY_WORKLIST_SPACE_ID=... # hostOnly — the one team space; unset denies everything
|
|
652
|
+
MERCURY_WORKLIST_PRINCIPALS=whatsapp:<jid>=levi,whatsapp:<jid>=udi # hostOnly — caller → principal
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
Two gates run above the action switch, as in `overview`: the space must equal
|
|
656
|
+
`MERCURY_WORKLIST_SPACE_ID` exactly, and the caller must resolve through the
|
|
657
|
+
principal map (LID ↔ phone aliases included) to exactly one human principal —
|
|
658
|
+
`mercury` is refused as a value. `subject` comes from the map, never from the
|
|
659
|
+
agent; each request is built from the action's allow-list, and any other key
|
|
660
|
+
refuses the call before anything is sent. `add` keys its `external_id` on
|
|
661
|
+
`req.messageId` (with `#<item>` for the second and later task of one message),
|
|
662
|
+
so a redelivered message adds nothing twice.
|
|
663
|
+
|
|
664
|
+
Outcomes the agent acts on (`CLAIM_HELD`, `VERSION_CONFLICT`, …) come back as
|
|
665
|
+
200 `{ ok: false, code, … }`, because mrctl drops every field of a non-2xx but
|
|
666
|
+
`error`; failures it cannot fix are non-2xx whose `error` starts with the code.
|
|
667
|
+
Every call is bounded at 5 s. The skill is installed into the team space's
|
|
668
|
+
workspace only, with a matching `before_container` fragment.
|
|
669
|
+
|
|
632
670
|
## Examples
|
|
633
671
|
|
|
634
672
|
See [`examples/extensions/`](../examples/extensions/) for complete, working extensions ranging from minimal (charts — CLI + skill) to full-featured (napkin — hooks, jobs, config, widgets, KB distillation).
|
|
@@ -350,3 +350,30 @@
|
|
|
350
350
|
`known-limitation` is then the next step, in a later goal.
|
|
351
351
|
- **Used by:** review-intake-to-repo, review-verdict-feedback,
|
|
352
352
|
conversation-review-report-and-digest.
|
|
353
|
+
|
|
354
|
+
## D-012 (PROPOSED, awaiting owner): from "detection only" to "detect and propose; apply only with approval"
|
|
355
|
+
- **Category:** scope
|
|
356
|
+
- **Decided:** not yet. Proposed 2026-10-24 after the owner asked for profiles
|
|
357
|
+
that improve automatically from group behaviour
|
|
358
|
+
(`docs/ideas/profile-improvement-proposals.md`). Until the owner decides, the
|
|
359
|
+
goal's "Detection only" constraint stands.
|
|
360
|
+
- Proposed change: a verified finding may produce a **draft** change, either a
|
|
361
|
+
lesson delta in a space's machine-managed region or a preference row,
|
|
362
|
+
together with its eval result. Nothing is applied without a one-tap owner/admin
|
|
363
|
+
approval, except a narrow auto-apply tier behind an off-by-default flag: a
|
|
364
|
+
person's own preference, and format knobs within the archetype's bounds after
|
|
365
|
+
a distinct-member quorum.
|
|
366
|
+
- **Alternatives considered:**
|
|
367
|
+
- **Keep detection only.** Safe, but every finding stays a manual edit, which
|
|
368
|
+
is the tuning loop the owner wants gone.
|
|
369
|
+
- **Fully automatic apply** (OpenClaw-style self-editing, ACE-style curation
|
|
370
|
+
with no review). Rejected by the evidence: ACE degrades on noisy feedback,
|
|
371
|
+
thumbs feedback caused GPT-4o's sycophancy, and one user's votes can poison a
|
|
372
|
+
feedback-driven system (arXiv 2507.02850).
|
|
373
|
+
- **Reasoning:** the closest working product (Intercom Fin) drafts fixes with
|
|
374
|
+
evidence and keeps an admin on apply. This keeps D-010's "a finding is a
|
|
375
|
+
hypothesis" and D-011's human triage, and adds only the draft and the eval run.
|
|
376
|
+
- **Revisit if:** the approval ledger shows over ~90% acceptance of a proposal
|
|
377
|
+
kind for a month. That kind can then move into the auto-apply tier.
|
|
378
|
+
- **Used by:** profile-improvement-proposals, bad-response-signals,
|
|
379
|
+
behaviour-eval-suite.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Decisions: Deploy in minutes
|
|
2
|
+
|
|
3
|
+
**Goal**: [deploy-in-minutes](goal.md)
|
|
4
|
+
|
|
5
|
+
## D-001: No new technology; the existing deploy pieces get faster
|
|
6
|
+
- **Category:** tech-stack
|
|
7
|
+
- **Decided:** bun/TypeScript for logic that must be tested (`src/ops/`, `src/cli/`), bash only as a thin caller, Docker BuildKit + GHCR as today. No deploy tool (no Ansible, no blue/green proxy, no second live process).
|
|
8
|
+
- **Alternatives considered:** blue/green with two live processes behind a proxy (WhatsApp allows one linked-device client per session, so two live processes evict each other: rehearsal-bench D-004); Watchtower/registry-driven auto-updates (no gate, no drain).
|
|
9
|
+
- **Reasoning:** the baseline shows the restart is 4–8 s. Every cost is in the steps around it (waiting, building, installing while stopped, rebuilding the derived image). Removing them needs no new machinery.
|
|
10
|
+
- **Revisit if:** zero-downtime (not just a quick deploy) becomes a requirement.
|
|
11
|
+
- **Used by:** all stories.
|
|
12
|
+
|
|
13
|
+
## D-002: What "deploy time" measures, and what it leaves out
|
|
14
|
+
- **Category:** scope
|
|
15
|
+
- **Decided:** deploy time runs from the deploy command starting until the live bot serves the new commit **and** its derived image is ready (`Using cached agent image` or `Built derived agent image` for the new base). The rehearsal is inside it. The check gate (`bun run check`, CI) is outside: it runs before the PR, not at deploy. Budgets: **code class ≤ 120 s, image/deps class ≤ 300 s** (`docs/release-gate.md` §1 discriminators decide the class).
|
|
16
|
+
- **Alternatives considered:** measuring only downtime (would hide the 7-minute derived build that runs after users are back); including the check gate (deploy and check grow for different reasons and have different owners).
|
|
17
|
+
- **Reasoning:** the owner's complaint was the wall-clock cost of a deploy, and the derived image is part of the deploy because runs lack extension CLIs until it is built.
|
|
18
|
+
- **Revisit if:** the check gate becomes part of the deploy command.
|
|
19
|
+
- **Used by:** deploy-time-budget, home-deploy-command, every M2 story.
|
|
20
|
+
|
|
21
|
+
## D-003: The limits are a ratchet, measured on every deploy, with per-phase shares
|
|
22
|
+
- **Category:** pattern
|
|
23
|
+
- **Decided:** owner requirement 2026-10-22 ("we must always maintain the limits"). Three layers: (1) every deploy writes a timing record with a per-phase breakdown and a verdict (`within` / `over`) against its class budget, on both boxes; (2) each phase has a **share** of the budget, and the reader warns when a phase's rolling median exceeds its share, *before* the total breaks; (3) the phases that grow with the repo (warm base-image build, derived rebuild on an app-only change, `bun install --frozen-lockfile`, boot to listening, rehearsal) are measured in CI's `publish-image` and fail the release over their share × a CI factor. A fourth limit, the **pause** (SIGTERM → the new process listening, i.e. the time the bot takes no new work), is **≤ 30 s** on every deploy of either class, recorded and judged the same way (owner, 2026-10-22: "blocking for a very short period"). The budgets, the pause limit and the shares live in one module (`src/ops/deploy-budget.ts`) that the CLI, the reader and CI all import.
|
|
24
|
+
- **Alternatives considered:** a target measured once at the end of the goal (decays silently: the stated reason for this decision); a monitor-only dashboard (nobody reads it before the limit breaks); failing the deploy itself when it runs over (the deploy has already happened, so failing hides that).
|
|
25
|
+
- **Reasoning:** the same shape as the ratchets in `CLAUDE.md` (a limit that may only hold or tighten, read by a gate). Per-phase shares turn "deploys got slow" into "the derived rebuild grew 40% since 0.25.0".
|
|
26
|
+
- **Revisit if:** CI timings turn out not to track box timings (CI factor drifts over 2×): then the CI leg becomes advisory and the per-deploy verdict is the only gate.
|
|
27
|
+
- **Used by:** deploy-time-budget (owner), home-deploy-command, host-install-before-stop, agent-image-releases-share-layers.
|
|
28
|
+
|
|
29
|
+
## D-004: A restart pauses briefly, then restores everything. The gap rule is retired, not automated.
|
|
30
|
+
- **Category:** architecture
|
|
31
|
+
- **Decided:** owner 2026-10-22 ("never lost: drain, then re-run"; revised the same day: "must be able to run mid-day while the bot is working without blocking it, or blocking for a very short period and then restoring in full everything that was missed"). A deploy prepares everything (rehearsal, image, install) while the bot serves normally; only the stop/start pauses it. On SIGTERM the host stops admitting new runs and waits up to `shutdown.drainMs` (**default 20 s**, logged at start and when the bound fires) for active runs, **then** kills what is left. Messages that arrive during the pause, and queued work not yet started, are saved and run at boot from the stored turn. A **scheduled** run that was cut off, or whose slot fell inside the restart, re-runs once at boot whatever its `catch_up` setting is (`skip` stays the policy for long outages: the scheduler was down for longer than the restart window). A **chat** turn that was cut off mid-run **resumes** once at boot: it reruns with the original message and a record of what the cut-off run already did (finished tool calls; calls started without a result marked "outcome unknown"), with the rule not to repeat anything that changed the outside world. If no readable record exists, the turn is older than the restart window, or the resume is itself cut off, the user is told, as today (`chat-run-journal.ts`). The pause (stop → new process listening) has its own limit, **30 s** (D-003). Release-gate **Gate 9** ("a restart lands in a gap") becomes "a restart pauses briefly and restores", and the sync's `live-not-quiet` refusal goes.
|
|
32
|
+
- **Alternatives considered:** hand the running container to the next process (much larger lifecycle change, and container-entry's stdout pipe dies with the host); keep the gap rule and have the deploy command wait for a gap (still up to 55 min at home and 4 h on Tagula on weekdays).
|
|
33
|
+
- **Reasoning:** the stop already takes under a second, so a drain costs nothing on an idle box and lets a run that is about to finish finish. A long drain was rejected (first draft: 90 s) because the bot takes no new work while it drains, and the owner's rule is a very short pause. With a short drain, long runs are cut off more often, so a cut-off has to lose nothing: scheduled runs re-run (rerunnable by design), and chat turns resume from their record instead of re-running blind, which could double-send or double-act. The notice stays only as the closed state for when the record is missing.
|
|
34
|
+
- **Supersedes:** the owner's 2026-09-22 decision that interrupted runs are not re-run ("only the label moves"), for restarts.
|
|
35
|
+
- **Conflict flagged:** release-gate Gate 9 and its `live-not-quiet` refusal (R5.1, `docs/release-gate.md`). Resolution: Gate 9 is amended by home-deploy-command, with the owner's 2026-10-22 answer as the authority. The "working hours" policy hook stays the fleet's.
|
|
36
|
+
- **Revisit if:** resumed chat turns are seen repeating an outside action (then calls with an unknown outcome fall back to the notice), or the pause limit cannot hold at 30 s (the drain shrinks first; the limit loosens only by owner decision).
|
|
37
|
+
- **Used by:** restart-drains-in-flight-runs, restart-reruns-cut-off-scheduled-runs, restart-resumes-cut-off-chat-turns, home-deploy-command, deploy-time-budget (the pause limit).
|
|
38
|
+
|
|
39
|
+
## D-005: Home bot pulls the published image when the tree matches; else builds with the published cache, before the restart
|
|
40
|
+
- **Category:** architecture
|
|
41
|
+
- **Decided:** owner 2026-10-22. The home deploy pulls `ghcr.io/tagula-ai/mercury-agent:<version>` when the target's baked files are byte-identical to that release (checked with the image's own manifest, `parseCopyInstructions`). Otherwise it builds locally with `--cache-from` the published `:buildcache`. Either way the image exists **before** the restart, under a version tag. `:latest` is retagged only after it passes the check.
|
|
42
|
+
- **Alternatives considered:** always build (the 18–39 min dependency builds); always pull (unreleased `dev` with baked changes could not be deployed, which breaks "the home bot is the beta tester").
|
|
43
|
+
- **Reasoning:** the most common rebuild trigger is a version bump with no baked change (2026-09-09 gotcha), and CI has already built that image.
|
|
44
|
+
- **Revisit if:** the GHCR package stays unreadable from the home box (needs a `read:packages` login there).
|
|
45
|
+
- **Used by:** local-deploy-pulls-the-published-image, home-deploy-command.
|
|
46
|
+
|
|
47
|
+
## D-006: Mercury goal; the fleet half is filed in tagula-agents
|
|
48
|
+
- **Category:** scope
|
|
49
|
+
- **Decided:** owner 2026-10-22. This goal builds everything in Mercury: drain/re-run, `mercury upgrade` installing before it stops, image pull/prebuild, the timing record and reader, rehearsal of image and dependency changes. The fleet updater's changes (call the new `mercury upgrade` flow, prebuild the derived image before the stop, write the same timing record, rehearse on the box) are filed as items in tagula-agents at the M2 checkpoint and listed in the roadmap as an external dependency of the final measurement.
|
|
50
|
+
- **Alternatives considered:** stories in both repos (one plan, two review regimes); home only (the owner named both boxes).
|
|
51
|
+
- **Reasoning:** each repo's code is reviewed and deployed by its own path. Mercury publishes the pieces and the fleet calls them (the same split as release-gate's "Interface with fleet-release-gate").
|
|
52
|
+
- **Revisit if:** the fleet items sit unclaimed past the M2 checkpoint.
|
|
53
|
+
- **Used by:** host-install-before-stop, deploy-time-budget, the M3 checkpoint.
|
|
54
|
+
|
|
55
|
+
## D-007: The home deploy command moves into the repo; `~/sync-mercury.sh` becomes a one-line caller
|
|
56
|
+
- **Category:** architecture
|
|
57
|
+
- **Decided:** the phase logic (rehearse, image ready, staged install, reset, one restart, timing record) becomes a Mercury command, `mercury deploy-local` (`src/ops/deploy-local.ts`), reviewed and tested like any other code. `~/sync-mercury.sh` keeps only its box-specific paths and calls it. This extends release-gate G-012 ("the rehearsal is a Mercury command; the sync is a thin caller") to the whole deploy.
|
|
58
|
+
- **Alternatives considered:** keep growing the unreviewed 306-line local script (every speed change would land unreviewed, untested and invisible to the other contributor).
|
|
59
|
+
- **Reasoning:** the speed work changes the order of the deploy's phases. That order is the contract, so it belongs where tests can pin it.
|
|
60
|
+
- **Revisit if:** none foreseen.
|
|
61
|
+
- **Used by:** home-deploy-command, local-deploy-pulls-the-published-image, rehearse-image-and-deps-changes.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# Deploy in minutes — a deploy is a quick, easy operation on every box
|
|
2
|
+
|
|
3
|
+
**Status**: Active
|
|
4
|
+
**Slug**: deploy-in-minutes
|
|
5
|
+
**Created**: 2026-10-22
|
|
6
|
+
**Last updated**: 2026-10-22
|
|
7
|
+
**Owner**: Sahar
|
|
8
|
+
**Idea**: promoted from `docs/ideas/deploy-in-minutes.md` (`50c03bc8`)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Goal Statement
|
|
13
|
+
|
|
14
|
+
A deploy must be quick and easy, both on the home bot and on the Tagula box
|
|
15
|
+
(owner, raised more than once; 2026-10-22: "the problem here is a requirement
|
|
16
|
+
of 30 MINUTES just for a deploy. it must be a quick and easy operation both
|
|
17
|
+
locally and on the Tagula box"). Planned deploys today need a quiet window,
|
|
18
|
+
a base image build from source, a second restart for the image and a
|
|
19
|
+
rehearsal that refuses exactly the risky changes. So deploys are postponed,
|
|
20
|
+
batched and coordinated, and each one ends up larger and riskier.
|
|
21
|
+
|
|
22
|
+
**And it must stay quick** (owner, 2026-10-22): "in the future as more
|
|
23
|
+
tests/code/files/other are added, deploy times will probably increase. we
|
|
24
|
+
must always maintain the limits mentioned of 2 min code / 5 min image." The
|
|
25
|
+
limits are a standing budget that every later change is measured against. A
|
|
26
|
+
deploy that met them once does not count as meeting them.
|
|
27
|
+
|
|
28
|
+
## Measured baseline (2026-10-22)
|
|
29
|
+
|
|
30
|
+
Measured before planning, from journals, `docker buildx history`, rehearsal
|
|
31
|
+
reports (home) and a read-only pass over the Tagula box journal (14 days, 23
|
|
32
|
+
restarts, 9 upgrades). "Deploy time" here runs from the deploy command
|
|
33
|
+
starting until the live bot serves the new code on its derived image
|
|
34
|
+
(D-002).
|
|
35
|
+
|
|
36
|
+
### Home bot (`~/sync-mercury.sh`, source-run)
|
|
37
|
+
|
|
38
|
+
| Phase | Measured | Source |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| Waiting for a quiet window | 0–55 min. One hourly cron (task 1338, `0 8-23 * * *`) plus the 5-minute due-soon rule. Sessions waited for it by hand (`waitgap.sh`, 2026-10-22) | `sync-mercury.sh` `live-not-quiet` |
|
|
41
|
+
| Rehearsal, when it runs | **29–46 s**, green, $0.24–0.25 (2026-10-21 12:12 and 12:31, both manual) | `~/mercury-shadow/rehearsal/*` mtimes |
|
|
42
|
+
| Rehearsal through the sync | **refused 4 of 4** since R5.1: `boot-report-missing`, `live-cron-due`, `src-deps-differ`, `image-drift`. Each deploy then went out `--no-rehearse` | `journalctl --user -t mercury-sync` |
|
|
43
|
+
| Base image build, app-only change | 8–13 s (warm cache) | buildx history `mercury-src/container` |
|
|
44
|
+
| Base image build, dependency change | **17 m 53 s, 39 m 13 s**; the third, on 2026-10-22, finished at **33 m**, 27.5 m of it in one step: `RUN npx playwright install --with-deps chromium` (layer 11/38 of `container/Dockerfile`), rerun because the `pi` pin above it changed | buildx history (`wt128`, `imgbuild`); `docs/bugs/pinchtab-install-pulls-an-unpinned-playwright.md` |
|
|
45
|
+
| `bun install` (deps change) | runs in the mirror *after* the reset, before the restart | `sync-mercury.sh` |
|
|
46
|
+
| Host-global `pi` | installed by hand (`bun add -g …pi-coding-agent@1.3.0`) outside the sync | 2026-10-22 `deploy.sh` |
|
|
47
|
+
| Service stop → start | ~0 s stop, 3–4 s to `Started interval job` | systemd + journal, 4 restarts 10-20/21 |
|
|
48
|
+
| Second restart for the image | done in 2 of the last 3 deploys (02:30 + 02:31, 15:03 + 15:04) | systemd |
|
|
49
|
+
| Derived image build after the restart | **5 m 48 s – 9 m 31 s** (median ~7 m, 6 builds); 12.8 s once when cached. Runs spawn on the base image, without extension CLIs, meanwhile | `Built derived agent image … durationMs` |
|
|
50
|
+
| Image sizes | base 5.22 GB, derived 5.84 GB | `docker images` |
|
|
51
|
+
|
|
52
|
+
### Tagula box (`tagula-box-upgrade` nightly + manual §4)
|
|
53
|
+
|
|
54
|
+
| Phase | Measured (min / median / max) | Source |
|
|
55
|
+
|---|---|---|
|
|
56
|
+
| Updater total (the one real upgrade in 14 days) | 154 s | updater journal 2026-10-22 04:51:21 → 04:53:55 IDT |
|
|
57
|
+
| Login, inspect, disk `room`, snapshot | ~4 s | same |
|
|
58
|
+
| Image pull, layers shared | ≤ 2 s; cold boot-time pull 113 s (37 of 38 layers) | same; mercury journal 10-19 |
|
|
59
|
+
| `mercury upgrade` = npm install **with the service stopped** | 50 / 55 / 65 s | systemd stop → start gap, 9 upgrades |
|
|
60
|
+
| Graceful stop | 13 ms / ~30 ms / 0.7 s; never timed out | `Received signal` → `Shutdown: complete` |
|
|
61
|
+
| Start → `Server started` | 7.2 / 7.9 / 12.6 s (one 116 s outlier: a boot-time pull blocked startup) | journal |
|
|
62
|
+
| **User-visible downtime per upgrade** | 62 / ~65 / 79 s | SIGTERM → WhatsApp open |
|
|
63
|
+
| Derived image build | 73 / 78 / 80 s (11 builds); the updater waits for it | `durationMs` |
|
|
64
|
+
| Work killed by a restart | 4 of 23 restarts: 3 chat runs (notified at boot), 1 scheduled run (task 422, on its :45 slot, logged `interrupted`, **not re-run**) | journal |
|
|
65
|
+
| Cron density | 44 active tasks (33 cron, 11 `at`), 17–20 fires per weekday. Largest quiet gap 00:45–05:00 IDT | `tasks`, read-only |
|
|
66
|
+
| Deploy route | 8 of 9 upgrades were daytime manual or beta deploys. The nightly updater did 1 (the other nights it held or failed to log in) | updater journal |
|
|
67
|
+
|
|
68
|
+
### What the baseline says
|
|
69
|
+
|
|
70
|
+
1. **The restart itself is not the cost**: 4 s at home, ~8 s on Tagula plus
|
|
71
|
+
55 s of npm install that runs *while the service is stopped*.
|
|
72
|
+
2. **The derived image is rebuilt on every release**: ~7 min at home, ~78 s
|
|
73
|
+
on Tagula.
|
|
74
|
+
3. **Dependency changes are the long pole at home**: an 18–39 min source
|
|
75
|
+
build of an image CI already published.
|
|
76
|
+
4. **The quiet window exists only because a restart kills in-flight runs,
|
|
77
|
+
and nothing re-runs them.** The sub-second graceful stop kills containers
|
|
78
|
+
right away (`runtime.ts` step 3 `killAll` comes before step 4's wait).
|
|
79
|
+
5. **The rehearsal is cheap (30–46 s) but refuses**, so it has never gated a
|
|
80
|
+
real deploy.
|
|
81
|
+
|
|
82
|
+
## Constraints
|
|
83
|
+
|
|
84
|
+
- The release gate stays in force (`docs/release-gate.md`): the rehearsal
|
|
85
|
+
runs on every deploy because it is cheap enough, never skipped because it
|
|
86
|
+
is expensive (required).
|
|
87
|
+
- Mercury's own repo holds what Mercury owns. The fleet updater
|
|
88
|
+
(`box-upgrade.ts`, `run-box-upgrade.md`) is tagula-agents': its changes are
|
|
89
|
+
filed there as items, not built here (owner, 2026-10-22; D-006).
|
|
90
|
+
- Subscription OAuth only, no API keys (standing).
|
|
91
|
+
- The home bot stays the beta tester: unreleased `dev` commits must stay
|
|
92
|
+
deployable, including ones that change baked files (owner, 2026-10-22;
|
|
93
|
+
D-005).
|
|
94
|
+
|
|
95
|
+
## Preferences
|
|
96
|
+
|
|
97
|
+
- In-flight work is **never lost**: the restart drains for a bounded time,
|
|
98
|
+
then re-runs what it cut off. No gap hunt (required, owner 2026-10-22;
|
|
99
|
+
D-004).
|
|
100
|
+
- The home bot pulls the published image when the tree matches a release,
|
|
101
|
+
and otherwise builds with the published layer cache (required, owner
|
|
102
|
+
2026-10-22; D-005).
|
|
103
|
+
- One command per box, one restart per deploy (required).
|
|
104
|
+
- Tooling: bash + bun + Docker, as today (you decide; D-001).
|
|
105
|
+
|
|
106
|
+
## Target Users
|
|
107
|
+
|
|
108
|
+
- **The owner (Sahar)** deploying `dev` to the home bot several times a day,
|
|
109
|
+
from any session, at any hour.
|
|
110
|
+
- **Whoever runs a Tagula box upgrade**: the nightly updater, or a person
|
|
111
|
+
doing a beta or manual deploy (Sahar, Tsabari).
|
|
112
|
+
- **People talking to the bots**, who should never notice a deploy: no lost
|
|
113
|
+
scheduled article, no unanswered message (inferred).
|
|
114
|
+
|
|
115
|
+
## Success Criteria
|
|
116
|
+
|
|
117
|
+
1. **Code-only deploy ≤ 2 min, at any time of day**, home bot: one command,
|
|
118
|
+
one restart, rehearsal included, no gap refusal. Measured by the deploy's
|
|
119
|
+
own timing record.
|
|
120
|
+
2. **Release with an image or dependency change ≤ 5 min** on the home bot and
|
|
121
|
+
the Tagula box: one command, one restart, rehearsed. The derived image is
|
|
122
|
+
ready when the restart lands, or seconds after it.
|
|
123
|
+
3. **A deploy runs mid-day without blocking the bot, and loses nothing**:
|
|
124
|
+
preparation runs while the bot serves; the pause (stop → listening) is
|
|
125
|
+
≤ 30 s; messages that arrive during it run after boot; a scheduled run in
|
|
126
|
+
flight or due during the restart re-runs once; a chat turn in flight
|
|
127
|
+
finishes or resumes from what it already did, with no duplicated action
|
|
128
|
+
and no "send it again". Proven by a deploy forced during a scheduled run
|
|
129
|
+
and a chat turn.
|
|
130
|
+
4. **The limits hold over time**: every deploy on both boxes writes a timing
|
|
131
|
+
record with a verdict against its budget; a phase that drifts past its
|
|
132
|
+
share warns before the total limit is broken; a change that would break a
|
|
133
|
+
limit fails a gate in CI or at deploy, with a reader that shows the trend.
|
|
134
|
+
5. **The rehearsal gates every deploy, including image and dependency
|
|
135
|
+
changes.** `--no-rehearse` reasons naming `image:` or `deps:` drop to zero.
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Roadmap: Deploy in minutes
|
|
2
|
+
|
|
3
|
+
**Goal**: [deploy-in-minutes](goal.md)
|
|
4
|
+
**Last updated**: 2026-10-22
|
|
5
|
+
|
|
6
|
+
> Order follows the baseline. M1 removes the wait, which is the cost on every
|
|
7
|
+
> deploy, code-only included, and adds the meter that every later story is
|
|
8
|
+
> judged by. M2 removes the builds and installs that sit in front of a
|
|
9
|
+
> restart, which is the cost of a release. M3 makes the gate cheap enough to
|
|
10
|
+
> run on all of them.
|
|
11
|
+
|
|
12
|
+
## Milestones
|
|
13
|
+
|
|
14
|
+
### Milestone 1: A code-only deploy at any moment, measured
|
|
15
|
+
> After this, a code-only deploy to the home bot is one command at any hour,
|
|
16
|
+
> pauses the bot for at most 30 s, loses no run or chat turn, and prints its
|
|
17
|
+
> own phase timings against the 2-minute budget.
|
|
18
|
+
|
|
19
|
+
| ID | Story | Slug | Depends on | Status |
|
|
20
|
+
|----|-------|------|------------|--------|
|
|
21
|
+
| M1.1 | Every deploy writes a phase-timing record with a verdict against its class budget (120 s code / 300 s image) and the 30 s pause limit; `mercury deploy-timings` shows the trend and per-phase drift | deploy-time-budget | — | backlog |
|
|
22
|
+
| M1.2 | SIGTERM drains: stop admitting, wait ≤ `shutdown.drainMs` (20 s) for active runs, save queued and arriving work, then kill | restart-drains-in-flight-runs | — | backlog |
|
|
23
|
+
| M1.3 | A scheduled run cut off by a restart, or due during it, re-runs once at boot | restart-reruns-cut-off-scheduled-runs | M1.2 | backlog |
|
|
24
|
+
| M1.4 | A chat turn cut off by a restart resumes once at boot from a record of what it already did; the notice is only the fallback | restart-resumes-cut-off-chat-turns | M1.2 | backlog |
|
|
25
|
+
| M1.5 | `mercury deploy-local`: the home deploy as a reviewed Mercury command (rehearse → reset → one restart → wait for the derived image → timing record). No gap refusal. Gate 9 amended | home-deploy-command | M1.1–M1.4 | backlog |
|
|
26
|
+
|
|
27
|
+
> Nine stories, one over the usual cap of eight: M1.4 was added at the owner's
|
|
28
|
+
> review (2026-10-22), and M1 does not meet "restore everything" without it.
|
|
29
|
+
|
|
30
|
+
**Checkpoint:** at midday, run `~/sync-mercury.sh` for a code-only change
|
|
31
|
+
**while task 1338's run is in flight and an owner DM is mid-turn** (a
|
|
32
|
+
multi-tool turn). The rehearsal is green; the timing record says
|
|
33
|
+
`class=code`, `verdict=within`, total ≤ 120 s, pause ≤ 30 s; `mercury
|
|
34
|
+
deploy-timings` shows it beside the baseline. Task 1338 finishes (drained) or
|
|
35
|
+
re-runs after boot: one article. The DM turn finishes or resumes: one answer,
|
|
36
|
+
no notice, no tool action done twice. A message sent during the pause is
|
|
37
|
+
answered after boot.
|
|
38
|
+
|
|
39
|
+
### Milestone 2: A release is ready before the restart
|
|
40
|
+
> After this, a release that changes the image or dependencies deploys in
|
|
41
|
+
> ≤ 5 minutes on the home bot, with one restart and the derived image ready
|
|
42
|
+
> when the bot comes back, and `mercury upgrade` no longer installs while the
|
|
43
|
+
> service is stopped.
|
|
44
|
+
|
|
45
|
+
| ID | Story | Slug | Depends on | Status |
|
|
46
|
+
|----|-------|------|------------|--------|
|
|
47
|
+
| M2.1 | The home deploy pulls the published base image when the tree's baked files match a release, else builds with the published cache, before the restart | local-deploy-pulls-the-published-image | M1.5 | backlog |
|
|
48
|
+
| M2.2 | Extension layers of the derived image survive an app-only release (adopted: spec already architected) | agent-image-releases-share-layers | — | backlog |
|
|
49
|
+
| M2.3 | `mercury upgrade` and `deploy-local` install the new host package or `node_modules` into a staged directory **before** stopping, then swap; host-global `pi` pinned by the deploy, not by hand | host-install-before-stop | M1.1 | backlog |
|
|
50
|
+
|
|
51
|
+
**Checkpoint:** deploy one release with a dependency change and a version
|
|
52
|
+
bump to the home bot: timing record `class=image`, total ≤ 300 s, one
|
|
53
|
+
restart, `Using cached agent image` (or a seconds-long `Built … layout=split`)
|
|
54
|
+
right after boot. On Tagula, a manual `mercury upgrade` of the same release:
|
|
55
|
+
stop → start gap under 15 s (was 55 s). File the fleet items in
|
|
56
|
+
tagula-agents (D-006): the updater calls the staged upgrade, waits on the new
|
|
57
|
+
derived image before the stop, and writes the same timing record. **Re-judge
|
|
58
|
+
the future item `prebuild-derived-image-before-restart`** against M2.2's
|
|
59
|
+
measured rebuild on both boxes.
|
|
60
|
+
|
|
61
|
+
### Milestone 3: The gate runs on every deploy
|
|
62
|
+
> After this, image and dependency changes are rehearsed like code changes,
|
|
63
|
+
> and the budget holds on both boxes.
|
|
64
|
+
|
|
65
|
+
| ID | Story | Slug | Depends on | Status |
|
|
66
|
+
|----|-------|------|------------|--------|
|
|
67
|
+
| M3.1 | `shadow rehearse` covers `image-drift` (shadow-only image tag, built or pulled before `up`) and `src-deps-differ` (own `bun install --frozen-lockfile` in the staged copy) | rehearse-what-the-shadow-refuses | M2.1, M2.3 | backlog |
|
|
68
|
+
|
|
69
|
+
**Checkpoint:** two weeks of deploys on the home bot with no `--no-rehearse`
|
|
70
|
+
reason naming `image:` or `deps:`. Every timing record is `within`. One
|
|
71
|
+
Tagula upgrade through the updater carrying the fleet items writes a record
|
|
72
|
+
`within` its budget. The goal closes on these records, and the ratchet
|
|
73
|
+
(M1.1's reader and the CI leg) keeps them after it closes.
|
|
74
|
+
|
|
75
|
+
## Future — decomposed at the M2 checkpoint
|
|
76
|
+
|
|
77
|
+
| Item | Condition |
|
|
78
|
+
|------|-----------|
|
|
79
|
+
| `prebuild-derived-image-before-restart` (`docs/ideas/`) | Only if M2.2's measured derived rebuild for an app-only release does not fit its budget share on either box. Then it becomes an M3 story |
|
|
80
|
+
| `hand-built-agent-image-transfer-moves-only-changed-layers` (`docs/ideas/`) | Not on the deploy path. Only for registry outages |
|
|
81
|
+
|
|
82
|
+
## External dependencies
|
|
83
|
+
|
|
84
|
+
| Needed by | What | Where |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| M3 checkpoint | Fleet updater: staged `mercury upgrade`, derived image ready before the stop, timing record, rehearse on the box | tagula-agents items, filed at the M2 checkpoint (D-006) |
|
|
87
|
+
| M2.1 | A `read:packages` GHCR login on the home box | owner, one-time |
|
|
88
|
+
|
|
89
|
+
## Dependency Graph
|
|
90
|
+
|
|
91
|
+
```
|
|
92
|
+
M1.1 ───────────────┬──────────────► M1.5 ──► M2.1 ──┐
|
|
93
|
+
M1.2 ──► M1.3 ──────┤ (M1.2 too) ├──► M3.1
|
|
94
|
+
M1.2 ──► M1.4 ──────┘ │
|
|
95
|
+
M1.1 ──► M2.3 ───────────────────────────────────────┘
|
|
96
|
+
M2.2 (independent; already architected)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
DAG check: no story depends on a later milestone; M2.2 has no dependencies.
|
|
@@ -117,6 +117,8 @@ lab space and every item is either ticked with the date or moved into M2 as
|
|
|
117
117
|
a shadow-testable item.
|
|
118
118
|
|
|
119
119
|
### What the pending list says the bench still lacks (2026-09-15)
|
|
120
|
+
|
|
121
|
+
> **Superseded 2026-10-25 (credential part):** the shadow no longer shares a refresh chain with live. Both bots run on long-lived `claude setup-token` tokens and the shadow has its own since 2026-10-21 (M1.3d, D-017), so nothing refreshes the Anthropic credential on either side; M1.3c is deferred and no longer blocks L1134. See `docs/configuration.md`.
|
|
120
122
|
> Written after the v0.23.0-beta.2 sweep, in which 63 manual checks were
|
|
121
123
|
> cleared from the box and the bench and seven from the owner's phone, and 55
|
|
122
124
|
> stayed open. The earlier version of this analysis was a session report and
|
|
@@ -124,7 +124,7 @@ command or strikes the rule; no rule survives without a command.
|
|
|
124
124
|
| ID | Story | Slug | Depends on | Status |
|
|
125
125
|
|----|-------|------|------------|--------|
|
|
126
126
|
| R5.1 | `~/sync-mercury.sh --rehearse` (ex rehearsal-bench M3.3): after the mirror is reset and before the restart, `shadow up --src <mirror>`, `preflight`, `smoke` for the spaces that have fixtures, print cost and `shadow diff`, ask before restarting live; `--rehearse` becomes the default and `--no-rehearse` must name a reason that lands in the journal | sync-rehearse | R1.1, R3.2, rehearsal-bench M1.3 + M3.1 | **landed 2026-10-20 (code + docs); box checks wait for the bootstrap deploy.** `mercury shadow rehearse`, the `~/sync-mercury.sh` patch, and fixtures for `main`. Spec: [`docs/archive/2026-10-20-sync-rehearse.md`](../../archive/2026-10-20-sync-rehearse.md). The first box run refused `boot-report-missing`: the deployed `8407fdb6` predates M3.1, so nothing is rehearsable until the bootstrap deploy. Earlier: **backlog, unblocked 2026-10-19** (M3.1 landed as `1fe47951`; its six box checks are still open). Planned in [`docs/backlog/sync-rehearse.md`](../../backlog/sync-rehearse.md), with two corrections to this row: the sequence is a Mercury command, `mercury shadow rehearse --src <tree>` (G-012), and `~/sync-mercury.sh` rehearses a detached worktree of the target sha **before** the mirror moves, not after (G-013). `smoke` refuses while a shadow is up (`src/smoke/boot.ts`), so it runs after `down` from a second staging of the same tree hash. No live space has a `smoke.yaml` yet, so the owner's first fixtures are part of the story (absence denies → `no-fixtures`). Image-baked and dependency changes cannot be rehearsed yet → idea `rehearse-what-the-shadow-refuses` |
|
|
127
|
-
| R5.2 | Workflow wiring: `/f-bug-fix` and `/f-feature-dev` gain a **Gate** step between the check gate and deploy that runs preflight + smoke in the shadow and attaches both reports to the doc; the post-mortem template gains a required `Gate check:` line; `pending-verification.md` entries must carry an owner and a date | workflow-gate-step | R4.1, R5.1 | **Mercury half landed 2026-10-21;
|
|
127
|
+
| R5.2 | Workflow wiring: `/f-bug-fix` and `/f-feature-dev` gain a **Gate** step between the check gate and deploy that runs preflight + smoke in the shadow and attaches both reports to the doc; the post-mortem template gains a required `Gate check:` line; `pending-verification.md` entries must carry an owner and a date | workflow-gate-step | R4.1, R5.1 | **Mercury half landed 2026-10-21. Checkpoint: the rehearsed path ran green on 2026-10-25; one clause still open.** `~/sync-mercury.sh dev` rehearsed `ac761106` (worklist-security R1+R2, five post-mortems passing `tests/release-gate-evidence.test.ts`) before the mirror moved, as the first green rehearsal ahead of a deploy: snapshot, up, preflight, down, smoke main and diff all passed, $0.2398, report `~/mercury-shadow/rehearsal/2026-10-25T12-31-29-095Z.json`. Then the deploy, with boot preflight 9 pass / 0 blocked on `mercury-agent-ext:8fe6fa7ddb4a`. It needed a `--no-rehearse` deploy of `89f349c0` first (baked `ymail.ts`; the derived image only builds after a restart). Still open: "the manual check is replaced by the reports". These fixes' manual checks are live worklist and overview turns, and this box has neither installed, so the reports cannot stand in for them; the next rehearsed fix whose check the smoke covers closes it. Earlier: `tests/release-gate-evidence.test.ts` + `tests/helpers/deploy-docs.ts`, cutoff 2026-10-22 (a post-mortem dated 2026-10-21 already sat on `dev` without the block). Spec: [`docs/archive/2026-10-21-workflow-gate-step.md`](../../archive/2026-10-21-workflow-gate-step.md). The R5 checkpoint (one real fix through check gate → `shadow rehearse` → deploy, its post-mortem passing this test) waits for the bootstrap deploy, since every rehearsal refuses `boot-report-missing` until then. Boilerplate idea extended with the template block and the `MANUAL-VERIFY` owner field (local `faa8050`, unpushed). Earlier: **backlog — split 2026-10-19 (G-014).** Mercury half planned in [`docs/backlog/workflow-gate-step.md`](../../backlog/workflow-gate-step.md): `tests/release-gate-evidence.test.ts` fails any spec or post-mortem archived after the cutoff without the `release-gate.md` §4 block (class list read from §4, refusal ids from R5.1's `RehearseRefusal`). The `Gate check:` line is already enforced by R3.3. The Gate step, the template block and the owner field are workflow formats and go to the boilerplate idea `rehearse-step-in-fix-and-feature-dev` (local `555f5ad`, unpushed) |
|
|
128
128
|
|
|
129
129
|
**Checkpoint:** one real fix ships through the full path — check gate,
|
|
130
130
|
shadow, preflight report, smoke report, deploy — and the corresponding
|
package/docs/live-testing.md
CHANGED
|
@@ -394,7 +394,9 @@ line above every destructive command (archived spec:
|
|
|
394
394
|
`shadow rehearse` always passes, they are printed under `Warnings:` instead.
|
|
395
395
|
It then refuses `credential-shared-chain`: the shadow would share a rotating
|
|
396
396
|
credential with live. The fix is the shadow's own token file
|
|
397
|
-
(`docs/configuration.md`, Shadow mode).
|
|
397
|
+
(`docs/configuration.md`, Shadow mode). That refusal only fires on an install
|
|
398
|
+
still on an `auth.json` login (or an env blob); our boxes and their shadow run
|
|
399
|
+
on long-lived tokens that never refresh, so there is no chain to share. It
|
|
398
400
|
prints **every** refusal, not the first. `--dry-run` runs every check and
|
|
399
401
|
prints the unit command without starting anything — run it first, always.
|
|
400
402
|
`--src` defaults to `~/mercury-src` and takes any git working tree — a
|