Commit Graph
112 Commits
Author SHA1 Message Date
cflmy f4a404bae9 fix(sandbox): add platform-neutral strict child inspection
CI / fmt + clippy + test (Linux x86_64) (push) Waiting to run
CI / schema instance validation + consumers (push) Waiting to run
CI / runtime contract (macos-latest) (push) Waiting to run
CI / runtime contract (windows-latest) (push) Waiting to run
ci/woodpecker/push/woodpecker Pipeline was successful
The CLI referenced Linux-only marker_present/verify_active directly, so
macOS and Windows builds failed with E0425. Add StrictChildState and
inspect_strict_child() to marqdo-sandbox: Linux performs the full identity
verification, while every other platform rejects even a forged
MARQDO_STRICT_ACTIVE marker. The Linux-only functions are no longer
re-exported from the crate root, so future callers cannot bypass the
platform boundary.

This is step 1 of the CI/security RFC (B01).
2026-11-21 16:36:49 +08:00
cflmy 9c1723d44f test(markdown): cover the removed syntax-selector key probe
frontmatter::has_key() is what rejects marqdo_semantics/syntax directives;
add unit coverage for a present key, an absent key and invalid YAML (which
reports no key rather than panicking).

Verified: cargo test -p marqdo-markdown and the workspace suite green
(507 passed, 0 failed, 2 ignored).
2026-11-21 15:57:13 +08:00
cflmy b3429cbeb3 fix(frontend): emit diagnostics in the specified stable order
spec/mapping.md §8 requires diagnostics ordered by source position, then
code, so IDE/CI diffs are stable. analyze_source appended diagnostics by
pipeline stage (units, mapping, inference, call validation), so a later
heading error could precede an earlier payload error.

Sort the final list by (span.start, code) with span-less diagnostics last,
and pin the order with a test that mixes an indexing-stage duplicate-heading
error with an earlier mapping-stage syntax error.

Verified: clippy -D warnings clean; cargo test --workspace --locked green.
2026-11-21 15:55:23 +08:00
cflmy 0bbe0f6524 fix(frontend): honour the Setext no-declaration rule; drop dead helper
RFC-LANG-0002 allows a mode declaration only as an ATX heading prefix; a
Setext heading merely inherits the nearest ancestor mode. heading_declaration
was applied to every heading, so a Setext 'title' beginning with @exec/
@knowledge silently switched modes and could create a function.

- skip declaration parsing for Setext headings (they keep their literal name
  and inherited mode); add a regression test
- remove the dead normalized_heading_name helper and its imports, which only
  existed for the removed link-form call resolution

Verified: clippy -D warnings clean; cargo test --workspace --locked green
(505 passed, 0 failed, 2 ignored).
2026-11-21 15:52:46 +08:00
cflmy a3f9770761 fix(frontend): point unmatched end diagnostics at the end payload
A stray end after an earlier statement was reported with the span of the
previous payload (position-1) and a confusing 'ends outside its owning
function segment' message. Report it on the end payload itself with the
standard sem.unmatched_end wording, and pin the span with a unit test.

Verified: clippy -D warnings clean and cargo test --workspace --locked
green (62 targets).
2026-11-21 15:50:46 +08:00
cflmy 9fb97bc2df fix(frontend): recognize signatures only from Exec payloads
signature::detect() scanned the function body independently of heading
modes, skipping only level>=3 headings. A 'params(...)' code span in an
### @knowledge section was therefore taken as the function signature
('inspect --signature' reported it as explicit), even though that span is
inert documentation and is never executed.

Unify recognition with the executable traversal:

- MappedBody now reports the params(...) payload the mapper accepted; the
  mapper already enforces Exec mode, directness, first-function-wide
  position and single declaration
- signature::from_payload validates that text and rewrites default-value
  spans; signature::detect is removed along with its mode-blind heuristic
- analyze uses the mapper result, so Knowledge sections cannot declare a
  signature and prose/Knowledge subsections may still precede the first
  Exec declaration
- tests: Knowledge params ignored; Exec params after prose/Knowledge is the
  signature; spec/mapping.md states the recognition rule

