03.AegisFlow
Active Session
01 . Project Overview

AegisFlow

Autonomous cluster telemetry and Bayesian HMM scheduler that cuts deadline misses by 87%

Bayesian HMM • 99.58% State Accuracy • Zero Dependencies

aegis.hmm
N0HEALTHYN1DEGRADED · 0.13sN2DOWN · EV BARRIERHMM 99.58% acc · 0.64 ms/step · 31/31 invariants

Description

Zero-dependency Python distributed cluster scheduler designed for latent node degradation and sudden crashes. An exact Bayesian Hidden Markov Model infers hidden node health in 0.13–0.35 steps with 99.58% accuracy, while mathematical triage gating and a cold-restart expected-value barrier hold unnecessary migrations at 0.00 and capture 96% of the Oracle ceiling.

Timeline

98.3%

Role

AI Systems Engineer

Status

Production

Year

2026

Deployment

0.64 ms/step Engine

Core Stack

Pure Python / Bayesian HMM

View Source Code
02 . Core Rationale

Why I Built It

Understanding the core problems, proposed solutions, and realized product achievements.

The problem

When cluster nodes silently degrade or crash mid-workload, naive round-robin and greedy schedulers keep dispatching tasks into dead queues—causing cascading deadline misses and wasteful cold-restart thrashing.

What actually happens
Step T

Node 2 enters silent degradation (elevated latency_ms and error_rate, heartbeat_ok still noisy).

T+0.13

Exact HMM forward filter updates posterior belief over {Healthy, Degraded, Down} and detects degradation in 0.13 steps.

T+0.35

Task progress stalls; HMM confirms node is Down with 99.58% state accuracy and 0.000% false condemnations.

EV Gate

Triage gate drops doomed tasks (-0.01/step pending vs -1.00 miss penalty) while EV barrier blocks useless migrations (0.00 churn).

End

Deadline misses drop 87% (98.2 -> 13.2) and on-time completion climbs to 98.3% at 0.64 ms/step.

The fix, step by step
1
Replace heuristic z-scores with an Exact Bayesian HMM filter
agent.py

Forward-filters emission likelihoods across heartbeat_ok, latency_ms, error_rate, and per-task duration_remaining while discarding zero-signal queue_len.

2
Enforce hard capacity and mathematical triage gating
agent.py

Computes analytical completion probability before allocating a slot; leaving a doomed task pending costs ~100x less than letting it poison a healthy slot (+714 pt ablation swing).

3
Guard reroutes with a Cold-Restart Expected-Value Barrier
agent.py

Because rerouting resets elapsed progress to zero, tasks only migrate when target completion gain exceeds the restart penalty — yielding exact 0.00 unnecessary migrations.

4
Verify 31 strict behavioral invariants and crash containment
test_invariants.py

Dual try/except safety wrapper falls back in <0.1ms to capacity-respecting actions (+338.0 reward even under injected internal faults).

Result

Captures 96% of the theoretical Oracle ceiling (745.00 vs 750.94 pts) with 100% head-to-head seed wins against baseline on held-out perturbed clusters.

Deadline miss drop
-87%
On-time completion
98.3%
Oracle ceiling captured
96%
Decision speed
0.64 ms/step
03 . System Pipeline

Architecture Pipelines

Visual system flow diagrams representing data pipelines and structured checks.

Pipeline Data flow nodes (Glows on Hover)
01 // hmm-filter

Exact Bayesian HMM

Tracks 3-state hidden Markov posterior per node from noisy latency, heartbeat, error rate, and task progress.

02 // triage-gate

Analytical Triage Gate

Slack-ordered urgency planner that suppresses mathematically uncompletable tasks rather than starving viable jobs.

03 // ev-barrier

Cold-Restart EV Barrier

Weighs lost progress against target node survival probability to eliminate thrashing (0.00 spurious churn).

04 // probation

Recovery Probation Ramp

Throttles initial capacity on recovering nodes so flaky Markov transitions don't cause stampeding herds.

05 // failsafe

31 Invariants & Fallback

Zero-dependency stdlib implementation with <0.1ms exception fallback and full ablation benchmark harness.

04 . Core Capabilities

Features & Capabilities

Key features and built-in components implemented inside the codebase.

