Verify control-flow invariants and document the development contract
This commit is contained in:
1 parent
71d29261a8
commit
1dc088b602
22 files changed
+269
-80
No files matched your search
@@ -1,9 +1,9 @@
|
||||
# Analysis v2 and Trace v2 consumers
|
||||
# Analysis and Trace v2 consumers
|
||||
|
||||
Both are public, versioned JSON artifacts. A consumer must read them as files,
|
||||
never link Marqdo's Rust internals or depend on `inspect --ir`.
|
||||
|
||||
## Analysis v2 (static)
|
||||
## Analysis v2 and v3 (static)
|
||||
|
||||
```bash
|
||||
marqdo check index.mq.md --emit ./analysis.json
|
||||
@@ -13,7 +13,10 @@ marqdo check index.mq.md --emit ./analysis.json
|
||||
independent Markdown-link check and can make `check` fail; on failure the emit
|
||||
target is removed. Do not generate a consumer artifact with
|
||||
`check --refs --emit` without checking the exit code.
|
||||
- `schema: "marqdo.analysis"`, `schema_version: 2`.
|
||||
- `schema: "marqdo.analysis"`. The writer emits `schema_version: 2` for
|
||||
projects without loop transfers and `3` when a function body contains
|
||||
`break` or `continue`. Check the version before walking function bodies.
|
||||
Both versions encode `else if` in the ordered `branch.arms` array.
|
||||
- Top level: `producer` (`name`, `version` = product version,
|
||||
`markdown_profile`), `project`, `modules`, `diagnostics`.
|
||||
- `project`: `root_id` (`root:<name>@<version>` for manifest projects),
|
||||
@@ -26,9 +29,10 @@ marqdo check index.mq.md --emit ./analysis.json
|
||||
instance ids, never absolute paths.
|
||||
- `check` does not load plugin libraries, start kernels/providers or execute the
|
||||
program.
|
||||
- Schemas: `spec/schemas/analysis-v2.schema.json`; contract:
|
||||
`spec/analysis-v2.md`; consumers: `tests/consumers/analysis_consumer.py`,
|
||||
`tests/consumers/validate_protocols.py`.
|
||||
- Contracts: [Analysis v2](../../spec/analysis-v2.md) and
|
||||
[Analysis v3](../../spec/analysis-v3.md). Each links to its schema.
|
||||
The independent consumers in `tests/consumers/` check the version and
|
||||
decode the public nodes.
|
||||
|
||||
View must render the **original Markdown** and use Analysis only to correlate
|
||||
source offsets/heading units/callable mapping. Knowledge must use heading
|
||||
@@ -50,7 +54,8 @@ marqdo run index.mq.md --trace-file ./trace.json
|
||||
stale; do not bind it to the new source. `run --trace-file` does not emit
|
||||
Analysis itself.
|
||||
- Event kinds: `call.enter`, `call.exit`, `branch.eval`, `loop.iteration`,
|
||||
`return`, `effect`, and possibly `trace.truncated`. Sourced events carry a
|
||||
`control.break`, `control.continue`, `return`, `effect` and possibly
|
||||
`trace.truncated`. Sourced events carry a
|
||||
module id and a UTF-8 span.
|
||||
- Defaults are 100,000 events / 32 MiB; `--trace-max-events` and
|
||||
`--trace-max-bytes` adjust them (`0` = unlimited). A consumer must tolerate
|
||||
@@ -80,10 +85,11 @@ marqdo run index.mq.md --event-stream jsonl --trace-file ./trace.json
|
||||
a complete stream. An EOF without a terminal event is `incomplete`
|
||||
(SIGKILL/crash/broken pipe); never synthesize success.
|
||||
- `run.started.source` contains `root_id` and the `sha256:` digest of the exact
|
||||
Analysis v2 bytes. `--trace-file` may be combined; both writers share one
|
||||
Analysis bytes. `--trace-file` may be combined; both writers share one
|
||||
opaque run id, and Trace v2 remains atomic and value-free.
|
||||
- Structural events: `call.enter`/`call.exit` (`frame_id`, `parent_frame_id`),
|
||||
`return`, `branch.eval`, `loop.iteration`, `effect`. Frames identify call
|
||||
`return`, `branch.eval`, `loop.iteration`, `control.break`,
|
||||
`control.continue` and `effect`. Frames identify call
|
||||
instances, not functions; a failed argument binding creates no frame.
|
||||
- Values are off by default (`value_state: not_requested`).
|
||||
`--observe-variable NAME` and `--observe-parameter NAME` are exact-name
|
||||
|
||||
@@ -58,9 +58,15 @@ stdout and diagnostics.
|
||||
documentation. Unmarked headings inherit the nearest ancestor mode.
|
||||
- `**strong**`, `*emph*` and inline `` `code` `` are interchangeable carriers of
|
||||
one statement each.
|
||||
- Control flow uses keywords: `if`/`else`/`while`/`end`, plus `params(...)` and
|
||||
`return`.
|
||||
- Lists, block quotes and paragraphs are presentation only.
|
||||
- A branch has an `if`, any number of `else if` arms and an optional
|
||||
final `else`, followed by one `end`. Each condition is evaluated in order.
|
||||
- A `while` loop ends at `end`. Inside its body, `break` exits the nearest
|
||||
loop and `continue` skips to its next condition check. `return` exits
|
||||
the function. See the [runnable example](../../examples/control-flow.mq.md).
|
||||
- Lists, block quotes and paragraphs organize the source view. For review or
|
||||
linting, put each branch head at the start of an ordered list item and
|
||||
place the loop head at the start of a bullet item. Nest the body visually
|
||||
and close each group with its own `end` carrier.
|
||||
- The normative contract is
|
||||
[`../architecture/RFC-LANG-0002-unified-semantics.md`](../architecture/RFC-LANG-0002-unified-semantics.md),
|
||||
[`../../spec/mapping.md`](../../spec/mapping.md) and
|
||||
|
||||
@@ -44,7 +44,8 @@ marqdo-view/
|
||||
rejects a mismatched range at install and dispatch time with a
|
||||
`requires marqdo …` diagnostic.
|
||||
- `analysis`/`trace` are declared only if the tool consumes them; the current
|
||||
core provides Analysis v2 and Trace v2.
|
||||
development branch provides Analysis v2/v3 and Trace v2. Declare
|
||||
`analysis: [2, 3]` when the reader handles both versions.
|
||||
- `command` must match `^[a-z][a-z0-9-]*$` and must not collide with a built-in
|
||||
command (`init`, `run`, `call`, `check`, `inspect`, `fmt`, `plugin`, `add`,
|
||||
`remove`, `lock`, `sync`, `tool`, `help`).
|
||||
@@ -72,7 +73,7 @@ The tool receives:
|
||||
|---|---|
|
||||
| `MARQDO_BIN` | absolute path of the running `marqdo` executable |
|
||||
| `MARQDO_TOOL_PROTOCOL` | `1` |
|
||||
| `MARQDO_PROTOCOL_ANALYSIS` | `2` when Analysis v2 was negotiated |
|
||||
| `MARQDO_PROTOCOL_ANALYSIS` | Highest shared Analysis version. Read the artifact envelope for its actual version. |
|
||||
| `MARQDO_PROTOCOL_TRACE` | `2` when Trace v2 was negotiated |
|
||||
|
||||
Call `$MARQDO_BIN` with an argv array; do not assume `marqdo` is on `PATH`.
|
||||
|
||||
Reference in new issue
Block a user