Verified: clippy -D warnings clean; cargo test --workspace --locked green
(62 targets).
2026-11-21 15:48:37 +08:00
cflmy d5002ac826 docs(code): remove stale pre-RFC role wording and fix review aid
Follow-up cleanup of text left by the concurrent implementation:

- marqdo-markdown AST, marqdo-ir statements/branch arms, frontend units,
  payload and signature module docs now describe RFC-LANG-0002 roles
  (payload carriers, heading modes, if/else groups, while/end, params)
- marqdo-expression public docs list parse_payload_statement and stop
  describing a Markdown-link call that no longer exists
- retired markdown.invalid_construct/markdown.inert_executable constants
  are documented as decode-only history for old Analysis/Trace JSON
- drop the stale 'expected red' comment in the CLI integration test
- the dev-only .mq.md review aid no longer reports semicolons inside
  string literals, and skips AST baselines / expected-invalid negatives

Verified: fmt, clippy -D warnings and cargo test --workspace --locked green.
2026-11-21 15:44:31 +08:00
cflmy 361a6cc341 refactor(ir): drop the dead call-statement representation
The pre-RFC link-form block-quote call was removed by RFC-LANG-0002, but the
IR still carried Stmt::Call, CallSite and CallTarget with matching branches in
the runtime, infer, call validation, loader, analysis projection and JSON
output. No mapper produces that variant any more, so it was a second call
representation that could never be reached.

- remove Stmt::Call, CallSite and CallTarget from marqdo-ir
- remove the runtime exec_call_site path and every exhaustive match arm
- remove the 'call_site' Analysis node and its JSON helpers
- state in spec/analysis-v2.md that calls are expressions; keep v1 as history
  with a note that call_site is not produced by the current language

Verified: cargo clippy --workspace --all-targets -D warnings clean and
cargo test --workspace --locked green (62 targets).
2026-11-21 15:39:29 +08:00
cflmy b38b769932 fix(frontend): enforce function-wide params position
The concurrent mapper tracked the first params declaration in the Mapper (so
duplicates across heading segments were caught) but checked 'first payload'
with a per-segment vector index. A params(...) in a later ### @exec segment
was therefore accepted even after an earlier segment had executed statements,
and a duplicate could even be reported as a position error.

- track whether any statement has been lowered for the function and require
  params(...) to come before it, across all heading segments
- check duplicates first, then execution order, then the in-segment index
- add negative fixtures 48 (after an earlier segment) and 49 (duplicate
  across segments); update the corpus count and spec wording

Verified: cargo test --workspace --locked green (62 targets).
2026-11-21 15:36:30 +08:00
cflmy ffd1cc9862 refactor(expression): own the v2 payload statement grammar
Move keyword recognition out of the Markdown mapper and into the single
expression/statement parser:

- add parse_payload_statement + PayloadStatement for if/else/while/end/
  return/params/ordinary; keyword matching uses complete tokens, requires
  whitespace before a control expression, rejects trailing tokens/colons
  and reserves the statement words in expression positions
- keep expression spans payload-relative so the frontend can rewrite them
  onto the file; malformed params(...) interiors stay owned by the
  signature parser (one sem.syntax diagnostic, not a duplicate)
- simplify the frontend mapper to control-stack lowering and mapped
  semantic diagnostics only
- emit sem.no_entry_function from run when no Exec H2 main exists
- add else-under-while, params-in-quote, Knowledge-inertness and
  no-entry tests; update the corpus counts
- make the EBNF parameter type annotation optional (params(n) is valid)

Verified: cargo fmt --check, cargo clippy -D warnings and
cargo test --workspace --locked: 501 passed, 0 failed, 2 ignored.
2026-11-21 12:29:07 +08:00
cflmy e029853e32 feat(lang): implement RFC-LANG-0002 unified semantics (breaking)
One Markdown-to-program mapping, no version selector or legacy mapper.

Frontend/runtime:
- resolve @exec/@knowledge heading declarations with nearest-ancestor
  inheritance; only an Exec H2 is callable; add UnitKind::Knowledge and
  sem.* diagnostics (mode marker, unit name, exec-without-function,
  payload nesting/empty, syntax, control stack, params position,
  version directive, inferred-signature lint)
