Skip to content

Runtime Invariants

pawaca edited this page Aug 30, 2026 · 1 revision

Runtime Invariants

Upstream's configurable assertion registry and Edge's platform-specific invariant contracts.

Upstream reference: Runtime Invariants

What Upstream Provides

The package provides — a configurable registry where each workspace package publishes runtime checks under its npm name. Key design points:

  • Scope: checks examine authoritative event streams or mutable data, never whether services or methods exist.
    • Selection: toggle + / regex patterns. Blocklist wins.
    • Isolation: each installer runs in a dedicated cordis child fiber. Failures produce attributed to the violating package.
    • Convention: every workspace package provides a companion plugin, verified by toolchain.

What Edge Changed

Transitive Dependency dsh-invariants

is present in the standalone dependency closure (transitive via other upstream packages) but not explicitly installed as a plugin. No call exists. Upstream companion invariant plugins are not registered.

Edge-Specific AGENTS.md invariant contracts

Edge defines its own invariant contracts in (lines 30–39), enforced by code review and CI rather than by the runtime registry. These cover platform-specific guarantees that upstream's package-scoped assertion model doesn't address:

Invariant Enforcement
No correlated subqueries on request paths — DO SQL queries must use materialized tables, never per-row scans against unbounded event tables Code review +
Credential safety — never log , bearer tokens, or owner cookies. Provider credentials are per-call resolved, never cached across requests or written to session events design + code review
Projection delivery ordering — projections for seq N arrive after their backing frame and after flush Sync capture + seq-matched drain in
DO SQL atomicity — event batches and summary updates commit in a single transaction boundary
Single upstream version — all standalone dependencies pin one exact version CI +
Gzip budget — direct mode Worker must stay below 921,600 bytes gzip Build script budget check
Patch discipline — every retained upstream patch has a version-bound filename, failing-without-it test, rationale, and removal condition Code review + patch verification script
cordis sub-registry provide — + must be paired when another plugin uses Code review (learned from )

What Edge Did NOT Change

  • Upstream's package API, type, and companion plugin convention
    • Session event ordering and append-only guarantees (upstream class)
    • Flush/checkpoint contracts (upstream interface)

Architecture Summary

Component Category Notes
registry Available In dependency closure but not installed as plugin
AGENTS.md contracts Edge-specific 8 platform invariants enforced by review + CI
DO SQL constraints Edge-specific tables, constraints,

Key observation: Upstream's invariant system is a runtime assertion registry scoped to package-level checks. Edge's invariants are platform-level contracts (SQL atomicity, credential safety, projection ordering) that operate at a different layer. The two are complementary — upstream's registry could be installed to add per-package runtime checks without conflicting with Edge's structural invariants.

English

中文

Clone this wiki locally