fix(cowork-service): 3 bugs — flag names, IPC call guard, health status

BUG 1: feature-flags.ts had 3 wrong flag names + missing 3 from seed.ts
  - Removed: browser_extension_enabled, institutional_knowledge_enabled
  - Renamed: connectors_enabled → mcp_connectors_enabled
  - Added: llm_multi_model_enabled, telemetry_enabled, platform_auth_required
  - Fixed defaults to match seed.ts (marketplace_enabled=true, dispatch_api_enabled=true)
  - Now 13 flags exactly matching platform-service/src/modules/flags/seed.ts

BUG 2: ipc-bridge.ts call() had 'initialize' exemption that allowed null deref
  - If call('initialize') was invoked externally without start(), the guard
    passed but this.child!.stdin!.write() would crash with null dereference
  - During normal start(), child.stdin.writable is true so no exemption needed
  - Removed the method !== 'initialize' exemption

BUG 3: health routes didn't factor IPC bridge into overall health status
  - allOk only checked platform-service reachability
  - Now allOk = depsOk && ipcConnected — service reports 503 when bridge is down
  - IPC bridge disconnection makes health 'degraded' (correct — fallback mode works)

24 tests passing, typecheck clean.
This commit is contained in:
saravanakumardb1 2026-04-02 22:20:52 -07:00
parent 19674c7ef7
commit 2191427605
3 changed files with 14 additions and 9 deletions

View File

@ -9,18 +9,21 @@ import { config } from './config.js';
const registry = createFlagRegistry({
defaults: {
// ── Product-specific flags (seed.ts clawcowork entry) ──
sandbox_enabled: true,
plugins_enabled: true,
computer_use_enabled: false,
browser_extension_enabled: false,
connectors_enabled: true,
mcp_connectors_enabled: true,
scheduling_enabled: true,
computer_use_enabled: false,
parallel_agents_enabled: true,
marketplace_enabled: true,
wasm_plugins_enabled: false,
dispatch_api_enabled: false,
marketplace_enabled: false,
institutional_knowledge_enabled: false,
llm_multi_model_enabled: false,
audit_logging_enabled: true,
platform_auth_required: false,
dispatch_api_enabled: true,
// ── Common flag (from COMMON_FLAGS in seed.ts) ──
telemetry_enabled: false,
},
enabled: config.FEATURE_FLAGS_ENABLED,
});

View File

@ -109,7 +109,7 @@ export class IpcBridge {
/** Send a JSON-RPC call and await the response. */
async call(method: string, params: Record<string, unknown>): Promise<IpcResponse> {
if (!this.child?.stdin?.writable && method !== 'initialize') {
if (!this.child?.stdin?.writable) {
throw new Error('IPC bridge not started');
}

View File

@ -31,13 +31,15 @@ export async function healthRoutes(app: FastifyInstance) {
};
}
const allOk = Object.values(checks).every(c => c.status === 'ok');
const ipcConnected = getIpcBridge().isRunning;
const depsOk = Object.values(checks).every(c => c.status === 'ok');
const allOk = depsOk && ipcConnected;
reply.code(allOk ? 200 : 503);
return {
status: allOk ? 'ok' : 'degraded',
service: config.SERVICE_NAME,
productId: PRODUCT_ID,
ipcBridge: getIpcBridge().isRunning ? 'connected' : 'disconnected',
ipcBridge: ipcConnected ? 'connected' : 'disconnected',
checks,
timestamp: new Date().toISOString(),
};