Home/Docs/Architecture & Contracts/Local / Prod Parity

Local / Production Placement ParityπŸ”—

This document describes the shared public contracts across local and production placements and the infrastructure adapters that may differ.

Related

DocRole
index.mdArchitecture & service map
worker-temporal.mdWorker PATH L vs PATH T operations
cli-architecture.mdcontextunity local up
security-model.mdToken / Shield posture
testing-standards.mdHow to prove parity
ADR-0015Trusted-local vs encrypted-external object boundary and authority split

1. PrincipleπŸ”—

SAME:  manifests, graph definitions, SDK method names, payload models,
        tool bindings, error codes, feature-flag names,
        Execution Trace/UDB/FaultSpool shapes

MAY DIFFER: process topology, storage engine, task engine, secret backend,
            object-store adapter, embedder host, discovery, key backend/profile
Important

Invariant: Business workflows and agent graphs keep the same public contracts across local and production placement; only infrastructure adapters change.

Invariant: If external object offload is implemented, trusted-local and encrypted-external references remain distinct, and the external object store receives ciphertext only.

Forbidden

Anti-patternWhy
A separate local-only public client API with different methodsAgents and tests diverge
Silent no-op success on local (Huey β€œcompleted” without side effects)Local green, prod broken / reverse
Claiming completion from production Temporal registration aloneLocal DX and CP local-parity fail
Different payload field names per backendSDK/tool breakage
Unlabeled weak crypto presented as production-equivalentSecurity footgun
file://, MinIO and S3/R2 treated as interchangeable raw URIsErases the trust boundary and permits plaintext external writes

2. Placement matrix (local vs production)πŸ”—

PlaneShared contractLocal placementProduction placementProof style
Service APIgRPC + ContextUnit + ContextTokenIn-process / loopback ports (create_local_*)Multi-host service meshSame SDK tests against both
Brain storagecells, blackboard, synapses, conversations, execution traces, and embedding jobsSQLite + sqlite-vec where configuredPostgres + RLS + pgvectorStorage parity suites
Worker executionShared run_<job> + request/result modelsPATH L: Huey dispatch or CLI one-shot; no Temporal process or durable schedulesPATH T: Temporal schedules + activitiesDual-runtime tests (see Β§3)
RouterGraphs, tools, conductor, memory injectionSame Router process; points at local Brain/WorkerSame contracts; remote endpointsInproc + integration
ShieldToken, project-key, secret, firewall, and typed trace-artifact RPC contractsSame RPCs; secret backend is env or sqlite; trace-artifact protection needs SHIELD_MASTER_KEYSame RPCs; secret backend support remains env or sqlite; no silent plaintext fallbackVerify permission, tenant, project binding, and missing-key failures
Trace-artifact archiveBrain owns a typed protected-artifact lifecycle; Worker's S3TraceArtifactArchive archives and restores opaque envelopes through a C0-selected S3-compatible profileUses the configured profile and Brain lifecycle RPCsUses the configured profile and Brain lifecycle RPCsVerify ciphertext-only archive, identity binding, CAS receipts, and authorized reads
Generic external-object placementADR-0015 is design-only; it defines no general object reference, upload/download API, or placement callerNo generic object-offload implementationNo generic object-offload implementationDo not infer generic storage parity from the separate trace-artifact archive
Vectors / embeddingsCell embedding columns + job status enumConfigured Brain embedder; optional sqlite-vecConfigured Brain embedder (default image bundles pinned ONNX); PG vectorStatus + vector_present, not metadata alone
DiscoveryService identity + tenant scopeIn-process / optional RedisRedis (or equiv) registryBootstrap same env keys
Execution/debug evidenceBrain Execution Trace; UDB FaultOccurrence; DLQ-0 fallbackSame trace contract; LocalFileDlqWriter JSONL for bounded unavailable UDB inputDirect UDB delivery plus bounded per-instance JSONL emergency spool; no HA/persistent-spool claimSame IDs, bounds, redaction, replay semantics; optional Redis health state is non-authoritative
Technical telemetryOTel instrumentation/export contract when enabledDisabled or local Collector/backendDeployment-approved OTLP backend/CollectorExport failure never invalidates Execution Trace or UDB
FixturesPhase fixture loader shapesgolden profile (small, committed)parity / scale generatedSame keys; different volume
GPU / heavy jobsStrongman/distill workflow payloadDry-run / skip with explicit reasonTemporal + GPU isolationNever silent success

3. Worker dual-runtime (PATH L / PATH T)πŸ”—

Worker is the most common place dual placement is mis-implemented. Target shape:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ SHARED CORE                                  β”‚
β”‚  run_<job>(request, *, brain, dlq, …)        β”‚
β”‚  no temporalio, no huey imports              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β–Ό                             β–Ό
 PATH L                          PATH T
 CLI one-shot                    @workflow / @activity
 Huey start_workflow β†’ run_*     Temporal schedule / StartWorkflow
 No Temporal server              Temporal server required
ObligationPATH LPATH T
Run shared coreRequiredRequired
Durable scheduleUnsupported on PATH L; RegisterSchedules fails closed and operators can trigger supported jobs through the CLITemporal Schedule
StartWorkflowMust call run_* (no simulate-success)Starts Temporal workflow
Retry / backoffHuey/simple loopsWorkflow-deterministic timers / retry policy
HA / multi-hostSingle processTemporal cluster
ProofTests without Temporal processCompose/live Temporal when schedules claimed

PATH L: Huey dispatches registered types to shared run_* (no simulate-success); durable schedule registration fails closed. PATH T compose: docker-compose.yml runs Temporal (+ UI) on the shared Postgres and a single worker service (gRPC + in-process Temporal pollers).


