Unclassified

Runtime Substrate and Workbench Surface Contract

Status: Derived implementation contract — required for platform completion; does not supersede frozen architecture

Date: 2026-07-28
Authority: ARCHITECTURE_LOCK.md and IMPLEMENTATION_CONTRACT_v1.1.md

1. Binding rules

  1. Schemas are pure entity-based. Persisted records represent a business or
    platform entity, relationship, event, evidence artifact, policy, capability,
    execution, or versioned definition. They are never created merely because a
    sidebar label exists. There is no home, inbox, work-view-1, or
    finance-manager source-of-truth table.
  2. Projections are RBAC-based. Gateway derives tenant, membership, role,
    permissions, policy, entitlement and permitted connector context from the
    authenticated identity. Projection Engine then applies role, department,
    industry, data availability, freshness and user preference. The browser may
    request a view; it cannot select a broader data scope.
  3. A Workbench surface never maps one-to-one to a physical table. It resolves a
    versioned projection contract through Gateway and Projection Engine.
  4. A physical table may be a primary source, but every projection may use
    multiple supporting sources, permission rules, connector availability and
    capability state.
  5. Product never reads or writes platform tables directly. A mutation is a
    semantic command through Gateway → Governance → Hermes where required →
    Pipeline promotion → projection invalidation.
  6. The following runtime guarantees are mandatory Base Spine/platform
    capabilities: event transport, idempotency, capability resolution,
    discovery, queues, retry/replay, sync/reconciliation, observability, cache
    discipline and object/evidence storage. Industry and connector extensions
    may add mappings; they must not redefine these guarantees.
  7. The Twin is silent by default. A conversational intake may be offered in a
    contextual surface, but it neither becomes a mandatory chat panel nor writes
    truth directly. Submitted content is triaged, evidenced, governed where
    required, then promoted through the Pipeline.

2. Runtime substrate

flowchart LR
    I["Ingress: webhook, poll, stream, API, MCP, user intent"] --> V["Validate + archive raw artifact"]
    V --> E["Immutable event + idempotency/deduplication"]
    E --> B["Event bus / stream / queue"]
    B --> D["Discovery and capability resolution"]
    D --> G["Governance"]
    G --> H["Hermes / worker runtime"]
    H --> P["Provider or local execution"]
    P --> O["Outcome event"]
    O --> S["Sync, verify and reconcile"]
    S --> W["Pipeline promotion to Spine"]
    W --> X["Projection invalidation and Workbench"]

The Projection Engine and Workbench sit above this substrate. They can observe
its state through semantic projections; they do not manage queue delivery,
stream offsets, provider execution or retries directly.

3. Runtime guarantees and table-status map

The table names in the Required completion records column are the target
contract. A name is not evidence that a migration exists. The migration-035
status below is a repository reading, not a live database verification.

Runtime guaranteeExisting migration-035 evidenceRequired completion records / service stateRelease rule
Event bus and Pub/Subspine_event_types, spine_events, topics, subscriptions, deliveries, offsets, dead letterspublisher registry, subscription filters, per-tenant ordering and replay policyImmutable envelope, delivery attempt tracking, isolated subscriber failure and poison-event quarantine.
Idempotency and deduplicationevent idempotency_key; sync mutation idempotency keyspine_idempotency_keys, deduplication records, operation fingerprintsSame logical operation + scope + key produces one accepted effect. Provider timeout is reconciled before a retry.
Capability matrixcapabilities, versions, provider/policy bindings, runs and stepsimplementation, requirement, role, connector and availability matrix recordsResolve capability by tenant/workspace/role/connector/auth/data/policy; installation expands implementations, never redefines base capability.
Discoverydiscovery runs, assets, capability candidates, domain manifestssnapshots, discovered objects/fields/events/operations, classification and extension candidatesDiscovery describes and maps a provider. It never mutates physical schema automatically.
Queues and workersevent deliveries and continuity retries; Cloudflare runtime bindings are outside schemaruntime queues, message/lease/attempt/dead-letter metadata and queue policiesUser work queues and platform execution queues are separate planes.
Streamingevent consumer offsetsstream/partition/checkpoint/consumer-group metadata where a provider needs ordered replayUse for ordered/high-volume changes; do not confuse it with Pub/Sub fan-out.
Webhook ingressintegration webhook endpointsverified deliveries, signatures, classified events and failure records; raw payload in R2Verify signature, archive raw payload, check replay/idempotency, then publish canonical event.
Polling ingressconnector cursors and sync runspoll definitions, schedules, leases, results/failuresAdvance a cursor only after emitted events are durably accepted.
Sync and reconciliationsync runs, mutations, conflicts, verificationsdefinitions, checkpoints, pending mutations, dead letters and reconciliation recordsAn API success is not closure; re-ingest, compare expected/actual, reconcile, then close.
Replay and reprocessingdelivery dead letters and continuity retriesreprocess request/run/item, replay checkpoint and dead-letter resolutionReplay is a governed operation with dry-run/execution mode, target consumers, side-effect policy and verification method.
Logging and traceabilityaudit log, event correlation/causation, entity trace/correlation fieldsstructured log references, runtime errors, trace spans, causation/lineage recordsRedacted, tenant-aware, queryable and retention-controlled. Logs are not audit lineage.
Observability and healthconnection health and selected runtime stateservice health, health checks, metrics, SLOs, incidents, alert rules/deliveriesCover infrastructure plus connector, queue, capability, sync and projection freshness.
Cache disciplineprojection snapshots; D1/KV bounded-state contractcache namespace, invalidation rule, refresh and health metadataCache is reproducible, versioned and non-authoritative; never cache secrets.
Object/evidence storeevidence links and object referencesblob/version/link/retention/access/integrity metadata, with bytes in R2Object store owns bytes; Neon owns metadata/ownership; knowledge and vector indexes are derived.

