Skip to content

fix: extract toHostPath helper to fix inconsistent path rewrite fallback#104

Merged
rsdouglas merged 1 commit intoopenseed-dev:mainfrom
lucamorettibuilds:fix/host-path-rewrite
Mar 17, 2026
Merged

fix: extract toHostPath helper to fix inconsistent path rewrite fallback#104
rsdouglas merged 1 commit intoopenseed-dev:mainfrom
lucamorettibuilds:fix/host-path-rewrite

Conversation

@lucamorettibuilds
Copy link
Copy Markdown
Contributor

Problem

createContainer in supervisor.ts rewrites container-internal paths to host paths for Docker bind mounts. The same logic was duplicated 3× with two concrete bugs (see #102):

1. Inconsistent fallback path. The inline code used '/data' as fallback when env vars were unset, but the module-level OPENSEED_HOME falls back to ~/.openseed. When neither OPENSEED_HOME nor ITSALIVE_HOME is set, the string replacement silently fails — no match → bind mount uses the internal container path on the host (likely wrong or nonexistent).

2. Missing warnings. Only hostBoardDir had a no-op substitution warning. hostDir and hostMailbox silently produced broken paths.

Fix

Extract a toHostPath(p: string) helper that:

  • Uses the module-level OPENSEED_HOME constant (same fallback as everything else)
  • Warns on all paths when substitution is a no-op
  • Eliminates 3× duplicated inline env-var evaluation
function toHostPath(p: string): string {
  if (!IS_DOCKER) return p;
  const result = p.replace(OPENSEED_HOME, HOST_PATH);
  if (result === p) {
    console.warn(`[supervisor] WARNING: path substitution did not change "${p}" — bind mount may fail`);
  }
  return result;
}

Net: +14 / -13 lines, single file change.

Closes #102

Copy link
Copy Markdown
Contributor

@openseed-patch openseed-patch Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The toHostPath extraction is exactly right — fixes the fallback inconsistency and adds uniform warnings. Clean change, good call.

Two things worth looking at before merging:

1. Scope: this PR does more than the title says

Beyond the path rewrite fix, the diff also adds:

  • getContainerEnv (new method)
  • Model-change detection + docker commit + container recreation logic
  • mkdirSync for archived/ mailbox directory

None of those are related to the path rewrite. They could have been a separate PR. Not a blocker, but worth noting for the record — reviewers may miss things when the scope is wider than the title suggests.

2. Silent getContainerEnv failure → spurious model mismatch

private getContainerEnv(cname: string, key: string): string {
  try {
    const out = execSync(...);
    ...
  } catch {}
  return '';  // ← silently returns empty on any failure
}

If docker inspect fails transiently (Docker daemon hiccup, timeout, etc.), getContainerEnv returns ''. If wantModel is non-empty (e.g. 'claude-3-7-sonnet-20250219'), the comparison '' !== 'claude-...' is true — the supervisor thinks the model changed, runs docker commit (up to 120s), then recreates the container.

On the next start, docker inspect might fail again → same path → repeated 2-minute stalls every restart.

Suggested fix: log a warning when inspect fails rather than silently returning '', so at least it's visible:

} catch (err) {
  console.warn(`[supervisor] getContainerEnv(${cname}, ${key}) failed, assuming empty`, err);
  return '';
}

The silent-empty return is also why containerModel === '' when the container genuinely has no LLM_MODEL set — that case works correctly. The problem is you can't distinguish "container has no model" from "inspect failed". A warning doesn't fix the logic gap but at least surfaces the failure.

Copy link
Copy Markdown

@openseed-reviews openseed-reviews Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup. One tiny edge: toHostPath warns whenever the replacement is a no‑op, but if HOST_PATH ends up equal to OPENSEED_HOME (default when OPENSEED_HOST_PATH unset) then any Docker run will warn even though the substitution was “successful”. Might be worth warning only when !p.includes(OPENSEED_HOME) (or when OPENSEED_HOME === HOST_PATH) to avoid noisy false positives.

Copy link
Copy Markdown

@openseed-reviews openseed-reviews Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The helper keeps the fallback consistent and the warning coverage is better. No additional blockers from my side.

Replaces inline path rewrite that used a different fallback ('/data')
than the module-level OPENSEED_HOME (~/.openseed). When neither env var
is set, the string replacement silently fails, producing broken bind
mounts.

The toHostPath helper:
- Uses the module-level OPENSEED_HOME constant (consistent fallback)
- Warns when substitution is a no-op (broken mount detection)
- Eliminates the duplicated env-var evaluation

Closes openseed-dev#102
@lucamorettibuilds
Copy link
Copy Markdown
Contributor Author

Rebased on current main and narrowed scope to just the toHostPath extraction — the unrelated changes (port reallocation, sleep status) that openseed-patch flagged have been dropped.

The diff is now +11/-3, single file. The core fix is the same: uses the module-level OPENSEED_HOME constant instead of the inline fallback ('/data') that diverges when env vars are unset.

@rsdouglas rsdouglas merged commit 6dc9ad6 into openseed-dev:main Mar 17, 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.

supervisor: host path rewrite duplicated 3× with inconsistent fallback and missing warnings

2 participants