Commit Graph
21 Commits
Author SHA1 Message Date
cflmy 9bceac910b feat(tool): negotiate protocols and verify the whole tool bundle (B-09 B-10)
- replace the hand-rolled version matcher with semver; require valid tool
  versions and marqdo ranges
- declare SupportedProtocols (tool 1, analysis 2, trace 2) and negotiate tool
  Analysis/Trace declarations at install and dispatch; disjoint/empty sets fail
  closed with tool.protocol_incompatible
- record a v2 whole-bundle manifest (path/size/sha256 + deterministic bundle
  digest), copy exactly that bundle into staging, re-verify it, and recompute it
  before every dispatch
- reject auxiliary-file, extra-file, missing-file and entrypoint tampering,
  record/command mismatches, traversal and a source root record.json
- remove tools by detaching with rename before deletion
- expose negotiated protocol environment variables to declared tools
- update tool-v1 and STATUS; add negotiation/bundle tests
2026-11-20 13:02:55 +08:00
cflmy d890686a2b feat(trace): Trace v2 identity, module-owned events and capacity bounds (B-16)
- bind traces to the logical project identity and the exact emitted Analysis
  digest; every span-bearing event carries module_id
- add host TraceState budgets (100k events / 32 MiB defaults), CLI
  --trace-max-events/--trace-max-bytes, terminal trace.truncated events, and a
  final serialized byte cap; budgets never change run.status
- disable semantic recording when no trace is requested
- cap worker frames at 8 MiB, align request/result/capability wire caps, make
  clean EOF distinct from protocol errors, and mark/kill a worker after a
  transport failure instead of reusing it
- add trace-v2 spec/schema, independent trace consumer, CI check and tests
- record the S2/C state in STATUS
2026-11-20 13:01:22 +08:00
cflmy 55dcb57553 feat(analysis): Analysis v2 logical identity and resource projection (B-06 B-07)
- add ProjectIdentity (manifest root instance or workspace snapshot digest)
  and remove absolute-path root ids from Analysis bytes
- replace the resources count with an addressable array over the two real
  marqdo-ir resource kinds (formula, code), including unit/span/payload digest
  and code language
- project diagnostics by module/relative path/span, removing machine paths
- define the digest as SHA-256 of the exact emitted bytes so consumers can
  verify it; Trace binds to the same digest
- add analysis-v2 spec and JSON schema, supersede v1, update the independent
  Python consumer, schemas and docs
- tests: location-independent byte equality and resource addressing
2026-11-20 12:58:58 +08:00
cflmy 509bdb1bf6 fix(runtime): resolve runtime errors against their logical module (B-08)
RuntimeError and CallFrame now carry a logical ModuleId and an origin
(source/callsite). Errors are attributed at function/body boundaries so the
innermost callee module wins; argument-binding errors and host/plugin/foreign
boundaries are attributed to the caller callsite without fabricating a foreign
stack.

The CLI resolves (module_id, span) through LoadedProject::locate instead of
indexing every span against the entry file. Unknown modules and out-of-range
spans keep the module id and byte span but emit null line/file. Human output and
frames now point at the correct file.

Record the decision in ADR-0017 and supersede the ADR-0006 limitation. Add an
end-to-end imported-module division-by-zero test.
2026-11-20 12:57:44 +08:00
cflmy 6fed396d20 feat(package): lock v3 package-instance graph and strict sync (B-02 B-03 B-04)
- lock the full transitive closure with per-instance alias edges, root
  manifest digest, full content digests and structured path/git sources
- reject v1/v2 locks; validate ids, digests, edges, reachability and sources
- resolve every locked edge by (parent instance, alias) and fail closed on
  missing locks/edges/records, digest or source drift and root drift
- require a lock for run/check/inspect when dependencies exist and map lock
  errors to exit 1
- make sync strict in both modes, never rewrite the lock, and materialize the
  whole closure with env.json schema 2
- verify Git cache markers, require full commit hashes and confirm HEAD
- stop add/remove from patching the lock; regenerate example locks
- update package-format.md and STATUS for S1
2026-11-20 12:55:30 +08:00
cflmy 74e34c668b fix(ci): remove empty-directory dependency from prose property test (B-01)
The property test builds all fixtures in code but asserted that
tests/properties/ existed. Git does not track empty directories, so a fresh
clone failed before exercising the invariance checks. Drop the assertion and
the now-unused repo_root helper; keep every prose-invariance assertion intact.

Record the S0/H0 local gate and the pending CI URL in STATUS.
2026-11-20 12:47:38 +08:00
cflmy 44c2df2361 feat(m0.6-r2): isolated plugin worker transport
- add a hidden __plugin-worker mode that loads one native library in a child
  process and serves length-prefixed JSON invoke frames
- add host WorkerPlugin with ready handshake, export cross-check, per-call
  timeout and crash/EOF propagation
- route kind: worker without in-process trust; native still requires explicit
  trust; wasm is rejected explicitly
