feat(FN-2950): merge fusion/fn-2950
- Updated routing policy documentation in `docs/architecture.md` and `docs/settings-reference.md` - Revised docs reflect the latest routing configuration options and behavior Commits merged: - feat(FN-2950): complete Step 6 — update routing policy documentation Files changed: docs/architecture.md | 19 ++++++++++--------- docs/settings-reference.md | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) Fusion-Task-Id: FN-2950
This commit is contained in:
45
packages/engine/src/node-routing-policy.ts
Normal file
45
packages/engine/src/node-routing-policy.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import type { NodeStatus, UnavailableNodePolicy } from "@fusion/core";
|
||||
|
||||
export interface PolicyResult {
|
||||
allowed: boolean;
|
||||
fallbackToLocal: boolean;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
const UNHEALTHY_STATUSES: ReadonlySet<NodeStatus> = new Set(["offline", "error", "connecting"]);
|
||||
|
||||
export function applyUnavailableNodePolicy(
|
||||
nodeStatus: NodeStatus | undefined,
|
||||
policy: UnavailableNodePolicy | undefined,
|
||||
isLocal: boolean,
|
||||
): PolicyResult {
|
||||
if (isLocal) {
|
||||
return { allowed: true, fallbackToLocal: false, reason: "local-execution" };
|
||||
}
|
||||
|
||||
if (nodeStatus === undefined) {
|
||||
return { allowed: true, fallbackToLocal: false, reason: "unknown-health" };
|
||||
}
|
||||
|
||||
if (nodeStatus === "online") {
|
||||
return { allowed: true, fallbackToLocal: false, reason: "healthy" };
|
||||
}
|
||||
|
||||
if (!UNHEALTHY_STATUSES.has(nodeStatus)) {
|
||||
return { allowed: true, fallbackToLocal: false, reason: "healthy" };
|
||||
}
|
||||
|
||||
if (policy === "fallback-local") {
|
||||
return {
|
||||
allowed: true,
|
||||
fallbackToLocal: true,
|
||||
reason: `fallback-local:${nodeStatus}`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
allowed: false,
|
||||
fallbackToLocal: false,
|
||||
reason: `blocked:${nodeStatus}`,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user