Specification

LagomDocument specification

The complete schema reference for Lagom documents. Covers the root document object, sections, typed elements, variables, governance metadata, and file format conventions.

LagomDocument

Every Lagom document resolves to a LagomDocument object. Whether authored as .lagom.md or .lagom.json, the parsed result conforms to this interface. The document carries metadata, content sections, variables, entity references, connector bindings, agent actions, and governance rules.

LagomDocument interface
interface LagomDocument {
  $schema: string;              // Schema URL for validation
  lagomVersion: string;         // Spec version (e.g. "1.0")
  kind: "LagomDocument";        // Discriminator
  id: string;                   // Stable unique identifier
  title: string;                // Document title
  description?: string;         // Optional summary
  documentType: DocumentType;   // sop | policy | playbook | ...
  status: DocumentStatus;       // draft | active | deprecated | archived
  owner?: OwnerRef;             // Owner team or person
  aliases?: string[];           // Alternative names for resolution
  sections: LagomSection[];     // Ordered content sections
  variables?: LagomVariable[];  // Document-scoped variables
  entities?: BusinessEntityRef[];  // Referenced business entities
  connectors?: ConnectorRef[];  // External system connectors
  actions?: AgentAction[];      // Declared agent actions
  governance?: GovernanceMetadata;  // Ownership and review rules
  references?: DocumentReference[];  // Typed relationships
  extensions?: Record<string, unknown>;  // Namespaced custom data
}
Field Type Required Description
$schema string yes URL to the Lagom JSON Schema for validation
lagomVersion string yes Spec version this document conforms to
kind "LagomDocument" yes Type discriminator, always "LagomDocument"
id string yes Stable unique identifier for cross-referencing
title string yes Document title for display, search, and agent context
documentType DocumentType yes One of: sop, policy, playbook, decision, guide, workflow
status DocumentStatus yes Lifecycle state: draft, active, deprecated, archived
sections LagomSection[] yes Ordered list of content sections
owner OwnerRef no Team or person responsible for this document
governance GovernanceMetadata no Review cadence, confidence, staleness rules

LagomSection

Sections are the top-level organizational unit within a document. Each section has a stable ID, a title, and an ordered list of typed elements. In .lagom.md, sections correspond to Markdown headings.

LagomSection interface
interface LagomSection {
  id: string;                   // Stable section identifier
  title: string;                // Section heading
  elements: LagomElement[];     // Ordered typed blocks
  visibility?: VisibilityScope; // internal | external | public | private
}

LagomElement union

Every block in a Lagom document is a typed element. The element type is a discriminated union on the elementType field. Each element has an id, optional label, and type-specific properties. Elements are organized into 6 categories, each serving a distinct role in the document system.

LagomElement base
interface LagomElementBase {
  id: string;                   // Stable unique identifier
  elementType: string;           // Discriminator
  label?: string;               // Optional display label
  visible?: boolean;            // Render visibility (default: true)
  condition?: string;           // Variable expression for conditional display
}

Basic — Markdown primitives

Fundamental content blocks that map directly to standard Markdown constructs. These require no special metadata and render universally.

Heading
Paragraph
Markdown
Blockquote
List
Horizontal Rule

HeadingElement

HeadingElement
interface HeadingElement extends LagomElementBase {
  elementType: "heading";
  level: 1 | 2 | 3 | 4 | 5 | 6;  // Heading depth
  content: string;              // Heading text (may contain inline markdown)
}

ParagraphElement

ParagraphElement
interface ParagraphElement extends LagomElementBase {
  elementType: "paragraph";
  content: string;              // Inline markdown content
}

MarkdownElement

MarkdownElement
interface MarkdownElement extends LagomElementBase {
  elementType: "markdown";
  content: string;              // Raw markdown block (multi-line)
}

BlockquoteElement

BlockquoteElement
interface BlockquoteElement extends LagomElementBase {
  elementType: "blockquote";
  content: string;              // Quoted text content
}

ListElement

ListElement
interface ListElement extends LagomElementBase {
  elementType: "list";
  ordered: boolean;             // Numbered vs bullet list
  items: string[];              // List item content (inline markdown)
}

HorizontalRuleElement

HorizontalRuleElement
interface HorizontalRuleElement extends LagomElementBase {
  elementType: "horizontal_rule";
}

Advanced — Variable-bound interactive elements

Interactive elements that bind to document variables. When rendered in an interactive surface, users can supply values that propagate through the document via variable interpolation. In static contexts, they render as their default or placeholder values.

