feat(stdlib): add path and regex product modules
This commit is contained in:
1 parent
bde6f1d0ba
commit
cffb6790be
10 files changed
+758
-8
No files matched your search
+7
-5
@@ -58,7 +58,7 @@ byte-identical).
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace --locked PASS
|
||||
469 passed, 0 failed, 2 ignored; includes 7/7 Linux security tests
|
||||
471 passed, 0 failed, 2 ignored; includes 7/7 Linux security tests
|
||||
```
|
||||
|
||||
The documentation and test migration is local work; re-run this block after it
|
||||
@@ -201,10 +201,12 @@ This is still a **local VM lane**, not a self-hosted GitHub Actions security URL
|
||||
storage are unchanged. `std:fs/file` provides bounded `读文本`/`写文本`/`复制文件`
|
||||
over the existing `resource.*` ABI plus `存在`/`元数据`/`列出目录`/`创建目录`/
|
||||
`删除`/`重命名` over `resource.request` (ADR-0041); `data/json`/`data/csv`
|
||||
provide recursive JSON and quoted single-row CSV product parsers. Append/seek/
|
||||
watch, recursive walk, streaming JSON/CSV and a JSON depth bound remain open.
|
||||
provide recursive JSON and quoted single-row CSV product parsers; `path` and a
|
||||
`regex` subset are pure `.mq.md`. Append/seek/watch, recursive walk, streaming
|
||||
JSON/CSV, a JSON depth bound, regex groups/alternation and `datetime`/`env`/
|
||||
`process` remain open.
|
||||
- Bundled standard library (CM-A10, ADR-0028): `stdlib/` ships
|
||||
`format`/`text`/`io`/`fs`/`data`; explicit `std:` imports resolve only inside the bundle;
|
||||
`format`/`text`/`io`/`fs`/`data`/`path`/`regex`; explicit `std:` imports resolve only inside the bundle;
|
||||
a SHA-256 digest over `*.mq.md` is verified before loading; Analysis records
|
||||
`project.stdlib`; a frozen-binary test asserts the CLI hash is unchanged after
|
||||
running a `std:io` project and that tampering is rejected. `打印/print` is
|
||||
@@ -230,7 +232,7 @@ This is still a **local VM lane**, not a self-hosted GitHub Actions security URL
|
||||
status/index links and SHA-pinned evidence; `crates/cli/tests/architecture_boundaries.rs`
|
||||
pins the workspace graph, `marqdo-runtime -> marqdo-host`, the bundled stdlib
|
||||
digest and the stdio/file/TCP endpoints; `crates/cli/tests/stdlib_product.rs`
|
||||
runs every public stdlib module (`console/csv/demo/format/fs/http/io/json/stream/table/text/utf8`)
|
||||
runs every public stdlib module (`console/csv/demo/format/fs/http/io/json/path/regex/stream/table/text/utf8`)
|
||||
through `std:` imports over `stdlib/tests/*.mq.md`. `tools/pack-stdlib.py`
|
||||
now sorts `.mq.md` by the same relative path key as the CLI. Source/test baseline
|
||||
`0d40de7`; later docs-only commits keep code/test bytes identical. Evidence:
|
||||
|
||||
@@ -18,7 +18,7 @@ platform".
|
||||
| Dimension | Current state | Source |
|
||||
|---|---|---|
|
||||
| Implemented | Rust workspace `0.1.0`: Markdown/frontend/IR, tree-walk runtime, `Memory`, capability host, Tool/Analysis/Trace, Plugin ABI, Foreign kernels, bundled stdlib, CLI composition root | `Cargo.toml`, `crates/`, `stdlib/` |
|
||||
| Tested locally | `cargo test --workspace --locked`: **469 passed, 0 failed, 2 ignored** on Linux x86_64 at the baseline | `docs/STATUS.md` §3 |
|
||||
| Tested locally | `cargo test --workspace --locked`: **471 passed, 0 failed, 2 ignored** on Linux x86_64 at the baseline | `docs/STATUS.md` §3 |
|
||||
| Bundled stdlib released | In-repo bundle `marqdo-stdlib@0.1.0`, SHA-256 digest verified before loading; it is **not** an external registry package | `stdlib/stdlib.json`, `stdlib/README.md` |
|
||||
| Multi-platform verified | Linux local gate is the only executed lane here; Windows/macOS native lanes are **UNVERIFIED**, and the GitHub security lane remains a **VM-only** gate | `docs/STATUS.md` §1, §4 |
|
||||
|
||||
@@ -90,6 +90,8 @@ review RFC, not a new crate per provider.
|
||||
| `resource.request` | `resource.request("fs.exists|metadata|list|mkdir|remove|rename", paths)`; project mode, grant-checked, recoverable fs Result | implemented `fs.*`; no seek/append/watch | `resource_streams`, `stdlib_product` |
|
||||
| `std:data/json` | `json.解析(文本)` -> Result with nested Value; `json.格式化(值)` -> Text | implemented (recursive, recoverable errors) | `stdlib_product` |
|
||||
| `std:data/csv` | `csv.解析行(文本)` -> Result with List<Text>; `csv.格式化行(列表)` -> Text | implemented (single row, quoted) | `stdlib_product` |
|
||||
| `std:path` | `path.连接/文件名/目录名/扩展名/规范/是否绝对`; lexical only | implemented (no I/O) | `stdlib_product` |
|
||||
| `std:regex` | `regex.匹配/搜索` with `^ $ . * + ? [...]` escapes | implemented subset; no groups/alternation | `stdlib_product` |
|
||||
| file metadata / directory / rename / remove / mkdir | not part of the current Resource contract | **not implemented**; needs a separate Resource Operation ADR | — |
|
||||
| TCP | `resource.open("tcp", ip:port, ["read","write"])`; exact IP grant, 5 s timeout | implemented; no DNS/TLS/server socket/UDP | `tcp_endpoint`, `http_over_tcp` |
|
||||
| HTTP/1.1 | `stdlib/net/http.mq.md`: status/header/chunked-byte parse, request build | implemented over an already-authorized TCP stream; not a DNS/TLS client | `stdlib_http`, `http_over_tcp`, `stdlib_product` |
|
||||
@@ -121,7 +123,7 @@ that a phase is complete.
|
||||
| P1 | `crates/cli/src/commands.rs` and `crates/marqdo-host/src/host.rs` still mix multiple responsibilities | open refactor, behavior-preserving |
|
||||
| P2 | HTTP parsing is Unicode-codepoint oriented; a general byte body is not the only path | open; convert before a general network release |
|
||||
| P2 | No DNS, TLS, listener or UDP provider | open |
|
||||
| P2 | No `std:path`, `std:regex`, `std:datetime`, `std:env`, `std:process`, secure random or compression | open |
|
||||
| P2 | `std:path` and a regex subset are implemented; no `std:datetime`, `std:env`, `std:process`, secure random or compression | open |
|
||||
| P2 | Memory limits: 16 MiB per region, 64 MiB per run | current budget, not a product limit |
|
||||
| P3 | No concurrency tasks, atomics or cancellable long-running scheduling | open; separate ADR |
|
||||
| P3 | No native optimizer/JIT or columnar numeric backend | open; benchmark-first |
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
# Evidence: `std:path` and `std:regex`
|
||||
|
||||
Date: 2026-11-21 (Asia/Shanghai)
|
||||
Source baseline: `bde6f1d0ba6f3ab19829ea63e5e85f1df84979a4`
|
||||
Repository: `marqdo-cli`
|
||||
RFC item: P2 pure path/regex stdlib APIs
|
||||
|
||||
## Implemented
|
||||
|
||||
`stdlib/path.mq.md` (pure `.mq.md`):
|
||||
|
||||
- `连接(片段列表)` skips empty segments and inserts one `/`.
|
||||
- `文件名`, `目录名`, `扩展名` split on the last `/` and `.`.
|
||||
- `规范(路径)` lexically folds `.`, empty segments and `..`, keeps a leading
|
||||
`/`; it never touches the filesystem.
|
||||
- `是否绝对(路径)`.
|
||||
|
||||
`stdlib/regex.mq.md` (pure `.mq.md`):
|
||||
|
||||
- `匹配(模式, 文本)` requires a full match; `搜索(模式, 文本)` tries every
|
||||
start position.
|
||||
- Supports `^`, `$`, `.`, `*`, `+`, `?`, `[...]` ranges/negation and
|
||||
backslash escapes. Recursive token matcher with backtracking.
|
||||
- Invalid patterns are recoverable `regex.invalid`; groups/alternation are
|
||||
`regex.unsupported`.
|
||||
|
||||
No Rust builtin or host operation was added.
|
||||
|
||||
## Tests
|
||||
|
||||
`stdlib/tests/path.mq.md` and `stdlib/tests/regex.mq.md` run through
|
||||
`std:path`/`std:regex` and are pinned by
|
||||
`crates/cli/tests/stdlib_product.rs` (10 product tests total).
|
||||
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
cargo clippy --workspace --all-targets -- -D warnings PASS
|
||||
cargo test --workspace 471 passed, 0 failed, 2 ignored
|
||||
cargo test -p marqdo-cli --test stdlib_product 10 passed
|
||||
python3 tools/pack-stdlib.py PASS
|
||||
```
|
||||
|
||||
## Not covered
|
||||
|
||||
No regex groups, alternation, named classes (`\d`), Unicode property classes,
|
||||
incremental matching or a compiled-pattern cache. No path I/O or symlink
|
||||
resolution. Those remain open product work.
|
||||
Reference in new issue
Block a user