@miraland-labs/conduit-bridge 0.16.195 → 0.16.197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -20,7 +20,7 @@ import { BOOTSTRAP_RESULTS, buildSovereignExecutionFacts, workspaceIsClean } fro
20
20
  import { ensureCheckout } from "./checkout.js";
21
21
  import { buildOnShiftIntentProof, managedWorkspacePath, maybeApplyOnShiftIntent } from "./on-shift-apply.js";
22
22
  import { expandOpsValue, loadOpsEnv, OPS_VERBS, runOps } from "./ops.js";
23
- import { assignmentsPending, pumpExecutionSlots, renewLeases } from "./execution.js";
23
+ import { pumpExecutionSlots, renewLeases } from "./execution.js";
24
24
  import { createRehearsalWorktree, rehearsalWorktreePath, removeAttemptWorktree } from "./attempt-worktree.js";
25
25
  import { applyRunnerToolPath, installRunnerService, uninstallRunnerService } from "./service.js";
26
26
  import { attemptsActiveOnComputer, BRIDGE_PROTOCOL_VERSION, cachedBridgePreflight, gateRehearsalLockHeld, planGateRehearsals, PREFLIGHT_CACHE_TTL_MS, runGateRehearsal, unavailableWorkspacePreflight } from "./preflight.js";
@@ -667,24 +667,21 @@ async function runner() {
667
667
  await heartbeat(client, config, workspace, currentBrief, preflight, intentProof, bootstrapResult);
668
668
  }
669
669
  await renewLeases(client, config);
