Repository navigation
cloud: replay project setup recipes by lockfile hash #16151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 10 commits
b28ac7b
08fc33d
262db81
eda96d9
a7e36fd
1eeb945
3168165
ed47391
885e66d
327d452
917c4a3
ec6353d
5e7e2be
56d7001
361f02b
0699f6f
ce76610
5a8f0b2
32ec0aa
c585d4a
52b2b08
f971c14
2b05695
58dfb27
024ff56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import CryptoKit | ||
| import Foundation | ||
|
|
||
| /// `cmux vm dev`: one command from a local folder to a running dev layout on a | ||
|
|
@@ -56,7 +57,7 @@ extension CMUXCLI { | |
| \(openFocusDefaultHelp) | ||
| --dry-run Print the plan (detection, remote path, layout) without touching anything. | ||
| --json {machine, workspace_id, local_workspace_id, workspace_name, existing, local, | ||
| remote, synced, command, port, url, terminals: {dev, shell}, layout_applied, opened} | ||
| remote, synced, command, recipe, port, url, terminals: {dev, shell}, layout_applied, opened} | ||
|
|
||
| Examples: | ||
| cmux vm dev brave-otter # this folder → brave-otter, layout opened here | ||
|
|
@@ -82,6 +83,67 @@ extension CMUXCLI { | |
| static let unrecognized = VMDevDetection(kind: "none", command: nil, port: nil, detail: "no package.json, Cargo.toml, go.mod, Makefile dev target, manage.py, pyproject.toml, requirements.txt, or index.html here") | ||
| } | ||
|
|
||
| /// A checked-in `.cmux/cloud.json` recipe. Values are intentionally plain | ||
| /// commands and named ports; secrets stay in `cmux vm env`. | ||
| struct VMDevRecipe: Equatable { | ||
| let setup: [String] | ||
| let checks: [String] | ||
| let lockHash: String? | ||
| let source: String | ||
| } | ||
|
|
||
| static func vmDevRecipe(in directory: URL) -> VMDevRecipe? { | ||
| let url = directory.appendingPathComponent(".cmux/cloud.json") | ||
| guard let data = try? Data(contentsOf: url), | ||
| let object = try? JSONSerialization.jsonObject(with: data) as? [String: Any], | ||
| let setup = object["setup"] as? [String], | ||
| setup.allSatisfy({ !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }) else { return nil } | ||
| let checks = (object["checks"] as? [String]) ?? [] | ||
|
Comment on lines
+97
to
+101
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A malformed |
||
| // Include every supported lockfile in the digest. A changed lockfile | ||
| // therefore invalidates the materialized setup on the next `vm dev`. | ||
| let lockfiles = ["bun.lock", "bun.lockb", "pnpm-lock.yaml", "yarn.lock", "package-lock.json", "uv.lock", "poetry.lock", "Cargo.lock", "go.sum"] | ||
| var digestInput = Data("cmux-cloud-recipe-v1\0".utf8) | ||
| for command in setup { | ||
| digestInput.append(Data(command.utf8)); digestInput.append(0) | ||
| } | ||
| for name in lockfiles { | ||
| let lock = directory.appendingPathComponent(name) | ||
| guard let bytes = try? Data(contentsOf: lock) else { continue } | ||
| digestInput.append(Data(name.utf8)); digestInput.append(0); digestInput.append(bytes); digestInput.append(0) | ||
| } | ||
|
Comment on lines
+104
to
+116
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' '--- diff stat ---'
git diff --stat 70e997fb47b0f9315ca716ba93f981788b6e6519 f971c14856648d9b6a281c394d20f007897a7318 -- CLI/CMUXCLI+VMDev.swift
printf '%s\n' '--- changed diff ---'
git diff --unified=80 70e997fb47b0f9315ca716ba93f981788b6e6519 f971c14856648d9b6a281c394d20f007897a7318 -- CLI/CMUXCLI+VMDev.swift
printf '%s\n' '--- file outline ---'
ast-grep outline CLI/CMUXCLI+VMDev.swift
printf '%s\n' '--- relevant references ---'
rg -n -C 5 'sync|lockHash|lock hash|ready|marker|setup|checks|digestInput|flock|cloud\.json' CLI/CMUXCLI+VMDev.swiftRepository: manaflow-ai/cmux Length of output: 42025 🏁 Script executed: set -eu
git diff --stat 70e997fb47b0f9315ca716ba93f981788b6e6519 f971c14856648d9b6a281c394d20f007897a7318 -- CLI/CMUXCLI+VMDev.swift
git diff --unified=80 70e997fb47b0f9315ca716ba93f981788b6e6519 f971c14856648d9b6a281c394d20f007897a7318 -- CLI/CMUXCLI+VMDev.swift
ast-grep outline CLI/CMUXCLI+VMDev.swift
rg -n -C 5 'sync|lockHash|lock hash|ready|marker|setup|checks|digestInput|flock|cloud\.json' CLI/CMUXCLI+VMDev.swiftRepository: manaflow-ai/cmux Length of output: 42123 🌐 Web query:
💡 Result: Hash lockfiles from the remote tree when
When sync is disabled, compute the lockfile digest inside the remote lock body from the remote project path. Otherwise, require 🤖 Prompt for AI Agents |
||
| let hash = SHA256.hash(data: digestInput).map { String(format: "%02x", $0) }.joined() | ||
| return VMDevRecipe(setup: setup, checks: checks, lockHash: hash, source: ".cmux/cloud.json") | ||
| } | ||
|
|
||
| static func vmDevSetupCommand(_ recipe: VMDevRecipe, remote: String) -> String { | ||
| guard let hash = recipe.lockHash else { return ":" } | ||
| // The same recipe can be used by two checkouts on one machine. Include | ||
| // the remote project path in the cache scope so an install for one | ||
| // checkout never suppresses setup for another. | ||
| let scope = SHA256.hash(data: Data("\(remote)\0\(hash)".utf8)).map { String(format: "%02x", $0) }.joined() | ||
| let root = "$HOME/.cache/cmux/setup/\(scope)" | ||
| let marker = "\(root)/ready" | ||
| let lock = "\(root)/lock" | ||
|
Comment on lines
+126
to
+129
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Install revision A, install revision B at the same |
||
| let setup = recipe.setup | ||
| .filter { !$0.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty } | ||
| .map { "(\($0))" } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrapping a command directly as |
||
| .joined(separator: " && ") | ||
| let run = setup.isEmpty ? ":" : setup | ||
| // `flock` is provided by util-linux in every devbox image. Holding the | ||
| // descriptor for the whole check/install/marker transaction means a | ||
| // killed owner cannot leave a stale directory that blocks future runs; | ||
| // the marker is checked again after lock acquisition so a waiter never | ||
| // replays a recipe that another owner completed while it was waiting. | ||
| // `flock 9` alone would release the lock as soon as the helper exits. | ||
| // Run the complete check/install/marker transaction as the lock child so | ||
| // concurrent dev invocations serialize and killed owners are reclaimed | ||
| // by the kernel. The body is single-quoted for `/bin/sh -c`; escape any | ||
| // recipe quotes without changing their meaning inside the nested shell. | ||
| let body = "if [ -f \"\(marker)\" ]; then :; else \(run) && : > \"\(marker)\"; fi" | ||
| let quotedBody = "'" + body.replacingOccurrences(of: "'", with: "'\"'\"'") + "'" | ||
| return "mkdir -p \"\(root)\" && flock 9 /bin/sh -c \(quotedBody) 9>\"\(lock)\"" | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| /// Framework → default dev port, decided from the script's words (what the author | ||
| /// actually runs: `next dev`, `bunx vite --host`, `ng serve`) and, when the script | ||
| /// names no framework, from the dependencies. Whole tokens only, so `expose-gc` | ||
|
|
@@ -448,7 +510,16 @@ extension CMUXCLI { | |
| let remote = options.remote ?? "work/\(basename)" | ||
|
|
||
| let detection = Self.detectVMDevProject(in: localURL) | ||
| let command = options.command ?? detection.command | ||
| let recipe = Self.vmDevRecipe(in: localURL) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Recipe-only projects default to Prompt for AI agents |
||
| let detectedCommand = options.command ?? detection.command | ||
| let command: String? | ||
| if let recipe, let detectedCommand { | ||
| command = "\(Self.vmDevSetupCommand(recipe, remote: remote)) && \(detectedCommand)" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Prompt for AI agents
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
Comment on lines
+524
to
+527
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
A recipe still appends |
||
| } else if let recipe { | ||
| command = Self.vmDevSetupCommand(recipe, remote: remote) | ||
|
Comment on lines
+526
to
+529
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Setup only runs when creating the dev pane. If the workspace already has panes,
Comment on lines
+528
to
+529
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
From a project with |
||
| } else { | ||
| command = detectedCommand | ||
| } | ||
| let port: Int? | ||
| if let explicit = options.port { | ||
| port = explicit | ||
|
|
@@ -499,6 +570,7 @@ extension CMUXCLI { | |
| "open": !options.noOpen, | ||
| "detected": ["kind": detection.kind, "detail": detection.detail], | ||
| "command": Self.vmDevJSON(command), | ||
| "recipe": Self.vmDevJSON(recipe.map { ["source": $0.source, "setup": $0.setup, "checks": $0.checks, "lock_hash": Self.vmDevJSON($0.lockHash)] }), | ||
| "port": Self.vmDevJSON(port), | ||
| "layout": Self.vmDevJSON(documentObject), | ||
| ] | ||
|
|
@@ -664,6 +736,7 @@ extension CMUXCLI { | |
| "synced": sync, | ||
| "detected": ["kind": detection.kind, "detail": detection.detail], | ||
| "command": Self.vmDevJSON(command), | ||
| "recipe": Self.vmDevJSON(recipe.map { ["source": $0.source, "setup": $0.setup, "checks": $0.checks, "lock_hash": Self.vmDevJSON($0.lockHash)] }), | ||
| "port": Self.vmDevJSON(port), | ||
| "url": Self.vmDevJSON(publicURL), | ||
| "terminals": ["dev": Self.vmDevJSON(terminals["dev"]), "shell": Self.vmDevJSON(terminals["shell"])], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,6 +67,23 @@ extension CLINotifyProcessIntegrationRegressionTests { | |
| } | ||
| } | ||
|
|
||
| private final class VMDevProcessResults: @unchecked Sendable { | ||
| private let lock = NSLock() | ||
| private var values: [ProcessRunResult] = [] | ||
|
|
||
| func append(_ value: ProcessRunResult) { | ||
| lock.lock() | ||
| values.append(value) | ||
| lock.unlock() | ||
| } | ||
|
|
||
| func snapshot() -> [ProcessRunResult] { | ||
| lock.lock() | ||
| defer { lock.unlock() } | ||
| return values | ||
| } | ||
| } | ||
|
|
||
| /// The base64 body of a `printf %s '<b64>' | base64 -d …` command. | ||
| private static func vmDevBase64Payload(inCommand command: String) -> Data? { | ||
| guard let start = command.range(of: "printf %s '"), | ||
|
|
@@ -219,6 +236,48 @@ extension CLINotifyProcessIntegrationRegressionTests { | |
| return plan | ||
| } | ||
|
|
||
| /// Execute a generated dev command in the same way the machine shell does. | ||
| /// Keeping this at the integration boundary lets setup replay tests exercise | ||
| /// the lock/marker protocol even though the CLI target is not linked into | ||
| /// this test bundle. | ||
| private func runGeneratedVMDevCommand( | ||
| _ command: String, | ||
| cwd: URL, | ||
| home: URL, | ||
| extraEnvironment: [String: String] = [:], | ||
| timeout: TimeInterval = 10 | ||
| ) -> ProcessRunResult { | ||
| var environment = ProcessInfo.processInfo.environment | ||
| environment["HOME"] = home.path | ||
| environment.merge(extraEnvironment) { _, new in new } | ||
| let process = Process() | ||
| process.executableURL = URL(fileURLWithPath: "/bin/sh") | ||
| process.arguments = ["-c", command] | ||
| process.currentDirectoryURL = cwd | ||
| process.environment = environment | ||
| let output = Pipe() | ||
| let error = Pipe() | ||
| process.standardOutput = output | ||
| process.standardError = error | ||
| do { | ||
| try process.run() | ||
| } catch { | ||
| return ProcessRunResult(status: -1, stdout: "", stderr: "(error)", timedOut: false) | ||
| } | ||
| let deadline = Date().addingTimeInterval(timeout) | ||
| while process.isRunning && Date() < deadline { | ||
| RunLoop.current.run(until: Date().addingTimeInterval(0.01)) | ||
| } | ||
| let timedOut = process.isRunning | ||
| if timedOut { | ||
| process.terminate() | ||
| process.waitUntilExit() | ||
| } | ||
| let stdout = String(data: output.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" | ||
| let stderr = String(data: error.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" | ||
| return ProcessRunResult(status: process.terminationStatus, stdout: stdout, stderr: stderr, timedOut: timedOut) | ||
| } | ||
|
|
||
| // MARK: - Detection (dry run, no socket) | ||
|
|
||
| func testVMDevDryRunDetectsProjectsWithoutTouchingTheSocket() throws { | ||
|
|
@@ -348,6 +407,126 @@ extension CLINotifyProcessIntegrationRegressionTests { | |
| XCTAssertEqual(document["cwd"] as? String, "/srv/web") | ||
| } | ||
|
|
||
| func testVMDevReplaysCheckedInRecipeAndGatesSetupOnLockfileHash() throws { | ||
| let fixture = try vmDevFixture("recipe", files: [ | ||
| ".cmux/cloud.json": #"{"setup":["bun install"],"checks":["bun test"]}"#, | ||
| "package.json": #"{"scripts":{"dev":"bun run dev"}}"#, | ||
| "bun.lock": "lock-v1", | ||
| ]) | ||
| defer { try? FileManager.default.removeItem(at: fixture.root) } | ||
| let plan = try vmDevDryRunPlan("recipe", project: fixture.project, home: fixture.home) | ||
| let command = try XCTUnwrap(plan["command"] as? String) | ||
| XCTAssertTrue(command.contains("$HOME/.cache/cmux/setup/"), command) | ||
| XCTAssertTrue(command.contains("bun install"), command) | ||
| XCTAssertTrue(command.contains("bun run dev"), command) | ||
| let recipe = try XCTUnwrap(plan["recipe"] as? [String: Any]) | ||
| XCTAssertEqual(recipe["source"] as? String, ".cmux/cloud.json") | ||
| XCTAssertEqual(recipe["setup"] as? [String], ["bun install"]) | ||
| XCTAssertEqual(recipe["checks"] as? [String], ["bun test"]) | ||
| XCTAssertNotNil(recipe["lock_hash"] as? String) | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| } | ||
|
|
||
| func testVMDevSetupReplayScopesByRemoteAndSkipsAfterSuccess() throws { | ||
| let fixture = try vmDevFixture("replay", files: [ | ||
| ".cmux/cloud.json": #"{"setup":["echo run >> \"$COUNT\""],"checks":[]}"#, | ||
| "package.json": #"{"scripts":{"dev":"true"}}"#, | ||
| "package-lock.json": "lock-v1", | ||
| ]) | ||
| defer { try? FileManager.default.removeItem(at: fixture.root) } | ||
| let count = fixture.root.appendingPathComponent("count") | ||
| let plan = try vmDevDryRunPlan("replay", project: fixture.project, home: fixture.home, extra: ["--command", ":", "--remote", "work/replay-a"]) | ||
| let commandA = try XCTUnwrap(plan["command"] as? String) | ||
| let first = runGeneratedVMDevCommand(commandA, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path]) | ||
| XCTAssertEqual(first.status, 0, "\(first.stdout)\n\(first.stderr)") | ||
| let second = runGeneratedVMDevCommand(commandA, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path]) | ||
| XCTAssertEqual(second.status, 0, "\(second.stdout)\n\(second.stderr)") | ||
| XCTAssertEqual(try String(contentsOf: count).split(separator: "\n").count, 1) | ||
|
|
||
| let planB = try vmDevDryRunPlan("replay-b", project: fixture.project, home: fixture.home, extra: ["--command", ":", "--remote", "work/replay-b"]) | ||
| let commandB = try XCTUnwrap(planB["command"] as? String) | ||
| let third = runGeneratedVMDevCommand(commandB, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path]) | ||
| XCTAssertEqual(third.status, 0, "\(third.stdout)\n\(third.stderr)") | ||
| XCTAssertEqual(try String(contentsOf: count).split(separator: "\n").count, 2) | ||
| } | ||
|
|
||
| func testVMDevSetupFailureReleasesLockForRetryAndEmptySetupIsValid() throws { | ||
| let fixture = try vmDevFixture("retry", files: [ | ||
| ".cmux/cloud.json": #"{"setup":["if [ ! -f \"$FAIL_FLAG\" ]; then : > \"$FAIL_FLAG\"; false; else echo retry >> \"$COUNT\"; fi"]}"#, | ||
| "package.json": #"{"scripts":{"dev":"true"}}"#, | ||
| "package-lock.json": "lock-v1", | ||
| ]) | ||
| defer { try? FileManager.default.removeItem(at: fixture.root) } | ||
| let count = fixture.root.appendingPathComponent("count") | ||
| let failFlag = fixture.root.appendingPathComponent("failed-once") | ||
| let plan = try vmDevDryRunPlan("retry", project: fixture.project, home: fixture.home, extra: ["--command", ":"]) | ||
| let command = try XCTUnwrap(plan["command"] as? String) | ||
| let failed = runGeneratedVMDevCommand(command, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path, "FAIL_FLAG": failFlag.path]) | ||
| XCTAssertNotEqual(failed.status, 0) | ||
| let retried = runGeneratedVMDevCommand(command, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path, "FAIL_FLAG": failFlag.path]) | ||
| XCTAssertEqual(retried.status, 0, "\(retried.stdout)\n\(retried.stderr)") | ||
| XCTAssertEqual(try String(contentsOf: count), "retry\n") | ||
|
|
||
| let empty = try vmDevFixture("empty-recipe", files: [ | ||
| ".cmux/cloud.json": #"{"setup":[]}"#, | ||
| "package.json": #"{"scripts":{"dev":"true"}}"#, | ||
| "package-lock.json": "lock-v1", | ||
| ]) | ||
| defer { try? FileManager.default.removeItem(at: empty.root) } | ||
| let emptyPlan = try vmDevDryRunPlan("empty-recipe", project: empty.project, home: empty.home, extra: ["--command", ":"]) | ||
| let emptyCommand = try XCTUnwrap(emptyPlan["command"] as? String) | ||
| let emptyRun = runGeneratedVMDevCommand(emptyCommand, cwd: empty.project, home: empty.home) | ||
| XCTAssertEqual(emptyRun.status, 0, "\(emptyRun.stdout)\n\(emptyRun.stderr)") | ||
| } | ||
|
|
||
| func testVMDevSetupConcurrentInvocationsRunOnce() throws { | ||
| let fixture = try vmDevFixture("concurrent", files: [ | ||
| ".cmux/cloud.json": #"{"setup":["sleep 0.2; echo run >> \"$COUNT\""],"checks":[]}"#, | ||
| "package.json": #"{"scripts":{"dev":"true"}}"#, | ||
| "package-lock.json": "lock-v1", | ||
| ]) | ||
| defer { try? FileManager.default.removeItem(at: fixture.root) } | ||
| let count = fixture.root.appendingPathComponent("count") | ||
| let plan = try vmDevDryRunPlan("concurrent", project: fixture.project, home: fixture.home, extra: ["--command", ":"]) | ||
| let command = try XCTUnwrap(plan["command"] as? String) | ||
| let group = DispatchGroup() | ||
| let results = VMDevProcessResults() | ||
| for _ in 0..<2 { | ||
| group.enter() | ||
| DispatchQueue.global().async { | ||
| let result = self.runGeneratedVMDevCommand(command, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path]) | ||
| results.append(result) | ||
| group.leave() | ||
| } | ||
| } | ||
| group.wait() | ||
| let values = results.snapshot() | ||
| XCTAssertEqual(values.count, 2) | ||
| XCTAssertTrue(values.allSatisfy { $0.status == 0 }, values.map { "\($0.status): \($0.stderr)" }.joined(separator: "\n")) | ||
| XCTAssertEqual(try String(contentsOf: count).split(separator: "\n").count, 1) | ||
| } | ||
|
|
||
| func testVMDevSetupOwnerDeathReleasesLockForRetry() throws { | ||
| let fixture = try vmDevFixture("owner-death", files: [ | ||
| // The first owner kills the generated shell after taking the lock. | ||
| // A later invocation must acquire the kernel lock and retry instead | ||
| // of waiting forever on a stale directory. | ||
| ".cmux/cloud.json": #"{"setup":["if [ ! -f \"$FAIL_FLAG\" ]; then : > \"$FAIL_FLAG\"; kill -KILL $$; else echo retry >> \"$COUNT\"; fi"]}"#, | ||
|
cubic-dev-ai[bot] marked this conversation as resolved.
Resolved
|
||
| "package.json": #"{"scripts":{"dev":"true"}}"#, | ||
| "package-lock.json": "lock-v1", | ||
| ]) | ||
| defer { try? FileManager.default.removeItem(at: fixture.root) } | ||
| let count = fixture.root.appendingPathComponent("count") | ||
| let failFlag = fixture.root.appendingPathComponent("killed-once") | ||
| let plan = try vmDevDryRunPlan("owner-death", project: fixture.project, home: fixture.home, extra: ["--command", ":"]) | ||
| let command = try XCTUnwrap(plan["command"] as? String) | ||
| let killed = runGeneratedVMDevCommand(command, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path, "FAIL_FLAG": failFlag.path]) | ||
| XCTAssertNotEqual(killed.status, 0) | ||
| let retried = runGeneratedVMDevCommand(command, cwd: fixture.project, home: fixture.home, extraEnvironment: ["COUNT": count.path, "FAIL_FLAG": failFlag.path], timeout: 2) | ||
| XCTAssertEqual(retried.status, 0, "stdout=\(retried.stdout) stderr=\(retried.stderr)") | ||
| XCTAssertFalse(retried.timedOut, "retry remained blocked behind a stale setup lock") | ||
| XCTAssertEqual(try String(contentsOf: count), "retry\n") | ||
| } | ||
|
Comment on lines
+559
to
+580
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Test uses real-time sleep in the concurrency and timeout paths. The retry assertion uses 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| // MARK: - The socket sequence | ||
|
|
||
| func testVMDevBuildsTheLayoutInAFreshWorkspaceAndOpensItHere() throws { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: The recipe guard behaves inconsistently for empty/checks-only recipes.
allSatisfyis vacuously true for an empty array, so"setup": []is accepted as a recipe (marker machinery runs, dev command is wrapped in a no-op setup prefix), while a recipe with onlychecksand nosetupkey is silently dropped and falls back to auto-detection — even though the docs say the slice "acceptssetupandchecks". Reject an empty setup array explicitly (or accept checks-only recipes) so presence of.cmux/cloud.jsonalone decides whether the recipe is honored.Prompt for AI agents