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.
12 KiB
Phase 2 repair acceptance (2026-10-08)
These repairs extend the existing shared retrieval core. Real-model quality acceptance remains pending; no real provider calls were made and no cutoff was invented.
Current acceptance for the two additional repairs is recorded in the remaining-repairs section. Earlier counts below are historical.
Reproductions and corrections
| Defect | Reproduction before repair | Correction and regression evidence |
|---|---|---|
| Canonical handoff after unlocked retrieval | Three PostgreSQL barriers returned ok after removal, actor disablement or authority change committed between candidate retrieval and publication. A unit commit-failure case also published references. | Finalization takes settings-first persisted authority locks, checks enabled actor and the execution's pinned epoch, admits evidence and stages references inside a short transaction. Successful commit is the service handoff boundary; failed/revoked finalization publishes no references. Bounded candidate barriers cover all three mutations; admission barriers prove removal/disablement cannot commit while finalization holds locks. Existing provider barriers and execution-wide reference tests pass. |
| Terminal punctuation destroys exact patterns | Ten unit punctuation cases failed; ten corrected PostgreSQL recovery cases failed with the target outside the first 50 semantic candidates. | Python extraction and parameterized PostgreSQL boundaries accept terminal periods while retaining internal separators. Regressions cover query, context and source punctuation, Persian/Arabic digits and kaf/yeh, article/date/identifier patterns, separator distinctions, partial-match rejection and quantities. Eighteen real PostgreSQL recovery cases exercise the exact branch beyond the semantic limit. Comparison policy is v2; embedding preprocessing is unchanged. |
| Final calibration failures discard reports | Final SQL revalidation exceptions escaped after completed observations; revoked reports lost timings, and the CLI produced no retained report. | SQL and authority failures retain a technical_error report with cutoff=null, actual call counts, completed timings and safe categories. Unconfirmed evidence/query annotations are suppressed, safe binding/profile metadata remains, and cutoff loading rejects failed reports. Six deterministic final-failure cases, two real SQL final-failure cases and CLI readability/exclusive-output tests pass without extra calls. |
| SQL errors are indiscriminately retryable | Permanent/unknown SQL failures were retryable; pool timeout normalization was missing. | Timeout normalization remains. Only explicit transient SQLSTATEs and disconnection errors are retryable; permanent and unknown errors default false. Unit and real PostgreSQL cases cover undefined table, permission, syntax, timeout, serialization/deadlock and unknown errors, with safe constant messages. |
Before production changes, the new unit regressions reported 25 failed, 14 passed (1.51 seconds). The corrected exact-recovery PostgreSQL reproduction reported 10 failed, 10 deselected (15.53 seconds). An initial test fixture SQL literal was corrected before that reproduction; it was not a product defect.
The service boundary protects canonical result handoff at transaction commit. Future transport delivery has no implemented guard and is not certified by these tests. Provider calls remain outside database transactions. Eligibility before ranking/limits, deterministic chunk-ID merge, five whole chunks within 12,000 evidence-text characters, faithful text and actual nullable locators remain unchanged.
Executed checks
All PostgreSQL commands used this existing isolated test database, with disposable schemas only:
$env:TEST_DATABASE_URL = 'postgresql+psycopg://postgres:search-test-only@127.0.0.1:54938/rag_scoped_search_test'
.venv/Scripts/python -m tests.postgres_prerequisites
.venv/Scripts/python -m pytest tests/unit/test_scoped_search.py tests/unit/test_search_phase2.py tests/unit/test_search_phase2_repairs.py -q --tb=short
.venv/Scripts/python -m pytest tests/integration/test_scoped_search.py tests/integration/test_search_phase2.py tests/integration/test_search_phase2_repairs.py --require-postgres -q --tb=short
.venv/Scripts/python -m pytest -m 'not postgres' -q --tb=short
.venv/Scripts/python -m pip check
.venv/Scripts/python -B -m app.search --help
.venv/Scripts/python -B -m app.calibrate_search --help
git diff --check
- Prerequisite probe: PostgreSQL 16.15, pgvector 0.8.7.
- Affected unit tests: 75 passed, 0.91 seconds.
- Affected isolated PostgreSQL tests: 97 passed, zero skips, 128.65 seconds.
- Full provider-free regression: 1161 passed, 3 skipped, 305 deselected, 58.59 seconds. Skips are existing Windows symlink privilege cases.
- pip check: No broken requirements found.
- Both CLI help commands passed. AST, new-file whitespace, local documentation links and tracked diff whitespace passed.
- Applied migrations were compared byte-for-byte with HEAD. Unrelated baseline files, dependencies, annotation/original bytes and Phase 1 inspection CLI were preserved.
- Cleanup probe found zero leftover test schemas and zero public tables. The existing test container was restored to its original stopped state.
The affected PostgreSQL suite includes the existing ingestion/publication-through-selection/search tests with independent literal expected numbers, conditions, negations, exceptions, partial-publication barriers and failed-batch invisibility. This is affected PostgreSQL acceptance, not a claim that the entire PostgreSQL suite ran.
Remaining calibration prerequisites
Current model-quality status remains pending. Real calibration requires separate explicit provider-call authorization, approved original-to-selected-document bindings, and verified compatibility of the configured real model, ingestion database and retained profile. The six-answerable/four-unsupported annotations and original are unchanged. The ten-call budget and exclusive output creation remain enforced.
Selection still maximizes complete-support coverage with zero unsupported false positives and chooses the stricter cutoff on ties. A successful measured report is required; deterministic tests supply no production threshold. Phases 3/4 remain outside this repair.
Remaining two repairs: current acceptance (2026-10-08)
This section supersedes the earlier test counts for current Phase 2 technical acceptance. It preserves the four repairs above and adds only literal calibration boundaries and confirmed-disconnection classification.
Reproduction and correction
- Calibration evidence: unrestricted substring membership accepted independently annotated ۲۵ بار inside ۱۲۵ بار, ۱۰ روز inside ۱۱۰ روز, and PUMP-7 inside PUMP-70. Frozen-original regressions also reproduced numeric/date/identifier extensions and an incorrect six-of-six cutoff result. Literal annotation matching now checks Unicode letters, numbers, combining marks, connector characters and format joiners, plus date/identifier/numeric separators. Internal extensions fail; terminal sentence periods remain punctuation. No evidence normalization or expected-fact derivation was added. Every phrase in a required group must still occur together in one whole admitted chunk bound to the approved document.
- Confirmed disconnection: a Psycopg OperationalError wrapped by SQLAlchemy with SQLSTATE absent and connection_invalidated=true was normalized as nonretryable at candidate retrieval, handoff and calibration finalization. The shared mapper now recognizes that confirmed disconnect. Permanent and unknown SQLSTATEs remain nonretryable, and genuinely unknown failures without invalidation remain nonretryable. Messages stay constant and safe; no retry loop or additional provider work was introduced.
Before production changes:
.venv/Scripts/python -m pytest tests/unit/test_search_phase2_remaining.py -q --tb=short
19 failed, 12 passed, 0.99 seconds: 16 annotation/coverage regressions and three confirmed-disconnect boundaries failed.
New unit regressions use the frozen six-answerable/four-unsupported annotations and original. All unchanged groups pass; independently corrupted groups fail, incomplete/split groups fail, and wrong document bindings fail. Corruption cannot inflate coverage to six-of-six; corruption of all six yields measured_failure with no cutoff. The unchanged fixture retains six complete-support cases, zero unsupported false positives and the stricter cutoff on ties. No annotation/original bytes or labels changed.
New PostgreSQL regressions close only the test's own actual Psycopg connection before the next SQLAlchemy execution. They verify SQLSTATE-less, connection-invalidated errors at retrieval and handoff, empty sources, no consumed reference and exactly one deterministic embedding call. Final calibration disconnection retains ten completed timings/call counts, technical_error with null cutoff, safe messages and suppressed evidence, with no additional calls. Initial administrative backend termination produced SQLSTATE 57P01; the fixture was corrected to exercise the requested SQLSTATE-less case.
Exact final commands and results
$env:TEST_DATABASE_URL = 'postgresql+psycopg://postgres:search-test-only@127.0.0.1:54938/rag_scoped_search_test'
.venv/Scripts/python -m tests.postgres_prerequisites
.venv/Scripts/python -m pytest tests/unit/test_scoped_search.py tests/unit/test_search_phase2.py tests/unit/test_search_phase2_repairs.py tests/unit/test_search_phase2_remaining.py -q --tb=short
.venv/Scripts/python -m pytest tests/integration/test_scoped_search.py tests/integration/test_search_phase2.py tests/integration/test_search_phase2_repairs.py tests/integration/test_search_phase2_remaining.py --require-postgres -q --tb=short
.venv/Scripts/python -m pytest -m 'not postgres' -q --tb=short
.venv/Scripts/python -m pip check
.venv/Scripts/python -B -m app.search --help
.venv/Scripts/python -B -m app.calibrate_search --help
git diff --check
- Prerequisites: PostgreSQL 16.15, pgvector 0.8.7, passed.
- Affected unit acceptance: 107 passed, 1.26 seconds.
- Affected isolated PostgreSQL acceptance: 100 passed, zero skips, 138.82 seconds.
- Provider-free regression: 1193 passed, 3 skipped, 308 deselected, 59.67 seconds. Skips remain Windows symlink privilege cases.
- pip check: No broken requirements found. Both CLI help commands passed.
- Tracked diff whitespace, separate new-file whitespace, AST and local documentation link checks passed.
- All three applied migration files compare byte-for-byte with HEAD. SHA-256 baseline comparisons preserve unrelated tracked/untracked files, dependencies, frozen original/annotations, lexical/evidence modules, calibration/inspection CLIs and previous regression files.
- Database cleanup probe: 0 leftover test schemas / 0 public tables. Existing test container restored to its original stopped state.
Only calibration.py, sql_error() in service.py, two new regression files and current status documentation changed in this repair. Retrieval SQL, admission budgets, settings-first locks and commit-time staged source publication are unchanged. Full PostgreSQL regression and real-provider calibration were not run; affected PostgreSQL acceptance is complete.
Real-model quality acceptance still requires explicit separate provider-call authorization, approved original/document bindings and verified model/database/profile compatibility. No real provider calls were made, no production cutoff was invented, and Phases 3/4 remain pending.