The Thinking Network (Installment 12): Live AI Telemetry & Automated Fallbacks

Installment 12 of The Thinking Network. We wire the trust monitor to live data, utilizing a Prometheus Python exporter to dynamically gate AI routing authority based on real-time telemetry.

The Thinking Network (Installment 12): Live AI Telemetry & Automated Fallbacks

Architecture Overview: Phase 8 (Live Wiring)Objective: Wire the autonomous trust monitor to live network data streams to enforce closed-loop accountability.Core Technologies: prometheus_client Python library, custom Prometheus scrape jobs, Containerlab networking, and automated failure testing.The Goal: Export AI predictions as Prometheus gauges and actively test the network's safety mechanisms by intentionally killing the sensing agent, successfully triggering an autonomous suspension of the AI's predictive authority.

The previous installment ended with an honest admission. The trust monitor ran. It produced a score of 0.92. That score came from hardcoded values - not from Phase 7's predictions, not from Phase 5's measurements, not from anything that happened in the lab.

This installment closes that gap.


What Needed to Change

Three things were required before the trust monitor could read real data.

Phase 7 needed to export its predictions. The original script printed predictions to the terminal and nowhere else. The trust monitor had nothing to query. The fix was adding a Prometheus gauge to Phase 7 - exporting the predicted value and the timestamp it was made on a dedicated port.

Prometheus needed to scrape Phase 7. The existing prometheus.yml scraped two targets: the gNMIc exporter on port 9804 and Phase 5's sensing agent on port 9999. Phase 7's new exporter on port 9998 was invisible to Prometheus until a third scrape job was added.

The trust monitor needed to be rewritten. The stub lived in toolkit/ and imported nothing from lab_config.py. It had no connection to the live infrastructure. The v2 version moves to scripts/, imports from lab_config.py, and replaces the three hardcoded values with three functions that query real data.

These changes produced two new scripts: phase7_predictive_ai_v2.py and trust_monitor_v2.py. The originals remain untouched. The series can reference both versions.


Phase 7 v2 - Adding the Export

The change to Phase 7 was minimal. Three Prometheus gauges added:


from prometheus_client import Gauge, start_http_server

AI_PREDICTION_MS        = Gauge('nokia_ai_prediction_ms',
    'Phase 7 predicted L3 RTT in ms (30s ahead)', ['lab'])
AI_PREDICTION_TIMESTAMP = Gauge('nokia_ai_prediction_timestamp',
    'Unix timestamp when Phase 7 prediction was made', ['lab'])
AI_PREDICTION_TREND     = Gauge('nokia_ai_prediction_rising',
    'Phase 7 trend direction: 1=rising, 0=stable/falling', ['lab'])

Each prediction cycle now exports three values. The timestamp gauge is the critical one - it tells the trust monitor exactly when each prediction was made, so it can look up the actual measurement at prediction_time + 30s and calculate the accuracy delta.

Phase 7 v2 starts a Prometheus HTTP server on port 9998. Phase 5 uses 9999. No conflict.

The startup log confirms it:

Phase 7 Prometheus exporter started on port 9998
  Exports: nokia_ai_prediction_ms, nokia_ai_prediction_timestamp
  These are read by trust_monitor_v2.py to calculate Accuracy

Prometheus Configuration Update

Adding Phase 7 as a scrape target required one addition to prometheus.yml. Since fish shell does not support heredoc syntax, Python was used to append to the file:


with open('configs/prometheus/prometheus.yml', 'a') as f:
    f.write('''
  - job_name: "phase7-predictive"
    static_configs:
      - targets: ["172.20.20.1:9998"]
        labels:
          lab: "nbl-diamond-v1"
          source: "phase7-predictive"
''')

The Prometheus container was restarted to pick up the new config:


docker restart clab-nbl-diamond-v1-prometheus

Verification that Prometheus was scraping Phase 7:


curl -s "[http://172.20.20.20:9090/api/v1/query?query=nokia_ai_prediction_ms](http://172.20.20.20:9090/api/v1/query?query=nokia_ai_prediction_ms)"

"value": ["1779039896.864", "2.4595841886475682"]

