Implements the two CLI-owned P0 sub-issues of the ecosystem architecture tickets without adding document-language syntax. Environment report (marqdo-cli#26 §9.2, binding for #20): - `marqdo inspect --environment [--json]` emits `marqdo.environment` v1: producer version and build-embedded source commit, platform/arch/glibc and real strict probe, adjacent provider-worker version/SHA (offline `--build-info`, bounded), verified Bundle identity, current protocol revisions and path-free diagnostics. Project-independent, offline, and exclusive with document inspection flags. - Release builds embed `MARQDO_BUILD_SOURCE_SHA`; the CI `build` lane sets it. `tools/release/package.py` refuses to stage an archive whose binaries report another commit or Bundle digest, and `tools/release/smoke.py` re-verifies the extracted archive. - Spec: `spec/environment.md`. Tests: `environment_report.rs` (5 cases) and in-module unit tests; docs/releasing/COMPATIBILITY/STATUS updated. Document-structure contract (marqdo-cli#25): - `spec/document-structure.md` states the current author/tool semantics once: heading mode inheritance (nearest ancestor, only Exec H2 callable), unit identity and duplicate-name rules, anchor collision numbering, byte-exact half-open spans, `index.mq.md` entry vs directory-dependency import meaning, link != import != call, Proposed annotations marked not implemented, and the Analysis fields consumers may rely on. It links the single authoritative specs instead of duplicating them. - Tests: `document_structure.rs` (6 cases) + docs_consistency coverage. No runtime behavior change, no new language surface, no new cross-repo dependency. `docs_consistency` and `architecture_boundaries` remain green.
182 lines
7.8 KiB
Markdown
182 lines
7.8 KiB
Markdown
# 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.2.0",
|
|
"tree_digest": "sha256:...",
|
|
"instance_id": "stdlib:marqdo-stdlib@0.2.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.
|