Skip to content

Add namespace option to customize the sandcastle prefix#553

Open
elkinjosetm wants to merge 2 commits into
mattpocock:mainfrom
elkinjosetm:feat/namespace-option
Open

Add namespace option to customize the sandcastle prefix#553
elkinjosetm wants to merge 2 commits into
mattpocock:mainfrom
elkinjosetm:feat/namespace-option

Conversation

@elkinjosetm
Copy link
Copy Markdown

@elkinjosetm elkinjosetm commented May 5, 2026

Closes #552.

Changes

  • New optional namespace?: string field on RunOptions, CreateSandboxOptions, and CreateWorktreeOptions (default "sandcastle").
  • Threaded into:
    • WorktreeManager — branch (<ns>/<ts> or <ns>/<sanitized-name>/<ts>), worktree dir (<ns>-<ts> / <ns>-<sanitized-name>-<ts>), parent dir (.<ns>/worktrees/).
    • run(), createSandbox(), createWorktree() (and the methods returned by the latter two) — log path under .<ns>/logs/.
    • syncOut() — patches path under .<ns>/patches/.
    • BindMountCreateOptions + IsolatedCreateOptions — new optional namespace?: string field forwarded to providers via startSandbox().
    • sandboxes/docker.ts, sandboxes/podman.ts — container name <ns>-<uuid> (visible in docker ps / podman ps).
    • sandboxes/daytona.ts — session id <ns>-<uuid>.
  • .sandcastle/.env lookup intentionally unchanged (user-managed config; renaming would force migration on every existing user).
  • Image-name default (sandcastle:<slug>) is already overridable via docker({ imageName }) and stays as-is.
  • Validation: same sanitizeName rules as the existing name option. Empty strings are rejected synchronously at the public API entry point. A value that sanitizes to no alphanumeric characters (e.g. "///") is rejected with a descriptive error.
  • New tests:
    • src/WorktreeManager.test.tsresolveNamespace defaults / sanitizes / rejects invalid; generateTempBranchName honors namespace; WorktreeManager.create propagates namespace to branch + worktree dir; WorktreeManager.pruneStale operates on the namespaced worktrees dir without touching others; default behavior preserved when namespace is omitted.
    • src/sandboxes/docker.test.ts — provider uses createOptions.namespace as container prefix; falls back to "sandcastle" when omitted.
    • src/sandboxes/podman.test.ts — provider uses createOptions.namespace as container prefix.
  • Providers fall back to "sandcastle" when createOptions.namespace is omitted, so callers that don't thread it (e.g. interactive()) and any third-party provider continue to work unchanged.
  • Changeset: patch.
  • README: RunOptions example + RunOptions/CreateSandboxOptions/CreateWorktreeOptions reference tables.

Backwards compatibility

Default "sandcastle" keeps current behavior byte-for-byte. Pure additive opt-in — no existing call sites need changes.

Verification

  • npm run typecheck (only pre-existing @daytona/sdk optional-peer warnings remain — unchanged from main).
  • npm test — namespace tests pass (WorktreeManager + sandboxes/docker); pre-existing failure count unchanged from main (Mac /private/var/folders symlink-related failures + Podman Machine env failures already on main).
  • Manual review confirms name semantics still flow through the existing path (no change to the name option).

… paths

Adds an optional `namespace?: string` field to `RunOptions`,
`CreateSandboxOptions`, and `CreateWorktreeOptions`. When set, replaces
the hardcoded `sandcastle` prefix in:
- branch ref (`<namespace>/<timestamp>` or `<namespace>/<name>/<timestamp>`)
- worktree directory (`<namespace>-<timestamp>`)
- worktree parent (`.<namespace>/worktrees/`)
- log directory (`.<namespace>/logs/`)
- patches directory (`.<namespace>/patches/`)

Defaults to `"sandcastle"`, preserving existing behavior byte-for-byte.
The `.sandcastle/.env` lookup is intentionally unchanged — renaming would
force migration on every existing user.

Closes mattpocock#552.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 5, 2026

@elkinjosetm is attempting to deploy a commit to the Matt Pocock's projects Team on Vercel.

A member of the Team first needs to authorize it.

…ytona)

Threads the resolved `namespace` from RunOptions through `BindMountCreateOptions`
and `IsolatedCreateOptions` so the docker, podman, and daytona providers use
`<namespace>-<uuid>` instead of the hardcoded `sandcastle-<uuid>` for container
names (visible in `docker ps`, `podman ps`) and Daytona session ids.

- `BindMountCreateOptions.namespace?: string` — provider reads this for naming.
- `IsolatedCreateOptions.namespace?: string` — same, for isolated providers.
- `startSandbox()` accepts an optional `namespace` and forwards it to
  `provider.create({ ..., namespace })`.
- `createSandbox`, `createSandboxFromWorktree`, `createWorktree`, `worktreeRun`,
  `worktreeInteractive`, and `run()` now pass the resolved namespace through.
- Providers fall back to `"sandcastle"` when the field is omitted, preserving
  byte-for-byte behavior for callers that don't thread it (e.g. `interactive()`).

Tests: docker/podman provider tests verify the prefix flips with
`createOptions.namespace`. Changeset + issue body updated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@elkinjosetm elkinjosetm changed the title Add namespace option to customize sandcastle prefix in branch + paths Add namespace option to customize the sandcastle prefix May 6, 2026
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.

Add namespace option to customize the sandcastle prefix

1 participant