4. Canonical runtime envelope

Every ingress path normalizes to an envelope equivalent to this contract before
it enters the event bus or queue:

interface SpineEventEnvelope<T = unknown> {
  eventId: string;
  eventType: string;
  eventVersion: string;
  tenantId: string;
  workspaceId?: string;
  source: {
    type: "webhook" | "poll" | "stream" | "api" | "mcp" | "user" | "agent" | "system";
    provider?: string;
    connectionId?: string;
    externalEventId?: string;
  };
  subject: { entityType?: string; entityId?: string; externalEntityId?: string };
  traceId: string;
  correlationId: string;
  causationId?: string;
  occurredAt: string;
  receivedAt: string;
  idempotencyKey: string;
  payload: T;
  provenance: { rawPayloadRef?: string; evidenceRefs: string[]; schemaVersion: string };
}

traceId covers the end-to-end operation, correlationId groups related work,
and causationId identifies the direct parent command/event. These identifiers
must flow from user intent or ingress through approval, capability execution,
provider response, re-ingestion, verification and final Spine mutation.

5. Reliability policy: until successful, safely

“Until successful” means retry until success, terminal non-retryable state,
policy expiration, dead letter, or required human intervention. It never means
an unbounded blind retry loop.

accepted → idempotency reserved → attempt
attempt → succeeded → verify → reconcile → close
attempt → retryable failure → backoff → scheduled attempt
attempt → ambiguous provider outcome → query/reconcile before retry
attempt → terminal failure | policy expired | retries exhausted → dead letter / escalation

Every retry policy needs maximum attempts and elapsed time, backoff/jitter,
retryable versus terminal errors, circuit-breaker thresholds, dead-letter
handling, and human escalation conditions. Provider mutations such as payment,
email, provisioning, deployment or record update must not be repeated until
the remote effect is proven absent.

6. Adaptive Spine expansion law

The Spine adapts to more data without flattening the base model or forcing
the Product to hard-code provider schemas:

Base schema module
→ connector discovery
→ versioned provider schema
→ approved mapping to canonical entity/relationship/field definition
→ additive domain extension candidate where no canonical mapping exists
→ governed approval and migration where physical expansion is required
→ pipeline promotion, provenance and projection recompilation

The Base Spine remains the minimum standard: identity, entity, work, event,
knowledge, evidence, memory, governance, capability and continuity. A new
industry, role, department or connector can add fields, entity subtypes,
relationships, projections and capabilities, but cannot weaken tenant
isolation, governance, provenance, idempotency or the Pipeline-writer law.

7. Surface backend contract

interface SurfaceBackendContract {
  navId: string;
  projectionId: string;
  primarySources: string[];
  supportingSources: string[];
  requiredContext: ["tenant", "membership", "role", "policy", "freshness"];
  commands: Array<{ capability: string; approval: "none" | "policy" | "human" }>;
  runtime?: {
    publishTopics?: string[];
    consumeTopics?: string[];
    queue?: string;
    syncDefinition?: string;
    idempotencyScope?: string;
    reprocessingPolicy?: string;
  };
}

Shared navigation and changing work surface

The sidebar structure is common. What changes is the Work projection:

Base manifest + active tenant + role + department + industry
+ connector/schema availability + policy + user preference
→ Projection Engine → permitted Workbench surface

The twelve role/domain projections are Workbench views—not user-facing “L1”
labels. A view definition stores filters, grouping, layout and capabilities; it
does not store the operational truth displayed in that view.

Canonical sidebar shell

The following navigation shell is common across the Product. RBAC determines
whether a user sees an item and whether it is read-only, operational, or
administrative. The Work branch is the adaptive branch: its actual views
are composed from role × department × industry × tenant policy × connector
availability, rather than being hard-coded per provider or user.

