Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
address review (codex): skip the top-level clone when resuming a failed install
[._.]/ Adam Eivy8adc75d503cf
diff --git a/server/services/imageTo3d/trellis2.js b/server/services/imageTo3d/trellis2.jsindex ac18a54232..b2af05eb22 100644--- a/server/services/imageTo3d/trellis2.js+++ b/server/services/imageTo3d/trellis2.js@@ -60,17 +60,26 @@ export function isTrellis2Installed({ base, exists = existsSync } = {}) {/*** The install as an ordered list of `{stage, command, args, cwd?}` steps: shallow-* clone the port, then run its `setup.sh` (which builds the venv + fetches weights).- * Pure — the SSE install route executes these; keeping them a data structure makes- * the plan assertable without running it.+ * Keeping the plan a data structure makes it assertable without running it.+ *+ * **The clone step is skipped when the repo is already present** (`<root>/.git`+ * exists). This is load-bearing for resume: if a prior install cloned the top-level+ * repo but failed inside `setup.sh` (the common #2952 case — a dep clone dropped),+ * re-running with an unconditional `git clone … <root>` would abort ("destination+ * path already exists and is not an empty directory") and never reach the idempotent+ * `setup.sh`. `exists` is injectable so the skip is deterministic in tests.* @param {string} [base]+ * @param {{exists?: (p: string) => boolean}} [opts]* @returns {Array<{stage: string, command: string, args: string[], cwd?: string}>}*/-export function buildInstallSteps(base) {+export function buildInstallSteps(base, { exists = existsSync } = {}) {const root = trellis2Root(base);- return [- { stage: 'clone', command: 'git', args: ['clone', '--depth', '1', TRELLIS2_REPO, root] },- { stage: 'setup', command: 'bash', args: ['setup.sh'], cwd: root },- ];+ const steps = [];+ if (!exists(join(root, '.git'))) {+ steps.push({ stage: 'clone', command: 'git', args: ['clone', '--depth', '1', TRELLIS2_REPO, root] });+ }+ steps.push({ stage: 'setup', command: 'bash', args: ['setup.sh'], cwd: root });+ return steps;}/**@@ -176,8 +185,11 @@ export function installTrellis2({spawnImpl = spawn,maxRetries = 3,sleep = (ms) => new Promise((r) => setTimeout(r, ms)),+ exists = existsSync,} = {}) {- const steps = buildInstallSteps(base);+ // `exists` lets the clone step be skipped when the repo is already on disk (resume+ // after a setup-stage failure) — see buildInstallSteps.+ const steps = buildInstallSteps(base, { exists });let currentChild = null;let canceled = false;diff --git a/server/services/imageTo3d/trellis2.test.js b/server/services/imageTo3d/trellis2.test.jsindex 7068765c1e..abce673f51 100644--- a/server/services/imageTo3d/trellis2.test.js+++ b/server/services/imageTo3d/trellis2.test.js@@ -48,14 +48,24 @@ describe('isTrellis2Installed', () => {});describe('buildInstallSteps', () => {- it('clones the MPS port then runs its setup.sh', () => {- const steps = buildInstallSteps(BASE);+ it('clones the MPS port then runs its setup.sh when nothing is on disk', () => {+ const steps = buildInstallSteps(BASE, { exists: () => false });expect(steps.map((s) => s.stage)).toEqual(['clone', 'setup']);expect(steps[0]).toMatchObject({ command: 'git' });expect(steps[0].args).toContain(TRELLIS2_REPO);expect(steps[0].args).toContain(trellis2Root(BASE));expect(steps[1]).toMatchObject({ command: 'bash', args: ['setup.sh'], cwd: trellis2Root(BASE) });});++ it('skips the clone step and resumes at setup.sh when the repo is already present', () => {+ // A prior install cloned the top-level repo but failed inside setup.sh (the+ // #2952 case). Re-cloning into the non-empty root would abort, so resume must+ // begin at the idempotent setup.sh.+ const gitDir = `${trellis2Root(BASE)}/.git`;+ const steps = buildInstallSteps(BASE, { exists: (p) => p === gitDir });+ expect(steps.map((s) => s.stage)).toEqual(['setup']);+ expect(steps[0]).toMatchObject({ command: 'bash', args: ['setup.sh'], cwd: trellis2Root(BASE) });+ });});describe('buildGenerateArgs', () => {@@ -250,6 +260,21 @@ describe('installTrellis2', () => {await expect(promise).rejects.toMatchObject({ code: 'TRELLIS2_INSTALL_FAILED', stage: 'clone' });});+ it('resumes at setup (no re-clone) when the repo is already on disk', async () => {+ // Re-running Install after a setup-stage failure must NOT re-clone into the+ // existing root; it must go straight to the idempotent setup.sh.+ const child = makeChild();+ const spawnImpl = vi.fn(() => child);+ const gitDir = `${trellis2Root(BASE)}/.git`;+ const { promise } = installTrellis2({+ base: BASE, spawnImpl, exists: (p) => p === gitDir, sleep: () => Promise.resolve(),+ });+ expect(spawnImpl).toHaveBeenCalledTimes(1);+ expect(spawnImpl).toHaveBeenNthCalledWith(1, 'bash', ['setup.sh'], { cwd: trellis2Root(BASE) });+ child.emit('close', 0);+ await expect(promise).resolves.toEqual({ ok: true });+ });+it('retries a transient network failure in place and succeeds on the retry', async () => {// clone attempt 1 (transient fail) → clone attempt 2 (ok) → setup (ok)const children = [makeChild(), makeChild(), makeChild()];