updated 2026-11-26·3 min read
Declarative Boundary Contracts Reference
Declarative boundary rule layout (LINT-001, LINT-002, LINT-004) and cross-boundary diff remediation.
contracts/boundary_policy.yaml ties SQL schemas, Python ETL workers, and Rust edge proxies into one checkable spec without forcing you to rewrite native code into an IDL.

Target Bindings in boundary_policy.yaml
Upstream Producers
- ClickHouse Target:
migrations/001_bot_signals.sql, enforced predicateAND database = currentDatabase(), 200 canonical columns withr0andr1shards isolated. - Python ETL Pipeline:
services/feature-pipelinecovering 6 security domains (200 features) serialized intopayloads/features.jsonwith explicit 200-item bounds.
Downstream Consumer & Invariants
- Rust L7 Edge Proxy:
crates/cloudflame-proxyallocating[FeatureDescriptor; 200]stack storage partitioned via Dual-Zone128 + 72select_nth_unstable_by(0 Bheap). - Active Policy Digest:
e3b0c442...b855(schema_version: "2026.09.25",max_canonical_features: 200).
Enforced Contract Invariants
# contracts/boundary_policy.yaml
schema_version: "2026.09.25"
target_workspace: "cloudflame-l7-proxy"
max_canonical_features: 200
rules:
- id: "LINT-004"
assertion: "cardinality_risk_ratio = C_upstream / B_downstream <= 1.0"
on_violation: "block_pr_merge_upstream"
protection: "avoids 502/TryFromSliceError blackouts across edge nodes"
heap_allocation_limit_bytes: 0
- id: "LINT-001"
assertion: "system.columns reflection query must declare database filter"
on_violation: "flag_unscoped_reflection"
- id: "LINT-002"
assertion: "wire serialization sinks must declare explicit limit or slice clamp"
on_violation: "reject_unbounded_payload"
Cross-Boundary Remediation Diff (stokes audit --diff)
When drift pushes the Cardinality Risk Ratio to 1.40 (280 features arriving at a 200-slot buffer), Stokes emits coordinated upstream and downstream fixes:
// services/feature-pipeline/catalog_sync.py
- query = "SELECT name, type FROM system.columns WHERE table LIKE 'events%'"
+ query = "SELECT name, type FROM system.columns WHERE database = currentDatabase() AND table = 'events'"
// crates/cloudflame-proxy/src/engine/feature_ingest.rs
- raw_features.into_boxed_slice().try_into().unwrap() // panic on #201
+ ingest_descriptors_dual_zone(&mut raw_features, &mut buffer); // 128 core + 72 adaptive
Boundary Contracts & Rules FAQ
- What is the Cardinality Risk Ratio?
upstream_columns / buffer_capacity. Values<= 1.0guarantee safe intake; values> 1.0(such as280 / 200 = 1.40) cause downstream buffer overflow panics. - What are
LINT-001throughLINT-006?LINT-001flags unscopedsystem.columnsqueries;LINT-002flags unbounded Python extraction loops;LINT-003flags unbounded Protobufrepeatedfields withoutstokes.max_items;LINT-004flags.try_into().unwrap()on fixed arrays;LINT-005flags heap allocations on hot paths;LINT-006flagsSELECT *wildcards. - How do queries trace contracts without running code? AST/regex patterns map SQL projections, Python extraction loops, Protobuf repeated fields, and Rust fixed-size arrays directly from source files.
- How does Stokes prevent silent data corruption? It prevents blind truncation by pinning 128 core signals in Zone 0 (
priority >= 200), partitioning the remaining 72 slots in Zone 1 viaselect_nth_unstable_by, and scoping upstream queries withAND database = currentDatabase().
See Untyped Seams Across Compilers and Channel Binding & Manifests for boundary examples.