Skip to content

Commit 9392b2b

Browse files
committed
chore: move daemon invalidation out of perf PR
1 parent 7d5f248 commit 9392b2b

4 files changed

Lines changed: 24 additions & 116 deletions

File tree

src/daemon-client.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { runCmdDetached, runCmdSync } from './utils/exec.ts';
1313
import { findProjectRoot, readVersion } from './utils/version.ts';
1414
import { createRequestId, emitDiagnostic, withDiagnosticTimer } from './utils/diagnostics.ts';
1515
import { isAgentDeviceDaemonProcess, stopProcessForTakeover } from './utils/process-identity.ts';
16-
import { computeDaemonCodeSignature as computeSharedDaemonCodeSignature } from './daemon/code-signature.ts';
1716
import {
1817
resolveDaemonPaths,
1918
resolveDaemonServerMode,
@@ -739,7 +738,13 @@ export function computeDaemonCodeSignature(
739738
entryPath: string,
740739
root: string = findProjectRoot(),
741740
): string {
742-
return computeSharedDaemonCodeSignature(entryPath, root);
741+
try {
742+
const stat = fs.statSync(entryPath);
743+
const relativePath = path.relative(root, entryPath) || entryPath;
744+
return `${relativePath}:${stat.size}:${Math.trunc(stat.mtimeMs)}`;
745+
} catch {
746+
return 'unknown';
747+
}
743748
}
744749

745750
async function sendRequest(

src/daemon/code-signature.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

src/daemon/server-lifecycle.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'node:fs';
2-
import { readVersion } from '../utils/version.ts';
2+
import path from 'node:path';
3+
import { findProjectRoot, readVersion } from '../utils/version.ts';
34
import { isAgentDeviceDaemonProcess, readProcessStartTime } from '../utils/process-identity.ts';
4-
import { resolveDaemonCodeSignature as resolveSharedDaemonCodeSignature } from './code-signature.ts';
55

66
export type DaemonLockInfo = {
77
pid: number;
@@ -11,7 +11,16 @@ export type DaemonLockInfo = {
1111
};
1212

1313
export function resolveDaemonCodeSignature(): string {
14-
return resolveSharedDaemonCodeSignature(process.argv[1]);
14+
const entryPath = process.argv[1];
15+
if (!entryPath) return 'unknown';
16+
try {
17+
const stat = fs.statSync(entryPath);
18+
const root = findProjectRoot();
19+
const relativePath = path.relative(root, entryPath) || entryPath;
20+
return `${relativePath}:${stat.size}:${Math.trunc(stat.mtimeMs)}`;
21+
} catch {
22+
return 'unknown';
23+
}
1524
}
1625

1726
export function writeInfo(

src/utils/__tests__/daemon-client.test.ts

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,42 +1032,14 @@ test('downloadRemoteArtifact times out stalled artifact responses and removes pa
10321032
}
10331033
});
10341034

1035-
test('computeDaemonCodeSignature fingerprints the daemon source tree', () => {
1035+
test('computeDaemonCodeSignature includes relative path, size, and mtime', () => {
10361036
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-daemon-signature-'));
10371037
try {
1038-
const daemonEntryPath = path.join(root, 'src', 'daemon.ts');
1039-
const perfPath = path.join(root, 'src', 'platforms', 'ios', 'perf.ts');
1040-
fs.mkdirSync(path.dirname(perfPath), { recursive: true });
1038+
const daemonEntryPath = path.join(root, 'dist', 'src', 'daemon.js');
1039+
fs.mkdirSync(path.dirname(daemonEntryPath), { recursive: true });
10411040
fs.writeFileSync(daemonEntryPath, 'console.log("daemon");\n', 'utf8');
1042-
fs.writeFileSync(perfPath, 'export const value = 1;\n', 'utf8');
1043-
1044-
const firstSignature = computeDaemonCodeSignature(daemonEntryPath, root);
1045-
assert.match(firstSignature, /^src:\d+:[a-f0-9]{16}$/);
1046-
1047-
fs.writeFileSync(perfPath, 'export const value = 2;\n', 'utf8');
1048-
const secondSignature = computeDaemonCodeSignature(daemonEntryPath, root);
1049-
assert.notEqual(secondSignature, firstSignature);
1050-
} finally {
1051-
fs.rmSync(root, { recursive: true, force: true });
1052-
}
1053-
});
1054-
1055-
test('computeDaemonCodeSignature ignores source test files', () => {
1056-
const root = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-device-daemon-signature-tests-'));
1057-
try {
1058-
const daemonEntryPath = path.join(root, 'src', 'daemon.ts');
1059-
const runtimePath = path.join(root, 'src', 'platforms', 'ios', 'perf.ts');
1060-
const testPath = path.join(root, 'src', 'platforms', 'ios', '__tests__', 'perf.test.ts');
1061-
fs.mkdirSync(path.dirname(testPath), { recursive: true });
1062-
fs.writeFileSync(daemonEntryPath, 'console.log("daemon");\n', 'utf8');
1063-
fs.writeFileSync(runtimePath, 'export const value = 1;\n', 'utf8');
1064-
fs.writeFileSync(testPath, 'export const ignored = 1;\n', 'utf8');
1065-
1066-
const firstSignature = computeDaemonCodeSignature(daemonEntryPath, root);
1067-
fs.writeFileSync(testPath, 'export const ignored = 2;\n', 'utf8');
1068-
const secondSignature = computeDaemonCodeSignature(daemonEntryPath, root);
1069-
1070-
assert.equal(secondSignature, firstSignature);
1041+
const signature = computeDaemonCodeSignature(daemonEntryPath, root);
1042+
assert.match(signature, /^dist\/src\/daemon\.js:\d+:\d+$/);
10711043
} finally {
10721044
fs.rmSync(root, { recursive: true, force: true });
10731045
}

0 commit comments

Comments
 (0)