Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
refactor(slug): raise the #5032 refusal through the wave error catalogue
garrytan9c6faaa439d4
diff --git a/docs/guides/write-refusals.md b/docs/guides/write-refusals.mdindex 9e508e3d19..6ebdec0d4f 100644--- a/docs/guides/write-refusals.md+++ b/docs/guides/write-refusals.md@@ -59,9 +59,8 @@ of making a duplicate.| <a id="writer_not_quiesced"></a>`writer_not_quiesced` | `writer_not_quiesced` | Activation found an older writer, a legacy lock, or queued, running or recovering work. When work blocks it, the message names the blocking effect id, kind, source, page and request id. | Stop the writers named in the [claim and activate runbook](../architecture/topologies.md#claim-and-activate-runbook), inspect the named work with `gbrain sources writer status <source> --json`, let it finish, then retry. A committed write whose embedding effect is stuck queued or failed is settled by `gbrain repair embedding-effects --source <source>` (preview), then the same command with `--apply`; see [stale queued embedding effects](repair.md#stale-queued-embedding-effects). || <a id="migrations_running"></a>`migrations_running` | `migrations_running` (exit 75) | `gbrain apply-migrations` (or the post-upgrade step of `gbrain upgrade`) found another runner holding the brain's orchestration lock and stopped before touching the migration ledger, so migrations never run twice in parallel. The message names the holder's host and pid. A holder that died is taken over automatically on the next run. `gbrain upgrade` reports this as `Migrations: running`, not as a failed upgrade. | Wait for the other run to finish; `gbrain doctor` shows migration progress. Then `gbrain apply-migrations --yes` confirms everything is applied. || <a id="writer_deactivate"></a>`writer_deactivate` blockers | `writer_not_quiesced`, `writer_admin_locked`, `writer_admin_state_changed`, `writer_lock_unavailable` | `gbrain sources writer deactivate` found pending work (a queued, running or recovering write, a topology change or effect that is not settled, a held connector item, or a live connector or maintenance lease), the writer admin lock, a changed admin state, or a local process holding a worktree lock. Nothing changed. The suggestion names each blocker and its exit. | Run `gbrain sources writer deactivate --dry-run` for the full list, run each named exit (`gbrain cancel-write-request <request_id>`, `gbrain sync --source <id> --no-pull --retry-failed`, `gbrain repair embedding-effects --source <id>`, `gbrain sources writer retry-effects <source> --request-id <id> --dry-run`, `gbrain sources writer unlock`, `gbrain sources retry-held <id>`), then deactivate again with a fresh `--expected-state` from `gbrain sources writer status --json`. See the [deactivate runbook](../architecture/topologies.md#deactivate-runbook). |-| <a id="colon_slug_windows_write_through"></a>`colon_slug_windows_write_through` | `colon_slug_windows_write_through` | A page slug such as `calendar:abc` is valid, but its canonical file name would contain `:`, which Windows cannot store (it names an alternate data stream). On Windows, a write that would publish that file is refused before admission, and `gbrain sync` skips each such file with this reason instead of failing the run. Database-only writes of the same slug (no repo configured, `sync.write_through` off, or an unbound source) still succeed, and macOS and Linux are unchanged. | Use a slug without `:` (the suggestion names one), or write the page from a macOS or Linux host that owns the source. For a skipped sync file, rename it without `:` on a macOS or Linux checkout, commit, then run `gbrain sync --source <source> --no-pull` on the Windows host. || unknown option (repair) | `invalid_params` | `gbrain repair` refuses any option it does not list, so a mistyped flag or `--max-usd` never runs a repair silently without it. | Fix the option (`gbrain repair --help`). To cap paid repair work, run `gbrain doctor --remediate --yes --include-repairs --max-usd <n>`. |-| <a id="colon_slug_windows_write_through"></a>`colon_slug_windows_write_through` | `colon_slug_windows_write_through` | A slug containing `:` cannot be written through to a file on Windows. | Write it on a non-Windows host, or choose a slug without `:`. |+| <a id="colon_slug_windows_write_through"></a>`colon_slug_windows_write_through` | `colon_slug_windows_write_through` | A page slug such as `calendar:abc` is valid, but its canonical file name would contain `:`, which Windows cannot store (it names an alternate data stream). On Windows, a write that would publish that file is refused before admission, and `gbrain sync` skips each such file with this reason instead of failing the run. Database-only writes of the same slug (no repo configured, `sync.write_through` off, or an unbound source) still succeed, and macOS and Linux are unchanged. | Use a slug without `:` (the suggestion names one), or write the page from a macOS or Linux host that owns the source. For a skipped sync file, rename it without `:` on a macOS or Linux checkout, commit, then run `gbrain sync --source <source> --no-pull` on the Windows host. || <a id="embedding_auth_failed"></a>`embedding_auth_failed` | `embedding_auth_failed` | The embedding provider rejected the configured key (HTTP 401 or 403). | Check which key is in effect and replace it. |### Other error codesdiff --git a/src/commands/sync/imports.ts b/src/commands/sync/imports.tsindex 0a13f77b32..abad79bc19 100644--- a/src/commands/sync/imports.ts+++ b/src/commands/sync/imports.ts@@ -26,6 +26,7 @@ import { isPathSafe } from '../../core/sync-git.ts';import { resolveStallAbortSeconds, composeAbortSignals } from '../../core/sync-reconcile.ts';import { sanitizePathForDisplay } from '../../core/sync.ts';import { isWindowsColonTarget } from '../../core/persistence/native-file-target.ts';+import { ERROR_CATALOGUE } from '../../core/error-catalogue.ts';import type { SyncOpts, SyncResult } from '../sync.ts';import { partial, markCompleted, noteTypeWarning, maybeYield } from './sync-run.ts';import type { SyncPlan, SyncProgress, SyncRun } from './sync-run.ts';@@ -251,7 +252,7 @@ async function importOnePath(run: SyncRun, ctx: ImportContext, eng: BrainEngine,// instead of the silent "deleted after the pin" skip below.if (isWindowsColonTarget(path)) {failedFiles.push({ path, error: `colon_slug_windows_write_through: ${path} has a ':' in its name, which Windows cannot store. `- + `Rename it without ':' on a macOS or Linux checkout and commit, then re-run gbrain sync (docs/guides/write-refusals.md#colon_slug_windows_write_through).` });+ + `Rename it without ':' on a macOS or Linux checkout and commit, then run gbrain sync${opts.sourceId ? ` --source ${opts.sourceId}` : ''} (${ERROR_CATALOGUE.colon_slug_windows_write_through.docs}).` });progressAt.last = Date.now();progress.tick(1, `skip:${path}`);return;diff --git a/src/core/ops/contract.ts b/src/core/ops/contract.tsindex a1300b766b..791729e2e2 100644--- a/src/core/ops/contract.ts+++ b/src/core/ops/contract.ts@@ -46,7 +46,6 @@ export type ErrorCode =| 'unavailable' // a required dependency cannot serve (no API key, gateway down, model refusal)| 'budget_unsatisfiable' // RESERVED in v1 — schema-listed, never returned| 'embedding_budget_below_worst_case' // #5680: migration cap below its worst-case authorization; refused before any change- | 'colon_slug_windows_write_through' // #5032: a ':' file name cannot be stored on Windows; refused before admission// eslint-disable-next-line @typescript-eslint/ban-types| (string & {}); // OPEN union for forward-compat (eE7 / D13)diff --git a/src/core/persistence/native-file-target.ts b/src/core/persistence/native-file-target.tsindex bc73a35084..21f5679faa 100644--- a/src/core/persistence/native-file-target.ts+++ b/src/core/persistence/native-file-target.ts@@ -1,6 +1,7 @@import { lstatSync, readdirSync, realpathSync, statSync, type BigIntStats } from 'node:fs';import { isAbsolute, join, relative, resolve, sep } from 'node:path';import { OperationError } from '../ops/contract.ts';+import { catalogueError } from '../error-catalogue.ts';export function nativeFileTarget(root: string, target: string, code?: string): string {const unsafe = () => new OperationError(code ?? 'source_changed', 'The canonical file target has no unambiguous native identity.',@@ -59,10 +60,9 @@ export function nativeFileTarget(root: string, target: string, code?: string): s* writes of the same slug are unaffected.*/export function colonSlugWindowsRefusal(slug: string, sourceId: string): OperationError {- return new OperationError('colon_slug_windows_write_through',+ return catalogueError('colon_slug_windows_write_through',`Page ${slug} has a ':' in its file name, which Windows cannot store.`,- `Use a slug without ':' (for example ${slug.replaceAll(':', '-')}), or write ${slug} from a macOS or Linux host that owns source ${sourceId}.`,- 'docs/guides/write-refusals.md#colon_slug_windows_write_through');+ `Use a slug without ':' (for example ${slug.replaceAll(':', '-')}), or write ${slug} from a macOS or Linux host that owns source ${sourceId}.`);}/** #5032: true when this process is on Windows and the relative file target contains `:`. */diff --git a/src/core/persistence/sync-discovery.ts b/src/core/persistence/sync-discovery.tsindex 1557e7b0ae..fa6e9e617c 100644--- a/src/core/persistence/sync-discovery.ts+++ b/src/core/persistence/sync-discovery.ts@@ -13,6 +13,7 @@ import { getWorktreeBinding, type WorktreeBinding } from './ownership.ts';import { localHostId } from './identity.ts';import { sha256 } from './digest.ts';import { isWindowsColonTarget } from './native-file-target.ts';+import { ERROR_CATALOGUE } from '../error-catalogue.ts';import { currentCompanyBrainSync } from '../company-brain/profile.ts';import type { CompanyBrainPlan } from '../company-brain/types.ts';import { assertDistinctSyncOrigins, legacySyncOrigin, sameSyncOrigin, syncOriginPath, type SyncOriginScope } from './sync-origin.ts';@@ -144,7 +145,7 @@ export async function discoverManagedSync(engine: BrainEngine, opts: SyncOpts, cif (eligible(path)) refused.set(path, { path, code: 'colon_slug_windows_write_through',message: `${path} has a ':' in its name, which Windows cannot store; sync skipped it.`,suggestion: `Rename it without ':' on a macOS or Linux checkout and commit, then run gbrain sync --source ${sourceId} --no-pull.`,- docs: 'docs/guides/write-refusals.md#colon_slug_windows_write_through' });+ docs: ERROR_CATALOGUE.colon_slug_windows_write_through.docs });return true;};const storable = <T extends { source_path: string | null }>(page: T) => page.source_path === null || !isWindowsColonTarget(page.source_path);