Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e43a3d82c | ||
|
|
bc05b0aa6c | ||
|
|
36666ab52b | ||
|
|
79da4d2ca4 | ||
|
|
a9ccb3a6da | ||
|
|
0f87f856db | ||
|
|
123a54cb3e | ||
|
|
63776735e9 | ||
|
|
73b51ffb69 | ||
|
|
8c6e2c6509 | ||
|
|
c96589a3c5 | ||
|
|
0973241a1f | ||
|
|
6cfdd811b4 | ||
|
|
ed86796d6b | ||
|
|
13affa76dd | ||
|
|
c44b0f9438 | ||
|
|
29fc0108f5 | ||
|
|
9b21486c7d |
No files matched your search
+20
-5
@@ -16,7 +16,9 @@ steps:
|
||||
- apt-get install -y --no-install-recommends ca-certificates git python3 python3-jsonschema
|
||||
- cargo build --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
- python3 tools/ci/check_dependency_boundaries.py
|
||||
- python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
|
||||
# The contract and test steps share a mutable submodule checkout.
|
||||
- mkdir -p target
|
||||
- flock target/ecosystem-bundle.lock python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
|
||||
- MARQDO_TEST_STDLIB_BUNDLE="$PWD/target/ecosystem-stdlib" bash tools/ci/contract_lane.sh
|
||||
|
||||
test:
|
||||
@@ -24,10 +26,20 @@ steps:
|
||||
commands:
|
||||
- rustup component add clippy rustfmt
|
||||
- apt-get update
|
||||
- apt-get install -y --no-install-recommends curl ca-certificates git python3 python3-jsonschema build-essential gcc-mingw-w64-x86-64
|
||||
- curl -fsSL https://deb.nodesource.com/setup_22.x | bash -
|
||||
- apt-get install -y --no-install-recommends nodejs
|
||||
- python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
|
||||
- apt-get install -y --no-install-recommends curl ca-certificates git python3 python3-jsonschema build-essential gcc-mingw-w64-x86-64 xz-utils
|
||||
# Node 22 is required by the ES-module foreign-kernel tests. Install the
|
||||
# official tarball from the reachable npmmirror binary mirror; the
|
||||
# NodeSource apt repository has repeatedly stalled in this runner.
|
||||
- |
|
||||
set -eu
|
||||
curl -fsSL --retry 5 --retry-delay 5 \
|
||||
"https://cdn.npmmirror.com/binaries/node/v22.23.5/node-v22.23.5-linux-x64.tar.xz" \
|
||||
-o /tmp/node.tar.xz
|
||||
tar -xJf /tmp/node.tar.xz -C /usr/local --strip-components=1
|
||||
node --version
|
||||
npm --version
|
||||
- mkdir -p target
|
||||
- flock target/ecosystem-bundle.lock python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
|
||||
- python3 tools/stdlib/bundle.py --stdlib-dir target/ecosystem-stdlib
|
||||
- cargo fmt --all -- --check
|
||||
- cargo clippy --workspace --all-targets -- -D warnings
|
||||
@@ -69,6 +81,9 @@ steps:
|
||||
- apt-get install -y --no-install-recommends ca-certificates git openssl python3 python3-jsonschema build-essential
|
||||
# Release archives must ship both binaries: the provider worker is the
|
||||
# only supported transport and resolution is a sibling-of-CLI lookup.
|
||||
# The release commit is embedded in both binaries so `inspect
|
||||
# --environment` and package/smoke evidence bind to the exact source SHA.
|
||||
- export MARQDO_BUILD_SOURCE_SHA="$CI_COMMIT_SHA"
|
||||
- cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
- test -x target/release/marqdo-provider-worker
|
||||
- python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
|
||||
|
||||
@@ -15,13 +15,20 @@ steps:
|
||||
- cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
- |
|
||||
set -eu
|
||||
baseline_sha=2c7c4f31e7a388d3fcfa717a77067e696ed13854
|
||||
git fetch --no-tags origin refs/tags/v3.0.0-beta.1
|
||||
# Previous published RC for the rc.6 comparison.
|
||||
baseline_sha=c44b0f943875d563bb7c170f8ccd3fd56a82360f
|
||||
git fetch --no-tags origin refs/tags/v3.0.0-rc.5
|
||||
test "$(git rev-parse 'FETCH_HEAD^{commit}')" = "$baseline_sha"
|
||||
perf_dir="$(mktemp -d)"
|
||||
git worktree add --detach "$perf_dir/beta" "$baseline_sha"
|
||||
trap 'git worktree remove --force "$perf_dir/beta"; rm -rf "$perf_dir"' EXIT
|
||||
(cd "$perf_dir/beta" && cargo build --release --locked -p marqdo-cli)
|
||||
# The external-Bundle migration moved the print workload fixture out of
|
||||
# the removed in-repo stdlib tree; both binaries must measure the same
|
||||
# workload sources/expected digests, so copy the perf definition into
|
||||
# the baseline worktree.
|
||||
rm -rf "$perf_dir/beta/tools/perf"
|
||||
cp -a tools/perf "$perf_dir/beta/tools/perf"
|
||||
|
||||
version="$(target/release/marqdo --version | cut -d ' ' -f 2)"
|
||||
python3 tools/release/package.py --version "$version" --source-sha "$CI_COMMIT_SHA" \
|
||||
@@ -38,7 +45,8 @@ steps:
|
||||
echo "G4_CPU $(awk -F: '/model name/ {print $2; exit}' /proc/cpuinfo | xargs)"
|
||||
echo "G4_GOVERNOR $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor 2>/dev/null || echo unavailable)"
|
||||
(cd "$perf_dir/beta" && python3 tools/perf/runner.py --no-build \
|
||||
--warmups 5 --samples 20 --platform-id woodpecker-agent-1 \
|
||||
--stdlib-dir "$candidate/stdlib" --warmups 5 --samples 20 \
|
||||
--platform-id woodpecker-agent-1 \
|
||||
--cpu-list "$cpu_list" --out "$perf_dir/beta.json" > /dev/null)
|
||||
python3 tools/perf/runner.py --no-build --binary "$candidate/marqdo" \
|
||||
--stdlib-dir "$candidate/stdlib" --warmups 5 --samples 20 \
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Marqdo CLI — Agent / Contributor Operating Rules
|
||||
|
||||
<!-- marqdo:repo-conventions v1 -->
|
||||
|
||||
生态级仓库开发规范:https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-CONVENTIONS.md
|
||||
|
||||
|
||||
**Start here:** read `docs/architecture/RFC-LANG-0002-unified-semantics.md` — it is the single current language authority — and its normative summary `spec/mapping.md` + `spec/expression.ebnf`. Then read `docs/architecture/CURRENT.md` (the single current architecture overview, including the Engine / Host Contract / Native Host map), [ADR-0071](docs/adr/0071-engine-host-contract-boundary.md) (boundary rules and keep-in-workspace decision), `docs/STATUS.md` (what is actually implemented), the relevant `spec/` files, `docs/adr/` for decisions at their date, the developer entry point `docs/developers/README.md`, `docs/contributor-guide.md`, and `tests/README.md` plus the conformance fixtures. Do not assume any current implementation, legacy Marqdo syntax, historical planning document or old architecture gate is authoritative.
|
||||
|
||||
For next-phase work, the authoritative release policy for the current
|
||||
|
||||
+28
-2
@@ -5,8 +5,9 @@ All notable changes to the Marqdo CLI workspace. Published prereleases:
|
||||
`2c7c4f31e7a388d3fcfa717a77067e696ed13854`),
|
||||
`3.0.0-rc.1` (source `f7a5a7b0163bf5229ed09adfffd892f9899e6667`) and
|
||||
`3.0.0-rc.2` (source `9149ee40a48fcda692c5c112f66c465487d13dfb`) and
|
||||
`3.0.0-rc.3` (2026-11-24, source `1e2a045cc78bf40972181abb44e7117c56cf4401`); the section below is the current
|
||||
release record. Current
|
||||
`3.0.0-rc.3` (2026-11-24, source `1e2a045cc78bf40972181abb44e7117c56cf4401`)
|
||||
and `3.0.0-rc.4` (2026-11-25, source `452e9a32bd9e40dba427d4180691c58bab74449e`);
|
||||
the section below is the current release record. Current
|
||||
protocol contracts are Analysis v3, Observation v1, CLI Tool revision 1,
|
||||
Plugin ABI v1, Foreign wire v1, Provider manifest v2 and lock v4; independent
|
||||
package versions (including the bundled stdlib `0.1.0`) are versioned
|
||||
@@ -14,6 +15,31 @@ separately and do not follow the product version. Dates use ISO 8601.
|
||||
Older sections are release records: a retired option or spec they name is
|
||||
available at its tagged commit, not in the current tree.
|
||||
|
||||
## 3.0.0-rc.6 (candidate)
|
||||
|
||||
- The release index binds the packaged CLI and Worker assets to the tested
|
||||
source SHA and the actual stdlib Bundle inputs.
|
||||
- A Linux RC can report strict isolation as unsupported with maintainer
|
||||
approval and same-archive fail-closed evidence. Stable and LTS require a
|
||||
passing disposable-VM gate.
|
||||
|
||||
## 3.0.0-rc.5 (2026-11-27)
|
||||
|
||||
Release record for tag `v3.0.0-rc.5` (Linux x86_64, glibc 2.39 prerelease).
|
||||
The Gitea release carries the archive; known limitations (strict L1 UNVERIFIED
|
||||
in the release environment, shared-node G4 WARN only) are recorded in
|
||||
`docs/releases/3.0.0-rc.5.md`.
|
||||
|
||||
- The CLI and provider worker consume one explicit external stdlib Bundle
|
||||
(`--stdlib-dir`/Bundle pin) and the repository no longer carries a `stdlib/`
|
||||
source tree (issue #11 Phase B). Contract lanes and product tests materialize
|
||||
the ecosystem Bundle through `tools/ci/fetch_ecosystem_bundle.py`.
|
||||
- Tooling, docs and test support reference the external Bundle; the release
|
||||
archive still ships exactly one verified stdlib Bundle.
|
||||
- Version metadata is `3.0.0-rc.5` on this candidate branch only. Remaining
|
||||
release gates: frozen SHA, same-SHA CI, strict VM, G4 performance and
|
||||
maintainer approval.
|
||||
|
||||
## 3.0.0-rc.4 (2026-11-25)
|
||||
|
||||
- The Rust workspace, CLI version output and protocol producers report
|
||||
|
||||
+24
-21
@@ -1,22 +1,21 @@
|
||||
# Compatibility and support matrix
|
||||
|
||||
Snapshot: product version **`3.0.0-rc.4`** (prerelease, released 2026-11-25).
|
||||
Tag `v3.0.0-rc.4` at source SHA
|
||||
`452e9a32bd9e40dba427d4180691c58bab74449e`; release
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4. The previous
|
||||
release is `3.0.0-rc.3` at source SHA
|
||||
`1e2a045cc78bf40972181abb44e7117c56cf4401`; its evidence remains under
|
||||
[`docs/evidence/`](docs/evidence/2026-11-24-rc.3-release.md). This file records
|
||||
Snapshot: product version **`3.0.0-rc.6`** (prerelease, release candidate,
|
||||
2026-11-28). Tag `v3.0.0-rc.6` on the tested release commit; release
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.6. The previous
|
||||
release is `3.0.0-rc.5` at source SHA
|
||||
`c44b0f943875d563bb7c170f8ccd3fd56a82360f`; its evidence remains under
|
||||
[`docs/releases/3.0.0-rc.5.md`](docs/releases/3.0.0-rc.5.md). This file records
|
||||
what was actually verified and separates it from what is only implemented. The
|
||||
supported release platform is **Linux x86_64 (glibc 2.39)**; everything else is
|
||||
experimental and not claimed for this prerelease. Executed status and SHA-bound
|
||||
evidence are in [`docs/STATUS.md`](docs/STATUS.md) and
|
||||
[`docs/evidence/`](docs/evidence/).
|
||||
|
||||
The `3.0.0-rc.4` release includes the post-beta protocol convergence and the
|
||||
closed public Analysis boundary below. See the
|
||||
The `3.0.0-rc.6` release candidate includes the post-beta protocol convergence
|
||||
and the closed public Analysis boundary below. See the
|
||||
[RC acceptance procedure](docs/releasing.md). The platform evidence table
|
||||
records the beta, rc.1/rc.2/rc.3 and rc.4 candidate verification.
|
||||
records the beta, rc.1/rc.2/rc.3, rc.4 and rc.5 candidate verification.
|
||||
|
||||
## Language source syntax (breaking change)
|
||||
|
||||
@@ -56,7 +55,7 @@ Consequences for compatibility:
|
||||
|
||||
## Post-`3.0.0-beta.1` boundary changes (RFC-EXT-0003)
|
||||
|
||||
These landed after the beta tag and **are included in the `3.0.0-rc.4` candidate**; they are
|
||||
These landed after the beta tag and **are included in the `3.0.0-rc.6` candidate**; they are
|
||||
intentional beta-line incompatibilities. Frozen decisions: ADR-0060..0063; executed
|
||||
evidence: [`docs/evidence/2026-11-22-rfc-ext-0003-core-hardcoding.md`](docs/evidence/2026-11-22-rfc-ext-0003-core-hardcoding.md).
|
||||
|
||||
@@ -91,7 +90,7 @@ consume this candidate's `check --emit` output.
|
||||
| Surface | Version | Compatibility rule |
|
||||
|---|---|---|
|
||||
| Markdown profile | `marqdo.md.v1` | Frozen parser/options. The RFC-LANG-0002 mapping rewrite keeps this profile; the source-language break is tracked above, not by a new profile id. |
|
||||
| Language / CLI | `3.0.0-rc.4` (candidate) | SemVer prerelease: breaking changes inside the 3.0 beta line are allowed and announced in the changelog. The `.mq.md` source language changed incompatibly (RFC-LANG-0002); there is no old-syntax execution path or downgrade. CLI flags may change with a changelog note; `strict` refusal is contractual. |
|
||||
| Language / CLI | `3.0.0-rc.6` (candidate) | SemVer prerelease: breaking changes inside the 3.0 beta line are allowed and announced in the changelog. The `.mq.md` source language changed incompatibly (RFC-LANG-0002); there is no old-syntax execution path or downgrade. CLI flags may change with a changelog note; `strict` refusal is contractual. |
|
||||
| `marqdo.lock` | v4 | v3 is rejected with an explicit `marqdo lock` migration error; v1/v2 are rejected with a relock instruction; `run`/`call`/`check` never rewrite or fetch the lock. `extensions:` records manifest/artifact identity (integrity, not publisher auth). |
|
||||
| Analysis | v3 | One writer and one current major for every project, including projects without loop transfers. Consumers reject other majors; the retired v2 selector, schema and documents are gone (ADR-0068). |
|
||||
| Observation | v1 | One `run_id`/`seq` event sequence per execution, delivered as JSONL, JSON snapshot or file snapshot from the same run. Values are opt-in and bounded; consumers reject other identifiers (spec/observation.md). |
|
||||
@@ -102,6 +101,7 @@ consume this candidate's `check --emit` output.
|
||||
| Analysis `calls[].state/target` | v3 projection | Projected from the unique binding; official stdlib aliases appear as `function`. The private binding table is not serialized. |
|
||||
| Extension selection | lock v4 | `marqdo.yaml.extensions` only `./path` or `@alias/path`; declaration is not a grant; declared identity must match the lock (`ext.extension_lock_mismatch`). |
|
||||
| Foreign wire | v1 | One-shot request envelope; provider descriptors are explicit. |
|
||||
| Environment report | v1 | `inspect --environment --json` (`marqdo.environment`). Additive fields are compatible; code/semantic changes need a schema revision (spec/environment.md). It never projects paths, credentials or source. |
|
||||
|
||||
## Platform / feature evidence
|
||||
|
||||
@@ -125,6 +125,7 @@ portable/tested locally but the native platform lane has not run here;
|
||||
| External conformance repository (`marqdo-extension-conformance`, frozen CLI) | PASS (7/7 categories against the published archive, fixture repo `015ff8ac…`; see the rc.3 evidence bundle) | UNVERIFIED | UNVERIFIED |
|
||||
| Analysis v3 + Observation v1 + Python consumers | PASS (same-SHA CI contract lane and archive smoke; independent consumers) | UNVERIFIED | UNVERIFIED |
|
||||
| CLI Tool revision 1 + independent consumers | PASS | UNVERIFIED | UNVERIFIED |
|
||||
| Environment report (`inspect --environment`, embedded source SHA, Bundle identity) | PASS (workspace tests + CI build identity embedding) | UNVERIFIED | UNVERIFIED |
|
||||
| Native ABI (`plugin inspect`, trusted call) | PASS (C fixture) | UNVERIFIED (host-native fixture) | **UNSUPPORTED** |
|
||||
| Worker ABI + `fs.read` bridge | PASS (Unix) | UNVERIFIED | **UNSUPPORTED** (Unix-gated) |
|
||||
| Foreign Python/Node | PASS (system `python3`/`node`) | UNVERIFIED | UNVERIFIED |
|
||||
@@ -139,7 +140,7 @@ build of both binaries), the release-archive cold-install smoke, the external
|
||||
frozen-binary conformance repository, and the disposable-VM strict lane. The
|
||||
source of truth is the Gitea remote `git.cflmy.cn/cflmy/marqdo-cli` with
|
||||
Woodpecker at `ci.cflmy.cn`; a GitHub mirror is not the authoritative lane for
|
||||
this beta. macOS/Windows entries are implementation notes, not support claims;
|
||||
this prerelease line. macOS/Windows entries are implementation notes, not support claims;
|
||||
the Windows C ABI/provider paths remain fail-closed.
|
||||
|
||||
## Strict L1 scope (ADR-0021)
|
||||
@@ -199,14 +200,16 @@ the Windows C ABI/provider paths remain fail-closed.
|
||||
|
||||
## Release decision
|
||||
|
||||
**`3.0.0-rc.4` prerelease — released as a Linux x86_64 RC.** The RC profile in
|
||||
**`3.0.0-rc.6` prerelease — release candidate for a Linux x86_64 RC.** The RC
|
||||
profile in
|
||||
[`docs/MARQDO_3_0_PRERELEASE_PLAN.md`](docs/MARQDO_3_0_PRERELEASE_PLAN.md) §3 was
|
||||
used: Linux is the only supported platform, macOS/Windows are UNSUPPORTED for
|
||||
this scope, strict L1 has same-SHA disposable-VM evidence, and G4 performance is
|
||||
a maintainer-approved shared-node `WARN` for this named RC only. The aggregate
|
||||
decision and per-gate evidence are in
|
||||
[`docs/evidence/ci/1e2a045cc78bf40972181abb44e7117c56cf4401/manifest.json`](docs/evidence/ci/1e2a045cc78bf40972181abb44e7117c56cf4401/manifest.json)
|
||||
(`RC_RELEASE_CANDIDATE`) and the release assets; see
|
||||
[`docs/evidence/2026-11-24-rc.3-release.md`](docs/evidence/2026-11-24-rc.3-release.md).
|
||||
A prerelease does not imply stable `3.0.0` or LTS; the stable gate remains
|
||||
this scope. This cycle verifies the deterministic archive, the archive-only
|
||||
Ubuntu 24.04 cold install, the migrated extensions, frozen external conformance
|
||||
and a shared-host performance `WARN`. The RC records `strict: unsupported` with
|
||||
same-SHA fail-closed smoke evidence; the disposable-VM strict L1 PASS remains a
|
||||
stable/LTS gate, so no isolation PASS is claimed here. The RC gate aggregate
|
||||
(`RC_RELEASE_CANDIDATE`) is generated by `tools/ci/release_evidence.py`; the
|
||||
per-gate references are recorded in CLI issue #22 and the release assets. A
|
||||
prerelease does not imply stable `3.0.0` or LTS; the stable gate remains
|
||||
stricter and separate.
|
||||
Generated
+18
-17
@@ -412,10 +412,11 @@ checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-cli"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"hex",
|
||||
"libc",
|
||||
"marqdo-expression",
|
||||
"marqdo-foreign",
|
||||
"marqdo-frontend",
|
||||
@@ -439,7 +440,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-expression"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
@@ -450,7 +451,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-foreign"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"libc",
|
||||
@@ -466,7 +467,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-frontend"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-ir",
|
||||
@@ -481,7 +482,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-host"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"getrandom 0.4.3",
|
||||
@@ -510,7 +511,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-host-contract"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
@@ -518,7 +519,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-ir"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-span",
|
||||
@@ -528,7 +529,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-markdown"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"comrak",
|
||||
"marqdo-span",
|
||||
@@ -539,7 +540,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-package"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"hex",
|
||||
"semver",
|
||||
@@ -553,7 +554,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-plugin-abi"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-value",
|
||||
"serde",
|
||||
@@ -563,7 +564,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-plugin-sdk"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-plugin-abi",
|
||||
"serde",
|
||||
@@ -572,7 +573,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-provider-worker"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"libloading",
|
||||
"marqdo-host",
|
||||
@@ -586,7 +587,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-runtime"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-frontend",
|
||||
@@ -606,7 +607,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-sandbox"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"serde",
|
||||
@@ -614,14 +615,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-span"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-value"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
@@ -632,7 +633,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-worker-ipc"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
edition = "2021"
|
||||
rust-version = "1.89"
|
||||
license = "Apache-2.0"
|
||||
|
||||
@@ -10,7 +10,7 @@ The official implementation is a Rust workspace; Python/Node are optional
|
||||
foreign kernels, never the compiler target.
|
||||
|
||||
This repository is the new, independent Marqdo toolchain, now at product
|
||||
version **`3.0.0-rc.4`** in this checkout. It is **not** a compatibility rewrite of
|
||||
version **`3.0.0-rc.6`** in this checkout. It is **not** a compatibility rewrite of
|
||||
`cflmy/marqdo`; the old syntax, package format and plugin ABI v2 are not
|
||||
claimed to work here. See [docs/developers/](docs/developers/README.md) for the
|
||||
third-party entry point and `docs/MARQDO_3_0_PRERELEASE_PLAN.md` for the beta
|
||||
@@ -27,19 +27,23 @@ release policy.
|
||||
> [`docs/STATUS.md`](docs/STATUS.md) and
|
||||
> [`docs/migration/README.md`](docs/migration/README.md).
|
||||
|
||||
> **Current release: `3.0.0-rc.4` prerelease** —
|
||||
> [release](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4),
|
||||
> source `452e9a32bd9e40dba427d4180691c58bab74449e`, Linux x86_64. The previous
|
||||
> published baseline was `3.0.0-beta.1` —
|
||||
> [release](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-beta.1),
|
||||
> source `2c7c4f31e7a388d3fcfa717a77067e696ed13854`. The public beta target is **Linux x86_64 (glibc)**; macOS and Windows are experimental and not claimed, and the
|
||||
> C ABI plugin/provider paths are Linux-only in this beta. The language
|
||||
> **Current release: `3.0.0-rc.6` prerelease** —
|
||||
> [release](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.6),
|
||||
> source: the tagged release commit, Linux x86_64. The previous published
|
||||
> release was `3.0.0-rc.5` —
|
||||
> [release](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.5),
|
||||
> source `c44b0f943875d563bb7c170f8ccd3fd56a82360f`. The supported prerelease
|
||||
> target is **Linux x86_64 (glibc 2.39)**; macOS and Windows are experimental
|
||||
> and not claimed, and the C ABI plugin/provider paths are Linux-only in this
|
||||
> prerelease line. The language
|
||||
> (RFC-LANG-0002), lock v4, Analysis, Observation, CLI Tool, Plugin ABI v1
|
||||
> (native + worker), pinned Foreign providers and Resource Provider v2 are
|
||||
> implemented and covered by tests. **`strict` OS isolation is Linux-only and
|
||||
> probe-gated**; unsupported hosts must fail closed, and strict L2
|
||||
> (Worker/Foreign/Provider) is not implemented. The broker and worker
|
||||
> transports are not sandboxes. The beta release decision, support matrix and
|
||||
> (Worker/Foreign/Provider) is not implemented. This RC records `strict:
|
||||
> unsupported` with same-SHA fail-closed evidence; a disposable-VM PASS is
|
||||
> required for stable/LTS, not for the RC. The broker and worker
|
||||
> transports are not sandboxes. The RC release decision, support matrix and
|
||||
> remaining gaps are recorded in [`docs/STATUS.md`](docs/STATUS.md),
|
||||
> [`COMPATIBILITY.md`](COMPATIBILITY.md),
|
||||
> [`docs/developers/release-limits.md`](docs/developers/release-limits.md) and
|
||||
@@ -53,7 +57,7 @@ runs fmt, clippy, workspace tests with `--locked`, the dependency-direction and
|
||||
engine-independence gates, the plugin SDK consumption gate, the Windows
|
||||
cross-target compile gate and a release build of both binaries. The strict OS-isolation lane
|
||||
requires the disposable VM described in [docs/ci.md](docs/ci.md); a GitHub
|
||||
mirror is not used as the authoritative lane for this beta.
|
||||
mirror is not used as the authoritative lane for this prerelease line.
|
||||
|
||||
## Build
|
||||
|
||||
@@ -98,6 +102,7 @@ marqdo run index.mq.md # executes ## @exec main
|
||||
marqdo run index.mq.md --output jsonl # live Observation JSON Lines
|
||||
marqdo inspect index.mq.md --ast
|
||||
marqdo inspect index.mq.md --signature
|
||||
marqdo inspect --environment --json # offline installed-identity report
|
||||
marqdo call index.mq.md main
|
||||
```
|
||||
|
||||
@@ -266,6 +271,9 @@ rules are [`RFC-LANG-0002`](docs/architecture/RFC-LANG-0002-unified-semantics.md
|
||||
[Observation](spec/observation.md) delivers the same run as live JSONL or
|
||||
a JSON snapshot. [CLI Tool](spec/cli-tool.md) installs independently built
|
||||
commands with exact protocol requirements and verifies their entire bundle.
|
||||
`inspect --environment --json` reports the offline installed identity
|
||||
(version, embedded source commit, platform, Bundle, protocol revisions) for
|
||||
feedback and release evidence.
|
||||
|
||||
Run everything:
|
||||
|
||||
@@ -395,7 +403,9 @@ tests/ conformance/negative corpus, embedding consumer an
|
||||
[`plugin-abi.md`](spec/plugin-abi.md), [`math.md`](spec/math.md),
|
||||
[`foreign.md`](spec/foreign.md), [`cli-tool.md`](spec/cli-tool.md),
|
||||
[`analysis.md`](spec/analysis.md), [`observation.md`](spec/observation.md),
|
||||
[`worker-ipc.md`](spec/worker-ipc.md);
|
||||
[`worker-ipc.md`](spec/worker-ipc.md),
|
||||
[`environment.md`](spec/environment.md),
|
||||
[`document-structure.md`](spec/document-structure.md);
|
||||
JSON Schemas in [`spec/schemas/`](spec/schemas/).
|
||||
* [`tests/README.md`](tests/README.md) — conformance corpus and `UPDATE_GOLDENS`
|
||||
workflow.
|
||||
|
||||
@@ -30,6 +30,7 @@ hex = { workspace = true }
|
||||
sha2 = { workspace = true }
|
||||
semver = { workspace = true }
|
||||
tempfile = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
|
||||
[[bin]]
|
||||
name = "marqdo"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//! Embed the release source commit when the build supplies it.
|
||||
//!
|
||||
//! The release pipeline builds the archive from one commit and records the
|
||||
//! same commit in `SOURCE_SHA`/`RELEASE_INFO.json`; embedding it here lets
|
||||
//! `marqdo inspect --environment --json` report the exact product identity
|
||||
//! without reading files next to the binary (marqdo-cli#26 §9.2). An ordinary
|
||||
//! development build simply has no embedded commit and reports `null` instead
|
||||
//! of guessing.
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-env-changed=MARQDO_BUILD_SOURCE_SHA");
|
||||
let Ok(sha) = std::env::var("MARQDO_BUILD_SOURCE_SHA") else {
|
||||
return;
|
||||
};
|
||||
let sha = sha.trim();
|
||||
let valid = sha.len() == 40
|
||||
&& sha
|
||||
.chars()
|
||||
.all(|ch| ch.is_ascii_hexdigit() && !ch.is_ascii_uppercase());
|
||||
if valid {
|
||||
println!("cargo:rustc-env=MARQDO_BUILD_SOURCE_SHA={sha}");
|
||||
} else {
|
||||
println!(
|
||||
"cargo:warning=MARQDO_BUILD_SOURCE_SHA is not a full lowercase 40-hex commit; \
|
||||
the environment report will not claim a source commit"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ pub const SCHEMA: &str = "marqdo.analysis";
|
||||
/// Current public revision.
|
||||
pub const SCHEMA_VERSION: u32 = 3;
|
||||
/// Markdown profile recorded by the producer.
|
||||
const MARKDOWN_PROFILE: &str = "marqdo.md.v1";
|
||||
pub const MARKDOWN_PROFILE: &str = "marqdo.md.v1";
|
||||
|
||||
/// Projection shared with `inspect --ast`.
|
||||
pub fn document_projection(root: &marqdo_markdown::MdNode, source_len: usize) -> Value {
|
||||
|
||||
@@ -19,9 +19,20 @@ pub struct InspectFlags {
|
||||
pub platform: bool,
|
||||
/// Show declared/loaded extension identities (never grants).
|
||||
pub extensions: bool,
|
||||
/// Print the offline installed-environment diagnostic report.
|
||||
///
|
||||
/// Exclusive with document inspection: it needs no project and must not be
|
||||
/// combined with project flags (enforced by the argument parser).
|
||||
pub environment: bool,
|
||||
}
|
||||
|
||||
pub fn inspect(file: Option<&Path>, flags: &InspectFlags, json: bool, plugins: &[PathBuf]) -> i32 {
|
||||
// The installed-environment report is project-independent and must not
|
||||
// prepare, load or execute anything. The argument parser rejects combining
|
||||
// it with document-inspection flags.
|
||||
if flags.environment {
|
||||
return crate::environment::emit(json);
|
||||
}
|
||||
let prepared = match prepare_project(file, json, plugins) {
|
||||
Ok(prepared) => prepared,
|
||||
Err(code) => return code,
|
||||
|
||||
@@ -0,0 +1,443 @@
|
||||
//! Offline installed-environment report (`marqdo inspect --environment`).
|
||||
//!
|
||||
//! This is the stable machine-readable diagnostic export required by
|
||||
//! marqdo-cli#26 §9.2 / marqdo#56 §9.4. It reads only installed identity and
|
||||
//! process-platform facts:
|
||||
//!
|
||||
//! * it never executes project code, opens a provider session, loads a plugin
|
||||
//! or accesses the network;
|
||||
//! * it never prints credentials, Analysis/source content, user data or
|
||||
//! absolute host paths;
|
||||
//! * a degraded installation is reported as data (`status` + stable
|
||||
//! `diagnostics[].code`) instead of being hidden.
|
||||
//!
|
||||
//! The report schema is `marqdo.environment` version 1. It is intentionally
|
||||
//! separate from the Analysis/Observation/CLI-Tool protocols: it describes the
|
||||
//! installation used for feedback, not a project.
|
||||
|
||||
use std::io::Read;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
use serde_json::{json, Value};
|
||||
|
||||
use marqdo_value::codes;
|
||||
|
||||
use crate::output;
|
||||
|
||||
/// Report schema name.
|
||||
pub const SCHEMA: &str = "marqdo.environment";
|
||||
/// Current report revision.
|
||||
pub const SCHEMA_VERSION: u32 = 1;
|
||||
|
||||
/// Build-time source commit, when the release build supplied one.
|
||||
const BUILD_SOURCE_SHA: Option<&str> = option_env!("MARQDO_BUILD_SOURCE_SHA");
|
||||
|
||||
/// Upper bound for reading the adjacent worker's offline build identity.
|
||||
///
|
||||
/// The command prints one small JSON line; the bound keeps a replaced or
|
||||
/// broken sibling binary from hanging the diagnostic export.
|
||||
const WORKER_BUILD_INFO_TIMEOUT: Duration = Duration::from_millis(750);
|
||||
|
||||
/// Build the complete environment report.
|
||||
pub fn report() -> Value {
|
||||
let mut diagnostics: Vec<Value> = Vec::new();
|
||||
let producer = producer_json();
|
||||
let platform = platform_json();
|
||||
let worker = worker_json(&mut diagnostics);
|
||||
let bundle = bundle_json(&mut diagnostics);
|
||||
json!({
|
||||
"schema": SCHEMA,
|
||||
"schema_version": SCHEMA_VERSION,
|
||||
"producer": producer,
|
||||
"platform": platform,
|
||||
"worker": worker,
|
||||
"bundle": bundle,
|
||||
"protocols": protocols_json(),
|
||||
"diagnostics": diagnostics,
|
||||
})
|
||||
}
|
||||
|
||||
/// Print the report and return the process exit code.
|
||||
///
|
||||
/// Emitting a report always succeeds: a degraded installation is data, not a
|
||||
/// command failure. Usage errors (for example combining `--environment` with a
|
||||
/// project-inspection flag) are rejected by the argument parser before this
|
||||
/// function runs.
|
||||
pub fn emit(json_output: bool) -> i32 {
|
||||
let report = report();
|
||||
if json_output {
|
||||
output::print_json(&report);
|
||||
return 0;
|
||||
}
|
||||
let producer = &report["producer"];
|
||||
let source = producer["source"]["sha"].as_str().unwrap_or("unavailable");
|
||||
println!(
|
||||
"marqdo {} (source {source})",
|
||||
producer["version"].as_str().unwrap_or("unknown")
|
||||
);
|
||||
let platform = &report["platform"];
|
||||
println!(
|
||||
"platform: {}/{} ({})",
|
||||
platform["os"].as_str().unwrap_or("unknown"),
|
||||
platform["arch"].as_str().unwrap_or("unknown"),
|
||||
platform["family"].as_str().unwrap_or("unknown")
|
||||
);
|
||||
if let Some(libc) = platform["libc"].as_object() {
|
||||
let version = libc.get("version").and_then(Value::as_str).unwrap_or("");
|
||||
println!(
|
||||
"libc: {}{}",
|
||||
libc.get("family")
|
||||
.and_then(Value::as_str)
|
||||
.unwrap_or("unknown"),
|
||||
if version.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(" {version}")
|
||||
}
|
||||
);
|
||||
}
|
||||
println!(
|
||||
"worker: {}",
|
||||
report["worker"]["status"].as_str().unwrap_or("unknown")
|
||||
);
|
||||
let bundle = &report["bundle"];
|
||||
match bundle["status"].as_str().unwrap_or("unknown") {
|
||||
"verified" => println!(
|
||||
"bundle: {} {} (tree {})",
|
||||
bundle["name"].as_str().unwrap_or("unknown"),
|
||||
bundle["version"].as_str().unwrap_or("unknown"),
|
||||
bundle["tree_digest"].as_str().unwrap_or("unknown")
|
||||
),
|
||||
status => println!("bundle: {status}"),
|
||||
}
|
||||
let protocols = &report["protocols"];
|
||||
println!(
|
||||
"protocols: analysis={} observation={} cli-tool={} plugin-abi={} provider-manifest={} lock={}",
|
||||
protocols["analysis"],
|
||||
protocols["observation"],
|
||||
protocols["cli_tool"]["version"],
|
||||
protocols["plugin_abi"]["version"].as_str().unwrap_or("unknown"),
|
||||
protocols["provider_manifest"],
|
||||
protocols["package_lock"]
|
||||
);
|
||||
let diagnostics = report["diagnostics"]
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
if diagnostics.is_empty() {
|
||||
println!("diagnostics: none");
|
||||
} else {
|
||||
for diagnostic in diagnostics {
|
||||
println!(
|
||||
"diagnostics: [{}] {}",
|
||||
diagnostic["code"].as_str().unwrap_or("unknown"),
|
||||
diagnostic["message"].as_str().unwrap_or("")
|
||||
);
|
||||
}
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
fn producer_json() -> Value {
|
||||
let source = match BUILD_SOURCE_SHA {
|
||||
Some(sha) => json!({"sha": sha, "origin": "embedded"}),
|
||||
None => json!({"sha": null, "origin": "unavailable"}),
|
||||
};
|
||||
json!({
|
||||
"name": "marqdo",
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"source": source,
|
||||
})
|
||||
}
|
||||
|
||||
fn platform_json() -> Value {
|
||||
let capabilities = marqdo_sandbox::PlatformCapabilities::detect();
|
||||
json!({
|
||||
"os": capabilities.os,
|
||||
"arch": capabilities.arch,
|
||||
"family": std::env::consts::FAMILY,
|
||||
"libc": libc_json(),
|
||||
"strict": serde_json::to_value(capabilities.strict).unwrap_or(Value::Null),
|
||||
"worker_processes": capabilities.worker_processes,
|
||||
})
|
||||
}
|
||||
|
||||
fn libc_json() -> Value {
|
||||
#[cfg(all(target_os = "linux", target_env = "gnu"))]
|
||||
{
|
||||
// SAFETY: `gnu_get_libc_version` returns a pointer to a static
|
||||
// NUL-terminated string owned by the C library for the process
|
||||
// lifetime; it is copied immediately and never retained.
|
||||
let version = unsafe {
|
||||
let pointer = libc::gnu_get_libc_version();
|
||||
if pointer.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(
|
||||
std::ffi::CStr::from_ptr(pointer)
|
||||
.to_string_lossy()
|
||||
.into_owned(),
|
||||
)
|
||||
}
|
||||
};
|
||||
json!({"family": "glibc", "version": version})
|
||||
}
|
||||
#[cfg(target_env = "musl")]
|
||||
{
|
||||
json!({"family": "musl", "version": null})
|
||||
}
|
||||
#[cfg(not(any(all(target_os = "linux", target_env = "gnu"), target_env = "musl")))]
|
||||
{
|
||||
Value::Null
|
||||
}
|
||||
}
|
||||
|
||||
fn sibling_program(name: &str) -> Option<PathBuf> {
|
||||
let executable = std::env::current_exe().ok()?;
|
||||
let directory = executable.parent()?;
|
||||
let file_name = if cfg!(windows) {
|
||||
format!("{name}.exe")
|
||||
} else {
|
||||
name.to_string()
|
||||
};
|
||||
let candidate = directory.join(file_name);
|
||||
candidate.is_file().then_some(candidate)
|
||||
}
|
||||
|
||||
fn worker_json(diagnostics: &mut Vec<Value>) -> Value {
|
||||
let Some(worker) = sibling_program("marqdo-provider-worker") else {
|
||||
return json!({
|
||||
"name": "marqdo-provider-worker",
|
||||
"status": "absent",
|
||||
"version": null,
|
||||
"source_sha": null,
|
||||
});
|
||||
};
|
||||
match read_worker_build_info(&worker) {
|
||||
Ok((version, source_sha)) => json!({
|
||||
"name": "marqdo-provider-worker",
|
||||
"status": "present",
|
||||
"version": version,
|
||||
"source_sha": source_sha,
|
||||
}),
|
||||
Err(reason) => {
|
||||
diagnostics.push(json!({
|
||||
"code": codes::ENV_WORKER_INFO_UNAVAILABLE,
|
||||
"message": "the adjacent provider worker did not report its offline build identity",
|
||||
"detail": reason,
|
||||
}));
|
||||
json!({
|
||||
"name": "marqdo-provider-worker",
|
||||
"status": "present",
|
||||
"version": null,
|
||||
"source_sha": null,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Read the worker's single-shot `--build-info` document.
|
||||
///
|
||||
/// Only the version and a validated source SHA are retained; no path or
|
||||
/// environment value is projected. The child is bounded and killed if the
|
||||
/// installed binary does not answer in time.
|
||||
fn read_worker_build_info(worker: &Path) -> Result<(String, Option<String>), String> {
|
||||
let mut child = Command::new(worker)
|
||||
.arg("--build-info")
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()
|
||||
.map_err(|error| format!("cannot execute the adjacent provider worker: {error}"))?;
|
||||
let deadline = Instant::now() + WORKER_BUILD_INFO_TIMEOUT;
|
||||
loop {
|
||||
match child.try_wait() {
|
||||
Ok(Some(status)) => {
|
||||
if !status.success() {
|
||||
return Err("the adjacent provider worker rejected `--build-info`".to_string());
|
||||
}
|
||||
break;
|
||||
}
|
||||
Ok(None) => {
|
||||
if Instant::now() >= deadline {
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
return Err("the adjacent provider worker did not answer in time".to_string());
|
||||
}
|
||||
std::thread::sleep(Duration::from_millis(10));
|
||||
}
|
||||
Err(error) => return Err(format!("cannot wait for the provider worker: {error}")),
|
||||
}
|
||||
}
|
||||
let mut output = String::new();
|
||||
child
|
||||
.stdout
|
||||
.take()
|
||||
.ok_or_else(|| "the provider worker produced no output".to_string())?
|
||||
.read_to_string(&mut output)
|
||||
.map_err(|error| format!("cannot read the provider worker output: {error}"))?;
|
||||
let value: Value = serde_json::from_str(output.trim())
|
||||
.map_err(|_| "the provider worker output is not one JSON document".to_string())?;
|
||||
if value.get("schema").and_then(Value::as_str) != Some("marqdo.build-info")
|
||||
|| value.get("schema_version").and_then(Value::as_u64) != Some(1)
|
||||
|| value.get("product").and_then(Value::as_str) != Some("marqdo-provider-worker")
|
||||
{
|
||||
return Err("the provider worker build identity is not a current document".to_string());
|
||||
}
|
||||
let version = value
|
||||
.get("version")
|
||||
.and_then(Value::as_str)
|
||||
.filter(|version| !version.is_empty())
|
||||
.ok_or_else(|| "the provider worker build identity has no version".to_string())?
|
||||
.to_string();
|
||||
let source_sha = match value.get("source_sha") {
|
||||
Some(Value::Null) | None => None,
|
||||
Some(Value::String(sha)) if is_source_sha(sha) => Some(sha.clone()),
|
||||
Some(_) => {
|
||||
return Err(
|
||||
"the provider worker build identity has an invalid source commit".to_string(),
|
||||
)
|
||||
}
|
||||
};
|
||||
Ok((version, source_sha))
|
||||
}
|
||||
|
||||
fn is_source_sha(sha: &str) -> bool {
|
||||
sha.len() == 40
|
||||
&& sha
|
||||
.chars()
|
||||
.all(|ch| ch.is_ascii_hexdigit() && !ch.is_ascii_uppercase())
|
||||
}
|
||||
|
||||
fn bundle_json(diagnostics: &mut Vec<Value>) -> Value {
|
||||
let origin = if std::env::var_os(crate::stdlib::STDLIB_DIR_ENV).is_some() {
|
||||
"explicit-env"
|
||||
} else {
|
||||
"sibling"
|
||||
};
|
||||
match crate::stdlib::StdlibBundle::discover() {
|
||||
Ok(Some(bundle)) => json!({
|
||||
"status": "verified",
|
||||
"origin": origin,
|
||||
"name": bundle.name(),
|
||||
"version": bundle.version(),
|
||||
"tree_digest": bundle.digest(),
|
||||
"instance_id": bundle.instance_id(),
|
||||
}),
|
||||
Ok(None) => json!({
|
||||
"status": "absent",
|
||||
"origin": null,
|
||||
"name": null,
|
||||
"version": null,
|
||||
"tree_digest": null,
|
||||
"instance_id": null,
|
||||
}),
|
||||
Err(error) => {
|
||||
let (code, message) = categorize_bundle_error(&error);
|
||||
diagnostics.push(json!({"code": code, "message": message}));
|
||||
json!({
|
||||
"status": "invalid",
|
||||
"origin": origin,
|
||||
"name": null,
|
||||
"version": null,
|
||||
"tree_digest": null,
|
||||
"instance_id": null,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Map one bundle load failure to a stable code and a path-free message.
|
||||
///
|
||||
/// The raw loader error can contain an absolute host path, so it is never
|
||||
/// projected: diagnostics carry a stable code and a fixed message.
|
||||
fn categorize_bundle_error(error: &str) -> (&'static str, &'static str) {
|
||||
if error.contains("digest mismatch") || error.contains("alias metadata digest") {
|
||||
(
|
||||
codes::ENV_STDLIB_DIGEST_MISMATCH,
|
||||
"the installed stdlib Bundle does not match its declared digest",
|
||||
)
|
||||
} else if error.contains("cannot read")
|
||||
|| error.contains("cannot open")
|
||||
|| error.contains("cannot open stdlib directory")
|
||||
{
|
||||
(
|
||||
codes::ENV_STDLIB_UNREADABLE,
|
||||
"the installed stdlib Bundle cannot be read",
|
||||
)
|
||||
} else {
|
||||
(
|
||||
codes::ENV_STDLIB_INVALID,
|
||||
"the installed stdlib Bundle is not a current verified Bundle",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
fn protocols_json() -> Value {
|
||||
json!({
|
||||
"markdown_profile": crate::analysis::MARKDOWN_PROFILE,
|
||||
"analysis": crate::analysis::SCHEMA_VERSION,
|
||||
"observation": crate::observation::SCHEMA_VERSION,
|
||||
"cli_tool": {
|
||||
"version": crate::tool::PROTOCOL_VERSION,
|
||||
"api_revision": crate::tool::API_REVISION,
|
||||
},
|
||||
"plugin_abi": {
|
||||
"version": marqdo_plugin_abi::ABI_VERSION_STRING,
|
||||
"major": marqdo_plugin_abi::ABI_MAJOR,
|
||||
"minor": marqdo_plugin_abi::ABI_MINOR,
|
||||
},
|
||||
"provider_manifest": crate::provider_manifest::PROVIDER_SCHEMA_VERSION,
|
||||
"package_lock": marqdo_package::LOCK_VERSION,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn report_is_one_current_document() {
|
||||
let report = report();
|
||||
assert_eq!(report["schema"], SCHEMA);
|
||||
assert_eq!(report["schema_version"], 1);
|
||||
assert_eq!(report["producer"]["name"], "marqdo");
|
||||
assert_eq!(report["producer"]["version"], env!("CARGO_PKG_VERSION"));
|
||||
assert!(report["platform"]["os"].is_string());
|
||||
assert!(report["protocols"]["analysis"].is_number());
|
||||
assert!(report["protocols"]["package_lock"].is_number());
|
||||
assert!(report["diagnostics"].is_array());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn report_never_projects_absolute_host_paths_or_secrets() {
|
||||
let text = serde_json::to_string(&report()).unwrap();
|
||||
assert!(!text.contains("/root/"), "{text}");
|
||||
assert!(!text.contains("\\Users\\"), "{text}");
|
||||
assert!(!text.contains("token"), "{text}");
|
||||
assert!(!text.contains("api_key"), "{text}");
|
||||
assert!(!text.contains("secret"), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bundle_failures_map_to_stable_path_free_codes() {
|
||||
let (code, message) =
|
||||
categorize_bundle_error("stdlib digest mismatch: declared sha256:aa, actual sha256:bb");
|
||||
assert_eq!(code, codes::ENV_STDLIB_DIGEST_MISMATCH);
|
||||
assert!(!message.contains('/'));
|
||||
let (code, _) = categorize_bundle_error("cannot read `/root/private/stdlib.json`: denied");
|
||||
assert_eq!(code, codes::ENV_STDLIB_UNREADABLE);
|
||||
let (code, _) = categorize_bundle_error("`/root/x` has no name");
|
||||
assert_eq!(code, codes::ENV_STDLIB_INVALID);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_sha_validation_is_strict() {
|
||||
assert!(is_source_sha("63776735e924ade279cdf59d5c733dc24bfdabbb"));
|
||||
assert!(!is_source_sha("6377673"));
|
||||
assert!(!is_source_sha("63776735E924ADE279CDF59D5C733DC24BFDABBB"));
|
||||
assert!(!is_source_sha("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"));
|
||||
}
|
||||
}
|
||||
+13
-1
@@ -8,6 +8,7 @@ mod analysis;
|
||||
mod args;
|
||||
mod commands;
|
||||
mod document_refs;
|
||||
mod environment;
|
||||
mod extension_descriptors;
|
||||
mod extension_selection;
|
||||
mod loader;
|
||||
@@ -97,7 +98,7 @@ enum Command {
|
||||
Call(CallArgs),
|
||||
/// Statically check a document without executing it.
|
||||
Check(CheckArgs),
|
||||
/// Inspect AST, units, signatures, IR, references or platform support.
|
||||
/// Inspect AST, units, signatures, IR, references, platform support or the installed environment.
|
||||
Inspect(InspectArgs),
|
||||
/// Conservative formatting: normalises line endings and trailing newlines.
|
||||
Fmt(FmtArgs),
|
||||
@@ -298,6 +299,16 @@ struct InspectArgs {
|
||||
/// Print declared/loaded extension identities (never grants).
|
||||
#[arg(long)]
|
||||
extensions: bool,
|
||||
/// Print the offline installed-environment diagnostic report.
|
||||
///
|
||||
/// Reads only installed identity and platform facts: no project code is
|
||||
/// executed, no provider session is started and no absolute path,
|
||||
/// credential or source content is printed (marqdo-cli#26 §9.2).
|
||||
#[arg(
|
||||
long,
|
||||
conflicts_with_all = ["file", "ast", "units", "signature", "ir", "refs", "platform", "extensions", "plugin"]
|
||||
)]
|
||||
environment: bool,
|
||||
/// Explicitly selected plugin manifest for extension inspection (repeatable).
|
||||
#[arg(long = "plugin", value_name = "PATH")]
|
||||
plugin: Vec<PathBuf>,
|
||||
@@ -462,6 +473,7 @@ fn dispatch() -> i32 {
|
||||
refs: args.refs,
|
||||
platform: args.platform,
|
||||
extensions: args.extensions,
|
||||
environment: args.environment,
|
||||
};
|
||||
commands::inspect(args.file.as_deref(), &flags, args.json, &args.plugin)
|
||||
}
|
||||
|
||||
@@ -156,6 +156,11 @@ impl StdlibBundle {
|
||||
}
|
||||
|
||||
/// Declared stdlib version.
|
||||
/// Declared Bundle name.
|
||||
pub fn name(&self) -> &str {
|
||||
&self.name
|
||||
}
|
||||
|
||||
pub fn version(&self) -> &str {
|
||||
&self.version
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ use serde::{Deserialize, Serialize};
|
||||
use sha2::{Digest, Sha256};
|
||||
|
||||
const SCHEMA: &str = "marqdo.cli-tool";
|
||||
const PROTOCOL_VERSION: u32 = 1;
|
||||
pub(crate) const PROTOCOL_VERSION: u32 = 1;
|
||||
const RECORD_VERSION: u32 = 2;
|
||||
const MAX_BUNDLE_FILES: usize = 4096;
|
||||
const MAX_BUNDLE_BYTES: u64 = 256 * 1024 * 1024;
|
||||
|
||||
const API_REVISION: u32 = 1;
|
||||
pub(crate) const API_REVISION: u32 = 1;
|
||||
|
||||
const BUILTIN_COMMANDS: &[&str] = &[
|
||||
"init", "run", "call", "check", "inspect", "fmt", "plugin", "add", "remove", "lock", "sync",
|
||||
|
||||
@@ -154,7 +154,7 @@ fn stdlib_sources_live_in_the_ecosystem_not_in_this_repository() {
|
||||
"the accepted Bundle pin must name the ecosystem source, not a vendored path"
|
||||
);
|
||||
assert_eq!(pin.name, "marqdo-stdlib");
|
||||
assert_eq!(pin.version, "0.2.0");
|
||||
assert_eq!(pin.version, "0.3.0");
|
||||
assert_eq!(pin.source_commit.len(), 40);
|
||||
let root = stdlib_support::bundle_dir();
|
||||
let manifest: serde_json::Value =
|
||||
|
||||
@@ -300,3 +300,85 @@ fn current_contract_documents_do_not_reference_retired_interfaces() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn environment_report_contract_is_documented_once() {
|
||||
let root = repo_root();
|
||||
let spec = read(&root.join("spec/environment.md"));
|
||||
for needle in [
|
||||
"marqdo.environment",
|
||||
"schema_version: 1",
|
||||
"inspect --environment",
|
||||
"MARQDO_BUILD_SOURCE_SHA",
|
||||
"env.stdlib_digest_mismatch",
|
||||
"never project",
|
||||
] {
|
||||
assert!(
|
||||
spec.contains(needle),
|
||||
"spec/environment.md is missing `{needle}`"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
!root.join("spec/environment-v1.md").exists(),
|
||||
"the environment report must have one current specification"
|
||||
);
|
||||
let readme = read(&root.join("README.md"));
|
||||
assert!(
|
||||
readme.contains("spec/environment.md"),
|
||||
"README.md does not link the environment report spec"
|
||||
);
|
||||
let releasing = read(&root.join("docs/releasing.md"));
|
||||
assert!(
|
||||
releasing.contains("inspect --environment")
|
||||
&& releasing.contains("MARQDO_BUILD_SOURCE_SHA"),
|
||||
"docs/releasing.md does not document the identity binding"
|
||||
);
|
||||
let compatibility = read(&root.join("COMPATIBILITY.md"));
|
||||
assert!(
|
||||
compatibility.contains("Environment report"),
|
||||
"COMPATIBILITY.md does not list the environment report contract"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn document_structure_contract_has_one_overview_and_author_entry_points() {
|
||||
let root = repo_root();
|
||||
let spec = read(&root.join("spec/document-structure.md"));
|
||||
for needle in [
|
||||
"## 1. Document root and heading modes",
|
||||
"index.mq.md",
|
||||
"link, import, call",
|
||||
"Proposed",
|
||||
] {
|
||||
assert!(
|
||||
spec.contains(needle),
|
||||
"spec/document-structure.md is missing `{needle}`"
|
||||
);
|
||||
}
|
||||
for linked in [
|
||||
"mapping.md",
|
||||
"analysis.md",
|
||||
"references.md",
|
||||
"package-format.md",
|
||||
"heading-annotations-v1.md",
|
||||
] {
|
||||
assert!(
|
||||
spec.contains(linked),
|
||||
"spec/document-structure.md must link the single source {linked}"
|
||||
);
|
||||
}
|
||||
assert!(
|
||||
!root.join("spec/document-structure-v1.md").exists(),
|
||||
"the document structure must have one current overview"
|
||||
);
|
||||
let readme = read(&root.join("README.md"));
|
||||
assert!(
|
||||
readme.contains("spec/document-structure.md"),
|
||||
"README.md does not link the document structure contract"
|
||||
);
|
||||
let developers = read(&root.join("docs/developers/README.md"));
|
||||
assert!(
|
||||
developers.contains("document-structure.md"),
|
||||
"docs/developers/README.md does not point authors at the structure contract"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,376 @@
|
||||
//! Contract tests for `spec/document-structure.md` (marqdo-cli#25).
|
||||
//!
|
||||
//! These drive the real binary and assert only the current, implemented
|
||||
//! document-structure semantics: heading modes and inheritance, unit identity
|
||||
//! and scope rules, anchor collision numbering, byte-exact spans, `index.mq.md`
|
||||
//! entry/import meaning, and the link ≠ import ≠ call separation.
|
||||
|
||||
#[path = "support/stdlib.rs"]
|
||||
pub mod stdlib_support;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Output;
|
||||
|
||||
struct TempDir(PathBuf);
|
||||
|
||||
impl TempDir {
|
||||
fn new(tag: &str) -> Self {
|
||||
let nanos = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|duration| duration.as_nanos())
|
||||
.unwrap_or(0);
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"marqdo-document-structure-{tag}-{}-{nanos}",
|
||||
std::process::id()
|
||||
));
|
||||
std::fs::create_dir_all(&path).unwrap();
|
||||
Self(path)
|
||||
}
|
||||
|
||||
fn path(&self) -> &Path {
|
||||
&self.0
|
||||
}
|
||||
|
||||
fn write(&self, relative: &str, contents: &str) {
|
||||
let path = self.path().join(relative);
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent).unwrap();
|
||||
}
|
||||
std::fs::write(path, contents).unwrap();
|
||||
}
|
||||
|
||||
fn write_bytes(&self, relative: &str, contents: &[u8]) {
|
||||
let path = self.path().join(relative);
|
||||
if let Some(parent) = path.parent() {
|
||||
std::fs::create_dir_all(parent).unwrap();
|
||||
}
|
||||
std::fs::write(path, contents).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempDir {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn cli(args: &[&str], dir: &Path) -> Output {
|
||||
stdlib_support::cli_command()
|
||||
.args(args)
|
||||
.current_dir(dir)
|
||||
.output()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn stderr(output: &Output) -> String {
|
||||
String::from_utf8_lossy(&output.stderr).to_string()
|
||||
}
|
||||
|
||||
fn check_document(dir: &Path, document: &str, artifact: &Path) -> serde_json::Value {
|
||||
let output = cli(
|
||||
&["check", document, "--emit", artifact.to_str().unwrap()],
|
||||
dir,
|
||||
);
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"check {document} failed: {}",
|
||||
stderr(&output)
|
||||
);
|
||||
serde_json::from_slice(&std::fs::read(artifact).unwrap()).unwrap()
|
||||
}
|
||||
|
||||
fn units(analysis: &serde_json::Value) -> Vec<&serde_json::Value> {
|
||||
analysis["modules"][0]["units"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn unit<'a>(analysis: &'a serde_json::Value, path: &[&str]) -> &'a serde_json::Value {
|
||||
let path: Vec<String> = path.iter().map(|segment| segment.to_string()).collect();
|
||||
units(analysis)
|
||||
.into_iter()
|
||||
.find(|unit| {
|
||||
unit["path"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.map(|segment| segment.as_str().unwrap())
|
||||
.eq(path.iter().map(String::as_str))
|
||||
})
|
||||
.unwrap_or_else(|| panic!("missing unit {path:?}"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heading_modes_inherit_from_the_nearest_ancestor_not_a_sibling() {
|
||||
let dir = TempDir::new("modes");
|
||||
dir.write(
|
||||
"index.mq.md",
|
||||
"# @knowledge 数学\n\n\
|
||||
## @exec main\n\n`return 1`\n\n\
|
||||
## 普通说明\n\n这段是知识叙述。\n\n\
|
||||
### 子节\n\n更多知识。\n\n\
|
||||
## @exec 计算力\n\n`return 2`\n\n\
|
||||
### 细节\n\n`return 3`\n",
|
||||
);
|
||||
let artifact = dir.path().join("analysis.json");
|
||||
let analysis = check_document(dir.path(), "index.mq.md", &artifact);
|
||||
|
||||
let root = &units(&analysis)[0];
|
||||
assert_eq!(root["path"], serde_json::json!([]));
|
||||
assert_eq!(root["kind"], "root");
|
||||
assert_eq!(root["mode"], "knowledge");
|
||||
assert_eq!(root["mode_origin"], "default");
|
||||
|
||||
let namespace = unit(&analysis, &["数学"]);
|
||||
assert_eq!(namespace["kind"], "namespace");
|
||||
assert_eq!(namespace["parent_id"], root["id"]);
|
||||
|
||||
let main = unit(&analysis, &["数学", "main"]);
|
||||
assert_eq!(main["kind"], "function");
|
||||
assert_eq!(main["mode"], "exec");
|
||||
assert_eq!(main["mode_origin"], "explicit");
|
||||
assert!(main["function"].is_string());
|
||||
assert_eq!(main["parent_id"], namespace["id"]);
|
||||
|
||||
// A sibling heading without a marker inherits the Knowledge H1, never the
|
||||
// preceding Exec H2.
|
||||
let knowledge = unit(&analysis, &["数学", "普通说明"]);
|
||||
assert_eq!(knowledge["kind"], "knowledge");
|
||||
assert_eq!(knowledge["mode"], "knowledge");
|
||||
assert_eq!(knowledge["mode_origin"], "inherited");
|
||||
assert_eq!(knowledge["mode_source_unit_id"], namespace["id"]);
|
||||
assert!(knowledge["function"].is_null());
|
||||
|
||||
// An H3 under an Exec H2 is Exec and belongs to that function.
|
||||
let section = unit(&analysis, &["数学", "计算力", "细节"]);
|
||||
assert_eq!(section["kind"], "section");
|
||||
assert_eq!(section["mode"], "exec");
|
||||
assert_eq!(section["mode_origin"], "inherited");
|
||||
assert_eq!(
|
||||
section["parent_id"],
|
||||
unit(&analysis, &["数学", "计算力"])["id"]
|
||||
);
|
||||
assert_eq!(
|
||||
section["function"],
|
||||
unit(&analysis, &["数学", "计算力"])["function"]
|
||||
);
|
||||
|
||||
// A level-3 section under Knowledge never becomes callable.
|
||||
let knowledge_section = unit(&analysis, &["数学", "普通说明", "子节"]);
|
||||
assert_eq!(knowledge_section["kind"], "section");
|
||||
assert!(knowledge_section["function"].is_null());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn same_name_is_addressable_in_different_parents_but_rejected_in_one_scope() {
|
||||
let allowed = TempDir::new("same-name-allowed");
|
||||
allowed.write(
|
||||
"index.mq.md",
|
||||
"# @knowledge 甲\n\n## 说明\n\nA\n\n# @knowledge 乙\n\n## 说明\n\nB\n",
|
||||
);
|
||||
let analysis = check_document(
|
||||
allowed.path(),
|
||||
"index.mq.md",
|
||||
&allowed.path().join("analysis.json"),
|
||||
);
|
||||
let first = unit(&analysis, &["甲", "说明"]);
|
||||
let second = unit(&analysis, &["乙", "说明"]);
|
||||
assert_ne!(first["id"], second["id"]);
|
||||
let anchors = analysis["modules"][0]["anchors"].as_array().unwrap();
|
||||
assert_eq!(anchors.len(), 4);
|
||||
assert_eq!(
|
||||
anchors
|
||||
.iter()
|
||||
.find(|anchor| anchor["anchor"] == "说明")
|
||||
.unwrap()["unit_id"],
|
||||
first["id"]
|
||||
);
|
||||
assert_eq!(
|
||||
anchors
|
||||
.iter()
|
||||
.find(|anchor| anchor["anchor"] == "说明-2")
|
||||
.unwrap()["unit_id"],
|
||||
second["id"]
|
||||
);
|
||||
|
||||
let rejected = TempDir::new("same-name-rejected");
|
||||
rejected.write(
|
||||
"index.mq.md",
|
||||
"# @knowledge 数学\n\n## @exec 计算\n\n`return 1`\n\n## @exec 计算\n\n`return 2`\n",
|
||||
);
|
||||
let artifact = rejected.path().join("analysis.json");
|
||||
let output = cli(
|
||||
&["check", "index.mq.md", "--emit", artifact.to_str().unwrap()],
|
||||
rejected.path(),
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(
|
||||
stderr(&output).contains("sem.duplicate_unit_name"),
|
||||
"unexpected stderr: {}",
|
||||
stderr(&output)
|
||||
);
|
||||
assert!(
|
||||
!artifact.exists(),
|
||||
"a failed check must not leave an Analysis artifact"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spans_are_half_open_utf8_bytes_even_with_bom_crlf_and_no_final_newline() {
|
||||
let dir = TempDir::new("spans");
|
||||
let mut bytes = Vec::new();
|
||||
bytes.extend_from_slice(b"\xef\xbb\xbf"); // UTF-8 BOM
|
||||
bytes.extend_from_slice("# @knowledge 数学\r\n\r\n## @exec 计算\r\n\r\n`return 1`".as_bytes()); // CRLF line endings, no trailing newline
|
||||
dir.write_bytes("index.mq.md", &bytes);
|
||||
let analysis = check_document(dir.path(), "index.mq.md", &dir.path().join("analysis.json"));
|
||||
let module = &analysis["modules"][0];
|
||||
let source = module["source"].as_str().unwrap();
|
||||
assert_eq!(source.as_bytes(), bytes.as_slice());
|
||||
assert_eq!(module["document"]["span"]["start"], 0);
|
||||
assert_eq!(module["document"]["span"]["end"], bytes.len());
|
||||
|
||||
for unit in units(&analysis) {
|
||||
let start = unit["span"]["start"].as_u64().unwrap() as usize;
|
||||
let end = unit["span"]["end"].as_u64().unwrap() as usize;
|
||||
assert!(start <= end && end <= bytes.len(), "span out of range");
|
||||
assert!(
|
||||
std::str::from_utf8(&bytes[start..end]).is_ok(),
|
||||
"span is not on UTF-8 boundaries"
|
||||
);
|
||||
if let Some(heading) = unit["heading_span"].as_object() {
|
||||
let hs = heading["start"].as_u64().unwrap() as usize;
|
||||
let he = heading["end"].as_u64().unwrap() as usize;
|
||||
assert_eq!(bytes[hs], b'#', "heading_span must start at the heading");
|
||||
assert!(std::str::from_utf8(&bytes[hs..he]).is_ok());
|
||||
}
|
||||
}
|
||||
// The function section runs to EOF because it is the last heading.
|
||||
let function = unit(&analysis, &["数学", "计算"]);
|
||||
assert_eq!(
|
||||
function["span"]["end"].as_u64().unwrap() as usize,
|
||||
bytes.len()
|
||||
);
|
||||
let heading_start = function["heading_span"]["start"].as_u64().unwrap() as usize;
|
||||
assert_eq!(&bytes[heading_start..heading_start + 2], b"##");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn index_md_is_the_entry_and_a_directory_dependency_resolves_to_its_index() {
|
||||
let dir = TempDir::new("index-entry");
|
||||
dir.write(
|
||||
"marqdo.yaml",
|
||||
"project:\n name: demo\n version: 0.1.0\ndependencies:\n geo:\n path: ./geometry\n",
|
||||
);
|
||||
dir.write(
|
||||
"geometry/index.mq.md",
|
||||
"# @knowledge 几何\n\n## @exec 面积\n\n`return 6`\n",
|
||||
);
|
||||
dir.write(
|
||||
"index.mq.md",
|
||||
"---\nimport:\n geo: '@geo'\n---\n\n# @knowledge 主\n\n## @exec main\n\n`return 1`\n",
|
||||
);
|
||||
let lock = cli(&["lock"], dir.path());
|
||||
assert!(lock.status.success(), "lock failed: {}", stderr(&lock));
|
||||
let analysis = check_document(dir.path(), "index.mq.md", &dir.path().join("analysis.json"));
|
||||
assert_eq!(
|
||||
analysis["project"]["entry_module_id"],
|
||||
"root:demo@0.1.0::index.mq.md"
|
||||
);
|
||||
let modules = analysis["modules"].as_array().unwrap();
|
||||
assert_eq!(modules.len(), 2, "no implicit modules may be loaded");
|
||||
let dependency = modules
|
||||
.iter()
|
||||
.find(|module| module["id"].as_str().unwrap().starts_with("dep:geo@"))
|
||||
.expect("dependency module");
|
||||
assert!(
|
||||
dependency["id"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.ends_with("::index.mq.md"),
|
||||
"a directory dependency resolves to its index.mq.md"
|
||||
);
|
||||
let root = modules
|
||||
.iter()
|
||||
.find(|module| module["id"] == "root:demo@0.1.0::index.mq.md")
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
root["imports"][0]["resolved"], dependency["id"],
|
||||
"the explicit import names the dependency index module"
|
||||
);
|
||||
assert!(
|
||||
dependency["units"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.any(|unit| unit["path"] == serde_json::json!(["几何", "面积"])),
|
||||
"the dependency index is a normal document with normal units"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_markdown_link_is_neither_an_import_nor_a_call() {
|
||||
let dir = TempDir::new("link-only");
|
||||
dir.write(
|
||||
"index.mq.md",
|
||||
"# @knowledge 主\n\n[另一个文稿](other.mq.md)\n\n## @exec main\n\n`return 1`\n",
|
||||
);
|
||||
dir.write("other.mq.md", "# @knowledge 其他\n\n## 说明\n\n正文\n");
|
||||
|
||||
let plain = check_document(dir.path(), "index.mq.md", &dir.path().join("plain.json"));
|
||||
assert_eq!(plain["modules"].as_array().unwrap().len(), 1);
|
||||
let reference = &plain["modules"][0]["references"][0];
|
||||
assert_eq!(reference["state"], "not_loaded");
|
||||
assert!(plain["modules"][0]["imports"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.is_empty());
|
||||
assert!(plain["modules"][0]["calls"].as_array().unwrap().is_empty());
|
||||
|
||||
// `check --refs` verifies local link targets through the explicit
|
||||
// verification catalog; it still does not import the target or add it to
|
||||
// the program, and the emitted Analysis keeps the loaded-only reference
|
||||
// projection (`not_loaded` means "not part of this program", not "missing").
|
||||
let refs_artifact = dir.path().join("refs.json");
|
||||
let output = cli(
|
||||
&[
|
||||
"check",
|
||||
"index.mq.md",
|
||||
"--refs",
|
||||
"--emit",
|
||||
refs_artifact.to_str().unwrap(),
|
||||
],
|
||||
dir.path(),
|
||||
);
|
||||
assert!(output.status.success(), "{}", stderr(&output));
|
||||
assert!(
|
||||
!stderr(&output).contains("ref."),
|
||||
"an existing local link target must not produce a refs diagnostic: {}",
|
||||
stderr(&output)
|
||||
);
|
||||
let refs: serde_json::Value =
|
||||
serde_json::from_slice(&std::fs::read(&refs_artifact).unwrap()).unwrap();
|
||||
assert_eq!(refs["modules"].as_array().unwrap().len(), 1);
|
||||
assert_eq!(refs["modules"][0]["references"][0]["state"], "not_loaded");
|
||||
assert!(refs["modules"][0]["imports"].as_array().unwrap().is_empty());
|
||||
assert!(refs["modules"][0]["calls"].as_array().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_mode_markers_are_still_hard_errors() {
|
||||
let dir = TempDir::new("bad-marker");
|
||||
dir.write("index.mq.md", "# @knowledge 数学\n\n## @foo 标题\n\n正文\n");
|
||||
let artifact = dir.path().join("analysis.json");
|
||||
let output = cli(
|
||||
&["check", "index.mq.md", "--emit", artifact.to_str().unwrap()],
|
||||
dir.path(),
|
||||
);
|
||||
assert_eq!(output.status.code(), Some(1));
|
||||
assert!(
|
||||
stderr(&output).contains("sem.invalid_mode_marker"),
|
||||
"unexpected stderr: {}",
|
||||
stderr(&output)
|
||||
);
|
||||
assert!(!artifact.exists());
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
//! Black-box tests for `marqdo inspect --environment` (marqdo-cli#26 §9.2).
|
||||
//!
|
||||
//! The report is the offline diagnostic export used by feedback tooling. These
|
||||
//! tests drive the real binary and assert the stable schema, the honest
|
||||
//! degraded-installation representation, the argument boundary and the
|
||||
//! no-secret/no-absolute-path rule.
|
||||
|
||||
#[path = "support/stdlib.rs"]
|
||||
pub mod stdlib_support;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Output;
|
||||
|
||||
struct TempDir(PathBuf);
|
||||
|
||||
impl TempDir {
|
||||
fn new(tag: &str) -> Self {
|
||||
let nanos = std::time::SystemTime::now()
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.map(|duration| duration.as_nanos())
|
||||
.unwrap_or(0);
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"marqdo-environment-{tag}-{}-{nanos}",
|
||||
std::process::id()
|
||||
));
|
||||
std::fs::create_dir_all(&path).unwrap();
|
||||
Self(path)
|
||||
}
|
||||
|
||||
fn path(&self) -> &Path {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for TempDir {
|
||||
fn drop(&mut self) {
|
||||
let _ = std::fs::remove_dir_all(&self.0);
|
||||
}
|
||||
}
|
||||
|
||||
fn cli(args: &[&str], dir: &Path) -> Output {
|
||||
stdlib_support::cli_command()
|
||||
.args(args)
|
||||
.current_dir(dir)
|
||||
.output()
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn stdout(output: &Output) -> String {
|
||||
String::from_utf8_lossy(&output.stdout).to_string()
|
||||
}
|
||||
|
||||
fn json(output: &Output) -> serde_json::Value {
|
||||
serde_json::from_slice(&output.stdout).unwrap_or_else(|error| {
|
||||
panic!(
|
||||
"stdout is not JSON: {error}\n{}",
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn environment_report_is_stable_and_project_independent() {
|
||||
let dir = TempDir::new("no-project");
|
||||
let output = cli(&["inspect", "--environment", "--json"], dir.path());
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"inspect --environment failed: {}",
|
||||
String::from_utf8_lossy(&output.stderr)
|
||||
);
|
||||
let report = json(&output);
|
||||
assert_eq!(report["schema"], "marqdo.environment");
|
||||
assert_eq!(report["schema_version"], 1);
|
||||
assert_eq!(report["producer"]["name"], "marqdo");
|
||||
assert_eq!(report["producer"]["version"], env!("CARGO_PKG_VERSION"));
|
||||
let source_sha = &report["producer"]["source"]["sha"];
|
||||
if let Some(sha) = source_sha.as_str() {
|
||||
assert_eq!(sha.len(), 40, "embedded source SHA must be a full commit");
|
||||
assert!(sha
|
||||
.chars()
|
||||
.all(|ch| ch.is_ascii_hexdigit() && !ch.is_ascii_uppercase()));
|
||||
} else {
|
||||
assert_eq!(report["producer"]["source"]["origin"], "unavailable");
|
||||
}
|
||||
assert!(report["platform"]["os"].is_string());
|
||||
assert!(report["platform"]["arch"].is_string());
|
||||
assert!(report["platform"]["strict"].is_object());
|
||||
assert_eq!(report["protocols"]["analysis"], 3);
|
||||
assert_eq!(report["protocols"]["observation"], 1);
|
||||
assert_eq!(report["protocols"]["cli_tool"]["api_revision"], 1);
|
||||
assert_eq!(report["protocols"]["package_lock"], 4);
|
||||
assert_eq!(report["protocols"]["markdown_profile"], "marqdo.md.v1");
|
||||
assert!(report["worker"]["status"].is_string());
|
||||
assert!(report["bundle"]["status"].is_string());
|
||||
assert!(report["diagnostics"].is_array());
|
||||
// The report is deterministic: the same installation emits the same bytes.
|
||||
let again = cli(&["inspect", "--environment", "--json"], dir.path());
|
||||
assert_eq!(output.stdout, again.stdout);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn environment_report_never_leaks_paths_or_secrets() {
|
||||
let dir = TempDir::new("no-leak");
|
||||
let output = cli(&["inspect", "--environment", "--json"], dir.path());
|
||||
assert!(output.status.success());
|
||||
let text = stdout(&output);
|
||||
assert!(!text.contains(dir.path().to_str().unwrap()), "{text}");
|
||||
assert!(!text.contains("/root/"), "{text}");
|
||||
assert!(!text.contains("\\Users\\"), "{text}");
|
||||
for forbidden in [
|
||||
"token",
|
||||
"api_key",
|
||||
"secret",
|
||||
"password",
|
||||
"BEGIN PRIVATE KEY",
|
||||
] {
|
||||
assert!(
|
||||
!text.to_ascii_lowercase().contains(forbidden),
|
||||
"report contains forbidden field {forbidden}: {text}"
|
||||
);
|
||||
}
|
||||
// No project source is ever projected.
|
||||
assert!(!text.contains("@exec"), "{text}");
|
||||
assert!(!text.contains("source_bytes"), "{text}");
|
||||
}
|
||||
|
||||
/// Write a syntactically valid Bundle whose declared digest matches its tree.
|
||||
///
|
||||
/// This exercises the report's verified path without network access; the real
|
||||
/// product Bundle is verified by the stdlib/product tests.
|
||||
fn write_valid_bundle(root: &Path) -> serde_json::Value {
|
||||
std::fs::write(root.join("io.mq.md"), "# @knowledge io\n\n`print`\n").unwrap();
|
||||
let digest = stdlib_support::tree_digest(root).unwrap();
|
||||
let manifest = serde_json::json!({
|
||||
"name": "marqdo-stdlib",
|
||||
"version": "0.0.0-test",
|
||||
"digest": digest,
|
||||
});
|
||||
std::fs::write(
|
||||
root.join("stdlib.json"),
|
||||
serde_json::to_string_pretty(&manifest).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
manifest
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verified_bundle_is_reported_with_its_public_identity() {
|
||||
let bundle = TempDir::new("bundle");
|
||||
let manifest = write_valid_bundle(bundle.path());
|
||||
let dir = TempDir::new("bundle-project");
|
||||
let output = stdlib_support::cli_command()
|
||||
.args(["inspect", "--environment", "--json"])
|
||||
.env("MARQDO_STDLIB_DIR", bundle.path())
|
||||
.current_dir(dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(output.status.success());
|
||||
let report = json(&output);
|
||||
assert_eq!(report["bundle"]["status"], "verified");
|
||||
assert_eq!(report["bundle"]["origin"], "explicit-env");
|
||||
assert_eq!(report["bundle"]["name"], manifest["name"]);
|
||||
assert_eq!(report["bundle"]["version"], manifest["version"]);
|
||||
assert_eq!(report["bundle"]["tree_digest"], manifest["digest"]);
|
||||
assert_eq!(
|
||||
report["bundle"]["tree_digest"].as_str().unwrap(),
|
||||
stdlib_support::tree_digest(bundle.path()).unwrap()
|
||||
);
|
||||
assert!(report["diagnostics"].as_array().unwrap().is_empty());
|
||||
let text = stdout(&output);
|
||||
assert!(!text.contains(bundle.path().to_str().unwrap()), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_bundle_is_reported_as_data_with_a_stable_path_free_code() {
|
||||
let bundle = TempDir::new("bad-bundle");
|
||||
std::fs::write(
|
||||
bundle.path().join("stdlib.json"),
|
||||
"{\"name\":\"broken\",\"version\":\"0.0.0\",\"digest\":\"sha256:00\"}",
|
||||
)
|
||||
.unwrap();
|
||||
let dir = TempDir::new("bad-bundle-project");
|
||||
let output = stdlib_support::cli_command()
|
||||
.args(["inspect", "--environment", "--json"])
|
||||
.env("MARQDO_STDLIB_DIR", bundle.path())
|
||||
.current_dir(dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
// A degraded installation is reported, not turned into a command failure.
|
||||
assert!(output.status.success());
|
||||
let report = json(&output);
|
||||
assert_eq!(report["bundle"]["status"], "invalid");
|
||||
assert_eq!(report["bundle"]["origin"], "explicit-env");
|
||||
let diagnostics = report["diagnostics"].as_array().unwrap();
|
||||
assert_eq!(diagnostics.len(), 1);
|
||||
assert_eq!(diagnostics[0]["code"], "env.stdlib_digest_mismatch");
|
||||
let text = stdout(&output);
|
||||
assert!(!text.contains(bundle.path().to_str().unwrap()), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn environment_is_exclusive_with_document_inspection() {
|
||||
let dir = TempDir::new("exclusive");
|
||||
let output = cli(&["inspect", "--environment", "--platform"], dir.path());
|
||||
assert_eq!(output.status.code(), Some(2));
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
assert!(
|
||||
stderr.contains("cannot be used with"),
|
||||
"unexpected stderr: {stderr}"
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//! Embed the release source commit when the build supplies it.
|
||||
//!
|
||||
//! `marqdo inspect --environment --json` reports the adjacent worker build
|
||||
//! identity through the worker's offline `--build-info` command. The commit is
|
||||
//! optional: a development build reports `null` rather than a guessed SHA.
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-env-changed=MARQDO_BUILD_SOURCE_SHA");
|
||||
let Ok(sha) = std::env::var("MARQDO_BUILD_SOURCE_SHA") else {
|
||||
return;
|
||||
};
|
||||
let sha = sha.trim();
|
||||
let valid = sha.len() == 40
|
||||
&& sha
|
||||
.chars()
|
||||
.all(|ch| ch.is_ascii_hexdigit() && !ch.is_ascii_uppercase());
|
||||
if valid {
|
||||
println!("cargo:rustc-env=MARQDO_BUILD_SOURCE_SHA={sha}");
|
||||
} else {
|
||||
println!(
|
||||
"cargo:warning=MARQDO_BUILD_SOURCE_SHA is not a full lowercase 40-hex commit; \
|
||||
the worker build-info will not claim a source commit"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,15 @@ const ABI_VERSION: u32 = 1;
|
||||
const MAX_FRAME_BYTES: usize = 1024 * 1024;
|
||||
const ERROR_MAX: usize = 1024;
|
||||
|
||||
/// Offline build identity printed by `--build-info`.
|
||||
///
|
||||
/// `marqdo inspect --environment --json` runs this single-shot command to
|
||||
/// report the adjacent worker version/SHA without opening a provider session
|
||||
/// (marqdo-cli#26 §9.2).
|
||||
const BUILD_INFO_SCHEMA: &str = "marqdo.build-info";
|
||||
const BUILD_INFO_SCHEMA_VERSION: u32 = 1;
|
||||
const BUILD_SOURCE_SHA: Option<&str> = option_env!("MARQDO_BUILD_SOURCE_SHA");
|
||||
|
||||
type AbiVersionFn = unsafe extern "C" fn() -> u32;
|
||||
type OpenFn = unsafe extern "C" fn(*const c_char, *const c_char, *const c_char, *mut u64) -> i32;
|
||||
type ReadFn = unsafe extern "C" fn(u64, *mut u8, u32, *mut u32, *mut i32) -> i32;
|
||||
@@ -144,7 +153,25 @@ fn fail(message: &str) -> Json {
|
||||
json!({"ok": false, "code": "host.error", "message": message})
|
||||
}
|
||||
|
||||
/// Print one deterministic build-identity document and exit.
|
||||
fn print_build_info() {
|
||||
println!(
|
||||
"{}",
|
||||
json!({
|
||||
"schema": BUILD_INFO_SCHEMA,
|
||||
"schema_version": BUILD_INFO_SCHEMA_VERSION,
|
||||
"product": "marqdo-provider-worker",
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
"source_sha": BUILD_SOURCE_SHA,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
if std::env::args_os().nth(1).as_deref() == Some(std::ffi::OsStr::new("--build-info")) {
|
||||
print_build_info();
|
||||
return;
|
||||
}
|
||||
let Some(path) = std::env::args_os().nth(1) else {
|
||||
eprintln!("usage: marqdo-provider-worker <c-abi-library>");
|
||||
std::process::exit(2);
|
||||
|
||||
@@ -78,6 +78,14 @@ pub mod codes {
|
||||
pub const REF_INVALID: &str = "ref.invalid";
|
||||
/// A Markdown reference target was not verified by the current catalog.
|
||||
pub const REF_NOT_LOADED: &str = "ref.not_loaded";
|
||||
/// The installed stdlib Bundle cannot be read (`inspect --environment`).
|
||||
pub const ENV_STDLIB_UNREADABLE: &str = "env.stdlib_unreadable";
|
||||
/// The installed stdlib Bundle is not a current verified Bundle.
|
||||
pub const ENV_STDLIB_INVALID: &str = "env.stdlib_invalid";
|
||||
/// The installed stdlib Bundle does not match its declared digest.
|
||||
pub const ENV_STDLIB_DIGEST_MISMATCH: &str = "env.stdlib_digest_mismatch";
|
||||
/// The adjacent provider worker did not report its build identity.
|
||||
pub const ENV_WORKER_INFO_UNAVAILABLE: &str = "env.worker_info_unavailable";
|
||||
/// The requested math operation is outside the supported subset.
|
||||
pub const MATH_UNSUPPORTED: &str = "math.unsupported";
|
||||
/// A foreign language kernel is not available on this machine.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
| 公开版本 | `Cargo.toml` 仍为 `0.1.0`,若干工具兼容样例 `<1` | 3.0.0-beta 发布前必须迁移验证 |
|
||||
| 第三方入门 | README 有扩展示例、`spec/` 有协议;Tool v1 标头仍称 Proposed,plugin spec 某段称 Native only | 需要整合并去除失效状态文本 |
|
||||
|
||||
## 3. 两套必须明确分开的发布策略
|
||||
## 3. 各发行阶段的发布策略
|
||||
|
||||
### 3.1 Beta(允许明确声明的非安全性缺口)
|
||||
|
||||
@@ -45,11 +45,17 @@
|
||||
|
||||
**可延期至后续 Beta 或稳定版:** Windows Native/Worker ABI、macOS Provider Worker、strict L2、uv/npm 自动建环境、分布式 registry、JIT、内置 Knowledge/Proof/View、成熟异步/并发模型、未经承诺的平台安装包。明确注明项目默认 `project` 模式不是 OS 沙箱,Worker 也不是完整沙箱。
|
||||
|
||||
### 3.2 Stable / LTS(不可用 Beta 例外替代)
|
||||
### 3.2 RC
|
||||
|
||||
- 同 SHA 的归档烟测实际验证 strict 不可用时安全拒绝运行,经维护者批准后,RC 可按 `strict: unsupported` 发行。发布索引、支持范围及门禁记录仍绑定同一候选。通过标准与命令见 [发布手册](releasing.md#linux-rc-preconditions)。
|
||||
- 已观测的隔离缺陷、未运行的烟测、过期证据均阻塞 RC。具备合格一次性 VM 后按同 SHA 取得 strict PASS,可声明相应支持。
|
||||
|
||||
### 3.3 Stable / LTS
|
||||
|
||||
- Stable `3.0.0`:在公开支持的 Linux 平台上所有承诺功能有安全/兼容/性能证据;公开协议与变更策略清楚;有迁移说明和至少一次真实使用者反馈周期。平台可继续限定 Linux,不要求通过虚假的“全平台 LTS”门禁。
|
||||
- LTS(建议后续 `3.2.x`):冻结 `.mq.md` 语言语义、Analysis/Trace/Tool/Plugin/Provider 各自协议主版本和 lockfile 契约;提供安全修复流程、回归 CI、外部仓库兼容矩阵、从 3.0 及 2.9 迁移材料、发布渠道与公告模板。
|
||||
- LTS 应提前承诺支持窗口(建议至少 12 个月,实际长短由维护资源决定),定义安全补丁与非破坏性修复回移规则,明确 API/ABI 哪些会不兼容;不因开发完成某一里程碑自动称 LTS。
|
||||
- 一次性 VM 上的同 SHA strict G3 通过证据是 stable/LTS 的发布门禁。
|
||||
- 默认不为旧 `cflmy/marqdo` 的历史语法或旧插件 ABI 建隐性兼容层。需要迁移的由独立迁移工具、教程和示例承担。
|
||||
|
||||
## 4. 3.0.0-beta.1 之前建议拆分的 5 个短 PR
|
||||
|
||||
+64
-23
@@ -1,18 +1,16 @@
|
||||
# Marqdo Implementation Status
|
||||
|
||||
Snapshot: **2026-11-25**, product version **`3.0.0-rc.4`** (prerelease,
|
||||
released). Tag `v3.0.0-rc.4` at source SHA
|
||||
**`452e9a32bd9e40dba427d4180691c58bab74449e`**; release:
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4. The previous release is `3.0.0-rc.3` at source SHA
|
||||
**`1e2a045cc78bf40972181abb44e7117c56cf4401`**; release:
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.3. The supported
|
||||
platform is **Linux x86_64 (glibc 2.39)**. The rc.3 same-SHA gate aggregate is
|
||||
[`evidence/ci/1e2a045cc78bf40972181abb44e7117c56cf4401/manifest.json`](evidence/ci/1e2a045cc78bf40972181abb44e7117c56cf4401/manifest.json)
|
||||
(decision `RC_RELEASE_CANDIDATE`); its binary hashes are in that archive's
|
||||
`RELEASE_INFO.json`, not in the rc.4 candidate. Previous prereleases:
|
||||
`3.0.0-rc.2` at `9149ee40a48fcda692c5c112f66c465487d13dfb` and
|
||||
`3.0.0-beta.1` at `2c7c4f31e7a388d3fcfa717a77067e696ed13854`. Do not copy a
|
||||
SHA from a plan.
|
||||
Snapshot: **2026-11-28**, product version **`3.0.0-rc.6`** (prerelease,
|
||||
release candidate). Tag `v3.0.0-rc.6` on the tested release commit; release:
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.6. The previous
|
||||
release is `3.0.0-rc.5` at source SHA
|
||||
**`c44b0f943875d563bb7c170f8ccd3fd56a82360f`**; release:
|
||||
https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.5. The supported
|
||||
platform is **Linux x86_64 (glibc 2.39)**. The RC.6 gate aggregate
|
||||
(`RC_RELEASE_CANDIDATE`) is generated by `tools/ci/release_evidence.py`; the
|
||||
same-SHA CI and evidence references are recorded in CLI issue #22 and the
|
||||
release assets. Previous prereleases are recorded in their tagged release
|
||||
notes; do not copy a SHA from a plan.
|
||||
|
||||
Current architecture overview:
|
||||
[`architecture/CURRENT.md`](architecture/CURRENT.md).
|
||||
@@ -21,9 +19,10 @@ Authoritative release policy:
|
||||
evidence). Support matrix: [`../COMPATIBILITY.md`](../COMPATIBILITY.md).
|
||||
Developer entry point: [`developers/README.md`](developers/README.md).
|
||||
|
||||
The rc.4 same-SHA gate aggregate is
|
||||
The historical rc.4 same-SHA gate aggregate remains at
|
||||
[`evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`](evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json)
|
||||
(decision `RC_RELEASE_CANDIDATE`). This file records what was actually executed.
|
||||
(decision `RC_RELEASE_CANDIDATE`); it is not rc.6 evidence. This file records
|
||||
what was actually executed.
|
||||
"Implemented" does not mean "verified on every platform"; the evidence column
|
||||
says which commands were run and where. Status is generated from executed commands/logs; a gate row without a
|
||||
command, log or source path is a defect, not a state. Historical snapshots
|
||||
@@ -33,11 +32,16 @@ as current status.
|
||||
|
||||
## RC candidate
|
||||
|
||||
The workspace reports `3.0.0-rc.4` and declares Rust 1.89 as its locked
|
||||
minimum. Linux x86_64 on glibc 2.39 is the supported platform. The rc.4
|
||||
manifest is green on its SHA with the documented strict-VM PASS and a
|
||||
maintainer-approved shared-node performance `WARN`; stable/LTS still requires a
|
||||
dedicated fixed node. The release records below refer to their tagged binaries.
|
||||
The workspace reports `3.0.0-rc.6` and declares Rust 1.89 as its locked
|
||||
minimum. Linux x86_64 on glibc 2.39 is the supported platform. rc.6 binds the
|
||||
release archive, checksum, tested source SHA and actual external Bundle inputs
|
||||
in `release-evidence.json`; the same-SHA Woodpecker `main` gate, deterministic
|
||||
archive build, archive-only Ubuntu 24.04 cold install, migrated extensions,
|
||||
frozen external conformance and a shared-host performance `WARN` are recorded
|
||||
in CLI issue #22. The RC records `strict: unsupported` with same-SHA fail-closed
|
||||
smoke evidence; a disposable-VM strict L1 PASS remains a stable/LTS gate, and
|
||||
the shared-host performance exception does not carry over to stable/LTS. The
|
||||
release records below refer to their tagged binaries.
|
||||
|
||||
## Current protocol integration
|
||||
|
||||
@@ -75,6 +79,43 @@ The `spec/` tree contains only current contracts; retired specifications are in
|
||||
Git history and tagged archives. The earlier release records below describe
|
||||
their tagged binaries and are not current protocol claims.
|
||||
|
||||
## 0.13 Document structure contract — issue #25 (unreleased)
|
||||
|
||||
[`spec/document-structure.md`](../spec/document-structure.md) now states the
|
||||
current author/tool semantics in one place: heading mode inheritance (nearest
|
||||
ancestor, never a sibling; only Exec H2 callable), unit identity and
|
||||
`sem.duplicate_unit_name`, anchor slug collision numbering, byte-exact
|
||||
half-open spans (BOM/CRLF/missing final newline), `index.mq.md` entry vs
|
||||
directory-dependency import meaning, and the link ≠ import ≠ call separation.
|
||||
It links the authoritative `mapping.md`/`analysis.md`/`references.md`/
|
||||
`package-format.md` facts instead of duplicating them, marks heading annotations
|
||||
as Proposed (not implemented) and lists the Analysis fields consumers may rely
|
||||
on. Contract tests: `crates/cli/tests/document_structure.rs` (6 cases) plus
|
||||
`docs_consistency`. No document-language syntax was added; no runtime behavior
|
||||
changed.
|
||||
|
||||
## 0.12 Installed-environment diagnostic report — issue #26 §9.2 (unreleased)
|
||||
|
||||
`marqdo inspect --environment --json` emits the `marqdo.environment` v1 report:
|
||||
product version, build-embedded source commit, platform (including the real
|
||||
strict probe and glibc version), adjacent provider-worker build identity,
|
||||
verified Bundle name/version/tree digest, current protocol revisions and
|
||||
path-free diagnostics. It is offline and project-independent: it does not load
|
||||
a module, start a provider session, open a plugin or print a path/credential.
|
||||
|
||||
* Spec: [`spec/environment.md`](../spec/environment.md).
|
||||
* Tests: `crates/cli/tests/environment_report.rs` (schema, determinism,
|
||||
no-leak, verified/invalid Bundle, argument exclusivity) and unit tests in
|
||||
`crates/cli/src/environment.rs`.
|
||||
* Release binding: the release build embeds `MARQDO_BUILD_SOURCE_SHA`;
|
||||
`tools/release/package.py` refuses an archive whose binary reports another
|
||||
commit, and `tools/release/smoke.py` re-verifies the extracted archive. CI's
|
||||
`build` lane exports the variable before `cargo build --release`.
|
||||
* Window/macOS native lanes are **UNVERIFIED**; the report is Linux-verified
|
||||
only. This work is not part of the tagged rc.6 release record.
|
||||
* Evidence: [`evidence/2026-11-30-cli-environment-and-document-contract.md`](evidence/2026-11-30-cli-environment-and-document-contract.md)
|
||||
(source gates, workspace tests, archive identity binding and smoke PASS).
|
||||
|
||||
## 0.11 Explicit stdlib Bundle input — issue #11 Phase A (unreleased)
|
||||
|
||||
Phase A lands the build-input boundary only: the stdlib production sources and
|
||||
@@ -118,7 +159,7 @@ evidence named by issue #11.
|
||||
## 0.12 Engine / Host Contract boundary — issue #13 (unreleased candidate)
|
||||
|
||||
This is an **internal architecture candidate**, not a release. The product
|
||||
version stays `3.0.0-rc.4`; no new tag or release claim is made. Baseline is
|
||||
version stays `3.0.0-rc.5`; no new tag or release claim is made. Baseline is
|
||||
`master` at `4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`; the PR records the exact
|
||||
candidate SHA and evidence is
|
||||
[`evidence/2026-11-26-issue-13-engine-host-boundary.md`](evidence/2026-11-26-issue-13-engine-host-boundary.md).
|
||||
@@ -230,7 +271,7 @@ Local evidence and raw numbers:
|
||||
[`evidence/2026-11-25-rc.4-analysis-boundary.md`](evidence/2026-11-25-rc.4-analysis-boundary.md).
|
||||
|
||||
Executed 2026-11-25 in the local Linux x86_64 development container
|
||||
(workspace `3.0.0-rc.4`, Rust 1.100.0):
|
||||
(workspace `3.0.0-rc.5`, Rust 1.100.0):
|
||||
|
||||
```text
|
||||
cargo fmt --all -- --check PASS
|
||||
@@ -262,7 +303,7 @@ is a maintainer-approved shared-node `WARN` for this RC only; stable/LTS still
|
||||
requires a dedicated fixed node. The gate aggregate is
|
||||
[`evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`](evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json)
|
||||
(`RC_RELEASE_CANDIDATE`). Release
|
||||
[notes and assets](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.4).
|
||||
[notes and assets](https://git.cflmy.cn/cflmy/marqdo-cli/releases/tag/v3.0.0-rc.5).
|
||||
Downstream migration issues: `marqdo-view#6`, `marqdo-lint#4`.
|
||||
|
||||
## 0.9 Pre-stable protocol convergence — issue #8 (RC.3 candidate)
|
||||
|
||||
@@ -4,7 +4,7 @@ Status: **current architecture overview**. This file summarises the tree as it
|
||||
is today. It is not a release promise, does not reopen a frozen ADR, and does not
|
||||
replace `spec/` or a recorded test log.
|
||||
|
||||
- Baseline: `452e9a32bd9e40dba427d4180691c58bab74449e` (2026-11-25, tagged `v3.0.0-rc.4`; same-SHA evidence in `../STATUS.md` and `../evidence/ci/452e9a32bd9e40dba427d4180691c58bab74449e/manifest.json`).
|
||||
- Baseline: `c44b0f943875d563bb7c170f8ccd3fd56a82360f` (rc.5, last published); the rc.6 release-candidate changes and same-SHA evidence are recorded in `../STATUS.md` and CLI issue #22.
|
||||
- Normative behavior: `spec/`; frozen decisions: `docs/adr/`; executed evidence: `docs/STATUS.md` and `docs/evidence/`.
|
||||
- This is the **single current overview**. Do not add a second running "current state" file;
|
||||
update this file, `docs/STATUS.md` and an evidence file together.
|
||||
|
||||
@@ -209,7 +209,7 @@ counts, harness responsibilities and known observations.
|
||||
|
||||
## 5. Coding conventions
|
||||
|
||||
* Rust edition 2021, `rust-version = 1.89`, workspace version `3.0.0-rc.4`.
|
||||
* Rust edition 2021, `rust-version = 1.89`, workspace version `3.0.0-rc.6`.
|
||||
* `unsafe` is forbidden in pure crates (for example `marqdo-expression` uses
|
||||
`#![forbid(unsafe_code)]`); the ABI/loader crates contain the only
|
||||
`unsafe` code and every block has a SAFETY comment explaining the contract.
|
||||
|
||||
@@ -6,7 +6,7 @@ Rust structures, `marqdo-ir` internals, `inspect --ir`, relative paths into the
|
||||
core checkout, or host memory layout. Adding a new domain function must not
|
||||
require a core commit.
|
||||
|
||||
Product version for these docs: **`3.0.0-rc.4`** (Linux x86_64 candidate).
|
||||
Product version for these docs: **`3.0.0-rc.6`** (Linux x86_64 candidate).
|
||||
Current protocol contracts: Analysis, Observation, CLI Tool, Plugin ABI v1,
|
||||
Foreign wire v1, Provider manifest v2, lock v4 and markdown profile
|
||||
`marqdo.md.v1`. Product, protocol and package versions are independent; see
|
||||
@@ -40,9 +40,12 @@ Foreign wire v1, Provider manifest v2, lock v4 and markdown profile
|
||||
providers, extension selection and lock v4.
|
||||
5. [analysis-observation.md](analysis-observation.md) — the public static/dynamic data
|
||||
contracts and digest binding.
|
||||
6. [compatibility.md](compatibility.md) — version axes, platform matrix and the
|
||||
6. [document-structure.md](../../spec/document-structure.md) — heading modes,
|
||||
units/anchors/spans, `index.mq.md` entry meaning and the link≠import≠call
|
||||
separation (single author/tool overview).
|
||||
7. [compatibility.md](compatibility.md) — version axes, platform matrix and the
|
||||
prerelease policy.
|
||||
7. [release-limits.md](release-limits.md) — the honest beta limitations (this
|
||||
8. [release-limits.md](release-limits.md) — the honest beta limitations (this
|
||||
file ships in the archive as `KNOWN_LIMITATIONS.md`).
|
||||
|
||||
The full worked handbook is
|
||||
@@ -82,8 +85,13 @@ export MARQDO_BIN=/absolute/path/to/marqdo
|
||||
# Put marqdo-provider-worker next to it for provider tests, exactly as the
|
||||
# release archive does.
|
||||
$MARQDO_BIN --version
|
||||
$MARQDO_BIN inspect --environment --json # version, embedded source SHA, Bundle, protocols
|
||||
```
|
||||
|
||||
The environment report is the supported way to record which CLI/Bundle a
|
||||
consumer tested against; see [`../../spec/environment.md`](../../spec/environment.md).
|
||||
It reads only installed identity and prints no host paths or credentials.
|
||||
|
||||
Compute the binary SHA-256 before and after your suite; it must not move. The
|
||||
reference implementation of this gate is
|
||||
[`marqdo-extension-conformance`](https://git.cflmy.cn/cflmy/marqdo-extension-conformance)
|
||||
|
||||
@@ -6,9 +6,9 @@ This page summarizes the public support policy. The authoritative matrix is
|
||||
|
||||
## Version axes (do not conflate)
|
||||
|
||||
| Axis | `3.0.0-rc.4` value | Change rule |
|
||||
| Axis | `3.0.0-rc.6` value | Change rule |
|
||||
|---|---|---|
|
||||
| Product / CLI | `3.0.0-rc.4` (candidate) | SemVer prerelease. See `CHANGELOG.md` for changes from the beta. |
|
||||
| Product / CLI | `3.0.0-rc.6` (candidate) | SemVer prerelease. See `CHANGELOG.md` for changes from the beta. |
|
||||
| Analysis | v3 | One writer and one current major for every project. New major for incompatible changes; consumers reject unknown majors. |
|
||||
| Observation | v1 | One `run_id`/`seq` event sequence per execution; JSONL, JSON snapshot and file snapshot come from the same run. New major for incompatible required-field/ordering/redaction changes. |
|
||||
| CLI Tool | revision 1 | Exact `requires.api_revision` plus optional exact `analysis`/`observation` integers; no version arrays or negotiation. |
|
||||
@@ -41,7 +41,7 @@ values are off by default, and `--mode strict` refuses `--output jsonl` and
|
||||
|
||||
## Language compatibility
|
||||
|
||||
`3.0.0-rc.4` implements RFC-LANG-0002 only. Pre-RFC `.mq.md` source
|
||||
`3.0.0-rc.6` implements RFC-LANG-0002 only. Pre-RFC `.mq.md` source
|
||||
(Strong-execute / Emph-return / ordered-list branch / bullet-list loop /
|
||||
block-quote call / first code-span signature) is **not executable**; there is no
|
||||
`--legacy`, syntax switch or downgrade path. Migration is a rewrite task
|
||||
|
||||
@@ -113,7 +113,7 @@ keyword or built-in. The selected provider is verified (schema version, target,
|
||||
artifact SHA-256, duplicate kind, grant) before the sibling
|
||||
`marqdo-provider-worker` starts; a missing helper is
|
||||
`ext.worker_unavailable` and never falls back to `PATH` or in-process loading.
|
||||
Linux x86_64 only for this beta; not an OS sandbox. Runnable example:
|
||||
Linux x86_64 only for this prerelease line; not an OS sandbox. Runnable example:
|
||||
`examples/provider-demo/` (build with its `build.sh`; the tracked manifest has a
|
||||
zero digest template). Normative contract:
|
||||
[`../../spec/resource-provider-v2.md`](../../spec/resource-provider-v2.md).
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
# Quickstart: install and run
|
||||
|
||||
Product: `3.0.0-rc.4` (Linux x86_64 candidate). Install a **release archive**, not
|
||||
Product: `3.0.0-rc.6` (Linux x86_64 candidate). Install a **release archive**, not
|
||||
a source checkout, when you only consume Marqdo.
|
||||
|
||||
## 1. Install the archive
|
||||
|
||||
```bash
|
||||
sha256sum -c marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz.sha256
|
||||
tar -xzf marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz
|
||||
cd marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu
|
||||
./marqdo --version # marqdo 3.0.0-rc.4
|
||||
sha256sum -c marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu.tar.gz.sha256
|
||||
tar -xzf marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu.tar.gz
|
||||
cd marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu
|
||||
./marqdo --version # marqdo 3.0.0-rc.6
|
||||
./marqdo --help
|
||||
```
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Marqdo 3.0.0-rc.4 — known limitations
|
||||
# Marqdo 3.0.0-rc.6 — known limitations
|
||||
|
||||
This file ships in the release archive as `KNOWN_LIMITATIONS.md`. It is part of
|
||||
the release record: it defines the platform and feature scope for the release candidate.
|
||||
@@ -19,9 +19,12 @@ user and is not a security boundary against hostile code.
|
||||
|
||||
## `strict` isolation
|
||||
|
||||
`strict` is Linux-only and probe-gated. The RC release requires same-SHA
|
||||
G3 evidence from a non-root disposable VM. The CLI fails closed when the
|
||||
runtime probe is unavailable.
|
||||
`strict` is Linux-only and probe-gated. A stable/LTS release requires
|
||||
same-SHA G3 evidence from a non-root disposable VM. A release candidate may
|
||||
record `strict: unsupported` when the packaged archive proves that strict mode
|
||||
fails closed on the distribution test environment and the maintainer approves
|
||||
the RC exception; it must not claim an isolation PASS. The CLI fails closed
|
||||
whenever the runtime probe is unavailable.
|
||||
|
||||
Even when available:
|
||||
|
||||
@@ -57,11 +60,11 @@ Even when available:
|
||||
|
||||
## Compatibility and versioning
|
||||
|
||||
* `3.0.0-rc.4` is a **prerelease**. The changelog lists changes from the beta.
|
||||
* `3.0.0-rc.6` is a **prerelease**. The changelog lists changes from the beta.
|
||||
* The product version is independent of protocol versions: Analysis,
|
||||
Observation, CLI Tool, Plugin ABI v1, Foreign wire v1, Provider manifest v2
|
||||
and lock v4 keep their own identifiers.
|
||||
* The official bundled stdlib keeps its independent package version `0.1.0`.
|
||||
* The official bundled stdlib keeps its independent package version `0.3.0`.
|
||||
A plugin `.mq.md` package version such as `0.1.0` is also independent.
|
||||
* `project.marqdo` in `marqdo.yaml` is enforced in this release. SemVer
|
||||
prerelease rules apply: `>=3.0.0,<4.0.0` does **not** accept a prerelease core. Packages and Tools can use a prerelease range such as
|
||||
|
||||
@@ -20,7 +20,7 @@ marqdo-view/
|
||||
examples/
|
||||
```
|
||||
|
||||
`tool.json` for the `3.0.0-rc.4` candidate:
|
||||
`tool.json` for the `3.0.0-rc.6` candidate:
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
# 3.0.0-rc.5 候选准备(未发布)
|
||||
|
||||
日期:2026-11-27。分支:`release/3.0.0-rc.5-candidate`。本文件记录**候选准备**,不是发布记录:没有 tag、没有 Gitea Release、没有上传资产。
|
||||
|
||||
## 范围
|
||||
|
||||
- 工作区版本 `3.0.0-rc.4` → `3.0.0-rc.5`(Cargo.toml/Cargo.lock),CHANGELOG 增加“unreleased candidate”区段。
|
||||
- 内容基线:CLI `deadf6e`(外部 Bundle Phase B,无仓库内 `stdlib/` 树)+ 根外部 Bundle `marqdo-stdlib@0.2.0`(`digest sha256:db905508...`)。
|
||||
- 其余当前文档仍描述上一个已发布 rc.4;正式发布前必须在冻结 SHA 上统一 README/COMPATIBILITY/STATUS/开发者文档并重跑门禁。候选分支不合并即不改变产品发布声明。
|
||||
|
||||
## 候选验证(本机)
|
||||
|
||||
- 见父仓 #2 证据 `docs/evidence/2026-11-27-issue2-release-readiness.md`:确定性归档、smoke、离线冷安装、三个迁出扩展、外部 conformance、std surface、坏摘要 fail-closed。
|
||||
- 本分支版本化为 rc.5 后重新生成归档时,仅版本/元数据变化;发布前须在冻结 SHA 上重新执行全部命令并记录摘要。
|
||||
|
||||
## rc.5 候选归档(未发布)
|
||||
|
||||
- 候选提交 `9b21486`(版本/metadata + 性能 harness 修复),CLI `--release` 构建成功。
|
||||
- 同输入连续两次 `package.py`:`marqdo-3.0.0-rc.5-x86_64-unknown-linux-gnu.tar.gz` sha256 均为 `446197adb3c23dde87abc389490602e27856d6eb172667208080c8072a5ddece`(确定性 PASS)。
|
||||
- `smoke.py` PASS;Ubuntu 24.04/glibc 2.39、`--network none`、无 Cargo 冷安装 PASS(缺 Bundle fail-closed;语言-only 可运行)。
|
||||
- 未上传、无 tag、无 Release;`SOURCE_SHA` = 候选提交。
|
||||
|
||||
## 性能门禁(G4)候选结果
|
||||
|
||||
- 迁移后发现真实 harness 缺口:`stdlib-print-demo` 工作负载仍引用已删除的 CLI 内 `stdlib/demo.mq.md`,外部 Bundle 候选无法测量。
|
||||
- 修复(本候选分支):新增 `tools/perf/fixtures/print-demo.mq.md`,工作负载改名为 `print-demo` 并指向 fixture,重新记录 `tools/perf/expected/print-demo.json`;`performance.yml` 在 baseline worktree 中复制同一 `tools/perf`,保证两个二进制测同一工作负载。
|
||||
- 本机共享节点 paired run(Intel i7-8565U,8 CPU,taskset pin,5 warmups/20 samples):baseline 为**上一发布 rc.4**(`452e9a32...`,同一 harness/工作负载/fixture),candidate 为 rc.5 归档二进制 + 外部 Bundle。`correctness=VERIFIED`,9/9 工作负载 COMPARED,最大 p50 +5.15%、最大 RSS +4.87%,`investigate=false`(均低于 15%/20% 阈值)。
|
||||
- **仍不是 G4 PASS**:报告 `status=SMOKE`、`environment_approved=false`,本机节点未获维护者针对该 RC 的批准;按 RC 政策只能作为 shared-node WARN 候选,需维护者在获批节点/环境复跑并明确批准。
|
||||
|
||||
## Strict L1(BLOCKED,未运行)
|
||||
|
||||
- 本环境无 disposable VM;`bwrap` 无法创建命名空间(`bwrap: No permissions to create a new namespace`),`unshare -Ur` 被拒(`/proc/self/uid_map: Operation not permitted`),`runuser -u nobody` 被拒(`cannot set groups: Operation not permitted`)。
|
||||
- `tests/security/run-lane.sh` 明确要求普通用户在 disposable VM/可信 self-hosted runner 上运行并拒绝 root;本机无法产生 strict 证据,记录 BLOCKED 而非 PASS。
|
||||
|
||||
## 未完成(阻塞发布,不冒充 PASS)
|
||||
|
||||
- 冻结候选 SHA 与文档/版本一致性;
|
||||
- strict L1 独立 VM、非 root 同 SHA 证据;
|
||||
- G4 性能固定节点或维护者批准的 shared-node WARN;
|
||||
- 维护者显式 tag/Release 批准。
|
||||
|
||||
按 `docs/releasing.md`,自动化只可预备 RC 与证据,不得自行 tag/release。
|
||||
@@ -0,0 +1,141 @@
|
||||
# CLI 0f87f85 — offline environment report, release identity binding and document-structure contract
|
||||
|
||||
Date: 2026-11-30.
|
||||
Repository: `cflmy/marqdo-cli`.
|
||||
Candidate commit: `0f87f856dba28e34bbd2743d23b8f9b1fe96424a`
|
||||
(branch `codex/issue-25-26-environment-document-contract`, PR
|
||||
[#27](https://git.cflmy.cn/cflmy/marqdo-cli/pulls/27)).
|
||||
Issues: [marqdo-cli#26](https://git.cflmy.cn/cflmy/marqdo-cli/issues/26) §9.2
|
||||
(P1), [marqdo-cli#25](https://git.cflmy.cn/cflmy/marqdo-cli/issues/25),
|
||||
[marqdo-cli#20](https://git.cflmy.cn/cflmy/marqdo-cli/issues/20) binding.
|
||||
Parent tickets: `marqdo#55`, `marqdo#56`.
|
||||
|
||||
Executed host: Linux x86_64, glibc 2.43
|
||||
(`rustc 1.100.0 (0ef1bc386 2026-11-09)`, `cargo 1.100.0 (3acc79c0c 2026-11-05)`,
|
||||
Python 3.14.4). Windows/macOS native lanes were **not** run (no runner in this
|
||||
environment) and remain `UNVERIFIED`.
|
||||
|
||||
## 1. Bundle input
|
||||
|
||||
`python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib`
|
||||
materialized the pinned ecosystem Bundle (pin commit
|
||||
`48189243f747d5f73d5a38a565010e64e2db74e7`, components
|
||||
`stdlib/{collections,data,fs,io,system,text}` at their pinned gitlinks):
|
||||
|
||||
```text
|
||||
name: marqdo-stdlib
|
||||
version: 0.2.0
|
||||
tree_digest: sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7
|
||||
aliases_digest: sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb
|
||||
files: 18
|
||||
```
|
||||
|
||||
All workspace tests below ran with
|
||||
`MARQDO_TEST_STDLIB_BUNDLE="$PWD/target/ecosystem-stdlib"`.
|
||||
|
||||
## 2. Source-level gates
|
||||
|
||||
| Command | Result |
|
||||
|---|---|
|
||||
| `cargo fmt --all -- --check` | PASS |
|
||||
| `cargo clippy --workspace --all-targets -- -D warnings` | PASS |
|
||||
| `cargo test --workspace --locked` | PASS: 638 passed, 0 failed, 2 ignored (74 suites) |
|
||||
| `cargo test -p marqdo-cli --test docs_consistency` | PASS: 9 passed |
|
||||
| `cargo test -p marqdo-cli --test environment_report` | PASS: 5 passed |
|
||||
| `cargo test -p marqdo-cli --test document_structure` | PASS: 6 passed |
|
||||
| `python3 tools/ci/check_dependency_boundaries.py` | PASS |
|
||||
| `python3 tools/ci/check_engine_boundary.py` | PASS |
|
||||
| `python3 tools/ci/check_plugin_sdk.py` | PASS |
|
||||
| `python3 tools/ci/independent_build.py` | PASS (PASS payload, clean target dir) |
|
||||
| `python3 -m unittest discover -s tools/ci -p 'test_*.py'` | PASS: 80 tests |
|
||||
| `python3 -m unittest discover -s tools/ci -p 'test_release*.py'` | PASS: 29 tests (10 skipped by platform guards) |
|
||||
|
||||
Note: `cargo clippy` must be invoked as
|
||||
`cargo clippy --workspace --all-targets -- -D warnings` (one `--`). A doubled
|
||||
separator makes clippy-driver treat `-D` as a second input file; that failure
|
||||
was a local invocation error, not a code failure.
|
||||
|
||||
## 3. `inspect --environment` probes
|
||||
|
||||
```console
|
||||
$ marqdo inspect --environment --json
|
||||
{"schema":"marqdo.environment","schema_version":1,
|
||||
"producer":{"name":"marqdo","version":"3.0.0-rc.6",
|
||||
"source":{"sha":null,"origin":"unavailable"}}, # dev binary
|
||||
"platform":{"os":"linux","arch":"x86_64","family":"unix",
|
||||
"libc":{"family":"glibc","version":"2.43"},
|
||||
"strict":{"state":"unavailable","reason":"..."},"worker_processes":true},
|
||||
"worker":{"name":"marqdo-provider-worker","status":"present",
|
||||
"version":"3.0.0-rc.6","source_sha":null},
|
||||
"bundle":{"status":"absent", ...},
|
||||
"protocols":{"analysis":3,"observation":1,"cli_tool":{"version":1,"api_revision":1},
|
||||
"plugin_abi":{"version":"1.0","major":1,"minor":0},
|
||||
"provider_manifest":2,"package_lock":4,"markdown_profile":"marqdo.md.v1"},
|
||||
"diagnostics":[]}
|
||||
|
||||
$ marqdo inspect --environment --platform # argument boundary
|
||||
error: the argument '--environment' cannot be used with '--platform' # exit 2
|
||||
```
|
||||
|
||||
The integration test also builds a valid synthetic Bundle and an invalid one:
|
||||
`verified` identity is reported for the valid tree, and a digest mismatch is
|
||||
reported as `status: invalid` + `env.stdlib_digest_mismatch` without printing
|
||||
the Bundle path. Two consecutive invocations are byte-identical.
|
||||
|
||||
## 4. Release archive (identity binding, #20/#26)
|
||||
|
||||
Release build and archive were produced from the candidate commit with
|
||||
`MARQDO_BUILD_SOURCE_SHA=0f87f856dba28e34bbd2743d23b8f9b1fe96424a`:
|
||||
|
||||
```console
|
||||
$ cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
Finished `release` profile in 51.40s
|
||||
|
||||
$ python3 tools/release/package.py --source-sha 0f87f856... --version 3.0.0-rc.6 \
|
||||
--stdlib-dir target/ecosystem-stdlib --bundle-pin tools/stdlib/bundle-pin.json
|
||||
{"archive":"dist/marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu.tar.gz",
|
||||
"sha256":"58f4ea3a317ac2cf311804f94462d49699b7f159d6ef308a60f2728dad707a9a",
|
||||
"size":4928069,"source_sha":"0f87f856...","version":"3.0.0-rc.6",
|
||||
"target":"x86_64-unknown-linux-gnu"}
|
||||
|
||||
$ python3 tools/release/smoke.py --archive dist/marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu.tar.gz --skip-strict
|
||||
smoke: verified stdlib 0.2.0 tree=sha256:db905508... files=18
|
||||
smoke: archive version 3.0.0-rc.6, source 0f87f856dba28e34bbd2743d23b8f9b1fe96424a
|
||||
smoke: bundled stdlib missing -> fail-closed OK
|
||||
smoke: language-only program runs without the bundled stdlib
|
||||
smoke: PASS
|
||||
```
|
||||
|
||||
`package.py` now runs the staged binary's `inspect --environment --json` and
|
||||
refuses to stage when `producer.source.sha`/`worker.source_sha` differ from
|
||||
`--source-sha`, when the Bundle is not `verified`, or when its tree digest
|
||||
differs from the archived Bundle. `smoke.py` repeats the check from the
|
||||
extracted archive. The PASS above therefore proves the archive carries the
|
||||
exact release commit in both binaries and the exact shipped Bundle.
|
||||
|
||||
Strict mode is `UNVERIFIED` on this shared host (`bwrap` cannot create the
|
||||
required namespaces); `smoke.py --skip-strict` records that honestly rather
|
||||
than turning a refusal into a PASS.
|
||||
|
||||
## 5. CI
|
||||
|
||||
| Pipeline | Result |
|
||||
|---|---|
|
||||
| Woodpecker push [#155](https://ci.cflmy.cn/repos/1/pipeline/155) (candidate `0f87f856`) | PASS: clone, contract, test, independent-build, minimum-rust, build all success |
|
||||
| Woodpecker pull_request [#156](https://ci.cflmy.cn/repos/1/pipeline/156) (PR #27) | PASS: same six steps success on the candidate tree |
|
||||
| Woodpecker push (docs evidence commit, branch head) | re-runs the same six steps; result recorded in the PR once complete |
|
||||
|
||||
Steps `contract`/`test`/`independent-build`/`minimum-rust`/`build` are the
|
||||
release-relevant lanes; the Windows `cargo check` cross gate runs inside
|
||||
`test`, but native Windows/macOS runs remain out of scope here.
|
||||
|
||||
## 6. Not verified / limits
|
||||
|
||||
- Native macOS and Windows build/run lanes (§3 target matrix): no runner in
|
||||
this environment; `UNVERIFIED`. Only the Linux cross-compile check runs.
|
||||
- Strict VM lane (`bwrap` namespaces): `UNVERIFIED`; strict stays fail-closed.
|
||||
- MQDH/consumer acceptance of the release archive: consumer repositories own
|
||||
their own acceptance; this record proves the CLI-side archive identity only.
|
||||
- A formal tagged Release is not created by this change: publication remains a
|
||||
reviewed owner step (`docs/releasing.md` §6). The archive above is a local
|
||||
candidate, not a published asset.
|
||||
@@ -0,0 +1,43 @@
|
||||
# Marqdo CLI 3.0.0-rc.5 release notes
|
||||
|
||||
Released as a Linux x86_64 (glibc 2.39) prerelease. Tag `v3.0.0-rc.5` on the
|
||||
tagged release commit; the Gitea release carries the archive, its `.sha256` and
|
||||
`RELEASE_INFO.json` inside the archive.
|
||||
|
||||
## What changed
|
||||
|
||||
- The standard library is one explicit external Bundle (`--stdlib-dir`, Bundle
|
||||
pin) and the CLI repository no longer contains a `stdlib/` source tree
|
||||
(marqdo-cli#11 Phase B). Contract lanes, product tests and the perf harness
|
||||
materialize the ecosystem Bundle instead of an in-repo copy.
|
||||
- The release archive still ships exactly one verified stdlib Bundle
|
||||
(`marqdo-stdlib@0.2.0`).
|
||||
- The migrated performance `print-demo` workload now uses a self-contained
|
||||
fixture so the G4 comparison no longer depends on the removed in-repo stdlib
|
||||
tree; the paired baseline is the previous release rc.4.
|
||||
|
||||
## Verification on this release cycle
|
||||
|
||||
| Gate | Result |
|
||||
| --- | --- |
|
||||
| Deterministic archive (same inputs built twice) | PASS |
|
||||
| `smoke.py` | PASS |
|
||||
| Archive-only Ubuntu 24.04/glibc 2.39, `--network none`, non-root, no Cargo | PASS |
|
||||
| Migrated extensions http/regex/archive with the archive CLI + Bundle | PASS |
|
||||
| Frozen external conformance with the archive CLI/RELEASE_INFO | PASS |
|
||||
| std: surface (text/JSON/FS/path/datetime/table/Console) | PASS |
|
||||
| Missing/tampered Bundle fail-closed | PASS |
|
||||
| Disposable-VM strict L1, non-root, same SHA | **UNVERIFIED** (no VM/namespaces in the release environment; no PASS claimed) |
|
||||
| G4 paired shared-node comparison | Shared-node only: 9/9 workloads compared, max p50 +5.15%, max RSS +4.87%, below thresholds; **not an approved-node G4 PASS** |
|
||||
|
||||
This release was explicitly approved by the maintainer with the two limitations
|
||||
above recorded; stable/LTS still requires the disposable-VM strict lane and a
|
||||
maintainer-approved fixed performance node.
|
||||
|
||||
## Known limitations
|
||||
|
||||
- Linux x86_64 is the only supported platform; macOS/Windows remain UNSUPPORTED
|
||||
for this prerelease line.
|
||||
- `strict` availability depends on host namespaces; unsupported hosts fail
|
||||
closed and do not downgrade.
|
||||
- See `docs/developers/release-limits.md` for the full list.
|
||||
+59
-23
@@ -73,8 +73,12 @@ unsupported/experimental in
|
||||
|
||||
Use the frozen-SHA build and archive checks above. Additionally:
|
||||
|
||||
- Strict L1 requires a same-SHA PASS on a disposable VM as a non-root user.
|
||||
Record the strict evidence and verify the archived binary on that guest.
|
||||
- Report strict L1 as `PASS` only with same-SHA evidence from a disposable VM
|
||||
running as a non-root user. An RC may report `strict: unsupported` with
|
||||
maintainer approval and a same-SHA archive smoke log which confirms strict
|
||||
execution fails closed on the distribution test environment. A skipped
|
||||
test or an observed isolation defect blocks publication. Stable and LTS
|
||||
require the disposable-VM PASS.
|
||||
- Measure the packaged CLI with 5 warmups and 20 samples or more for each of
|
||||
the nine workloads, or for the changed boundary's representative fixture when
|
||||
the gate is scoped by an accepted ADR. Compare against a correctness-verified
|
||||
@@ -203,13 +207,34 @@ python3 tools/ci/release_evidence.py --profile beta --target-sha "$sha" \
|
||||
missing, skipped, failed or SHA-mismatched gate is `DO_NOT_RELEASE`; never
|
||||
hand-edit a manifest to PASS. For a Linux RC, use
|
||||
`--profile rc --require-release` and declare both excluded platforms. If
|
||||
the shared-node exception applies, pass
|
||||
strict is unavailable, supply `strict_vm=UNSUPPORTED:<candidate-sha>:<smoke-log>`
|
||||
and `--rc-strict-unsupported-approval <release-notes-reference>`. The smoke
|
||||
log must show strict mode's explicit refusal from the packaged binary. If the
|
||||
shared-node exception applies, pass
|
||||
`--rc-shared-performance-approval <release-notes-reference>` and supply
|
||||
`performance=WARN:<candidate-sha>:<comparison-evidence>`. Use the generated
|
||||
`RC_RELEASE_CANDIDATE` decision before running the tagging commands.
|
||||
Stable releases use `--profile stable --require-release` and require native
|
||||
Windows and macOS PASS in addition to the Linux and contract gates.
|
||||
|
||||
### 5.1 Environment identity binding
|
||||
|
||||
Release builds must embed the release commit in both binaries:
|
||||
|
||||
```bash
|
||||
export MARQDO_BUILD_SOURCE_SHA="$(git rev-parse HEAD)"
|
||||
cargo build --release --locked -p marqdo-cli -p marqdo-provider-worker
|
||||
```
|
||||
|
||||
`tools/release/package.py` runs the staged `marqdo inspect --environment --json`
|
||||
and refuses to stage an archive unless `producer.source.sha` and
|
||||
`worker.source_sha` equal `--source-sha` and the adjacent Bundle reports
|
||||
`status: verified` with the archived `tree_digest`.
|
||||
`tools/release/smoke.py` re-runs the same check from the extracted archive, so
|
||||
a release asset cannot claim a source commit it was not built from. The report
|
||||
is specified by [`../spec/environment.md`](../spec/environment.md); it never
|
||||
prints credentials, Analysis content or absolute host paths.
|
||||
|
||||
## 6. Tagging and publication (owner approval required)
|
||||
|
||||
Only after all gates above are green on the frozen SHA:
|
||||
@@ -221,8 +246,25 @@ git tag -a "v${version}" -m "Marqdo CLI v${version}" "$sha"
|
||||
git push origin "v${version}"
|
||||
```
|
||||
|
||||
Then create the Gitea release for the tag with `prerelease: true`, attach the
|
||||
tarball and its `.sha256`, and include the release notes. The notes must state:
|
||||
Before publication, use the existing Bundle producer and the exact Woodpecker
|
||||
pipeline number to create the ecosystem release index. Build and cold-test the
|
||||
archive with the `--bundle-pin` and Bundle directory below, as in sections 3–4.
|
||||
The receipt is the root producer's build summary and stays with the release
|
||||
evidence.
|
||||
|
||||
```bash
|
||||
python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib \
|
||||
--receipt target/ecosystem-stdlib.receipt.json
|
||||
# Run the existing package and smoke commands with that Bundle.
|
||||
archive="dist/marqdo-${version}-x86_64-unknown-linux-gnu.tar.gz"
|
||||
python3 tools/release/release_index.py --archive "$archive" \
|
||||
--bundle-receipt target/ecosystem-stdlib.receipt.json \
|
||||
--pipeline "$pipeline_number" > dist/release-evidence.json.tmp
|
||||
mv dist/release-evidence.json.tmp dist/release-evidence.json
|
||||
```
|
||||
|
||||
Create a Gitea draft for the tag with `prerelease: true` and attach the tarball,
|
||||
its `.sha256`, and `release-evidence.json`. The notes must state:
|
||||
|
||||
* prerelease status, support lifetime and the Linux x86_64 platform scope;
|
||||
* the breaking RFC-LANG-0002 language change and no legacy path;
|
||||
@@ -232,21 +274,16 @@ tarball and its `.sha256`, and include the release notes. The notes must state:
|
||||
* the checksum-integrity-not-signature caveat and the known-limitations file;
|
||||
* the exact source SHA and links to the evidence manifest.
|
||||
|
||||
Example Gitea API shape (token with repository release permission; never commit
|
||||
the token):
|
||||
Download the draft's assets from Gitea and verify their sizes and digests against
|
||||
the index. Compare the downloaded index to the local copy and verify the remote
|
||||
tag points at the tested SHA. Publish the complete draft, then confirm the
|
||||
public tag and asset set again. Resume an interrupted draft only for the same
|
||||
tag, commit and matching assets. For an already published release, verify the
|
||||
existing bytes and send any outstanding notification. Report a mismatch to the
|
||||
release owner and stop. A failed notification is retried independently through
|
||||
the root reconcile workflow, with its cron as the recovery path.
|
||||
|
||||
```bash
|
||||
curl -X POST -H "Authorization: token $MARQDO_GIT_TOKEN" \
|
||||
-H 'Content-Type: application/json' \
|
||||
https://git.cflmy.cn/api/v1/repos/cflmy/marqdo-cli/releases \
|
||||
-d '{"tag_name":"v3.0.0-beta.1","name":"Marqdo CLI 3.0.0-beta.1",
|
||||
"prerelease":true,"draft":false,"body":"..."}'
|
||||
curl -X POST -H "Authorization: token $MARQDO_GIT_TOKEN" \
|
||||
-F "attachment=@dist/marqdo-3.0.0-beta.1-x86_64-unknown-linux-gnu.tar.gz" \
|
||||
https://git.cflmy.cn/api/v1/repos/cflmy/marqdo-cli/releases/<id>/assets
|
||||
```
|
||||
|
||||
The tag points at the tested SHA. Evidence files and the final STATUS update
|
||||
Evidence files and the final STATUS update
|
||||
may land in a **post-release docs commit** that references the tagged SHA, so
|
||||
that the evidence never has to claim a SHA it cannot contain. Do not force-push,
|
||||
do not tag a red commit, and do not upload macOS/Windows binaries unless those
|
||||
@@ -254,10 +291,9 @@ platform lanes actually passed.
|
||||
|
||||
## 7. Rollback
|
||||
|
||||
- Missing/mismatched gate discovered after tagging: mark the release withdrawn,
|
||||
delete the assets, keep the tag only if source/tag integrity is unaffected,
|
||||
and ship a corrected prerelease (for example `3.0.0-beta.2`). Never delete a
|
||||
failing test.
|
||||
- Missing or mismatched gate discovered after tagging: record the withdrawal
|
||||
in an issue, retain the published tag and assets for traceability, and ship
|
||||
a corrected prerelease with a new tag (for example `3.0.0-beta.2`).
|
||||
- Platform regression: remove that platform from `COMPATIBILITY.md`, the
|
||||
release notes and the archive, then fix and re-run the gate.
|
||||
- Security regression: set strict back to fail-closed/unsupported, publish a
|
||||
|
||||
+8
-4
@@ -10,8 +10,9 @@ be registered as a dedicated self-hosted security runner.
|
||||
> ([`architecture/RFC-LANG-0002-unified-semantics.md`](architecture/RFC-LANG-0002-unified-semantics.md)).
|
||||
> The lane is only evidence for the **exact SHA in its
|
||||
> `strict-evidence.json`**; a PASS at an older SHA or on another host is
|
||||
> historical. Every candidate release must rerun `tests/security/run-lane.sh`
|
||||
> and archive the evidence document. See [`STATUS.md`](STATUS.md).
|
||||
> historical. A stable or LTS release must rerun `tests/security/run-lane.sh`
|
||||
> and archive the evidence document. Linux RCs can use the approved
|
||||
> fail-closed path in [the release procedure](releasing.md#linux-rc-preconditions).
|
||||
|
||||
**Do not run this on a daily host with valuable data.** The VM is disposable;
|
||||
the commands below do not disable AppArmor or any global host protection.
|
||||
@@ -38,9 +39,9 @@ export SOURCE_SHA="$(git rev-parse HEAD)" # reviewed commit, clean tree
|
||||
mkdir -p .tools/vm && cd .tools/vm
|
||||
# Replace with the reviewed dated release URL, never .../current/...
|
||||
curl -L -o ubuntu-base.img \
|
||||
https://cloud-images.ubuntu.com/releases/26.04/release-20261120/ubuntu-26.04-server-cloudimg-amd64.img
|
||||
https://cloud-images.ubuntu.com/releases/resolute/release-20261108/ubuntu-26.04-server-cloudimg-amd64.img
|
||||
curl -L -o SHA256SUMS \
|
||||
https://cloud-images.ubuntu.com/releases/26.04/release-20261120/SHA256SUMS
|
||||
https://cloud-images.ubuntu.com/releases/resolute/release-20261108/SHA256SUMS
|
||||
grep 'ubuntu-26.04-server-cloudimg-amd64.img' SHA256SUMS | sha256sum -c -
|
||||
sha256sum ubuntu-base.img | tee ubuntu-base.img.sha256
|
||||
qemu-img create -f qcow2 -b ubuntu-base.img -F qcow2 \
|
||||
@@ -159,6 +160,9 @@ mkdir -p ~/marqdo-${SOURCE_SHA}
|
||||
tar -C ~/marqdo-${SOURCE_SHA} -xf ~/marqdo-${SOURCE_SHA}.tar
|
||||
cd ~/marqdo-${SOURCE_SHA}
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
python3 tools/ci/fetch_ecosystem_bundle.py --out target/ecosystem-stdlib
|
||||
export MARQDO_STDLIB_DIR="$PWD/target/ecosystem-stdlib"
|
||||
export MARQDO_TEST_STDLIB_BUNDLE="$MARQDO_STDLIB_DIR"
|
||||
export MARQDO_TESTED_SHA="$SOURCE_SHA"
|
||||
export MARQDO_SOURCE_ARCHIVE="$HOME/marqdo-${SOURCE_SHA}.tar"
|
||||
export MARQDO_SOURCE_ARCHIVE_SHA256="sha256:<digest from the host>"
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
# Marqdo Document Structure and Entry Semantics
|
||||
|
||||
This is the author/tool-facing overview of **what a `.mq.md` document is** and
|
||||
**how a document becomes a program**: heading modes, unit identity, anchors,
|
||||
spans, `index.mq.md` entry meaning, and the three document relations (link,
|
||||
import, call). It states only semantics that are implemented today.
|
||||
|
||||
Normative detail lives in one place per fact: syntax and the Markdown→program
|
||||
mapping are
|
||||
[`mapping.md`](mapping.md) / [`../docs/architecture/RFC-LANG-0002-unified-semantics.md`](../docs/architecture/RFC-LANG-0002-unified-semantics.md);
|
||||
the public static projection is [`analysis.md`](analysis.md); link/reference
|
||||
resolution is [`references.md`](references.md); package and entry resolution is
|
||||
[`package-format.md`](package-format.md) plus [`references.md`](references.md)
|
||||
§3.1. This document links those facts for readers and states the consumer
|
||||
stability contract; it does not create a second specification.
|
||||
|
||||
## 1. Document root and heading modes
|
||||
|
||||
A document is one CommonMark/GFM AST. Headings are sibling blocks, so scopes
|
||||
are derived from heading levels, never from container nesting.
|
||||
|
||||
| Heading | `kind` | Callable? | Notes |
|
||||
|---|---|---|---|
|
||||
| (document root) | `root` | no | Mode `knowledge`, level `0`, path `[]`. |
|
||||
| H1 | `namespace` | no | Namespace for nested functions. |
|
||||
| H2 with `@exec` | `function` | **yes** | The only callable document unit. |
|
||||
| H2 with `@knowledge` | `knowledge` | no | Inert knowledge section. |
|
||||
| H3–H6 | `section` | no | Section of the enclosing unit; never callable. |
|
||||
|
||||
Rules (implemented by `marqdo-frontend`):
|
||||
|
||||
* The **document root is Knowledge**. A document with no mode marker still has
|
||||
a knowledge root and cannot be called.
|
||||
* Only ATX headings may declare `@exec`/`@knowledge`; Setext headings never
|
||||
declare. The marker must be the heading's first `Text` child; any other
|
||||
`@word` marker is the hard error `sem.invalid_mode_marker` (there is no
|
||||
per-file mode or second selector).
|
||||
* A heading without a marker **inherits the nearest ancestor's effective
|
||||
mode**, never a sibling's. Inheritance pops same-or-higher-level ancestors
|
||||
first, which is why a `###` section under an Exec H2 is Exec while the next
|
||||
`##` sibling under a Knowledge H1 is Knowledge.
|
||||
* Only a level-2 Exec heading creates a `FunctionId`. A section inside it
|
||||
reports the owning function; a section outside one has no function.
|
||||
* Executable payloads outside an owning Exec H2 are
|
||||
`sem.exec_without_function`. Prose is inert everywhere.
|
||||
* Headings inside lists, block quotes or fenced code do not create units.
|
||||
* Mode declarations are not a navigation feature: adding `@knowledge`/`@exec`
|
||||
declares meaning, it does not select a different parser or execution path.
|
||||
|
||||
Heading annotations (`{#id}`-style) are **Proposed** in
|
||||
[`heading-annotations-v1.md`](heading-annotations-v1.md) and are not current
|
||||
capability: the CLI currently rejects unknown `@` markers with
|
||||
`sem.invalid_mode_marker`. Do not build tools on the proposal.
|
||||
|
||||
## 2. Units, identity, anchors and spans
|
||||
|
||||
A heading that participates in the language creates an addressable **unit**.
|
||||
The root is always `units[0]`; all units are in document order.
|
||||
|
||||
* `id` is the canonical identity and may contain escapes for `/`, `#` and `%`.
|
||||
`path` is the authoritative structural name; consumers must not split `id`
|
||||
into segments.
|
||||
* `parent_id` is the nearest real ancestor unit (not the Markdown DOM parent).
|
||||
* Two headings with the same canonical name in the **same scope** are a hard
|
||||
error (`sem.duplicate_unit_name`); they are not auto-suffixed. The same name
|
||||
under different parents is allowed and addressable by `path`/`id`.
|
||||
* `anchors` is a separate namespace of navigation names derived from heading
|
||||
text with the GitHub-style slug algorithm. Slug collisions get the numbered
|
||||
suffix `-2`, `-3`, … in document order. An anchor is a navigation name, not
|
||||
an identity: resolve it to `unit_id`, never to a function or execution right.
|
||||
* `heading_span` is the original heading AST span. `span` is the complete
|
||||
section range: from the heading start through the next heading of the same or
|
||||
higher level, or EOF; it includes child headings and excludes the next
|
||||
sibling. The root `span` covers the whole source including a BOM.
|
||||
* All spans are **half-open UTF-8 byte offsets** into `modules[].source`.
|
||||
Slicing `source.as_bytes()[span.start..span.end]` is exact, including for a
|
||||
BOM, CRLF line endings, combining characters, a missing trailing newline and
|
||||
multi-byte text. `analyze`/`check --emit` and `check --refs` are different
|
||||
projections; bind a digest when mixing artifacts (see `analysis.md` §1).
|
||||
|
||||
## 3. `index.mq.md` and entry semantics
|
||||
|
||||
`index.mq.md` is an **ordinary `.mq.md` document**. The file name is a
|
||||
convention, not a language keyword and not a second document type.
|
||||
|
||||
* The **project entry** is the file passed to `check`/`run`/`call`/`inspect`.
|
||||
Analysis records it as `project.entry_module_id`; it must occur exactly once
|
||||
in `modules`. A second entry of the same project gets its own Analysis and is
|
||||
never merged by basename.
|
||||
* `marqdo init` generates a starter `index.mq.md`. That is a project template
|
||||
choice, not execution semantics.
|
||||
* A **path dependency** whose `marqdo.yaml` `path:` names a directory resolves
|
||||
to `<directory>/index.mq.md` when the dependency is imported; the loaded
|
||||
module keeps the dependency's package instance identity
|
||||
(`dep:<name>@<version>[#<digest>]::index.mq.md`). That is import resolution,
|
||||
not "the project entry is whatever index file is nearby".
|
||||
* Nothing scans directories, auto-loads `index.mq.md`, or treats a directory
|
||||
link as an import. Imports come only from the explicit YAML front matter.
|
||||
* An `index.mq.md` used as navigation content does not change execution. Any
|
||||
`@exec` H2 in it is a normal callable function with normal capability rules;
|
||||
links inside it are static references only.
|
||||
* Unresolved imports/missing modules are diagnostics (`module.unresolved`,
|
||||
`ref.*`); there is no fuzzy search or basename fallback. See
|
||||
[`references.md`](references.md) §3 and §5.
|
||||
|
||||
## 4. Three relations: link, import, call
|
||||
|
||||
The three must not be conflated; none is inferred from another.
|
||||
|
||||
| Relation | Syntax | Effect | Public projection |
|
||||
|---|---|---|---|
|
||||
| **Link** | Markdown `[text](url)` / image | Static reference only. Never loads a module, never imports, never grants read/execute. | `modules[].references[]` with state `resolved`, `not_loaded`, `missing`, `ambiguous`, `external`, `outside_scope` or `invalid`. |
|
||||
| **Import** | YAML front matter `import: {alias: target}` in a module | Loads exactly the named module (`@dependency`, `std:<relative>` or relative path). Explicit, depth-first, no directory scan. | `modules[].imports[]` with `resolved` module id or `null` for a diagnostic import. |
|
||||
| **Call** | Expression inside an executable payload | Binds statically to one callable; runs only under `run`/`call` with capability authorization. | `modules[].calls[]` with state `function`, `builtin`, `plugin` or `unresolved`. |
|
||||
|
||||
Partition rules:
|
||||
|
||||
* A link **never** imports or executes. A document may link to a module it did
|
||||
not import; ordinary Analysis reports its state honestly (`not_loaded` when
|
||||
the catalog did not verify existence), and `check --refs` verifies local
|
||||
files without adding them to the program.
|
||||
* `ref("#anchor")` returns a static `Formula | Code | FunctionRef` handle; it
|
||||
does not read a section body and does not grant execution.
|
||||
* Only an Exec H2 function can be called; calling a knowledge unit, namespace,
|
||||
section or plain Markdown heading is not part of the language.
|
||||
* Dynamic (`unresolved`/`dynamic`) calls are legal runtime values; they do not
|
||||
become a second binding table.
|
||||
|
||||
## 5. Authoring guidance (not a CLI enforcement layer)
|
||||
|
||||
`marqdo#55` defines repository-level documentation expectations (project
|
||||
entry, navigation, minimum per-document purpose). The CLI does **not** enforce
|
||||
those editorial rules: Markdown structure checks belong to `marqdo-lint`, and
|
||||
navigation/index policy belongs to the consumer repository. A `.mq.md` document
|
||||
must be independently meaningful to a human reader; adding a new document or a
|
||||
new knowledge file must not require new CLI syntax.
|
||||
|
||||
## 6. Not supported / deferred
|
||||
|
||||
* Heading annotations (`heading-annotations-v1.md`, Proposed) and any
|
||||
`{#id}`/attribute syntax.
|
||||
* AI-specific metadata, decorators, sidecar indexes or a second document
|
||||
format.
|
||||
* Automatic execution of prose or knowledge paragraphs, or "execute this
|
||||
section" navigation commands.
|
||||
* A second mode selector (`map_v1`, `--legacy`, per-file syntax switch) or
|
||||
compatibility fallback for retired syntax.
|
||||
* Implicit imports from links, file names or directory scans; directory-based
|
||||
project entry inference.
|
||||
* Anchor-based execution rights: an anchor resolves to a unit identity only.
|
||||
|
||||
## 7. Consumer stability contract
|
||||
|
||||
Tools may rely on the following public projection without reading CLI source.
|
||||
Changes require an Analysis schema/ADR change and consumer updates; there is
|
||||
no private-structure dependency.
|
||||
|
||||
| Fact | Field | Stability |
|
||||
|---|---|---|
|
||||
| Project entry | `project.entry_module_id`, `project.root_id`, `project.identity_kind` | Stable. |
|
||||
| Module identity | `modules[].id`, `package_instance_id`, `relative_path`, `source_digest`, `source` | Stable; bind `AnalysisDigest` when mixing projections. |
|
||||
| Heading tree | `units[].id/path/parent_id/kind/name/level`, document order, root first | Stable. |
|
||||
| Modes | `units[].mode`, `mode_origin`, `mode_source_unit_id`, `function` | Stable. |
|
||||
| Navigation | `units[].heading_span/span`, `anchors[]` | Stable; byte offsets. |
|
||||
| Relations | `imports[].resolved`, `references[]` states, `calls[]` states/targets | Stable vocabulary; see `analysis.md` §5–§7. |
|
||||
| Inert payloads | `resources[]` `formula`/`code` kinds | Stable. |
|
||||
|
||||
A consumer that needs a structural fact not in that table must request an
|
||||
Analysis field through the schema process; it must not parse Markdown or IR
|
||||
privately. Lint/Knowledge/AI consumers specifically may depend on: entry module
|
||||
identity, heading tree, mode/mode_source, anchors, exact spans, import/call
|
||||
separation and reference states.
|
||||
|
||||
## 8. Contract tests
|
||||
|
||||
| Test | Asserts |
|
||||
|---|---|
|
||||
| `crates/cli/tests/document_structure.rs` | heading modes/inheritance, same-name scope rules, anchor collision numbering, byte-exact spans with BOM/CRLF/no-final-newline, `index.mq.md` entry and directory-dependency resolution, link≠import≠call, invalid `@word` rejection. |
|
||||
| `crates/cli/tests/heading_inheritance.rs` | sibling/ancestor inheritance through real `check`/`run`/`call`. |
|
||||
| `crates/cli/tests/conformance_semantics.rs` | mapping and diagnostics for unit/heading semantics. |
|
||||
| `crates/cli/tests/analysis_boundary.rs` | Analysis v3 shape and consumer validation. |
|
||||
|
||||
## 9. Change rules
|
||||
|
||||
* New document-language semantics require a language ADR plus `spec/mapping.md`
|
||||
and `RFC-LANG-0002` updates; a tool requirement alone is not a reason to add
|
||||
syntax (`marqdo#55` §13.4).
|
||||
* A new Analysis field requires an `analysis.md`/schema change and a consumer
|
||||
candidate on the same contract; no private projection is exposed.
|
||||
* No second document-structure specification is maintained here or in Lint,
|
||||
Knowledge, AI or the parent repository. This page links the single sources.
|
||||
@@ -0,0 +1,181 @@
|
||||
# Marqdo Environment Report
|
||||
|
||||
Current public contract for `marqdo inspect --environment`. The command emits
|
||||
one offline installation report used by user feedback, release evidence and
|
||||
diagnostic tooling. It is implemented by the CLI composition root
|
||||
(`crates/cli/src/environment.rs`); this document is the only normative
|
||||
specification for its shape. Release binding is defined by
|
||||
[marqdo-cli#20](https://git.cflmy.cn/cflmy/marqdo-cli/issues/20) and
|
||||
[marqdo-cli#26](https://git.cflmy.cn/cflmy/marqdo-cli/issues/26) §9.2.
|
||||
|
||||
Schema name: `marqdo.environment`, current `schema_version: 1`.
|
||||
|
||||
## 1. Invariants
|
||||
|
||||
`inspect --environment`:
|
||||
|
||||
* never executes project code, loads a module, starts a provider session,
|
||||
opens a plugin, or accesses the network;
|
||||
* takes no document and is rejected by the argument parser when combined with
|
||||
a project-inspection flag (`--ast`, `--units`, `--signature`, `--ir`,
|
||||
`--refs`, `--platform`, `--extensions`, `--plugin`, `FILE`);
|
||||
* prints no credential, no Analysis or source content, no user data and no
|
||||
absolute host path — the Bundle name/version/digest and the product version
|
||||
are the only installation identity shown;
|
||||
* reports a degraded installation as data (`status` plus a stable
|
||||
`diagnostics[].code`) and still exits `0`; the report is the diagnostic, not
|
||||
a command failure. Argument misuse remains a `2` usage error;
|
||||
* is deterministic for one installation: two invocations print identical bytes.
|
||||
|
||||
The adjacent provider worker is queried only through its single-shot
|
||||
`--build-info` command, bounded to 750 ms and killed on timeout. That is
|
||||
not a provider session: no library is loaded and no framed request is sent.
|
||||
|
||||
## 2. Output
|
||||
|
||||
```json
|
||||
{
|
||||
"schema": "marqdo.environment",
|
||||
"schema_version": 1,
|
||||
"producer": {
|
||||
"name": "marqdo",
|
||||
"version": "3.0.0-rc.6",
|
||||
"source": {
|
||||
"sha": "63776735e924ade279cdf59d5c733dc24bfdabbb",
|
||||
"origin": "embedded"
|
||||
}
|
||||
},
|
||||
"platform": {
|
||||
"os": "linux",
|
||||
"arch": "x86_64",
|
||||
"family": "unix",
|
||||
"libc": {"family": "glibc", "version": "2.39"},
|
||||
"strict": {"state": "unavailable", "reason": "bubblewrap cannot create the required namespaces: ..."},
|
||||
"worker_processes": true
|
||||
},
|
||||
"worker": {
|
||||
"name": "marqdo-provider-worker",
|
||||
"status": "present",
|
||||
"version": "3.0.0-rc.6",
|
||||
"source_sha": "63776735e924ade279cdf59d5c733dc24bfdabbb"
|
||||
},
|
||||
"bundle": {
|
||||
"status": "verified",
|
||||
"origin": "sibling",
|
||||
"name": "marqdo-stdlib",
|
||||
"version": "0.3.0",
|
||||
"tree_digest": "sha256:...",
|
||||
"instance_id": "stdlib:marqdo-stdlib@0.3.0"
|
||||
},
|
||||
"protocols": {
|
||||
"markdown_profile": "marqdo.md.v1",
|
||||
"analysis": 3,
|
||||
"observation": 1,
|
||||
"cli_tool": {"version": 1, "api_revision": 1},
|
||||
"plugin_abi": {"version": "1.0", "major": 1, "minor": 0},
|
||||
"provider_manifest": 2,
|
||||
"package_lock": 4
|
||||
},
|
||||
"diagnostics": []
|
||||
}
|
||||
```
|
||||
|
||||
### 2.1 Producer identity
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `producer.name` | Always `marqdo`. |
|
||||
| `producer.version` | Product SemVer of the running binary (`marqdo --version` without the name prefix). |
|
||||
| `producer.source.sha` | Full lowercase 40-hex commit embedded by the release build, or `null`. |
|
||||
| `producer.source.origin` | `embedded` when the build supplied `MARQDO_BUILD_SOURCE_SHA`; otherwise `unavailable`. This is a build fact, not a claim: a development build reports `null`. |
|
||||
|
||||
`MARQDO_BUILD_SOURCE_SHA` is a build-time environment variable consumed by
|
||||
`crates/cli/build.rs` and `crates/marqdo-provider-worker/build.rs`. It must be
|
||||
the exact 40-hex release commit. The release pipeline sets it from
|
||||
`CI_COMMIT_SHA`; `tools/release/package.py` refuses to stage an archive whose
|
||||
binary does not report the `--source-sha` commit, and
|
||||
`tools/release/smoke.py` re-verifies it from the archive alone.
|
||||
|
||||
### 2.2 Platform
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `platform.os`, `platform.arch` | `std::env::consts::OS` / `ARCH` of the running binary. |
|
||||
| `platform.family` | `std::env::consts::FAMILY` (`unix`/`windows`). |
|
||||
| `platform.libc` | `{"family": "glibc", "version": "<gnu_get_libc_version>"}` on linux-gnu, `{"family": "musl", "version": null}` on musl, `null` elsewhere. A version is a runtime fact, not a support claim. |
|
||||
| `platform.strict` | The current strict-isolation probe result, `{"state": "available"|"unavailable", ...}` (ADR-0021). `unavailable` includes the probe refusal reason and is contractual. |
|
||||
| `platform.worker_processes` | Whether the built host can spawn isolated worker processes. |
|
||||
|
||||
Platform support claims live only in [`COMPATIBILITY.md`](../COMPATIBILITY.md);
|
||||
this report states what the running installation is, never that a platform is
|
||||
supported.
|
||||
|
||||
### 2.3 Adjacent provider worker
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `worker.status` | `present` when `marqdo-provider-worker` is a regular file next to the running binary; `absent` otherwise. |
|
||||
| `worker.version` | Worker product version from its `--build-info` document, or `null`. |
|
||||
| `worker.source_sha` | Full lowercase 40-hex commit from the worker `--build-info` document, or `null`. |
|
||||
|
||||
When a present worker cannot produce a current build-info document within the
|
||||
bound, the report keeps `status: present`, leaves both identity fields `null`,
|
||||
and appends the `env.worker_info_unavailable` diagnostic. No path or error text
|
||||
from the worker is projected.
|
||||
|
||||
### 2.4 Bundle
|
||||
|
||||
| Field | Meaning |
|
||||
|---|---|
|
||||
| `bundle.status` | `verified` (manifest/alias digests and tree digest match), `absent` (no `MARQDO_STDLIB_DIR` and no sibling `stdlib/`), or `invalid` (an explicit or sibling Bundle failed verification). |
|
||||
| `bundle.origin` | `explicit-env` when `MARQDO_STDLIB_DIR` selected the Bundle, `sibling` when the adjacent `stdlib/` directory did, `null` when absent. |
|
||||
| `bundle.name`, `bundle.version` | Declared Bundle identity, or `null`. |
|
||||
| `bundle.tree_digest` | `sha256:` + verified content digest of all `.mq.md` files, or `null`. |
|
||||
| `bundle.instance_id` | Canonical verified instance id, or `null`. |
|
||||
|
||||
An explicit `MARQDO_STDLIB_DIR` is authoritative: a bad value reports
|
||||
`invalid` and does not silently fall back to a sibling Bundle. Bundle load
|
||||
errors never project the underlying path: they map to `env.stdlib_unreadable`,
|
||||
`env.stdlib_invalid` or `env.stdlib_digest_mismatch`.
|
||||
|
||||
### 2.5 Protocol versions
|
||||
|
||||
`protocols` repeats the current revisions of the contracts documented in
|
||||
[`../COMPATIBILITY.md`](../COMPATIBILITY.md): markdown profile, Analysis,
|
||||
Observation, CLI Tool revision/API revision, Plugin ABI, Resource Provider
|
||||
manifest and lock. These are the revisions this binary is built to, not a
|
||||
negotiation result for a project.
|
||||
|
||||
### 2.6 Diagnostics
|
||||
|
||||
`diagnostics` is a list of `{code, message}` records. Codes are stable and
|
||||
path-free:
|
||||
|
||||
| Code | Meaning |
|
||||
|---|---|
|
||||
| `env.stdlib_unreadable` | The installed Bundle directory/manifest cannot be read. |
|
||||
| `env.stdlib_invalid` | The installed Bundle is not a current verified Bundle. |
|
||||
| `env.stdlib_digest_mismatch` | Tree or alias digests do not match the manifest. |
|
||||
| `env.worker_info_unavailable` | An adjacent worker exists but did not report a current build identity. |
|
||||
|
||||
A verified installation reports an empty list. New codes are additive within
|
||||
`schema_version: 1`; renaming or removing a code is a schema change.
|
||||
|
||||
## 3. Consumer usage
|
||||
|
||||
```sh
|
||||
marqdo inspect --environment --json | jq -r '.producer.version, .platform.os,
|
||||
.bundle.status, .bundle.tree_digest'
|
||||
```
|
||||
|
||||
Human-readable output (no `--json`) prints the same facts as stable
|
||||
`key: value` lines; scripts must use `--json`. Consumers that need the report
|
||||
for feedback must attach it as text, not upload source or credentials.
|
||||
|
||||
## 4. Stability
|
||||
|
||||
The report is a public CLI output contract. Adding a field is compatible;
|
||||
changing a field's meaning, removing it or changing a diagnostic code requires
|
||||
a `schema_version` change and a consumer update. The report does not replace
|
||||
Analysis (static project facts), Observation (execution facts) or CLI Tool
|
||||
(revision negotiation), and must not be used as any of them.
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
# Marqdo Security Model (implemented status)
|
||||
|
||||
Status: describes enforcement in the `3.0.0-rc.4` candidate.
|
||||
Status: describes enforcement in the `3.0.0-rc.6` candidate.
|
||||
|
||||
Normative implementation:
|
||||
|
||||
|
||||
Generated
+8
-8
@@ -172,7 +172,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-expression"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
@@ -182,7 +182,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-frontend"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-ir",
|
||||
@@ -196,7 +196,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-host-contract"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"marqdo-value",
|
||||
@@ -204,7 +204,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-ir"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-span",
|
||||
@@ -213,7 +213,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-markdown"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"comrak",
|
||||
"marqdo-span",
|
||||
@@ -224,7 +224,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-runtime"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-expression",
|
||||
"marqdo-host-contract",
|
||||
@@ -239,14 +239,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-span"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-value"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
|
||||
Generated
+4
-4
@@ -16,7 +16,7 @@ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-plugin-abi"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-value",
|
||||
"serde",
|
||||
@@ -26,7 +26,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-plugin-sdk"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-plugin-abi",
|
||||
"serde",
|
||||
@@ -42,14 +42,14 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-span"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "marqdo-value"
|
||||
version = "3.0.0-rc.4"
|
||||
version = "3.0.0-rc.6"
|
||||
dependencies = [
|
||||
"marqdo-span",
|
||||
"num-bigint",
|
||||
|
||||
@@ -78,7 +78,7 @@ def build_dependencies(package: str, offline: bool) -> set[str]:
|
||||
stripped = line.strip()
|
||||
if not stripped:
|
||||
continue
|
||||
# Lines look like `marqdo-value v3.0.0-rc.4 (/path)` or `serde v1.0.1`.
|
||||
# Lines look like `marqdo-value v3.0.0-rc.5 (/path)` or `serde v1.0.1`.
|
||||
name = stripped.split(" v", 1)[0].strip()
|
||||
if name:
|
||||
names.add(name)
|
||||
|
||||
@@ -109,17 +109,16 @@ def fetch_root(pin: dict, cache: Path) -> Path:
|
||||
return cache
|
||||
|
||||
|
||||
def build_bundle(root: Path, out: Path) -> Path:
|
||||
def build_bundle(root: Path, out: Path) -> str:
|
||||
"""Build the Bundle; an existing output is reused only after verification.
|
||||
|
||||
CI jobs share one workspace, so a parallel or earlier job may already have
|
||||
materialized the same pinned Bundle. The output is built in a temporary
|
||||
sibling and moved into place atomically; a mismatch is rebuilt, never used.
|
||||
The caller serializes jobs that share a worktree. The output is built
|
||||
in a temporary sibling and moved into place.
|
||||
"""
|
||||
temp = out.with_name(out.name + ".partial-" + str(os.getpid()))
|
||||
if temp.exists():
|
||||
shutil.rmtree(temp)
|
||||
run(
|
||||
receipt = run(
|
||||
[
|
||||
sys.executable,
|
||||
str(root / "scripts" / "build-stdlib.py"),
|
||||
@@ -131,7 +130,7 @@ def build_bundle(root: Path, out: Path) -> Path:
|
||||
if out.exists():
|
||||
shutil.rmtree(out)
|
||||
temp.rename(out)
|
||||
return out
|
||||
return receipt
|
||||
|
||||
|
||||
def verify(pin: dict, bundle: Path) -> dict:
|
||||
@@ -158,12 +157,13 @@ def main(argv: list[str]) -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--out", default=str(ROOT / "target" / "ecosystem-stdlib"))
|
||||
parser.add_argument("--cache", default=str(ROOT / "target" / "ecosystem-root"))
|
||||
parser.add_argument("--receipt", type=Path, help="save the pinned producer's JSON summary")
|
||||
args = parser.parse_args(argv)
|
||||
out = Path(args.out).resolve()
|
||||
cache = Path(args.cache).resolve()
|
||||
try:
|
||||
pin = load_pin()
|
||||
if out.is_dir():
|
||||
if out.is_dir() and args.receipt is None:
|
||||
try:
|
||||
verify(pin, out)
|
||||
except (FetchError, OSError, json.JSONDecodeError):
|
||||
@@ -172,12 +172,14 @@ def main(argv: list[str]) -> int:
|
||||
print(out)
|
||||
return 0
|
||||
root = fetch_root(pin, cache)
|
||||
bundle = build_bundle(root, out)
|
||||
verify(pin, bundle)
|
||||
except FetchError as error:
|
||||
receipt = build_bundle(root, out)
|
||||
verify(pin, out)
|
||||
if args.receipt is not None:
|
||||
args.receipt.write_text(receipt, encoding="utf-8")
|
||||
except (FetchError, OSError, json.JSONDecodeError) as error:
|
||||
print(f"fetch-ecosystem-bundle: error: {error}", file=sys.stderr)
|
||||
return 1
|
||||
print(bundle)
|
||||
print(out)
|
||||
return 0
|
||||
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@ does not query CI and cannot turn an UNVERIFIED gate into a release.
|
||||
|
||||
The `rc` profile requires every gate on the target SHA. For a Linux-only RC,
|
||||
Windows and macOS must be explicitly UNSUPPORTED; the stable profile requires
|
||||
both to PASS. Strict VM, extension, clean install, version compatibility and
|
||||
performance require PASS. RC can record a shared-node performance WARN only
|
||||
with an explicit maintainer approval reference. The historical beta profile
|
||||
retains its own scoped exceptions.
|
||||
both to PASS. An RC can record strict as UNSUPPORTED with same-SHA fail-closed
|
||||
evidence and can record a measured shared-node performance WARN. Each
|
||||
exception requires an explicit maintainer approval reference.
|
||||
|
||||
Gate spec: `name=STATE:tested_sha:run_url` (url may contain colons).
|
||||
|
||||
@@ -106,6 +105,7 @@ def build_manifest(
|
||||
gates: list[str],
|
||||
profile: str = "stable",
|
||||
rc_shared_performance_approval: str = "",
|
||||
rc_strict_unsupported_approval: str = "",
|
||||
) -> dict:
|
||||
if not SHA_RE.fullmatch(target_sha):
|
||||
raise ValueError(f"target SHA must be 40 lowercase hex characters: {target_sha!r}")
|
||||
@@ -114,10 +114,13 @@ def build_manifest(
|
||||
except KeyError:
|
||||
raise ValueError(f"unknown profile {profile!r}; expected {sorted(PROFILES)}") from None
|
||||
approval = rc_shared_performance_approval.strip()
|
||||
if approval and profile != "rc":
|
||||
raise ValueError("shared-node approval is supported only by the rc profile")
|
||||
strict_approval = rc_strict_unsupported_approval.strip()
|
||||
if (approval or strict_approval) and profile != "rc":
|
||||
raise ValueError("RC exception approvals are supported only by the rc profile")
|
||||
if approval:
|
||||
accepted_states = {**accepted_states, "performance": {"PASS", "WARN"}}
|
||||
if strict_approval:
|
||||
accepted_states = {**accepted_states, "strict_vm": {"PASS", "UNSUPPORTED"}}
|
||||
parsed = {}
|
||||
for spec in gates:
|
||||
name, gate = parse_gate(spec)
|
||||
@@ -150,6 +153,8 @@ def build_manifest(
|
||||
recorded = utc_now()
|
||||
if approval and parsed["performance"]["state"] == "WARN":
|
||||
parsed["performance"]["rc_shared_node_approval"] = approval
|
||||
if strict_approval and parsed["strict_vm"]["state"] == "UNSUPPORTED":
|
||||
parsed["strict_vm"]["rc_unsupported_approval"] = strict_approval
|
||||
return {
|
||||
"schema": SCHEMA,
|
||||
"profile": profile,
|
||||
@@ -178,6 +183,11 @@ def main(argv: list[str]) -> int:
|
||||
default="",
|
||||
help="maintainer approval reference for the measured shared-node RC performance WARN",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rc-strict-unsupported-approval",
|
||||
default="",
|
||||
help="maintainer approval reference for same-SHA fail-closed strict evidence on an RC",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--require-release",
|
||||
action="store_true",
|
||||
@@ -186,7 +196,8 @@ def main(argv: list[str]) -> int:
|
||||
args = parser.parse_args(argv)
|
||||
try:
|
||||
manifest = build_manifest(
|
||||
args.target_sha, args.gate, args.profile, args.rc_shared_performance_approval
|
||||
args.target_sha, args.gate, args.profile, args.rc_shared_performance_approval,
|
||||
args.rc_strict_unsupported_approval,
|
||||
)
|
||||
except ValueError as error:
|
||||
print(f"error: {error}", file=sys.stderr)
|
||||
|
||||
@@ -36,7 +36,7 @@ def snapshot(run_id: str, status: str, value, extra_file: str = "/tmp/index.mq.m
|
||||
"run_id": run_id,
|
||||
"seq": 0,
|
||||
"kind": "stream.opened",
|
||||
"payload": {"producer": {"name": "marqdo", "version": "3.0.0-rc.4"}},
|
||||
"payload": {"producer": {"name": "marqdo", "version": "3.0.0-rc.6"}},
|
||||
},
|
||||
{
|
||||
"schema": "marqdo.observation",
|
||||
|
||||
@@ -95,6 +95,34 @@ class ReleaseEvidenceTests(unittest.TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
release_evidence.build_manifest(SHA, inputs, "stable", approval)
|
||||
|
||||
def test_rc_strict_unsupported_requires_same_sha_evidence_and_approval(self) -> None:
|
||||
approval = "release notes: maintainer approved strict unsupported for this RC"
|
||||
inputs = [spec for spec in self.rc_gates() if not spec.startswith("strict_vm=")]
|
||||
manifest = release_evidence.build_manifest(
|
||||
SHA, inputs + [gate("strict_vm", "UNSUPPORTED")], "rc",
|
||||
rc_strict_unsupported_approval=approval,
|
||||
)
|
||||
self.assertEqual(manifest["release_decision"], "RC_RELEASE_CANDIDATE")
|
||||
self.assertEqual(manifest["gates"]["strict_vm"]["state"], "UNSUPPORTED")
|
||||
self.assertEqual(manifest["gates"]["strict_vm"]["rc_unsupported_approval"], approval)
|
||||
for entry in (gate("strict_vm", "UNSUPPORTED", OTHER),
|
||||
gate("strict_vm", "UNSUPPORTED", url=""),
|
||||
gate("strict_vm", "FAIL"), gate("strict_vm", "UNVERIFIED")):
|
||||
with self.subTest(entry=entry):
|
||||
result = release_evidence.build_manifest(
|
||||
SHA, inputs + [entry], "rc", rc_strict_unsupported_approval=approval,
|
||||
)
|
||||
self.assertEqual(result["release_decision"], "DO_NOT_RELEASE")
|
||||
|
||||
def test_stable_rejects_rc_strict_exception(self) -> None:
|
||||
inputs = [gate(name, "UNSUPPORTED" if name == "strict_vm" else "PASS")
|
||||
for name in release_evidence.GATES]
|
||||
result = release_evidence.build_manifest(SHA, inputs)
|
||||
self.assertEqual(result["release_decision"], "DO_NOT_RELEASE")
|
||||
with self.assertRaises(ValueError):
|
||||
release_evidence.build_manifest(SHA, inputs,
|
||||
rc_strict_unsupported_approval="RC approval")
|
||||
|
||||
def test_stable_requires_extension_install_version_and_performance(self) -> None:
|
||||
names = ("extension", "clean_install", "version_compat", "performance")
|
||||
for name in names:
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
"""Release index ties an archive and the producer receipt to authoritative CI."""
|
||||
|
||||
import io
|
||||
import json
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "release"))
|
||||
import release_index
|
||||
|
||||
|
||||
class ReleaseIndexTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(directory.cleanup)
|
||||
self.archive = Path(directory.name) / "marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu.tar.gz"
|
||||
self.sha = "9" * 40
|
||||
self.bundle = {"name": "marqdo-stdlib", "version": "0.2.0",
|
||||
"tree_digest": "sha256:" + "1" * 64,
|
||||
"aliases_digest": "sha256:" + "2" * 64}
|
||||
self.receipt = {**self.bundle, "root_commit": "8" * 40,
|
||||
"components": [{"id": "std-io", "revision": "7" * 40}]}
|
||||
self.info = {
|
||||
"schema": "marqdo.release-info", "schema_version": 1, "product": "marqdo-cli",
|
||||
"build_profile": "release", "product_version": "3.0.0-rc.6",
|
||||
"target_triple": "x86_64-unknown-linux-gnu", "source_sha": self.sha,
|
||||
"stdlib": {**self.bundle, "source": {"kind": "ecosystem",
|
||||
"repository": "cflmy/marqdo", "commit": self.receipt["root_commit"]}},
|
||||
}
|
||||
steps = [{"name": name, "type": "commands", "state": "success"}
|
||||
for name in sorted(release_index.REQUIRED_STEPS)]
|
||||
self.pipeline = {"number": 3, "commit": self.sha, "status": "success", "event": "push",
|
||||
"workflows": [{"name": "main", "state": "success", "children": steps}]}
|
||||
self.repo = {"id": 2, "forge_remote_id": "19", "full_name": release_index.REPOSITORY}
|
||||
|
||||
with tarfile.open(self.archive, "w:gz") as output:
|
||||
top = self.archive.name.removesuffix(".tar.gz")
|
||||
for name, data in (("RELEASE_INFO.json", json.dumps(self.info)), ("SOURCE_SHA", self.sha)):
|
||||
member = tarfile.TarInfo(f"{top}/{name}")
|
||||
contents = data.encode()
|
||||
member.size = len(contents)
|
||||
output.addfile(member, io.BytesIO(contents))
|
||||
self.checksum = self.archive.with_name(self.archive.name + ".sha256")
|
||||
self.digest = release_index.sha256_file(self.archive)
|
||||
self.checksum.write_text(f"{self.digest} {self.archive.name}\n", encoding="utf-8")
|
||||
|
||||
def test_assets_and_dependencies_are_derived_from_the_inputs(self):
|
||||
with patch.object(release_index, "read_json", side_effect=[{"id": 19}, self.repo, self.pipeline]):
|
||||
index = release_index.evidence(self.archive, self.receipt, 3)
|
||||
self.assertEqual(index["ci"], {"pipeline_number": 3, "source_sha": self.sha,
|
||||
"url": f"{release_index.CI}/repos/2/pipeline/3"})
|
||||
self.assertEqual(index["assets"][0], {"name": self.archive.name, "sha256": self.digest,
|
||||
"size": self.archive.stat().st_size,
|
||||
"target": self.info["target_triple"]})
|
||||
self.assertEqual(index["dependencies"], [{"id": "std-io", "source_sha": "7" * 40}])
|
||||
|
||||
def test_index_rejects_green_pipeline_without_exact_sha_and_gates(self):
|
||||
wrong_commit = {**self.pipeline, "commit": "0" * 40}
|
||||
skipped_gate = {**self.pipeline["workflows"][0]}
|
||||
skipped_gate["children"] = skipped_gate["children"][1:]
|
||||
for pipeline in (wrong_commit, {**self.pipeline, "workflows": [skipped_gate]}):
|
||||
with (patch.object(release_index, "read_json", side_effect=[{"id": 19}, self.repo, pipeline]),
|
||||
self.assertRaisesRegex(ValueError, "exact SHA")):
|
||||
release_index.evidence(self.archive, self.receipt, 3)
|
||||
|
||||
def test_index_rejects_mismatched_receipt_or_archive_checksum(self):
|
||||
receipt = {**self.receipt, "root_commit": "0" * 40}
|
||||
with self.assertRaisesRegex(ValueError, "mismatches the Bundle"):
|
||||
release_index.evidence(self.archive, receipt, 3)
|
||||
self.checksum.write_text(f"{'0' * 64} {self.archive.name}\n", encoding="utf-8")
|
||||
with self.assertRaisesRegex(ValueError, "checksum disagrees"):
|
||||
release_index.evidence(self.archive, self.receipt, 3)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,49 @@
|
||||
{
|
||||
"measure_argv": [
|
||||
"call",
|
||||
"tools/perf/fixtures/print-demo.mq.md",
|
||||
"main"
|
||||
],
|
||||
"measure_sha256": "sha256:663b632142809ee1bdfa24671263228f52fe8017db0b81a15db8f2bf3028ea33",
|
||||
"normalized": {
|
||||
"events": {
|
||||
"by_kind": {
|
||||
"branch.eval": 70,
|
||||
"call.enter": 9,
|
||||
"call.exit": 9,
|
||||
"effect": 20,
|
||||
"loop.iteration": 24,
|
||||
"parameter.observed": 13,
|
||||
"return": 9,
|
||||
"run.completed": 1,
|
||||
"run.started": 1,
|
||||
"stdout.chunk": 1,
|
||||
"stream.opened": 1,
|
||||
"variable.assigned": 83
|
||||
},
|
||||
"count": 241,
|
||||
"sequence_sha256": "sha256:d7a9c356294e2ecace0f93b8b65c4eb0555073e1eec4846fb044dd5f395c97bd"
|
||||
},
|
||||
"schema": "marqdo.observation",
|
||||
"status": "ok",
|
||||
"stderr": {
|
||||
"bytes": 0,
|
||||
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
},
|
||||
"stdout": {
|
||||
"bytes": 16,
|
||||
"sha256": "sha256:ca03bebeb3052ad7ae18943d04dccb7921e58421c46a2d8db460fbe3e96d9d51"
|
||||
},
|
||||
"terminal": {
|
||||
"status": "ok",
|
||||
"value": {
|
||||
"type": "text",
|
||||
"value": "你好,Marqdo"
|
||||
},
|
||||
"value_type": "Text"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.perf.expected.v1",
|
||||
"wire_sha256": "sha256:a36f2476e799cc45127ebb31c1a7828115276a6bec39368b6b9f5297b7d16799",
|
||||
"workload": "print-demo"
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
{
|
||||
"measure_argv": [
|
||||
"run",
|
||||
"stdlib/demo.mq.md"
|
||||
],
|
||||
"measure_sha256": "sha256:4f5fcde6b4073511330c50f15bf07db13abc2cf0cf71de777e8e23ca870220fe",
|
||||
"normalized": {
|
||||
"events": {
|
||||
"by_kind": {
|
||||
"branch.eval": 1956,
|
||||
"call.enter": 131,
|
||||
"call.exit": 131,
|
||||
"effect": 404,
|
||||
"loop.iteration": 810,
|
||||
"parameter.observed": 166,
|
||||
"return": 131,
|
||||
"run.completed": 1,
|
||||
"run.started": 1,
|
||||
"stdout.chunk": 6,
|
||||
"stream.opened": 1,
|
||||
"variable.assigned": 2533
|
||||
},
|
||||
"count": 6271,
|
||||
"sequence_sha256": "sha256:e17ea3ebe3ecd40f9e619f06e3bd9d4370d34616caf02a6099bbffe0f686522d"
|
||||
},
|
||||
"schema": "marqdo.observation",
|
||||
"status": "ok",
|
||||
"stderr": {
|
||||
"bytes": 0,
|
||||
"sha256": "sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
|
||||
},
|
||||
"stdout": {
|
||||
"bytes": 380,
|
||||
"sha256": "sha256:4f5fcde6b4073511330c50f15bf07db13abc2cf0cf71de777e8e23ca870220fe"
|
||||
},
|
||||
"terminal": {
|
||||
"status": "ok",
|
||||
"value": {
|
||||
"type": "none"
|
||||
},
|
||||
"value_type": "None"
|
||||
}
|
||||
},
|
||||
"schema": "marqdo.perf.expected.v1",
|
||||
"wire_sha256": "sha256:7bed5196b8cd52d1de12561f445bc2271dd5e91ed9c4065ebf79d0cb22d8a826",
|
||||
"workload": "stdlib-print-demo"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
# 打印工作负载
|
||||
|
||||
## @exec main
|
||||
|
||||
**问候 = "你好,Marqdo"**
|
||||
|
||||
> **打印(问候)**
|
||||
|
||||
`return 问候`
|
||||
@@ -123,18 +123,20 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "stdlib-print-demo",
|
||||
"name": "print-demo",
|
||||
"kind": "run",
|
||||
"source": "stdlib/demo.mq.md",
|
||||
"source": "tools/perf/fixtures/print-demo.mq.md",
|
||||
"argv": [
|
||||
"run",
|
||||
"stdlib/demo.mq.md",
|
||||
"call",
|
||||
"tools/perf/fixtures/print-demo.mq.md",
|
||||
"main",
|
||||
"--output",
|
||||
"json"
|
||||
],
|
||||
"measure_argv": [
|
||||
"run",
|
||||
"stdlib/demo.mq.md"
|
||||
"call",
|
||||
"tools/perf/fixtures/print-demo.mq.md",
|
||||
"main"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -22,7 +22,7 @@ Usage (from the repository root, after
|
||||
|
||||
python3 tools/release/package.py \
|
||||
--source-sha "$(git rev-parse HEAD)" \
|
||||
--version 3.0.0-rc.4 \
|
||||
--version 3.0.0-rc.6 \
|
||||
--stdlib-dir stdlib \
|
||||
--bundle-pin tools/stdlib/bundle-pin.json
|
||||
"""
|
||||
@@ -187,6 +187,55 @@ def copy_tree(source: Path, destination: Path) -> None:
|
||||
shutil.copytree(source, destination, dirs_exist_ok=True)
|
||||
|
||||
|
||||
def verify_binary_identity(
|
||||
stage_dir: Path, version: str, source_sha: str, stdlib_info: dict
|
||||
) -> None:
|
||||
"""Prove the staged binaries embed the release commit and shipped Bundle.
|
||||
|
||||
`inspect --environment` is the same offline report users export for
|
||||
feedback (marqdo-cli#26 §9.2). The archive is not allowed to claim a source
|
||||
commit it was not built from, so packaging fails closed when the release
|
||||
build did not receive `MARQDO_BUILD_SOURCE_SHA` (marqdo-cli#20).
|
||||
"""
|
||||
result = subprocess.run(
|
||||
[str(stage_dir / "marqdo"), "inspect", "--environment", "--json"],
|
||||
cwd=stage_dir,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=60,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
fail(
|
||||
"the staged marqdo binary cannot report its environment: "
|
||||
f"exit {result.returncode}\n{result.stderr}"
|
||||
)
|
||||
try:
|
||||
report = json.loads(result.stdout)
|
||||
except json.JSONDecodeError as error:
|
||||
fail(f"the staged environment report is not JSON: {error}\n{result.stdout}")
|
||||
if report.get("schema") != "marqdo.environment" or report.get("schema_version") != 1:
|
||||
fail("the staged environment report is not marqdo.environment v1")
|
||||
if report.get("producer", {}).get("version") != version:
|
||||
fail("the staged marqdo binary version does not match RELEASE_INFO.json")
|
||||
embedded = report.get("producer", {}).get("source", {}).get("sha")
|
||||
if embedded != source_sha:
|
||||
fail(
|
||||
f"the staged marqdo binary embeds source {embedded!r}, not {source_sha}; "
|
||||
"rebuild with MARQDO_BUILD_SOURCE_SHA set to the release commit"
|
||||
)
|
||||
worker = report.get("worker", {})
|
||||
if worker.get("status") != "present" or worker.get("source_sha") != source_sha:
|
||||
fail(
|
||||
"the staged provider worker does not report the release commit; "
|
||||
"rebuild it with MARQDO_BUILD_SOURCE_SHA set to the release commit"
|
||||
)
|
||||
bundle = report.get("bundle", {})
|
||||
if bundle.get("status") != "verified":
|
||||
fail("the staged archive does not contain a verified adjacent stdlib Bundle")
|
||||
if bundle.get("tree_digest") != stdlib_info.get("tree_digest"):
|
||||
fail("the staged environment report does not match the archived Bundle digest")
|
||||
|
||||
|
||||
def stage(
|
||||
stage_dir: Path,
|
||||
version: str,
|
||||
@@ -216,6 +265,10 @@ def stage(
|
||||
# side effect: copy the verified tree next to the binary (ADR/SPEC H-08).
|
||||
copy_tree(stdlib_dir, stage_dir / "stdlib")
|
||||
|
||||
# The archive binds product identity to the shipped Bundle before any
|
||||
# checksum or RELEASE_INFO.json is written.
|
||||
verify_binary_identity(stage_dir, version, source_sha, stdlib_info)
|
||||
|
||||
# Examples without local build output, then the freshly built extension
|
||||
# artifacts so a clean install can run every example without a compiler.
|
||||
copy_tree(ROOT / "examples", stage_dir / "examples")
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate the ecosystem release index for a cold-tested CLI archive."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import tarfile
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
from package import sha256_file
|
||||
|
||||
REPOSITORY = "cflmy/marqdo-cli"
|
||||
FORGE = "https://git.cflmy.cn"
|
||||
CI = "https://ci.cflmy.cn"
|
||||
LIMIT = 1024 * 1024
|
||||
SHA = re.compile(r"[0-9a-f]{40}")
|
||||
COMPONENT_ID = re.compile(r"[a-z][a-z0-9-]*")
|
||||
REQUIRED_STEPS = {"contract", "test", "independent-build", "minimum-rust", "build"}
|
||||
|
||||
|
||||
def read_json(url: str) -> dict:
|
||||
with urllib.request.urlopen(url, timeout=20) as response:
|
||||
data = response.read(LIMIT + 1)
|
||||
if response.geturl() != url or len(data) > LIMIT:
|
||||
raise ValueError("unexpected CI or forge response")
|
||||
return json.loads(data)
|
||||
|
||||
|
||||
def verify_ci(source_sha: str, number: int) -> dict:
|
||||
if number < 1:
|
||||
raise ValueError("pipeline number must be positive")
|
||||
forge = read_json(f"{FORGE}/api/v1/repos/{REPOSITORY}")
|
||||
repo = read_json(f"{CI}/api/repos/lookup/{REPOSITORY}")
|
||||
repo_id = repo.get("id")
|
||||
if (type(forge.get("id")) is not int or type(repo_id) is not int or repo_id < 1
|
||||
or repo.get("full_name") != REPOSITORY
|
||||
or repo.get("forge_remote_id") != str(forge["id"])):
|
||||
raise ValueError("Woodpecker does not identify the canonical CLI repository")
|
||||
pipeline = read_json(f"{CI}/api/repos/{repo_id}/pipelines/{number}")
|
||||
successful = {
|
||||
step["name"]
|
||||
for workflow in pipeline.get("workflows", [])
|
||||
if workflow.get("name") == "main" and workflow.get("state") == "success"
|
||||
for step in workflow.get("children", [])
|
||||
if step.get("state") == "success" and step.get("type") == "commands"
|
||||
}
|
||||
if (pipeline.get("number") != number or pipeline.get("commit") != source_sha
|
||||
or pipeline.get("status") != "success"
|
||||
or pipeline.get("event") not in {"push", "pull_request"}
|
||||
or not REQUIRED_STEPS <= successful):
|
||||
raise ValueError("pipeline did not pass the CLI gates for the archive's exact SHA")
|
||||
return {"pipeline_number": number, "url": f"{CI}/repos/{repo_id}/pipeline/{number}",
|
||||
"source_sha": source_sha}
|
||||
|
||||
|
||||
def archive_info(archive: Path) -> dict:
|
||||
top = archive.name.removesuffix(".tar.gz")
|
||||
names = {f"{top}/RELEASE_INFO.json", f"{top}/SOURCE_SHA"}
|
||||
metadata = {}
|
||||
# Read the two fixed paths without extracting the archive.
|
||||
with tarfile.open(archive, "r|gz") as product:
|
||||
for member in product:
|
||||
if member.name not in names:
|
||||
continue
|
||||
if member.name in metadata or not member.isfile() or member.size > LIMIT:
|
||||
raise ValueError("invalid archive metadata entry")
|
||||
with product.extractfile(member) as file:
|
||||
metadata[member.name] = file.read()
|
||||
if metadata.keys() != names:
|
||||
raise ValueError("archive is missing release metadata")
|
||||
info = json.loads(metadata[f"{top}/RELEASE_INFO.json"])
|
||||
sha = metadata[f"{top}/SOURCE_SHA"].decode("ascii").strip()
|
||||
if (info.get("schema") != "marqdo.release-info" or info.get("schema_version") != 1
|
||||
or info.get("product") != "marqdo-cli" or not SHA.fullmatch(sha)
|
||||
or info.get("source_sha") != sha or info.get("build_profile") != "release"
|
||||
or archive.name != f"marqdo-{info['product_version']}-{info['target_triple']}.tar.gz"):
|
||||
raise ValueError("archive identity disagrees with RELEASE_INFO or SOURCE_SHA")
|
||||
return info
|
||||
|
||||
|
||||
def bundle_dependencies(info: dict, receipt: dict) -> list[dict]:
|
||||
bundle = info["stdlib"]
|
||||
source = bundle.get("source", {})
|
||||
if (source.get("kind") != "ecosystem" or source.get("repository") != "cflmy/marqdo"
|
||||
or not SHA.fullmatch(source.get("commit", ""))
|
||||
or receipt.get("root_commit") != source["commit"]
|
||||
or any(receipt.get(field) != bundle[field]
|
||||
for field in ("name", "version", "tree_digest", "aliases_digest"))):
|
||||
raise ValueError("producer receipt mismatches the Bundle in the archive")
|
||||
components = receipt["components"]
|
||||
if not isinstance(components, list) or not 1 <= len(components) <= 256:
|
||||
raise ValueError("Bundle receipt must identify its contributing components")
|
||||
dependencies = {}
|
||||
for component in components:
|
||||
name, revision = component["id"], component["revision"]
|
||||
if not COMPONENT_ID.fullmatch(name) or name == "cli" or not SHA.fullmatch(revision) or name in dependencies:
|
||||
raise ValueError("invalid or duplicate Bundle component identity")
|
||||
dependencies[name] = revision
|
||||
return [{"id": name, "source_sha": sha} for name, sha in sorted(dependencies.items())]
|
||||
|
||||
|
||||
def evidence(archive: Path, receipt: dict, number: int) -> dict:
|
||||
info = archive_info(archive)
|
||||
dependencies = bundle_dependencies(info, receipt)
|
||||
checksum = archive.with_name(archive.name + ".sha256")
|
||||
digest = sha256_file(archive)
|
||||
if checksum.stat().st_size > LIMIT or checksum.read_text().split() != [digest, archive.name]:
|
||||
raise ValueError("archive checksum disagrees with the release asset")
|
||||
return {
|
||||
"component_id": "cli", "repository": REPOSITORY, "tag": f"v{info['product_version']}",
|
||||
"source_sha": info["source_sha"], "ci": verify_ci(info["source_sha"], number),
|
||||
"assets": [
|
||||
{"name": path.name, "target": info["target_triple"], "size": path.stat().st_size,
|
||||
"sha256": sha}
|
||||
for path, sha in ((archive, digest), (checksum, sha256_file(checksum)))
|
||||
],
|
||||
"dependencies": dependencies,
|
||||
}
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--archive", type=Path, required=True)
|
||||
parser.add_argument("--bundle-receipt", type=Path, required=True)
|
||||
parser.add_argument("--pipeline", type=int, required=True)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
with args.bundle_receipt.open("rb") as file:
|
||||
data = file.read(LIMIT + 1)
|
||||
if len(data) > LIMIT:
|
||||
raise ValueError("Bundle receipt exceeds size limit")
|
||||
index = evidence(args.archive, json.loads(data), args.pipeline)
|
||||
except (OSError, ValueError, TypeError, KeyError, AttributeError, tarfile.TarError) as error:
|
||||
parser.exit(1, f"release-index: {error}\n")
|
||||
print(json.dumps(index, indent=2))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+47
-1
@@ -9,7 +9,7 @@ Provider v2 worker (positive, unauthorized and missing-helper fail-closed), and
|
||||
strict mode when the host genuinely supports it.
|
||||
|
||||
Usage:
|
||||
python3 tools/release/smoke.py --archive dist/marqdo-3.0.0-rc.4-x86_64-unknown-linux-gnu.tar.gz
|
||||
python3 tools/release/smoke.py --archive dist/marqdo-3.0.0-rc.6-x86_64-unknown-linux-gnu.tar.gz
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -175,6 +175,51 @@ ANALYSIS_CASES = {
|
||||
}
|
||||
|
||||
|
||||
def verify_environment_report(
|
||||
runner: "Runner", install: Path, version: str, source_sha: str, info: dict
|
||||
) -> None:
|
||||
"""The packaged binaries must report their real release identity.
|
||||
|
||||
`inspect --environment` is the offline diagnostic export for feedback
|
||||
(marqdo-cli#26 §9.2). This also proves the archive was built from the
|
||||
recorded commit and ships the recorded Bundle, not a build-machine tree.
|
||||
"""
|
||||
report = runner.json(["inspect", "--environment"])
|
||||
if report.get("schema") != "marqdo.environment" or report.get("schema_version") != 1:
|
||||
fail("inspect --environment is not marqdo.environment v1")
|
||||
producer = report.get("producer", {})
|
||||
if producer.get("version") != version:
|
||||
fail("inspect --environment producer version does not match RELEASE_INFO.json")
|
||||
embedded = producer.get("source", {}).get("sha")
|
||||
if embedded != source_sha:
|
||||
fail(
|
||||
f"inspect --environment reports source {embedded!r}, expected {source_sha}; "
|
||||
"the archive was not built with MARQDO_BUILD_SOURCE_SHA"
|
||||
)
|
||||
worker = report.get("worker", {})
|
||||
if worker.get("status") != "present" or worker.get("source_sha") != source_sha:
|
||||
fail("the adjacent provider worker does not report the release commit")
|
||||
bundle = report.get("bundle", {})
|
||||
declared = info["stdlib"]
|
||||
if bundle.get("status") != "verified":
|
||||
fail("inspect --environment does not see the adjacent Bundle")
|
||||
for field in ("name", "version", "tree_digest"):
|
||||
if bundle.get(field) != declared.get(field):
|
||||
fail(
|
||||
f"inspect --environment bundle.{field} does not match RELEASE_INFO.json "
|
||||
f"({bundle.get(field)!r} != {declared.get(field)!r})"
|
||||
)
|
||||
if report.get("diagnostics"):
|
||||
fail(f"a verified installation must not report diagnostics: {report['diagnostics']}")
|
||||
text = json.dumps(report)
|
||||
if str(install) in text:
|
||||
fail("inspect --environment contains an absolute host path")
|
||||
lowered = text.lower()
|
||||
for forbidden in ("api_key", "password", "private key"):
|
||||
if forbidden in lowered:
|
||||
fail(f"inspect --environment contains forbidden field {forbidden!r}")
|
||||
|
||||
|
||||
def verify_analysis_metadata(protocols: dict) -> None:
|
||||
if protocols.get("analysis") != ANALYSIS_VERSION or "analysis_versions" in protocols:
|
||||
fail("RELEASE_INFO.json must identify only the current Analysis revision")
|
||||
@@ -263,6 +308,7 @@ def main(argv: list[str]) -> int:
|
||||
version_out = runner.run(["--version"]).stdout.strip()
|
||||
if version_out != f"marqdo {version}":
|
||||
fail(f"--version printed {version_out!r}, expected 'marqdo {version}'")
|
||||
verify_environment_report(runner, install, version, source_sha, info)
|
||||
runner.run(["--help"])
|
||||
runner.run(["check", "examples/multi-module/index.mq.md"])
|
||||
hello = runner.run(["run", "examples/hello.mq.md"]).stdout
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
"schema": "marqdo.stdlib-bundle-pin",
|
||||
"schema_version": 1,
|
||||
"name": "marqdo-stdlib",
|
||||
"version": "0.2.0",
|
||||
"version": "0.3.0",
|
||||
"source": {
|
||||
"kind": "ecosystem",
|
||||
"repository": "cflmy/marqdo",
|
||||
"commit": "48189243f747d5f73d5a38a565010e64e2db74e7",
|
||||
"commit": "ad88b1e9e50aec978cb23d4e5fe316bbb779967f",
|
||||
"producer": "scripts/build-stdlib.py",
|
||||
"note": "Phase B (ADR-0070): the accepted Bundle is assembled by the ecosystem root commit that pins the component gitlinks. No stdlib source tree exists in this repository."
|
||||
"note": "Phase B (ADR-0070): the accepted Bundle is assembled by the ecosystem root commit that pins the component gitlinks. 0.3.0 adds the merged std-data strict JSON entry; candidate root commit ad88b1e9 is the paired ecosystem input."
|
||||
},
|
||||
"tree_digest": "sha256:db905508dde89763b9d43b47fc5d52c6a1d5445a91f3c86a550ced43e8aac9d7",
|
||||
"tree_digest": "sha256:4e47b0ff4b1e17d252cc74f20837014298fed4831050d65ca0c69f9cbdac55e9",
|
||||
"aliases_digest": "sha256:5f513c0fdbb3c1e9829be3c9fa23a2d1e89cb8510073fb5eb1e8e2f5265a83bb"
|
||||
}
|
||||
Reference in new issue
Block a user