Rye Own your data. Let agents do the rest.

Model

Rye — Core Contract and Conformance Kit

Validate your deployment against Rye's core contract before production rollout.

Source file: design/model/core-contract-and-conformance.md

Rye — Core Contract and Conformance Kit

Normative Contract, Implementation Checklist, and Test Matrix


1. Purpose

This document defines:

  1. The Core Contract that should stay stable across versions.
  2. A practical implementation checklist for shipping Rye safely.
  3. A conformance test matrix so adopters can verify behavior in their environment.

The goal is to keep Rye opinionated and agent-friendly while remaining extensible for unknown domains.


2. Layer Model

Rye should be implemented as three layers:

  1. Stable Core (normative): shared guarantees every adopter can rely on.
  2. Extensible Conventions (profiles): CRM/PM/domain-specific semantics that can vary.
  3. Agent-Safe Interface: constrained write paths, auditable operations, and consistent security semantics.

3. Core Contract (Normative)

3.1 Core Objects (MUST)

  • nodes, edges, events, event_participants, assertions, artifacts exist.
  • current_assertions exists and returns only non-superseded assertions.
  • assertions support supersession (superseded_at, superseded_by) and preserve history.
  • Soft-delete semantics are explicit (archived_at) where applicable.

3.2 Core Behavior (MUST)

  • Assertions are append-only in content: replacement is via supersession, not in-place mutation.
  • Events are immutable once written (except metadata fields if explicitly documented).
  • Entity and relationship typing is convention-driven (node_type, edge_type, etc.), not hardcoded by schema branching.
  • Provenance is preserved for agent and human operations (actor/session/event traceability).

3.3 Extensibility (MUST)

  • Unknown node_type and edge_type values are supported without migrations.
  • Domain table integration occurs through node_source_map (or equivalent mapping mechanism), not tight coupling.
  • Domain profiles can add conventions without breaking core contract behavior.

3.4 Security Model (MUST)

  • One authorization model is used consistently (session context + RLS recommended).
  • Security policy behavior is deterministic and testable by role/team/user context.
  • Field redaction behavior is deterministic and documented.
  • Agent permissions are explicit (read-only, constrained write, privileged/admin-assist).

3.5 Agent Interface (SHOULD)

  • Stable function surface for writes (for example: create, advance, supersede, merge flows).
  • Explicit forbidden operations for agents (for example: destructive deletes, unmanaged direct updates).
  • Human-approval boundaries for high-risk operations.

4. Implementation Checklist

Use this checklist before releasing a Rye version.

4.1 Spec and Versioning

  • Core contract is versioned (for example v1, v1.1) and changelog is published.
  • Every documented SQL example is syntactically valid for supported PostgreSQL versions.
  • Core vs profile-specific behavior is clearly labeled.

4.2 Schema and Functions

  • Fresh install path succeeds end-to-end.
  • Upgrade path from previous version is documented and tested.
  • Core functions are stable and documented with inputs, outputs, and side effects.
  • Invariants are enforced by constraints/triggers/functions, not only narrative docs.

4.3 Security and Governance

  • RLS scope is complete for all protected tables.
  • Write policies align with function behavior (no accidental bypasses).
  • Redacted views/functions are available for sensitive JSONB fields.
  • Audit/provenance requirements are met for all write operations.

4.4 Agent Operations

  • Agent write paths are constrained to approved functions.
  • High-risk actions require explicit human approval.
  • Denied operations produce clear, actionable errors.
  • Agent operations are logged and attributable.

4.5 Performance and Operability

  • Baseline indexes are in place and justified.
  • Query plan and p95/p99 latency baselines exist for core queries.
  • Materialized views are optional and justified by measured query pressure.
  • Monitoring dashboard includes schema growth, query latency, and policy overhead.

4.6 Documentation and Adoption

  • Conventions catalog exists (type definitions, required claim keys, semantics).
  • Minimum quickstart path exists for self-hosted adopters.
  • Conformance test kit is executable in CI.
  • Backward compatibility and deprecation policy are documented.

5. Conformance Test Matrix

Legend:

  • P0: required to claim “Rye Core Conformant”
  • P1: strongly recommended for production readiness
  • P2: optional/advanced
