# Request System Flowchart

This flow shows the current Worldshaper request pipeline from public submission through promotion into the public Active request list.

![Worldshaper Request System Flowchart](./request-system-flowchart.svg)

```mermaid
flowchart TD
  A[User submits request from Launcher Requests tab] --> B[POST /api/launcher-requests]
  B --> C[Server normalizes request<br/>status = pending<br/>stores sourceText + fallback title]
  C --> D[Request saved in launcher request store]

  D --> E{How does analysis start?}
  E -->|Auto / queued worker| F[Request analysis worker selects pending unprocessed requests]
  E -->|Admin clicks Run Pending Queue| F
  E -->|Admin manual resubmission| F

  F --> G[Mark request analysis.state = processing]
  G --> H[Routing pass]
  H --> H1[Map slang / loose wording to Worldshaper terminology]
  H1 --> H2[Suggest standardized tags, likely systems, likely modules]
  H2 --> I[Load only relevant KB docs]
  I --> J[Deep analysis pass]
  J --> K[Split submission into one or more atomic request items]
  K --> L[Generate title, category, standardized tags,<br/>parsed interpretation, implementation approach,<br/>review rationale, and confidence]

  L --> M{Can it auto-promote?}
  M -->|Yes| N[Requirements:<br/>all items statusRecommendation = active<br/>every item confidence >= promote threshold<br/>routing ambiguity is not high]
  N --> O[POST /api/launcher-requests/:id/process-analysis<br/>action = promote]
  O --> P[Server replaces pending submission with one or more active request rows]
  P --> Q[Public Requests tab shows those rows as Active]

  M -->|No| R[POST /api/launcher-requests/:id/process-analysis<br/>action = review]
  R --> S[Original request stays pending]
  S --> T[analysis.state = needs_review or error<br/>routing + analysis metadata saved on the request]
  T --> U[Admin reviews request in Admin window]
  U --> V{Admin outcome}
  V -->|Edit + approve| O
  V -->|Edit + resubmit| F
  V -->|Leave pending| S
```

## Notes

- Public submission starts as a single `pending` request record, even if the worker later splits it into multiple active items.
- The original `sourceText` is preserved through the workflow.
- Auto-promotion is intentionally strict:
  - every analyzed item must recommend `active`
  - every item must meet the confidence threshold
  - routing ambiguity cannot be `high`
- If the analyzer is unsure, the request is still interpreted and stored with review guidance instead of being dropped.
- Promotion replaces the pending submission with one or more normalized active request rows that appear on the public board.
