|
| 1 | +# ⚠️ STOP - CRITICAL READING REQUIRED |
| 2 | + |
| 3 | +**THIS FILE MUST BE READ FIRST BY ALL AI AGENTS** |
| 4 | + |
| 5 | +## WHAT IS THIS? |
| 6 | + |
| 7 | +This is the AI manifest for **ephapax** — a dyadic language with linear and affine type systems. It declares: |
| 8 | +- Canonical file locations (where things MUST be, and nowhere else) |
| 9 | +- Critical invariants (rules that must NEVER be violated) |
| 10 | +- Repository structure and organization |
| 11 | +- Dyadic language design (affine vs. linear modes) |
| 12 | + |
| 13 | +## CANONICAL LOCATIONS (UNIVERSAL RULE) |
| 14 | + |
| 15 | +### Machine-Readable Metadata: `.machine_readable/` ONLY |
| 16 | + |
| 17 | +These 6 SCM files MUST exist in `.machine_readable/` directory ONLY: |
| 18 | +1. **STATE.scm** - Project state, progress, blockers |
| 19 | +2. **META.scm** - Architecture decisions, governance |
| 20 | +3. **ECOSYSTEM.scm** - Position in ecosystem, relationships |
| 21 | +4. **AGENTIC.scm** - AI agent interaction patterns |
| 22 | +5. **NEUROSYM.scm** - Neurosymbolic integration config |
| 23 | +6. **PLAYBOOK.scm** - Operational runbook |
| 24 | + |
| 25 | +**CRITICAL:** If ANY of these files exist in `.machine_read/` or the root directory, this is an ERROR. |
| 26 | +**LEGACY:** `.machine_read/` is DEPRECATED. All files must migrate to `.machine_readable/`. |
| 27 | + |
| 28 | +### Bot Directives: `.bot_directives/` ONLY |
| 29 | + |
| 30 | +Bot-specific instructions for: |
| 31 | +- rhodibot - Git operations |
| 32 | +- echidnabot - Code quality |
| 33 | +- sustainabot - Dependency updates |
| 34 | +- glambot - Documentation |
| 35 | +- seambot - Integration |
| 36 | +- finishbot - Task completion |
| 37 | + |
| 38 | +### Agent Instructions |
| 39 | + |
| 40 | +- `.claude/CLAUDE.md` - Claude-specific patterns (if exists) |
| 41 | +- `0-AI-MANIFEST.a2ml` - THIS FILE (universal entry point) |
| 42 | + |
| 43 | +## CORE INVARIANTS |
| 44 | + |
| 45 | +1. **No SCM duplication** - Root must NOT contain STATE.scm, META.scm, etc. |
| 46 | +2. **Single source of truth** - `.machine_readable/` is authoritative |
| 47 | +3. **No stale metadata** - If root or `.machine_read/` SCMs exist, they are OUT OF DATE |
| 48 | +4. **License consistency** - All code PMPL-1.0-or-later (was EUPL-1.2, updated) |
| 49 | +5. **Author attribution** - Always "Jonathan D.A. Jewell <jonathan.jewell@open.ac.uk>" |
| 50 | +6. **Dyadic design** - Language supports BOTH affine and linear modes (not mutually exclusive) |
| 51 | + |
| 52 | +## DYADIC LANGUAGE DESIGN (CRITICAL CONCEPT) |
| 53 | + |
| 54 | +Ephapax is a **dyadic language** with TWO type system modes: |
| 55 | + |
| 56 | +### Affine Mode (Permissive) |
| 57 | +- Values can be used **at most once** (0 or 1 times) |
| 58 | +- **Can be dropped/ignored** without error |
| 59 | +- Suitable for: prototyping, exploration, optional resource cleanup |
| 60 | +- Trade-off: More flexible, less safety guarantees |
| 61 | +- Compilation: `just compile-affine input.eph affine output.wasm` |
| 62 | + |
| 63 | +### Linear Mode (Strict) |
| 64 | +- Values MUST be used **exactly once** (1 time only) |
| 65 | +- **Cannot be dropped** - compiler error if unused |
| 66 | +- Suitable for: resource safety, connection management, memory leak prevention |
| 67 | +- Trade-off: Stricter, stronger guarantees |
| 68 | +- Compilation: (To be implemented with same pipeline) |
| 69 | + |
| 70 | +### Dyadic Philosophy |
| 71 | +- **Not a migration path** - Both modes are first-class citizens |
| 72 | +- **Use case driven** - Choose mode based on requirements, not maturity |
| 73 | +- **Same syntax** - Language features identical, only type system strictness differs |
| 74 | +- **Mode switching** - Code can be checked in either mode via `--mode` flag |
| 75 | + |
| 76 | +## REPOSITORY STRUCTURE |
| 77 | + |
| 78 | +This repo contains a **two-stage compiler**: |
| 79 | + |
| 80 | +``` |
| 81 | +ephapax/ |
| 82 | +├── 0-AI-MANIFEST.a2ml # THIS FILE (start here) |
| 83 | +├── README.adoc # Project overview |
| 84 | +├── Cargo.toml # Rust workspace configuration |
| 85 | +├── justfile # Build commands |
| 86 | +│ |
| 87 | +├── idris2/ # Stage 1: Idris2 affine/linear type checker |
| 88 | +│ ├── ephapax-affine.ipkg # Idris2 package (handles BOTH modes) |
| 89 | +│ ├── src/ # Idris2 source (parser, type checker) |
| 90 | +│ └── build/ # Compiled Idris2 binary |
| 91 | +│ |
| 92 | +├── src/ # Stage 2: Rust WASM compiler (11 crates) |
| 93 | +│ ├── ephapax-syntax/ # AST definitions |
| 94 | +│ ├── ephapax-ir/ # S-expression IR |
| 95 | +│ ├── ephapax-lexer/ # Tokenizer (logos) |
| 96 | +│ ├── ephapax-parser/ # Parser (chumsky) |
| 97 | +│ ├── ephapax-typing/ # Type checker (Rust implementation) |
| 98 | +│ ├── ephapax-interp/ # Tree-walking interpreter |
| 99 | +│ ├── ephapax-wasm/ # WASM code generation |
| 100 | +│ ├── ephapax-runtime/ # Runtime support |
| 101 | +│ ├── ephapax-stdlib/ # Standard library |
| 102 | +│ ├── ephapax-repl/ # Interactive shell |
| 103 | +│ └── ephapax-cli/ # Command-line interface |
| 104 | +│ |
| 105 | +├── ephapax-linear/ # Linear mode specification & docs |
| 106 | +│ ├── docs/ # Linear semantics documentation |
| 107 | +│ ├── grammar/ # Linear mode grammar |
| 108 | +│ └── src/ # Linear-specific examples |
| 109 | +│ |
| 110 | +├── ephapax-proven/ # Coq-verified components |
| 111 | +│ └── (Subproject with formal proofs) |
| 112 | +│ |
| 113 | +├── formal/ # Coq formalization |
| 114 | +│ ├── Syntax.v # AST and types |
| 115 | +│ ├── Typing.v # Linear typing rules |
| 116 | +│ └── Semantics.v # Operational semantics & soundness |
| 117 | +│ |
| 118 | +├── examples/ # Example programs (affine & linear) |
| 119 | +├── conformance/ # Type system conformance tests |
| 120 | +│ ├── pass/ # Valid programs |
| 121 | +│ └── fail/ # Invalid programs (must be rejected) |
| 122 | +│ |
| 123 | +├── .machine_readable/ # SCM files (6 files) |
| 124 | +│ ├── STATE.scm |
| 125 | +│ ├── META.scm |
| 126 | +│ ├── ECOSYSTEM.scm |
| 127 | +│ ├── AGENTIC.scm |
| 128 | +│ ├── NEUROSYM.scm |
| 129 | +│ └── PLAYBOOK.scm |
| 130 | +│ |
| 131 | +└── .bot_directives/ # Bot instructions |
| 132 | +``` |
| 133 | + |
| 134 | +## COMPILATION PIPELINE |
| 135 | + |
| 136 | +### Current (Idris2 + Rust) |
| 137 | +``` |
| 138 | +input.eph |
| 139 | + → [Idris2: parse + typecheck in affine/linear mode] |
| 140 | + → IR (S-expression) |
| 141 | + → [Rust: WASM codegen] |
| 142 | + → output.wasm |
| 143 | +``` |
| 144 | + |
| 145 | +**Key commands:** |
| 146 | +- `just idris-build` - Build Idris2 stage |
| 147 | +- `just compile-affine input.eph affine output.wasm` - Full pipeline (affine) |
| 148 | +- `just smoke` - End-to-end test |
| 149 | +- `just build` - Build Rust stage only |
| 150 | + |
| 151 | +## SESSION STARTUP CHECKLIST |
| 152 | + |
| 153 | +✅ Read THIS file (0-AI-MANIFEST.a2ml) first |
| 154 | +✅ Understand **dyadic design** (affine vs. linear, both are first-class) |
| 155 | +✅ Understand canonical locations (.machine_readable/, not .machine_read/) |
| 156 | +✅ Know the invariants (no SCM duplication, etc.) |
| 157 | +✅ Check for MCP enforcement (if applicable) |
| 158 | +✅ Read `.machine_readable/STATE.scm` for current status |
| 159 | +✅ Read `.machine_readable/AGENTIC.scm` for interaction patterns |
| 160 | +✅ Check type checker completion status (currently 60%) |
| 161 | +✅ Check WASM codegen completion status (currently 30%) |
| 162 | + |
| 163 | +## LIFECYCLE HOOKS |
| 164 | + |
| 165 | +### on-enter (Session Start) |
| 166 | + |
| 167 | +When starting a new session: |
| 168 | + |
| 169 | +1. Read and acknowledge this manifest |
| 170 | +2. Log session start (optional but recommended) |
| 171 | + - Format: `[YYYY-MM-DD HH:MM:SS] Session started: [agent-name]` |
| 172 | + - Location: `.machine_readable/session-log.txt` |
| 173 | +3. Read `.machine_readable/STATE.scm` |
| 174 | +4. Check for blockers (type checker, WASM codegen) |
| 175 | +5. State understanding of canonical locations AND dyadic design |
| 176 | +6. Identify which mode (affine/linear) work applies to |
| 177 | + |
| 178 | +### on-exit (Session End) |
| 179 | + |
| 180 | +When ending a session: |
| 181 | + |
| 182 | +1. Update `.machine_readable/STATE.scm` if changes made |
| 183 | +2. Update completion percentages (type checker, WASM codegen) |
| 184 | +3. Log session end (optional but recommended) |
| 185 | + - Format: `[YYYY-MM-DD HH:MM:SS] Session ended: [summary]` |
| 186 | + - Location: `.machine_readable/session-log.txt` |
| 187 | +4. Document new blockers |
| 188 | +5. Summarize outcomes for BOTH modes if applicable |
| 189 | + |
| 190 | +## CRITICAL WORK IN PROGRESS |
| 191 | + |
| 192 | +**Type Checker (60% complete):** |
| 193 | +- ✅ Branch agreement verification |
| 194 | +- ✅ Borrow validity checking |
| 195 | +- ⚠️ Linear context threading (partial) |
| 196 | +- ❌ Region scope tracking (incomplete) |
| 197 | +- ❌ Affine mode support (planned) |
| 198 | + |
| 199 | +**WASM Codegen (30% complete):** |
| 200 | +- ⚠️ Primitives codegen (in progress) |
| 201 | +- ⚠️ Functions codegen (in progress) |
| 202 | +- ❌ Products/sums codegen (planned) |
| 203 | +- ❌ Regions codegen (planned) |
| 204 | +- ❌ Linear memory management (planned) |
| 205 | + |
| 206 | +**Target:** Make ephapax as complete as phronesis (working binary, full CLI, LSP, examples, docs) |
| 207 | + |
| 208 | +## ATTESTATION PROOF |
| 209 | + |
| 210 | +After reading this file, demonstrate understanding by stating: |
| 211 | + |
| 212 | +**"I have read the AI manifest. SCM files are located in `.machine_readable/` ONLY (not `.machine_read/`), bot directives in `.bot_directives/`, and I understand the dyadic design (affine vs. linear modes are both first-class). I will not create duplicate files in the root directory."** |
| 213 | + |
| 214 | +## META |
| 215 | + |
| 216 | +- **Format Version:** 1.0.0 |
| 217 | +- **Created:** 2026-02-07 |
| 218 | +- **Maintained By:** hyperpolymath |
| 219 | +- **License:** PMPL-1.0-or-later (was EUPL-1.2, updated) |
| 220 | +- **Protocol:** https://github.com/hyperpolymath/0-ai-gatekeeper-protocol |
| 221 | +- **Completion Status:** 40% overall (type checker 60%, WASM codegen 30%) |
0 commit comments