ask-is-fault-tolerant-and-bounded

IN derived (depth 1)

The ask module is fault-tolerant (always returns a string, catches LLM failures, falls back to raw FTS5 search) and execution-bounded (tool loop capped at 3 iterations), ensuring reliable bounded knowledge retrieval regardless of LLM availability.

Summary

The ask module is designed to never fail and never hang. It guarantees a string result no matter what happens — if the LLM times out or crashes, it falls back to raw search results instead of raising an error, and if the LLM gets stuck in a loop requesting more searches, it gets cut off after 3 iterations. This means any code calling ask can treat it as a reliable, predictable function without needing its own error handling for LLM flakiness.

Justifications

SL — Three independent safety properties (guaranteed return type, exception handling, iteration bound) form a complete reliability contract for the ask module

Antecedents (all must be IN):

  • ask-always-returns-string — `ask()` returns a string on every code path — LLM response, raw search results, or fallback; it never raises an exception to the caller.
  • ask-never-raises-on-llm-failure — `ask()` catches `TimeoutExpired` and `RuntimeError` from `_invoke_claude()` and returns raw FTS5 search results instead of propagating the exception — the function guarantees a string return.
  • ask-agentic-loop-is-bounded — The tool-call loop in `ask()` has a maximum iteration count; an LLM that perpetually requests more searches is terminated and the raw response is returned.

Dependents

These beliefs depend on this one:

Details