Feature Stores as Contracts: Eliminating Training-Serving Skew with Point-in-Time Correctness

Eliminate training-serving skew with Feature Contracts. Deep dive on Point-in-Time Correctness, PIT joins, skew taxonomy, and enforcement architecture

The 3 AM alert screams: "Model AUC dropped 5% overnight." You check data drift dashboards—clean. You check code deployments—unchanged. The feature store reports "healthy." Yet, the fraud model is bleeding revenue. The culprit isn't a bug; it’s a broken promise. A silent timestamp mismatch in a join between the offline training store and the online serving store meant the model trained on "yesterday's truth" but served "today's stale cache." This is Training-Serving Skew, and it happens because your feature store is acting like a database instead of a contract enforcer. This article formalizes the **Feature Contract**—a binding agreement covering Schema, Point-in-Time (PIT) Semantics, SLAs, and Lineage—as the architectural primitive required to eliminate skew in 2026 production systems. This pattern is a core pillar of the Engineering ML Systems in 2026: Beyond Notebooks to Reliable Production Architecture framework.

Executive Summary & Key Takeaways:
  • Skew is a Contract Violation: Training-serving skew is not an inevitable statistical phenomenon; it is a systemic failure to enforce temporal and semantic consistency between offline and online feature materialization.
  • The Feature Contract Primitive: A Feature Contract elevates a feature from a "column" to a versioned API dependency: Schema (Protobuf/Avro) + PIT Semantics (As-Of Join Logic) + SLAs (Freshness/Latency) + Lineage (Governance).
  • Point-in-Time Correctness is Non-Negotiable: The "As-Of Join" (retrieving feature state strictly as of the event timestamp) is the central clause. Implementing this correctly requires handling the "Leakage Window" between training cutoff and serving request time.
  • Four Skew Taxonomy: Detect breaches via Contract Monitoring: Schema Skew (breaking changes), Temporal Skew (Freshness SLA breach), Distribution Skew (Statistical drift), Aggregation Skew (Logic divergence Offline vs Online).
  • Architecture Shift: Move from "Feature Store as Repository" to "Feature Store as Contract Runtime" with a Central Contract Registry, Shift-Left CI/CD Gates, and Runtime Sidecar Enforcement.

Anatomy of a Feature Contract: Beyond Schema

Feature Stores as Contracts: Eliminating Training-Serving Skew with Point-in-Time Correctness
Feature Stores as Contracts: Eliminating Training-Serving Skew with Point-in-Time Correctness

Traditional schema registries (Avro, Protobuf) enforce structure—types, nullability, field order. They are necessary but insufficient for ML. A Feature Contract is a first-class citizen that binds four distinct pillars into a single, versioned artifact deployable via Infrastructure-as-Code.

Figure 1: The Four Pillars of a Feature Contract. A Contract is the atomic unit of trust between Data Engineering and ML Engineering.
Figure 1: The Four Pillars of a Feature Contract. A Contract is the atomic unit of trust between Data Engineering and ML Engineering.

1. Schema: The Structural Clause

This is the baseline. Use Protobuf (preferred for gRPC serving paths) or Avro (preferred for Spark/Iceberg offline paths). The contract must enforce semantic types (e.g., `USER_ID` vs `INT64`, `EMBEDDING_V2` vs `ARRAY`), not just primitive types. Nullability is a contract decision: `required` fields fail validation; `optional` fields trigger imputation logic defined in the Semantics clause.

2. Semantics: The Point-in-Time Correctness Clause

This is the differentiator. The contract explicitly defines how the feature value is derived relative to time.

  • Aggregation Logic: Exact SQL/UDF definition (e.g., `SUM(amount) OVER (PARTITION BY user_id ORDER BY event_ts RANGE BETWEEN INTERVAL '7' DAY PRECEDING AND CURRENT ROW)`).
  • PIT Join Strategy: AS OF JOIN (Left table timestamp >= Right table timestamp, take latest). Not `WHERE event_time < NOW()`.
  • Backfill Policy: `APPEND_ONLY` (immutable history), `CORRECTIVE` (overwrites allowed with audit trail), `RECOMPUTE_FULL` (triggers full lineage replay).

