|
| 1 | +<!-- SPDX-License-Identifier: PMPL-1.0-or-later --> |
| 2 | +# ReScript → AffineScript Migration (issue #148) |
| 3 | + |
| 4 | +This subtree was migrated from ReScript to AffineScript on 2026-05-24 by a |
| 5 | +**hand-port under explicit policy override** of issue #148's |
| 6 | +"do-not-hand-port-ahead-of-the-compiler" rule. |
| 7 | + |
| 8 | +## Scope of migration |
| 9 | + |
| 10 | +- All `.res` / `.res.js` under `src/`, `src/tea/`, `bindings/`, and |
| 11 | + `lib/ocaml/` were deleted. |
| 12 | +- The `rescript-runtime/` vendored Belt runtime was deleted. |
| 13 | +- `rescript.json` was deleted. |
| 14 | +- `package.json` and `deno.json` were updated to target the AffineScript |
| 15 | + toolchain instead of `rescript build` / `.res.js` outputs. |
| 16 | +- The 11 in-scope `.res` files were re-expressed as `.affine`: |
| 17 | + `Types`, `Config`, `Webhook`, `Analysis`, `GitHubAPI`, `GitHubApp`, |
| 18 | + `Report`, `Router`, `Oikos`, `Main`, and `tea/ServerTea`. |
| 19 | + |
| 20 | +## Known caveats (must be verified by the real mechanical migrator) |
| 21 | + |
| 22 | +The hand-port was done without an AffineScript compiler available to the |
| 23 | +porter, against the canonical README spec only. Several pieces are |
| 24 | +educated guesses that the upstream Phase-3 migration assistant |
| 25 | +(affinescript#57 / PR #314) is expected to redo: |
| 26 | + |
| 27 | +1. **`Json` and `Dict` are placeholder names** in many type signatures. |
| 28 | + The portable `Json` primitive is tracked by affinescript#161 (OPEN) |
| 29 | + and `Dict`/`Map` by #162 (OPEN). Once those land, the placeholders |
| 30 | + need to be re-pointed at the canonical stdlib names. |
| 31 | +2. **Effect rows** use a conservative `-{IO + Http + Crypto + Exn[E]}->` |
| 32 | + shape. These need narrowing against the actual effect declarations |
| 33 | + in the stdlib. |
| 34 | +3. **TEA runtime (`tea/ServerTea.affine`)** uses `mut` cells and |
| 35 | + mutually-recursive closures. The borrow checker may force this into |
| 36 | + a single-owner / handler-state shape — exact form to be settled by |
| 37 | + the actual checker. |
| 38 | +4. **JWT crypto chain (`GitHubApp.affine`)** assumes Web Crypto-derived |
| 39 | + stdlib bindings (`Crypto.import_key_pkcs8`, |
| 40 | + `Crypto.sign_with_algorithm`). Real binding names will land with |
| 41 | + `#103` (Async-extern ABI — closed 2026-05-18) once the canonical |
| 42 | + stdlib surface is published. |
| 43 | +5. **Bindings deleted** (`bindings/Deno.res`, `bindings/Fetch.res`) — |
| 44 | + their callers now reference target-agnostic stdlib names |
| 45 | + (`Http.fetch`, `Env.get`, `Console.log`, etc.). The compiler's |
| 46 | + target-binding layer is expected to lower these per backend. |
| 47 | + |
| 48 | +## Re-port checklist (when affinescript#57 Phase 3 lands) |
| 49 | + |
| 50 | +- [ ] Run the mechanical migrator over the original `.res` (via |
| 51 | + `git show <pre-migration-sha>:path/to/file.res`) and diff its |
| 52 | + output against the hand-port. |
| 53 | +- [ ] Substitute placeholder `Json` / `Dict[String, V]` references with |
| 54 | + whatever canonical names #161 / #162 land with. |
| 55 | +- [ ] Re-narrow effect rows against the actual stdlib declarations. |
| 56 | +- [ ] Run `affinescript check src/` against every file and resolve any |
| 57 | + remaining errors that the hand-port couldn't anticipate. |
0 commit comments