Use the count of healthy dependencies to choose a primary, fallback, or cache route.

healthy count The healthy dependency count is the controlled selector that drives the routing decision.
route fallback The route degrades from primary to fallback to cache as healthy dependencies drop away.

Dependency Fallback Remediation Report

healthyDeps
dependency_fallback_remediation_report.c
Replay: real traced execution (multi-file project)
#include <stdio.h>

int main(void) {
    int healthyDeps = 3;
    int totalDeps = 3;
    int degraded = totalDeps - healthyDeps;
    const char *route = "primary";

    if (healthyDeps < totalDeps) {
        route = "fallback";
    }

    if (healthyDeps == 0) {
        route = "cache";
    }

    printf("healthy=%d\n", healthyDeps);
    printf("degraded=%d\n", degraded);
    printf("route=%s\n", route);
    return 0;
}
#include <stdio.h>

int main(void) {
    int healthyDeps = 0;
    int totalDeps = 3;
    int degraded = totalDeps - healthyDeps;
    const char *route = "primary";

    if (healthyDeps < totalDeps) {
        route = "fallback";
    }

    if (healthyDeps == 0) {
        route = "cache";
    }

    printf("healthy=%d\n", healthyDeps);
    printf("degraded=%d\n", degraded);
    printf("route=%s\n", route);
    return 0;
}
#include <stdio.h>

int main(void) {
    int healthyDeps = 1;
    int totalDeps = 3;
    int degraded = totalDeps - healthyDeps;
    const char *route = "primary";

    if (healthyDeps < totalDeps) {
        route = "fallback";
    }

    if (healthyDeps == 0) {
        route = "cache";
    }

    printf("healthy=%d\n", healthyDeps);
    printf("degraded=%d\n", degraded);
    printf("route=%s\n", route);
    return 0;
}
  1. healthyDeps ← 3, totalDeps ← 3, degraded ← 0, route ← primary

    3int main(void) {4    int healthyDeps→ 3 = 3; //@healthyDeps=1, 05    int totalDeps→ 3 = 3;6    int degraded→ 0 = totalDeps3 - healthyDeps3;7    const char *route→ primary = "primary";89    if (healthyDeps < totalDeps) {10        route = "fallback";11    }1213    if (healthyDeps == 0) {14        route = "cache";15    }1617    printf("healthy=%d\n", healthyDeps3);18    printf("degraded=%d\n", degraded0);19    printf("route=%s\n", routeprimary);20    return 0;21}
    outputhealthy=3
    degraded=0
    route=primary
  1. healthyDeps ← 0, totalDeps ← 3, degraded ← 3, route ← primary

    3int main(void) {4    int healthyDeps→ 0 = 0;5    int totalDeps→ 3 = 3;6    int degraded→ 3 = totalDeps3 - healthyDeps0;7    const char *route→ primary = "primary";
  2. route ← fallback

    9if (healthyDeps0 < totalDeps3) {10    route→ fallback = "fallback";11}
  3. route ← cache

    13if (healthyDeps0 == 0) {14    route→ cache = "cache";15}
  4. printf("healthy=%d ", healthyDeps);

    17    printf("healthy=%d\n", healthyDeps0);18    printf("degraded=%d\n", degraded3);19    printf("route=%s\n", routecache);20    return 0;21}
    outputhealthy=0
    degraded=3
    route=cache
  1. healthyDeps ← 1, totalDeps ← 3, degraded ← 2, route ← primary

    3int main(void) {4    int healthyDeps→ 1 = 1;5    int totalDeps→ 3 = 3;6    int degraded→ 2 = totalDeps3 - healthyDeps1;7    const char *route→ primary = "primary";
  2. route ← fallback

    9if (healthyDeps1 < totalDeps3) {10    route→ fallback = "fallback";11}
  3. printf("healthy=%d ", healthyDeps);

    17    printf("healthy=%d\n", healthyDeps1);18    printf("degraded=%d\n", degraded2);19    printf("route=%s\n", routefallback);20    return 0;21}
    outputhealthy=1
    degraded=2
    route=fallback