Skip to content

Commit 542ac9a

Browse files
authored
fix: make live updater checkout portable (oc-237) (#122873)
1 parent a3207b5 commit 542ac9a

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎.agents/skills/openclaw-live-updater/SKILL.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "Maintain the canonical live OpenClaw main checkout, managed Gatewa
55

66
# OpenClaw Live Updater
77

8-
Keep `/Users/steipete/openclaw` a read-only-to-the-agent deployment mirror: clean, standalone, full, on `main`, and fast-forwarded only. Make every repair in the controlling Codex project worktree.
8+
Keep one operator-selected canonical live checkout as a read-only-to-the-agent deployment mirror: clean, standalone, full, on `main`, and fast-forwarded only. Make every repair in the controlling Codex project worktree.
99

1010
## Boundaries
1111

@@ -20,10 +20,11 @@ Keep `/Users/steipete/openclaw` a read-only-to-the-agent deployment mirror: clea
2020
1. Run the deterministic updater and retain its JSON:
2121

2222
```bash
23+
cd "<canonical-live-checkout>"
2324
node --import tsx .agents/skills/openclaw-live-updater/scripts/update-main.mjs
2425
```
2526

26-
Stop on any failed invariant. Do not repair the mirror destructively. The helper holds one checkout-scoped lock across update, build, Gateway proof, and Mac work. A concurrent heartbeat returns `reason: "overlap"`; it must not start another build. A dead owner lock may be recovered, but unreadable or unsafe lock state fails closed.
27+
The helper owns the current working directory by default; it does not search parent directories or infer a clone from the user's home directory. From a controlling worktree, pass the canonical mirror explicitly with `--checkout "<canonical-live-checkout>"`. Stop on any failed invariant. Do not repair the mirror destructively. The helper holds one checkout-scoped lock across update, build, Gateway proof, and Mac work. A concurrent heartbeat returns `reason: "overlap"`; it must not start another build. A dead owner lock may be recovered, but unreadable or unsafe lock state fails closed.
2728

2829
2. The helper verifies one unrewritten expected origin, an owned non-symlinked standalone/full clone, single worktree, clean `main`, fetches `origin/main`, rechecks for concurrent changes, and merges `--ff-only`. It then uses the source runner's canonical local-build metadata contract and parser: both `dist/.buildstamp` and `dist/.runtime-postbuildstamp` heads, required runtime-postbuild outputs, `dist/entry.js`, Control UI index plus referenced local assets, and `dist/build-info.json` must all match exact `afterSha`.
2930

@@ -39,7 +40,7 @@ Keep `/Users/steipete/openclaw` a read-only-to-the-agent deployment mirror: clea
3940

4041
Re-run the canonical freshness check immediately before every `pnpm openclaw` restart or probe so the source runner cannot hide stale output with an implicit auto-build. Every pass, including a no-update/current-build pass, must run deep RPC status and verbose health. If that first probe fails while the build is already exact-current, perform one managed Gateway restart and repeat both probes once. Do not rebuild a current exact-SHA artifact merely to self-heal the managed process; fail and diagnose if the one restart does not recover it.
4142

42-
3. If changed paths can affect macOS, the helper runs `scripts/restart-mac.sh --sign --wait --target-only` with `SKIP_TSC=1` and `SKIP_UI_BUILD=1` only after the exact-SHA JS/UI build completes. Reusing those artifacts keeps the live app bundle out of any later JavaScript build cleanup. Target-only mode may stop the canonical `/Applications/OpenClaw.app` process and this checkout's exact `dist` process before launching the rebuilt `dist` app. It defers when another worktree, temporary bundle, test, or agent-owned OpenClaw process is active; it never kills that process. The script's immediate `OK` is not proof. The helper waits and requires the exact executable `/Users/steipete/openclaw/dist/OpenClaw.app/Contents/MacOS/OpenClaw`, then repeats Gateway RPC and health proof.
43+
3. If changed paths can affect macOS, the helper runs `scripts/restart-mac.sh --sign --wait --target-only` with `SKIP_TSC=1` and `SKIP_UI_BUILD=1` only after the exact-SHA JS/UI build completes. Reusing those artifacts keeps the live app bundle out of any later JavaScript build cleanup. Target-only mode may stop the canonical `/Applications/OpenClaw.app` process and this checkout's exact `dist` process before launching the rebuilt `dist` app. It defers when another worktree, temporary bundle, test, or agent-owned OpenClaw process is active; it never kills that process. The script's immediate `OK` is not proof. The helper waits and requires the exact executable `<canonical-live-checkout>/dist/OpenClaw.app/Contents/MacOS/OpenClaw`, derived from the verified checkout, then repeats Gateway RPC and health proof.
4344

4445
Never kill another worktree, temporary bundle, test, or agent-owned OpenClaw process. If a foreign app prevents the exact target from staying alive, record the pending Mac attempt, report it, and retry on the next heartbeat. Escalate only after the conflict persists across repeated heartbeats; never claim Mac proof from another bundle or the short launch check. If `actions.macUiVerification` is true, exercise the changed behavior with the existing macOS/UI automation workflow after delayed exact-bundle proof.
4546

‎.agents/skills/openclaw-live-updater/scripts/update-main.mjs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import {
3535
resolveRuntimePostBuildRequirement,
3636
} from "../../../../scripts/run-node.mts";
3737

38-
const DEFAULT_CHECKOUT = "/Users/steipete/openclaw";
3938
const DEFAULT_EXPECTED_ORIGIN = "openclaw/openclaw";
4039
const FULL_SHA_RE = /^[0-9a-f]{40}$/u;
4140
const GATEWAY_READINESS_ATTEMPTS = 7;
@@ -3800,7 +3799,7 @@ export async function maintainMain(options, dependencies = {}) {
38003799
}
38013800

38023801
function parseArgs(argv) {
3803-
const options = { checkout: DEFAULT_CHECKOUT, remote: "origin" };
3802+
const options = { checkout: process.cwd(), remote: "origin" };
38043803
for (let index = 0; index < argv.length; index += 1) {
38053804
const arg = argv[index];
38063805
if (arg === "--checkout") {

‎test/scripts/openclaw-live-updater.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ console.log(JSON.stringify({ ok: true, channels: {} }));
15371537
});
15381538

15391539
test("accepts only the delayed exact target bundle process", () => {
1540-
const executable = "/Users/steipete/openclaw/dist/OpenClaw.app/Contents/MacOS/OpenClaw";
1540+
const executable = "/fixture/live-checkout/dist/OpenClaw.app/Contents/MacOS/OpenClaw";
15411541
const foreign = "41 /tmp/agent/OpenClaw.app/Contents/MacOS/OpenClaw";
15421542
expect(findExactMacTarget(foreign, executable)).toBeNull();
15431543
expect(findExactMacTarget(`${foreign}\n42 ${executable} --attach-only`, executable)).toEqual({
@@ -3436,7 +3436,7 @@ console.log(JSON.stringify({ ok: true, channels: {} }));
34363436
});
34373437
});
34383438

3439-
test("keeps successful CLI stdout as one machine-readable JSON object", () => {
3439+
test("defaults to the current standalone checkout without a machine-specific path", () => {
34403440
const { root, mirror, origin } = makeFixture();
34413441
mkdirSync(path.join(mirror, "node_modules"));
34423442
writeBuild(mirror);
@@ -3453,14 +3453,19 @@ console.log(JSON.stringify({ ok: true, channels: {} }));
34533453
chmodSync(pnpm, 0o755);
34543454
chmodSync(gitShim, 0o755);
34553455

3456-
const result = spawnSync(process.execPath, [script, "--checkout", mirror], {
3456+
const result = spawnSync(process.execPath, [script], {
3457+
cwd: mirror,
34573458
encoding: "utf8",
34583459
env: { ...process.env, PATH: `${binDir}:${process.env.PATH}` },
34593460
});
34603461

34613462
expect(result.status, result.stderr).toBe(0);
34623463
expect(result.stdout.trim().split("\n")).toHaveLength(1);
3463-
expect(JSON.parse(result.stdout)).toMatchObject({ ok: true, updated: false });
3464+
expect(JSON.parse(result.stdout)).toMatchObject({
3465+
ok: true,
3466+
checkout: realpathSync(mirror),
3467+
updated: false,
3468+
});
34643469
expect(result.stderr).toContain("child-output");
34653470
});
34663471

0 commit comments

Comments
 (0)