Skip to content

Commit 3ae2754

Browse files
committed
Merge branch 'upstream/main' into main
2 parents 9bbc45f + c1b2210 commit 3ae2754

323 files changed

Lines changed: 16287 additions & 2648 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.agents/skills/ios-debugger-agent/SKILL.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Avoid generic Mac window automation for switching among Simulator windows. Expli
3131

3232
## Choose build or launch
3333

34+
For T3 Code Mobile, run `node scripts/mobile-native-client.ts ensure ios <simulator-udid>` from the checkout on the simulator host first. It checks the local Expo native fingerprint against the installed client and builds/installs when stale, missing, or unknown. Then launch with the intended Metro bundle. Authorized verification includes native builds and installs; do not stop because the existing client is old. Use `check` instead of `ensure` only when the user explicitly prohibits rebuilding or requests a read-only check.
35+
3436
- Use `build_run_sim` when native source, native dependencies, entitlements, or project configuration changed.
3537
- Use `test_sim` for the smallest relevant native test target or test cases; do not run an entire workspace test matrix routinely.
3638
- Use `launch_app_sim` when a compatible app is already installed and no native rebuild is needed.

‎.agents/skills/test-t3-mobile/SKILL.md‎

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,28 @@ Inspect the host and the affected code before launching processes:
1515

1616
- On macOS with Xcode, prefer one representative iOS Simulator when the change is cross-platform so the user can watch through serve-sim. Load and follow [`ios-debugger-agent`](../ios-debugger-agent/SKILL.md), and load [`ios-simulator-browser`](../ios-simulator-browser/SKILL.md) when live streaming is available.
1717
- On macOS, Linux, or Windows with the Android SDK, use one Android Emulator when Android is the affected surface or iOS tooling is unavailable.
18-
- When the change is platform-specific, test that platform. When neither platform is viable, report the missing SDK, emulator, or dev-client prerequisite rather than claiming verification.
18+
- When the change is platform-specific, test that platform. When neither platform is viable, report the missing SDK or emulator prerequisite rather than claiming verification. A missing development client is a build step, not a blocker.
1919

2020
Do not treat unavailable iOS tooling as a blocker when Android is a valid representative target.
2121

22-
## Choose the lightest valid launch path
22+
## Ensure a compatible native client
2323

24-
- For JavaScript, TypeScript, or asset-only changes, reuse a compatible installed development client and start Metro. Do not rebuild native code merely to load a new bundle.
25-
- For native source, native dependencies, entitlements, config plugins, or generated project changes, rebuild the affected platform.
26-
- Use `vp run ios:dev` or `vp run android:dev` only when an Expo clean prebuild is actually required; both commands regenerate the native project.
27-
- If the user requested no native rebuild and no compatible app is installed, reuse an existing compatible `.app` or `.apk` artifact when available. Otherwise report the missing dev client instead of silently rebuilding.
24+
Authorized mobile verification includes building and installing a development client. A missing, stale, or unknown native client is not a reason to skip verification or leave a PR in draft. Build and install it, then continue. Respect an explicit user instruction not to rebuild; otherwise do not ask for separate permission.
2825

29-
The development identity on both platforms is:
26+
Run this from the checkout being tested, on the machine that hosts the selected simulator or emulator. Select and boot one explicit iOS UDID or Android emulator serial first:
3027

31-
- App: `T3 Code Dev`
32-
- Bundle/package identifier: `com.t3tools.t3code.dev`
33-
- URL scheme: `t3code-dev`
28+
```bash
29+
node scripts/mobile-native-client.ts ensure ios <simulator-udid>
30+
node scripts/mobile-native-client.ts ensure android <emulator-serial>
31+
```
32+
33+
`ensure` compares the checkout's local Expo development fingerprint and the installed app's binary contents against the last successful build record. It reuses a matching client; otherwise it runs a clean prebuild, builds and installs the development app, and records the successful result. It does not start Metro. Start Metro below after it succeeds. On hosts with an `agent-job` requirement, run the entire `ensure` command through that queue.
34+
35+
For a read-only decision, use `check` in place of `ensure`. Exit 0 means compatible, 2 means build required, and 1 means an operational error. An app installed outside this helper is initially unknown and gets rebuilt once. Records are local to the simulator host under `~/.cache/t3code/native-clients` and work across checkouts. Do not copy records between machines or write them manually.
36+
37+
A JavaScript-only diff, bundle identifier, app version, or recent install date does not prove native compatibility. Always check the whole checkout. Expo fingerprints are computed locally with `APP_VARIANT=development`; no EAS credentials or cloud build are required. Generated `ios/` and `android/` directories are excluded by `.fingerprintignore`, so edit native source modules or config plugins rather than generated output.
3438

35-
Bundle or package presence proves the correct variant, not native compatibility. Reuse it only when the current changes did not alter its Expo SDK, native dependencies, config plugins, entitlements, generated project, or native source.
39+
The development identity is `T3 Code Dev`, bundle/package `com.t3tools.t3code.dev`, scheme `t3code-dev`. If a build fails, investigate the build error and fix the local prerequisites. Report the concrete failure if it cannot be resolved, not “no compatible client.”
3640

