Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
docs(wakeshift): name wakeshift-env-key.ts in the key-files entry
garrytanbd8fe0b6f32c
diff --git a/docs/architecture/key-files/wakeshift.md b/docs/architecture/key-files/wakeshift.mdindex 9176ffaf90..76514b6bbb 100644--- a/docs/architecture/key-files/wakeshift.md+++ b/docs/architecture/key-files/wakeshift.md@@ -3,4 +3,4 @@[Subsystem index](../KEY_FILES.md). Read only the entries relevant to your change.Current behavior and load-bearing invariants; history belongs in Git and CHANGELOG.-- `src/core/ops/wakeshift.ts` + `src/core/wakeshift/{client,config,events,drain}.ts` + `src/core/wakeshift-env-key.ts` + `src/commands/wakeshift.ts` + `src/commands/doctor/checks/wakeshift.ts` — report back to agent conversations through Wakeshift (docs/guides/wakeshift.md), off by default. `client.ts` is the in-repo HTTP client (no SDK): key parsing (`wst_` + 50 base58 with a CRC32; legacy formats refused), a fresh EdDSA `app+jwt` assertion per request, one `fetch` with a 10 s timeout and no retry, loopback-only http. `config.ts` holds the host-only state: `wakeshift.enabled`/`url` in the file plane, the key (WAKESHIFT_API_KEY, which `env-key.ts` moves out of the environment on every config load so children never inherit it, the first value seen winning; else a 0600 `~/.gbrain/wakeshift.key`), the 0600 HMAC secret and the opaque Wakeshift user (HMAC over brain and principal); `wakeshiftPublished` is publish gate `mcp.publish_wakeshift`, which `mcp/publish-gates.ts` resolves from the file plane and key presence only (never the DB plane; not in `PUBLISH_GATE_KEYS`). `watch_job` runs the get_job owner fence (exported from `ops/jobs.ts`), subscribes the conversation (`once`, 7 d), stores a `wake_subscriptions` row (migration v290), rolls the subscription back when the insert fails, and hands Wakeshift's addition to dispatch through `ctx.emitToolTail` (the result's last text block plus `_meta` keys); `ctx.mcpCaller` (client name, User-Agent, request `_meta`) is set by the stdio and both HTTP transports. `drain.ts` is pull reconciliation: `gbrain serve` and `MinionWorker.start` run a 5 s unref'd timer, `gbrain jobs work` (PGLite) a final pass; at most 20 leased rows a tick, the emit id `<event>:<target>:<finished_us>:<status>:<row>:<namespace>` (12 hex of the watch's user and creation time, so brains on one key never collide), the claim re-checking backoff and attempts, a settle only under the claim's lease, the principal re-checked before each emit, 5 attempts on 30 s/2 m/8 m/30 m (429 honours Retry-After, other 4xx final), dead/revoked/expired rows ended at Wakeshift once. The payload (`events.ts`) is a pointer: job id, kind, status, times, next call; never page text. The CLI (`enable` with consent, the owner-only member check, GET /app and the manifest merge; `disable`, `status`, `test`) is the only writer of the enabled flag. Tests: `test/wakeshift-client.test.ts`, `test/wakeshift.serial.test.ts` (repo-less PGLite against `test/helpers/fake-wakeshift.ts`), `test/e2e/wakeshift-postgres.test.ts`.+- `src/core/ops/wakeshift.ts` + `src/core/wakeshift/{client,config,events,drain}.ts` + `src/core/wakeshift-env-key.ts` + `src/commands/wakeshift.ts` + `src/commands/doctor/checks/wakeshift.ts` — report back to agent conversations through Wakeshift (docs/guides/wakeshift.md), off by default. `client.ts` is the in-repo HTTP client (no SDK): key parsing (`wst_` + 50 base58 with a CRC32; legacy formats refused), a fresh EdDSA `app+jwt` assertion per request, one `fetch` with a 10 s timeout and no retry, loopback-only http. `config.ts` holds the host-only state: `wakeshift.enabled`/`url` in the file plane, the key (WAKESHIFT_API_KEY, which `wakeshift-env-key.ts` moves out of the environment on every config load so children never inherit it, the first value seen winning; else a 0600 `~/.gbrain/wakeshift.key`), the 0600 HMAC secret and the opaque Wakeshift user (HMAC over brain and principal); `wakeshiftPublished` is publish gate `mcp.publish_wakeshift`, which `mcp/publish-gates.ts` resolves from the file plane and key presence only (never the DB plane; not in `PUBLISH_GATE_KEYS`). `watch_job` runs the get_job owner fence (exported from `ops/jobs.ts`), subscribes the conversation (`once`, 7 d), stores a `wake_subscriptions` row (migration v290), rolls the subscription back when the insert fails, and hands Wakeshift's addition to dispatch through `ctx.emitToolTail` (the result's last text block plus `_meta` keys); `ctx.mcpCaller` (client name, User-Agent, request `_meta`) is set by the stdio and both HTTP transports. `drain.ts` is pull reconciliation: `gbrain serve` and `MinionWorker.start` run a 5 s unref'd timer, `gbrain jobs work` (PGLite) a final pass; at most 20 leased rows a tick, the emit id `<event>:<target>:<finished_us>:<status>:<row>:<namespace>` (12 hex of the watch's user and creation time, so brains on one key never collide), the claim re-checking backoff and attempts, a settle only under the claim's lease, the principal re-checked before each emit, 5 attempts on 30 s/2 m/8 m/30 m (429 honours Retry-After, other 4xx final), dead/revoked/expired rows ended at Wakeshift once. The payload (`events.ts`) is a pointer: job id, kind, status, times, next call; never page text. The CLI (`enable` with consent, the owner-only member check, GET /app and the manifest merge; `disable`, `status`, `test`) is the only writer of the enabled flag. Tests: `test/wakeshift-client.test.ts`, `test/wakeshift.serial.test.ts` (repo-less PGLite against `test/helpers/fake-wakeshift.ts`), `test/e2e/wakeshift-postgres.test.ts`.