3. SLAs: The Operational Clause

Features are dependencies with uptime requirements. The Contract specifies:

  • Freshness SLA: Max allowable lag between `event_timestamp` and `online_store_write_timestamp` (e.g., `P99 < 5 minutes` for fraud, `P99 < 24 hours` for churn).
  • Availability SLA: Online store read availability (e.g., `99.99%`).
  • Latency SLA: P99 read latency at serving tier (e.g., `< 5ms`).
  • Completeness SLA: Null rate threshold (e.g., `< 0.1%`).

4. Lineage & Governance: The Accountability Clause

Owner: Team/Individual (PagerDuty rotation). Deprecation Policy: Minimum notice period (e.g., 90 days), migration path. PII/Sensitivity Tags: `PII:HIGH`, `REGULATED:GDPR`. Cost Center: Attribution for compute/storage.

"A Schema Registry tells you what the data looks like. A Feature Contract tells you if you can trust it for a specific model at a specific timestamp."

— ML Platform Lead, Major Ride-Sharing Platform

Point-in-Time Correctness: The Non-Negotiable Clause

Point-in-Time (PIT) Correctness guarantees that the feature vector used for training at time T_train is identically reconstructable from the feature store at serving time T_serve for the same entity at the same event time T_event. This is the "Time Travel" guarantee.

The "As-Of Join" Reference Implementation

The core mechanic is the As-Of Join (Range Join). It finds the feature row with the greatest `event_timestamp` less than or equal to the `lookup_timestamp` (training event time or serving request time).

Anti-Pattern: The WHERE event_time < NOW() Trap.
Using the current wall-clock time (`NOW()`, `CURRENT_TIMESTAMP`) in training queries causes catastrophic leakage. The training set sees future data relative to the training event. In serving, `NOW()` is the request time. The logic diverges. The Contract mandates parameterized timestamps.

Reference SQL (BigQuery / Spark SQL / Flink Syntax)

-- CONTRACT CLAUSE: PIT_JOIN_DEFINITION
-- Feature: user_7d_spend
-- Entity: user_id
-- Timestamp Column: event_timestamp
-- Lookup Timestamp: :lookup_ts (Parameterized: Training Event Time OR Serving Request Time)

SELECT
  e.user_id,
  e.event_timestamp AS lookup_ts,
  f.amount_7d_sum,
  f.event_timestamp AS feature_event_ts
FROM
  `project.events` AS e  -- Left: Entity events (Training labels or Serving requests)
LEFT JOIN
  `project.feature_store.user_7d_spend` AS f
  ON e.user_id = f.user_id
  AND f.event_timestamp <= e.event_timestamp  -- AS-OF CONDITION
QUALIFY ROW_NUMBER() OVER (PARTITION BY e.user_id, e.event_timestamp ORDER BY f.event_timestamp DESC) = 1
-- QUALIFY ensures we pick the LATEST feature state BEFORE the lookup time.

PySpark Implementation (Offline Training Generation)

from pyspark.sql import functions as F
from pyspark.sql.window import Window

def pit_join(entities_df, features_df, entity_key, entity_ts_col, feature_ts_col):
    """
    Contract-compliant Point-in-Time Join.
    entities_df: DataFrame with [entity_key, entity_ts_col, ...labels]
    features_df: DataFrame with [entity_key, feature_ts_col, ...feature_values]
    """
    joined = entities_df.alias("e").join(
        features_df.alias("f"),
        (F.col(f"e.{entity_key}") == F.col(f"f.{entity_key}")) &
        (F.col(f"f.{feature_ts_col}") <= F.col(f"e.{entity_ts_col}")), # As-Of Condition
        "left"
    )
    
    # Deduplicate: Keep latest feature state per entity per lookup time
    window = Window.partitionBy(f"e.{entity_key}", f"e.{entity_ts_col}").orderBy(F.col(f"f.{feature_ts_col}").desc())
    return joined.withColumn("rn", F.row_number().over(window)).filter("rn = 1").drop("rn", f"f.{entity_key}")

