← Back to Pull requests

docs: converge repository truth after RAG evidence pipeline #20

Closed
unknown closed this pull request without merging on Sep 30, 2026 21:52 UTC
View on GitHub
unknown unknown commented on Sep 29, 2026 21:36 UTC
Author

Why

PR #19 introduced the reproducible 649-query RAG evidence pipeline, while several active docs, interview materials, readiness checklists, and drift guards still reflected the previous repository state. This is convergence v3 (baseline 4c97406c638825e5bd50d49cf6c0e2a5a2dc8f1e): audit-first, code→config→docs→interview→guards. Mid-PR review corrected an evidence-direction inversion: formal status is no longer read from Markdown — it is derived from provenance-bearing evidence artifacts (see "Formal evidence state (final architecture)").

What changed

Current-truth docs


  • README.md — "RAG 有数据" row now describes the real evidence pipeline (make rag-eval-import → -preflight → -smoke → rag-eval-649); smoke explicitly non-evidence; formal 649-query metrics NOT_VERIFIED; historical 30-query snapshots framed as historical. make eval-rag documented as compatibility alias.

  • Makefile — eval-rag is now an explicit alias delegating to rag-eval-649 (single canonical formal command; no second logic path).

  • CLAUDE.md — HEAD capabilities updated with the evidence pipeline; canonical RAG commands added; hard rule added: no provenance-bearing artifact → AI agents must not generate/propagate current Hit/MRR/NDCG percentages.

  • docs/reference/current-state.md — new "RAG evaluation / evidence state" section (4 configs, metric family, populations, committed preflight blocker, canonical command chain), now wording the state as artifact-derived.

  • docs/reference/rag-evaluation.md — §3.4 status line kept; a governance note added (artifact/evidence → facts → docs → guard; docs render and may not self-claim the state).
  • Design/ops docs


  • architecture-design.md — unsourced current numbers (60-70% repeats, 5-15s→<10ms, −60% LLM calls, L1≈30%/L2≈40%/total≈70%) reclassified as design goals with explicit NOT_MEASURED; RAG evaluation-architecture section added, clearly separated from the production request path.

  • e2e-verification-guide.md — "2026-06-20 复审一致" framing removed; fixed 5-PASSED output/1352-collected/large-SLA wording moved to an explicit Historical Evidence section; provider auth probe first (scripts/probe_provider_auth.py); provider prices marked historical estimates; embedding/reranker credential semantics documented per code.

  • production-evidence.md — two evidence families separated (provider/production vs RAG retrieval evaluation); metric contract extended (multi-K Hit/Recall/Precision/NDCG/MRR, measured stage latency, population semantics, failure taxonomy); RAG row marked NOT_VERIFIED.

  • production-readiness-checklist.md — gates now include doc/facts/openapi checks and the RAG evidence preflight; dynamic PASS results no longer frozen as permanent checkboxes; secrets/keys.json status corrected (removed from tracking this round, not "next commit"); local-machine .env statement replaced with repo-policy framing; pointers updated to the 2026 audits.

  • quick-launch-checklist.md — added embedding/reranker credentials, RAG preflight, Qdrant corpus/index readiness items (per code: EMBEDDING_API_KEY may fall back to OPENAI_API_KEY; RERANKER_API_KEY is standalone — no claim that all three keys must exist independently).
  • Interview materials (live docs only; frozen snapshot untouched)


  • interview-intro / interview-deep-dive / interview-questions-final / context-engineering-interview: added the most valuable current RAG interview content — why a single Recall is not enough, vector_only vs bm25_only vs hybrid_no_rerank vs hybrid_rerank ablation semantics, Hit@K/Recall@K/Precision@K/NDCG@K/MRR@K distinctions, the three population denominators, GOLD_NOT_INDEXED accounting, provider-401 fail-closed rationale, reranker silent-fallback danger & how to prove reranking works, bad-case taxonomy, provenance/benchmark-sha/git-sha discipline. No current 649-query numbers invented; legacy cache-latency claims softened to design goals; "生产级部署" softened to "部署架构(复核未完成)".

  • docs/reports/resume-description.md — excluded by design (evidence freeze 2026-09-29 banner; historical snapshot preserved as-is).
  • Governance


  • changelog.md — Unreleased now records PR #19 (4-config ablation, multi-K, measured stage latency, failure taxonomy, import manifest, structured preflight blockers, dynamic populations, formal metrics remain NOT_VERIFIED) and convergence v3; no v6.4 created.

  • docs/README.md — truth-hierarchy quick map (current-state = facts entry; rag-evaluation = canonical evaluation reference; production-evidence = evidence semantics; reports/audit = historical snapshots).

  • docs/reports/audit/2026-09-30-documentation-convergence-v3.md — HISTORICAL AUDIT SNAPSHOT with BASE_HEAD/FINAL_HEAD, fact matrix, drift list, baseline vs final verification, evidence boundary, hygiene results; finalized with the PR #20 governance closeout (§8 final matrix + §14 artifact-derived evidence direction).
  • Formal evidence state (final architecture)

    artifact/evidence
      → scripts/rag_evidence_status.py     # single derivation entry point
      → scripts/project_facts.py           # machine-readable fact projection
      → docs                               # rendered projection — does NOT own the state
      → scripts/audit_doc_consistency.py   # bidirectional consistency verifier
    

  • Markdown does not own the formal evidence state. The formal status is derived ONLY from provenance-bearing artifacts/evaluation/rag-649//report.json artifacts that pass the formal full-run contract; preflight-only / smoke / subset artifacts and doc declarations are rejected structurally.

  • VERIFIED contract: status == VERIFIED_FULL AND all four canonical experiments (vector_only / bm25_only / hybrid_no_rerank / hybrid_rerank) fully executed (metrics + run_summary, n_success == executed, benchmark sha256 bound to the current benchmark, evaluation_populations.primary_view == all_queries).

  • VERIFIED_FULL_NO_RERANK (reranker ablation leg missing) does NOT promote formal VERIFIED — NOT_VERIFIED, fail-closed. SUBSET_SMOKE / PARTIAL / preflight BLOCKED likewise NOT_VERIFIED.

  • Bidirectional doc guard: without an artifact, docs must not self-promote to VERIFIED; with a VERIFIED artifact, stale NOT_VERIFIED docs fail and VERIFIED claims must bind artifact provenance.

  • scripts/project_facts.py no longer hardcodes "expected NOT_VERIFIED until …" — --check derives the actual state and compares docs against it, so a future formal artifact needs no Python change: generate artifact + re-render docs, and the guard recognizes VERIFIED.

  • Current status: NOT_VERIFIED; rag_formal_artifact_path / timestamp / git_sha / schema_version are all null (no formal 649 full-run artifact exists yet). Historical artifacts (preflight v1, import manifest) are byte-identical.
  • Drift guards (automation, not manual fixes)


  • scripts/rag_evidence_status.py (new) — shared, schema-faithful derivation of the formal status from artifacts (validate_formal_rag_report returns the validation payload; canonical contract extracted from scripts/evaluate_rag.py, never a second schema).

  • scripts/audit_doc_consistency.py v3 — rules: (A/I) test counts framed as current truth; (B/J) canonical RAG eval commands resolvable in Makefile & canonical doc referenced by entry docs; (C+) canonical evidence-pipeline tokens; (D/K) metric claims follow the ARTIFACT-derived status (NOT_VERIFIED → provenance qualifier required; VERIFIED → provenance binding still required, never fully disabled); (E/L) make targets referenced by truth docs must exist; (F/M) tracked+ignored repository hygiene.

  • scripts/project_facts.py — machine-derived evaluation facts (experiments/metric family/Ks/populations/failure taxonomy/schema version) extracted from scripts/evaluate_rag.py at runtime; formal status + provenance fields projected from artifacts; --check guards experiments, populations and make-target presence in current-state.md and compares formal-status claims in BOTH directions. No one-off provider 401 hardcoded anywhere.

  • Regression tests in tests/unit/test_doc_consistency.py: final count 60 passed (artifact-driven governance assertions such as test_no_formal_artifact_is_not_verified, test_preflight_artifact_does_not_verify_metrics, test_smoke_subset_artifact_does_not_verify_metrics, test_valid_formal_artifact_marks_verified, test_verified_full_no_rerank_does_not_promote_formal_metrics, test_doc_cannot_self_promote_to_verified, test_verified_artifact_with_stale_not_verified_doc_fails, test_not_verified_artifact_with_fake_verified_doc_fails, test_metric_check_uses_artifact_state_not_doc_state, test_metric_claim_guard_uses_artifact_state_not_doc_state).
  • Repository hygiene


  • git rm --cached secrets/keys.json (rotation-ledger metadata only; per docs/security/public-repository-secret-policy.md, while .gitignore already ignores secrets/), tests/data/csai.db-shm, tests/data/csai.db-wal (SQLite runtime sidecars; main csai.db already untracked; no code/test depends on them). Local files kept. CLAUDE.md stays tracked intentionally (documented in the guard whitelist + audit report).
  • Evidence boundary

  • Current 649-query metrics remain NOT_VERIFIED until a new formal artifact exists (preflight-passed, provenance-bearing report.json from make rag-eval-649). The committed preflight v1 artifact shows the provider-auth blocker (401) — preserved as-is.

  • Historical metrics (2026-06 30-query Hit@3 80% / MRR 0.778, preflight v1, import manifest) remain historical and are quoted only with historical framing.

  • No production SLA/latency/billing claims invented anywhere; historical 2026-06 latency/price snippets are labeled snapshots, not current results.
  • Verification

    Superseded by the Final Closeout section below.* The table above/below in this

    section reflects the mid-PR state at HEAD 4f07746 (CI run 36638725103); it is kept

    for provenance, not as the final gate.

    Executed on the PR branch (mid-PR state, HEAD 4f07746518c8f73584438c898755c199d414aebf):

    | Command | Result |
    |---|---|
    | python3 scripts/rag_evidence_status.py | NOT_VERIFIED, rag_formal_artifact_
    = null |
    | python3 scripts/project_facts.py | OK — version 6.3, Qwen/Qwen3-8B, BAAI/bge-large-zh-v1.5, BAAI/bge-reranker-v2-m3, qdrant_only, 53 paths, 9 agents, 649 queries + eval facts (4 experiments / 5 metric names / K∈{1,3,5,8} / 3 populations / 5 taxonomy codes / schema rag-eval-evidence/v2 / formal NOT_VERIFIED) |
    | python3 scripts/project_facts.py --check docs/reference/current-state.md | OK (bidirectional formal-status comparison incl. rag-evaluation.md) |
    | python3 scripts/audit_doc_consistency.py | OK — 36 active documents (guard rule K uses the artifact-derived state) |
    | python3 scripts/generate_openapi.py --check | OK — 53 paths surface matches |
    | pytest tests/unit/test_doc_consistency.py -q | 60 passed |
    | pytest tests/unit/test_rag_eval_harness.py -q | 30 passed |
    | pytest -q -m "not real_llm" | passed (final run); test/collect counts taken from live command output, not hardcoded into docs |
    | ruff check <changed py files> | All checks passed |
    | npm test | 60 passed (7 files) |
    | npm run build | built OK |
    | git diff --check | clean |
    | git ls-files -ci --exclude-standard | only CLAUDE.md (intentional, whitelisted) |
    | CI (final run) | run 36638725103 — test (3.10/3.11/3.12) + security SUCCESS |

    Historical files preserved

  • artifacts/evaluation/rag-649/preflight-20260929T191128Z/report.json (v1 evidence — byte-identical)

  • artifacts/evaluation/rag-649/import_manifest_import-20260929T190455Z.json

  • docs/reference/rag-evaluation-report.json (2026-06 30-query snapshot)

  • docs/archive/, docs/reports/milestone/, docs/reports/plans/, old release notes

  • Old changelog version sections (including the v6.3 secrets/keys.json line — left as recorded, corrected only in Unreleased)

  • docs/reports/resume-description.md (evidence freeze)
  • Final Closeout (2026-10-01)

    Final round executed in worktree /home/dev/projects/csaa-convergence-v3
    (branch docs/convergence-v3-20260930); the main checkout was untouched.

  • BASE_SHA: 4c97406c638825e5bd50d49cf6c0e2a5a2dc8f1e (origin/main at PR start)

  • PR20_PRE_FINAL_HEAD: 4f07746518c8f73584438c898755c199d414aebf

  • FINAL_HEAD: 85e249831a3216debdabf9e395a930d61ba86863
  • Additional findings fixed in this round

    The P0 items (cache "local/in-process/sub-ms" claims; response_cache.py
    random-vector docstring; ops-guide stale script claims; E2E current/historical
    ambiguity; unsupported interview numbers) had been prepared as uncommitted
    worktree edits — they are now
    committed and code-verified (implementation
    fail-closed path, scripts/ existence, core/config.py env surface, drift-
    detector NEGATION_PAIRS, core/container.py LLM key reads).

    New drift found by re-deriving facts from code:

    1. P1 — production-operations-guide.md failover recipe referenced
    nonexistent DEEPSEEK_API_KEY; runtime always reads
    OPENAI_API_KEY/OPENAI_BASE_URL/OPENAI_MODEL (core/container.py:240-274),
    LLM_PROVIDER is a label only. Recipe fixed.
    2.
    P1 — same doc claimed DATABASE_POOL_SIZE/DATABASE_MAX_OVERFLOW env
    vars; the pool is hardcoded in db/database.py (10/20) — and the doc itself
    said so 500 lines earlier. Fixed to point at code.
    3.
    P2 — GUNICORN_THREADS/TIMEOUT/KEEPALIVE presented as env-tunable;
    only GUNICORN_WORKERS/GUNICORN_BIND are os.getenv-read, timeout/keepalive
    are hardcoded in gunicorn.conf.py. Fixed.
    4.
    P2 — README "40+ 否定/矛盾词对" vs code's exactly 40 (NEGATION_PAIRS);
    restated as code-derived count with source link.
    5.
    P2 — README "极致级生产就绪 - 超越99.9%..." reframed production-oriented
    with explicit estimate / NOT_VERIFIED qualifiers (Guard R semantics).

    New guard: S (env references must resolve)

    scripts/audit_doc_consistency.py now validates that env-shaped tokens in
    active docs resolve to a machine-derived config surface (core/config.py
    constants, env reads in any Python module, .env.example/.env.test,
    compose/deploy/workflow env) — with env-usage-context scoping and
    negative/historical line tolerance. This mechanizes the exact drift class
    found in the ops guide. 5 new regressions in tests/unit/test_doc_consistency.py
    (now 78) + real-repo invariant extended.

    Files changed in the final round

    README.md, cache/response_cache.py, docs/design/architecture-design.md,
    docs/design/interview-deep-dive.md, docs/design/interview-intro.md,
    docs/operations/e2e-verification-guide.md,
    docs/operations/production-operations-guide.md,
    docs/reference/current-state.md, docs/reference/rag-evaluation.md,
    docs/reports/audit/2026-09-30-documentation-convergence-v3.md (§15),
    docs/reports/releases/changelog.md, scripts/audit_doc_consistency.py,
    tests/unit/test_doc_consistency.py.

    Final-round verification (live output, no hardcoded counts)

    | Command | Result |
    |---|---|
    | python3 scripts/rag_evidence_status.py | NOT_VERIFIED, artifact fields null |
    | python3 scripts/project_facts.py | OK (6.3 / Qwen3-8B / 53 paths / 9 agents / 649 queries / formal NOT_VERIFIED) |
    | python3 scripts/project_facts.py --check docs/reference/current-state.md | OK |
    | python3 scripts/audit_doc_consistency.py | OK — 36 active docs incl. Guard S |
    | python3 scripts/generate_openapi.py --check | OK — 53 paths |
    | pytest tests/unit/test_doc_consistency.py -q + test_rag_eval_harness.py -q |
    108 passed (78 + 30) |
    | pytest -q -m "not real_llm" |
    1867 passed, 5 deselected; 3 pre-existing collection/setup errors in tests/integration/test_integration.py (pytest-asyncio FixtureDef.unittest env incompatibility) — reproduced identically on origin/main, unrelated to this PR |
    | ruff check (changed py files) | clean; full-repo baseline 130 pre-existing errors in files untouched by this PR (alerts/notifier.py 26, collaboration/orchestrator.py 14, auth/service.py 14, …) |
    | npm test | 60 passed (7 files) |
    | npm run build | built OK (524ms) |
    | git diff --check | clean |
    | git ls-files -ci --exclude-standard | only CLAUDE.md (intentional, whitelisted) |
    |
    CI (final run) | run 36781311836 — tests (3.10/3.11/3.12) + security SUCCESS |

    Evidence boundary (unchanged)

  • RAG formal 649-query metrics: NOT_VERIFIED (blocker: provider credential 401, archived).

  • Provider token/billing: NOT_AVAILABLE. Production latency/SLA: NOT_MEASURED.

  • Provider credential root cause: UNKNOWN (401 not attributable further).

  • Redis/Qdrant/PostgreSQL deployment verification, ERP real mode: NOT_VERIFIED**.
  • PR #20 closes the repository-truth/documentation convergence. It does NOT close

    production validation — that remains tracked in Issue #7 (kept OPEN).

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: Xander-Xai Review duration: 1455m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #20"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%