Skip to content

Commit dd4528b

Browse files
authored
fix(macos): pair app builds with verified node workers (#131466)
Pair packaged apps with complete private arm64 and x86_64 workers whose full build identity matches the app. Preserve independently managed Gateways and complete recognized native-first state through the canonical initializer. Verify emitted-SDK filesystem calls, native capabilities, readiness and shutdown before app publication. Derive elevation payloads without modifying canonical installed inputs. Preserve universal slices, resources and contained links; reject incomplete, malformed, escaping or mismatched payloads. Reuse descriptor-bound native inventory for signing while retaining the portable installer's independent distribution contract and every Foundation identity, entitlement, notarization and architecture gate. Use the existing pinned-pnpm package path, including Corepack-only builders, and avoid recursive app-glob expansion. Centralize Mac CI ownership. Carry invocation-owned Git lock cleanup into main's canonical Git owner and regenerate its workflow projection, retaining lifetime fencing and pre-existing/junction-linked locks. Fix the Android refresh race exposed by CI by removing the redundant reconnect after connect already replaces each role's socket. Preserve authentication, scopes and physical connection leases, with a controlled real-WebSocket regression. Closes #131459
1 parent 7f4c9b7 commit dd4528b

104 files changed

Lines changed: 8668 additions & 1041 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.

‎.github/actions/ensure-base-commit/policy.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ def ensure_base():
5252
for arguments, message, warning, resolution in attempts:
5353
print(message, flush=True)
5454
try:
55-
run_git(os.getcwd(), "-c", "protocol.version=2", "fetch", *arguments, timeout=30)
55+
run_git(os.getcwd(), "-c", "protocol.version=2", "fetch", *arguments,
56+
timeout=30, reclaim_locks=True)
5657
except (GitFailure, FetchTimeout):
5758
# A failed fetch can still supply the base. Lifecycle failures and
5859
# cancellation escape this policy before any availability probe.

‎.github/actions/git-owner/owner.py‎

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,37 @@ def __init__(self, code):
183183
self.code = code
184184

185185

186-
def run_git(directory, *arguments, timeout=None, stdout=None, stderr=None, env=None):
186+
def git_lock_files(directory):
187+
git_dir = os.path.join(os.path.realpath(directory), ".git")
188+
if not os.path.lexists(git_dir):
189+
return set()
190+
if not os.path.isdir(git_dir) or os.path.realpath(git_dir) != git_dir:
191+
raise RuntimeError("Checkout Git directory is not physical")
192+
def scan_error(error):
193+
raise error
194+
locks = set()
195+
for root, directories, files in os.walk(git_dir, onerror=scan_error):
196+
directories[:] = [name for name in directories
197+
if os.path.realpath(os.path.join(root, name)) == os.path.join(root, name)]
198+
locks.update(os.path.join(root, name) for name in files if name.endswith(".lock"))
199+
return locks
200+
201+
202+
def run_git(directory, *arguments, timeout=None, stdout=None, stderr=None, env=None,
203+
reclaim_locks=False):
187204
global closed
188205
if closed:
189206
raise RuntimeError("Git owner is closed")
190207
check_cancelled()
191208
if git is None:
192209
raise RuntimeError("Git unavailable")
210+
# Process ownership alone does not grant metadata ownership: generic callers
211+
# may use linked worktrees. Only exclusive checkout fetches reclaim locks.
212+
previous_locks = git_lock_files(directory) if reclaim_locks else None
193213
command = [git, "-C", directory, *arguments]
194214
job = None
195215
child = None
216+
timed_out = False
196217
deadline = time.monotonic() + timeout if timeout is not None else None
197218
try:
198219
options = {"stdin": subprocess.DEVNULL, "stdout": stdout, "stderr": stderr,
@@ -217,6 +238,7 @@ def run_git(directory, *arguments, timeout=None, stdout=None, stderr=None, env=N
217238
os.set_handle_inheritable(job, False)
218239
while child.poll() is None and not cancelled:
219240
if deadline is not None and time.monotonic() >= deadline:
241+
timed_out = True
220242
raise FetchTimeout()
221243
time.sleep(0.05)
222244
finally:
@@ -226,6 +248,11 @@ def run_git(directory, *arguments, timeout=None, stdout=None, stderr=None, env=N
226248
try:
227249
if child is not None:
228250
drain(child, job)
251+
if previous_locks is not None and (timed_out or cancelled or child.returncode):
252+
# Forced termination skips Git's lockfile cleanup. This checkout is exclusive;
253+
# reclaim only newly created locks after tree extinction, never existing locks.
254+
for lock in sorted(git_lock_files(directory) - previous_locks):
255+
os.unlink(lock)
229256
finally:
230257
if job is not None:
231258
close_handle(job)
@@ -251,7 +278,7 @@ def fetch(directory, *refs, prune=False, max_attempts=3, depth=1,
251278
run_git(directory, "-c", "protocol.version=2", "fetch", "--no-tags",
252279
*(["--prune"] if prune else []), "--no-recurse-submodules", f"--depth={depth}",
253280
*(["--filter=blob:none"] if blobless else []), "origin", *refs,
254-
timeout=fetch_timeout_seconds)
281+
timeout=fetch_timeout_seconds, reclaim_locks=True)
255282
return
256283
except (FetchTimeout, GitFailure) as error:
257284
check_cancelled()
@@ -383,9 +410,10 @@ def main():
383410
raise RuntimeError("Git owner is closed")
384411
check_cancelled()
385412
return
386-
if sys.argv[1] != "--git":
413+
if sys.argv[1] not in ("--git", "--checkout-git"):
387414
raise ValueError("Unknown Git owner command")
388-
run_git(os.getcwd(), *sys.argv[3:], timeout=float(sys.argv[2]) or None)
415+
run_git(os.getcwd(), *sys.argv[3:], timeout=float(sys.argv[2]) or None,
416+
reclaim_locks=sys.argv[1] == "--checkout-git")
389417
return
390418
if git is None:
391419
raise RuntimeError("Git unavailable")

‎.github/workflows/ci.yml‎

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,16 +392,37 @@ jobs:
392392
self.code = code
393393

394394

395-
def run_git(directory, *arguments, timeout=None, stdout=None, stderr=None, env=None):
395+
def git_lock_files(directory):
396+
git_dir = os.path.join(os.path.realpath(directory), ".git")
397+
if not os.path.lexists(git_dir):
398+
return set()
399+
if not os.path.isdir(git_dir) or os.path.realpath(git_dir) != git_dir:
400+
raise RuntimeError("Checkout Git directory is not physical")
401+
def scan_error(error):
402+
raise error
403+
locks = set()
404+
for root, directories, files in os.walk(git_dir, onerror=scan_error):
405+
directories[:] = [name for name in directories
406+
if os.path.realpath(os.path.join(root, name)) == os.path.join(root, name)]
407+
locks.update(os.path.join(root, name) for name in files if name.endswith(".lock"))
408+
return locks
409+
410+
411+
def run_git(directory, *arguments, timeout=None, stdout=None, stderr=None, env=None,
412+
reclaim_locks=False):
396413
global closed
397414
if closed:
398415
raise RuntimeError("Git owner is closed")
399416
check_cancelled()
400417
if git is None:
401418
raise RuntimeError("Git unavailable")
419+
# Process ownership alone does not grant metadata ownership: generic callers
420+
# may use linked worktrees. Only exclusive checkout fetches reclaim locks.
421+
previous_locks = git_lock_files(directory) if reclaim_locks else None
402422
command = [git, "-C", directory, *arguments]
403423
job = None
404424
child = None
425+
timed_out = False
405426
deadline = time.monotonic() + timeout if timeout is not None else None
406427
try:
407428
options = {"stdin": subprocess.DEVNULL, "stdout": stdout, "stderr": stderr,
@@ -426,6 +447,7 @@ jobs:
426447
os.set_handle_inheritable(job, False)
427448
while child.poll() is None and not cancelled:
428449
if deadline is not None and time.monotonic() >= deadline:
450+
timed_out = True
429451
raise FetchTimeout()
430452
time.sleep(0.05)
431453
finally:
@@ -435,6 +457,11 @@ jobs:
435457
try:
436458
if child is not None:
437459
drain(child, job)
460+
if previous_locks is not None and (timed_out or cancelled or child.returncode):
461+
# Forced termination skips Git's lockfile cleanup. This checkout is exclusive;
462+
# reclaim only newly created locks after tree extinction, never existing locks.
463+
for lock in sorted(git_lock_files(directory) - previous_locks):
464+
os.unlink(lock)
438465
finally:
439466
if job is not None:
440467
close_handle(job)
@@ -460,7 +487,7 @@ jobs:
460487
run_git(directory, "-c", "protocol.version=2", "fetch", "--no-tags",
461488
*(["--prune"] if prune else []), "--no-recurse-submodules", f"--depth={depth}",
462489
*(["--filter=blob:none"] if blobless else []), "origin", *refs,
463-
timeout=fetch_timeout_seconds)
490+
timeout=fetch_timeout_seconds, reclaim_locks=True)
464491
return
465492
except (FetchTimeout, GitFailure) as error:
466493
check_cancelled()
@@ -592,9 +619,10 @@ jobs:
592619
raise RuntimeError("Git owner is closed")
593620
check_cancelled()
594621
return
595-
if sys.argv[1] != "--git":
622+
if sys.argv[1] not in ("--git", "--checkout-git"):
596623
raise ValueError("Unknown Git owner command")
597-
run_git(os.getcwd(), *sys.argv[3:], timeout=float(sys.argv[2]) or None)
624+
run_git(os.getcwd(), *sys.argv[3:], timeout=float(sys.argv[2]) or None,
625+
reclaim_locks=sys.argv[1] == "--checkout-git")
598626
return
599627
if git is None:
600628
raise RuntimeError("Git unavailable")
@@ -718,7 +746,7 @@ jobs:
718746
fi
719747
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ] && [ "$RELEASE_GATE" = "true" ]; then
720748
merge_ref="refs/remotes/origin/release-gate-merge"
721-
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --git 120 fetch \
749+
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --checkout-git 120 fetch \
722750
--no-tags --no-recurse-submodules --depth=2 origin \
723751
"+refs/pull/${PULL_REQUEST_NUMBER}/merge:${merge_ref}"
724752
release_gate_head="$(git rev-parse "${merge_ref}^2")"
@@ -1563,7 +1591,7 @@ jobs:
15631591
# Include the synthetic merge, every pull request commit, and one
15641592
# ancestor so TruffleHog can clone and resolve the bounded range.
15651593
fetch_depth=$((PR_COMMIT_COUNT + 2))
1566-
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --git 120 \
1594+
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --checkout-git 120 \
15671595
-c protocol.version=2 \
15681596
fetch --no-tags --no-recurse-submodules --depth="$fetch_depth" origin "$PR_MERGE_SHA"
15691597

@@ -2438,7 +2466,7 @@ jobs:
24382466
# Base freshness belongs to the landing gate; chasing moving main here can never converge.
24392467
prepared=false
24402468
for attempt in {1..6}; do
2441-
if python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --git 120 fetch --no-tags --depth=2 origin \
2469+
if python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --checkout-git 120 fetch --no-tags --depth=2 origin \
24422470
"+refs/pull/${PULL_REQUEST_NUMBER}/merge:refs/remotes/origin/ci-ratchet-merge"; then
24432471
merge_sha="$(git rev-parse refs/remotes/origin/ci-ratchet-merge)"
24442472
read -r frozen_base_sha merge_head extra_parent <<<"$(git show -s --format=%P "$merge_sha")"
@@ -2490,7 +2518,7 @@ jobs:
24902518
case "$TASK" in
24912519
bundled-protocol)
24922520
pnpm test:bundled
2493-
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --git 0 fetch --no-tags --no-recurse-submodules --depth=1 origin \
2521+
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --checkout-git 0 fetch --no-tags --no-recurse-submodules --depth=1 origin \
24942522
"+${PROTOCOL_SINCE_BASE_SHA}:refs/remotes/origin/protocol-since-base"
24952523
pnpm protocol:check
24962524
;;
@@ -3199,7 +3227,7 @@ jobs:
31993227
exit 1
32003228
fi
32013229
if [ -n "$PR_BASE_SHA" ]; then
3202-
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --git 120 fetch --no-tags --depth=1 origin "+${PR_BASE_SHA}:refs/remotes/origin/ci-base"
3230+
python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --checkout-git 120 fetch --no-tags --depth=1 origin "+${PR_BASE_SHA}:refs/remotes/origin/ci-base"
32033231
node scripts/report-test-temp-creations.mjs --base refs/remotes/origin/ci-base --head HEAD --no-merge-base
32043232
fi
32053233
pnpm deps:patches:check
@@ -3217,7 +3245,7 @@ jobs:
32173245
npm_lock_base=""
32183246
if [[ "${GITHUB_EVENT_NAME:-}" != "workflow_dispatch" && -n "$DIFF_BASE_SHA" ]] &&
32193247
has_package_script "deps:npm-lock:check:changed"; then
3220-
if python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --git 120 fetch --no-tags --depth=1 origin "+${DIFF_BASE_SHA}:refs/remotes/origin/npm-lock-base"; then
3248+
if python3 -I -S "$RUNNER_TEMP/ci-git-owner.py" --checkout-git 120 fetch --no-tags --depth=1 origin "+${DIFF_BASE_SHA}:refs/remotes/origin/npm-lock-base"; then
32213249
npm_lock_base="refs/remotes/origin/npm-lock-base"
32223250
else
32233251
fetch_status="$?"

0 commit comments

Comments
 (0)