Phase 7's prediction of 2.46ms, stored in Prometheus, available for the trust monitor to query.

Trust Monitor v2 - The Three Live Functions

Accuracy - compares Phase 7's prediction at time T to Phase 5's actual measurement at time T+30s:


def calculate_accuracy() -> float:
    prediction, _ = query_instant("nokia_ai_prediction_ms")
    pred_time, _  = query_instant("nokia_ai_prediction_timestamp")

    # The prediction applies to pred_time + PREDICT_AHEAD_S (30s)
    target_time = pred_time + PREDICT_AHEAD_S

    # Only calculate if the prediction has resolved
    if target_time > time.time():
        return 0.85  # neutral until resolved

    actual = query_at_time("nokia_latency_l3_ms", target_time)
    error  = abs(prediction - actual)
    return max(0.0, min(1.0, 1.0 - (error / SLA_THRESHOLD_MS)))

Reliability - measures how stale the sensing data is:


def calculate_reliability() -> float:
    _, last_ts = query_instant("nokia_latency_l3_ms")
    gap = time.time() - last_ts

    if gap <= RELIABILITY_WARN_S:   return 1.0
    if gap >= RELIABILITY_ZERO_S:   return 0.0
    # Linear degradation between warn and zero thresholds
    return max(0.0, 1.0 - ((gap - RELIABILITY_WARN_S) / span))

Explainability - checks whether Phase 7's model is producing sensible output:


def calculate_explainability() -> float:
    prediction, _ = query_instant("nokia_ai_prediction_ms")
    in_bounds = 0.0 <= prediction <= 100.0
    return 1.0 if in_bounds else 0.0

What the Live Trust Monitor Showed

With all three phases running and the new scripts deployed, the trust monitor produced its first real score:

12:45:35  --- Trust Evaluation Cycle ---
12:45:35    Reliability: last sample 0.0s ago | score=1.00
12:45:35    Explainability: prediction 1.67ms within bounds -- score 1.0
12:45:35    [TRUST] Additive score:       0.94  (operative)
12:45:35    [TRUST] Multiplicative score: 0.85  (research comparison)
12:45:35    [TRUST] Components: Acc=0.85 Rel=1.00 Expl=1.00
12:45:35    [OK] Trust score 0.94 above threshold -- Phase 7 authority maintained

Real numbers. Accuracy at 0.85 - Phase 7's predictions were within 15% of actuals. Reliability at 1.00 - sensing data arriving on schedule. Explainability at 1.00 - predictions within valid bounds.

The multiplicative formula on the same data: 0.85. Both above threshold. Both telling the same story on healthy data.

The Reliability Collapse Test

To prove the system works, we must initiate a Chaos Engineering test. By deliberately killing the sensing agent, we force a reliability collapse to ensure the AI's authority is immediately suspended.

Phase 5 was killed deliberately to test the alert mechanism:


pkill -f phase5_sensing

The trust monitor detected the data gap within one cycle:

12:46:45    [OK] Trust score 0.94  ← Phase 5 running
12:46:55    Reliability: no samples found -- score 0.0  ← Phase 5 killed
12:46:55    [TRUST] Additive: 0.54 | Multiplicative: 0.0
12:46:55    [ALERT] Trust score 0.54 below threshold 0.85
12:46:55    [ALERT] Reverting to Phase 6 reactive logic
12:46:55    [ALERT] Phase 7 predictive actions should be suspended

Ten seconds after the sensing agent died, Phase 7's authority was suspended. The additive score dropped from 0.94 to 0.54. The multiplicative score went to 0.0 immediately - one component at zero collapses the entire multiplicative product.

This is the additive vs multiplicative comparison made real. On clean data both formulas produce similar results. On a failure condition they diverge dramatically. The additive formula reduces authority proportionally. The multiplicative formula eliminates it entirely.

The Recovery

Phase 5 was restarted:

python3 phase5_sensing.py &

The trust score recovered in stages:

12:58:56    Reliability: 0.0   Trust: 0.4   ← Phase 5 still dead
12:59:16    Reliability: 1.00  Trust: 0.8   ← Phase 5 back, Accuracy on fallback
12:59:46    Reliability: 1.00  Trust: 0.94  ← Accuracy resolved, full recovery
[OK] Trust score 0.94 above threshold -- Phase 7 authority maintained

