Back to tutorials

Build a Lattice

advanced 30 minutes

What You’ll Build

A validated .lattice.yaml file that defines a workflow as a directed graph of nodes and edges. By the end, you’ll have a composable, FAIR-annotated lattice ready for execution or federation.

Prerequisites

Steps

Step 1: Define the Workflow

Sketch your workflow as nodes and data flow. Example — a data analysis pipeline:

Collect Data → Clean Data → Analyze → Visualize → Report

Each box becomes a node. Each arrow becomes an edge.

Step 2: Choose the Lattice Type

If your workflow…ChooseExecution Mode
Processes data through stagespipelinesequential
Makes decisions and loopsagenthybrid
Retrieves and reasons over knowledgecontext_graphvaries
Orchestrates multiple sub-processesworkflowhybrid

Our data analysis pipeline is a pipeline with sequential execution.

Step 3: Write the YAML

Create my_analysis.lattice.yaml:

lattice:
  name: data_analysis
  version: "1.0.0"
  lattice_type: pipeline
  description: "End-to-end data analysis from collection to report"

  execution:
    mode: sequential
    runtime: local
    tier: L1

  nodes:
    - id: collect_data
      type: process
      description: "Gather raw data from sources"

    - id: clean_data
      type: module
      ref: "what/modules/module_data_cleaner"
      description: "Remove duplicates, handle missing values"

    - id: analyze
      type: module
      ref: "what/modules/module_statistical_analysis"
      description: "Run statistical analysis on clean data"

    - id: visualize
      type: module
      ref: "what/modules/module_chart_generator"
      description: "Generate charts and figures"

    - id: report
      type: process
      description: "Compile findings into a report"

  edges:
    - from: collect_data
      to: clean_data
      label: "raw data"
    - from: clean_data
      to: analyze
      label: "clean dataset"
      data_mapping:
        clean_output: analysis_input
    - from: analyze
      to: visualize
      label: "statistical results"
    - from: visualize
      to: report
      label: "charts and figures"

  fair:
    license: "MIT"
    keywords: [data-analysis, pipeline, statistics]
    creators: ["Your Name"]
    provenance: "Built for quarterly data reporting"

Key decisions:

  • Node IDs are snake_case and descriptive (not node_1, step_a)
  • module nodes have ref pointing to implementations; process nodes are human/agent steps
  • Edges use data_mapping for explicit field mapping
  • The fair block has at least keywords and license

Step 4: Validate

Run the schema validator:

python what/lattices/tools/lattice_validate.py my_analysis.lattice.yaml

Fix any errors: missing required fields, invalid node references, disconnected nodes.

Step 5: Add Federation Metadata (Optional)

If you want to share this lattice with other projects:

  federation:
    shareable: true
    source_instance: my_project
    version_policy: minor

This enables the lattice to be imported and composed into other vaults. See the federation readiness checklist.

Step 6: Validate Again

Re-run validation after adding federation properties — the validator checks federation consistency too.

What You Learned

  • Lattices are declarative graphs: nodes + edges + metadata (§5.1)
  • Four types cover all workflow patterns
  • FAIR metadata is required — keywords and license minimum
  • Explicit data_mapping on edges prevents implicit assumptions

Next Steps