# Usage in Training Pipeline
training_set = pit_join(
    entities_df=labels_df, 
    features_df=offline_store.read("user_7d_spend"), 
    entity_key="user_id", 
    entity_ts_col="event_timestamp", 
    feature_ts_col="event_timestamp"
)
Figure 2: PIT Correctness Visualization. Training uses state AS OF T_train. Serving uses state AS OF T_serve. The Contract ensures the JOIN LOGIC is identical; only the lookup timestamp parameter changes.
Figure 2: PIT Correctness Visualization. Training uses state AS OF T_train. Serving uses state AS OF T_serve. The Contract ensures the JOIN LOGIC is identical; only the lookup timestamp parameter changes.

The Leakage Window & Backfill Handling

The "Leakage Window" is the interval (T_train_cutoff, T_serve]. If a backfill corrects historical feature values after the model was trained but before it serves, the online store must reflect that correction before the model sees the entity again, or the Contract Freshness SLA is breached. The Contract's `Backfill Policy` clause dictates the propagation mechanism (CDC stream vs. batch recompute).

Taxonomy of Skew: Detecting Contract Breaches

Monitoring "drift" is vague. Monitoring "Contract Breaches" is actionable. We categorize skew into four distinct violation types, each with a specific detection mechanism tied to the Contract clauses.

Figure 3: The Skew Taxonomy. Every skew type maps to a specific Contract Clause and Detection Metric.
Figure 3: The Skew Taxonomy. Every skew type maps to a specific Contract Clause and Detection Metric.
Skew Type Contract Clause Violated Root Cause Detection Metric / Alert Remediation
Schema Skew Schema Upstream producer changes type/name; Consumer not updated. Schema Registry Compatibility Check (BACKWARD/TRANSITIVE); Great Expectations `expect_column_to_exist`. Block deployment via CI/CD Gate; Consumer-side adapter layer.
Temporal Skew SLA (Freshness) Ingestion pipeline lag; Online store write failure; Clock drift. max(event_timestamp) - now() > Freshness_SLA; Lag metric per feature view. Alert on-call; Fallback to default/last-known-value (if Contract allows).
Distribution Skew Semantics / SLA (Completeness) Upstream data quality issue (sensor failure); Population shift. PSI (Population Stability Index) > 0.2; KL Divergence; Null Rate > Completeness_SLA. Retrain trigger; Data quality incident response.
Aggregation Skew Semantics (Logic) Offline SQL (Spark) != Online UDF (Redis Lua / Go); Window boundary off-by-one. Shadow Validation: Compare Offline Computed vs Online Served for same Entity/Time (Checksum Diff). Unify logic via Shared Library (WASM/SQL UDF) or Transpiler.

Aggregation Skew is the most insidious. It occurs when the Offline Store computes a 7-day window using `RANGE BETWEEN INTERVAL '7' DAY PRECEDING` (calendar aware) while the Online Store uses a fixed-size rolling buffer of 168 hours (leap second/daylight savings agnostic). The Contract must specify the exact window semantics (Calendar vs. Fixed Duration) and the implementation must be shared (e.g., a Rust/WASM module compiled for both Spark and the Online Serving Sidecar).

Architecture Patterns: Enforcing Contracts at Scale

Contracts are useless without a runtime that enforces them. We define three architectural patterns for the "Feature Store as Contract Runtime."

Figure 4: Feature Store as Contract Runtime. The Contract Registry is the Control Plane; Enforcement Points are the Data Plane.
Figure 4: Feature Store as Contract Runtime. The Contract Registry is the Control Plane; Enforcement Points are the Data Plane.

Pattern A: Centralized Contract Registry (The Control Plane)

A dedicated service (backed by Git + DB) storing Contract definitions (Protobuf + JSON Policy). It serves as the source of truth for:

  1. Code Generation: Generates PIT Join SQL templates, Online Store UDFs, Validation Suites.
  2. Compatibility Checks: Enforces `BACKWARD` compatibility on `PUT` (Producer cannot break Consumer).
  3. Lineage Graph: Maps `Source Table -> Feature View -> Model Version`.