IW
├── Home
├── My Work
│   ├── Inbox
│   ├── Tasks
│   ├── My Queue
│   ├── Approvals
│   ├── Notifications
│   ├── Recent Work
│   └── Favorites
├── Communications
│   ├── Activity Feed
│   ├── Email
│   ├── Calendar
│   ├── Meetings
│   ├── Chat
│   └── Calls
├── Documents Shared
├── Personal
│   ├── Notes
│   ├── Knowledge Base
│   └── Brainstorming Sessions
├── Activity
├── Finance Manager
├── Work
│   └── Adaptive views: role × department × industry
│       ├── View 1
│       └── View N
├── Platform
│   ├── Integration Manager
│   ├── Connector Marketplace
│   ├── Activation Hub
│   ├── Capability Manager
│   ├── MCP Pool (internal Platform operators only)
│   ├── AI Models
│   ├── Knowledge
│   ├── Memory & Continuity
│   ├── Automation
│   ├── Pipelines
│   ├── Governance
│   └── Observability
└── Administration
    ├── Organizations
    ├── Users
    ├── Roles
    ├── Permissions
    ├── Audit
    ├── Billing
    ├── Deployments
    ├── API Keys
    └── Security

Chat is a communication or contextual-intake surface. It does not turn the
Silent Twin into a permanent sidebar destination, and any contextual Twin
engagement still uses the Four Buttons and governed Pipeline paths.

Surface groups

GroupPrimary projection responsibilityTypical supporting truth
HomeComposite operational summaryevents, work, approvals, notifications, calendar, timeline, readiness.
My Work / Inbox / Tasks / QueuePrioritized work and attentionwork items, queue membership read model, messages, approvals, notifications, exceptions.
CommunicationsHuman and provider communication continuitymessages, threads, calendar, meetings, calls, evidence and entity links.
Documents / Notes / KnowledgeDocument, evidence and derived knowledge accessblobs, documents, shares, evidence, knowledge/chunks, retrieval indexes.
PersonalUser-scoped preferences, favorites and permitted contextmemberships, favorites, tuning profile, notifications, permitted memory.
BrainstormingDomain extension, not a replacement chat historysession, messages, canvas state, ideas/insights, decisions, promoted knowledge.
Organizational Memory / Company WikiFirst-class operating handbook projectionpromoted memory, knowledge pages, policies, rituals, decisions, linked subpages, embedded views, and approved outcomes.
WorkRole/department/industry operational projectioncanonical entities, work, signals, relationships, capabilities and governance.
Integration / ActivationTenant connectivity and readinesscatalog, installation/connection, discovery, schemas, webhooks, sync, health, activation/hydration.
Capability / MCP / AIPermitted technical capability availabilityregistry, implementations, bindings, policy, health and runs. MCP Pool remains internal.
Knowledge / Continuity / Automation / PipelinesPlatform operational control viewsmemory candidates/promotions, continuity, definitions/runs, event/queue/replay state.
Governance / ObservabilityAccountability and health projectionsdecisions, approvals, audit, traces, health, incidents, SLOs and freshness.
AdministrationTenant administrationorganisations, users, roles, permissions, billing, deployments, API-key metadata and security events.

Canvas and intake

Canvas views may render permitted context as cards, tables, timelines, images,
documents, graph fragments and safely formatted JSON data. They are
representations of a projection, never direct database or object-store access.

Organizational memory is a canvas-capable projection surface. In practice it
behaves like a company wiki or operating handbook: document-like pages, linked
subpages, embedded operational views, and approved write-back to Spine when the
user and governance allow it. It is a projection over memory and knowledge, not
a second truth store.

A contextual intake/chat surface may accept text, files or links. It must:

  1. archive the original artifact to the evidence/object-store path;
  2. create an observation/event with tenant, provenance and idempotency;
  3. have the Twin triage and propose classifications silently or on request;
  4. use governance for consequential routing or actions; and
  5. promote only validated outcomes to knowledge, work or canonical Spine truth.

8. Delivery checkpoint

Before a testing-environment event, provide evidence for:

  1. one ingress-to-reconciliation trace with event, idempotency, approval,
    execution, re-ingestion and projection invalidation identifiers;
  2. one retry/ambiguous-provider scenario that proves no duplicate side effect;
  3. one dead-letter and governed reprocessing scenario;
  4. one connector discovery-to-schema-mapping-to-projection scenario;
  5. cross-tenant and cross-environment isolation for queue, cache, object,
    credential, webhook and projection access; and
  6. a rendered Workbench showing shared navigation plus a role-specific Work
    projection, a canvas projection and explicit partial/degraded state.