RFC-0049 · Projection Algebra
Versioned draft snapshot
RFCs, reference catalogs, and evidence reflect Spec 3b2e3e7a114fb826b1445d39a48756b8fff629cd. Counts and pending/status notes belong to that snapshot. Read the dated project update for later progress.
Source repositories are private during staging. Links marked “repository access required” need access to the linked repository.
| Status | Draft corpus. Reference catalogs and RDF projections have generation drift checks; Gnomon proofs and projection semantics remain unverified for release. |
|---|
View the generated reference catalog →
Read design questions and decisions →
Reference catalog: the diagnostics, linked-RFC graph, defined terms, and normative-rule index for this RFC are in the reference catalog, generated from the structured Lean module. This document carries the prose: design rationale, entity-shape definitions in context, and migration notes.
1. Purpose
The Gnomon graph carries every entity, relation, kind, policy, module, and template as an gnomon (RFC-0036). Reads from this graph in the legacy runtime produce flat result sets — losing the closure property that the carrier set is. The Q2 plan acknowledges this gap directly:
Gnomons are not (yet) closed under their own algebra — traversal produces flat result sets, not gnomons. … The algebraic closure remains an open design goal.
This RFC closes that gap. It defines a projection algebra whose carriers are subgraphs of gnomons and whose operators preserve the carrier kind: every operator takes subgraphs in and produces a subgraph out (with a defined materialization step at the boundary that produces typed wire-form values for consumption).
This RFC also lifts query and mutation to first-class authoring-surface declaration kinds. A query is a typed projection consumer; a mutation is a typed template-instantiation chain with provenance. Together they are the primary app-building surface in Gnomon modules: a module’s externally-callable behavior is the set of queries and mutations it declares.
This RFC complements (and is a refinement of) RFC-0043 §3.2: the transport: query | mutation field on operations becomes a structural property derived from the authoring surface.
2. Definitions
| Term | Meaning |
|---|---|
| Subgraph | A set of gnomons: zero or more object-gnomons and zero or more edge-gnomons. Every projection’s input and output is a subgraph. |
| Carrier | The set of all gnomons in the runtime. The graph (graph.resource ∪ graph.statement) at a given system time and valid time is the carrier instance. |
| Projection | A typed function Subgraph → Subgraph. The closure property holds: every projection’s output is itself a valid input to another projection. |
| Source projection | A projection that takes a fixed input (the empty subgraph plus parameters) and produces a subgraph derived from the carrier. Source projections are how subgraphs come into existence. |
| Refinement projection | A projection that filters or restricts an input subgraph (σ, π, ρ). |
| Composition projection | A projection that combines two or more input subgraphs (∪, ∩, \, ⋈). |
| Closure projection | A projection that walks edges to expand a subgraph (traversal, transitive closure). |
| Aggregation | A function `Subgraph → Scalar |
| Materialization | The boundary operation that converts a subgraph to a wire-form value (for protocol response, audit hash, etc.). Distinct from aggregation; preserves structure but flattens to a serializable form. |
| Query | A typed, named declaration that exposes a parameterized projection as a callable read operation. |
| Mutation | A typed, named declaration that invokes a template (or chain of templates) under a transaction, producing gnomons with provenance. |
| Provenance projection | The named projection provenance(a) that returns the template-instantiation lineage subgraph rooted at any gnomon. |
3. The Closure Property
3.1 Why subgraph-in / subgraph-out
A closed algebra is one in which every operator takes carriers and produces carriers. Relational algebra is closed: every operator takes relations and produces a relation. The output of SELECT * FROM users WHERE active is itself a relation that can feed another SELECT.
The Gnomon algebra is closed at the subgraph level. Every projection takes a subgraph and produces a subgraph. The legacy traversal (graph.get_outgoing, graph.traverse) returns flat lists — that’s a materialization, not a closed algebra operator.
3.2 Subgraph as a normative shape
A subgraph G = (V, E) where:
V ⊆ ObjectGnomons— a set of object-gnomons (resources)E ⊆ EdgeGnomons— a set of edge-gnomons (statements)
Invariant: for every e ∈ E, both e.subject and e.object are in V. Edge-gnomons never reference vertices outside the subgraph (M49010).
This invariant means subgraphs are self-contained — a subgraph can be serialized, transmitted, audited, hashed, or stored without dangling references.
3.3 The empty subgraph
The empty subgraph ∅ = (∅, ∅) is the algebra’s identity element for union and the absorbing element for intersection. Every source projection starts from ∅ and parameters; refinement and composition projections take non-empty subgraphs as inputs.
3.4 The full subgraph
The full subgraph at system time t_sys and valid time t_val is the carrier — every gnomon that exists at that time. It is normally not materializable (size; tenant filtering applies; permissions filter further). Source projections give bounded views into it.
4. Source Projections
Source projections are how subgraphs come into existence. They take parameters but no input subgraph. Each takes the carrier as an implicit input filtered by the active session’s tenant and permission set (§9).
| Operator | Signature | Description |
|---|---|---|
σ_kind(K) | KindPattern → Subgraph | All object-gnomons whose kind matches the ltree pattern K (subtree match by default; exact via K::exact). |
σ_predicate(P) | PredicatePattern → Subgraph | All edge-gnomons whose predicate matches P (subtree default). The output subgraph includes the edges and their endpoint gnomons. |
byId(id) | Bigint → Subgraph | Singleton subgraph containing the gnomon with the given id (and zero edges). |
byName(kind, ext) | (KindPattern, Text) → Subgraph | Singleton object-gnomon with (kind, externalId) matching. |
subgraph(S) | Sequence<Gnomon> → Subgraph | Lift an explicit sequence of gnomons to a subgraph (with edge-endpoint closure auto-applied to satisfy §3.2). |
KindPattern and PredicatePattern are ltree expressions: bare paths (identity.user, org.member), subtree match (identity.*, org.*), or exact match (identity.user::exact).
4.1 Source projection invariants
- Every source projection is filtered by the active session’s tenant context (RFC-0048 §4.4); cross-tenant gnomons are unreachable (M49020).
- Every source projection is filtered by predicate-policy authorization (RFC-0042); gnomons the principal cannot read are excluded (M49021 — info, emitted with
--verbose-projection). - Source projections honor bitemporal qualifiers (§7); when no qualifier is given, the implicit qualifier is
asOf(now()).validAt(now()). - The empty result is valid (yields
∅); source projections never throw on missing data.
5. Refinement Projections
Refinement projections take a subgraph in and produce a smaller (or equal) subgraph by filtering or restricting. They never add gnomons.
| Operator | Signature | Description |
|---|---|---|
σ(S, predicate) | (Subgraph, Predicate) → Subgraph | Set selection — keep gnomons for which predicate(a) is true. Predicate is a typed expression over fields of a. |
π(S, fields) | (Subgraph, List<FieldPath>) → Subgraph | Field projection — restrict each gnomon’s data to the named fields. Gnomons with no field overlap are kept with empty data. |
ρ(S, name → name') | (Subgraph, RenameMap) → Subgraph | Rename fields within gnomon data (in-place, non-destructive — output is a new subgraph). |
vertices(S) | Subgraph → Subgraph | Project to vertex-only subgraph — drop edges. |
edges(S) | Subgraph → Subgraph | Project to edge-only subgraph — but the edge-endpoint closure invariant (§3.2) keeps the referenced vertices. To get a true “edges with no inner vertices” requires a separate predicate-policy check. |
5.1 Predicate expression language (σ)
Predicates in σ(S, predicate) are expressions in the canonical Gnomon expression language (RFC-0039 §5):
σ(orgs, { $and: [
{ $ref: "data.tier" }, // truthy check
{ $fn: "expr.equals", args: [
{ $ref: "data.region" }, "us-east"
]}
]})
The expression evaluates per-gnomon in S; gnomons that evaluate to truthy are kept.
6. Composition Projections
Composition projections combine two or more subgraphs.
| Operator | Signature | Description |
|---|---|---|
S₁ ∪ S₂ | (Subgraph, Subgraph) → Subgraph | Union — set-theoretic union of vertex sets and edge sets, with edge-endpoint closure. |
S₁ ∩ S₂ | (Subgraph, Subgraph) → Subgraph | Intersection. |
S₁ \ S₂ | (Subgraph, Subgraph) → Subgraph | Set difference — S₁ minus the gnomons also present in S₂. |
S₁ ⋈ p S₂ | (Subgraph, Predicate, Subgraph) → Subgraph | Join along predicate p — produces an edge-rich subgraph: edges of kind p between S₁ and S₂, plus their endpoints. |
traverse(S, path) | (Subgraph, PredicatePath) → Subgraph | Traversal — extend S with all gnomons reachable from S’s vertices along the predicate path. path is a sequence of predicate patterns. |
closure(S, p) | (Subgraph, PredicatePattern) → Subgraph | Transitive closure along predicate p. |
6.1 Traversal example
σ_kind(identity.user)
| byId(42) -- start at a single user
| traverse([org.member, org.contains]) -- walk to org, then org's other members
| σ(s => s.kind == "identity.user") -- restrict to users
This produces a subgraph: user 42, their org, all other users in that org, plus the connecting edges.
6.2 Join semantics
S₁ ⋈ p S₂ is outer-style — it returns the edges of kind p whose endpoints are in S₁ × S₂ (both directions). It does NOT cross-product non-related vertices. This is distinct from relational join.
To get a cross product (every vertex in S₁ paired with every vertex in S₂ regardless of edges), use the explicit cross(S₁, S₂) operator (which produces a subgraph containing both vertex sets but no synthetic edges; aggregations downstream produce the cartesian-product semantics on the materialized form).
7. Bitemporal Qualifiers
Every projection has an implicit bitemporal context: system time and valid time (RFC-0036 §8). Qualifiers fix one or both:
| Qualifier | Effect |
|---|---|
asOf(t) | Fix system time. The projection sees the graph as it was recorded at system time t. |
validAt(t) | Fix valid time. The projection sees facts that were asserted-as-true at valid time t. |
asOf(t).validAt(u) | Both axes fixed. |
| (no qualifier) | Both default to now(). |
Qualifiers compose with all source and composition operators:
σ_kind(orgs).asOf("2026-01-01").validAt("2025-12-31")
Edges contributed to a subgraph carry their bitemporal interval (validFrom, validTo). Predicates that evaluate against bitemporal context (e.g., “valid as of …”) use the qualifier.
7.1 Mixed-qualifier subgraphs
Composition operators on subgraphs with different qualifiers MUST normalize:
- For
∪: the result’s effective time is the latest of the two (most-recent semantics). - For
∩,\: the result is empty unless qualifiers match (M49030 emitted otherwise). - For
traverse: the inputs’ qualifiers MUST match; mismatch is an error (M49031).
Authors who want explicit mixed-time analysis MUST use named projections that materialize into a comparison form rather than attempting algebraic mixing.
8. Aggregation
Aggregation is the single boundary at which the algebra exits the closed carrier and produces a non-gnomon value.
| Operator | Signature | Description |
|---|---|---|
count(S) | Subgraph → Integer | Count of vertices in S (default; use count(S, edges) for edges). |
sum(S, f) | (Subgraph, FieldPath) → Number | Sum of field f across vertices. |
avg(S, f), min(S, f), max(S, f) | as expected | Standard aggregates. |
groupBy(S, f) | (Subgraph, FieldPath) → Map<Value, Subgraph> | Partition by field value. The output is a typed map of field-value to sub-subgraphs. The output map’s values are subgraphs — composition can continue on each partition. |
materialize(S) | Subgraph → WireValue | Convert a subgraph to wire-form (JSON-shaped typed value). See §9. |
8.1 Aggregation invariants
- Aggregations are scalar/tuple producers; their outputs are NOT subgraphs and cannot feed back into the projection algebra (closure breaks).
groupByreturns a typed map whose values are subgraphs; the map IS a non-gnomon value, but each value within is a subgraph that closure preserves.- Aggregations honor authorization: gnomons that the principal cannot read are excluded from the count/sum (RFC-0042 evaluation per gnomon). The result is a “principal-relative” aggregate.
- Aggregations on empty subgraphs return:
count = 0,sum = 0,avg = null,min = null,max = null. (M49040 — info ifnullis emitted, since RFC-0006 §4.A bans null in the type model — see §9.2.)
9. Materialization
materialize(S) is the boundary operator that produces a wire-form value from a subgraph. It is invoked when:
- A query is consumed across a protocol surface (HTTP response body, gRPC message, etc.).
- A subgraph is hashed for
argHashaudit (RFC-0047 §3.3). - A subgraph is serialized to a snapshot file or cache.
9.1 Materialization shapes
A materialized subgraph has the JSON shape:
{
"vertices": [
{ "id": <bigint-as-string>, "kind": <ltree>, "name": <text|null>, "data": <map> },
...
],
"edges": [
{ "id": <bigint-as-string>, "subject": <id>, "predicate": <ltree>, "object": <id>, "data": <map>, "validFrom": <instant?>, "validTo": <instant?> },
...
]
}
This is the canonical wire form. Bigint IDs are encoded as decimal strings (RFC-0036 §7.3).
9.2 Typed materialization for queries
When a query (§11) declares an output type, materialization produces a value of that type rather than the raw subgraph form. The transformation is:
- Single-vertex subgraph + entity-type output → typed entity value
- Single-vertex-set subgraph + List
output → typed list - Single-aggregate output → scalar/tuple
- Subgraph that cannot satisfy the declared type → M49050 error
Null at the materialization boundary follows RFC-0034 §5.2: optional fields absent from the response are omitted; null is never emitted on the wire.
9.3 Materialization is authorization-aware
materialize(S) evaluates predicate-policy permissions at every gnomon boundary. Gnomons the principal can see contribute fully; gnomons that fail authorization are dropped from the materialized output (M49021 informational). Sensitive fields (RFC-0008 §6.3a sensitive) are redacted per RFC-0047 §6.
10. The projection Declaration Kind
Projections are first-class declarations in .gnm source. A projection declaration has a name, parameters, an algebraic body, and an optional output-type annotation.
10.1 Syntax
projection-decl ::=
[ epistemic-modifier ]
"projection" IDENT "{" projection-body "}"
projection-body ::=
meaning-slot
[ "params" "{" param-decl* "}" ]
[ "returns" ":" type-expr ]
"body" ":" projection-expr
[ "materialize" ":" materialize-mode ]
[ "auth" ":" auth-mode ]
projection-expr ::=
source-expr
| refinement-expr
| composition-expr
| "(" projection-expr ")"
| IDENT (* references another projection by name *)
source-expr ::=
"kind" "(" kind-pattern ")"
| "predicate" "(" predicate-pattern ")"
| "byId" "(" expr ")"
| "byName" "(" kind-pattern "," expr ")"
refinement-expr ::=
projection-expr "|" "select" "{" expr "}"
| projection-expr "|" "fields" "[" field-path-list "]"
| projection-expr "|" "rename" "{" rename-list "}"
composition-expr ::=
projection-expr ("∪"|"union") projection-expr
| projection-expr ("∩"|"intersect") projection-expr
| projection-expr ("\\"|"diff") projection-expr
| projection-expr "|" "join" predicate-pattern "{" projection-expr "}"
| projection-expr "|" "traverse" "[" predicate-pattern-list "]"
| projection-expr "|" "closure" "(" predicate-pattern ")"
materialize-mode ::= "live" | "cached" | "view" | "reactive"
auth-mode ::= "principal" | "service" | "system"
10.2 Example projection declarations
Identity projection (kind-filtered subset — equivalent to view-mapping layer §RFC-C):
projection orgsByRegion {
meaning: "All organizations in a given region."
params { region: Text }
returns: List<Organization>
body:
kind(identity.organization)
| select { $fn: "expr.equals", args: [{ $ref: "data.region" }, { $ref: "params.region" }] }
| fields [id, name, region, createdAt]
materialize: view
}
Aggregation projection:
projection memberCountByOrg {
meaning: "Count of active members per organization."
params { orgId: Identifier }
returns: { orgId: Identifier, count: Integer }
body:
byId(params.orgId)
| join org.member { kind(identity.user) | select { $ref: "data.active" } }
| count
}
Subgraph projection (rooted closure):
projection orgWithMembers {
meaning: "An organization plus all its members and their roles."
params { orgId: Identifier }
returns: Subgraph
body:
byId(params.orgId)
| traverse [org.member, org.has_role]
| union (byId(params.orgId) | traverse [org.contains])
}
Composition (projection of a projection):
projection adminMembersByOrg {
meaning: "Members with admin role across orgs in a region."
params { region: Text }
returns: List<User>
body:
orgsByRegion(region: params.region) -- reuse another projection
| join org.has_role {
kind(identity.role) | select { $fn: "expr.equals", args: [{ $ref: "data.name" }, "admin"] }
}
| join org.member.has_role { kind(identity.user) }
| fields [id, name, email]
}
10.3 Materialize modes
| Mode | Semantics |
|---|---|
live (default) | Every invocation hits the graph. Authoritative; highest latency. |
cached | Memoized per-request with TTL from defaultConfig.projection-cache-ttl (RFC-0046). |
view | Compiled to a Postgres view (RFC-C view-mapping layer). Read-only persisted; eligible for materialized-view promotion when hot. |
reactive | Subscribed via the reactive query layer (RFC-0020). Pushes updates to consumers. |
The compiler enforces that only structurally-pure projections (no side-effects, no cross-tenant references, no time-relative qualifiers without explicit binding) qualify for view and reactive. Other declarations fall back to live with a warning (M49060).
10.4 Authorization mode
The auth slot determines whose permission set scopes the projection’s source operators:
principal(default) — the calling principal. Subject to predicate-policy filtering.service— the module’s service account. For projections that need to bypass user-level filtering (e.g., aggregate health metrics).system— the system principal. Reserved; requirescorecapability scope to declare.
A service or system projection that returns gnomons visible only to specific principals MUST be wrapped by a query (§11) that re-applies user-level filtering before exposing the result — otherwise it leaks (M49070).
11. Query Declarations
A query is a typed, named, callable declaration that exposes a projection as a read-side operation. Queries are the primary read-side surface of an Gnomon module.
11.1 Syntax
query-decl ::=
[ epistemic-modifier ]
"query" IDENT "{" query-body "}"
query-body ::=
meaning-slot
"input" "{" field-decl* "}"
"returns" ":" type-expr
"projection" ":" projection-expr
[ "auth" ":" auth-block ]
[ "errors" "{" error-entry* "}" ]
[ "policy" ":" policy-ref ]
[ "timeout" ":" duration ]
11.2 Semantics
A query:
- Takes typed input (validated against
input { }). - Executes its projection, parameterized by input values.
- Materializes the projection result against the declared
returnstype. - Returns the typed materialized value.
A query:
- MUST NOT have side effects. The projection algebra is read-only by construction. Compilers MUST reject queries whose body is not purely projective (M49080).
- MUST be idempotent. Multiple invocations with the same input return the same value (modulo bitemporal motion of the carrier).
- MUST respect authorization. The principal’s view of the carrier is what the projection sees.
11.3 Lowering to RFC-0043 operations
A query declaration lowers to an operation (RFC-0043 §3) with:
transport: queryeffects: [{ kind: query.projection, projection: <name> }]idempotency: { requiredKey: false }(queries do not need idempotency keys)inputSchemaRef,outputSchemaRefderived frominput { }andreturns
The projection effect kind (RFC-0043 §5.1) executes the named projection. The lowering is normative; authors who write query declarations get operation runtime behavior automatically.
11.4 Example query
query getOrgMembers {
meaning: "Active members of an organization."
input {
orgId: Identifier required
}
returns: List<User>
projection: orgWithMembers(orgId: input.orgId)
| select { $fn: "expr.equals", args: [{ $ref: "kind" }, "identity.user"] }
| select { $ref: "data.active" }
| fields [id, name, email, role]
auth { required: true }
policy: { preset: org.member.read }
errors {
NotFound: terminal
Unauthorized: terminal
}
}
12. Mutation Declarations
A mutation is a typed, named, callable declaration that invokes a template (or chain of templates) under a transaction, producing gnomons with provenance.
12.1 Syntax
mutation-decl ::=
[ epistemic-modifier ]
"mutation" IDENT "{" mutation-body "}"
mutation-body ::=
meaning-slot
"input" "{" field-decl* "}"
"returns" ":" type-expr
( "template" ":" template-invocation | "templates" "{" template-invocation+ "}" )
[ "auth" ":" auth-block ]
[ "guards" ":" guard-list ]
[ "idempotency" ":" idempotency-block ]
[ "errors" "{" error-entry* "}" ]
[ "policy" ":" policy-ref ]
template-invocation ::=
IDENT "(" "with" ":" expr-map ")"
12.2 Semantics
A mutation:
- Validates typed input (
input { }). - Evaluates
guards(pre-flight predicates); failures abort before any template runs. - Opens a transaction.
- Executes the named template (or chain of templates, in declared order) within the transaction.
- Records template provenance statements (
template.instance_of,template.with,module.installed_by) per RFC-0039 §6.5 + RFC-F. - Materializes the resulting subgraph against
returnstype. - Commits and returns; or rolls back on failure.
A mutation:
- MUST require an idempotency key (RFC-0043 §6) — mutation invocations are state-changing and replays must be safe.
- MUST be expressed as one or more template invocations. Direct manipulation of
graph.resourceorgraph.statementis reserved todb.graphand is not exposed to mutations (M49090). - MUST produce provenance for every gnomon created.
12.3 Lowering to RFC-0043 operations
A mutation declaration lowers to an operation with:
transport: mutationeffects: [{ kind: template.compose, template: <name>, with: <args> }, ...]idempotency: { requiredKey: true }inputSchemaRef,outputSchemaReffrom declarations
12.4 Example mutation
mutation createOrgWithOwner {
meaning: "Create a new organization with an initial owner-role member."
input {
name: Text required
region: Text required
ownerId: Identifier required
}
returns: Organization
template: org-with-owner(with: {
name: input.name
region: input.region
ownerId: input.ownerId
})
auth { required: true }
guards: [
{ when: { $fn: "expr.notEmpty", args: [{ $ref: "input.name" }] }, errorCode: "name-required" }
]
idempotency: { requiredKey: true }
errors {
Conflict: terminal
Unauthorized: terminal
}
}
13. The Provenance Projection (Built-in)
The framework provides a built-in named projection core.provenance(a) that returns the template-instantiation lineage of any gnomon a:
projection provenance {
meaning: "Template-instantiation lineage of an gnomon."
params { gnomonId: Identifier }
returns: Subgraph
body:
byId(params.gnomonId)
| closure(template.instantiated_from) -- walk back to root template
| union (byId(params.gnomonId) | traverse([template.with])) -- argument resources
| union (byId(params.gnomonId) | traverse([module.installed_by, principal.is])) -- caller principal
}
-- usage:
query auditLineage {
input { gnomonId: Identifier required }
returns: Subgraph
projection: provenance(gnomonId: input.gnomonId)
}
The provenance projection is a normative example of what RFC-F (Template-Mediated Creation Contract) makes queryable. Every gnomon has a derivable lineage subgraph; core.provenance formalizes the lookup.
14. Composition Rules and Invariants
-
Closure: every projection’s output is a valid input to another projection. The output of
materializeandaggregateoperators are NOT subgraphs — those operators are exit points (§3.1, §8.1). -
Determinism: a projection’s output is determined by
(carrier_state, parameters, bitemporal_qualifiers, principal). Two invocations with identical inputs produce the identical output (modulo carrier change between calls). -
Authorization-relative: every projection’s output is filtered by the
authmode’s principal scope (§10.4). Different principals see different result subgraphs from the same projection — this is intentional. -
Bitemporal-honest: when no qualifier is given, defaults are
asOf(now()).validAt(now()). When qualifiers are given they propagate consistently through all operators (§7). -
Empty-stable: every operator handles the empty subgraph gracefully (returns empty or zero, never throws).
-
No imperative steps: projections are pure expressions. The body is an expression tree, not a sequence of mutating statements (M49100).
-
No cross-tenant: projections cannot cross tenant boundaries (§4.1 inv 1). Cross-tenant analysis requires explicit elevation through a
service-scoped projection AND audit (M49110 always emitted). -
Edge-endpoint closure: every subgraph satisfies the invariant that edge endpoints are within the vertex set (§3.2, M49010).
-
Algebraic identities:
S ∪ ∅ = SS ∩ ∅ = ∅S \ ∅ = SS ∪ S = SS ∩ S = S- Compiler MAY (and SHOULD) optimize using these.
-
Operator precedence: refinement (
select,fields,rename) binds tighter than composition (∪,∩,\,join,traverse); use parentheses to override.
15. Compatibility and Migration
15.1 From RFC-0043 operations
RFC-0043’s transport: query | mutation field becomes a derived property:
- A
querydeclaration in source compiles to an operation withtransport: query. - A
mutationdeclaration compiles to an operation withtransport: mutation. - Direct authoring of
operationdeclarations remains available (escape hatch for advanced cases — saga steps, complex effect pipelines).
The query and mutation forms are recommended over direct operation authoring for the 95% case. RFC-0043 §3.2 invariant (mutations require idempotency keys) is enforced automatically by the lowering.
15.2 From the legacy view-mapping layer
The kind-typed SQL views described in kernel-primitives.md §View-Mapping Layer are projections with materialize: view:
projection teamView {
body: kind(savvi.studio.team.entity_type.team)
| fields [id, externalId, name, platform, currentStatus, description]
materialize: view
}
This compiles to:
CREATE OR REPLACE VIEW savvi_studio_team.team WITH (security_barrier = true) AS
SELECT r.id, r.external_id, (r.data->>'name')::TEXT AS name, ...
FROM graph.resource r
WHERE r.kind = 'savvi.studio.team.entity_type.team'::LTREE
AND r.deleted_at IS NULL;
The view-mapping layer (RFC-C, future) is a special case of this RFC: it’s the subset of projections whose materialize mode is view and whose body is a kind-filtered, field-projected source.
15.3 From legacy graph traversal
The legacy graph.get_outgoing(id, predicate), graph.get_incoming(id, predicate), and graph.traverse(start, options) functions return flat result sets. This RFC’s traverse(S, [predicates]) operator returns a subgraph; existing call sites continue to work via the materialization step.
15.4 KP32 closure
This RFC closes the Q2 plan’s KP32 deferred algebra spec. The “formal algebra” claim from the kernel-primitives.md analogy table is now an operational specification. Future formal categorical treatment (initial algebra, Yoneda embedding, etc.) MAY layer on top, but the operational form here is normatively complete.
Diagnostics
The diagnostic catalog for this RFC is authored in the structured Lean module and
rendered in reference catalog § Diagnostics. Inline mentions in
the prose above (e.g., “rejected with MNNxxx”) cross-link to the catalog
at render time.
Linked References
The cross-RFC dependency graph is rendered in reference catalog § Linked References. Out-of-KG pointers to legacy code or external resources, when present, remain in this document under “Source-tree references” below.