Pattern B: Shift-Left Contract Testing (CI/CD Gates)

Before a feature PR merges, the pipeline executes:

  1. Schema Lint: `buf breaking` / `avro-tools` compatibility check against `main` branch Contract.
  2. Semantic Validation: Run generated PIT Join on a "Golden Dataset" (curated sample covering edge cases: late arrivals, backfills, nulls). Assert output matches `expected_golden.parquet`.
  3. SLA Simulation: Replay last 7 days of ingestion logs against the new logic. Verify `Freshness_P99 < Contract.SLA`.
  4. Shadow Diff: Deploy candidate to Shadow Online Store. Mirror 1% traffic. Compare `Online_Value` vs `Offline_Recomputed_Value` (Checksum match > 99.99%).

Pattern C: Runtime Enforcement (The Sidecar Proxy)

The Online Serving Path intercepts every read via a Sidecar (Envoy/WASM filter or dedicated gRPC proxy):

  • Freshness Check: Read `feature_event_timestamp` from Online Store metadata. If `now() - feature_event_timestamp > Contract.Freshness_SLA` -> Return `STALE` error / Trigger Fallback / Alert.
  • Schema Coercion: Validate payload against Contract Protobuf. Reject/Log malformed writes from ingestion pipelines.
  • Rate Limiting / Quotas: Enforce per-model quotas defined in Contract Governance.

Implementation Guide: From Theory to Pipeline

Here is the end-to-end workflow to operationalize Feature Contracts using an OSS stack (Feast + Great Expectations + GitHub Actions) or managed equivalent (Tecton/Databricks).

Step 1: Define the Contract (Protobuf + Policy YAML)

// feature_contracts/user_spend/v1/user_7d_spend.proto
syntax = "proto3";
package feature_contracts.user_spend.v1;

import "google/protobuf/timestamp.proto";

message User7dSpend {
  string user_id = 1 [(feature_contract.semantic_type) = "ENTITY_KEY"];
  google.protobuf.Timestamp event_timestamp = 2 [(feature_contract.semantic_type) = "EVENT_TIME"];
  double amount_7d_sum = 3 [(feature_contract.semantic_type) = "AGGREGATE_SUM", (feature_contract.window) = "7D_CALENDAR"];
  int32 txn_count_7d = 4 [(feature_contract.semantic_type) = "AGGREGATE_COUNT", (feature_contract.window) = "7D_CALENDAR"];
}

// feature_contracts/user_spend/v1/contract_policy.yaml
contract:
  name: "user_7d_spend"
  version: "1.2.0"
  owner: "ml-platform-fraud"
  sla:
    freshness_p99_minutes: 5
    availability_pct: 99.99
    latency_p99_ms: 5
    completeness_null_rate_pct: 0.01
  semantics:
    pit_join_type: "AS_OF"
    aggregation_logic: "SUM(amount) WHERE event_ts IN [lookup_ts - 7d, lookup_ts] CALENDAR_ALIGNED"
    backfill_policy: "CORRECTIVE_WITH_AUDIT"
  governance:
    pii_tag: "NONE"
    deprecation_notice_days: 90

Step 2: Generate PIT Join Code (Templating)

Use a Jinja2/Python script in CI to render the SQL/PySpark join logic from the Protobuf descriptor and Policy YAML. This guarantees the Offline Training Query and the Online Serving Lookup logic are bitwise identical derivatives of the Contract.

Step 3: Implement Validation Suite (Great Expectations / Deequ)


# great_expectations/expectations/user_7d_spend_contract_suite.json
{
  "expectation_suite_name": "user_7d_spend_contract_v1",
  "expectations": [
    {"expectation_type": "expect_table_columns_to_match_ordered_list", "kwargs": {"column_list": ["user_id", "event_timestamp", "amount_7d_sum", "txn_count_7d"]}},
    {"expectation_type": "expect_column_values_to_not_be_null", "kwargs": {"column": "user_id", "mostly": 1.0}},
    {"expectation_type": "expect_column_values_to_be_between", "kwargs": {"column": "amount_7d_sum", "min_value": 0, "strict_min": true}},
    {"expectation_type": "expect_column_max_to_be_between", "kwargs": {"column": "event_timestamp", "min_value": "now() - 5m", "strict_min": false, "meta": {"contract_clause": "freshness_sla"}}}
  ]
}