- report worker_processes=true while keeping strict OS isolation unavailable
- test successful worker calls and worker crash isolation
- update plugin ABI spec and R2 status
2026-11-20 11:52:26 +08:00
cflmy 4ce37afb39 feat(m0.6-r6): release examples, public schemas and cross-platform CI
- add runnable examples for an unknown-name Tool, multi-export plugin,
  external kernel provider and same-name multi-version packages
- add JSON Schemas for Analysis v1, Trace v1 and Tool v1 and validate them in CI
- extend CI with protocol/consumer smoke tests and a Windows/macOS cargo check
- add --kernel provider descriptors and R6 example integration tests
- document the examples and update M0.6 status
2026-11-20 11:50:27 +08:00
cflmy 54c7b43d15 feat(m0.6-r5): pinned Git packages and materialized environments
- add content-addressed Git checkout cache for exact revisions; no hooks,
  submodules or floating branches
- resolve transitive @alias imports from each package's own manifest
- materialize locked path/Git packages into .marqdo/env atomically and prefer
  a matching env copy in the resolver
- make sync a real environment sync while keeping lock immutable
- kill Unix foreign-kernel process groups so grandchildren do not survive
- add Git/env/transitive integration tests and update package/security specs
2026-11-20 11:49:05 +08:00
cflmy b5a28a9825 feat(m0.6-r4): public Analysis v1 and Trace v1
- add check --emit with a deterministic, read-only semantic projection:
  package-aware modules, signatures, normalized bodies, refs, calls,
  diagnostics and source digests
- remove stale analysis artifacts on compile errors; atomic writes
- add run/call --trace-file with interpreter call/branch/loop/return events
  and host effect events under one sequence; redact values and record error
  status
- add Analysis/Trace v1 specs, ADR-0015 and an independent Python consumer
- add contract tests for determinism, stale artifacts, trace ordering/status
  and secret redaction
2026-11-20 11:46:37 +08:00
cflmy 25a1faa6ef feat(m0.6-r3): generic external CLI Tool Protocol v1
- add tool install/list/remove and unknown-command dispatch without hardcoded
  tool names or clap variants
- validate and copy local tool packages atomically, reject entrypoint escapes
  and symlinks, record and re-verify SHA-256
- forward OsString args, stdio, cwd and exit status without a shell; never
  execute PATH programs implicitly
- add black-box tests for arbitrary names, Unicode args, built-in conflicts,
  traversal, version mismatch, tampering and PATH hijacking
- add ADR-0013 and mark R3 complete
2026-11-20 11:44:20 +08:00
cflmy d940013f35 feat(m0.6-r2): complete-name plugin exports and capability broker
- register every plugin export by its complete dotted name; reject conflicting
  loads atomically instead of overwriting the first namespace
- route plugin calls by full export name and expose loaded descriptors to the
  runtime
- add CapabilityBroker for core grants and vendor policy, with audit records
- accept syntactically valid vendor capability requests in manifests while
  still denying them until a trusted policy exists
- add check --plugin static signature validation without dlopen
- test multi-export C plugin routing, conflict rollback, broker decisions and
  static arity rejection
2026-11-20 11:42:33 +08:00
cflmy 5877d9aa5e feat(m0.6-r1): package-aware module identity and resolver
- replace path-only ModuleId with {instance, relative_path} and canonical
  <instance>::<path> encoding
- add PackageResolver/ResolvedPackage in marqdo-package for path sources;
  hash package trees deterministically for content-addressed instance ids
- move import resolution out of the CLI loader; reject package escapes
- emit lock_version 2 with instance ids and migrate v1 lockfiles
- update references/package-format specs and the function-ref golden
- add package resolver tests for stable identity across path moves
2026-11-20 11:37:16 +08:00
cflmy fae0cd4b18 fix(host,cli): enforce console capability and label call --json output
- host: `打印` checks the console capability at the execution point (pure and
  project modes grant it, but the boundary is now real instead of decorative).
- cli: `marqdo call --json` reports "command":"call" instead of "run".
2026-11-20 10:56:26 +08:00
cflmy 2f1b10d0ee feat(cli): surface compile warnings on run/call
Non-error diagnostics (for example `markdown.inert_executable` for a would-be
execution node outside any function body) are now printed to stderr before
execution and included in `--json` run output, instead of being silently
hidden on a successful run.
2026-11-20 10:54:27 +08:00
cflmy 847c2c1580 fix: float wire precision, native stack safety, refs diagnostics and fixtures
Findings from the conformance corpus workstream, all fixed at the source:

- value/wire: enable serde_json's float_roundtrip so typed wire floats keep
  their exact digits across foreign/plugin boundaries (Python pi*9 now stays
  28.274333882308138).
- host: default interpreter stack budget lowered to 128 frames so deeply
  recursive documents hit a structured resource.exhausted instead of exhausting
  the native debug-build Rust stack; --stack remains available.
- frontend/map: calling an external HTTP(S) link is reported as ref.unresolved
  (consistent with other unresolvable call targets) instead of math.unsupported.
- frontend/analyze: invalid front matter emits a single frontmatter.invalid
  diagnostic (the YAML error is not repeated by the imports pass).