Code
Table
Checklist
Radio
Dropdown
Number
Slider
Textbox

CodeElement

CodeElement
interface CodeElement extends LagomElementBase {
  elementType: "code";
  language?: string;             // Syntax highlight language
  content: string;              // Code content
  title?: string;               // Optional caption
}

TableElement

TableElement
interface TableElement extends LagomElementBase {
  elementType: "table";
  title?: string;
  columns: string[];             // Column header labels
  rows: string[][];              // Row data (array of arrays)
}

ChecklistElement

ChecklistElement
interface ChecklistElement extends LagomElementBase {
  elementType: "checklist";
  title: string;
  items: string[];              // Checklist item labels
  variable?: string;            // Bind checked state to variable
}

RadioElement

RadioElement
interface RadioElement extends LagomElementBase {
  elementType: "radio";
  label: string;                // Input label
  options: string[];            // Selectable options
  variable: string;             // Variable to bind selected value
  default?: string;             // Pre-selected option
}

DropdownElement

DropdownElement
interface DropdownElement extends LagomElementBase {
  elementType: "dropdown";
  label: string;                // Input label
  options: string[];            // Selectable options
  variable: string;             // Variable to bind selected value
  default?: string;             // Pre-selected option
  placeholder?: string;        // Placeholder text
}

NumberElement

NumberElement
interface NumberElement extends LagomElementBase {
  elementType: "number";
  label: string;                // Input label
  variable: string;             // Variable to bind value
  min?: number;                // Minimum value
  max?: number;                // Maximum value
  step?: number;               // Increment step
  default?: number;            // Default value
}

SliderElement

SliderElement
interface SliderElement extends LagomElementBase {
  elementType: "slider";
  label: string;                // Input label
  variable: string;             // Variable to bind value
  min: number;                 // Minimum value
  max: number;                 // Maximum value
  step?: number;               // Increment step
  default?: number;            // Default position
}

TextboxElement

TextboxElement
interface TextboxElement extends LagomElementBase {
  elementType: "textbox";
  label: string;                // Input label
  variable: string;             // Variable to bind value
  placeholder?: string;        // Placeholder text
  multiline?: boolean;         // Allow multiline input
  maxLength?: number;          // Character limit
}

Visual — Structured visuals

Rich visual elements for data presentation, diagrams, and layout composition. Visual elements render as structured components in interactive surfaces and degrade gracefully to static representations in plain Markdown.

Card
Grid
Chart
Mermaid
Image
Tabulator
Treebark

CardElement

CardElement
interface CardElement extends LagomElementBase {
  elementType: "card";
  title: string;
  content: string;              // Markdown body content
  style?: "default" | "highlight" | "warning" | "info";
  icon?: string;                // Icon identifier
}

GridElement

GridElement
interface GridElement extends LagomElementBase {
  elementType: "grid";
  title?: string;
  columns: number;              // Number of grid columns
  items: GridItem[];            // Grid cell items
}

interface GridItem {
  label: string;
  value: string;
  trend?: string;              // Trend indicator (e.g. "+12%")
  icon?: string;
}

ChartElement

ChartElement
interface ChartElement extends LagomElementBase {
  elementType: "chart";
  title: string;
  chartType: "line" | "bar" | "pie" | "area" | "scatter";
  xAxis?: string;               // X-axis label
  yAxis?: string;               // Y-axis label
  dataRef?: string;             // Reference to data source
  data?: Record<string, unknown>[];  // Inline data points
}

MermaidElement

MermaidElement
interface MermaidElement extends LagomElementBase {
  elementType: "mermaid";
  title?: string;
  diagram: string;              // Mermaid diagram syntax
}

ImageElement

ImageElement
interface ImageElement extends LagomElementBase {
  elementType: "image";
  src: string;                  // Image URL or relative path
  alt?: string;                 // Accessibility alt text
  caption?: string;             // Display caption
  width?: number;               // Display width in pixels
}

TabulatorElement

TabulatorElement
interface TabulatorElement extends LagomElementBase {
  elementType: "tabulator";
  title?: string;
  columns: TabulatorColumn[];  // Column definitions
  data?: Record<string, unknown>[];  // Inline row data
  dataRef?: string;             // External data source
  pagination?: boolean;        // Enable pagination
  sortable?: boolean;          // Enable column sorting
}

interface TabulatorColumn {
  field: string;
  title: string;
  type?: "string" | "number" | "date" | "boolean";
}

TreebarkElement

TreebarkElement
interface TreebarkElement extends LagomElementBase {
  elementType: "treebark";
  title?: string;
  spec: Record<string, unknown>;  // Treebark visual specification
}