- extract Strong/Emph/inline Code as one-statement carriers, refuse
  nested carriers, and honour heading segment boundaries so an if/while
  cannot be closed across a heading
- lower if/else/while/end to the existing Branch/Loop/Return IR with a
  compile-time control stack; keep payload-relative source spans through
  expression parsing and rewrite them onto the file
- accept params(...) only as the first direct Exec H2 payload; keep the
  existing free-variable inference and named-only rule for inferred
  signatures; fix duplicate-mode/else/end and Knowledge-body inertness
- reject marqdo_semantics/syntax front matter directives

Data and tests:
- migrate stdlib/**/*.mq.md, regenerate stdlib.json digest
- migrate examples and the full semantics/negative/runtime corpus to
  the only current syntax; expected values/runtime codes preserved
- migrate Rust-embedded .mq.md fixtures, init template, CLI help and
  security-lane fixtures

Verified: cargo fmt --check, cargo clippy -D warnings and
cargo test --workspace --locked (green).
2026-11-21 12:26:46 +08:00
Marqdo Agent 0d8ed44010 feat(http): parse and build HTTP/1.1 framing by bytes 2026-11-21 11:05:15 +08:00
Marqdo Agent 28b178fc70 feat(regex): add host-backed groups, alternation and captures 2026-11-21 10:58:06 +08:00
Marqdo Agent 94a13880c4 feat(json,csv): bound depth and add multi-value/multi-row APIs 2026-11-21 10:51:55 +08:00
Marqdo Agent efbb8007e1 feat(compress): add bounded gzip product codec 2026-11-21 10:48:27 +08:00
Marqdo Agent ff3f19a2ea feat(net): add DNS, UDP, TCP listener and TLS endpoints 2026-11-21 10:43:08 +08:00
Marqdo Agent ee0c6cc80a feat(random): add explicitly granted OS entropy API 2026-11-21 10:25:11 +08:00
Marqdo Agent 6338fa10e9 feat(fs): add append, read_at and recursive walk 2026-11-21 10:20:07 +08:00
Marqdo Agent 7859c26213 refactor(cli,host): finish command, dispatch and package module split 2026-11-21 08:59:50 +08:00
Marqdo Agent 550e66b1e2 refactor(cli,host): split command entry points and provider/effects modules 2026-11-21 08:54:29 +08:00
Marqdo Agent 791819a725 refactor(cli,host): split sandbox, resource-open and process modules 2026-11-21 08:49:25 +08:00
Marqdo Agent 3ef18fb496 feat(process): add explicitly granted process API 2026-11-21 08:46:02 +08:00
Marqdo Agent 9922bfae98 feat(stdlib): add explicitly granted env API 2026-11-21 08:40:54 +08:00
Marqdo Agent ae69391bc0 feat(stdlib): add datetime and project-mode clock APIs 2026-11-21 08:36:40 +08:00
Marqdo Agent cffb6790be feat(stdlib): add path and regex product modules 2026-11-21 08:32:32 +08:00
Marqdo Agent bde6f1d0ba feat(stdlib): add JSON and CSV product parsers 2026-11-21 08:23:54 +08:00
Marqdo Agent fbe36bcc43 feat(resource): add grant-checked fs resource operations 2026-11-21 08:20:31 +08:00
Marqdo Agent cd90f059b4 feat(stdlib): add bounded std:fs/file read, write and copy 2026-11-21 08:10:10 +08:00
Marqdo Agent 0d40de7645 test(stdlib): add the demo module to the product lane 2026-11-21 01:56:04 +08:00
Marqdo Agent 04eae8746e test(stdlib): cover every bundled module through std imports 2026-11-21 01:50:01 +08:00
Marqdo Agent a8ccac9e67 test(architecture): gate stdlib layout, digest and resource endpoints 2026-11-21 01:45:07 +08:00
Marqdo Agent ce70bc4c42 test(docs): gate the current architecture and evidence links 2026-11-21 01:38:21 +08:00
cflmy 24c88bcc78 fix(resource): reject provider read and write over-reports
ci/woodpecker/push/woodpecker Pipeline was successful
CI / fmt + clippy + test (Linux x86_64) (push) Canceled after 0s
CI / schema instance validation + consumers (push) Canceled after 0s
CI / runtime contract (windows-latest) (push) Canceled after 0s
CI / release candidate artifact (macos-latest) (push) Canceled after 0s
CI / release candidate artifact (ubuntu-latest) (push) Canceled after 0s
CI / runtime contract (macos-latest) (push) Canceled after 0s
2026-11-21 01:05:14 +08:00
cflmy 4a0caabc03 fix(runtime): keep resource.read destination bounds strict 2026-11-21 00:58:42 +08:00
cflmy 02aecaa747 test(conformance): load nested stdlib imports without false cycles 2026-11-21 00:58:34 +08:00
cflmy 64a6b48866 fix(resource): share one stdin cursor across handles 2026-11-21 00:49:07 +08:00
cflmy 3b13d8499a feat(stdlib): add streaming IO and console line APIs 2026-11-21 00:48:46 +08:00
cflmy aed6a80ba7 feat(resource): add stdin and stderr stdio endpoints 2026-11-21 00:36:25 +08:00
cflmy 757c5ed15e feat(provider): add C ABI provider worker binding v1
- Add the separate marqdo-provider-worker binary: loads one trusted c-abi-1
  shared library and serves the ADR-0035 framed-JSON resource protocol, with
  fail-closed startup and no in-process fallback (ADR-0038).
