Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
chore(wave18b): lane 2 release notes and shared-file manifest
garrytanaa464808d63b
diff --git a/.wave18b/lane2-manifest.md b/.wave18b/lane2-manifest.mdnew file mode 100644index 0000000000..43b7b0dfca--- /dev/null+++ b/.wave18b/lane2-manifest.md@@ -0,0 +1,22 @@+# Wave 18b lane 2: shared-file manifest++Every edit to a shared registry, golden or generated file in this lane, for the+integrator. All are appends or regenerations; no existing assertion was weakened.++| File | Edit | Why |+|---|---|---|+| `src/core/config.ts` | +1 `KNOWN_CONFIG_KEYS` row `search.keyword_timeout_negative_cache_seconds` | 2.2 config key |+| `test/config-search-registry.test.ts` | +1 `DIRECTLY_READ_SINGLETONS` row for the same key | registry test requires every registered `search.*` key to name its reader |+| `src/commands/config/keyword-timeout-value.ts` | new branch in `refuseInvalidKeywordTimeoutValue` for the new key | `config set` validator (no `src/commands/config.ts` edit; the existing `search.` hook routes to it) |+| `src/core/error-registry.ts` | +1 `CODES` entry `keyword_skipped_after_timeout`; +1 `NOTICE_CODES` entry `facts_calibration_unmeasured` | 2.2 skip code, 2.3 notice |+| `docs/guides/error-codes.md` | regenerated (`bun run build:error-codes`) | so this lane's `verify` passes; integrator regenerates once after merging |+| `src/core/types.ts` | +1 `DEGRADED_REASONS` member `skipped_after_timeout`; +1 `SearchOpts.keywordTimeoutCache`; one doc line on `useCache` | 2.2 |+| `src/core/interop-notices.ts` | `degradedRecallNotice` names `keyword_arm_failed: skipped_after_timeout` with its own why and the `doctor --only keyword_plan` fix | 2.2 reason registered with why/fix |+| `scripts/module-size-limits.tsv` | ceilings: `postgres-engine.ts` 3060 -> 3063, `types.ts` 2315 -> 2319, `config.ts` 1979 -> 1980 (notes appended) | façade growth for 2.2 |+| `test/postgres-unit-arms.txt` | +1 row `test/keyword-timeout-negative-cache-6495.test.ts` | its DATABASE_URL-gated arm runs in a Postgres lane (`check:postgres-lanes`) |+| `test/fixtures/goldens/exports/types.json` | regenerated | `DEGRADED_REASONS`/`DegradedReason`, `SearchOpts.keywordTimeoutCache`, `PostgresEngine` private `keywordTimeouts` |+| `test/fixtures/goldens/doctor/json-postgres-fresh.json`, `test/fixtures/goldens/doctor/hot-checks-postgres-json.json` | regenerated on Postgres | `keyword_plan.details.negative_cache` (only diff) |++Not touched: doctor `registry.ts`, `doctor-categories.ts` (no new check), `run-verify-parallel.sh` (the 2.1 call-site guard is a unit test, not a verify script), `registry-build-checks.json`, `llms*.txt`, CHANGELOG, `BEHAVIOR_CHANGES`, VERSION.++Docs edited (not registries): `docs/guides/troubleshooting.md`, `docs/mcp/TOOL_REFERENCE.md`, `docs/protocol/MEMORY_VERBS_v1.md`, `docs/architecture/key-files/engines-2.md`, `docs/architecture/key-files/graph-and-facts.md`.diff --git a/.wave18b/lane2-release-notes.md b/.wave18b/lane2-release-notes.mdnew file mode 100644index 0000000000..b4e9702324--- /dev/null+++ b/.wave18b/lane2-release-notes.md@@ -0,0 +1,29 @@+# Wave 18b lane 2: proposed release notes (search and recall correctness)++The integrator assembles these into CHANGELOG and `BEHAVIOR_CHANGES`; no version+header or `since:` value is set here.++## CHANGELOG bullets ("What you'd see" rows and itemized changes)++### What you'd see++| Situation | Before | Now |+|---|---|---|+| A brain with `embedding_query_prefix` set runs `gbrain think`, MCP `think`, `synthesize`, CRAG think escalation or dream auto-think | the question's takes vector embedded without the prefix | embedded with the brain's prefix, like hybrid search |+| `gbrain takes search --semantic`, `gbrain search diagnose`, eval's vector baseline, `gbrain brainstorm` on a prefix brain | bare query embedding | prefixed query embedding (saved eval baselines on prefix brains move) |+| A broad hybrid keyword search on a large Postgres brain times out, then the same search runs again in the same `gbrain serve` / MCP process | waits the full `search.keyword_statement_timeout_ms` again and times out again | answers at once from the vector arm with `keyword_arm_failed: skipped_after_timeout` for 10 minutes (`search.keyword_timeout_negative_cache_seconds`, 0 = off); a narrower or differently scoped query still runs keyword search |+| `recall --question` on an embedding model whose fact admission floors were never measured | nothing says the floors are unmeasured | an informational `facts_calibration: {status: "unmeasured", model_key}` field on every such call, and one `facts_calibration_unmeasured` info notice per session pointing at `gbrain doctor --only fact_admission_floors` |++### Itemized changes++- `src/core/search/query-prefix.ts`: `embedQueryWithPrefix(engine, text, opts?)` loads the brain's `embedding_query_prefix` and embeds with the unbounded `embedQuery`, so each caller keeps its deadline behavior. Swapped in at `ops/search.ts` (CRAG), `verbs.ts` (synthesize), `commands/think.ts`, `commands/takes.ts`, `ops/takes.ts` (MCP think), `cycle/auto-think.ts`, `commands/search-diagnose.ts`, `search/eval.ts` and `brainstorm/orchestrator.ts` (a ninth site the guard found). `test/query-embed-call-sites.test.ts` walks the AST and allowlists the remaining direct `embedQuery` / `embedQueryBounded` uses with reasons (#3783).+- `src/core/postgres-engine/keyword-timeout-cache.ts` (new): a per-engine negative cache keyed on the keyword statement text, its parameters, the RLS source scope and the statement timeout (strict and relaxed statements separately). Only a genuine statement-timeout 57014 records an entry, never a user or admin cancel; entries expire at the TTL, at most 256 per engine. Hybrid's keyword arm opts in (`SearchOpts.keywordTimeoutCache`) unless the call passed `useCache: false`; a skip reports `keyword_arm_failed` with the new degraded reason `skipped_after_timeout` and error code `keyword_skipped_after_timeout` (fix: `gbrain doctor --only keyword_plan --json`). No extra statement per search; the TTL is read on the first timeout and each timeout writes one bounded `search.keyword_timeout_stats` row, which doctor `keyword_plan` reports as `details.negative_cache`. New config key `search.keyword_timeout_negative_cache_seconds` (integer seconds, default 600, range 0-86400, 0 = off; `config set` refuses other values). Per process: `serve` and MCP benefit, one-shot CLI calls do not. Postgres only (#6495).+- `src/core/facts/question-recall.ts`, `src/core/ops/facts.ts`, `src/core/verbs.ts`: recall's informational `facts_calibration` (declared in `RESPONSE_SCHEMAS`, `docs/protocol/MEMORY_VERBS_v1.md`, `docs/mcp/TOOL_REFERENCE.md`) and the `facts_calibration_unmeasured` info notice, deduped per brain per session through the notice ledger's `dedupe_key`. `facts_degraded` and `degraded_recall` are unchanged. `FACT_ADMISSION_FLOOR_EVIDENCE` moves to `search/fact-relevance.ts` so recall and doctor read one table (#6590).+- Tests: `test/query-prefix-call-sites.serial.test.ts` (eight paths record the prefix through a stubbed transport), `test/query-embed-call-sites.test.ts`, `test/keyword-timeout-negative-cache-6495.test.ts` (unit arm on an injected executor plus a Postgres arm with locked tables), `test/recall-facts-calibration-6590.test.ts`. Each fails on master.+- Docs: `docs/guides/troubleshooting.md` (keyword timeout section and symptom row: the skip, its key, its limits), `docs/mcp/TOOL_REFERENCE.md` (`search`/`query` keyword reason, recall `facts_calibration`), `docs/protocol/MEMORY_VERBS_v1.md` (field row), key-files entries.++## Proposed BEHAVIOR_CHANGES rows (`since:` left to the integrator)++- `think`, MCP `think`, `synthesize`, CRAG think escalation (`search.crag_think`), dream auto-think, `takes search --semantic`, `search diagnose`, `gbrain eval` vector baselines and `brainstorm` now embed their query with the brain's `embedding_query_prefix`, like hybrid search already did; on a brain with a prefix their retrieval shifts and saved eval baselines move.+- On Postgres, a hybrid keyword statement that hit `search.keyword_statement_timeout_ms` is skipped for `search.keyword_timeout_negative_cache_seconds` (default 600 s, 0 = off) in the same serving process when the same statement and scope run again: the search answers from the vector arm with `keyword_arm_failed: skipped_after_timeout` instead of waiting for the timeout. A narrower or differently scoped query, another brain and `use_cache: false` still run it; each timeout writes one `search.keyword_timeout_stats` row that doctor `keyword_plan` reports.+- `recall` with `question` adds an informational `facts_calibration: {status: "unmeasured", model_key}` when semantic matching ranked facts on an embedding model without measured admission floors, and shows one `facts_calibration_unmeasured` info notice per brain per session (mute with `gbrain notices mute facts_calibration_unmeasured`); `facts_degraded` is unchanged.