Files
cflmy 25fc24eea4 feat: add Marqdo Harness product services and workbench
Implement the downstream product in `packages/marqdo`:

- `@marqdo/mdh-harness`: application home layout, atomic writes, locks,
  bounded fixed-argv processes, safe tar extraction, Observation 1 and
  ValueWire validation;
- trusted Gitea release discovery, SHA-256/platform/Bundle verification,
  transactional environment install, rollback and cleanup, CLI Tool changes;
- private knowledge collections with strict import policy, the official
  `marqdo-knowledge` compile/query adapter and a disclosed locator fallback;
- Analysis 3 parsing, approved run/call execution, evidence and staleness;
- the six model operations (find/read/check/program/ecosystem/knowledge_search);
- the `/mdh` workbench over the existing web server with a same-origin fence;
- `mdh` launcher, CI/package/upstream scripts and a Woodpecker pipeline.

Tests: 28 node:test cases (27 PASS, one network-gated install test also PASS
with MDH_TEST_INSTALL=1). Product install/workbench evidence is recorded in
docs/mdh/evidence.

Part of marqdo#25 (MDH-03..MDH-08).
2026-11-28 10:41:39 +08:00

71 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build one Marqdo Harness candidate archive and verify it from a cold extract.
#
# The archive is a prebuilt portable tree: the forked DSH source, its production
# node_modules layout and the built lib/web artifacts. It contains no Marqdo
# CLI/stdlib/ext/tool implementation; those are installed at runtime from
# trusted releases into MDH_HOME. A user needs Node 24 and nothing else: no
# pnpm install, no Rust, no source build.
set -euo pipefail
cd "$(dirname "$0")/.."
root="$PWD"
out="${MARQDO_CI_OUT:-$root/.ci}"
mkdir -p "$out"
stage="$(mktemp -d "${TMPDIR:-/tmp}/mdh-package.XXXXXX")"
verify="$(mktemp -d "${TMPDIR:-/tmp}/mdh-cold.XXXXXX")"
trap 'rm -rf "$stage" "$verify"' EXIT
test -f apps/cli/lib/bin.js || { echo "build artifacts missing; run pnpm run build" >&2; exit 1; }
test -f apps/web/dist/index.html || { echo "web build missing; run pnpm run build" >&2; exit 1; }
name="marqdo-harness-$(git rev-parse --short HEAD)-x86_64-unknown-linux-gnu"
app="$stage/$name"
mkdir -p "$app"
# Copy the prebuilt tree without VCS data or local scratch.
tar -C "$root" -cf - \
--exclude=.git --exclude=.ci --exclude=.integration-work --exclude=.issue-work \
--exclude=node_modules/.cache --exclude='*.log' . | tar -C "$app" -xf -
cat > "$app/mdh" <<'SH'
#!/usr/bin/env bash
set -euo pipefail
here="$(cd "$(dirname "$0")" && pwd)"
exec node "$here/scripts/mdh.mjs" "$@"
SH
chmod 755 "$app/mdh"
# A cold extract with a fresh home and no developer checkout must compose the
# single product profile without network access.
export MDH_HOME="$verify/home"
"$app/mdh" --dump-config > "$verify/dump.yml" 2> "$verify/dump.err"
grep -q 'mdh-harness' "$verify/dump.yml"
grep -q 'mdh-web' "$verify/dump.yml"
test -s "$verify/dump.yml"
archive="$out/$name.tar.gz"
tar -czf "$archive" -C "$stage" "$name"
sha256sum "$archive" | tee "$out/$name.tar.gz.sha256"
stat -c '%n %s bytes' "$archive"
python3 - "$archive" "$verify/dump.yml" <<'PY'
import hashlib, json, pathlib, subprocess, sys
archive = pathlib.Path(sys.argv[1])
record = {
'schema': 'marqdo.mdh.package-evidence',
'schema_version': 1,
'status': 'PASS',
'archive': archive.name,
'size': archive.stat().st_size,
'sha256': hashlib.sha256(archive.read_bytes()).hexdigest(),
'application_sha': subprocess.check_output(['git', 'rev-parse', 'HEAD'], text=True).strip(),
'platform': 'x86_64-unknown-linux-gnu',
'node': subprocess.check_output(['node', '--version'], text=True).strip(),
'cold_compose': 'PASS',
'contains_marqdo_cli_source': False,
'unverified': ['signature', 'installer on a second clean host', 'real model E2E'],
}
(archive.parent / 'package-evidence.json').write_text(json.dumps(record, indent=2) + '\n')
print(json.dumps(record, indent=2))
PY