- spec/mapping: clarify that would-be execution nodes outside any function body
  are inert with a markdown.inert_executable warning (no "return outside a
  function" hard-error claim).
- tests: add the conformance corpus and harness (150 AST goldens, 36 semantic
  goldens, 48 hard-error + 6 warning + 10 runtime-error negatives, CLI/module/
  plugin integration tests, prose-invariance properties) and update the
  three reported observations to the fixed behaviour.
2026-11-20 10:54:16 +08:00
cflmy 33341a0e92 feat(cli): check --refs validates Markdown reference targets
Blueprint section 4.2: reference edges are static, never execution.

- For every loaded document, resolve same-document anchors, relative file
  links and target anchors (analysing referenced files statically without
  executing them); unresolved targets produce `ref.unresolved` errors with
  source spans.
- External HTTP(S) links are treated as external references, not errors.
- `inspect --refs` continues to print the resolved edge graph as JSON.
2026-11-20 10:51:54 +08:00
cflmy 7fbd5e9ec1 feat(host,runtime,cli): explicit plugin invocation from documents
Blueprint section 10 / P6: exports of an explicitly trusted plugin are callable
from a `.mq.md` file through a bound namespace.

- host: StdHost::load_plugin requires an explicit trust decision and a granted
  plugin capability, loads the native artifact through the ABI v1 loader with
  no capability handler (all plugin host-capability requests denied), and
  dispatches HostOp::PluginInvoke through the typed wire request/response.
  In-process native code is documented as sharing the host address space; no
  isolated worker transport exists in this build.
- runtime: a qualified call whose base is not a local value, import alias or
  builtin namespace is routed to the plugin namespace; plugin calls take named
  arguments only and plugin values become Marqdo values (Unit when absent).
- cli: run/call gain `--plugin <path>`, `--trust-native-plugin` and reuse
  `--allow-plugin <package>`; missing trust/grant/loaded namespace surface as
  structured errors.
- frontend: member-call bases are namespaces (builtin/import/plugin), never
  inferred parameters, so `solver.add(...)` does not invent a parameter.
2026-11-20 10:46:23 +08:00
cflmy 6f04c17f7a feat(cli,package): add/remove dependencies and cleaner manifest serialization
- `marqdo add <name> --path <dir>` / `--git URL --rev SHA` and
  `marqdo remove <name>` edit marqdo.yaml only after validating the dependency
  source (path-relative, git pinned by exact rev, no duplicate entry).
  Removing a dependency also drops its stale lock entry; locking stays an
  explicit step so no version changes happen silently.
- Manifest serialization omits empty dependency/plugin maps and empty
  capability requests, keeping generated manifests readable and stable.
2026-11-20 10:45:07 +08:00
cflmy e1ba630068 feat(cli): marqdo init/run/call/check/inspect/fmt/plugin/lock/sync
Composition root wiring the frontend, runtime, host and package layers:

- Project loader: deterministic project-root discovery, explicit front-matter
  imports only (`@dependency` or relative `.mq.md`), recursive module loading
  with cycle diagnostics, resolved import edges and cross-module call checks.
  Loading never executes anything.
- run/call: sandbox mode enforcement (strict refuses when unavailable),
  explicit capability grants, fuel/stack/output/timeout overrides, typed
  `--arg name=value` constants, program stdout separated from diagnostics, and
  machine-readable JSON output that embeds program output without mixing.
- check: static diagnostics only, human-readable locations with source lines
  and stable machine codes in JSON.
- inspect: canonical AST, heading units, signatures (explicit/inferred),
  executable IR, static reference edges (including cross-file links analysed
  without execution) and platform capability report.
- fmt: conservative, AST-preserving normalisation of line endings and trailing
  newlines; --check mode.
- plugin inspect: manifest/ABI/artifact validation and hash verification,
  never loading plugin code.
- init: minimal project (manifest, entry document, .gitignore).
- lock/sync --locked: deterministic path-dependency lockfile, stale lock or
  changed dependency content is an error (no silent upgrades).
- examples: hello, factorial, math formula, Python foreign call, static
  references and a two-module project with an explicit import.
2026-11-20 10:44:03 +08:00
cflmy df878b434a chore(workspace): scaffold Rust workspace and crate graph
Create the Marqdo CLI Rust workspace with the module boundaries from the
development blueprint (section 11):

- marqdo-span: byte spans and line/column mapping shared by every layer
- marqdo-value, marqdo-expression, marqdo-markdown, marqdo-ir
- marqdo-frontend, marqdo-runtime, marqdo-host, marqdo-sandbox
- marqdo-math, marqdo-foreign, marqdo-package
- marqdo-plugin-abi, marqdo-plugin-sdk
- marqdo-cli (binary `marqdo`)

Pin the Markdown parser exactly (comrak =1.0.0, no default features) so the
frozen profile can never drift silently. Dependencies are centralized in
workspace.dependencies; no crate is allowed to add its own version of a shared
dependency.
2026-11-20 10:23:39 +08:00