← Back to Pull requests

chore: reconcile repository truth and security contracts after offline pipeline merges #9

Closed
unknown closed this pull request without merging on Oct 01, 2026 18:25 UTC
View on GitHub
unknown unknown commented on Oct 01, 2026 17:28 UTC
Author

Why

Several rapid merge rounds (PR #3–#7) left current documentation, repository governance, and a small number of runtime contracts inconsistent with the final main branch. This PR re-derives repository truth from the code/tests/config at main (7edd740) and aligns the current docs and drift guards to it. Historical CHANGELOG release entries and merged PR bodies are not rewritten.

Repository governance

  • Audited merged PRs: #3, #4, #5, #6, #7 (all MERGED); no GitHub Release/tag exists.

  • Audited issues: #1 CLOSED (unchanged); #2 re-scoped from "implement + validate" to implementation-complete and CLOSED as completed, with external validation split into successor #8.

  • Audited branches: remote contains only main; this PR adds one reconciliation branch.

  • No historical merged PR body was modified.
  • Security fixes

  • Media RBAC now fails closed. GET /api/media/{doc_id} previously did payload.get("role_mask", 0) / payload.get("dept_mask", 0), so missing permission metadata was treated as public. It now reuses common.auth.is_document_authorized, so missing/malformed/negative/out-of-uint32 masks are denied.

  • RS256 authentication no longer depends on legacy HS256. common.auth.parse_identity only attempted Bearer verification when the legacy JWT_SECRET was enabled, so an RS256-only deployment never verified its own access tokens. Bearer verification is now always attempted; the HS256 fallback remains optional inside _decode_jwt.
  • Documentation reconciliation

  • docs/repository-truth-audit.md: refreshed verification date, recorded merged PR #3–#7, Elasticsearch search_after pagination sorting on unique keyword chunk_id (not ES8 _id), accurate CI state, and corrected the 2.3.0 offline-history semantics.

  • CHANGELOG.md: [Unreleased] records the PR #7 sort fix distinctly from the earlier pagination path; removed range-bound wording. Historical releases untouched.

  • PRD.md: RBAC documented as a uint32 mask contract with fail-closed handling; removed non-implemented Qdrant nlist/nprobe IVF tuning; is_allowed() pseudocode matches common/auth.py.

  • README.md / docs/*: documented the RS256-primary / legacy-HS256-fallback boundary, the media RBAC fail-closed check, and Elasticsearch pagination.
  • Drift prevention

  • scripts/check_repo_consistency.py no longer hardcodes one verification date: it requires an ISO YYYY-MM-DD date and resolves the candidate from symbolic HEAD. It does not depend on the current date or GitHub API.

  • New guards reject superseded governance claims, non-implemented Qdrant IVF parameters, the bare GET /metrics route, and any PRD RBAC claim that is not uint32.

  • New focused tests cover date handling, drift patterns, media fail-closed cases, and the RS256/HS256 identity contract.
  • Validation

    Run locally on the reconciliation HEAD:

    pytest:           740 passed, 1 skipped (741 collected)
    ruff check:       All checks passed
    ruff format:      203 files already formatted
    compileall:       ok
    repo consistency: passed
    git diff --check: ok
    docker compose config: ok
    

    Each of the five commits in this branch individually passes the repository consistency guard.

    Regression evidence: test_rs256_token_accepted_without_legacy_secret fails without the auth fix and passes with it.

    External validation still pending

    These are implemented in code but not validated against real external assets/runtimes, and this PR does not claim otherwise:

  • Real configured BGE model smoke — EXTERNAL_MODEL_ASSET_REQUIRED

  • Real configured CLIP model smoke — EXTERNAL_MODEL_ASSET_REQUIRED

  • Real PaddleOCR runtime smoke — external runtime not installed

  • Real Airflow DAG execution — Airflow not installed

  • Reproducible production evaluation / benchmark — no artifact checked in
  • Tracked in #8. Deterministic fake embedders and real Qdrant + Elasticsearch integration are not real-model validation.

    Diff: 493 lines (+369 / -124) across 6 files Reviewer: Xander-Xai Review duration: 57m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.71) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 493 lines diff across 6 files
    0.71
    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.371
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.071
    Real PR Conversation Timeline
    1 comments
    "Review active on #9"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed sensitive_module
    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: 70.6% (HIGH) · Higher = larger blast radius
    70.6%
    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: 27.9% · Safe to merge
    27.9%