File size: 655 Bytes
4f7cbb5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export interface CanResolveResult {
  allowed: boolean;
  reason?: string;
}

const ALLOWED_STATES = new Set([
  "waiting_for_response",
  "followup_due",
  "resolver_reply_received",
]);

/**
 * Check if a mission is eligible to be resolved.
 * Only missions in response-waiting states can be resolved.
 */
export function canResolve(mission: { state: string }): CanResolveResult {
  if (ALLOWED_STATES.has(mission.state)) {
    return { allowed: true };
  }
  return {
    allowed: false,
    reason: `Mission state "${mission.state}" is not eligible for resolution. Must be one of: waiting_for_response, followup_due, resolver_reply_received.`,
  };
}