Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(serve): a read-only stdio serve takes the one-shot direct-pool profile (#7599)
garrytanafd393426fd2
diff --git a/src/core/direct-pool-profile.ts b/src/core/direct-pool-profile.tsindex dbc091537e..6986f6fc3a 100644--- a/src/core/direct-pool-profile.ts+++ b/src/core/direct-pool-profile.ts@@ -1,7 +1,8 @@/*** How much of the direct (session) lane this process may hold. The CLI sets it* once per command; every other caller (embedders, tests) stays resident.- * - resident: daemons (serve, jobs, autopilot, sync --watch) keep the full pool.+ * - resident: daemons (serve, jobs, autopilot, sync --watch) keep the full pool; a stdio+ * `serve --access read-only` is one_shot instead (#7599), since harnesses run one per session.* - short_lived: a command that owns a consumer or takes a lease gets one connection.* - one_shot: a command that takes no lease routes nothing through the direct* pool; schema DDL still uses one connection for its session advisory lock@@ -20,6 +21,7 @@ const SHORT_LIVED_COMMANDS = new Set(['sync', 'mcp', 'dream', 'cycle', 'sources'let processProfile: DirectPoolProfile = 'resident';export function directPoolProfileForCommand(command: string, args: readonly string[]): DirectPoolProfile {+ if (command === 'serve' && args.includes('--access') && args[args.indexOf('--access') + 1] === 'read-only') return 'one_shot';if (RESIDENT_COMMANDS.has(command) || (command === 'sync' && args.includes('--watch'))) return 'resident';return SHORT_LIVED_COMMANDS.has(command) ? 'short_lived' : 'one_shot';}diff --git a/test/direct-pool-profile.test.ts b/test/direct-pool-profile.test.tsindex 3d35134386..1acd68d069 100644--- a/test/direct-pool-profile.test.ts+++ b/test/direct-pool-profile.test.ts@@ -42,6 +42,13 @@ describe('directPoolProfileForCommand', () => {expect(directPoolProfileForCommand(command, [])).toBe('one_shot');});+ test('#7599: a read-only stdio serve is one-shot; a read-write serve stays resident', () => {+ expect(directPoolProfileForCommand('serve', ['--access', 'read-only'])).toBe('one_shot');+ expect(directPoolProfileForCommand('serve', ['--surface', 'full', '--access', 'read-only'])).toBe('one_shot');+ for (const args of [[], ['--access', 'full'], ['--surface', 'read-only'], ['--http', '--port', '8080']])+ expect(directPoolProfileForCommand('serve', args)).toBe('resident');+ });+test('every claim owner keeps a direct route', () => {for (const command of OWNER_COMMANDS) expect(directPoolProfileForCommand(command, [])).not.toBe('one_shot');});