Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f8a9a58
refactor(onboard): lower cognitive complexity ratchet to 245
cv Jun 14, 2026
65d7578
refactor(rebuild): lower cognitive complexity ratchet to 244
cv Jun 14, 2026
433ba8a
refactor(rebuild): lower cognitive complexity ratchet to 243
cv Jun 14, 2026
30e2b10
refactor(onboard): move setupNim validation helpers
cv Jun 14, 2026
bd07191
Merge branch 'ratchet/245-setup-nim-cognitive-complexity' into ratche…
cv Jun 14, 2026
fda1c05
Merge branch 'ratchet/244-rebuild-cognitive-complexity' into ratchet/…
cv Jun 14, 2026
cdc58d7
test(rebuild): cover interactive confirmation
cv Jun 14, 2026
2879093
refactor(rebuild): lower cognitive complexity ratchet to 225
cv Jun 15, 2026
df63d1a
refactor(rebuild): lower cognitive complexity ratchet to 224
cv Jun 15, 2026
7778b05
Merge branch 'main' into ratchet/245-setup-nim-cognitive-complexity
cv Jun 15, 2026
b451a5b
fix(onboard): preserve local NIM fallback state
cv Jun 15, 2026
9e3ddf5
Merge branch 'ratchet/245-setup-nim-cognitive-complexity' into ratche…
cv Jun 15, 2026
08743b0
Merge branch 'ratchet/244-rebuild-cognitive-complexity' into ratchet/…
cv Jun 15, 2026
17913db
Merge branch 'ratchet/243-rebuild-confirm-cognitive-complexity' into …
cv Jun 15, 2026
18a4325
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
ed3170a
test(onboard): cover setupNim selection validator state
cv Jun 15, 2026
4ef8d6f
Merge branch 'ratchet/245-setup-nim-cognitive-complexity' into ratche…
cv Jun 15, 2026
3df8744
Merge branch 'ratchet/244-rebuild-cognitive-complexity' into ratchet/…
cv Jun 15, 2026
8d3daaa
Merge branch 'ratchet/243-rebuild-confirm-cognitive-complexity' into …
cv Jun 15, 2026
c8f5794
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
9194819
Merge remote-tracking branch 'origin/main' into ratchet/244-rebuild-c…
cv Jun 15, 2026
00724d3
Merge branch 'ratchet/244-rebuild-cognitive-complexity' into ratchet/…
cv Jun 15, 2026
57dafc8
Merge branch 'ratchet/243-rebuild-confirm-cognitive-complexity' into …
cv Jun 15, 2026
374e4a8
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
ebe72ba
test(onboard): align sandbox registration fixture
cv Jun 15, 2026
a23904d
Merge branch 'ratchet/244-rebuild-cognitive-complexity' into ratchet/…
cv Jun 15, 2026
af81f07
Merge branch 'ratchet/243-rebuild-confirm-cognitive-complexity' into …
cv Jun 15, 2026
d9ad1a0
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
cb69607
test(rebuild): cover active session warning
cv Jun 15, 2026
86b83a0
Merge branch 'ratchet/244-rebuild-cognitive-complexity' into ratchet/…
cv Jun 15, 2026
7b61d67
Merge branch 'ratchet/243-rebuild-confirm-cognitive-complexity' into …
cv Jun 15, 2026
e512f8f
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
94402c3
Merge remote-tracking branch 'origin/main' into ratchet/243-rebuild-c…
cv Jun 15, 2026
98902a7
Merge branch 'ratchet/243-rebuild-confirm-cognitive-complexity' into …
cv Jun 15, 2026
e28e8e7
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
04da8e5
Merge remote-tracking branch 'origin/main' into ratchet/225-rebuild-s…
cv Jun 15, 2026
d066d12
Merge branch 'ratchet/225-rebuild-single-agent-guard' into ratchet/22…
cv Jun 15, 2026
d6d5bfe
Merge remote-tracking branch 'origin/main' into ratchet/224-rebuild-r…
cv Jun 15, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"noExcessiveCognitiveComplexity": {
"level": "error",
"options": {
"maxAllowedComplexity": 225
"maxAllowedComplexity": 224
}
}
},
Expand Down
49 changes: 34 additions & 15 deletions src/lib/actions/sandbox/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ async function stageMessagingManifestPlanForRebuild(
return plan;
}

type RebuildSandboxEntry = registry.SandboxEntry & { agents?: unknown[] };

const runMessagingOpenshell: MessagingOpenShellRunner = (args, options = {}) =>
runOpenshell([...args], {
env: options.env as NodeJS.ProcessEnv | undefined,
Expand Down Expand Up @@ -340,6 +342,35 @@ async function confirmSandboxRebuildIfNeeded(
return true;
}

function checkRebuildGatewaySchemaPreflight(
sandboxName: string,
bail: (msg: string, code?: number) => never,
): boolean {
const gatewayPreflightIssue = detectOpenShellStateRpcPreflightIssue();
if (gatewayPreflightIssue) {
printOpenShellStateRpcIssue(gatewayPreflightIssue, {
action: `rebuilding sandbox '${sandboxName}'`,
command: `${CLI_NAME} ${sandboxName} rebuild`,
});
bail("OpenShell gateway schema mismatch.");
return false;
}
return true;
}

function getRebuildSandboxEntryOrBail(
sandboxName: string,
bail: (msg: string, code?: number) => never,
): RebuildSandboxEntry | null {
const sb = registry.getSandbox(sandboxName) as RebuildSandboxEntry | null;
if (!sb) {
console.error(` Sandbox '${sandboxName}' not found in registry.`);
bail(`Sandbox '${sandboxName}' not found in registry.`);
return null;
}
return sb;
}

function isSingleAgentRebuildSupported(
sb: registry.SandboxEntry & { agents?: unknown[] },
bail: (msg: string, code?: number) => never,
Expand Down Expand Up @@ -409,12 +440,8 @@ export async function rebuildSandbox(
// Active session detection — enrich the confirmation prompt if sessions are active
const rebuildActiveSessionCount = countActiveSandboxSessionsForRebuild(sandboxName);

const sb = registry.getSandbox(sandboxName) as any;
if (!sb) {
console.error(` Sandbox '${sandboxName}' not found in registry.`);
bail(`Sandbox '${sandboxName}' not found in registry.`);
return;
}
const sb = getRebuildSandboxEntryOrBail(sandboxName, bail);
if (!sb) return;

// Multi-agent guard (temporary — until swarm lands)
if (!isSingleAgentRebuildSupported(sb, bail)) return;
Expand All @@ -423,15 +450,7 @@ export async function rebuildSandbox(
const agent = agentRuntime.getSessionAgent(sandboxName);
const agentName = agentRuntime.getAgentDisplayName(agent);

const gatewayPreflightIssue = detectOpenShellStateRpcPreflightIssue();
if (gatewayPreflightIssue) {
printOpenShellStateRpcIssue(gatewayPreflightIssue, {
action: `rebuilding sandbox '${sandboxName}'`,
command: `${CLI_NAME} ${sandboxName} rebuild`,
});
bail("OpenShell gateway schema mismatch.");
return;
}
if (!checkRebuildGatewaySchemaPreflight(sandboxName, bail)) return;

// Hydrate non-secret messaging config before the rebuild touches anything
// destructive. The manifest plan in registry is the durable source; legacy
Expand Down
Loading