graph TD
Start([Start: ln-115]) --> P1[Phase 1: Check Conditions
Parse flags from coordinator]
P1 --> CheckFlags{hasDocker?}
CheckFlags -->|No| EarlyReturn([Return empty result
No Docker detected])
CheckFlags -->|Yes| P2[Phase 2: Create Document]
P2 --> Exists{runbook.md
exists?}
Exists -->|Yes| Skip[Skip with log]
Exists -->|No| Create[Copy template]
Create --> Setup[Populate setup steps
from package.json scripts]
Setup --> Env[Extract env vars
from .env.example]
Env --> Docker[Populate from
docker-compose.yml]
Docker --> CICD[Add CI/CD pipeline
from .github/workflows]
CICD --> Prune[Conditional Section Pruning]
Prune --> ScaleCheck{DEPLOYMENT_SCALE
= multi/auto?}
ScaleCheck -->|No| RemoveScale[Remove scaling/
load balancer sections]
ScaleCheck -->|Yes| KeepScale[Keep scaling sections]
RemoveScale --> GPUCheck
KeepScale --> GPUCheck
GPUCheck{HAS_GPU?}
GPUCheck -->|No| RemoveGPU[Remove GPU sections
nvidia, CUDA]
GPUCheck -->|Yes| KeepGPU[Keep GPU sections]
RemoveGPU --> ServiceCheck
KeepGPU --> ServiceCheck
ServiceCheck[Populate SERVICE_DEPENDENCIES
ONLY from DOCKER_SERVICES] --> PortCheck[Populate PORT_MAPPING
from docker-compose.yml ports]
PortCheck --> ContactCheck{DEVOPS_CONTACTS
empty?}
ContactCheck -->|Yes| MarkTBD[Mark KEY_CONTACTS
as TBD]
ContactCheck -->|No| PopContacts[Populate contacts]
MarkTBD --> P3
PopContacts --> P3
Skip --> P3
P3[Phase 3: Self-Validate] --> V1[Check SCOPE tag]
V1 --> V2[Validate sections:
Setup, Deployment, Troubleshooting]
V2 --> V3[Check env vars documented]
V3 --> V4[Check Maintenance section]
V4 --> P4[Phase 4: Return Status]
P4 --> Output[Return to coordinator:
created[], skipped[], tbd_count]
Output --> End([End: 0-1 doc processed])
classDef action fill:#C8E6C9,stroke:#388E3C,stroke-width:2px
classDef decision fill:#FFE0B2,stroke:#E64A19,stroke-width:2px
class P1,P2,Skip,Create,Setup,Env,Docker,CICD,Prune,RemoveScale,KeepScale,RemoveGPU,KeepGPU,ServiceCheck,PortCheck,MarkTBD,PopContacts,P3,V1,V2,V3,V4,P4,Output action
class CheckFlags,Exists,ScaleCheck,GPUCheck,ContactCheck decision