# Runtime Read Policy **Authoritative source for document loading** during every AI-assisted phase on TorbatYar. All framework stages ([development-loop.md](development-loop.md), [enterprise-phase-discovery.md](enterprise-phase-discovery.md), [master-prompt.md](master-prompt.md)) defer to this policy. When any other document says “read all …”, “read framework + architecture …”, or lists unconditional doc paths, **this policy wins**. **Incremental loading:** [context-cache-policy.md](context-cache-policy.md) governs whether to re-read or reuse cached context between phases. This policy still defines *what* may load; the cache policy defines *when to re-read* unchanged files. **Service state:** [service-snapshot-policy.md](service-snapshot-policy.md) provides compact per-service state. **[project-index.yaml](project-index.yaml) is the single runtime discovery entry point** — resolve service, snapshot, roadmap, and handover paths from the index; never scan repository folders. ## Execution entry (every phase) At phase start, in **exact** order: 1. Load [Project Index](project-index.yaml). 2. Load [Runtime Read Policy](runtime-read-policy.md) (this document). 3. Load [Context Cache Policy](context-cache-policy.md). 4. Load the current **service snapshot** — path from Project Index `snapshot_file` for the active service. 5. Read [phase-manifest.yaml](phase-manifest.yaml). 6. Read [service-manifest.yaml](service-manifest.yaml). 7. Read **only** the latest handover — path from Project Index `latest_handover` for the active service. 8. Read additional documents only when this policy requires them. **Never scan** folders to discover services, handovers, roadmaps, snapshots, ADRs, or architecture documents — resolve through Project Index. ## Loading tiers Agents MUST load documents only from the tiers below. Do not bulk-read directories or unrelated services. ### ALWAYS READ Required context at phase start. Split by [context-cache-policy.md](context-cache-policy.md): **Always reload from disk (every new phase):** | Document | Path | | --- | --- | | Project Index | [project-index.yaml](project-index.yaml) | | Service snapshot | From Project Index `snapshot_file` for active service | | Phase manifest | [phase-manifest.yaml](phase-manifest.yaml) | | Service manifest | [service-manifest.yaml](service-manifest.yaml) | | Progress | [progress.md](../progress.md) | | Next steps | [next-steps.md](../next-steps.md) | | Latest phase handover | From Project Index `latest_handover` for active service | Also load the **current phase brief** (phase doc or prompt) when assigned — new each phase. **Required but cache-eligible (reload only if changed):** | Document | Path | | --- | --- | | Module registry | [module-registry.md](../module-registry.md) | | Glossary | [glossary.md](../glossary.md) | | Docs index | [docs/README.md](../README.md) | | Definition of Done | [definition-of-done.md](definition-of-done.md) | | Quality gates | [quality-gates.md](quality-gates.md) | | Development loop | [development-loop.md](development-loop.md) | | Enterprise Phase Discovery | [enterprise-phase-discovery.md](enterprise-phase-discovery.md) | | Runtime Read Policy | [runtime-read-policy.md](runtime-read-policy.md) | | Context Cache Policy | [context-cache-policy.md](context-cache-policy.md) | | Service Snapshot Policy | [service-snapshot-policy.md](service-snapshot-policy.md) | Do **not** auto-read latest completed handover or completed phase documents when a valid service snapshot exists — use snapshot + latest handover only per [service-snapshot-policy.md](service-snapshot-policy.md). ### READ ONCE PER SERVICE Load once per service when entering that service’s work; cache per [context-cache-policy.md](context-cache-policy.md) — do not re-read on every sub-step or subsequent phase unless content changed: | Document | Path | | --- | --- | | Service roadmap | From Project Index `roadmap_file` for active service | | Service README | `backend/services//README.md` | Do **not** load latest completed phase documents when snapshot is valid — snapshot supersedes historical phase doc reconstruction. ### READ ONLY IF REFERENCED Load individual files from these areas **only** when required by one of the [Additional load triggers](#additional-load-triggers) below — never as bulk directory reads: | Area | Path | | --- | --- | | Architecture | `docs/architecture/*` | | ADRs | `docs/architecture/adr/*` | | Reference contracts | `docs/reference/*` | | Development standards | `docs/development/*` | | Deployment | `docs/deployment/*` | Examples: load [ADR-001](../architecture/adr/ADR-001.md) when tenancy or DB-per-service is in scope; load [testing-strategy.md](../development/testing-strategy.md) when running the Testing stage; load [event-catalog.md](../reference/event-catalog.md) when validating events. After first load, **cache** individual architecture, ADR, reference, development, and deployment files until changed. ### NEVER AUTO READ Do not load unless an [Additional load trigger](#additional-load-triggers) explicitly requires a specific file: | Category | Examples | | --- | --- | | Other services | Roadmaps, phase docs, handovers, snapshots of services not in current scope | | Completed phase history | Completed phase documents when a valid service snapshot exists | | Frontend | `frontend/` documentation (unless the phase scopes frontend work) | | Historical / audit | Old audit reports, superseded handovers, archived docs | | Bulk paths | `architecture/*`, `reference/*`, `development/*`, `deployment/*`, `phase-handover/*`, `service-snapshots/*` as directory scans | | Repository tree scan | Any folder walk to discover services, docs, or paths not listed in Project Index | ## Additional load triggers Beyond the tiers above, load a document **only** when: 1. **Required by the current phase** — listed in the phase brief, phase doc, or promoted Discovery scope. 2. **Required by the current service** — owning service README, templates, or in-service docs for work in progress. 3. **Referenced by [phase-manifest.yaml](phase-manifest.yaml)** — `required_docs`, deliverables, or phase metadata for this phase ID. 4. **Referenced by [service-manifest.yaml](service-manifest.yaml)** — service entry, dependencies, or required docs for the owning service. 5. **Referenced by [project-index.yaml](project-index.yaml)** — snapshot, roadmap, handover, or ADR path for the active service. 6. **Referenced by the latest handover** — explicit paths beyond index entries. 7. **Required by a compatibility or validation rule** — e.g. [quality-gates.md](quality-gates.md) gate, [boundary-rules.md](boundary-rules.md), or a cited ADR during Architecture Validation. When a trigger applies, load **only the referenced files**, not sibling or parent directories. ## Discovery inputs (policy mapping) [Enterprise Phase Discovery](enterprise-phase-discovery.md) synthesizes inputs below. Use this mapping instead of reading every path unconditionally: | Discovery input | Load via | | --- | --- | | Service baseline state | **Project Index** + **service snapshot** ([service-snapshot-policy.md](service-snapshot-policy.md)) | | Current Roadmap | Project Index `roadmap_file` + snapshot + manifests | | Current Architecture | READ ONLY IF REFERENCED (manifest, handover, phase, gate, ADR, or snapshot `active_adrs`) | | Service Boundaries | Snapshot + ALWAYS READ registries/manifests; boundary docs when referenced | | Previous Phase Handover | Project Index `latest_handover` (always reload) | | Existing Codebase | Inspect `backend/services//` for delta verification (not full reconstruction) | | Existing APIs | Snapshot `public_apis` summary; codebase/OpenAPI for current-phase changes | | Existing Domain Model | Snapshot + codebase + current phase doc | | Existing Events | Snapshot `published_events`; codebase for current-phase changes | | Existing Permissions | Snapshot `permission_prefix` + codebase | | Existing Aggregates | Codebase models; snapshot modules — not completed phase docs | | Existing Tests | Codebase `app/tests/` | | Existing Documentation | Snapshot + ALWAYS READ tier + current phase doc + triggered reference files | ## Framework and template docs Load framework templates ([cursor-guidelines.md](cursor-guidelines.md), [testing-template.md](testing-template.md), [api-template.md](api-template.md), etc.) **when the active development-loop stage or quality gate requires them**, not preemptively. [master-prompt.md](master-prompt.md) summarizes permanent rules; ALWAYS READ tier already includes loop, gates, DoD, and Discovery. ## Backward compatibility - Completed business phases and their handovers are unchanged. - Legacy prompts or docs that instruct unconditional reads are **superseded** by this policy; agents follow tiers and triggers above. - Path `docs/ai-framework/` remains canonical; no relocation required. - Enterprise Phase Discovery remains mandatory; Discovery uses snapshot + targeted loading, not full-tree or historical phase doc reads. - Cache reuse is an optimization; if change detection is unavailable, follow read tiers normally. - Services without a snapshot: path from Project Index; build per [service-snapshot-policy.md](service-snapshot-policy.md) fallback rules. - New services: add Project Index entry on registration; never discover by scanning. ## Related Documents - [Project Index](project-index.yaml) - [Service Snapshot Policy](service-snapshot-policy.md) - [Context Cache Policy](context-cache-policy.md) - [Master Prompt](master-prompt.md) - [Development Loop](development-loop.md) - [Enterprise Phase Discovery](enterprise-phase-discovery.md) - [Quality Gates](quality-gates.md) - [Phase Handover](phase-handover.md)