|
| 1 | +<!-- K9 Coordination Protocol — Generated for Claude Code --> |
| 2 | +<!-- Source: coordination.k9 | Generated: 2026-04-03 --> |
| 3 | +<!-- Re-generate: deno run --allow-read --allow-write generate.js coordination.k9 --> |
| 4 | + |
| 5 | +# PanLL — AI Coordination Rules |
| 6 | + |
| 7 | +> **Auto-generated from `coordination.k9`** — do not edit directly. |
| 8 | +> Re-generate with: `deno run --allow-read --allow-write generate.js coordination.k9` |
| 9 | +> Source of truth: `coordination.k9` in repository root. |
| 10 | +
|
| 11 | +## Project |
| 12 | + |
| 13 | +Neurosymbolic IDE built on the Binary Star model — human (symbolic, Panel-L) and machine (neural, Panel-N) orbiting a shared world state (Panel-W). 106 panels, custom TEA runtime, Gossamer desktop backend. |
| 14 | + |
| 15 | +**Languages:** ReScript, Rust, Elixir, JavaScript |
| 16 | +**License:** PMPL-1.0-or-later |
| 17 | +**Build system:** just |
| 18 | +**Runtime:** deno |
| 19 | + |
| 20 | +## Build Commands |
| 21 | + |
| 22 | +| Command | Description | |
| 23 | +|---------|-------------| |
| 24 | +| `just build` | Full build (ReScript + CSS + bundle) | |
| 25 | +| `just res` | ReScript compile only | |
| 26 | +| `just bundle` | esbuild bundle | |
| 27 | +| `just css` | Build CSS | |
| 28 | +| `just dev` | Start dev server on port 8000 | |
| 29 | +| `just test` | Run test suite (979 tests, 41 suites) | |
| 30 | +| `just coverage` | Run tests with coverage | |
| 31 | +| `just lint` | Lint ReScript source | |
| 32 | +| `just doctor` | Run project health checks | |
| 33 | + |
| 34 | +## INVARIANTS — Do Not Violate |
| 35 | + |
| 36 | +These rules are non-negotiable. Violating them will break the project |
| 37 | +or contradict deliberate architectural decisions. |
| 38 | + |
| 39 | +### [CRITICAL] custom-tea-runtime |
| 40 | + |
| 41 | +**Rule:** The custom TEA runtime in src/tea/ (18 modules) must NEVER be replaced with rescript-tea or any other library |
| 42 | + |
| 43 | +**Why:** rescript-tea was deliberately evaluated and rejected. The custom TEA runtime handles PanLL-specific needs: Anti-Crash circuit breaking, Vexometer cognitive load adaptation, OrbitalSync multi-panel state coherence, and panel lifecycle management. It is not legacy — it is the architecture. |
| 44 | + |
| 45 | +### [CRITICAL] no-typescript |
| 46 | + |
| 47 | +**Rule:** Do not introduce TypeScript files — ReScript is the frontend language |
| 48 | + |
| 49 | +**Why:** ReScript provides better type safety with less overhead. This is a deliberate, ecosystem-wide decision. |
| 50 | + |
| 51 | +### [CRITICAL] no-tauri |
| 52 | + |
| 53 | +**Rule:** Do not introduce Tauri references or dependencies — Gossamer is the desktop backend |
| 54 | + |
| 55 | +**Why:** PanLL was migrated FROM Tauri 2.0 TO Gossamer. This migration is complete and intentional. |
| 56 | + |
| 57 | +### [CRITICAL] tea-pattern-only |
| 58 | + |
| 59 | +**Rule:** All state management uses TEA (Model -> Msg -> Update -> View) — no MVC, Redux, hooks, or other patterns |
| 60 | + |
| 61 | +**Why:** TEA is foundational to PanLL's architecture. Model.res holds all state, Msg.res defines all messages, Update.res is the state transition kernel. |
| 62 | + |
| 63 | +### [CRITICAL] all-state-in-model |
| 64 | + |
| 65 | +**Rule:** ALL application state lives in Model.model — no global mutable state, no module-level state, no window.* state |
| 66 | + |
| 67 | +**Why:** TEA requires single state tree. Anti-Crash and OrbitalSync depend on this invariant for correctness. |
| 68 | + |
| 69 | +### [CRITICAL] no-npm-bun |
| 70 | + |
| 71 | +**Rule:** No npm, Bun, pnpm, or yarn — Deno is the orchestrator |
| 72 | + |
| 73 | +**Why:** npm is used ONLY for the ReScript compiler (which requires it). All other tooling uses Deno. Do not add npm dependencies. |
| 74 | + |
| 75 | +### [CRITICAL] anticrash-validates-all |
| 76 | + |
| 77 | +**Rule:** Anti-Crash circuit breaker validates ALL neural tokens before symbolic execution — never bypass this |
| 78 | + |
| 79 | +**Why:** Safety-critical: prevents untrusted neural output from corrupting symbolic state. The validation path exists for a reason. |
| 80 | + |
| 81 | +### [HIGH] panels-not-panes |
| 82 | + |
| 83 | +**Rule:** UI elements are called 'panels', NEVER 'panes', 'tabs', or 'windows' |
| 84 | + |
| 85 | +**Why:** PanLL naming convention — 'panels' is the correct term everywhere in code, docs, and communication |
| 86 | + |
| 87 | +### [CRITICAL] no-bulk-panel-deletion |
| 88 | + |
| 89 | +**Rule:** Do not delete more than 2 panel files in a single operation without explicit user approval |
| 90 | + |
| 91 | +**Why:** 106 panels have complex interdependencies. Bulk deletion can cascade and break OrbitalSync. |
| 92 | + |
| 93 | +### [HIGH] gossamer-bridge-pattern |
| 94 | + |
| 95 | +**Rule:** Gossamer commands in src/commands/ are invoke wrappers only — do not put business logic there |
| 96 | + |
| 97 | +**Why:** Business logic belongs in Update.res. Commands are thin bridges to the Gossamer backend. |
| 98 | + |
| 99 | +### [CRITICAL] binary-star-model |
| 100 | + |
| 101 | +**Rule:** The Binary Star architecture (Panel-L symbolic + Panel-N neural + Panel-W world) is deliberate — do not flatten into a single panel type |
| 102 | + |
| 103 | +**Why:** The three panel types serve fundamentally different roles. This is the core design of PanLL. |
| 104 | + |
| 105 | +### [CRITICAL] rescript-core-team |
| 106 | + |
| 107 | +**Rule:** The project owner is on the ReScript core team — do not suggest migrating away from ReScript |
| 108 | + |
| 109 | +**Why:** ReScript is not a temporary choice. The owner contributes to ReScript itself. |
| 110 | + |
| 111 | +## Protected Files and Directories |
| 112 | + |
| 113 | +Do NOT delete, reorganise, or replace these without explicit user approval: |
| 114 | + |
| 115 | +| Path | Reason | |
| 116 | +|------|--------| |
| 117 | +| `src/tea/` | Custom TEA runtime — 18 modules. NEVER replace with rescript-tea. | |
| 118 | +| `src/Model.res` | Single state tree — all application state lives here | |
| 119 | +| `src/Msg.res` | Message type definitions — the TEA message catalogue | |
| 120 | +| `src/Update.res` | State transition kernel — ~7500 lines, the heart of PanLL | |
| 121 | +| `src/View.res` | Root view renderer | |
| 122 | +| `src/App.res` | Application entry point | |
| 123 | +| `src/core/` | Core engines — AntiCrash, OrbitalSync, Contractiles, TypeLLEngine, VabEngine | |
| 124 | +| `src/components/` | 106 panel views — do not bulk-delete | |
| 125 | +| `src/commands/` | Gossamer bridge commands — thin wrappers only | |
| 126 | +| `src/modules/` | Module registry + TypeLLService — cross-panel type intelligence | |
| 127 | +| `src-gossamer/` | Rust backend (WebKitGTK) — Gossamer desktop integration | |
| 128 | +| `beam/` | Elixir/BEAM API layer | |
| 129 | +| `tests/` | 979 tests, 41 suites — never delete tests | |
| 130 | +| `.machine_readable/` | Canonical location for A2ML state files — MUST stay here | |
| 131 | +| `coordination.k9` | This file — source of truth for AI coordination | |
| 132 | + |
| 133 | +## Architecture Decisions (Deliberate) |
| 134 | + |
| 135 | +These choices may look unusual but are intentional: |
| 136 | + |
| 137 | +### gossamer-not-tauri |
| 138 | + |
| 139 | +**Decision:** Gossamer (Zig + WebKitGTK) is the desktop backend — migration from Tauri 2.0 is complete |
| 140 | + |
| 141 | +**Why:** Gossamer is the hyperpolymath desktop runtime. Tauri was used previously but replaced. |
| 142 | + |
| 143 | +**Rejected alternatives:** Tauri 2.0, Electron, native GTK |
| 144 | + |
| 145 | +### custom-tea-not-rescript-tea |
| 146 | + |
| 147 | +**Decision:** Custom TEA runtime (src/tea/, 18 modules) instead of the rescript-tea library |
| 148 | + |
| 149 | +**Why:** PanLL needs Anti-Crash integration, OrbitalSync, Vexometer hooks, and panel lifecycle — none available in rescript-tea |
| 150 | + |
| 151 | +**Rejected alternatives:** rescript-tea, Redux, MobX, React hooks pattern |
| 152 | + |
| 153 | +### deno-npm-hybrid |
| 154 | + |
| 155 | +**Decision:** Deno orchestrates everything, but npm is used solely for the ReScript compiler |
| 156 | + |
| 157 | +**Why:** ReScript compiler requires npm — this is the ONLY permitted npm usage. Do not extend npm's role. |
| 158 | + |
| 159 | +### binary-star |
| 160 | + |
| 161 | +**Decision:** Three panel types: Panel-L (symbolic/human), Panel-N (neural/machine), Panel-W (world/shared) |
| 162 | + |
| 163 | +**Why:** Neurosymbolic architecture requires clear separation of human reasoning, machine inference, and shared world state |
| 164 | + |
| 165 | +### vexometer-cognitive-load |
| 166 | + |
| 167 | +**Decision:** Vexometer monitors operator stress and adapts UI detail density |
| 168 | + |
| 169 | +**Why:** HTI (Human-Tool Interaction) principle — the IDE adapts to the human, not vice versa |
| 170 | + |
| 171 | +### anticrash-circuit-breaker |
| 172 | + |
| 173 | +**Decision:** Anti-Crash validates all neural tokens before they enter the symbolic pipeline |
| 174 | + |
| 175 | +**Why:** Safety boundary between neural and symbolic systems — prevents hallucinated code from corrupting state |
| 176 | + |
| 177 | +## Do NOT Create |
| 178 | + |
| 179 | +These files, patterns, or systems must NOT be introduced: |
| 180 | + |
| 181 | +- ****/*.ts** — TypeScript is banned — use ReScript |
| 182 | +- **Dockerfile** — Use Containerfile (Podman, not Docker) |
| 183 | +- ****/*.py** — Python is banned — use ReScript, Rust, or Elixir |
| 184 | +- **A replacement TEA runtime or state management library** — src/tea/ is the TEA runtime — it is custom, deliberate, and must not be replaced |
| 185 | +- **REST API endpoints parallel to existing Groove protocol endpoints** — Groove is the inter-service communication protocol — do not create REST alternatives |
| 186 | +- **A new panel type beyond Panel-L, Panel-N, Panel-W** — Binary Star model has exactly three types — adding more would break OrbitalSync |
| 187 | +- **Direct Tauri imports or tauri.conf.json** — Tauri migration to Gossamer is complete — do not reintroduce |
| 188 | + |
| 189 | +## Terminology |
| 190 | + |
| 191 | +Use the correct terms for this project: |
| 192 | + |
| 193 | +- Say **"panels"**, NOT "panes", "tabs", "windows" |
| 194 | + - PanLL UI elements are always called panels — this is enforced everywhere |
| 195 | +- Say **"Binary Star"**, NOT "dual-pane", "split-view", "two-panel" |
| 196 | + - The architectural model is Binary Star (Panel-L + Panel-N orbiting Panel-W) |
| 197 | +- Say **"Anti-Crash"**, NOT "validator", "sanitizer", "filter" |
| 198 | + - The neural token validation system is called Anti-Crash |
| 199 | +- Say **"Vexometer"**, NOT "stress meter", "load indicator", "fatigue tracker" |
| 200 | + - The cognitive load monitoring system is called Vexometer |
| 201 | +- Say **"OrbitalSync"**, NOT "state sync", "panel sync", "sync engine" |
| 202 | + - The multi-panel state coherence system is called OrbitalSync |
| 203 | + |
| 204 | +## Port Assignments |
| 205 | + |
| 206 | +| Service | Port | |
| 207 | +|---------|------| |
| 208 | +| dev-server | 8000 | |
| 209 | +| echidna | 9000 | |
| 210 | +| verisimdb | 8080 | |
| 211 | +| boj-server | 7700 | |
| 212 | +| typell | 7800 | |
| 213 | + |
| 214 | +## Ecosystem Context |
| 215 | + |
| 216 | +**Depends on:** |
| 217 | +- **gossamer** — Desktop backend runtime (Zig + WebKitGTK) |
| 218 | +- **verisimdb** — Persistent storage layer |
| 219 | +- **typell** — Type intelligence engine — cross-panel type checking |
| 220 | +- **boj-server** — MCP server — all external tool integration |
| 221 | + |
| 222 | +**Consumed by:** |
| 223 | +- **idaptik** — Uses PanLL as level editor for game content |
| 224 | + |
| 225 | +**Related projects:** |
| 226 | +- **echidna** — Proof engine — formal verification integration |
| 227 | +- **hypatia** — Neurosymbolic CI/CD scanning |
| 228 | +- **panic-attack** — Security scanning tool |
| 229 | +- **gitbot-fleet** — Bot orchestration (rhodibot, echidnabot, etc.) |
| 230 | +- **proven** — Formally verified alternatives library |
0 commit comments