Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

docs(prompts): write order 404 to reconcile the evolve/main branch divergence, log R2 flapping as owner row 36

nirholas307cd2213037
diff --git a/prompts/finish/404-auto-reconcile-evolve-main-divergence.md b/prompts/finish/404-auto-reconcile-evolve-main-divergence.md
new file mode 100644
index 000000000..aabd2b367
--- /dev/null
+++ b/prompts/finish/404-auto-reconcile-evolve-main-divergence.md
@@ -0,0 +1,95 @@
+# 404. Reconcile the `evolve` branch with `main`: a 140-file merge, done in risk-ordered batches
+
+How to run: paste this file's repo path into a fresh Claude Code chat in this repository and say "run this work order". Runnable now, no gate. Written by the evolve scout lane on 2026-10-11 from the measurements below. This order exists to finally close [production-100-OWNER-ACTIONS.md row 34](_context/production-100-OWNER-ACTIONS.md), which has been re-measured four times since 2026-10-11 without being fixed, and which blocks orders [060](060-x-grok-38-agent-mention-replies.md) and [061](061-x-grok-39-agent-mention-settings-ui.md) outright (both say so in their own status preambles). It is designed to be picked up across multiple sessions: if you run out of budget mid-task, leave the worktree clean (never a conflicted merge in progress) and hand off precisely, per the close-out section.
+
+## Operating clause (binding)
+
+- Read CLAUDE.md first. CLAUDE.md overrides everything, including this file.
+- Finish as much as this session allows. A conflict you cannot resolve with high confidence is not a reason to guess; it is a reason to stop on that one file, record exactly what you found, and move to the next batch. Never end the turn with an open question; a judgment call goes in one line of the final report.
+- The only permitted stops are the CLAUDE.md stop-and-ask gates (spend/sign/mint, push/deploy/post, committing content naming a crypto project other than $THREE, destroying unrecoverable data). Nothing in this order needs any of those.
+- **Never leave the shared worktree in a conflicted-merge or conflicted-rebase state when you stop.** Other agents run `git status`/`git add -A` sweeps against this exact directory between your tool calls. If you cannot finish resolving every conflict in one sitting, `git merge --abort` (or `git rebase --abort`) before you stop, and write down what you already resolved (file list + the resolution you'd apply) in this order's own "Evolve status update" preamble (follow the pattern in orders 060/061) so the next session does not redo the analysis.
+- No mocks, no fake data, no placeholder stubs, no unfinished-work markers, no commented-out code.
+- The em-dash and en-dash characters are banned in everything you write.
+- Concurrent agents share this worktree: do the merge, resolve every conflict, then commit it as one commit with explicit paths. Do not run `git add -A`.
+- Before committing, run `npm run check:rules -- --paths <files you touched>`. It must exit 0.
+
+## Why this matters (measured 2026-10-11, `evolve` at `8f82110eb`, `main` at `e33f529d8`)
+
+ git rev-list --left-right --count main...HEAD
+ # 376 134 (main has 376 commits evolve lacks; evolve has 134 commits main lacks)
+
+`evolve` branched from `main` and has never merged or rebased back, because `scripts/evolve.mjs`'s `syncWorktree()` silently swallows the problem: it tries `git reset --hard main` (works only if `evolve` is a pure fast-forward ancestor of `main`, which stopped being true weeks ago), falls back to `git rebase main`, and when THAT conflicts it runs `git rebase --abort` and returns the string `'conflict'` with no escalation. Every caller just logs "evolve branch conflicts with main; working on its current base until it is resolved" and continues working from the stale base. The gap has only grown across four separate re-measurements in `production-100-OWNER-ACTIONS.md` row 34 (358 to 362 to 376 commits behind) because nothing ever closes it.
+
+The cost is concrete, not hypothetical:
+- Orders [060](060-x-grok-38-agent-mention-replies.md) and [061](061-x-grok-39-agent-mention-settings-ui.md) cannot be built on `evolve` at all: their entire prerequisite subsystem (`x-mention-poll.js` and its ~14-file import closure) exists only on `main`.
+- `main` shipped a live, currently-silent production defect that is already fully diagnosed (row 34, re-measured with production's own API keys): `x-mention-reply.js`'s `chainFor()` builds a model chain from `agent-brain.js`/`agent-model.js` records shaped for a different caller (`copilot-engine.js`), then hands that mismatched chain to `llmComplete`, whose attempt loop calls `p.buildBody(...)`, a method only `llm.js`'s own `providerChain()` objects define. Every attempt throws, every mention reply falls back to the fixed help text, and the live `x_mention_events` table already carries 129 rows proving it (`reason: 'fallback:llm_error'`). This fix is two lines once `x-mention-reply.js` exists in this tree; it cannot be written at all until then.
+- A full trial merge (`git merge --no-commit --no-ff main`, done in this session, then `git merge --abort`, nothing committed) shows the conflict surface is 140 files, not the single file a rebase would hit first. The full list, captured 2026-10-11, is at the bottom of this file so you do not have to re-run the merge just to get it. Ten of those files are security- or money-adjacent (`api/_lib/auth.js`, `api/_lib/api-keys.js`, `api/_lib/rate-limit.js`, `api/_lib/idempotency.js`, `api/_lib/spend-scope.js`, `api/_lib/webhook-dispatch.js`, `api/_lib/x402-paid-endpoint.js`, `api/cron/x402-ring-leak-scan.js`, `api/_lib/x-search.js`, `api/_lib/sentiment-scout.js`); guessing a resolution on any of these is exactly the kind of shortcut CLAUDE.md forbids ("no good enough", "no errors without solutions" means find the real one, not a fast one).
+
+## Step 0: re-derive the current state
+
+ git fetch threews main 2>&1 | tail -5 || true
+ git rev-list --left-right --count main...HEAD
+ git log --oneline main..HEAD | head -20 # evolve's own unmerged work
+ git log --oneline HEAD..main | wc -l # how much main has grown since this file was written
+ git status --porcelain=v1 # must be clean before you start the merge below
+
+If the counts have moved a lot since 2026-10-11, trust your own numbers over this file's. If `git status` is not clean, that is another agent's in-flight work (likely regenerated `public/changelog*.json`, `public/features.json`, `public/sitemap/index.html`, which `npm run build:pages` rewrites constantly): `git stash push -u -m "404-wip-<timestamp>"` it aside, note the stash SHA, and restore it after your merge commit lands (never bare `git stash`/`git stash pop`, the stash stack is shared).
+
+## Tasks
+
+Do the merge as ONE operation (not a 134-step rebase replay): `git merge main` surfaces every conflicting file at once, which is far easier to audit and to stop/resume than a rebase that reconflicts commit by commit. A merge commit also makes `evolve` a proper descendant of `main`, so `scripts/evolve.mjs`'s existing `land()` fast-forward works unchanged afterward.
+
+1. **Start the merge.** `git merge --no-commit --no-ff main`. Expect conflicts; do not panic-abort. Work the list below in order (lowest risk first), and after resolving each file's conflict run the single most relevant test file if one is named, so a mistake surfaces immediately rather than at the end.
+
+2. **Batch A, mechanical (no judgment call):**
+ - `workers/*/worker_security.py` (17 files: `avatar-pipeline-controller`, `avatar-reconstruction`, `garment-forge`, `longcat`, `model-hunyuan3d`, `model-text2motion`, `model-trellis`, `model-triposg`, `model-triposr`, `model-video2motion`, `model-video2scene`, `rembg`, `remesh`, `rig`, `segment`, `stylize`, `texture`). CLAUDE.md's vendored-worker rule says these must all stay byte-identical copies of one canonical source. Read both sides' diffs (`git show main:<path>`, `git show HEAD:<path>`); whichever side has the MORE RECENT security fix is canonical (check both branches' commit history on `worker_security.py` with `git log --oneline -- <path>` on each side via `git log --oneline main -- <path>` and `git log --oneline HEAD -- <path>`). Copy that one version into every one of the 17 paths. Verify with `npm run check:vendored` (must report zero drift) before moving on.
+ - Generated/derived files that a build script owns outright and will regenerate correctly regardless of which side you pick: `public/.well-known/mcp.json`, `public/mcp-catalog.json`, `public/guards.json`, `public/llms.txt`, `public/llms-full.txt`, `CHANGELOG.md`, `data/changelog.json` (if it conflicts only on the entry list, keep both sides' entries, newest first; this file is hand-written, not generated, so read it rather than regenerating). Take main's version for the purely generated ones, then regenerate with the script each one names (`node scripts/build-pages.mjs` family; `npm run build:pages` covers most) and confirm `git diff` shows no further drift.
+
+3. **Batch B, additive (evolve added a file main never touched, or vice versa, zero real overlap):** Anything in the conflict list below that is actually a clean add on one side with no competing content (check with `git diff main HEAD -- <path>`; if one side's diff against the merge base is empty, there is no real conflict and you can take the non-empty side outright). Expect most of the `x-grok` prompt files, `prompts/finish/_context/x-grok-PROGRESS.md`, and the `docs/*` single-topic pages to fall here.
+
+4. **Batch C, same-feature parallel evolution (read both sides' intent, combine, never blind-pick):**
+ - `api/_lib/x-mention-store.js`, `api/_lib/gateway/adapters/x.js`, `api/_lib/x-search.js`, `api/_lib/sentiment-scout.js`, `api/cron/x402-ring-leak-scan.js`, `tests/x402-ring-leak-scan-run.test.js`, `tests/zz-probe.test.js`: `evolve`'s own HEAD (`f6dcafb23`, order 400) rewrote the ring-leak scanner to scan by tier under a lock and a budget, fixing a wallet-identity bug; `main` has its own independent history on the mention-store and gateway-adapter files from the x-grok campaign's later orders. Read `git log -p` on both sides for each file before touching it. The resolution preserves BOTH improvements; it is never "take main because main is bigger" or "take ours because we just shipped it." If a file's two versions solve genuinely unrelated problems, hand-merge the hunks.
+ - `api/_lib/webhook-dispatch.js`: already analyzed in a prior session. Main added SSRF-safe dispatcher handling and a webhook-signature format change; evolve added a response-body size cap and finer error classification in `deliver()`. Preserve both: start from main's SSRF-safe version and re-apply evolve's size-cap-and-classification logic inside it. Run `npx vitest run tests/webhook-dispatch*.test.js` after.
+ - `data/guards.json`, `data/pages.json`, `vercel.json`, `package.json`: additive lists both sides appended to. Union the entries; do not drop either side's additions. Run `npm run check:claude` and `npm run check:guards` (or whichever script `audit:guards` names) after touching `data/guards.json`.
+
+5. **Batch D, security- and money-adjacent (highest scrutiny, read every hunk):** `api/_lib/auth.js`, `api/_lib/api-keys.js`, `api/_lib/rate-limit.js`, `api/_lib/idempotency.js`, `api/_lib/spend-scope.js`, `api/_lib/x402-paid-endpoint.js`, `api/_mcp/policy.js`. For each: `git log --oneline main -- <path>` and `git log --oneline HEAD -- <path>` to see what each side actually changed and why (read the commit messages; they say the intent). If both sides' changes are orthogonal (touch different functions, different concerns), combine both. If you find a genuine behavioral contradiction you cannot resolve with full confidence from the commit history and code alone, STOP on that one file: `git checkout --conflict=merge -- <path>` to reset just that file's conflict markers for inspection, leave it unresolved, note the exact contradiction in this order's status preamble, and continue with the rest. Finish every other file before deciding whether to abort the whole merge over the ones you couldn't resolve, or commit with those specific files intentionally reverted to main's version plus a new, narrowly-scoped follow-up order naming exactly what needs a human call.
+
+6. **Finish the remaining conflict-list files** (the mcp-studio, dashboard-next, three-ws-cli, docs, and test fixture files) using the same read-both-sides-first discipline as batch C; none of them are security-adjacent, so a confident combine is almost always possible.
+
+7. **Commit the merge.** Once `git diff --diff-filter=U` is empty, `git commit` (no `-m`, let it open the default merge message, or supply one naming this order). This is the one commit allowed to touch this many files at once; it is a merge, not a sweep.
+
+8. **Fix the live `x-mention-reply.js` bug in the same session, now that the file exists.** In `api/_lib/x-mention-reply.js`, replace `chainFor()`'s body: instead of calling `resolveAgentBrain`/`modelChain`, resolve the agent's Grok key with `loadOwnerGrokKey(agent?.user_id)` from `api/_lib/agent-grok-key.js` (already on this branch, unchanged by the merge) and call `llm.js`'s own `providerChain({ grokKey, grokModel })` (or build the chain exactly as `llmComplete` expects; read `llm.js`'s `providerChain` signature first, since the merge may have changed it). Confirm the agent's chosen Grok model lives on `agent.meta` the same way `agentDefaultModel()` in `api/_lib/agent-model.js` already reads it (`meta.runtime.model`, `meta.brain.provider`, `meta.brain.model`), and resolve it the same way rather than inventing a second lookup path. Verify with `RUN_LLM_TESTS=1 npx vitest run tests/x-mention-reply.llm.test.js --reporter=verbose`: every case must show `source: 'model'` with no `TypeError`, not the `reason: 'llm_error'` fallback the diagnosis found. Commit this as its own topical commit, separate from the merge.
+
+9. **Update the record.** Delete the stale status preambles in orders [060](060-x-grok-38-agent-mention-replies.md) and [061](061-x-grok-39-agent-mention-settings-ui.md) that say the subsystem does not exist on `evolve` (it now does), leaving each order otherwise intact for a future session to actually build. Edit row 34 in [production-100-OWNER-ACTIONS.md](_context/production-100-OWNER-ACTIONS.md): if everything in this order lands, mark it closed per that file's own "retire a row" convention (read the file's own header for the exact mechanic); if batch D left anything unresolved, rewrite row 34 to describe only the remainder, not the whole divergence.
+
+## Definition of done
+
+- [ ] `git rev-list --left-right --count main...HEAD` reports `0` on the left (evolve's HEAD is now a descendant of `main`), or if batch D left a documented remainder, the report explains exactly why and names the follow-up.
+- [ ] `npm run check:vendored` exits 0.
+- [ ] `npx vitest run tests/webhook-dispatch*.test.js tests/x402-ring-leak-scan-run.test.js tests/x-mention-reply.llm.test.js` all pass, the last one with `source: 'model'` and no `buildBody` TypeError.
+- [ ] `npm test` (full `test:core`) passes, or every new failure is triaged and attributed to a specific unresolved batch-D file, not waved away.
+- [ ] `npm run check:rules -- --paths <files you touched>` exits 0.
+- [ ] `git status --short` is empty except files intentionally left for a follow-up, each named in the report.
+- [ ] Orders 060 and 061's stale "cannot be built" preambles are removed or corrected to reflect the subsystem now existing.
+
+## Never blocked
+
+| Blocker | Resolution (act, do not ask) |
+|---|---|
+| A batch-D file's two sides genuinely contradict | Finish every other file, commit with that file resolved to main's version (the more recently-reviewed, production-serving side), and write a new, narrowly-scoped follow-up order naming the exact contradiction and both commit SHAs. Do not guess on auth/money code. |
+| The merge is too large to finish in one session | `git merge --abort`, leave the worktree clean, and write what you already determined (per-file resolution notes) into this order's own preamble so the next session skips re-analysis. Never leave a conflicted merge sitting in the shared worktree. |
+| `main` has grown further since 2026-10-11 | Re-run step 0 and re-run the trial merge; the conflict list below is a starting point, not gospel. |
+| A test fails after a resolution you were confident in | Re-read both sides' diffs for that file; you combined wrong. Fix the combination, do not skip the test. |
+| `git fetch threews main` fails (no network to GitHub) | The local `main` ref in this worktree's parent repo is already current enough for everything in this order; proceed with the local ref and note it in the report. |
+| Orders 060/061 contradict what the merge actually produced on `x-mention-poll.js` or `x-agent-policy.js` | Trust the merged code over the orders' prose; correct the orders' preambles to match, as task 9 already asks. |
+
+## Captured conflict list (2026-10-11, from `git merge --no-commit --no-ff main`, then `git merge --abort`, nothing committed)
+
+CHANGELOG.md, STRUCTURE.md, api/_lib/api-keys.js, api/_lib/auth.js, api/_lib/gateway/adapters/x.js, api/_lib/idempotency.js, api/_lib/rate-limit.js, api/_lib/sentiment-scout.js, api/_lib/spend-scope.js, api/_lib/strategy-loop/tick.js, api/_lib/webhook-dispatch.js, api/_lib/x-mention-store.js, api/_lib/x-search.js, api/_lib/x402-paid-endpoint.js, api/_mcp-studio/account-tools.js, api/_mcp-studio/dispatch.js, api/_mcp-studio/gpt-forge-client.js, api/_mcp-studio/handler.js, api/_mcp-studio/tools.js, api/_mcp/policy.js, api/_mcp/prompts.js, api/_mcpagent/discovery.js, api/_mcpagent/dispatch.js, api/_mcpagent/tools.js, api/agents/_id/credits.js, api/agents/copilot.js, api/agents/orders.js, api/api-keys.js, api/config.js, api/cron/x402-ring-leak-scan.js, api/inference/[action].js, api/keys/index.js, api/mcp-studio/install.js, api/oauth/[action].js, api/ops/mcp-clients.js, data/changelog.json, data/grok-skill-md.template.md, data/guards.json, data/pages.json, data/skill-md.template.md, data/x-content/queue.json, data/x-content/reviews/ai-3d-skills.json, data/x-content/reviews/galaxy.json, docs/agent-skills.md, docs/api-reference.md, docs/aws-builder-center-universal-retargeting.md, docs/cli.md, docs/coinmarketcap-article-play.md, docs/grok-bot.md, docs/grok.md, docs/guards.md, docs/huggingface-agent-feedback-loop.md, docs/ibm-community-any-skeleton-animation-post.md, docs/mcp-agent.md, docs/mcp-studio.md, docs/mcp-x402-bazaar.md, docs/mcp.md, docs/nvidia-gtc-2027-poster.md, docs/ops/README.md, docs/ops/guard-wiring.md, docs/ops/mcp-clients.md, docs/threejs-forum-post.md, docs/tutorials/grok-bot-recipes.md, docs/x-mention-bot.md, package.json, packages/home-mcp/src/tools/preview-macro.js, packages/home-mcp/tests/registration.test.js, packages/three-ws-cli/README.md, packages/three-ws-cli/package.json, packages/three-ws-cli/src/cli.js, packages/three-ws-cli/src/clipboard.js, packages/three-ws-cli/src/commands/setup.js, packages/three-ws-cli/src/index.js, packages/three-ws-cli/tests/grok-bot.test.js, pages/connect.html, pages/grok.html, pages/mcp-clients.html, prompts/RUN-ORDER.md, prompts/finish/023-x-grok-01-connector-compat-probe.md, prompts/finish/024-x-grok-02-cloud-agent-rate-limits.md, prompts/finish/_context/parity-PROGRESS.md, prompts/finish/_context/x-grok-PROGRESS.md, prompts/x-grok/_generated/connector-probe-dev.json, prompts/x-grok/_generated/connector-probe.json, prompts/x-grok/_generated/operability.json, public/.well-known/mcp.json, public/changelog-recent.json, public/changelog.json, public/changelog.xml, public/features.json, public/grok-skill.md, public/guards.json, public/llms-full.txt, public/llms.txt, public/locales/en.json, public/login.html, public/mcp-catalog.json, public/sitemap/index.html, scripts/audit-agent-operability.mjs, scripts/audit-docs.mjs, scripts/build-mcp-surfaces.mjs, scripts/build-skills-pack.mjs, scripts/run-grok-recipe.mjs, scripts/xai-mcp-e2e.mjs, server-agent.json, server-grok.json, server-studio.json, server.json, src/dashboard-next/pages/api.js, src/dashboard-next/pages/settings.js, src/grok-page.js, src/inference-credits.js, tests/agent-wallet-withdraw.test.js, tests/agora-mcp-tools.test.js, tests/api/forge-nim.test.js, tests/api/launchpad-publish-edit-auth.test.js, tests/api/leaderboard-rollup-cron.test.js, tests/api/mcp-agent-catalog.test.js, tests/api/mcp-agent.test.js, tests/api/mcp-bazaar-challenge.test.js, tests/api/mcp-bazaar.test.js, tests/api/mcp-memory.test.js, tests/api/security-csrf-gates.test.js, tests/api/x402-pay-routing.test.js, tests/api/x402-spent-payments.test.js, tests/e2e/oauth-cloud-connector.spec.js, tests/eidon-imu-clip.test.js, tests/fixtures/mcp-golden-tools.json, tests/mcp-directory.test.js, tests/mcp-grok-accounts.test.js, tests/mcp-prompts.test.js, tests/mcp-remote-annotations.test.js, tests/mcp-studio-jobs.test.js, tests/mcp-use-cases-doc.test.js, tests/oauth-endpoints.test.js, tests/prepare-deploy-worktree.test.js, tests/pump-alert-eval.test.js, tests/real-funds-agreement-coverage.test.js, tests/route-build-inputs.test.js, tests/src/animation-canonical-support.test.js, tests/src/usdz-pipeline.test.js, tests/vanity-grinder-batch.test.js, tests/vaults-api-guards.test.js, tests/x-text-weight.test.js, tests/x402-ring-leak-scan-run.test.js, tests/zz-probe.test.js, vercel.json, vite.config.js, workers/agent-gateway/README.md, workers/avatar-pipeline-controller/worker_security.py, workers/avatar-reconstruction/worker_security.py, workers/garment-forge/worker_security.py, workers/longcat/worker_security.py, workers/model-hunyuan3d/worker_security.py, workers/model-text2motion/worker_security.py, workers/model-trellis/worker_security.py, workers/model-triposg/worker_security.py, workers/model-triposr/worker_security.py, workers/model-video2motion/worker_security.py, workers/model-video2scene/worker_security.py, workers/rembg/worker_security.py, workers/remesh/worker_security.py, workers/rig/worker_security.py, workers/segment/worker_security.py, workers/stylize/worker_security.py, workers/texture/worker_security.py
+
+## Close out (required)
+
+1. Verify every Definition of done line with command output in front of you.
+2. Commit the merge as one commit (step 7), the `x-mention-reply.js` fix as a separate topical commit, and the order-file/OWNER-ACTIONS updates as a third.
+3. If the merge fully lands, delete this file in the final commit (`git rm prompts/finish/404-auto-reconcile-evolve-main-divergence.md`) and append a dated entry to `prompts/finish/_context/production-100-PROGRESS.md` (or the campaign's own progress file) with the commit SHAs. If batch D left a remainder, leave this file in place with a status preamble describing exactly what remains, in the style of orders 060/061.
+4. Final report, in this order: step 0 measurements; per batch, what was resolved and how; any batch-D file left unresolved and why; test results; held hunks if any; one-line judgment calls. No trailing questions.
diff --git a/prompts/finish/_context/production-100-OWNER-ACTIONS.md b/prompts/finish/_context/production-100-OWNER-ACTIONS.md
index 03fe09bc5..b460ee0ce 100644
--- a/prompts/finish/_context/production-100-OWNER-ACTIONS.md
+++ b/prompts/finish/_context/production-100-OWNER-ACTIONS.md
@@ -9,7 +9,7 @@ it and, if that unblocks a work order, say which one in the owning pack's `produ
Rows carry the date they were added so staleness is visible. Re-verify a row before acting
on it; some resolve themselves as other work lands.
-## Open rows (2026-10-11 (even later): row 24 re-measured again after order 400's ring-leak-scan tiering/lock fix shipped on `evolve`; 2026-10-11 (later): row 35 added for the agent mention-policy migration; 2026-10-11 04:16 UTC: rows 1 and 24 re-measured by the deep triage sweep; row 34 added for the evolve/main branch divergence; 2026-10-10: row 33 added for the xAI MCP e2e key; rows 1, 19 and 24 re-measured by the triage sweep; 2026-10-09: rows 1, 2 and 24 re-measured by the triage sweep, row 31 added for the GPU worker redeploy and row 32 for database table retention; row 30 added for the Grok Bot CLI setup rerun; 2026-10-08: row 26 added for the coin-gated MCP catalog regeneration; rows 1 and 2 re-measured by the triage sweep, row 24 added for the paid Solana RPC credits, row 25 added for the MCP connector OAuth deploy; 2026-09-30: row 23 added for the $THREE receiver wallets; 2026-09-29: row 19 re-measured after the agent-sniper deploy; 2026-09-09: row 19 added, and row 1 corrected because its outage premise no longer holds; rows 1, 2, 3, 9, 13, 15 and 16 re-measured 2026-09-04; the former row 18 was cleared that day and its number is not reused; the 2026-09-02 and 2026-08-09 passes are folded in below)
+## Open rows (2026-10-11 (scout lane): row 36 added for the Cloudflare R2 flapping degraded/down pattern, and order 404 opened to reconcile the `evolve`/`main` divergence row 34 describes; 2026-10-11 (even later): row 24 re-measured again after order 400's ring-leak-scan tiering/lock fix shipped on `evolve`; 2026-10-11 (later): row 35 added for the agent mention-policy migration; 2026-10-11 04:16 UTC: rows 1 and 24 re-measured by the deep triage sweep; row 34 added for the evolve/main branch divergence; 2026-10-10: row 33 added for the xAI MCP e2e key; rows 1, 19 and 24 re-measured by the triage sweep; 2026-10-09: rows 1, 2 and 24 re-measured by the triage sweep, row 31 added for the GPU worker redeploy and row 32 for database table retention; row 30 added for the Grok Bot CLI setup rerun; 2026-10-08: row 26 added for the coin-gated MCP catalog regeneration; rows 1 and 2 re-measured by the triage sweep, row 24 added for the paid Solana RPC credits, row 25 added for the MCP connector OAuth deploy; 2026-09-30: row 23 added for the $THREE receiver wallets; 2026-09-29: row 19 re-measured after the agent-sniper deploy; 2026-09-09: row 19 added, and row 1 corrected because its outage premise no longer holds; rows 1, 2, 3, 9, 13, 15 and 16 re-measured 2026-09-04; the former row 18 was cleared that day and its number is not reused; the 2026-09-02 and 2026-08-09 passes are folded in below)
| # | Action | Size | Unblocks | Detail lives in |
|---|---|---|---|---|
@@ -47,6 +47,7 @@ on it; some resolve themselves as other work lands.
| 33 | **Create a production xAI API key so a Grok model's live MCP calls against three.ws can be proven** (added 2026-10-10 by the evolve loop, x-grok order 039, which already owns this exact gate as order 927: `prompts/finish/927-x-grok-46-owner-grok-api-key.md`). Step 0 re-derivation this session found no `GROK_API_KEY`/`XAI_API_KEY` anywhere: not in `process.env`, not in `.env`/`.env.local`, not on the `three-ws-api` Cloud Run service (`node scripts/read-service-env.mjs '^(GROK\|XAI)_API_KEY$' --names` returned nothing). `scripts/xai-mcp-e2e.mjs` (npm script `e2e:xai-mcp`) is built and verified end to end in dry-run mode: it matches xAI's current Responses API remote-MCP schema field for field and names this gate when no key is found. Create a key at console.x.ai, then either set it directly (`gcloud run services update three-ws-api --region us-central1 --update-env-vars GROK_API_KEY=<key>`) or hand it to order 927 to wire through Secret Manager; afterward `npm run e2e:xai-mcp` should exit 0 against production. | minutes, console only | Closes x-grok order 039's one remaining Definition of Done line, and order 927 | [_context/x-grok-PROGRESS.md](x-grok-PROGRESS.md), 2026-10-10 entry |
| 34 | **Decide how to reconcile the `evolve` worktree branch with `main`: it is 358 commits behind** (added 2026-10-11 by the evolve loop, while working x-grok order 050). `git log --oneline HEAD..main \| wc -l` from `/home/user/projects/.evolve-wt` on branch `evolve` returns 358: `main` shipped (among much else) x-grok orders 044, 046 to 052, and 055 to 058 (the `x-mention-poll.js` bot, its safety rails, budget controller, and the make/image3d/avatar handlers) while `evolve` has no record of any of it, because `evolve` never merged or rebased from `main` after it branched. `evolve` also carries 20+ of its own commits not on `main` yet (x-grok orders 038 to 040, 043, 045, 049, an accessibility fix, an a11y wire-up), so this is a real two-way divergence, not a simple fast-forward. The practical cost: this session spent real effort re-discovering and re-implementing order 050's mention-poll cron from scratch before noticing `main` already shipped a more complete version, and the same evidence shows orders 051, 052, 055, 056, 057 and 058's order files are stale duplicates sitting in `prompts/finish/` on `evolve` for the same reason (noted in [x-grok-PROGRESS.md](x-grok-PROGRESS.md), 2026-10-11 entry); every future evolve session that picks one up will repeat this exact waste until the branch is caught up. Merging or rebasing 358 commits safely is a judgment call about which side wins on any file both branches touched (this evolve worktree's own x-search/agent-brain/agent-gateway/gateway-adapter work overlaps the same `api/cron/[name].js` and `vercel.json` main also edited); that is not a mechanical fix an agent should attempt unattended. Decide the reconciliation approach (likely: rebase `evolve`'s unique commits onto current `main`, resolving the handful of shared-file conflicts by hand) and either do it or direct an agent to. **Re-measured 2026-10-11 while verifying order 051 against `main` from a throwaway detached worktree (removed after, nothing committed to `main`): `main`'s shipped `x-mention-reply.js` has a live bug that this reconciliation should fix in the same pass.** `composePublicReply`'s `chainFor()` builds its model chain from `agent-brain.js`/`agent-model.js` (`{name,url,key,model}` records meant for `copilot-engine.js`'s own round-trip reader), then hands that chain to `llmComplete` in `llm.js`, whose attempt loop calls `p.buildBody(...)`, a method only `llm.js`'s own, differently-shaped `providerChain()` objects define. Every attempt on every rung throws the same `TypeError` and the whole chain "exhausts" in milliseconds, always landing on the safe fixed fallback reply. Verified live with production's own `GROQ_API_KEY`/`OPENROUTER_API_KEY`/`NVIDIA_API_KEY` (`RUN_LLM_TESTS=1 npx vitest run tests/x-mention-reply.llm.test.js --reporter=verbose`): 16/16 "passed" (the test accepts a safe fallback as a pass) but all 16 fell back with `reason: 'llm_error', detail: '... p.buildBody is not a function'`, and the real `x_mention_events` table already carries 129 rows with `reason: 'fallback:llm_error'` from the live mention-poll cron, recorded before this was diagnosed. The public reply bot has likely never sent a single real model-composed reply to a stranger; it is safe (every post-check still holds) but has silently answered every public mention with the fixed help text only. Fix, once someone is on `main`: change `chainFor()` to build from `llm.js`'s own `providerChain({ grokKey, grokModel })` (resolving the agent's Grok key/model the way `agent-grok-key.js` already does) instead of `modelChain`/`resolveAgentBrain`, so the chain shape matches what `llmComplete` reads. Full writeup: [x-grok-PROGRESS.md](x-grok-PROGRESS.md), 2026-10-11 entry for order 051. **Re-measured again 2026-10-11 while working order 060 (agent mention replies): the gap is now 362 commits behind / 117 ahead, and order 060 cannot be built at all until this reconciles, because its entire prerequisite subsystem (`x-mention-poll.js` and its ~14-file import closure, orders 045-058) exists only on `main` and has no file to extend on `evolve`; left open with a dated status note rather than hand-copied or duplicated. Full writeup: [x-grok-PROGRESS.md](x-grok-PROGRESS.md), 2026-10-11 entry for order 060.** | decision, then a rebase (the `chainFor()` fix itself is a small, mechanical change once on `main`) | Stops repeat duplicate work across the whole x-grok campaign and any other area both branches touched, and fixes a currently-silent production defect in the public X reply bot | [x-grok-PROGRESS.md](x-grok-PROGRESS.md), 2026-10-11 entries |
| 35 | **Apply the agent mention-policy migration, then ship it with the next deploy** (added 2026-10-11 by the evolve loop, x-grok order 061, which is otherwise complete and retired). `api/_lib/migrations/20261011220000_agent_mention_policy.sql` adds `mention_replies_enabled`, `mention_replies_dry_run`, `mention_replies_daily_cap` and `mention_replies_allowed_intents` to `agent_x_policies`, the four fields the new "Answer mentions" panel on `pages/agent-edit.html` (Social tab) reads and writes. `npm run db:status` on 2026-10-11 lists it as the only pending migration. The read path (`GET /api/x/agents`) already works without it, since the query is `select *` and `rowToPolicy()` defaults the missing columns; only the write path breaks: `saveAgentPolicy`'s `INSERT` names the four columns explicitly, so a save attempt against the unmigrated table answers 500 with Postgres `42703 undefined_column`, verified live in a local run of the full UI against the real dev database on 2026-10-11 (every other state, no-connection/missing-scope/connected/populated-decisions, was verified working by temporarily granting `X_OAUTH_CLIENT_ID`/`SECRET` in `.env.local` only, never in production). Apply it with `node scripts/apply-migrations.mjs --apply --file 20261011220000_agent_mention_policy.sql`, or `npm run db:status` then `npm run db:migrate` (nothing else is pending as of this writing). `npm run db:check` blocks the next deploy on it until then. Separately, and not blocking this row: production has never set `X_OAUTH_CLIENT_ID`/`X_OAUTH_CLIENT_SECRET` at all (`node scripts/read-service-env.mjs '^X_OAUTH_CLIENT'` finds nothing), so the whole per-agent "connect this agent's own X account" flow (distinct from the company bot account's `X_API_KEY`/`X_ACCESS_TOKEN` posting credentials, which are set) answers "X connections are not enabled on this deployment" for every agent today; that is a pre-existing gap this order did not create and its settings UI already degrades to that state correctly. | one command | The "Answer mentions" save button in the agent settings UI | [x-grok-PROGRESS.md](x-grok-PROGRESS.md), 2026-10-11 entry for order 061 |
+| 36 | **Check Cloudflare R2's own status/dashboard for the bucket behind `S3_BUCKET`: it flaps between healthy and unreachable without any corresponding change on our side** (added 2026-10-11 by the evolve scout lane). Queried `ops_alerts` directly (columns: `signature, title, detail, severity, count, environment, first_seen, last_seen`): since 2026-09-08 the `object_storage` sensor (`api/_lib/ops/object-storage-health.js`) has logged roughly 167 "DEGRADED: Object storage (Cloudflare R2)" events (`bucket reachable but slow, signed list ~1095ms` against a 1000ms threshold) and about 18 "DOWN" events, interleaved with many "RESOLVED" events minutes apart showing a healthy 150 to 300ms. Reproduced live with production's own `S3_ACCESS_KEY_ID`/`S3_SECRET_ACCESS_KEY`/`S3_BUCKET`/`S3_ENDPOINT` (pulled via `node scripts/read-service-env.mjs` one variable at a time, used in-process, then deleted from disk immediately): `gatherObjectStorageHealth()` returned `{"status":"down","detail":"bucket unreachable: Please enable R2 through the Cloudflare Dashboard.","metrics":{"latencyMs":135,"credentialFault":false}}`, a 135ms response, i.e. the bucket answered fast but Cloudflare's own API told us R2 was not enabled, which cannot be true most of the time this account is clearly serving reads. Ruled out as a code cause: the credential is not rejected (`credentialFault:false`, no `SignatureDoesNotMatch`), and the AWS SDK's Node HTTP handler already defaults to keep-alive on (`keepAlive:true, maxSockets:50` in `@smithy/node-http-handler`), so this is not the classic missing-keep-alive latency bug. The probe itself is a single signed `ListObjectsV2Command` with no retry (`api/_lib/ops/object-storage-health.js:76-92`), so a genuinely transient one-off Cloudflare hiccup is indistinguishable from a sustained outage in this sensor today, which may be inflating the DOWN/DEGRADED counts above a one-retry version would show. Two independent things to do, neither owned by this reconciliation order: (a) check Cloudflare's own R2 dashboard/status page for the account behind `S3_BUCKET` for incidents correlated with the alert timestamps above (owner/dashboard access this agent does not have); (b) if the pattern looks like a true transient flap rather than sustained Cloudflare-side degradation, a future order could add one immediate retry before `gatherObjectStorageHealth()` classifies `down`/`degraded`, with a test proving a single synthetic failure followed by a synthetic success no longer pages. Not attempted here because the current evidence does not confidently distinguish "add a retry" from "mute a real recurring problem", and CLAUDE.md is explicit that a check does not get weakened without a dated, measured reason; this row exists so neither path gets silently skipped. | Cloudflare dashboard check (owner), then optionally a small, test-covered retry (agent) | Every avatar, thumbnail and generated GLB reads through this bucket; `/cdn/*` and the forge both degrade when it flaps | `ops_alerts` table, queried 2026-10-11 |
Deleted 2026-09-01: the former row 5 (`WALLET_ENCRYPTION_KEY_PREVIOUS` policy), which
declared itself "delete on reading" and had outlived that by three weeks.