3741
## Start one disposable T3 environment
3842

@@ -98,21 +102,19 @@ Use `ios-debugger-agent` to select one UDID and set these XcodeBuildMCP session
98102
- Simulator ID: the selected UDID
99103
- Bundle ID: `com.t3tools.t3code.dev`
100104

101-
Check the installed client with:
105+
After `ensure` succeeds, open the Metro URL:
102106

103107
```bash
104-
xcrun simctl get_app_container <simulator-udid> com.t3tools.t3code.dev app
105108
xcrun simctl openurl <simulator-udid> <printed-dev-client-url>
106109
```
107110

108111
Accept the iOS confirmation prompt and dismiss the developer menu when it obscures the app.
109112

110113
### Android launch
111114

112-
Select one running emulator serial from `adb devices` and check the installed client:
115+
Use the emulator serial already checked by `ensure`:
113116

114117
```bash
115-
adb -s <emulator-serial> shell pm path com.t3tools.t3code.dev
116118
adb -s <emulator-serial> reverse tcp:<metro-port> tcp:<metro-port>
117119
adb -s <emulator-serial> shell am start -W \
118120
-a android.intent.action.VIEW \

‎.github/VOUCHED.td‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ github:D3OXY
2525
github:dbalders
2626
github:eggfriedrice24
2727
github:extoci
28+
github:f-trycua
2829
github:flamboh
2930
github:FllipEis
3031
github:gbarros-dev
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""Stage an untrusted preview ZIP without letting it replace packaging code."""
2+
3+
import shutil
4+
import stat
5+
import sys
6+
import zipfile
7+
from pathlib import Path
8+
9+
ROOTS = ("server/dist", "desktop/dist-electron")
10+
REQUIRED_FILES = {
11+
"server/dist/bin.mjs",
12+
"server/dist/client/index.html",
13+
"desktop/dist-electron/main.cjs",
14+
}
15+
# The current bundle is about 32 MiB compressed. Bound extraction on the
16+
# trusted runner even when the PR replaces the uploader entirely.
17+
MAX_ARCHIVE_BYTES = 512 * 1024 * 1024
18+
MAX_EXPANDED_BYTES = 2 * 1024 * 1024 * 1024
19+
MAX_ENTRIES = 50_000
20+
21+
22+
def stage_bundle(archive: Path, destination: Path):
23+
if archive.stat().st_size > MAX_ARCHIVE_BYTES:
24+
raise ValueError("Preview archive is too large")
25+
with zipfile.ZipFile(archive) as bundle:
26+
entries = bundle.infolist()
27+
if len(entries) > MAX_ENTRIES:
28+
raise ValueError("Preview archive has too many entries")
29+
if sum(entry.file_size for entry in entries) > MAX_EXPANDED_BYTES:
30+
raise ValueError("Expanded preview bundle is too large")
31+
seen = set()
32+
files = set()
33+
for entry in entries:
34+
name = entry.filename.removesuffix("/")
35+
parts = name.split("/")
36+
# Reject ambiguous paths before normalization, including names
37+
# that would alias on the macOS signing runner.
38+
if (
39+
entry.orig_filename != entry.filename
40+
or any(part in ("", ".", "..") for part in parts)
41+
or any(char in name for char in "\\:")
42+
or not name.isascii()
43+
or any(ord(char) < 32 or ord(char) == 127 for char in name)
44+
):
45+
raise ValueError(f"Unsafe preview path: {entry.filename!r}")
46+
allowed = any(name.startswith(root + "/") for root in ROOTS)
47+
if entry.is_dir():
48+
allowed |= any(root == name or root.startswith(name + "/") for root in ROOTS)
49+
if not allowed:
50+
raise ValueError(f"Unexpected preview path: {name!r}")
51+
kind = stat.S_IFMT(entry.external_attr >> 16)
52+
if kind not in (0, stat.S_IFDIR if entry.is_dir() else stat.S_IFREG):
53+
raise ValueError(f"Non-regular preview entry: {name!r}")
54+
if name.casefold() in seen:
55+
raise ValueError(f"Duplicate preview path: {name!r}")
56+
seen.add(name.casefold())
57+
if not entry.is_dir():
58+
files.add(name)
59+
if not REQUIRED_FILES <= files:
60+
raise ValueError("Preview bundle is missing required entry points")
61+
# Validate all names before writing anything. This is a fresh directory
62+
# outside the checkout; neither pre-existing links nor trusted files
63+
# can be followed or overwritten. ZIP permissions are never restored.
64+
destination.mkdir(parents=True, exist_ok=False)
65+
for entry in entries:
66+
target = destination / entry.filename
67+
if entry.is_dir():
68+
target.mkdir(parents=True, exist_ok=True)
69+
else:
70+
target.parent.mkdir(parents=True, exist_ok=True)
71+
with bundle.open(entry) as source, target.open("xb") as output:
72+
shutil.copyfileobj(source, output)
73+
74+
75+
if __name__ == "__main__":
76+
stage_bundle(Path(sys.argv[1]), Path(sys.argv[2]))
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
import importlib.util
2+
import stat
3+
import tempfile
4+
import unittest
5+
import zipfile
6+
from pathlib import Path
7+
from unittest.mock import patch
8+
9+
spec = importlib.util.spec_from_file_location(
10+
"stage_preview_bundle", Path(__file__).with_name("stage-preview-bundle.py")
11+
)
12+
staging = importlib.util.module_from_spec(spec)
13+
spec.loader.exec_module(staging)
14+
15+
16+
class StagePreviewBundleTests(unittest.TestCase):
17+
def setUp(self):
18+
self.temp = tempfile.TemporaryDirectory()
19+
self.addCleanup(self.temp.cleanup)
20+
self.root = Path(self.temp.name)
21+
self.archive = self.root / "bundle.zip"
22+
self.destination = self.root / "staged"
23+
24+
def bundle(self, extra=(), missing=None):
25+
with zipfile.ZipFile(self.archive, "w") as bundle:
26+
for name in sorted(staging.REQUIRED_FILES - {missing}):
27+
bundle.writestr(name, b"bundle data, never executed")
28+
for name, content in extra:
29+
bundle.writestr(name, content)
30+
31+
def stage(self):
32+
staging.stage_bundle(self.archive, self.destination)
33+
34+
def test_preserves_valid_bundle_layout_and_bytes(self):
35+
self.bundle([("server/", b""), ("server/dist/", b""),
36+
("desktop/dist-electron/chunks/helper.cjs", b"chunk")])
37+
self.stage()
38+
for name in staging.REQUIRED_FILES:
39+
self.assertEqual((self.destination / name).read_bytes(), b"bundle data, never executed")
40+
self.assertEqual((self.destination / "desktop/dist-electron/chunks/helper.cjs").read_bytes(), b"chunk")
41+
42+
def test_rejects_builder_overwrite_and_unsafe_paths_before_writing(self):
43+
for name in [
44+
"desktop/node_modules/electron-builder/cli.js",
45+
"desktop/package.json",
46+
"server/dist/../../desktop/package.json",
47+
"../package.json",
48+
"/server/dist/absolute",
49+
"server/dist/./alias",
50+
"server/dist//alias",
51+
"server/dist/back\\slash",
52+
"server/dist/file:stream",
53+
"server/dist/BIN.MJS",
54+
]:
55+
with self.subTest(name=name):
56+
self.bundle([(name, b"untrusted")])
57+
with self.assertRaises(ValueError):
58+
self.stage()
59+
self.assertFalse(self.destination.exists())
60+
61+
def test_rejects_links_and_special_files(self):
62+
for mode in [stat.S_IFLNK, stat.S_IFIFO, stat.S_IFCHR]:
63+
with self.subTest(mode=mode):
64+
entry = zipfile.ZipInfo("server/dist/link")
65+
entry.create_system = 3
66+
entry.external_attr = (mode | 0o777) << 16
67+
self.bundle([(entry, b"../../../desktop/node_modules")])
68+
with self.assertRaises(ValueError):
69+
self.stage()
70+
self.assertFalse(self.destination.exists())
71+
72+
def test_requires_entry_points(self):
73+
self.bundle(missing="desktop/dist-electron/main.cjs")
74+
with self.assertRaises(ValueError):
75+
self.stage()
76+
self.assertFalse(self.destination.exists())
77+
78+
def test_bounds_archive_size_expanded_size_and_entry_count(self):
79+
for limit in ["MAX_ARCHIVE_BYTES", "MAX_EXPANDED_BYTES", "MAX_ENTRIES"]:
80+
with self.subTest(limit=limit), patch.object(staging, limit, 1):
81+
self.bundle()
82+
with self.assertRaises(ValueError):
83+
self.stage()
84+
self.assertFalse(self.destination.exists())
85+
86+
def test_refuses_existing_destination(self):
87+
self.bundle()
88+
self.destination.mkdir()
89+
sentinel = self.destination / "trusted"
90+
sentinel.write_text("untouched")
91+
with self.assertRaises(FileExistsError):
92+
self.stage()
93+
self.assertEqual(sentinel.read_text(), "untouched")
94+
95+
96+
if __name__ == "__main__":
97+
unittest.main()

‎.github/workflows/ci.yml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ jobs:
103103
sudo sed -i 's|http://|https://|g' /etc/apt/blacksmith-ubuntu-mirrors.txt /etc/apt/sources.list.d/ubuntu.sources
104104
sudo apt-get update && sudo apt-get install -y libsecret-1-dev pkg-config
105105
106+
- name: Test preview artifact validation
107+
run: python3 -B .github/scripts/stage-preview-bundle.test.py
108+
106109
- name: Test nightly release checks
107110
run: node --test .github/scripts/check-nightly-release.test.cjs
108111

0 commit comments

Comments
 (0)