IDCategoryPriorityWhat to validateMethodPass CriteriaCovered By
SC-01Schema InstallP0Fresh schema install worksRun migrations on empty DBAll objects created without manual interventiondocker-test.sh --reset
SC-02Schema ReapplyP0Migration behavior is deterministicRe-run migration sequenceExpected idempotent result or explicit versioned failuremigrate.sh (tracks applied)
SC-03Schema UpgradeP0Forward upgrade works on realistic dataApply vN -> vN+1 on fixture DBNo data loss, invariants preserved
FN-01Function ContractP0Core function signatures/behavior are stableUnit tests per functionInputs/outputs and side effects match specverify.sh, S5 (merge_nodes)
FN-02SupersessionP0Assertion supersession behaviorInsert + supersede sequence testExactly one active assertion per subject/type per flow02_supersession, S7 (concurrent)
FN-03ProvenanceP0Writes retain actor/source traceabilityIntegration testsAll writes produce required provenance fieldsS5 (merge provenance)
IV-01IntegrityP0No orphan referencesFK/integrity checks after test flowsNo broken refs in core tablesFK constraints + S5
IV-02History SafetyP0Historical assertions remain queryablePoint-in-time query testsPrior assertions preserved and reconstructableS5 (superseded assertions)
EX-01Type ExtensibilityP0New node_type/edge_type works without migrationInsert/query unknown typesCRUD + traversal works for new types01_core_contract
EX-02Domain OverlayP1Integration with external domain tablesnode_source_map + join testsStable joins and deterministic mapping behavior
EX-03Profile IsolationP1CRM/PM profile does not break coreEnable/disable profile testsCore behavior unchanged without profile tables/views
SE-01Read SecurityP0RLS read matrix by role/team/userTable-driven security testsAllowed reads succeed; disallowed reads blockedS1-S4, R1-R4
SE-02Write SecurityP0Authorized writes onlyRole-based mutation testsUnauthorized writes blocked consistentlyS1 (agent), S3, R6, R8-R9
SE-03RedactionP0Field-level redaction behaviorQuery redacted views across rolesSensitive fields hidden per policyS1 (nodes_secure), S4
SE-04Policy ConsistencyP1No policy bypasses via alternate pathDirect DML + function path testsEquivalent enforcement across paths01_assertion_policies, R8
AG-01Agent Read OpsP0Agent can fetch minimal context safelyScenario tests with agent roleReturns scoped, redacted, relevant contextS1 (agent:crm-sync), S2 (agent:pm-bot)
AG-02Agent Write OpsP0Agent can perform allowed writes onlyScenario tests via approved functionsAllowed writes succeed, forbidden writes failS1, S2, R6, R9
AG-03Human Approval GateP1High-risk actions are gatedSimulated approval workflow testsAction blocked without approval, succeeds with approval
AG-04Agent AuditabilityP1Agent actions are fully auditableEvent/provenance log verificationActor, time, and target references completeS5 (log_agent_query)
QY-01Query ContractsP0Core query outputs are deterministicSnapshot tests for core views/functionsStable schemas and deterministic row semanticsS1-S4 (exact counts)
QY-02Profile QueriesP1CRM/PM views return one-row-per-entity when promisedFixture tests for fan-out casesNo duplicate entity rows unless documented
CC-01Code GenerationP0Human-readable codes under concurrencyParallel insert testsNo duplicates; sequence semantics preserved01_code_generation.sh
CC-02Local SequenceP1Project-local sequence behaviorParallel task create testsNo collisions; monotonic per project
OP-01ObservabilityP1Core metrics emittedSmoke tests against monitoring queriesMetrics available for size/latency/errors
OP-02Performance BaselineP1Baseline latency and explain plansBenchmark fixture + plan checksMeets documented baseline thresholds
OP-03Scale GuardrailsP2Degradation behavior past baselineStress testsClear breakpoints and mitigations documented
BC-01Backward CompatibilityP0Previous client workflows still functionCompatibility suite across versionsNo breaking change without version bump + migration notes
BC-02Deprecation PolicyP1Deprecated features remain operable through grace periodContract tests on deprecated pathsBehavior + warnings match policy

Coverage Legend

  • S1-S6: Scenario tests (tests/scenarios/01-06_*.sql)
  • R1-R10: Recommendation tests within 06_recommendations.sql
  • S7: Concurrent supersession test (07_concurrent_supersession.sh)
  • 01_*, 02_*, 03_*: Conformance/security/concurrency tests
  • : Not yet covered by automated tests

6. Release Gates

Gate A — Core Conformant

Required: all P0 tests pass.

Gate B — Production Ready

Required: all P0 and P1 tests pass, plus operational runbook available.

Gate C — Scale Ready

Required: P0/P1 pass and relevant P2 scale tests completed for target workload.


7. Suggested Repo Structure for Adoption

/schema
  /core
  /profiles
  /migrations
/tests
  /conformance
  /security
  /concurrency
  /performance
/docs
  core-contract.md
  conventions-catalog.md
  agent-ops-guide.md

This separation helps teams reuse the core while customizing profiles and domain integrations safely.