Files
sow-tools/scripts/crucible-smoke.sh
T
archvillainette a131b25e5b feat(nwsync): emit blobs and per-artifact NSYM, assemble merged manifests (#71)
Builds sow-tools#53. Format spec followed is the resolution comment of sow-platform#94, checked line by line against niv/neverwinter.nim at HEAD (`nwsync.nim`, `compressedbuf.nim`, `nwsync/private/libupdate.nim`).

## What lands

`crucible nwsync emit <artifact> --out DIR` — explodes one `.hak`/`.erf`, or one loose file such as the TLK, into NWSync blobs plus a NSYM v3 manifest covering only that artifact, with the same `.json` sidecar upstream writes. Blob path `data/sha1/<h0h1>/<h2h3>/<sha1>`, body in NWCompressedBuffer framing (magic `NSYC`, version 3, algorithm 2, uncompressed size, zstd header version 1, dictionary 0, raw zstd frame). The sha1 that names a blob is over the uncompressed bytes.

`crucible nwsync assemble --order NAMES --entries DIR --out DIR [--group-id N]` — merges the per-artifact manifests into one, reading no bulk data at all. Merge rule is resref shadowing, not concatenation: a resref in more than one artifact resolves to the earliest artifact in `--order`, which is how the game resolves it. `--group-id` stays caller-supplied (1 current, 2 testing; 0 is absent, matching upstream omitting a zero integer meta field).

Rules taken from upstream and not re-invented: `nss`/`ndb`/`gic` always skipped; an unresolvable restype is a hard error, not a skip; a resource over 15 MB fails closed; no `latest` file and no `.origin` file, ever. A `.mod` is refused outright — a persistent world publishes no module contents, so the module contributes no bytes.

## Two deliberate departures

- **Emitter version is its own field, not the build revision.** `emitter_version` is a constant bumped only when emitted bytes change. Keying the refuse-to-merge check on `created_with` would invalidate every published index on every unrelated crucible commit and force a re-emit of the whole 15 GB corpus — the opposite of "nothing downstream ever needs the hak again".
- **`SOURCE_DATE_EPOCH` pins the sidecar timestamp.** The manifest itself was already deterministic; the sidecar's `created` was not, against the determinism rule in `docs/consumer-contract.md`.

## Not in this PR, and why

- **Direct upload.** Only the local `--out` sink exists, which is the conformance path. The upload sink and the mid-hak-failure question are sow-tools#60, and the consumer wiring is #65.
- **The conformance run against upstream.** sow-tools#59 owns getting `nwn_nwsync_write` running and capturing reference output. The format here was read from upstream source rather than from its output, so the byte-for-byte manifest comparison and the after-decompression blob comparison still have to happen — that is what #59 is for. The tests in this PR check the layout against the spec, so a shared misreading would pass them.
- **The `artifacts/haks/sha256/<a>/<b>/<sha256>.nsym` location.** emit writes `<out>/<name>.nsym`; where a publisher puts it is the publisher's business (#65).
- **The acceptance gate** — a real client syncing from an assembled manifest — is unchanged and still open.

## Checks

`make check` green (vet, unit tests, shellcheck, yamllint, workflow contract), `make smoke` green with the new builder, `nix build .#crucible` produces `crucible-nwsync`.

🤖 Generated with [Claude Code](https://claude.com/claude-code)Reviewed-on: #71

Co-authored-by: vickydotbat <vickydotbat@tutamail.com>
2026-07-29 10:50:05 +00:00

66 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Smoke test the built Crucible binaries:
# - the dispatcher reports version + lists builders
# - an unwired builder (no migrated logic yet) fails closed with exit 70
# - a wired builder rejects a missing subcommand with a usage error (exit 64,
# NOT 70) and exits cleanly under --help — proof it delegates to the migrated
# nwn-tool surface rather than faking an artifact
# - each standalone shim agrees with the dispatcher
set -euo pipefail
cd "$(dirname "$0")/.."
bin=bin
[[ -x "${bin}/crucible" ]] || { echo "no ${bin}/crucible — run scripts/build-binaries.sh first" >&2; exit 1; }
"${bin}/crucible" version >/dev/null
"${bin}/crucible" list >/dev/null
# Keep in sync with internal/dispatch.Registry (Wired flag).
unwired=()
wired=(assets depot hak module nwsync topdata wiki)
exit_of() { set +e; "$@" >/dev/null 2>&1; local c=$?; set -e; echo "${c}"; }
for b in "${unwired[@]}"; do
[[ -x "${bin}/crucible-${b}" ]] || { echo "missing ${bin}/crucible-${b}" >&2; exit 1; }
via_dispatch="$(exit_of "${bin}/crucible" "${b}")"
via_shim="$(exit_of "${bin}/crucible-${b}")"
if [[ "${via_dispatch}" -ne 70 ]]; then
echo "FAIL: crucible ${b} exit=${via_dispatch}, want 70 (unwired must fail closed)" >&2
exit 1
fi
if [[ "${via_shim}" -ne 70 ]]; then
echo "FAIL: crucible-${b} exit=${via_shim}, want 70 (must match dispatcher)" >&2
exit 1
fi
done
for b in "${wired[@]}"; do
[[ -x "${bin}/crucible-${b}" ]] || { echo "missing ${bin}/crucible-${b}" >&2; exit 1; }
# --help is a clean exit for a wired builder.
help_code="$(exit_of "${bin}/crucible" "${b}" --help)"
if [[ "${help_code}" -ne 0 ]]; then
echo "FAIL: crucible ${b} --help exit=${help_code}, want 0 (wired builder)" >&2
exit 1
fi
# No subcommand is a usage error, and crucially NOT the unwired 70.
via_dispatch="$(exit_of "${bin}/crucible" "${b}")"
via_shim="$(exit_of "${bin}/crucible-${b}")"
for pair in "dispatch:${via_dispatch}" "shim:${via_shim}"; do
code="${pair#*:}"
if [[ "${code}" -eq 70 ]]; then
echo "FAIL: ${pair%%:*} crucible ${b} still fails closed (70) but is wired" >&2
exit 1
fi
if [[ "${code}" -ne 64 ]]; then
echo "FAIL: ${pair%%:*} crucible ${b} exit=${code}, want 64 (missing subcommand)" >&2
exit 1
fi
done
done
echo "smoke ok: ${#unwired[@]} unwired fail closed (70), ${#wired[@]} wired delegate to nwn-tool logic"