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
fix: use the promise chmod when materializing the screened review input, which failed every Stage 2 spawn
[._.]/ Adam Eivyfce26302a558
diff --git a/server/services/modelAbuseGuard.js b/server/services/modelAbuseGuard.jsindex 5f6b954830..b7f23287af 100644--- a/server/services/modelAbuseGuard.js+++ b/server/services/modelAbuseGuard.js@@ -9,7 +9,8 @@* credentials, or network access.*/-import { chmod, existsSync } from 'node:fs';+import { existsSync } from 'node:fs';+import { chmod } from 'node:fs/promises';import { homedir, platform } from 'node:os';import { dirname, join } from 'node:path';import { execFile, spawn } from '../lib/childProcess.js';diff --git a/server/services/modelAbuseGuard.materialize.test.js b/server/services/modelAbuseGuard.materialize.test.jsnew file mode 100644index 0000000000..6e63586da6--- /dev/null+++ b/server/services/modelAbuseGuard.materialize.test.js@@ -0,0 +1,51 @@+import { afterEach, describe, expect, it } from 'vitest';+import { mkdtemp, readFile, rm, stat } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { PATHS } from '../lib/fileUtils.js';+import {+ materializePublicReviewInput,+ materializePublicReviewPatches,+ writePublicReviewInputSnapshot,+ PUBLIC_REVIEW_INPUT_FILENAME,+ PUBLIC_REVIEW_PATCH_DIRNAME,+ PUBLIC_REVIEW_PATCH_MANIFEST_FILENAME,+} from './modelAbuseGuard.js';++// Runs against the real filesystem on purpose: the materializers were only ever+// exercised through mocks, which is how a callback-style `chmod` from `node:fs`+// (throws synchronously when called without a callback) shipped and failed every+// Stage 2 spawn with "The \"cb\" argument must be of type function".+const scanKey = 'a'.repeat(64);+const headSha = 'b'.repeat(40);+const pullRequests = [{+ number: 42,+ headSha,+ title: 'docs: example change',+ body: '',+ diff: 'diff --git a/README.md b/README.md\n+example\n',+}];++let workspace;+afterEach(async () => {+ if (workspace) await rm(workspace, { recursive: true, force: true });+ await rm(join(PATHS.cos, 'public-review-inputs', `${scanKey}.json`), { force: true });+});++describe('materializing the screened public-review snapshot', () => {+ it('writes the input file and the patch set read-only into the workspace', async () => {+ workspace = await mkdtemp(join(tmpdir(), 'portos-public-review-'));+ expect(await writePublicReviewInputSnapshot({ scanKey, pullRequests })).toBe(true);++ expect(await materializePublicReviewInput({ scanKey, workspacePath: workspace })).toBe(true);+ const input = JSON.parse(await readFile(join(workspace, PUBLIC_REVIEW_INPUT_FILENAME), 'utf8'));+ expect(input.pullRequests.map((pr) => pr.number)).toEqual([42]);+ expect((await stat(join(workspace, PUBLIC_REVIEW_INPUT_FILENAME))).mode & 0o222).toBe(0);++ expect(await materializePublicReviewPatches({ scanKey, workspacePath: workspace, allowedPullRequestNumbers: [42] })).toBe(true);+ const manifest = JSON.parse(await readFile(join(workspace, PUBLIC_REVIEW_PATCH_DIRNAME, PUBLIC_REVIEW_PATCH_MANIFEST_FILENAME), 'utf8'));+ expect(manifest.patches).toEqual([expect.objectContaining({ number: 42, headSha, path: `${PUBLIC_REVIEW_PATCH_DIRNAME}/PR-42.patch` })]);+ expect(await readFile(join(workspace, PUBLIC_REVIEW_PATCH_DIRNAME, 'PR-42.patch'), 'utf8')).toBe(pullRequests[0].diff);+ expect((await stat(join(workspace, PUBLIC_REVIEW_PATCH_DIRNAME, 'PR-42.patch'))).mode & 0o222).toBe(0);+ });+});