← Back to Pull requests

fix: close merged review debt and converge repository truth #23

Closed
unknown closed this pull request without merging on Oct 01, 2026 15:05 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 12:06 UTC
Author

Why

Multiple merged feature/remediation PRs (#9–#22) left unresolved review debt and two kinds of current-truth drift:

  • Code review debt that was still LIVE on current main — e.g. the RAG evaluator's primary all_queries denominator averaged only over survivors; reranker uplift compared raw ranks so every miss↔hit transition was inverted; an unconfigured reranker was treated as healthy; preflight blocked bm25_only on an unrelated embedding outage; the streaming provider adapter could never read choices[0].delta.content; warmup 401 runs reported PASS; quoted API keys escaped the pre-commit guard.

  • Contract/guard holes — project_facts.py hardcoded the metric family and population list and read effective config (polluted by a local .env) instead of source fallbacks; the OpenAPI audit failed open; docs carried two lifecycle taxonomies.
  • Evidence direction for this PR: code/evidence → tests → facts → current docs → GitHub metadata. No metric was fabricated; no v6.4, release, tag, history rewrite or protected-main change was made.

    Review-debt matrix (PR #9–#21)

    Legend: LIVE FIXED = the finding still held on current main and this PR fixes it; FIXED ELSEWHERE = already fixed by a later merged PR; SUPERSEDED = invalidated by a later refactor/move.

    | PR | Thread | Sev | Status on main | Disposition |
    |---|---|---|---|---|
    | #9 | Strip tracking-only query strings | P2 | LIVE | LIVE FIXED — _clean_url emits the filtered query |
    | #10 | Revalidate private ERP authz before serving hits | P1 | LIVE | LIVE FIXED — private ERP tools are never served from cache (authorization_required) |
    | #10 | Reject ERP not-found strings from cache writes | P2 | LIVE | LIVE FIXED — cacheable_result rejects 未找到… |
    | #11 | Preserve payload doc_id vs collision guard | P2 | LIVE | LIVE FIXED — explicit doc_id wins over metadata |
    | #11 | Apply execution deletion filter to dry-run | P2 | LIVE | LIVE FIXED — dry-run uses the same safe_to_delete filter |
    | #11 | Bound migration vector processing | P2 | LIVE | LIVE FIXED — compact pass-1 + bounded batch upsert/delete |
    | #12 | Update existing L2 tests for fail-closed | P1 | FIXED ELSEWHERE | FIXED ELSEWHERE — test_cache_embedding_fail_closed.py + fixtures on main |
    | #12 | Invalidate legacy synthetic-vector entries | P2 | LIVE | LIVE FIXED — CACHE_PAYLOAD_VERSION v1→v2 |
    | #13 | Apply request filters to BM25 results | P1 | LIVE | LIVE FIXED — scene/metadata predicate on BM25 candidates |
    | #13 | Fail rebuild when a collection cannot be opened | P1 | LIVE | LIVE FIXED — DEGRADED, never publishes READY |
    | #14 | Preserve Recall@K and MRR in artifacts | P2 | LIVE | LIVE FIXED |
    | #14 | Derive channel outcomes from channel results | P2 | LIVE | LIVE FIXED — marked NOT_MEASURED (no fabricated attribution) |
    | #14 | Render status from evidence payload | P2 | LIVE | LIVE FIXED — render_markdown derives from payload |
    | #15 | Index streaming choices before reading delta | P1 | LIVE | LIVE FIXED — _nested traverses list indexes |
    | #15 | Include every billable attempt in cost cap | P1 | LIVE | LIVE FIXED — cases × (warmup+repeat) × max_attempts |
    | #15 | Render staging-specific Markdown evidence | P2 | LIVE | LIVE FIXED — same renderer, payload-driven |
    | #15 | Mark zero-success runs as failures | P2 | LIVE | LIVE FIXED — FAILED (PARTIAL reserved for mixed) |
    | #16 | Preserve warmup authentication failures | P1 | LIVE | LIVE FIXED — BLOCKED_BY_AUTHENTICATION |
    | #16 | Handle malformed JSON from 200 chat probes | P2 | LIVE | LIVE FIXED — INVALID_PROVIDER_RESPONSE |
    | #17 | Restore production-evidence script instructions | P1 | FIXED ELSEWHERE | FIXED ELSEWHERE — ops guide already documents both entry points |
    | #17 | Preserve detection of quoted API keys | P1 | LIVE | LIVE FIXED — regex + check_secrets.py cover quotes/case/whitespace |
    | #18 | Treat OpenAPI construction failures as errors | P2 | LIVE | LIVE FIXED — fail closed (only missing ImportError warns) |
    | #18 | Extract fallback facts without local overrides | P2 | LIVE | LIVE FIXED — AST fallback extraction |
    | #18 | Match each generated fact to its labeled field | P2 | LIVE | LIVE FIXED — field-to-field capture, no global token search |
    | #18 | Apply historical-banner filtering to extras | P2 | SUPERSEDED | LIVE FIXED (guard hardened) — extras now honor the banner |
    | #19 | Include failed requests in all-queries denominator | P1 | LIVE | LIVE FIXED — zero-metric rows enter the population |
    | #19 | Treat a missing rank as worse than every hit | P1 | LIVE | LIVE FIXED — reciprocal-rank comparison |
    | #19 | Block rerank when provider unconfigured | P1 | LIVE | LIVE FIXED — RERANKER_PROVIDER_UNAVAILABLE |
    | #19 | Verify document identities before skipping import | P1 | LIVE | LIVE FIXED — logical id + corpus hash audit |
    | #19 | Derive blockers from requested experiments | P2 | LIVE | LIVE FIXED — CLI experiments passed into preflight |
    | #19 | Import into the configured Qdrant endpoint | P2 | LIVE | LIVE FIXED — QDRANT_HOST/QDRANT_PORT |
    | #20 | Derive the metric family instead of hardcoding | P2 | LIVE | LIVE FIXED — shared scripts/eval_contract.py |
    | #20 | Validate populations extracted from evaluator | P2 | LIVE | LIVE FIXED — guard iterates derived list |
    | #21 | Raise floor to pytest-asyncio 0.23.4 | P1 | FIXED ELSEWHERE | FIXED ELSEWHERE — completed by PR #22 (requirements-dev.txt + dev-compat lane) |

    No thread is marked "resolved" without a current-main verification.

    Code fixes

  • RAG evaluator (scripts/evaluate_rag.py, scripts/eval_contract.py): end-to-end denominator, reciprocal-rank uplift, unconfigured-reranker blocker, requested-experiment-scoped preflight, contract single-sourcing.

  • Eval import (scripts/import_eval_corpus.py): identity/hash audit, configured Qdrant endpoint, manifest provenance. Migration (rag/point_id_migration.py): dry-run parity + bounded batches.

  • Evidence harness (evaluation/provider_adapter.py, provider_runner.py, runner.py): streaming list traversal, malformed-JSON handling, warmup-auth status, worst-case cost cap, JSON/Markdown parity, channel metrics without fabrication.

  • Governance (scripts/project_facts.py, audit_doc_consistency.py, config_fallback.py): derived facts, env-independent fallbacks, field-to-field checks, fail-closed OpenAPI.

  • Security/cache/RAG (core/tool_result_compressors.py, core/tool_result_cache.py, agents/base_agent.py, tools/erp_tools.py, cache/cache_policy.py, rag/qdrant_knowledge_base.py, scripts/check_secrets.py, .pre-commit-config.yaml): tracking-URL strip, private-ERP cache boundary, not-found cache rejection, doc_id precedence, BM25 filters, rebuild fail-closed, cache version bump, quoted credentials.
  • Documentation convergence

  • docs/README.md: one canonical lifecycle taxonomy (per-file lifecycle inside reference/); retired labels are aliases only.

  • changelog.md: ## Unreleased (no auto-expiring month range) + entries for this PR; historical sections untouched.

  • Makefile: layered dependency contract (Deployment / CI Lane A / Dev Lane B / historical lock).

  • docs/reference/current-state.md: CURRENT truth no longer bound to a verification date; documents env-independent fallback facts.

  • README.md architecture: /api/chat/multimodal shown as the unified entry, /api/chat/image as legacy/specialized.

  • production-readiness-checklist.md: explicit evidence-state legend.
  • Evidence boundaries

  • Formal 649-query RAG metrics: NOT_VERIFIED. No provenance-bearing formal artifact was produced by this PR; the preflight-only artifact still shows a provider-auth blocker.

  • Provider authentication: NOT_VERIFIED (no provider call made).

  • Production latency / SLA: NOT_MEASURED.

  • Provider billing: NOT_VERIFIED / NOT_MEASURED.

  • Real Redis / real ERP / real Qdrant migration: NOT_VERIFIED.

  • Local fixture benchmarks are not production evidence; smoke/subset runs are not formal RAG evidence.
  • Verification

    python3 scripts/project_facts.py                                   # exit 0
    python3 scripts/project_facts.py --check docs/reference/current-state.md   # OK
    python3 scripts/audit_doc_consistency.py                           # OK (32 active docs)
    python3 scripts/generate_openapi.py --check                        # OK (53 paths)
    
    pytest tests/unit/ -q -m "not real_llm and not stress"             # 1536 passed
    pytest tests/unit/test_review_debt_regressions.py -q               # 22 passed
    pytest tests/unit/test_repository_contract.py test_doc_consistency.py \
           test_ci_contract.py test_secret_guard.py -q                 # passed
    pytest --collect-only -q                                           # 1917 collected
    
    npm test                                                          # 60 passed (7 files)
    npm run build                                                     # built
    git diff --check                                                   # clean
    

    Not run / environment-blocked: real provider calls, real Redis, real ERP, real Qdrant corpus import, and make rag-eval-649 (would require provider credentials + a populated index). These are left NOT_RUN / NOT_VERIFIED, not reported as PASS.

    GitHub cleanup

  • Threads resolved: the LIVE threads above, each with a current-main re-verification and a reply referencing this PR/commit.

  • Threads retained unresolved: none marked UNKNOWN remain open without a note; any unresolved thread without a verified fix is left open.

  • Issue #7 remains OPEN; acceptance items (provider auth, production latency, production cache, real ERP, real Redis, formal 649 metrics) stay unchecked.

  • Remote branch state: fix/post-merge-review-debt-and-truth-convergence pushed; only main remains protected; no force-push, no history rewrite.
  • Updates #7

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: Xander-Xai Review duration: 178m
    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 #23"
    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%