COG-4: Grid Lattice
Status: Draft (Work in Progress)
Version: 0.2
Created: 2025-01-23
Updated: 2026-10-29
Authors: Mike Anderson
This standard defines the state boundary of a running venue, its lattice representation, and the routes through which callers access that state.
Purpose
A venue is one authoritative running lattice application instance. Users, agents, sessions, jobs and adapter components share its atomic state boundary. An incoming event validates its preconditions and commits a state update; external outputs follow the successful commit. Persistence and replication publish snapshots of that state.
LWW reconciliation supports backup, replication and failover. It MUST NOT be treated as a way to combine arbitrary independently executing forks of a venue. Selecting a coherent snapshot cannot reconcile conflicting external effects or preserve arbitrary workflow invariants from both forks. A failover deployment MUST fence the previous writer before the replacement produces outputs.
Specification
Lattice Structure
The reference implementation uses two sibling root regions:
:grid
:venues
<venue-owner-account-key> signed owner entry
:value whole-venue LWW boundary
:version persisted venue format integer
:timestamp snapshot reconciliation timestamp
:did venue identity
:assets content-addressed asset registry
:storage content-addressed blob storage
:users login directory
:user-data DID → user record
:schedule scheduled events
:adapters adapter name → private CAD3 value
:user-deletions pending adapter/user cleanup
:meta shared content-addressed metadata
:dlfs independently signed user drive maps
The signing envelope belongs to the Convex owner lattice. The venue format
version belongs inside its :value, not at the application root or in that
envelope. DLFS has its own format and reconciliation rules, defined by Convex.
Root Lattice
The root lattice supplies structural navigation for :grid and :dlfs. Application
components bind signing, timestamps and account-lifecycle checks to their
editing cursors. Navigating a generic cursor alone does not install those policies.
Grid Lattice
Venues Index (:venues)
Venue entries are owned and signed by account key. The canonical DID is stored inside the signed venue value. Implementations MUST authenticate incoming owner entries before accepting state from them. A signature proves ownership; it does not prevent two processes holding the same key from executing concurrently.
Shared Metadata (:meta)
Shared metadata uses the Convex content-addressed lattice. Value identifiers derive from canonical CAD3 values, as specified in COG-5. This shared region is separate from the whole-venue snapshot boundary.
Venue Lattice
Local writes MUST commit through the authoritative application's atomic cursor updates or transactions. Preconditions and mutations MUST observe the same transactional state. Update callbacks MUST be retry-safe and MUST NOT perform network I/O or other external effects. Child components obtained from a transaction draft participate in that same commit.
The complete venue :value is the unit of external LWW reconciliation. Its
children are structurally navigable, but are not independently merged when
reconciling venue snapshots. This includes assets and storage: deletions and
garbage collection MUST survive publication of the current snapshot.
Assets (:assets)
Asset metadata is immutable and content-addressed. Registry membership belongs to the venue snapshot; immutability does not require unioning deleted registry entries back into the current venue.
Jobs
Jobs live in their owning user's j index. There is no venue-level job
registry. The current record is authoritative;
local lifecycle transitions are atomic. See COG-8.
Storage (:storage)
The venue may retain content-addressed blob data within its snapshot or use another configured content backend. Content hashes protect integrity; they do not confer read authority. External content and DLFS are not made part of a venue transaction merely by being referenced from it.
Venue Versions and Migrations
:version is a persisted format contract, independent of the software version
published at v/info/version. An absent :version means version 0. Nil, negative
and non-integer versions are invalid. A locally unsupported newer version MUST
prevent startup writes, adapter activation and recovered execution.
Ordered venue migrations MUST complete atomically before those activities. The version advances only with the successful migration; failure leaves both data and version unchanged. Reopening a current venue MUST NOT rewrite its state merely to check the version.
Implementations that do not check :version MUST be operationally excluded
from stores at version 1 or later.
The reference implementation writes version 1; its repository documentation
(venue/docs/MIGRATE.md) describes its migrations.
Per-User Namespace
:user-data maps each DID to its user record. Public paths describe logical
values, not physical envelopes:
| Key | Name | Access and interpretation |
|---|---|---|
a | Assets | User's content-addressed asset registry |
g | Agents | Framework-managed agent and session records |
j | Jobs | Framework-managed current job records |
s | Secrets | Encrypted credentials, governed by secret operations |
w | Workspace | General-purpose user data |
o | Operations | User operation definitions and pins |
h | HITL | Framework-managed human requests, COG-16 |
The reference implementation wraps w, o and h values in {updated, data}
records. Standard accessors hide these envelopes. Agent ts, job updated and
user activity metadata describe changes; they are not independent venue merge
boundaries. Retained workers or transaction views cannot write into a deleted
or recreated account.
Path Navigation
Standard accessors provide read, list, slice, inspect, write, append, delete and
copy. String paths use / separators; vector paths carry individual keys.
Navigation interprets map keys and vector indices by value type. Storing null
is distinct from deleting an entry.
w/ and o/ accept ordinary writes subject to authority. Scoped virtual views
include n/ (agent), c/ (session), t/ (job) and v/ (venue globals).
Their resolvers enforce their own scope and mutation policies. s/NAME permits
whole-record deletion through covia:delete; generic writes cannot replace
framework-managed agent, job, secret or HITL records.
Adapter Extension Routes
x/<adapterName>/... selects an active adapter's explicit view for the current
user. <owner-did>/x/<adapterName>/... selects another local user's view under
normal cross-user authority checks. The owner and authenticated actor MUST
remain distinct. Venue identity alone does not bypass those checks.
An adapter MAY expose any CAD3 value shape or a pure local projection. It
exposes nothing by default; exposed views are read-only unless mutations are
explicitly enabled. crud/read, crud/write and crud/delete permissions
apply in addition to adapter policy. Reading a parent exposes its complete
subtree; a parent write can replace that subtree. Implementations MUST prevent
parent mutations from bypassing protected child fields.
Writable views MUST update authoritative venue state atomically. View
resolution and transformations MUST be local and free of external effects.
External actions belong in adapter operations. Disabled or unloaded adapters
have no active route, and missing views MUST NOT fall through to physical user
storage. The bare x path does not promise a directory listing.
The adapter owns write policy and value validation for its view; a refusal reason reaches the caller unchanged. Views use the standard accessors and live for one operation or transaction.
The addressed owner and the execution owner are distinct. Namespace delegation
MUST NOT reinterpret an agent, session, job or task ID under a different owner.
Local scope accessors (n/, c/, t/) are unavailable when the execution
owner differs from the addressed namespace owner. Route documentation can be
published in adapter information.
Adapter-Owned State
:adapters/<name> is venue-private storage with an adapter-owned schema.
It has no mandatory per-user layout and is not implicitly exposed through
x/. User content may remain in ordinary user namespaces. Credentials remain
in secret storage; adapter records hold references to them.
When an adapter maintains user-associated state, its deletion hook MUST remove
that state in the user-deletion transaction. Post-commit cleanup of workers or
external resources MUST be idempotent. Disabled adapters participate; unloaded
adapters retain pending cleanup until activation. The reference implementation
tracks unfinished cleanup at :user-deletions and blocks account recreation
until it completes.
A whole-venue backup includes adapter state. The user export/import/clone contract covers the user record, not arbitrary user associations in private adapter state. Implementations MUST NOT describe those as equivalent backup scopes or export a private adapter root as one user's data.
Venue Identification
The venue's canonical DID identifies it to callers (COG-2); its
signing account key identifies the owner entry in the lattice. A declared
did:web identity does not change the owner-key storage path.
Merge Operations
External reconciliation selects a complete venue value by :timestamp; it
does not recursively union its children. Convex retains the local value on
equal timestamps. This directional tie rule is not a
conflict-resolution protocol for independently executing writers.
Local atomic update order determines current state, including multiple writes within one millisecond. A later local write MUST NOT be discarded because its timestamp equals its predecessor's. Timestamps MUST NOT regress when the host clock moves backwards. They are evidence for snapshot reconciliation, not a substitute for atomic local sequencing or writer fencing.
State Synchronisation
Publication and persistence follow committed application state. A host MUST NOT merge an older published snapshot back over newer local writes. An atomic in-memory commit is distinct from publication and a durable flush; operations that require a durability barrier must request one explicitly.
Replication may transfer authenticated snapshots or deltas. Recovery MUST retain the single-writer constraint. Divergence from an independently running fork needs explicit operational handling, not a promise of lossless LWW repair.
Security Considerations
Authenticate snapshot ownership, enforce resource authority at user-facing accessors, and keep private adapter state separate from exposed views. Neither possession of a content hash nor venue identity grants arbitrary access to another user's resources. Signing keys and accurate clocks do not replace failover fencing. Unsupported venue formats must not execute locally.
Reference Implementation
The Covia venue is the reference implementation of this specification. Its
repository documentation (venue/docs/PERSISTENCE.md, venue/docs/ADAPTERS.md
and venue/docs/MIGRATE.md) describes its implementation contracts and tests.