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.
131 lines
4.7 KiB
Markdown
131 lines
4.7 KiB
Markdown
# RFC-CM P1 evidence: addressable Memory and place assignment
|
||
|
||
Date: 2026-11-20 (Asia/Shanghai)
|
||
Repository: `marqdo-cli`
|
||
Baseline commit: `a113d894962d8c00eb02efb42e0e73f8b084a1fa` (`docs: bind
|
||
README/COMPATIBILITY/CHANGELOG to the convergence SHA`)
|
||
Working tree: RFC-CM P1 changes, **not committed** at the time of this report.
|
||
Decision record: [ADR-0022](../adr/0022-addressable-memory-and-place-assignment.md)
|
||
Scope: RFC-CM-0001 R1 / RFC-CM-0002 P1 only. P2–P6 are **not** implemented.
|
||
|
||
## Environment
|
||
|
||
* Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
|
||
* `PATH=/root/.cargo/bin:$PATH`
|
||
* `CARGO_HOME=/root/work/marqdo-cli/.cache/cargo`
|
||
* `CARGO_TARGET_DIR=/root/work/marqdo-cli/.cache/target`
|
||
* No GitHub credentials in this checkout; this is **local** evidence, not a
|
||
GitHub Actions result. Windows/macOS lanes were not run.
|
||
|
||
## Static and workspace gate
|
||
|
||
```text
|
||
cargo fmt --all -- --check PASS
|
||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||
cargo test --workspace --locked PASS
|
||
47 test binaries, 389 passed, 0 failed, 2 ignored (doc-tests)
|
||
```
|
||
|
||
The 2 ignored tests are the existing `marqdo-plugin-sdk` doc-tests, not new
|
||
memory tests.
|
||
|
||
## Focused evidence
|
||
|
||
```text
|
||
cargo test -p marqdo-runtime --lib memory
|
||
8 passed; 0 failed
|
||
regions_are_isolated_and_handles_share_identity
|
||
create_is_zero_filled_and_reports_pages
|
||
grow_keeps_old_bytes_and_zero_fills_new_pages
|
||
failed_grow_does_not_change_region_or_budget
|
||
invalid_offsets_are_structured_errors
|
||
create_validates_page_counts_and_budget
|
||
forged_and_stale_handles_are_rejected
|
||
page_arithmetic_never_overflows
|
||
|
||
cargo test -p marqdo-runtime --test interpreter memory
|
||
3 passed; 0 failed
|
||
memory_region_is_shared_by_handle_identity
|
||
memory_handle_cannot_reach_the_host_boundary
|
||
memory_budget_is_enforced_without_changing_the_region
|
||
|
||
cargo test -p marqdo-value --lib memory
|
||
2 passed; 0 failed
|
||
memory_display_never_leaks_the_runtime_handle
|
||
memory_handles_are_not_transferable
|
||
|
||
cargo test -p marqdo-expression --lib memory_index
|
||
1 passed; 0 failed
|
||
memory_index_assignment_parses_as_a_place
|
||
|
||
cargo test -p marqdo-cli \
|
||
--test conformance_semantics --test negative \
|
||
--test analysis_trace --test examples_r6
|
||
semantic_goldens_match_end_to_end_execution ok
|
||
runtime_negative_goldens ok
|
||
analysis_v2_projects_memory_place_targets_additively ok
|
||
addressable_memory_example_runs_through_the_cli ok
|
||
cli_memory_budget_override_fails_closed ok
|
||
(20 tests total in these four binaries, 0 failed)
|
||
```
|
||
|
||
## End-to-end CLI
|
||
|
||
```text
|
||
$ marqdo run examples/memory-buffer.mq.md --json
|
||
{"success": true, "value": {"type": "int", "decimal": "141"}, ...}
|
||
|
||
$ marqdo run examples/memory-buffer.mq.md --max-memory 0 --json
|
||
{"success": false, "error": {"code": "resource.exhausted", ...}, ...}
|
||
```
|
||
|
||
The example creates one 64 KiB page with a declared maximum of four pages,
|
||
writes two bytes through two names that share one region, and returns
|
||
`42 + 99 = 141`.
|
||
|
||
## Fixtures
|
||
|
||
Semantic goldens:
|
||
|
||
* `tests/conformance/semantics/45-memory-buffer.mq.md` — shared identity
|
||
(`另一个名字 = 区域`) and two byte writes.
|
||
* `tests/conformance/semantics/46-memory-grow-zero-fill.mq.md` — zero-page
|
||
create, `grow` returning the old count, old bytes preserved, new byte zero,
|
||
`memory.size`.
|
||
* `tests/conformance/semantics/47-memory-isolation-and-alias.mq.md` — two
|
||
regions do not alias at the same offset; handle equality is identity.
|
||
|
||
Runtime negatives:
|
||
|
||
| Fixture | Expected code |
|
||
|---|---|
|
||
| `13-memory-out-of-bounds` | `runtime.index` |
|
||
| `14-memory-byte-range` | `runtime.type` |
|
||
| `15-index-assign-non-memory` | `runtime.type` |
|
||
| `16-memory-huge-offset` | `runtime.index` |
|
||
| `17-memory-grow-beyond-max` | `resource.exhausted` |
|
||
| `18-memory-negative-pages` | `runtime.memory` |
|
||
|
||
## What this does not prove
|
||
|
||
* No `.mq.md` stdlib repository or allocator/closure fixture yet (RFC-CM P2).
|
||
* No `Resource`, `Stream`, byte-transfer ABI, stdlib `print` migration or
|
||
`Table` storage abstraction (P3–P5).
|
||
* No Windows/macOS evidence and no remote CI URL.
|
||
* No claim of block-level memory safety for a user-written allocator; the
|
||
runtime only bounds each access to its region.
|
||
* No claim that `strict` accepts new I/O: memory is pure computation and no
|
||
`HostOp` or provider was added.
|
||
|
||
## 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
|
||
cargo fmt --all -- --check
|
||
cargo clippy --workspace --all-targets -- -D warnings
|
||
cargo test --workspace --locked
|
||
cargo run -p marqdo-cli -- run examples/memory-buffer.mq.md --json
|
||
```
|