mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 07:02:29 +01:00
A project created with a gitUrl and no dirPath (Heidi, 2026-09-10) failed on both channels with the same root cause, upstream of both zellij call sites: inject-core passed `dir: null`, so executor enqueued a bare INJECT — which can only puppet an existing tab — instead of a DISPATCH, the cold-start path the box already runs (ensureBoxWorkspace → clone → owned PTY → agent). - inject-core: when no checkout is known, carry the directory the runner will clone into (coldStartWorkspaceDir — same derivation as resolveRunnerWorkspaceDir/ensureBoxWorkspace), so the queue gets a dispatch. - execution-access: policy, not physics — a clone-only project goes to the builder that clones when it is online, even with the laptop present. The lock tier is unchanged (repo-only stays portable; explicit fallback honored), so every existing routing assertion still holds. - tests: routing cases for clone-only shapes; a new pure test pinning that the queued dir equals what the runner derives. Fixes #575 and the box half of #580. Claude-Session: https://claude.ai/code/session_01KXoMmDTW3jq6xb1JC1Yh4e Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
/**
|
|
* Inline tests for coldStartWorkspaceDir — the `dir` a queued dispatch carries
|
|
* for a project that has a repo but no checkout.
|
|
* Run: npx tsx scripts/test/cold-start-workspace-dir.ts
|
|
*
|
|
* The contract: it must agree with the runner's own derivation
|
|
* (resolveRunnerWorkspaceDir / ensureBoxWorkspace), or the transcript path and
|
|
* the run path disagree during the first minute of a cold start.
|
|
*/
|
|
import path from "path";
|
|
import { coldStartWorkspaceDir } from "@/lib/execution-access";
|
|
import { BOX_DEV_ROOT, resolveRunnerWorkspaceDir } from "@/lib/agent-execution/box-workspace-path";
|
|
|
|
const CLONEABLE = "https://github.com/bitbaum/heidi";
|
|
|
|
const dir = coldStartWorkspaceDir("Heidi", CLONEABLE);
|
|
if (dir !== path.join(BOX_DEV_ROOT, "heidi")) throw new Error(`unexpected dir: ${dir}`);
|
|
if (dir !== resolveRunnerWorkspaceDir("Heidi", "")) {
|
|
throw new Error("must equal what the runner derives for the same tab with no requested dir");
|
|
}
|
|
if (
|
|
coldStartWorkspaceDir("Zürich Dialekt/App", CLONEABLE) !==
|
|
path.join(BOX_DEV_ROOT, "z-rich-dialekt-app")
|
|
) {
|
|
throw new Error("must sanitize the project name the way the runner does");
|
|
}
|
|
if (coldStartWorkspaceDir("Heidi", null) !== null)
|
|
throw new Error("no repo → nothing to materialize");
|
|
if (coldStartWorkspaceDir("Heidi", "not-a-url") !== null) throw new Error("uncloneable → null");
|
|
if (coldStartWorkspaceDir("Heidi", "") !== null) throw new Error("empty → null");
|
|
|
|
console.log("cold-start-workspace-dir: ok");
|