Step 4: Deploy Monitoring Dashboard (Grafana/Datadog)

Dashboard Panels per Contract:

  • Freshness Lag (P50, P95, P99): `now() - max(event_timestamp)` grouped by `feature_view`. Alert if P99 > Contract SLA.
  • Schema Violation Rate: Count of `SchemaRegistry.DeserializationError` per feature.
  • Shadow Diff Rate: % of shadow requests where `Online_Value != Offline_Recomputed_Value`.
  • Contract Version Distribution: % of traffic served by Contract v1.0 vs v1.1 (Blue/Green rollout visibility).

Step 5: Incident Response Runbook for Contract Breach

Runbook: Temporal Skew Breach (Freshness SLA Violation)
  1. ACK: PagerDuty alerts On-Call (Owner defined in Contract Governance).
  2. DIAGNOSE: Check Ingestion Pipeline DAG (Airflow/Dagster) for `user_7d_spend` materialization task. Look for `LATE_ARRIVAL` or `BACKFILL_RUNNING` tags.
  3. MITIGATE: If Online Store is stale: Trigger emergency `materialize_incremental` for affected entities. If logic bug: Rollback Online Store to previous Contract Version (Blue/Green).
  4. VERIFY: Run Shadow Validation Suite. Confirm Freshness Lag < SLA. Confirm Shadow Diff Rate ~ 0%.
  5. POSTMORTEM: Update Contract `backfill_policy` or `freshness_sla` if root cause was unrealistic SLA. Document in Contract Changelog.

Vendor Landscape: Who Supports Contracts Natively?

No vendor implements the full "Contract Runtime" perfectly yet. The table below scores current capabilities (as of 2026) against the Four Pillars. Score: 0 (None) - 5 (Native/First-Class).

Capability / Vendor Feast (OSS) Tecton Hopsworks Databricks FS (Unity Catalog) Vertex AI Feature Store
Native PIT Join (Offline) 4 (Python SDK `get_historical_features`) 5 (Declarative, handles late data natively) 4 (SQL-based AS-OF joins) 4 (Time Travel + Point-in-Time Lookup) 3 (Timestamp key lookup, manual AS-OF logic often needed)
Contract Registry (Schema + Policy) 2 (Feature Service YAML only; No SLA/Policy engine) 5 (Feature Services + SLAs + Monitoring built-in) 3 (Schema Registry + Validation API) 4 (Unity Catalog: Schema, Lineage, Tags, Quality) 3 (Schema + Monitoring, limited Policy-as-Code)
SLA Monitoring & Alerting 1 (DIY: Feast + Prometheus/Grafana) 5 (Native Freshness/Accuracy Dashboards) 3 (Built-in Monitoring UI) 4 (Lakehouse Monitoring / Quality Tab) 4 (Feature Monitoring Jobs)
Schema Evolution Safety 3 (Protobuf/Avro support, manual compat checks) 5 (Enforced Compatibility Modes) 4 (Avro/Schema Registry Integration) 5 (Unity Catalog: Type Widening, Column Masking) 3 (Protobuf, manual enforcement)
Offline/Online Logic Parity 2 (User ensures UDF parity; WASM support emerging) 5 (Single Def -> Offline/Online Compilation) 3 (HSFS Engine parity focus) 4 (Python UDFs / Spark SQL parity) 2 (Divergent Offline/Online compute paths common)
Governance as Code (Terraform/Api) 4 (Feast Apply / Terraform Provider) 5 (Full Terraform / CLI / API) 4 (Terraform Provider / Python SDK) 4 (Terraform / Databricks CLI) 3 (Terraform / gcloud)

Strategic Recommendation: If you need zero-ops Contract Runtime today → Tecton. If you need OSS control + Lakehouse integration → Feast + Unity Catalog/Iceberg + Custom Contract Registry Layer. If you are all-in Databricks → Unity Catalog Feature Store is rapidly closing the Contract gap.