The staged recovery reflects the architecture. Reliability recovers the moment Prometheus receives a fresh sample. Accuracy recovers more slowly - it needs a prediction to have been made, 30 seconds to pass, and an actual measurement to be available at that timestamp. The system does not snap back to full authority instantly. It earns it back through demonstrated performance.

The Persistent Client IP Problem

One operational gap surfaced repeatedly during this session: the client container IP addresses do not persist across Phase 5 restarts or ContainerLab redeploys. Every time Phase 5 restarts, L3 latency reads 0.00ms until the IPs are manually reapplied.

A post-deploy script was created to fix this:

# post_deploy.py
cmds = [
    ["docker", "exec", "clab-nbl-diamond-v1-client-l3-1",
     "ip", "addr", "add", "10.100.1.2/24", "dev", "eth1"],
    ["docker", "exec", "clab-nbl-diamond-v1-client-l3-1",
     "ip", "route", "add", "10.100.4.0/24", "via", "10.100.1.1"],
    ["docker", "exec", "clab-nbl-diamond-v1-client-l3-2",
     "ip", "addr", "add", "10.100.4.2/24", "dev", "eth1"],
]

Run after every deploy or Phase 5 restart:

python3 scripts/post_deploy.py

The permanent fix is a ContainerLab exec hook that runs these commands automatically after node initialization. That is a Phase 3 update and a backlog item.

What the Trust Layer Now Does

The trust monitor is no longer a stub. It reads three real signals from the live lab and produces a score that reflects actual system behavior.

When the sensing agent is healthy and Phase 7's predictions are accurate, the score is 0.94. Phase 7 keeps authority.

When the sensing agent dies, the score drops to 0.54 within ten seconds. The alert fires. Phase 7 authority is suspended.

When the sensing agent recovers, the score climbs back through 0.80 and returns to 0.94 as accuracy resolves against fresh data. Phase 7 authority is restored.

That is accountability made operational. Not a dashboard metric. Not a log entry that someone reads later. A live gate that governs what the AI is allowed to do based on how well it is currently performing.

The Additive vs Multiplicative Finding

This session produced the first real data point for the research comparison between the two trust formulas.

On nominal data: Additive 0.94, Multiplicative 0.85. Both above threshold. Similar behavior.

On a single component failure (Reliability = 0): Additive 0.54, Multiplicative 0.0. The additive formula reduces authority proportionally. The multiplicative formula eliminates it entirely.

The right formula depends on the safety requirements of the system. For a network that carries real traffic, the multiplicative formula's zero-trust response to any single component failure is the more conservative and arguably safer choice. For a research lab where false negatives are more costly than false positives, the additive formula's proportional response preserves more operational continuity.

Both are implemented. Both are logged on every cycle. The Chaos Engine in Phase 10 will stress-test both under degraded conditions and produce a documented comparison.

Build Record

July 12, 2026 - Dell Precision 3571 - Garuda Linux rolling - SR Linux v26.3.2_

Phase 7 v2 exports verified:

nokia_ai_prediction_ms{lab="nbl-diamond-v1"} 2.459
nokia_ai_prediction_timestamp{lab="nbl-diamond-v1"} 1779039896.864
nokia_ai_prediction_rising{lab="nbl-diamond-v1"} 1.0

Nominal trust score (live data):

Components: Acc=0.85 Rel=1.00 Expl=1.00
Additive: 0.94 | Multiplicative: 0.85
[OK] Phase 7 authority maintained

Reliability collapse test:

12:46:45  Trust: 0.94  ← nominal
12:46:55  Trust: 0.54  ← Phase 5 killed, alert fires
12:59:46  Trust: 0.94  ← full recovery after Phase 5 restart

Phase 8 gate criterion met: Trust score calculates from live data AND alert fires when reliability collapses AND score recovers when sensing agent restarts.

The Thinking Network - Nokia SR Linux series. Twelve installments. A fabric that senses, predicts, acts, and now watches itself with real data. The wiring is visible. The trust is earned.