From 3fe1ca3c0c93b1f42ce6363f74b01c4820ded412 Mon Sep 17 00:00:00 2001 From: cflmy Date: Tue, 24 Nov 2026 17:04:03 +0800 Subject: [PATCH] docs: record the single-contract policy and review gate --- AGENTS.md | 5 +- docs/STATUS.md | 47 +++- docs/architecture/CURRENT.md | 5 + .../PROTOCOL_CONVERGENCE_POLICY.md | 202 ++++++++++++++++++ docs/architecture/README.md | 5 +- docs/contributor-guide.md | 5 +- 6 files changed, 256 insertions(+), 13 deletions(-) create mode 100644 docs/architecture/PROTOCOL_CONVERGENCE_POLICY.md diff --git a/AGENTS.md b/AGENTS.md index 52d1778..60c18fa 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -36,8 +36,9 @@ correctness and release evidence before expanding the surface. ## Pre-stable protocol changes -Read [ADR-0068](docs/adr/0068-single-current-public-contracts.md) before changing -a public boundary. Keep one current specification, producer and validator per +Read [ADR-0068](docs/adr/0068-single-current-public-contracts.md) and the +[single-contract convergence policy](docs/architecture/PROTOCOL_CONVERGENCE_POLICY.md) +before changing a public boundary. Keep one current specification, producer and validator per boundary. Replace retired paths in the same integration, reject unsupported formats explicitly, and update independent consumers and release smoke tests. Keep old formats in Git history. Preserve authority, attribution and resource diff --git a/docs/STATUS.md b/docs/STATUS.md index f167d02..f28bd75 100644 --- a/docs/STATUS.md +++ b/docs/STATUS.md @@ -34,11 +34,39 @@ published beta. ## Current protocol integration -[ADR-0068](adr/0068-single-current-public-contracts.md) governs the work -for [issue #8](https://git.cflmy.cn/cflmy/marqdo-cli/issues/8). Current -developer inputs are [Analysis](../spec/analysis.md), -[Observation](../spec/observation.md) and the [CLI Tool](../spec/cli-tool.md). -The earlier release records below describe their tagged binaries. +[ADR-0068](adr/0068-single-current-public-contracts.md) and the +[single-contract policy](architecture/PROTOCOL_CONVERGENCE_POLICY.md) govern +every public boundary. Current developer inputs are +[Analysis](../spec/analysis.md), [Observation](../spec/observation.md) and the +[CLI Tool](../spec/cli-tool.md); the shared persistent-worker transport is +[worker-ipc](../spec/worker-ipc.md). + +Issue [#8](https://git.cflmy.cn/cflmy/marqdo-cli/issues/8) converged the +pre-stable contracts in one breaking integration, with no compatibility layer: + +- Analysis has one writer and one current `schema_version` for every project, + including projects without loop transfers. The content-driven v2/v3 selector + and the retired `spec/analysis-v*.md` documents are gone. +- Trace and Execution Events became one Observation event definition. One + execution emits one `run_id`/`seq` sequence; `--output jsonl` and + `--observation-file` deliver those same events, never a second execution or a + second numbering. The retired `--json`/`--trace-file`/`--event-stream` + options are rejected. +- CLI Tool requirements are single exact integers (`api_revision`, optional + `analysis`, optional `observation`). Version arrays and intersection + negotiation are removed; retired registrations are rejected with a reinstall + instruction. +- Plugin and resource-provider workers share one bounded framed transport + ([worker-ipc](../spec/worker-ipc.md)) while each boundary keeps its own + vocabulary, limits, capabilities and error codes. +- Extension descriptors (plugin/provider/kernel) and lock v4 keep their current + format identifiers. Retired lock versions are rejected with an explicit + `marqdo lock` regeneration instruction; there is no migrator. Renumbering an + unchanged format was explicitly rejected. + +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. Beta release record — `3.0.0-beta.1` @@ -47,9 +75,10 @@ The earlier release records below describe their tagged binaries. - Workspace/crate version, `marqdo --version` and Analysis `producer.version` are `3.0.0-beta.1`; `Cargo.lock` is committed and release builds use `--locked`. -- Independent axes are unchanged: Analysis v2, Trace v2, Tool v1, Plugin ABI +- At the tagged beta, the axes were Analysis v2, Trace v2, Tool v1, Plugin ABI v1, Foreign wire v1, Provider manifest v2, lock v4, markdown profile - `marqdo.md.v1`; bundled stdlib stays package version `0.1.0`. + `marqdo.md.v1`; bundled stdlib stayed package version `0.1.0`. Those are + historical identifiers, not current claims. - `project.marqdo` is enforced; prerelease SemVer rules are covered by tests (`>=3.0.0,<4.0.0` does not silently accept a beta core). - Only the Linux x86_64 archive is claimed. macOS/Windows are @@ -110,7 +139,7 @@ exports reconcile exactly with the static manifest. The independent frozen-binary suite is the beta gate above; the older `6a7bb98` manifest is historical and superseded by the release-SHA manifest. -## 0.5 Post-beta addition — Execution Events v1 (unreleased) +## 0.5 Historical: post-beta Execution Events v1 (superseded by Observation) This section records work **after** the `v3.0.0-beta.1` tag. It is not part of the tagged beta archive and no new release tag has been created. The design @@ -272,7 +301,7 @@ digests. The external lane ran from a temporary fixture checkout with Cargo absent from PATH. Archive SHA-256 is `8934bfc25c7b5526071eae6f24143ca3805ad3d7cc484626a4345b1deed430b2`. -## 0.8 Structured control flow — RFC-CTRL-0005 (RC.2 candidate) +## 0.8 Historical: structured control flow — RFC-CTRL-0005 (RC.2 snapshot) [ADR-0067](adr/0067-structured-control-flow.md) covers the phase A implementation. An `else if` carrier adds a condition arm to the existing branch IR. diff --git a/docs/architecture/CURRENT.md b/docs/architecture/CURRENT.md index a8adc15..037ac70 100644 --- a/docs/architecture/CURRENT.md +++ b/docs/architecture/CURRENT.md @@ -258,10 +258,15 @@ that a phase is complete. 5. When behavior or status changes, update code + tests + `docs/STATUS.md` + this file + an evidence file in the same change. A fixture/demo is not a published stdlib API. +6. A public-boundary change must follow + [`PROTOCOL_CONVERGENCE_POLICY.md`](PROTOCOL_CONVERGENCE_POLICY.md): one + current contract, replace in place, reject retired inputs, no compatibility + path or version negotiation, and no version bump without a shape change. ## 7. References - [Architecture index](README.md) — RFC/ADR/evidence history. +- [Protocol convergence policy](PROTOCOL_CONVERGENCE_POLICY.md) — one-contract rules, anti-patterns and review checklist. - [Implementation status](../STATUS.md) — executed state and blockers. - [Language/frontmatter blueprint](../DEVELOPMENT_BLUEPRINT.md) — design baseline; not current status. - [3.0 prerelease plan](../MARQDO_3_0_PRERELEASE_PLAN.md) — current release policy and beta gates. diff --git a/docs/architecture/PROTOCOL_CONVERGENCE_POLICY.md b/docs/architecture/PROTOCOL_CONVERGENCE_POLICY.md new file mode 100644 index 0000000..1bd1128 --- /dev/null +++ b/docs/architecture/PROTOCOL_CONVERGENCE_POLICY.md @@ -0,0 +1,202 @@ +# Protocol convergence policy (pre-stable) + +Status: **current contributor policy**. Owner: architecture review. Authority: +[ADR-0068](../adr/0068-single-current-public-contracts.md), adopted for +[issue #8](https://git.cflmy.cn/cflmy/marqdo-cli/issues/8) before the first +stable release. This page is the checklist that prevents the same failure from +returning; it does not replace `spec/` or an ADR. + +## 1. The failure this policy prevents + +Before issue #8 the tree kept several competing models of the same fact: + +- Analysis chose `schema_version` 2 or 3 from the **content** of the project + (presence of `break`/`continue`), and a Tool declared an **array** of + Analysis versions and installed when the arrays intersected. Installation + succeeded while the actual output stayed unreadable for that project. +- Trace and Execution Events each defined a public representation of the same + execution, with separate writers, budgets and privacy rules. +- `spec/` still carried superseded Analysis/Trace/Events documents beside the + current ones, so a reader could not tell which contract the binary emitted. + +The root cause was not "too many JSON files". It was **maintaining a replaced +architecture as a second live path** after the architecture had changed. The +cure is one current contract per real boundary, replaced in place, with +retired inputs rejected explicitly. + +## 2. Current boundary map + +Every row has exactly one current contract. A change must keep it that way. + +| Real boundary | Current contract | Single producer / validator | Retired, kept in Git only | +|---|---|---|---| +| Markdown syntax | [`markdown-profile.md`](../../spec/markdown-profile.md) `marqdo.md.v1` | `marqdo-markdown` (frozen Comrak options) | older profiles | +| Language mapping | [`mapping.md`](../../spec/mapping.md), [`expression.ebnf`](../../spec/expression.ebnf) | `marqdo-frontend` + `marqdo-expression` | pre-RFC-LANG-0002 mapping | +| Static facts | [`analysis.md`](../../spec/analysis.md) + `analysis.schema.json` | `crates/cli/src/analysis.rs` | Analysis v1/v2/v3 split | +| Runtime facts | [`observation.md`](../../spec/observation.md) + two schemas (event, snapshot) | Host observation sink, CLI assigns `run_id`/`seq` | Trace v1/v2, Execution Events v1 | +| Installed commands | [`cli-tool.md`](../../spec/cli-tool.md) + `cli-tool.schema.json` | `crates/cli/src/tool.rs` | Tool v1 arrays/negotiation | +| C ABI | [`plugin-abi.md`](../../spec/plugin-abi.md) + C header | `marqdo-plugin-abi`, SDK | obsolete ABI major | +| Foreign kernels | [`foreign.md`](../../spec/foreign.md) wire v1 | `marqdo-foreign` (one-shot) | retired wire/versions | +| Resource providers | [`resource-provider-v2.md`](../../spec/resource-provider-v2.md) manifest v2 | CLI manifest validation + Host worker | retired manifests | +| Worker plumbing | [`worker-ipc.md`](../../spec/worker-ipc.md) (internal, no version) | `marqdo-worker-ipc` | private framing copies | +| Extension selection + lock | [`extension-selection.md`](../../spec/extension-selection.md), lock v4 | `marqdo-package` + CLI | lock v1–v3 readers/migrators | +| Values | [`value-wire.md`](../../spec/value-wire.md) | `marqdo-value::wire` | alternate encoders | + +A boundary may have **two root objects** of one contract (currently Observation +event and snapshot). Two root objects are not two protocols: they share one +event definition and one schema authority. + +## 3. Rules + +### 3.1 One current contract per boundary + +- One current format identifier, one producer, one validation path. +- No selection of a schema from project content, feature detection or runtime + state. +- No multi-version arrays, version ranges, "highest shared version", capability + probing or intersection negotiation. +- No simultaneous emission of an old and a new format, and no compatibility + adapter between two writers. + +### 3.2 Replace in place, in one integration + +- Change the producer, specification, JSON Schema, independent consumers, + fixtures and CI in the same change series. The intermediate commits on a + branch may be incomplete; a merged state may not contain two live paths. +- Delete the replaced implementation, spec and fixtures in that integration. + Git history and tagged archives are the archaeology; `spec/` is not. +- Keep the existing format identifier when the contract **shape** does not + change. Do not renumber formats for appearance, symmetry or "freshness" + (**no version bump without a shape change**). Conversely, when the shape + changes, an in-place replacement at the existing identifier is allowed + pre-stable and preferred over adding a parallel version. + +### 3.3 Reject, never migrate silently + +- Unsupported formats, versions, fields and command options fail with a + corrective action (for example "run `marqdo lock` to regenerate", "remove and + reinstall the tool"). +- No automatic upgrade of an old lock, tool record, manifest or machine output; + no field guessing; no fallback to a legacy reader; no "temporarily accept + both". +- Keep historical formats retrievable from Git and release tags, but do not let + the current binary read them. + +### 3.4 Never trade a safety invariant for convergence + +Removing a compatibility path must not remove integrity, authorization, type +checks, worker timeouts, size limits, secret handling or OS-isolation gates. +Convergence is about the fact model, not about relaxing it. When deleting code +that looks like "legacy compatibility", confirm first that it is not one of: + +- Analysis/Observation digest binding and source attribution; +- tool bundle hashing, entrypoint/path/symlink checks, command-conflict checks; +- plugin/provider artifact target/path/sha256 verification and native trust; +- capability grants, declared-vs-installed handler checks, budgets; +- strict mode fail-closed behavior and worker quarantine; +- Value Wire type fidelity and non-transferable handle rules. + +### 3.5 Preserve privacy when merging fact models + +A unified model must keep the strictest privacy default of the models it +replaces. Today value observation is off by default; selected names must be +declared; Text needs separate consent; Memory/Handle are never serialized. +Merging Trace into Observation never blesses Trace-era value exposure. + +## 4. Mandatory change procedure + +For any change to a public boundary, in order: + +1. **ADR.** Record the single target design, the boundary, the identifier + decision (keep or replace) and what is deleted. If an ADR is superseded, mark + its header Historical so no reader treats it as current. +2. **Specification in place.** Update the one current `spec/*.md` (never add a + parallel "v-next" current spec). Update the JSON Schema if one exists. + `spec/` must describe only what the current tree emits. +3. **One producer, one validator.** Delete the alternate selection logic, the + second writer, the legacy reader and their dead error paths in the same + series. `grep` is evidence: no `legacy`, `compat`, `schema_v2_or_v3`, + `shared_version`, version arrays or fallback branches may remain runnable. +4. **Fixtures and consumers.** Replace goldens with ones produced by the **real + CLI**, update the independent consumer(s), and add negative fixtures for the + retired input. Never weaken or delete a security/semantic negative test to + go green. +5. **CLI and docs.** Update `--help`, README, developer guides, examples and + release/smoke scripts. No alias for a retired option. +6. **Enforcement gate.** Add or keep a source-level check that the duplicate + cannot quietly return (see `architecture_boundaries` tests; for example the + shared worker transport test forbids reimplementing framing). +7. **Evidence.** Record the executed commands in `docs/STATUS.md` and an + evidence file with the exact SHA. A design document is not evidence. + +## 5. Anti-patterns — do not do these + +| Tempting move | Why it is rejected | Do instead | +|---|---|---| +| Keep v2 output for "simple" projects | Content-driven schema selection is the original bug | One writer, one identifier | +| Accept `analysis: [2,3]` and pick the intersection | Installs succeed when output is unreadable | One exact requirement, reject mismatch | +| Add `--legacy`, `compat`, `map_v1` or per-file switch | Reintroduces a second live architecture | Replace the current path; delete the old one | +| Keep the old writer behind a new "Unified" trait | Cosmetic abstraction over two fact models | One producer feeding all destinations | +| Rename `analysis-v3.md` to `analysis.md` only | Docs claim what code does not do | Update code, schema, fixtures, consumers together | +| Accept old lock/tool/extension silently | Hides a broken upgrade and loses integrity | Fail with an explicit regenerate/reinstall message | +| Delete security tests to make CI green | Convergence must not lower the bar | Keep/strengthen negatives | +| Renumber an unchanged format "to be safe" | Creates migration cost without a shape change | Keep the existing identifier | +| Add a second observation writer per destination | Two sources of truth for one execution | One event sequence, many destinations | +| Share worker capabilities with shared framing | Transport sharing is not authority sharing | Share framing only; keep grants per boundary | + +## 6. Review checklist + +A reviewer must be able to answer "yes" to all of these before approving a +protocol-boundary change: + +- [ ] Does this boundary still have exactly one current contract and one + producer/validator? +- [ ] Did the replaced spec/implementation/fixtures get deleted in this + integration (not scheduled "later")? +- [ ] Are retired inputs rejected with a corrective action, with no migrator, + alias, fallback or field guessing? +- [ ] Is the format identifier unchanged unless the contract shape changed? +- [ ] Do independent consumers and real-CLI fixtures validate the new artifact, + including at least one negative case? +- [ ] Are digest binding, attribution, grants, budgets, timeouts, size limits, + secret handling and strict-mode fail-closed behavior intact and tested? +- [ ] Does the privacy default stay structural, with explicit value/Text + consent? +- [ ] Are `--help`, README, developer docs, examples and release smoke updated + to the current contract only? +- [ ] Is there a source-level gate preventing the duplicate path from returning? +- [ ] Is the executed evidence recorded against a SHA (not a plan or a claim)? + +## 7. Definition of Done for a convergence change + +- `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets -- -D + warnings`, `cargo test --workspace --locked` pass. +- `cargo test -p marqdo-cli --test architecture_boundaries --test + docs_consistency` pass. +- Independent consumers validate real CLI output; schema files parse; retired + options and formats are proven rejected. +- `spec/` contains no superseded current-contract document; retired ADRs carry a + Historical header; `docs/STATUS.md` names the executed evidence. +- The release archive smoke test is updated before an RC is tagged, and the RC + evidence is bound to the archive's SHA. + +## 8. Stable-release boundary + +Everything above applies **before the first stable release**. After the first +stable release a separate compatibility policy must define which contracts are +stabilized, the deprecation window and the upgrade rules. Do not import +post-stable compatibility obligations into the pre-stable tree, and do not +assume this policy authorizes breaking stable contracts later. + +## 9. Where the policy is enforced + +| Enforcement | Artifact | +|---|---| +| Absolute language/architecture rules | [`AGENTS.md`](../../AGENTS.md) | +| Public-contract decision | [ADR-0068](../adr/0068-single-current-public-contracts.md) | +| Architecture overview and boundary table | [`architecture/CURRENT.md`](CURRENT.md) | +| Normative contracts | `spec/*.md` + `spec/schemas/*.json` | +| Source-level boundary gates | `crates/cli/tests/architecture_boundaries.rs` | +| Docs/link/status gates | `crates/cli/tests/docs_consistency.rs` | +| Independent consumers | `tests/consumers/*.py` | +| Release evidence | [`STATUS.md`](../STATUS.md), `docs/evidence/`, `docs/releasing.md` | diff --git a/docs/architecture/README.md b/docs/architecture/README.md index 5d99d6d..7fe60f4 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -5,6 +5,9 @@ Status: **index**. The single current architecture overview is input and evidence. It is not a second running-status page. - Current architecture and four state dimensions: [`CURRENT.md`](CURRENT.md). +- Public-contract convergence rules and review checklist: + [`PROTOCOL_CONVERGENCE_POLICY.md`](PROTOCOL_CONVERGENCE_POLICY.md) + ([ADR-0068](../adr/0068-single-current-public-contracts.md)). - **Current language contract:** [`RFC-LANG-0002-unified-semantics.md`](RFC-LANG-0002-unified-semantics.md), adopted by [ADR-0052](../adr/0052-unified-markdown-semantics.md) and @@ -21,7 +24,7 @@ input and evidence. It is not a second running-status page. |---|---|---| | [Unified semantics RFC-LANG-0002](RFC-LANG-0002-unified-semantics.md) | **Adopted and implemented** | Single syntax: heading modes, unified payloads, keyword control flow, breaking migration and acceptance gates. | | [Architecture audit and refactor RFC](Marqdo_CLI_Latest_Architecture_Audit_and_Refactor_RFC.md) | **Review input (historical)** | Responsibility convergence, stdio/file/stream correctness, CLI/Host split and the migration order at the time. Its language examples predate RFC-LANG-0002. | -| [Runtime observability RFC-OBS-0001](RFC-OBS-0001-runtime-observability.md) | **Adopted and implemented (P0/P1)** | Typed host observation, Execution Events v1 NDJSON, frame identity, selected bounded values; P2 memory metadata remains deferred. | +| [Runtime observability RFC-OBS-0001](RFC-OBS-0001-runtime-observability.md) | **Historical: superseded by Observation (ADR-0068)** | Its event vocabulary and privacy model fed the current [Observation](../../spec/observation.md) contract; the Execution Events v1 name/options are retired. | | [Compute machine RFC-0001](../MARQDO_COMPUTE_MACHINE_RFC_0001.md) | **Proposed** | Opaque `Memory`, addressable regions, wire/host rejection. Compute semantics are unchanged by the syntax rewrite; its `.mq.md` examples are historical spelling. | | [Core and stdlib migration RFC-0002](../MARQDO_COMPUTE_CORE_STDLIB_MIGRATION_RFC_0002.md) | **Proposed** | Minimum core, `.mq.md` stdlib and system-capability migration. The stdlib source migration is complete; current status is recorded in ../STATUS.md. | | RFC-EXT-0003 core/extension boundary (issue #3) | **Adopted slices in ADR-0060–0063** | H-01/H-03/H-04/H-05/H-06/H-07/H-08/H-02 decisions; heading annotations are Step A (Proposed), foreign F-B deferred. See [`resource-operations.md`](resource-operations.md) and `spec/heading-annotations-v1.md`. | diff --git a/docs/contributor-guide.md b/docs/contributor-guide.md index e4588c5..2a4378d 100644 --- a/docs/contributor-guide.md +++ b/docs/contributor-guide.md @@ -24,6 +24,7 @@ marqdo-cli/ ├── docs/ │ ├── DEVELOPMENT_BLUEPRINT.md architecture baseline (language-mapping sections historical) │ ├── architecture/RFC-LANG-0002-unified-semantics.md current language authority +│ ├── architecture/PROTOCOL_CONVERGENCE_POLICY.md one-current-contract rules + review checklist │ ├── STABLE_RELEASE_IMPLEMENTATION.md authoritative next-phase/release plan │ ├── STATUS.md current evidence, work packages, blockers │ ├── migration/ syntax-migration rules + file inventory @@ -45,11 +46,13 @@ marqdo-cli/ │ ├── security.md modes, capabilities, budgets, trust │ ├── package-format.md marqdo.yaml / marqdo.lock / init │ ├── plugin-abi.md C ABI v1, SDK, host lifecycle +│ ├── worker-ipc.md shared persistent-worker framing/transport │ ├── math.md removed core math outlook + migration (ADR-0061) │ ├── foreign.md Python/Node kernel protocol │ ├── cli-tool.md external command registration and dispatch │ ├── analysis.md current static projection -│ └── observation.md live events and snapshots +│ ├── observation.md live events and snapshots +│ └── cli-tool.md external command registration and dispatch ├── crates/ │ ├── marqdo-span/ Span, LineCol, LineIndex (leaf) │ ├── marqdo-value/ Value, diagnostics, errors, wire encoding