docs(spec): adopt RFC-LANG-0002 unified language semantics
Replace the Strong/Emph/List/Quote mapping in place with the single @exec/@knowledge heading-mode model, unified payload carriers and keyword control flow. - add the authoritative RFC, ADR-0052 and a historical ADR index - rewrite spec/mapping.md and spec/expression.ebnf as the normative mapping/statement grammar; update evaluation, references, math, foreign, package-format, plugin-abi, security and schema notes - rewrite README, AGENTS, COMPATIBILITY and CHANGELOG for the breaking language change; update the architecture index/overview and active docs - mark superseded planning docs, compute RFCs, evidence and syntax-role ADRs as historical/superseded without rewriting their decisions - add migration guide, per-file inventory and dev-only audit scripts The frontend/stdlib migration is completed in the following commits; this commit contains documentation only.
This commit is contained in:
1 parent
0d8ed44010
commit
49835424ee
47 files changed
+4941
-603
No files matched your search
@@ -1,6 +1,14 @@
|
||||
# ADR-0002: Executable nodes execute only inside level-2 function bodies
|
||||
|
||||
Status: **Accepted**
|
||||
> **Historical / superseded in part.** The execution-scope decision (payloads
|
||||
> only inside an owning H2 function, never at module top level) remains, but
|
||||
> the carrier/role rules in this ADR (`Strong` executes, `Emph` returns, lists
|
||||
> and quotes are instructions) were replaced by
|
||||
> [ADR-0052](0052-unified-markdown-semantics.md) and
|
||||
> [`spec/mapping.md`](../../spec/mapping.md). The syntax examples below are the
|
||||
> syntax at the time of the decision, not current syntax.
|
||||
|
||||
Status: **Accepted (historical mapping superseded by ADR-0052)**
|
||||
Date: 2026-11-20
|
||||
|
||||
## Context
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# ADR-0003: `ref` resolution order and `ref.ambiguous` (S-07)
|
||||
|
||||
> **Historical syntax note.** The AST shape below uses the pre-RFC-LANG-0002
|
||||
> spelling, where a `strong` node carried an executable statement. Under the
|
||||
> current contract
|
||||
> ([RFC-LANG-0002](../architecture/RFC-LANG-0002-unified-semantics.md),
|
||||
> [ADR-0052](0052-unified-markdown-semantics.md),
|
||||
> [`spec/mapping.md`](../../spec/mapping.md)), `Strong`, `Emph` and inline
|
||||
> `Code` are interchangeable one-statement payload carriers inside an `@exec`
|
||||
> scope. The `ref` resolution decision itself remains current.
|
||||
|
||||
Status: **Accepted**
|
||||
Date: 2026-11-20
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# ADR-0005: AST normalization (Setext headings, task items, code-span ticks, strikethrough)
|
||||
|
||||
> **Historical mapping note.** The profile/AST normalization rules in this ADR
|
||||
> remain current. Its role claims — that ordered/bullet list structure
|
||||
> "determines branch/loop roles" and that `strong`/`emph` carry execute/return
|
||||
> roles — were superseded by
|
||||
> [RFC-LANG-0002](../architecture/RFC-LANG-0002-unified-semantics.md) /
|
||||
> [ADR-0052](0052-unified-markdown-semantics.md) and
|
||||
> [`spec/mapping.md`](../../spec/mapping.md): lists and block quotes are
|
||||
> presentation containers, and `Strong`, `Emph` and inline `Code` are
|
||||
> interchangeable one-statement payload carriers. Strikethrough and the other
|
||||
> inert regions stay inert.
|
||||
|
||||
Status: **Accepted**
|
||||
Date: 2026-11-20
|
||||
|
||||
|
||||
@@ -55,6 +55,14 @@ Codes are stable contract. Diagnostic **codes** (for example
|
||||
`markdown.invalid_construct`, `expr.parse`, `symbol.unknown`,
|
||||
`permission.denied`, `ref.ambiguous`) are stable; message wording is not.
|
||||
|
||||
> **Historical diagnostic note.** `markdown.invalid_construct` (and the
|
||||
> executable-shape `Strong`/`Emph`/list/quote errors it described) belongs to
|
||||
> the pre-RFC-LANG-0002 mapping. Under the current contract
|
||||
> ([RFC-LANG-0002](../architecture/RFC-LANG-0002-unified-semantics.md) /
|
||||
> [ADR-0052](0052-unified-markdown-semantics.md),
|
||||
> [`spec/mapping.md`](../../spec/mapping.md) §8) syntax-role failures use the
|
||||
> `sem.*` codes. The rest of this CLI contract is unaffected.
|
||||
|
||||
### 3. Stream separation
|
||||
|
||||
* **Program output** (`打印`/`print`) goes to stdout in text mode. In JSON mode
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
# ADR-0007: Arbitrary-precision `Int` and the typed wire encoding (S-08)
|
||||
|
||||
> **Historical syntax note.** The numeric model and typed wire-encoding
|
||||
> decisions remain current. The phrase "code spans/plain text of
|
||||
> `strong`/`emph`/conditions" below describes the pre-RFC-LANG-0002
|
||||
> payload/condition mapping; under
|
||||
> [RFC-LANG-0002](../architecture/RFC-LANG-0002-unified-semantics.md) /
|
||||
> [ADR-0052](0052-unified-markdown-semantics.md), payloads are carried by
|
||||
> `Strong`, `Emph` or inline `Code` and control flow is keyword based.
|
||||
|
||||
Status: **Accepted**
|
||||
Date: 2026-11-20
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
# ADR-0022: Addressable `Memory` and Memory-index place assignment (RFC-CM P1)
|
||||
|
||||
> **Historical syntax note.** The `Memory` index place-assignment decision
|
||||
> remains current. The sentence below that "the surface syntax remains a
|
||||
> `strong` node … no Markdown role, heading or list meaning changes" is the
|
||||
> historical pre-RFC-LANG-0002 spelling: under
|
||||
> [RFC-LANG-0002](../architecture/RFC-LANG-0002-unified-semantics.md) /
|
||||
> [ADR-0052](0052-unified-markdown-semantics.md), `m[i] = b` is carried by any
|
||||
> `Strong`/`Emph`/inline `Code` payload inside an `@exec` scope, and lists,
|
||||
> quotes and headings carry no instruction role.
|
||||
|
||||
Status: **Accepted**
|
||||
Date: 2026-11-20
|
||||
Relates to: `docs/MARQDO_COMPUTE_MACHINE_RFC_0001.md` (CM-A01/CM-A02/CM-A03),
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# ADR-0052: Unified Markdown semantics — heading modes, unified payloads and keyword control flow
|
||||
|
||||
Status: **Accepted (target contract; frontend implementation pending)**
|
||||
Date: 2026-11-21
|
||||
Supersedes: ADR-0002 in part (executable roles), the AST→program mapping in
|
||||
`spec/mapping.md` and the statement layer in `spec/expression.ebnf`
|
||||
Specs: `spec/mapping.md`, `spec/expression.ebnf`
|
||||
Authority: `docs/architecture/RFC-LANG-0002-unified-semantics.md`
|
||||
Tracks: `docs/migration/semantic-rewrite-inventory.tsv`
|
||||
|
||||
## Context
|
||||
|
||||
The previous language mapping binds program meaning to Markdown presentation:
|
||||
|
||||
* `Strong` executes;
|
||||
* `Emph` returns;
|
||||
* an ordered list is a branch;
|
||||
* a bullet list is a loop;
|
||||
* a block quote is a call;
|
||||
* an H2 is unconditionally a function and a standalone code span after it is a
|
||||
signature.
|
||||
|
||||
That makes ordinary document structure impossible to use freely inside a
|
||||
function, forces control flow to depend on list type and nesting, and gives
|
||||
inline code a signature privilege no other carrier has. It also means a parse
|
||||
failure can only be reported as a shape error, because there is no separate
|
||||
statement syntax to parse.
|
||||
|
||||
## Decision
|
||||
|
||||
Adopt a single, breaking Markdown→program mapping. There is no V1/V2
|
||||
coexistence, no per-file syntax selector and no `--legacy` path.
|
||||
|
||||
1. **Heading modes.** H1–H6 may start their first plain Text child with an
|
||||
exact `@exec` or `@knowledge` declaration followed by whitespace and a
|
||||
non-empty name. Unmarked headings inherit the nearest ancestor heading's
|
||||
mode; the document root is Knowledge. The declaration is stripped from the
|
||||
semantic heading name.
|
||||
2. **Function boundary unchanged.** Only an Exec H2 is a callable function. H2
|
||||
Knowledge is an inert knowledge unit. H3–H6 are sections and never create
|
||||
callables. A payload with no owning Exec H2 is `sem.exec_without_function`.
|
||||
3. **Unified payloads.** In an Exec scope, `Strong`, `Emph` and inline `Code`
|
||||
are interchangeable carriers of one statement. Only direct Text/Code
|
||||
children are extracted; nested carriers are `sem.payload_nested`; each AST
|
||||
carrier is extracted at most once.
|
||||
4. **Keyword control flow.** A payload is exactly one of `if`, `else`, `while`,
|
||||
`end`, `return`, `params(...)`, assignment or expression. `if`/`while` are
|
||||
closed by an explicit `end`; `else` is optional. Lists, block quotes and
|
||||
paragraphs are containers with no instruction type.
|
||||
5. **Segments.** A control block may not cross a heading boundary. Each
|
||||
heading's direct body is one segment; the stack must be empty at every
|
||||
boundary. Complete segments append to the owning H2 function in source
|
||||
order.
|
||||
6. **Signatures.** An optional `params(...)` statement is legal only as the
|
||||
first direct payload of an Exec H2; otherwise free-variable inference
|
||||
applies. The old standalone code-span signature is removed.
|
||||
7. **IR unchanged in kind.** Control words lower to the existing
|
||||
`Assign`/`Eval`/`Branch`/`Loop`/`Return`. No `HostOp`, no second
|
||||
interpreter, no runtime knowledge of Markdown.
|
||||
8. **Security unchanged.** `@exec` is not a capability grant. `@knowledge`
|
||||
produces no IR and therefore no effects.
|
||||
9. **Errors never fall back to prose.** A malformed payload in an Exec scope is
|
||||
a hard diagnostic; spelling errors in mode declarations are hard errors, not
|
||||
inherited modes.
|
||||
|
||||
## Consequences
|
||||
|
||||
* Every `.mq.md` source in the repository — stdlib, examples, fixtures, Rust
|
||||
embedded samples, docs — must be migrated. Old syntax must not remain a
|
||||
supported active language.
|
||||
* `spec/mapping.md` and `spec/expression.ebnf` are replaced in place; there is
|
||||
no second active spec. Historical material is archived with a banner.
|
||||
* Normal emphasis in an Exec section becomes a payload and may fail as an
|
||||
unknown symbol. Authors must use `@knowledge` sections for purely visual
|
||||
emphasis. This is accepted as the price of determinism.
|
||||
* Until the Rust frontend, expression parser, bundled stdlib and fixtures are
|
||||
migrated, the implemented CLI does **not** accept this syntax. The tree must
|
||||
not be released or described as complete during that window. See
|
||||
`docs/STATUS.md`.
|
||||
* Test fixtures are migrated as text; execution goldens are expected to be red
|
||||
until the implementation lands. No test may silently keep asserting the old
|
||||
mapping as current.
|
||||
* Migration is AST-role based, not a global regex rewrite; ambiguous cases stop
|
||||
for manual rewrite.
|
||||
|
||||
## Alternatives rejected
|
||||
|
||||
* **Keep both mappings per file.** Rejected: two active specs, unstable
|
||||
semantics for the same source, permanent maintenance and accidental
|
||||
execution.
|
||||
* **Infer control flow from list shape.** Rejected: ordinary prose lists would
|
||||
execute and parse errors could silently become documents.
|
||||
* **Use `mq exec` fenced blocks only.** Rejected: loses native Markdown
|
||||
document structure and the language's purpose.
|
||||
* **Bind `end` to indentation or list nesting.** Rejected: reformatting would
|
||||
change control flow.
|
||||
* **Treat emphasis type as intent.** Rejected: no deterministic way to tell
|
||||
emphasis from execution from the AST.
|
||||
@@ -0,0 +1,33 @@
|
||||
# Architecture Decision Records (ADRs)
|
||||
|
||||
These files record decisions **at the date they were made**. They are not a
|
||||
description of current language behavior, implementation state or current
|
||||
architecture; read them as decision history.
|
||||
|
||||
- **Status is not a current-language claim.** A status such as "Accepted" means
|
||||
the decision was accepted then, not that its syntax or behavior is still
|
||||
active. Superseded ADRs keep their original decision text and date; they are
|
||||
not rewritten.
|
||||
- **Syntax-role decisions are superseded by
|
||||
[ADR-0052](0052-unified-markdown-semantics.md).** The earlier mapping —
|
||||
`Strong` executes, `Emph` returns, ordered list is a branch, bullet list is a
|
||||
loop, block quote is a call, plus the associated `markdown.inert_executable` /
|
||||
`markdown.invalid_construct` role diagnostics — is retired. The current
|
||||
language contract is
|
||||
[RFC-LANG-0002](../architecture/RFC-LANG-0002-unified-semantics.md), with its
|
||||
normative summaries [`spec/mapping.md`](../../spec/mapping.md) and
|
||||
[`spec/expression.ebnf`](../../spec/expression.ebnf): `@exec`/`@knowledge`
|
||||
heading modes, `Strong`/`Emph`/inline `Code` as interchangeable
|
||||
one-statement payload carriers, and `if`/`else`/`while`/`end`/`return`/
|
||||
`params` keywords. The Rust frontend in this checkout still implements the
|
||||
pre-RFC mapping; see [`docs/STATUS.md`](../STATUS.md).
|
||||
- **Infrastructure ADRs** (crates, ABI, capabilities, CLI/JSON contract,
|
||||
packaging, security isolation) remain current unless a later ADR supersedes
|
||||
them. ADRs with a historical banner keep the banner scoped to the superseded
|
||||
part.
|
||||
- This index is not a spec. For current architecture see
|
||||
[`docs/architecture/CURRENT.md`](../architecture/CURRENT.md); for executed
|
||||
status see [`docs/STATUS.md`](../STATUS.md).
|
||||
|
||||
Files: `0001`–`0050`, plus `0051-byte-exact-http-framing.md` (HTTP framing) and
|
||||
`0052-unified-markdown-semantics.md` (current language mapping).
|
||||
Reference in new issue
Block a user