Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(bootstrap): render the due-job list as SCHEDULES.md in OpenClaw workspaces (#7470)
garrytanbafd25d5d7be
diff --git a/INSTALL_FOR_AGENTS.md b/INSTALL_FOR_AGENTS.mdindex ed160199f3..b02fc77208 100644--- a/INSTALL_FOR_AGENTS.md+++ b/INSTALL_FOR_AGENTS.md@@ -553,16 +553,21 @@ Read skills/soul-audit/SKILL.md and follow it.This generates SOUL.md (agent identity), USER.md (user profile), ACCESS_POLICY.md(who sees what), and HEARTBEAT.md (operational cadence) from the user's answers.-**On OpenClaw 2026.10.6 and later,** `openclaw doctor --fix` imports a-workspace `HEARTBEAT.md` into its own monitor, archives the file under the-state directory's `backups/heartbeat-migration/` and removes it, while the-rendered `AGENTS.md` still tells the agent to read it at session start. Until-the render adapts to OpenClaw ([#7470](https://github.com/garrytan/gbrain/issues/7470)),-put gbrain's file back after each doctor fix: `gbrain bootstrap render --only HEARTBEAT.md`-re-renders it from the confirmed answers, or copy the archived file back when-the user edited it. Jobs that must run on time belong in the host scheduler-through the [one wrapper](docs/guides/cron-schedule.md#calling-gbrain-unattended),-not only in `HEARTBEAT.md`, which runs only when a session starts.+**On OpenClaw,** the due-job list renders as `SCHEDULES.md` instead, and the+rendered `AGENTS.md` points there. OpenClaw 2026.10.6 retired its own+`HEARTBEAT.md`: `openclaw doctor --fix` imports a workspace file by that name+into its heartbeat monitor, archives it under the state directory's+`backups/heartbeat-migration/` and removes it. Render detects an OpenClaw+workspace (`OPENCLAW_WORKSPACE_DIR`, `OPENCLAW_WORKSPACE`, or a `workspace`+tree under `OPENCLAW_STATE_DIR`, `~/.openclaw` or `~/.openclaw-<profile>`);+for a workspace OpenClaw finds only through its config, pass `--host openclaw`.+A workspace rendered before this change still has the old references: re-render+both files with `gbrain bootstrap render --only AGENTS.md,HEARTBEAT.md --force`+(the old copies are backed up first; carry over any hand edits, and copy the+doctor's archived `HEARTBEAT.md` when the user edited the job list). Jobs that+must run on time belong in the host scheduler through the+[one wrapper](docs/guides/cron-schedule.md#calling-gbrain-unattended), not+only in the due-job list, which runs only when a session starts.If skipped, minimal defaults are installed automatically.diff --git a/docs/architecture/key-files/agent-bootstrap.md b/docs/architecture/key-files/agent-bootstrap.mdindex c09264c5d8..304db29db4 100644--- a/docs/architecture/key-files/agent-bootstrap.md+++ b/docs/architecture/key-files/agent-bootstrap.md@@ -13,7 +13,7 @@ User-facing contract: `docs/guides/bootstrap.md`. Runbook the paste block fetche- `src/core/bootstrap/assets.ts` — every template + the question bank embedded via Bun `with { type: 'file' }` imports (the chunkers/code.ts pattern) so the compiled binary renders with no repo checkout; `DERIVED_TOKENS` (GITHUB_REPO_URL, CORPUS_RETENTION_DAYS) is the non-bank half of the template token set the CI bijection guard checks.- `templates/bootstrap/` — the ten `{{TOKEN}}` identity templates (AGENTS/CLAUDE/SOUL/USER/MEMORY/HEARTBEAT/ACCESS_POLICY/GITHUB/memory-README/gitignore), `questions.json` (12 asked / 6 required; consent keys; `persist:false` sink keys), and `template-repo/` — the VENDORED deterministic render the release job diffs against before publishing the public template repo. Generic placeholder content only (privacy iron rule; CI-asserted).- `src/core/bootstrap/interview.ts` — interview state at `<ws>/state/interview.json` (committed; multi-device re-render source). Read-back confirm hash: `--confirm` must present the hash of the exact answer set shown to the human, and ANY later answer change clears the confirmation — the single-batch self-confirm attack is structurally impossible. Set-time enforcement: length caps, reject-lists, allowed-lists, control-char strip, `{{` escaping. Conflict-markered files return agent-readable errors, not stack traces.-- `src/core/bootstrap/render.ts` — token substitution with interview values treated as data (line-leading `#`/`<!--`/fence escaping), hard-fail on unresolved tokens, never-clobber + timestamped backups on `--force`, blank-line collapse, byte floors scaled to answered count. `--minimal` is the deterministic placeholder mode the template-repo generator uses (byte-identical across runs; leaves required tokens as literal fill-me markers; writes `initialized:false`). `--only` never writes agent.json.+- `src/core/bootstrap/render.ts` — token substitution with interview values treated as data (line-leading `#`/`<!--`/fence escaping), hard-fail on unresolved tokens, never-clobber + timestamped backups on `--force`, blank-line collapse, byte floors scaled to answered count. `--minimal` is the deterministic placeholder mode the template-repo generator uses (byte-identical across runs; leaves required tokens as literal fill-me markers; writes `initialized:false`). `--only` never writes agent.json. A template's `openclawDest` replaces its dest when `host: 'openclaw'` (the dispatcher's `--host openclaw`, or `detectOpenClawWorkspace`): HEARTBEAT.md renders as SCHEDULES.md, because OpenClaw 2026.10.6+ doctor removes a workspace HEARTBEAT.md, and the derived `SCHEDULES_FILE` token keeps AGENTS.md pointing at the file that was written (#7470; `test/bootstrap-render.test.ts`).- `src/core/bootstrap/lock.ts` — the bootstrap-run mutex (atomic mkdir + pid liveness + age guard + ownership token; steal requires dead pid AND stale age) and the family's shared typed `BootstrapError` (GH_MISSING/GH_AUTH carry exit 2 = human action needed).- `src/core/bootstrap/repo.ts` / `attach.ts` / `uninstall.ts` — private-repo lifecycle. `createPrivateRepo`: gh gates, slugified name probe, `gh repo create --private --source --push`, privacy verified via `gh api .private` (rate-limit/5xx is VERIFY_UNAVAILABLE, distinct from not-private) before any push, idempotency keyed off the remote URL. A pre-existing origin is adopted (disposition 'adopted') when the authed gh user owns it, there's no recorded `repo_url`, and it is SAFE — empty or already carrying our history (`assertAdoptableOrigin`; a foreign-content repo is refused `ORIGIN_NOT_EMPTY`, never a silent no-op); this is the create-repo-first path. Org-owned origins and anything else are refused and pointed at attach. Repo-local git identity is set in both create and adopt paths before commit; `repo_url` is recorded only after a successful push. `attachWorkspace` (machine two): requires an `initialized` manifest, writes this machine's receipt, returns structured wiring steps. `uninstallWorkspace`: receipt-keyed, refuses under a live serve (read-only lock probe — never opens the engine), removes exactly receipt-recorded paths + marker-keyed host entries, keeps the brain unless `--delete-brain` AND bootstrap created it; never wholesale-deletes the gbrain home. All gh/git through an injectable ExecRunner seam.- `src/core/bootstrap/hooks.ts` + `host-specs.ts` — host wiring. `host-specs.ts` is the ONE module owning host-format assumptions (dated spec targets with verifiedAt + doc references: claude-code hooks/settings shapes incl. the 10,000-char hook-output cap and the five hook events; codex mcp-add argv, the streamable-HTTP `url` + `http_headers = { Authorization = "Bearer <t>" }` config shape (loads on codex-cli 0.147.x and 0.149.x; inline `bearer_token` is rejected at config load by >=0.149), `codexConfigPath()` honoring CODEX_HOME, `claudeUserSettingsPath()` honoring CLAUDE_CONFIG_DIR/$HOME explicitly — Bun's homedir() ignores a remapped HOME, which would point sandboxed writers at the operator's real settings; the shared resolution lives in the private `claudeConfigBase()` (CLAUDE_CONFIG_DIR-else-$HOME-else-homedir(), the directory playing the role of `~/.claude` — NOT for `claudeUserMcpConfigPath`, whose default lives at the HOME level as `~/.claude.json`), which also feeds `claudeUserSkillsDir()`/`claudeProjectSkillsDir()` (native SKILL.md discovery, the harness-bridge install targets; user scope attested, project scope provisional-from-docs) — and the opencode shapes: `opencodeConfigDir`/`opencodeGlobalConfigPath` (XDG-only resolution; the `.jsonc` name preferred for parity with `opencode mcp add`; OPENCODE_CONFIG/_CONFIG_DIR/_CONFIG_CONTENT deliberately NOT honored — observed INERT in opencode 1.18.18, honoring them would write registrations into a file opencode never reads), `opencodeProjectConfigPath`, `opencodeGlobalSiblingPath` (the OTHER member of the global filename pair — writers reconcile `mcp.<name>` across it because opencode merges both), and `OPENCODE_HAS_HOOKS=false` — 'gbrain does not wire opencode's plugin/event system yet', not 'opencode has no hooks'). The settings writers are path+marker parameterized: `writeClaudeHooksAt`/`removeClaudeHooksAt` take an explicit settings file and a marker VALUE (workspace installs stamp `bootstrap-v1` in `.claude/settings.local.json`; harness installs stamp `bootstrap-harness-v1` in user-scope settings or a --project dir — the two coexist and each removal strips only its own; `refuseOnForeignGbrainMarker` blocks same-file double-wiring), fail-closed on broken JSON (a settings file that doesn't parse THROWS with the path — a writer must never relocate or overwrite a config it can't read), mode-preserving realpath-resolved atomic writes (dotfile symlinks survive), and fixed-or-timestamped backups. `addPermissionsAllowEntry`/`removePermissionsAllowEntry` manage the harness lane's `mcp__<name>` headless pre-approval with set semantics and NO marker (ownership rides the harness receipt; foreign entries always survive); the add path fails CLOSED when an existing `permissions` key or `permissions.allow` carries a shape it doesn't understand (host security policy is never rewritten on a guess), while removal leaves shapes it can't read untouched and reports nothing-to-remove. `registerClaudeMcp`/`registerCodexMcp` build argv only (Claude Code takes `--scope`, project default; Codex has no scope flag — `codex mcp add` is always user-global; `-e`/`--env GBRAIN_SOURCE` so MCP writes land in the workspace source, and the serve argv from `stdioServeArgv` in `src/core/mcp-registration.ts`: `--surface starter` by default so a pre-existing `mcp_surface: verbs` config row can't narrow the registration, or the `surface` the caller passes — `bootstrap hooks --surface`, or an existing entry's form carried over on replacement, `null` meaning a bare `serve`). `bootstrap hooks` never narrows: a matching registration is kept, `verifyMcpTargetsWorkspace` returns the existing entry's surface (`registeredSurface`) and the mismatch re-add keeps it, and the opencode writer keeps the existing command's form unless `--surface` is given. The opencode workspace lane execs NOTHING — registration is the direct `opencode-json.ts` write with an INVERTED scope default (user-global; opencode spawns project-config servers with no trust prompt, so `MCP_SCOPE=project` is an explicit opt-in that writes the committed-candidate `opencode.json` with a PATH-resolved command and prints the sharing warning), verification is config parse-back + a best-effort `opencode mcp list --pure` probe — the probe spawns via a held Bun.spawn handle from a fresh EMPTY temp-dir cwd (never the invoking cwd: opencode merges a project opencode.json from cwd and spawns its servers with no trust prompt), is SKIPPED entirely for project scope (printed note; parse-back is authoritative) and on plugin-bearing configs (`mcp list` is a code-execution surface), and on timeout actually kills the child (SIGTERM → SIGKILL, bounded pipe drain, code 124 into the could-not-confirm branch; `probeSpawn` is the injectable seam). User-scope writes also reconcile the SIBLING global filename first (ours → removed with a note; foreign → refuse naming both files) so a merge-shadow registration can never survive. `detectHarness` probes `OPENCODE`/`OPENCODE_PID` (set in opencode's bash-tool children, observed 1.18.18). `ClaudeHookEnv.GBRAIN_SEAT` (#4618) renders `GBRAIN_SEAT=<label>` into local-carrier hook commands (never the committed carrier); `writeClaudeHooksAt` keeps the seat a prior install of the same marker rendered when the caller passes none, and `''` clears it. `parseSeatFlags` validates `--seat <label>` / `--no-seat` for `bootstrap hooks` and `bootstrap harness` and returns a `note` where a seat cannot be rendered (codex, opencode, the cloud committed carrier). Pinned by `test/bootstrap-seat.serial.test.ts`. Harness-lane hook ownership does not rest on the marker alone: Claude Code can drop unknown keys when it rewrites settings.json, so `parseClaudeHookCommand` (the inverse of `buildClaudeHookCommand`: shellQuote-aware word split, env keys limited to the four the builder writes, each at most once, an absolute launcher, nothing after `hook <sub>`, and a re-render that must equal the input) feeds `classifyHarnessHook(entry, event, identity)` → `marked` / `command` (unmarked, exactly the harness hook for THAT event, launcher/source/seat inside a `HarnessHookIdentity`, no GBRAIN_HOME) / `unowned` (harness-looking under a wired event but edited or another install's; never deleted) / null. `harnessHookIdentity(receipt, target, current)` merges the running install with the receipt's recorded `launcher`/`seat` and source binding (seats constrain only when recorded). `writeClaudeHooksAt({identity})` replaces owned unmarked entries like marked ones (one entry per event on re-run, seat carried from marked then owned entries) and notes `harness_hook_unowned` lookalikes; `removeClaudeHooksAt(path, marker, {identity, dryRun})` returns `unmarked` (event + why, never command text) and `unowned` events; `scanHarnessHookCarrier` is the read-only per-event census (doctor, `--status`, the cross-HOME guard with identity `'any'`); `groupsCarryGbrainHook` feeds `hook_carrier_overlap`. The workspace lane (bootstrap-v1) keys on the marker alone. Pinned by `test/bootstrap-harness-hook-ownership.test.ts`. `hookEntryHash` (sha256 over `type`, `command`, `timeout`; the marker excluded, so a dropped marker keeps the hash) backs the opt-in `ownedEntryHashes` option on both writers: with it a marker match alone never replaces or removes an entry, edited marked entries come back in `preserved`, and unmarked entries with an owned hash are still ours (`gbrain setup`); without it every existing caller keeps marker-keyed ownership.diff --git a/llms-full.txt b/llms-full.txtindex 378bf168c1..8a841958bc 100644--- a/llms-full.txt+++ b/llms-full.txt@@ -3205,16 +3205,21 @@ Read skills/soul-audit/SKILL.md and follow it.This generates SOUL.md (agent identity), USER.md (user profile), ACCESS_POLICY.md(who sees what), and HEARTBEAT.md (operational cadence) from the user's answers.-**On OpenClaw 2026.10.6 and later,** `openclaw doctor --fix` imports a-workspace `HEARTBEAT.md` into its own monitor, archives the file under the-state directory's `backups/heartbeat-migration/` and removes it, while the-rendered `AGENTS.md` still tells the agent to read it at session start. Until-the render adapts to OpenClaw ([#7470](https://github.com/garrytan/gbrain/issues/7470)),-put gbrain's file back after each doctor fix: `gbrain bootstrap render --only HEARTBEAT.md`-re-renders it from the confirmed answers, or copy the archived file back when-the user edited it. Jobs that must run on time belong in the host scheduler-through the [one wrapper](docs/guides/cron-schedule.md#calling-gbrain-unattended),-not only in `HEARTBEAT.md`, which runs only when a session starts.+**On OpenClaw,** the due-job list renders as `SCHEDULES.md` instead, and the+rendered `AGENTS.md` points there. OpenClaw 2026.10.6 retired its own+`HEARTBEAT.md`: `openclaw doctor --fix` imports a workspace file by that name+into its heartbeat monitor, archives it under the state directory's+`backups/heartbeat-migration/` and removes it. Render detects an OpenClaw+workspace (`OPENCLAW_WORKSPACE_DIR`, `OPENCLAW_WORKSPACE`, or a `workspace`+tree under `OPENCLAW_STATE_DIR`, `~/.openclaw` or `~/.openclaw-<profile>`);+for a workspace OpenClaw finds only through its config, pass `--host openclaw`.+A workspace rendered before this change still has the old references: re-render+both files with `gbrain bootstrap render --only AGENTS.md,HEARTBEAT.md --force`+(the old copies are backed up first; carry over any hand edits, and copy the+doctor's archived `HEARTBEAT.md` when the user edited the job list). Jobs that+must run on time belong in the host scheduler through the+[one wrapper](docs/guides/cron-schedule.md#calling-gbrain-unattended), not+only in the due-job list, which runs only when a session starts.If skipped, minimal defaults are installed automatically.diff --git a/plugin/skills/soul-audit/SKILL.md b/plugin/skills/soul-audit/SKILL.mdindex a8cbd267e2..68277be3b4 100644--- a/plugin/skills/soul-audit/SKILL.md+++ b/plugin/skills/soul-audit/SKILL.md@@ -63,7 +63,10 @@ gbrain bootstrap render --only SOUL.md --force```Render targets: `SOUL.md`, `USER.md`, `ACCESS_POLICY.md`, `HEARTBEAT.md`,-`AGENTS.md` (re-render whichever files the changed keys feed).+`AGENTS.md` (re-render whichever files the changed keys feed). In an OpenClaw+workspace the `HEARTBEAT.md` target writes `SCHEDULES.md`, because OpenClaw+2026.10.6+ removes a workspace `HEARTBEAT.md`; render detects the workspace,+or pass `--host openclaw`.## Phases (each independent, each re-runnable)@@ -101,7 +104,8 @@ ACCESS_POLICY.md.### Phase 6: Operational CadenceAsk: "How often should the agent check in? Morning briefing? End of day summary?What recurring jobs do you want?"-Keys: `HEARTBEAT_CADENCE`, `QUIET_HOURS`. Renders: HEARTBEAT.md. Jobs ship+Keys: `HEARTBEAT_CADENCE`, `QUIET_HOURS`. Renders: HEARTBEAT.md (SCHEDULES.md on+OpenClaw). Jobs shipdisabled — enable one at a time after a manual dry run (the ritual is in therendered file).diff --git a/scripts/structural-suites.tsv b/scripts/structural-suites.tsvindex 37aa0b1cf7..1c92c8c03f 100644--- a/scripts/structural-suites.tsv+++ b/scripts/structural-suites.tsv@@ -38,6 +38,7 @@ test/book-mirror.test.ts gbrain book-mirror — source file invariants 2 readFiltest/bootstrap-codex-door.test.ts Codex door — rendered AGENTS.md pull protocol (Gate 3) 2 readFileSynctest/bootstrap-contract.test.ts bootstrap same-turn write-back contract 6 readFileSynctest/bootstrap-opencode-door.serial.test.ts opencode door — rendered AGENTS.md pull protocol 1 readFileSync+test/bootstrap-render.test.ts renderWorkspace — OpenClaw host keeps its schedule list out of HEARTBEAT.md (#7470) 5 readFileSynctest/bootstrap-shared-skills.test.ts (file-level) 19 readFileSynctest/brain-durability-hook.serial.test.ts #4682 — push-lock timeout is fail-loud for the helper only 1 readFileSynctest/brain-durability-hook.serial.test.ts brain-commit-push.sh (D13 guarantee) 4 readFileSyncdiff --git a/skills/skills.lock.json b/skills/skills.lock.jsonindex 237b9054c5..39061c6a08 100644--- a/skills/skills.lock.json+++ b/skills/skills.lock.json@@ -224,7 +224,7 @@"skillpack-harvest/SKILL.md": "0f86314b58d25b5511809f567c04aedc3fba6fe35ed642ac52d8216ae365b6eb","skillpack-harvest/routing-eval.jsonl": "cb4783288e95af3132b32ecb40a54cffc095f57b36240f96a25c2d2adf5e68c6","smoke-test/SKILL.md": "f5099e1d2ab9dc6827096249e68414f7ae357c29b39fb069a54bb7fb74f414a5",- "soul-audit/SKILL.md": "5a1d17b3190f75e85c6a8e4afe696a0ae8a3116bb60ad36ca2e350f1598b53d7",+ "soul-audit/SKILL.md": "7a48e180849f7502d332878c443397f90a3756f45caa94f76bcfcc7c997469c8","strategic-reading/SKILL.md": "ab2cd3adc79289374cfbc5cb3d5ee17f962fd8f7f3c997a1da708da0ed67797c","strategic-reading/routing-eval.jsonl": "eb0fc239c93aac53cf7d856190967bb65eaf970b4fe8bd0aad1c87495fbb8ccd","testing/SKILL.md": "c69fe3456aa981bbcfe06c7633042eabf68617c69e9c26c00e47a0848fd90fb3",diff --git a/skills/soul-audit/SKILL.md b/skills/soul-audit/SKILL.mdindex da3a86f5b0..7ad9619d6c 100644--- a/skills/soul-audit/SKILL.md+++ b/skills/soul-audit/SKILL.md@@ -62,7 +62,10 @@ gbrain bootstrap render --only SOUL.md --force```Render targets: `SOUL.md`, `USER.md`, `ACCESS_POLICY.md`, `HEARTBEAT.md`,-`AGENTS.md` (re-render whichever files the changed keys feed).+`AGENTS.md` (re-render whichever files the changed keys feed). In an OpenClaw+workspace the `HEARTBEAT.md` target writes `SCHEDULES.md`, because OpenClaw+2026.10.6+ removes a workspace `HEARTBEAT.md`; render detects the workspace,+or pass `--host openclaw`.## Phases (each independent, each re-runnable)@@ -100,7 +103,8 @@ ACCESS_POLICY.md.### Phase 6: Operational CadenceAsk: "How often should the agent check in? Morning briefing? End of day summary?What recurring jobs do you want?"-Keys: `HEARTBEAT_CADENCE`, `QUIET_HOURS`. Renders: HEARTBEAT.md. Jobs ship+Keys: `HEARTBEAT_CADENCE`, `QUIET_HOURS`. Renders: HEARTBEAT.md (SCHEDULES.md on+OpenClaw). Jobs shipdisabled — enable one at a time after a manual dry run (the ritual is in therendered file).diff --git a/src/commands/bootstrap.ts b/src/commands/bootstrap.tsindex bafff61013..425b8ff223 100644--- a/src/commands/bootstrap.ts+++ b/src/commands/bootstrap.ts@@ -50,7 +50,7 @@ import {readInterviewState,routeProviderKeyToConfig,} from '../core/bootstrap/interview.ts';-import { renderWorkspace, BootstrapRenderError } from '../core/bootstrap/render.ts';+import { renderWorkspace, BootstrapRenderError, detectOpenClawWorkspace } from '../core/bootstrap/render.ts';import { acquireBootstrapLock, BootstrapError } from '../core/bootstrap/lock.ts';import { createPrivateRepo, defaultRunner, type ExecRunner, type RepoReceipt } from '../core/bootstrap/repo.ts';import { attachWorkspace } from '../core/bootstrap/attach.ts';@@ -123,9 +123,11 @@ Subcommands (run \`gbrain bootstrap status\` first — it is the resume entrypoi--status Gate: exits nonzero until required answers exist.--show Read-back payload (all answers + confirm hash).--confirm <hash> Record the human's confirmation of the read-back.- render [--force] [--only F] [--minimal]+ render [--force] [--only F] [--minimal] [--host openclaw|generic]Render identity files from the confirmed answers.- Never clobbers; --force backs up first.+ Never clobbers; --force backs up first. In an+ OpenClaw workspace (detected, or --host openclaw)+ the due-job list renders as SCHEDULES.md.contract [--repair] Audit the same-turn GBrain write-back contract.--repair appends it additively and backs up AGENTS.md.hooks [--harness claude-code|codex|opencode] [--repair] [--no-hooks] [--gbrain-bin <path>]@@ -888,6 +890,12 @@ async function runRender(ws: string, rest: string[], home: string): Promise<numbconst force = rest.includes('--force');const minimal = rest.includes('--minimal');const only = flagValues(rest, '--only');+ const hostFlag = flagValue(rest, '--host');+ if (hostFlag !== undefined && hostFlag !== 'openclaw' && hostFlag !== 'generic') {+ console.error(`unknown --host '${hostFlag}' — pass --host openclaw or --host generic`);+ return 2;+ }+ const host = hostFlag === 'openclaw' || (hostFlag === undefined && !minimal && detectOpenClawWorkspace(ws)) ? 'openclaw' : undefined;// Public-origin gate [FIX6]: identity files (SOUL.md/USER.md/…) must NEVER// land in a public repo. `bootstrap status` enforces this for the template@@ -964,11 +972,19 @@ async function runRender(ws: string, rest: string[], home: string): Promise<numbminimal,derived,createdBy: `gbrain@${VERSION}`,+ ...(host ? { host } : {}),});if (only.length === 0 && !minimal) writeRenderReceipt(home, ws);abortIfInjected('render');+ if (host) {+ console.log(+ 'OpenClaw workspace: the due-job list renders as SCHEDULES.md, and AGENTS.md points there. OpenClaw 2026.10.6+ ' ++ 'retired HEARTBEAT.md, and its doctor migration imports and removes any workspace file by that name. ' ++ 'Pass --host generic to keep HEARTBEAT.md.',+ );+ }console.log(`rendered: ${res.written.join(', ') || '(nothing new)'}`);if (res.skipped.length > 0) console.log(`kept (already present — use --force to overwrite): ${res.skipped.join(', ')}`);if (res.backups.length > 0) console.log(`backups: ${res.backups.join(', ')}`);diff --git a/src/core/bootstrap/assets.ts b/src/core/bootstrap/assets.tsindex f5afe26f2d..495dff30e3 100644--- a/src/core/bootstrap/assets.ts+++ b/src/core/bootstrap/assets.ts@@ -47,6 +47,10 @@ export interface BootstrapTemplate {dest: string;/** Group for `render --only`. */group: 'identity' | 'contract' | 'scaffold';+ /** Destination in an OpenClaw workspace, when it differs: OpenClaw+ * 2026.10.6+ retired its own HEARTBEAT.md and `openclaw doctor --fix`+ * imports and removes any workspace file by that name (#7470). */+ openclawDest?: string;}/** The cloud environment setup script [D16] — NOT a rendered template (it is@@ -63,7 +67,7 @@ export const BOOTSTRAP_TEMPLATES: BootstrapTemplate[] = [{ assetPath: T_SOUL as unknown as string, dest: 'SOUL.md', group: 'identity' },{ assetPath: T_USER as unknown as string, dest: 'USER.md', group: 'identity' },{ assetPath: T_MEMORY as unknown as string, dest: 'MEMORY.md', group: 'identity' },- { assetPath: T_HEARTBEAT as unknown as string, dest: 'HEARTBEAT.md', group: 'contract' },+ { assetPath: T_HEARTBEAT as unknown as string, dest: 'HEARTBEAT.md', group: 'contract', openclawDest: 'SCHEDULES.md' },{ assetPath: T_ACCESS as unknown as string, dest: 'ACCESS_POLICY.md', group: 'contract' },{ assetPath: T_GITHUB as unknown as string, dest: 'GITHUB.md', group: 'contract' },{ assetPath: T_MEMORY_README as unknown as string, dest: 'memory/README.md', group: 'scaffold' },@@ -90,6 +94,9 @@ export const DERIVED_TOKENS = ['GITHUB_REPO_URL',/** From config `dream.synthesize.corpus_retention_days` (default 30). */'CORPUS_RETENTION_DAYS',+ /** The rendered name of the due-job list: HEARTBEAT.md, or its+ * `openclawDest` when rendering for OpenClaw. */+ 'SCHEDULES_FILE',] as const;export interface QuestionSpec {diff --git a/src/core/bootstrap/render.ts b/src/core/bootstrap/render.tsindex abd53465c4..3e4be6d9be 100644--- a/src/core/bootstrap/render.ts+++ b/src/core/bootstrap/render.ts@@ -39,7 +39,8 @@*/import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';-import { dirname, join } from 'node:path';+import { homedir } from 'node:os';+import { dirname, join, relative, resolve, sep } from 'node:path';import { BOOTSTRAP_TEMPLATES, DERIVED_TOKENS, GITHUB_URL_PLACEHOLDER, loadQuestionBank, readTemplate } from './assets.ts';import {@@ -101,6 +102,10 @@ export interface RenderOptions {/** Recorded as agent.json `source_id`. When unset, an existing initialized* manifest's source_id is preserved; otherwise defaults to 'workspace'. */sourceId?: string;+ /** The harness the workspace belongs to. 'openclaw' writes each template's+ * `openclawDest` instead of its dest (HEARTBEAT.md → SCHEDULES.md, #7470).+ * Ignored in minimal mode (determinism). */+ host?: 'openclaw';}export interface RenderResult {@@ -114,6 +119,7 @@ export interface RenderResult {export const DERIVED_DEFAULTS: Record<(typeof DERIVED_TOKENS)[number], string> = {GITHUB_REPO_URL: GITHUB_URL_PLACEHOLDER,CORPUS_RETENTION_DAYS: '30',+ SCHEDULES_FILE: 'HEARTBEAT.md',};const TOKEN_RE = /\{\{([A-Z0-9_]+)\}\}/g;@@ -125,7 +131,33 @@ const TOKEN_RE = /\{\{([A-Z0-9_]+)\}\}/g;/** [ENG-10] The only paths the renderer may ever write, relative to the* workspace root. Skillpack scaffolds, skills/, and anything else are out. */export function isBootstrapRenderDest(relPath: string): boolean {- return BOOTSTRAP_TEMPLATES.some((t) => t.dest === relPath);+ return BOOTSTRAP_TEMPLATES.some((t) => t.dest === relPath || t.openclawDest === relPath);+}++/**+ * Whether a workspace belongs to OpenClaw, from OpenClaw's own layout: the+ * configured workspace (OPENCLAW_WORKSPACE_DIR, or gbrain's OPENCLAW_WORKSPACE),+ * or a `workspace` tree under the state directory (OPENCLAW_STATE_DIR,+ * ~/.openclaw, or a profile's ~/.openclaw-<profile>). A workspace elsewhere+ * that OpenClaw was pointed at by config alone needs `render --host openclaw`.+ */+export function detectOpenClawWorkspace(+ workspaceDir: string,+ env: Record<string, string | undefined> = process.env,+ home: string = homedir(),+): boolean {+ const ws = resolve(workspaceDir);+ for (const configured of [env.OPENCLAW_WORKSPACE_DIR, env.OPENCLAW_WORKSPACE]) {+ if (configured && resolve(configured) === ws) return true;+ }+ const underWorkspaceOf = (stateDir: string): boolean => {+ const rel = relative(resolve(stateDir), ws);+ const first = rel.split(sep)[0] ?? '';+ return rel !== '' && !rel.startsWith('..') && /^workspace(-.+)?$/.test(first);+ };+ if (env.OPENCLAW_STATE_DIR && underWorkspaceOf(env.OPENCLAW_STATE_DIR)) return true;+ const profile = relative(resolve(home), ws).split(sep)[0] ?? '';+ return /^\.openclaw(-.+)?$/.test(profile) && underWorkspaceOf(join(home, profile));}/**@@ -187,7 +219,11 @@ function buildResolver(opts: RenderOptions, state: InterviewState | null): (tokeconst canonical = DERIVED_DEFAULTS[token as (typeof DERIVED_TOKENS)[number]];if (minimal) return { kind: 'value', value: canonical };const supplied = opts.derived?.[token];- return { kind: 'value', value: supplied !== undefined ? supplied : canonical };+ if (supplied !== undefined) return { kind: 'value', value: supplied };+ if (token === 'SCHEDULES_FILE' && opts.host === 'openclaw') {+ return { kind: 'value', value: BOOTSTRAP_TEMPLATES.find((t) => t.dest === canonical)!.openclawDest! };+ }+ return { kind: 'value', value: canonical };}const spec = bank.questions[token];if (!spec) return { kind: 'unresolved' };@@ -227,9 +263,13 @@ export function renderWorkspace(workspaceDir: string, opts: RenderOptions = {}):}// Validate --only against the known dest list (typo protection).- const selected = BOOTSTRAP_TEMPLATES.filter((t) => !opts.only || opts.only.includes(t.dest));+ const destFor = (t: (typeof BOOTSTRAP_TEMPLATES)[number]): string =>+ !minimal && opts.host === 'openclaw' && t.openclawDest ? t.openclawDest : t.dest;+ const selected = BOOTSTRAP_TEMPLATES.filter(+ (t) => !opts.only || opts.only.includes(t.dest) || (t.openclawDest !== undefined && opts.only.includes(t.openclawDest)),+ );if (opts.only) {- const known = new Set(BOOTSTRAP_TEMPLATES.map((t) => t.dest));+ const known = new Set(BOOTSTRAP_TEMPLATES.flatMap((t) => (t.openclawDest ? [t.dest, t.openclawDest] : [t.dest])));const unknown = opts.only.filter((o) => !known.has(o));if (unknown.length > 0) {throw new BootstrapRenderError(@@ -278,7 +318,7 @@ export function renderWorkspace(workspaceDir: string, opts: RenderOptions = {}):const token = m[1]!;if (!placeholders.has(token)) unresolved.add(token);}- rendered.push({ dest: t.dest, content: collapseBlankLines(out) });+ rendered.push({ dest: destFor(t), content: collapseBlankLines(out) });}if (unresolved.size > 0) {diff --git a/src/core/bootstrap/verify.ts b/src/core/bootstrap/verify.tsindex 79239101a8..788e19fcd6 100644--- a/src/core/bootstrap/verify.ts+++ b/src/core/bootstrap/verify.ts@@ -289,12 +289,12 @@ function checkTokenSweep(ws: string): VerifyCheck {return { id, ok: true, warn: true, detail: 'template clone (initialized:false) — placeholder tokens are expected; render before verifying for real' };}const offenders: string[] = [];- for (const t of BOOTSTRAP_TEMPLATES) {- const p = join(ws, t.dest);+ for (const dest of BOOTSTRAP_TEMPLATES.flatMap((t) => (t.openclawDest ? [t.dest, t.openclawDest] : [t.dest]))) {+ const p = join(ws, dest);if (!existsSync(p)) continue;const raw = readFileSync(p, 'utf8');const tokens = [...raw.matchAll(TOKEN_RE)].map((m) => m[1]);- if (tokens.length > 0) offenders.push(`${t.dest} (${[...new Set(tokens)].join(', ')})`);+ if (tokens.length > 0) offenders.push(`${dest} (${[...new Set(tokens)].join(', ')})`);}if (offenders.length > 0) {return { id, ok: false, detail: `unresolved {{TOKEN}}s in rendered files: ${offenders.join('; ')} — finish the interview and re-run render` };@@ -362,8 +362,8 @@ function trackedWorkspaceFiles(ws: string): { files: string[]; via: 'git' | 'fal/* not a repo — fallback below */}const files: string[] = [];- for (const t of BOOTSTRAP_TEMPLATES) {- if (existsSync(join(ws, t.dest))) files.push(t.dest);+ for (const dest of BOOTSTRAP_TEMPLATES.flatMap((t) => (t.openclawDest ? [t.dest, t.openclawDest] : [t.dest]))) {+ if (existsSync(join(ws, dest))) files.push(dest);}if (existsSync(join(ws, 'state', 'interview.json'))) files.push(join('state', 'interview.json'));return { files, via: 'fallback' };diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex 2011131857..62ace9659a 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -26,7 +26,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'beliefs': ['--apply', '--archived-at', '--brain', '--from-url-env', '--help', '--json', '--probe', '--purge-mirror', '--since', '--source'],'bench': ['--baseline', '--brain', '--force', '--from', '--help', '--json', '--label', '--limit', '--source', '--threshold-jaccard', '--threshold-latency-multiplier', '--threshold-top1', '--to', '--tool'],'book-mirror': ['--accept-pending', '--access', '--add', '--all', '--allowed-operations', '--asof', '--author', '--background', '--body', '--bound-slug-prefixes', '--brain', '--chapters-dir', '--client', '--context-file', '--cursor', '--date', '--dated-since', '--days', '--dry-run', '--entities', '--explain', '--federated-read', '--follow', '--from-index', '--full', '--fuzzy', '--group', '--group-by', '--help', '--http', '--id', '--include-deleted', '--json', '--kind', '--limit', '--max-cost', '--max-cost-usd', '--max-turns', '--max-usd', '--model', '--multimodal', '--no-accept-pending', '--no-autopilot-install', '--no-confirm', '--no-follow', '--page', '--params', '--path', '--phase', '--prefer', '--progress-interval', '--progress-json', '--purge', '--quiet', '--recent', '--refresh-operations', '--row', '--scopes', '--session', '--since', '--slug', '--slugs', '--source', '--sources', '--stale', '--surface', '--timeout', '--timeout-ms', '--timings', '--title', '--to', '--updated-after', '--url', '--wait', '--yes'],- 'bootstrap': ['--abbrev-ref', '--accept-visibility-change-consequences', '--active', '--add', '--adopt', '--all', '--allow-unverified-remote', '--auto', '--autostash', '--batch-check', '--bearer-token-env-var', '--brain', '--branch', '--cached', '--confirm', '--count', '--delete-brain', '--diff-filter', '--dim', '--dry-run', '--enable', '--env', '--error-unmatch', '--exclude-standard', '--expect-remote', '--ff-only', '--file', '--force', '--gbrain-bin', '--get', '--get-all', '--git-dir', '--git-path', '--hard', '--harness', '--header', '--heads', '--help', '--home', '--hostname', '--http', '--id', '--init', '--install', '--is-inside-work-tree', '--issuer-url', '--jq', '--json', '--keep-checkout', '--local', '--local-env-vars', '--mcp-even-if-plugin', '--mcp-only', '--mcp-url', '--minimal', '--name', '--name-only', '--no-autostash', '--no-capture', '--no-cron', '--no-hooks', '--no-seat', '--no-tags', '--no-verify', '--oauth-client-id', '--oauth-client-secret', '--only', '--operations', '--others', '--pat-file', '--path', '--pglite', '--porcelain', '--port', '--private', '--project', '--pull', '--pure', '--push-only', '--quiet', '--rebase', '--refresh-operations', '--refresh-skills', '--remove', '--repair', '--require-clean', '--resolve', '--scope', '--scopes', '--seat', '--set', '--short', '--show', '--show-toplevel', '--skills', '--skip', '--source', '--sources', '--status', '--surface', '--to', '--token', '--token-name', '--unset-all', '--url', '--verify', '--version', '--visibility', '--workspace', '--yes'],+ 'bootstrap': ['--abbrev-ref', '--accept-visibility-change-consequences', '--active', '--add', '--adopt', '--all', '--allow-unverified-remote', '--auto', '--autostash', '--batch-check', '--bearer-token-env-var', '--brain', '--branch', '--cached', '--confirm', '--count', '--delete-brain', '--diff-filter', '--dim', '--dry-run', '--enable', '--env', '--error-unmatch', '--exclude-standard', '--expect-remote', '--ff-only', '--file', '--force', '--gbrain-bin', '--get', '--get-all', '--git-dir', '--git-path', '--hard', '--harness', '--header', '--heads', '--help', '--home', '--host', '--hostname', '--http', '--id', '--init', '--install', '--is-inside-work-tree', '--issuer-url', '--jq', '--json', '--keep-checkout', '--local', '--local-env-vars', '--mcp-even-if-plugin', '--mcp-only', '--mcp-url', '--minimal', '--name', '--name-only', '--no-autostash', '--no-capture', '--no-cron', '--no-hooks', '--no-seat', '--no-tags', '--no-verify', '--oauth-client-id', '--oauth-client-secret', '--only', '--operations', '--others', '--pat-file', '--path', '--pglite', '--porcelain', '--port', '--private', '--project', '--pull', '--pure', '--push-only', '--quiet', '--rebase', '--refresh-operations', '--refresh-skills', '--remove', '--repair', '--require-clean', '--resolve', '--scope', '--scopes', '--seat', '--set', '--short', '--show', '--show-toplevel', '--skills', '--skip', '--source', '--sources', '--status', '--surface', '--to', '--token', '--token-name', '--unset-all', '--url', '--verify', '--version', '--visibility', '--workspace', '--yes'],'brainstorm': ['--brain', '--force-rechunk', '--force-resume', '--help', '--json', '--judge-model', '--limit', '--list-runs', '--max-cost', '--max-far-set', '--max-ideas-per-judge-call', '--max-usd', '--no-save', '--probe', '--resume', '--save', '--source', '--source-id', '--stale', '--strict-budget', '--yes'],'cache': ['--brain', '--help', '--json', '--source', '--yes'],'calibration': ['--access', '--add', '--all', '--allowed-operations', '--asof', '--body', '--bound-slug-prefixes', '--brain', '--client', '--cursor', '--date', '--dated-since', '--days', '--dry-run', '--entities', '--federated-read', '--from-index', '--full', '--fuzzy', '--group-by', '--help', '--holder', '--http', '--id', '--include-deleted', '--json', '--key-prefix', '--kind', '--limit', '--max-usd', '--model', '--multimodal', '--no-autopilot-install', '--page', '--params', '--path', '--phase', '--prefer', '--purge', '--recent', '--refresh-operations', '--regenerate', '--row', '--scopes', '--scrub-gstack', '--session', '--since', '--slugs', '--source', '--sources', '--stale', '--surface', '--to', '--undo-wave', '--updated-after', '--url', '--with-calibration', '--yes'],diff --git a/templates/bootstrap/AGENTS.md.template b/templates/bootstrap/AGENTS.md.templateindex 08afb44bf2..2447167955 100644--- a/templates/bootstrap/AGENTS.md.template+++ b/templates/bootstrap/AGENTS.md.template@@ -111,7 +111,7 @@ Trust runtime-provided context first — it usually already includes this file,`SOUL.md`, `USER.md`, `MEMORY.md`, and injected brain context. Then:1. If a hook status file or greeting digest reports a problem (failed pushes, hookdegradation), surface it in the first reply.-2. Check `HEARTBEAT.md`'s due-job list; run what is due (session-triggered schedules+2. Check `{{SCHEDULES_FILE}}`'s due-job list; run what is due (session-triggered schedulesrun at turn boundaries — nothing fires while the harness is closed).## Memory architecture@@ -122,7 +122,7 @@ Trust runtime-provided context first — it usually already includes this file,| Hot state | MEMORY.md | every session (main only — security boundary) | same-turn file edits || Daily log | memory/YYYY-MM-DD.md | on demand | append-only, same turn || The brain | brain/ via gbrain tools | searched on demand, injected per turn | `put_page` / fences / timeline |-| Schedules | HEARTBEAT.md | session start | explicit edits |+| Schedules | {{SCHEDULES_FILE}} | session start | explicit edits |## Timediff --git a/templates/bootstrap/HEARTBEAT.md.template b/templates/bootstrap/HEARTBEAT.md.templateindex 7ff6f5336b..d809aceb63 100644--- a/templates/bootstrap/HEARTBEAT.md.template+++ b/templates/bootstrap/HEARTBEAT.md.template@@ -1,4 +1,4 @@-# HEARTBEAT.md+# {{SCHEDULES_FILE}}Session-triggered schedules for {{AGENT_NAME}}. These are cadence-prompted jobsthat fire at turn/session boundaries **while the harness is open** — nothing runsdiff --git a/test/bootstrap-render.test.ts b/test/bootstrap-render.test.tsindex 04c06e7038..1e2b7e7710 100644--- a/test/bootstrap-render.test.ts+++ b/test/bootstrap-render.test.ts@@ -28,6 +28,7 @@ import {UnresolvedTokenError,BootstrapRenderError,DERIVED_DEFAULTS,+ detectOpenClawWorkspace,} from '../src/core/bootstrap/render.ts';import { BOOTSTRAP_TEMPLATES } from '../src/core/bootstrap/assets.ts';import { readManifest, writeManifest, TEMPLATE_PLACEHOLDER_MANIFEST } from '../src/core/bootstrap/format.ts';@@ -467,3 +468,61 @@ describe('renderWorkspace — machine-specific wiring stays out of the repo [B8]expect(gh).not.toContain('15-minute');});});++describe('renderWorkspace — OpenClaw host keeps its schedule list out of HEARTBEAT.md (#7470)', () => {+ test('host openclaw renders the due-job list as SCHEDULES.md and AGENTS.md points only there', () => {+ const ws = answeredWs();+ const result = renderWorkspace(ws, { host: 'openclaw' });+ expect(result.written).toContain('SCHEDULES.md');+ expect(result.written).not.toContain('HEARTBEAT.md');+ expect(existsSync(join(ws, 'HEARTBEAT.md'))).toBe(false);+ const schedules = readFileSync(join(ws, 'SCHEDULES.md'), 'utf8');+ expect(schedules.startsWith('# SCHEDULES.md\n')).toBe(true);+ expect(schedules).toContain('## Due-job list');+ expect(TOKEN_RE.test(schedules)).toBe(false);+ const agents = readFileSync(join(ws, 'AGENTS.md'), 'utf8');+ expect(agents).not.toContain('HEARTBEAT.md');+ expect(agents).toMatch(/SCHEDULES\.md[^\n]*due-job list/);+ expect(agents).toContain('| Schedules | SCHEDULES.md |');+ });++ test('every other harness keeps HEARTBEAT.md', () => {+ const ws = answeredWs();+ const result = renderWorkspace(ws);+ expect(result.written).toContain('HEARTBEAT.md');+ expect(existsSync(join(ws, 'SCHEDULES.md'))).toBe(false);+ expect(readFileSync(join(ws, 'HEARTBEAT.md'), 'utf8').startsWith('# HEARTBEAT.md\n')).toBe(true);+ expect(readFileSync(join(ws, 'AGENTS.md'), 'utf8')).toMatch(/HEARTBEAT\.md[^\n]*due-job list/);+ });++ test('--only HEARTBEAT.md on OpenClaw writes SCHEDULES.md, never the file the host doctor removes', () => {+ const ws = answeredWs();+ const result = renderWorkspace(ws, { host: 'openclaw', only: ['HEARTBEAT.md'] });+ expect(result.written).toEqual(['SCHEDULES.md']);+ expect(existsSync(join(ws, 'HEARTBEAT.md'))).toBe(false);+ expect(isBootstrapRenderDest('SCHEDULES.md')).toBe(true);+ });++ test('minimal mode ignores the host, so the template repo stays byte-identical', () => {+ const a = makeWs(), b = makeWs();+ renderWorkspace(a, { minimal: true });+ renderWorkspace(b, { minimal: true, host: 'openclaw' });+ expect(existsSync(join(b, 'SCHEDULES.md'))).toBe(false);+ for (const dest of ALL_DESTS) {+ expect(readFileSync(join(b, dest), 'utf8')).toBe(readFileSync(join(a, dest), 'utf8'));+ }+ });++ test('detectOpenClawWorkspace: the configured workspace, a state-dir workspace, or a profile; nothing else', () => {+ const home = '/home/alice-example';+ expect(detectOpenClawWorkspace('/srv/agent-ws', { OPENCLAW_WORKSPACE_DIR: '/srv/agent-ws/' }, home)).toBe(true);+ expect(detectOpenClawWorkspace('/srv/agent-ws', { OPENCLAW_WORKSPACE: '/srv/agent-ws' }, home)).toBe(true);+ expect(detectOpenClawWorkspace(`${home}/.openclaw/workspace`, {}, home)).toBe(true);+ expect(detectOpenClawWorkspace(`${home}/.openclaw/workspace/agent-a`, {}, home)).toBe(true);+ expect(detectOpenClawWorkspace(`${home}/.openclaw-work/workspace`, {}, home)).toBe(true);+ expect(detectOpenClawWorkspace('/var/oc/workspace', { OPENCLAW_STATE_DIR: '/var/oc' }, home)).toBe(true);+ expect(detectOpenClawWorkspace(`${home}/agent`, {}, home)).toBe(false);+ expect(detectOpenClawWorkspace(`${home}/.openclawish/workspace`, {}, home)).toBe(false);+ expect(detectOpenClawWorkspace('/srv/other', { OPENCLAW_WORKSPACE_DIR: '/srv/agent-ws' }, home)).toBe(false);+ });+});