Montis.icu Unified Prefetch Architecture β v5.1 Design
The Montis.icu Coach App operates on a authority-driven architecture separating
measurement, interpretation, prescription,
and interface.
Data integrity originates from Intervals.icu,
computation executes in Railway (python), and conversational rendering
never alters canonical truth.
π§ Strategy β’ π’ Technical β’ π Coaching β’ π΅ Future
The system is intentionally divided into independent architectural layers, each with a single responsibility and defined authority.
- π§ Strategy & Philosophy β Governing architectural doctrine. Defines authority boundaries and non-negotiable contracts for interpretation.
- π’ Technical Pipeline - Operational Architecture β Deterministic data ingestion, validation, aggregation, and semantic serialization (URF v5.1). Immutable canonical outputs.
- π Coaching Intelligence Pipeline β Structural performance modelling (Tier-3), progression analysis, and deterministic adaptive prescription logic.
- π΅ Future Technical Pipeline Architecture β Model-agnostic conversational layer using MCP tools. Renders insights without computing or mutating metrics.
This separation enforces:
- Measurement Integrity
- Transparent Decision Intelligence
- Interface Abstraction Without Authority
Conversational AI is a rendering layer β never a computational authority.
π§ System Strategy & Architectural Philosophy
The Montis.icu Coach App is engineered around strict authority separation. No layer may override or recompute another layerβs outputs.
π Core Architectural Contract
Coaching logic never mutates canonical metrics.
Tier-1 and Tier-2 outputs are immutable and remain the single source of performance truth.
- Measurement is deterministic and audited.
- Interpretation is rule-based and traceable.
- Prescription executes via a deterministic state engine.
- LLMs render outcomes but never compute, infer, or adjust metrics.
This prevents metric drift, silent recomputation, probabilistic coaching artifacts, and black-box behavior.
π§± Responsibility Separation Model
Measurement β Technical Pipeline (Tier-0 / Tier-1 / Tier-2) Interpretation β Coaching Pipeline (Tier-3 Intelligence) Prescription β Adaptive Decision Engine (Deterministic Rules) Interface β LLM Rendering Layer (Read-Only)
No single layer owns more than one responsibility. This structure enables auditability, stateless execution, and predictable system evolution.
π― Strategic Positioning
Unlike heuristic AI dashboards or machine-learning coaching engines, this system does not invent, infer, or probabilistically manipulate performance metrics.
- No hidden state
- No probabilistic coaching inference
- No language-model metric computation
- No silent threshold adjustment
The result is a deterministic performance intelligence platform β not a black-box AI coach.
βοΈ Current Operational Pipeline (Production)
Status: Live β’ Used in production β’ Backward compatible
ββββββββββββββββββββββββββββββββ
β ChatGPT / CLI App β
β (Tool invocation layer) β
βββββββββββββββ¬βββββββββββββββββ
β HTTPS tool call
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Cloudflare Worker (Edge) β
β β’ Auth + routing proxy β
β β’ Handles start/end normalization β
β β’ Prefetches Intervals data β JSON context β
βββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββ
β Railway Backend (FastAPI) β
β β’ Tier-0: Prefetch normalization β
β - DataFrame coercion + baseline columns β
β - Empty-source detection + AuditHalt β
β β’ Tier-1: Activity & wellness validation β
β - moving_time filtering, zero-checks β
β β’ Tier-2: Aggregation + enforcement β
β - Totals reconciliation, variance checks β
β β’ Tier-3: Forecast, PI and ESPE β
β - Advanced Coaching β
β β’ Outputs URF v5.1 Semantic JSON β
βββββββββββββββ¬βββββββββββββββββββββββββββββββββ
βΌ
ββββββββββββββββββββββββββββββββ
β Intervals.icu API β
β (authoritative source) β
ββββββββββββββββββββββββββββββββ
π Cloudflare handles authentication, routing, and optional synthetic testing.
π Railway performs full computation, validation, and serialization.
π§© Current Architecture Guarantees
| Area | Implementation | Guarantee |
|---|---|---|
| Prefetch Flow | Cloudflare normalizes date params and injects optional test payloads | Safe staging tests without real data |
| Execution Model | Python execution on Railway (FastAPI + Pandas) | Deterministic, audited output |
| Tier-0 Validation | Baseline column checks (`moving_time`, `distance`, etc.) | No schema drift or missing fields |
| Tier-1 Audit | Filters invalid / null activities, computes daily summaries | Enforced numeric consistency |
| Tier-2 Metrics & Enforcement | Derived Metrics, Lock totals, enforce logical consistency | No variance bleed between scopes |
| Tier-3 Coaching | Forecast, Performance Intelligence and ESPE | Integrated performance modelling |
| Serialization | Single-pass semantic JSON (no float loss) | Stable numeric precision |
| Observability | Structured logs at all Tier boundaries | Traceable audit chain (lightβfullβwellness) |
| Schema Version | URF v5.1 unified contracts | Cross-version compatibility with GPT tool API |
π§ Future Technical Pipeline
| Design Goal | Implementation | Guarantee |
|---|---|---|
| Natural Language Interface | LLMs interact exclusively via MCP tools (no UI state, no clicks) | Human-like interaction without loss of determinism |
| Multi-LLM Compatibility | MCP-standard tool schemas (OpenAI, Anthropic, Mistral, local models) | No vendor lock-in; identical outputs across models |
| Secure Access Control | Cloudflare Workers act as MCP + OAuth gateway | Intervals.icu tokens never exposed to LLMs |
| Edge Policy Enforcement | OAuth scopes, rate limits, and request validation at Cloudflare Edge | Strong isolation between clients, tools, and athletes |
| Execution Engine | Python services on Railway (FastAPI + Pandas) | Deterministic, auditable metric computation |
| Authoritative Data Source | Intervals.icu APIs (activities, intervals, FIT-derived data) | Single source of truth for all training data |
| Semantic Contract | URF v5.1 structured semantic JSON | LLMs interpret results without recomputation or inference |
| Context Integrity | Explicit context windows (activity, 7d, 90d, rolling) | No accidental βseasonalβ or cross-scope mislabeling |
| Headless by Design | No dependency on web UI or dashboards | Future-proof for voice, agents, automation, and APIs |
| Tool-First Expansion | New capabilities exposed as MCP tools | Feature growth without breaking existing clients |
βοΈ Future Operational Pipeline
Status: Planned β’ Incremental rollout β’ No breaking changes
π§ System Diagram
ββββββββββββββββββββββ
β Human / LLM Agent β
β (Chat, Voice, AI) β
βββββββββββ¬βββββββββββ
β Natural Language
βΌ
ββββββββββββββββββββββββββββββββ
β MCP Tool Interface (Standard)β
β β’ Typed tool contracts β
β β’ No UI state β
β β’ Multi-LLM compatible β
βββββββββββ¬βββββββββββββββββββββ
β MCP call
βΌ
ββββββββββββββββββββββββββββββββ
β Cloudflare Edge (OAuth + MCP)β
β β’ OAuth token handling β
β β’ Scope enforcement β
β β’ Rate limiting β
β β’ Request normalization β
βββββββββββ¬βββββββββββββββββββββ
β Authenticated request
βΌ
ββββββββββββββββββββββββββββββββ
β Railway Execution Layer β
β (FastAPI + Pandas) β
β β’ Tier-0 validation β
β β’ Tier-1 audit β
β β’ Tier-2 enforcement β
β β’ Tier-3 Methodology β
β β’ Deterministic computation β
βββββββββββ¬βββββββββββββββββββββ
β Canonical queries
βΌ
ββββββββββββββββββββββββββββββββ
β Intervals.icu APIs β
β β’ Activities (7d / 90d) β
β β’ Intervals & FIT-derived β
βββββββββββ¬βββββββββββββββββββββ
β Structured data
βΌ
ββββββββββββββββββββββββββββββββ
β Semantic JSON (URF v5.1) β
β β’ Explicit context windows β
β β’ Locked totals β
β β’ No recomputation allowed β
βββββββββββ¬βββββββββββββββββββββ
β Read-only
βΌ
ββββββββββββββββββββββββββββββββ
β LLM Rendering / Reasoning β
β β’ Descriptive only β
β β’ Coach-like narrative β
β β’ No metric invention β
ββββββββββββββββββββββββββββββββ
π Cloudflare handles authentication, routing, and optional synthetic testing.
π Railway performs full computation, validation, and serialization.
π‘Independence from LLMs via MCP
π Key Insights
-
There is no UI state
Every interaction is stateless, reproducible, and tool-driven. -
LLMs never compute metrics
They only interpret pre-computed, audited semantic JSON. -
OAuth tokens never reach the model
Cloudflare fully isolates authentication from reasoning. -
Intervals.icu remains the single source of truth
All metrics originate from published APIs or FIT-derived data. -
Context is explicit, never inferred
Each metric declares whether it is activity, 7d, 90d, or rolling. -
The system is headless by design
It works equally well for chat, voice, automation, or background agents.
βοΈ How It Works (End-to-End)
-
User or AI issues a natural-language request
Example: βExplain my weekly intensity balance and recovery status.β -
Request is converted into an MCP tool call
- Strongly typed inputs
- Explicit report scope (weekly / season / activity)
-
Cloudflare Edge handles trust and policy
- OAuth token exchange with Intervals.icu
- Scope validation
- Rate limiting
- Parameter normalization
-
Railway executes the computation
- Tier-0: schema + column validation
- Tier-1: numeric consistency and filtering
- Tier-2: locked totals and scope enforcement
- No cross-window leakage (e.g. weekly β seasonal)
-
Canonical semantic JSON is produced
- URF v5.1 contract
- Explicit context windows
- Deterministic numeric precision
- No derived ambiguity
-
LLM renders the report
- Descriptive, coach-like language
- Anchored strictly to provided semantics
- No recomputation, guessing, or extrapolation
π§ Why This Matters
This architecture enables natural language coaching at scale without:
- Dashboards
- Sliders
- Charts
- Hidden state
- Silent recomputation
The result is a system that is:
- Auditable
- Secure
- Model-agnostic
- Future-proof
- Genuinely conversational
Natural language becomes the interface β not the source of truth.
π Architectural Continuity
The future MCP-native architecture does not replace the current system. It formalizes the same guarantees behind a standard tool interface.
- Same Railway execution engine
- Same Tier-0/1/2 enforcement
- Same URF v5.1 semantic contract
- Same Intervals.icu data authority
π― Decision Governance
- The Adaptive Decision Engine is the sole prescriptive authority.
- Tier-2 metrics provide diagnostic context.
- Tier-3 synthesizes capability state.
- LLMs never modify, override, or invent recommendations.
π§ Coaching Intelligence Pipeline (Performance Layer)
Status: Evolutionary (v6+) β’ Deterministic β’ Rule-based β’ No metric recomputation
The Coaching Pipeline operates strictly on validated canonical data produced by the Technical Pipeline. It does not compute raw metrics. It transforms trusted semantic inputs into structured performance intelligence and deterministic training decisions.
CANONICAL SEMANTIC DATA (URF v5.1)
β
βΌ
Tier-3A: Stress Intelligence
(WDRM / ISDM / NDLI)
β
βΌ
Tier-3B: Progression Intelligence
ESPE v1 β Power Curve Progression
β’ Duration anchors (5s / 1m / 5m / 20m / 60m)
β’ Curve rotation detection
β’ Endurance vs anaerobic shift
β
βΌ
Tier-3C: System Modeling (Future)
ESPE v2 β Physiological System Engine
β’ Glycolytic vs aerobic bias
β’ Durability gradient
β’ VOβ reserve capacity
β’ Energy system balance score
β
βΌ
Adaptive Decision Engine (ADE)
β
βΌ
COACHING SEMANTIC LAYER (v6)
β
βΌ
Final Structured Report
π Stage 1 β Stress Intelligence
Evaluates how the athlete is expressing training load under fatigue.
- WDRM β Anaerobic repeatability and Wβ² depletion behavior
- ISDM β Durability and fatigue resistance
- NDLI β Neural load density and intensity clustering
Answers: βCan the athlete tolerate additional stress?β
π Stage 2 β Progression Intelligence (ESPE v1)
Tracks energy system progression using power curves and structural signals.
- Endurance (60min trend)
- Threshold (20min trend)
- VOβ Capacity (5min trend)
- Anaerobic Repeatability (1min + Wβ² behavior)
Answers: βIs current training producing adaptation?β
𧬠Stage 2B β System Modeling (ESPE v2)
The next evolution of the Energy System Progression Engine extends beyond simple power-duration changes and models the athleteβs physiological system balance.
- Glycolytic vs aerobic bias
- Durability gradient
- VOβ reserve capacity
- System balance score
This stage transforms curve progression into deeper physiological diagnostics describing how the athleteβs energy systems are adapting to training stimulus.
π§ Stage 3 β Adaptive Decision Engine (ADE)
Applies deterministic, rule-based logic to produce structured prescription guidance.
IF: Neural density high AND Repeatability decreasing AND FatigueTrend elevated THEN: Reduce VO2 duration 15% Convert tempo β endurance Insert OFF day
No GPT improvisation. No hidden logic. Rules are executed inside Railway and serialized into the semantic graph.
π§ Training State Machine
All prescription logic is governed by a deterministic training state model. The system cannot prescribe progression outside the current state.
Training State Machine: Stable β Progress Dense β Absorb Strain β Consolidate Overreached β Recover
The state machine governs intensity permission and load progression. It ensures Tier-2 diagnostics cannot override Tier-3 state.
π¦ Coaching Semantic Output (v6)
The Coaching Semantic Layer converts structural intelligence into clear, athlete-readable language β without removing analytical depth.
adaptive_layer: readiness_state progression_state neural_state durability_state prescription_adjustment
The system supports:
- Athlete Mode β Clear readiness, next-step guidance, and actionable adjustments.
- Coach Mode β Full structural diagnostics including WDRM, ESPE, NDLI, thresholds, state transitions, and rule traces.
Complexity is abstracted in Athlete Mode, but fully accessible in Coach Mode.
Any recommendation can be queried for complete technical breakdown β including source metrics, thresholds, trend deltas, and deterministic rule logic.
The system hides complexity β it never hides transparency.
π¬ Contact
For integration, customization, or coaching inquiries, connect via GitHub link below or DM via Intervals.icu DM and contribute in Intervals.icu Forum.
github.com/revo2wheels
Built with β€οΈ for endurance athletes β by Clive King.
Made in the Suisse Alps π¨π.
Powered by Intervals.icu, Cloudflare and the Railway Engine.