| `CLAUDE.md` ("Commands"), with pnpm run through corepack (`corepack pnpm …`). |
| 6 |
| 7 | ## 1. Know what you are changing |
| 8 |
| 9 | | You touched | It is | What else must change in the same commit | |
| 10 | |---|---|---| |
| 11 | | `packages/core/src/sandbox`, `renderer`, `shared`, `host/validator*`, `allowlist`, `css-sanitizer`, `url-policy`, `profile.json` | the shared contract: one JS for every client | the rebuilt bundles with their `.qbc` (`pnpm build:ios`, `build:android`, `build:desktop`), a unit test; after `profile.json`, first `packages/core/scripts/profile-build.ts` | |
| 12 | | What a widget sees or may do, decided in glue: limits, timers, visibility, the order of ops / anim / queries, Intl, the SDK checks | parity glue, five copies: web worker, Node harness, Swift, Kotlin, C++ | the same change in every copy, or a line in the commit message saying why it is one platform only | |
| 13 | | `CpuBudget*`, `SdkPolicy*`, the `intl` capability | a policy checked against a fixture in `packages/core/tests/fixtures`: `cpu-budget.json`, `sdk-policy.json`, `intl-cases.json` | all four copies and the fixture together (`intl-cases.json` holds V8's answers: add the case to `packages/core/scripts/intl-cases.ts` and regenerate); `build:ios`, `build:android`, `build:desktop` copy the fixtures into the native tests | |
| 14 | | What a widget author sees: a profile feature, an SDK call, a limit, a default, who gets a press, a dev-tool flag | the authors' contract | `docs/widget-runtime-profile.md` (the guide and its agent block, which must stand alone: a bot's model sees nothing else; their out lists are generated: run `profile-build.ts` after `profile.json`), and `docs/changes.md` | |
| 15 | | The wire between the glue and the bundles (`docs/protocol.md`) in a way the previous release's glue cannot run with | the protocol | `protocol` in `VERSION.json`, then `pnpm build:ios`, `build:android`, `build:desktop` (they stamp the bundles and write the glue's `WidgetSandboxVersion` / `twidget/version.h`) | |
| 16 | | `packages/ios/Sources/CQuickJS/quickjs` (the submodule) or `packages/quickjs-wasm` | the engine | the bundles' `.qbc`, and `packages/quickjs-wasm/build.sh` (the pinned emscripten, `--docker` without it): `dist/` and `dist.sha256` together | |
| 17 | | Your renderer, pools, demo, build files | platform only | nothing else | |
| 18 |
| 19 | If you cannot do every copy yourself, push a branch and ask for the rest; do not push the |
| 20 | one-platform half to `main`. |
| 21 |
| 22 | ## 2. Put logic in the right place |
| 23 |
| 24 | - Logic that needs no platform data (option processing, defaults, ordering rules) goes into |
| 25 | the shim once, not into five copies of glue. Example: ECMA-402's date defaults live in |
| 26 | `packages/core/src/sandbox/globals.ts`, so every host, present and future, gets them. |
| 27 | - Locale data and native APIs stay in glue. |
| 28 | - A widget feature goes in or out only through `profile.json`; adding one is profile 2. |
| 29 |
| 30 | ## 3. Test what you changed |
| 31 |
| 32 | - Always: `pnpm typecheck`, `pnpm test:unit`. |
| 33 | - Shim, validator or renderer JS: `pnpm test:attacks` on both renderers |
| 34 | (`TW_RENDERER=shadow` too, 0 hits), the conformance run (`scripts/conformance/run-web.ts`, |
| 35 | then `packages/conformance/tools/report.mjs` for `packages/conformance/results`), |
| 36 | and the corpora the change can affect (`test:compat`, `test:showcase`, `test:defaults`, …). |
| 37 | - Glue: the tests of every platform you changed: `xcodebuild test` (macOS and iOS), Android |
| 38 | JVM and `connectedDebugAndroidTest`, desktop `twidget-tests` and `twidget-run --attacks`. |
| 39 | Code that never ran on its platform is not done. |
| 40 | - Not the frozen renderer prototypes (Blitz, the plain litehtml core; `docs/decisions.md`, "The renderer prototypes are |
| 41 | frozen"): a change is not checked on them, and "not checked on Blitz/litehtml" is no gap. |
| 42 | - A new behaviour gets a test that fails without the change. |
| 43 | - Cost: measure anything that runs per element or per query on a large DOM (500+ elements). |
| 44 | A widget has 300 ms of CPU per second and at most 500 ms in one task; a quadratic loop |
| 45 | over a few hundred nodes is a dead widget. |
| 46 |
| 47 | ## 4. Write it down |
| 48 |
| 49 | - One behaviour change per commit; the message says what changed and in which copies. |
| 50 | - `docs/changes.md`: a line under the next release's section; remove known issues you fixed. |
| 51 | - Test counts and commands in `CLAUDE.md` when you add tests or suites. |
| 52 |
| 53 | ## 5. Push |
| 54 |
| 55 | - Rebase on the latest `main`; rebuild the bundles if the rebase touched `packages/core`. |
| 56 | - If a release is being prepared, say so before pushing: the release is rebased on top of |
| 57 | you and re-tested. |
| 58 | - There is no CI in `main` yet (the GitHub Actions workflows wait on the branch `claude/ci`), so |
| 59 | §3 is the check. A failure on a timing-sensitive test (`docs/changes.md`, known issues) is |
| 60 | re-run once; a second failure is real. |
| 61 | - Never edit generated files by hand: `profile-tables.ts`, `docs/profile-v1.md`, the out lists |
| 62 | between the `profile:summary` and `profile:agent` markers of `docs/widget-runtime-profile.md`, the |
| 63 | bundles and `.qbc`, `packages/conformance/{catalogue,manifest,channel}.json`, |
| 64 | `packages/core/tests/fixtures/intl-cases.json` and the fixtures' copies in the native tests, |
| 65 | `WidgetSandboxVersion.swift` / `.kt` and `twidget/version.h` (from `VERSION.json`), |
| 66 | `packages/quickjs-wasm/dist` and `dist.sha256` (from `build.sh`). |
| 67 |
| 68 | ## 6. Cut a release |
| 69 |
| 70 | - One release commit: `VERSION.json`'s `version` (semver, the tag without its `v`) and, in the |
| 71 | same commit, the files that repeat it (`package.json`, `packages/core/package.json`, |
| 72 | `packages/android/widget-sandbox/build.gradle.kts`); `protocol`, `profile` and `sdk` only when |
| 73 | they changed (`profile` only with profile 2 in `packages/core/profile.json`; `sdk` with a new |
| 74 | SDK version, not an addition to SDK v1). Then `pnpm build:ios`, `build:android`, |
| 75 | `build:desktop`: the bundles carry the stamp and the glue the constants |
| 76 | (`packages/core/tests/unit/version.test.ts` names any file left behind, and every native glue |
| 77 | refuses bundles of another protocol, profile or sdk), the release notes in `docs/changes.md`, |
| 78 | `CLAUDE.md`'s status. |
| 79 | - §3's matrix green on the release commit (its results in the release notes), then the annotated |
| 80 | tag `v<version>` on it. |
| 81 |