feat(config): top-level instanceId field (Phase D2.1 foundation)#11
Merged
Conversation
Adds an optional `instanceId` field to OpenClawConfig. Validates 1-128 chars matching `[A-Za-z0-9_-]+` so the value can serve as a filesystem-safe path component. When set, downstream features (memory-wiki vault path, cloud-mirror state file, health snapshot, shard directory layout) scope per-instance resources to this id. When unset, single-user Tier A defaults apply. This is the foundation PR for Phase D2.1 (per-instance harness hardening); subsequent PRs surface the field on health, scope the memory-wiki vault, and update the cloud-mirror daemon. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Surfaced by Codex Anvil (PR #11 smoke 20260428T073028Z): the new top-level `instanceId` config field changed the public config surface hash, so `pnpm config:docs:check` failed against the stale baseline. Regenerated via `pnpm config:docs:gen`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
instanceIdfield toOpenClawConfig(top-level). Validates as 1-128 chars matching[A-Za-z0-9_-]+so the value is filesystem-safe for use as a path component.When set, downstream features scope per-instance resources to this id:
~/.openclaw/wiki/{instanceId}/(PR follow-up)~/.openclaw/state/wiki-mirror.{instanceId}.json(PR follow-up)instanceIdfield (PR follow-up)BenchAGI_Mono_RepoPR fix(daemon): use minimal PATH for gateway services openclaw/openclaw#477When unset, single-user Tier A defaults apply (
~/.openclaw/wiki/main/).Why
Phase D2.1 hardening — the per-business shard architecture from
BenchAGI_Mono_RepoPR openclaw#477 (Phase D2 monorepo) requires the harness to know which Bench instance it belongs to so it can scope filesystem resources. This is the fork-side foundation PR; B/C/D follow.Changes
src/config/types.openclaw.ts: new optionalinstanceIdfield onOpenClawConfig.src/config/zod-schema.ts:instanceIdvalidator (z.string().min(1).max(128).regex(/^[A-Za-z0-9_-]+$/).optional()).src/config/schema.help.ts/schema.labels.ts: human-readable label + help.src/config/schema.base.generated.ts: regenerated viapnpm config:schema:gen— adds the new field block; also picks up the stalerequired: ["command"]removal from PR fix(config): accept partial cliBackends overrides by making command optional #5.src/config/config-misc.test.ts: 3 new tests (accept valid, accept absent, reject path-traversal/empty/slash).Dependent PRs
feat(health): surface instanceId on health snapshotfeat(memory-wiki): scope vault path to instanceIdfeat(claude-code-bridge): cloud-mirror reads instanceId for per-vault scopingTest plan
pnpm vitest run src/config/config-misc.test.ts— 54 tests passpnpm config:schema:check— schema regen idempotent🤖 Generated with Claude Code
Anvil Handoff
instanceIdtoOpenClawConfigwith strict regex/^[A-Za-z0-9_-]{1,128}$/so the value is filesystem-safe. Three other PRs (feat(health): surface instanceId on health snapshot (Phase D2.1) #12 health, feat(memory-wiki): scope vault path to instanceId (Phase D2.1) #13 memory-wiki, feat(claude-code-bridge): cloud-mirror reads instanceId for per-vault scoping (Phase D2.1) #14 cloud-mirror) stack on this. Generatedschema.base.generated.tsviapnpm config:schema:gen; the regen also clears a stalerequired: ["command"]in cliBackends that should have shipped with already-merged fix(config): accept partial cliBackends overrides by making command optional #5.src/config/types.openclaw.ts,src/config/zod-schema.ts,src/config/schema.help.ts,src/config/schema.labels.ts,src/config/schema.base.generated.ts,src/config/config-misc.test.tspnpm vitest run src/config/config-misc.test.ts→ 54 passed (3 new).pnpm config:schema:checkclean. Pre-commit (tsgo + oxlint + madge + import-cycle) green.required: ["command"]from cliBackends — confirm matches PR fix(config): accept partial cliBackends overrides by making command optional #5 runtime intent and isn't a regression. (2) The[A-Za-z0-9_-]{1,128}regex is duplicated in #13 (memory-wiki config) and #14 (cloud-mirror.mjs); a copy edit could let them drift. (3) New top-level field onOpenClawConfig— confirm no other validators withadditionalProperties: false` would reject configs that have it.pnpm config:schema:genagain, expect no diff). Byte-for-byte alignment between zod regex and emitted JSON-schema pattern. Search for additional consumers ofcfg.instanceIdwe should wire (CLI banners, logs, agent identity).