Skip to content

feat(config): top-level instanceId field (Phase D2.1 foundation)#11

Merged
LightDriverCS merged 2 commits into
mainfrom
feat/config-instance-id
Apr 28, 2026
Merged

feat(config): top-level instanceId field (Phase D2.1 foundation)#11
LightDriverCS merged 2 commits into
mainfrom
feat/config-instance-id

Conversation

@LightDriverCS

@LightDriverCS LightDriverCS commented Apr 28, 2026

Copy link
Copy Markdown

Summary

Adds an optional instanceId field to OpenClawConfig (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:

  • memory-wiki vault path → ~/.openclaw/wiki/{instanceId}/ (PR follow-up)
  • cloud-mirror daemon state file → ~/.openclaw/state/wiki-mirror.{instanceId}.json (PR follow-up)
  • health snapshot → surfaces instanceId field (PR follow-up)
  • shard directory layout — already wired in BenchAGI_Mono_Repo PR fix(daemon): use minimal PATH for gateway services openclaw/openclaw#477

When unset, single-user Tier A defaults apply (~/.openclaw/wiki/main/).

Why

Phase D2.1 hardening — the per-business shard architecture from BenchAGI_Mono_Repo PR 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 optional instanceId field on OpenClawConfig.
  • src/config/zod-schema.ts: instanceId validator (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 via pnpm config:schema:gen — adds the new field block; also picks up the stale required: ["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

  • PR B (forthcoming): feat(health): surface instanceId on health snapshot
  • PR C (forthcoming): feat(memory-wiki): scope vault path to instanceId
  • PR D (forthcoming): feat(claude-code-bridge): cloud-mirror reads instanceId for per-vault scoping

Test plan

  • pnpm vitest run src/config/config-misc.test.ts — 54 tests pass
  • pnpm config:schema:check — schema regen idempotent
  • Pre-commit hooks (tsgo + oxlint + madge + import-cycle) pass

🤖 Generated with Claude Code

Anvil Handoff

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]>
@LightDriverCS
LightDriverCS merged commit 5d77f7a into main Apr 28, 2026
4 of 11 checks passed
@LightDriverCS
LightDriverCS deleted the feat/config-instance-id branch April 28, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant