# Lead implementation evidence

Status: available verification complete. Date: 2026-09-05.

## Baseline and fixes

- Baseline: `env PYTHONPATH=src .venv/bin/python -m pytest tests/test_bic007_bi_conversation_api.py tests/test_bic006_bi_conversations.py tests/test_london_calendar_guard.py -q -p no:cacheprovider --tb=short`. Result: 59 passed, 1 failed, 33.04 s. See `lead-baseline.log`.
- F01 proof first: `tests/test_insights_authorization.py`. The original 27-case matrix failed before implementation. Each failure hit a forbidden result-hydration seam before authorization. See `authorization-before.log`.
- Added `_scope_conversation_for_user` in `api/routers/bi_query.py`. It reads ownership metadata, checks session permission, and uses `get_owned`. GET, selected-turn GET, delete, export and column authorization use it. Job routes use the same helper.
- F04/F09 proof first: three metadata tests failed. Units were discarded and no answer record existed. See `metadata-before.log`. Then the new federated watermark test failed while the three metadata checks passed. See `federated-freshness-before.log`.
- Added `bi/answer_record.py`. Currency, units, aggregation and denominator metadata survive model serialization. Existing `confidence_factors` JSON stores the compact evidence record. This adds no database column. Legacy query time stays unknown. Snapshot save time is separate.
- Gold watermark lookup now reads nested federation sources. Source refresh time differs from query time. Unknown source age stays unknown. The cache is scoped to connection, vault and user.
- F08: full GET accepts `after_turn_index`. A scoped single-turn GET preserves enrichment and SQL display metadata without transferring other turns.
- F13 proof first: dashboard refresh failed its independent federated-value test. It dispatched the unrelated single-source executor. See `dashboard-before.log`.
- Added `services/bi_query_entrypoint.py`. Direct query, cost override, dashboard refresh and Compose share replay/federation/single-source dispatch. Request limits and permissions flow into federation. Dashboard uses the configured generator, definition resolver and SSH manager. Compose stores column metadata and attaches the answer record to its evidence chunk.
- The London failure is expectation drift against the documented London-calendar decision. The assertion now expects the exact converted SQL. The SQL implementation was not changed to satisfy it.

## Independent database evidence

A throwaway PostgreSQL 16 container is used. It is called `lore-insights-verification-pg`. It binds only to localhost. No configured application source is used.

`tests/test_insights_postgres_values.py` proves:

- July 31 at 22:59:59 UTC is July in London. July 31 at 23:00:00 UTC is August.
- July membership is `[1]`, total 100. August membership is `[2, 3, 4]`, total 201. The null value is excluded from the non-null count.
- The spring DST change skips the 01:00 local hour.
- The autumn DST change maps two distinct UTC hours into one local clock-hour bucket.
- Explicit UTC SQL keeps UTC month membership.

## Integrated commands and outcomes

`env PYTHONPATH=src LORE_INSIGHTS_TEST_DSN=<isolated-fixture-DSN> .venv/bin/python -m pytest tests/test_insights_postgres_values.py tests/test_insights_answer_record.py tests/test_insights_authorization.py tests/test_bic007_bi_conversation_api.py tests/test_bic006_bi_conversations.py -q -p no:cacheprovider --tb=short`

Result: 87 passed, 8 warnings, 31.84 s. See `lead-integrated-1.log`. The DSN is supplied from the isolated fixture. It is not a production credential.

`env PYTHONPATH=src .venv/bin/python -m pytest tests/test_insights_entrypoint_parity.py tests/test_bic008_bi_dashboards.py tests/test_bi_single_shot_federated_routing.py tests/test_compose_bi_federated_routing.py tests/test_bi_query_api.py tests/test_full_result_export_enrichments.py tests/test_bi_share_snapshot.py tests/test_bi_share_api.py tests/test_compose_bi_execution.py tests/test_compose_bi_promotion.py tests/test_compose_bi_name_splice.py -q -p no:cacheprovider --tb=short`

Intermediate result: 177 passed, 1 failed, 83.40 s. The failed name-splice assertion required a one-field dictionary and rejected additive unit metadata. Its replacement keeps the client-name assertion and checks GBP money metadata. See `entrypoint-intermediate.log`.