- Reuse StdHost::register_worker_resource_provider; language still sees only
  resource.* and project-mode/name grants.
- Compile a C test provider and run open/read/write/close through the helper;
  cover missing-library fail-closed. Trusted process boundary, not a sandbox;
  existing plugin-Worker ABI binding remains open.
- Add ADR/spec/status/README/changelog/evidence; workspace member and tests.

Gate: fmt, clippy -D warnings, 440 tests passed.
2026-11-20 23:30:22 +08:00
cflmy 313ac035e8 test(p2): prove foreign/plugin shortcuts fail in the pure lane
- Add negative tests: foreign.call -> permission.denied and plugin.invoke ->
  structured failure under --mode pure, complementing the 21-fixture pure lane.
- Update P2 evidence/tests README/changelog.

Gate: fmt, clippy -D warnings, 438 tests passed.
2026-11-20 23:29:14 +08:00
cflmy 974102dfc3 feat(host): add provider package manifest v1
- Add a marqdo.provider schema v1 loader (schema/version/ABI/platform library)
  and StdHost::register_provider_package, reusing the C ABI adapter and shared
  kind/name checks (ADR-0037).
- Add a compiled-provider + provider.json installation test; language use still
  requires project mode and allow_resource_provider.
- Update ADR/spec/status/README/changelog and evidence; no registry, signature
  or CLI install is claimed.

Gate: fmt, clippy -D warnings, 437 tests passed.
2026-11-20 23:28:30 +08:00
cflmy 5e5c3a84d9 test(host): cover C ABI version/mode fail-closed paths
- Build a second C provider reporting ABI v2 and assert registration fails
  with resource.unsupported.
- Assert pure/strict refuse a registered C provider kind with permission.denied.
- Refresh the C ABI evidence/test README.

Gate: fmt, clippy -D warnings, 436 tests passed.
2026-11-20 23:27:37 +08:00
cflmy b22a89e7b4 feat(host): add trusted C ABI ResourceProvider v1
- Add the frozen marqdo_resource_provider.h ABI (version + open/read/write/
  close/last_error) and a libloading-based host adapter with version/symbol
  checks and callsite-attached host errors (ADR-0036).
- Add StdHost::register_c_resource_provider using the same kind/name validation
  and project-mode name grant as the in-process/worker providers.
- Compile a C shared-library test provider; cover round-trip and fail-closed
  missing-library behavior. Trusted native code, not a sandbox; plugin-Worker
  binding remains open.
- Update ADRs/spec/status/README/changelog and evidence.

Gate: fmt, clippy -D warnings, 435 tests passed.
2026-11-20 23:26:25 +08:00
cflmy 01f6fe46a7 feat(host): add worker resource-provider transport v1
- Add a host-managed helper process speaking framed JSON (4-byte BE length)
  with ping/open/read/write/close/shutdown, max 1 MiB frames and structured
  error mapping (ADR-0035).
