arborist/aborist/qa
russell@unturf.com f23d3a3067
qa: JSON-mode stop-sequence guards against post-brace token runaway
Bench data shows residual JSON-mode token runaway after the
pointer-ID switch: ~4 cases out of 66 land UNGROUNDED 0/0 at
12-15s instead of ~2-4s normal. Pattern: Hermes-3-8B emits a
valid claim object, then keeps generating whitespace / blank
lines until max_tokens (512) exhausts. The truncated payload
won't parse and the lenient pre-parser returns no claims.

Concrete instances in the latest bench (2026-04-30T19-55-11Z):
  - tell me about the apollo program (3/3 samples runaway)
  - tell me about the python programming language (1/3)

Fix: pass `stop=["\n\n"]` to the chat completion in JSON mode so
vLLM cuts generation at the first blank line. Well-formed JSON-
mode output never legitimately contains a blank line — Hermes
emits one object on a single line (or with simple internal
newlines), never `\n\n`. The stop sequence is the runaway
signature itself.

Plumbing:
  - OpenAICompatibleClient.chat_completion: new `stop` kwarg,
    injects into request payload when non-empty
  - StubClient already absorbs **kwargs; no change needed
  - DEFAULT_POLICY (runner) + DEFAULT_QUERY_POLICY (query) gain
    `claim_lattice_json_stop_sequences = ["\n\n"]`. Folds into
    governance_policy_hash so changing the stop list invalidates
    prior cached records.
  - Both call sites in runner.py / query.py read the policy
    field and pass it only on JSON mode (pointer + quote modes
    don't need it).

Defensive measure: worst case the stop sequence never fires;
best case the apollo/python residuals recover and JSON's
strict-rate climbs further.
2026-04-30 16:15:07 -04:00
..
__init__.py multi-source corpus query: pose a question, the tree pulls related cached docs 2026-04-27 11:43:57 -04:00
client.py qa: JSON-mode stop-sequence guards against post-brace token runaway 2026-04-30 16:15:07 -04:00
concepts.py concept overlay: synonym expansion + rivalry exclusion 2026-04-27 12:34:00 -04:00
dag.py qa: G0 claim-lattice-pointer answer mode — CTI quote-by-pointer 2026-04-29 21:19:19 -04:00
evidence.py qa: JSON mode uses pointer IDs (E1, E2, …) — close hallucination loop 2026-04-30 15:27:55 -04:00
inspect.py qa: per-claim status taxonomy on verifier + repair-action plans on sidecar 2026-04-29 18:37:52 -04:00
keys.py qa: dedup-mode policy + JIT fidelity — agents pick fast-cache vs audit-grade 2026-04-29 16:36:39 -04:00
parse_claims.py qa: G0 claim-lattice-pointer answer mode — CTI quote-by-pointer 2026-04-29 21:19:19 -04:00
query.py qa: JSON-mode stop-sequence guards against post-brace token runaway 2026-04-30 16:15:07 -04:00
repair.py qa: chain-segment failure localization + re-prompt repair tier 2026-04-29 19:27:33 -04:00
runner.py qa: JSON-mode stop-sequence guards against post-brace token runaway 2026-04-30 16:15:07 -04:00
verify.py qa: JSON mode uses pointer IDs (E1, E2, …) — close hallucination loop 2026-04-30 15:27:55 -04:00