docs(planning): Phase 1 architecture-refactor window (Steps 1.1a–1.1f) + ADRs 0005–0009 - #41
Merged
Conversation
…1a–1.1f) + ADRs 0005–0009 Locks in architecture + optimization decisions before Phase 1.2 (connectors) that are very expensive to retrofit. Defers no implementation; updates all affected planning + architecture docs in one coherent pass. ## What changes ### TRACKER.md - Inserts Phase 1 Steps 1.1a–1.1f (refactor window) between 1.1 and 1.2. - Inserts Phase 2 Step 2.11 (agent-loop validation spike). - Milestone counts: Phase 1 10→16, Phase 2 10→11, Total 77→84. - Next action updated to 1.1a. ### Phase 1 plan (planning/phases/phase-1-ingestion.md) Six new detailed step plans with Goal / Inputs / Deliverables / Test plan / Acceptance criteria: - 1.1a — Core type & SPI refactor: RequestContext threaded through every SPI; typed tenant_id + acl_labels on Chunk/Embedding; trust_level for prompt-injection defense; Embedding.dtype (float32/int8/binary); BlobRef for lazy chunk text; QueryPlan + ChunkRef; typed StageEvent. - 1.1b — SPI split: RetrievalBackend / IndexBackend; bulk + streaming + retrieve_ids/hydrate + IndexHint. - 1.1c — PolicyEngine package (rag-policy): single PDP for ACL / PII / quotas / redaction. Supersedes scattered checks. Coverage linter blocks bypasses. Step 6.4 (ACL egress verifier) marked redundant. - 1.1d — Pipeline + Batcher primitives in rag-core. - 1.1e — Three-cache SPI split (EmbeddingCache / RetrievalCache / AnswerCache), hot-path discipline doc, async telemetry with drop-on-overflow. - 1.1f — ADRs 0005–0009 + reviewer checklist. ### Phase 2 plan (planning/phases/phase-2-retrieval.md) - Step 2.11 — Agent-loop validation spike at end of Phase 2 to validate retrieval design against agent access patterns before Phase 3. ### Architecture docs (new) - docs/architecture/request-context.md — the per-request envelope. - docs/architecture/policy-engine.md — central PDP design + usage + extension. - docs/architecture/caching.md — three caches, three invalidation rules. - docs/architecture/performance.md — hot-path discipline, per-SPI p99 budgets, reviewer checklist. ### ADRs (new) - ADR-0005 — PolicyEngine as central PDP. - ADR-0006 — Two-stage reranker as default SPI shape from day 1. - ADR-0007 — Chunk.text: str | BlobRef enables lazy hydration + tiering. - ADR-0008 — Cost-aware planner; fallback triggered planner-side before dispatch, not by post-hoc timeout. - ADR-0009 — Vector index strategy by scale tier + int8/binary quantization; resolves ADR-0004 §2 "ivfflat hardcoded" gap. ### HLD (docs/architecture/RAG-Platform-HLD.md) - v1.0 → v1.1. - §4.2 components table expanded: PolicyEngine added; Knowledge Store split into Retrieval + Index; runtime primitives table added (RequestContext, QueryPlan, Pipeline, Batcher, PolicyEngine, StageEvent, ChunkRef, BlobRef). - §10 governance rewritten around PolicyEngine PDP; trust_level documented as prompt-injection foundation; Step 6.4 (egress verifier) marked redundant. - §11 observability adds StageEvent stream + async telemetry path. ### EXECUTION-PLAN.md - §3 phase summary updated (Phase 1 + refactor window; Phase 2 + spike). - §9 change log: v1.2 entry. ### PROBLEM-TRACEABILITY.md - Cross-tenant, ACL, PII entries route through PolicyEngine PDP. - Latency entry adds 1.1b/1.1d/1.1e + ADRs 0006/0008/0009. - Step 6.4 marked superseded. - New entry: prompt injection → trust_level + LLM adapter isolation strategy. - 22 → 23 entries. ### RISK-REGISTER.md - R2, R4, R5, R11 mitigations hardened with explicit pointers to ADRs 0005, 0006, 0008, 0009 and the PolicyEngine coverage linter. ### CLAUDE.md - Current phase / next step updated to 1.1a + refactor window context. - Repo layout: rag-policy and rag-backends packages added. - Python packages table: rag-policy added; rag-core + rag-observability descriptions updated for Pipeline / Batcher / async exporter. - New sections: RequestContext threading, PolicyEngine, hot-path discipline. - Standing constraints expanded. ### docs/README.md - Indexes the four new architecture docs and five new ADRs. ## Documentation Every affected file is updated in this single PR per the standing per-PR-documentation rule. Cross-references between TRACKER, planning, architecture, and ADRs are bidirectional. ## Test plan No code changes in this PR — planning + docs only. Implementation work begins on a separate branch for Step 1.1a. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 tasks
officialCodeWork
added a commit
that referenced
this pull request
May 23, 2026
chore(tracker): log PR #41 in history table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Inserts a six-step refactor window (1.1a–1.1f) between Phase 1 Step 1.1 and Step 1.2 to lock in architecture + optimization decisions that are very expensive to retrofit later. Also inserts Phase 2 Step 2.11 (agent-loop validation spike). Adds 5 new ADRs and 4 new architecture docs. Updates the HLD to v1.1 to reflect the new patterns.
No code changes — planning + docs only. Implementation begins on the 1.1a branch.
What changes
New Phase 1 steps (planning/phases/phase-1-ingestion.md)
New Phase 2 step
Milestone counts
New ADRs (docs/adr/)
New architecture docs (docs/architecture/)
HLD update (v1.0 → v1.1)
Planning doc updates
CLAUDE.md
Why this PR, why now
After review with the team, the V1.0 plan had three architectural risks that were going to surface as expensive Phase-4/Phase-7 rework:
These are fixed cheaply before the 6 connectors + 4 retrieval backends + agent loop are written. After that point, the cost is 4–6× higher.
Documentation
Per CLAUDE.md per-PR doc rule, every affected file is updated in this PR:
Cross-references between TRACKER, planning, architecture, and ADRs are bidirectional.
Test plan
🤖 Generated with Claude Code