DNA's nouns (resource types) and its connections (relationship types) describe the graph. A Lens names a pattern over that graph: a small set of typed node slots, the directed edges between them, and an optional sentence that reads the pattern in plain language.
The same Lens definition works in two directions:
- Query — find every subgraph in a DNA document that matches the pattern (e.g. every subject holds assignment within boundary binding that exists).
- Command — assert a specific binding of the pattern into the graph (e.g. grant this subject that assignment). No separate schema is needed for each direction.
The LensType contract
Every lens — the core ones below and any you declare inside a DNA document's lenses block — composes a shared base contract:
name— a human-readable name for the pattern.nodes[]— the typed slots. Each declares atype(the resource type it holds) and, when an edge or the sentence references it, aslotidentifier.edges[]— directed connections between slots. Each declaresfromandto(slot names) andvia(the relationship type traversed). Layer lenses omit edges entirely.sentence— an optional template with{{slot}}markers, one per declared slot, giving a readable rendering of the pattern.
The lenses below ship with @dna-codes/dna-core and fall into two shapes: layer lenses, which group a whole layer's resource types with no edges, and subgraph & traversal lenses, which wire a few slots together along named relationships.
Layer lenses
Each layer lens groups all the resource types in one DNA layer — nodes, no edges.
Operational layer lens
Resource types
- Person
- Group
- Role
- Membership
- Domain
- Resource
- Operation
- Action
- Process
- Rule
- Task
- Trigger
Product layer lens
Resource types
- User
- Role
- Resource
- Operation
- Action
- Field
- Endpoint
- Namespace
- Param
- Schema
- Block
- Layout
- Page
- Route
Technical layer lens
Resource types
- Cell
- Connection
- Construct
- Environment
- Node
- Output
- Provider
- Variable
- View
- Zone
Subgraph & traversal lenses
These lenses connect resource types across relationships, with a sentence that reads the pattern aloud.
People subgraph lens
person belongs to group
Node slots
| Slot | Resource type |
|---|---|
| person | Person |
| group | Group |
Edges
| From | To | Via (relationship) |
|---|---|---|
| person | group | Person_Group |
Access Control subgraph lens
subject holds assignment within boundary , granting grant against target
Node slots
| Slot | Resource type |
|---|---|
| subject | User |
| assignment | Role |
| boundary | Domain |
| grant | Operation |
| target | Resource |
Edges
| From | To | Via (relationship) |
|---|---|---|
| subject | assignment | User_Role |
| assignment | boundary | Role_Domain |
| assignment | grant | Role_Operation |
| grant | target | Operation_Resource |
Execution subgraph lens
process runs through task , triggered by trigger
Node slots
| Slot | Resource type |
|---|---|
| process | Process |
| task | Task |
| trigger | Trigger |
Edges
| From | To | Via (relationship) |
|---|---|---|
| process | task | Process_Task |
| trigger | process | Trigger_Process |