graph TD
Start([Input: doc_path, project_root]) --> Read[Read Document
Full content]
Read --> Phase1[Phase 1: SCOPE EXTRACTION
Parse SCOPE comment or infer]
Phase1 --> HasScope{SCOPE tag
found?}
HasScope -->|Yes| UseScope[Use stated SCOPE]
HasScope -->|No| InferScope[Infer from doc type]
UseScope --> Phase2
InferScope --> Phase2
Phase2[Phase 2: CONTENT-SCOPE ALIGNMENT
Analyze sections vs scope]
Phase2 --> CheckCoverage[Check: Scope fully covered?]
CheckCoverage --> CheckRelevance[Check: All content serves scope?]
CheckRelevance --> CheckFocus[Check: No scope creep?]
CheckFocus --> AlignScore[Calculate scope_alignment score]
AlignScore --> Phase3[Phase 3: FACT VERIFICATION
Per document type]
Phase3 --> DocType{Document
Type?}
DocType -->|architecture.md| VerifyArch[Verify layers, components
Check import patterns]
DocType -->|tech_stack.md| VerifyTech[Verify versions
Check package files]
DocType -->|api_spec.md| VerifyAPI[Verify endpoints
Check controllers]
DocType -->|requirements.md| VerifyReq[Verify features exist
Search implementations]
DocType -->|Other| VerifyGeneral[Verify paths, commands
Check file existence]
VerifyArch --> CollectFindings
VerifyTech --> CollectFindings
VerifyAPI --> CollectFindings
VerifyReq --> CollectFindings
VerifyGeneral --> CollectFindings
CollectFindings[Collect findings with evidence]
CollectFindings --> FactScore[Calculate fact_accuracy score]
FactScore --> Phase4[Phase 4: SCORING & REPORT
Combine scores, format JSON]
Phase4 --> Output([Return JSON to ln-600])
classDef discovery fill:#e1f5fe,stroke:#01579b
classDef processing fill:#fff3e0,stroke:#e65100
classDef action fill:#e8f5e9,stroke:#2e7d32
classDef output fill:#f3e5f5,stroke:#7b1fa2
classDef decision fill:#fff9c4,stroke:#f57f17
class Start,Read,Phase1 discovery
class HasScope,DocType decision
class UseScope,InferScope,Phase2,CheckCoverage,CheckRelevance,CheckFocus,AlignScore processing
class Phase3,VerifyArch,VerifyTech,VerifyAPI,VerifyReq,VerifyGeneral,CollectFindings,FactScore action
class Phase4,Output output