Skip to content

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

fix: await protocol events and parallelize atlas CI fixtures

[._.]/ Adam Eivyb597019baf3b
diff --git a/server/services/codexAppServer.turn.test.js b/server/services/codexAppServer.turn.test.js
index 3855049a92..7b440cbe14 100644
--- a/server/services/codexAppServer.turn.test.js
+++ b/server/services/codexAppServer.turn.test.js
@@ -41,7 +41,12 @@ const makeChild = () => {
child.stderr = new EventEmitter();
child.stdin = Object.assign(new EventEmitter(), {
destroyed: false,
- write: (line, cb) => { child.written.push(JSON.parse(line)); cb?.(); return true; },
+ write: (line, cb) => {
+ child.written.push(JSON.parse(line));
+ child.emit('request-written');
+ cb?.();
+ return true;
+ },
});
child.kill = vi.fn(() => { child.emit('exit', null, 'SIGTERM'); });
child.emitFrame = (frame) => child.stdout.emit('data', `${JSON.stringify(frame)}\n`);
@@ -61,8 +66,27 @@ const makeChild = () => {
/** Wait for PortOS to write `method`, then run `answer` against that frame. */
const awaitRequest = async (child, method, answer) => {
- let frame = null;
- await vi.waitFor(() => { frame = child.take(method); expect(frame).toBeTruthy(); });
+ // Scratch-directory creation is real async I/O, not a one-second protocol
+ // deadline. Await the fake wire itself within the enclosing test's budget.
+ const frame = await new Promise((resolve, reject) => {
+ const cleanup = () => {
+ child.off('request-written', check);
+ child.off('exit', exited);
+ };
+ const check = () => {
+ const request = child.take(method);
+ if (!request) return;
+ cleanup();
+ resolve(request);
+ };
+ const exited = () => {
+ cleanup();
+ reject(new Error(`App-server exited before writing ${method}`));
+ };
+ child.on('request-written', check);
+ child.once('exit', exited);
+ check();
+ });
if (typeof answer === 'function') answer(frame);
else child.reply(frame, answer);
return frame;
diff --git a/server/services/sprites/atlas.test.js b/server/services/sprites/atlas.test.js
index 71d68b775a..e5a981cbdd 100644
--- a/server/services/sprites/atlas.test.js
+++ b/server/services/sprites/atlas.test.js
@@ -194,15 +194,16 @@ async function buildFinalizedScannerSet(recordId, {
status: 'complete',
directions: {},
};
- for (const direction of SPRITE_DIRECTIONS) {
+ // Independent fixture files can be materialized together; retain registry
+ // order when hashing the selection rather than completion order on disk.
+ const directions = await Promise.all(SPRITE_DIRECTIONS.map(async direction => {
const runId = `${trackId}-${direction}-${(seq++).toString(16).padStart(8, '0')}`;
const generatedRel = `runs/${runId}/generated`;
- const frames = [];
- for (let i = 0; i < labels.length; i++) {
+ const frames = await Promise.all(labels.map(async (phase, i) => {
const rel = `${generatedRel}/frames/${String(i).padStart(2, '0')}-${labels[i]}.png`;
await walkFramePng(join(dir, rel), 36 + i * 12, 2 + i * 2);
- frames.push({ outputIndex: i, phase: labels[i], path: rel, sha256: sha256(await readFile(join(dir, rel))) });
- }
+ return { outputIndex: i, phase, path: rel, sha256: sha256(await readFile(join(dir, rel))) };
+ }));
const runManifest = {
schemaVersion: 1,
kind: `deterministically-packaged-grok-${trackId}-video`,
@@ -217,11 +218,12 @@ async function buildFinalizedScannerSet(recordId, {
const manifestRel = `${generatedRel}/${recordId}-${trackId}-${direction}-manifest.json`;
const manifestBytes = JSON.stringify(runManifest);
await writeFile(join(dir, manifestRel), manifestBytes);
- selection.directions[direction] = {
+ return [direction, {
status: 'approved', runId, runPath: `runs/${runId}`, runManifest: manifestRel,
runManifestSha256: sha256(Buffer.from(manifestBytes)), approvedAt: new Date().toISOString(),
- };
- }
+ }];
+ }));
+ selection.directions = Object.fromEntries(directions);
await mkdir(join(dir, trackId), { recursive: true });
const selectionRel = `${trackId}/${recordId}-${trackId}-selection-v1.json`;
const selectionBytes = JSON.stringify(selection);