Focused follow-up: `tests/test_compose_bi_name_splice.py tests/test_insights_authorization.py tests/test_insights_answer_record.py tests/test_insights_entrypoint_parity.py`. Result: 39 passed, 24.04 s. Later additions are covered by the final 735-test gate.

`npm run build:css`: passed. Tailwind completed in 4.214 s. It reported a stale caniuse data warning. No dependency update was made by the lead.

Lead-owned Python lint: passed after import and line-length corrections. The final changed-file check passed for all 64 Python files.

## Limits and remaining gates

- Live model answer quality and production source freshness are not verified by synthetic SQL generation.
- Actual screen-reader behavior is not established by browser accessibility assertions.
- The full suite, strict type check, three-reviewer challenge, and final 735-test gate are complete. The final report records remaining live checks and publication verification.
- The temporary PostgreSQL container must be stopped after final checks. Application deployment is prohibited for this task.

## Final verification

The sole full suite used eight workers and file scheduling. It completed with 27,515 passed, 48 failed, 21 skipped, and 1,534 warnings in 649.13 seconds. See `full-suite-first.log`. Runtime source then remained frozen.

The owners repaired 27 test-contract failures without relaxing runtime guards. Their focused runs passed 61, 42, and 41 tests. The final combined union of all 36 changed Python test files passed 735 tests with 100 existing timestamp warnings in 70.89 seconds. See `final-focused.log` and `final-focused-test-files.txt`. The exact command and environment are in the parent verification report.

The 21 other failures reproduce on the original revision with matching failure IDs and reasons. An archived base checkout used the same Python environment and Node dependencies. `baseline-residuals.log`, `baseline-harness.log`, and `full-suite-triage.json` retain the evidence. The baseline harness was first skipped without Node dependencies, then rerun with them. No skipped check is counted as passed.

Strict mypy passed all 1159 source files. Ruff passed all 64 changed/new Python files. Browser, Node, CSS, and whitespace checks passed as recorded in the parent report. No full-suite green result or production verification is claimed.

## Reproducing the base comparison

The archived source was created with `git archive 6ce7648afa0b69d17b765c1bb20a6fe7c3fa061f`, extracted into `/tmp/lore-insights-base-6ce7648`. Its `.venv` and `node_modules` point to the same installed dependencies as the current workspace. No base source was changed. From that directory:

```sh
env PYTHONPATH=src LORE_DB_PATH=/tmp/lore-insights-base-tests.db \
  QDRANT_HOST=127.0.0.1 QDRANT_PORT=32784 LORE_LLM_LIVE=0 LORE_BI_LIVE=0 \
  .venv/bin/python -m pytest \
  tests/test_c2_run_rate_sar_semantics.py \
  tests/test_eval_oracle_playwright_harness.py \
  tests/test_span_refine_marker_splice.py \
  tests/test_content_deck_templates_b.py \
  tests/test_compose_floor_preflight.py \
  tests/test_bench_adapters.py \
  tests/test_bi_paraphrase_eval_cli.py -q --tb=short
# 19 failed, 178 passed, 4 skipped, 16 warnings in 124.72 seconds.
```

The Node dependency link was added after the first run collected the harness skips. With that link present, the same environment and `pytest tests/test_eval_oracle_playwright_harness.py -q --tb=short` returned 2 failed, 22 passed in 17.33 seconds. Those two failures match the current full run exactly.

## Final additive measurement gate

The final source changes add separate submission, base-persistence, required-check, and merge timings to the existing job/query traces. Federation reports parent wall time and retains child trace IDs. Error and clarification timings remain recorded but do not set first_useful_ms.

After all source edits froze, the combined 36-file gate passed **745 tests**, with 100 existing timestamp warnings, in **71.87 seconds**. See `final-tracing-focused.log`. The exact command is the prior combined command with `LORE_DB_PATH=/tmp/lore-insights-final-tracing.db`. There were no skipped cases. The independent tracing/federation/merge gate passed 142 tests; see `federation-timing.log`.

The full suite preceded this additive tracing pass. It was not rerun. All changed Python test files passed the final focused union. The standalone browser fixture is now reproducible with a pinned and checksum-verified Chart.js download; nine affected checks and a two-check cold-cache gate passed.

Final full strict mypy: success, no issues in 1159 source files. Final Ruff: all 64 changed/new Python files passed. See `mypy-final.log` and `ruff-final.log`.
