fix: use owner-level unidesk state

This commit is contained in:
Codex
2026-07-10 05:09:13 +02:00
parent 01ff35d0f8
commit fbd9dbbae1
48 changed files with 133 additions and 148 deletions
+6 -5
View File
@@ -2,7 +2,7 @@ import { spawnSync } from "node:child_process";
import { closeSync, existsSync, ftruncateSync, lstatSync, mkdirSync, opendirSync, openSync, readdirSync, readFileSync, readSync, rmSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
import { basename, dirname, join, resolve } from "node:path";
import { type UniDeskConfig, repoRoot, rootPath } from "./config";
import { type UniDeskConfig, repoRoot, rootPath, stateRoot } from "./config";
import { runRemoteGcCommand } from "./gc-remote";
type GcRisk = "low" | "medium" | "high" | "blocked";
@@ -928,11 +928,12 @@ function yamlStateRoots(value: unknown, label: string): GcPathRoot[] {
return Object.entries(record).map(([id, rawPath]) => {
if (!/^[a-z0-9._-]+$/iu.test(id)) throw new Error(`${label}.${id} must use a simple id`);
const displayPath = yamlString(rawPath, `${label}.${id}`);
if (displayPath.startsWith("/") || displayPath.includes("..") || displayPath.includes("\\")) {
throw new Error(`${label}.${id} must be a repo-relative .state path without ..`);
if (displayPath.includes("..") || displayPath.includes("\\")) {
throw new Error(`${label}.${id} must be a canonical state path without ..`);
}
if (!displayPath.startsWith(".state/")) throw new Error(`${label}.${id} must start with .state/`);
return { id, displayPath, path: rootPath(...displayPath.split("/")) };
const path = resolvePath(displayPath);
if (!path.startsWith(`${stateRoot}/`)) throw new Error(`${label}.${id} must be under ${stateRoot}/`);
return { id, displayPath, path };
});
}