Skip to content

fix(hooks,foraging,mcp): surface silent catch failures#495

Merged
NagyVikt merged 3 commits intomainfrom
agent/claude/fix-silent-catch-blocks
May 8, 2026
Merged

fix(hooks,foraging,mcp): surface silent catch failures#495
NagyVikt merged 3 commits intomainfrom
agent/claude/fix-silent-catch-blocks

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

@NagyVikt NagyVikt commented May 8, 2026

Summary

  • Replaces 9 empty catch {} / catch (err) {} (no body) blocks with console.error/process.stderr.write logging following the existing codebase pattern
  • Adds one-line WHY comments to 5 genuinely-tolerant catches (fs-stat races, best-effort marker cleanup, missing working-copy paths)
  • Colony rule test(tasks): lock down handoff lifecycle + hook injection #9 ("no silent failures") was the most-violated rule — a session with 43/43 failing MCP calls went unnoticed because failures vanished into empty catches

Sites changed (logged)

  • packages/hooks/src/handlers/session-start.ts: kickForagingScan, buildReadyClaimNudgePreface, buildAttentionBudgetSection, buildTaskPreface unreadMessages, buildSuggestionPreface (embed, findSimilarTasks, buildSuggestionPayload), resolveSuggestionEmbedder, loadSuggestionCore
  • packages/foraging/src/scanner.ts: scanExamplesFs readdirSync
  • apps/mcp-server/src/tools/foraging.ts: enrichForagingHits JSON.parse

Sites left intentionally silent (commented)

  • packages/hooks/src/handlers/session-start.ts: releaseForagingSessionStartScan (stale marker just delays next scan), readForagingSessionStartMarker (missing/malformed marker → proceed with scan)
  • packages/foraging/src/scanner.ts: statSync in directory loop (readdir/stat race), compactExistingPaths statSync (path absent from working copy), computeRufloContentHash statSync (variant path), fileExists, directoryExists

Test plan

  • pnpm typecheck passes
  • pnpm lint passes
  • pnpm --filter @colony/hooks test passes
  • pnpm --filter @colony/foraging test passes
  • pnpm --filter @colony/mcp-server test passes

NagyVikt and others added 3 commits May 8, 2026 19:40
Rule #9: no silent failures. Every empty catch in session-start,
scanner, and the foraging MCP tool now either logs
[colony] <site>: <message> to stderr or carries a one-line comment
explaining why tolerance is intentional (fs-stat races on missing
entries, best-effort marker cleanup). A whole session 43/43 MCP call
failures could previously vanish with no trace.
…e names

Wrap two overlong process.stderr.write/console.error calls to satisfy
biome line-length rule. Remove @colony/mcp-server from changeset
(private package) and drop to the two publishable packages.
@NagyVikt NagyVikt merged commit 829556b into main May 8, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant