Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9388442be | ||
|
|
4d200eca1d | ||
|
|
bb0492d294 | ||
|
|
cca9dc8330 | ||
|
|
b4777dad6d | ||
|
|
f4c628c757 | ||
|
|
839966a4f4 | ||
|
|
86975b87a7 | ||
|
|
de4c1ee1e1 | ||
|
|
ad117235b5 | ||
|
|
20a70420a8 | ||
|
|
ec141c1257 | ||
|
|
2fc6762395 | ||
|
|
664499c92e | ||
|
|
931e91527c | ||
|
|
04f23098e1 | ||
|
|
61b2e744df | ||
|
|
e17f244e0d | ||
|
|
62bb97428a | ||
|
|
f8bb92b51b | ||
|
|
277a7cb445 | ||
|
|
07e668dc48 | ||
|
|
4fc80fcbdc | ||
|
|
3b54a2a574 | ||
|
|
39167eb1a5 | ||
|
|
7ce4194707 | ||
|
|
dc0ff8f13e | ||
|
|
160c76c6d1 | ||
|
|
86fb47afd7 | ||
|
|
d550b829bd | ||
|
|
1a5ff424ce | ||
|
|
b72d5d7988 | ||
|
|
31d0fb6ca7 | ||
|
|
db02c6b9c9 | ||
|
|
21b6fb528d | ||
|
|
7083bce26a | ||
|
|
f915320914 | ||
|
|
7c8848ebb0 | ||
|
|
cf7bfd1c93 | ||
|
|
5e14737152 | ||
|
|
ca37b19cf8 | ||
|
|
d5465aebf2 | ||
|
|
d715c2e56b | ||
|
|
ad47d2347c | ||
|
|
684d703b0a | ||
|
|
40ab7bf32a | ||
|
|
7c55e86320 | ||
|
|
c0f9d917c1 | ||
|
|
a5d35321bd | ||
|
|
efe1773e9c | ||
|
|
c4556ab237 | ||
|
|
f075a58119 | ||
|
|
9d0f2fc212 | ||
|
|
e9e46972fb | ||
|
|
551f4c99c1 | ||
|
|
402c9e0748 | ||
|
|
474cc5fb01 | ||
|
|
e204f5a5d3 | ||
|
|
3cde99b259 | ||
|
|
51c6daa3bd | ||
|
|
135dc156e3 | ||
|
|
d79f975d0b | ||
|
|
b0de385777 | ||
|
|
c7b14a8666 | ||
|
|
9e61d0f127 | ||
|
|
06dd9993b6 | ||
|
|
143f713c79 | ||
|
|
5ffbf3ce4a | ||
|
|
34a12bc33f | ||
|
|
7afa184a99 | ||
|
|
a7c5ad5db1 | ||
|
|
6e6d1b4941 | ||
|
|
9bdd912933 | ||
|
|
4db50757c0 | ||
|
|
270489b887 | ||
|
|
a38cac81d8 | ||
|
|
3bc4fdf05b | ||
|
|
db3278f977 | ||
|
|
d94fbda344 | ||
|
|
b7dbbbaf6c | ||
|
|
178da6bc32 | ||
|
|
ddee418a8d | ||
|
|
2cb1a26f06 | ||
|
|
b277cc65e0 | ||
|
|
9f26656cb9 | ||
|
|
48cba7d93c | ||
|
|
71c6f82487 | ||
|
|
eaa6c4712f | ||
|
|
a6ac27e7fd | ||
|
|
1e87029261 | ||
|
|
672216d7e1 | ||
|
|
75472802bc | ||
|
|
afca73d368 | ||
|
|
d8a6dfd315 | ||
|
|
e9ae134c59 | ||
|
|
f0ebc628c6 | ||
|
|
6ae9662d8e | ||
|
|
8c628f1499 | ||
|
|
48ddb3d469 | ||
|
|
804cba4305 | ||
|
|
d7abd7f3bb | ||
|
|
57a299a785 | ||
|
|
74f7b43486 | ||
|
|
e25021af76 | ||
|
|
f0719072a1 | ||
|
|
9885a845c9 | ||
|
|
196c8ea0d6 | ||
|
|
c9063f03ea | ||
|
|
1add47b322 | ||
|
|
80991402dc | ||
|
|
1a6599437b | ||
|
|
184d8ef33b | ||
|
|
038560e580 | ||
|
|
21a3669cee | ||
|
|
b3b4b57794 | ||
|
|
6ae44b418a | ||
|
|
4a2f8b04bb | ||
|
|
8f9ab0845d | ||
|
|
baaeda305c | ||
|
|
7e01d33f0e | ||
|
|
9fd788b5a9 | ||
|
|
710fd0eeb3 | ||
|
|
e15f655ba4 | ||
|
|
59be6f7846 | ||
|
|
5304f3e9d4 | ||
|
|
85389b9883 | ||
|
|
db1507e986 | ||
|
|
96bfa67b3d | ||
|
|
5ff3a03ada | ||
|
|
23d45d914e | ||
|
|
bad1143b02 | ||
|
|
92d4a2e996 | ||
|
|
2fab18e289 | ||
|
|
1b16ed663f | ||
|
|
83ad26c3a3 | ||
|
|
fd51561b4e | ||
|
|
9e201941aa | ||
|
|
2ab188f1c0 | ||
|
|
9513e62e24 | ||
|
|
97db94c9bf | ||
|
|
5015d7cf9f | ||
|
|
df19f6cfe3 | ||
|
|
6bc6cb6be4 | ||
|
|
1e59b4c400 | ||
|
|
33f9705926 | ||
|
|
da6253b3dd | ||
|
|
ac1264e2ca | ||
|
|
2eb099fdc8 | ||
|
|
b28f9bf0a1 | ||
|
|
d0b8d6306b | ||
|
|
9666b87516 | ||
|
|
e3a9c2518d | ||
|
|
18918d1c4d | ||
|
|
8d24b5131f | ||
|
|
770946d026 | ||
|
|
8601797233 | ||
|
|
b73232bdd3 | ||
|
|
f131228a59 | ||
|
|
e321667b10 | ||
|
|
849bac8946 | ||
|
|
6fd088af9f | ||
|
|
b54bfc9312 | ||
|
|
e1378a1f4d | ||
|
|
5a84614809 | ||
|
|
63e6faef62 | ||
|
|
d37a9b09b8 | ||
|
|
560d4a4560 | ||
|
|
52e5a75a87 | ||
|
|
c196f422ed | ||
|
|
f0b57ca231 | ||
|
|
2db08457f2 | ||
|
|
083fa4ab24 | ||
|
|
35172010b1 | ||
|
|
57b1052679 | ||
|
|
1e355a2a34 | ||
|
|
44621c345f | ||
|
|
220e573b14 | ||
|
|
6befe42eb0 | ||
|
|
b30a9bc414 | ||
|
|
ac4780f451 | ||
|
|
3da7f9c5c3 | ||
|
|
c842c6f5b9 | ||
|
|
6676f9c83b | ||
|
|
65b005f1e4 | ||
|
|
752acbf654 | ||
|
|
f5fce74169 | ||
|
|
9c7622dac3 | ||
|
|
c14bcca103 | ||
|
|
1fa315ea93 | ||
|
|
f9730979c1 | ||
|
|
59d0c922e9 | ||
|
|
2ea51bd31f | ||
|
|
e5c82d79a0 | ||
|
|
9afef94a61 | ||
|
|
a7b0366cbe | ||
|
|
428d9f9f67 | ||
|
|
1b120f352f | ||
|
|
0a7c662d39 | ||
|
|
b91a000a17 | ||
|
|
8de0aa24d9 | ||
|
|
cad2c93616 | ||
|
|
78f462c4e1 | ||
|
|
3b72d17cbc | ||
|
|
d440442db6 | ||
|
|
67ef189d8b | ||
|
|
fbcae59ef5 | ||
|
|
9821bca1ce | ||
|
|
3d74474f6c | ||
|
|
f0e2975180 | ||
|
|
d43210050b | ||
|
|
ef051bdb87 | ||
|
|
0ca9fb3fb5 | ||
|
|
cbd55d6374 | ||
|
|
96906805f1 | ||
|
|
73b2e8fdd4 | ||
|
|
5da45337f7 | ||
|
|
f21d5e444e | ||
|
|
9a1472d955 | ||
|
|
2abe66800c | ||
|
|
0d38866dcf | ||
|
|
f993fa1c5f | ||
|
|
83d769f02d | ||
|
|
c8ad4b8135 | ||
|
|
bd18d8d6d1 | ||
|
|
659986ce38 | ||
|
|
062b4618c2 | ||
|
|
deb901d638 | ||
|
|
02f4ce5667 | ||
|
|
285cf5947b | ||
|
|
1a003e383a | ||
|
|
963ebf5bd7 | ||
|
|
ba9c9ae81d | ||
|
|
076e9048dc | ||
|
|
05eb051184 | ||
|
|
ddaa6afef5 | ||
|
|
6f69b4407f | ||
|
|
6dbffa022d | ||
|
|
5bb8c03664 | ||
|
|
886195ec1e | ||
|
|
288d8e3457 | ||
|
|
5208bdeb0d | ||
|
|
a6c9b41f90 | ||
|
|
70c423a5e4 | ||
|
|
89c320df0b | ||
|
|
7b2cf4374f | ||
|
|
49964e38c0 | ||
|
|
e70cdb478d | ||
|
|
be01b287b9 | ||
|
|
c2f8cb7ca1 | ||
|
|
89ee692bf0 | ||
|
|
a20923ce46 | ||
|
|
8101cd0449 | ||
|
|
30164cb1ba | ||
|
|
0640410726 | ||
|
|
2c7267ad43 | ||
|
|
daf8ee0b2f | ||
|
|
ed886fe181 | ||
|
|
4eaf5ef8bb | ||
|
|
0de9540739 | ||
|
|
31891a1a0c | ||
|
|
45d9aa90ba | ||
|
|
7a84f6cf10 | ||
|
|
f0fb406acf | ||
|
|
82406bce99 | ||
|
|
72d673a855 | ||
|
|
e2cd2383ce | ||
|
|
5661c6116c | ||
|
|
6d70e6d778 | ||
|
|
be1a836745 | ||
|
|
239ef1c54d | ||
|
|
61b51ae0e3 | ||
|
|
bfc69e4b4d | ||
|
|
af281c9fc4 | ||
|
|
bd422fd8d1 | ||
|
|
33a03c8a7b | ||
|
|
a17459e8a9 | ||
|
|
b2ee17d7c1 | ||
|
|
7963cc70f3 | ||
|
|
b792ed9f7b | ||
|
|
2e66b1fdfc | ||
|
|
8100062a78 | ||
|
|
a1762fdd74 | ||
|
|
388b43a27c | ||
|
|
23f0a1ae38 | ||
|
|
85b1734d4d | ||
|
|
3ffe84f968 | ||
|
|
220efad62b | ||
|
|
b98a0f0d22 | ||
|
|
95305c36fa | ||
|
|
48aa875c0e | ||
|
|
a8cd2ad2eb | ||
|
|
4a07c1ca9d | ||
|
|
cf5c9948c8 | ||
|
|
2288d416aa | ||
|
|
ddfe45c66e | ||
|
|
9547cf2463 | ||
|
|
1c7d059f55 | ||
|
|
6fa4576078 | ||
|
|
ae7b27de82 | ||
|
|
6b73b3defe | ||
|
|
7aad7911f6 | ||
|
|
6da92244cc | ||
|
|
c471145e96 | ||
|
|
64a991ad45 | ||
|
|
0ec4fbc4a3 | ||
|
|
ea50b695a7 | ||
|
|
331c6dce7f | ||
|
|
4f5834ba72 | ||
|
|
aa16c180e5 | ||
|
|
470d4eb993 | ||
|
|
99d91ddaa4 | ||
|
|
ab3b55e29a | ||
|
|
e4abc31f1e | ||
|
|
b7d1981b57 | ||
|
|
64a3cd6d7d | ||
|
|
48e2c27f2f | ||
|
|
8b2ea5721a | ||
|
|
df2f1273e9 | ||
|
|
f9e8236899 | ||
|
|
8f341f20c9 | ||
|
|
808d685355 | ||
|
|
80720ad592 | ||
|
|
a483337a02 | ||
|
|
1ffba7093a | ||
|
|
3da315e7b5 | ||
|
|
a2ca89aa10 | ||
|
|
990bb0b689 | ||
|
|
7251f1a1f1 | ||
|
|
30e471530b | ||
|
|
de592a00e8 | ||
|
|
2a04db134c | ||
|
|
37d3667de4 | ||
|
|
9697b765e5 | ||
|
|
9d9a872bcc | ||
|
|
9235c83eb7 | ||
|
|
e0c85a20ef | ||
|
|
3c5bdb84a9 | ||
|
|
70de6e1786 | ||
|
|
47dfc65265 | ||
|
|
41ebf22eea | ||
|
|
3d429662c9 | ||
|
|
7b38fb5c6b | ||
|
|
7537adc30f | ||
|
|
94696b0f54 | ||
|
|
fff6a5b028 | ||
|
|
da6e1a9678 | ||
|
|
8eca20005b | ||
|
|
2fa1fec8d8 | ||
|
|
9bd2a4c688 | ||
|
|
4fb03aff0b | ||
|
|
d7950ac153 | ||
|
|
36caf34c68 | ||
|
|
90e3778660 | ||
|
|
94331c58ec | ||
|
|
c30a6d9b99 | ||
|
|
37ae1abbe9 | ||
|
|
82b76e2138 | ||
|
|
8a16cadbaf | ||
|
|
2b1d4fecb8 | ||
|
|
cec1bb9de3 | ||
|
|
25ec0b9d13 | ||
|
|
966cc05a90 | ||
|
|
1cbd88aba0 | ||
|
|
553867262c | ||
|
|
11639bf439 | ||
|
|
a261a6440a | ||
|
|
6f04a5cffb | ||
|
|
30c9622806 | ||
|
|
69dfb7f09a | ||
|
|
e60821f0e0 | ||
|
|
64bf016191 | ||
|
|
5192f777fe | ||
|
|
283c7ac4ba | ||
|
|
78eb3ecae9 | ||
|
|
d3037064e6 | ||
|
|
0ad91b6e7f | ||
|
|
ca72e381c6 | ||
|
|
491219bf1f | ||
|
|
e5c7547067 | ||
|
|
bfc31507f8 | ||
|
|
03adf215ce | ||
|
|
916cff733c | ||
|
|
a041981276 | ||
|
|
964cc27901 | ||
|
|
acf761b2f5 | ||
|
|
ab8182cb4e | ||
|
|
ef4ec2ad4b | ||
|
|
61514c1294 | ||
|
|
894d6d68f5 | ||
|
|
fccec9f097 | ||
|
|
50a3d6b872 | ||
|
|
e259dd23c7 | ||
|
|
df78cda8bf | ||
|
|
605c2bb734 | ||
|
|
cb11a71d63 | ||
|
|
41124c7260 | ||
|
|
b0b275227b | ||
|
|
cb293fe790 | ||
|
|
1d694dcbd8 | ||
|
|
32407df9c5 | ||
|
|
162e774294 | ||
|
|
063ed7120a | ||
|
|
34b15a9ace | ||
|
|
fbecb7365e | ||
|
|
4029b858ea | ||
|
|
5b2577f6a9 | ||
|
|
bc142f84a2 | ||
|
|
e4829603ff | ||
|
|
1d77cec991 | ||
|
|
4ba4871af7 | ||
|
|
edc503a7a8 | ||
|
|
323dc321a2 | ||
|
|
6154b46cb8 | ||
|
|
abc409c2d4 | ||
|
|
1877237c7a | ||
|
|
e0513d2983 | ||
|
|
9dd425b223 | ||
|
|
50871eb5de | ||
|
|
4b71a2ae2f | ||
|
|
197d348711 | ||
|
|
5c9358acaa | ||
|
|
cbe8052020 | ||
|
|
69a18ce912 | ||
|
|
f0c6ba9946 | ||
|
|
90f3913a81 | ||
|
|
2652fee49b | ||
|
|
2f466ffc9c | ||
|
|
9146ed2f49 | ||
|
|
f0f16e4f6e | ||
|
|
00da6b57a4 | ||
|
|
6ab2f16809 | ||
|
|
6efcf3e10c | ||
|
|
748203ea19 | ||
|
|
b125b76351 | ||
|
|
758decaa56 | ||
|
|
2d9066e089 | ||
|
|
35a684000d | ||
|
|
9e3e9bb4f0 | ||
|
|
a8e05cbb92 | ||
|
|
e6987965f6 | ||
|
|
fc28abf24b | ||
|
|
85a8986870 | ||
|
|
faea70aeba | ||
|
|
d19039aeef | ||
|
|
49c0d96edf | ||
|
|
3137c2b162 | ||
|
|
c3e8fb67d7 | ||
|
|
72b960fa39 | ||
|
|
08e4932f04 | ||
|
|
1b4830ff06 | ||
|
|
694f8d1c6e | ||
|
|
1b61ce1112 | ||
|
|
60af905e70 | ||
|
|
8650f05f95 | ||
|
|
8fe8f9a9c1 | ||
|
|
936593c258 | ||
|
|
2919147c80 | ||
|
|
1ba3d01bc6 | ||
|
|
5fcdefd057 | ||
|
|
38a6e3ce65 | ||
|
|
f2d2fb2f24 | ||
|
|
8829e2f9b9 | ||
|
|
2deea7abb0 | ||
|
|
b64ae880e0 | ||
|
|
887dd6e455 | ||
|
|
f1a68ac9b0 | ||
|
|
55dd01612e | ||
|
|
3c50a64885 | ||
|
|
9ccfd9dfef | ||
|
|
4f584da0f8 | ||
|
|
362f127922 | ||
|
|
9cf9fc9c5c | ||
|
|
e00781a661 | ||
|
|
d25b15737a | ||
|
|
b0c4992c79 | ||
|
|
dd5ea32488 | ||
|
|
c13a021e43 | ||
|
|
476d69cd1d | ||
|
|
a148e08197 | ||
|
|
831eb66fee | ||
|
|
1153afb4fb | ||
|
|
a2ffb122e2 | ||
|
|
3957a95818 | ||
|
|
6a3df51707 | ||
|
|
6afbed3c36 | ||
|
|
eea3ea4c6f | ||
|
|
10bca3f44e | ||
|
|
e77f42c111 | ||
|
|
6e3b73884b | ||
|
|
5ba6ef7f84 | ||
|
|
80ead5f3a7 | ||
|
|
32af2f0024 | ||
|
|
f0121f31d0 | ||
|
|
0e19c103ef | ||
|
|
32843c2551 | ||
|
|
da11342e03 | ||
|
|
180620e436 | ||
|
|
96398e3775 | ||
|
|
d2d40b6c1a | ||
|
|
724887717f | ||
|
|
bdf99c17bf | ||
|
|
108e01746c | ||
|
|
200fa826b0 | ||
|
|
f4c394323d | ||
|
|
2b06c08a4b | ||
|
|
a78f245dff | ||
|
|
23ea08daf2 | ||
|
|
b4680cbfd0 | ||
|
|
d60f6e971f | ||
|
|
89c5a192f4 | ||
|
|
23b5502217 | ||
|
|
a17cbc3b40 | ||
|
|
5719e8ac40 |
No files matched your search
@@ -13,26 +13,25 @@ Use this skill for the web client. For iOS Simulator, Android Emulator, or physi
|
||||
2. Choose a base directory that belongs only to the current worktree or test:
|
||||
- Use the repository's ignored `.t3` directory for reusable worktree-local state.
|
||||
- Use `mktemp -d /tmp/t3code-test.XXXXXX` for disposable state and retain the printed absolute path.
|
||||
3. Start the full web stack with `vp run dev --home-dir <base-dir>`. Add `--share`
|
||||
to also publish it on the tailnet so the user can open it from another device
|
||||
(see "Share a dev server with the user" below).
|
||||
3. Start the full web stack with `vp run dev`. Add `--share` when the user needs to open it from another tailnet device. In a linked worktree it defaults to that worktree's gitignored `.t3`; pass `--home-dir <base-dir>` only when the test needs a different isolated directory.
|
||||
4. Keep the terminal session alive and read the selected server port, web port, base directory, and pairing URL from its output.
|
||||
|
||||
Ports are derived from the worktree path, so a worktree prefers the same pair on
|
||||
every run rather than racing others for the default. That is a preference, not a
|
||||
guarantee — the runner shifts both ports when either is already taken. Read the
|
||||
actual values from the dev-runner line rather than assuming `5733`/`13773`, and
|
||||
re-read them after a restart; `node scripts/dev-runner.ts dev --dry-run` prints
|
||||
them without starting anything.
|
||||
|
||||
Inside a worktree, the dev runner defaults to that worktree's own gitignored `.t3` rather than the shared `~/.t3` — including when `T3CODE_HOME` is exported in the environment, which would otherwise resolve to `~/.t3/userdata`: the live database the user's installed T3 Code is running against. Do not override that default to the shared home.
|
||||
|
||||
A fresh isolated database is empty, which is fine for flows you drive yourself but useless for anything that renders a list of existing work. To populate it, stop the dev server and run `bun run dev:seed` (`--threads N` to change the count), then restart. It copies recent projects and threads from the shared home read-only and refuses to write to it. Prefer this over hand-writing fixtures when you just need the UI to look real; use `references/sqlite-fixtures.md` when a test needs specific, controlled rows.
|
||||
|
||||
Treat a base directory as disposable only when it was created or deliberately selected for the current test. Never delete or directly seed the shared `~/.t3` directory. Prefer starting with a new temporary base directory over clearing state of uncertain ownership.
|
||||
|
||||
The worktree-local default deliberately outranks an ambient `T3CODE_HOME`; do not pass the shared home through to a worktree dev server.
|
||||
|
||||
Ports are derived from the worktree path but can shift when occupied. Always read the actual values from the `[dev-runner]` line.
|
||||
|
||||
Shared browser dev is single-origin: Vite proxies the backend paths, so never set `VITE_HTTP_URL` or `VITE_WS_URL` for `dev`/`dev:web`.
|
||||
|
||||
The dev runner disables browser auto-open by default. Do not pass `--browser` during automated testing: an automatically opened page can consume the one-time bootstrap token before the controlled browser uses it.
|
||||
|
||||
### Verify a shared environment before human handoff
|
||||
|
||||
When another person will use the printed pairing URL, first open the shared origin without the pairing path or fragment in the controlled browser and confirm the T3 Code app loads. This browser navigation is required even when curl succeeds because browsers block some otherwise reachable ports before making a network request.
|
||||
|
||||
Do not open the other person's complete pairing URL during this reachability check; doing so consumes its one-time token. If the agent also needs an authenticated browser, create and consume a separate pairing token, then leave a fresh token for the other person.
|
||||
|
||||
## Preserve the environment while iterating
|
||||
|
||||
Treat the overall testing or implementation loop—not an assistant turn or one verification pass—as the environment lifecycle boundary.
|
||||
@@ -41,7 +40,7 @@ Treat the overall testing or implementation loop—not an assistant turn or one
|
||||
- Do not stop the server merely because one verification pass completed or because you are yielding a response to the user.
|
||||
- Before starting another environment, check whether the existing process and browser tab still serve the task. Reuse them when healthy instead of discarding useful state.
|
||||
- On a later turn, verify that the existing process is alive and reuse its printed ports and base directory. If it exited, restart with the same base directory; create a new pairing token only when the browser session is no longer valid.
|
||||
- Tell the user when a test environment remains available, including its non-secret web URL when useful. Never include a pairing token.
|
||||
- Tell the user when a test environment remains available, including its non-secret web URL when useful. Include a pairing token only when the user still needs to pair (see below).
|
||||
|
||||
## Authenticate the browser on the first navigation
|
||||
|
||||
@@ -51,63 +50,13 @@ Treat the overall testing or implementation loop—not an assistant turn or one
|
||||
4. Wait for the pairing exchange and redirect to finish before navigating elsewhere.
|
||||
5. Continue in the same browser context so its stored bearer session remains available.
|
||||
|
||||
Treat pairing URLs as secrets: they grant access to the environment. Never put one anywhere it outlives the moment — screenshots, committed files, durable logs, or a PR description.
|
||||
|
||||
The one exception is handing access to the user who asked for it: when they want to open the app themselves (see "Share a dev server with the user"), the URL is the deliverable, so give it to them directly in the response. Do not volunteer one otherwise. A pairing token is short-lived and single-use; opening the URL in another browser or opening it twice can consume it.
|
||||
Keep pairing URLs out of screenshots, committed files, and durable logs. When the user asked for a shared environment, the deliverable IS the full pairing URL — paste it in your reply, token and all; a bare origin is useless to them. A pairing token is short-lived and single-use; opening the URL in another browser or opening it twice can consume it, so never open a URL you handed to the user.
|
||||
|
||||
## Recover a consumed or expired pairing token
|
||||
|
||||
Ask the running server for a fresh pairing URL:
|
||||
Run `node apps/server/src/bin.ts pair` from the repository root. It discovers the running dev server (worktree `.t3` first, same precedence as the dev runner) and prints a fresh `Pair URL` against the server's current web origin, including a `--share` tailnet origin. Pass `--base-dir <base-dir>` only when the server was started with `--home-dir`, using the identical path.
|
||||
|
||||
```bash
|
||||
bun run dev:pair # implicit ~/.t3 home
|
||||
bun run dev:pair -- --base-dir <base-dir> # explicit --home-dir environment
|
||||
```
|
||||
|
||||
It finds the running server's own `server-runtime.json` under the base directory
|
||||
— checking both the `dev` and `userdata` state directories and verifying the
|
||||
recorded process is alive — so it needs no port and builds the URL against the
|
||||
web origin already in use, including a `--share` tailnet URL. Pass `--base-dir`
|
||||
only when the dev server was started with `--home-dir`. Add `--ttl 1h` for a
|
||||
longer window or `--json` for machine-readable output.
|
||||
|
||||
Use the printed `Pair URL` once. If the command reports no running server, the
|
||||
dev process has exited — restart it and use the URL from its own startup log.
|
||||
|
||||
Use `auth pairing list` to inspect active token metadata; it intentionally cannot
|
||||
reveal token secrets. `auth pairing create` remains available for scripted cases
|
||||
that need explicit control over every flag.
|
||||
|
||||
## Share a dev server with the user
|
||||
|
||||
When the user wants to try the change themselves — from their laptop, their
|
||||
phone, or anything else on their tailnet — start the stack with `--share`:
|
||||
|
||||
```bash
|
||||
bun run dev:share # or: vp run dev --share --home-dir <base-dir>
|
||||
```
|
||||
|
||||
This publishes the web port over HTTPS on the machine's tailnet and prints
|
||||
`[dev-runner] shared on tailnet: https://<host>:<port>/`. The pairing URL logged
|
||||
right after is already built against that origin, so give the user that URL
|
||||
verbatim — it is the deliverable, and it works unchanged on any of their devices.
|
||||
This is the one case where a pairing URL belongs in a response: it is going to
|
||||
the person who asked for it. It still must not go anywhere durable.
|
||||
|
||||
Dev is single-origin: Vite proxies `/api`, `/ws`, `/oauth`, and `/.well-known` to
|
||||
the backend, so one shared port covers the whole app. Do not map backend paths by
|
||||
hand, and do not set `VITE_HTTP_URL`/`VITE_WS_URL` for a shared server — absolute
|
||||
localhost URLs get compiled into the bundle and send the remote browser to its
|
||||
own machine.
|
||||
|
||||
The mapping is removed when the dev server exits, and re-running `--share`
|
||||
replaces any mapping left behind by a run that was killed. If the tailnet is
|
||||
unavailable the dev server still starts and serves locally; the warning explains
|
||||
what to fix.
|
||||
|
||||
Expect one failed `ws://localhost:<port>` HMR attempt in the remote console
|
||||
before Vite falls back to the page origin. That is Vite's own hot-reload socket,
|
||||
not the app's connection — ignore it.
|
||||
Tokens from `pair` carry standard client scopes. The startup pairing URL carries admin scopes; if the user needs Settings → Connections management (`access:write`), restart the server and hand over the new startup URL instead.
|
||||
|
||||
## Inspect or seed SQLite state
|
||||
|
||||
@@ -135,9 +84,7 @@ If completion is uncertain, keep the environment alive and mention that it is re
|
||||
## Troubleshoot predictably
|
||||
|
||||
- If the browser shows an unauthenticated pairing screen, issue a new token instead of retrying the consumed URL.
|
||||
- If the pairing URL is no longer visible, run `bun run dev:pair`.
|
||||
- If the replacement token is rejected, verify that the CLI and server resolve the same state directory — pass `--base-dir` only when the server was started with `--home-dir`, and use the same path.
|
||||
- If the pairing URL is no longer visible, create a replacement token with both `--dev-url` and `--base-url`.
|
||||
- If the replacement token is rejected, verify that the CLI and server use the identical absolute base directory and web URL.
|
||||
- If the UI shows unexpected data, verify that every command uses the identical explicit base directory before editing anything.
|
||||
- If ports move because another instance is running, trust the current dev-runner output rather than assuming ports `13773` and `5733`.
|
||||
- If a remote browser reaches the page but the app cannot connect, check that the served bundle has no absolute `localhost` backend URL baked in: `VITE_HTTP_URL` and `VITE_WS_URL` must be unset for `dev`/`dev:web`.
|
||||
- If a shared URL returns 403 with "host is not allowed", the hostname is outside `*.ts.net`; add it to `T3CODE_DEV_ALLOWED_HOSTS` (comma-separated).
|
||||
@@ -66,7 +66,7 @@ Use these client origins:
|
||||
- Android Emulator: `http://10.0.2.2:<server-port>`
|
||||
- Physical device: bind the backend to `0.0.0.0` and use the host's reachable LAN origin
|
||||
|
||||
Always enter the complete `http://` origin; the mobile host field otherwise assumes HTTPS. When testing web and mobile together, run `vp run dev --home-dir <base-dir> --host 127.0.0.1` instead and do not launch a second backend over the same base directory.
|
||||
Enter the complete `http://` origin to make the test transport explicit. Bare IP addresses default to HTTP, while bare hostnames default to HTTPS. When testing web and mobile together, run `vp run dev --home-dir <base-dir> --host 127.0.0.1` instead and do not launch a second backend over the same base directory.
|
||||
|
||||
## Start or reuse Metro safely
|
||||
|
||||
@@ -125,31 +125,29 @@ Do not start, stop, erase, or reconfigure an emulator owned by another task. Tra
|
||||
|
||||
## Pair each client once
|
||||
|
||||
Issue a fresh credential against the running backend's exact base directory:
|
||||
Use the bundled helper from the repository root. It issues a fresh credential against the running backend's exact base directory, opens the existing Add Environment route with the credential in an encoded query parameter, and asks that route to connect once:
|
||||
|
||||
```bash
|
||||
T3CODE_PORT=<server-port> node apps/server/src/bin.ts auth pairing create \
|
||||
--base-dir <base-dir> \
|
||||
--base-url <mobile-origin> \
|
||||
--ttl 15m \
|
||||
--label agent-mobile-<short-device-id>
|
||||
.agents/skills/test-t3-mobile/scripts/pair-client.sh \
|
||||
ios <simulator-udid> <server-port> <base-dir>
|
||||
|
||||
.agents/skills/test-t3-mobile/scripts/pair-client.sh \
|
||||
android <emulator-serial> <server-port> <base-dir>
|
||||
```
|
||||
|
||||
In PowerShell, set `$env:T3CODE_PORT = "<server-port>"` first and run the `node ... auth pairing create` command without the leading assignment.
|
||||
Run only the command for the selected platform. The helper uses `http://127.0.0.1:<server-port>` for iOS and `http://10.0.2.2:<server-port>` for Android. Pass a fifth argument only when testing a non-development URL scheme.
|
||||
|
||||
If the visible Add Environment action is not exposed as a semantic target, open the app's registered route instead of guessing coordinates:
|
||||
The helper opens this registered route:
|
||||
|
||||
```bash
|
||||
xcrun simctl openurl <simulator-udid> 't3code-dev://connections/new'
|
||||
adb -s <emulator-serial> shell am start -W \
|
||||
-a android.intent.action.VIEW \
|
||||
-d 't3code-dev://connections/new' \
|
||||
com.t3tools.t3code.dev
|
||||
```text
|
||||
t3code-dev://connections/new?pairingUrl=<encoded-pairing-url>&autoConnect=1
|
||||
```
|
||||
|
||||
Run only the command for the selected platform.
|
||||
The Add Environment route owns the behavior: `pairingUrl` prefills its normal host and token inputs, while `autoConnect=1` submits once in development builds and returns to Home after success. Without `autoConnect`, the same route only prefills the form for manual inspection.
|
||||
|
||||
In T3 Code Dev, open Add Environment and enter the complete `<mobile-origin>` and newly printed `Token`. Verify the expected seeded projects appear before exercising the affected flow.
|
||||
Do not enter pairing hosts or tokens through simulator keyboard automation. Xcode's semantic typer sends HID-style key events through the simulator's active keyboard state, which can corrupt uppercase tokens and punctuation even when the host Mac uses a U.S. input source. The one-shot route is the deterministic pairing path. Use the visible form only as a fallback, and paste credentials rather than typing them character by character.
|
||||
|
||||
Verify the expected seeded projects appear before exercising the affected flow.
|
||||
|
||||
Pairing credentials are secret, short-lived, and single-use. Create a different credential for every simulator, emulator, physical device, or browser. If an attempt fails, issue a new credential rather than retrying the old one. Do not expose tokens in screenshots, commits, or final responses.
|
||||
|
||||
@@ -183,6 +181,8 @@ Keep local verification focused. Do not turn this workflow into a full repositor
|
||||
- **Old UI or an old error appears:** verify Metro's worktree, variant, URL, and port before diagnosing the app.
|
||||
- **The environment remains empty:** verify the platform-specific HTTP origin, use a fresh token, and confirm project seeding used the identical base directory.
|
||||
- **A second client cannot pair:** pairing tokens are single-use; issue another token.
|
||||
- **The pairing form opens but does not connect:** confirm the deep link uses the existing `connections/new` route, includes `autoConnect=1`, and carries a freshly minted encoded `pairingUrl`.
|
||||
- **Pairing text changes case or punctuation:** do not retry semantic typing. Use `scripts/pair-client.sh`; the simulator keyboard layout and HID input path are not reliable for credentials.
|
||||
- **iOS semantic actions fail:** set explicit XcodeBuildMCP defaults and refresh with `snapshot_ui`.
|
||||
- **Android cannot reach Metro:** verify `adb reverse` for the exact Metro port and relaunch the development-client URL.
|
||||
- **Android cannot reach the backend:** use `10.0.2.2`, not `127.0.0.1`, for the Android Emulator.
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <ios|android> <device-id> <server-port> <base-dir> [url-scheme]" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
[[ $# -ge 4 && $# -le 5 ]] || usage
|
||||
|
||||
platform="$1"
|
||||
device_id="$2"
|
||||
server_port="$3"
|
||||
base_dir="$4"
|
||||
url_scheme="${5:-t3code-dev}"
|
||||
|
||||
case "$platform" in
|
||||
ios)
|
||||
mobile_origin="http://127.0.0.1:${server_port}"
|
||||
;;
|
||||
android)
|
||||
mobile_origin="http://10.0.2.2:${server_port}"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
repo_root="$(git rev-parse --show-toplevel)"
|
||||
cd "$repo_root"
|
||||
|
||||
if ! pairing_output="$({
|
||||
T3CODE_PORT="$server_port" node apps/server/src/bin.ts auth pairing create \
|
||||
--base-dir "$base_dir" \
|
||||
--base-url "$mobile_origin" \
|
||||
--ttl 15m \
|
||||
--label "agent-mobile-${device_id:0:8}"
|
||||
} 2>&1)"; then
|
||||
echo "Could not mint a mobile pairing credential." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pairing_url="$(printf '%s\n' "$pairing_output" | sed -n 's/^Pair URL: //p' | tail -n 1)"
|
||||
if [[ -z "$pairing_url" ]]; then
|
||||
echo "Could not parse the mobile pairing URL." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
deep_link="$(PAIRING_URL="$pairing_url" URL_SCHEME="$url_scheme" node - <<'NODE'
|
||||
const query = new URLSearchParams({
|
||||
pairingUrl: process.env.PAIRING_URL,
|
||||
autoConnect: "1",
|
||||
});
|
||||
process.stdout.write(`${process.env.URL_SCHEME}://connections/new?${query}`);
|
||||
NODE
|
||||
)"
|
||||
|
||||
case "$platform" in
|
||||
ios)
|
||||
xcrun simctl openurl "$device_id" "$deep_link"
|
||||
;;
|
||||
android)
|
||||
# adb shell re-joins its arguments and evaluates them through the device
|
||||
# shell, so the deep link's `?`/`&` must be quoted once more for that shell.
|
||||
adb -s "$device_id" shell \
|
||||
"am start -W -a android.intent.action.VIEW -d '$deep_link' com.t3tools.t3code.dev" \
|
||||
>/dev/null
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Opened the existing Add Environment route with a fresh pairing credential."
|
||||
@@ -1,12 +1,14 @@
|
||||
# Optional: T3 Connect source builds
|
||||
# Leave these unset to disable optional T3 Connect features in local source builds.
|
||||
# Release builds inject their public values at build time. Do not add server-side
|
||||
# secrets to this file.
|
||||
# `cp .env.example .env` enables T3 Connect against the production deployment.
|
||||
# These are the same public identifiers baked into official release builds, not
|
||||
# secrets. Remove or comment them out to build with cloud features disabled.
|
||||
# Do not add server-side secrets to this file.
|
||||
|
||||
# Get these from the Clerk Dashboard under API keys, JWT templates, and OAuth applications.
|
||||
# T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_...
|
||||
# T3CODE_CLERK_JWT_TEMPLATE=t3-relay
|
||||
# T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=oauthapp_...
|
||||
# Production Clerk instance. To use your own, get these from the Clerk Dashboard
|
||||
# under API keys, JWT templates, and OAuth applications.
|
||||
T3CODE_CLERK_PUBLISHABLE_KEY=pk_live_Y2xlcmsudDMuY29kZXMk
|
||||
T3CODE_CLERK_JWT_TEMPLATE=t3-relay
|
||||
T3CODE_CLERK_CLI_OAUTH_CLIENT_ID=hzxSgY2cH10sDU2r
|
||||
|
||||
# Optional: signed macOS passkey builds. The RP domain defaults to the Frontend API
|
||||
# hostname encoded in T3CODE_CLERK_PUBLISHABLE_KEY. Set the override only when Clerk
|
||||
@@ -15,8 +17,9 @@
|
||||
# T3CODE_MACOS_PROVISIONING_PROFILE=/absolute/path/to/t3code.provisionprofile
|
||||
# T3CODE_CLERK_PASSKEY_RP_DOMAINS=example.clerk.accounts.dev,clerk.example.com
|
||||
|
||||
# Get this from your relay deployment. `infra/relay` deploys update it automatically.
|
||||
# T3CODE_RELAY_URL=https://relay.example.com
|
||||
# Production relay. For a self-hosted relay, `infra/relay` deploys update it
|
||||
# automatically.
|
||||
T3CODE_RELAY_URL=https://relay.t3.codes
|
||||
|
||||
# Optional: hosted app origin used by the CLI's out-of-band OAuth flow.
|
||||
# Defaults to https://app.t3.codes; override to test against a staging deployment.
|
||||
|
||||
@@ -9,6 +9,7 @@ body:
|
||||
attributes:
|
||||
value: |
|
||||
Use this form for broken behavior, regressions, crashes, or reliability problems.
|
||||
Feature requests belong in [Discussions](https://github.com/pingdotgg/t3code/discussions/categories/ideas).
|
||||
Search existing issues first and keep the report focused on one problem.
|
||||
|
||||
- type: checkboxes
|
||||
@@ -30,6 +31,7 @@ body:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- apps/mobile
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Feature request
|
||||
url: https://github.com/pingdotgg/t3code/discussions/categories/ideas
|
||||
about: Suggest an improvement or new capability in Discussions.
|
||||
@@ -1,101 +0,0 @@
|
||||
name: Feature request
|
||||
description: Propose a scoped improvement or new capability.
|
||||
title: "[Feature]: "
|
||||
labels:
|
||||
- enhancement
|
||||
- needs-triage
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Use this form for new capabilities or meaningful improvements to existing behavior.
|
||||
This repo is still early. Small, concrete requests that clearly explain the problem and scope are much easier to evaluate.
|
||||
|
||||
- type: checkboxes
|
||||
id: checks
|
||||
attributes:
|
||||
label: Before submitting
|
||||
options:
|
||||
- label: I searched existing issues and did not find a duplicate.
|
||||
required: true
|
||||
- label: I am describing a concrete problem or use case, not just a vague idea.
|
||||
required: true
|
||||
|
||||
- type: dropdown
|
||||
id: area
|
||||
attributes:
|
||||
label: Area
|
||||
description: Which part of the project would this change affect?
|
||||
options:
|
||||
- apps/web
|
||||
- apps/server
|
||||
- apps/desktop
|
||||
- packages/contracts or packages/shared
|
||||
- Build, CI, or release tooling
|
||||
- Docs
|
||||
- Not sure
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: problem
|
||||
attributes:
|
||||
label: Problem or use case
|
||||
description: What are you trying to do? What is hard, slow, or impossible today?
|
||||
placeholder: I want to reconnect to an existing provider session after a browser refresh without losing the current thread state.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: proposal
|
||||
attributes:
|
||||
label: Proposed solution
|
||||
description: Describe the behavior, API, or UX you want.
|
||||
placeholder: Persist enough session metadata so the client can discover and reattach to the active provider session on load.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: value
|
||||
attributes:
|
||||
label: Why this matters
|
||||
description: Who benefits, and what outcome does this unlock?
|
||||
placeholder: This would make reconnects predictable during network drops and reduce accidental duplicate sessions.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: scope
|
||||
attributes:
|
||||
label: Smallest useful scope
|
||||
description: What is the narrowest version of this request that would still solve your problem?
|
||||
placeholder: A first pass only needs to support restoring the active session for the current thread.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives considered
|
||||
description: Workarounds, prior art, or other approaches you considered.
|
||||
placeholder: I currently work around this by manually restarting the provider session, but that loses in-flight context.
|
||||
|
||||
- type: textarea
|
||||
id: tradeoffs
|
||||
attributes:
|
||||
label: Risks or tradeoffs
|
||||
description: What costs, complexity, or edge cases should be considered?
|
||||
placeholder: This may require careful handling when the underlying provider session has already exited.
|
||||
|
||||
- type: textarea
|
||||
id: references
|
||||
attributes:
|
||||
label: Examples or references
|
||||
description: Links, screenshots, mockups, or comparable tools.
|
||||
|
||||
- type: checkboxes
|
||||
id: contribution
|
||||
attributes:
|
||||
label: Contribution
|
||||
options:
|
||||
- label: I would be open to helping implement this.
|
||||
@@ -11,9 +11,11 @@
|
||||
# Keep entries sorted alphabetically.
|
||||
github:adityavardhansharma
|
||||
github:binbandit
|
||||
github:chrisdeeming
|
||||
github:chuks-qua
|
||||
github:cursoragent
|
||||
github:gbarros-dev
|
||||
github:gfsaaser24
|
||||
github:github-actions[bot]
|
||||
github:hwanseoc
|
||||
github:jamesx0416
|
||||
@@ -25,7 +27,9 @@ github:Noojuno
|
||||
github:notkainoa
|
||||
github:PatrickBauer
|
||||
github:realAhmedRoach
|
||||
github:saphid
|
||||
github:shiroyasha9
|
||||
github:StiensWout
|
||||
github:Yash-Singh1
|
||||
github:eggfriedrice24
|
||||
github:Ymit24
|
||||
@@ -33,3 +37,5 @@ github:shivamhwp
|
||||
github:jappyjan
|
||||
github:justsomelegs
|
||||
github:UtkarshUsername
|
||||
github:SunkenInTime
|
||||
github:bil0000
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800"><image width="1280" height="800" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAAMgCAIAAADz+lisAAAQAElEQVR4nOzdB3gU5drG8YGEBAiEFnrvvQsISBUERUGxIBYsR1EsR0X0oCj2jl3xU8FCUVABUXrvHQzSIXRCJ4RAIJV8d/aVcd1AsoGokPf/u/baazIzO/tOWZh7nimBSUlJDgAAAAAA2V1OBwAAAAAACxCAAQAAAABWIAADAAAAAKxAAAYAAAAAWIEADAAAAACwAgEYAAAAAGAFAjAAAAAAwAoEYAAAAACAFQjAAAAAAAArEIABAAAAAFYgAAMAAAAArEAABgAAAABYgQAMAAAAALACARgAAAAAYAUCMAAAAADACgRgAAAAAIAVCMAAAAAAACsQgAEAAAAAViAAAwAAAACsQAAGAAAAAFiBAAwAAAAAsAIBGAAAAABgBQIwAAAAAMAKBGAAAAAAgBUIwAAAAAAAKxCAAQAAAABWIAADAAAAAKxAAAYAAAAAWIEADAAAAACwAgEYAAAAAGAFAjAAAAAAwAoEYAAAAACAFQjAAAAAAAArEIABAAAAAFYgAAMAAAAArEAABgAAAABYgQAMAAAAALACARgAAAAAYAUCMAAAAADACgRgAAAAAIAVCMAAAAAAACsQgAEAAAAAViAAAwAAAACsQAAGAAAAAFiBAAwAAAAAsEKgA8APKSkpDgAAwMUqR44cDoCMEICBszBx1/sdAADg4mdisPc7AG8EYOAvUs5ISkpKTNRbsuidGAwAAC5miruBgQE5c+bMlStQL8lxhgPgjBzawXcAeEXfhITE2NhTKSmnc+XKFRSUyyMwICDAAQAAuFjpkL2O3ScmJmpPRpR7Q0Lyak+GGAx4IwADqZR7T3ucPHkqPj6xSJFC+g/DAQAAuDQpBh85cjQ4OFfevHlyepCBAYcADDhn0q9+C8ePxwYHBxcsGOoAAABc+qKjY+Lj4/PnDwkMDCQDAw4BGDDpNzEx8cSJkwULFggODnIAAACyi/j4hOjoY/ny5c2VKxcZGOA5wLCaueg3OTmZ9AsAALIl7d4ULBiqXR3t8Jg9HwewGAEYVjPp9+TJU8GpSL8AACAb8uznBGuHx2RgB7AYARj2OnPP54TExCSu+wUAANmYdnUSEpK020MRGJYjAMNepvx76lR84cKFHAAAgGytSJGCp07FUQSG5QjAsJT7yF+988QjAACQ7QUFBZ0+7SQmJlIEhs0IwLCXuflzrlykXwAAYAUd9NfRf+0COYCtCMCw1Jn7P5+m/AsAACyh3R7t/FABhs0IwLCXDn/qX38qwAAAwBLa7dHODxVg2CzQAaxkjn0qAufKxa8AAABYQbs9p/8oAFMBhqXY9YfV9K9/QECAAwAAYAHt9hB9YTlOgYaNzD/9/AcAAAAsxI4QbEYABgAAAABYgQAMAAAAALACARgAAAAAYAUCMAAAAADACgRgAAAAAIAVCMAAAAAAACsQgAEAAAAAViAAAwAAAACsQAAGAAAAAFiBAAwAAAAAsAIBGAAAAABgBQIwAAAAAMAKBGAAAAAAgBUIwAAAAAAAKxCAAQAAAABWCBg4cKAD2CclJSU5OTk+PjE0NJ+T1U6fPr1nz56tW7eePp0SGprfyb6io4+9//6HOXLkKFeunGM9rfEffvipQIECRYoUdi5iO3bsHD/+l8mTpxQpUiRXrqCLZw1GRKQuwIIFCxYu7LsAZ8yYOWbM2IYNG+TKlcv5R3gvpaJFizr/qs8//3LDho3169dzAOCCHT9+Ijg4KDAwMIeHA1gm0AGQpebNm//6629o79n8GRKSt1evXg8/3Ef/0ziXvr1790VFHalatWpwcLD+XLRo0bffDgsPD7/iipZOltq8ecvp08k1atRwLoxPgzPl2LFju3fvLlWqVNo8dtZGbtkS8cEHH5YtW6Zq1SrOxWrXrl033nhTbOxJbZnNmjXZsWPH37QGz0NEROoCrFChfJUqlX0Gvfnm2zqo1Lx58wzbmZSUtHHjRh2GKFu2rHO+fJZSrVo1nX/PgQMH3n//A3V07359SEiIAwAALgABGMhKq1b91rv3g+rQbrpeOsg6ceLEzz77v9WrVw8e/Enu3LmdS9xXX309YsTIiRN/qVw5NaK0adP6iSceb9LkMier/fe/jx06dGjlyuXOhfFpcKYsWbL0sceeePnlF2+55Wbn72zkP2nhwsXKdX37Pn7fff/JmTNnbGzs37QGs9arr760du16f9p59Gj0TTf1uPbaLoMGve2cL5+l5Pyrihcv/sorL+kIDukXAIALRwAGskxk5N777++tjiFDvnDrVPfdd++TTz49a9asKVOmXn99Nyd70R75Aw/c7+DSERkZqff27dubXHeprMHLPZx/is9S+tfdfPNNDgAAyArcBAvIMnPmzFHV6OGHH/I+SzNPnjzPPfesOoYNG+72nDRpct++/Ro3btK16w3vvDNo585dpr86une/adSoH0aO/E5VrBo1aut9zpy5GrRnzx4NGjToPe9v/OWXX9Vz3rz56k5MTPzmm2/vuuteTbZPn4d/+mmMO5o+pdHWrl33wAN9NE0zaP36DQ899GiLFq300vgbN250x58/f/69996n6WjQI4/81wyKiYnRRMaNG6fuhx9+VN2bN2/Zv3+/OvyZNbn99jsHDHh+8eIl993XW83o3PmaoUO/TkpK8lmMS5cu0zR37NiphakOLQHT/1wz+NRT/9Noa9asMX+mpKSoAeqzYcOGtA120tAXPf543zZt2muymmsdpzD91fP1199UxwcffKTPjh//iz+NdDxXgL///geaO01QS2/z5s3eH9T0NWUNuu22Oz777P9UgHXOQXP00kuvdOjQyayFFStWuoO0KLTotBg1nV697v7ss8/VDDMonU3o8OHDGvT999+r+5FHUhdIePhqnzWoxuuDWg7uB7/44kuNEBUVpaFafVqJ3o389tthGnrgwAHnHJuZBn344UfaGDQXzzwzYMmSJd4f15ZmthYtrq+++ibtxuD6+ONPNXEzm+aLtm/fbpakpvziiy8dO3bMSS34f3P33feqY/bs2Rrn1VdfNx9Ppxlms5w6dVqPHj3V7OXLV6RdSs65txN/Vta5fpg+NPuDB3+mb1Qz9K7NQ581g7Su+/V7Wh2zZqXOV9qXO6b/GxgAAHaiAgxkGUVKvXfqdJVP/1KlSq5fv8b9U3vAzz2XevM51Zf279+nJDNhwqQffxxVrFixuLhTmoh2W7W/3q5d2woVyq9du/bBBx8aO/anmjVrnDx5Uvvl//3vI0FBQe6kNH7dunXU/eKLL48ZM7Z48eItW7bU/vfs2XNiYo7fe+/djic8a7TevR+Mj49r1apV4cKFNm3apJ1mDerZ89bjx49PmDBR40+a9GulSpXMDnRISN7mzZvv339gxoyZek2ePEHNq1y5sqapEFK2bLmCBQsEBwfHxydoyi1aNM9w1tRTQXr79h1qZKNGDZs2bbJs2XIl5ODgoDvuuN17cemr9UVmYarDvT/HuWZQH1d0GTBg4NixPwYGBiqpKoTfffdd5cqVS9tgn1WjJaPopQ7NQkBAoPLYokWL3333nS5drilbtuy+ffu0IkqUKK7pFChQwJ9Gyocffnz0aJSWnr5ai27Vqt/Gjx9XtGiY4zlg8fTT/c2yjYiI0Jhr1qz7+OMPAgICfBqmFXTzzbeqo3HjRhpq1sLgwR9rwSrhK7BpUoULF9ba/O23cC3J8PDwTz/9WLOfziZUqlQpd4GUL18+NDQ0T57cPmtQOVOfVQs7dLhy167d+mCZMmW0lEw0VeZUw7zbefDgQX08Li7+rJuZ0tf99z+oQwB16tTRVjpu3M96fffdCG0AGn/lylUaqg5tDHp/++131FrnHFSS1cSTkhLdL9JnAwMDmjW7fNasWQr8hw8f+eSTj8LCimjWtm7dGhycWzNbokQJjZ9+MzZ6aNPSnKrZKomnXUrpbCfpr6z0f5g++vd/Vr9Etequu3rpOJE2D62CN954zfH826LtUB358+f3Ppn/xIkTmqDWl9kC/d/AAACwFgEYyDJr1qzV+1l34t0TKXft2qWIqOjyyy/jwsJSQ5EJjS+88NJnn31qxlF0UVwx9935v//74oMPPlSo05/du9/w3nsfLF26VLvpGnTo0GElHwWVQoUKKfJpJ7tz507vvTfIc2HnyZ49b1eiaNu2tTKtmaz23bUzbW6iq2qYk1ouG2KSj5my9s41sopj9evXe/vtt8qXT70t8IgRI1VGmz9/Qa9ed77zzlvqVp/+/Z8ye+HeBV5/Zk2FxFdeecmcz6mvu+OOXt9/P9onACul6ItUUjt06JA6TM90ZlCt7dPnAVVB1bBu3bq+8sqrWgWPPfaoau9pG+xDMUNf98AD93fs2MHxxAwdF5g4cbKCzZNPPqGq4GOPPXHrrT3SXgN81kYaqsVNnjxRmV+hUbP/88/jV65cqZYrwimcKGX99NPoggULasznn3/hxx9/0gg33tjdZ/q9e/fxXkGmYR98kJqpfv11gnKOtoH/+79PTbDRZNVHs6nYn84m9Mwz/1NTVT4dMmToM8/0Nxuq9xo0ydnTwh90vMDxnLZgyuD+897MXnrpZcXO55571qziLVsirruumwqkCxfO05+PPvqY5yu+MQFYG7Oq2f5/kYLim2++ro1Btd/27Tsocx49erRr1+uU/RSJ1Qx3vQwa9O65mmFyozan558fcPvtt5nx0y4lraZzbSfpr6xJfvwwDXMcSjM1cuRwtUobj0q+27Zti4uL8753QJMml3lfCK3M7KT+nD/QsY9MbWAAAFiLU6CBLKOdbMU/tzx7ViYkP/10PxMR5aabblRQURnn9OnTpo8yrXvX2auuSt3h3r17j97NLine truncated
|
||||
|
After Width: | Height: | Size: 42 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="800"><image width="1280" height="800" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAAMgCAIAAADz+lisAAAQAElEQVR4nOzdB5gV5dkG4AEWkCoKKopiw96wx15jD3YNaogaC5bEgmJHrDFW7LH3KNgrVuwFKypWmgVUivS2u5T/3Z14/s02V8VE9rvva69zzc6ZM/PNN3N255n3zJyiWbNmZQAAAFDfNcwAAAAgAQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJJQlAF1MHfu3AwA4LeqQYMGGfBjBGCoRh53Kz4CAPz25TG44iNQkQAM/2HuD2bNmlVaGg+zQzyKwQDAb1nE3aKiRg0bNmzcuCh+QoMfZMAPGsQBfgZUiL4lJaXTps2YO3dO48aNmzRpXK6oUaNGGQDAb1Wcso9z96WlpXEkEyL3tmjRPI5kxGCoSACGMpF755SbPn1GcXFp27YLxT+MDABg/hQx+PvvJzRt2rh582YNy8nAkAnAkP2QfuO9MGXKtKZNm7Zp0zoDAJj/TZw4ubi4uFWrFkVFRTIwZAIw5Om3tLR06tTpbdos2LRpkwwAoL4oLi6ZOHFSy5bNGzduLAOD7wEmaflFv7Nnz5Z+AYB6KQ5v2rRpHYc6ccCTH/lkkDABmKTl6Xf69BlNy0i/AEA9VH6c0zQOePIMnEHCBGDS9cM9n0tKS2e57hcAqMfiUKekZFYc9igCkzgBmHTl5d8ZM4oXXnihDACgXmvbts2MGTMVgUmcAEyiCl/5G4++8QgAqPeaNGkyZ05WWlqqCEzKBGDSld/8uXFj6RcASEKc9I+z/3EIlEGqBGAS9cP9n+co/wIAiYjDnjj4UQEmZQIw6YrTn/HXXwUYAEhEHPbEwY8KMCkryiBJ+bnPiMCNG3sXAABJiMOeOf8uAKsAkyiH/iQt/vo3atQoAwBIQBz2iL4kzkegSVH+p98/AAAgQQ6ESJkADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASRCAAQAASIIADAAAQBIEYAAAAJIgAAMAAJAEARgAAIAkCMAAAAAkQQAGAAAgCQIwAAAASWjUq1evDNIzd+7c2bNnFxeXtm7dMpvX5syZM3LkyGHDhs2ZM7d161ZZ/TVx4qTLLru8QYMGHTt2zJIXW7xfv/sWXHDBtm0Xzn7Dvvjiy4cffqR//yfbtm3buHGT384WHDq0rAPbtGmz8MKVO/DZZ5+7//4H1l67c+PGjbP/ioq9tMgii2T/U9ddd8Mnn3y61lprZgC/2JQpU5s2bVJUVNSgXAaJKcqAeeqll14+//y/x9Fz/muLFs27det21FFHxH+abP73zTffjh///QorrNC0adP49bXXXrvtttsHDRq06aabZPPU558PmTNn9sorr5z9MpUa/JNMmjTp66+/XmKJJarmsWobOWTI0D59Ll9qqSVXWKFT9lv11Vdf7bnnXtOmTY89c8MN1//iiy9+pS34MwwdWtaByyyzdKdOy1d66oILLoyTShtttNGPtnPWrFmffvppnIZYaqmlsp+rUi+tuuoq2f/O6NGjL7usTwzsscduLVq0yACAX0AAhnnp3XffO+yw7jEQh+nxEydZH3/88Wuv/ef7779/zTVXLbDAAtl87uabb7nzzrsef/yR5ZcviyhbbLH5cccdu/7662Xz2t/+dszYsWPfeeet7Jep1OCf5I03Bh5zzHFnn917n332zn7NRv43vfrq65Hrjj/+2EMO+UvDhg2nTZv2K23Beevcc88aPPjjurRzwoSJe+217y677HzxxRdmP1elXsr+pxZbbLFzzjkrzuBIvwDwywnAMM+MGvXNoYceFgM33nh9oU51yCEH9+jRc8CAAU8++dRuu+2a1S9xRH744YdmzD9GjRoVj1tvvXWe6+aXLfi7ctl/S6Ve+p/be++9MgBgXnATLJhnXnjhhagaHXXUkRU/pdmsWbPTTz81Bm6//Y7CyCee6H/88Sesu+76XbrsftFFF3/55Vf5+BjYY4+97rmn3113/SuqWCuvvFo8vvDCi/HUyJEj46mLL7604hIfeeTRGPnSSy/HcGlp6a233vbnPx8csz3iiKPuu+/+wmTxqphs8OCPDj/8iJhn/tTHH39y5JF/3XjjzeInpv/0008L07/88ssHH3xIzCeeOvrov+VPTZ48OWby4IMPxvBRR/01hj//fMh3330XA3VZtbD//n867bQzXn/9jUMOOSyascMOO9100y2zZs2q1I0DB74Z8/ziiy+jM2MgeiAfX9MKnnjiSTHZhx9+mP86d+7caECM+eSTT6o2OKsiFnTsscdvscXWMdtY6zhPkY+Pkeeff0EM9OlzRbz24YcfqUsjs/IrwC+7rE+sXcwweu/zzz+v+MKYf8w5ntpvvwOuvfafUYDNahBrdNZZ52y77fb5Vnj77XcKT0VXRNdFN8Z8unU78Nprr4tm5E/VsguNGzcunrr77rtj+Oijyzpk0KD3K23BaHy8MPqh8MLrr78hJhg/fnw8G5svNmLFRt522+3x7OjRo7MadrN46vLLr4idIdbilFNOe+ONNyq+PPa0fG+J7rr55lur7gwFV155dcw8X818QSNGjMh7Mubcu/dZkyZNysoK/rceeODBMfD888/HNOeee37+8lqake+WTz319L77do1mv/XW21V7Kat5P6nLxqrpjVlJrP4111wbS4xmxGPsHvHa/KnY1iec0DMGBgwoW6+qP4Up676DAUCaVIBhnolIGY/bb79dpfFLLLH4xx9/WPg1joBPP73s5nNRX/ruu28jyTz22BP33nvPoosuOnPmjJhJHLbG8fpWW225zDJLDx48uHv3Ix944L5VVll5+vTpcVz+t78d3aRJk8KsYvo11lg9hnv3Pvv++x9YbLHFNtlkkzj+fv75FyZPnnLwwQdm5eE5JjvssO7FxTM322yzhRde6LPPPouD5niqa9c/Tpky5bHHHo/pn3ji0eWWWy4/gG7RovlGG2303Xejn332ufjp3/+xaN7yyy8f84wQstRSHdu0WbBp06bFxSUx54033uhHVy1GRpAeMeKLaOQ666y9wQbrv/nmW5GQmzZtcsAB+1fsrlh0LCjvzBgo3J+jphWMl0d0Oe20Xg88cG9RUVEk1QjhBx74544dO1ZtcKVNEz0T0SsGYhUaNSqKPPbaa69fcslFO++801JLLfXtt9/GhmjffrGYz4ILLliXRobLL79ywoTx0Xux6Oi6d9997+GHH1xkkXZZ+QmLnj1Pzvt26NChMeWHH3505ZV9GjVqVKlhsYH23vuPMbDuuuvEs/lWuOaaK6NjI+FHYItZLbzwwrE133tvUPTkoEGDrr76ylj9WnahJZZYotAhSy+9dOvWrZs1W6DSFoycGa+NFm677TZfffV1vHDJJZeMXsqjaWTOaFjFdo4ZMyZePnNmcbW7WaSvQw/tHqcAVl999dhLH3zwofj517/ujB0gpn/nnXfj2RiInSEeL7zwomhtVoMoycbMZ80qLSwoXltU1GjDDX83YMCACPzjxn1/1VVXtGvXNlZt2LBhTZsuECvbvn37mL72ZnxaLnatWNNodpTEq/ZSLftJ7Rur9jdmJSeffGq8E6NVf/5ztzhPFLtHbIK///28rPxvS+yHMdCqVauKH+afOnVqzDC2V74H1n0HA4BkCcAwz3z44eB4rPYgvvBByq+++ioiYkSXRx55sF27slCUh8Yzzzzr2muvzqeJ6BJxJb/vzj//eX2fPpdHqItf99hj90sv7TNw4MA4TI+nxo4dF8kngspCCy0UkS8OsnfYYftLL724/MLO6V277h+JYsstN49Mm882jt3jYDq/iW5Uw7KyctmNefLJ5xxH5zFxFMfWWmvNCy/8x9JLl90W+M4774oy2ssvv9Kt258uuugfMRxjTj75xPwovGKBty6rFoXEc845K/88ZyzugAO63X1330oBOFJKLChKamPHjo2BfGQtKxitPeKIw6MKGg3bddcu55xzbmyCY475a9Teqza4kogZsbjDDz/097/fNiuPGXFe4PHH+0ew6dHjuKgKHnPMcX/8475VrwGutpG5qMX17/94ZP4IjbH6Dz308DvvvBMtjwgX4SRS1n339W3Tpk1MecYZZ957730xwZ577lFp/ocddkTFDZQ3rE+fskz16KOPRc6JfeCf/7w6DzYx2xgTqxmxv5Zd6JRTToqmRvn0xhtvOuWUk/MdteIWzJNzeQv7xfmCrPxjC3kZvO4q7mZnnXV2xM7TTz8138RDhgz9wx92jQLpq6++FL/+9a/HlC/i1jwAx84c1ey6LyiC4gUXnB87Q9R+t95628icEyZM6NLlD5H9IhJHMwrb5eKLL6mpGXlujN3pjDNO23///fLpq/ZSbKaa9pPaN9YTdXhj5vLzULFSd911R7Qqdp4o+Q4fPnzmzJkV7x2w/vrrVbwQOjJzVvZ27hPnPn7SDgYAyfIRaJhn4iA74l+hPFutPCT37HlCHhHDXnvtGUElyjhz5szJx0SmLdx1drvtyg64v/56ZDzmR9tPLine truncated
|
||||
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1280" height="1000" viewBox="0 0 1280 1000"><image width="1280" height="1000" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABQAAAAPkCAIAAAB5gwQOAAABLGlDQ1BfAAB4nJWQPUsDQRCGH0NA1DSiooXFlWnUJGI+UAsTNWiZKES7y+UIYhKPy4n2af0R1naCjQipbawEKxEbe0Gwje/dFReQFJlhdp59d9jdGYgtIYunoN3x3Eq5aNROTo3JTybkgZlW12G0qer3Lax9XWF8m2rYXUv5W+G5elxXNsTzzZCvfa6HfOPzled44luf3aNKSfwgTjaHuD7EluP69e/irXbr0or+TcLuHFeVa4plylzIm7SwWaPKOWeYohR7FMizrrwj31CkyUgpkNUuRYkiOa059qXkdZZmN2BV+PMMn+x9wHZ/MBg8RdphH+6zMP0YaclNmE3A80ukRTN2TNcMpLgiZhfhZ0Gt3MHcF8z0pC76xyN6Nf71anBAB4tVUUbdpMn+AQyUTdocuQPoAAAQAElEQVR4nOz9B3hUV7rvCe9SFgiRQWSJnDMGTLIBY4NtbGMbnAPO3T7dfbrPmZl7n5nnztz7PTPfnXtudzvnhHMAY3LOOeeco8hBOdb8ai3VZqtKEgIjLKz/73HTpaq9V3hX2O9/vXuvHVVQUOAIIYQQQgghhBC/d6IcIYQQQgghhBCiCiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLIQQQgghhBCiSiABLEQofr/f5/PxryOEEEIIcWtinRn+dYQQHiSAhQjFXip0wRBCCCHELY2cGSHCkQAWVRHFeIUQQghRlVF8WFRZJIBFlcOrfkuc9wsLCyMiIvhXFwYhhBBC3HJYB8Y6M/xb4gGuOyRXR1Q1JIBFVcE70bvTvftnyAWgDHkshBBCCFGZcZ0c918n6POU6AVJCYsqha+goMAR4vdIyH3O3inePcD9vsQUdJu0EEIIIW45yuPbuHI33EGSHha/bxQBFr9bQvayCgn2lnhhCJnqzZGOEEIIIcQtRLgDE+71hDwRFqJ4pX7F7xgJYPF7ozR9W/xGoCti2DEP/Zonfu2v/KdJXwghhBC/D/xGzwYkbYTBvRfa/BR6p7QXhYLF7xLdAi1+t9iNH5i4+WDmbl9Q3BZN9HkB8vPzC+x+V8GpP3CsbnwWQgghxK1O0KUpCvPanbGioiKjo6Oio6ODyvaKgwQcwPel7Z4lxO8ACWDx+6HE2K8ra82cHrgMoHhzcnLz8nLp/OZCEBkVFfjXTPg+RYCFEEII8TvCb70gVvsLCwvy89G2BfwVGYkMjomNjUEP4/4UFjpuTDgk5Ks4sPidIQEsbnlC9mywH5jdQ44yX/qzs3Oys3PtvB8bGx2J+I2KNIudEUV3AwkhhBBC/L6wz3mZu+IKiQQUFOTn5OTZSEBcXExcXCyukHGiinlC9k46p/iuWvKWxK2OBLD4/WCXJ630dVcrzf3PgS/y8vKzkb85udHR0fHxcfxrljx9V90LWgghhBDiVifE50EG5+XlZWVl8y9x4Lg4XKMoG1ZwnxO2x7t/OkL8LpAAFrcwJd7tHK5p+ZdlTqZ4PjLFx8fHe+72cRypXyGEEEJUATyukeM+F5aVlUV4gB8JD8TGRrsv0Qh3q0KScoS4NZEAFrcq7mJk2GZXTkgcmGk9IyMzIiKyRo3qMTHR4bv8a11TCCGEEL97XIfHu+7P59zcvLS0jMLCgurVqxEqCIn92mNCNseS7yRuXSSAxa2NO4N7lye903p2dk5mZmZkZGRCQoJVv1Yne1/7rhlcCCGEEFUBr/NjX4FhVS4aOD09HV1QrVq1uLhY93ivZ+X6S3KcxC2N9jcXtx7+IO5OV954r7tUyZ95eXmZmdnM7DVqJLCiaX8NEcmaxIUQQghRRXDdHu8dzoCbhLOEy4TjhPvkfY7Me8+dPdd9f6SeIBO3IhLA4tbDG791glrXu5xpj2EVk/Avv1evXj06Otr93osjhBBCCFHFCHeHcJNwlnCZ+Ij7ZDaIvuJleX0tx7PVqFwpcSsiASxuJfwevIuR4fcz84HpOzc3r1q1+Li4WLtA6Q0RCyGEEEJUcYrfHOfgMuE44T7hRIVo3RJdL8WBxa2IBLC4lShP7NdiXnqUEx0dFRcXF1ygVOBXCCGEEOIKHtco8A//s+9DwonClXIPUxxY/J6QABa3Eu46pbvcGK5+7U9m1g5M4pGR7jvctUIphBBCCBGKcaWKnvjFccJ9wm/ClfJGd8NvtQtxyYS4VZAAFrcM3uk1/M5n9xim5YKCwLvdo6IiY2KineAcbVc5HSGEEEII4cFGgF0pi/uEE4UrZZ4EdkrTwO6eWE5xJ02ISo4EsLhl8HnezF7inc+u0GXNkkk5NjYmMjJSN+cIIYQQQlwV17nCfcKJwpWy99OVFgf2imE5WuIWQgJY3Bp4d1nwFX/dkfcAX+A1v4H7n/kQGRlln2bx602/QgghhBBl4lG2jnGibEQh9D5nf9jrkbxOmhCVHwlgcQvgD3tpu7tnQ8iGWI65IaegoIDFy+joSHt6yP5YQgghhBAiBG/AACcKcKi8D505xW/E83pl/rDtSIWotEgAi1uAEKHreILA4RtiFRQEViuZtSMiIty3HykCLIQQQghRBq6/hPuEE4UrhUOFW1XaxlfhjpncLXFLIAEsbgHC73MO+dLxSGKWKvkYGVm0nYOjjRmEEEIIIcqBx3Hy4UrhUOFWlcf78n4pRCVHAlhUdkLurnG/DFl3dIrdKW2/0cYMQgghhBDlxeM4FT0M7L23OTzk657l1yuRxK2DBLCo1HhFb+nbPhf7YP716aVHQgghhBDXR/DFSFcUb7jT5YS9GMnRxiviVkACWFRqwtcUvd+E7MHgXAkXK+orhBBCCHH9uBHg4i5WsV1I/SU9HiwfTFRyJIBFpcY7n4ZMqe4SY8itOBylO3CEEEIIIX4N/iKKvWvDdb3CXTLdBS1uFaIcISo3ERERdgt+Pjiem22806t3Ojarlbr/WQghhBDi+jHuls/eVed93Nd+CLkvz7x6I7Bjlv3gCFGJUQRYVGr8YW9dD/m+lPfROUIIIYQQ4tfg3gIdcuez/fWqTpoQlRMJYFF58RffeLDEu2v8xTfEMn9K/gohhBBC3BB8HhcrgD/s5ZTe59T8xfcrFaISIgEsKin+4jtdlfbBPdizQqk5VwghhBDiBoBb5UrcEu+/K+2DNLCotOgZYFFJCdlaMOTtR07xd697dyDUhFtJCGk1n3aG9OAPe5F11TFOuGMU7idVkEFKnBzUMysP/rCXi3r/VBuFUKLGUH8WNxyvrxVy5XKKX85Ki1IIUdmQABaVFPeibnfAcr+0Eytfhlz4/Vf26HcqgnIuZ4a8GKCcx4d/DvmmjJ+ccrxzLzxgfq0JXrUkxZ8I4nOxx4Gc4g8IXcel8VpyvzaDlKfHhLjg5Wnc8DqGHO8vZRc3f9jrvkIS5sASyx/eRuVxjsuQo9fhu5Sz25eHivCcfGHPrYV8L35bTOcp+XtHhFGaWWQucWNhVPrD3m/kfuPdoNT+ZD00J2ynaCEqDxLAojJilxvt/s/u9GqnVKt+7WG+sDcAmy8rRAGHa4YSj3F/cv8tjwYuz68lihmnHHjLE1LOciYYkkLZJwYve1d+9Ye9LMG5dhetNIOXmLsna6e0fHye6jjFnmgq+RSf53LuK7flvXX3lay+ij21XuLxIWWwj2P5SupaZZzrlGL5Mo68Dnzl6/bhI+i6c7w+wvqJvLTKgpnAfWqO8iNbiYrGulUhq9jeK5qrgV1vzfG8wkNdVFRCJIBFZcQXFnBzP3vn0xC1EFQFFTLVepVP+Gzukd/XdtNvSOTNc0UpSrWMpLy/lpaL37yToEQpVf4EyxBa7gHhmse9FvqKP6pddlKl4S2bN7XSukqwpUpOx1/KrbAlnYIB/SHHlC2DvdX0lbTWUPz0kvfSdE8Pa4hiEeASg8y+sIiuN19/8ehuiXXx/+oI8FXPzcrK2rfvQFra5fbt29epUzs7O/vUqTP01rp161SvXt2+ReM6CnDV4tkPly9fvnDhQlRUVN26dePj4x1RObBDh2kjLS0tNfVUXFxcUlLD6Ojo6+6QlRB/8a0c3WnHLL1dWwVtUrm5uefPn2dA1axZs1atWhU0dkRVxl4lQrwg759ufCJcHqsrisqJBLCojPjDHh+1b5Line truncated
|
||||
|
After Width: | Height: | Size: 231 KiB |
@@ -0,0 +1,429 @@
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
|
||||
const ARTIFACT_NAME = "thread-transfer-results";
|
||||
const RESULT_FILE = "thread-transfer-result.json";
|
||||
const COMMENT_MARKER = "<!-- t3-thread-transfer-report -->";
|
||||
const PROVIDERS = ["codex", "claudeAgent"];
|
||||
const OBSERVED_KEYS = [
|
||||
"totalWireBytes",
|
||||
"threadSnapshotWireBytes",
|
||||
"threadSnapshotDecodedBytes",
|
||||
"measuredTurnWebSocketWireBytes",
|
||||
"measuredTurnWebSocketDecodedBytes",
|
||||
"measuredTurnWebSocketMessages",
|
||||
];
|
||||
const CEILING_KEYS = [
|
||||
"totalWireBytes",
|
||||
"threadSnapshotWireBytes",
|
||||
"measuredTurnWebSocketWireBytes",
|
||||
"measuredTurnWebSocketDecodedBytes",
|
||||
"measuredTurnWebSocketMessages",
|
||||
];
|
||||
const SCENARIO_KEYS = [
|
||||
"id",
|
||||
"historyTurns",
|
||||
"historyCommandToolsPerTurn",
|
||||
"historyMcpResultBytes",
|
||||
"measuredCommandTools",
|
||||
"measuredMcpResultBytes",
|
||||
];
|
||||
|
||||
function resultShaMarker(sha) {
|
||||
return `<!-- t3-thread-transfer-result-sha:${sha} -->`;
|
||||
}
|
||||
|
||||
function assertObject(value, label) {
|
||||
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
||||
throw new Error(`${label} must be an object`);
|
||||
}
|
||||
}
|
||||
|
||||
function assertExactKeys(value, expected, label) {
|
||||
assertObject(value, label);
|
||||
const actual = Object.keys(value).sort();
|
||||
const wanted = [...expected].sort();
|
||||
if (actual.length !== wanted.length || actual.some((key, index) => key !== wanted[index])) {
|
||||
throw new Error(`${label} has unexpected fields`);
|
||||
}
|
||||
}
|
||||
|
||||
function assertMetric(value, label) {
|
||||
if (!Number.isSafeInteger(value) || value < 0 || value > 1_000_000_000) {
|
||||
throw new Error(`${label} must be a non-negative safe integer below 1,000,000,000`);
|
||||
}
|
||||
}
|
||||
|
||||
function validateResult(value) {
|
||||
assertExactKeys(value, ["schemaVersion", "scenario", "providers"], "result");
|
||||
if (value.schemaVersion !== 1) {
|
||||
throw new Error("result.schemaVersion must be 1");
|
||||
}
|
||||
|
||||
assertExactKeys(value.scenario, SCENARIO_KEYS, "result.scenario");
|
||||
if (value.scenario.id !== "thread-transfer-v1") {
|
||||
throw new Error("result.scenario.id is not supported");
|
||||
}
|
||||
for (const key of SCENARIO_KEYS.slice(1)) {
|
||||
assertMetric(value.scenario[key], `result.scenario.${key}`);
|
||||
}
|
||||
|
||||
assertExactKeys(value.providers, PROVIDERS, "result.providers");
|
||||
for (const provider of PROVIDERS) {
|
||||
const entry = value.providers[provider];
|
||||
assertExactKeys(entry, ["observed", "ceiling"], `result.providers.${provider}`);
|
||||
assertExactKeys(entry.observed, OBSERVED_KEYS, `result.providers.${provider}.observed`);
|
||||
assertExactKeys(entry.ceiling, CEILING_KEYS, `result.providers.${provider}.ceiling`);
|
||||
for (const key of OBSERVED_KEYS) {
|
||||
assertMetric(entry.observed[key], `result.providers.${provider}.observed.${key}`);
|
||||
}
|
||||
for (const key of CEILING_KEYS) {
|
||||
assertMetric(entry.ceiling[key], `result.providers.${provider}.ceiling.${key}`);
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function readResult(directory) {
|
||||
if (!directory) return undefined;
|
||||
const file = path.join(directory, RESULT_FILE);
|
||||
if (!fs.existsSync(file)) return undefined;
|
||||
const stat = fs.lstatSync(file);
|
||||
if (!stat.isFile() || stat.size > 64 * 1_024) {
|
||||
throw new Error("thread transfer result must be a regular file smaller than 64 KiB");
|
||||
}
|
||||
return validateResult(JSON.parse(fs.readFileSync(file, "utf8")));
|
||||
}
|
||||
|
||||
function formatBytes(bytes) {
|
||||
if (bytes < 1_024) return `${bytes} B`;
|
||||
if (bytes >= 1_024 * 1_024) return `${(bytes / 1_024 / 1_024).toFixed(2)} MiB`;
|
||||
return `${(bytes / 1_024).toFixed(1)} KiB`;
|
||||
}
|
||||
|
||||
function formatValue(value, kind) {
|
||||
return kind === "messages" ? value.toLocaleString("en-US") : formatBytes(value);
|
||||
}
|
||||
|
||||
function formatImpact(current, baseline, kind) {
|
||||
if (baseline === undefined) return "—";
|
||||
const delta = current - baseline;
|
||||
const prefix = delta > 0 ? "+" : delta < 0 ? "−" : "";
|
||||
const magnitude = formatValue(Math.abs(delta), kind);
|
||||
const percent =
|
||||
baseline === 0 ? "" : ` (${prefix}${Math.abs((delta / baseline) * 100).toFixed(1)}%)`;
|
||||
return `${prefix}${magnitude}${percent}`;
|
||||
}
|
||||
|
||||
function sameScenario(left, right) {
|
||||
return SCENARIO_KEYS.every((key) => left[key] === right[key]);
|
||||
}
|
||||
|
||||
const METRICS = [
|
||||
{ key: "totalWireBytes", label: "Total thread wire", kind: "bytes" },
|
||||
{ key: "threadSnapshotWireBytes", label: "Thread snapshot wire", kind: "bytes" },
|
||||
{
|
||||
key: "measuredTurnWebSocketWireBytes",
|
||||
label: "Live turn WebSocket wire",
|
||||
kind: "bytes",
|
||||
},
|
||||
{
|
||||
key: "measuredTurnWebSocketDecodedBytes",
|
||||
label: "Live turn WebSocket decoded",
|
||||
kind: "bytes",
|
||||
},
|
||||
{ key: "measuredTurnWebSocketMessages", label: "Live turn messages", kind: "messages" },
|
||||
];
|
||||
|
||||
function renderComment(input) {
|
||||
const current = input.current;
|
||||
const baseline = input.baseline;
|
||||
const comparable = baseline !== undefined && sameScenario(current.scenario, baseline.scenario);
|
||||
const rows = [];
|
||||
const ceilingChanges = [];
|
||||
let failed = false;
|
||||
|
||||
for (const provider of PROVIDERS) {
|
||||
for (const metric of METRICS) {
|
||||
const observed = current.providers[provider].observed[metric.key];
|
||||
const ceiling = current.providers[provider].ceiling[metric.key];
|
||||
const baselineObserved = comparable
|
||||
? baseline.providers[provider].observed[metric.key]
|
||||
: undefined;
|
||||
const pass = observed <= ceiling;
|
||||
failed ||= !pass;
|
||||
rows.push(
|
||||
`| ${provider === "codex" ? "Codex" : "Claude"} | ${metric.label} | ${baselineObserved === undefined ? "—" : formatValue(baselineObserved, metric.kind)} | ${formatValue(observed, metric.kind)} | ${formatImpact(observed, baselineObserved, metric.kind)} | ${formatValue(ceiling, metric.kind)} | ${pass ? "✅" : "❌"} |`,
|
||||
);
|
||||
|
||||
if (baseline && baseline.providers[provider].ceiling[metric.key] !== ceiling) {
|
||||
ceilingChanges.push(
|
||||
`- ${provider === "codex" ? "Codex" : "Claude"} ${metric.label}: ${formatValue(baseline.providers[provider].ceiling[metric.key], metric.kind)} → ${formatValue(ceiling, metric.kind)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const baselineLink = input.baselineRun
|
||||
? `[\`${input.baselineRun.sha.slice(0, 7)}\`](${input.baselineRun.url})`
|
||||
: "unavailable";
|
||||
const currentLink = `[\`${input.currentRun.sha.slice(0, 7)}\`](${input.currentRun.url})`;
|
||||
const notices = [];
|
||||
if (!baseline) {
|
||||
notices.push(
|
||||
"> ℹ️ No successful `main` baseline artifact is available yet. This run establishes the initial measurement.",
|
||||
);
|
||||
} else if (!comparable) {
|
||||
notices.push(
|
||||
"> ⚠️ The thread fixture changed, so impact percentages are not directly comparable to the `main` baseline.",
|
||||
);
|
||||
} else if (!input.baselineRun.matchesBase) {
|
||||
notices.push(
|
||||
"> ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful `main` measurement shown below.",
|
||||
);
|
||||
}
|
||||
if (ceilingChanges.length > 0) {
|
||||
notices.push(
|
||||
`> ⚠️ **This PR changes transfer ceilings:**\n>\n${ceilingChanges.map((line) => `> ${line}`).join("\n")}`,
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
COMMENT_MARKER,
|
||||
resultShaMarker(input.currentRun.sha),
|
||||
"## Thread transfer impact",
|
||||
"",
|
||||
failed
|
||||
? "❌ One or more thread transfer ceilings were exceeded."
|
||||
: "✅ Thread transfer remains within every enforced ceiling.",
|
||||
...(notices.length > 0 ? ["", ...notices] : []),
|
||||
"",
|
||||
"| Provider | Metric | Main baseline | This PR | Impact | PR ceiling | |",
|
||||
"| --- | --- | ---: | ---: | ---: | ---: | --- |",
|
||||
...rows,
|
||||
"",
|
||||
`Baseline: ${baselineLink} · PR result: ${currentLink} · Source CI: ${input.currentRun.conclusion}`,
|
||||
"",
|
||||
"<details>",
|
||||
"<summary>Scenario and decoded snapshot size</summary>",
|
||||
"",
|
||||
`${current.scenario.historyTurns} historical turns, ${current.scenario.historyCommandToolsPerTurn} command tools per turn, ${formatBytes(current.scenario.historyMcpResultBytes)} retained MCP result per historical turn, and a ${formatBytes(current.scenario.measuredMcpResultBytes)} retained result in the measured turn.`,
|
||||
"",
|
||||
...PROVIDERS.map(
|
||||
(provider) =>
|
||||
`- ${provider === "codex" ? "Codex" : "Claude"} decoded thread snapshot: ${formatBytes(current.providers[provider].observed.threadSnapshotDecodedBytes)}`,
|
||||
),
|
||||
"",
|
||||
"</details>",
|
||||
"",
|
||||
"_Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed._",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
async function artifactsForRun(github, owner, repo, runId) {
|
||||
return github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
|
||||
owner,
|
||||
repo,
|
||||
run_id: runId,
|
||||
per_page: 100,
|
||||
});
|
||||
}
|
||||
|
||||
function findResultArtifact(artifacts) {
|
||||
return artifacts.find((artifact) => artifact.name === ARTIFACT_NAME && !artifact.expired);
|
||||
}
|
||||
|
||||
async function resolve({ github, context, core }) {
|
||||
const source = context.payload.workflow_run;
|
||||
const { owner, repo } = context.repo;
|
||||
if (source.event !== "pull_request") {
|
||||
core.setOutput("publish", "false");
|
||||
return;
|
||||
}
|
||||
|
||||
let pullNumber = source.pull_requests?.[0]?.number;
|
||||
if (!pullNumber) {
|
||||
const associated = await github.paginate(
|
||||
github.rest.repos.listPullRequestsAssociatedWithCommit,
|
||||
{ owner, repo, commit_sha: source.head_sha, per_page: 100 },
|
||||
);
|
||||
const matchingPulls = associated.filter(
|
||||
(pull) =>
|
||||
pull.state === "open" &&
|
||||
pull.head.sha === source.head_sha &&
|
||||
pull.head.ref === source.head_branch,
|
||||
);
|
||||
if (matchingPulls.length !== 1) {
|
||||
core.info(
|
||||
`Expected one open pull request for ${source.head_repository?.full_name ?? "unknown repository"}:${source.head_branch ?? "unknown branch"} at ${source.head_sha}; found ${matchingPulls.length}.`,
|
||||
);
|
||||
core.setOutput("publish", "false");
|
||||
return;
|
||||
}
|
||||
pullNumber = matchingPulls[0].number;
|
||||
}
|
||||
if (!pullNumber) {
|
||||
core.info("No open pull request is associated with the completed CI run.");
|
||||
core.setOutput("publish", "false");
|
||||
return;
|
||||
}
|
||||
|
||||
const { data: pull } = await github.rest.pulls.get({ owner, repo, pull_number: pullNumber });
|
||||
if (pull.head.sha !== source.head_sha) {
|
||||
core.info(`Skipping stale CI result ${source.head_sha}; PR head is ${pull.head.sha}.`);
|
||||
core.setOutput("publish", "false");
|
||||
return;
|
||||
}
|
||||
|
||||
const sourceArtifacts = await artifactsForRun(github, owner, repo, source.id);
|
||||
const sourceArtifact = findResultArtifact(sourceArtifacts);
|
||||
const workflowRuns = await github.paginate(github.rest.actions.listWorkflowRuns, {
|
||||
owner,
|
||||
repo,
|
||||
workflow_id: source.workflow_id,
|
||||
branch: pull.base.ref,
|
||||
event: "push",
|
||||
status: "success",
|
||||
per_page: 100,
|
||||
});
|
||||
const orderedRuns = [
|
||||
...workflowRuns.filter((run) => run.head_sha === pull.base.sha),
|
||||
...workflowRuns.filter((run) => run.head_sha !== pull.base.sha),
|
||||
].slice(0, 20);
|
||||
|
||||
let baselineRun;
|
||||
for (const run of orderedRuns) {
|
||||
const artifacts = await artifactsForRun(github, owner, repo, run.id);
|
||||
if (findResultArtifact(artifacts)) {
|
||||
baselineRun = run;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
core.setOutput("publish", "true");
|
||||
core.setOutput("pull_number", String(pullNumber));
|
||||
core.setOutput("pr_artifact", sourceArtifact ? "true" : "false");
|
||||
core.setOutput("pr_run_id", String(source.id));
|
||||
core.setOutput("pr_sha", source.head_sha);
|
||||
core.setOutput("pr_conclusion", source.conclusion ?? "unknown");
|
||||
core.setOutput("baseline_artifact", baselineRun ? "true" : "false");
|
||||
core.setOutput("baseline_run_id", baselineRun ? String(baselineRun.id) : "");
|
||||
core.setOutput("baseline_sha", baselineRun?.head_sha ?? "");
|
||||
core.setOutput(
|
||||
"baseline_matches_base",
|
||||
baselineRun?.head_sha === pull.base.sha ? "true" : "false",
|
||||
);
|
||||
}
|
||||
|
||||
async function upsertComment(github, context, pullNumber, body, options = {}) {
|
||||
const { owner, repo } = context.repo;
|
||||
const comments = await github.paginate(github.rest.issues.listComments, {
|
||||
owner,
|
||||
repo,
|
||||
issue_number: pullNumber,
|
||||
per_page: 100,
|
||||
});
|
||||
const existing = comments.find(
|
||||
(comment) =>
|
||||
comment.user?.login === "github-actions[bot]" && comment.body?.includes(COMMENT_MARKER),
|
||||
);
|
||||
if (
|
||||
options.preserveResultSha &&
|
||||
existing?.body?.includes(resultShaMarker(options.preserveResultSha))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
if (existing) {
|
||||
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
|
||||
} else {
|
||||
await github.rest.issues.createComment({ owner, repo, issue_number: pullNumber, body });
|
||||
}
|
||||
}
|
||||
|
||||
async function upsertCommentForCurrentHead(
|
||||
github,
|
||||
context,
|
||||
core,
|
||||
pullNumber,
|
||||
expectedSha,
|
||||
body,
|
||||
options,
|
||||
) {
|
||||
const { owner, repo } = context.repo;
|
||||
const { data: pull } = await github.rest.pulls.get({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pullNumber,
|
||||
});
|
||||
if (pull.head.sha !== expectedSha) {
|
||||
core.info(`Skipping stale CI result ${expectedSha}; PR head is ${pull.head.sha}.`);
|
||||
return false;
|
||||
}
|
||||
|
||||
await upsertComment(github, context, pullNumber, body, options);
|
||||
return true;
|
||||
}
|
||||
|
||||
async function publish({ github, context, core }) {
|
||||
const pullNumber = Number(process.env.PR_NUMBER);
|
||||
if (!Number.isSafeInteger(pullNumber) || pullNumber <= 0) {
|
||||
throw new Error("PR_NUMBER is invalid");
|
||||
}
|
||||
|
||||
const current = readResult(process.env.PR_RESULT_DIR);
|
||||
const currentRun = {
|
||||
sha: process.env.PR_SHA,
|
||||
conclusion: process.env.PR_CONCLUSION,
|
||||
url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.PR_RUN_ID}`,
|
||||
};
|
||||
if (!current) {
|
||||
await upsertCommentForCurrentHead(
|
||||
github,
|
||||
context,
|
||||
core,
|
||||
pullNumber,
|
||||
currentRun.sha,
|
||||
[
|
||||
COMMENT_MARKER,
|
||||
"## Thread transfer impact",
|
||||
"",
|
||||
`⚠️ The latest [CI run](${currentRun.url}) did not produce a thread transfer result for \`${currentRun.sha.slice(0, 7)}\`.`,
|
||||
"",
|
||||
"_This comment will update automatically after the next completed run._",
|
||||
].join("\n"),
|
||||
{ preserveResultSha: currentRun.sha },
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const baseline = readResult(process.env.BASELINE_RESULT_DIR);
|
||||
const baselineRun = baseline
|
||||
? {
|
||||
sha: process.env.BASELINE_SHA,
|
||||
matchesBase: process.env.BASELINE_MATCHES_BASE === "true",
|
||||
url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${process.env.BASELINE_RUN_ID}`,
|
||||
}
|
||||
: undefined;
|
||||
const body = renderComment({ current, baseline, currentRun, baselineRun });
|
||||
const published = await upsertCommentForCurrentHead(
|
||||
github,
|
||||
context,
|
||||
core,
|
||||
pullNumber,
|
||||
currentRun.sha,
|
||||
body,
|
||||
);
|
||||
if (published) {
|
||||
core.info(`Updated thread transfer report on PR #${pullNumber}.`);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
publish,
|
||||
readResult,
|
||||
renderComment,
|
||||
resolve,
|
||||
upsertCommentForCurrentHead,
|
||||
validateResult,
|
||||
};
|
||||
@@ -0,0 +1,292 @@
|
||||
const assert = require("node:assert/strict");
|
||||
const test = require("node:test");
|
||||
|
||||
const {
|
||||
renderComment,
|
||||
resolve,
|
||||
upsertCommentForCurrentHead,
|
||||
validateResult,
|
||||
} = require("./thread-transfer-report.cjs");
|
||||
|
||||
function result(overrides = {}) {
|
||||
const observed = {
|
||||
totalWireBytes: 2_200_000,
|
||||
threadSnapshotWireBytes: 1_950_000,
|
||||
threadSnapshotDecodedBytes: 9_100_000,
|
||||
measuredTurnWebSocketWireBytes: 250_000,
|
||||
measuredTurnWebSocketDecodedBytes: 1_150_000,
|
||||
measuredTurnWebSocketMessages: 15,
|
||||
};
|
||||
const ceiling = {
|
||||
totalWireBytes: 2_900_000,
|
||||
threadSnapshotWireBytes: 2_600_000,
|
||||
measuredTurnWebSocketWireBytes: 320_000,
|
||||
measuredTurnWebSocketDecodedBytes: 1_550_000,
|
||||
measuredTurnWebSocketMessages: 20,
|
||||
};
|
||||
return {
|
||||
schemaVersion: 1,
|
||||
scenario: {
|
||||
id: "thread-transfer-v1",
|
||||
historyTurns: 10,
|
||||
historyCommandToolsPerTurn: 5,
|
||||
historyMcpResultBytes: 900_000,
|
||||
measuredCommandTools: 20,
|
||||
measuredMcpResultBytes: 1_100_000,
|
||||
},
|
||||
providers: {
|
||||
codex: { observed: { ...observed, ...overrides }, ceiling },
|
||||
claudeAgent: { observed, ceiling },
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test("validates the fixed artifact schema", () => {
|
||||
assert.equal(validateResult(result()).schemaVersion, 1);
|
||||
assert.throws(
|
||||
() => validateResult({ ...result(), injectedMarkdown: "@everyone" }),
|
||||
/unexpected fields/,
|
||||
);
|
||||
assert.throws(
|
||||
() => validateResult(result({ totalWireBytes: "lots" })),
|
||||
/non-negative safe integer/,
|
||||
);
|
||||
});
|
||||
|
||||
test("renders baseline, impact, ceiling, and ceiling changes", () => {
|
||||
const baseline = result();
|
||||
const current = result({ measuredTurnWebSocketWireBytes: 260_000 });
|
||||
current.providers.codex.ceiling = {
|
||||
...current.providers.codex.ceiling,
|
||||
measuredTurnWebSocketWireBytes: 330_000,
|
||||
};
|
||||
const comment = renderComment({
|
||||
current,
|
||||
baseline,
|
||||
currentRun: {
|
||||
sha: "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
||||
conclusion: "success",
|
||||
url: "https://github.com/pingdotgg/t3code/actions/runs/2",
|
||||
},
|
||||
baselineRun: {
|
||||
sha: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
||||
matchesBase: true,
|
||||
url: "https://github.com/pingdotgg/t3code/actions/runs/1",
|
||||
},
|
||||
});
|
||||
|
||||
assert.match(comment, /Main baseline \| This PR \| Impact \| PR ceiling/);
|
||||
assert.match(comment, /\+9\.8 KiB \(\+4\.0%\)/);
|
||||
assert.match(comment, /This PR changes transfer ceilings/);
|
||||
assert.match(comment, /312\.5 KiB → 322\.3 KiB/);
|
||||
assert.match(comment, /<!-- t3-thread-transfer-report -->/);
|
||||
assert.match(
|
||||
comment,
|
||||
/<!-- t3-thread-transfer-result-sha:bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb -->/,
|
||||
);
|
||||
});
|
||||
|
||||
test("resolves a fallback PR with a redacted head repo and exact main baseline", async () => {
|
||||
const outputs = {};
|
||||
const listWorkflowRunArtifacts = () => {};
|
||||
const listWorkflowRuns = () => {};
|
||||
const listPullRequestsAssociatedWithCommit = () => {};
|
||||
const github = {
|
||||
paginate: async (method, input) => {
|
||||
if (method === listPullRequestsAssociatedWithCommit) {
|
||||
return [
|
||||
{
|
||||
number: 5350,
|
||||
state: "open",
|
||||
head: { sha: "head-sha", ref: "feature-branch", repo: null },
|
||||
},
|
||||
];
|
||||
}
|
||||
if (method === listWorkflowRunArtifacts) {
|
||||
return [
|
||||
{
|
||||
name: "thread-transfer-results",
|
||||
expired: false,
|
||||
runId: input.run_id,
|
||||
},
|
||||
];
|
||||
}
|
||||
if (method === listWorkflowRuns) {
|
||||
return [{ id: 1, head_sha: "base-sha" }];
|
||||
}
|
||||
throw new Error("unexpected pagination call");
|
||||
},
|
||||
rest: {
|
||||
actions: { listWorkflowRunArtifacts, listWorkflowRuns },
|
||||
pulls: {
|
||||
get: async () => ({
|
||||
data: {
|
||||
head: { sha: "head-sha" },
|
||||
base: { sha: "base-sha", ref: "main" },
|
||||
},
|
||||
}),
|
||||
},
|
||||
repos: { listPullRequestsAssociatedWithCommit },
|
||||
},
|
||||
};
|
||||
await resolve({
|
||||
github,
|
||||
context: {
|
||||
repo: { owner: "pingdotgg", repo: "t3code" },
|
||||
payload: {
|
||||
workflow_run: {
|
||||
id: 2,
|
||||
event: "pull_request",
|
||||
workflow_id: 3,
|
||||
head_sha: "head-sha",
|
||||
head_branch: "feature-branch",
|
||||
head_repository: { full_name: "pingdotgg/t3code" },
|
||||
conclusion: "success",
|
||||
pull_requests: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
core: {
|
||||
info: () => {},
|
||||
setOutput: (key, value) => {
|
||||
outputs[key] = value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(outputs.publish, "true");
|
||||
assert.equal(outputs.pull_number, "5350");
|
||||
assert.equal(outputs.pr_artifact, "true");
|
||||
assert.equal(outputs.baseline_run_id, "1");
|
||||
assert.equal(outputs.baseline_matches_base, "true");
|
||||
});
|
||||
|
||||
test("does not guess when a fallback commit belongs to multiple PRs", async () => {
|
||||
const outputs = {};
|
||||
const listPullRequestsAssociatedWithCommit = () => {};
|
||||
let fetchedPull = false;
|
||||
await resolve({
|
||||
github: {
|
||||
paginate: async (method) => {
|
||||
assert.equal(method, listPullRequestsAssociatedWithCommit);
|
||||
return [5350, 5351].map((number) => ({
|
||||
number,
|
||||
state: "open",
|
||||
head: {
|
||||
sha: "head-sha",
|
||||
ref: "feature-branch",
|
||||
repo: { full_name: "pingdotgg/t3code" },
|
||||
},
|
||||
}));
|
||||
},
|
||||
rest: {
|
||||
actions: {},
|
||||
pulls: {
|
||||
get: async () => {
|
||||
fetchedPull = true;
|
||||
},
|
||||
},
|
||||
repos: { listPullRequestsAssociatedWithCommit },
|
||||
},
|
||||
},
|
||||
context: {
|
||||
repo: { owner: "pingdotgg", repo: "t3code" },
|
||||
payload: {
|
||||
workflow_run: {
|
||||
id: 2,
|
||||
event: "pull_request",
|
||||
workflow_id: 3,
|
||||
head_sha: "head-sha",
|
||||
head_branch: "feature-branch",
|
||||
head_repository: { full_name: "pingdotgg/t3code" },
|
||||
conclusion: "success",
|
||||
pull_requests: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
core: {
|
||||
info: () => {},
|
||||
setOutput: (key, value) => {
|
||||
outputs[key] = value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(outputs.publish, "false");
|
||||
assert.equal(fetchedPull, false);
|
||||
});
|
||||
|
||||
test("does not publish a stale result after the PR head advances", async () => {
|
||||
let listedComments = false;
|
||||
const info = [];
|
||||
const published = await upsertCommentForCurrentHead(
|
||||
{
|
||||
paginate: async () => {
|
||||
listedComments = true;
|
||||
return [];
|
||||
},
|
||||
rest: {
|
||||
issues: {
|
||||
listComments: () => {},
|
||||
createComment: () => {
|
||||
throw new Error("must not create a stale comment");
|
||||
},
|
||||
updateComment: () => {
|
||||
throw new Error("must not update a stale comment");
|
||||
},
|
||||
},
|
||||
pulls: {
|
||||
get: async () => ({ data: { head: { sha: "new-head-sha" } } }),
|
||||
},
|
||||
},
|
||||
},
|
||||
{ repo: { owner: "pingdotgg", repo: "t3code" } },
|
||||
{ info: (message) => info.push(message) },
|
||||
5350,
|
||||
"old-head-sha",
|
||||
"stale body",
|
||||
);
|
||||
|
||||
assert.equal(published, false);
|
||||
assert.equal(listedComments, false);
|
||||
assert.deepEqual(info, ["Skipping stale CI result old-head-sha; PR head is new-head-sha."]);
|
||||
});
|
||||
|
||||
test("preserves a successful result when a same-SHA rerun has no artifact", async () => {
|
||||
let updatedComment = false;
|
||||
const sha = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
|
||||
const published = await upsertCommentForCurrentHead(
|
||||
{
|
||||
paginate: async () => [
|
||||
{
|
||||
id: 1,
|
||||
user: { login: "github-actions[bot]" },
|
||||
body: `<!-- t3-thread-transfer-report -->\n<!-- t3-thread-transfer-result-sha:${sha} -->`,
|
||||
},
|
||||
],
|
||||
rest: {
|
||||
issues: {
|
||||
listComments: () => {},
|
||||
createComment: () => {
|
||||
updatedComment = true;
|
||||
},
|
||||
updateComment: () => {
|
||||
updatedComment = true;
|
||||
},
|
||||
},
|
||||
pulls: {
|
||||
get: async () => ({ data: { head: { sha } } }),
|
||||
},
|
||||
},
|
||||
},
|
||||
{ repo: { owner: "pingdotgg", repo: "t3code" } },
|
||||
{ info: () => {} },
|
||||
5350,
|
||||
sha,
|
||||
"missing artifact warning",
|
||||
{ preserveResultSha: sha },
|
||||
);
|
||||
|
||||
assert.equal(published, true);
|
||||
assert.equal(updatedComment, false);
|
||||
});
|
||||
@@ -6,6 +6,10 @@ on:
|
||||
branches:
|
||||
- main
|
||||
|
||||
concurrency:
|
||||
group: ci-${{ github.event.pull_request.number || github.sha }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
@@ -14,6 +18,11 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -22,6 +31,11 @@ jobs:
|
||||
cache: true
|
||||
run-install: true
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
components: rustfmt
|
||||
|
||||
- name: Ensure Electron runtime is installed
|
||||
run: vp run --filter @t3tools/desktop ensure:electron
|
||||
|
||||
@@ -31,6 +45,9 @@ jobs:
|
||||
- name: Typecheck
|
||||
run: vpr typecheck
|
||||
|
||||
- name: Check resource monitor formatting
|
||||
run: cargo fmt --manifest-path native/resource-monitor/Cargo.toml -- --check
|
||||
|
||||
- name: Build desktop pipeline
|
||||
run: vp run build:desktop
|
||||
|
||||
@@ -47,6 +64,11 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -55,26 +77,60 @@ jobs:
|
||||
cache: true
|
||||
run-install: true
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
|
||||
- name: Ensure Electron runtime is installed
|
||||
run: vp run --filter @t3tools/desktop ensure:electron
|
||||
|
||||
- name: Test
|
||||
env:
|
||||
T3CODE_TRANSFER_BUDGET_REPORT_PATH: ${{ runner.temp }}/t3code-transfer-budget.md
|
||||
T3CODE_TRANSFER_BUDGET_RESULT_PATH: ${{ runner.temp }}/thread-transfer-result.json
|
||||
run: vp run test
|
||||
|
||||
- name: Publish transfer budget report
|
||||
if: always()
|
||||
run: |
|
||||
if test -f "${{ runner.temp }}/t3code-transfer-budget.md"; then
|
||||
tee -a "$GITHUB_STEP_SUMMARY" < "${{ runner.temp }}/t3code-transfer-budget.md"
|
||||
else
|
||||
echo "Transfer budget report was not produced." >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
|
||||
- name: Upload thread transfer result
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: thread-transfer-results
|
||||
path: ${{ runner.temp }}/thread-transfer-result.json
|
||||
if-no-files-found: ignore
|
||||
retention-days: 30
|
||||
|
||||
- name: Test resource monitor
|
||||
run: cargo test --locked --manifest-path native/resource-monitor/Cargo.toml
|
||||
|
||||
mobile_native_static_analysis:
|
||||
name: Mobile Native Static Analysis
|
||||
runs-on: blacksmith-12vcpu-macos-26
|
||||
runs-on: blacksmith-6vcpu-macos-26
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Install mobile native static analysis tools
|
||||
run: brew bundle install --file apps/mobile/Brewfile
|
||||
@@ -89,13 +145,20 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Exercise release-only workflow steps
|
||||
run: node scripts/release-smoke.ts
|
||||
@@ -38,13 +38,20 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=t3code-relay...
|
||||
|
||||
- name: Deploy production relay stage
|
||||
id: deploy
|
||||
|
||||
@@ -2,13 +2,18 @@ name: Mobile EAS Preview
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize, labeled, unlabeled]
|
||||
types: [opened, reopened, synchronize, labeled]
|
||||
|
||||
jobs:
|
||||
preview:
|
||||
name: EAS Preview
|
||||
if: contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment')
|
||||
if: |
|
||||
contains(github.event.pull_request.labels.*.name, '🚀 Mobile Continuous Deployment') &&
|
||||
(github.event.action != 'labeled' || github.event.label.name == '🚀 Mobile Continuous Deployment')
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
concurrency:
|
||||
group: mobile-eas-preview-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
@@ -34,6 +39,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
# No sparse-checkout here: it makes actions/checkout fetch with
|
||||
# --filter=blob:none, and eas-cli archives the project via
|
||||
# `git clone --depth 1 file://<workspace>`, which fails (exit 128)
|
||||
# when the partial clone can't serve the unfetched blobs.
|
||||
|
||||
- name: Setup Vite+
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
@@ -41,7 +50,9 @@ jobs:
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
|
||||
- name: Expose pnpm
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
|
||||
@@ -5,6 +5,25 @@ name: Mobile EAS Production
|
||||
# in the same OS/pnpm as the EAS build; a macOS `eas build` computes a different
|
||||
# fingerprint (platform-specific deps + pnpm version) and errors. On this Linux
|
||||
# runner, with corepack pinning pnpm 10.24 in eas.json, local == build.
|
||||
#
|
||||
# Every merge to main that touches the mobile app reconciles, per platform:
|
||||
# 1. Store builds: if the latest production build's version differs from
|
||||
# app.config.ts, cut a new build and submit it (TestFlight + Play internal
|
||||
# track). Bumping `version` is therefore all it takes to
|
||||
# start the next release train — the first build of a version enters
|
||||
# external-TestFlight beta review immediately, and later builds of the
|
||||
# same version auto-approve until that version is released. After App
|
||||
# Store approval, Apple closes the release train and `version` must be
|
||||
# bumped before another iOS build can be submitted. Releasing to the App
|
||||
# Store stays a manual App Store Connect step.
|
||||
# 2. OTA: publish a production-channel update for each platform where at
|
||||
# least one finished production build matches the current native
|
||||
# fingerprint. Old-version binaries with a matching fingerprint receive
|
||||
# it too. When native drift means no binary could install the update,
|
||||
# it is skipped and flagged in the job summary instead of published
|
||||
# into the void.
|
||||
# workflow_dispatch remains as a manual override for both modes (e.g. to
|
||||
# retry an errored build or force an OTA).
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -25,14 +44,38 @@ on:
|
||||
- ios
|
||||
- android
|
||||
- all
|
||||
version:
|
||||
description: "Optional build version override (blank uses app.config.ts; an override is committed before building)"
|
||||
required: false
|
||||
type: string
|
||||
message:
|
||||
description: "OTA update message (mode=update only)"
|
||||
required: false
|
||||
type: string
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- apps/mobile/**
|
||||
- packages/client-runtime/**
|
||||
- packages/contracts/**
|
||||
- packages/shared/**
|
||||
- assets/**
|
||||
- scripts/**
|
||||
- patches/**
|
||||
- pnpm-lock.yaml
|
||||
- pnpm-workspace.yaml
|
||||
- .github/workflows/mobile-eas-production.yml
|
||||
|
||||
# Serialize runs so OTAs publish in merge order. GitHub keeps at most one
|
||||
# queued run per group, so a burst of merges collapses into one run of the
|
||||
# newest commit — intermediate commits don't need their own OTA.
|
||||
concurrency:
|
||||
group: mobile-eas-production
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
production:
|
||||
name: EAS Production ${{ inputs.mode }}
|
||||
name: EAS Production ${{ github.event_name == 'push' && 'auto' || inputs.mode }}
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -52,11 +95,25 @@ jobs:
|
||||
echo "EXPO_TOKEN is not available; skipping EAS production job."
|
||||
fi
|
||||
|
||||
- id: version_app_token
|
||||
name: Mint release app token for version override
|
||||
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build' && inputs.version != ''
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ secrets.RELEASE_APP_ID }}
|
||||
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.version_app_token.outputs.token || github.token }}
|
||||
# No sparse-checkout here: it makes actions/checkout fetch with
|
||||
# --filter=blob:none, and eas-cli archives the project via
|
||||
# `git clone --depth 1 file://<workspace>`, which fails (exit 128)
|
||||
# when the partial clone can't serve the unfetched blobs.
|
||||
|
||||
- name: Setup Vite+
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
@@ -64,7 +121,9 @@ jobs:
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
|
||||
- name: Expose pnpm
|
||||
if: steps.expo-token.outputs.present == 'true'
|
||||
@@ -92,15 +151,74 @@ jobs:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
run: eas env:pull production --non-interactive
|
||||
|
||||
- name: Build and submit
|
||||
if: steps.expo-token.outputs.present == 'true' && inputs.mode == 'build'
|
||||
- name: Apply manual version override
|
||||
if: steps.version_app_token.outcome == 'success'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.version_app_token.outputs.token }}
|
||||
APP_SLUG: ${{ steps.version_app_token.outputs.app-slug }}
|
||||
RELEASE_VERSION: ${{ inputs.version }}
|
||||
run: |
|
||||
if [ "$GITHUB_REF_TYPE" != "branch" ]; then
|
||||
echo "Version overrides require dispatching this workflow from a branch; received $GITHUB_REF_TYPE '$GITHUB_REF_NAME'." >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! [[ "$RELEASE_VERSION" =~ ^[0-9]+(\.[0-9]+){1,2}$ ]]; then
|
||||
echo "Version override must contain two or three dot-separated integers; received '$RELEASE_VERSION'." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
node --input-type=module -e '
|
||||
import fs from "node:fs";
|
||||
const path = "apps/mobile/app.config.ts";
|
||||
const source = fs.readFileSync(path, "utf8");
|
||||
const next = source.replace(
|
||||
/^( version: ")[^"]+(".*)$/m,
|
||||
`$1${process.env.RELEASE_VERSION}$2`,
|
||||
);
|
||||
if (next === source && !source.includes(` version: "${process.env.RELEASE_VERSION}"`)) {
|
||||
throw new Error("Could not update app version");
|
||||
}
|
||||
fs.writeFileSync(path, next);
|
||||
'
|
||||
vp fmt apps/mobile/app.config.ts
|
||||
|
||||
if git diff --quiet -- apps/mobile/app.config.ts; then
|
||||
echo "app.config.ts is already at $RELEASE_VERSION; no version commit needed."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
user_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"
|
||||
git config user.name "${APP_SLUG}[bot]"
|
||||
git config user.email "${user_id}+${APP_SLUG}[bot]@users.noreply.github.com"
|
||||
git add apps/mobile/app.config.ts
|
||||
git commit \
|
||||
-m "chore(mobile): bump app version to $RELEASE_VERSION" \
|
||||
-m "Co-authored-by: codex <[email protected]>"
|
||||
git push origin "HEAD:refs/heads/${GITHUB_REF_NAME}"
|
||||
|
||||
- name: Summarize manual build version
|
||||
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
|
||||
working-directory: apps/mobile
|
||||
run: |
|
||||
version="$(npx expo config --json --type public | jq -r '.version')"
|
||||
{
|
||||
echo "## Manual production build"
|
||||
echo
|
||||
echo "- App version: \`$version\`"
|
||||
echo "- Platform: \`${{ inputs.platform }}\`"
|
||||
echo
|
||||
echo "> Apple closes an iOS release train after App Store approval. Before building iOS, confirm \`$version\` is newer than the approved App Store version."
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Build and submit (manual)
|
||||
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'build'
|
||||
working-directory: apps/mobile
|
||||
env:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
run: eas build --platform ${{ inputs.platform }} --profile production --auto-submit --non-interactive --no-wait
|
||||
|
||||
- name: Publish OTA update
|
||||
if: steps.expo-token.outputs.present == 'true' && inputs.mode == 'update'
|
||||
- name: Publish OTA update (manual)
|
||||
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'workflow_dispatch' && inputs.mode == 'update'
|
||||
working-directory: apps/mobile
|
||||
env:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
@@ -111,3 +229,62 @@ jobs:
|
||||
--platform ${{ inputs.platform }} \
|
||||
--message "${{ inputs.message || format('Production OTA ({0})', github.sha) }}" \
|
||||
--non-interactive
|
||||
|
||||
# No --status filter on build:list: an in-queue/in-progress build must
|
||||
# count as existing, or every merge during the build window would cut a
|
||||
# duplicate. After an errored build, retry via workflow_dispatch
|
||||
# mode=build — pushes won't re-trigger it until the app version changes.
|
||||
- id: store_builds
|
||||
name: Ensure store builds exist for the current app version
|
||||
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
|
||||
continue-on-error: true
|
||||
working-directory: apps/mobile
|
||||
env:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
run: |
|
||||
failed=0
|
||||
version="$(npx expo config --json --type public | jq -r '.version')"
|
||||
for platform in ios android; do
|
||||
latest="$(eas build:list --platform "$platform" --build-profile production --limit 1 --json --non-interactive | jq -r '.[0].appVersion // "none"')"
|
||||
if [ "$latest" = "$version" ]; then
|
||||
echo "$platform: production build for $version already exists (or is in progress)"
|
||||
continue
|
||||
fi
|
||||
echo "$platform: latest production build is $latest, app.config.ts says $version — building"
|
||||
if eas build --platform "$platform" --profile production --auto-submit --non-interactive --no-wait; then
|
||||
echo ":building_construction: $platform: scheduled production build and submission for $version" >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
failed=1
|
||||
echo ":x: $platform: production build or submission failed for $version" >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
done
|
||||
exit "$failed"
|
||||
|
||||
- name: Publish fingerprint-gated OTA
|
||||
if: steps.expo-token.outputs.present == 'true' && github.event_name == 'push'
|
||||
working-directory: apps/mobile
|
||||
env:
|
||||
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||
run: |
|
||||
message="$(git log -1 --pretty=%s | head -c 120) ($(git rev-parse --short=9 HEAD))"
|
||||
for platform in ios android; do
|
||||
# eas-cli prints an environment-loaded notice to stdout before the
|
||||
# JSON even with --json, so discard everything before the document.
|
||||
hash="$(eas fingerprint:generate --platform "$platform" --environment production --json --non-interactive | sed -n '/^{/,$p' | jq -er '.hash | select(type == "string" and length > 0)')"
|
||||
matching="$(eas build:list --platform "$platform" --build-profile production --status finished --fingerprint-hash "$hash" --limit 1 --json --non-interactive | jq 'length')"
|
||||
if [ "$matching" -gt 0 ]; then
|
||||
eas update \
|
||||
--channel production \
|
||||
--environment production \
|
||||
--platform "$platform" \
|
||||
--message "$message" \
|
||||
--non-interactive
|
||||
echo ":white_check_mark: $platform: OTA published to production (fingerprint \`$hash\`)" >> "$GITHUB_STEP_SUMMARY"
|
||||
else
|
||||
echo ":warning: $platform: no finished production build matches fingerprint \`$hash\` — OTA skipped; JS changes reach $platform only once a matching build ships" >> "$GITHUB_STEP_SUMMARY"
|
||||
fi
|
||||
done
|
||||
|
||||
- name: Propagate store build failure
|
||||
if: steps.store_builds.outcome == 'failure'
|
||||
run: exit 1
|
||||
@@ -0,0 +1,205 @@
|
||||
name: Mobile Fingerprint Check
|
||||
|
||||
# Detects whether a PR changes the native fingerprint — i.e. whether merging
|
||||
# it would leave main un-OTA-able until a new store build ships. Native-change
|
||||
# PRs get the "📱 Native Change" label so they can be held and merged as a
|
||||
# batch right before the next store submission, keeping main OTA-able for
|
||||
# everything else in between. (Once one native PR merges, every later merge
|
||||
# inherits the drifted fingerprint and loses OTA reach too — that is why the
|
||||
# signal has to fire before merge, not after.)
|
||||
#
|
||||
# The check is advisory: it always passes, the label is the signal. Both
|
||||
# fingerprints are computed in this one job (same OS, same corepack-pinned
|
||||
# pnpm), so the comparison is self-consistent; no EXPO_TOKEN needed.
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- apps/mobile/**
|
||||
- packages/client-runtime/**
|
||||
- packages/contracts/**
|
||||
- packages/shared/**
|
||||
- assets/**
|
||||
- scripts/**
|
||||
- patches/**
|
||||
- pnpm-lock.yaml
|
||||
- pnpm-workspace.yaml
|
||||
- .github/workflows/mobile-fingerprint-check.yml
|
||||
|
||||
concurrency:
|
||||
group: mobile-fingerprint-check-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
fingerprint:
|
||||
name: Native fingerprint diff
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
pull-requests: write
|
||||
env:
|
||||
APP_VARIANT: production
|
||||
NODE_OPTIONS: --max-old-space-size=8192
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
# Default pull_request checkout is the merge commit (PR applied on
|
||||
# top of base), so the "head" fingerprint is the state main would
|
||||
# actually be in after merging — stale branches compare cleanly.
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
pnpm_version="$(node --print "require('./package.json').packageManager.split('@').pop()")"
|
||||
vp_pnpm_bin="$HOME/.vite-plus/package_manager/pnpm/$pnpm_version/pnpm/bin"
|
||||
echo "$vp_pnpm_bin" >> "$GITHUB_PATH"
|
||||
"$vp_pnpm_bin/pnpm" --version
|
||||
|
||||
- name: Fingerprint merge result
|
||||
working-directory: apps/mobile
|
||||
run: |
|
||||
mkdir -p "$RUNNER_TEMP/fp/head" "$RUNNER_TEMP/fp/base"
|
||||
for platform in ios android; do
|
||||
npx expo-updates fingerprint:generate --platform "$platform" > "$RUNNER_TEMP/fp/head/$platform.json"
|
||||
done
|
||||
|
||||
- name: Fingerprint base
|
||||
run: |
|
||||
git checkout --quiet "${{ github.event.pull_request.base.sha }}"
|
||||
# Re-sync node_modules to the base commit's lockfile before
|
||||
# fingerprinting — a dep-changing PR must not fingerprint the base
|
||||
# against head's installed packages.
|
||||
pnpm install --filter=@t3tools/mobile...
|
||||
cd apps/mobile
|
||||
for platform in ios android; do
|
||||
npx expo-updates fingerprint:generate --platform "$platform" > "$RUNNER_TEMP/fp/base/$platform.json"
|
||||
done
|
||||
|
||||
- id: compare
|
||||
name: Compare fingerprints
|
||||
run: |
|
||||
changed=""
|
||||
{
|
||||
echo "## Native fingerprint diff"
|
||||
echo
|
||||
for platform in ios android; do
|
||||
head_hash="$(jq -r .hash "$RUNNER_TEMP/fp/head/$platform.json")"
|
||||
base_hash="$(jq -r .hash "$RUNNER_TEMP/fp/base/$platform.json")"
|
||||
if [ "$head_hash" = "$base_hash" ]; then
|
||||
echo "- ✅ **$platform**: unchanged (\`$head_hash\`) — OTA-compatible"
|
||||
continue
|
||||
fi
|
||||
changed="$changed $platform"
|
||||
echo "- 📱 **$platform**: \`$base_hash\` → \`$head_hash\` — merging requires a new native build before OTAs work again"
|
||||
jq -r -n \
|
||||
--slurpfile h "$RUNNER_TEMP/fp/head/$platform.json" \
|
||||
--slurpfile b "$RUNNER_TEMP/fp/base/$platform.json" '
|
||||
($b[0].sources | map({ (.filePath // .id): .hash }) | add // {}) as $bm
|
||||
| $h[0].sources[]
|
||||
| select($bm[(.filePath // .id)] != .hash)
|
||||
| " - \(.type): `\(.filePath // .id)`"'
|
||||
done
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "changed_platforms=${changed# }" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Sync native change label
|
||||
# Fork PRs get a read-only token under pull_request; the check stays
|
||||
# advisory there (summary only). This workflow must not move to
|
||||
# pull_request_target — it installs and runs PR code.
|
||||
if: github.event.pull_request.head.repo.full_name == github.repository
|
||||
uses: actions/github-script@v8
|
||||
env:
|
||||
CHANGED_PLATFORMS: ${{ steps.compare.outputs.changed_platforms }}
|
||||
with:
|
||||
script: |
|
||||
const managedLabel = {
|
||||
name: "📱 Native Change",
|
||||
color: "d93f0b",
|
||||
description:
|
||||
"Changes the native fingerprint; merging blocks production OTAs until a new store build ships.",
|
||||
};
|
||||
const nativeChanged = (process.env.CHANGED_PLATFORMS ?? "").trim() !== "";
|
||||
const issueNumber = context.payload.pull_request.number;
|
||||
|
||||
try {
|
||||
const { data: existing } = await github.rest.issues.getLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: managedLabel.name,
|
||||
});
|
||||
|
||||
if (
|
||||
existing.color !== managedLabel.color ||
|
||||
(existing.description ?? "") !== managedLabel.description
|
||||
) {
|
||||
await github.rest.issues.updateLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: managedLabel.name,
|
||||
color: managedLabel.color,
|
||||
description: managedLabel.description,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
try {
|
||||
await github.rest.issues.createLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
name: managedLabel.name,
|
||||
color: managedLabel.color,
|
||||
description: managedLabel.description,
|
||||
});
|
||||
} catch (createError) {
|
||||
if (createError.status !== 422) {
|
||||
throw createError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
per_page: 100,
|
||||
});
|
||||
const hasLabel = currentLabels.some((label) => label.name === managedLabel.name);
|
||||
|
||||
if (nativeChanged && !hasLabel) {
|
||||
await github.rest.issues.addLabels({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
labels: [managedLabel.name],
|
||||
});
|
||||
} else if (!nativeChanged && hasLabel) {
|
||||
try {
|
||||
await github.rest.issues.removeLabel({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
name: managedLabel.name,
|
||||
});
|
||||
} catch (removeError) {
|
||||
if (removeError.status !== 404) {
|
||||
throw removeError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
core.info(
|
||||
`PR #${issueNumber}: native fingerprint ${nativeChanged ? `changed (${process.env.CHANGED_PLATFORMS})` : "unchanged"}`,
|
||||
);
|
||||
@@ -37,13 +37,22 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
- --filter=@t3tools/scripts...
|
||||
- --filter=t3...
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
@@ -77,13 +86,22 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/mobile...
|
||||
- --filter=@t3tools/scripts...
|
||||
- --filter=t3...
|
||||
|
||||
- name: Expose pnpm
|
||||
run: |
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
name: Publish AUR package
|
||||
|
||||
# See packaging/aur/README.md.
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
release_tag:
|
||||
required: true
|
||||
type: string
|
||||
pkgrel:
|
||||
required: false
|
||||
default: "1"
|
||||
type: string
|
||||
secrets:
|
||||
AUR_SSH_PRIVATE_KEY:
|
||||
required: true
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: "Release tag to publish"
|
||||
required: true
|
||||
type: string
|
||||
pkgrel:
|
||||
description: "Arch package release override"
|
||||
required: false
|
||||
default: "1"
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: publish-aur
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Validate and publish
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
timeout-minutes: 30
|
||||
container:
|
||||
image: archlinux:base-devel
|
||||
|
||||
steps:
|
||||
- name: Install Arch packaging tools
|
||||
run: pacman -Syu --noconfirm --needed git github-cli jq namcap openssh sudo
|
||||
|
||||
- name: Checkout packaging sources
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Create unprivileged build user
|
||||
run: |
|
||||
useradd --create-home builder
|
||||
install -Dm0440 /dev/stdin /etc/sudoers.d/builder <<'EOF'
|
||||
builder ALL=(root) NOPASSWD: /usr/bin/pacman
|
||||
EOF
|
||||
|
||||
- name: Validate and publish package sources
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
RELEASE_TAG: ${{ inputs.release_tag }}
|
||||
PKGREL: ${{ inputs.pkgrel || '1' }}
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
run: packaging/aur/scripts/release.sh
|
||||
@@ -38,6 +38,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- id: check
|
||||
name: Compare HEAD to last nightly tag
|
||||
@@ -84,6 +88,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -192,6 +200,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -269,14 +281,19 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=t3...
|
||||
|
||||
- name: Build node-pty linux-x64 prebuild
|
||||
shell: bash
|
||||
@@ -326,21 +343,29 @@ jobs:
|
||||
platform: mac
|
||||
target: dmg
|
||||
arch: arm64
|
||||
rust_target: aarch64-apple-darwin
|
||||
resource_key: darwin-arm64
|
||||
- label: macOS x64
|
||||
runner: blacksmith-12vcpu-macos-26
|
||||
platform: mac
|
||||
target: dmg
|
||||
arch: x64
|
||||
rust_target: x86_64-apple-darwin
|
||||
resource_key: darwin-x64
|
||||
- label: Linux x64
|
||||
runner: blacksmith-32vcpu-ubuntu-2404
|
||||
platform: linux
|
||||
target: AppImage
|
||||
arch: x64
|
||||
rust_target: x86_64-unknown-linux-gnu
|
||||
resource_key: linux-x64
|
||||
- label: Windows x64
|
||||
runner: blacksmith-32vcpu-windows-2025
|
||||
platform: win
|
||||
target: nsis
|
||||
arch: x64
|
||||
rust_target: x86_64-pc-windows-msvc
|
||||
resource_key: win32-x64
|
||||
# - label: Windows arm64
|
||||
# runner: windows-11-arm
|
||||
# platform: win
|
||||
@@ -351,14 +376,26 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
fetch-depth: 0
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/desktop...
|
||||
- --filter=t3...
|
||||
- --filter=@t3tools/scripts...
|
||||
|
||||
- name: Setup Rust
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.rust_target }}
|
||||
|
||||
- name: Download relay client tracing config
|
||||
uses: actions/download-artifact@v8
|
||||
@@ -598,6 +635,19 @@ jobs:
|
||||
# done
|
||||
# fi
|
||||
|
||||
- name: Collect resource monitor
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
binary_name="t3-resource-monitor"
|
||||
if [[ "${{ matrix.platform }}" == "win" ]]; then
|
||||
binary_name="${binary_name}.exe"
|
||||
fi
|
||||
source_path="native/resource-monitor/target/${{ matrix.rust_target }}/release/${binary_name}"
|
||||
target_dir="resource-monitor-publish/${{ matrix.resource_key }}"
|
||||
mkdir -p "$target_dir"
|
||||
cp "$source_path" "$target_dir/$binary_name"
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
@@ -605,6 +655,13 @@ jobs:
|
||||
path: release-publish/*
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload resource monitor
|
||||
uses: actions/upload-artifact@v7
|
||||
with:
|
||||
name: resource-monitor-${{ matrix.resource_key }}
|
||||
path: resource-monitor-publish/${{ matrix.resource_key }}/*
|
||||
if-no-files-found: error
|
||||
|
||||
publish_cli:
|
||||
name: Publish CLI to npm
|
||||
needs: [preflight, relay_public_config, build]
|
||||
@@ -624,6 +681,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -659,6 +720,24 @@ jobs:
|
||||
- name: Build CLI package
|
||||
run: vp run --filter t3 build
|
||||
|
||||
- name: Download resource monitors
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
pattern: resource-monitor-*
|
||||
path: ${{ runner.temp }}/resource-monitors
|
||||
|
||||
- name: Bundle resource monitors into CLI package
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
for artifact_dir in "$RUNNER_TEMP"/resource-monitors/resource-monitor-*; do
|
||||
resource_key="${artifact_dir##*/resource-monitor-}"
|
||||
target_dir="apps/server/dist/resource-monitor/${resource_key}"
|
||||
mkdir -p "$target_dir"
|
||||
cp "$artifact_dir"/t3-resource-monitor* "$target_dir/"
|
||||
chmod +x "$target_dir"/t3-resource-monitor 2>/dev/null || true
|
||||
done
|
||||
|
||||
- name: Publish CLI package
|
||||
run: node apps/server/scripts/cli.ts publish --tag "${{ needs.preflight.outputs.cli_dist_tag }}" --app-version "${{ needs.preflight.outputs.version }}" --verbose
|
||||
|
||||
@@ -667,20 +746,18 @@ jobs:
|
||||
needs: [preflight, build, publish_cli]
|
||||
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.build.result == 'success' && needs.publish_cli.result == 'success' }}
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
timeout-minutes: 30
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- id: app_token
|
||||
name: Mint release app token
|
||||
uses: actions/create-github-app-token@v2
|
||||
with:
|
||||
app-id: ${{ secrets.RELEASE_APP_ID }}
|
||||
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
||||
owner: ${{ github.repository_owner }}
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -740,7 +817,7 @@ jobs:
|
||||
|
||||
- name: Publish release
|
||||
if: needs.preflight.outputs.previous_tag != ''
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: ${{ needs.preflight.outputs.tag }}
|
||||
target_commitish: ${{ needs.preflight.outputs.ref }}
|
||||
@@ -757,11 +834,11 @@ jobs:
|
||||
release-assets/*.blockmap
|
||||
release-assets/*.yml
|
||||
fail_on_unmatched_files: true
|
||||
token: ${{ steps.app_token.outputs.token }}
|
||||
token: ${{ github.token }}
|
||||
|
||||
- name: Publish first release
|
||||
if: needs.preflight.outputs.previous_tag == ''
|
||||
uses: softprops/action-gh-release@v2
|
||||
uses: softprops/action-gh-release@v3
|
||||
with:
|
||||
tag_name: ${{ needs.preflight.outputs.tag }}
|
||||
target_commitish: ${{ needs.preflight.outputs.ref }}
|
||||
@@ -777,7 +854,17 @@ jobs:
|
||||
release-assets/*.blockmap
|
||||
release-assets/*.yml
|
||||
fail_on_unmatched_files: true
|
||||
token: ${{ steps.app_token.outputs.token }}
|
||||
token: ${{ github.token }}
|
||||
|
||||
publish_aur:
|
||||
name: Publish AUR package
|
||||
needs: [preflight, release]
|
||||
if: ${{ !failure() && !cancelled() && needs.preflight.result == 'success' && needs.release.result == 'success' }}
|
||||
uses: ./.github/workflows/publish-aur.yml
|
||||
with:
|
||||
release_tag: ${{ needs.preflight.outputs.tag }}
|
||||
secrets:
|
||||
AUR_SSH_PRIVATE_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
|
||||
deploy_web:
|
||||
name: Deploy hosted web app
|
||||
@@ -802,6 +889,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
@@ -864,6 +955,7 @@ jobs:
|
||||
echo "Deploying hosted web app for $channel_name channel."
|
||||
deployment_url="$(
|
||||
vp dlx [email protected] deploy \
|
||||
--archive=tgz \
|
||||
--prod \
|
||||
--skip-domain \
|
||||
--yes \
|
||||
@@ -915,6 +1007,10 @@ jobs:
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.app_token.outputs.token }}
|
||||
persist-credentials: true
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- id: app_bot
|
||||
name: Resolve GitHub App bot identity
|
||||
@@ -985,6 +1081,10 @@ jobs:
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ needs.preflight.outputs.ref }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
name: Thread Transfer Report
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: [CI]
|
||||
types: [completed]
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: Publish PR comment
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
runs-on: ubuntu-24.04
|
||||
concurrency:
|
||||
group: thread-transfer-report-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.id }}
|
||||
cancel-in-progress: true
|
||||
steps:
|
||||
# workflow_run has a write-capable token even for fork PRs. Only load the
|
||||
# publisher from the trusted default branch and never execute PR code.
|
||||
- name: Checkout trusted publisher
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.event.repository.default_branch }}
|
||||
sparse-checkout: .github/scripts
|
||||
|
||||
- name: Test trusted publisher
|
||||
run: node --test .github/scripts/thread-transfer-report.test.cjs
|
||||
|
||||
- id: resolve
|
||||
name: Resolve PR and baseline artifacts
|
||||
uses: actions/github-script@v8
|
||||
with:
|
||||
script: |
|
||||
const reporter = require("./.github/scripts/thread-transfer-report.cjs");
|
||||
await reporter.resolve({ github, context, core });
|
||||
|
||||
- name: Download PR result
|
||||
if: steps.resolve.outputs.publish == 'true' && steps.resolve.outputs.pr_artifact == 'true'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: thread-transfer-results
|
||||
path: ${{ runner.temp }}/thread-transfer/pr
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ steps.resolve.outputs.pr_run_id }}
|
||||
|
||||
- name: Download main baseline
|
||||
if: steps.resolve.outputs.publish == 'true' && steps.resolve.outputs.baseline_artifact == 'true'
|
||||
uses: actions/download-artifact@v8
|
||||
with:
|
||||
name: thread-transfer-results
|
||||
path: ${{ runner.temp }}/thread-transfer/main
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
run-id: ${{ steps.resolve.outputs.baseline_run_id }}
|
||||
|
||||
- name: Update thread transfer comment
|
||||
if: steps.resolve.outputs.publish == 'true'
|
||||
uses: actions/github-script@v8
|
||||
env:
|
||||
PR_NUMBER: ${{ steps.resolve.outputs.pull_number }}
|
||||
PR_SHA: ${{ steps.resolve.outputs.pr_sha }}
|
||||
PR_CONCLUSION: ${{ steps.resolve.outputs.pr_conclusion }}
|
||||
PR_RUN_ID: ${{ steps.resolve.outputs.pr_run_id }}
|
||||
PR_RESULT_DIR: ${{ runner.temp }}/thread-transfer/pr
|
||||
BASELINE_SHA: ${{ steps.resolve.outputs.baseline_sha }}
|
||||
BASELINE_MATCHES_BASE: ${{ steps.resolve.outputs.baseline_matches_base }}
|
||||
BASELINE_RUN_ID: ${{ steps.resolve.outputs.baseline_run_id }}
|
||||
BASELINE_RESULT_DIR: ${{ runner.temp }}/thread-transfer/main
|
||||
with:
|
||||
script: |
|
||||
const reporter = require("./.github/scripts/thread-transfer-report.cjs");
|
||||
await reporter.publish({ github, context, core });
|
||||
@@ -0,0 +1,132 @@
|
||||
name: Web Preview
|
||||
|
||||
# Label a PR `preview:web` to get a hosted-web preview deployment on Vercel for
|
||||
# that push and every subsequent push. The deployment is a plain (non-prod,
|
||||
# non-aliased) deploy into the existing hosted-web Vercel project, so the
|
||||
# latest/nightly channel aliases are never touched.
|
||||
#
|
||||
# The build intentionally omits the T3 Connect cloud config (Clerk keys, relay
|
||||
# URL): previews boot as the hosted-static app with manual pairing only. Pair a
|
||||
# server into a preview with `t3 pair --tailscale` (or any reachable HTTPS
|
||||
# backend) and open the pairing URL against the preview origin.
|
||||
#
|
||||
# The preview must be opened at the exact deployment URL from the PR comment.
|
||||
# Vite bakes that URL in as the hosted origin (via VERCEL_URL), and
|
||||
# `isHostedStaticApp` matches on origin, so branch-alias URLs will not
|
||||
# self-identify as the hosted app.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [labeled, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: web-preview-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy web preview
|
||||
# Same-repo PRs only: fork PRs do not receive the Vercel secrets, and this
|
||||
# workflow should skip rather than fail for them. On `labeled` events, only
|
||||
# the preview label itself triggers a deploy.
|
||||
if: >-
|
||||
github.event.pull_request.head.repo.full_name == github.repository &&
|
||||
contains(github.event.pull_request.labels.*.name, 'preview:web') &&
|
||||
(github.event.action != 'labeled' || github.event.label.name == 'preview:web')
|
||||
runs-on: blacksmith-8vcpu-ubuntu-2404
|
||||
timeout-minutes: 10
|
||||
env:
|
||||
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
|
||||
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
|
||||
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
|
||||
VERCEL_TEAM_SLUG: ${{ vars.VERCEL_TEAM_SLUG }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/.repos/
|
||||
sparse-checkout-cone-mode: false
|
||||
|
||||
- name: Setup Vite+
|
||||
uses: voidzero-dev/setup-vp@v1
|
||||
with:
|
||||
node-version-file: package.json
|
||||
cache: true
|
||||
run-install: |
|
||||
args:
|
||||
- --filter=@t3tools/scripts...
|
||||
- --filter=@t3tools/web...
|
||||
|
||||
- id: deploy
|
||||
name: Deploy preview
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
if [[ -z "${VERCEL_TOKEN:-}" || -z "${VERCEL_ORG_ID:-}" || -z "${VERCEL_PROJECT_ID:-}" ]]; then
|
||||
echo "Missing one or more required Vercel secrets: VERCEL_TOKEN, VERCEL_ORG_ID, VERCEL_PROJECT_ID." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
vercel_scope="${VERCEL_TEAM_SLUG:-$VERCEL_ORG_ID}"
|
||||
|
||||
deployment_url="$(
|
||||
vp dlx [email protected] deploy \
|
||||
--archive=tgz \
|
||||
--yes \
|
||||
--token "$VERCEL_TOKEN" \
|
||||
--scope "$vercel_scope"
|
||||
)"
|
||||
|
||||
echo "Deployed $deployment_url"
|
||||
echo "deployment_url=$deployment_url" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Comment deployment URL
|
||||
uses: actions/github-script@v8
|
||||
env:
|
||||
DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment_url }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
with:
|
||||
script: |
|
||||
const marker = "<!-- web-preview-deploy -->";
|
||||
const body = [
|
||||
marker,
|
||||
"### Web preview",
|
||||
"",
|
||||
`${process.env.DEPLOYMENT_URL} (for ${process.env.HEAD_SHA.slice(0, 7)})`,
|
||||
"",
|
||||
"Open this exact URL — the hosted-app origin is baked in at build time.",
|
||||
"Pair a server into it with `t3 pair --tailscale`, or paste a host + pairing",
|
||||
"code under Settings → Connections.",
|
||||
].join("\n");
|
||||
|
||||
const { data: comments } = await github.rest.issues.listComments({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
per_page: 100,
|
||||
});
|
||||
const existing = comments.find((comment) => comment.body?.includes(marker));
|
||||
|
||||
if (existing) {
|
||||
await github.rest.issues.updateComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
comment_id: existing.id,
|
||||
body,
|
||||
});
|
||||
} else {
|
||||
await github.rest.issues.createComment({
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: context.payload.pull_request.number,
|
||||
body,
|
||||
});
|
||||
}
|
||||
@@ -30,6 +30,7 @@ dist-electron/
|
||||
.showcase/
|
||||
apps/mobile/.showcase/
|
||||
artifacts/app-store/screenshots/
|
||||
native/**/target/
|
||||
node_modules/
|
||||
.alchemy/
|
||||
*.log
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
title: Effect Service Conventions
|
||||
model: claude-opus-4-8
|
||||
model: claude-opus-5
|
||||
effort: high
|
||||
input: full_diff
|
||||
tools:
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
---
|
||||
title: UI Consistency
|
||||
model: claude-opus-5
|
||||
effort: high
|
||||
input: full_diff
|
||||
tools:
|
||||
- browse_code
|
||||
- git_tools
|
||||
- github_api_read_only
|
||||
- modify_pr
|
||||
include:
|
||||
- "apps/web/src/**/*.ts"
|
||||
- "apps/web/src/**/*.tsx"
|
||||
- "apps/web/src/**/*.css"
|
||||
conclusion: failure
|
||||
showToolCalls: true
|
||||
---
|
||||
|
||||
# UI consistency review
|
||||
|
||||
Review changed web UI code and directly affected call sites for consistency with the shared component system, Tailwind ownership, and the behavioral constraints below. Apply these rules when a pull request creates, moves, or modifies controls or styling. Do not demand unrelated repository-wide cleanup.
|
||||
|
||||
The goal is not to minimize CSS or class counts at any cost. The goal is to put each behavior in the smallest correct owner while preserving interaction, theming, accessibility, layout, and browser behavior.
|
||||
|
||||
## Shared controls and variants
|
||||
|
||||
- Prefer the core UI primitives in `apps/web/src/components/ui` over native controls or locally reconstructed primitives. In ordinary product UI, a raw `<button>` that recreates `Button`, a raw input that recreates `Input` or `InputGroup`, or a local trigger that recreates `Select`, `Toggle`, or `Menu` is a concrete finding.
|
||||
- Do not flag raw elements that intentionally implement a semantic row, tab, resize handle, swatch, image target, editor surface, or another interaction whose behavior or geometry differs from the core primitive.
|
||||
- When multiple call sites repeat the same durable geometry or treatment, prefer a named primitive size or variant. Examples include compact controls, micro icon actions, muted ghost actions, and glass actions. Keep contextual layout, width, and color at the call site.
|
||||
- Flag large call-site class strings that override a primitive's core height, radius, padding, focus ring, cursor, hit target, or base state colors. Prefer extending the primitive contract when the same pattern is genuinely shared.
|
||||
- Preserve accessibility and interaction semantics during migrations: focus-visible rings, disabled behavior, loading state, keyboard behavior, pointer cursor, `aria-*`, Base UI or Radix render/close props, and coarse-pointer hit targets.
|
||||
- Do not require tests for a tiny visual-only class migration. Require focused tests when primitive composition changes behavior, prop forwarding, state transitions, keyboard handling, or width/defaulting logic.
|
||||
|
||||
## CSS and Tailwind ownership
|
||||
|
||||
- Ordinary one-owner presentation belongs in the owning TS or TSX module as static Tailwind classes or owner-level CSS variables. Examples include local geometry, spacing, typography, backgrounds, borders, simple vendor pseudo-elements, and component-only positioning.
|
||||
- Keep global CSS when it is genuinely reusable or behaviorally complex: generated markdown or imperative DOM, custom elements and shadow roots, masks, shared or complex pseudo-elements, animations, glass composition, runtime theme variables, safe-area calculations, scrollbar-lane preservation, Electron drag regions, and browser/vendor integration. Simple owner-local pseudo-elements may still belong in the owning module.
|
||||
- Before calling a selector dead, trace literal, dynamic, generated, imperative, test, custom-element, and shadow-root consumers. Search both the emitted class string and any class-valued field names through their final DOM sink. A helper returning a class is not proof that it is rendered, and a missed downstream property read can make a deletion unsafe.
|
||||
- Flag duplicate declarations only after comparing cascade layer, selector specificity, inheritance, runtime theme scope, media/variant scope, and the final owning element. Textually identical declarations are not necessarily behaviorally redundant.
|
||||
- When moving CSS into Tailwind, preserve selector scope and cascade ownership. A utility at the owner is preferable to a fragile global override that depends on stylesheet order.
|
||||
- Do not request moving complex global behavior into arbitrary Tailwind merely to reduce `index.css`. Do not preserve ordinary one-owner CSS merely because it already exists globally.
|
||||
|
||||
## Themes and generated CSS
|
||||
|
||||
- Use the project variants for theme-only declarations:
|
||||
- dark-only declarations use `@variant dark`;
|
||||
- light-only declarations use `@variant light`;
|
||||
- raw `.dark` should remain only in the `dark` and `light` custom-variant definitions.
|
||||
- Preserve custom themes and runtime token bridges. Removing a variable or selector is safe only when all runtime, inspector, generated, and theme-palette consumers are accounted for.
|
||||
- Inspect emitted production CSS after unusual variants, arbitrary selectors, nested pseudo-elements, or attribute matching. Source syntax that looks valid is insufficient.
|
||||
- Flag malformed or empty emitted selectors such as empty `:is()` or `:not(:is())`, selector branches that can never match their own class attribute, and transformations that silently drop the intended rule.
|
||||
- Prefer source-level logic over clever selectors when behavior depends on consumer-provided class strings. Preserve `MenuPopup`'s current defaulting contract: a string `className` containing a `w-*`, `min-w-*`, or `max-w-*` utility after variant prefixes are stripped suppresses `min-w-32`; a string without one and a functional/non-string `className` keep the default. Arbitrary width values count as width utilities, and the consumer class must be merged last so it retains control. Do not replace this with a raw class-attribute substring selector.
|
||||
- Do not fail solely because a valid emitted selector is verbose or because a source rule uses an intentional custom property.
|
||||
|
||||
## Scroll and virtualized lists
|
||||
|
||||
- `ScrollArea` owns and masks its Base UI viewport. A virtualized list usually owns a native scrolling element and cannot automatically reuse viewport-specific `ScrollArea` behavior.
|
||||
- Repeated native or virtualized overflow fades should use the shared virtualized-scroll-fade contract rather than component-named mask selectors.
|
||||
- Preserve runtime top and bottom overflow state. Do not replace dynamic fades with an always-on static mask.
|
||||
- Preserve fade geometry and keep the native scrollbar lane opaque so the track and thumb stay visible and usable. A visually similar mask that fades the scrollbar is a regression.
|
||||
- Verify actual scroll behavior when changing virtualizers, masks, overflow ownership, or scrollbar selectors. Source-level class comparison is not enough.
|
||||
|
||||
## Visual and layout preservation
|
||||
|
||||
- Preserve responsive geometry, titlebar insets, panel and inline-preview modes, desktop Electron layout, light and dark contrast, clipping, radius, and composable shadows.
|
||||
- For meaningful visual changes, prefer available real-app evidence using the actual component and state. A mock recreation does not validate the real component. Light and dark evidence is useful when theme-sensitive styles change, but missing or inaccessible evidence alone is not a finding; report only a concrete regression supported by the diff, code, or available artifacts.
|
||||
- Do not treat a screenshot as proof of keyboard, overflow, scrollbar, responsive, or runtime-theme behavior. Pair visual evidence with source, computed-style, emitted-CSS, or interaction checks as appropriate.
|
||||
- Be alert to shared primitive color indirection. When a primitive routes icon color through a CSS variable, ensure migrated contextual icons retain their intended tone, including pressed and disabled states.
|
||||
|
||||
## Change discipline
|
||||
|
||||
- Review the pull request's changed scope and directly affected consumers. Do not turn a focused PR into a demand for unrelated legacy cleanup.
|
||||
- Prefer the smallest durable contract over a component-specific workaround or a broad abstraction with one consumer.
|
||||
- Preserve intentional exceptions and comments that explain browser, virtualizer, theme, or Electron constraints.
|
||||
- If a proposed cleanup cannot prove ownership or semantic equivalence, ask for evidence or leave it unchanged rather than guessing.
|
||||
- Select verification gates according to the changed behavior: typecheck or focused tests for typing and interaction contracts, production build and emitted-CSS inspection for Tailwind or selector transformations, and real-app evidence for meaningful visual behavior when available. These gates are complementary when applicable, but do not require every gate for tiny visual-only migrations or fail solely because an artifact the configured tools cannot produce is absent.
|
||||
|
||||
## Reporting
|
||||
|
||||
Report only concrete violations introduced by changed lines or behavior, plus pre-existing behavior that the patch directly makes relevant or worsens. Touching a large file does not make unrelated retained issues reportable. Prefer precise inline comments on the smallest relevant line range. Explain the broken behavior or ownership rule, not merely the preferred syntax, and state the smallest expected fix. A clear consistency or regression risk may fail the check. Do not fail for optional aesthetic preferences, harmless class ordering, or unrelated legacy code.
|
||||
|
||||
This check defaults to failure. When there are no findings, stop immediately and make the entire final response exactly `All clear` on one line. Do not add a title, explanation, punctuation, Markdown, JSON, or trailing analysis, and do not continue reasoning after deciding the review is clean.
|
||||
@@ -1 +1 @@
|
||||
alchemy/test/**
|
||||
alchemy/test/**
|
||||
|
After Width: | Height: | Size: 233 KiB |
|
After Width: | Height: | Size: 194 KiB |
|
After Width: | Height: | Size: 218 KiB |
|
After Width: | Height: | Size: 219 KiB |
|
After Width: | Height: | Size: 162 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 205 KiB |
|
After Width: | Height: | Size: 273 KiB |
|
After Width: | Height: | Size: 233 KiB |
|
After Width: | Height: | Size: 194 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 162 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 205 KiB |
|
After Width: | Height: | Size: 236 KiB |
|
After Width: | Height: | Size: 233 KiB |
|
After Width: | Height: | Size: 194 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 216 KiB |
|
After Width: | Height: | Size: 162 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 205 KiB |
|
After Width: | Height: | Size: 271 KiB |
|
After Width: | Height: | Size: 118 KiB |
|
After Width: | Height: | Size: 157 KiB |
|
After Width: | Height: | Size: 172 KiB |
|
After Width: | Height: | Size: 190 KiB |
|
After Width: | Height: | Size: 190 KiB |
|
After Width: | Height: | Size: 180 KiB |
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate the PR screenshots from the built site and commit them if changed.
|
||||
# Usage: .github/pr-assets/update-screenshots.sh [pr-number]
|
||||
# Assumes website/dist is freshly built (DOCS_FAST=1 bun astro build).
|
||||
set -euo pipefail
|
||||
|
||||
PR="${1:-721}"
|
||||
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
||||
OUT="$ROOT/.github/pr-assets/$PR"
|
||||
DIST="$ROOT/website/dist"
|
||||
CHROME="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
||||
PORT=4899
|
||||
|
||||
[ -d "$DIST" ] || { echo "website/dist missing — build first"; exit 1; }
|
||||
mkdir -p "$OUT"
|
||||
|
||||
python3 -m http.server "$PORT" --directory "$DIST" >/dev/null 2>&1 &
|
||||
SERVER_PID=$!
|
||||
trap 'kill $SERVER_PID 2>/dev/null || true' EXIT
|
||||
sleep 1
|
||||
|
||||
shot() { # shot <file> <path> [extra chrome flags...]
|
||||
local file="$1" path="$2"; shift 2
|
||||
"$CHROME" --headless=new --disable-gpu --hide-scrollbars \
|
||||
--window-size=1600,1000 --virtual-time-budget=6000 \
|
||||
"$@" --screenshot="$OUT/$file" "http://localhost:$PORT$path" 2>/dev/null
|
||||
echo "$file: $(wc -c <"$OUT/$file" | tr -d ' ') bytes"
|
||||
}
|
||||
|
||||
shot landing.png /
|
||||
shot docs-tab.png /getting-started/
|
||||
shot cloudflare-hub.png /cloudflare/
|
||||
shot aws-hub.png /aws/
|
||||
shot planetscale-hub.png /planetscale/
|
||||
shot axiom-hub.png /axiom/
|
||||
shot reference.png /providers/cloudflare/workers/durableobject/
|
||||
shot cloudflare-hub-dark.png /cloudflare/ --force-dark-mode --blink-settings=preferredColorScheme=2
|
||||
|
||||
cd "$ROOT"
|
||||
if git status --porcelain -- ".github/pr-assets/$PR" | grep -q .; then
|
||||
git add ".github/pr-assets/$PR"
|
||||
git commit -q -m "chore(website): refresh PR screenshots
|
||||
|
||||
Co-Authored-By: Claude Fable 5 <[email protected]>"
|
||||
git push
|
||||
echo "screenshots refreshed and pushed"
|
||||
else
|
||||
echo "screenshots unchanged"
|
||||
fi
|
||||
@@ -0,0 +1,41 @@
|
||||
name: check
|
||||
|
||||
# Runs the website docs validator (`bun run docs:check`) on every PR
|
||||
# so broken links / missing API references fail fast before merge.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
NODE_VERSION: "24"
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-22-large
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
# `bun install` needs the distilled submodule (workspace member)
|
||||
submodules: true
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
- run: bun tsc -b
|
||||
- run: bun run docs:check
|
||||
@@ -0,0 +1,55 @@
|
||||
name: Claude Code
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
pull_request_review_comment:
|
||||
types: [created]
|
||||
issues:
|
||||
types: [opened, assigned]
|
||||
pull_request_review:
|
||||
types: [submitted]
|
||||
|
||||
jobs:
|
||||
claude:
|
||||
if: |
|
||||
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
id-token: write
|
||||
actions: read
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Configure AWS credentials
|
||||
id: aws
|
||||
uses: aws-actions/configure-aws-credentials@v6
|
||||
with:
|
||||
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
||||
aws-region: us-east-1
|
||||
output-credentials: true
|
||||
|
||||
- name: Run Claude Code
|
||||
uses: anthropics/claude-code-action@v1
|
||||
env:
|
||||
AWS_ACCESS_KEY_ID: ${{ steps.aws.outputs.aws-access-key-id }}
|
||||
AWS_SECRET_ACCESS_KEY: ${{ steps.aws.outputs.aws-secret-access-key }}
|
||||
AWS_SESSION_TOKEN: ${{ steps.aws.outputs.aws-session-token }}
|
||||
AWS_REGION: us-east-1
|
||||
AWS_DEFAULT_REGION: us-east-1
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
|
||||
with:
|
||||
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||
claude_args: |
|
||||
--model claude-fable-5
|
||||
--allowedTools "Bash(aws:*),WebFetch,WebSearch"
|
||||
@@ -1,137 +0,0 @@
|
||||
name: Deploy Website
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "website/**"
|
||||
- "packages/alchemy/**"
|
||||
- "bun.lock"
|
||||
- ".github/workflows/deploy.yml"
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
- closed
|
||||
paths:
|
||||
- "website/**"
|
||||
- "packages/alchemy/**"
|
||||
- "bun.lock"
|
||||
- ".github/workflows/deploy.yml"
|
||||
|
||||
concurrency:
|
||||
group: deploy-website-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
STAGE: ${{ github.event_name == 'pull_request' && format('pr-{0}',
|
||||
github.event.number) || (github.ref == 'refs/heads/main' && 'prod' ||
|
||||
github.ref_name) }}
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
if: ${{ github.event.action != 'closed' }}
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
# Mint a token for the alchemy-version-bot GitHub App so the PR
|
||||
# preview comment (created via GitHub.Comment in alchemy.run.ts)
|
||||
# posts under the bot's identity instead of `github-actions[bot]`.
|
||||
# Same App as release.yml — its installation scopes already cover
|
||||
# PR comments.
|
||||
- name: Generate bot token
|
||||
id: bot-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
with:
|
||||
app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
|
||||
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
# Build the website ahead of `alchemy deploy`. The
|
||||
# Cloudflare.StaticSite resource declares the same `bun run build`
|
||||
# in its config and runs it as part of the create lifecycle, but
|
||||
# on update plans alchemy reads `dist/` during plan.diff before
|
||||
# the embedded Build resource gets a chance to (re)run, causing
|
||||
# a NotFound on a fresh CI checkout. Building here makes the
|
||||
# workflow correct under both create and update plans.
|
||||
- name: Build website
|
||||
working-directory: website
|
||||
run: bun run build
|
||||
|
||||
- name: Deploy
|
||||
working-directory: website
|
||||
run: bun alchemy deploy --stage ${{ env.STAGE }} --yes
|
||||
env:
|
||||
# Alchemy's Cloudflare auth provider accepts either a scoped
|
||||
# API token (CLOUDFLARE_API_TOKEN) or the legacy global API
|
||||
# key paired with email (CLOUDFLARE_API_KEY +
|
||||
# CLOUDFLARE_EMAIL). We use the latter here so CI matches
|
||||
# the credentials in Doppler / .env, where only the admin
|
||||
# global key is provisioned.
|
||||
CLOUDFLARE_API_KEY: ${{ secrets.ADMIN_CLOUDFLARE_API_KEY }}
|
||||
CLOUDFLARE_EMAIL: ${{ secrets.ADMIN_CLOUDFLARE_EMAIL }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ env.STAGE == 'prod' &&
|
||||
secrets.PROD_CLOUDFLARE_ACCOUNT_ID ||
|
||||
secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
|
||||
PULL_REQUEST: ${{ github.event.number }}
|
||||
# On `pull_request` events GitHub Actions' built-in
|
||||
# `GITHUB_SHA` is the synthetic merge commit (PR head merged
|
||||
# into base) — that SHA never shows up in the PR's git log.
|
||||
# `GITHUB_SHA` is also a reserved env var, so a step-level
|
||||
# override is silently ignored. Pass the PR head SHA under
|
||||
# a non-reserved name and read it from alchemy.run.ts.
|
||||
BUILD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }}
|
||||
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
if:
|
||||
${{ github.event_name == 'pull_request' && github.event.action == 'closed'
|
||||
}}
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Generate bot token
|
||||
id: bot-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
with:
|
||||
app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
|
||||
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: Safety Check
|
||||
run: |-
|
||||
if [ "${{ env.STAGE }}" = "prod" ]; then
|
||||
echo "ERROR: Cannot destroy prod environment in cleanup job"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Destroy Preview Environment
|
||||
working-directory: website
|
||||
run: bun alchemy destroy --stage ${{ env.STAGE }} --yes
|
||||
env:
|
||||
CLOUDFLARE_API_KEY: ${{ secrets.ADMIN_CLOUDFLARE_API_KEY }}
|
||||
CLOUDFLARE_EMAIL: ${{ secrets.ADMIN_CLOUDFLARE_EMAIL }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
|
||||
PULL_REQUEST: ${{ github.event.number }}
|
||||
GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }}
|
||||
@@ -1,180 +0,0 @@
|
||||
name: pr-package
|
||||
|
||||
# Publishes alchemy + better-auth + pr-package tarballs to the pr-package
|
||||
# service at pkg.ing on every push to main and every PR sync. On PR close,
|
||||
# deletes every tag we ever assigned for that PR so the underlying tarballs
|
||||
# become orphaned and the bucket cleans them up.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
env:
|
||||
PR_PACKAGE_HOST: pkg.ing
|
||||
NODE_VERSION: "24"
|
||||
|
||||
jobs:
|
||||
# ── Publish on push-to-main and PR sync. ──────────────────────────────────
|
||||
publish:
|
||||
if: github.event_name == 'push' || (github.event_name == 'pull_request' &&
|
||||
github.event.action != 'closed')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
# Build everything: tsdown bundles alchemy (bin/ + cli lib) and tsc -b
|
||||
# populates lib/ for the layer packages (better-auth, pr-package).
|
||||
# Their tarballs ship both src/ and lib/, and consumers in non-bun
|
||||
# runtimes resolve via the `import` condition → ./lib/index.js.
|
||||
- run: bun run build:packages
|
||||
|
||||
- name: Compute tags
|
||||
id: tags
|
||||
env:
|
||||
EVENT: ${{ github.event_name }}
|
||||
# `head_ref` for PRs (source branch), `ref_name` for push (e.g. "main").
|
||||
BRANCH: ${{ github.event_name == 'pull_request' && github.head_ref ||
|
||||
github.ref_name }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
# PR builds run on the merge commit by default; tag the actual head sha
|
||||
# so consumers can pin to a specific PR commit.
|
||||
SHA: ${{ github.event_name == 'pull_request' &&
|
||||
github.event.pull_request.head.sha || github.sha }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
short="${SHA:0:7}"
|
||||
long="$SHA"
|
||||
tags=("$short" "$long" "$BRANCH")
|
||||
if [ "$EVENT" = "pull_request" ]; then
|
||||
tags+=("pr-${PR_NUMBER}")
|
||||
fi
|
||||
json=$(printf '%s\n' "${tags[@]}" | jq -R . | jq -s -c .)
|
||||
echo "tags=$json" >> "$GITHUB_OUTPUT"
|
||||
echo "short=$short" >> "$GITHUB_OUTPUT"
|
||||
echo "Tags: $json"
|
||||
|
||||
# PR builds expire after 1 week; pushes to main omit the header and
|
||||
# fall back to the worker's defaultTtl (3 weeks).
|
||||
- name: Publish alchemy
|
||||
env:
|
||||
TOKEN: ${{ secrets.PR_PACKAGE_TOKEN }}
|
||||
TAGS: ${{ steps.tags.outputs.tags }}
|
||||
TTL: ${{ github.event_name == 'pull_request' && '1 week' || '' }}
|
||||
working-directory: packages/alchemy
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -f *.tgz
|
||||
bun pm pack --destination .
|
||||
tgz=$(ls *.tgz)
|
||||
echo "Publishing $tgz with tags $TAGS ttl=${TTL:-default}"
|
||||
curl -fsSL --show-error -X PUT \
|
||||
"https://${PR_PACKAGE_HOST}/projects/alchemy/packages" \
|
||||
-H "Authorization: Bearer ${TOKEN}" \
|
||||
-H "X-Tags: ${TAGS}" \
|
||||
${TTL:+-H "X-TTL: ${TTL}"} \
|
||||
-H "Content-Type: application/gzip" \
|
||||
--data-binary "@${tgz}"
|
||||
|
||||
- name: Publish better-auth
|
||||
env:
|
||||
TOKEN: ${{ secrets.PR_PACKAGE_TOKEN }}
|
||||
TAGS: ${{ steps.tags.outputs.tags }}
|
||||
TTL: ${{ github.event_name == 'pull_request' && '1 week' || '' }}
|
||||
working-directory: packages/better-auth
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -f *.tgz
|
||||
bun pm pack --destination .
|
||||
tgz=$(ls *.tgz)
|
||||
echo "Publishing $tgz with tags $TAGS ttl=${TTL:-default}"
|
||||
curl -fsSL --show-error -X PUT \
|
||||
"https://${PR_PACKAGE_HOST}/projects/@alchemy.run/better-auth/packages" \
|
||||
-H "Authorization: Bearer ${TOKEN}" \
|
||||
-H "X-Tags: ${TAGS}" \
|
||||
${TTL:+-H "X-TTL: ${TTL}"} \
|
||||
-H "Content-Type: application/gzip" \
|
||||
--data-binary "@${tgz}"
|
||||
|
||||
- name: Publish pr-package
|
||||
env:
|
||||
TOKEN: ${{ secrets.PR_PACKAGE_TOKEN }}
|
||||
TAGS: ${{ steps.tags.outputs.tags }}
|
||||
TTL: ${{ github.event_name == 'pull_request' && '1 week' || '' }}
|
||||
working-directory: packages/pr-package
|
||||
run: |
|
||||
set -euo pipefail
|
||||
rm -f *.tgz
|
||||
bun pm pack --destination .
|
||||
tgz=$(ls *.tgz)
|
||||
echo "Publishing $tgz with tags $TAGS ttl=${TTL:-default}"
|
||||
curl -fsSL --show-error -X PUT \
|
||||
"https://${PR_PACKAGE_HOST}/projects/@alchemy.run/pr-package/packages" \
|
||||
-H "Authorization: Bearer ${TOKEN}" \
|
||||
-H "X-Tags: ${TAGS}" \
|
||||
${TTL:+-H "X-TTL: ${TTL}"} \
|
||||
-H "Content-Type: application/gzip" \
|
||||
--data-binary "@${tgz}"
|
||||
|
||||
# PR-only: leave a sticky comment with the install URLs pinned to this
|
||||
# commit. Uses pkg.ing (the canonical short host), which serves both
|
||||
# the pretty alias paths and the underlying /projects/:project/tags/:tag
|
||||
# API directly.
|
||||
- name: Generate bot token
|
||||
if: github.event_name == 'pull_request'
|
||||
id: bot-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
with:
|
||||
app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
|
||||
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Comment on PR
|
||||
if: github.event_name == 'pull_request'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.bot-token.outputs.token }}
|
||||
REPO: ${{ github.repository }}
|
||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||
SHORT_SHA: ${{ steps.tags.outputs.short }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
MARKER="<!-- pr-package-comment -->"
|
||||
# Use `bun add <name>@<url>` instead of `bun add <url>`. Without an
|
||||
# explicit name, bun's resolver hits a DependencyLoop bug when the
|
||||
# consumer already has the same package name resolved from npm
|
||||
# (oven-sh/bun#5789, oven-sh/bun#17946). The aliased form bypasses
|
||||
# the buggy reconciliation path and works on fresh and existing
|
||||
# projects alike.
|
||||
BODY=$(printf '%s\n\nInstall the packages built from this commit:\n\n**alchemy**\n```sh\nbun add alchemy@https://pkg.ing/alchemy/%s\n```\n\n**@alchemy.run/better-auth**\n```sh\nbun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/%s\n```\n\n**@alchemy.run/pr-package**\n```sh\nbun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/%s\n```\n' "$MARKER" "$SHORT_SHA" "$SHORT_SHA" "$SHORT_SHA")
|
||||
|
||||
existing=$(gh api --paginate \
|
||||
"repos/${REPO}/issues/${PR_NUMBER}/comments" \
|
||||
--jq ".[] | select(.user.login == \"alchemy-version-bot[bot]\") | select(.body | startswith(\"${MARKER}\")) | .id" \
|
||||
| head -1)
|
||||
|
||||
if [ -n "$existing" ]; then
|
||||
gh api -X PATCH "repos/${REPO}/issues/comments/${existing}" -f body="$BODY"
|
||||
else
|
||||
gh api -X POST "repos/${REPO}/issues/${PR_NUMBER}/comments" -f body="$BODY"
|
||||
fi
|
||||
@@ -0,0 +1,42 @@
|
||||
name: pr-package
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
# `labeled` so adding the `force-ci` label re-triggers the run. We
|
||||
# intentionally do NOT listen to `closed` — pr-package tags persist
|
||||
# past PR close so existing install URLs keep resolving.
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
|
||||
# Reusable workflows can't widen permissions — the caller must grant
|
||||
# `pull-requests: write` for the sticky install-instructions comment.
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
pr-package:
|
||||
uses: alchemy-run/actions/.github/workflows/pr-package.yml@a18b368e044cb380a8c4904d5cfbccbc2798e768 # main
|
||||
with:
|
||||
# The bun workspace includes `distilled/packages/*` from the
|
||||
# distilled submodule, so the publish jobs must check it out.
|
||||
submodules: "true"
|
||||
# A submodule-pointer bump doesn't fall under any package dir, but
|
||||
# it changes what gets bundled — republish everything.
|
||||
rebuild-all-paths: |
|
||||
distilled
|
||||
cloudflare-tools
|
||||
# `|| true` keeps the cp harmless in packages whose pkg dir is
|
||||
# nested differently or that don't need the root README.
|
||||
build-command: "cp ../../README.md . 2>/dev/null || true; bun run build"
|
||||
# Every package's tsc build pulls in the alchemy -> distilled
|
||||
# project-reference chain (distilled/aws is huge), so all three
|
||||
# need the larger runner — same as distilled's own CI.
|
||||
packages: |
|
||||
[
|
||||
{ "dir": "packages/alchemy", "name": "alchemy", "runner": "ubuntu-22-large" },
|
||||
{ "dir": "packages/better-auth", "name": "@alchemy.run/better-auth", "runner": "ubuntu-22-large" },
|
||||
{ "dir": "packages/pr-package", "name": "@alchemy.run/pr-package", "runner": "ubuntu-22-large" }
|
||||
]
|
||||
secrets: inherit
|
||||
@@ -1,432 +1,51 @@
|
||||
name: Release NPM Package
|
||||
name: release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
channel:
|
||||
description: "Release channel"
|
||||
required: true
|
||||
type: choice
|
||||
default: beta
|
||||
options:
|
||||
- release
|
||||
- beta
|
||||
- alpha
|
||||
- tag
|
||||
spec:
|
||||
version:
|
||||
description: >-
|
||||
Channel-specific value. tag: REQUIRED, the explicit full version (e.g.
|
||||
2.0.0-experimental.1). release: REQUIRED, patch|minor|major or an
|
||||
explicit x.y.z. beta|alpha: optional, an integer N to force
|
||||
2.0.0-<channel>.N; leave blank to auto-increment.
|
||||
Release spec. Empty = next beta. `patch|minor|major` or `x.y.z`
|
||||
for a stable release. `beta` / `beta.N` / `alpha` / `alpha.N`
|
||||
for a prerelease. Anything else = tag release on
|
||||
`0.0.0-<name>`.
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
concurrency:
|
||||
group: release-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# Reusable workflows can't widen permissions — the caller must grant
|
||||
# `contents: write` (commit + tag) and `id-token: write` (npm OIDC).
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
|
||||
env:
|
||||
NODE_VERSION: "24"
|
||||
# Files produced by the bump job and consumed by every publish job + the
|
||||
# final commit job. Listed once here so additions stay in sync.
|
||||
BUMP_ARTIFACT_PATHS: |
|
||||
packages/alchemy/lib
|
||||
packages/alchemy/bin
|
||||
packages/alchemy/package.json
|
||||
packages/better-auth/package.json
|
||||
packages/better-auth/lib
|
||||
packages/pr-package/package.json
|
||||
packages/pr-package/lib
|
||||
bun.lock
|
||||
jobs:
|
||||
# ── Step 1: Compute the next version and stage the bump in-memory. ──
|
||||
# No git commit: we want a failed publish to leave no orphan commit
|
||||
# behind. The staged files ride to the publish jobs (and the final commit
|
||||
# job) as an artifact.
|
||||
bump:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.bump.outputs.version }}
|
||||
channel: ${{ inputs.channel }}
|
||||
sha: ${{ steps.sha.outputs.sha }}
|
||||
steps:
|
||||
- name: Validate inputs
|
||||
env:
|
||||
CHANNEL: ${{ inputs.channel }}
|
||||
SPEC: ${{ inputs.spec }}
|
||||
run: |
|
||||
case "$CHANNEL" in
|
||||
tag)
|
||||
if [ -z "$SPEC" ]; then
|
||||
echo "::error::'tag' channel requires an explicit version in 'spec' (e.g. 2.0.0-experimental.1)"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
release)
|
||||
if [ -z "$SPEC" ]; then
|
||||
echo "::error::'release' channel requires a 'spec' (patch|minor|major|x.y.z)"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
fetch-depth: 0
|
||||
|
||||
- id: sha
|
||||
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
registry-url: https://registry.npmjs.org/
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
- id: bump
|
||||
env:
|
||||
CHANNEL: ${{ inputs.channel }}
|
||||
SPEC: ${{ inputs.spec }}
|
||||
run: |
|
||||
if [ -n "$SPEC" ]; then
|
||||
VERSION=$(bun ./scripts/release/bump.ts "$CHANNEL" "$SPEC")
|
||||
else
|
||||
VERSION=$(bun ./scripts/release/bump.ts "$CHANNEL")
|
||||
fi
|
||||
echo "Resolved version: $VERSION (channel: $CHANNEL)"
|
||||
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# Build everything once, up front, against the bumped versions. Outputs
|
||||
# ride to every publish job as the `build-output` artifact so we don't
|
||||
# rebuild three times in parallel.
|
||||
- run: bun run build:packages
|
||||
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: bump-files
|
||||
path: ${{ env.BUMP_ARTIFACT_PATHS }}
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
|
||||
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
||||
with:
|
||||
name: build-output
|
||||
path: |
|
||||
packages/*/lib
|
||||
packages/*/bin
|
||||
if-no-files-found: error
|
||||
retention-days: 7
|
||||
include-hidden-files: true
|
||||
|
||||
# ── Step 2: Commit (bump + changelog) and tag BEFORE publishing.
|
||||
# Committing first means the publishable source of truth is the tagged
|
||||
# commit; publish jobs check it out by SHA. Durability: if a previous
|
||||
# attempt already committed and tagged but failed during npm publish, the
|
||||
# bump job's HEAD-tag detection reuses the existing version, and this job
|
||||
# detects HEAD is already at the tag and skips the commit/push.
|
||||
# Skipped for `tag` channel — those releases are intentionally uncommitted.
|
||||
commit-and-tag:
|
||||
needs: bump
|
||||
if: inputs.channel != 'tag'
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
sha: ${{ steps.commit.outputs.sha }}
|
||||
steps:
|
||||
- name: Generate bot token
|
||||
id: bot-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
with:
|
||||
app-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
|
||||
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
fetch-depth: 0
|
||||
token: ${{ steps.bot-token.outputs.token }}
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: bump-files
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
- name: Configure git
|
||||
run: |
|
||||
git config user.email "alchemy-version-bot[bot]@users.noreply.github.com"
|
||||
git config user.name "alchemy-version-bot[bot]"
|
||||
|
||||
- id: commit
|
||||
name: Commit bump + changelog, tag, push
|
||||
env:
|
||||
VERSION: ${{ needs.bump.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="v${VERSION}"
|
||||
|
||||
# Durability: if HEAD already points at the release tag (resumed
|
||||
# run after a previous attempt committed+tagged but publish
|
||||
# failed), there is nothing to do. Use HEAD as the publish SHA.
|
||||
HEAD_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || true)
|
||||
if [ "$HEAD_TAG" = "$TAG" ]; then
|
||||
echo "HEAD is already at ${TAG}; skipping commit/tag/push"
|
||||
SHA=$(git rev-parse HEAD)
|
||||
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Generate release notes; release-notes.ts is idempotent and
|
||||
# bails out if the tag heading is already present in CHANGELOG.md.
|
||||
bun scripts/release/release-notes.ts "${TAG}"
|
||||
|
||||
# Stage bump files (overwritten by the downloaded artifact) and
|
||||
# the new changelog entry as a single commit.
|
||||
git add packages/alchemy/package.json \
|
||||
packages/better-auth/package.json \
|
||||
packages/pr-package/package.json \
|
||||
bun.lock \
|
||||
CHANGELOG.md
|
||||
|
||||
if git diff --cached --quiet; then
|
||||
echo "No changes to commit (already on a release commit?)"
|
||||
else
|
||||
git commit -m "chore(release): ${VERSION}"
|
||||
fi
|
||||
|
||||
if ! git rev-parse --verify "refs/tags/${TAG}" >/dev/null 2>&1; then
|
||||
git tag -a "${TAG}" -m "Release ${TAG}"
|
||||
fi
|
||||
|
||||
git push origin HEAD
|
||||
if git ls-remote --exit-code --tags origin "refs/tags/${TAG}" >/dev/null 2>&1; then
|
||||
echo "Tag ${TAG} already on remote, skipping tag push"
|
||||
else
|
||||
git push origin "refs/tags/${TAG}"
|
||||
fi
|
||||
|
||||
SHA=$(git rev-parse HEAD)
|
||||
echo "sha=${SHA}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# ── Step 3a: Build and publish `alchemy`. ──
|
||||
# For non-tag channels, checkout the just-committed tagged SHA; for the
|
||||
# `tag` channel (no commit), checkout the bump's pre-bump SHA and rely
|
||||
# on the bump-files artifact instead.
|
||||
publish-alchemy:
|
||||
needs: [bump, commit-and-tag]
|
||||
if:
|
||||
always() && needs.bump.result == 'success' && (needs.commit-and-tag.result
|
||||
== 'success' || needs.commit-and-tag.result == 'skipped')
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
ref: ${{ needs.commit-and-tag.outputs.sha || needs.bump.outputs.sha }}
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
registry-url: https://registry.npmjs.org/
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Upgrade npm for OIDC trusted publishing
|
||||
run: |
|
||||
npm install -g npm@latest && npm --version
|
||||
sed -i '/always-auth/d' ~/.npmrc 2>/dev/null || true
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: bump-files
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: build-output
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
- run: bun scripts/release/publish-package.ts packages/alchemy ${{
|
||||
needs.bump.outputs.channel }}
|
||||
|
||||
# ── Step 3b: Build and publish `@alchemy.run/better-auth`. ──
|
||||
publish-better-auth:
|
||||
needs: [bump, commit-and-tag, publish-alchemy]
|
||||
if:
|
||||
always() && needs.bump.result == 'success' && (needs.commit-and-tag.result
|
||||
== 'success' || needs.commit-and-tag.result == 'skipped') &&
|
||||
needs.publish-alchemy.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
ref: ${{ needs.commit-and-tag.outputs.sha || needs.bump.outputs.sha }}
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
registry-url: https://registry.npmjs.org/
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Upgrade npm for OIDC trusted publishing
|
||||
run: |
|
||||
npm install -g npm@latest && npm --version
|
||||
sed -i '/always-auth/d' ~/.npmrc 2>/dev/null || true
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: bump-files
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: build-output
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
- run: bun scripts/release/publish-package.ts packages/better-auth ${{
|
||||
needs.bump.outputs.channel }}
|
||||
|
||||
# ── Step 3c: Build and publish `@alchemy.run/pr-package`. ──
|
||||
publish-pr-package:
|
||||
needs: [bump, commit-and-tag, publish-alchemy]
|
||||
if:
|
||||
always() && needs.bump.result == 'success' && (needs.commit-and-tag.result
|
||||
== 'success' || needs.commit-and-tag.result == 'skipped') &&
|
||||
needs.publish-alchemy.result == 'success'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
ref: ${{ needs.commit-and-tag.outputs.sha || needs.bump.outputs.sha }}
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
registry-url: https://registry.npmjs.org/
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- name: Upgrade npm for OIDC trusted publishing
|
||||
run: |
|
||||
npm install -g npm@latest && npm --version
|
||||
sed -i '/always-auth/d' ~/.npmrc 2>/dev/null || true
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: bump-files
|
||||
|
||||
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
|
||||
with:
|
||||
name: build-output
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
- run: bun scripts/release/publish-package.ts packages/pr-package ${{
|
||||
needs.bump.outputs.channel }}
|
||||
|
||||
# ── Step 4: Create GitHub Release and notify Discord. ──
|
||||
# Runs only after every publish job succeeded. The bump+changelog commit
|
||||
# and tag were already pushed by `commit-and-tag` before publishing.
|
||||
finalize:
|
||||
needs:
|
||||
[
|
||||
bump,
|
||||
commit-and-tag,
|
||||
publish-alchemy,
|
||||
publish-better-auth,
|
||||
publish-pr-package,
|
||||
]
|
||||
if: inputs.channel != 'tag'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
ref: ${{ needs.commit-and-tag.outputs.sha }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: |
|
||||
bun-${{ runner.os }}-
|
||||
|
||||
- run: bun install
|
||||
|
||||
- name: Create GitHub Release
|
||||
env:
|
||||
VERSION: ${{ needs.bump.outputs.version }}
|
||||
CHANNEL: ${{ needs.bump.outputs.channel }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: bun scripts/release/github-release.ts "v${VERSION}" "${CHANNEL}"
|
||||
|
||||
- name: Notify Discord
|
||||
if: success() && env.DISCORD_WEBHOOK != ''
|
||||
env:
|
||||
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
VERSION: ${{ needs.bump.outputs.version }}
|
||||
CHANNEL: ${{ needs.bump.outputs.channel }}
|
||||
run: bun scripts/release/discord-notify.ts "v${VERSION}" "${CHANNEL}"
|
||||
release:
|
||||
uses: alchemy-run/actions/.github/workflows/release.yml@a18b368e044cb380a8c4904d5cfbccbc2798e768 # main
|
||||
with:
|
||||
# The bun workspace includes `distilled/packages/*` from the
|
||||
# distilled submodule, so consumer checkouts must fetch it.
|
||||
submodules: "true"
|
||||
version: ${{ inputs.version }}
|
||||
repo: alchemy-run/alchemy
|
||||
current-version: "2.0.0"
|
||||
# Each package builds in its own publish job: the tsc build pulls
|
||||
# in the alchemy -> distilled project-reference chain (distilled/aws
|
||||
# is huge), which doesn't fit the bump job's ubuntu-latest box.
|
||||
build-mode: per-package
|
||||
# The alchemy package ships the repo-root README.md; copy it in
|
||||
# before the build so `bun pm pack` picks it up. Same trick the
|
||||
# legacy `publish:npm` script used (`|| true` keeps it harmless
|
||||
# elsewhere).
|
||||
build-command: "cp ../../README.md . 2>/dev/null || true; bun run build"
|
||||
packages: |
|
||||
[
|
||||
{ "dir": "packages/alchemy", "name": "alchemy", "runner": "ubuntu-22-large" },
|
||||
{ "dir": "packages/better-auth", "name": "@alchemy.run/better-auth", "runner": "ubuntu-22-large" },
|
||||
{ "dir": "packages/pr-package", "name": "@alchemy.run/pr-package", "runner": "ubuntu-22-large" }
|
||||
]
|
||||
secrets: inherit
|
||||
@@ -1,93 +0,0 @@
|
||||
name: test
|
||||
|
||||
# Smoke-tests `alchemy destroy → deploy → destroy` against each example.
|
||||
# `bun test:canary` drives the whole suite — it iterates both bun and pnpm
|
||||
# runtimes itself and publishes canary tarballs to pkg.ing before deploying.
|
||||
|
||||
on:
|
||||
# TODO(sam): re-enable these when they are running reliably and not polluting our account
|
||||
# push:
|
||||
# branches: [main]
|
||||
# pull_request:
|
||||
# types: [opened, reopened, synchronize]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
# Required for aws-actions/configure-aws-credentials to mint a session
|
||||
# via OIDC instead of long-lived AWS_ACCESS_KEY_ID secrets.
|
||||
id-token: write
|
||||
|
||||
env:
|
||||
PKGING_HOST: pkg.ing
|
||||
NODE_VERSION: "24"
|
||||
# PR runs use `pr-<n>` so each PR has its own isolated cloud namespace;
|
||||
# main pushes use `main`; manual `workflow_dispatch` runs use the branch
|
||||
# name. Forwarded to the smoke test as $SMOKE_STAGE.
|
||||
SMOKE_STAGE: ${{ github.event_name == 'pull_request' && format('pr-{0}',
|
||||
github.event.number) || (github.ref == 'refs/heads/main' && 'main' ||
|
||||
github.ref_name) }}
|
||||
|
||||
concurrency:
|
||||
# Cancel an in-progress run for the same PR (or branch) when a new push
|
||||
# arrives — the smoke suite mutates real cloud state, so two parallel
|
||||
# runs against the same SMOKE_STAGE would race.
|
||||
group: test-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
smoke:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
|
||||
with:
|
||||
node-version: ${{ env.NODE_VERSION }}
|
||||
|
||||
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- uses: pnpm/action-setup@0e279bb959325dab635dd2c09392533439d90093 # v6.0.8
|
||||
with:
|
||||
version: latest
|
||||
|
||||
- uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: bun-${{ runner.os }}-${{ hashFiles('bun.lock') }}
|
||||
restore-keys: bun-${{ runner.os }}-
|
||||
|
||||
# Bootstrap install so `bun test:canary` itself can resolve. The
|
||||
# test then runs its own `bun install` + `pnpm install` in canary
|
||||
# `beforeAll` after rewriting the catalog to pkg.ing tarballs, so
|
||||
# there's nothing pnpm-specific to wire up here.
|
||||
- run: bun install
|
||||
|
||||
# OIDC → short-lived AWS session. Exports AWS_ACCESS_KEY_ID,
|
||||
# AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, AWS_REGION; the
|
||||
# `output-credentials: true` flag also surfaces aws-account-id as a
|
||||
# step output (which we forward as `AWS_ACCOUNT_ID` below — the
|
||||
# action does NOT set it as an env var on its own).
|
||||
- id: aws-creds
|
||||
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # v6.1.1
|
||||
with:
|
||||
role-to-assume: ${{ vars.AWS_ROLE_ARN }}
|
||||
aws-region: ${{ vars.AWS_REGION }}
|
||||
output-credentials: true
|
||||
|
||||
- name: Smoke
|
||||
env:
|
||||
# AWS — `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
|
||||
# `AWS_SESSION_TOKEN`, `AWS_REGION` are already exported by
|
||||
# configure-aws-credentials; we only need to forward the account
|
||||
# id, which Alchemy's `loadFromEnv` requires when CI=true.
|
||||
AWS_ACCOUNT_ID: ${{ steps.aws-creds.outputs.aws-account-id }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.TEST_CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
|
||||
NEON_API_KEY: ${{ secrets.NEON_API_KEY }}
|
||||
PR_PACKAGE_TOKEN: ${{ secrets.PR_PACKAGE_TOKEN }}
|
||||
PKGING_HOST: ${{ env.PKGING_HOST }}
|
||||
SMOKE_STAGE: ${{ env.SMOKE_STAGE }}
|
||||
run: bun test:canary
|
||||
@@ -0,0 +1,136 @@
|
||||
name: website
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "website/**"
|
||||
- "packages/alchemy/**"
|
||||
- "bun.lock"
|
||||
- ".github/workflows/deploy.yml"
|
||||
pull_request:
|
||||
# `labeled` so adding `deploy-website` on an open PR triggers a
|
||||
# deploy without needing another push.
|
||||
types:
|
||||
- opened
|
||||
- reopened
|
||||
- synchronize
|
||||
- labeled
|
||||
- closed
|
||||
paths:
|
||||
- "website/**"
|
||||
- "packages/alchemy/**"
|
||||
- "bun.lock"
|
||||
- ".github/workflows/deploy.yml"
|
||||
|
||||
concurrency:
|
||||
group: deploy-website-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
env:
|
||||
STAGE: ${{ github.event_name == 'pull_request' && format('pr-{0}',
|
||||
github.event.number) || (github.ref == 'refs/heads/main' && 'prod' ||
|
||||
github.ref_name) }}
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
# Deploy on push-to-main and `workflow_dispatch` always. On PRs,
|
||||
# require BOTH:
|
||||
# - the PR is internal (forks can't access bot/Cloudflare secrets
|
||||
# so `create-github-app-token` would error immediately), AND
|
||||
# - the PR carries the `deploy-website` label (opt-in — most PRs
|
||||
# don't need a website preview, so default to skipping).
|
||||
if: >-
|
||||
github.event.action != 'closed' &&
|
||||
(github.event_name != 'pull_request' ||
|
||||
(github.event.pull_request.head.repo.full_name == github.repository &&
|
||||
contains(github.event.pull_request.labels.*.name, 'deploy-website')))
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
# `bun install` needs the distilled submodule (workspace member)
|
||||
submodules: true
|
||||
|
||||
# Mint a token for the alchemy-version-bot GitHub App so the PR
|
||||
# preview comment (created via GitHub.Comment in alchemy.run.ts)
|
||||
# posts under the bot's identity instead of `github-actions[bot]`.
|
||||
# Same App as release.yml — its installation scopes already cover
|
||||
# PR comments.
|
||||
- name: Generate bot token
|
||||
id: bot-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
with:
|
||||
client-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
|
||||
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
# Secrets (Cloudflare credentials, etc.) are injected by
|
||||
# `doppler run` from the `alchemy-v2` project — `prod` config on
|
||||
# main, `dev` config everywhere else.
|
||||
- name: Deploy
|
||||
working-directory: website
|
||||
run: bun alchemy deploy --stage "$STAGE" --yes
|
||||
env:
|
||||
PULL_REQUEST: ${{ github.event.number }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ startsWith(env.STAGE, 'prod') && secrets.PROD_CLOUDFLARE_API_TOKEN || secrets.TEST_CLOUDFLARE_API_TOKEN }}
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ startsWith(env.STAGE, 'prod') && secrets.PROD_CLOUDFLARE_ACCOUNT_ID || secrets.TEST_CLOUDFLARE_ACCOUNT_ID }}
|
||||
BUILD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
|
||||
GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }}
|
||||
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
if: >-
|
||||
github.event_name == 'pull_request' && github.event.action == 'closed' &&
|
||||
github.event.pull_request.head.repo.full_name == github.repository
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
# `bun install` needs the distilled submodule (workspace member)
|
||||
submodules: true
|
||||
|
||||
- name: Generate bot token
|
||||
id: bot-token
|
||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
||||
with:
|
||||
client-id: ${{ secrets.ALCHEMY_VERSION_BOT_ID }}
|
||||
private-key: ${{ secrets.ALCHEMY_VERSION_BOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
|
||||
|
||||
- name: Install Doppler CLI
|
||||
uses: dopplerhq/cli-action@4819d808ab99e5cde19a0637a16536a4038fad73 # v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
|
||||
- name: Safety Check
|
||||
run: |-
|
||||
if [ "${{ env.STAGE }}" = "prod" ]; then
|
||||
echo "ERROR: Cannot destroy prod environment in cleanup job"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Destroy Preview Environment
|
||||
working-directory: website
|
||||
run: >-
|
||||
doppler run --project "$DOPPLER_PROJECT" --config "$DOPPLER_CONFIG"
|
||||
-- bun alchemy destroy --stage "$STAGE" --yes
|
||||
env:
|
||||
DOPPLER_TOKEN: ${{ secrets.DOPPLER_TOKEN }}
|
||||
PULL_REQUEST: ${{ github.event.number }}
|
||||
GITHUB_TOKEN: ${{ steps.bot-token.outputs.token }}
|
||||
@@ -45,4 +45,9 @@ examples/cloudflare-worker/src/scratch.ts
|
||||
!/packages/alchemy/bin/cli.js
|
||||
.vendor/*
|
||||
.tmp
|
||||
pnpm-lock.yaml
|
||||
pnpm-lock.yaml
|
||||
!.vendor/distilled
|
||||
|
||||
.ai-workspace/
|
||||
/processes/
|
||||
.probe
|
||||
@@ -1,3 +1,13 @@
|
||||
[submodule "vendor/alchemy"]
|
||||
path = .vendor/alchemy
|
||||
url = git@github.com:alchemy-run/alchemy.git
|
||||
url = https://github.com/alchemy-run/alchemy.git
|
||||
# ~900MB reference-only checkout of the v1 repo — skipped by
|
||||
# `git submodule update --init` (CI included). Fetch explicitly with
|
||||
# `git submodule update --init --checkout .vendor/alchemy`.
|
||||
update = none
|
||||
[submodule "distilled"]
|
||||
path = distilled
|
||||
url = https://github.com/alchemy-run/distilled.git
|
||||
[submodule "cloudflare-tools"]
|
||||
path = cloudflare-tools
|
||||
url = https://github.com/alchemy-run/cloudflare-tools.git
|
||||
@@ -17,6 +17,8 @@
|
||||
"**/*.mdx",
|
||||
"**/*.md",
|
||||
"**/.vendor/**",
|
||||
"**/package.json"
|
||||
"**/package.json",
|
||||
"./distilled",
|
||||
"**/fixtures/chart/templates/**"
|
||||
]
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
{
|
||||
"diffEditor.renderSideBySide": false,
|
||||
"js/ts.experimental.useTsgo": true,
|
||||
"typescript.experimental.useTsgo": true,
|
||||
"typescript.tsdk": "node_modules/@typescript/native-preview/lib",
|
||||
"typescript.native-preview.tsdk": "node_modules/@typescript/native-preview/lib",
|
||||
// Point the editor at THIS workspace's pinned typescript@7 install. The
|
||||
// Effect diagnostics (e.g. `anyUnknownInErrorContext`) come from
|
||||
// `effect-tsgo patch` (run automatically on install via `prepare`), which
|
||||
// patches the workspace `node_modules/typescript` binary in place — the
|
||||
// editor must use the WORKSPACE version or no Effect diagnostics appear.
|
||||
// Opt in once per machine via Command Palette -> "TypeScript: Select
|
||||
// TypeScript Version" -> "Use Workspace Version".
|
||||
// (`enablePromptUseWorkspaceTsdk` below makes the editor prompt for this.)
|
||||
"typescript.tsdk": "node_modules/typescript/lib",
|
||||
"typescript.enablePromptUseWorkspaceTsdk": true,
|
||||
"typescript.preferences.importModuleSpecifier": "relative",
|
||||
"typescript.preferences.importModuleSpecifierEnding": "js",
|
||||
"typescript.preferences.importModuleSpecifierEnding": "ts",
|
||||
"oxc.enable": true,
|
||||
"oxc.lint.run": "onSave",
|
||||
"json.schemaDownload.enable": true,
|
||||
@@ -45,6 +50,12 @@
|
||||
"packages/alchemy/bin/**/*.js*": true,
|
||||
"packages/alchemy/bin/**/*.d*": true
|
||||
},
|
||||
"files.watcherExclude": {
|
||||
"**/distilled/**": true
|
||||
},
|
||||
"search.exclude": {
|
||||
"**/distilled/**": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.indentSize": 2,
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode"
|
||||
@@ -62,4 +73,4 @@
|
||||
"editor.defaultFormatter": "oxc.oxc-vscode"
|
||||
},
|
||||
"oxc.enable.oxfmt": true
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,9 @@ A Resource Provider implements the following Lifecycle Operations:
|
||||
- **Pre-Create** - an optional operation that creates a stub of a Resource before reconcile runs. Used to resolve circular dependencies — e.g. Function A and B depend on each other, so we create a stub of Function A first and then `reconcile` later wires up the real dependency.
|
||||
- **Reconcile** - converges a Resource's actual cloud state to the desired state described by the new Input Properties. Called for both first-time provisioning and subsequent updates. The provider receives `output` (current Attributes) and `olds` (previous Props) which may both be `undefined` on a greenfield create, both defined on an update, or `output !== undefined && olds === undefined` on an adoption. See the **Reconciler doctrine** section below for the required shape.
|
||||
- **Delete** - deletes an existing Resource. It must be designed as idempotent because it is always possible for state persistence to fail after the delete operation is called. If the resource doesn't exist during deletion, it should not be considered an error.
|
||||
- **Capability** - a runtime requirement of a Function (e.g. require `SQS.SendMessage` on a `SQS.Queue`). Each Capability is split into two parts: a `Binding.Service` (runtime SDK wrapper) and a `Binding.Policy` (deploy-time IAM/binding attachment).
|
||||
- **Binding.Service** - an Effect Service that wraps an SDK client and exposes a `.bind(resource)` method returning a typed callable for runtime use. Provided as a Layer on the **Function** Effect so it gets bundled into the Lambda/Worker. See [Binding](./packages/alchemy/src/Binding.ts).
|
||||
- **Binding.Policy** - an Effect Service that runs only at deploy time to attach IAM policies (AWS) or bindings (Cloudflare) to a Function's role/config. At runtime, `Binding.Policy` uses `Effect.serviceOption` so it gracefully becomes a no-op when the layer is not provided. Policy layers are provided on the **Stack** via `AWS.providers()()`, not on the Function.
|
||||
- **Binding** - data attached to a Resource via `resource.bind(data)`. A Binding is a `{ context: PolicyContext, data: BindingData }` tuple that is collected on the Stack during plan/deploy. Bindings enable circular references between Resources — the `Binding.Policy` calls `ctx.bind({ policyStatements: [...] })` on the target Function, which records the binding data on the Stack. The Resource Provider then receives the resolved binding data in its `reconcile` lifecycle operation via the `bindings` parameter.
|
||||
- **Capability** - a runtime requirement of a Function (e.g. require read access to an `R2Bucket`, or `SQS.SendMessage` on a `SQS.Queue`). A Capability is modeled as one or more `Binding.Service`s. Where the underlying API distinguishes access levels, split it into `Read` / `Write` / `ReadWrite` services (see the **Read/Write/ReadWrite binding convention** below); otherwise a single service suffices. Each service typically ships two interchangeable implementations: a native **binding** (`*Binding`) and a token-scoped **HTTP** client (`*Http`).
|
||||
- **Binding.Service** - an Effect Service that exposes a `.bind(resource)` method returning a typed runtime client. Its outer (init) Effect resolves the host Function/Worker and its environment, then registers the deploy-time binding — environment variables, IAM policy statements (AWS), or a native Cloudflare binding — by calling ``host.bind`${resource}`(data)``, guarded by `!globalThis.__ALCHEMY_RUNTIME__` so it is a no-op once running inside the deployed Function/Worker. Provided as a Layer on the **Function/Worker** Effect so it gets bundled into the Lambda/Worker. See [Binding](./packages/alchemy/src/Binding.ts).
|
||||
- **Binding** - data attached to a target Function/Worker via ``host.bind`${resource}`(data)`` from inside a `Binding.Service`. The binding data is collected on the Stack during plan/deploy. Bindings enable circular references between Resources — e.g. a capability binds `{ policyStatements: [...] }` (AWS) or `{ bindings: [...] }` (Cloudflare) onto the host. The Resource Provider then receives the resolved binding data in its `reconcile` lifecycle operation via the `bindings` parameter.
|
||||
- **Binding Contract** - the shape of data a Resource accepts from Bindings. For example, a Lambda Function accepts `{ env?: Record<string, any>, policyStatements?: PolicyStatement[] }` because it needs environment variables and IAM policies. A Cloudflare Worker accepts `{ bindings: Worker.Binding[] }` for its native binding system. The Binding Contract is declared as the fourth type parameter on the `Resource` interface. See [Lambda Function](./packages/alchemy/src/AWS/Lambda/Function.ts) and [Cloudflare Worker](./packages/alchemy/src/Cloudflare/Workers/Worker.ts).
|
||||
- **Dependency** - Resources depend on other Resources through two mechanisms:
|
||||
- Output Properties of one Resource passed as Input Properties to another Resource (non-circular, directed acyclic graph)
|
||||
@@ -39,7 +38,7 @@ A Resource Provider implements the following Lifecycle Operations:
|
||||
- **Physical Name** - a unique name for a Resource, e.g. `my-bucket-1234567890`. It is usually best to generate them using the built-in createPhysicalName utility function which generates
|
||||
- **Logical ID** - the logical ID identifying a resource within a Stack, e.g. `my-bucket`. It is stable across creates, updates, deletes and replaces.
|
||||
- **Instance ID** - a unique identifier for an instance of a Resource. It is stable across creates, updates and deletes. It changes when a resource is replaced. It is truncated and used as the suffix of the Physical Name.
|
||||
- **Event Source** - a special kind of Binding between a Function and a Resource that produces events that invoke the Function, e.g. `SQS.QueueEventSource`. Event Sources are implemented as Binding.Service + Binding.Policy pairs, where the attach logic creates/updates the event source mapping via the cloud provider API.
|
||||
- **Event Source** - a special kind of Binding between a Function and a Resource that produces events that invoke the Function, e.g. `SQS.QueueEventSource`. Implemented as a `Binding.Service` whose init Effect both registers the runtime event listener on the host and, at deploy time, yields the event-source mapping resource (or calls the cloud provider API to create/update it).
|
||||
- **Replacement** - the process of replacing a Resource with a new one. A new one is created, downstream dependencies are updated with the new reference, and then the old one is deleted. Or, the old one is deleted first and then the new one is created.
|
||||
- **Dependency Violation** - an error that some APIs call when an operation cannot be performed because a dependency is not met. E.g. you cannot delete an EIP until the NAT Gateway it is attached to is deleted. Lifecycle operations typically retry Dependency Violations.
|
||||
- **Eventual Consistency** - create/update/delete operations can be eventually consistent leading to a variety of failure modes. For example, a Resource may be created but not yet available for use, or a Resource may be deleted but still appear in the console. Errors caused by eventual consistency should be retried, and lifecycle operations/tests should be carefully designed to wait for consistency before proceeding.
|
||||
@@ -49,25 +48,42 @@ A Resource Provider implements the following Lifecycle Operations:
|
||||
|
||||
# File System Conventions
|
||||
|
||||
Each Service's Resources follow the same pattern. Resource contract and provider are co-located in the same file. Capabilities (Binding.Service + Binding.Policy) are in separate files named after the capability.
|
||||
Each Service's Resources follow the same pattern. Resource contract and provider are co-located in the same file. Each Capability lives in its own file(s) named after the capability and access level (`Binding.Service` contract + the `*Binding` / `*Http` implementations).
|
||||
|
||||
```sh
|
||||
# source files
|
||||
packages/alchemy/src/{Cloud}/{Service}/index.ts # re-exports all resources and capabilities
|
||||
packages/alchemy/src/{Cloud}/{Service}/index.ts # re-exports resources, capability contracts, and impl layers
|
||||
packages/alchemy/src/{Cloud}/{Service}/{Resource}.ts # resource contract + resource provider
|
||||
packages/alchemy/src/{Cloud}/{Service}/{Capability}.ts # Binding.Service + Binding.Policy for a capability
|
||||
packages/alchemy/src/{Cloud}/{Service}/{Capability}.ts # Binding.Service contract + runtime client interface
|
||||
# test files
|
||||
packages/alchemy/test/{Cloud}/{Service}/{Resource}.test.ts
|
||||
# docs (auto-generated from source-code JSDoc - DO NOT manually edit)
|
||||
website/src/content/docs/providers/{Cloud}/{Resource}.md # API reference, generated by `bun generate:api-reference`
|
||||
```
|
||||
|
||||
A capability that exposes distinct access levels is split into a contract per level plus interchangeable native-binding and HTTP implementations, with shared scaffolding kept in *un-exported* helper files (see the **Read/Write/ReadWrite binding convention** below). For example, the Cloudflare R2 bucket capability:
|
||||
|
||||
```sh
|
||||
packages/alchemy/src/Cloudflare/R2/BucketTypes.ts # shared types + error (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketRead.ts # BucketRead Binding.Service + ReadBucketClient (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketWrite.ts # BucketWrite Binding.Service + WriteBucketClient (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketReadWrite.ts # BucketReadWrite Binding.Service + ReadWriteBucketClient (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketBinding.ts # shared worker-binding scaffolding (NOT exported from index)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketReadBinding.ts # ReadBucketBinding layer + makeRead (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketWriteBinding.ts # WriteBucketBinding layer + makeWrite (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketReadWriteBinding.ts # ReadWriteBucketBinding layer (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketHttp.ts # shared HTTP/token scaffolding (NOT exported from index)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketReadHttp.ts # ReadBucketHttp layer (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketWriteHttp.ts # WriteBucketHttp layer (exported)
|
||||
packages/alchemy/src/Cloudflare/R2/BucketReadWriteHttp.ts # ReadWriteBucketHttp layer (exported)
|
||||
```
|
||||
|
||||
Examples of actual paths:
|
||||
|
||||
```sh
|
||||
packages/alchemy/src/AWS/S3/Bucket.ts # S3 Bucket resource + provider
|
||||
packages/alchemy/src/AWS/S3/GetObject.ts # S3 GetObject Binding.Service + Binding.Policy
|
||||
packages/alchemy/src/AWS/S3/PutObject.ts # S3 PutObject Binding.Service + Binding.Policy
|
||||
packages/alchemy/src/AWS/S3/GetObject.ts # S3 GetObject capability (Binding.Service)
|
||||
packages/alchemy/src/AWS/S3/PutObject.ts # S3 PutObject capability (Binding.Service)
|
||||
packages/alchemy/src/AWS/SQS/Queue.ts # SQS Queue resource + provider
|
||||
packages/alchemy/src/AWS/SQS/SendMessage.ts # SQS SendMessage capability
|
||||
packages/alchemy/src/AWS/Kinesis/Stream.ts # Kinesis Stream resource + provider
|
||||
@@ -79,6 +95,75 @@ packages/alchemy/src/AWS/EC2/Vpc.ts # VPC resource + provider
|
||||
packages/alchemy/src/AWS/EC2/Subnet.ts # Subnet resource + provider
|
||||
```
|
||||
|
||||
# The Resource Factory Process
|
||||
|
||||
Alchemy resource coverage is produced as a **software factory**: fleets of agents implement and live-test IaC resources in waves, and every API mismatch the tests surface is fed back as a patch to distilled. The factory was used to take Cloudflare from 36 to 239 cataloged resources (250 test files / 600+ test cases, 1000+ patched operations) and is the template for every future provider.
|
||||
|
||||
## The flywheel
|
||||
|
||||
```
|
||||
catalog ──> implement ──> live test ──> unmatched error / wrong schema?
|
||||
^ │
|
||||
│ v
|
||||
update statuses <── regenerate service <── patch distilled
|
||||
```
|
||||
|
||||
1. **Catalog** — fan out research agents over the provider's distilled service modules (one batch per thematic group). Each agent reads the generated SDK (`distilled/packages/{cloud}/src/services/{service}.ts`), cross-references the vendor API docs, and writes a self-contained design spec to `processes/{Cloud}/catalog/{service}.md`: resources, namespaces, props/attrs with replacement rules, lifecycle-to-operation mapping, scope (account/zone), testability, priority. The coordinator aggregates a machine-readable `summary.json` + human `INDEX.md` that tracks `implemented | partial | missing` per resource — this is the factory's order book.
|
||||
2. **Implement + test** in waves (below). Tests run against the real cloud (`bun run test --profile testing`); zone-scoped tests use the standing test zone (`alchemy-test-2.us` via `findZoneByName`).
|
||||
3. **Patch the SDK, never the consumer** — every `UnknownCloudflareError`, out-of-union status error, or wrong request/response schema found by a test becomes a patch under `distilled/packages/{cloud}/patches/{service}/{op}.json` (see the Typed Error Doctrine section). Regenerate only that service. The typed union improves for every future consumer of the SDK — that is the flywheel's output.
|
||||
4. **Update the catalog** statuses after each wave and pick the next batch from the order book. Repeat until everything left is documented as out of scope (deprecated APIs, billing/data-only endpoints, closed-beta, needs-external-systems).
|
||||
|
||||
## Orchestration rules (the coordinator)
|
||||
|
||||
- **One workflow at a time**, ~12 concurrent agents (cap ≈ CPU cores − 2). Two parallel workflows double throughput but also double crash blast-radius — only do it when the machine and budget clearly allow.
|
||||
- **One agent per distilled service.** Service ownership is the unit of isolation: only the owner may touch `patches/{service}/` and regenerate `src/services/{service}.ts`, so generator runs never race. An agent may own several resources of its service; a very large same-service backlog (e.g. zero-trust) runs as a **sequential chain** of agents inside the workflow, in parallel with all other services.
|
||||
- **Shared-file discipline.** `Providers.ts` and the provider barrel `index.ts` are edited by every agent: single minimal insertions only, re-read and retry on edit conflict, never rewrite wholesale.
|
||||
- **`Layer.mergeAll` ceiling.** Keep `Providers.ts`'s provider layers in *nested* `Layer.mergeAll` groups (~90 entries each). A flat ~200-argument call exceeds tsc's variadic inference and **silently drops the tail layers** from the inferred union, producing baffling `Provider<X> is not assignable to StackServices` cascades across every test file.
|
||||
- **Crash resilience.** Word every task as *assess-first*: "partial work may exist from an interrupted run — list your dirs, read existing files, check registration, FINISH rather than rewrite." Completed agent results are banked in the workflow journal even if the workflow dies; the coordinator recovers them from `journal.jsonl` and re-dispatches only the lost tasks.
|
||||
- **The coordinator (not agents) does**: the authoritative type-check, distilled lib rebuilds, combined verification runs, catalog/index updates, cross-cutting fixes (shared-file restructures, Effect-version API migrations), and deterministic mass transforms (mechanical codemods are scripted centrally, not fanned out).
|
||||
- **Monitor for stalls**: an agent transcript that hasn't been written for ~5 minutes with no child test process is stalled — kill and re-dispatch; don't wait.
|
||||
|
||||
## Resource budget: one type-checker for the whole factory
|
||||
|
||||
`tsc -b` over the workspace is expensive; dozens of agents running it concurrently thrashes the machine (and concurrent `tsbuildinfo` writes race). Instead:
|
||||
|
||||
- **Agents are banned** from running `tsc` or `bun run build` (root or distilled) in any form. The coordinator owns type-checking and runs a one-shot `bun tsc -b` at wave boundaries.
|
||||
- **The test runner resolves distilled from `src/*.ts` directly, NOT the built `lib/`** (`alchemy-test` runs in plain bun, which resolves the `bun` export condition natively). So a regenerated service is **immediately test-visible** the moment `bun scripts/generate.ts --service {service}` (+ oxlint/oxfmt) finishes — there is nothing to rebuild and **nothing to wait for**. Do NOT sleep and do NOT gate a test re-run on a build after regenerating. This applies to response-schema patches as well as error-tag-only patches.
|
||||
|
||||
## Speed doctrine: never wait on a hang
|
||||
|
||||
- Run tests with `bun run test` (works from the repo root or `packages/alchemy`; suite paths are relative to `packages/alchemy`, e.g. `test/Cloudflare/...`). Wrap **every** test invocation in a hard kill: `timeout 240 bun run test <suite> --profile testing`. Hitting the wall **is** the failure — read the partial output (and the run's log under `.alchemy/log/test/`), find the hang (unbounded retry, infinite pagination, the engine deadlock below), fix the root cause. Never just re-run hoping. The runner also prints the currently-running tests whenever nothing finishes for 10s — use that list to identify the hang.
|
||||
- Per-test timeout ≤ 90–120s (`{ timeout: ... }` on the test, or `--timeout` for the whole run). A suite needing more than ~3–5 minutes total is a bug.
|
||||
- Every `Effect.retry`/`Effect.repeat` is bounded: `times ≤ 8–10`, total backoff under ~45–60s. Never poll for asynchronous provisioning slower than ~90s — skipIf-gate instead.
|
||||
- **Known engine bug**: a deploy that *replaces* a resource while simultaneously *removing* its old dependency deadlocks. Keep both dependencies deployed across replacement steps in tests (see `test/Cloudflare/R2/BucketEventNotification.test.ts`).
|
||||
- **Three-iteration budget**: if a suite is not green after ~3 fix iterations and the blocker is platform behavior (entitlement, slow async provisioning, beta API), implement fully, skipIf-gate with the typed tag and exact error, verify a skip-clean run, and report honestly. Do not burn an hour on one resource.
|
||||
|
||||
## Entitlement gating pattern
|
||||
|
||||
Most enterprise/plan-gated resources are still fully implementable; only the live lifecycle is gated:
|
||||
|
||||
1. **Probe once** against the real API to capture the exact rejection (code + message). If it surfaces as an untyped catch-all, patch distilled first so the entitlement error is a typed tag (e.g. `MagicTransitNotOnboarded` code 1012, `SaasQuotaNotAllocated` code 1404, `AdvancedCertificateManagerRequired` code 1450).
|
||||
2. Keep an **ungated probe test** that asserts the typed tag is returned — this proves both the patch and the gating are correct, forever, at near-zero cost.
|
||||
3. skipIf-gate the full lifecycle behind an env var (`CLOUDFLARE_TEST_MAGIC_TRANSIT=1`, `CLOUDFLARE_TEST_DLP=1`, …) so an entitled account can run it unchanged.
|
||||
4. Record the testability verdict (`yes | limited | no`) and the exact error in the catalog notes.
|
||||
|
||||
Deprecated APIs (superseded by Rulesets etc.), billing/subscription objects, pure data-APIs, and closed-beta endpoints are *documented as out of scope* in `INDEX.md` rather than implemented.
|
||||
|
||||
## What every agent task prompt must include
|
||||
|
||||
A wave task prompt is a contract. Include, every time:
|
||||
|
||||
1. The **distilled service the agent owns** and the resources to build (with namespace + directory).
|
||||
2. **Assess-first** instruction (finish partial work, don't rewrite).
|
||||
3. The reading list: this file's Reconciler doctrine + Typed Error Doctrine, the catalog spec, the distilled service module + existing patches, current exemplar resources/tests (account-level CRUD, zone singleton capture-and-restore, observe-before-delete), and the registration files.
|
||||
4. The **type-check/build ban** (above) — agents never run `tsc`/`bun run build`; the coordinator owns type-checking.
|
||||
5. The **speed doctrine** (above) verbatim — agents rediscover unbounded waits otherwise.
|
||||
6. The **Typed Error Doctrine** hard rule with the patch-regenerate command for *their* service only.
|
||||
7. Registration discipline for the shared files, including the nested-mergeAll note.
|
||||
8. Test requirements: `test.provider`, start **and** end with `stack.destroy()`, deterministic names (engine default or constant), out-of-band verification via distilled, typed wait-until-gone, replacement coverage where applicable.
|
||||
9. Known footguns: `diff` receives `Input<Props>` — narrow with `isResolved(news)` before property access; never `Input<T>` in declared Props; Effect 4 APIs (`Effect.result` + `Result.isSuccess/isFailure`, not `Effect.either`/`effect/Either`); request-schema patch keys are camelCase, response keys are wire snake_case; fixtures (CSRs, PEMs, JWKS) are generated once and checked in as constants, never at test time.
|
||||
10. A **structured result schema**: `{ service, resources, testsPassed, testCommand, files, patches (with reasons), skippedTests (with exact errors), notes }` — the coordinator aggregates these into the catalog.
|
||||
|
||||
# Documentation Generation
|
||||
|
||||
**Source of truth:** The source code is the single source of truth for all API documentation. JSDoc comments in `packages/alchemy/src/**/*.ts` are extracted and used to generate the public API reference markdown.
|
||||
@@ -185,9 +270,11 @@ This generates:
|
||||
- Show real-world patterns like error handling, combining with other resources
|
||||
- Use descriptive titles that explain what the example demonstrates
|
||||
|
||||
# Workflow
|
||||
# Workflow (per-service inner loop)
|
||||
|
||||
Development of Alchemy-Effect Resources is heavily pattern based. Each Service has many Resources that each have 0 oor more Capabilities and Event Sources. When working on a new Service, the following steps should be followed.
|
||||
This is the inner loop that each factory agent (see **The Resource Factory Process** above) executes for the service it owns — it applies equally when a single engineer brings up one service by hand.
|
||||
|
||||
Development of Alchemy-Effect Resources is heavily pattern based. Each Service has many Resources that each have 0 or more Capabilities and Event Sources. When working on a new Service, the following steps should be followed.
|
||||
|
||||
1. Research the AWS Service and identify its Resources, Identifier Types, Structs, Capabilities, and Event Sources. Refer to the corresponding Terraform Provider, Pulumi Provider, and CloudFormation docs for that service (use the provided tools specifically for searching these docs for services and resources).
|
||||
|
||||
@@ -348,53 +435,92 @@ export interface Function extends Resource<
|
||||
> {}
|
||||
```
|
||||
|
||||
:::tip
|
||||
Some Input Property types are wrapped in an `Input<T>`, but not all are. Only properties that may need to be references to another resource's Output Attribute. E.g. common use-cases are `Input<VpcId>`, `Input<QueueUrl>`, `Tags: Record<string, Input<string>>`.
|
||||
:::
|
||||
|
||||
:::warning
|
||||
For fields like `name: string`, `bucketName: string`, `bucketPrefix: string`, you should not use `Input<string>` because these properties need to be statically knowable in the `diff` function.
|
||||
**Never use `Input<T>` in declared Props interfaces.** Declare plain types (`zoneId: string`, `ips?: string[]`, nested structs with plain fields). The `Resource` machinery applies `Input` automatically — and `Input<T>` is deep (it recursively distributes over arrays and object fields), so even nested references like `memberships: [{ identifier: zone.zoneId }]` accept `Output<string>` without any explicit annotation. Writing `Input<string>` in a Props interface produces a redundant double-wrap.
|
||||
|
||||
```ts
|
||||
// ❌ wrong
|
||||
export interface LoadBalancerProps {
|
||||
zoneId: Input<string>;
|
||||
}
|
||||
|
||||
// ✅ right — the engine wraps automatically and deeply
|
||||
export interface LoadBalancerProps {
|
||||
zoneId: string;
|
||||
}
|
||||
```
|
||||
|
||||
`Input<T>` in a *function signature* is still legitimate when the function genuinely receives unresolved values at runtime (e.g. helpers that resolve tag maps, or `DurableObjectNamespace.from(scriptName: Input<string>)`).
|
||||
:::
|
||||
|
||||
7. Implement the Capabilities as `Binding.Service` + `Binding.Policy` pairs in `packages/alchemy/src/{Cloud}/{Service}/{Capability}.ts`.
|
||||
7. Implement each Capability as a `Binding.Service` in `packages/alchemy/src/{Cloud}/{Service}/{Capability}.ts`.
|
||||
|
||||
Each capability has two parts:
|
||||
A single `Binding.Service` does both halves of a capability in one Effect:
|
||||
|
||||
- **`Binding.Service`** — runtime SDK wrapper, provided on the Function Effect (bundled into Lambda/Worker)
|
||||
- **`Binding.Policy`** — deploy-time IAM policy attachment, provided on the Stack via `AWS.providers()()` (never bundled)
|
||||
- **Init (outer) Effect** — resolves the host Function/Worker and its environment, then registers the deploy-time binding by calling ``host.bind`${resource}`(data)`` (environment variables + IAM policy statements for AWS, native bindings for Cloudflare), guarded by `!globalThis.__ALCHEMY_RUNTIME__` so it becomes a no-op once running inside the deployed Function/Worker.
|
||||
- **Runtime (inner) callable** — the typed client returned to the caller; its methods require `Alchemy.RuntimeContext` (see below).
|
||||
|
||||
There is no separate deploy-time policy object and nothing to register in `providers()` — the implementation layer is provided directly on the Function/Worker Effect.
|
||||
|
||||
Read through the established capabilities to understand the pattern:
|
||||
|
||||
- [S3 GetObject](./packages/alchemy/src/AWS/S3/GetObject.ts) — `Binding.Service` + `Binding.Policy`
|
||||
- [S3 PutObject](./packages/alchemy/src/AWS/S3/PutObject.ts) — `Binding.Service` + `Binding.Policy`
|
||||
- [SQS SendMessage](./packages/alchemy/src/AWS/SQS/SendMessage.ts) — `Binding.Service` + `Binding.Policy`
|
||||
- [DynamoDB GetItem](./packages/alchemy/src/AWS/DynamoDB/GetItem.ts) — `Binding.Service` + `Binding.Policy`
|
||||
- [Kinesis PutRecord](./packages/alchemy/src/AWS/Kinesis/PutRecord.ts) — `Binding.Service` + `Binding.Policy`
|
||||
- [Lambda InvokeFunction](./packages/alchemy/src/AWS/Lambda/InvokeFunction.ts) — `Binding.Service` + `Binding.Policy`
|
||||
- [S3 GetObject](./packages/alchemy/src/AWS/S3/GetObject.ts), [S3 PutObject](./packages/alchemy/src/AWS/S3/PutObject.ts)
|
||||
- [SQS SendMessage](./packages/alchemy/src/AWS/SQS/SendMessage.ts), [DynamoDB GetItem](./packages/alchemy/src/AWS/DynamoDB/GetItem.ts)
|
||||
- [Kinesis PutRecord](./packages/alchemy/src/AWS/Kinesis/PutRecord.ts), [Lambda InvokeFunction](./packages/alchemy/src/AWS/Lambda/InvokeFunction.ts)
|
||||
- Access-split Cloudflare capabilities: [R2 Bucket](./packages/alchemy/src/Cloudflare/R2/), [KV Namespace](./packages/alchemy/src/Cloudflare/KV/), [Queue](./packages/alchemy/src/Cloudflare/Queue/)
|
||||
|
||||
For Event Sources, see:
|
||||
|
||||
- [SQS QueueEventSource](./packages/alchemy/src/AWS/SQS/QueueEventSource.ts)
|
||||
- [S3 BucketEventSource](./packages/alchemy/src/AWS/S3/BucketEventSource.ts)
|
||||
|
||||
The `Binding.Policy` implementation calls `ctx.bind({ policyStatements: [...] })` on the target Function, which records binding data on the Stack. The `Binding.Service` implementation resolves the Policy via `yield* Policy(resource)`, then returns a typed callable that wraps the SDK client. At runtime, the Policy is not provided and becomes a no-op.
|
||||
|
||||
Each capability exports four things:
|
||||
Each capability exports its contract plus one or more implementation layers:
|
||||
|
||||
```ts
|
||||
// 1. The Binding.Service class
|
||||
// 1. The Binding.Service class (the contract) + a bind alias for ergonomic use
|
||||
export class PutRecord extends Binding.Service<...>()("AWS.Kinesis.PutRecord") {}
|
||||
export const putRecord = PutRecord.bind;
|
||||
|
||||
// 2. The Binding.Service Live layer (provided on Function Effect)
|
||||
export const PutRecordLive = Layer.effect(PutRecord, ...);
|
||||
|
||||
// 3. The Binding.Policy class
|
||||
export class PutRecordPolicy extends Binding.Policy<...>()("AWS.Kinesis.PutRecord") {}
|
||||
|
||||
// 4. The Binding.Policy Live layer (provided on Stack via AWS.providers()())
|
||||
export const PutRecordPolicyLive = Layer.effect(PutRecordPolicy, ...);
|
||||
// 2. The implementation layer — resolves the host + environment, registers the
|
||||
// binding inline (guarded by __ALCHEMY_RUNTIME__), and returns the runtime client.
|
||||
export const PutRecordLive = Layer.effect(
|
||||
PutRecord,
|
||||
Effect.gen(function* () {
|
||||
const host = yield* Worker; // or the AWS Function host
|
||||
const env = yield* WorkerEnvironment; // or Lambda.FunctionEnvironment
|
||||
return Effect.fn(function* (stream: Stream) {
|
||||
if (!globalThis.__ALCHEMY_RUNTIME__) {
|
||||
// AWS: { policyStatements: [...] } Cloudflare: { bindings: [...] }
|
||||
yield* host.bind`${stream}`({ policyStatements: [...] });
|
||||
}
|
||||
return /* typed runtime client closing over `env` */;
|
||||
});
|
||||
}),
|
||||
);
|
||||
```
|
||||
|
||||
Provide the implementation layer on the **Function/Worker** Effect (`Effect.provide(PutRecordLive)`).
|
||||
|
||||
### Read/Write/ReadWrite binding convention
|
||||
|
||||
When a capability's API distinguishes access levels (R2 `head`/`get`/`list` vs `put`/`delete`; KV `get`/`getWithMetadata`/`list` vs `put`/`delete`), split it into three `Binding.Service`s so consumers can request least privilege, each with two interchangeable implementations:
|
||||
|
||||
- **`{Cap}Read.ts` / `{Cap}Write.ts` / `{Cap}ReadWrite.ts`** — the `Binding.Service` class + runtime client interface + a `bind` alias (e.g. `ReadBucket = BucketRead.bind`). `ReadWrite`'s client interface `extends` both the `Read` and `Write` client interfaces.
|
||||
- **`{Cap}Binding.ts`** — *shared* worker-binding scaffolding: a `make{Cap}Binding({ makeClient })` that resolves `WorkerEnvironment` + host `Worker`, registers the native binding via ``host.bind`${resource}`(...)`` (guarded by `__ALCHEMY_RUNTIME__`), plus a `make{Cap}Helpers` returning the low-level `raw`/`use`/`tryPromise` primitives. **Do NOT export this file from `index.ts`.**
|
||||
- **`{Cap}ReadBinding.ts` / `{Cap}WriteBinding.ts` / `{Cap}ReadWriteBinding.ts`** — `Layer.effect` implementations over the native binding (`ReadBucketBinding`, …) plus the `makeRead`/`makeWrite` client builders. `ReadWrite` composes the read + write builders.
|
||||
- **`{Cap}Http.ts`** — *shared* HTTP/token scaffolding: a `makeHttp{Cap}Binding({ permissionGroups, makeClient })` that mints a scoped `AccountApiToken` with the right permission groups, binds the token's `value`/`accountId` into the Worker, and resolves the per-operation scope. **Do NOT export this file from `index.ts`.**
|
||||
- **`{Cap}ReadHttp.ts` / `{Cap}WriteHttp.ts` / `{Cap}ReadWriteHttp.ts`** — `Layer.effect` implementations over the cloud's HTTP API (`ReadBucketHttp`, …). Operations the HTTP API can't support `Effect.die` with a typed error.
|
||||
|
||||
Rules:
|
||||
|
||||
- **Keep shared scaffolding internal.** Re-export only the contracts, the per-level layers, and the client builders from `index.ts`. Exporting `{Cap}Binding.ts`/`{Cap}Http.ts` leaks generic helper names into the flat `Cloudflare`/`AWS` namespace and collides across services.
|
||||
- **Use service-unique helper names.** Avoid generic `makeHelpers`/`makeWrite`; prefix with the capability (`makeQueueHelpers`, `makeWriteQueueClient`) so re-exported builders never clash.
|
||||
- **Namespace the public surface.** Export the service both flatly and as a namespace (`export * as KV from "./KV/index.ts"`) so callers write `Cloudflare.KV.ReadWriteNamespace(ns)`. The bind-alias callables drop the redundant service prefix (`ReadWriteNamespace`, not `ReadWriteKVNamespace`); the underlying classes/interfaces keep it (`KVNamespaceReadWrite`, `ReadWriteKVNamespaceClient`).
|
||||
- **No resource-level `bind`.** The Resource is plain `Resource<T>("Cloud.Type")` with no `bind:` field; callers bind via the namespaced capability, not `resource.bind`.
|
||||
- **Single-mode capabilities stay single.** A producer-only capability (e.g. Cloudflare Queue's send-only producer, which has no runtime read) ships just the `Write` service — don't invent a `Read` the runtime can't satisfy. The HTTP impl can still cover both directions where the API does.
|
||||
|
||||
Reference: [Cloudflare R2 Bucket](./packages/alchemy/src/Cloudflare/R2/), [KV Namespace](./packages/alchemy/src/Cloudflare/KV/), [Queue](./packages/alchemy/src/Cloudflare/Queue/).
|
||||
|
||||
### Runtime-only methods: color with `Alchemy.RuntimeContext`
|
||||
|
||||
The runtime callable returned by a `Binding.Service` (the inner Effect inside `.bind(resource)`'s return) **must** declare `Alchemy.RuntimeContext` as a requirement. This is how Alchemy models "this code can only run inside a deployed Function/Worker" at the type level — analogous to a colored function.
|
||||
@@ -427,10 +553,14 @@ Rules:
|
||||
|
||||
Why this matters: consumers can build cloud-agnostic services on top of bindings using `Layer.effect(Tag, ...)` without polluting their service interface with `WorkerEnvironment`. See [Layers concept](./website/src/content/docs/concepts/layers.mdx).
|
||||
|
||||
After implementing, register the Policy in `AWS.providers()()`:
|
||||
After implementing, re-export the contract and implementation layers from the service's `index.ts` (but keep the shared `{Cap}Binding.ts`/`{Cap}Http.ts` scaffolding un-exported).
|
||||
|
||||
- Add the `*PolicyLive` layer to `bindings()` in [Providers.ts](./packages/alchemy/src/AWS/Providers.ts)
|
||||
- Re-export from the service's `index.ts`
|
||||
### Isolate scope vs request scope (runtime bridges)
|
||||
|
||||
**Layer construction is isolate-scoped; the effects built services expose are request-scoped.**
|
||||
|
||||
- **At layer build / Worker init (instance scope)** a layer MAY resolve services and env/config, register listeners and `bind` declarations, assemble `Effect.fn` clients, and perform one-shot I/O that produces a plain cached value (e.g. fetch a secret and cache it for a client). It MUST NOT acquire **disposable** resources — connections, pools, streams, anything with a finalizer (`Layer.scoped` / `Effect.acquireRelease` / init-level `Effect.addFinalizer`) — or retain I/O-backed *objects* or promises across events (workerd pins them to the creating request's IoContext). The runtime bridges (Worker event, Durable Object call, Workflow run, Lambda invoke) build the layer stack **once per instance** on the first event. Instance finalizers run at instance shutdown at best: **never on workerd** (no teardown hook), and in a **best-effort 500 ms SIGTERM window on Lambda** (the generated entry registers an internal extension to obtain it and closes the instance scope on SIGTERM; not delivered on hard failures). Server processes (Containers, ECS Tasks) close their root scope on graceful exit.
|
||||
- **At request scope**, anything needing I/O or cleanup is an effect requiring `Scope.Scope`, acquired lazily per call. Every bridge provides a fresh `Scope` per event; `Effect.addFinalizer` in a handler attaches to it and runs after the response (registered with `ctx.waitUntil` on workerd; settled inline on Lambda). Per-request memoization keys on the scope object (`yield* Effect.scope`) — see [Drizzle/Postgres.ts](./packages/alchemy/src/Drizzle/Postgres.ts) for the canonical WeakMap pattern. One pool/socket per event is the law on workerd (sockets are IoContext-pinned); Hyperdrive is the cross-request pooler.
|
||||
|
||||
:::tip
|
||||
If you need to know what AWS region or account ID the resource is being created/updated in, you can use this inside any of the lifecycle operations.
|
||||
@@ -447,8 +577,7 @@ You should favor getting the region/account INSIDE the lifecycle operations inst
|
||||
|
||||
```ts
|
||||
reconcile: Effect.fn(function* ({ id, news, output, session }) {
|
||||
const region = yield* Region;
|
||||
const accountId = yield* Account;
|
||||
const { accountId, region } = yield* AWSEnvironment.current;
|
||||
});
|
||||
```
|
||||
|
||||
@@ -541,6 +670,53 @@ See the [VPC Smoke Test](./test/AWS/EC2/Vpc.smoke.test.ts) for an example.
|
||||
|
||||
11. Add the resource-level JSDoc (`@section` + `@example` blocks) and field-level JSDoc on each prop/attribute on the source `.ts` file. Then run `bun generate:api-reference` to refresh `website/src/content/docs/providers/{Cloud}/{Resource}.md`. Do NOT manually edit the generated markdown.
|
||||
|
||||
# Typed Error Doctrine (distilled)
|
||||
|
||||
Every error a distilled operation can produce in practice MUST be a tagged error in that operation's **type-level** error union. The catch-all classes (`UnknownCloudflareError`, `CloudflareHttpError`, and the status-derived classes like `NotFound`/`BadRequest` that distilled leaves out of the typed union) exist only to *surface* gaps — they are never something alchemy code handles.
|
||||
|
||||
**When you hit an unmatched error** (an `UnknownCloudflareError`, or you find yourself wanting to check `CloudflareHttpError.status` or an out-of-union `NotFound`), the fix is ALWAYS a distilled patch, never a catch in alchemy:
|
||||
|
||||
1. Note the error's code / status / message from the failure output.
|
||||
2. Add or extend `distilled/packages/cloudflare/patches/{service}/{operation}.json` with a **meaningful, resource-specific tag** (e.g. `WidgetNotFound`, not a bare `NotFound`):
|
||||
|
||||
```json
|
||||
{ "errors": { "WidgetNotFound": [{ "code": 1234 }] } }
|
||||
```
|
||||
|
||||
Matchers may combine `code`, `status`, and `message` (`{ "includes": "..." }` / `{ "matches": "..." }`) — e.g. `[{ "status": 400, "message": { "includes": "snippet not found" } }]` when Cloudflare misuses 400 for a missing resource. Prefer matching the Cloudflare error `code` when one exists; fall back to `status` + `message` otherwise.
|
||||
|
||||
3. Regenerate ONLY that service: `cd distilled/packages/cloudflare && bun scripts/generate.ts --service {service}` (then `bun oxlint --fix src/services/{service}.ts && bun oxfmt --write src/services/{service}.ts`).
|
||||
4. Handle the now-typed tag in alchemy code and re-run the tests.
|
||||
|
||||
**Forbidden patterns** — these defeat the type system and must never appear in alchemy code or tests:
|
||||
|
||||
```ts
|
||||
// ❌ unknown-typed structural predicates
|
||||
const isNotFoundError = (e: unknown): boolean =>
|
||||
Predicate.hasProperty(e, "_tag") && (e as { _tag: unknown })._tag === "NotFound";
|
||||
|
||||
// ❌ widening casts to duck-typed tags
|
||||
Effect.retry({ while: (e) => (e as { _tag?: string })._tag === "Forbidden" })
|
||||
|
||||
// ❌ catching the catch-all HTTP error by status
|
||||
Effect.catchIf((e) => e._tag === "CloudflareHttpError" && e.status === 404, ...)
|
||||
```
|
||||
|
||||
**Required patterns** — fully inferred, no casts, no `unknown`:
|
||||
|
||||
```ts
|
||||
// ✅ catch a typed tag
|
||||
.pipe(Effect.catchTag("WidgetNotFound", () => Effect.void))
|
||||
|
||||
// ✅ retry while a typed tag is observed (e is the op's inferred error union)
|
||||
Effect.retry({ while: (e) => e._tag === "WidgetNotFound", schedule, times })
|
||||
|
||||
// ✅ multiple tags
|
||||
Effect.catchTag(["WidgetNotFound", "Gone"], () => Effect.succeed(undefined))
|
||||
```
|
||||
|
||||
If `Effect.catchTag("SomeTag", ...)` fails to typecheck, that is the signal that distilled's union is missing the error — patch distilled (step 2 above); do not loosen the alchemy-side types.
|
||||
|
||||
# Test Fixtures for Effect-Native Workers / Functions
|
||||
|
||||
To test runtime behavior of an Effect-native Worker, Workflow, Lambda, etc., write a **fixture** that defines the Worker/Function with the bindings under test and exposes one HTTP route per behavior, then write a **test** that deploys the fixture once via `beforeAll` and drives it over HTTP.
|
||||
@@ -569,10 +745,10 @@ import { Gateway } from "./gateway.ts";
|
||||
export default class TestWorker extends Cloudflare.Worker<TestWorker>()(
|
||||
"TestWorker",
|
||||
{
|
||||
main: import.meta.filename,
|
||||
main: import.meta.url,
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const aiGateway = yield* Cloudflare.AiGateway.bind(Gateway);
|
||||
const aiGateway = yield* Cloudflare.AI.QueryGateway(Gateway);
|
||||
|
||||
return {
|
||||
fetch: Effect.gen(function* () {
|
||||
@@ -584,7 +760,7 @@ export default class TestWorker extends Cloudflare.Worker<TestWorker>()(
|
||||
return HttpServerResponse.text("ok");
|
||||
}),
|
||||
};
|
||||
}).pipe(Effect.provide(Cloudflare.AiGatewayBindingLive)),
|
||||
}).pipe(Effect.provide(Cloudflare.AI.QueryGatewayBinding)),
|
||||
) {}
|
||||
```
|
||||
|
||||
@@ -596,8 +772,8 @@ Compose a `Stack` that deploys the fixture, share one deploy across the file wit
|
||||
// Service.test.ts
|
||||
import * as Alchemy from "@/index.ts";
|
||||
import * as Cloudflare from "@/Cloudflare";
|
||||
import * as Test from "@/Test/Vitest";
|
||||
import { expect } from "@effect/vitest";
|
||||
import * as Test from "@/Test/Alchemy";
|
||||
import { expect } from "alchemy-test";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schedule from "effect/Schedule";
|
||||
import * as HttpClient from "effect/unstable/http/HttpClient";
|
||||
@@ -643,7 +819,7 @@ Notes:
|
||||
- `afterAll.skipIf(!!process.env.NO_DESTROY)(destroy(Stack))` is the standard cleanup — set `NO_DESTROY=1` locally to keep the deployment around between runs while iterating.
|
||||
- Always retry the first request (`Schedule.exponential("500 millis")`) — fresh workers.dev URLs and Lambda function URLs take a few seconds to start serving 200s.
|
||||
- For POST: use `client.post(url)` for empty bodies, or `HttpClient.execute(HttpClientRequest.post(url).pipe(HttpClientRequest.bodyJsonUnsafe(body)))` for typed bodies.
|
||||
- **Never use `while (Date.now() < deadline)` loops to poll** for an async side effect (a workflow status, a cron fire, a queue drain, eventual-consistency read, etc.). Use `Effect.repeat` with a `Schedule` and an `until` predicate so the polling participates in the Effect runtime — tracing, interruption, and error propagation work correctly, and the intent is declarative. Cap iterations with `times: N` (or a bounded schedule) so the test fails fast instead of running until the vitest timeout:
|
||||
- **Never use `while (Date.now() < deadline)` loops to poll** for an async side effect (a workflow status, a cron fire, a queue drain, eventual-consistency read, etc.). Use `Effect.repeat` with a `Schedule` and an `until` predicate so the polling participates in the Effect runtime — tracing, interruption, and error propagation work correctly, and the intent is declarative. Cap iterations with `times: N` (or a bounded schedule) so the test fails fast instead of running until the test timeout:
|
||||
|
||||
```ts
|
||||
// good — declarative, bounded, interruption-safe
|
||||
@@ -655,7 +831,7 @@ Notes:
|
||||
}),
|
||||
);
|
||||
|
||||
// bad — opaque loop, ignores interruption, leaks into vitest timeout
|
||||
// bad — opaque loop, ignores interruption, leaks into the test timeout
|
||||
let value: Value | undefined;
|
||||
const deadline = Date.now() + 180_000;
|
||||
while (Date.now() < deadline) {
|
||||
@@ -669,7 +845,7 @@ Notes:
|
||||
|
||||
## Reference implementations
|
||||
|
||||
- Cloudflare AiGateway — [worker fixture](./packages/alchemy/test/Cloudflare/AiGateway/worker.ts) + [test](./packages/alchemy/test/Cloudflare/AiGateway/AiGateway.test.ts) (the deploy+fetch case lives at the bottom of the file)
|
||||
- Cloudflare.AI.Gateway — [worker fixture](./packages/alchemy/test/Cloudflare/AI/fixtures/TestWorker.ts) + [test](./packages/alchemy/test/Cloudflare/AI/Gateway.test.ts) (the deploy+fetch case lives at the bottom of the file)
|
||||
- Cloudflare D1Connection — [worker fixture](./packages/alchemy/test/Cloudflare/D1/d1-worker.ts) + [test](./packages/alchemy/test/Cloudflare/D1/D1Binding.test.ts)
|
||||
- Cloudflare Workflow — [workflow fixture](./packages/alchemy/test/Cloudflare/Workers/fixtures/test-workflow.ts) + [worker fixture](./packages/alchemy/test/Cloudflare/Workers/fixtures/workflow-worker.ts) + [test](./packages/alchemy/test/Cloudflare/Workers/Workflow.test.ts)
|
||||
- Cloudflare Cron Trigger — [worker + DO fixture](./packages/alchemy/test/Cloudflare/Workers/fixtures/cron-worker.ts) + [test](./packages/alchemy/test/Cloudflare/Workers/CronEventSource.test.ts) (cron handler writes to a DO; test polls a fetch route with `Effect.repeat` until the scheduled handler fires)
|
||||
@@ -700,7 +876,92 @@ Always run type checking before committing changes:
|
||||
bun tsc -b
|
||||
```
|
||||
|
||||
This runs the TypeScript compiler in build mode, which checks all projects in the workspace. This is critical because CI will fail if there are type errors.
|
||||
This runs the TypeScript compiler in build mode, which checks all projects in the workspace (including the distilled packages, which are project references). This is critical because CI will fail if there are type errors.
|
||||
|
||||
## Running tests
|
||||
|
||||
`packages/alchemy/test` runs on **alchemy-test** (`packages/alchemy-test`), our own single-process, Effect-native test runner. The CLI is vitest/bun-test compatible: positional paths (files or directories) and `-t` work the same way.
|
||||
|
||||
There is exactly ONE entry point: `bun run test <options>`. It works identically from the repo root and from `packages/alchemy` (the root script just cds into `packages/alchemy`); suite paths are always relative to `packages/alchemy`. Compose the flags you need — there are no per-variant package scripts. NOTE: `bun run test`, not `bun test` — the latter invokes bun's own built-in test runner.
|
||||
|
||||
```bash
|
||||
# a suite, against the real cloud
|
||||
bun run test test/Cloudflare/{Service}/{Resource}.test.ts --profile testing
|
||||
|
||||
# a directory, filtered by test name
|
||||
bun run test test/Cloudflare/Workers -t "cron" --profile testing
|
||||
|
||||
# positional args that aren't real paths are file-name substring filters
|
||||
bun run test Bucket --profile testing # every *Bucket* test file
|
||||
|
||||
# skip the slow tests (replaces the old FAST=1 env prefix)
|
||||
bun run test --fast --profile testing
|
||||
|
||||
# interactive TUI (humans only — never in an agent shell)
|
||||
bun run test --tui
|
||||
```
|
||||
|
||||
(`examples/` still use plain `bun test`.)
|
||||
|
||||
### Cleaning leaked test resources
|
||||
|
||||
If an interrupted live-cloud test leaves resources behind, do **not** add
|
||||
test-specific API cleanup helpers, adoption workarounds, or alternate names to
|
||||
make the test pass. Clean the testing account with the account-wide teardown
|
||||
command, then rerun the failing test:
|
||||
|
||||
```bash
|
||||
bun nuke
|
||||
bun clear:state --profile testing
|
||||
```
|
||||
|
||||
Lifecycle tests should continue to validate normal stack ownership and cleanup;
|
||||
they must not silently adopt or directly delete leaked resources from earlier
|
||||
runs.
|
||||
|
||||
Additional flags beyond vitest:
|
||||
|
||||
| Flag | Default | Purpose |
|
||||
| ----------------- | ------- | ------------------------------------------------------------- |
|
||||
| `-t <regex>` | — | Test-name pattern (regex, like bun/vitest) tested against the full nested title (`file > describes > name`), so any fragment matches regardless of nesting. An invalid regex degrades to a literal substring instead of erroring. Remember to escape regex metacharacters when filtering literally: `-t "create \(default\)"` |
|
||||
| `--profile <name>` | — | Sets `ALCHEMY_PROFILE` before any test module is imported. Use `--profile testing` for live-cloud suites instead of an `ALCHEMY_PROFILE=testing` env prefix |
|
||||
| `--fast` | off | Sets `FAST=1` before imports — suites `skipIf(process.env.FAST)` their slow tests (long-provisioning resources, smoke tests). Replaces the `FAST=1` env prefix |
|
||||
| `--timeout <ms>` | 120000 | Default per-test timeout |
|
||||
| `--retry <n>` | 2 | Re-runs of a failing test body (use `--retry 0` when debugging) |
|
||||
| `--concurrency <n\|unbounded>` | 32 | Files running concurrently (one bun process, no forks). Bounded by default — unbounded saturates the event loop on large suites and produces spurious 0ms `beforeAll` timeouts |
|
||||
| `--sequential` | off | Run tests within each file sequentially |
|
||||
| `--tui` | off | Opt-in interactive TUI (default is line-per-test output) |
|
||||
|
||||
Output behavior (plain mode, the default):
|
||||
|
||||
- The collection phase (importing every test file, ~45s for the full suite) reports `collecting N/TOTAL test files (elapsed) <current file>` — repainted in place on a TTY, printed every 5s otherwise. A run that appears stuck before any test starts is almost always just collecting; if it really is stuck, the line names the file whose import hangs.
|
||||
- One line per test as it finishes, prefixed with a `[done/total]` progress counter so the remaining count is visible; a **failing test prints its error and captured output inline** immediately.
|
||||
- Passing tests' output is swallowed on the console — but **every** test's output (passes included) is streamed to a per-run log at **`.alchemy/log/test/{timestamp}-pid{pid}.log`** (relative to the cwd), so concurrent runs in different terminals never trample each other. The absolute path (with line/KB counts) is printed at the end of every run (`Full log: …`) — read that file when you need the complete record, e.g. a passing test's deploy output or a hang's partial log. The file is appended live, so it's readable mid-run; logs older than a week are pruned automatically (by stat mtime).
|
||||
- If nothing finishes for 10s, the runner prints the list of currently-running tests with elapsed times — the first place to look when a run seems hung.
|
||||
- Exit code is non-zero if any test failed.
|
||||
|
||||
Runner semantics to know:
|
||||
|
||||
- Everything runs in ONE bun process: files run concurrently (respecting `describe.sequential`), imports of all test files happen up-front (they must be lazy and pure — registration only, no top-level side effects beyond `Test.make`/`describe`/`test`).
|
||||
- Tests that mutate process-global state (e.g. `process.env.PATH`) must pass `{ exclusive: true }` in the test options to take the whole-process write lock.
|
||||
- The harness (`alchemy-test` package) provides `describe`, `it`/`test` (incl. `it.effect`/`it.live`), hooks, `layer`, `expect`, and `assert` — the codemod `scripts/codemod-alchemy-test.ts` migrates vitest imports and is idempotent.
|
||||
- The runner runs in plain bun, so distilled resolves from `src/*.ts` via the `bun` export condition — a regenerated service is test-visible immediately, no `lib/` rebuild required.
|
||||
|
||||
## The convergence loop: nuke → test → census → fix-fleet
|
||||
|
||||
Ironing out the AWS suite is an iterative loop, driven by a coordinator, that terminates only when the suite is green AND the account is clean for **two consecutive rounds**. "Green" alone is not the bar — a passing test that leaves cloud resources behind is a provider bug by definition.
|
||||
|
||||
Each iteration:
|
||||
|
||||
0. **Clean slate** — first run `aws sso login` (the alchemy `testing` profile and the raw `aws` CLI ride the same SSO session; an expired token mid-round breaks the pipeline with auth errors — only escalate to a human if the login doesn't complete automatically). Then `bun nuke --yes` (deletes every alchemy-tagged cloud resource; `scripts/nuke.sh` already spares state buckets, SSO roles, and AWS-managed singletons) then `bun alchemy state clear ./stacks/nuke.ts --profile testing --yes`. Never overlap nuke with a running suite. Plain `bun clear:state` lacks the profile and dies on expired Cloudflare OAuth; nuke without `--yes` hangs on an interactive confirm in non-interactive shells.
|
||||
1. **Full suite, bounded** — `bun run test test/AWS --profile testing`. The runner defaults to `--concurrency 32`; NEVER override it to `unbounded` on a full-suite run: all ~775 files' `beforeAll` deploys start at once, the event loop saturates, and hundreds of fake 0ms `beforeAll TimeoutError` failures drown the real signal (heap is ~8.5 GB regardless of N — the constraint is CPU, not memory). Target ≤10 min wall-clock, hard cap 128; measured 32 → ~21 min clean. The saturation tell is `beforeAll` failures at 0ms; real failures fail slow. If the cap can't reach 10 min, the residual is individual slow files — skipIf-gate them per the speed doctrine.
|
||||
2. **Leak census** — `bun nuke --dry-run` after the suite; diff against the pre-suite baseline. Worklist = **failed services ∪ leaking services** (a service can pass green and still leak). Leave the leaked resources LIVE as forensic evidence for the fix agents; carry-over holdouts that survive repeated nuke passes (stuck deletes) go on the worklist too — their delete path is the bug.
|
||||
3. **Fix-fleet workflow** — one agent per service on the worklist (account-singleton services — CloudTrail, Config, SecurityHub, GuardDuty, ControlTower, IdentityCenter — run as a sequential chain; everything else fans out). Each agent gets its exact failures, its leak inventory, and this root-cause priority: **provider bug > distilled patch > test fix** — never paper over a provider leak in the test. Each agent runs ONLY its own suite (`timeout 240 bun run test test/AWS/{Service} --profile testing`), audits its tests for non-deterministic names (rely on PhysicalName auto-naming; random data in message payloads/idempotency tokens is fine), verifies zero orphans from its service via out-of-band distilled list/describe calls, and reports a structured result. Agents never run tsc/build and never run the account-wide nuke.
|
||||
4. **Gate** — the coordinator runs the one-shot `bun tsc -b`, fixes cross-cutting fallout, commits the iteration (+ distilled submodule bump when patches were made), and loops back to 0. Terminate on two consecutive iterations of green-suite + census reduced to documented-undeletable residue (e.g. BackupSearch terminal records, Contributor-Insights rules with no delete API, keys in scheduled deletion).
|
||||
|
||||
## Multi-agent sessions: the coordinator owns type-checking
|
||||
|
||||
When many agents work concurrently (see **The Resource Factory Process**), do NOT let each agent run `bun tsc -b` — concurrent runs thrash the machine and race on `tsbuildinfo`. Agents never invoke the compiler; the coordinator runs a one-shot `bun tsc -b` at wave boundaries as the authoritative type check.
|
||||
|
||||
## Build Commands
|
||||
|
||||
@@ -852,3 +1113,31 @@ Example PR description (BAD — do not do this):
|
||||
### Summary ← no, summary needs no heading
|
||||
Persist the user's theme...
|
||||
```
|
||||
|
||||
# Blog / Release Notes Conventions
|
||||
|
||||
Release blog posts live in `website/src/content/docs/blog/` named
|
||||
`YYYY-MM-DD-beta-NN.md` (date = the release date).
|
||||
|
||||
**Frontmatter `title` format:** `<version> - <short title>`, e.g.
|
||||
`2.0.0-beta.45 - Config & RPC Workers`. The title renders in the
|
||||
blog TOC sidebar, so the descriptive suffix must be short — a few
|
||||
words that fit neatly on one line. Lead with the version so the
|
||||
list stays sorted and scannable.
|
||||
|
||||
Writing style (match the existing beta posts, e.g.
|
||||
[beta.41](./website/src/content/docs/blog/2026-05-20-beta-41.md),
|
||||
[beta.44](./website/src/content/docs/blog/2026-05-22-beta-44.md)):
|
||||
|
||||
- **Lean, concise, zero-fluff.** Illustrate each new
|
||||
feature/fix and link to the relevant docs/tutorials/guides.
|
||||
- Read each PR in the release's changelog to understand what
|
||||
actually changed before writing.
|
||||
- Lead with the headline features (one `##` heading each, with a
|
||||
short code snippet or `diff`), then fold the long tail into an
|
||||
`## Also in this release` bullet list.
|
||||
- Put breaking changes in a `:::caution` callout at the top.
|
||||
- Cite PRs inline as `([#NNN](…/pull/NNN))` and credit external
|
||||
contributors by name.
|
||||
- End with a `## Where to go next` list of doc links plus the
|
||||
CHANGELOG and compare links.
|
||||
@@ -1,6 +1,6 @@
|
||||
<div align="center">
|
||||
|
||||
<a href="https://v2.alchemy.run">
|
||||
<a href="https://alchemy.run">
|
||||
<img src="./images/readme-hero.png" alt="Alchemy — Infrastructure as Effects" width="360" />
|
||||
</a>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
**Infrastructure-as-Effects** — cloud infrastructure and application logic as a single, type-safe [Effect](https://effect.website) program.
|
||||
|
||||
[Docs](https://v2.alchemy.run) · [Tutorial](https://v2.alchemy.run/tutorial/part-1) · [Examples](./examples) · [Discord](https://discord.gg/jwKw8dBJdN)
|
||||
[Docs](https://alchemy.run) · [Tutorial](https://alchemy.run/tutorial/part-1) · [Examples](./examples) · [Discord](https://discord.gg/jwKw8dBJdN)
|
||||
|
||||
</div>
|
||||
|
||||
@@ -21,13 +21,13 @@
|
||||
A Worker bound to a R2 bucket and serving objects from it:
|
||||
|
||||
```typescript
|
||||
const Bucket = Cloudflare.R2Bucket("bucket");
|
||||
const Bucket = Cloudflare.R2.Bucket("bucket");
|
||||
|
||||
export default Cloudflare.Worker(
|
||||
"api",
|
||||
{ main: import.meta.path },
|
||||
{ main: import.meta.url },
|
||||
Effect.gen(function* () {
|
||||
const bucket = yield* Cloudflare.R2Bucket.bind(Bucket);
|
||||
const bucket = yield* Cloudflare.R2.ReadWriteBucket(Bucket);
|
||||
return {
|
||||
fetch: Effect.gen(function* () {
|
||||
const request = yield* HttpServerRequest;
|
||||
@@ -35,30 +35,45 @@ export default Cloudflare.Worker(
|
||||
return HttpServerResponse.stream(object!.body);
|
||||
})
|
||||
};
|
||||
}),
|
||||
}).pipe(Effect.provide(Cloudflare.R2.ReadWriteBucketBinding)),
|
||||
);
|
||||
```
|
||||
|
||||
One `bind()` wires the binding, env var, and typed connection — at deploy time and at runtime.
|
||||
One `ReadWriteBucket(Bucket)` call wires the binding, env var, and typed client — at deploy time and at runtime.
|
||||
|
||||
---
|
||||
|
||||
- **One program, one language.** Resources, Lambdas/Workers, IAM, and SDKs live in the same Effect program — no YAML, no second runtime.
|
||||
- **Bindings, not glue code.** `S3.GetObject.bind(bucket)` wires the IAM policy, env var, and a typed SDK call in a single line.
|
||||
- **Bindings, not glue code.** `S3.GetObject(bucket)` wires the IAM policy, env var, and a typed SDK call in a single line.
|
||||
- **Errors in the type system.** Every cloud API failure is a tagged Effect error you handle — or don't — on purpose.
|
||||
- **AWS + Cloudflare today.** S3, SQS, DynamoDB, Kinesis, Lambda, EC2 / Workers, R2, D1, Durable Objects, Containers.
|
||||
- **Same code, every stage.** Local dev, `plan` / `deploy`, smoke tests, and CI all share one mental model.
|
||||
|
||||
```sh
|
||||
bun add alchemy effect
|
||||
bun add alchemy@next effect@next
|
||||
```
|
||||
|
||||
## GitHub Action
|
||||
|
||||
Use the root action to deploy `prod` from `main`, deploy PR previews as
|
||||
`staging-{number}`, and destroy PR previews when the PR closes:
|
||||
|
||||
```yaml
|
||||
- uses: alchemy-run/alchemy@v1
|
||||
env:
|
||||
CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
|
||||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
The workflow must install the `alchemy` CLI before this action runs.
|
||||
|
||||
## Bootstrap with an AI coding agent
|
||||
|
||||
Paste this into Claude Code, Cursor, or any agent that can fetch a URL:
|
||||
|
||||
```
|
||||
You are an Alchemy expert. Read https://v2.alchemy.run/llms.txt to load the
|
||||
You are an Alchemy expert. Read https://alchemy.run/llms.txt to load the
|
||||
full documentation index, then act as my pair on this project.
|
||||
|
||||
Goal: help me set up, build, test, and deploy a cloud application with
|
||||
@@ -72,11 +87,11 @@ dependencies or breaking conventions.
|
||||
|
||||
## Learn more
|
||||
|
||||
- [What is Alchemy?](https://v2.alchemy.run/what-is-alchemy) — the framework in 2 minutes
|
||||
- [Getting Started](https://v2.alchemy.run/getting-started) — your first Stack
|
||||
- [Tutorial](https://v2.alchemy.run/tutorial/part-1) — five-part walkthrough to a tested, CI-deployed app
|
||||
- [What is Alchemy?](https://alchemy.run/what-is-alchemy) — the framework in 2 minutes
|
||||
- [Getting Started](https://alchemy.run/getting-started) — your first Stack
|
||||
- [Tutorial](https://alchemy.run/tutorial/part-1) — five-part walkthrough to a tested, CI-deployed app
|
||||
- [Examples](./examples) — runnable projects on AWS and Cloudflare
|
||||
- [llms.txt](https://v2.alchemy.run/llms.txt) — agent-ready documentation index
|
||||
- [llms.txt](https://alchemy.run/llms.txt) — agent-ready documentation index
|
||||
|
||||
> **alchemy** is in alpha. Expect breaking changes. Come hang in our [Discord](https://discord.gg/jwKw8dBJdN).
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
name: Alchemy
|
||||
description: Deploy Alchemy stages for pull requests and the main branch, and destroy pull request stages when closed.
|
||||
author: alchemy-run
|
||||
branding:
|
||||
icon: upload-cloud
|
||||
color: green
|
||||
inputs:
|
||||
working-directory:
|
||||
description: Directory where the Alchemy project should be run.
|
||||
required: false
|
||||
default: .
|
||||
main-branch:
|
||||
description: Branch that deploys as the persistent prod stage and is never destroyed.
|
||||
required: false
|
||||
default: main
|
||||
outputs:
|
||||
action:
|
||||
description: "The lifecycle action that ran: deploy, destroy, or skip."
|
||||
value: ${{ steps.resolve.outputs.action }}
|
||||
stage:
|
||||
description: The Alchemy stage name.
|
||||
value: ${{ steps.resolve.outputs.stage }}
|
||||
pull-request:
|
||||
description: The pull request number for PR stages.
|
||||
value: ${{ steps.resolve.outputs.pull-request }}
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- id: resolve
|
||||
shell: bash
|
||||
env:
|
||||
MAIN_BRANCH: ${{ inputs.main-branch }}
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
EVENT_ACTION: ${{ github.event.action }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
PR_NUMBER: ${{ github.event.number }}
|
||||
run: |
|
||||
if [ "$EVENT_NAME" = "pull_request" ]; then
|
||||
echo "stage=staging-$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
echo "pull-request=$PR_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
if [ "$EVENT_ACTION" = "closed" ]; then
|
||||
echo "action=destroy" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "action=deploy" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$REF_NAME" = "$MAIN_BRANCH" ]; then
|
||||
echo "stage=prod" >> "$GITHUB_OUTPUT"
|
||||
echo "pull-request=" >> "$GITHUB_OUTPUT"
|
||||
echo "action=deploy" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "stage=" >> "$GITHUB_OUTPUT"
|
||||
echo "pull-request=" >> "$GITHUB_OUTPUT"
|
||||
echo "action=skip" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- if: ${{ steps.resolve.outputs.action == 'deploy' }}
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
env:
|
||||
STAGE: ${{ steps.resolve.outputs.stage }}
|
||||
PULL_REQUEST_VALUE: ${{ steps.resolve.outputs.pull-request }}
|
||||
run: |
|
||||
if [ -n "$PULL_REQUEST_VALUE" ]; then
|
||||
export PULL_REQUEST="$PULL_REQUEST_VALUE"
|
||||
fi
|
||||
alchemy deploy --stage "$STAGE" --yes
|
||||
|
||||
- if: ${{ steps.resolve.outputs.action == 'destroy' }}
|
||||
shell: bash
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
env:
|
||||
STAGE: ${{ steps.resolve.outputs.stage }}
|
||||
PULL_REQUEST_VALUE: ${{ steps.resolve.outputs.pull-request }}
|
||||
run: |
|
||||
if [ -n "$PULL_REQUEST_VALUE" ]; then
|
||||
export PULL_REQUEST="$PULL_REQUEST_VALUE"
|
||||
fi
|
||||
alchemy destroy --stage "$STAGE" --yes
|
||||
@@ -0,0 +1,4 @@
|
||||
# Per-run raw samples (regenerated every run; keep out of git).
|
||||
data/
|
||||
.alchemy/
|
||||
!contexts/*/*.js
|
||||
@@ -0,0 +1,74 @@
|
||||
import * as AWS from "alchemy/AWS";
|
||||
import * as Alchemy from "alchemy";
|
||||
import * as Cloudflare from "alchemy/Cloudflare";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Layer from "effect/Layer";
|
||||
import BunMicrovmLive from "./src/bun-image.ts";
|
||||
import ContainerWorker from "./src/container-worker.ts";
|
||||
import EffectfulBunLive from "./src/effectful-bun.ts";
|
||||
import EffectfulContainerLive from "./src/effectful-container.ts";
|
||||
import EffectfulNodeLive from "./src/effectful-node.ts";
|
||||
import ExternalMicrovmLive from "./src/external-image.ts";
|
||||
import MicrovmWorker from "./src/microvm-worker.ts";
|
||||
import NodeMicrovmLive from "./src/node-image.ts";
|
||||
import OpencodeMicrovmLive from "./src/opencode-image.ts";
|
||||
import Orchestrator from "./src/orchestrator.ts";
|
||||
|
||||
/**
|
||||
* MicroVM is a gated AWS Lambda preview. The container benchmark runs against
|
||||
* Cloudflare alone; set `BENCH_MICROVM=1` (on an onboarded account) to also
|
||||
* deploy the two MicroVM images and the Lambda + Worker hosts that boot them.
|
||||
*/
|
||||
export const benchMicrovm = !!process.env.BENCH_MICROVM;
|
||||
|
||||
/**
|
||||
* Combined cold-start benchmark stack.
|
||||
*
|
||||
* - Cloudflare: a {@link ContainerWorker} fronting three container variants
|
||||
* (effectful bundled-Effect image, bun-baseline Dockerfile, remote pre-built
|
||||
* image), each behind its own Durable Object.
|
||||
* - AWS (optional, `BENCH_MICROVM=1`): six MicroVM images (effectful Effect
|
||||
* bundle on bun + node, raw bun + node baselines, an external Python
|
||||
* Dockerfile, and an eagerly-started opencode server) booted by both a
|
||||
* Lambda {@link Orchestrator} and a cross-cloud Cloudflare
|
||||
* {@link MicrovmWorker}.
|
||||
*
|
||||
* Exposes each host's URL so the driver can fire boot/shutdown loads and record
|
||||
* the time-to-usable-service for every variant.
|
||||
*/
|
||||
export default Alchemy.Stack(
|
||||
"ContainerBenchmark",
|
||||
{
|
||||
providers: Layer.mergeAll(AWS.providers(), Cloudflare.providers()),
|
||||
state: Alchemy.localState(),
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const containerWorker = yield* ContainerWorker;
|
||||
|
||||
if (!benchMicrovm) {
|
||||
return { containerWorkerUrl: containerWorker.url.as<string>() };
|
||||
}
|
||||
|
||||
const orchestrator = yield* Orchestrator;
|
||||
const microvmWorker = yield* MicrovmWorker;
|
||||
return {
|
||||
containerWorkerUrl: containerWorker.url.as<string>(),
|
||||
lambdaUrl: orchestrator.functionUrl.as<string>(),
|
||||
microvmWorkerUrl: microvmWorker.url.as<string>(),
|
||||
};
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
benchMicrovm
|
||||
? Layer.mergeAll(
|
||||
EffectfulContainerLive,
|
||||
EffectfulBunLive,
|
||||
EffectfulNodeLive,
|
||||
BunMicrovmLive,
|
||||
NodeMicrovmLive,
|
||||
ExternalMicrovmLive,
|
||||
OpencodeMicrovmLive,
|
||||
)
|
||||
: EffectfulContainerLive,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,11 @@
|
||||
# Same base image as the effectful container (`oven/bun:latest`), but with NO
|
||||
# Effect program bundled in — just a one-line Bun HTTP server. This isolates
|
||||
# the Effect-runtime/bundle cost from the base-image pull/boot cost: any
|
||||
# time-to-usable-service gap between this and the effectful variant is
|
||||
# attributable to the bundled Effect runtime, not the image.
|
||||
FROM oven/bun:latest
|
||||
|
||||
RUN printf 'Bun.serve({ port: 8080, hostname: "0.0.0.0", fetch: () => new Response("ok") });\n' > /server.ts
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["bun", "/server.ts"]
|
||||
@@ -0,0 +1,17 @@
|
||||
# Bun baseline MicroVM — the dumbest possible Bun HTTP server, built the EXACT
|
||||
# same way alchemy's effectful image is built (same MicroVM base, same bun
|
||||
# install via the official installer). The ONLY difference from the effectful
|
||||
# `EffectfulBun` image is the server code: a raw `Bun.serve({ fetch })` with no
|
||||
# Effect runtime, no alchemy bootstrap, no RPC protocol. Any time-to-usable
|
||||
# gap between this and the effectful variant is the alchemy/Effect cold-start
|
||||
# tax, with runtime (bun) and CPU arch (ARM_64) held constant.
|
||||
FROM public.ecr.aws/lambda/microvms:al2023-minimal
|
||||
|
||||
RUN dnf install -y unzip tar && curl -fsSL https://bun.sh/install | bash && ln -s /root/.bun/bin/bun /usr/local/bin/bun && dnf clean all
|
||||
|
||||
WORKDIR /app
|
||||
COPY server.js .
|
||||
|
||||
EXPOSE 8080
|
||||
ENV PORT=8080
|
||||
ENTRYPOINT ["bun", "/app/server.js"]
|
||||
@@ -0,0 +1,19 @@
|
||||
// Dumbest possible bun HTTP server — the cold-start baseline. Mirrors the
|
||||
// effectful Sandbox's two routes (`/echo` and a default text response) so the
|
||||
// in-VM workload is identical; everything that differs in time-to-usable is
|
||||
// the alchemy/Effect abstraction, not the work the server does.
|
||||
const port = Number(process.env.PORT ?? 8080);
|
||||
|
||||
Bun.serve({
|
||||
port,
|
||||
hostname: "0.0.0.0",
|
||||
fetch(req) {
|
||||
const url = new URL(req.url);
|
||||
if (url.pathname === "/echo") {
|
||||
return Response.json({ message: url.searchParams.get("message") ?? "" });
|
||||
}
|
||||
return new Response("hello from bun microvm");
|
||||
},
|
||||
});
|
||||
|
||||
console.log(`bun microvm baseline listening on :${port}`);
|
||||
@@ -0,0 +1,15 @@
|
||||
# Node baseline MicroVM — the dumbest possible node HTTP server, built the EXACT
|
||||
# same way alchemy's effectful node image is built (`dnf install -y nodejs` on
|
||||
# the MicroVM base — the runtime the Lambda VMs already ship). The only
|
||||
# difference from the effectful node `EffectfulNode` image is the server code: a
|
||||
# raw `http.createServer` with no Effect runtime, no alchemy bootstrap, no RPC.
|
||||
FROM public.ecr.aws/lambda/microvms:al2023-minimal
|
||||
|
||||
RUN dnf install -y nodejs && dnf clean all
|
||||
|
||||
WORKDIR /app
|
||||
COPY server.js .
|
||||
|
||||
EXPOSE 8080
|
||||
ENV PORT=8080
|
||||
ENTRYPOINT ["node", "/app/server.js"]
|
||||
@@ -0,0 +1,22 @@
|
||||
// Dumbest possible node HTTP server — the node cold-start baseline. Mirrors the
|
||||
// effectful Sandbox's two routes (`/echo` and a default text response) so the
|
||||
// in-VM workload is identical; everything that differs in time-to-usable is the
|
||||
// alchemy/Effect abstraction, not the work the server does.
|
||||
const http = require("node:http");
|
||||
|
||||
const port = Number(process.env.PORT ?? 8080);
|
||||
|
||||
http
|
||||
.createServer((req, res) => {
|
||||
const url = new URL(req.url, "http://microvm");
|
||||
if (url.pathname === "/echo") {
|
||||
res.writeHead(200, { "content-type": "application/json" });
|
||||
res.end(JSON.stringify({ message: url.searchParams.get("message") ?? "" }));
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { "content-type": "text/plain" });
|
||||
res.end("hello from node microvm");
|
||||
})
|
||||
.listen(port, "0.0.0.0", () => {
|
||||
console.log(`node microvm baseline listening on :${port}`);
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
# opencode (a real coding-agent server, ~100MB binary on a Bun runtime) started
|
||||
# EAGERLY as the entrypoint. The MicroVM image build runs this entrypoint,
|
||||
# waits for it to initialize, and snapshots the running memory+disk — so every
|
||||
# `RunMicrovm` resumes with the opencode server already listening instead of
|
||||
# paying its process startup on each boot.
|
||||
FROM public.ecr.aws/lambda/microvms:al2023-minimal
|
||||
|
||||
RUN dnf install -y unzip tar gzip git && dnf clean all
|
||||
RUN curl -fsSL https://opencode.ai/install | bash \
|
||||
&& ln -s /root/.opencode/bin/opencode /usr/local/bin/opencode
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
# The server binds 0.0.0.0, so require basic auth (username defaults to
|
||||
# `opencode`). The benchmark's readiness probe presents these credentials.
|
||||
ENV OPENCODE_SERVER_PASSWORD=bench
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["opencode", "serve", "--hostname", "0.0.0.0", "--port", "8080"]
|
||||
@@ -0,0 +1,9 @@
|
||||
FROM public.ecr.aws/lambda/microvms:al2023-minimal
|
||||
|
||||
RUN dnf install -y python3 && dnf clean all
|
||||
|
||||
WORKDIR /app
|
||||
COPY app.py .
|
||||
|
||||
EXPOSE 8080
|
||||
CMD ["python3", "app.py"]
|
||||
@@ -0,0 +1,16 @@
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
|
||||
class Handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header("Content-Type", "text/plain")
|
||||
self.end_headers()
|
||||
self.wfile.write(b"hello from external microvm")
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
HTTPServer(("0.0.0.0", 8080), Handler).serve_forever()
|
||||
@@ -0,0 +1,21 @@
|
||||
# The Cloudflare-container twin of `../microvm-opencode/Dockerfile`: the same
|
||||
# opencode server started eagerly as the entrypoint. Cloudflare containers boot
|
||||
# the image from scratch on each cold start (no memory snapshot), so this
|
||||
# variant pays opencode's process startup inside every boot — the comparison
|
||||
# the MicroVM snapshot variant is designed to isolate.
|
||||
#
|
||||
# Cloudflare builds containers for linux/amd64 and the AWS MicroVM base image
|
||||
# is ARM64-only, so use plain Amazon Linux 2023 (same OS family, multi-arch).
|
||||
# The base OS barely matters — opencode ships its own runtime.
|
||||
FROM amazonlinux:2023
|
||||
|
||||
RUN dnf install -y unzip tar gzip git && dnf clean all
|
||||
RUN curl -fsSL https://opencode.ai/install | bash \
|
||||
&& ln -s /root/.opencode/bin/opencode /usr/local/bin/opencode
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
ENV OPENCODE_SERVER_PASSWORD=bench
|
||||
|
||||
EXPOSE 8080
|
||||
ENTRYPOINT ["opencode", "serve", "--hostname", "0.0.0.0", "--port", "8080"]
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"name": "@alchemy.run/benchmark-container",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "Apache-2.0",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/alchemy-run/alchemy.git",
|
||||
"directory": "benchmark/container"
|
||||
},
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"deploy": "alchemy deploy",
|
||||
"destroy": "alchemy destroy",
|
||||
"logs": "alchemy logs",
|
||||
"tail": "alchemy tail",
|
||||
"bench": "bun test test/bench.test.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@distilled.cloud/aws": "workspace:*",
|
||||
"@effect/platform-bun": "catalog:",
|
||||
"@effect/platform-node": "catalog:",
|
||||
"alchemy": "workspace:*",
|
||||
"effect": "catalog:"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@cloudflare/containers": "catalog:",
|
||||
"@cloudflare/workers-types": "catalog:",
|
||||
"@types/bun": "catalog:"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
# Cold-start benchmark
|
||||
|
||||
Run `2026-07-02T01-28-09-381Z` — 700 samples. Metric: **time to usable service** (host start → first successful request).
|
||||
|
||||
Methodology: targets run sequentially so they never contend for shared quotas. Containers are measured under concurrent load (10 rounds × 10 simultaneous boots). MicroVMs are measured **independently** — 25 serial boots at concurrency 1 — because the Lambda MicroVM API is throttled per account/Region (RunMicrovm 5 TPS/burst 5, TerminateMicrovm 10 TPS), so concurrent boots would measure API admission rather than VM cold start. Each boot launches, waits until the service is usable, then terminates before the next; the image is pre-warmed once (untimed) so we measure cold start, not first-pull distribution.
|
||||
|
||||
| environment | variant | ok | ready p50 | ready p95 | ready mean | ready max | first → last round (mean) |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| container | effectful | 100/100 | 2.3s | 24.0s | 4.7s | 46.7s | 15.3s → 2.1s |
|
||||
| container | bun | 100/100 | 1.7s | 23.9s | 3.9s | 47.3s | 17.4s → 1.7s |
|
||||
| container | remote | 100/100 | 2.6s | 24.4s | 4.5s | 26.1s | 11.5s → 2.4s |
|
||||
| container | opencode | 100/100 | 10.5s | 15.6s | 12.0s | 58.6s | 25.4s → 10.6s |
|
||||
| lambda→microvm | effectful-bun | 25/25 | 2.9s | 4.4s | 2.8s | 4.8s | 4.8s → 2.0s |
|
||||
| lambda→microvm | effectful-node | 25/25 | 3.2s | 3.7s | 3.6s | 16.6s | 3.4s → 2.5s |
|
||||
| lambda→microvm | bun | 25/25 | 2.7s | 3.2s | 2.7s | 3.7s | 3.2s → 2.3s |
|
||||
| lambda→microvm | node | 25/25 | 3.3s | 3.8s | 3.2s | 4.2s | 3.5s → 3.3s |
|
||||
| lambda→microvm | external | 25/25 | 2.2s | 2.8s | 2.2s | 2.8s | 2.4s → 2.2s |
|
||||
| lambda→microvm | opencode | 25/25 | 3.4s | 4.1s | 3.4s | 4.5s | 3.8s → 4.1s |
|
||||
| worker→microvm | effectful-bun | 25/25 | 2.7s | 3.7s | 2.8s | 4.1s | 3.7s → 3.2s |
|
||||
| worker→microvm | effectful-node | 25/25 | 3.6s | 9.4s | 4.0s | 9.6s | 6.0s → 2.8s |
|
||||
| worker→microvm | bun | 25/25 | 3.1s | 3.8s | 2.9s | 5.4s | 3.8s → 3.2s |
|
||||
| worker→microvm | node | 25/25 | 3.2s | 4.3s | 3.4s | 6.9s | 3.2s → 3.0s |
|
||||
| worker→microvm | external | 25/25 | 2.4s | 2.9s | 2.3s | 3.0s | 3.0s → 2.9s |
|
||||
| worker→microvm | opencode | 24/25 | 3.6s | 4.0s | 3.5s | 4.2s | 1.9s → 3.1s |
|
||||
|
||||
Raw per-boot samples: `data/samples-2026-07-02T01-28-09-381Z.csv`. Aggregates: `report/summary.csv`.
|
||||
@@ -0,0 +1,17 @@
|
||||
env,variant,ok,total,ready_min_ms,ready_p50_ms,ready_p95_ms,ready_mean_ms,ready_max_ms,round_means_ms
|
||||
container,effectful,100,100,993,2321,23999,4743,46726,15258;10798;2069;2153;2442;2002;4540;3020;3050;2095
|
||||
container,bun,100,100,608,1710,23903,3905,47294,17436;6231;1747;3987;1372;2107;1586;1564;1370;1651
|
||||
container,remote,100,100,1127,2565,24405,4484,26064,11452;9197;2396;2759;2423;6993;2335;2192;2669;2428
|
||||
container,opencode,100,100,4363,10492,15614,12043,58621,25400;10537;9987;9869;10632;11032;11265;11090;10013;10611
|
||||
lambda→microvm,effectful-bun,25,25,1550,2860,4417,2790,4792,4792;3584;2516;1854;2860;3087;2888;2784;1550;2866;4417;3019;2323;2896;2167;2883;2582;2914;3394;2430;2529;2105;2976;2284;2040
|
||||
lambda→microvm,effectful-node,25,25,2098,3190,3701,3647,16627,3413;3221;3482;3218;3459;3287;3190;16627;3427;2098;3110;3201;3056;3084;2462;3701;3115;3158;3165;3261;3112;2517;3245;3123;2455
|
||||
lambda→microvm,bun,25,25,1705,2747,3160,2680,3721,3160;2689;2770;3091;3721;1705;2273;2799;2742;2152;2747;2872;2705;3039;3008;2226;2873;2706;2060;2757;2733;2061;2785;3039;2293
|
||||
lambda→microvm,node,25,25,1970,3329,3816,3205,4193,3516;3192;3342;3573;3383;3438;2709;3329;3816;3578;4193;3196;1970;3372;3557;3243;2263;3235;3395;3476;2458;3093;2909;2575;3303
|
||||
lambda→microvm,external,25,25,1495,2193,2759,2167,2786,2416;2274;2137;2187;2262;1578;2242;1495;2244;2160;1588;1955;2193;2183;1581;2145;2717;2215;2193;2220;2315;2786;2132;2759;2189
|
||||
lambda→microvm,opencode,25,25,1901,3409,4107,3350,4506,3829;3406;4506;3501;3409;3612;2943;2636;3518;3797;3427;3209;3811;3367;2674;2558;3299;3188;1901;3494;2648;3232;3851;3830;4107
|
||||
worker→microvm,effectful-bun,25,25,1951,2686,3653,2797,4137,3653;3031;1951;3251;3526;4137;2429;2986;2922;2686;2977;2245;2487;2359;2412;2743;2935;2638;2619;2405;2762;2652;2489;2425;3207
|
||||
worker→microvm,effectful-node,25,25,2346,3561,9393,4003,9617,6029;4248;2802;3788;3409;3636;3774;4250;2789;9617;3663;3150;2346;3561;3587;2740;3494;3228;3698;3334;3423;9393;3809;3519;2800
|
||||
worker→microvm,bun,25,25,1779,3053,3797,2932,5405,3797;1928;5405;3315;3053;3311;2370;3177;3432;3039;3401;2447;3298;3263;2499;1984;2146;2192;2505;3012;3073;2566;3122;1779;3174
|
||||
worker→microvm,node,25,25,2611,3247,4328,3410,6890,3175;2884;3556;3271;2616;3906;2725;4328;2829;4212;3351;3176;3525;3281;3533;2611;3789;3446;2726;3001;6890;2972;3247;3161;3029
|
||||
worker→microvm,external,25,25,1760,2404,2925,2292,2977,2977;2497;2424;1760;2404;1868;2630;2020;1982;2420;2650;2043;2324;2441;1855;2469;1913;2478;1942;2425;2280;1877;2268;2424;2925
|
||||
worker→microvm,opencode,24,25,1903,3606,4027,3513,4188,1903;3796;3705;;3381;3439;3786;3393;2603;3606;3730;3338;3800;3567;4188;3298;4027;3985;3502;3449;3796;3717;3731;3502;3074
|
||||
|
@@ -0,0 +1,168 @@
|
||||
# Generates the blog plots for the MicroVM vs Container cold-start post from a
|
||||
# benchmark samples CSV (see test/bench.test.ts). Usage:
|
||||
# uv run --with matplotlib --with scipy scripts/plot-blog.py data/samples-<run>.csv <outdir>
|
||||
import csv
|
||||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
import matplotlib
|
||||
import numpy as np
|
||||
from scipy.stats import gaussian_kde
|
||||
|
||||
matplotlib.use("Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
samples_csv, outdir = sys.argv[1], sys.argv[2]
|
||||
|
||||
rows = []
|
||||
with open(samples_csv) as f:
|
||||
for r in csv.DictReader(f):
|
||||
if r["ok"] == "true" and r["readyMs"]:
|
||||
rows.append((r["env"], r["variant"], int(r["readyMs"]) / 1000.0))
|
||||
|
||||
by_key = defaultdict(list)
|
||||
for env, variant, s in rows:
|
||||
by_key[(env, variant)].append(s)
|
||||
|
||||
# Colors readable on both light and dark backgrounds.
|
||||
FG = "#8b8b94"
|
||||
CF = "#f6821f" # Cloudflare orange
|
||||
CF2 = "#fbb673"
|
||||
VM = "#4f8ff7" # MicroVM blue
|
||||
VM2 = "#8fb8fa"
|
||||
VM3 = "#2fbf9b"
|
||||
|
||||
plt.rcParams.update(
|
||||
{
|
||||
"figure.facecolor": "none",
|
||||
"axes.facecolor": "none",
|
||||
"savefig.facecolor": "none",
|
||||
"text.color": FG,
|
||||
"axes.edgecolor": FG,
|
||||
"axes.labelcolor": FG,
|
||||
"xtick.color": FG,
|
||||
"ytick.color": FG,
|
||||
"grid.color": FG,
|
||||
"grid.alpha": 0.15,
|
||||
"font.size": 12,
|
||||
"font.family": "sans-serif",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def style(ax):
|
||||
ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
ax.grid(True, axis="x", linewidth=0.6)
|
||||
ax.set_axisbelow(True)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- strip plot
|
||||
series = [
|
||||
("Cloudflare container — Effect image", ("container", "effectful"), CF),
|
||||
("Cloudflare container — plain Bun image", ("container", "bun"), CF2),
|
||||
("AWS MicroVM — Effect image (Bun)", ("lambda\u2192microvm", "effectful-bun"), VM),
|
||||
("AWS MicroVM — plain Bun image", ("lambda\u2192microvm", "bun"), VM2),
|
||||
("AWS MicroVM — from a Cloudflare Worker", ("worker\u2192microvm", "effectful-bun"), VM3),
|
||||
]
|
||||
|
||||
import random
|
||||
|
||||
|
||||
def strip_plot(rows, fname, xmax=None, logx=False):
|
||||
fig, ax = plt.subplots(figsize=(9.5, 0.75 + 0.78 * len(rows)))
|
||||
random.seed(7)
|
||||
for i, (label, key, color) in enumerate(reversed(rows)):
|
||||
xs = by_key[key]
|
||||
ys = [i + random.uniform(-0.16, 0.16) for _ in xs]
|
||||
ax.scatter(xs, ys, s=26, color=color, alpha=0.75, linewidths=0)
|
||||
ax.set_yticks(range(len(rows)))
|
||||
ax.set_yticklabels([label for label, _, _ in reversed(rows)])
|
||||
ax.set_xlabel("time to usable service (seconds) — every boot in the run")
|
||||
if logx:
|
||||
ax.set_xscale("log")
|
||||
ax.set_xticks([1, 2, 3, 5, 10, 20, 40, 60])
|
||||
ax.set_xticklabels(["1s", "2s", "3s", "5s", "10s", "20s", "40s", "60s"])
|
||||
elif xmax:
|
||||
ax.set_xlim(0, xmax)
|
||||
style(ax)
|
||||
fig.tight_layout()
|
||||
fig.savefig(f"{outdir}/{fname}", dpi=200)
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
all_max = max(max(by_key[k]) for _, k, _ in series)
|
||||
strip_plot(series, "every-boot.png", xmax=all_max * 1.04)
|
||||
|
||||
# ------------------------------------------------------- opencode strip plot
|
||||
# Solid hues = opencode, lighter tints of the same hue = hello world.
|
||||
VM_L = "#8fb8fa"
|
||||
VM3_L = "#93e2cc"
|
||||
oc_series = [
|
||||
("Cloudflare container — opencode (via Worker)", ("container", "opencode"), CF),
|
||||
("AWS MicroVM — opencode (via Lambda)", ("lambda\u2192microvm", "opencode"), VM),
|
||||
("AWS MicroVM — opencode (via Worker)", ("worker\u2192microvm", "opencode"), VM3),
|
||||
("Cloudflare container — hello world (via Worker)", ("container", "bun"), CF2),
|
||||
("AWS MicroVM — hello world (via Lambda)", ("lambda\u2192microvm", "bun"), VM_L),
|
||||
("AWS MicroVM — hello world (via Worker)", ("worker\u2192microvm", "bun"), VM3_L),
|
||||
]
|
||||
strip_plot(oc_series, "opencode.png", logx=True)
|
||||
|
||||
# --------------------------------------------------- opencode density (KDE)
|
||||
# Density in log-space: the MicroVM variants show as tall narrow spikes
|
||||
# (consistency), the container as a wide hump at ~10s. NB: the container's
|
||||
# 20-60s tail is nearly invisible at this scale — the strip plot and the
|
||||
# table's max column carry that part of the story.
|
||||
fig, ax = plt.subplots(figsize=(9.5, 4.8))
|
||||
grid = np.logspace(np.log10(0.3), np.log10(70), 500)
|
||||
for label, key, color in oc_series:
|
||||
xs = np.log10(np.array(by_key[key]))
|
||||
density = gaussian_kde(xs, bw_method=0.25)(np.log10(grid))
|
||||
ax.plot(grid, density, color=color, linewidth=2.2, label=label)
|
||||
ax.fill_between(grid, density, color=color, alpha=0.15)
|
||||
ax.set_xscale("log")
|
||||
ax.set_xticks([1, 2, 3, 5, 10, 20, 40, 60])
|
||||
ax.set_xticklabels(["1s", "2s", "3s", "5s", "10s", "20s", "40s", "60s"])
|
||||
ax.set_xlabel("time to usable service (seconds)")
|
||||
ax.set_ylabel("density")
|
||||
ax.legend(frameon=False, fontsize=10.5)
|
||||
ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
ax.grid(True, linewidth=0.6)
|
||||
ax.set_axisbelow(True)
|
||||
fig.tight_layout()
|
||||
fig.savefig(f"{outdir}/opencode-density.png", dpi=200)
|
||||
plt.close(fig)
|
||||
|
||||
# ----------------------------------------------------------------------- CDF
|
||||
fig, ax = plt.subplots(figsize=(9.5, 4.8))
|
||||
for label, key, color in series:
|
||||
xs = sorted(by_key[key])
|
||||
ys = [(i + 1) / len(xs) * 100 for i in range(len(xs))]
|
||||
ax.plot(xs, ys, color=color, linewidth=2.2, label=label)
|
||||
ax.set_xlabel("time to usable service (seconds)")
|
||||
ax.set_ylabel("% of boots at or below")
|
||||
ax.set_xscale("log")
|
||||
ax.set_xticks([1, 2, 3, 5, 10, 20])
|
||||
ax.set_xticklabels(["1s", "2s", "3s", "5s", "10s", "20s"])
|
||||
ax.set_ylim(0, 102)
|
||||
ax.legend(frameon=False, loc="lower right", fontsize=10.5)
|
||||
ax.spines["top"].set_visible(False)
|
||||
ax.spines["right"].set_visible(False)
|
||||
ax.grid(True, linewidth=0.6)
|
||||
ax.set_axisbelow(True)
|
||||
fig.tight_layout()
|
||||
fig.savefig(f"{outdir}/cdf.png", dpi=200)
|
||||
plt.close(fig)
|
||||
|
||||
|
||||
def pct(xs, p):
|
||||
xs = sorted(xs)
|
||||
return xs[min(len(xs) - 1, int(p / 100 * len(xs)))]
|
||||
|
||||
|
||||
for label, key, _ in series + oc_series:
|
||||
xs = by_key[key]
|
||||
print(
|
||||
f"{label:45s} n={len(xs):3d} p50={pct(xs,50):.1f}s p95={pct(xs,95):.1f}s max={max(xs):.1f}s"
|
||||
)
|
||||
@@ -0,0 +1,8 @@
|
||||
import * as AWS from "alchemy/AWS";
|
||||
|
||||
/**
|
||||
* Build role shared by every MicroVM image (effectful bun/node, bun/node
|
||||
* baselines, external Python). Kept in its own module so the effectful image
|
||||
* entrypoints can import it without pulling each other's server bundle in.
|
||||
*/
|
||||
export const MicrovmBuildRole = AWS.IAM.Role("MicrovmBuildRole");
|
||||
@@ -0,0 +1,18 @@
|
||||
import * as Cloudflare from "alchemy/Cloudflare";
|
||||
|
||||
/**
|
||||
* Non-Effect container built from a Dockerfile whose base image is the *same*
|
||||
* `oven/bun:latest` the effectful variant uses — but with no Effect program
|
||||
* bundled, just a raw `Bun.serve`. Comparing this against the effectful variant
|
||||
* rules out base-image pull/boot time as the cause of any gap: the remaining
|
||||
* difference is the bundled Effect runtime.
|
||||
*/
|
||||
export class BunContainer extends Cloudflare.Container<BunContainer>()(
|
||||
"BenchBunContainer",
|
||||
{
|
||||
context: `${import.meta.dirname}/../contexts/bun`,
|
||||
maxInstances: 100,
|
||||
instanceType: "lite",
|
||||
instances: 0,
|
||||
},
|
||||
) {}
|
||||
@@ -0,0 +1,33 @@
|
||||
import * as AWS from "alchemy/AWS";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { MicrovmBuildRole } from "./build-role.ts";
|
||||
|
||||
/**
|
||||
* Bun baseline MicroVM image — the dumbest possible `Bun.serve` HTTP server,
|
||||
* built from `contexts/microvm-bun/` the same way alchemy builds the effectful
|
||||
* {@link import("./effectful-bun.ts").EffectfulBun} image (same MicroVM base, same bun install, same ARM_64 arch,
|
||||
* same 512 MiB). The only difference is the absence of the Effect runtime and
|
||||
* the alchemy bootstrap, so `effectful.readyMs − bun.readyMs` isolates the
|
||||
* cold-start cost of alchemy's Effect abstraction with the runtime and CPU
|
||||
* architecture held constant.
|
||||
*/
|
||||
export class BunMicrovm extends AWS.Lambda.MicrovmImage<BunMicrovm>()(
|
||||
"MicrovmBenchBun",
|
||||
) {}
|
||||
|
||||
export default BunMicrovm.make(
|
||||
MicrovmBuildRole.pipe(
|
||||
Effect.map((buildRole) => ({
|
||||
// External (Dockerfile) mode: the runtime is NOT chosen by alchemy's
|
||||
// `runtime` prop (that only applies to effectful `main:` images). It is
|
||||
// decided entirely by this context's Dockerfile, which installs and runs
|
||||
// bun. Match the effectful EffectfulBun's image config: ARM_64, 512 MiB.
|
||||
context: new URL("../contexts/microvm-bun/", import.meta.url).pathname,
|
||||
buildRole,
|
||||
resources: [{ minimumMemoryInMiB: 512 }],
|
||||
cpuConfigurations: [{ architecture: "ARM_64" }],
|
||||
})),
|
||||
),
|
||||
// External (Dockerfile) mode — no Effect runtime to bundle.
|
||||
Effect.succeed({}),
|
||||
);
|
||||
@@ -0,0 +1,46 @@
|
||||
import * as Cloudflare from "alchemy/Cloudflare";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schedule from "effect/Schedule";
|
||||
import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
|
||||
import { BunContainer } from "./bun-container.ts";
|
||||
|
||||
/**
|
||||
* Durable Object backing one bun-baseline container instance. `boot()` blocks
|
||||
* until the `Bun.serve` HTTP server answers on its TCP port. NOTE: the
|
||||
* authoritative cold-start clock runs in the Worker AROUND the whole DO call —
|
||||
* the container layer eagerly starts the container during DO construction, so
|
||||
* a clock started here would miss part of the start.
|
||||
*/
|
||||
export class BunObject extends Cloudflare.DurableObject<BunObject>()(
|
||||
"BenchBunObject",
|
||||
Effect.gen(function* () {
|
||||
const container = yield* BunContainer;
|
||||
|
||||
return Effect.gen(function* () {
|
||||
const { fetch } = yield* container.getTcpPort(8080);
|
||||
|
||||
return {
|
||||
boot: () =>
|
||||
Effect.gen(function* () {
|
||||
const start = yield* Effect.sync(() => Date.now());
|
||||
yield* fetch(HttpClientRequest.get("http://container/")).pipe(
|
||||
Effect.flatMap((r) => r.text),
|
||||
Effect.retry({
|
||||
schedule: Schedule.min([Schedule.exponential("1 second"), Schedule.spaced("5 seconds")]),
|
||||
times: 40,
|
||||
}),
|
||||
);
|
||||
const readyMs = (yield* Effect.sync(() => Date.now())) - start;
|
||||
return { readyMs };
|
||||
}),
|
||||
shutdown: () => container.destroy().pipe(Effect.ignore),
|
||||
};
|
||||
});
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
Cloudflare.Containers.layer(BunContainer, {
|
||||
enableInternet: true,
|
||||
}),
|
||||
),
|
||||
),
|
||||
) {}
|
||||
@@ -0,0 +1,75 @@
|
||||
import * as Cloudflare from "alchemy/Cloudflare";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
|
||||
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
|
||||
import { BunObject } from "./bun-object.ts";
|
||||
import { EffectfulObject } from "./effectful-object.ts";
|
||||
import { OpencodeObject } from "./opencode-object.ts";
|
||||
import { RemoteObject } from "./remote-object.ts";
|
||||
|
||||
/**
|
||||
* Cloudflare Worker host for the container cold-start benchmark. Each request
|
||||
* names a fresh DO instance (`?name=`), which boots its own container.
|
||||
*
|
||||
* - `GET /boot?variant=effectful|bun|remote|opencode&name=K` boots one
|
||||
* container and returns `{ readyMs }`. It does NOT shut down.
|
||||
* - `GET /shutdown?variant=…&name=K` tears the container down so the next boot
|
||||
* is an independent cold start and the account's container cap isn't exhausted.
|
||||
*
|
||||
* TIMING: the clock runs HERE in the Worker, around the entire DO call — not
|
||||
* inside the DO. The container layer eagerly calls `container.start()` during
|
||||
* DO construction, so a clock started inside `boot()` would miss instance
|
||||
* allocation and start entirely, undercounting the cold start. Wrapping the
|
||||
* `getByName(name).boot()` call captures DO creation + container start +
|
||||
* readiness probe, while staying inside Cloudflare (no client network in the
|
||||
* number) — symmetric with the MicroVM hosts, which start the clock before
|
||||
* `RunMicrovm`.
|
||||
*/
|
||||
export default class ContainerWorker extends Cloudflare.Worker<ContainerWorker>()(
|
||||
"BenchContainerWorker",
|
||||
{
|
||||
main: import.meta.filename,
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
const effectful = yield* EffectfulObject;
|
||||
const remote = yield* RemoteObject;
|
||||
const bun = yield* BunObject;
|
||||
const opencode = yield* OpencodeObject;
|
||||
|
||||
const objectFor = (variant: string) =>
|
||||
variant === "remote"
|
||||
? remote
|
||||
: variant === "bun"
|
||||
? bun
|
||||
: variant === "opencode"
|
||||
? opencode
|
||||
: effectful;
|
||||
|
||||
return {
|
||||
fetch: Effect.gen(function* () {
|
||||
const request = yield* HttpServerRequest;
|
||||
const url = new URL(request.url, "http://x");
|
||||
const name = url.searchParams.get("name") ?? "default";
|
||||
const variant = url.searchParams.get("variant") ?? "effectful";
|
||||
|
||||
if (url.pathname === "/boot") {
|
||||
// Time the WHOLE thing: DO creation, eager container start during
|
||||
// layer construction, and the readiness probe inside boot().
|
||||
const start = yield* Effect.sync(() => Date.now());
|
||||
yield* objectFor(variant).getByName(name).boot();
|
||||
const readyMs = (yield* Effect.sync(() => Date.now())) - start;
|
||||
return yield* HttpServerResponse.json({ readyMs });
|
||||
}
|
||||
if (url.pathname === "/shutdown") {
|
||||
yield* objectFor(variant).getByName(name).shutdown();
|
||||
return yield* HttpServerResponse.json({ ok: true });
|
||||
}
|
||||
return HttpServerResponse.text("ok");
|
||||
}).pipe(
|
||||
Effect.catch((err) =>
|
||||
Effect.succeed(HttpServerResponse.text(String(err), { status: 500 })),
|
||||
),
|
||||
),
|
||||
};
|
||||
}),
|
||||
) {}
|
||||
@@ -0,0 +1,31 @@
|
||||
import * as AWS from "alchemy/AWS";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { MicrovmBuildRole } from "./build-role.ts";
|
||||
import { effectfulImpl } from "./effectful-impl.ts";
|
||||
|
||||
/**
|
||||
* Effectful MicroVM image on **bun** — a bundled Effect program exposing a raw
|
||||
* `fetch` handler and a typed RPC `hello` method. Pairs with the bun baseline
|
||||
* ({@link import("./bun-image.ts")}): same runtime + ARM_64 arch, the only
|
||||
* difference being the bundled Effect runtime / alchemy bootstrap. Compare to
|
||||
* {@link import("./effectful-node.ts").EffectfulNode} for the node-vs-bun delta.
|
||||
*/
|
||||
export class EffectfulBun extends AWS.Lambda.MicrovmImage<
|
||||
EffectfulBun,
|
||||
{
|
||||
hello: (message: string) => Effect.Effect<string>;
|
||||
}
|
||||
>()("MicrovmEffectfulBun") {}
|
||||
|
||||
export default EffectfulBun.make(
|
||||
MicrovmBuildRole.pipe(
|
||||
Effect.map((buildRole) => ({
|
||||
main: import.meta.filename,
|
||||
buildRole,
|
||||
runtime: "bun" as const,
|
||||
resources: [{ minimumMemoryInMiB: 512 }],
|
||||
cpuConfigurations: [{ architecture: "ARM_64" }],
|
||||
})),
|
||||
),
|
||||
effectfulImpl,
|
||||
);
|
||||
@@ -0,0 +1,35 @@
|
||||
import * as Cloudflare from "alchemy/Cloudflare";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
|
||||
|
||||
/**
|
||||
* Minimal Effect-native container for the cold-start benchmark. Alchemy bundles
|
||||
* this file's Effect program into a generated image; the DO proxies a trivial
|
||||
* `ping()` RPC into it, which is enough to prove the container is up and
|
||||
* accepting connections on its RPC port.
|
||||
*/
|
||||
export class EffectfulContainer extends Cloudflare.Container<
|
||||
EffectfulContainer,
|
||||
{
|
||||
ping: () => Effect.Effect<string>;
|
||||
}
|
||||
>()("BenchEffectfulContainer") {}
|
||||
|
||||
export default EffectfulContainer.make(
|
||||
{
|
||||
main: import.meta.filename,
|
||||
image: "oven/bun:latest",
|
||||
// Match wrangler's container config so the comparison isolates the
|
||||
// framework, not the tier: max_instances 100 (Alchemy defaults to 1),
|
||||
// instance_type "lite", and instances 0 (pure scale-from-zero).
|
||||
maxInstances: 100,
|
||||
instanceType: "lite",
|
||||
instances: 0,
|
||||
},
|
||||
Effect.gen(function* () {
|
||||
return {
|
||||
ping: () => Effect.succeed("pong"),
|
||||
fetch: Effect.succeed(HttpServerResponse.text("ok")),
|
||||
};
|
||||
}),
|
||||
);
|
||||
@@ -0,0 +1,24 @@
|
||||
import * as Effect from "effect/Effect";
|
||||
import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
|
||||
import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
|
||||
|
||||
/**
|
||||
* The effectful MicroVM server, shared verbatim by the bun and node effectful
|
||||
* images so the only thing that differs between them is the JS runtime. Exposes
|
||||
* a raw `fetch` handler (with an `/echo` route) and a typed RPC `hello` method.
|
||||
*/
|
||||
export const effectfulImpl = Effect.gen(function* () {
|
||||
return {
|
||||
fetch: Effect.gen(function* () {
|
||||
const request = yield* HttpServerRequest;
|
||||
const url = new URL(request.url, "http://microvm");
|
||||
if (url.pathname === "/echo") {
|
||||
return yield* HttpServerResponse.json({
|
||||
message: url.searchParams.get("message") ?? "",
|
||||
});
|
||||
}
|
||||
return HttpServerResponse.text("hello from effectful microvm");
|
||||
}),
|
||||
hello: (message: string) => Effect.succeed(`hello, ${message}!`),
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import * as AWS from "alchemy/AWS";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { MicrovmBuildRole } from "./build-role.ts";
|
||||
import { effectfulImpl } from "./effectful-impl.ts";
|
||||
|
||||
/**
|
||||
* Effectful MicroVM image on **node** — identical server to the bun effectful
|
||||
* {@link import("./effectful-bun.ts").EffectfulBun}, but bundled for the node
|
||||
* runtime (`dnf install -y nodejs`, no bun install). Since the Lambda MicroVM
|
||||
* base ships node, this avoids the bun installer step entirely; comparing it to
|
||||
* the bun effectful isolates the runtime's contribution to cold start.
|
||||
*/
|
||||
export class EffectfulNode extends AWS.Lambda.MicrovmImage<
|
||||
EffectfulNode,
|
||||
{
|
||||
hello: (message: string) => Effect.Effect<string>;
|
||||
}
|
||||
>()("MicrovmEffectfulNode") {}
|
||||
|
||||
export default EffectfulNode.make(
|
||||
MicrovmBuildRole.pipe(
|
||||
Effect.map((buildRole) => ({
|
||||
main: import.meta.filename,
|
||||
buildRole,
|
||||
runtime: "node" as const,
|
||||
resources: [{ minimumMemoryInMiB: 512 }],
|
||||
cpuConfigurations: [{ architecture: "ARM_64" }],
|
||||
})),
|
||||
),
|
||||
effectfulImpl,
|
||||
);
|
||||
@@ -0,0 +1,50 @@
|
||||
import * as Cloudflare from "alchemy/Cloudflare";
|
||||
import * as Effect from "effect/Effect";
|
||||
import * as Schedule from "effect/Schedule";
|
||||
import { EffectfulContainer } from "./effectful-container.ts";
|
||||
|
||||
/**
|
||||
* Durable Object backing one effectful container instance. `boot()` blocks
|
||||
* until the container is accepting RPC (`ping()` answers). NOTE: the
|
||||
* authoritative cold-start clock runs in the Worker AROUND the whole DO call —
|
||||
* the container layer eagerly starts the container during DO construction, so
|
||||
* a clock started here would miss part of the start.
|
||||
*
|
||||
* Each distinct `getByName(name)` is a distinct DO instance and therefore a
|
||||
* distinct container instance, which is how the benchmark spins up N of them.
|
||||
*/
|
||||
export class EffectfulObject extends Cloudflare.DurableObject<EffectfulObject>()(
|
||||
"BenchEffectfulObject",
|
||||
Effect.gen(function* () {
|
||||
const container = yield* EffectfulContainer;
|
||||
|
||||
return Effect.gen(function* () {
|
||||
return {
|
||||
// Time container cold-start → reachable (RPC answers). Leaves the
|
||||
// container running so the benchmark can `shutdown()` it separately —
|
||||
// the timing must not include teardown. A freshly-built image is still
|
||||
// distributing to the edge metal on the first boots, so retry until the
|
||||
// RPC port answers.
|
||||
boot: () =>
|
||||
Effect.gen(function* () {
|
||||
const start = yield* Effect.sync(() => Date.now());
|
||||
yield* container.ping().pipe(
|
||||
Effect.retry({
|
||||
schedule: Schedule.min([Schedule.exponential("1 second"), Schedule.spaced("5 seconds")]),
|
||||
times: 40,
|
||||
}),
|
||||
);
|
||||
const readyMs = (yield* Effect.sync(() => Date.now())) - start;
|
||||
return { readyMs };
|
||||
}),
|
||||
shutdown: () => container.destroy().pipe(Effect.ignore),
|
||||
};
|
||||
});
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
Cloudflare.Containers.layer(EffectfulContainer, {
|
||||
enableInternet: true,
|
||||
}),
|
||||
),
|
||||
),
|
||||
) {}
|
||||
@@ -0,0 +1,29 @@
|
||||
import * as AWS from "alchemy/AWS";
|
||||
import * as Effect from "effect/Effect";
|
||||
import { MicrovmBuildRole } from "./build-role.ts";
|
||||
|
||||
/**
|
||||
* Non-Effect ("external") MicroVM image — built server-side from a plain
|
||||
* Dockerfile (a tiny Python HTTP server on :8080). No Effect program is
|
||||
* bundled and no in-VM runtime is injected; it is the AWS analog of the
|
||||
* Cloudflare `bun`/`remote` container variants.
|
||||
*/
|
||||
export class ExternalMicrovm extends AWS.Lambda.MicrovmImage<ExternalMicrovm>()(
|
||||
"MicrovmBenchExternal",
|
||||
) {}
|
||||
|
||||
export default ExternalMicrovm.make(
|
||||
MicrovmBuildRole.pipe(
|
||||
Effect.map((buildRole) => ({
|
||||
context: new URL("../contexts/microvm-python/", import.meta.url).pathname,
|
||||
buildRole,
|
||||
// Pin memory to match the effectful image so both fit the per-account
|
||||
// MicroVM memory quota at the benchmark's concurrency. Keep the default
|
||||
// x86_64 arch — forcing ARM_64 breaks the Python image build.
|
||||
resources: [{ minimumMemoryInMiB: 512 }],
|
||||
})),
|
||||
),
|
||||
// External mode builds from the Dockerfile; there is no Effect runtime to
|
||||
// bundle, so the impl shape is empty.
|
||||
Effect.succeed({}),
|
||||
);
|
||||