# ThothII operating workflow ThothII guides every question through eight phases. The model proposes the work, the reviewer makes decisions at gates, and the system records persistent artifacts and decisions. ```mermaid flowchart LR Q["Question"] --> F1["F1 Clarification"] F1 --> F2["F2 Memory"] F2 --> F3["F3 Rewriting"] F3 --> F4["F4 Evidence"] F4 --> F5["F5 Schema"] F5 --> F6["F6 CTE plan"] F6 --> F7["F7 SQL"] F7 --> F8["F8 Promotion"] F8 --> DONE["Finalized session"] ``` ## Workflow principles - The model proposes; the reviewer approves, corrects, or rejects. - The session ledger records every material decision. - Persisted state is the source of truth. - A phase advances only when its artifacts and gates are complete. - Resume rebuilds context from persisted artifacts, not from the conversation. ## F1: clarification The system identifies the ambiguity most likely to change the meaning of the question and presents one decision at a time. Mutually exclusive interpretations use a single choice; multiple valid answers use a multiple choice. ## F2: Memory The system proposes Memory items that fit the question. Selected items enter the current session context; unselected items remain available for future questions. ## F3: rewriting The system rewrites the question explicitly using the approved clarifications. The reviewer checks the resulting question and its assumptions before continuing. ## F4: Evidence The system retrieves Evidence from the active corpus and presents citations and provenance. The reviewer decides which items apply to the question. ## F5: schema Tables, columns, relationships, and filters are linked to the approved meaning of the question. The summary closes the phase when the question, assumptions, and DWH elements are consistent. ## F6: CTE plan The query is broken into named CTEs with a purpose, dependencies, tables, filters, and output columns. The reviewer sees each step before the system produces the final SQL. ## F7: final SQL The system produces `sql_final.sql`, checks it against the approved plan, and presents the artifact to the reviewer. A correction can reopen the CTE plan without discarding decisions that remain valid. ## F8: Memory promotion At the end of the session, the system proposes reusable clarifications. The reviewer decides which ones to promote to the global registry, and the session is then finalized. ## Available gates | Gate | Use | | --- | --- | | Single choice | Only one interpretation can be valid | | Multiple choice | Several items can be valid at the same time | | Artifact confirmation | Approval of a document or phase result | | Phase confirmation | Explicitly closes a phase | ## Resume and reopening A resumed session returns to its last incomplete phase. Reopening invalidates only the decisions and artifacts that depend on the changed point; the rest of the work remains valid.