PEP-87: drop another story's unfinished edits swept into this branch

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Асель 2026-11-14 23:43:58 +05:00
parent 8c702b1d4e
commit b47d2e8022
2 changed files with 0 additions and 32 deletions

View File

@ -643,8 +643,6 @@ async function main(): Promise<void> {
const ob = await outboxStats(db);
console.log(`outbox: ${ob.pending} ожидают, ${ob.failed} не доставлены`);
console.log(`раннеры: ${(await listSessions(db, { active: true })).length} активных · вопросы: ${(await pendingQuestions(db)).length} открытых`);
const foreign = await tmux.foreignServerEnv().catch(() => []);
if (foreign.length) console.log(`⚠ в окружении tmux-сервера чужие переменные: ${foreign.join(", ")} — агенты их унаследуют; очистятся при следующем запуске раннера или: ${foreign.map((n) => `tmux set-environment -g -u ${n}`).join("; ")}`);
const paired = new Set((await adminRecipients(db)).map((u) => u.login));
const admins = (await platformAdmins(db)).map((l) => `${l}${paired.has(l) ? " (Telegram)" : " (без Telegram)"}`);
console.log(`админы: ${admins.join(", ") || "нет"}`);

View File

@ -41,35 +41,6 @@ export interface NewTmuxSession {
width?: number;
}
/**
* PEP-69: names that must never come from a tmux server's global environment. Every session
* inherits it, and a server started by some test run or tool shell carries that process's
* GITEA_*, PEPPA_*, DATABASE_URL, MOCK_* — agents and their MCP then talk to the wrong place.
* What an agent needs is passed per session (`new-session -e`) or read from `.env`.
*/
const FOREIGN_ENV = /^(GITEA_|PEPPA_|MOCK_|DATABASE_URL$)/;
/** Foreign variables in the global environment of the tmux server (default server only). */
export async function foreignServerEnv(p: Pane = { name: "" }): Promise<string[]> {
// A dedicated socket (-L, tests) is its owner's own server: nothing foreign in it.
if (process.env.PEPPA_TMUX_SOCKET) return [];
let out: string;
try {
out = await tmuxOn(p, ["show-environment", "-g"]);
} catch (e) {
if (e instanceof HostUnreachable) throw e;
return []; // no server running
}
return out.split("\n").map((l) => l.split("=")[0]!.trim()).filter((k) => FOREIGN_ENV.test(k));
}
/** Removes them from the server's global environment; returns the names removed. */
export async function scrubServerEnv(p: Pane = { name: "" }): Promise<string[]> {
const names = await foreignServerEnv(p);
for (const n of names) await tmuxOn(p, ["set-environment", "-g", "-u", n]);
return names;
}
export async function newSession(s: NewTmuxSession): Promise<void> {
if (isRunnerClient()) return viaService("newSession", [s]);
const envArgs = Object.entries(s.env).flatMap(([k, v]) => ["-e", `${k}=${v}`]);
@ -77,7 +48,6 @@ export async function newSession(s: NewTmuxSession): Promise<void> {
// Keep the server up when its last session ends: otherwise a session created while the
// previous last one is being killed can land on a server that is shutting down.
await tmuxOn(p, ["start-server", ";", "set-option", "-s", "exit-empty", "off"]);
await scrubServerEnv(p).catch(() => {}); // PEP-69
await tmuxOn(p, ["new-session", "-d", "-s", s.name, "-c", s.cwd, "-x", String(s.width ?? 220), "-y", "50", ...envArgs, s.command]);
// Keep the pane after claude exits so the watchdog can read the exit status.
await tmuxOn(p, ["set-option", "-t", s.name, "remain-on-exit", "on"]);