Files
marqdo-knowledge/scripts/regenerate-analysis-fixture.sh
T
marqdo-knowledge 59d5afe10b feat(analysis): consume the current public Analysis v3 contract
- add the process boundary for the core CLI: explicit MARQDO_BIN/--marqdo-bin
  only (never PATH), argv-only invocation of check ENTRY --emit, bounded
  timeout, private temp artifact, exit checks and absolute-path sanitisation
- deserialize every Analysis record with closed serde shapes and validate
  semantic invariants that JSON Schema cannot express: identities, source
  digests, UTF-8 spans, unit tree/order/mode ancestry, anchors, functions and
  signatures, references states, calls, resources, diagnostics and budgets
- validate statement/expression trees structurally with depth and span checks
- convert accepted modules into DocumentFacts, preserving honest upstream
  reference states and one node per Exec unit/function
- merge modules across entry contexts only when identity and source agree,
  otherwise report knowledge.analysis_context_conflict
- add the real rc.4 Analysis positive fixture (with provenance and regeneration
  script), tamper negative tests and optional real-binary integration tests
2026-11-26 00:29:19 +08:00

63 lines
1.3 KiB
Bash
Executable File

#!/bin/sh
# Regenerate the committed Analysis positive fixture with a real core CLI.
#
# Usage: scripts/regenerate-analysis-fixture.sh /path/to/marqdo
# The emitted artefact is recorded together with the producer identity in
# tests/fixtures/analysis/README.md. Never hand-edit the fixture.
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
BIN=${1:?usage: $0 /path/to/marqdo}
WORK=$(mktemp -d)
trap 'rm -rf "$WORK"' EXIT
mkdir -p "$WORK/project/physics"
cat > "$WORK/project/marqdo.yaml" <<'YAML'
project:
name: demo
version: 0.1.0
marqdo: ">=3.0.0-beta.1,<4.0.0"
dependencies: {}
YAML
cat > "$WORK/project/physics/mechanics.mq.md" <<'MD'
---
type: Theory
title: 经典力学
tags: [physics, mechanics]
---
# 经典力学
## @knowledge 牛顿第二定律
合外力等于质量与加速度的乘积。
$$
F = ma
$$
| 符号 | 含义 |
| --- | --- |
| m | 质量 |
| a | 加速度 |
计算入口:[计算力](#计算力)。
## @exec 计算力
`params(m, a)`
依据[牛顿第二定律](#牛顿第二定律)。
`return m * a`
MD
(
cd "$WORK/project"
"$BIN" check physics/mechanics.mq.md --emit "$WORK/analysis.json"
)
cp "$WORK/analysis.json" "$ROOT/tests/fixtures/analysis/mechanics.json"
(
cd "$ROOT/tests/fixtures/analysis"
sha256sum mechanics.json > mechanics.json.sha256
)
"$BIN" --version
sha256sum "$BIN"