Skip to content

08 MG Grammar

Varietyz edited this page Apr 2, 2026 · 1 revision

📐 Memory Grammar (MG) — Quick Reference

Annotation-based DSL for structured memory files.
Every annotation starts with @. Every operator has exactly one meaning.

See also: Memory Schema


· ⚙️ Operators

Operator Name Meaning Arity
:= Bind Assigns value to name Binary
-> Relate Directed relationship Binary
=> Transition State change (from => to) Binary
>> Sequence Ordered steps (A then B) Binary
| Union List of alternatives Binary
|> Pipe Scoped continuation Unary

· 📌 Annotations by Category

· 🆔 Identity

Annotation Values Example
@type project user feedback reference @type project
@domain Registered values from grammar/registries/domains.md @domain ai-governance | governance
@owner Registered values from grammar/registries/owners.md @owner jay-baleine

· 🏷️ Classification

Annotation Purpose Example
@tag Searchable terms @tag schema | validation | frontmatter
@scope Visibility scope @scope session

· 🔄 Lifecycle

Annotation Purpose Example
@state Current state or transition @state active or @state draft => active
@verified Last verification date @verified 2026-04-02
@version Content version @version 3
@stale Days until stale (-1 = never) @stale 14 or @stale never

· 📝 Content

Annotation Purpose Example
@context Situation or transition @context "migration in progress"
@decided Named decision @decided architecture := "event-driven"
@rule Behavioral rule @rule "always validate before write"
@note Free-form note @note "revisit after Phase 2"

· 🔗 Relations

Annotation Purpose Example
@depends File dependencies @depends schema -> grammar
@supersedes File this replaced @supersedes old-file
@next Ordered sequence @next phase-1 >> phase-2 >> phase-3
@blocks Blocking dependency @blocks deployment -> testing

· 📁 Files

Annotation Purpose Example
@created File created @created src/new-module.js
@modified File modified @modified src/config.js
@removed File removed @removed src/deprecated.js

· 🔔 Notify

Annotation Purpose Example
@notify Alert owner with pipeline @notify jay-baleine |> @load schema.md |> @rule "validate"

· 🛡️ Constraints

Annotation Purpose Example
@max Line budget @max 150
@require Required dependency @require auth-module
@forbid Prohibited content @forbid "hardcoded credentials"

· 📋 Type Profiles

Each @type constrains which annotations are valid.

Type Required Optional Enforced
project @domain, @owner, @state, @verified, @version, @stale @tag, @context, @decided, @next, @depends, @supersedes, @created, @modified, @removed, @notify, @max, @note
feedback @domain, @owner, @verified, @version @tag, @rule, @context, @depends, @note @stale never
user @domain, @owner, @verified, @version @tag, @scope, @context, @note @stale >= 90
reference @domain, @owner, @verified, @version @tag, @context, @depends, @note, @max @state, @next, @notify, @created, @modified, @removed FORBIDDEN

· 🔍 Disambiguation Rules

  1. Every line starts with @ or |>. No other line start is valid.
  2. -> is always a directed relationship. Never a transition.
  3. => is always a state transition. Only after @state.
  4. >> is always an ordered sequence. Only after @next.
  5. | is always union. Only in @domain and @tag lists.
  6. |> is always pipe-forward. Only in @notify chains.
  7. := is always value binding. Only in @decided and named @rule.
  8. Quoted strings are free text. Bare words are identifiers or paths.

· 🖥️ Compiler

node grammar/compiler/mg-compile.js --validate
node grammar/compiler/mg-compile.js --validate --compiled-index
node grammar/compiler/mg-compile.js --validate --json

Navigation

🏠 Home


Quick Reference


Getting Started


Links

Clone this wiki locally