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:
1 parent
a113d89496
commit
92bfbf2568
127 files changed
+11351
-141
No files matched your search
@@ -0,0 +1,130 @@
|
||||
# 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
|
||||
```
|
||||
@@ -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
|
||||
```
|
||||
@@ -0,0 +1,104 @@
|
||||
# RFC-CM CM-A06 extension evidence: buffered project-file writes
|
||||
|
||||
Date: 2026-11-20 (Asia/Shanghai)
|
||||
Repository: `marqdo-cli`
|
||||
Baseline: `a113d89` plus the uncommitted RFC-CM P0–P3 changes.
|
||||
Decision record: [ADR-0026](../adr/0026-buffered-project-file-write-streams.md)
|
||||
Related: [ADR-0025](2026-11-20-resource-stream-p3.md),
|
||||
[STATUS §5](../STATUS.md).
|
||||
Scope: project-file **write** extension only; no network/process/directory.
|
||||
|
||||
## Environment and gate
|
||||
|
||||
Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
|
||||
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace --locked PASS
|
||||
406 passed, 0 failed, 2 ignored (existing plugin-sdk doc-tests)
|
||||
```
|
||||
|
||||
No GitHub CI is available from this checkout; this is local evidence.
|
||||
|
||||
## Implemented behavior
|
||||
|
||||
`resource.open("file", "<project-relative path>", ["write"])`:
|
||||
|
||||
* project mode only; requires an `fs_write` glob grant and the same
|
||||
`ProjectFs` path policy (reject absolute, `..`, symlink escapes);
|
||||
* pure mode refuses file resources by mode; strict refuses every resource open;
|
||||
* the writer owns an in-memory buffer; `resource.write` appends and returns
|
||||
`{ok:true, value:{count}}` without touching the filesystem;
|
||||
* `resource.close` flushes through `ProjectFs::write_bytes` and then marks the
|
||||
handle closed; a failed flush leaves the handle open with its buffer;
|
||||
* an unclosed writer never creates the file (no flush on drop);
|
||||
* buffer ceiling is the existing 8 MiB file limit; an oversized append is
|
||||
`resource.exhausted` and leaves both buffer and file unchanged;
|
||||
* `resource.read` on a writer, and `resource.write` on a reader, are
|
||||
`resource.unsupported`;
|
||||
* no new `Value`, `HostOp`, Markdown node or wire shape.
|
||||
|
||||
## Tests
|
||||
|
||||
### Host integration (`crates/marqdo-host/tests/resource_streams.rs`, 9)
|
||||
|
||||
```text
|
||||
pure_mode_writes_stdout_through_a_resource
|
||||
stdout_write_obeys_the_output_budget_atomically
|
||||
strict_mode_refuses_every_resource_open
|
||||
resource_handles_cannot_cross_the_generic_host_boundary
|
||||
pure_mode_refuses_file_resources_even_with_a_grant
|
||||
project_file_writes_buffer_until_close_and_require_a_grant
|
||||
file_write_buffer_has_a_hard_ceiling
|
||||
project_file_reads_are_chunked_and_require_a_grant
|
||||
traversal_and_unsupported_rights_are_refused
|
||||
```
|
||||
|
||||
The write test asserts the file does not exist before `close`, appears with
|
||||
`abcdef` after `close`, closed read/close return `resource.closed`, and the
|
||||
same open without `fs_write` is `permission.denied`.
|
||||
|
||||
### CLI integration (`crates/cli/tests/resource_streams.rs`, 4)
|
||||
|
||||
```text
|
||||
project_file_stream_writes_on_close_then_reads_back
|
||||
run index.mq.md --allow-write out.bin --allow-read out.bin --json
|
||||
write count 3, close ok, read count 3 eof true, bytes 65/66/67
|
||||
out.bin on disk = "ABC"
|
||||
|
||||
file_copy_is_written_in_mqmd_through_chunked_streams
|
||||
.mq.md opens data.txt for read and out.bin for write,
|
||||
loops resource.read(16) / resource.write(count) until eof,
|
||||
closes both; total 6; out.bin on disk = "abcdef"
|
||||
(C09 file copy without a Rust copy_file builtin)
|
||||
|
||||
project_file_stream_reads_chunks_into_memory
|
||||
file_stream_requires_a_read_grant
|
||||
```
|
||||
|
||||
### Host table unit tests (`crates/marqdo-host/src/resource.rs`, 3)
|
||||
|
||||
Chunked EOF, forged/closed handles, stdout-not-readable and file-not-writable
|
||||
(read-only direction) remain covered; the writer uses the same handle checks.
|
||||
|
||||
## What this does not prove
|
||||
|
||||
* No append/truncate/seek, directories, metadata, network, process, clock,
|
||||
random, device or generic provider registry.
|
||||
* No crash-atomic replace: `ProjectFs::write_bytes` is one validated write, not
|
||||
a temp-file rename.
|
||||
* No file write in `pure` or `strict`.
|
||||
* No CM-A07 stdlib `print` migration.
|
||||
* No Windows/macOS evidence and no remote CI URL.
|
||||
|
||||
## 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 test -p marqdo-host --test resource_streams
|
||||
cargo test -p marqdo-cli --test resource_streams
|
||||
cargo test --workspace --locked
|
||||
```
|
||||
@@ -0,0 +1,144 @@
|
||||
# RFC-CM CM-A06 evidence: minimal Resource/Stream ABI
|
||||
|
||||
Date: 2026-11-20 (Asia/Shanghai)
|
||||
Repository: `marqdo-cli`
|
||||
Baseline: `a113d89` plus the uncommitted RFC-CM P0–P3 changes.
|
||||
Decision record: [ADR-0025](../adr/0025-minimal-resource-stream-abi.md)
|
||||
Related: [P1](2026-11-20-memory-p1.md),
|
||||
[P2 result/allocator](2026-11-20-result-and-free-list-p2.md),
|
||||
[STATUS §5](../STATUS.md).
|
||||
Scope: **first CM-A06 slice only**. Not the full P3 migration.
|
||||
|
||||
## Environment and gate
|
||||
|
||||
Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
|
||||
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace --locked PASS
|
||||
402 passed, 0 failed, 2 ignored (existing plugin-sdk doc-tests)
|
||||
```
|
||||
|
||||
No GitHub CI is available from this checkout; this is local evidence.
|
||||
|
||||
## Implemented slice
|
||||
|
||||
### Value and wire
|
||||
|
||||
* `Value::Resource(ResourceHandle)` is an opaque host-issued handle; fields are
|
||||
private, the constructor is host-only, and `display`/`repr` render only
|
||||
`Resource`.
|
||||
* `to_wire(Resource)` emits only `{"type":"resource"}`; `from_wire` rejects the
|
||||
tag. A `Resource` inside a list/map/table is equally rejected on decode.
|
||||
* The generic `Host::invoke` boundary rejects resources before dispatch, like
|
||||
`Memory`. Plugins/foreign kernels never receive either handle kind.
|
||||
|
||||
### Builtins
|
||||
|
||||
```text
|
||||
resource.open(kind, descriptor, rights) -> Resource
|
||||
resource.read(handle, memory, offset, max_bytes) -> Result {count, eof}
|
||||
resource.write(handle, memory, offset, length) -> Result {count}
|
||||
resource.close(handle) -> Result
|
||||
```
|
||||
|
||||
* `read` validates the destination region **before** reading from the provider
|
||||
and caps the request to the remaining bytes.
|
||||
* EOF is `{ok:true, value:{count:0, eof:true}}`, not an error.
|
||||
* Closed handles return `{ok:false, code:"resource.closed"}`; forged/cross-run/
|
||||
stale handles are fatal `runtime.resource`; unsupported kind/rights are
|
||||
`resource.unsupported`; missing grant is `permission.denied`.
|
||||
* Bytes move only as copied `Memory` ranges for the duration of the call. No
|
||||
host pointer is stored in a region.
|
||||
|
||||
### Providers in this slice
|
||||
|
||||
| Kind | Descriptor | Rights | Mode | Behavior |
|
||||
|---|---|---|---|---|
|
||||
| `stdio` | `stdout` | `write` | pure/project | appends to the program output buffer after the output-budget check |
|
||||
| `file` | project-relative path | `read` | project | bounded regular file loaded at open; chunked reads with EOF |
|
||||
| anything else | — | — | — | explicit `resource.unsupported` |
|
||||
|
||||
* `strict` refuses every `resource.open` with `permission.denied` (CM-A11
|
||||
fail-closed); no provider is silently enabled.
|
||||
* `pure` allows only stdio stdout (console grant), exactly the existing
|
||||
console exception; file resources are refused by an explicit mode check,
|
||||
even if a caller hand-constructs a matching `fs_read` grant.
|
||||
* File paths still go through `ProjectFs::resolve` (absolute paths, `..`,
|
||||
symlink escapes rejected) and require an `fs_read` glob grant.
|
||||
* File size is bounded by the existing 8 MiB read limit.
|
||||
* `resource.write` to stdout charges the existing output budget; a budget
|
||||
failure produces no output. There is no separate I/O-byte budget yet.
|
||||
|
||||
## Tests
|
||||
|
||||
### Host integration (`crates/marqdo-host/tests/resource_streams.rs`, 7)
|
||||
|
||||
```text
|
||||
pure_mode_writes_stdout_through_a_resource
|
||||
stdout_write_obeys_the_output_budget_atomically
|
||||
strict_mode_refuses_every_resource_open
|
||||
resource_handles_cannot_cross_the_generic_host_boundary
|
||||
pure_mode_refuses_file_resources_even_with_a_grant
|
||||
project_file_reads_are_chunked_and_require_a_grant
|
||||
traversal_and_unsupported_rights_are_refused
|
||||
```
|
||||
|
||||
### Host table unit tests (`crates/marqdo-host/src/resource.rs`, 3)
|
||||
|
||||
```text
|
||||
file_reads_are_chunked_with_eof
|
||||
forged_and_closed_handles_are_rejected
|
||||
stdout_is_not_readable_and_file_is_not_writable
|
||||
```
|
||||
|
||||
### CLI integration (`crates/cli/tests/resource_streams.rs`, 2)
|
||||
|
||||
```text
|
||||
project_file_stream_reads_chunks_into_memory
|
||||
data.txt = "abcdef"
|
||||
run index.mq.md --allow-read data.txt --json
|
||||
results: counts 2/4/0, eof false/true/true, bytes 97..102
|
||||
resource.close => ok:true
|
||||
|
||||
file_stream_requires_a_read_grant
|
||||
same document without --allow-read
|
||||
exit 1, error.code = permission.denied, no bytes read
|
||||
```
|
||||
|
||||
### Semantic fixture 66
|
||||
|
||||
`tests/conformance/semantics/66-resource-stdout-write.mq.md`:
|
||||
|
||||
* `.mq.md` UTF-8 encoder writes `"你好,资源!\n"` into `Memory`;
|
||||
* `resource.open("stdio","stdout",["write"])`;
|
||||
* `resource.write` reports count 19;
|
||||
* `resource.close` succeeds;
|
||||
* a second `resource.read` on the closed handle returns
|
||||
`{ok:false,code:"resource.closed"}`;
|
||||
* captured program stdout is exactly `你好,资源!\n`.
|
||||
|
||||
## What this does not prove
|
||||
|
||||
* No file write, directory listing, rename, metadata, network, DNS, TLS,
|
||||
process, clock, random or device resources.
|
||||
* No generic third-party provider registry (CM-A09) and no Worker/ABI byte
|
||||
transfer.
|
||||
* No stdlib `print` migration (CM-A07); `打印` still uses `HostOp::Print`.
|
||||
* No strict-mode stream support. Strict L1 is unchanged and refuses opens.
|
||||
* No async/nonblocking/seek/zero-copy and no per-stream deadline.
|
||||
* No Windows/macOS native lane and no remote CI URL.
|
||||
* Host-in-process I/O is not an OS sandbox; project mode remains cooperative.
|
||||
|
||||
## 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 test -p marqdo-host
|
||||
cargo test -p marqdo-cli --test resource_streams
|
||||
cargo test -p marqdo-cli --test conformance_semantics
|
||||
cargo test --workspace --locked
|
||||
```
|
||||
@@ -0,0 +1,361 @@
|
||||
# RFC-CM CM-A05 evidence: `Result` convention and first-fit free-list allocator
|
||||
|
||||
Date: 2026-11-20 (Asia/Shanghai)
|
||||
Repository: `marqdo-cli`
|
||||
Baseline: `a113d89` plus the uncommitted RFC-CM P0/P1/P2 changes.
|
||||
Decision records: [ADR-0024](../adr/0024-recoverable-result-convention.md),
|
||||
[ADR-0023](../adr/0023-minimal-structure-observation-and-construction.md)
|
||||
Related: [P1](2026-11-20-memory-p1.md),
|
||||
[P2 closure](2026-11-20-memory-p2-closure.md),
|
||||
[structure API](2026-11-20-structure-api-p2.md).
|
||||
Scope: CM-A05 convention, a `.mq.md` first-fit allocator, and the later P2
|
||||
fixtures 56–59 (binary tree, CSV splitter, hash table, UTF-8 encoder). Full P2
|
||||
gate still **not** passed.
|
||||
|
||||
## Environment and gate
|
||||
|
||||
Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
|
||||
|
||||
```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)
|
||||
```
|
||||
|
||||
No GitHub CI is available from this checkout; this is local evidence.
|
||||
|
||||
## `Result` convention (ADR-0024)
|
||||
|
||||
Success and failure are ordinary `Map` values:
|
||||
|
||||
```text
|
||||
success: {ok: true, value: <Value>}
|
||||
failure: {ok: false, code: <Text>, message: <Text>[, details: <Map>]}
|
||||
```
|
||||
|
||||
No `Result` value type, exception, `try`/`catch` or automatic propagation was
|
||||
added. Expected conditions return this shape; wrong types, out-of-bounds,
|
||||
invalid/stale handles, budget exhaustion and capability denial remain fatal
|
||||
`RuntimeError`s.
|
||||
|
||||
## Allocator fixture 55
|
||||
|
||||
`tests/conformance/semantics/55-first-fit-free-list-allocator.mq.md` is a
|
||||
pure `.mq.md` first-fit allocator over `Memory`:
|
||||
|
||||
* 8-byte block header: total block size (`u32`) and free-list next (`u32`);
|
||||
* region header: free-list head at offset 0, bump pointer at offset 4;
|
||||
* allocation rounds the request up to an 8-byte multiple;
|
||||
* first fit walks the free list, splits a fitting block when the remainder is
|
||||
at least 16 bytes, otherwise unlinks it;
|
||||
* no suitable free block falls back to the bump pointer;
|
||||
* no space returns `{ok:false, code:"alloc.no_space", message:...}`;
|
||||
* the free list is address-sorted; `释放` inserts a block and coalesces it
|
||||
with an address-adjacent successor and predecessor without erasing payload
|
||||
bytes.
|
||||
|
||||
Observed result (compact wire values):
|
||||
|
||||
```text
|
||||
甲 (8 bytes) -> {ok:true, value:16}
|
||||
乙 (16 bytes) -> {ok:true, value:32}
|
||||
丙 (8 bytes) -> {ok:true, value:16} # reuses 甲's freed block
|
||||
丁 (4 bytes) -> {ok:true, value:16} # reuses the same block
|
||||
戊 (16 bytes) -> {ok:true, value:32} # reuses 乙's freed block
|
||||
己 (64 bytes) -> {ok:true, value:56}
|
||||
庚 (8 bytes) -> {ok:true, value:56} # split from 己
|
||||
辛 (16 bytes) -> {ok:true, value:72} # split remainder
|
||||
壬 (8 bytes) -> {ok:true, value:96} # split remainder
|
||||
癸 (8 bytes) -> {ok:true, value:112} # exact remainder
|
||||
failure -> {ok:false, code:"alloc.no_space",
|
||||
message:"没有足够的空闲空间"}
|
||||
payload bytes -> 44, 55, 66, 77 at 庚/辛/壬/癸
|
||||
```
|
||||
|
||||
A second region isolates coalescing from bump allocation:
|
||||
|
||||
```text
|
||||
甲2 8B, 乙2 8B, 丙2 8B -> payloads 16, 32, 48
|
||||
fill 65472B -> consumes the rest of the 64 KiB region
|
||||
free 甲2, 乙2, 丙2 -> address-adjacent blocks merge to one 48-byte block
|
||||
丁2 40B (need 48) -> {ok:true, value:16} # only the merged block fits
|
||||
戊2 8B -> {ok:false, alloc.no_space} # bump space exhausted
|
||||
```
|
||||
|
||||
Without coalescing, `丁2` would see only three 16-byte fragments and the
|
||||
exhausted bump pointer, so it would fail; the observed success at offset 16
|
||||
proves the merge.
|
||||
|
||||
The payload addresses do not overlap:
|
||||
`庚=56..71`, `辛=72..95`, `壬=96..111`, `癸=112..127`. The earlier bytes
|
||||
`甲=16..23`, `乙=32..47`, `戊=32..47` show deliberate reuse after `释放`
|
||||
(the block is not zeroed; callers must initialise a block they allocate).
|
||||
|
||||
`cargo test -p marqdo-cli --test conformance_semantics` passes with fixture 55
|
||||
included. `cargo run -p marqdo-cli -- run
|
||||
tests/conformance/semantics/55-first-fit-free-list-allocator.mq.md --json`
|
||||
returns `success: true` with the checked-in expected value.
|
||||
|
||||
## Binary tree fixture 56
|
||||
|
||||
`tests/conformance/semantics/56-memory-binary-tree.mq.md` is a second
|
||||
`.mq.md` structure over `Memory`:
|
||||
|
||||
* 16-byte nodes: one-byte value at offset 0, left child offset at 4, right
|
||||
child offset at 8; `0` is the empty child;
|
||||
* region header at offset 0 is the bump pointer, initialised to 8;
|
||||
* `插入` is recursive and writes the child link through its parent block;
|
||||
* `遍历` is recursive in-order and builds the result with `list.concat`;
|
||||
* inserted `[5, 3, 8, 1, 4, 7, 9]`, returned:
|
||||
|
||||
```text
|
||||
root=8
|
||||
in-order=[1,3,4,5,7,8,9]
|
||||
root.left=24
|
||||
root.right=40
|
||||
```
|
||||
|
||||
No Rust tree/container algorithm, new `HostOp`, `Value` variant or Markdown
|
||||
syntax was added. `cargo test -p marqdo-cli --test conformance_semantics`
|
||||
passes with fixture 56 included.
|
||||
|
||||
## CSV row splitter fixture 57
|
||||
|
||||
`tests/conformance/semantics/57-csv-row-splitter.mq.md` splits a single CSV row
|
||||
using only `.mq.md` and the CM-A04 primitives:
|
||||
|
||||
* `text.codepoints` enumerates Unicode scalar values;
|
||||
* `text.from_codepoint` reconstructs each character;
|
||||
* `list.append` builds the field list, `list.concat` appends the final field;
|
||||
* comma is the separator; empty fields are preserved.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
"甲,乙,,丙" -> ["甲","乙","","丙"]
|
||||
"" -> [""]
|
||||
"a,b" -> ["a","b"]
|
||||
```
|
||||
|
||||
Quoted fields, embedded commas, doubled quotes and line breaks are **not**
|
||||
implemented. This is a C05 demonstration, not a claim that CSV is complete.
|
||||
|
||||
## Hash table fixture 58
|
||||
|
||||
`tests/conformance/semantics/58-memory-hash-table.mq.md` implements an
|
||||
open-addressing hash table over `Memory`:
|
||||
|
||||
* 8-byte header: element count at 0, slot count at 4; slots from offset 8,
|
||||
8 bytes each (`key:u32`, `value:u32`);
|
||||
* key `0` means empty, so business keys start at 1;
|
||||
* hash is `key % capacity` with linear probing;
|
||||
* existing keys update in place without incrementing the count; a full table
|
||||
returns `{ok:false, code:"hash.full", ...}`.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
capacity 32: insert 5->50, 37->370 (collision at slot 5), 12->120, update 5->55
|
||||
lookup 5 => 55, 37 => 370, 12 => 120, 99 => None
|
||||
count => 3
|
||||
capacity 2: insert 1, 2, then 4 => hash.full
|
||||
```
|
||||
|
||||
No Rust hash container, `HostOp` or new `Value` type was added.
|
||||
|
||||
## UTF-8 encoder fixture 59
|
||||
|
||||
`tests/conformance/semantics/59-utf8-encoder.mq.md` writes UTF-8 bytes into
|
||||
`Memory` using `text.codepoints` and byte indexing:
|
||||
|
||||
* code points below `0x80` -> 1 byte;
|
||||
* below `0x800` -> 2 bytes; below `0x10000` -> 3 bytes; otherwise 4 bytes;
|
||||
* the fixture encodes `"Aé中𝄞"` to
|
||||
`[65, 195, 169, 228, 184, 173, 240, 157, 132, 158]` with length 10.
|
||||
|
||||
## UTF-8 decoder fixture 60
|
||||
|
||||
`tests/conformance/semantics/60-utf8-decoder.mq.md` decodes UTF-8 from
|
||||
`Memory` and validates every sequence:
|
||||
|
||||
* `utf8.truncated` when a multi-byte sequence runs past the region length;
|
||||
* `utf8.invalid_continuation` when a byte outside `0x80..0xBF` appears in a
|
||||
continuation position;
|
||||
* `utf8.invalid_scalar` for overlong 3-byte forms, surrogates and values above
|
||||
`0x10FFFF`;
|
||||
* `utf8.invalid_lead` for `0x80..0xC1` and `0xF5..0xFF` lead bytes.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
[65,195,169,228,184,173] -> ok "Aé中"
|
||||
[228,184] -> utf8.truncated
|
||||
[228,65,173] -> utf8.invalid_continuation
|
||||
[237,160,128] -> utf8.invalid_scalar
|
||||
[240,157,132,158] -> ok "𝄞"
|
||||
```
|
||||
|
||||
Together with fixture 59 this closes the C04 encode/decode demonstration using
|
||||
only `.mq.md`; no Rust UTF-8 codec is called.
|
||||
|
||||
## Graph adjacency fixture 61
|
||||
|
||||
`tests/conformance/semantics/61-memory-graph-adjacency.mq.md` stores a directed
|
||||
graph in `Memory`:
|
||||
|
||||
* 16-byte node: one-byte value at 0, edge-list head `u32` at 4;
|
||||
* 8-byte edge: target node offset at 0, next edge offset at 4;
|
||||
* edges are head-inserted, so traversal returns the most recently added edge
|
||||
first;
|
||||
* nodes `甲/乙/丙` at offsets 8/24/40, edges `甲→乙`, `甲→丙`, `乙→丙`.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
甲=8, 乙=24, 丙=40
|
||||
邻接(甲) => [40, 24] # 丙 then 乙 (head insertion)
|
||||
邻接(乙) => [40]
|
||||
邻接(丙) => []
|
||||
```
|
||||
|
||||
No Rust graph container, `HostOp` or new `Value` type was added.
|
||||
|
||||
## JSON subset parser fixture 62
|
||||
|
||||
`tests/conformance/semantics/62-json-array-parser.mq.md` is a recursive
|
||||
descent parser over `text.codepoints`:
|
||||
|
||||
* supports nested arrays and objects, strings with standard escapes including
|
||||
`\uXXXX`, non-negative and negative integers, `true`/`false`/`null`,
|
||||
whitespace, and returns `{ok,value,next}`;
|
||||
* errors are `Result` maps: `json.unexpected_eof`, `json.invalid_array`,
|
||||
`json.invalid_object`, `json.invalid_string`, `json.invalid_number`,
|
||||
`json.invalid_literal`, `json.unexpected_token`;
|
||||
* floats are explicitly out of scope.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
" [1, 23, [4, 5], -6] " -> ok [1,23,[4,5],-6], next=20
|
||||
"[1 2]" -> json.invalid_array
|
||||
"[1," -> json.unexpected_eof
|
||||
{"a": 1, "b": [true, null, "说\"好"]}
|
||||
-> ok {a:1, b:[true,null,"说\"好"]}, next=35
|
||||
"\"a\\nb\"" -> ok "a\nb", next=6
|
||||
```
|
||||
|
||||
No Rust JSON parser, new `Value` type or `HostOp` was added.
|
||||
|
||||
## Bytecode VM fixture 63
|
||||
|
||||
`tests/conformance/semantics/63-memory-bytecode-vm.mq.md` is a small stack
|
||||
bytecode machine written entirely in `.mq.md`:
|
||||
|
||||
* program bytes at offset 0; stack at a caller-provided `Memory` offset;
|
||||
* instruction set: `1=PUSH imm8`, `2=ADD`, `3=MUL`, `5=JMP`, `6=JZ`, `7=HALT`;
|
||||
* state (`pc`, `sp`, running, error) is ordinary local state; the stack and
|
||||
program live in `Memory`;
|
||||
* `(5 + 7) * 3` executes to `{ok:true, value:36}`;
|
||||
* a `JZ` program jumps over a `PUSH 99` and returns `{ok:true, value:42}`.
|
||||
|
||||
No Rust VM, opcode enum, `HostOp` or new `Value` type was added.
|
||||
|
||||
## Integer codecs fixture 64
|
||||
|
||||
`tests/conformance/semantics/64-memory-integer-codecs.mq.md` provides generic
|
||||
big-endian and variable-length integer codecs over `Memory`:
|
||||
|
||||
* `写大端(内存,基址,值,宽度)` writes the least significant byte last, so the
|
||||
result is big-endian for widths 2, 4 and 8;
|
||||
* `读大端(内存,基址,宽度)` rebuilds the integer with `value * 256 + byte`;
|
||||
* `写变长`/`读变长` are LEB128 (7-bit continuation) with the consumed byte
|
||||
count.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
u16 4660 -> 4660
|
||||
u32 305419896 -> 305419896
|
||||
u64 1311768467463790320 -> 1311768467463790320
|
||||
u64 18446744073709551615 -> 18446744073709551615
|
||||
varint 123456789 -> 4 bytes, decoded 123456789, consumed 4
|
||||
last two bytes of u64::MAX -> 255, 255
|
||||
```
|
||||
|
||||
No Rust codec builtin or new `Value` type was added.
|
||||
|
||||
## Table sort fixture 65
|
||||
|
||||
`tests/conformance/semantics/65-table-sort-stdlib.mq.md` sorts a table by a
|
||||
column using only CM-A04 primitives:
|
||||
|
||||
* `table.row` extracts rows, `table.cell` compares the sort column;
|
||||
* `插入有序` builds a new row list with `list.append` and binary condition
|
||||
branches (insertion sort);
|
||||
* `表(列名, 已排序)` rebuilds the result; the input table is unchanged.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
原表 rows: 甲87, 乙92, 丙71
|
||||
升序 rows: 丙71, 甲87, 乙92
|
||||
原表: unchanged
|
||||
```
|
||||
|
||||
No Rust table sort, `HostOp` or new `Value` type was added.
|
||||
|
||||
## Table join fixture 67
|
||||
|
||||
`tests/conformance/semantics/67-table-join-stdlib.mq.md` joins two tables on a
|
||||
column using only CM-A04 primitives:
|
||||
|
||||
* nested `table.row` / `table.cell` loops compare the join keys;
|
||||
* matches append `list.concat(left_row, right_row)` to the output rows;
|
||||
* `表(list.concat(headers...), rows)` rebuilds the result; both inputs are
|
||||
unchanged.
|
||||
|
||||
Observed: left `甲/乙/丙`, right `乙/甲/丁` on column 0 yields the two matched
|
||||
rows `甲 87 甲 B` and `乙 92 乙 A`. No Rust join or `HostOp` was added.
|
||||
|
||||
## Quoted CSV fixture 68
|
||||
|
||||
`tests/conformance/semantics/68-csv-quoted-row.mq.md` parses one CSV row with
|
||||
quoted fields:
|
||||
|
||||
* `"..."` quotes fields, `""` is a literal quote, commas inside quotes are
|
||||
preserved;
|
||||
* empty fields are preserved;
|
||||
* multi-line fields and whitespace trimming are out of scope.
|
||||
|
||||
Observed:
|
||||
|
||||
```text
|
||||
甲,"乙,丙","说""好" -> ["甲", "乙,丙", "说"好"]
|
||||
a,,c -> ["a", "", "c"]
|
||||
"" -> [""]
|
||||
"a""b",c -> ["a"b", "c"]
|
||||
```
|
||||
|
||||
No Rust CSV parser or new `Value` type was added.
|
||||
|
||||
## What remains open
|
||||
|
||||
* JSON floats, table group, and an independent `marqdo-stdlib` repository;
|
||||
* CM-A06 `Resource`/`Stream` byte-transfer ABI; EOF/partial semantics are
|
||||
reserved by ADR-0024 but not implemented;
|
||||
* CM-A07–CM-A11 (stdlib naming, Table storage, provider ABI, packaging,
|
||||
strict resource policy) and P3–P6;
|
||||
* the RFC §10.5 frozen-CLI closure lane and Windows/macOS evidence.
|
||||
|
||||
## 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 test -p marqdo-cli --test conformance_semantics
|
||||
cargo run -q -p marqdo-cli -- run \
|
||||
tests/conformance/semantics/55-first-fit-free-list-allocator.mq.md --json
|
||||
cargo test --workspace --locked
|
||||
```
|
||||
@@ -0,0 +1,94 @@
|
||||
# RFC-CM CM-A07 Compat-A evidence: `.mq.md` print prototype
|
||||
|
||||
Date: 2026-11-20 (Asia/Shanghai)
|
||||
Repository: `marqdo-cli`
|
||||
Baseline: `a113d89` plus the uncommitted RFC-CM P0–P3 changes.
|
||||
Decision record: [ADR-0027](../adr/0027-print-migration-compat-a.md)
|
||||
Related: [Resource P3](2026-11-20-resource-stream-p3.md),
|
||||
[file write](2026-11-20-resource-file-write-p3.md), [STATUS §5](../STATUS.md).
|
||||
Scope: **Compat-A only**. Builtin `打印` is not migrated; no alias routing and
|
||||
no removal of `HostOp::Print`.
|
||||
|
||||
## Environment and gate
|
||||
|
||||
Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
|
||||
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace --locked PASS
|
||||
407 passed, 0 failed, 2 ignored (existing plugin-sdk doc-tests)
|
||||
```
|
||||
|
||||
No GitHub CI is available from this checkout; this is local evidence.
|
||||
|
||||
## Prototype
|
||||
|
||||
Ordinary `.mq.md` modules under `examples/stdlib/`:
|
||||
|
||||
| File | Responsibility |
|
||||
|---|---|
|
||||
| `format.mq.md` | `显示` for Unit/None/Bool/Int/Float/Text/List/Map/Table, `值显示` (repr), `转义文本`, `列表显示`, `映射显示`, `表格显示`, `连接文本` |
|
||||
| `text.mq.md` | `utf8编码(文本, 内存, 基址)` — 1–4 byte UTF-8 into `Memory` |
|
||||
| `io.mq.md` | `写文本` (encode → `resource.write(stdout)` → close) and `写值` (format + newline) |
|
||||
| `demo.mq.md` | side-by-side `io.写值(x)` and builtin `打印(x)` for a nested list and a table |
|
||||
|
||||
The call chain is exactly the RFC target shape:
|
||||
|
||||
```text
|
||||
io.写值(value)
|
||||
-> format.显示(value) # .mq.md value formatting, no Rust display()
|
||||
-> text.utf8编码(text, memory) # .mq.md UTF-8 encoder
|
||||
-> resource.open(stdout)
|
||||
-> resource.write(memory, ...) # bytes through Memory
|
||||
-> resource.close(stdout)
|
||||
```
|
||||
|
||||
No `HostOp`, no new builtin, no parser change and no special stdlib dispatch.
|
||||
The module is loaded only through an explicit Markdown import alias.
|
||||
|
||||
## Output comparison
|
||||
|
||||
```text
|
||||
$ marqdo run examples/stdlib/demo.mq.md
|
||||
["文本", 2, 1.5, [3, true], {a: 1, b: "x"}, None]
|
||||
["文本", 2, 1.5, [3, true], {a: 1, b: "x"}, None]
|
||||
Table[名称 | 分数]{甲 | 87; 乙 | 92}
|
||||
Table[名称 | 分数]{甲 | 87; 乙 | 92}
|
||||
```
|
||||
|
||||
The first and third lines are `io.写值`; the second and fourth are builtin
|
||||
`打印`. They are byte-identical.
|
||||
|
||||
CLI test:
|
||||
`crates/cli/tests/examples_r6.rs::mqmd_stdlib_print_output_matches_builtin_print`
|
||||
asserts exactly four lines, pairwise equality, and the exact list/table text.
|
||||
|
||||
## Covered and uncovered values
|
||||
|
||||
Covered by Compat-A comparison: `Unit`, `None`, `Bool`, `Int`, `Float`, `Text`,
|
||||
`List`, `Map`, `Table`.
|
||||
|
||||
Not covered: `Formula`, `Code`, `FunctionRef`, `PluginHandle`. The language
|
||||
still has no public observation for the module/name/handle identity needed to
|
||||
reproduce `Value::display()`/`repr()` for those types; adding it is a CM-A04
|
||||
extension, not part of this slice. This is the explicit blocker for Compat-B.
|
||||
|
||||
## What is not migrated
|
||||
|
||||
* `打印`/`print` still resolves to the existing builtin and `HostOp::Print`.
|
||||
* No alias table, no bundled stdlib resolution, no `std` package.
|
||||
* No stdlib version/digest or offline distribution (CM-A10).
|
||||
* No Compat-B/C comparison lane or removal of the Rust `Value::display()` path.
|
||||
* The demo/stdlib is an `examples/` prototype, 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
|
||||
cargo run -q -p marqdo-cli -- run examples/stdlib/demo.mq.md
|
||||
cargo test -p marqdo-cli --test examples_r6
|
||||
cargo test --workspace --locked
|
||||
```
|
||||
@@ -0,0 +1,110 @@
|
||||
# RFC-CM CM-A04 evidence: minimal structure observation and construction
|
||||
|
||||
Date: 2026-11-20 (Asia/Shanghai)
|
||||
Repository: `marqdo-cli`
|
||||
Baseline: `a113d89` plus the uncommitted RFC-CM P0/P1/P2 changes.
|
||||
Decision record: [ADR-0023](../adr/0023-minimal-structure-observation-and-construction.md)
|
||||
Related: [P1 memory evidence](2026-11-20-memory-p1.md),
|
||||
[P2 closure evidence](2026-11-20-memory-p2-closure.md),
|
||||
[STATUS §5](../STATUS.md).
|
||||
Scope: CM-A04 only. The full RFC-CM-0002 P2 gate is **not** passed.
|
||||
|
||||
## Environment and gate
|
||||
|
||||
Ubuntu 26.04 development container, Linux x86_64, Rust 1.100.0.
|
||||
|
||||
```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 pre-existing `marqdo-plugin-sdk` doc-tests. No
|
||||
GitHub CI was available from this checkout; this is local evidence.
|
||||
|
||||
## Builtins added (pure, no `HostOp`, no capability)
|
||||
|
||||
| Name | Semantics |
|
||||
|---|---|
|
||||
| `list.append` | new list with one appended value; input unchanged |
|
||||
| `list.concat` | new concatenated list; inputs unchanged |
|
||||
| `map.keys` | Text keys in canonical sorted order |
|
||||
| `map.has` | key membership |
|
||||
| `map.get` | stored value or `None`; `map.has` disambiguates a stored `None` |
|
||||
| `map.set` | new map with the key; input unchanged |
|
||||
| `map.remove` | new map without the key; missing key is a no-op |
|
||||
| `text.codepoints` | Unicode scalar values as `Int`, in order |
|
||||
| `text.from_codepoint` | one-scalar Text, or `None` for surrogate/out-of-range |
|
||||
| `table.columns` | header names in column order |
|
||||
| `table.row` | new list of row cells; non-negative coordinate |
|
||||
| `table.cell` | cell value; non-negative row/column |
|
||||
|
||||
No `sort`, `filter`, `join`, `group`, JSON/CSV, `table.set_cell`, mutable
|
||||
List/Map or new Markdown syntax was added. Constructors never mutate their
|
||||
arguments; this preserves INV-02.
|
||||
|
||||
## Semantic fixtures
|
||||
|
||||
```text
|
||||
51-list-map-value-semantics:
|
||||
original list [1,2] unchanged; appended [1,2,3]
|
||||
original map {a:1,b:2} unchanged; map.set c=3 then remove a
|
||||
keys after remove => ["b","c"]
|
||||
map.has(original, "c") => false
|
||||
map.get(original, "z") => None
|
||||
list.concat([1],[2,3]) => [1,2,3]
|
||||
|
||||
52-text-codepoints:
|
||||
text.codepoints("aé中") => [97, 233, 20013]
|
||||
text.from_codepoint(20013) => "中"
|
||||
text.from_codepoint(0xD800) => None
|
||||
text.from_codepoint(0x110000) => None
|
||||
|
||||
53-table-projection:
|
||||
columns => ["名称","分数"]
|
||||
row 1 => ["乙",92]
|
||||
cell(0,1) => 87
|
||||
长度(table) => 2
|
||||
|
||||
54-table-filter-stdlib:
|
||||
原表 3 rows, threshold 80
|
||||
结果 table has 2 rows (甲 87, 乙 92)
|
||||
原表 is still 3 rows and byte-for-byte the same logical table
|
||||
```
|
||||
|
||||
Fixture 54 is the first `.mq.md` algorithm over the new primitives: it uses
|
||||
`table.columns`, `table.cell`, `table.row`, `list.append` and `表` to rebuild a
|
||||
filtered table. It is a conformance document, not a shipped `table.filter`
|
||||
builtin; no Rust table algorithm was added.
|
||||
|
||||
CLI confirms all three return `success: true` with the checked-in wire values.
|
||||
|
||||
## Runtime negatives
|
||||
|
||||
| Fixture | Expected code | Observed |
|
||||
|---|---|---|
|
||||
| `19-list-append-wrong-type` | `runtime.type` | `runtime.type` |
|
||||
| `20-table-cell-out-of-bounds` | `runtime.index` | `runtime.index` |
|
||||
| `21-map-key-not-text` | `runtime.type` | `runtime.type` |
|
||||
|
||||
## Focused command
|
||||
|
||||
```text
|
||||
cargo test -p marqdo-cli --test conformance_semantics --test negative
|
||||
semantic_goldens_match_end_to_end_execution ... ok
|
||||
runtime_negative_goldens ... ok
|
||||
```
|
||||
|
||||
## What remains open
|
||||
|
||||
* CM-A05 recoverable `Result`/EOF/partial model. This report predates ADR-0024,
|
||||
which now freezes the `Result` map convention; the Stream EOF/partial part
|
||||
remains CM-A06. `map.get` returning `None` is a lookup convention, **not**
|
||||
that contract.
|
||||
* CM-A06 `Resource`/`Stream` ABI, CM-A07 stdlib naming/alias, CM-A08 Table
|
||||
storage/physical migration, CM-A09 provider ABI, CM-A10 stdlib packaging,
|
||||
CM-A11 strict resource policy.
|
||||
* A separate `marqdo-stdlib` repository, graph containers, a full JSON parser,
|
||||
quoted/escaped CSV and the RFC §10.5 frozen-CLI closure lane.
|
||||
* Windows/macOS native lanes. No remote CI URL exists for this working tree.
|
||||
Reference in new issue
Block a user