| 1 | # Accept & Execute β C4 Diagrams
|
| 2 |
|
| 3 | ## Level 1: System Context
|
| 4 |
|
| 5 | ```mermaid
|
| 6 | flowchart TB
|
| 7 | user["π€ Developer"]
|
| 8 |
|
| 9 | web["PAS Web<br/><i>Leptos WASM + Axum SSR</i>"]
|
| 10 | cli["PAS CLI<br/><i>decompose & scaffold</i>"]
|
| 11 | fs[("Filesystem<br/><i>specs, pipelines, issues</i>")]
|
| 12 |
|
| 13 | user -- "Approve & Execute" --> web
|
| 14 | web -- "SSE progress stream" --> user
|
| 15 | web -- "child process" --> cli
|
| 16 | web -- "read/write" --> fs
|
| 17 | cli -- "write .dot" --> fs
|
| 18 |
|
| 19 | style user fill:#08427b,color:#fff,stroke:#08427b
|
| 20 | style web fill:#1168bd,color:#fff,stroke:#1168bd
|
| 21 | style cli fill:#999,color:#fff,stroke:#999
|
| 22 | style fs fill:#999,color:#fff,stroke:#999
|
| 23 | ```
|
| 24 |
|
| 25 | ## Level 2: Container
|
| 26 |
|
| 27 | ```mermaid
|
| 28 | flowchart TB
|
| 29 | user["π€ Developer"]
|
| 30 |
|
| 31 | subgraph web ["PAS Web"]
|
| 32 | wasm["Browser Client<br/><i>Leptos WASM, xterm.js</i>"]
|
| 33 | axum["Axum Server<br/><i>Leptos SSR</i>"]
|
| 34 | broadcast[("Broadcast Channels<br/><i>tokio, in-memory</i>")]
|
| 35 | end
|
| 36 |
|
| 37 | cli["PAS CLI"]
|
| 38 | fs[("Filesystem")]
|
| 39 |
|
| 40 | user -- "click button" --> wasm
|
| 41 | wasm -- "POST server fn" --> axum
|
| 42 | axum -- "HTTP + SSE" --> wasm
|
| 43 | axum -- "tokio::process" --> cli
|
| 44 | axum -- "std::fs" --> fs
|
| 45 | axum -- "publish_event()" --> broadcast
|
| 46 | broadcast -- "BroadcastStream" --> axum
|
| 47 |
|
| 48 | style user fill:#08427b,color:#fff,stroke:#08427b
|
| 49 | style wasm fill:#1168bd,color:#fff,stroke:#1168bd
|
| 50 | style axum fill:#1168bd,color:#fff,stroke:#1168bd
|
| 51 | style broadcast fill:#438dd5,color:#fff,stroke:#438dd5
|
| 52 | style cli fill:#999,color:#fff,stroke:#999
|
| 53 | style fs fill:#999,color:#fff,stroke:#999
|
| 54 | style web fill:none,stroke:#1168bd,stroke-dasharray:5 5
|
| 55 | ```
|
| 56 |
|
| 57 | ### Container Legend
|
| 58 |
|
| 59 | | Container | Technology | Responsibility |
|
| 60 | |-----------|-----------|----------------|
|
| 61 | | Browser Client | Leptos WASM, xterm.js | Renders UI, dispatches server fns, subscribes to SSE |
|
| 62 | | Axum Server | Rust, Leptos SSR | Handles server fns, spawns CLI processes, streams events |
|
| 63 | | Broadcast Channels | tokio::broadcast | Session-keyed event bus with 100-event replay buffer |
|
| 64 | | PAS CLI | Rust binary | `decompose` specs into epics, `scaffold` pipeline .dot files |
|
| 65 | | Filesystem | Local disk | `.pas/spec.md`, `pipelines/*.dot`, beads issues |
|
| 66 |
|
| 67 | ## Level 3: Component
|
| 68 |
|
| 69 | ```mermaid
|
| 70 | flowchart TB
|
| 71 | subgraph browser ["Browser (WASM)"]
|
| 72 | approval["ApprovalBar"]
|
| 73 | exec_panel["ExecutionPanel"]
|
| 74 | exec_node["ExecutionNode"]
|
| 75 | end
|
| 76 |
|
| 77 | subgraph server ["Axum Server (SSR)"]
|
| 78 | start_exec["start_execution()"]
|
| 79 | cli_path["pas_cli_path()"]
|
| 80 | runner["PipelineRunner"]
|
| 81 | stream["stream_events()"]
|
| 82 | publish["publish_event()"]
|
| 83 | replay[("SESSION_STATE<br/><i>replay buffer</i>")]
|
| 84 | end
|
| 85 |
|
| 86 | cli["PAS CLI"]
|
| 87 | registry["Handler Registry"]
|
| 88 |
|
| 89 | approval -- "POST" --> start_exec
|
| 90 | start_exec --> cli_path
|
| 91 | start_exec -- "decompose / scaffold" --> cli
|
| 92 | start_exec -- "tokio::spawn" --> runner
|
| 93 | start_exec -- "ExecutionResponse" --> approval
|
| 94 | approval -- "on_approve(session_id)" --> exec_panel
|
| 95 | exec_panel -- "SSE EventSource" --> stream
|
| 96 | exec_panel --> exec_node
|
| 97 | runner -- "resolve + execute" --> registry
|
| 98 | runner --> publish
|
| 99 | publish --> replay
|
| 100 | stream -- "reconnect replay" --> replay
|
| 101 | stream -- "SSE events" --> exec_panel
|
| 102 |
|
| 103 | style approval fill:#1168bd,color:#fff,stroke:#1168bd
|
| 104 | style exec_panel fill:#1168bd,color:#fff,stroke:#1168bd
|
| 105 | style exec_node fill:#1168bd,color:#fff,stroke:#1168bd
|
| 106 | style start_exec fill:#438dd5,color:#fff,stroke:#438dd5
|
| 107 | style cli_path fill:#438dd5,color:#fff,stroke:#438dd5
|
| 108 | style runner fill:#438dd5,color:#fff,stroke:#438dd5
|
| 109 | style stream fill:#438dd5,color:#fff,stroke:#438dd5
|
| 110 | style publish fill:#438dd5,color:#fff,stroke:#438dd5
|
| 111 | style replay fill:#438dd5,color:#fff,stroke:#438dd5
|
| 112 | style cli fill:#999,color:#fff,stroke:#999
|
| 113 | style registry fill:#999,color:#fff,stroke:#999
|
| 114 | style browser fill:none,stroke:#1168bd,stroke-dasharray:5 5
|
| 115 | style server fill:none,stroke:#438dd5,stroke-dasharray:5 5
|
| 116 | ```
|
| 117 |
|
| 118 | ### Component Legend
|
| 119 |
|
| 120 | | Component | File | Responsibility |
|
| 121 | |-----------|------|----------------|
|
| 122 | | ApprovalBar | `components/approval_bar.rs` | Button, dispatches `start_execution()`, shows phase spinner |
|
| 123 | | ExecutionPanel | `components/execution_panel.rs` | Subscribes to SSE, renders node list with live status |
|
| 124 | | ExecutionNode | `components/execution_node.rs` | Single node: status badge, cost, notes |
|
| 125 | | start_execution() | `server/execute.rs` | Orchestrates decompose, scaffold, parse, spawn |
|
| 126 | | pas_cli_path() | `server/execute.rs` | Resolves CLI binary from `PAS_CLI_PATH` env var |
|
| 127 | | PipelineRunner | `server/execute.rs` | Walks graph, executes handlers, publishes events |
|
| 128 | | stream_events() | `server/stream.rs` | SSE endpoint, bridges broadcast to EventSource |
|
| 129 | | publish_event() | `server/stream.rs` | Writes to broadcast channel + replay buffer |
|
| 130 | | SESSION_STATE | `server/stream.rs` | Last 100 events per session for reconnect replay |
|
| 131 |
|
| 132 | ## Sequence Diagram
|
| 133 |
|
| 134 | ```mermaid
|
| 135 | sequenceDiagram
|
| 136 | actor User
|
| 137 | participant AB as ApprovalBar
|
| 138 | participant SE as start_execution
|
| 139 | participant CLI as PAS CLI
|
| 140 | participant FS as Filesystem
|
| 141 | participant PR as PipelineRunner
|
| 142 | participant BC as Broadcast
|
| 143 | participant SSE as stream_events
|
| 144 | participant EP as ExecutionPanel
|
| 145 |
|
| 146 | User->>AB: Click Approve & Execute
|
| 147 | AB->>SE: POST server fn
|
| 148 |
|
| 149 | SE->>FS: Check spec.md exists
|
| 150 | SE->>CLI: pas decompose spec.md
|
| 151 | CLI-->>SE: Epic ID: attractor-xxx
|
| 152 |
|
| 153 | SE->>CLI: pas scaffold attractor-xxx
|
| 154 | CLI-->>FS: Write .dot file
|
| 155 | CLI-->>SE: exit 0
|
| 156 |
|
| 157 | SE->>FS: Read .dot file
|
| 158 | SE->>SE: Parse β PipelineGraph
|
| 159 | SE->>PR: tokio::spawn
|
| 160 | SE-->>AB: { session_id, epic_id }
|
| 161 |
|
| 162 | AB->>EP: on_approve(session_id)
|
| 163 | EP->>SSE: EventSource connect
|
| 164 |
|
| 165 | loop Each pipeline node
|
| 166 | PR->>BC: node_start
|
| 167 | BC-->>SSE: broadcast
|
| 168 | SSE-->>EP: SSE event
|
| 169 | EP->>EP: Add node (InProgress)
|
| 170 |
|
| 171 | PR->>PR: Execute handler
|
| 172 |
|
| 173 | PR->>BC: node_complete
|
| 174 | BC-->>SSE: broadcast
|
| 175 | SSE-->>EP: SSE event
|
| 176 | EP->>EP: Update status + cost
|
| 177 | end
|
| 178 |
|
| 179 | PR->>BC: pipeline_complete
|
| 180 | BC-->>SSE: broadcast
|
| 181 | SSE-->>EP: SSE event
|
| 182 | EP->>EP: Show Done badge
|
| 183 | PR->>PR: clear_session_state
|
| 184 | ```
|