feat: add workflow dry-run observability

This commit is contained in:
john
2026-07-24 22:44:26 +08:00
parent c9ad841543
commit 19706eb3a0
15 changed files with 725 additions and 41 deletions
+20 -9
View File
@@ -363,11 +363,27 @@ export function createOrchestratorAdminConfigService(pool, {
if (!runtime.effective || !workflowMatched) {
return { ...base, reason: runtime.reason ?? 'workflow_not_enabled' };
}
const rolloutKey = runId || requestId || `${userId ?? ''}:${normalizedWorkflow}`;
const bucket = stableRolloutBucket(rolloutKey);
const explicitlyAllowed = Boolean(userId && config.userAllowlist.includes(String(userId)));
const percentAllowed = bucket < config.rolloutPercent;
const rolloutSelected = explicitlyAllowed || percentAllowed;
const rolloutReason = explicitlyAllowed
? 'user_allowlist'
: percentAllowed
? 'percentage'
: 'canary_not_selected';
if (config.mode === ORCHESTRATOR_MODE.SHADOW) {
return {
...base,
shadowEngine: config.primaryEngine,
reason: 'shadow',
candidateEngine: rolloutSelected
? config.primaryEngine
: WORKFLOW_ENGINE.NATIVE,
candidateReason: rolloutReason,
bucket,
dryRun: true,
};
}
if (config.mode === ORCHESTRATOR_MODE.ACTIVE) {
@@ -384,25 +400,20 @@ export function createOrchestratorAdminConfigService(pool, {
: { ...selected, reason: 'execution_gate_disabled', dryRun: true };
}
if (config.mode === ORCHESTRATOR_MODE.CANARY) {
const explicitlyAllowed = Boolean(userId && config.userAllowlist.includes(String(userId)));
const rolloutKey = runId || requestId || `${userId ?? ''}:${normalizedWorkflow}`;
const bucket = stableRolloutBucket(rolloutKey);
const percentAllowed = bucket < config.rolloutPercent;
if (!explicitlyAllowed && !percentAllowed) {
if (!rolloutSelected) {
return { ...base, reason: 'canary_not_selected', bucket };
}
const candidateReason = explicitlyAllowed ? 'user_allowlist' : 'percentage';
const selected = {
...base,
candidateEngine: config.primaryEngine,
candidateReason,
candidateReason: rolloutReason,
bucket,
};
if (config.primaryEngine === WORKFLOW_ENGINE.NATIVE) {
return { ...selected, reason: candidateReason };
return { ...selected, reason: rolloutReason };
}
return runtime.executionHandoff.enabled
? { ...selected, engine: config.primaryEngine, reason: candidateReason }
? { ...selected, engine: config.primaryEngine, reason: rolloutReason }
: { ...selected, reason: 'execution_gate_disabled', dryRun: true };
}
return base;