feat(search): add calibrated retrieval and LangChain knowledge tool
Add exact and semantic evidence admission, measured calibration, bounded tool execution, and independent held-out evaluation preparation with regression coverage and operator guides. Real-provider quality gates remain pending. Validation: 1300 provider-free tests passed; 3 Windows symlink skips. PostgreSQL acceptance not rerun because TEST_DATABASE_URL is unset.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Live document MVP TODO
|
||||
|
||||
Updated 2026-10-07 against the revision 1.3 specifications.
|
||||
Updated 2026-10-08 against the revision 1.3 specifications and scoped-search repair review.
|
||||
|
||||
This checklist tracks implementation; it does not replace the governing
|
||||
[delivery plan](../specifications/RAG-AI-Phase1-Delivery-Plan.md),
|
||||
@@ -48,7 +48,7 @@ reported before promising a live demo.
|
||||
The four supplied examples are acceptance fixtures, not a filename allowlist
|
||||
or a four-document capacity limit.
|
||||
|
||||
## WP3 - Worker, review and publication (backend implemented; transport/selection pending)
|
||||
## WP3 - Worker, review and publication (backend implemented; authenticated transport and Live invalidation pending)
|
||||
|
||||
- [x] Add reviewed forward extraction-state/audit changes without editing applied revisions.
|
||||
- [x] Implement separate worker claim tokens, leases, heartbeats, bounded attempts and recovery.
|
||||
@@ -60,22 +60,22 @@ or a four-document capacity limit.
|
||||
- [x] Resume the same eligible failed document/job through the trusted retry backend/CLI after approval; fresh output requires fresh review. Authenticated D04 transport remains pending.
|
||||
- [x] Retain faithful complete FAQ extraction and explicitly approve included factual Q&A groups.
|
||||
- [x] Publish all validated chunks plus ready state in one transaction; keep new ready documents inactive.
|
||||
- [ ] Implement activation/selection revisions, access epochs and invalidation with the documented lock order.
|
||||
- [x] Implement atomic backend activation/selection, revision counters, access epochs and search-context rechecks with the documented lock order; see [search Phase 1/2 evidence](../agent-reference-map.md).
|
||||
- [x] Verify duplicate workers, expired leases, stale approvals, retries and partial failures against isolated PostgreSQL.
|
||||
|
||||
## WP4 - Shared scoped search
|
||||
|
||||
- [ ] Implement one backend pgvector search service using compatible bounded query embeddings.
|
||||
- [ ] Derive organization/user/conversation scope from backend identity.
|
||||
- [ ] Filter to authorized, ready, active and undeleted documents.
|
||||
- [ ] Combine semantic evidence with exact normalized identifiers and bounded context.
|
||||
- [ ] Return faithful text and document_id/chunk_id/location sources.
|
||||
- [x] Implement one backend pgvector search service using compatible bounded query embeddings; see [Phase 2 handoff](../guides/scoped-search-phase2.md).
|
||||
- [x] Resolve persisted enabled actors and derive organization/user scope at the trusted operator boundary; model arguments cannot override scope. Browser identity and owned conversation integration remain pending in WP2/WP5.
|
||||
- [x] Filter to authorized, ready, active, undeleted and unpurged documents in every retrieval branch.
|
||||
- [x] Combine semantic evidence with exact normalized identifiers and bounded untrusted context in the same retrieval core.
|
||||
- [x] Return faithful whole-chunk text, document_id/chunk_id/location and execution-wide source references within evidence budgets.
|
||||
- [ ] Evaluate real Persian questions, numbers, conditions, exceptions and insufficient-evidence behavior.
|
||||
- [ ] Record the measured decision on reranking/ANN; implement only if evaluation demonstrates a need.
|
||||
|
||||
## WP5 - LangChain and native Live
|
||||
|
||||
- [ ] Expose the shared search through a small LangChain retriever/tool boundary.
|
||||
- [x] Expose the shared search through a strict sync/async LangChain tool with lazy imports, bounded admission/deadlines, cancellation and shutdown; see [Phase 3 handoff](../guides/scoped-search-phase3.md).
|
||||
- [ ] Keep persistent secrets and provider-specific objects behind server adapters.
|
||||
- [ ] Add minimal owned voice conversations, Live sessions and voice tool-call persistence through forward migrations.
|
||||
- [ ] Implement session reservation and authenticated backend WSS audio relay to Gemini Live.
|
||||
@@ -101,6 +101,27 @@ or a four-document capacity limit.
|
||||
- [ ] Verify restart recovery, revocation, failure reporting and all MVP-01 through MVP-14 criteria.
|
||||
- [ ] Record actual results, remaining limits and demo run instructions.
|
||||
|
||||
## Scoped-search technical checkpoint (2026-10-08)
|
||||
|
||||
Search milestone phases below are separate from ingestion Phases 1-6.
|
||||
Implemented component checkmarks do not establish practical retrieval or Live readiness.
|
||||
|
||||
- [x] Phase 4 evaluation preparation and review repairs: 16 answerable and six unsupported original-derived draft annotations restored as UTF-8; status aligned; calibration-question overlap/malformed annotations rejected before settings/database/provider setup.
|
||||
- [x] Final repair review: 52 targeted provider-free tests rerun and passed; original hashes/status/DOCX literal checks, pip check, tracked whitespace and all three applied-migration byte comparisons passed.
|
||||
- [ ] Complete and freeze 20 answerable cases, including four unseen cases, plus six unsupported cases; obtain original approvals and required exact-output/factual DOCX human decisions. The unseen slots remain empty.
|
||||
- [ ] Bind approved original hashes to actual eligible ready documents and select the corpus through the atomic selection service.
|
||||
- [ ] Obtain funded-profile/provider-call authorization and separate bounded ingestion, calibration and evaluation budgets; measure and freeze the Phase 2 cutoff before held-out evaluation.
|
||||
- [ ] Rerun mandatory isolated PostgreSQL acceptance with --require-postgres for the current repair checkpoint. TEST_DATABASE_URL is absent; the earlier 311-pass result is historical.
|
||||
- [ ] Pass the real Phase 4 gate: at least 18/20, every critical case, all six unsupported cases returning no_evidence, and no unauthorized/ineligible sources.
|
||||
|
||||
The repair records a full provider-free run of 1300 passed with three existing
|
||||
Windows symlink skips; that full run was not repeated during final review.
|
||||
See the [Phase 4 operator guide](../guides/scoped-search-phase4.md),
|
||||
[status snapshot](../calibration/phase4-status.json) and
|
||||
[scoped-search plan](scoped-search-implementation-plan.md) for actual commands,
|
||||
historical results and remaining prerequisites. Quality acceptance is not run;
|
||||
provider calls are zero. Generated-answer and Live readiness remain unevaluated.
|
||||
|
||||
## Conditional delivery checkpoints
|
||||
|
||||
| Checkpoint | Required progress |
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
**Date:** 2026-10-07
|
||||
**Target file:** `docs/plans/scoped-search-implementation-plan.md`
|
||||
**Status:** Phase 1 first-result checkpoint implemented with provider-free PostgreSQL acceptance (2026-10-07); real-provider demonstration is pending ingestion database connectivity. Phases 2-4 remain pending. This four-phase plan replaces the earlier seven-phase proposal.
|
||||
**Status:** Phase 1 first-result checkpoint implemented with provider-free PostgreSQL acceptance (2026-10-07); real-provider demonstration is pending ingestion database connectivity. Phase 2 technical retrieval correctness is implemented with provider-free unit/PostgreSQL acceptance (2026-10-08); real-model cutoff calibration remains pending explicit call authorization and approved original/document bindings. Phase 3 thin LangChain integration is technically accepted (2026-10-08): 162 affected unit and 103 affected PostgreSQL tests (including the runner shutdown repair), zero skips, with the declared search extra installed; see [Phase 3 handoff](../guides/scoped-search-phase3.md). Phase 4 historical preparatory regressions passed (2026-10-08): 1258 provider-free tests and 311 mandatory isolated PostgreSQL tests. Real quality acceptance remains not run; see [Phase 4 handoff](../guides/scoped-search-phase4.md). All six Phase 2 repairs passed 107 affected unit tests, 100 isolated PostgreSQL tests and 1193 provider-free regression tests; see [repair acceptance](../guides/scoped-search-phase2-repairs.md) and [Phase 2 results](../guides/scoped-search-phase2.md). This four-phase plan replaces the earlier seven-phase proposal.
|
||||
|
||||
## 1. Delivery Strategy
|
||||
|
||||
@@ -211,7 +211,7 @@ Use a thin `StructuredTool` adapter with an explicit argument schema and synchro
|
||||
|
||||
Default execution limits: four running calls, eight waiting calls, and a 75-second total deadline. SQL statement/lock timeouts are five/two seconds. Validate configuration; retain the explicit provider timeout policy.
|
||||
|
||||
Cancellation suppresses late results. A running blocking call holds its slot until it exits, even if its caller times out. Queue waiting consumes the deadline. Saturation and timeout return normalized technical errors. Do not create unbounded executor queues or internal provider retries.
|
||||
Cancellation suppresses late results. A running blocking call holds its slot until it exits, even if its caller times out. Queue waiting consumes the deadline. Saturation and timeout return normalized technical errors. Do not create unbounded executor queues or internal provider retries. Runner closure returns nonretryable SEARCH_CANCELLED for queued/new calls and suppresses late running results. Repeated close is safe; submission and closure share a lock, submitted slots remain held until actual completion, and close joins work plus queued admission releases. Call blocking close outside active event loops and its worker pool. See [shutdown repair acceptance](../guides/scoped-search-phase3.md#shutdown-repair-acceptance-2026-10-08).
|
||||
|
||||
**Execution prompt**
|
||||
|
||||
@@ -332,3 +332,69 @@ Each phase reports its working command, observed output, actual checks, and rema
|
||||
No latency or concurrent-user service-level target has been approved. Measure timings and enforce the stated execution bounds without claiming an unapproved performance target. Actual provider runs require explicit opt-in, compatible credentials, approved inputs, and a bounded operator call budget.
|
||||
|
||||
**Speed rule:** finish and demonstrate each usable checkpoint before expanding it. Optimize only a reproduced quality or latency problem. The MVP search milestone remains incomplete until the confirmed real-quality gate passes.
|
||||
|
||||
|
||||
## Historical Phase 4 preparatory checkpoint (2026-10-08)
|
||||
|
||||
Final regression acceptance: 1258 provider-free passed, three existing Windows
|
||||
symlink skips; 311 mandatory isolated PostgreSQL passed with zero skips.
|
||||
pip check, tracked/new-file whitespace, Python/JSON inspection and byte
|
||||
preservation of all three applied migrations passed. No production fixes.
|
||||
|
||||
[Original annotations](../calibration/phase4-cases.draft.json) contain 16 draft
|
||||
answerable and six unsupported cases, with four explicitly empty unseen slots.
|
||||
Original SHA-256 hashes are recorded; approval and actual document bindings
|
||||
remain pending. This is not a completed/frozen 20-case set.
|
||||
[Opt-in evaluator](../../tests/evaluate_search.py) calls canonical SearchService
|
||||
with the frozen Phase 2 calibration, validates actual selection/bindings and
|
||||
sources, enforces a maximum 26-query call budget, retains every failure/not-run
|
||||
case, and applies the exact gate. Ten provider-free evaluation regressions pass.
|
||||
|
||||
[Status](../calibration/phase4-status.json) and
|
||||
[operator guide](../guides/scoped-search-phase4.md) record actual results.
|
||||
Real provider calls: zero. Phase 2 has no measured cutoff. Funded-profile/call
|
||||
authorization, approved unseen originals, human review/DOCX inclusion and actual
|
||||
ready document bindings remain missing. Phase 4 quality gate is not run;
|
||||
retrieval readiness, generated-answer readiness and Live readiness are not claimed.
|
||||
|
||||
Cleanup confirmed zero disposable schemas and zero public tables. The created
|
||||
Phase 4 test container and its anonymous volume were removed; existing containers
|
||||
were preserved. Temporary original-page renderings were removed. Baseline
|
||||
comparison found a concurrent change to scripts/live_voice_server.py, which this
|
||||
evaluation did not edit. All other unrelated baseline files were unchanged.
|
||||
|
||||
|
||||
## Phase 4 review repairs (2026-10-08)
|
||||
|
||||
The two review findings are fixed in the evaluation boundary. All 16 answerable
|
||||
and six unsupported annotations were reconstructed from actual original PDFs,
|
||||
infographic and DOCX, verified by strict UTF-8 read-back and synchronized with
|
||||
the status snapshot. Zero unresolved populated annotations; all four unseen
|
||||
slots remain empty. No original/review approvals or document bindings changed.
|
||||
|
||||
Question-only comparison against the supplied full Phase 2 report now rejects
|
||||
exact and formatting-equivalent overlap and missing/malformed annotations before
|
||||
settings/database/provider setup. NFKC, casefold, Persian/Arabic letter/digit
|
||||
variants, Unicode whitespace/format controls and terminal punctuation are
|
||||
comparison-only; original evidence and retrieval preprocessing remain unchanged.
|
||||
Different questions may share original documents; semantic paraphrases are not
|
||||
automatically detected. Safe errors identify the prerequisite/corrective action.
|
||||
|
||||
Current checks: **52 targeted tests passed**; full provider-free **1300 passed,
|
||||
3 existing Windows symlink skips, 311 deselected**; pip check, tracked/new-file
|
||||
whitespace, AST/JSON, persisted UTF-8 and all three migration byte comparisons
|
||||
passed. Mandatory isolated PostgreSQL is **not run**: TEST_DATABASE_URL is not
|
||||
configured. Earlier PostgreSQL counts remain historical evidence only.
|
||||
[Operator guide](../guides/scoped-search-phase4.md) and
|
||||
[status](../calibration/phase4-status.json) record commands and limitations.
|
||||
|
||||
Quality acceptance remains not_run with zero provider calls. Pending: measured
|
||||
Phase 2 cutoff/funded-profile authorization and bounded budget, approved
|
||||
originals/DOCX human review, actual eligible bindings and four unseen annotations.
|
||||
No retrieval, generated-answer or Live readiness is claimed.
|
||||
|
||||
Final preservation inspection observed a change to scripts/live_voice_server.py
|
||||
outside this repair. It was left untouched; all other unrelated baseline files
|
||||
were unchanged. All three applied migrations match HEAD byte-for-byte. Local
|
||||
documentation links and new-file inspection passed. Existing intentional Markdown
|
||||
hard breaks were preserved. Temporary original-image inspection files were removed.
|
||||
|
||||
Reference in New Issue
Block a user