670
- // Dispatched work outranks a rehearsal already running, and so does an attempt on this
671
- // computer (this runner or another). Stop it with nothing recorded, release the lock, and
672
- // claim on this same cycle. The rehearsal stays due.
673
- if (gateRehearsalRunning && (attemptsActiveOnComputer() || await assignmentsPending(client))) {
670
+ // Only an active attempt interrupts a rehearsal. Waiting work takes the next cycle.
671
+ if (gateRehearsalRunning && attemptsActiveOnComputer()) {
674
672
  gateRehearsalAbort?.abort();
675
673
  await gateRehearsalDone;
676
674
  }
677
- // Another runner on this computer rehearsing its gate, or any runner with an attempt in
678
- // flight: claim as usual, rehearse on a later cycle. An assignment already waiting is
679
- // claimed below; this cycle does not start a rehearsal.
675
+ // Another runner with an attempt in flight takes precedence over a new rehearsal.
680
676
  if (workspace && onlineDriverIds(config).length && !gateRehearsalRunning && rehearsalPlan?.due
681
677
  && running.size === 0 && Object.keys(config.activeAttempts).length === 0 && !gateRehearsalLockHeld()
682
- && !attemptsActiveOnComputer()
683
- && !await assignmentsPending(client)) {
678
+ && !attemptsActiveOnComputer()) {
679
+ console.log(`Claim deferred for gate rehearsal in ${rehearsalPlan.due.workspace}`);
684
680
  startGateRehearsal(rehearsalPlan.due.workspace, rehearsalPlan.due.plan);
685
681
  }
686
- // No claim while the gate rehearses: the rehearsal measures the gate alone, never beside an attempt.
687
- if (workspace && onlineDriverIds(config).length && !gateRehearsalRunning) {
682
+ // Idle computers rehearse before claiming. Active attempts keep their execution slots pumping.
683
+ if (workspace && onlineDriverIds(config).length && !gateRehearsalRunning
684
+ && (!rehearsalPlan?.due || running.size > 0 || Object.keys(config.activeAttempts).length > 0 || attemptsActiveOnComputer())) {
688
685
  // Read the workspace again, then publish it. The last brief stands if the read fails.
689
686
  const publishWorkspaceState = async (options = {}) => {
690
687
  // Not while an investigation runs: its observation-only check compares the source checkout
@@ -740,7 +737,7 @@ async function runner() {
740
737
  await new Promise((resolveSleep) => setTimeout(resolveSleep, intervalMs));
741
738
  }
742
739
  }
743
- /** True while the gate rehearsal runs in the background. A dispatched assignment aborts it, then this cycle claims. */
740
+ /** True while the gate rehearsal runs in the background. Waiting assignments do not interrupt it. */
744
741
  let gateRehearsalRunning = false;
745
742
  let gateRehearsalAbort = null;
746
743
  let gateRehearsalDone = Promise.resolve();
@@ -809,7 +806,7 @@ function startGateRehearsal(workspace, plan) {
809
806
  else if (rehearsal === null && attemptsActiveOnComputer())
810
807
  console.log("Gate rehearsal stopped: an attempt is in flight on this computer");
811
808
  else if (abort.signal.aborted)
812
- console.log("Gate rehearsal stopped: an assignment is waiting");
809
+ console.log("Gate rehearsal stopped: an attempt is in flight on this computer");
813
810
  })
814
811
  .catch((error) => console.error(`Gate rehearsal failed: ${redactSecrets(error instanceof Error ? error.message : "unknown error")}`))
815
812
  .finally(async () => {
@@ -156,16 +156,20 @@ export function buildInvestigationPrompt(assignment, commit, context) {
156
156
  * verdict per criterion is the product; prose without verdicts is an unusable brief.
157
157
  */
158
158
  export function buildDeliveryVerificationPrompt(assignment, commit, context) {
159
- // The lane's shell holds only the registered commands, so it cannot run git itself. Bridge ran the
160
- // stat; the lane reads the named files at the pinned commit.
159
+ // Bridge supplies the stat; OS-sandboxed lanes can also read through their read-only shell.
160
+ const osSandbox = context.boundedBy === "os_sandbox";
161
+ const readFiles = osSandbox
162
+ ? `Read the tree with read-only shell commands such as cat, sed, ls, grep, and git show ${commit}:<path> at the pinned commit.`
163
+ : "Read the changed files that matter to each criterion at the pinned commit; you cannot run git.";
161
164
  const stat = context.diffStat?.trim() ?? "";
162
165
  const cut = stat.length > DIFF_STAT_MAX_CHARS;
163
166
  const diff = stat
164
- ? `CHANGE SUMMARY (git diff --stat ${assignment.base_commit ?? "base"}..${commit}, computed by Bridge)\n${cut ? `${stat.slice(0, DIFF_STAT_MAX_CHARS)}\n[cut at ${DIFF_STAT_MAX_CHARS} characters]` : stat}\nRead the changed files that matter to each criterion at the pinned commit; you cannot run git.`
165
- : "No change summary is available: read the files each criterion names at the pinned commit; you cannot run git.";
167
+ ? `CHANGE SUMMARY (git diff --stat ${assignment.base_commit ?? "base"}..${commit}, computed by Bridge)\n${cut ? `${stat.slice(0, DIFF_STAT_MAX_CHARS)}\n[cut at ${DIFF_STAT_MAX_CHARS} characters]` : stat}\n${readFiles}`
168
+ : osSandbox ? `No change summary is available: read the files each criterion names at the pinned commit. ${readFiles}`
169
+ : "No change summary is available: read the files each criterion names at the pinned commit; you cannot run git.";
166
170
  const commands = context.verificationCommands.length
167
- ? `REGISTERED COMMANDS (the only commands your shell accepts)\n${context.verificationCommands.map((command) => `- ${command}`).join("\n")}`
168
- : "REGISTERED COMMANDS\n- none: this repository registers no verification command, so judge from the files only";
171
+ ? `${osSandbox ? "REGISTERED COMMANDS (the only gate commands)" : "REGISTERED COMMANDS (the only commands your shell accepts)"}\n${context.verificationCommands.map((command) => `- ${command}`).join("\n")}`
172
+ : `${osSandbox ? "REGISTERED COMMANDS (the only gate commands)" : "REGISTERED COMMANDS"}\n- none: this repository registers no verification command, so judge from the files only`;
169
173
  const keys = (assignment.brief_keys ?? []).map((key) => key.trim()).filter(Boolean);
170
174
  const briefKeysBlock = keys.length ? `BRIEF KEYS\n${keys.join("\n")}` : "";
171
175
  const returns = (assignment.owner_returns ?? []).map((text) => text.trim()).filter(Boolean);
@@ -178,7 +182,9 @@ export function buildDeliveryVerificationPrompt(assignment, commit, context) {
178
182
  "You have repo_read and test_run only. Do not edit, create, delete, format, commit, branch, push, install, or change any file.",
179
183
  diff,
180
184
  formatGatesRunBlock(context.gatesRun ?? []),
181
- "Bridge already ran the gates at this commit. The GATES RUN block is the only gate fact — use those exit codes and output tails; do not choose which commands count as gates. You may still run a REGISTERED COMMAND to read more. Run nothing that is not registered. Never start a server, deploy, or call a production system.",
185
+ osSandbox
186
+ ? "Bridge already ran the gates at this commit. The GATES RUN block is the only gate fact — use those exit codes and output tails; do not choose which commands count as gates. A registered-command rerun that fails on the read-only tree is not evidence against the delivery and is not a new gate. Never start a server, deploy, or call a production system."
187
+ : "Bridge already ran the gates at this commit. The GATES RUN block is the only gate fact — use those exit codes and output tails; do not choose which commands count as gates. You may still run a REGISTERED COMMAND to read more. Run nothing that is not registered. Never start a server, deploy, or call a production system.",
182
188
  // T132: three verifications ended at the time limit with no brief. Order the work so the brief
183
189
  // exists before the budget does not.
184
190
  "Order of work: read the GATES RUN facts first, then the changed files that matter, then write the brief. You may run a registered command to read more, one at a time and never two at once (a test suite that rewrites a source file and restores it races against itself when run concurrently, and a changed tree voids your run). Your time is limited: a brief with `unclear` verdicts for what you did not reach is the required outcome; a run that ends without a brief settles nothing.",
@@ -868,6 +874,7 @@ export async function executeNextInvestigation(client, config, workspace, brief,
868
874
  })
869
875
  : [];
870
876
  const context = {
877
+ boundedBy: boundedByForDriver(driverId),
871
878
  verificationCommands,
872
879
  diffStat: assignment.base_commit ? await diffStatSince(attemptWorkspace, assignment.base_commit) : null,
873
880
  gatesRun,
package/dist/preflight.js CHANGED
@@ -611,6 +611,8 @@ async function rehearseGate(workspace, plan, options) {
611
611
  const seconds = Math.round(elapsed / 1_000);
612
612
  if (result.code !== 0 || result.timedOut === true || elapsed <= VERIFICATION_TIMEOUT_MS) {
613
613
  commands.push({ command, seconds, exit_code: result.code, timed_out: result.timedOut === true });
614
+ if (result.code !== 0 || result.timedOut === true)
615
+ break;
614
616
  continue;
615
617
  }
616
618
  // The pass fit only the rehearsal's limit: it was a warm-up. Measure once more, in a fresh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miraland-labs/conduit-bridge",
3
- "version": "0.16.195",
3
+ "version": "0.16.197",
4
4
  "description": "Conduit Bridge CLI — join, connect, disconnect, multi-driver lanes, and run Claude Code / Codex / Cursor / OpenCode / Pi / Kiro / Antigravity / Grok Build agents for a Conduit organization",
5
5
  "type": "module",
6
6
  "bin": {