This document is the canonical language spec for OrgScript. It consolidates the reference syntax, semantics, canonical model, and diagnostic contract from the supporting docs and supersedes draft-only wording in docs/syntax.md, docs/semantics.md, spec/canonical-model.md, and spec/diagnostics.md.
OrgScript is a description language for organizational logic. It is designed to be:
- readable by people
- deterministic for parsers and validators
- stable in version control
- analyzable by AI
- portable across downstream tools and exports
OrgScript is not a general-purpose programming language. It describes business logic, not executable software.
- Plain text
- UTF-8
- Indentation uses spaces
- One statement per line
- Keywords are lowercase
- Strings use double quotes
- Suggested extension:
.orgs - Comments use whole-line
# ...form in v1 - Structured annotations use whole-line
@key "value"form in v1
An OrgScript file contains one or more top-level blocks of these kinds:
processstateflowrulerolepolicymetricevent
Each block name is a canonical identifier. Block names use PascalCase. Entity and field references use lowercase dotted notation such as lead.status or order.paid.
process: a directed operational flow with explicit trigger, decisions, and actionsstateflow: the allowed states and legal transitions for a modeled entityrule: a constraint or mandatory business rulerole: a permission boundarypolicy: time-based or context-based organizational behaviormetric: a tracked business measureevent: a named trigger with associated reactions
The language recognizes these core statements:
when: declares an entry trigger or condition contextif: declares a conditional branchelse if: declares an additional conditional branchelse: declares the fallback branchassign: sets a modeled valuetransition: changes a modeled statenotify: emits a message to a target actor or systemcreate: declares creation of a modeled entityupdate: declares mutation of a modeled fieldrequire: declares a named prerequisite or approval gatestop: ends the current branch
The same keyword must keep the same primary meaning across the language.
OrgScript uses indentation-based blocks and lexical keywords. The reference grammar is defined in spec/grammar.ebnf.
OrgScript supports two non-executable documentation forms:
- comments
- annotations
Comments:
- begin with
# - must occupy their own logical line in v1
- are human-oriented only
- are not authoritative business logic
- do not change parsing semantics, semantic validation, analysis, or transition legality
Annotations:
- use
@key "value" - attach to the immediately following supported block or statement
- are parseable metadata
- are non-semantic
- are included in the AST and canonical model
Supported annotation keys in v1:
@note@owner@todo@source@status@review
In v1, comments and annotations are supported on:
- top-level block declarations
whenif- action statements such as
assign,transition,notify,create,update,require, andstop
They are not supported on list sections such as states, transitions, can, cannot, or raw field lines such as formula, owner, target, and applies to.
process describes linear operational logic with explicit decisions and actions.
wheninside aprocessis the entry triggerifandelse ifexpress branching logicthenis part of the conditional formif ... thenstopterminates the current branch and prevents later sibling statements from applying to that branch
stateflow declares legal states and legal transitions only. It does not define execution order.
rule declares a constraint that should remain true whenever its condition matches.
role declares compact permissions through can and cannot sections.
policy declares context-based or time-based responses.
whenintroduces the conditionthenstarts the response block for that condition- a policy may contain multiple trigger-response sections
metric declares a measurable outcome with a formula, owner, and target.
event declares a named trigger with associated actions.
The canonical reading rules are:
- File order matters within a block
- Indentation defines containment
- Block type is semantically significant
wheninprocessis distinct fromwheninpolicyifis distinct fromwhenstateflowdefines legality, not executionrequireis a first-class prerequisite reference, not prosestopends the current branch- explicit values and branch order must be preserved
- comments are ignored by semantic interpretation
- annotations are metadata only and do not alter semantics
OrgScript prefers explicit description over inference. If a statement is ambiguous, the language should favor a more explicit form rather than hidden defaults or shorthand.
If business logic matters, it must be modeled in OrgScript constructs, not hidden in comments.
OrgScript text compiles into a language-neutral canonical model. The canonical model is the stable intermediate representation used for:
- validation
- formatting
- documentation
- export
- AI analysis
Canonical model guidelines:
- preserve meaning independent of formatting
- preserve document kind, statement order, and branch order
- preserve explicit identifiers and values exactly
- keep the model close to the source AST
- do not invent business semantics during export
- include annotations on supported nodes
- exclude comments
Canonical node families include:
- document nodes
- structural nodes
- conditional nodes
- action nodes
- expression nodes
Suggested document kinds match the top-level blocks listed above.
Diagnostics must serve both humans and machines.
orgscript validate <file> --jsonorgscript lint <file> --jsonorgscript check <file> --json
Each diagnostic entry should include:
sourcecodeseveritylinemessage
Combined check --json output should also preserve stage-local status fields such as valid, clean, canonical, and skipped.
validate:0for valid,1for invalid or CLI failurelint:0for warnings only or no findings,1for errors or CLI failurecheck:0for valid, lint-clean, canonically formatted files;1otherwise
At minimum, validation should reject or flag:
- unknown keywords
- invalid block structure
elsewithout a precedingif- duplicate state names in one
stateflow - undefined or illegal state transitions
- empty blocks where content is required
- duplicate top-level names within the same namespace, according to policy
- malformed annotation syntax
- unsupported annotation keys
- misplaced annotations
- inline
#comments after code, which are intentionally unsupported in v1
OrgScript evolves conservatively.
- keep the core vocabulary small
- prefer backward-compatible additions
- preserve keyword meanings once shipped
- add new constructs only when existing ones cannot express the need clearly
- avoid turning OrgScript into a general-purpose programming language
- document any new keyword, grammar rule, or semantic change before it becomes canonical
If a change affects parsing, canonical modeling, or diagnostics, it must be treated as a spec change, not just an implementation detail.
Supporting material lives in:
docs/manifesto.mddocs/language-principles.mddocs/syntax.mddocs/semantics.mdspec/grammar.ebnfspec/canonical-model.mdspec/diagnostics.mddocs/orgscript-for-humans.mddocs/orgscript-for-ai.md