fix: guard session_ids with optional chaining to prevent crash

boulderState?.session_ids.includes() only guards boulderState, not
session_ids. If boulder.json is corrupted or missing the field,
session_ids is undefined and .includes() crashes silently, losing
subagent results.

Changes:
- readBoulderState: validate parsed JSON is object, default session_ids to []
- atlas hook line 427: boulderState?.session_ids?.includes
- atlas hook line 655: boulderState?.session_ids?.includes
- prometheus-md-only line 93: boulderState?.session_ids?.includes
- appendSessionId: guard with ?. and initialize to [] if missing

Fixes #1672
This commit is contained in:
YeonGyu-Kim
2026-02-09 10:01:08 +09:00
parent ebbb65c770
commit f7436903f0
4 changed files with 15 additions and 5 deletions
@@ -43,7 +43,7 @@ export function getAgentFromSession(sessionID: string, directory: string): strin
// Check boulder state (persisted across restarts) - fixes #927
const boulderState = readBoulderState(directory)
if (boulderState?.session_ids.includes(sessionID) && boulderState.agent) {
if (boulderState?.session_ids?.includes(sessionID) && boulderState.agent) {
return boulderState.agent
}