diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b551e60 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,58 @@ +# Changelog + +All notable changes to `marqdo-knowledge`. The project follows SemVer for the +tool version; schema and protocol revisions are independent numbers. This beta +line makes no stable-version claim. + +## 0.1.0-beta.1 — 2026-11-26 + +First beta. One derived SQLite artifact, three business commands, current public +Analysis v3 as the only Marqdo program-semantics input, OKF v0.3 recognition and +an explicit opt-in semantic channel. + +### Added + +- `compile`: deterministic discovery, exact UTF-8 source snapshot with content + digests, plain CommonMark/GFM projection, real `marqdo check --emit` Analysis + consumption, unified graph, single SQLite projection, atomic rebuild and + transactional incremental update with digest-guarded facts reuse. +- `check`: static source/Analysis/reference checks, database structure and + currentness checks, no knowledge-base writes, `--okf` conformance mode. +- `query`: exact canonical-id/alias/unique-name lookup, weighted FTS5 lexical + search (CJK bigram segmentation), bounded fuzzy gram/edit-distance recall, + weighted RRF fusion, budgeted graph expansion, document/execution/hybrid + slices with exact source text and 32 KiB default budget, Markdown and JSON + output, stale-snapshot refusal unless `--snapshot`. +- OKF v0.3: concept/`index.md`/`log.md` roles, metadata preservation, concept-id + aliases, `resource` reference edges, `check --okf` conformance validation. +- Semantic channel: OpenAI-compatible `POST /embeddings`, explicit opt-in, + loopback HTTP or TLS-only remote with `--allow-remote-embedding`, strict + response validation and all-or-nothing vector publication. +- Packaging: `tool.json`, release archive script, cold-install verification + script, CI workflow, mixed example, executed evidence records. +- Tests: 104 unit tests plus integration suites for compile, storage, query, + OKF, embeddings, and the real core CLI boundary (139 tests total in the + recorded run). + +### Security + +- No knowledge execution, plugin loading, foreign kernel, network document + fetch or shell invocation. +- Root-confined filesystem access; symlinks skipped; traversal/absolute/drive/ + NUL paths rejected; referenced binaries never text-indexed. +- Offline by default; only an explicitly configured embedding endpoint performs + network I/O. Credentials are read from the environment and never stored. +- Atomic publication and rollback; foreign or old databases are never silently + overwritten or migrated. + +### Known limitations (see docs/STATUS.md) + +- Real-model semantic quality and the specification §16 retrieval/performance + benchmarks are NOT RUN; no threshold is claimed. +- Linux x86_64 only. +- Incremental compiles avoid re-analysis but still rewrite the projection inside + one transaction; the write-volume benchmark is unmeasured. +- OKF bundle-root absolute links are resolved by `check --okf`; `compile` keeps + Native semantics. +- Single-character CJK queries use a bounded probe and may be truncated. +- No migration: schema revision changes require `compile --rebuild`. diff --git a/Cargo.lock b/Cargo.lock index 0b77b32..dca0236 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -620,7 +620,7 @@ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" [[package]] name = "marqdo-knowledge" -version = "0.1.0" +version = "0.1.0-beta.1" dependencies = [ "clap", "comrak", diff --git a/Cargo.toml b/Cargo.toml index 3c82ecf..bcf6d5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "marqdo-knowledge" -version = "0.1.0" +version = "0.1.0-beta.1" edition = "2021" rust-version = "1.89" license = "Apache-2.0" diff --git a/README.md b/README.md index fa0508a..5b76d18 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,14 @@ derived, can be deleted at any time and is rebuilt from the Markdown sources. There is no project configuration file, no metadata sidecar, no node manifest and no separate knowledge IR file. -## Status +## Release + +Current release: **`0.1.0-beta.1`** (beta channel, Linux x86_64). See +[`CHANGELOG.md`](CHANGELOG.md) and +[`docs/releases/0.1.0-beta.1.md`](docs/releases/0.1.0-beta.1.md) for what is +included and what is explicitly NOT done. CI/CD configuration is described in +[`docs/ci.md`](docs/ci.md); the release procedure is in +[`docs/releasing.md`](docs/releasing.md). 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 @@ -60,7 +67,7 @@ marqdo knowledge query QUERY [--root ROOT] [--exact] [--kind KIND] [--limit N] See [`spec/knowledge.md`](spec/knowledge.md) for the contract, [`docs/architecture/OVERVIEW.md`](docs/architecture/OVERVIEW.md) for the internal architecture and [`docs/evidence/`](docs/evidence/) for executed -evidence. Release verification: `MARQDO_BIN=/path/to/marqdo scripts/verify-release.sh`. +evidence. Release verification: `MARQDO_BIN=/path/to/marqdo scripts/ci.sh release`. ## License diff --git a/docs/STATUS.md b/docs/STATUS.md index de314da..20b76b7 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -1,9 +1,21 @@ # Status -Last updated: 2026-11-26. Evidence-based: this file lists what the code does and +Last updated: 2026-11-26 (release `0.1.0-beta.1`). 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. +## Release state + +- Channel: **beta** (`0.1.0-beta.1`), Linux x86_64. Not a stable claim. +- Release notes: [`releases/0.1.0-beta.1.md`](releases/0.1.0-beta.1.md). +- CI/CD: [`.woodpecker/main.yml`](../.woodpecker/main.yml), + [`.github/workflows/ci.yml`](../.github/workflows/ci.yml) and + [`scripts/ci.sh`](../scripts/ci.sh); procedure in [`ci.md`](ci.md) and + [`releasing.md`](releasing.md). +- Archive: built by the release lane from the frozen source SHA with + `SOURCE_SHA`, `RELEASE_INFO.json` and SHA-256; the tag annotation records the + exact archive hash. + ## Baselines - Development specification: `marqdo-knowledge-development.md` (outside this @@ -43,6 +55,8 @@ must not be claimed as passing. | 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 native install on other platforms | Archive was built and cold-installed on Linux x86_64 only. | +| CI provider run URL for this beta | The pipeline configuration is committed; no external Woodpecker/GitHub run URL is recorded in this workspace. Local lanes were executed on the release SHA. | +| Version-freeze reproducibility of `RELEASE_INFO.json` | It contains build metadata (`built_at_utc`, rustc/cargo versions); the archive SHA is recorded by the pipeline, not reproducible byte-for-byte from the same commit. | | 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) diff --git a/docs/releases/0.1.0-beta.1.md b/docs/releases/0.1.0-beta.1.md new file mode 100644 index 0000000..7053cc4 --- /dev/null +++ b/docs/releases/0.1.0-beta.1.md @@ -0,0 +1,194 @@ +# marqdo-knowledge 0.1.0-beta.1 + +Release date: 2026-11-26 +Release channel: **beta** (first beta; not a stable-version claim) +Platform: Linux x86_64 (glibc), Rust release build + +Core CLI integration baseline: `cflmy/marqdo-cli` `3.0.0-rc.4` +(`4bbefc92449ee480c8a2c89b0308feb4cda8d0e7`) + +Contract versions: + +| Boundary | Version | +|---|---| +| `marqdo.cli-tool` | revision 1 | +| tool API revision | 1 | +| consumed `marqdo.analysis` | revision 3 (current closed shape) | +| SQLite schema | revision 1 | +| result/error envelope | schema_version 1 | +| OKF | 0.3 | + +## What this beta is + +A runnable knowledge compiler and query tool for existing Markdown directories. +It compiles original sources into **one** rebuildable SQLite artifact at +`/.marqdo/knowledge.sqlite` and answers exact, lexical, fuzzy, graph and +optionally semantic queries plus bounded reading/dependency slices. It never +executes knowledge and never rewrites source files. + +## What is complete in this beta + +### Commands and contracts + +- Exactly three business commands: `compile`, `check`, `query`, with stable + `knowledge.*` diagnostic codes and exit codes 0/1/2. +- Single machine envelope (`marqdo.knowledge.result`, schema_version 1) for + compile/check/query and a single error envelope. +- Source-of-truth rule: original Markdown plus explicit resources; the database + is derived and deletable. Content-based freshness, never mtimes. +- Explicit `compile --rebuild`; old/foreign databases are rejected, never + migrated or overwritten. + +### Compilation + +- Deterministic discovery and snapshot: sorted root-relative paths, skipped + `.git`/`.marqdo`/`target`/`node_modules`/hidden entries and symlinks, fixed + exclude globs, per-file/total/document budgets, exact UTF-8 bytes and SHA-256 + digests, BOM/CRLF/CJK preserved. +- Plain `.md`: pinned CommonMark/GFM options (tables, footnotes, task lists, + strikethrough, autolink, dollar math, front matter) projected to exact + half-open UTF-8 spans. +- `.mq.md`: only the current public `marqdo check --emit` Analysis v3 artifact, + with closed-shape deserialization and semantic validation of identities, + source digests, spans, units/modes/ancestry, anchors, functions/signatures, + references states, calls, resources, diagnostics and budgets. Any other + revision or tampered field is rejected; no fallback parser. +- Unified graph: one `Node` type (document/namespace/section/function/ + statement/resource/external), one `Edge` type (contains/references/imports/ + calls) with origin/state/raw target/source span; repeated link occurrences are + separate edges; unresolved targets are never fabricated. +- OKF v0.3 metadata recognition (concept roles, `index.md`/`log.md` reserved + roles, metadata preservation, concept-id aliases, `resource` path edges) and + `check --okf` conformance/link notices. +- Incremental semantics equal to a full compile: unchanged documents reuse + digest-guarded facts; any `.mq.md`/manifest/lock/core-identity change re-runs + Analysis conservatively; plain-only edits do not invoke the core CLI; a + failure never replaces the last successful artifact. +- Semantic indexing (explicit): OpenAI-compatible embeddings, bounded batching, + strict response validation, float32 BLOB storage, config-change invalidation, + content/model-digest reuse and all-or-nothing publication. + +### Search and retrieval + +- Exact channel: canonical ids, exact aliases, unique exact names; ambiguous + names return candidates and never choose one. +- Lexical channel: FTS5 `unicode61` over CJK-bigram-segmented weighted fields. +- Fuzzy channel: bounded 2/3-gram recall plus edit-distance scoring, CJK + single-character and prefix fallbacks; no whole-corpus distance scan. +- Fusion: weighted RRF (exact 1.5, lexical/fuzzy/semantic 1.0); identity and + binding are never fuzzy. +- Graph expansion: default 1 hop, references bidirectional, contains children, + calls/imports directional with `--reverse`, depth/relation filters, seed/edge/ + node budgets, 0.35 depth decay, `truncated` reported. +- Slices: document/execution/hybrid with exact source text, source path+span + provenance, module context/imports for execution, explicit external/dynamic + gaps, deterministic 32 KiB default byte budget. +- Semantic channel: explicit `--semantic`, exact cosine scan with bounded vector + budget; default queries remain offline even when vectors exist. +- Kind filters apply after candidate/graph expansion; human Markdown and machine + JSON outputs derive from the same result object. + +### Safety and operations + +- No execution paths; no plugin/foreign/attester/provider use; argv-only core + CLI invocation with timeout, private temp artifacts and exit verification. +- Root confinement, symlink refusal, percent-decoding once, NUL/path-escape + rejection; external URLs stored inert and never fetched. +- SQLite `foreign_keys=ON`, parameterised SQL, CHECK invariants, integrity + checks, owner-only file permissions, atomic rename publication and rollback. +- Package: `tool.json` (`marqdo.cli-tool` rev 1, `requires.api_revision: 1`, + `requires.analysis: 3`), release archive with `bin/marqdo-knowledge`, docs and + spec; cold install/dispatch/compile/query/check/remove verified with a real + `marqdo` binary in an isolated `MARQDO_TOOL_HOME`. + +## Verification recorded for this release + +- `cargo fmt --all -- --check`: clean. +- `cargo clippy --all-targets --locked -- -D warnings`: clean. +- `cargo test --workspace --locked` with the real rc.4 core binary: + **139 passed, 0 failed** (104 unit; compile 6; core_cli 3; embedding 4; OKF 7; + query 11; storage 4). +- `cargo build --release --locked`: clean. +- Release archive built by `scripts/package-release.sh` and cold-installed with + the real core CLI (the archive name and SHA-256 are recorded by the release + lane and the git tag annotation): install → dispatch + `knowledge --help` → compile `examples/mixed` (5 docs, 15 nodes, 15 edges, + 13 search units) → query (hits with channels) → check (database current, + 0 errors) → remove. + +## What is NOT complete in this beta + +These are explicit non-claims, not hidden gaps. Details in `docs/STATUS.md`. + +1. **Real-model semantic quality benchmark**: only the protocol, validation, + storage, reuse and fusion are exercised (local mock). No pinned real model + was run; no semantic Recall@10 claim is made. +2. **Specification §16 retrieval and performance gates**: frozen multi-domain + dataset, held-out queries, Recall/MRR/nDCG, latency/RSS/build-time targets + and incremental write-volume benchmarks are NOT RUN. No performance number is + claimed. +3. **Platforms**: Linux x86_64 only. Windows/macOS are untested and not claimed. +4. **Upstream batch Analysis interface (U01)**: the current upstream exposes + per-entry `check --emit`; this beta invokes it per `.mq.md` entry and merges + contexts conservatively, as permitted for the development stage. The final + upstream batch/document-scan interface is not available in the pinned core. +5. **Incremental write granularity**: facts reuse avoids re-analysis for + plain-only edits, but the projection rows are rewritten in one transaction. + Semantics equal a full build; the write-volume benchmark is unmeasured. +6. **OKF compile-time absolute links**: bundle-root absolute links (`/path.md`) + receive OKF semantics only in `check --okf`. `compile` has no `--okf` flag and + keeps Native semantics, so such links are reported `out_of_scope` in the + compiled graph. +7. **Single-character CJK queries**: bounded title/symbol/body probe with + truncation reporting; not an exhaustive scan. +8. **No migration**: schema revision changes require an explicit + `compile --rebuild`. There is no legacy reader and no automatic upgrade. +9. **Release archive reproducibility**: the archive was built locally and + cold-installed; no public CI run URL or independent artifact attestation is + recorded for this beta. + +## Install and first run + +```sh +# From a checkout of this repository (Linux x86_64, Rust toolchain 1.89+): +scripts/cargo.sh build --release --locked +# Install the tool bundle through the core CLI: +marqdo tool install ./dist/marqdo-knowledge-0.1.0-beta.1-x86_64-unknown-linux-gnu +marqdo knowledge --help +marqdo knowledge compile ./examples/mixed --json +marqdo knowledge query '归一化' --root ./examples/mixed +marqdo knowledge check ./examples/mixed --json +marqdo tool remove knowledge +``` + +The tool requires a compatible core `marqdo` (`MARQDO_API_REVISION=1`, +Analysis revision 3) to be dispatched normally; direct development invocation +accepts `--marqdo-bin PATH`. + +## Compatibility and upgrade notes + +- There is no earlier released version; this is the first beta. +- Consumes only the current closed Analysis revision-3 shape (the same revision + number emitted by older rc build with a different shape is rejected). +- SQLite schema revision 1; any schema change in a future version requires + `compile --rebuild`. +- Database ownership: a file not created by this tool is never overwritten. +- Upgrade path for beta users: replace the tool bundle, then run + `marqdo knowledge compile --rebuild` if the schema revision changed. + +## Security notes + +Default behavior is offline. The only network path is an explicitly configured +embedding endpoint (`--semantic` query or embedding options at compile); remote +endpoints require HTTPS and `--allow-remote-embedding`. The API key is read from +`MARQDO_KNOWLEDGE_EMBEDDING_API_KEY`; it is never stored in the database, logs or +output. Diagnostics and logs never contain source text, credentials or absolute +machine paths. + +## Evidence + +- `docs/evidence/2026-11-26-implementation.md` — executed test counts, real + Analysis integration, T01 install/dispatch and release-archive cold install. +- `docs/STATUS.md` — capability matrix with implemented/tested vs NOT RUN. +- Committed real Analysis fixture with provenance: + `tests/fixtures/analysis/`. diff --git a/packaging/tool.json b/packaging/tool.json index a291b60..c8facbf 100644 --- a/packaging/tool.json +++ b/packaging/tool.json @@ -2,8 +2,11 @@ "schema": "marqdo.cli-tool", "schema_version": 1, "name": "marqdo-knowledge", - "version": "0.1.0", + "version": "0.1.0-beta.1", "command": "knowledge", "entrypoint": "bin/marqdo-knowledge", - "requires": {"api_revision": 1, "analysis": 3} + "requires": { + "api_revision": 1, + "analysis": 3 + } } diff --git a/spec/knowledge.md b/spec/knowledge.md index f3f7899..74741de 100644 --- a/spec/knowledge.md +++ b/spec/knowledge.md @@ -1,6 +1,6 @@ # marqdo-knowledge public contract -Status: current contract for this implementation (in progress). The normative +Status: current contract for `0.1.0-beta.1` (first beta; no stable-version claim). The normative development specification is `marqdo-knowledge-development.md`; this file records the exact contract this repository implements. Where the two differ, the development specification wins and this file must be corrected in place — @@ -13,7 +13,7 @@ there is never a second active contract. "schema": "marqdo.cli-tool", "schema_version": 1, "name": "marqdo-knowledge", - "version": "0.1.0", + "version": "0.1.0-beta.1", "command": "knowledge", "entrypoint": "bin/marqdo-knowledge", "requires": {"api_revision": 1, "analysis": 3}