|
| 1 | +// SPDX-License-Identifier: MPL-2.0 |
| 2 | += No Hand-Authored JavaScript (Source) Policy |
| 3 | +:revdate: 2026-06-02 |
| 4 | +:status: ACTIVE (warn-first rollout) |
| 5 | +:issue-254: hyperpolymath/standards#254 |
| 6 | + |
| 7 | +This document is the canonical estate-wide statement that estate-authored code |
| 8 | +MUST NOT contain hand-authored JavaScript or TypeScript *source*. It complements |
| 9 | +rather than replaces the existing machinery: |
| 10 | + |
| 11 | +* `docs/JS-RUNTIME-POLICY.adoc` — the JS *runtime & package-manager* hierarchy |
| 12 | + (Deno > Bun > pnpm > npm) and the lockfile / `node_modules` rules. |
| 13 | +* `.claude/CLAUDE.md` §JavaScript Exemptions / §TypeScript Exemptions — the |
| 14 | + human-readable mirror of the hypatia carve-outs. |
| 15 | +* hypatia `cicd_rules/javascript_detected`, `javascript_jsx_detected`, |
| 16 | + `typescript_detected` — the SINGLE SOURCE OF TRUTH for detection and the |
| 17 | + `path_allow_prefixes` carve-outs. This document does not override it. |
| 18 | + |
| 19 | +== The rule |
| 20 | + |
| 21 | +Estate-authored application logic is written in AffineScript (compiled to |
| 22 | +typed-wasm) or, for performance / systems / ABI / FFI work, in Rust + Zig |
| 23 | +compiled to WebAssembly with Idris2-proven ABIs. Hand-authored `.js`, `.jsx`, |
| 24 | +`.mjs`, `.cjs`, `.ts`, and `.tsx` source is therefore not an accepted |
| 25 | +destination for new estate code. |
| 26 | + |
| 27 | +This is a deliberate tightening of the earlier "JavaScript banned where |
| 28 | +AffineScript cannot reach" stance ({issue-254}): the target is *no* hand-authored |
| 29 | +JavaScript, not merely *no unnecessary* JavaScript. |
| 30 | + |
| 31 | +== What this does NOT cover (not "JavaScript source") |
| 32 | + |
| 33 | +The following are out of scope and MUST NOT be treated as violations: |
| 34 | + |
| 35 | +* *Generated / compiled output* — `*.res.js`, `*.res.mjs`, `lib/js/**`, |
| 36 | + `lib/es6/**`, `lib/bs/**`, `out/**`, `dist/**`, `.deno/**`, `generated/**`, |
| 37 | + `*.min.js`. Compiler output is not source. |
| 38 | +* *The build-time wasm host shim* — the generated wasm-bindgen-class glue that |
| 39 | + lets a wasm module reach the browser DOM/canvas. It is generated, not authored, |
| 40 | + and unavoidable in a browser host (wasm has no direct DOM access). "No |
| 41 | + JavaScript" means no hand-authored application JavaScript. |
| 42 | +* *Declaration headers* — `*.d.ts` (FFI / library type boundaries). |
| 43 | +* *Vendored / upstream* — `node_modules/**`, `deps/**`, and vendored forks. |
| 44 | +* *Documented carve-outs* — every `path_allow_prefixes` entry on the hypatia |
| 45 | + rules (MCP / plugin hosts, tooling configs, bootstrap shims, consumer-facing |
| 46 | + bindings, VSCode extension entry points, archived repos, etc.). hypatia is |
| 47 | + authoritative; the CLAUDE.md tables mirror it. |
| 48 | + |
| 49 | +== Enforcement (two deliberately distinct layers) |
| 50 | + |
| 51 | +[cols="1,3", options="header"] |
| 52 | +|=== |
| 53 | +| Layer | Behaviour |
| 54 | + |
| 55 | +| hypatia `cicd_rules/javascript_detected` (authoritative) |
| 56 | +| HARD-BLOCK for NEW `.js` / `.jsx` in non-carve-out paths, with an inline |
| 57 | + pragma escape (`// hypatia: allow cicd_rules/javascript_detected -- <reason>`). |
| 58 | + Existing files are grandfathered while the {issue-254} migration proceeds. |
| 59 | + |
| 60 | +| `no-js-scan.yml` (this rollout — WARN-FIRST) |
| 61 | +| NON-BLOCKING companion. On any push / PR touching JS or TS it reports the full |
| 62 | + count and list of hand-authored JS/TS to the run summary, so each repo's |
| 63 | + migration surface is visible. It never fails the build. It excludes only the |
| 64 | + generated / vendored / declaration files listed above. By owner decision a |
| 65 | + repo flips from warn to block once its surface reaches zero. |
| 66 | +|=== |
| 67 | + |
| 68 | +== Rollout status (2026-06-02) |
| 69 | + |
| 70 | +Warn-first `no-js-scan.yml` added to: `standards`, `burble`, `gossamer`. |
| 71 | +`gossamer` is already at zero hand-authored JS/TS. `paint-type` joins when write |
| 72 | +access is available — its `src/ui/app.js` is the increment-0 MVP UI, slated to |
| 73 | +move into Rust/wasm per that repo's ADR-0002. Other estate repos adopt via |
| 74 | +template propagation. |
0 commit comments