- Add StdHost::register_worker_resource_provider using the same protocol,
  kind-conflict and name-grant checks as the in-process provider; pure/strict
  refuse provider kinds.
- Tests spawn a Python helper and cover round-trip, grant/mode denial and
  missing-program failure; no parser/Value/runtime/HostOp change.
- Update ADR/spec/status/README/changelog and evidence; C ABI binding remains
  open.

Gate: fmt, clippy -D warnings, 433 tests passed.
2026-11-20 23:25:09 +08:00
cflmy 8bbed34bd3 test(c12): add sparse-matrix triples and multiply fixture
- Fixture 73 implements triple-list lookup, dense conversion and sparse
  multiply with Int arithmetic and exact indexing.
- Include it in the P2 pure closure lane and update golden count to 73,
  C12 evidence mapping, status/README/changelog.

Gate: fmt, clippy -D warnings, 430 tests passed.
2026-11-20 23:19:45 +08:00
cflmy b020904199 test(p4): prove row-store/columnar table equivalence
- Add semantic fixture 72: a .mq.md columnar List/Map table store, converted,
  sorted and filtered; compare headers/cells with the T0 row Table via a
  cell-wise helper (Table == is not structural in this language version).
- Teach the direct-runtime semantic harness to resolve entry std: imports.
- Update ADR-0032, P4 status, docs/changelog/evidence; semantic goldens 72.

Gate: fmt, clippy -D warnings, 430 tests passed.
2026-11-20 23:14:38 +08:00
cflmy e981168d92 feat(stdlib): add HTTP framing over TCP and close P5 C10 locally
- Add stdlib/net/http.mq.md: status/header/chunked response parsing and request
  construction in .mq.md; no host HTTP/TLS implementation.
- Add stdlib/tests/http.mq.md and an end-to-end loopback test that sends a GET
  over resource.open("tcp"), reads bytes, parses the response and returns
  status/content-type/body.
- Update ADR-0034, status/spec/README/changelog and evidence; refresh the
  bundle digest.

Gate: fmt, clippy -D warnings, 430 tests passed.
2026-11-20 23:13:06 +08:00
cflmy 0d4dc1da03 test(p2): close C01-C06/C11/C12 in a pure no-Foreign/no-Plugin lane
- Add crates/cli/tests/p2_closure.rs: 20 semantic fixtures run through the real
  CLI in --mode pure (Capabilities::pure), source scan for foreign./plugin./
  import:, and golden value/stdout comparison.
- Run the stdlib table self-test in pure mode; no host shortcut or recompilation
  is needed for the selected algorithms.
- Mark P2 gate PASS locally (external stdlib repo publication and remote CI
  remain outside the C01-C12 gate); add evidence and docs.

Gate: fmt, clippy -D warnings, 428 tests passed.
2026-11-20 23:12:03 +08:00
cflmy 69a28ed1e1 feat(stdlib): add table GFM rendering and an HTTP/1.1 parser fixture
- stdlib/data/table.mq.md adds 连接片段/连接行/转义单元格/转GFM; logical Table
  renders as a GFM pipe table with pipe/newline escaping (CM-A08 P4 gate).
- Add semantic fixture 71: HTTP/1.1 status/header/chunked response parsing and
  request construction in .mq.md; no host HTTP/TLS implementation (C10).
- Update table CLI test, golden count 71, specs/status/README/changelog and
  evidence.

Gate: fmt, clippy -D warnings, 426 tests passed; bundle digest refreshed.
2026-11-20 23:10:19 +08:00
cflmy 00bdcad1ff feat(host): add IP-literal blocking TCP resource endpoint (P5)
- resource.open("tcp", ip:port, ["read","write"]) with exact IP grants,
  project mode only, 5s connect/read/write timeouts; no DNS/TLS/UDP/server
  sockets (ADR-0034).
- Add TCP stream storage/dispatch in the resource table; CLI --allow-net IP;
  pure/strict preflight rejects the grant and the language endpoint.
- Host loopback echo/grant/DNS/strict tests and a .mq.md CLI echo test.
- Update specs, status, architecture, README, changelog and evidence.

Gate: fmt, clippy -D warnings, 426 tests passed.
2026-11-20 23:05:06 +08:00