docs(release): packaging, examples, evidence and honest status matrix

- add packaging/tool.json, release archive and verification scripts, CI
  workflow and a mixed Markdown/OKF/Marqdo example
- record real T01 evidence: cold install in an isolated MARQDO_TOOL_HOME,
  dispatch, compile, query, check and remove against marqdo 3.0.0-rc.4
- refresh STATUS with implemented/tested areas and explicit NOT RUN items
  (real-model semantic quality, performance/retrieval benchmarks, non-Linux
  platforms, release-archive cold install, incremental write-volume benchmark)
- document OKF link-mode limitation, incremental write granularity and
  single-character query bounds in the current contract and architecture
- give every CLI option practical examples in --help
This commit is contained in:
marqdo-knowledge committed 2026-11-26 02:30:03 +08:00
1 parent 87b9c132aa
commit 172271fe62
16 files changed
+328 -43

No files matched your search

+21
View File
@@ -0,0 +1,21 @@
name: ci
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: "1.89"
components: rustfmt, clippy
- run: cargo fmt --all -- --check
- run: cargo clippy --all-targets --locked -- -D warnings
- run: cargo test --workspace --locked
- run: cargo build --release --locked
# A real core CLI is required for the integration lane; the pinned
# release archive and MARQDO_TEST_BIN are configured by the release
# environment. Without it, the optional integration tests report a skip.
- name: core CLI integration lane
if: env.MARQDO_TEST_BIN != ''
run: cargo test --test core_cli --test compile
+10 -7
View File
@@ -25,11 +25,13 @@ and no separate knowledge IR file.
## Status
This repository is an implementation in progress against the development
specification `marqdo-knowledge-development.md` (kept outside this repository's
source tree; the frozen contract is mirrored in [`spec/knowledge.md`](spec/knowledge.md)).
See [`docs/STATUS.md`](docs/STATUS.md) for the exact, evidence-based state of
each capability. **Do not infer unimplemented behavior from design documents.**
The first stable-version gate is not claimed. The implemented vertical path is
compile/check/query over plain Markdown, Marqdo Analysis v3 and OKF v0.3, with a
single rebuildable SQLite projection, exact/lexical/fuzzy/graph/semantic
channels, slices and explicit opt-in embeddings. [`docs/STATUS.md`](docs/STATUS.md)
is the authoritative capability matrix including **NOT RUN** items (real-model
semantic quality, performance benchmarks, non-Linux platforms, release-archive
cold install). **Do not infer unimplemented behavior from design documents.**
## Building
@@ -55,9 +57,10 @@ marqdo knowledge query QUERY [--root ROOT] [--exact] [--kind KIND] [--limit N]
[--format markdown|json] [--snapshot] [--semantic]
```
See [`spec/knowledge.md`](spec/knowledge.md) for the contract and
See [`spec/knowledge.md`](spec/knowledge.md) for the contract,
[`docs/architecture/OVERVIEW.md`](docs/architecture/OVERVIEW.md) for the
internal architecture.
internal architecture and [`docs/evidence/`](docs/evidence/) for executed
evidence. Release verification: `MARQDO_BIN=/path/to/marqdo scripts/verify-release.sh`.
## License
+58 -32
View File
@@ -1,49 +1,75 @@
# Status
Last updated: 2026-11-25. Evidence-based; this file lists what the code does,
not what the design intends. Anything not listed as verified is **NOT RUN** and
Last updated: 2026-11-26. Evidence-based: this file lists what the code does and
what was actually executed. Anything not listed as verified is **NOT RUN** and
must not be claimed as passing.
The development baseline is `marqdo-knowledge-development.md` (kept outside
this repository). Upstream Analysis baseline for integration is
`cflmy/marqdo-cli` `3.0.0-rc.4` (`4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`),
contract `marqdo.analysis` revision 3. The original static audit in the
development specification refers to `e6066e6`; the current public boundary has
since been implemented upstream as ADR-0069, so this tool targets the current
revision-3 shape and rejects everything else.
## Baselines
## Capability matrix
- Development specification: `marqdo-knowledge-development.md` (outside this
repository).
- Core CLI integration: `cflmy/marqdo-cli` `3.0.0-rc.4`
(`4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`), `marqdo.analysis` revision 3,
`marqdo.cli-tool` revision 1, tool API revision 1.
- Committed Analysis fixture: `tests/fixtures/analysis/mechanics.json`, produced
by the real rc.4 binary (provenance in that directory's README).
## Implemented and tested
| Area | State | Evidence |
|---|---|---|
| Repository scaffold, CLI surface, exit codes | implemented | unit tests in `src/cli.rs` |
| Discovery, snapshot, budgets | in progress | - |
| Plain Markdown projection | in progress | - |
| Analysis v3 adapter + semantic validation | in progress | - |
| Unified graph and reference resolution | in progress | - |
| SQLite schema, transactions, atomic publish | in progress | - |
| Compile command | in progress | - |
| Lexical / fuzzy / graph query, RRF | in progress | - |
| Slices | in progress | - |
| Incremental update | in progress | - |
| OKF v0.3 recognition and check | in progress | - |
| Semantic channel (OpenAI-compatible embeddings) | in progress | - |
| Packaging (`tool.json`, release script) | in progress | - |
| Performance / retrieval benchmarks | NOT RUN | no frozen dataset yet |
| Real-model semantic benchmark | NOT RUN | requires a pinned model revision not available in this environment |
| Cold install against a real `marqdo` binary | NOT RUN | - |
| Deterministic discovery, boundaries, budgets, snapshot digests | implemented | `src/document/discovery.rs` tests |
| Plain CommonMark/GFM projection with exact UTF-8 byte spans | implemented | `src/document/markdown.rs` tests |
| Analysis v3 closed-shape + semantic validation, tamper negatives | implemented | `src/document/analysis.rs` tests, committed real fixture |
| Core CLI process boundary, timeout, temp artifact, sanitisation | implemented | `tests/core_cli.rs` against real rc.4 binary |
| Unified graph, identities, exact reference resolution, statements/resources | implemented | `src/graph/*` tests |
| Single SQLite projection, constraints, atomic rebuild, transactional update, foreign-db refusal | implemented | `src/storage/*` tests, `tests/storage.rs` |
| Derived FTS5 (CJK bigram) + gram + embedding indexes | implemented | `tests/storage.rs`, `tests/embedding.rs` |
| Compile command incl. digest-based incremental facts reuse and conservative re-analysis bound | implemented | `tests/compile.rs` |
| Check command (sources, references, database structure/currentness) | implemented | `tests/compile.rs`, `tests/query.rs` |
| Exact / lexical / fuzzy / graph query, weighted RRF, bounded expansion | implemented | `src/query/*` tests, `tests/query.rs` |
| Document / execution / hybrid slices with 32 KiB budget | implemented | `tests/query.rs`, `src/query/slice.rs` |
| OKF v0.3 metadata recognition, reserved roles, concept aliases, `check --okf` conformance | implemented | `tests/okf.rs` |
| Explicit OpenAI-compatible semantic channel with all-or-nothing indexing | implemented | `tests/embedding.rs` (local mock protocol server) |
| Real `marqdo tool install` / dispatch / compile / query / check / remove (T01) | verified | cold install in isolated `MARQDO_TOOL_HOME` on 2026-11-26 with rc.4 |
| Packaging (`tool.json`, release archive script), CI workflow | implemented | `packaging/tool.json`, `scripts/package-release.sh`, `.github/workflows/ci.yml` |
## Known limitations
## NOT RUN / not verified
* Linux x86_64 is the only release-candidate platform.
* The exact quality/performance gates of the development specification §16 are
not yet measured; no threshold is claimed.
| Item | Reason |
|---|---|
| Real-model semantic quality benchmark (§8.3/§16) | Requires a pinned open model revision and weights; only a protocol mock ran here. No semantic quality claim is made. |
| §16 retrieval/performance benchmarks (Recall@10, MRR, latency, RSS) | Frozen multi-domain dataset and reference hardware not available in this environment; no threshold claimed. |
| Windows/macOS native testing | Release candidate platform is Linux x86_64 only. |
| Upstream batch `--documents` Analysis interface (U01) | Current upstream exposes per-entry `check --emit`; this tool invokes it per `.mq.md` entry and merges contexts, as the specification permits for the development stage. |
| Release archive built and cold-installed from the archive | `scripts/package-release.sh` exists; the archive lane is not part of the executed evidence above. |
| Incremental write-granularity benchmark | Incremental compiles reuse facts (no re-analysis for plain-only edits) but rewrite the projection inside one transaction; the specification's write-count benchmark has not been run. |
## Known limitations (explicit, not hidden)
- **OKF root-absolute links** (`/path.md`) are given OKF semantics only in
`check --okf`; `compile` has no `--okf` flag and keeps Native semantics, so a
root-absolute link in a compiled OKF bundle is reported `out_of_scope` rather
than resolved. Relative OKF links and `resource` fields are resolved in both.
- **Incremental write granularity**: rows for the whole projection are rewritten
in the transaction. Semantics are equal to a full build and Analysis is not
re-run when only plain documents changed, but the write-volume benchmark is
unmeasured.
- **Semantic quality**: only the protocol, validation, storage, reuse and fusion
are tested; retrieval quality depends entirely on the user-supplied model.
- **Exact single-character CJK queries** use a bounded title/symbol/body probe
and report truncation; they are not a complete index scan.
- **No migration**: any schema revision change requires `compile --rebuild`.
## Reproduce
```sh
scripts/cargo.sh fmt --all -- --check
scripts/cargo.sh clippy --all-targets -- -D warnings
scripts/cargo.sh test
scripts/cargo.sh build --release
scripts/cargo.sh test --workspace --locked
scripts/cargo.sh build --release --locked
# Optional real-core integration lane:
MARQDO_TEST_BIN=/path/to/marqdo cargo test --test core_cli --test compile
# Full local release verification (requires real marqdo):
MARQDO_BIN=/path/to/marqdo scripts/verify-release.sh
```
+4 -2
View File
@@ -174,9 +174,9 @@ database loses nothing.
4. Optional semantic channel: OpenAI-compatible `POST /embeddings`, explicit
opt-in, vectors stored as float32 BLOBs and invalidated on config change.
5. Weighted Reciprocal Rank Fusion per search unit, then per node.
6. Bounded graph expansion from high-ranked seeds (depth, relations, reverse,
7. Bounded graph expansion from high-ranked seeds (depth, relations, reverse,
node/edge budgets, decay) with `truncated` reported honestly.
7. Slices: document (contains + references), execution (calls + imports),
8. Slices: document (contains + references), execution (calls + imports),
hybrid; deterministic byte budget, original source text only.
Fuzzy/semantic recall may be approximate. Identity and binding never are.
@@ -204,6 +204,8 @@ Fuzzy/semantic recall may be approximate. Identity and binding never are.
| `src/graph/` | identity, node/edge building, reference/call resolution |
| `src/storage/` | SQLite schema, transactions, read/write APIs, indexes |
| `src/query/` | search, fuzzy, semantic, fusion, graph expansion, slices |
| `src/embedding.rs` | opt-in OpenAI-compatible embeddings transport, response validation, vector reuse |
| `src/text.rs` | search normalisation/tokenisation shared by index and query |
| `src/model.rs` | shared typed domain values |
| `src/diagnostic.rs` | diagnostic codes and deterministic collections |
| `src/error.rs` | unified error and exit semantics |
@@ -0,0 +1,65 @@
# Evidence: implementation run 2026-11-26
Environment: Linux x86_64, Rust 1.100.0 (toolchain stable, crate MSRV 1.89),
`cargo --locked`. Core CLI for integration:
`cflmy/marqdo-cli` `3.0.0-rc.4` at
`4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`, binary built by that checkout
(`marqdo 3.0.0-rc.4`, Analysis revision 3).
## Test counts (executed)
```text
cargo test --workspace --locked
lib unit tests: 104 passed
tests/compile.rs: 6 passed
tests/core_cli.rs: 3 passed (MARQDO_TEST_BIN=real marqdo)
tests/embedding.rs: 4 passed (local mock embeddings server)
tests/okf.rs: 7 passed
tests/query.rs: 11 passed
tests/storage.rs: 4 passed
doc tests: 0
```
`cargo clippy --all-targets -- -D warnings` and `cargo fmt --all -- --check`
are clean in this tree at the recorded commits.
## Real tool install / dispatch (T01)
Performed with an isolated `MARQDO_TOOL_HOME` and the real core CLI:
```sh
$MARQDO tool install <staged-dir> # tool.json + bin/marqdo-knowledge
$MARQDO tool list # knowledge 0.1.0 (marqdo-knowledge)
$MARQDO knowledge --help # dispatched, no core start-up side effects
$MARQDO knowledge compile ./examples/mixed --json
payload: documents=5 nodes=15 edges=15 search_units=13 grams=235
$MARQDO knowledge query '归一' --root ./examples/mixed --format json
channels: lexical, fuzzy, graph hits > 0
$MARQDO knowledge check ./examples/mixed --json
database: current errors: 0
$MARQDO tool remove knowledge
$MARQDO tool list # no tools installed
```
The dispatch preserved argv/cwd and set `MARQDO_BIN`/`MARQDO_API_REVISION` as
specified; no shell interpolation was used.
## Real Analysis integration
- `tests/core_cli.rs` invokes the real `check --emit` for a valid project
(validated, converted, function node present) and for an invalid `.mq.md`
(invocation fails, no artifact, no fabricated callable).
- `tests/compile.rs::mixed_project_uses_real_analysis_when_available` compiles a
mixed root through real Analysis: 1 context, real producer version, callable
function metadata with the upstream FunctionId, and a plain-Markdown link into
the Marqdo module resolving to the anchored node.
- Negative validator tests tamper the committed real fixture (digest, span,
revision, missing/unknown fields, error diagnostics, duplicate module,
resolved-without-target) and require rejection.
## Not covered by this evidence
- No real embedding model was invoked; the semantic lane used a local protocol
mock. No semantic-quality number is claimed.
- No retrieval/performance benchmark was run.
- Windows/macOS were not tested.
+7
View File
@@ -0,0 +1,7 @@
# Mixed example
A small knowledge root that mixes ordinary Markdown, OKF metadata and a Marqdo
document. `marqdo knowledge compile examples/mixed` creates one derived SQLite
artifact; the Markdown files are never modified.
Requires a `marqdo` core CLI with Analysis revision 3 (3.0.0-rc.4 or later).
+5
View File
@@ -0,0 +1,5 @@
project:
name: mixed-example
version: 0.1.0
marqdo: ">=3.0.0-beta.1,<4.0.0"
dependencies: {}
+7
View File
@@ -0,0 +1,7 @@
# 笔记
概率归一化是常见操作,参见[经典力学](physics/mechanics.mq.md#经典力学)。
## 归一化
消除向量模长影响。
+10
View File
@@ -0,0 +1,10 @@
---
type: Glossary
title: 术语
description: 常用术语
tags: [glossary]
---
# 术语
- **归一化**:消除尺度影响。
+4
View File
@@ -0,0 +1,4 @@
# Mixed example bundle
- [经典力学](../physics/mechanics.mq.md) - 理论
- [笔记](../notes.md) - 普通知识
+30
View File
@@ -0,0 +1,30 @@
---
type: Theory
title: 经典力学
tags: [physics, mechanics]
---
# 经典力学
## @knowledge 牛顿第二定律
合外力等于质量与加速度的乘积。
$$
F = ma
$$
| 符号 | 含义 |
| --- | --- |
| m | 质量 |
| a | 加速度 |
计算入口:[计算力](#计算力)。
## @exec 计算力
`params(m, a)`
依据[牛顿第二定律](#牛顿第二定律)。
`return m * a`
+9
View File
@@ -0,0 +1,9 @@
{
"schema": "marqdo.cli-tool",
"schema_version": 1,
"name": "marqdo-knowledge",
"version": "0.1.0",
"command": "knowledge",
"entrypoint": "bin/marqdo-knowledge",
"requires": {"api_revision": 1, "analysis": 3}
}
+24
View File
@@ -0,0 +1,24 @@
#!/bin/sh
# Build and package a release archive with tool.json and the binary entrypoint.
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)
TARGET=${TARGET:-x86_64-unknown-linux-gnu}
DIST="$ROOT/dist/marqdo-knowledge-$VERSION-$TARGET"
rm -rf "$DIST"
mkdir -p "$DIST/bin"
"$ROOT/scripts/cargo.sh" build --release --locked
cp "$ROOT/target/release/marqdo-knowledge" "$DIST/bin/marqdo-knowledge"
chmod 755 "$DIST/bin/marqdo-knowledge"
cp "$ROOT/packaging/tool.json" "$DIST/tool.json"
cp "$ROOT/README.md" "$ROOT/LICENSE-APACHE" "$DIST/"
mkdir -p "$DIST/docs" "$DIST/spec"
cp -r "$ROOT/docs/STATUS.md" "$ROOT/docs/architecture" "$DIST/docs/"
cp -r "$ROOT/spec/knowledge.md" "$DIST/spec/"
ARCHIVE="$DIST.tar.gz"
tar -C "$(dirname "$DIST")" -czf "$ARCHIVE" "$(basename "$DIST")"
( cd "$(dirname "$ARCHIVE")" && sha256sum "$(basename "$ARCHIVE")" > "$(basename "$ARCHIVE").sha256" )
printf 'archive: %s\n' "$ARCHIVE"
cat "$ARCHIVE.sha256"
+31
View File
@@ -0,0 +1,31 @@
#!/bin/sh
# Reproducible local release verification. Requires a real marqdo CLI path.
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
MARQDO=${MARQDO_BIN:?set MARQDO_BIN to the core marqdo binary}
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' "$ROOT/Cargo.toml" | head -1)
cd "$ROOT"
scripts/cargo.sh fmt --all -- --check
scripts/cargo.sh clippy --all-targets -- -D warnings
scripts/cargo.sh test --workspace --locked
scripts/cargo.sh build --release --locked
# Cold tool install in an isolated tool home.
TOOL_HOME=$(mktemp -d)
export MARQDO_TOOL_HOME="$TOOL_HOME"
trap 'rm -rf "$TOOL_HOME"' EXIT
"$MARQDO" tool install "$ROOT/packaging" >/dev/null 2>&1 || {
# packaging/tool.json expects bin/marqdo-knowledge; stage it.
STAGE=$(mktemp -d)
mkdir -p "$STAGE/bin"
cp "$ROOT/packaging/tool.json" "$STAGE/tool.json"
cp "$ROOT/target/release/marqdo-knowledge" "$STAGE/bin/marqdo-knowledge"
"$MARQDO" tool install "$STAGE"
}
"$MARQDO" knowledge --help >/dev/null
"$MARQDO" knowledge compile "$ROOT/examples/mixed" --json >/tmp/knowledge-compile.json
"$MARQDO" knowledge query '量子归一话' --root "$ROOT/examples/mixed" --format json >/tmp/knowledge-query.json
"$MARQDO" knowledge check "$ROOT/examples/mixed" --json >/tmp/knowledge-check.json
"$MARQDO" tool remove knowledge
printf 'verify-release: ok (v%s, core %s)\n' "$VERSION" "$("$MARQDO" --version)"
+41 -1
View File
@@ -125,7 +125,29 @@ carry no fabricated path, span or snippet.
Machine mode never emits partial JSON on stdout. Diagnostics are also reported
on stderr as human lines with stable `knowledge.*` codes.
## 4. Analysis input
## 3.3 Semantic mode
`--semantic` is the only network path. It requires compile-time and query-time
options to match exactly (sanitised endpoint, model, revision, dimension); the
API key is read from `MARQDO_KNOWLEDGE_EMBEDDING_API_KEY` and is never stored or
printed. Remote endpoints must be HTTPS and require
`--allow-remote-embedding`; loopback HTTP is allowed for a local compatible
service. A failed or incomplete embedding run publishes nothing and leaves the
previous artifact intact. Semantic results are explicitly marked in `channels`;
their quality depends on the user-supplied model and is not a correctness score.
## 4. OKF (document layer)
OKF v0.3 is recognised from front matter only: `index.md`/`log.md` are reserved
roles at every level, other documents with a non-empty `type` are concepts
(concept id = bundle-relative path without `.md`, mapped to the document node),
unknown keys/types are preserved and tolerated, and `resource` is the only
metadata field treated as a path. Compile has no `--okf` flag and keeps Native
link semantics; `check --okf` additionally applies OKF bundle-root absolute
link semantics and reports conformance/notice diagnostics. OKF never executes an
executor or attester and never upgrades trust.
## 5. Analysis input
Marqdo program semantics come only from the core CLI:
@@ -144,6 +166,14 @@ CommonMark/GFM/footnote options and never gain executable semantics.
## 5. Databases and freshness
Incremental compiles reuse digest-guarded normalised facts for unchanged
documents and never re-run Analysis when only plain Markdown changed. Any
`.mq.md`/manifest/lock/core-identity change re-runs Analysis conservatively. The
projection rows are then rewritten and committed in one transaction, so
incremental semantics equal a full compile; the write-volume benchmark is not
yet measured.
The database stores one `build` row with:
* application id and schema revision;
@@ -159,6 +189,16 @@ rejected with a rebuild instruction; nothing is migrated or overwritten. A
`knowledge.database_stale` unless `--snapshot` is supplied, in which case the
result states `current: false` and the snapshot digest.
## 5.1 Known limitations
* OKF bundle-root absolute links are only resolved by `check --okf`; compiled
Native knowledge reports them `out_of_scope`.
* Single-character CJK queries use a bounded title/symbol/body probe and may be
truncated; they are not exhaustive.
* No schema migration: a schema revision change requires `compile --rebuild`.
* Semantic retrieval quality requires a real model; only protocol, validation,
storage and fusion are covered by this repository's tests.
## 6. Vocabulary
Resolution states: `resolved`, `not_loaded`, `missing`, `ambiguous`, `external`,
+2 -1
View File
@@ -18,7 +18,8 @@ use std::path::PathBuf;
about = "Compile Markdown and Marqdo documents into a deterministic, queryable knowledge projection.",
long_about = None,
disable_help_subcommand = true,
propagate_version = true
propagate_version = true,
after_help = "Examples:\n marqdo knowledge compile . --json\n marqdo knowledge query '如何判断量子态是否合法' --kind function\n marqdo knowledge query '归一化检查' --format json --limit 5\n marqdo knowledge query '<canonical-id>' --slice document\n marqdo knowledge check . --okf --json\n marqdo knowledge compile . --embedding-url http://127.0.0.1:8080/v1 --embedding-model MODEL --embedding-revision REV\n marqdo knowledge query '消除向量模长影响' --semantic --embedding-url http://127.0.0.1:8080/v1 --embedding-model MODEL --embedding-revision REV"
)]
pub struct Cli {
/// Core Marqdo binary used for static Analysis (`check --emit`).