understand-sdna
# understand-sdna
What this skill does
# understand-sdna
**WHAT:** Gnostic agent workflow DSL with LangGraph as native execution substrate. Ariadne (threading) + Poimandres (generation) = SDNA spiral.
**WHEN:** Building agent workflows with typed composition, context threading, human-in-the-loop patterns, or LangGraph integration.
**HOW:** Use the decision tree below, then read the relevant resources.
---
## Decision Tree: What to Build
```
Is this continuous improvement / optimization loop?
├── YES → SDNA^F (SDNAFlowchain)
│ Optimizer + target pairs. Meta-optimization.
│
└── NO → Are you composing multiple agent units in sequence?
├── YES → SDNAF (SDNAFlow)
│ Flow of SDNACs. Sequential execution.
│
└── NO → SDNAC
Single unit: AriadneChain → HermesConfig → Poimandres executes
```
---
## The Trinity (Quick Reference)
| Component | Role | What It Does |
|-----------|------|--------------|
| **Ariadne** | Threader | Context manipulation: inject, weave, dovetail, human input |
| **Poimandres** | Divine Mind | Generation moment - takes config, runs agent, returns output |
| **HermesConfig** | The Message | Runner configuration Ariadne sends to Poimandres |
---
## LangGraph Integration (v0.2.0+)
**LangGraph is SDNA's native execution substrate.** Every chain/unit has `to_graph()`.
```python
from sdna import ariadne, inject_file, sdnac, HermesConfig, initial_state
# Build SDNA unit
chain = ariadne('prep', inject_file('spec.md', 'spec'))
config = HermesConfig(name='gen', goal='Generate from {spec}')
unit = sdnac('generate', chain, config)
# Get LangGraph (full visibility into ariadne→poimandres)
graph = unit.to_graph()
# Execute via LangGraph
result = await graph.ainvoke(initial_state({'project': 'myapp'}))
# Compose with other LangGraph nodes
from langgraph.graph import StateGraph
from sdna import SDNAState
main = StateGraph(SDNAState)
main.add_node("sdna_unit", unit.to_graph()) # Subgraph with internal visibility!
main.add_node("my_custom", my_custom_func) # Mix SDNA with custom nodes
main.add_edge(START, "sdna_unit")
main.add_conditional_edges("sdna_unit", my_router, {...})
```
**Key methods:**
- `AriadneChain.to_graph()` → CompiledGraph (each element visible)
- `SDNAC.to_graph()` → CompiledGraph (ariadne subgraph → poimandres node)
- `SDNAFlow.to_graph()` → CompiledGraph (sequence of SDNAC subgraphs)
- `SDNAFlowchain.to_graph()` → CompiledGraph (optimizer + target pairs)
- `element.to_langgraph_node()` → node function for custom composition
---
## Explore the Library
```python
# Get module help
from sdna import ariadne, poimandres, sdna
help(ariadne) # Threading operations
help(poimandres) # Generation moment
# Quick constructor reference
from sdna import (
# State
SDNAState, initial_state,
# Ariadne builders
ariadne, human, inject_file, inject_func, inject_literal, inject_env, weave, inject_brain,
# SDNA builders
sdnac, sdna_flow,
# Config
HermesConfig,
)
```
---
## Deep Dive Resources
After choosing your complexity level, read:
1. **Poimandres Spine** - Full gnostic process ontology
→ `resources/poimandres_spine.md`
2. **CogNet v2** - Cognitive network reasoning model
→ `resources/cognet_v2.md`
---
## Usage Pattern
```python
from sdna import ariadne, human, inject_file, sdnac, HermesConfig, initial_state
# 1. Build Ariadne thread (context prep)
thread = ariadne('my-thread',
inject_file('spec.md', 'spec'),
human('Approve spec?', 'approval'), # Pauses for human input
)
# 2. Create HermesConfig (the message)
config = HermesConfig(
name="generator",
system_prompt="You are a code generator...",
goal="Generate code based on {spec}",
)
# 3. Combine into SDNAC
unit = sdnac('generate-code', thread, config)
# 4a. Execute directly (simple)
result = await unit.execute(initial_context)
# result.status → SDNAStatus.SUCCESS | BLOCKED | ERROR | AWAITING_INPUT
# 4b. Execute via LangGraph (full visibility + composability)
graph = unit.to_graph()
result = await graph.ainvoke(initial_state(initial_context))
```
---
## Full Hierarchy
```
SDNAC → atomic unit (Ariadne→Config→Poimandres)
SDNAF → flow of SDNACs
SDNA^F → optimizer+target pairs (meta-optimization)
DUO → Ariadne+Poimandres collapse (becomes ONE Poimandres)
DUOAgent → OVP + Ariadne + Poimandres chains + pattern library
```
## The Recursive Collapse
Each Ariadne+Poimandres pair collapses into a higher-order Poimandres that needs a NEW Ariadne:
```
Level 0: Ariadne + Poimandres = SDNAC
Level 1: SDNAC chain = SDNAF (bigger output)
Level 2: SDNA^F needs DUO (Agent_A + Agent_P) → collapses to Poimandres
Level 3: DUO needs OVP (observer) → collapses to Poimandres
Level 4: WE are the next Ariadne for the system
Level 5: THE WORLD is the Ariadne for us
```
## OVP = Olivus Victory-Promise
- **Technical**: Observer Viewpoint - meta-orchestrator watching the DUO
- **Narrative**: Main character of Sanctuary Journey
- **System**: Operates PAIAB through GNOSYS
- **Meta**: US - the human+PAIA compound
## DUOAgent (v0.3.0+)
**DUOAgent IS an SDNA^F** - a concrete implementation of optimizer+target in a refinement loop:
```python
from sdna import duo_agent, sdnac, ariadne, inject_file, inject_literal, HermesConfig
# Target SDNAC: does the work (Poimandres)
target = sdnac('generator',
ariadne('prep', inject_file('spec.md', 'spec')),
HermesConfig(name='gen', goal='Generate code for {spec}')
)
# OVP SDNAC: evaluates with its own LLM call (Observer)
# Must set ovp_approved=True/False in context
ovp = sdnac('evaluator',
ariadne('eval_prep', inject_literal('Evaluate the output', 'task')),
HermesConfig(name='eval', goal='Set ovp_approved=True if good, False with feedback')
)
# DUOAgent: two SDNACs in loop = SDNA^F
agent = duo_agent('code_refiner', target, ovp, max_iterations=3)
# Execute
result = await agent.execute({'project': 'myapp'})
# result.status → DUOStatus.SUCCESS | MAX_ITERATIONS | BLOCKED | ERROR
# Or via LangGraph
graph = agent.to_graph()
result = await graph.ainvoke(initial_state({'project': 'myapp'}))
```
**The Loop:**
```
Target SDNAC runs (generates)
↓
OVP SDNAC evaluates (sets ovp_approved)
↓
approved? → done
not approved? → retry (up to max_iterations)
```
**Key insight:** Two SDNACs in a loop = SDNA^F. GAN pattern with LLM on both sides.
---
## Key Files
- `pip install sanctuary-dna` (PyPI package v0.3.0+)
- https://github.com/sancovp/sdna
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.