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.4 KB
Raw Blame
/** Versioned coordinator, computed-conflict and exact-reviewer reopen authority [V2,H16]. */
import { AGENT_GRANT_ENGINE } from './agent-grant-engine.js';
import { SUBMITTED_CONFLICT_ENGINE } from './engine-metadata.js';
import { listAgents } from './board-query.js';
import { verdictWithdrawalTarget } from './verdict-withdrawal.js';
import { computedConflictProblem } from './computed-conflict-receipt.js';
import { Refused } from './refused.js';

/** Preserve historical authority and refusal order without granting a caller assertion new authority. */
export function reopenAuthority(board, found, actor, options, withdrawn) {
  const { forWithdrawal, forMerge, currentEngine, computedConflict, assertedConflict } = options;
  if (computedConflict !== undefined) return currentEngine >= AGENT_GRANT_ENGINE && assertedConflict === undefined
    ? computedConflictProblem(board, found, actor, computedConflict) : new Refused('COORDINATOR_ONLY', 'only the coordinator reopens submissions');
  if (forWithdrawal) { withdrawn(verdictWithdrawalTarget(board, found, actor)); return null; }
  if (forMerge && found.item_status === 'submitted' && currentEngine >= SUBMITTED_CONFLICT_ENGINE
    && currentEngine < AGENT_GRANT_ENGINE && listAgents(board).some(agent => agent.agent_id === actor)) return null;
  return actor === 'coordinator' ? null : new Refused('COORDINATOR_ONLY', 'only the coordinator reopens submissions');
}