#5776·gbrain

Windows: skill publication always fails for files in subfolders (`readBundleFile` rejects backslash in relative path)

Author: matthieuhayozCreated Sep 30, 2026Updated Sep 30, 2026
Labelsbug

On Windows, readBundleFile in src/core/persistence/bundle-files.ts throws storage_error for every file that is not directly in the bundle root. The relative path is validated against a regex that rejects backslashes, but on Windows the path separator is a backslash, so any nested path fails.

This blocks the projection stage of migration v0.53.0, which stays at action_required indefinitely.

Environment

  • gbrain 0.60.11.0 (upgraded from 0.51.0.0 via gbrain upgrade, bun install)
  • bun 1.3.14
  • Windows 11 Home 10.0.26200
  • Engine: PGLite, single default source

Steps to reproduce

  1. On Windows, export a DB-only source to a content root: gbrain apply-migrations --migration 0.53.0 --export-db-only --content-root <root> --export-source default --confirm-quiesced --backup-confirmed
  2. Run gbrain apply-migrations --migration 0.53.0 --yes

Actual result

[shared-skills] action_required. 1 source(s) need host action; no grants or bundle consent changed.
[shared-skills] default: storage_error: Skill publication requires bounded regular files without aliases, links, or special files.

--dry-run --json shows inventory and ownership complete, projection planned, members action_required. Re-running never gets past projection.

Expected result

The projection stage publishes the memory pack, as it would on macOS/Linux.

Cause

bundle-files.ts, line 26:

typescript
|| rel.split(sep).length > BUNDLE_FILE_LIMITS.depth || /[\\\x00-\x1f:]/.test(rel)) throw unsafe();

rel comes from relative(root, path). On Windows sep is \, so rel for any nested file (e.g. sub\nested.md) contains a backslash and matches the regex.

Minimal reproduction

typescript
import { readBundleFile } from 'gbrain/src/core/persistence/bundle-files.ts';
import { realpathSync } from 'node:fs';
import { join } from 'node:path';

// <root>/top.md and <root>/sub/nested.md both exist as plain files
const root = realpathSync(process.argv[2]);
for (const rel of ['top.md', 'sub/nested.md']) {
  try { readBundleFile(join(root, rel), root); console.log('OK  ', rel); }
  catch (e) { console.log('FAIL', rel, (e as Error).message); }
}

Output on Windows, in a plain local temp folder (no symlinks, no cloud-sync folder):

OK   top.md
FAIL sub/nested.md Skill publication requires bounded regular files without aliases, links, or special files.

The same result occurs inside a OneDrive folder, so the location is not the cause.

Suggested fix

Run the character check per path segment instead of on the whole relative path, e.g.:

typescript
|| rel.split(sep).some(part => /[\\/\x00-\x1f:]/.test(part))

This keeps the intent (no separators, control characters or colons inside a segment) while allowing the platform separator between segments.