Case Study: Recovering from 'The Silent Drift'

Context: A fintech company serving real-time credit scoring. Model: Gradient Boosted Trees. Feature: `user_30d_cash_flow_volatility`.

Incident: Model PSI (Population Stability Index) drifted 0.15 -> 0.45 over 2 weeks. AUC dropped 0.03. No code deploy. No upstream schema change. Data drift monitors (univariate) showed minor shifts, nothing explaining the magnitude.

Root Cause Analysis (Contract Lens):

  1. Offline Store: A backfill job ran 10 days ago to correct `transaction_amount` for a known upstream bug (Jan 1-15 data). The Offline Store (Iceberg) now reflects corrected history.
  2. Online Store: The materialization pipeline (Flink -> Redis) processed the backfill but hit a transient Redis OOM error on Jan 12th. The checkpoint recovered, but the corrected values for Jan 1-15 were never written to Redis. Redis served stale, buggy values for those dates.
  3. Contract Gap: The Feature Contract existed (Schema + Logic) but lacked a Freshness SLA with Backfill Verification Clause. The monitoring checked "Is data < 24h old?" (Yes, recent transactions flowed). It did not check "Does historical data match Offline Truth?".

Resolution via Contract Enforcement:

  1. Added `backfill_verification: true` to Contract Policy.
  2. Implemented Shadow Validation Job (Pattern C): Daily Spark job reads `Offline_Store AS OF yesterday` vs `Online_Store SNAPSHOT`. Computes checksum per entity. Alert on mismatch > 0%.
  3. Deployed Sidecar Freshness Check with `historical_horizon_check`: Verifies Online Store has values for `event_timestamp` up to `Contract.lookback_window` (30 days), not just `now() - 24h`.

Result: Skew incidents dropped to zero. The "Contract" transformed a vague data quality issue into a specific, testable, enforceable SLA breach with an automated remediation path.

Advanced: Contract Evolution & Governance

Contracts change. Managing that change without breaking downstream models is the final maturity step.

Semantic Versioning for Features (SemVer-F)

  • PATCH (1.0.1): Bug fix in aggregation logic (e.g., fixed off-by-one in window). Risk: Changes historical values. Requires full backfill + Model Retrain/Shadow Validation. Breaking for Reproducibility.
  • MINOR (1.1.0): New feature added (`user_30d_spend` added alongside `user_7d_spend`). Backward compatible. Consumers opt-in.
  • MAJOR (2.0.0): Breaking change: `user_id` -> `hashed_user_id`; `7D_CALENDAR` -> `7D_FIXED`. Requires new Contract Name (`user_spend_v2`) or Namespace. Old Contract enters `DEPRECATED` state (90-day sunset per Governance Clause).

Governance as Code (Terraform Example)


resource "feast_feature_service" "fraud_v1" {
  name        = "fraud_scoring_v1"
  project     = "production"
  features    = [
    "user_7d_spend:v1.2.0",  # Pinned Contract Version
    "merchant_risk_score:v1.0.0"
  ]
  tags = {
    sla_tier = "gold"
    owner    = "ml-fraud"
  }
}

resource "feast_feature_view" "user_7d_spend_v1_2_0" {
  name        = "user_7d_spend"
  version     = "1.2.0"
  entity      = "user_id"
  ttl         = "720h" # 30 days
  schema      = filebase64("schemas/user_7d_spend.proto")
  online      = true
  source      = feast_file_source.offline_user_spend
  
  # Contract Policy as Metadata
  metadata = jsonencode({
    freshness_sla_minutes = 5
    pit_join_type         = "AS_OF_CALENDAR"
    backfill_policy       = "CORRECTIVE_WITH_AUDIT"
  })
}

Multi-Tenancy via Contract Namespaces

Enforce isolation: `team_fraud.user_7d_spend:v1` vs `team_marketing.user_7d_spend:v1`. Different SLAs, different owners, different PII tags. The Contract Registry enforces namespace boundaries—preventing Marketing from reading Fraud's PII-HIGH features without explicit `ACCESS_GRANT` Contract.

Conclusion: Contracts are the API of Data

