File size: 2,013 Bytes
a8f4b72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { SymbolResolver, type LanguageProfileRegistry, type SymbolAliasRegistry } from '@projectos/schema-engine';

export interface PlanCheck { valid: boolean; issues: string[] }
export interface PromotionCheck { valid: boolean; issues: string[] }

export function validateFrontierPromotion(
  item: { id?: string; projectId?: string | null; title?: string; description?: string; rationale?: string; status?: string },
  projectId: string
): PromotionCheck {
  const issues: string[] = [];
  if (!item.id?.trim()) issues.push('A frontier record identifier is required.');
  if (!projectId.trim() || item.projectId !== projectId) issues.push('The frontier record must belong to the target project.');
  if (!item.title?.trim()) issues.push('A titled frontier record is required.');
  if (!(item.description?.trim() || item.rationale?.trim())) issues.push('Promotion needs a description or rationale.');
  if (item.status !== 'candidate' && item.status !== 'tracking') issues.push('Only candidate or tracking frontier records can be promoted.');
  return { valid: issues.length === 0, issues };
}

export function validatePlanDraft(plan: { question?: string; council?: string; agents?: string[] }): PlanCheck {
  const issues: string[] = [];
  if (!plan.question?.trim()) issues.push('A question is required.');
  if (!plan.council?.trim()) issues.push('A council template must be selected.');
  if (!plan.agents?.length) issues.push('At least one specialist agent must be assigned.');
  return { valid: issues.length === 0, issues };
}

export function resolveSymbols(names: string[], registry: SymbolAliasRegistry): string[] {
  const resolver = new SymbolResolver(registry);
  return names.map((name) => resolver.resolve(name));
}

export function emitSymbols(
  names: string[],
  registry: SymbolAliasRegistry,
  profiles: LanguageProfileRegistry,
  profileName: string
): string[] {
  const resolver = new SymbolResolver(registry, profiles);
  return names.map((name) => resolver.emit(name, profileName));
}