Data — Business data references

Elements that establish bindings to external systems, describe business objects, and reference live data. Data elements define the integration layer — they declare what systems and entities the document references, without prescribing how to orchestrate them.

Connector
Entity
Data Reference

ConnectorElement

ConnectorElement
interface ConnectorElement extends LagomElementBase {
  elementType: "connector";
  name: string;                 // Display name
  type: "saas" | "database" | "api" | "file";
  url?: string;                 // Connection endpoint
  connectionString?: string;   // Database connection string
  auth?: "oauth2" | "api-key" | "service-account" | "none";
  scopes?: string[];            // Required permission scopes
}

EntityElement

EntityElement
interface EntityElement extends LagomElementBase {
  elementType: "entity";
  name: string;                 // Business entity name (e.g. "Deal")
  source: string;               // Connector ID this entity belongs to
  fields?: EntityField[];       // Field definitions
}

interface EntityField {
  name: string;
  type: "string" | "number" | "date" | "boolean"
    | "currency" | "enum" | "reference";
  required?: boolean;
  description?: string;
}

DataReferenceElement

DataReferenceElement
interface DataReferenceElement extends LagomElementBase {
  elementType: "data_reference";
  title: string;
  source: string;               // Connector ID
  query?: string;               // Query expression
  refreshInterval?: string;    // Auto-refresh cadence (e.g. "1h")
  format?: "table" | "json" | "csv";
}

Agent — AI-native workflow primitives

Elements that provide context, capabilities, and constraints for AI agents. Agent elements are definitions — they describe what an agent knows, what it can do, and what assets it has access to. They do not execute actions themselves; execution is handled by the platform layer (such as the Lagom Knowledge Base Platform) built on top of these definitions.

Instruction
Skill
Asset
Script

InstructionElement

InstructionElement
interface InstructionElement extends LagomElementBase {
  elementType: "instruction";
  role?: "system" | "user" | "assistant";  // Message role
  content: string;              // Instruction text (supports variable interpolation)
}

SkillElement

SkillElement
interface SkillElement extends LagomElementBase {
  elementType: "skill";
  name: string;                 // Skill name (for agent tool selection)
  description: string;          // What this skill does
  requiredContext?: string[];   // Variables that must be set before use
  outputVariable?: string;     // Variable to store the result
}

AssetElement

AssetElement
interface AssetElement extends LagomElementBase {
  elementType: "asset";
  name: string;                 // Asset display name
  type: "document" | "data" | "template" | "image";
  source?: string;              // Path or URL to the asset
  description?: string;        // What this asset contains
  mimeType?: string;            // Content type
}

ScriptElement

ScriptElement
interface ScriptElement extends LagomElementBase {
  elementType: "script";
  name: string;                 // Script display name
  language?: string;            // Language identifier (e.g. "pseudo", "python")
  code: string;                 // Script body
  description?: string;        // What the script does
}

Process — Execution primitives

Elements that define workflow execution order, conditions, and control flow. Process elements feed into the ProcessDAG — a directed acyclic graph that describes execution order, parallelism, and conditional branching. Like all lagom.md elements, these are definitions; the platform layer orchestrates actual execution.

Step
Condition
Decision
Evidence
Flow
Approval Gate
Policy Rule

StepElement

Represents a single procedure step in an SOP or workflow. Steps carry ownership, tooling, input/output contracts, retry policies, and approval requirements.

StepElement
interface StepElement extends LagomElementBase {
  elementType: "step";
  title: string;
  description?: string;
  owner?: string;              // Role or person responsible
  system?: string;             // System of record
  tool?: string;               // Tool identifier (e.g. google_drive.create_folder)
  requiresApproval?: boolean;  // Gate before execution
  inputMap?: Record<string, string>;  // Variable bindings
  requiredEntity?: string;     // Business entity dependency
  expectedDuration?: string;   // Human-readable estimate
  retry?: RetryPolicy;         // Retry configuration
  approval?: ApprovalConfig;   // Approval gate configuration
  onFailure?: "escalate" | "skip" | "abort";
  escalateTo?: string;         // Escalation target on failure
}

ConditionElement

ConditionElement
interface ConditionElement extends LagomElementBase {
  elementType: "condition";
  expression: string;           // Boolean expression using variables
  thenBranch?: string;          // Element ID to execute if true
  elseBranch?: string;          // Element ID to execute if false
}

DecisionElement

