feat(rfc-cm): baseline P0-P3 compute machine, stdlib and resource slices

Implements the first vertical slices of RFC-CM-0001/0002 on top of a113d89:

- P1: opaque Memory regions (64 KiB pages, budgets, grow-only), byte
  read/write, Memory-index place assignment, wire/host-boundary rejection.
- CM-A04/A05: value-semantics List/Map/Text/Table primitives and the
  recoverable Result map convention.
- CM-A06: opaque Resource handles, resource.open/read/write/close, stdout
  write, granted project-file read and buffered write, strict fail-closed.
- CM-A07 Compat-A: explicit .mq.md format/utf8/io chain matching builtin
  print for the covered value types; builtin remains default.
- P2 fixtures: allocators, list/tree/graph/hash, integer codecs, UTF-8
  encode/decode, CSV/JSON subsets, table filter/sort/join, bytecode VM.
- ADRs 0022-0027, spec updates, evidence reports and 68 semantic goldens.

Gate: cargo fmt --check, clippy -D warnings, 407 tests passed.
This commit is contained in:
cflmy committed 2026-11-20 21:16:54 +08:00
1 parent a113d89496
commit 92bfbf2568
127 files changed
+11351 -141

No files matched your search

@@ -0,0 +1,74 @@
# RFC-CM P2 partial evidence: `.mq.md`-written codec, allocator and list
Date: 2026-11-20 (Asia/Shanghai)
Repository: `marqdo-cli`
Baseline: `a113d89` plus the uncommitted RFC-CM P0/P1/P2 changes.
Related: [ADR-0022](../adr/0022-addressable-memory-and-place-assignment.md),
[P1 evidence](2026-11-20-memory-p1.md),
[RFC-CM-0002 §7.2](../../docs/MARQDO_COMPUTE_CORE_STDLIB_MIGRATION_RFC_0002.md).
Scope: **partial P2 only**. The RFC-CM-0002 P2 gate is **not** passed.
> Historical slice: this report predates ADR-0023 (CM-A04 structure API),
> ADR-0024 (CM-A05 Result), the coalescing allocator (fixture 55) and the
> binary tree/CSV fixtures (56–57). Its "what remains" list is superseded by
> [`2026-11-20-structure-api-p2.md`](2026-11-20-structure-api-p2.md) and
> [`2026-11-20-result-and-free-list-p2.md`](2026-11-20-result-and-free-list-p2.md);
> the P2 gate itself is still not passed.
## What was added without Rust algorithm code
Three semantic fixtures are ordinary `.mq.md` documents. They call only
language builtins (`memory.new/size/grow`), indexing, arithmetic, functions,
branches and loops. No Rust crate was changed for the algorithms themselves.
| Fixture | `.mq.md` subject | Result |
|---|---|---|
| `tests/conformance/semantics/48-memory-bump-allocator.mq.md` | big-endian u32 encode/decode and a 4-byte-header bump allocator; allocates 8, 16, 8 bytes and writes a byte | `[4, 12, 28, 36, 255]` |
| `tests/conformance/semantics/49-memory-linked-list.mq.md` | allocates three 8-byte nodes (`value:u8`, `next:u32`), links them and traverses the list | `[4, 12, 20, 60]` |
| `tests/conformance/semantics/50-memory-allocation-failure-atomic.mq.md` | a too-large allocation returns `None` without moving the header; the next allocation still starts at 4 | `[None, 4, 4, 65536]` |
Observed CLI results (all `success: true`):
```text
48: [4, 12, 28, 36, 255]
49: [4, 12, 20, 60]
50: [None, 4, 4, 65536]
```
`cargo test -p marqdo-cli --test conformance_semantics` passes with these three
fixtures included.
## Why this is not the P2 gate
RFC-CM-0002 §9/P2 requires C01–C06 and C11 to pass in an environment with
Foreign/native plugins disabled, and requires a minimal API for dynamic
List/Map/Table construction and observation plus recoverable errors. This
slice does **not** provide:
* duplicate-free/allocator adversarial tests (C01 now has a first-fit
free-list allocator with reuse, splitting and coalescing, fixture 55);
* graph/hash-table structures (C02 now has a singly linked list and a binary
search tree, fixtures 49 and 56, but no graph/hash table);
* general List/Map/Table construction, mutation-free rebuilding or key
enumeration (CM-A04 is undecided);
* a `Result`/recoverable-error contract for parser/IO/EOF/partial conditions
(CM-A05 is undecided);
* an independent `marqdo-stdlib` repository, version/digest contract or
frozen-CLI-binary closure lane (the RFC §10.5 experiment).
It also does not add a stdlib API to the CLI; the fixtures are conformance
documents, not a shipped standard library.
## Reproduce
```bash
export PATH=/root/.cargo/bin:$PATH
export CARGO_HOME=/root/work/marqdo-cli/.cache/cargo
export CARGO_TARGET_DIR=/root/work/marqdo-cli/.cache/target
for f in 48-memory-bump-allocator 49-memory-linked-list \
50-memory-allocation-failure-atomic; do
cargo run -q -p marqdo-cli -- run \
tests/conformance/semantics/$f.mq.md --json
done
cargo test -p marqdo-cli --test conformance_semantics
```