Synthesis language
This guide documents the language implemented in Local Cognitive today, not the broader research proposal. It is intended for people writing contracts and agent workflows by hand in their preferred editor.
An LC program has two authored files:
| File | Purpose |
|---|---|
ModuleName.lcspec |
Define what the generated module must satisfy: its description, output files, frozen interfaces, and acceptance gates, including the engineer’s own tests and architecture rules. |
ModuleName.lcflow |
Define how to construct it: select models, assign roles, generate files, evaluate, branch, and repeat. |
LC Flow is an interpreted programming language with variables, expressions, conditionals, and loops. It is not JSON, JavaScript, or a shell script. Calls are restricted to the runtime actions documented below.
The generated source code is a candidate implementation. An agent’s statement that it has finished is not acceptance evidence.
Contents
Section titled “Contents”- Quick start: a complete calculator program
- Writing a module with a coding agent, and checking it offline
- Basic syntax
- LC Spec reference
- Contracts on rails: tests and architecture gates
- LC Flow reference
- Runtime functions
- Model role methods
- Multiple roles and a repair loop
- Agents
- Acceptance and run outcomes
- Files, editor, and application UI
- Common mistakes
- V1 boundaries and future language features
Quick start: a complete calculator program
Section titled “Quick start: a complete calculator program”Create this structure inside a project registered in Local Cognitive:
your-project/ Synthesis/ Calculator/ Calculator.lcspec Calculator.lcflowThe two filenames, module name, and implement name must agree. Module names start with an ASCII letter and contain only letters, digits, and underscores, with a maximum of 64 characters. Synthesis/Name/Name.* is the recommended layout, but matching Name.lcspec / Name.lcflow files may also live together at the project root or in a nested source folder. Their containing folder does not have to match the module name.
Alternatively, use New module in the application: enter a name, choose Empty module or Calculator example, and select the parent folder inside your project. The dialog previews both paths before creating <folder>/<name>/<name>.lcspec and .lcflow. Existing files are never overwritten. The empty template is a neutral starter with a placeholder evaluator and an unresolved flow; it does not automatically load a model or prove a contract.
1. Write the contract
Section titled “1. Write the contract”Save as Synthesis/Calculator/Calculator.lcspec:
module Calculator version "1" { target { language = JavaScript; }
description = "Build a small dark calculator using plain HTML, CSS, and JavaScript. calculator.js defines a global calculate(a, b, operation) function for numeric +, -, *, /. Division by zero throws Error. index.html has labeled number inputs id=a and id=b, a labeled select id=operation with values + - * /, button id=calculate, button id=clear, and output id=result. Calculate displays the answer or Error; Clear empties both inputs and the result. Link style.css and load a classic calculator.js script at the end of body after all controls, without async/defer. No external dependencies, network access, inline event attributes, modules, or dynamic evaluation.";
artifacts { file "calculator.js"; file "index.html"; file "style.css"; }
evaluate "calculator-v1" { hard arithmetic = Pass("calculator-arithmetic-v1"); hard ui = Pass("calculator-ui-v1"); }}description guides the models. The evaluate block selects trusted application checks. The description does not automatically become executable assertions.
2. Write the generation process
Section titled “2. Write the generation process”Save as Synthesis/Calculator/Calculator.lcflow:
implement Calculator using "calculator-v1" { limit iterations 6, time 15m, cost 0usd; policy = "local-files-v1";
available = await models.list(provider = "llamacpp"); selected = models.select( available, max_size = 6GiB, prefer = "qwen2.5-7b" ); developer = await models.load(selected);
spec = freeze(Calculator.spec); candidate = checkout("calculator"); feedback = none;
while (!accepted(candidate, spec)) { candidate = await developer.revise(candidate, spec, feedback, file = "calculator.js", format = "source", instruction = "Write a global calculate(a,b,operation) function with numeric + - * / and throw Error on division by zero. Then wire #calculate click: convert #a.value and #b.value using Number, call calculate, display numeric answer in #result.textContent; catch errors and display Error. Wire #clear click to empty both input values and result text. Do not name a button variable calculate because that would shadow the function. No other behavior is needed.");
candidate = await developer.revise(candidate, spec, feedback, file = "index.html", format = "source", instruction = "Write complete HTML with title Calculator. Head links style.css using link rel=stylesheet. Body has label/input type=number id=a, label/input type=number id=b, labeled select id=operation with option values + - * /, button id=calculate, button id=clear, output id=result. End body with exactly one script src=calculator.js. No inline JavaScript, no other scripts. Do not omit the second input or any label.");
candidate = await developer.revise(candidate, spec, feedback, file = "style.css", format = "source", instruction = "Write only a tiny dark CSS stylesheet: dark body background, light text, centered main content, spaced labeled inputs, select, buttons and visible result. Use at most 12 rules. No JavaScript, no HTML, no imports, no url resources. Stop after the last closing brace.");
evidence = await evaluate(candidate, spec, keep = "best"); verdict = verify(spec, evidence); checkpoint(candidate, evidence, verdict);
if (verdict.status == Pass) { return accept(candidate, evidence); } if (verdict.status == Unknown) { return needs_review(evidence); }
feedback = verdict.violations; }
return unresolved();}3. Run it
Section titled “3. Run it”- Install or import a suitable GGUF model through Models. This flow does not download models.
- Open Synthesis, select the project workspace, and refresh the module list.
- Select Calculator, resolve any diagnostics, and choose Run synthesis.
- Follow Agent Activity, inspect the gate results, and review Changes.
- If accepted, choose Apply verified patch to write the files into
your-project/calculator/.
max_size limits the GGUF file size, not parameter count, RAM, or VRAM. prefer is a preference, not a requirement: the runtime can choose another eligible installed model. See model discovery and selection for strict selection.
In a recorded run of the same focused tasks, a 7B model passed and 0.6B and 1.5B models did not. A syntactically valid flow does not guarantee model success.
Writing a module with a coding agent, and checking it offline
Section titled “Writing a module with a coding agent, and checking it offline”lc-synthesis is a skill for coding agents that read the Agent Skills format
(Claude Code and others): download lc-synthesis-skill.zip
from the latest release (or copy the folder from this repository) into the agent’s skills folder (for Claude Code,
~/.claude/skills/ or the project’s .claude/skills/) and ask it for a module. It holds a condensed language reference, every diagnostic code
with its fix, complete examples in TypeScript, Python and C++, and scripts/check.mjs, the offline check below in one
file that needs only Node.js 18 or newer.
The check reads a module from disk and reports what the module screen would: the compiler’s diagnostics, the runtime’s limits, the module’s name, missing test files and untested clauses. It does not know this computer’s providers, consent or sandbox.
node skills/lc-synthesis/scripts/check.mjs Synthesis/RateLimiter # a module's folder, a .lcspec or a projectlocal-cognitive-server synthesis check Synthesis/RateLimiter --json # the same on a server (no sudo)Each problem is a line path:line:column severity CODE message, then one line a module (RateLimiter: ok). It exits
0 when no module has an error, 1 when one has.
Numbered clauses. Write the description as clauses, [C1] ... [C2] ..., and name each in the test that checks it
(test("[C3] refuses a fractional request", ...); in Python a docstring, in C++ a comment above LC_TEST), or mark the
gate that checks it with a comment, hard clock = Forbid(...); // [C7]. The check then warns about a clause nothing
checks (SPEC_CLAUSE_UNTESTED) and a test that names a clause the description does not number
(SPEC_CLAUSE_UNKNOWN). A clause no test checks is one a run can accept code that ignores: in a study of small local
models, most accepted candidates passed every visible test and still broke a clause the tests did not cover. The
rate limiter template is written this way.
Describing a module to a model in the app. Synthesis → New module → Describe it to a model: say what the module
must do, its language, the folder for its code and the model that writes the draft. The model writes the contract in
numbered clauses and a test for each, taught with the same reference and examples as the skill; the app derives the
flow and checks the draft, sending problems back to the model up to four times. The draft opens where a module would,
marked Draft, and nothing is written to the project until you press Save module. Draft with the strongest model you
have: a cloud model when the project allows cloud models, otherwise the largest installed one. Small models write
contracts that pass the check but get expected values wrong (a 9B model wrote that 3,910 seconds is 1h30m10s): read
every expected value against its clause before saving, since a wrong one is a test no correct code passes.
Basic syntax
Section titled “Basic syntax”Names, strings, comments, and punctuation
Section titled “Names, strings, comments, and punctuation”- Syntax is case-sensitive:
Passandpassare different names. - General identifiers use ASCII letters, digits, and underscores, and cannot start with a digit. The application’s module naming rule is slightly stricter: no leading underscore.
- Statements and property assignments end with
;. - Blocks use
{ ... }.ifandwhilealways require both parentheses and braces. - Strings use either double or single quotes. Double quotes are used throughout this guide.
- Strings must stay on one source line. Use
\nfor an embedded newline. Escapes include\r,\t,\b,\f,\\,\",\',\/, and\uXXXX. - Comments use
//or/* ... */. Block comments do not nest. - There are no template strings, string interpolation, or multiline string literals.
// A line comment./* A block comment. */message = "First line\nSecond line";label = "Calculator" + " UI";Values and units
Section titled “Values and units”| Kind | Examples |
|---|---|
| String | "calculator.js", 'llamacpp' |
| Number | 0, 42, 0.25, 1e3, -2 |
| Boolean | true, false |
| No value | none or null |
| Array | ["src/api.js", "README.md"] |
| Duration | 250ms, 30s, 15m, 2h |
| Byte size | 128B, 64KiB, 512MiB, 6GiB |
| Cost | 0usd, 2.5usd |
Units attach directly to numbers: 15m, not 15 m. GB, MB, min, and USD are not recognized units. Duration and size values are normalized internally to milliseconds and bytes. The compiler distinguishes numbers, durations, byte sizes, and costs; it is not a general dimensional-analysis system.
Arrays (lists) can be passed to actions and expose .length. list[0] is the first element; an index is a whole number, and one outside the list is a runtime error. A list’s elements share one type: ["a", "b"] is a list of strings, and [] is an empty list whose element type the first append decides. Lists are values, never changed in place: append(list, item) returns a new list with item at its end, and range(n) the numbers 0 to n - 1 (at most 10,000). There are no object literals or destructuring. Runtime records expose only documented fields.
names = [];for (i in range(3)) { names = append(names, "agent");}first = names[0];Expressions and precedence
Section titled “Expressions and precedence”Operators, from highest precedence to lowest:
| Level | Operators |
|---|---|
| Member access and calls | selected.id, verify(spec, evidence) |
| Unary / await | !, unary -, unary +, await |
| Multiplication | *, /, % |
| Addition | +, - |
| Ordered comparison | <, <=, >, >= |
| Equality | ==, != |
| Logical AND | && |
| Logical OR | || |
Parentheses override precedence. Binary operators associate left to right within a level. && and || short-circuit and require booleans. Equality does not coerce types. + also concatenates two strings; it does not automatically convert numbers into strings.
attempt = 1;attempt = attempt + 1;retry = attempt < 4 && !(attempt == 0);delay = 500ms + 1s;double_delay = delay * 2;Use matching quantity types for addition and comparisons. Quantities may be multiplied or divided by a plain number on the right. V1 does not derive new unit dimensions; do not use it for physical-unit algebra.
LC Spec reference
Section titled “LC Spec reference”Module header
Section titled “Module header”The header is module Name version "version-string" { ... }. system is accepted as an alias for module.
The version must be a nonempty string. It is authored metadata, not a package resolver or automatic migration mechanism.
target
Section titled “target”The application accepts language = JavaScript; (aliases Javascript, JS), TypeScript (TS), Python and Cpp. The language tells the model what it writes; each test file’s extension decides how it runs. Omitting target is also allowed.
Target fields use scalar values or bare identifiers, not expressions, arrays, or unit quantities. Other targets, such as engine = UnrealEngine;, require an adapter and are rejected by the current compiler configuration.
description
Section titled “description”Use description = "..."; for the module’s requirements and public behavior. Describe observable results, input/output conventions, and failure cases clearly.
This field is natural-language model context, not a proof system. A requirement is only independently checked when a trusted evaluator implements it.
artifacts
Section titled “artifacts”Declare each file the model writes with file "relative/path.ext"; inside artifacts { ... }, and each file the engineer wrote, such as an interface the model must implement, with frozen "relative/path.ext";. Paths are relative to the flow’s checkout(...) directory, not to the Synthesis directory.
For example, file "calculator.js"; combined with checkout("calculator") produces <project>/calculator/calculator.js after Apply.
A frozen file must exist in the checkout folder when the run checks it out. The model reads its full text in every revision and may not change it: revise refuses it, and Apply leaves it as it is.
artifacts { frozen "include/AbilitySystem.h"; // the engineer's interface file "src/AbilitySystem.cpp"; // the model's implementation}A files "notes/**"; line declares an area: a pattern (relative to the checkout folder) where models and agents may create files whose names the contract does not fix, such as one note per agent. Area files are part of the candidate (gates check them, Apply writes them) but none is required. A contract declares at least one file or one area.
The runtime allows 1–12 files the model writes (or none with an area), up to 12 areas and up to 12 frozen files, with lowercase extensions: .js, .mjs, .cjs, .ts, .mts, .cts, .py, .c, .cc, .cpp, .cxx, .h, .hh, .hpp, .hxx, .inl, .json, .html, .css, .txt and .md. Files cannot be added outside this list by a model. Paths must also satisfy the project path restrictions. These limits, and the flow’s iteration and time limits, are reported as diagnostics when the module is listed or refreshed (SPEC_ARTIFACT_LIMIT, SPEC_ARTIFACT_TYPE, SPEC_ARTIFACT_PATH, FLOW_LIMIT_RANGE), so a module that Run would refuse is never shown as valid.
Every declared file is part of the contract: a candidate missing one, or with an empty one, fails an implicit hard gate named artifacts even when every declared gate passes. A run cannot be accepted with part of its files.
A candidate with TypeScript files (.ts, .mts, .cts) is also type-checked by an implicit soft gate named types (typescript when the contract has a gate called types), listed before the first Tests gate. Nothing runs and nothing is written: the compiler reads the candidate’s files, the frozen files and the visible tests (never hidden ones), as the tests run them (ES modules, local imports with their .ts extension, a type imported with import type, erasable syntax only), with TypeScript’s own library declarations and nothing from node_modules. Its findings are feedback items such as src/router.ts:8: 'Pattern' cannot be used as a value because it was imported using 'import type'. (TS1361) or, for a test’s call, tests/rateLimiter.test.ts:20: Expected 1 arguments, but got 0. (An argument for 'tokens' was not provided: src/rateLimiter.ts:23) (TS2554): at most six, those that fail when the code runs first. Being soft, it never decides acceptance, and keep = "best" never counts it. Errors about what it cannot see (Node’s own modules and globals, packages) are left out; more than 512 KiB of TypeScript is not checked (Unknown).
evaluate
Section titled “evaluate”There must be exactly one acceptance group. Its name must match using "..." in the flow. At least one gate must be hard.
Gate syntax:
hard gate_name = Pass("registered-evaluator-id");hard gate_name = Tests("tests/a.test.ts", timeout = 30s);hard gate_name = Exports("src/a.ts", ["Name"]);hard gate_name = Imports("src/**", allow = ["src/**"], deny = ["node:*"]);hard gate_name = Forbid("src/**", "Date\\.now", message = "take the time from options.now()");hard gate_name = Grounded("REPORT.md", min = 5);soft gate_name = Tests("tests/holdout.test.ts", hidden = true);gate_nameis an identifier used in diagnostics and evidence; gate names must be unique.Pass(...)declares a required result of a registered evaluator. It is not a function you implement in the flow.Tests,Exports,ImportsandForbidare the built-in contract checks: see Contracts on rails. They work in any acceptance group; the examples use"contract-v1".hardgates determine acceptance. Any hard Fail produces Fail; otherwise any hard Unknown produces Unknown; otherwise the verdict is Pass.softgates are evaluated and reported but do not prevent acceptance, including when they return Fail or Unknown. Their non-Pass messages still appear inverdict.violations.
The built-in acceptance group is "calculator-v1", with these evaluator IDs:
| ID | What it checks |
|---|---|
"calculator-arithmetic-v1" |
The global calculate(a, b, operation) function, arithmetic cases, and division-by-zero behavior. |
"calculator-ui-v1" |
Required HTML controls, labels and resources, script placement, and interactions in a bounded semantic DOM harness. |
These checks are provided by the application, not generated by the developer model. The UI harness is not a full browser or visual-quality test. For a Pass(...) gate, a different group name or an unregistered evaluator ID returns Unknown at runtime (and the module shows a SPEC_EVALUATOR_UNREGISTERED warning); changing a string does not install a new evaluator.
environment, workload, and soft minimize Mean(...) from the research examples are not executable V1 features.
The engineer’s test files live next to the contract, by path relative to the .lcspec folder, and the model never writes them. A Tests(...) gate names the files it runs; declare files the tests only use, such as fixtures or shared helpers, in a tests section:
tests { file "tests/helpers.ts";}A run reads every test file when it starts and keeps that copy: editing them during a run changes nothing, and a restart uses the same copy. A module whose test file is missing shows SPEC_TEST_MISSING. At most 24 test files, 512 KiB together.
When tests run, the module’s files (artifacts and frozen files, at their paths under the checkout folder) and the test files (at their paths under the contract’s folder) share one folder. A test imports the module by relative path: tests/rateLimiter.test.ts imports ../src/rateLimiter.ts. A path may appear only once across artifacts, frozen files and test files (SPEC_PATH_CONFLICT).
Contracts on rails: tests and architecture gates
Section titled “Contracts on rails: tests and architecture gates”A small local model writes better code when the contract leaves it little room: an interface it may not change, tests it must pass, and rules about what its code may use. These gates turn the engineer’s architecture into checks, and every failure goes back to the model as an exact item.
module RateLimiter version "1" { target { language = TypeScript; } description = "A token-bucket rate limiter...";
artifacts { file "src/rateLimiter.ts"; } tests { file "tests/rateLimiter.test.ts"; }
evaluate "contract-v1" { hard shape = Exports("src/rateLimiter.ts", ["RateLimiter"]); hard dependencies = Imports("src/**", deny = ["**"]); hard clock = Forbid("src/**", "Date\\.now|setTimeout", message = "take the time only from options.now()"); hard behavior = Tests("tests/rateLimiter.test.ts", timeout = 30s); }}New module → Rate limiter (TypeScript, with tests) creates this contract, its flow and its tests. The same idea works in C++: an ability system core against a frozen header.
Tests: the engineer’s tests
Section titled “Tests: the engineer’s tests”Tests("file" [, more files] [, timeout = 30s] [, hidden = true]) runs the engineer’s tests against the candidate. One gate runs files of one language, chosen by extension:
| Files | How they run |
|---|---|
.ts, .mts, .js, .mjs, .cjs |
node --test. TypeScript runs on Node.js 22.18 or newer with erasable type syntax only (no enum, namespace or parameter properties), so local imports name the .ts file. The server brings its own Node.js; the desktop app uses the one installed on the computer. |
.py |
Python 3 unittest. The folder that holds the module and the tests is on sys.path: from src.rate_limiter import RateLimiter. |
.cpp, .cc, .cxx |
Built with every C and C++ source of the module (artifacts and frozen) as C++20 with -fsanitize=address,undefined, then run. Tests include lc_test.hpp, a small framework the runtime provides: LC_TEST(name), LC_CHECK(expr), LC_CHECK_EQ(actual, expected), LC_CHECK_NEAR(actual, expected, eps) and LC_CHECK_THROWS(expr). Each folder holding a header is on the include path. |
The gate passes when at least one test ran and every test passed. It fails on a failed test, a build error, a crash or a timeout. It is Unknown when this computer has no sandbox or no toolchain for the language. The timeout (1–120 s, 30 s by default) covers running the tests; a C++ build has 90 s of its own.
hidden = true seals the tests: the model never sees them, and its feedback says only how many failed. Use it for a holdout set beside visible tests.
Tests that a model proposes (propose_tests) are never run: only the engineer’s tests decide.
The sandbox
Section titled “The sandbox”Every test run is sandboxed: no network, writes only inside its own temporary folder, and nothing read from the user’s home folder, other temporary folders or the app’s data (not even whether a file there exists). On macOS this is the built-in sandbox-exec; on Linux, bubblewrap (bwrap, which needs user namespaces). The server installer sets bubblewrap up from 0.1.3; on a server installed earlier, run sudo local-cognitive-server sandbox once after updating. On Windows it is a regular AppContainer with no capabilities (so no loopback, LAN, internet or DNS) inside a kill-on-close Job object, running the app’s own bundled Node; each run gets a container of its own, so concurrent runs cannot reach each other’s folder or named objects. There Tests run for JavaScript and TypeScript, Python only where the sandbox can read it (installed under Program Files, otherwise the gate is Unknown), and C++ tests are Unknown. The terminal is more limited on Windows (see below).
Inside the sandbox there are no system services, Apple Events or signals to other processes on macOS, and on Linux no capabilities and, with bubblewrap 0.8 or later, no user namespaces of its own, so the code under test cannot ask another program to act for it.
Before anything runs, the runtime also checks the module’s files:
- They import only files of the module, packages and system headers: no absolute paths, nothing outside its folder.
- They leave the test harness alone. The tests run in the same process as the code they test, so the module may not import
assert,node:test,unittestorlc_test.hpp, end the process (process.exit,os._exit,exit()), define its ownmain()in C++, or read the environment variable that signs the results.
Each result line the test harness prints is signed with a token made for that run, so text the code under test prints cannot pass for a result. Together these stop the plain ways to fake a pass, not every possible one: code written on purpose to defeat its tests from inside their process could still do it. Read an accepted candidate’s diff before Apply.
Exports: the public shape
Section titled “Exports: the public shape”Exports("file", ["Name", ...]) passes when the file declares or exports each name:
- TypeScript and JavaScript:
exportdeclarations andexport { … }, or simple CommonJSexports.Name. - Python: top-level
def,classor assignments. - C++: classes, structs, enums, namespaces, type aliases and functions.
Owner::methodpasses when the module defines it.
Imports: what may depend on what
Section titled “Imports: what may depend on what”Imports("pattern", allow = [...], deny = [...]) checks every import of every file the model wrote that matches the pattern: import and require, Python import and from, C++ #include. An import fails when it matches a deny pattern, or, with an allow list, when it matches none of it.
Relative imports are matched as module paths (./math in src/core/a.ts is src/core/math); others as written: node:fs, os, <thread>. In patterns, ** matches any path and * any characters except /, so node:* covers Node.js built-ins and <*> standard C++ headers. A pattern that matches no file fails, because it is most likely a typo.
Forbid: what the code may not use
Section titled “Forbid: what the code may not use”Forbid("pattern", "regular expression" [, message = "..."]) fails where the expression (JavaScript syntax) matches a file the model wrote, outside comments and strings. In a contract string a backslash is written twice: "Date\\.now".
Imports and Forbid check only the files the model wrote: frozen files and tests are the engineer’s.
Grounded: references that hold
Section titled “Grounded: references that hold”Grounded("REPORT.md" [, min = N]) reads a candidate file (an artifact or an area file) and checks every path it cites, such as src/core/loop.ts or src/core/loop.ts:42 or src/core/loop.ts:40-48: the file must exist in the project as Apply would leave it (the candidate’s own files included), and a cited line or range must be within the file. It passes when every reference holds and at least min files (1 by default) are cited. A bare name without a folder (Node.js, README.md) and a URL are not references. What fails goes back to the model as exact items: REPORT.md:14 cites src/a.ts:300, but src/a.ts has 120 lines.
This is what makes a report of parallel agents acceptable evidence: its claims point at real code. It does not check that a claim about the code is true; read the report.
Feedback
Section titled “Feedback”What each failed gate found goes back to the model in the next revision as a numbered list of short, exact items, in verdict.violations (at most 12):
1. behavior: refills with the time that passed: Expected values to be strictly equal: 0 !== 2 (expected 2, actual 0) [tests/rateLimiter.test.ts:26]2. clock: src/rateLimiter.ts:12 uses "Date.now": take the time only from options.now()The model also reads the frozen files and the visible tests in every revision.
LC Flow reference
Section titled “LC Flow reference”Header, policy, and limits
Section titled “Header, policy, and limits”The header is implement Name using "acceptance-group" { ... }. Both names must match the contract.
Every flow must declare exactly one top-level policy assignment and one top-level budget declaration:
limit iterations 6, time 15m, cost 0usd;policy = "local-files-v1";iterations and time are required; cost is optional. Put these declarations first for readability.
iterationsmust be a positive integer, at most 32 in the application. It counts all entries into allwhilebodies across the run, including nested loops. It does not count model calls.timemust be a positive duration, at most120m. It covers the whole executing flow, including model loading.costmust be a nonnegative USD quantity. It is recorded, not yet enforced: a run counts the tokens of every call (shown with the run), but no price table stops a cloud run. Do not rely on it as a spending limit.stepsis optional: the interpreter steps (statements and expressions evaluated) the run may take, 10,000 by default and at most 1,000,000. A longforloop needs more:limit iterations 4, time 30m, steps 50000;.
Exhausting a budget ends the run as Unresolved. It does not jump to code after the loop. To return earlier, use a condition or return unresolved(); inside the body.
The policy says what the run may use:
| Policy | Models | Also |
|---|---|---|
local-files-v1 |
Installed built-in llama.cpp models only. | — |
cloud-files-v1 |
Local models and any provider set up in Settings → Models & Providers (OpenAI, Claude, Gemini, Qwen, DeepSeek, OpenRouter, Groq, Perplexity, LM Studio, Ollama…). | — |
agents-v1 |
As cloud-files-v1. |
Agents with file tools, run in parallel: see Agents. |
Every policy confines project reads and writes only declared candidate artifacts until Apply. None grants downloads, network tools, arbitrary filesystem access or commands on the computer itself: under agents-v1, an agent given terminal(...) runs a few programs in a sandbox, in a copy of what it may read.
A cloud model receives the contract’s description, frozen files, visible tests, the candidate’s files and whatever inspect(...) read. Hidden tests never leave the computer. So a flow names each provider as a string (provider = "deepseek", never a variable), and a cloud provider runs only in a project that allows cloud models: the Cloud models switch at the bottom of the Synthesis workspace, which only the computer that owns the project can set. On a server its owner sets it with sudo local-cognitive-server cloud-models allow <project>; a paired device only shows it. The module lists what Run would refuse: SYNTHESIS_PROVIDER for a provider that is not set up here or has no key, SYNTHESIS_CLOUD_CONSENT for a cloud provider in a project that does not allow it, SYNTHESIS_SANDBOX for an agent’s terminal(...) that names a command its platform’s sandbox does not run (on Windows a terminal runs only node, npm and npx).
Variables and control flow
Section titled “Variables and control flow”Assignment creates or updates a variable. There is no let, var, const, or explicit type annotation.
counter = 0;
while (counter < 3) { counter = counter + 1; if (counter == 1) { continue; } else if (counter == 2) { checkpoint(candidate); } else { return unresolved(); }}Variables must be assigned before use on every control-flow path. Initialize values such as feedback = none; before a loop when needed. Do not depend on a variable created only inside a loop being available after it. Reassignments normally retain the variable’s inferred type; none can be used as an initial placeholder.
for (item in list) { ... } runs its body once for each element of a list, in order. item is a new name that exists only inside the loop. Because a list is finite, a for loop always ends: it does not count toward iterations (each element still costs interpreter steps).
continue; skips the remainder of the innermost loop iteration (while or for). There is no break, switch, try/catch, user-defined function, import, or recursion.
Calls and await
Section titled “Calls and await”Call arguments can be positional or named. Named arguments use =, not :. Positional arguments must precede named ones. Repeated or unknown named arguments are errors. Trailing commas are accepted in calls and arrays.
selected = models.select(available, max_size = 6GiB, prefer = "qwen2.5");developer = await models.load(selected);await is required for models.list, models.load, evaluate, and every model role method. model("exact-name") also loads a model, but its current compiler signature allows omission of await; using await model(...) is valid and clearer.
Statements execute in order: await starts nothing in the background, and there are no parallel blocks. Work runs in parallel only in parallel_map, which runs agents (see Agents). Call model methods through a variable such as developer.revise(...), not a chained expression such as models.load(selected).revise(...).
Exposed fields
Section titled “Exposed fields”| Value | Readable fields |
|---|---|
| Module name | Calculator.spec |
| Selected model | .id, .displayName, .providerId, .sizeBytes |
| Model list or ordinary array | .length |
| Candidate | .id, .path, .hash |
| Evidence | .status |
| Verdict | .status, .violations |
| Review | .notes, .violations |
These are read-only from DSL: candidate.path = "..."; is not valid. Evidence contains more detail in the UI/API, but arbitrary evidence fields are not accessible in the language. Treat candidate, evidence, frozen spec, and model roles as runtime handles, not objects you can construct yourself.
Status constants include Pass, Fail, Unknown, Blocked, Unresolved, and NeedsReview. The current evaluator returns only the first three. Keep evaluator verdicts separate from overall run outcomes.
Runtime functions
Section titled “Runtime functions”In signatures below, [argument] means an optional positional argument. The brackets are documentation notation, not syntax to paste into a call.
Model discovery and selection
Section titled “Model discovery and selection”| Function | Meaning |
|---|---|
await models.list(provider = "llamacpp") |
Return installed local models, or with another provider (cloud-files-v1) the models that provider lists. provider defaults to "llamacpp". Each call returns its own list. |
models.select(available, max_size = 6GiB, prefer = "qwen2.5-7b", provider = "llamacpp", id = "exact-id") |
Select a model from the returned list. All named arguments are optional. id must match exactly. max_size compares GGUF file sizes, so it is an error for a list of cloud models. |
await models.load(selected [, slots = 6, context = 16384]) |
Load the selected model and return a model role handle. A cloud model needs no loading. slots (1–16) is how many requests the local model answers at once, each with context tokens: what local agents running in parallel need. The model keeps that shape until it is loaded with another. |
await model("exact-id", provider = "deepseek") |
A specific model: an installed local one by ID or display name, or with another provider that provider’s model ID. Returns a role handle. |
Local and cloud roles mix in one flow:
policy = "cloud-files-v1";developer = await model("deepseek-flash", provider = "deepseek");local = await models.list(provider = "llamacpp");reviewer = await models.load(models.select(local, max_size = 6GiB, prefer = "qwen2.5-7b"));Selection works as follows:
- Keep eligible models from the supplied runtime list.
- If
max_sizeis provided, require a known positive GGUF size no larger than the limit. - Prefer a case-insensitive substring match in the model ID or display name.
- Then prefer a file of more than about 3 bits a weight to a low-bit one (
IQ1_*,IQ2_*,Q2_K,TQ1_0and the like), then the larger file, so the most capable model the limit allows wins; then the model ID.
When the selected model is a low-bit file, the run’s log shows a warning: such a file keeps little of the model’s quality, and code it writes is much weaker. In Models, Q4_K_M is the variant offered first whenever it fits with room.
No eligible model is a runtime error, not none. Without a size limit, a model with unknown size can remain eligible. To require a specific model, use its exact ID with model(...) or id = ...; do not rely on prefer as an exact match. There is no download, and a local flow never falls back to a cloud model.
Contract and workspace
Section titled “Contract and workspace”| Function | Meaning |
|---|---|
freeze(Calculator.spec) |
Return the current run’s frozen contract handle. Runs already snapshot both authored source files at launch. |
checkout("calculator") |
Create the run’s candidate from the current declared files under this project-relative output directory. Only one checkout is allowed per run. |
inspect(["README.md", "src/api.js"]) |
Read up to 12 explicit project-relative text files as context. No directory traversal, globs, or recursive directory scan. Each file is limited to 24,000 bytes. |
checkout is not Git checkout and does not create a branch or modify project files. Candidate revisions are stored separately until the user applies them. Existing declared output files become the baseline; absent files begin empty.
Evaluation and lifecycle
Section titled “Evaluation and lifecycle”| Function | Meaning |
|---|---|
await evaluate(candidate, spec [, tests]) |
Run the contract’s gates (registered evaluators and the built-in checks: Tests, Exports, Imports, Forbid) and return evidence. supplemental = tests is an alternative named argument. Tests a model proposes are not executed: only the engineer’s tests run. |
await evaluate(candidate, spec, keep = "best") |
The same, and a candidate worse than the best one this run has evaluated is set aside: the candidate goes back to the best one, and its evidence is returned (the activity says which iteration’s it kept). Better means more of the contract’s required gates passed, then more visible tests passed; hidden gates never count, so the holdout is not spent on choosing. A tie goes to the newer candidate. The templates use it: an iteration never loses what an earlier one had. |
verify(spec, evidence) |
Validate evidence freshness and return {status, violations} as a runtime record. Stale evidence is a runtime error. |
accepted(candidate, spec) |
Read acceptance state; this does not evaluate the candidate. In the usual repair loop, successful termination happens through return accept(...). |
checkpoint(value [, ...]) |
Save the current run record and candidate snapshot. Takes 1–8 values. V1 does not separately serialize each argument as an arbitrary user checkpoint variable. |
merge(value [, ...]) |
Combine 1–8 feedback values, flattening arrays one level and removing none values. |
stagnant(count) |
True when the last count evaluations have identical gate IDs, statuses, and messages, and the latest result is not Pass. Use a positive integer. This is not a code-quality or semantic-progress metric. |
Terminal actions
Section titled “Terminal actions”Terminal actions must be returned directly:
if (verdict.status == Pass) { return accept(candidate, evidence);}if (verdict.status == Unknown) { return needs_review(evidence);}return unresolved();accept(candidate, evidence)requires fresh trusted Pass evidence for the current candidate and a compiler-recognized Pass guard.needs_review(evidence)requires fresh evidence and ends the run for human review. It does not automatically send a message to another agent or create a task.unresolved()ends without acceptance. An optional string argument is accepted syntactically, but V1 does not persist it as a reason; do not rely on it for reporting.
Use the explicit pattern if (verdict.status == Pass) { return accept(...); }, where verdict came from verify. The compiler also recognizes the reversed comparison and a Pass comparison inside &&; it does not prove equivalent arbitrary boolean expressions. Runtime freshness checks still apply even after the static guard check.
result = accept(...);, bare accept(...);, return true;, and return; are invalid. Falling off the end of a valid flow yields Unresolved; an explicit terminal return is clearer.
Model role methods
Section titled “Model role methods”A role is a variable holding a loaded model. Names such as architect, developer, tester, and reviewer are conventions, not special keywords or separately configured model aliases.
revise: generate candidate files
Section titled “revise: generate candidate files”Typical signatures:
await developer.revise(candidate, spec)await developer.revise(candidate, spec, feedback)await developer.revise(candidate, spec, design, feedback)All return the candidate handle. Optional named arguments:
| Argument | Meaning |
|---|---|
file = "calculator.js" |
Revise only this declared artifact. Without file, visit all declared artifacts in declaration order, one generation request per file. |
format = "source" |
Request raw complete file source, optionally enclosed in one complete code fence. |
format = "json" |
Default model-response format: an object with a content string. This is an internal output protocol, not the authored DSL format. |
instruction = "..." |
A focused file task, at most 6,000 characters. |
Revisions replace the whole selected file in the candidate; they are not patches. An invalid generation leaves that file’s previous candidate content unchanged and adds feedback. Every revision invalidates earlier acceptance evidence, so evaluate again before accepting.
When instruction is supplied and nonempty, it replaces the full description and peer-file excerpts in that generation prompt. The model still receives the current file and bounded feedback. Include the relevant interface and integration requirements in the focused instruction. Trusted evaluation still uses the whole contract’s registered gates.
revise uses bounded prompts and responses: one request per file, with no tools. For models that read, search and change files themselves, see Agents. Generation settings such as token limit and temperature are currently runtime-controlled, not DSL arguments.
What the model reads for a file: the contract (or the focused instruction), the frozen files, the visible tests, the module’s other files as they are now (each as code), the result of the last check and the file as it is now. The result groups the feedback into problems in this file (or in tests that use it) and the rest, with the line each item cites, the assertion that failed and the failing test’s source, and how many visible tests and required checks passed; it takes at most 4,500 characters, as the feedback did before.
A small model that cannot tell what to change copies the file it is shown. When a file comes back byte for byte as it was while the feedback points into it (an item names it, or a failed visible test uses it), revise asks once more about the first failure in that file only: a local model whose chat template thinks first (Qwen3, Nemotron and the like) thinks first, up to 1,024 tokens; any other model answers with SEARCH/REPLACE edits, and with the whole file if the edits do not apply. The activity says so. An answer that is no better is still the model’s, and evaluate(..., keep = "best") keeps the run from losing ground.
Every request has a seed derived from the run’s seed (drawn when the run starts; a restart after an interruption keeps it, any other restart draws a new one so it is not the same attempt again), the iteration, the file and the request, and each one is recorded in the activity with its sampling, thinking budget, a hash of its prompt, its tokens, how it finished and how long it took. With the same seed, model and runtime, a local run repeats as it ran. When a thinking budget runs out, the app’s llama.cpp is told to end the thinking with a line that says to write the file now.
Advisory methods
Section titled “Advisory methods”| Method | Result and purpose |
|---|---|
await architect.propose(spec [, context]) |
A textual design proposal. |
await architect.reconsider(spec, design [, evidence [, feedback]]) |
A revised textual design. |
await tester.propose_tests(spec [, candidate]) |
Textual test suggestions, not executable trusted tests. |
await reviewer.inspect(candidate, design [, evidence]) |
A review record with .notes and .violations. Currently the response is placed in notes and violations is empty. |
Advisory calls receive bounded context and candidate excerpts. They do not modify the candidate or grant acceptance. Different variable names do not ensure model independence: to use a different reviewer model, load a different installed model explicitly.
Multiple roles and a repair loop
Section titled “Multiple roles and a repair loop”This alternative complete flow works with the quick-start Calculator.lcspec. It demonstrates advisory roles and stagnation handling, not a stronger success guarantee. It uses one model for all roles and the default JSON response protocol for revision; the focused source-format quick start is the tested 7B path.
implement Calculator using "calculator-v1" { limit iterations 6, time 15m, cost 0usd; policy = "local-files-v1";
available = await models.list(provider = "llamacpp"); selected = models.select(available, max_size = 6GiB, prefer = "qwen2.5-7b"); developer = await models.load(selected); architect = developer; tester = developer; reviewer = developer;
spec = freeze(Calculator.spec); candidate = checkout("calculator"); context = inspect([]); feedback = none; design = await architect.propose(spec, context);
while (!accepted(candidate, spec)) { candidate = await developer.revise(candidate, spec, design, feedback); tests = await tester.propose_tests(spec, candidate);
// Test suggestions are advisory. Registered evaluators decide. evidence = await evaluate(candidate, spec, supplemental = tests); review = await reviewer.inspect(candidate, design, evidence); verdict = verify(spec, evidence); checkpoint(candidate, evidence, verdict);
if (verdict.status == Pass) { return accept(candidate, evidence); } if (verdict.status == Unknown) { return needs_review(evidence); }
feedback = merge(verdict.violations, review.notes); if (stagnant(3)) { design = await architect.reconsider(spec, design, evidence, feedback); } }
return unresolved();}Replace inspect([]) with specific project files if context is needed. Use a loaded role variable for each model; there is no per-role configuration block. To run many models at once, see Agents.
Agents
Section titled “Agents”With policy = "agents-v1" a flow makes agents and runs them in parallel. An agent is a model with file rights; it works in its own loop of tool calls (read, search, write) until it returns an answer. Rights are set in the flow by path patterns relative to the project. To start from a working module, choose New module → Repository review (parallel agents): four agents on one local model review src/, and a lead writes the report.
Twenty cloud agents review a folder, each leaving a note, and a lead writes a report that must cite real code:
implement RepoReview using "contract-v1" { limit iterations 4, time 40m, steps 20000; policy = "agents-v1";
lead = await model("deepseek-flash", provider = "deepseek"); spec = freeze(RepoReview.spec); candidate = checkout("review");
tasks = await lead.split("Review error handling in src/: one part per agent.", 20, paths = files.read("src/**"));
agents = []; for (i in range(20)) { agents = append(agents, agent(provider = "deepseek", model = "deepseek-flash", tools = [files.read("src/**"), files.write("review/notes/**")], instructions = "Write your findings to one note in review/notes/, each item with path:line.", steps = 16)); }
results = await parallel_map(agents, tasks, concurrency = 20); candidate = await lead.synthesize(candidate, spec, results, file = "REPORT.md");
// The report is checked, and written again with the exact problems until it holds. while (!accepted(candidate, spec)) { evidence = await evaluate(candidate, spec); verdict = verify(spec, evidence); if (verdict.status == Pass) { return accept(candidate, evidence); } if (verdict.status == Unknown) { return needs_review(evidence); } candidate = await lead.synthesize(candidate, spec, results, file = "REPORT.md", feedback = verdict.violations); } return unresolved();}with a contract whose candidate has the report and an area for the notes:
artifacts { file "REPORT.md"; files "notes/**";}evaluate "contract-v1" { hard grounded = Grounded("REPORT.md", min = 5);}| Call | Meaning |
|---|---|
files.read("src/**", ...), files.write(...), files.delete(...) |
Rights: 1–12 project-relative patterns (* within a folder, ** across folders). Reading gives file.list, file.search and file.read; writing file.write, file.replace and file.append; deleting file.delete. |
agent(provider = "deepseek", model = "deepseek-flash", tools = [...], instructions = "...", steps = 16) |
An agent: a description, not a process. agent(role, tools = [...]) uses a loaded role instead (a local model with slots, for example). steps (1–60, 16 by default) bounds its turns. |
terminal(allow = ["node", "npm"]) |
A terminal: the agent runs these commands (of node, npm, npx, python3, git, rg, ls, cat; all of them without allow) in a sandbox, in a copy of the files it may read with its current changes. See Agents’ terminal. |
http(allow = ["https://staging.example.com", "https://api.example.com/v1"]) |
A web request: the agent gets http.request {method,url,headers?,body?}, which the engine makes only to these origins, for authorized testing of the owner’s own services. See Agents reaching a web service. The project must allow the targets. |
files.write("notes/**", own = true) |
Writing, where each file belongs to the agent that first creates or changes it, for the rest of the parallel_map: the others read it and change nothing of it. |
await parallel_map(agents, tasks, concurrency = 8, on_error = "collect", checkout = "required", answer_file = "review/notes/agent-{n}.md") |
Runs every task (a list of texts) with an agent: task i with agent i, round the list (or one agent for all). At most concurrency (1–64) run at once. Results come back in task order. With answer_file, the answer of an agent that wrote no file itself is saved as that file (see below). |
await lead.split(goal, n [, context], paths = files.read(...), instruction = "...") |
A model splits a goal into n independent tasks; paths lists the files the agents can read (up to 400) for it. |
await lead.synthesize(candidate, spec, results, file = "REPORT.md", instruction = "...", feedback = verdict.violations) |
A model writes one candidate file from the results. Results too many for its prompt are merged in groups first. The file is kept under 2,500 words unless instruction asks for another length; an answer the model’s output limit cuts off is never used, and is asked for again once, half as long. With feedback, it writes the file again knowing exactly which checks the last one failed: the repair loop for a report. |
Each result has .ok, .output (the agent’s answer, at most 8,000 characters), .error, .task, .files (what it wrote) and .index; the list has .completed and .failed. With on_error = "collect" (the default) a failed agent is a result with ok == false; with "fail" the first failure stops the others and the run ends Blocked.
A run starts at most 1,000 agent tasks in all, and its candidate holds at most 300 files.
answer_file is for models that answer in text instead of writing their file, as small local models often do: a module whose tests count the agents’ notes would fail on them. When an agent finishes with an answer and wrote no file itself, its answer is saved as answer_file, with {n} its number (as in the Agents tab) and {call}, if given, which parallel_map of the run this is. The agent is told so before it answers. It is saved as that agent: inside its write rights and the candidate folder, a checkout taken when checkout = "required", never over another agent’s file or one this run already wrote, and over a file an earlier Apply left. An answer in one fenced block is saved as the block’s text. A save that is refused leaves the agent finished, with the reason on its row; a failed agent’s error is never saved. The file is in the agent’s .files, marked “its answer” in the Agents tab.
What agents may touch:
- They read only what their rights name, and never a contract or its tests (any
Synthesisfolder and the module’s own folder), whatever the patterns say. - They write only into the run’s candidate: inside the
checkoutfolder, and only its declared files and areas. The project changes only on Apply, which writes every file at once (deletions included) after checking that none changed meanwhile. - Every agent reads a project file as the run first read it (up to 256 MB a run), so an edit to the project during the run never gives two agents different versions;
Groundedchecks against the same. - When two agents change one file, the second finds the version changed, reads it again and redoes its change.
- An agent can check files out for its work, as in Perforce:
file.checkout {"paths": [...]}takes them all or none, including files it only reads. Until it submits (file.submit), reverts (file.revert) or finishes, the others read the last submitted version (its changes stay its own) and change nothing of them. A finished agent’s checkout is submitted, a failed one’s dropped (listed as reverted on its row). Withcheckout = "required", every change needs a checkout first. - Only an agent that holds nothing may wait for files (
waitSeconds, up to 600): one that holds files is refused at once, so two agents never wait on each other. - No agent uses plugins or MCP servers or asks for approval: a refusal is final, and it is told why. Only an agent given
terminal(...)runs commands, and only in its sandbox. - A cloud agent sends what it reads to its provider: the project must allow cloud models.
Local agents share one model through its slots: each slot answers one agent at a time, so give a model as many slots as agents should run at once (memory permitting; the load is refused with a reason when they do not fit).
installed = await models.list(provider = "llamacpp");qwen = await models.load(models.select(installed, prefer = "qwen3.5"), slots = 6, context = 16384);agents = [];for (i in range(6)) { agents = append(agents, agent(qwen, tools = [files.read("src/**"), files.write("review/notes/**")]));}results = await parallel_map(agents, tasks, concurrency = 6);Agents reaching a web service
Section titled “Agents reaching a web service”http(allow = [...]) gives an agent one tool, http.request {method, url, headers?, body?}, for authorized testing of the owner’s own web services — checking headers, authentication, how an endpoint answers malformed input, and the like. The engine makes the request, never code in a sandbox, and only within strict limits:
- An allowlist the owner declares. A request reaches only an origin the agent’s
http(allow = [...])names (a scheme, host and port, with an optional path prefix), and that origin must be one the project allows. On this computer the project’s allowlist is a setting; on a server its owner sets it withsudo local-cognitive-server web-targets allow <project> <url>…. The flow’s targets must be within the project’s, or Run is refused (SYNTHESIS_WEB_CONSENT). - No reaching in. The address a name resolves to is checked and pinned for the connection, so a name cannot answer with an allowed address and then a private one; this machine, private networks, link-local, carrier-NAT and cloud-metadata addresses are always refused. A redirect is followed only within the allowlist.
- Bounded. The response body is capped, each request times out, and the whole run has a budget of requests.
- No borrowed identity. The request carries none of the app’s own credentials. Put any token the service needs in
headersyourself; a header that holds a secret (Authorization,Cookie) is recorded on the run’s Agents tab asset, never its value, as are secret response headers.
An agent with only the http right (no write, delete or terminal) still acts, not just reads: it makes requests. Each request and its response status is a step on the Agents tab.
The terminal, through the same allowlist. An agent that has both http(allow = [...]) and terminal(...) may reach those same targets with a real tool from its sandbox (a request with python3, and the scanners a later release adds), not only through http.request. The sandbox’s one way to the network is a loopback proxy the engine runs, which enforces the very same allowlist, owner consent and run budget; everything else on the network stays denied, so a tool cannot reach this machine or a target off the list. A plain http:// request is checked in full (host, port and path); an https:// one is tunnelled by host and port (the proxy never decrypts it, so it cannot see the path). This works on macOS and on a Linux server. On Linux the sandbox keeps a network of its own with nothing in it but its own loopback: the proxy listens on a UNIX socket in a folder the sandbox sees read-only (it can connect to the socket, never replace it), and a small forwarder inside bridges 127.0.0.1:3128 to it, so tools that honour HTTP_PROXY (curl, git, python3) reach the allowed targets and nothing else. Before an agent’s terminal gets the web, the server checks that the proxy is the only way out: other local ports (IPv4 and IPv6), this machine’s addresses, its resolvers, abstract sockets and vsock stay unreachable, and there is no route but loopback. When the check fails, the run says why and the terminal runs with no network, as before. The Linux desktop window gives its terminals no web access. http.request works on every platform.
Cloud agents are limited by their provider: when one answers that it is overloaded or rate-limited (HTTP 429), the run sends it fewer requests at once and repeats the refused one after a pause, without spending the agent’s turn. An agent’s request, and split and synthesize, may take up to 10 minutes, so a slow model’s long answer is not cut off (a chat gives an added provider 60 s).
Agents’ terminal
Section titled “Agents’ terminal”With terminal(...) among its tools, an agent can build and test as it works: terminal.run {"command": "node", "args": ["--test", "tests/a.test.ts"]} and the like. It sees the real output and fixes what fails before it answers.
- Commands run in the same sandbox as the contract’s tests (
sandbox-execon macOS, bubblewrap on Linux): no network (unless the agent also has thehttpright, which opens the agent’s allowlisted targets through a proxy — see Agents reaching a web service), nothing of the user’s home folder, other temporary folders or the app’s data, writes only in the agent’s own copy. - The copy holds the files the agent may read, as the run read them, with the candidate’s files as the agent sees them (its own changes included), refreshed before each command. The project’s
node_modulesis linked read-only; its git history too, unless the contract has hidden tests (history could hold them). Contracts and their tests are never in it. - What a command writes stays in the copy: the candidate changes only through the file tools, so the gates and Apply see only those changes.
- At most 120 s a command, and 240 s of CPU time for each of its processes; output bounded. Whatever a command leaves running is killed when it ends.
gitonly reads (log, show, diff, blame, status, grep…);npmrunstest,runandls, neverinstall: a command has no network, sonpm testuses the project’s ownnode_modules(on a server, its owner installs it once withsudo local-cognitive-server deps <project>). A server brings its ownnodeandnpm; on a computer they are the ones installed there (Homebrew, nvm or the system’s). On Windows a terminal runs onlynode,npmandnpx, all from the app’s own bundled Node;node --testrun directly gets its files run in one process, but a project’s test script must pass that flag itself (node --test --experimental-test-isolation=nonewith the bundled Node 22; Node does not take it fromNODE_OPTIONS), or it times out with a note that says so.git,ls,catandpython3are not available there yet, and the copy has no projectnode_modulesor git history. - Before a run gives agents a terminal, the sandbox shows it isolates: a process inside it tries to read a file outside its folders, write outside its work folder and reach a local port. Any success, and the run stops with the reason (contract tests are Unknown for the same reason). On Windows the check also proves that what a command leaves running dies when the helper is killed.
The run shows its agents under Agents: how many are queued, running, done and failed, the agents one per task (model, steps, tokens, time, files, error), and beside them the chosen agent’s steps. The run’s token counts include every agent’s.
Acceptance and run outcomes
Section titled “Acceptance and run outcomes”The normal cycle is:
revise candidate -> evaluate registered gates -> verify evidence | Pass -> return accept | Unknown -> return needs_review Fail -> feedback -> next iterationEvidence is bound to the exact candidate file contents, frozen specification, and evaluator version. Editing the candidate invalidates earlier evidence. Model reviews and generated test ideas cannot substitute for trusted gate results.
| Run outcome | Meaning |
|---|---|
| Accepted | The flow returned valid acceptance with fresh passing hard-gate evidence. Files are still not applied automatically. |
| Needs review | The flow returned needs_review(...), commonly because a hard gate was Unknown. |
| Unresolved | The flow returned unresolved(), ended without a terminal result, or exhausted a budget. |
| Blocked | A runtime action failed, for example because no model matched or a forbidden path was used. |
| Cancelled | The run was stopped by the user. |
| Interrupted | Execution was interrupted by runtime shutdown/restart. |
The UI may also show Queued and Running while work is in progress. Fail is a gate/verdict result, not the final run state for an exhausted repair loop.
Acceptance proves the implemented checks, not every sentence in description, visual quality, or production readiness. Review generated code and use additional project-specific validation as appropriate.
Files, editor, and application UI
Section titled “Files, editor, and application UI”Edit the two DSL files in Synthesis or in any editor. Contract and Flow are editors of the module’s files: Save (⌘S or Ctrl+S) writes the file and checks it, each problem is marked on its line and listed under the editor, and a problem in Diagnostics opens its line. A run saves what was edited first. When the file was changed elsewhere since it was opened, Save writes nothing until you choose Reload from disk or Replace with mine; a file with CRLF line ends keeps them. A run’s snapshot is read-only. Open in editor opens the project or module in your IDE; files saved there are read on Refresh.
Modules and Diagnostics are panels beside the module. With both open, the one opened later sits below the other; drag the panels’ left edge to set their width and the line between them to share the height. The list of files in Changes, and of agents in Agents, is resized the same way (double-click a handle to reset it). The module’s run history is in the Modules panel: a finished run is deleted there after you confirm, with its log, candidate and agents’ steps, and Clear deletes all finished runs of the module. Files a run already applied stay in the project.
With a paired server selected, the screen shows that server’s projects (those made from a device in its shared folders), runs on its models, and applies to its folders. Its sources are edited on the server and shown read-only, runs are not deleted from the device, Open in editor is not offered there, and a project file a report cites is marked but not opened (only the server reads its project).
+ Project registers an existing project folder and selects it. Selecting a project or pressing Refresh discovers matching DSL files recursively, without importing or copying them. New module creates new files and is separate from discovery. The list displays source paths, so equally named modules in different folders remain distinct; existing conventional modules retain their run-history identity. Moving a module to a different path changes its identity. Historical run records are not imported from another application data directory.
Discovery includes the root and up to 12 folder levels. It skips hidden folders, symlinks, paths outside the supported naming rules, and dependency/build folders (node_modules, dist, build, release, coverage, vendor, target, Binaries, Intermediate, DerivedDataCache). A scan stops with an explicit error above 20,000 entries or 100 modules; choose a more specific project root in that case. An incomplete pair appears with a source-read diagnostic, rather than being silently accepted. New-module folder selection is restricted to discoverable locations.
Changes saved in another editor are read on Refresh; Save in Synthesis checks them at once. Both are compiled again on Run. Starting a run freezes both source files. Changes saved while a run is executing affect the next run, not the current one. Use the run snapshot view to inspect the sources behind historical results.
Restart from snapshot is available for unsuccessful or interrupted runs. It creates a new run from the saved DSL, reads the current project’s output files as the new baseline, and starts from the beginning. It does not resume at the last statement or restore arbitrary DSL variables from a checkpoint.
Apply verified patch is separate from accept(...). It writes accepted candidate files only after checking that the project baseline has not changed. A conflict requires review and another run; acceptance is not permission to overwrite unrelated edits.
Project path restrictions
Section titled “Project path restrictions”- Paths are project-relative and use
/, never absolute paths or backslashes. - No
.or..segments, hidden names,node_modules, or symlink components. - Each segment starts with an ASCII letter, digit, underscore, or hyphen; subsequent characters may also include dots. Spaces are not accepted in DSL-relative paths.
- The whole relative path is at most 240 characters.
checkoutcannot target a path with aSynthesissegment, protecting authored DSL files.- Source files read by the application and each candidate artifact are limited to 128 KiB. The standalone parser has a separate 256 KiB source-length guard, but the application read limit is stricter.
- A project exposes at most 100 Synthesis modules, and at most two Synthesis runs may execute concurrently.
Common mistakes
Section titled “Common mistakes”| Symptom or diagnostic | What to change |
|---|---|
| Module not discovered | Save Name.lcspec and Name.lcflow together in a discoverable project folder, match the declared module name, select the right workspace, and Refresh. Check Hidden modules if you previously removed it from view. |
FLOW_MODULE / FLOW_EVALUATOR |
Match the spec module and acceptance-group names in the flow header. |
FLOW_AWAIT_REQUIRED |
Add await before the asynchronous action. |
FLOW_POLICY_CAPABILITY |
Agents (agent, files.*, parallel_map, split, synthesize) need policy = "agents-v1". |
FLOW_AGENT_MODEL |
Name an agent’s model once: a loaded role, or provider and model. |
FLOW_FILE_PATTERN |
Rights take project-relative patterns such as "src/**", without hidden folders or ... |
FLOW_ANSWER_FILE |
answer_file is a string path with {n}, such as "review/notes/agent-{n}.md" (and {call} if wanted), without wildcards, hidden folders or ... |
FLOW_HTTP_TARGET |
http(allow = [...]) names web addresses such as "https://staging.example.com" or "https://api.example.com/v1": an https:// (or http://) host and optional path, without credentials, a query or a fragment. |
SYNTHESIS_WEB_CONSENT |
An agent’s http targets must be ones the project allows (its owner sets them; on a server, sudo local-cognitive-server web-targets allow <project> <url>…). |
FLOW_FOR_VARIABLE |
Give the loop variable a new name; it exists only inside the loop. |
FLOW_INDEX |
Index a list with a whole number: list[0]. |
FLOW_UNDEFINED_NAME |
Assign the variable before use on every path; initialize loop feedback before the loop. |
FLOW_ASSIGNMENT_TYPE |
Do not reuse a variable for an unrelated value type. |
LEX_UNIT |
Use GiB, MiB, m, or usd, with exact spelling and no separating space. |
FLOW_POLICY |
Declare policy = "local-files-v1"; (or "cloud-files-v1", "agents-v1") exactly once at the top level. |
FLOW_POLICY_PROVIDER |
A provider other than llamacpp needs policy = "cloud-files-v1" or "agents-v1". |
FLOW_PROVIDER_LITERAL |
Write the provider as a string: provider = "openai". |
SYNTHESIS_PROVIDER / SYNTHESIS_CLOUD_CONSENT |
Set the provider up (and its key) in Settings → Models & Providers; switch on Cloud models for the project (on a server: sudo local-cognitive-server cloud-models allow <project>). |
SYNTHESIS_SANDBOX |
The terminal names a command this platform’s sandbox does not run. On Windows a terminal runs only node, npm and npx: narrow terminal(allow = [...]) to those, or run the flow on a Mac or a Linux server. |
FLOW_ACCEPT_GUARD |
Put return accept(...) inside if (verdict.status == Pass) after verify. |
FLOW_TERMINAL_RETURN |
Return terminal actions directly; do not assign or invoke them as standalone statements. |
FLOW_UNKNOWN_CALL |
Use registered calls only. There is no unreal.build, analyze, shell, or getAllModels intrinsic. Use models.list. |
SPEC_UNSUPPORTED_SECTION / SPEC_UNSUPPORTED_TARGET |
The requested domain semantics need a trusted adapter; adding prose or a new section name does not implement it. Express architecture with Exports, Imports, Forbid and the engineer’s Tests. |
SPEC_TEST_MISSING |
Put the test file next to the .lcspec, at the path the contract names. |
SPEC_PATH_CONFLICT |
A path appears twice across artifacts, frozen files and test files; they share one folder when tests run. |
SPEC_CLAUSE_UNTESTED / SPEC_CLAUSE_UNKNOWN |
Name each numbered clause in a test or on the gate that checks it, and only clauses the description numbers. Every code’s fix is in the skill’s references/diagnostics.md. |
A Tests gate is Unknown |
The message names what is missing: a sandbox (on Linux install bubblewrap, and on a Local Cognitive server run sudo local-cognitive-server sandbox, 0.1.3 or later), Node.js 22.18+ for TypeScript, Python 3 (on Windows only under Program Files), or a C++ compiler (C++ is Unknown on Windows). |
| No installed model matches | Import an eligible GGUF or change selection. prefer does not download a model. |
| Unknown evaluator result | The group/ID is not registered. Use a supported evaluator or implement a trusted adapter in the application. |
| Stale evidence | Re-run evaluate and verify after the last candidate revision. |
| Apply conflict | Project output changed since checkout. Review the changes and start a new run. |
V1 boundaries and future language features
Section titled “V1 boundaries and future language features”The research syntax is broader than this implementation. The following are not executable in the current application:
- Contract inheritance with
extends, or cross-module imports/dependency resolution. - Formal
interface,behavior,invariants,constraints, andarchitecturesections. - Formal
implies,Eventually(...), lifecycle, latency, or throughput requirements. - Unreal Engine builds (UnrealBuildTool), engine automation tests, or multiplayer evaluators. C++ modules build and test as plain C++20 with the standard library: write an engine-agnostic core against a frozen header, then integrate it in the engine.
- Evaluation environment/workload selection and numeric optimization objectives such as
soft minimize Mean(...). - User-defined functions, custom runtime actions declared in DSL, or general object manipulation.
- Executing model-proposed tests (only the engineer’s tests run), or registering new trusted evaluators from a DSL file.
- Agents writing outside the run’s candidate, or a terminal command the platform’s sandbox does not run (on Windows, anything but
node,npmandnpx). - Model downloads, arbitrary tools, or host shell access.
The parser preserves some research-style sections as source, but the compiler rejects unsupported semantics. Parseable does not mean executable or verified. An ability system core works today as plain C++ with a frozen header, tests and architecture gates; the formal sections and engine adapters do not.
