Spanda

Lesson 12 — Recovery, continuity, and cognitive policies

Goal: Use declarative policy blocks for failure recovery, mission handoff, and platform resilience — without scattering imperative glue code through behaviors.

Examples:

Options reference: platform-feature-examples.md · Workflows: workflows/README.md

Guides: self-healing.md · mission-continuity.md · cognitive-resilience-architecture.md


Recovery policy

Map sensor or subsystem failures to safe operating modes:

recovery_policy RoverRecovery {
    on gps.failed {
        switch_to visual_odometry;
        reduce_speed 0.5 m/s;
        enter degraded_mode;
    }
}

CLI: spanda heal, spanda recover, spanda sim --inject-failure.


Continuity policy

When a robot fails mid-mission, define how work continues on a successor:

continuity_policy PatrolContinuity {
    on robot.failed {
        resume from checkpoint;
        reassign mission;
    }
}

CLI: spanda continuity, spanda takeover, spanda succession.


Cognitive & resilience policies

Optional blocks that tie programs to the platform homeostasis and attention subsystems:

@policy(kind: "homeostasis")
PlatformStability {
    metric cpu_pct;
    metric memory_pct;
    metric battery_pct;
}

@policy(kind: "attention")
MissionFocus {
    rule suppress_low_priority;
    rule boost_critical_health;
}

CLI: spanda homeostasis check, spanda reflex list, Control Center Cognitive & Resilience tab.


Try it

spanda check examples/features/recovery_policy_options.sd
spanda heal examples/features/recovery_policy.sd
spanda recover examples/features/recovery_policy.sd --failure gps

spanda continuity examples/features/continuity_policy_options.sd \
  --failed RoverAlpha --progress 72 --trigger robot_failed

spanda homeostasis check --json
spanda check examples/workflows/gps_loss_full_stack.sd
spanda demo self-healing
spanda demo continuity

Exercise

  1. Add a on lidar.failed branch to your recovery_policy that enters safe_mode.
  2. Declare two robots and a continuity_policy that transfers state to a named successor.
  3. Run ./scripts/cognitive_resilience_smoke.sh and inspect homeostasis output.

After Spanda 101

Next step Resource
Platform options + workflows platform-feature-examples.md · workflows/README.md
Full showcase index examples/showcase/README.md
Feature lookup examples/features/README.md
Mission assurance mission-assurance.md + spanda demo assurance
Language reference spanda-language.md