Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

1.5 KB
Raw Blame
/** Keep one compatibility setup move recoverable without stealing an interrupted work result [S1,H16]. */
import {
  ensureCoordinator,
  specApprovalBaselineExists,
} from './board.js';
import { loadConfig } from './config.js';
import {
  relayLinked,
  relayRecovered,
} from './relay.js';
import { captureSpecApprovalBaseline } from './spec-approval.js';
import { gitSyncLinked } from './local-state.js';

/** Establish cold local authority inside the checkout lease; linked and recovered moves keep relay authority. */
export function ensureSpecApprovalCoordinator(ctx, board, baseline) {
  if (!baseline || !ctx.info.isMain || relayLinked(ctx.info.root) || relayRecovered(ctx.info.root) || gitSyncLinked(ctx.info.root)) return;
  ensureCoordinator(board, ctx.info.root);
}

/** Reuse the exact interrupted setup payload; only a main-checkout command can establish it. */
export function initialSpecApprovalBaseline(ctx, board, operation) {
  if (!ctx.info.isMain || operation === 'recordSpecApprovalBaseline') return null;
  const recovered = relayRecovered(ctx.info.root, { includePending: true });
  // A pending send or catch-up can retain the original move while its setup reply is still unreported.
  // Repeating that same move consumes its receipt through ordinary relay validation, not a new seed.
  if (recovered?.operation === 'recordSpecApprovalBaseline') return recovered.args[0].baseline;
  return specApprovalBaselineExists(board) ? null : captureSpecApprovalBaseline(ctx.info.root, loadConfig(ctx.info.root));
}