|
| 1 | +;; SPDX-License-Identifier: MIT OR AGPL-3.0-or-later |
| 2 | +;; SPDX-FileCopyrightText: 2024-2025 hyperpolymath |
| 3 | +;; |
| 4 | +;; LLM_SUPERINTENDENT.scm - AI/LLM Interaction Guidelines for AffineScript |
| 5 | +;; |
| 6 | +;; This file provides machine-readable guidance for AI assistants working |
| 7 | +;; on this repository. It defines constraints, priorities, and behavioral |
| 8 | +;; expectations aligned with the scope arrest directive. |
| 9 | + |
| 10 | +(define llm-superintendent |
| 11 | + '((schema . "hyperpolymath.llm-superintendent/1") |
| 12 | + (repo . "hyperpolymath/affinescript") |
| 13 | + (updated . "2026-01-01") |
| 14 | + |
| 15 | + ;; ========================================================================= |
| 16 | + ;; IDENTITY & SCOPE |
| 17 | + ;; ========================================================================= |
| 18 | + (identity |
| 19 | + . ((project . "AffineScript") |
| 20 | + (type . "programming-language-compiler") |
| 21 | + (current-phase . "f0-control-pass") |
| 22 | + (one-sentence . "OCaml/Dune compiler frontend for AffineScript, a language with affine types, dependent types, row polymorphism, and extensible effects targeting WASM."))) |
| 23 | + |
| 24 | + ;; ========================================================================= |
| 25 | + ;; SCOPE ARREST - WHAT THIS REPO IS AND IS NOT |
| 26 | + ;; ========================================================================= |
| 27 | + (scope |
| 28 | + . ((is |
| 29 | + . ("A programming language specification" |
| 30 | + "An OCaml/Dune compiler frontend (lexer, parser, type checker)" |
| 31 | + "A CLI tool with lex/parse/check/compile subcommands" |
| 32 | + "A conformance test suite" |
| 33 | + "Documentation for the language")) |
| 34 | + (is-not |
| 35 | + . ("A framework" |
| 36 | + "A standard library (stdlib is separate)" |
| 37 | + "A package registry" |
| 38 | + "An IDE or editor" |
| 39 | + "A build system (beyond the compiler itself)")))) |
| 40 | + |
| 41 | + ;; ========================================================================= |
| 42 | + ;; F0 CONTROL PASS - AUTHORITATIVE BEHAVIOR |
| 43 | + ;; ========================================================================= |
| 44 | + (f0-authority |
| 45 | + . ((primary-authority . "OCaml/Dune implementation behavior") |
| 46 | + (binding-artifacts |
| 47 | + . ("CLI exit codes and output format" |
| 48 | + "Diagnostic message structure" |
| 49 | + "Conformance test corpus" |
| 50 | + "Golden test outputs")) |
| 51 | + (non-binding-in-f0 |
| 52 | + . ("Type system implementation details (many TODOs)" |
| 53 | + "Borrow checker implementation (skeleton only)" |
| 54 | + "Code generation (not implemented)" |
| 55 | + "Runtime behavior (Rust runtime is quarantined)")))) |
| 56 | + |
| 57 | + ;; ========================================================================= |
| 58 | + ;; ALLOWED MODIFICATIONS |
| 59 | + ;; ========================================================================= |
| 60 | + (allowed-modifications |
| 61 | + . ((encouraged |
| 62 | + . ("Bug fixes to lexer/parser" |
| 63 | + "Completing TODO items in type checker" |
| 64 | + "Adding conformance tests" |
| 65 | + "Improving error messages" |
| 66 | + "Adding SPDX headers where missing" |
| 67 | + "Documentation improvements")) |
| 68 | + (permitted-with-justification |
| 69 | + . ("New CLI subcommands" |
| 70 | + "Parser grammar extensions" |
| 71 | + "Type system feature implementation")) |
| 72 | + (requires-explicit-approval |
| 73 | + . ("Changing the language semantics" |
| 74 | + "Adding new language keywords" |
| 75 | + "Changing diagnostic formats (breaks conformance)" |
| 76 | + "Modifying golden test expected outputs")) |
| 77 | + (forbidden |
| 78 | + . ("Adding a second authoritative implementation" |
| 79 | + "Moving semantic authority away from OCaml reference" |
| 80 | + "Introducing TypeScript as implementation language" |
| 81 | + "Network-required builds/tests" |
| 82 | + "Feature expansion not required for golden path" |
| 83 | + "Adding frameworks or unnecessary dependencies")))) |
| 84 | + |
| 85 | + ;; ========================================================================= |
| 86 | + ;; IMPLEMENTATION CONSTRAINTS |
| 87 | + ;; ========================================================================= |
| 88 | + (implementation |
| 89 | + . ((primary-language . "OCaml") |
| 90 | + (build-system . "Dune 3.14 + Menhir 3.0") |
| 91 | + (required-ocaml-version . ">= 5.1") |
| 92 | + (allowed-languages |
| 93 | + . (("OCaml" . "Compiler implementation") |
| 94 | + ("Scheme" . "Machine-readable control plane files") |
| 95 | + ("Just" . "Task runner glue"))) |
| 96 | + (quarantined |
| 97 | + . (("Rust" . "WASM runtime - not authoritative in f0"))) |
| 98 | + (forbidden |
| 99 | + . ("TypeScript" "Go" "Python (except SaltStack)")))) |
| 100 | + |
| 101 | + ;; ========================================================================= |
| 102 | + ;; GOLDEN PATH REQUIREMENTS |
| 103 | + ;; ========================================================================= |
| 104 | + (golden-path |
| 105 | + . ((commands |
| 106 | + . ("dune build" |
| 107 | + "dune runtest" |
| 108 | + "dune exec affinescript -- lex examples/hello.as" |
| 109 | + "dune exec affinescript -- parse examples/ownership.as")) |
| 110 | + (success-criteria |
| 111 | + . ("Build succeeds on clean machine with OCaml toolchain" |
| 112 | + "All tests pass" |
| 113 | + "CLI commands work on shipped examples" |
| 114 | + "Invalid programs produce deterministic diagnostics")) |
| 115 | + (exit-codes |
| 116 | + . ((success . 0) |
| 117 | + (parse-error . 1) |
| 118 | + (type-error . 2) |
| 119 | + (internal-error . 255))))) |
| 120 | + |
| 121 | + ;; ========================================================================= |
| 122 | + ;; CONFORMANCE REQUIREMENTS |
| 123 | + ;; ========================================================================= |
| 124 | + (conformance |
| 125 | + . ((directory . "conformance/") |
| 126 | + (structure |
| 127 | + . ((valid-programs . "conformance/valid/") |
| 128 | + (invalid-programs . "conformance/invalid/") |
| 129 | + (golden-outputs . "conformance/*.expected"))) |
| 130 | + (minimum-counts |
| 131 | + . ((valid-programs . 10) |
| 132 | + (invalid-programs . 10))) |
| 133 | + (test-requirements |
| 134 | + . ("Each program has .expected file with golden output" |
| 135 | + "Exit codes are deterministic" |
| 136 | + "Diagnostic messages match expected patterns")))) |
| 137 | + |
| 138 | + ;; ========================================================================= |
| 139 | + ;; LICENSING |
| 140 | + ;; ========================================================================= |
| 141 | + (licensing |
| 142 | + . ((spdx-identifier . "MIT OR AGPL-3.0-or-later") |
| 143 | + (canonical-file . "./LICENSE") |
| 144 | + (header-format |
| 145 | + . ";; SPDX-License-Identifier: MIT OR AGPL-3.0-or-later\n;; SPDX-FileCopyrightText: 2024-2025 hyperpolymath") |
| 146 | + (enforcement |
| 147 | + . ("All source files MUST have SPDX headers" |
| 148 | + "All license declarations MUST agree" |
| 149 | + "No contradictory license files")))) |
| 150 | + |
| 151 | + ;; ========================================================================= |
| 152 | + ;; BEHAVIORAL GUIDELINES FOR AI ASSISTANTS |
| 153 | + ;; ========================================================================= |
| 154 | + (llm-behavior |
| 155 | + . ((always |
| 156 | + . ("Read existing code before modifying" |
| 157 | + "Check conformance impact of changes" |
| 158 | + "Preserve existing behavior unless explicitly changing it" |
| 159 | + "Add tests for new functionality" |
| 160 | + "Use consistent code style with existing codebase" |
| 161 | + "Check for TODO comments and address them appropriately")) |
| 162 | + (never |
| 163 | + . ("Guess at language semantics" |
| 164 | + "Modify golden test outputs without justification" |
| 165 | + "Add dependencies not strictly necessary" |
| 166 | + "Introduce TypeScript or forbidden languages" |
| 167 | + "Over-engineer solutions" |
| 168 | + "Add features beyond what was requested")) |
| 169 | + (prefer |
| 170 | + . ("Minimal changes that achieve the goal" |
| 171 | + "Reusing existing patterns in the codebase" |
| 172 | + "Clear error messages over clever code" |
| 173 | + "Completing existing TODOs over new features")))) |
| 174 | + |
| 175 | + ;; ========================================================================= |
| 176 | + ;; KEY FILES |
| 177 | + ;; ========================================================================= |
| 178 | + (key-files |
| 179 | + . ((implementation |
| 180 | + . ("lib/lexer.ml" ;; Sedlex lexer |
| 181 | + "lib/parser.mly" ;; Menhir grammar |
| 182 | + "lib/parse_driver.ml" ;; Parser integration |
| 183 | + "lib/ast.ml" ;; AST definitions |
| 184 | + "lib/token.ml" ;; Token types |
| 185 | + "lib/span.ml" ;; Source locations |
| 186 | + "lib/error.ml" ;; Diagnostics |
| 187 | + "lib/typecheck.ml" ;; Type checker (WIP) |
| 188 | + "lib/unify.ml" ;; Type unification (WIP) |
| 189 | + "lib/borrow.ml" ;; Borrow checker (stub) |
| 190 | + "bin/main.ml")) ;; CLI |
| 191 | + (specification |
| 192 | + . ("affinescript-spec.md" ;; Language spec |
| 193 | + ".machine_read/SPEC.core.scm")) ;; Formal core |
| 194 | + (machine-readable |
| 195 | + . (".machine_read/LLM_SUPERINTENDENT.scm" |
| 196 | + ".machine_read/SPEC.core.scm" |
| 197 | + ".machine_read/ROADMAP.f0.scm")) |
| 198 | + (tests |
| 199 | + . ("test/test_lexer.ml" |
| 200 | + "test/test_parser.ml" |
| 201 | + "test/test_golden.ml" |
| 202 | + "conformance/")))) |
| 203 | + |
| 204 | + ;; ========================================================================= |
| 205 | + ;; FUTURE PHASES (NOT F0) |
| 206 | + ;; ========================================================================= |
| 207 | + (future-phases |
| 208 | + . ((f1 . "Complete type checker + borrow checker") |
| 209 | + (f2 . "WASM code generation") |
| 210 | + (f3 . "Standard library") |
| 211 | + (f4 . "Tooling (LSP, package manager)"))))) |
| 212 | + |
| 213 | +;; Export for machine consumption |
| 214 | +(define (get-superintendent) llm-superintendent) |
0 commit comments