Files
marqdo-view/scripts/check-docs.sh
T
Marqdo View 340ecb035f
ci/woodpecker/push/woodpecker Pipeline was successful
feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
Replace the retired rc.2 Analysis v2/Trace v2/Execution Events v1 stack with the
single current contract family:

- Analysis v3 (ADR-0069 public boundary): one check --emit artifact carries the
  exact source, Markdown AST, heading scopes (heading_span + complete span),
  anchors, state-bearing references, calls, resources and diagnostics; the old
  revision-3 shape is rejected with a rebuild hint.
- Observation v1: one run/call --output jsonl stream (+ atomic
  --observation-file snapshot) decoded by one decoder and projected into the
  reader/SSE/export layers; stale/malformed/truncated/incomplete never render
  as success.
- CLI Tool revision 1: requires {api_revision:1, analysis:3, observation:1},
  product range >=3.0.0-rc.3,<4.0.0, only MARQDO_BIN and
  MARQDO_API_REVISION are consumed.
- Remove compatibility branches, retired flags/env vars and duplicate decoders;
  re-record Analysis v3 and Observation v1 fixtures; rewrite contract,
  integration and security tests (173 passing locally).
- Add check-no-legacy/check-docs/check-observation gates, rc.4 pins in the
  CI pipelines, 0.3.0 Tool bundle and evidence manifest support.

See issues #4, #5 and #6; acceptance baseline is CLI source
452e9a32bd9e40dba427d4180691c58bab74449e, archive
9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8.
2026-11-25 22:12:51 +08:00

90 lines
4.3 KiB
Bash
Executable File

#!/usr/bin/env bash
# G12 (issue #5): current documentation must describe the rc.4 contracts as the
# only current capability. Historical CHANGELOG entries may name retired
# interfaces only under an explicit `## History` heading.
#
# Checked files:
# README.md, COMPATIBILITY.md, CHANGELOG.md, docs/STATUS.md, docs/ACCEPTANCE.md
#
# The script never rewrites files and never claims a gate is PASS: it only
# reports fact drift between the current docs and the rc.4 contract baseline.
#
# Usage: scripts/check-docs.sh
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
fail=0
hit() {
printf 'FAIL[%s] %s\n' "$1" "$2"
fail=1
}
legacy_pattern='Analysis v2|Trace v2|Execution Events|--trace-file|--event-stream|PROTOCOL_ANALYSIS|PROTOCOL_TRACE|TOOL_PROTOCOL|3\.0\.0-beta|>=3\.0\.0-rc\.2'
run_json_pattern='run[^.。\n]{0,20}--json|call[^.。\n]{0,20}--json|--json[^.。\n]{0,20}run|--json[^.。\n]{0,20}call'
# ------------------------------------------------------------- baseline ----
for file in README.md COMPATIBILITY.md docs/STATUS.md; do
[[ -f "$file" ]] || { hit "missing doc" "$file"; continue; }
grep -q '0\.3\.0' "$file" || hit "version drift" "$file: does not state View 0.3.0"
done
for file in README.md COMPATIBILITY.md docs/STATUS.md docs/ACCEPTANCE.md; do
[[ -f "$file" ]] || { hit "missing doc" "$file"; continue; }
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "legacy contract as current capability" "$file:$line: $text"
done < <(grep -nE "$legacy_pattern" "$file" || true)
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "retired run --json as current output" "$file:$line: $text"
done < <(grep -nE "$run_json_pattern" "$file" || true)
done
grep -qE 'Analysis[^A-Za-z0-9]+3' COMPATIBILITY.md || hit "contract drift" "COMPATIBILITY.md: no current Analysis 3 row"
grep -qE 'Observation[^A-Za-z0-9]+1' COMPATIBILITY.md || hit "contract drift" "COMPATIBILITY.md: no current Observation 1 row"
grep -qE 'api_revision[^A-Za-z0-9]+1|API revision[^A-Za-z0-9]+1' COMPATIBILITY.md \
|| hit "contract drift" "COMPATIBILITY.md: no current Tool api_revision 1 row"
grep -q '>=3.0.0-rc.3,<4.0.0' COMPATIBILITY.md || hit "product range drift" "COMPATIBILITY.md: expected >=3.0.0-rc.3,<4.0.0"
# ------------------------------------------------------------- CHANGELOG ---
if [[ ! -f CHANGELOG.md ]]; then
hit "missing doc" "CHANGELOG.md"
else
history_line="$(grep -nE '^##[[:space:]]+(History|历史)' CHANGELOG.md | head -1 | cut -d: -f1 || true)"
if [[ -z "$history_line" ]]; then
if grep -qE "$legacy_pattern" CHANGELOG.md; then
hit "CHANGELOG history" "CHANGELOG.md: retired interfaces appear without an explicit '## History' heading"
fi
else
# Only the current (pre-history) part may be scanned for legacy claims.
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "legacy contract as current CHANGELOG entry" "CHANGELOG.md:$line: $text"
done < <(head -n "$((history_line - 1))" CHANGELOG.md | grep -nE "$legacy_pattern" || true)
while IFS=: read -r line text; do
[[ -n "$line" ]] && hit "retired run --json in current CHANGELOG entry" "CHANGELOG.md:$line: $text"
done < <(head -n "$((history_line - 1))" CHANGELOG.md | grep -nE "$run_json_pattern" || true)
if ! head -n "$((history_line - 1))" CHANGELOG.md | grep -q '0\.3\.0'; then
hit "CHANGELOG current entry" "CHANGELOG.md: no 0.3.0 entry before '## History'"
fi
fi
fi
# --------------------------------------------------------------- report ----
if [[ "$fail" -ne 0 ]]; then
cat >&2 <<'EOF'
check-docs: FAIL
Update the current docs to the rc.4 baseline:
* one static source: `check --emit` Analysis revision 3 (ADR-0069);
* one runtime sequence: Observation revision 1 (`--output jsonl` /
`--observation-file`), no retired trace file or event stream;
* CLI Tool revision 1 with exact `requires` (api_revision 1, analysis 3,
observation 1), no `compatibility` field;
* product range >=3.0.0-rc.3,<4.0.0, acceptance pinned to rc.4.
Old release notes belong under CHANGELOG's explicit `## History` heading.
Do not claim PASS/UNVERIFIED results that have no generated evidence.
EOF
exit 1
fi
echo "check-docs: PASS (README/COMPATIBILITY/CHANGELOG/STATUS/ACCEPTANCE describe the rc.4 baseline; CHANGELOG history is explicit)"