Feature Checklist
  • ✓Exact Bayesian Hidden Markov Model forward filter (0.13s degraded detection, 0.35s down detection, 99.58% accuracy)
  • ✓87% reduction in deadline misses (98.2 -> 13.2) and 98.3% on-time rate across paired 400-step benchmarks
  • ✓Cold-restart expected-value barrier guaranteeing 0.00 unnecessary task migrations
  • ✓Defensive probation ramp dampening post-recovery Markov oscillations
  • ✓Zero external dependencies (pure Python stdlib) executing at 0.64 ms/step (39x faster than 25.0 ms budget)
  • ✓31/31 deterministic system invariant tests passing + 100% win rate across held-out perturbed Markov chains
03 . Technical Barriers

Solving Complex Bottlenecks

A deep dive into security rule architectures, race conditions, and verification solutions.

Problem

Early blueprint heuristics treated high queue_len as node distress evidence alongside latency and error rates.

Why it was difficult

In the real cluster simulator, queue_len simply mirrors the scheduler's own past dispatches with zero noise or health dependence—feeding it into inference caused circular self-reinforcing bias.

The fix
1
Audit true emission distributions per hidden state in cluster_env.py
env/cluster_env.py
2
Drop queue_len from Bayesian likelihood updates entirely
agent.py
3
Use task stall progress (duration_remaining delta) as direct state evidence
agent.py
What I learned

"Feature intuition has to bow to the real generative model—feeding a deterministic echo of your own actions into a Bayesian filter creates confirmation bias."

06 . Build Log Timeline

Development Journey

A chronological day-by-day log detailing core milestones and features added.

Milestone timeline
Phase 1

Emission Audit & Exact HMM Filter

Replaced initial CUSUM draft with an exact 3-state HMM forward filter once true emission profiles and pre-step act() order were verified.

Phase 2

Triage Gating & Cold-Restart Barrier

Added hard-capacity enforcement, slack urgency ordering, and EV migration barrier—capturing 96% of the Oracle ceiling.

Phase 3

Ablations, 31 Invariants & Scale Verification

Ran held-out perturbed Markov generalization benchmarks, verified 31/31 invariants, and scaled to 32 nodes / 256 slots at 4.42 ms/step.

07 . System Reliability

Operational Metrics

No public-facing site to audit — these are the safeguards that keep an unattended pipeline honest.

State inference accuracy99.58%

infers node degradation in 0.13 steps and crashes in 0.35 steps with 0.000% false condemnations

Unnecessary migrations0.00

cold-restart expected-value barrier eliminates thrashing across all paired benchmark seeds

Invariant test suite31 / 31

capacity limits, crash containment, and monotonicity properties verified in test_invariants.py

Step budget headroom39x faster

0.64 ms/step measured vs 25.0 ms wall-clock budget (4.42 ms/step at 32 nodes / 256 slots)

05 . Architecture Decisions

Trade-off Explanations

Concise rationales for technology selections and future roadmaps.

Design Choices

Analytical Posterior Over Black-Box RL

Exact 3-State HMM

With known emission noise characteristics and a 400-step episode budget, exact forward filtering converges in sub-millisecond time without training instability or opaque failure modes.

Zero External Dependencies for 0.64ms Latency

Pure Python Stdlib

Avoiding NumPy/PyTorch array dispatch overhead keeps per-step scheduling under 1ms on small clusters and guarantees deterministic portability in any sandbox.

Refusing Doomed Work Beats Best-Effort Queuing

Triage Suppression

Scoring +1 completion vs -1 miss vs -0.01/step pending makes leaving an uncompletable task unassigned ~100x cheaper than burning a healthy slot on it.

If I built V2...

"Evaluating scaling adjustments and cache controls shows true engineering maturity."

  • ✓Add online Baum-Welch / Dirichlet transition adaptation so the HMM self-calibrates if cluster failure rates shift mid-episode beyond fixed priors.
  • ✓Extend task urgency planning with batch-aware bin packing when heterogeneous task durations arrive in synchronized bursts.
  • ✓Export real-time Prometheus/OpenTelemetry metrics from the decision log stream for live cluster operator visibility.

Finished exploring this session?

End the workspace session to release resources and return back to the primary portfolio index.

Opening.theAegisFlow.

> Initializing Session...

INITIALIZING_WORKSPACE·0%