We started with a 3 AM alert. We end with a principle: Features are not data; they are dependencies. In 2026, treating features as unversioned, untyped, SLA-less CSV dumps is technical debt of the highest order. The Feature Contract—encapsulating Schema, Point-in-Time Semantics, Operational SLAs, and Governance Lineage—transforms the Feature Store from a passive repository into an active Contract Runtime.

The ROI is measurable: elimination of silent skew, reproducible training, confident backfills, and auditable compliance. The implementation path is clear: Define the Contract (Protobuf + Policy), Generate the PIT Join (Single Source of Truth), Enforce in CI/CD (Shift-Left), Enforce at Runtime (Sidecar), Monitor for Breaches (Contract Dashboards).

Stop guessing if your features are correct. Start contracting them.

Frequently Asked Questions

What is the difference between a Schema Registry and a Feature Contract?

A Schema Registry (e.g., Confluent, Apicurio) enforces structural compatibility (wire format: Avro/Protobuf) — ensuring a consumer can *deserialize* a message. A Feature Contract encompasses the Schema but adds **Semantic Clauses** (Point-in-Time Join logic, Aggregation definitions), **Operational SLAs** (Freshness, Latency, Availability), and **Governance Metadata** (Ownership, Deprecation, PII tags). A Schema Registry asks "Can I read this bytes?"; A Feature Contract asks "Can I trust this feature for *this model* at *this timestamp*?"

How does Point-in-Time (PIT) Correctness prevent Data Leakage?

Data Leakage (Look-Ahead Bias) occurs when training data includes information not available at prediction time (e.g., using `WHERE event_time < NOW()` in training). PIT Correctness mandates an **As-Of Join**: `Feature_Value = MAX(Feature) WHERE Feature_Event_Timestamp <= Lookup_Timestamp`. During training, `Lookup_Timestamp` is the historical event time (label time). During serving, `Lookup_Timestamp` is the request time. Because the *join logic is identical* and parameterized by the Contract, the model never sees "future" feature values relative to its decision point, eliminating temporal leakage by construction.

Can I implement Feature Contracts without buying a commercial Feature Store (Tecton/Databricks)?

Yes. The "Contract Runtime" pattern is architecture, not vendor-locked. You can build it on OSS: Feast (Feature Definitions/Serving) + Apache Iceberg/Delta Lake (Offline Store with Time Travel) + Great Expectations/Deequ (Contract Validation) + Custom Contract Registry (Git Repo + CI/CD Pipeline generating PIT SQL/UDFs) + Redis/DynamoDB + Sidecar Proxy (Online Enforcement). The commercial tools (Tecton, Databricks Unity Catalog) accelerate this by providing the Registry, Monitoring, and Offline/Online Logic Parity out-of-the-box, reducing the "DIY Tax."

How do you handle Aggregation Skew (Offline vs Online Logic Mismatch)?

Aggregation Skew is solved by **Single Source of Truth for Logic**. The Feature Contract defines the aggregation (e.g., in a shared `.sql` or `.rs`/WASM file). The CI/CD pipeline (Pattern B) compiles this single source into: 1. Spark SQL for Offline Materialization. 2. Rust/WASM UDF for Online Store (Redis Module / Feast Sidecar). 3. Flink SQL for Stream Materialization. The Shadow Validation Job (Pattern C) continuously verifies `Offline_Computed == Online_Served` for a sample of traffic. Any divergence is a Contract Breach (Aggregation Skew), blocking deployment.

What is the "Leakage Window" and how does the Contract manage it?

The Leakage Window is the time gap between the **Training Data Cutoff** (the latest event time in your training set) and the **Model Deployment Time**. During this window, the Offline Store might receive late-arriving data or backfills correcting history. If the Online Store isn't updated identically, the model serves on stale/incorrect features. The Contract manages this via the **Backfill Policy Clause** (mandating propagation to Online Store) and the **Freshness SLA** (which must cover the *entire lookback window*, not just the last 24h). The Shadow Validation Job explicitly compares Offline vs Online state for historical timestamps within the lookback window to detect Leakage Window divergence.

Post a Comment