cog Developer Preview

Learn cog by running it.

cog is a small declarative language and execution substrate for constructing governed semantic graphs with explicit entities, relations, perspectives, resolutions, transformations, constraints, emissions, validation, planning, and execution traces.

Canonical documentation

Ratified Developer Preview teaching estate

Explore the complete canonical documentation suite. Every guide is calibrated to tested language behavior, executable canonical fixtures, and the eight-command developer toolbelt.

Execution pipeline

The canonical consumer sequence

LEX → PARSE → COMPILE → VALIDATE → PLAN → EXECUTE → EMISSIONS + TRACE

Every execution passes through deterministic planning phases:

bind → transform → validate → emit

Every runtime execution returns an inspectable trace and explicit emissions.

Responsibility boundary

Layered cognitive architecture

Cog Kernel
  ↓
CogLib (Universal Cognitive Standard Library)
  ↓
Domain Libraries / Machine Editions
  ↓
Tools & Memory Substrates
  ↓
Applications & Consumer Surfaces

The kernel preserves governed declarations and execution structure. Higher-order cognitive algorithms are supplied by CogLib, domain libraries, adapters, tools, or applications.

Quick start

From zero to one runnable cognitive program

The Developer Preview targets Node 20 and npm 10 or newer. Use npx --no-installfor project-local CLI execution without global installation.

1 · Install

Add the core package

npm install @winmedia/cog-core

Package: @winmedia/cog-core. The release package exposes the core language, packaged curriculum in learning/, and executable examples/.

2 · Inspect

See what your installation can do

npx --no-install cog help
npx --no-install cog discover
npx --no-install cog workflows

Discovery matters because libraries and workflow capabilities should be read from the installed release rather than assumed from documentation.

3 · Write

Create observation.cog

Start with one explicit observation and one emission. The point is not the ambient-light example; it is learning the shape of a cognitive object that can be validated and executed.

define entity "observed-signal" {
  kind: observation
  level: L1
  operation: observe
  attribute: "ambient-light"
  value: "present"
  confidence: 1
}

emit {
  target: "observed-signal"
  kind: observation
}

4 · Validate, then run

npx --no-install cog validate observation.cog
npx --no-install cog run observation.cog

Keep validation before execution as the default habit. A cognitive program should fail visibly when its structure or semantics are not valid.

Language Grammar

The seven canonical statement families

Cog does not currently include loops, functions, imports, macros, or hidden control flow. Every Developer Preview program is composed from these seven explicit statement families:

StatementStructural Role & Purpose
define entityDeclare an addressable semantic object with kinds, levels, and explicit attributes.
relateDeclare a typed directed relationship between two entities.
viewDeclare a perspective or projection on an entity.
resolveBind an entity or target to a Cog resolution level (L1–L5).
transformDeclare transformation intent for an explicit target.
constrainAttach an explicit governed constraint rule to a target.
emitDeclare an explicit output target and emission kind.

CLI reference

The eight-command developer toolbelt

The CLI exposes a compact Unix-inspired developer toolbelt for inspecting, linting, graphing, tracing, and comparing .cog programs without needing a TypeScript harness.

CommandPurpose
cog helpShow the installed command surface.
cog discoverList available domain capability libraries.
cog workflowsList runnable workflow definitions available to the installed release.
cog validate <file>Parse and validate a .cog program without executing it.
cog run <file>Execute a validated .cog program.
cog lint <file>Find structural workflow smells before execution.
cog graph <file>Render compiled semantic structure as Mermaid flowchart.
cog trace <file> [--phase <phase>]Inspect the execution path, step order, and plan phases.
cog diff <before> <after>Compare execution traces between two running .cog programs.

Beginner's guide

Three levels of learning

Do not begin with the largest domain workflow. Learn the grammar of cognitive operations, learn to compose them in the Governed Decision tutorial, use the Level-2 developer toolbelt, then study the Level-3 application architectures.

Level 1

Learn the cognitive primitives

Begin with the seven statement families and ten canonical cognitive patterns: observation, identification, comparison, classification, relation, projection, resolution, constraint, transformation, and emission.

Outcome: You should be able to read a small .cog file and explain what cognitive operation each statement represents.

Governed Decision

Progressive tutorial

Compose the full language surface into one complete problem: evidence, perspectives, resolution, transformation, constraints, and emissions.

Outcome: You should be able to write an end-to-end governed cognitive decision program.

Level 2

Think in Unix-like cognitive commands

Use the eight-command Developer Preview toolbelt: discover, workflows, validate, lint, graph, run, trace, and diff.

Outcome: You should be able to inspect, lint, graph, and compare cognitive execution traces from the command line.

Level 3

Build complete cognitive workflows

Study five canonical application architectures: research synthesis, editorial document review & drift detection, decision analysis, audit reasoning, and knowledge graphs.

Outcome: You should be able to choose a domain library, adapt an example, validate it, and run a bounded cognitive workflow.

Examples

Read small programs before large ones

The repository groups canonical examples into primitives, pipelines, graphs, adapters, and applications. Start with primitives; use application examples when you are ready to see several operations composed into a domain workflow.

Primitive set

Canonical language primitives

Observation, identification, relation, classification, comparison, constraint, transformation, resolution, projection, and emission each have small canonical examples in the repository.

Research synthesis

Observe sources, extract claims, compare them, cluster them, resolve the synthesis, and emit a final result.

Read the canonical example →

Editorial review & drift detection

Use a bounded workflow for document review, drift detection, reconciliation, and explanation.

Read the canonical example →

Audit reasoning

Model findings, relations, severity, and audit resolution without hiding reasoning structure inside prose.

Read the canonical example →

Standard Library

Discover reusable cognitive domains

Run cog discover against the installed release for the authoritative list. The Developer Preview library family is organized around reusable domains rather than one giant general-purpose workflow.

Research Synthesis

cog:domain:research

Editorial Review

cog:domain:editorial

Decision Analysis

cog:domain:decision

Audit Reasoning

cog:domain:audit

Knowledge Graph

cog:domain:graph

Human Orientation

cog:domain:orientation

Cognitive Ecology

cog:domain:cognitive-ecology

Devotional Intelligence

cog:domain:devotional-intelligence

Developer Preview boundary

Expect a real toolchain, not a finished platform

  • The Developer Preview is for learning, experimentation, and bounded downstream use.
  • Syntax, library shape, diagnostics, and runtime contracts may still change before a stable release.
  • cog is not a hosted AI service, browser IDE, or replacement for the model or tools a workflow may call.
  • Prefer small validated programs over large speculative architectures while learning the language.