4. Service-by-service notesπŸ”—

4.1 BrainπŸ”—

ConcernSharedLocalProd
Public APIUpsertCell, QueryCells, blackboard, synapses, embedding RPCsSame method namesSame
StorageStorage protocol / mixinsSqliteBrainStorePostgresBrainStore + RLS
Tenant isolationToken + app checksApp-layer isolation if no RLSPostgres RLS + token
EmbeddingsJob ledger + statusMay skip vec backend β†’ truthful skippedPersist cells.embedding

4.2 RouterπŸ”—

ConcernSharedLocalProd
Graphs / tools / conductorManifest + compiler contractsSameSame
Brain/Worker clientsSDKLocalhost endpointsDiscovered / configured hosts
Auto-extractSame policy modulesBackground asyncioSame; enqueue to Brain

Router must not embed a second β€œlocal graph schema”.

4.3 WorkerπŸ”—

See Β§3 and worker-temporal.md.

ModeCommandRuns Temporal poller?
gRPC / localpython -m contextunity.workerNo
Temporal… --temporalYes

CLI one-shots (e.g. contextworker memory-synthesis) call shared runtime directly β€” preferred PATH L admin path.

4.4 ShieldπŸ”—

ConcernSharedLocalProd
RPC surfaceCurrent secret, project-key, session, policy, scan/statistics, and typed trace-artifact RPCs; see Shield serviceSame current RPC surfaceSame current RPC surface
AuthorityShield checks token scope, tenant, project, and node bindings on protected operations; trace-artifact encryption fails closed when its key is unavailableSame checks; dev mode may omit the master key, in which case trace-artifact operations return a precondition errorSame checks; configured keys are required for trace-artifact protection
Secrets storeFactory supports env and sqlite; other configured backends fail as unimplementedenv / sqliteenv / sqlite; no Postgres or Vault implementation

4.5 ForgeπŸ”—

ConcernSharedLocalProd
Dashboard and operator CLISame operator behavior and authenticated Brain RPCsPoints at local BrainPoints at cluster Brain
Worker kicksSame StartWorkflow / CLI semanticsMust work without Temporal if PATH LTemporal when deployed

Forge must show backend engine honestly (huey vs temporal), not imply Temporal-only.

4.6 CLI / LocalSupervisorπŸ”—

contextunity local up (see cli-architecture.md):

  • Local Brain (SQLite), local Worker (Huey-oriented), Router, lightweight Shield
  • Does not require Temporal for core DX
  • Missing GPU/Borg/object features: explicit skip/label, not fake success

5. Config surface (same keys, different values)πŸ”—

LayerLocal typicalProduction typical
WORKER_ENGINEhueytemporal (gRPC + in-process pollers in one Worker)
TEMPORAL_HOSTunset / unused on PATH Ltemporal:7233 or cluster
Brain DSN / modeSQLite pathPostgres DSN + schema
SHIELD_SECRET_BACKENDenv / sqliteenv / sqlite; postgres and vault fail as unimplemented
Embedderlocal / mock in testsproduction model endpoint
Generic external-object adapterNo current generic placement callerNo implementation
Trace-artifact archiveSeparate Brain/Worker lifecycle, disabled unless its C0 profile is configuredOpaque protected envelopes use the configured S3-compatible profile
Feature flagsoften off by defaultstaged enable

Rule: request payloads must not override engine, DLQ path, Brain endpoint, or catalog roots (fail closed / config-owned).


6. How to prove parityπŸ”—

LevelWhatExample
UnitShared run_* with fakesNo Temporal/Huey imports in runtime module
ContractSame SDK method against sqlite + postgresBrain storage parity tests
PATH LNo Temporal processCLI or Huey β†’ real side effects
PATH TTemporal presentSchedule or StartWorkflow β†’ same side effects
SecuritySame deny codesToken/tenant fail closed both placements
PostureLocal weaker crypto labeledProd fail-closed if vault missing
External-object seamNo current implementation; ADR-0015 is a design boundaryDo not claim local/production offload parity until source contracts and a production caller exist

Do not count as parity:

  • Mock-only admin answers
  • Huey status completed without Brain writes
  • β€œWorkflow registered” without a consume path

7. Current implementation statusπŸ”—

Brain implements SQLite and PostgreSQL storage paths for contracts that define both adapters, including cells, conversations, Execution Trace, and CellEdge operations. Worker supports local Huey execution and Temporal-backed execution for registered workflows. Active service configuration determines which backend is available.

Shield currently implements env and sqlite secret backends. PostgreSQL and Vault secret storage are not implemented. Generic external-object placement remains design-only under ADR-0015; the Brain/Worker trace-artifact lifecycle is a separate implemented contract.


8. Checklist for new featuresπŸ”—

Before claiming local/prod support:

  • One public contract (proto/SDK/CLI flags) documented
  • Shared core path (handler or run_*) has no engine-specific business forks
  • Local backend chosen and labeled if weaker
  • Production backend chosen; fail-closed if missing in prodlike
  • If external object offload is implemented, local and encrypted reference variants cannot be confused
  • If external object offload is implemented, the backend receives ciphertext only and the reference contains no plaintext or key material
  • If external object offload is implemented, Shield key authority, Worker I/O, and domain pointer authority are proven separately
  • PATH L proof (if Worker) without Temporal
  • PATH T proof (if schedules/HA claimed) with Temporal
  • Same error codes and event types both sides
  • No simulate-success stubs left on registered workflows

9. One-line summaryπŸ”—

Local and production use the same public contracts where both runtime adapters exist. Backend differences remain configuration-owned. Unsupported adapters and the design-only external object flow are not current capabilities.