refactor(main): simplify escalation trigger map + unify api-section curl guidance

- P3-52: replace 5-deep if-chain in deriveEscalationWakeTrigger with two
  lookup maps (status takes precedence over rule trigger), which removes
  the cognitive overhead of reading the chain and makes the two inputs'
  roles explicit.
- P3-53: rewrite the Windows-only curl warning as platform-neutral
  guidance that matches the surrounding examples. The old text said
  'prefer fetch on Windows' while the doc showed curl POSTs everywhere;
  the new text recommends fetch universally and explains when the curl
  temp-file pattern is needed.
This commit is contained in:
ZacharyZhang-NY committed 2026-04-16 23:27:29 -04:00
1 parent 9227e5f7c4
commit e892bf3366
2 files changed
+14 -7

No files matched your search

+11 -4
View File
@@ -20,11 +20,18 @@ function deriveHeartbeatWakeTrigger(triggerType: string, previousStatus: string
}
// Map the run/state combination → wake trigger for escalation to manager.
// Status-based mapping takes precedence; rule-trigger mapping is the fallback.
const ESCALATION_STATUS_TRIGGER_MAP: Record<string, string> = {
in_review: "subtask_completed",
blocked: "report_blocked",
};
const ESCALATION_RULE_TRIGGER_MAP: Record<string, string> = {
run_completed: "subtask_completed",
run_failed: "report_failed",
};
function deriveEscalationWakeTrigger(newStatus: string | null, ruleTrigger: string | null): string {
if (newStatus === "in_review") return "subtask_completed";
if (newStatus === "blocked") return "report_blocked";
if (ruleTrigger === "run_completed") return "subtask_completed";
if (ruleTrigger === "run_failed") return "report_failed";
if (newStatus && ESCALATION_STATUS_TRIGGER_MAP[newStatus]) return ESCALATION_STATUS_TRIGGER_MAP[newStatus];
if (ruleTrigger && ESCALATION_RULE_TRIGGER_MAP[ruleTrigger]) return ESCALATION_RULE_TRIGGER_MAP[ruleTrigger];
return "report_blocked";
}