Files
marqdo-extension-conformance/CONTRACT.md
T
2026-11-21 23:08:00 +08:00

8.0 KiB

Conformance contract

This repository is a third-party conformance fixture. It does not define Marqdo semantics; it consumes the published Marqdo contracts below. Where this document and the upstream specification disagree, the upstream specification wins and this fixture is wrong.

1. Versions consumed

Item Version used here Notes
Marqdo CLI / core marqdo 0.1.0 (--version) Frozen binary supplied externally as $MARQDO_BIN; SHA-256 recorded in evidence and checked before/after the run
Language semantics RFC-LANG-0002 / ADR-0052 Single Markdown→program mapping: @exec/@knowledge heading modes, if/else/while/end/return/params keywords, Strong/Emph/inline Code as interchangeable one-statement payload carriers
Markdown profile marqdo.md.v1 constant in Analysis producer.markdown_profile
Plugin ABI C ABI v1.0 (MQ_ABI_MAJOR=1, MQ_ABI_MINOR=0) include/marqdo_plugin_abi_v1.h (verbatim public header copy)
Plugin manifest plugin.yaml, ABI requirement ^1.0, kind: worker worker transport is the fixture default
Value Wire wire_version = 1 (type-tagged values) used by plugin envelopes and the foreign-kernel stdin envelope
Analysis marqdo.analysis schema_version: 2 produced by marqdo check FILE --emit FILE
Trace marqdo.trace schema_version: 2 produced by marqdo run FILE --trace-file FILE
Tool Protocol CLI Tool Protocol v1 (schema_version: 1, analysis: [2], trace: [2]) installed via marqdo tool install tool/tool.json
Resource Provider provider.json schema_version: 2, abi: c-abi-1, transport: worker, kind demo.sensor the frozen CLI does not yet expose --provider/--allow-provider; see §7
Provider worker wire ADR-0035 framed JSON v1: 4-byte big-endian length + JSON, max 1 MiB/frame, ops ping/open/read/write/close/shutdown implemented independently in provider/sensor.c (-DDEMO_SENSOR_WORKER)
Foreign kernel wire spec/foreign.md v1: stdin {"wire_version":1,"kind":"request","input":...}, stdout exactly one typed value for foreign.call implemented in kernel/mocklang (unknown language tag mocklang)
Git dependency / lock lock_version: 3, content_profile_version: 1, source git pinned to a full lowercase 40-hex commit marqdo lock/sync/check/run

2. Platform / target assumptions

  • Evidence is produced on Linux x86_64 (x86_64-unknown-linux-gnu).
  • Toolchain assumptions: python3 (standard library only), cc/gcc, git, POSIX shell. No Node, no Rust toolchain, no Marqdo workspace, no network access is required for the normal suite.
  • The plugin/provider build.sh scripts map the host to a Rust-style target triple. macOS maps to *-apple-darwin (.dylib); Windows is treated as UNSUPPORTED by this fixture and the build script fails explicitly instead of guessing another platform's artifact. A UNSUPPORTED result is never a PASS.

3. Hashes and identity

  • Artifact integrity: lowercase hex SHA-256 of the exact artifact bytes (plugin.yaml / provider.json sha256 fields). This is an integrity check, not publisher authentication.
  • Analysis digest: SHA-256 of the exact UTF-8 bytes written by check --emit (Trace v2 binds it as source.analysis_digest, sha256:<hex>). The independent tool verifies this binding.
  • Tool digest: SHA-256 of tool/inspect_ext.py as recorded in evidence.
  • Fixture identity: full Git commit SHA of this repository at test time; recorded in evidence as fixture_repo_sha.
  • Frozen CLI: SHA-256 of $MARQDO_BIN, recorded before/after and asserted unchanged. The evidence run used the provisional release binary with SHA-256 0179cd04a79a6bd26e5576ba9751ce51eaf3fba4ff14d44e8e5e0fea18d54ce2 (supplied by the task); the final release binary is supplied later and must be re-run through this suite. Scripts never hardcode this value: it is read from $MARQDO_BIN (optionally asserted against $MARQDO_EXPECTED_SHA256).

4. Grants and default run mode

Extension Default transport Required CLI grant Default mode
.mq.md package in-process Marqdo runtime none (file reads are project-relative) project
Callable plugin kind: worker child process --plugin <manifest-dir> + --allow-plugin demo.solver project
Foreign kernel child process --kernel <kernel.json> + --allow-foreign project
Resource provider worker (framed JSON) --provider <provider.json> + --allow-provider demo.sensor (not yet available) project
CLI tool separate CLI process tool install; the tool stays outside the .mq.md sandbox n/a

pure and strict modes must refuse every external extension grant. The fixture asserts those refusals as negative tests (exit 2 at CLI preflight). Manifest requires/permissions_requested declarations are requests, never grants.

5. Determinism / offline behavior

  • check --emit output must be location-independent (no absolute paths, timestamps, PIDs). The tool's heading-anchor digest must be identical for the same logical project regardless of checkout directory.
  • run --trace-file must produce a valid Trace v2 document whose source.analysis_digest matches the emitted Analysis bytes.
  • After marqdo lock has populated .marqdo/cache, deleting the Git source repository must not break check/run (no fetch at check/run time).
  • Moving the project directory must not change module identity or Analysis output.
  • The tool consumer only uses the Python standard library and the public Analysis v2 / Trace v2 files; it never links Rust or reads private IR.

6. Unsupported / fail-closed behavior declared by this fixture

  • Missing plugin export: must fail closed (runtime symbol.unknown in the current binary; static rejection is required by RFC-EXT-0001 §4.3 and is a recorded gap).
  • Wrong argument names / missing required arguments: static call.arity.
  • Positional plugin arguments: not supported by ABI v1; must be rejected (static rejection is a recorded gap; runtime rejects with runtime.type).
  • Duplicate full export across two plugins: deterministic prepare failure.
  • Tampered / missing / wrong-target plugin artifact: fail closed before the main function is executed.
  • Plugin ABI major mismatch: plugin.abi_mismatch.
  • Kernel digest mismatch: fail closed before spawn.
  • pure/strict with extension grants: CLI preflight refusal (exit 2).
  • Resource provider CLI: UNSUPPORTED in the current binary; the provider implementation and framed worker are still built and self-tested here.
  • Unknown platforms: build.sh fails explicitly; the runner records UNSUPPORTED, never PASS.

7. Known gaps observed through this suite

Recorded in evidence/results.json (known_gaps) with exit codes and repro commands. Summary:

  1. Static unknown plugin export is not rejected. $MARQDO_BIN check plugin/demo-missing-export.mq.md --plugin plugin/build exits 0, but RFC-EXT-0001 §4.3/§4.5 and the plugin spec require a static symbol.unknown; only run fails (exit 1). Repro recorded as case neg_plugin_unknown_export_check_static.
  2. Static positional plugin arguments are not rejected. check exits 0; run fails with runtime.type: plugin calls require named arguments. RFC-EXT-0001 §4.5(3) forbids "static pass, runtime reject". Repro recorded as case neg_plugin_positional_check_static.
  3. No --provider / --allow-provider in the frozen CLI. $MARQDO_BIN run provider/demo.mq.md --provider provider/build/provider.json --allow-provider demo.sensor exits 2 with unexpected argument '--provider'. RFC-EXT-0001 §5.2 requires these flags, so all provider CLI cases are UNSUPPORTED (the provider manifest v2 + worker implementation themselves are self-tested and pass).
  4. check --help still says "Write the public Analysis v1 projection" although --emit writes schema_version: 2 (documentation drift only; the Analysis v2 contract is what the tool validates).