Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

Merge remote PR hardening with verified runtime readiness

Rahmancd89e0e761c2
diff --cc bin/mso
index 114e0e75,aef943f0..39400ce3
--- a/bin/mso
+++ b/bin/mso
@@@ -210,19 -210,19 +210,21 @@@ service_unit_local_url()
}
service_wait_ready() {
- local base="$1" attempts="${MSO_SERVICE_HEALTH_ATTEMPTS:-40}" expected_version body i curl_bin="${MSO_CURL_BIN:-curl}"
- local local_url="$1" attempts="${MSO_SERVICE_READY_ATTEMPTS:-40}" body i
- [[ "$attempts" =~ ^[0-9]+$ ]] && [ "$attempts" -gt 0 ] || attempts=40
- for i in $(seq 1 "$attempts"); do
- body="$(curl --noproxy '*' -fsS --connect-timeout 1 --max-time 2 "$local_url/api/health" 2>/dev/null || true)"
- if printf '%s' "$body" | jq -e '
++ local local_url="$1" attempts="${MSO_SERVICE_READY_ATTEMPTS:-40}" expected_version body i curl_bin="${MSO_CURL_BIN:-curl}"
+ [[ "$attempts" =~ ^[0-9]+$ ]] && [ "$attempts" -ge 1 ] && [ "$attempts" -le 120 ] || attempts=40
+ expected_version="$(jq -r '.version // empty' "$ROOT/package.json" 2>/dev/null || true)"
+ [ -n "$expected_version" ] || return 1
+ for ((i = 1; i <= attempts; i++)); do
- body="$("$curl_bin" --noproxy '*' -fsS --max-time 1 "$base/api/health" 2>/dev/null || true)"
++ body="$("$curl_bin" --noproxy '*' -fsS --connect-timeout 1 --max-time 2 "$local_url/api/health" 2>/dev/null || true)"
+ if jq -e --arg version "$expected_version" '
- type == "object" and .status == "ok" and .version == $version and
- (.buildId | type == "string") and (.buildId | length > 0) and has("runtimeInstanceId")
+ type == "object" and .status == "ok" and .service == "mso" and
+ (.buildId | type == "string" and length > 0) and
+ (.buildSha | type == "string" and test("^[0-9a-f]{7,40}$")) and
- (.version | type == "string" and length > 0) and has("runtimeInstanceId")
- ' >/dev/null 2>&1; then
++ .version == $version and has("runtimeInstanceId")
+ ' <<<"$body" >/dev/null 2>&1; then
return 0
fi
- sleep 0.25
+ [ "$i" -ge "$attempts" ] || sleep 0.25
done
return 1
}
diff --cc bin/mso-service-lifecycle.test.ts
index 683ab50a,8380fa6b..5ded515b
--- a/bin/mso-service-lifecycle.test.ts
+++ b/bin/mso-service-lifecycle.test.ts
@@@ -13,17 -12,16 +13,17 @@@ function fixture()
const root = fs.mkdtempSync(path.join(os.tmpdir(), "mso-service-cli-")); roots.push(root);
const bin = path.join(root, "bin"), capture = path.join(root, "capture"), home = path.join(root, "home");
fs.mkdirSync(bin); fs.mkdirSync(home);
- fs.writeFileSync(path.join(bin, "curl"), `#!/bin/sh\n[ \"\${MSO_TEST_HEALTH_FAIL:-0}\" = 1 ] && exit 7\nprintf '%s\\n' '{\"status\":\"ok\",\"service\":\"mso\",\"buildId\":\"fixture\",\"buildSha\":\"abcdef1\",\"runtimeInstanceId\":null,\"version\":\"0.2.1\"}'\n`, { mode: 0o755 });
++ const curl = path.join(bin, "curl");
++ fs.writeFileSync(curl, `#!/bin/sh\nprintf 'curl %s\\n' "$*" >> "${capture}"\n[ \"\${MSO_TEST_HEALTH_FAIL:-0}\" = 1 ] && exit 7\nprintf '%s\\n' '{\"status\":\"ok\",\"service\":\"mso\",\"buildId\":\"fixture\",\"buildSha\":\"abcdef1\",\"runtimeInstanceId\":null,\"version\":\"${VERSION}\"}'\n`, { mode: 0o755 });
const manager = path.join(bin, "manager");
fs.writeFileSync(manager, `#!/bin/sh\nprintf 'manager %s\\n' "$*" >> "${capture}"\ncase "$*" in\n 'show -p WorkingDirectory --value mso.service') printf '%s\\n' "${process.cwd()}" ;;\n 'show -p Environment --value mso.service') printf 'PORT=4005\\n' ;;\n 'is-active --quiet mso.service') [ "\${MSO_TEST_SERVICE_ACTIVE:-1}" = 1 ] && exit 0; exit 3 ;;\n 'start mso.service'|'restart mso.service') [ "\${MSO_TEST_MANAGER_FAIL:-0}" = 1 ] && exit 23; exit 0 ;;\nesac\n`, { mode: 0o755 });
- const curl = path.join(bin, "curl");
- fs.writeFileSync(curl, `#!/bin/sh\nprintf 'curl %s\\n' "$*" >> "${capture}"\n[ "\${MSO_TEST_SERVICE_HEALTHY:-1}" = 1 ] || exit 22\nprintf '%s\\n' '{"status":"ok","version":"${VERSION}","buildId":"fixture","runtimeInstanceId":"service-fixture"}'\n`, { mode: 0o755 });
const helper = path.join(root, "service-update");
fs.writeFileSync(helper, `#!/bin/sh\nprintf 'helper %s\\n' "$*" >> "${capture}"\n`, { mode: 0o755 });
const gateway = path.join(root, "gateway");
fs.writeFileSync(gateway, `#!/bin/sh\nprintf 'gateway %s marker=%s local=%s\\n' "$*" "\${MSO_GATEWAY_RECOVERY_MARKER:-}" "\${MSO_GATEWAY_LOCAL_URL:-}" >> "${capture}"\ncase "$1" in\n runtime-assert-update-safe) [ "\${MSO_TEST_FALLBACK:-0}" = 1 ] && echo 'runtime: update-owned' || echo 'runtime: update-safe' ;;\n runtime-stop) [ -n "\${MSO_GATEWAY_RECOVERY_MARKER:-}" ] || exit 9; printf '1\\n' > "\$MSO_GATEWAY_RECOVERY_MARKER"; chmod 600 "\$MSO_GATEWAY_RECOVERY_MARKER"; echo 'runtime: stopped-owned' ;;\n local-start) echo 'runtime: healthy MSO at fixture' ;;\n *) exit 2 ;;\nesac\n`, { mode: 0o755 });
const exclusion = path.join(root, "runtime-exclusion");
- const env = { ...process.env, HOME: home, MSO_ENV: "/dev/null", MSO_GATEWAY_LOCAL_URL: "http://127.0.0.1:4005",
+ const env = { ...process.env, HOME: home, PATH: `${bin}:${process.env.PATH}`, MSO_ENV: "/dev/null", MSO_GATEWAY_LOCAL_URL: "http://127.0.0.1:4005",
- MSO_SYSTEMCTL_BIN: manager, MSO_SERVICE_UPDATE_BIN: helper, MSO_GATEWAY_BIN: gateway, MSO_RUNTIME_EXCLUSION_DIR: exclusion, MSO_SERVICE_HANDOFF_DIR: path.join(root, "handoff") };
+ MSO_SYSTEMCTL_BIN: manager, MSO_CURL_BIN: curl, MSO_SERVICE_UPDATE_BIN: helper, MSO_GATEWAY_BIN: gateway, MSO_RUNTIME_EXCLUSION_DIR: exclusion, MSO_SERVICE_HANDOFF_DIR: path.join(root, "handoff") };
return { root, capture, env, exclusion };
}
@@@ -79,18 -78,14 +80,15 @@@ describe("mso service/deploy runtime ex
expect(calls).toContain("gateway local-start");
});
-
- it("restores the gateway fallback if systemd starts but MSO never becomes healthy", () => {
+ it("restores the gateway fallback when Type=simple start returns before MSO becomes healthy", () => {
const f = fixture();
- const out = spawnSync(CLI, ["service", "start"], {
- env: { ...f.env, MSO_TEST_SERVICE_ACTIVE: "0", MSO_TEST_FALLBACK: "1", MSO_TEST_SERVICE_HEALTHY: "0", MSO_SERVICE_HEALTH_ATTEMPTS: "1" }, encoding: "utf8",
- });
+ const out = spawnSync(CLI, ["service", "start"], { env: { ...f.env, MSO_TEST_SERVICE_ACTIVE: "0", MSO_TEST_FALLBACK: "1", MSO_TEST_HEALTH_FAIL: "1", MSO_SERVICE_READY_ATTEMPTS: "1" }, encoding: "utf8" });
expect(out.status).not.toBe(0);
- expect(out.stderr).toContain("did not become healthy");
+ expect(out.stderr).toContain("/api/health did not become ready");
const calls = fs.readFileSync(f.capture, "utf8");
- expect(calls).toContain("gateway runtime-stop");
expect(calls).toContain("manager start mso.service");
- expect(calls).toContain("curl --noproxy * -fsS --max-time 1 http://127.0.0.1:4005/api/health");
+ expect(calls).toContain("manager stop mso.service");
++ expect(calls).toContain("curl --noproxy * -fsS --connect-timeout 1 --max-time 2 http://127.0.0.1:4005/api/health");
expect(calls).toContain("gateway local-start");
});
diff --cc docs/CHANGELOG.md
index b38a06d9,0f2d6a9c..567efdd9
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@@ -8,7 -8,9 +8,10 @@@ this is the *what*, and it is what Sett
**Fixed**
+ - `security` avoid recovery guard fsync convoy
+- `runtime` verify service readiness before handoff
+ - `jobs` finish retention before releasing runtime
+ - `runtime` preserve fallback recovery readiness
- `runtime` keep service starts on shared exclusion
- `settings` hide premature update warning
- `update` enforce main and raise MCP daily limit