DecisionElement
interface DecisionElement extends LagomElementBase {
  elementType: "decision";
  title: string;
  rationale?: string;           // Why this decision exists
  options?: string[];           // Available choices
  status?: "pending" | "accepted" | "rejected";
  date?: string;                // ISO 8601 decision date
  owner?: string;               // Decision maker
}

EvidenceElement

EvidenceElement
interface EvidenceElement extends LagomElementBase {
  elementType: "evidence";
  sourceType: "document" | "url" | "data" | "observation";
  title?: string;               // Evidence description
  author?: string;              // Who provided this evidence
  confidence?: "low" | "medium" | "high";
  url?: string;                 // Link to source
}

FlowElement

FlowElement
interface FlowElement extends LagomElementBase {
  elementType: "flow";
  title: string;
  parallel?: string[];           // Element IDs to run concurrently
  joinType?: "all" | "any";    // Wait for all or first to complete
}

ApprovalGateElement

ApprovalGateElement
interface ApprovalGateElement extends LagomElementBase {
  elementType: "approval_gate";
  approver: string;             // Role or person who approves
  appliesTo?: string[];         // Element IDs this gate applies to
  timeout?: string;             // Max wait time (e.g. "48h")
  escalation?: string;          // Who to escalate to on timeout
  onReject?: "abort" | "revise" | "escalate";
}

PolicyRuleElement

Captures a business policy rule with scope, severity, exceptions, and enforcement context. Policy rules export as structured constraints for AI agents.

PolicyRuleElement
interface PolicyRuleElement extends LagomElementBase {
  elementType: "policy_rule";
  rule: string;                 // The policy statement
  scope?: string;               // Who or what this applies to
  severity?: "standard" | "critical";
  enforcement?: "manual" | "automated" | "manual-with-automation";
  system?: string;              // Enforcement system
  exceptions?: string[];       // Listed exceptions
}

Supporting interfaces

Shared types referenced by process elements for retry policies and approval configurations.

RetryPolicy
interface RetryPolicy {
  maxAttempts: number;          // Maximum retry attempts
  firstRetryInterval: string;  // Initial delay (e.g. "5s")
  backoffCoefficient?: number; // Multiplier for each retry
  maxRetryInterval?: string;   // Maximum delay cap
}
ApprovalConfig
interface ApprovalConfig {
  timeout: string;              // Max wait time
  escalateTo?: string;         // Escalation target
  onReject?: "abort" | "revise" | "escalate";
  maxRevisions?: number;       // Max revision cycles
}

GovernanceMetadata

Governance metadata tracks ownership, review cadence, freshness, confidence, and agent readiness. This data powers dashboards, stale-document detection, and agent context filtering.

GovernanceMetadata
interface GovernanceMetadata {
  owner?: string;              // Responsible team or person
  reviewer?: string;           // Designated reviewer
  department?: string;         // Organizational unit
  reviewCadence?: string;      // monthly | quarterly | annually
  lastVerifiedAt?: string;     // ISO 8601 date
  staleAfterDays?: number;     // Days before flagged stale
  confidence?: "low" | "medium" | "high";
  riskLevel?: "low" | "medium" | "high";
  agentReady?: boolean;        // Safe for agent consumption
  externalSharingAllowed?: boolean;
  sourceOfTruth?: boolean;     // Canonical source document
}

Authoring conventions

Lagom documents can be authored in two formats. Both parse to the same LagomDocument object and round-trip without loss.

Extension Format Use case
.lagom.md Markdown + YAML fenced blocks Human authoring, git diffs, AI agent consumption
.lagom.json Canonical JSON Applications, validation, programmatic generation

In .lagom.md, document metadata lives in YAML frontmatter. Typed blocks use fenced code blocks with Lagom-namespaced language tags — for example lagom.step, lagom.instruction, lagom.connector, lagom.chart, lagom.decision, and lagom.approval_gate. The tag after lagom. corresponds directly to the elementType discriminator. Plain Markdown prose is parsed as Basic category elements (heading, paragraph, list, etc.).

Resources

Schema, types, and runtime assets for developers integrating the LagomDocument format. All assets are served from this origin. Pin $schema to the schema URL below.

Path Description
/schema/v1/idoc_v1.json JSON Schema for document validation
/schema/v1/idoc_v1.d.ts TypeScript type definitions
/dist/v1/chartifact.markdown.umd.js Markdown rendering runtime
/dist/v1/chartifact.sandbox.umd.js Sandbox execution environment
/dist/v1/chartifact.compiler.umd.js Document compiler
/dist/v1/chartifact-reset.css Base stylesheet for rendered documents