#!/usr/bin/env bash
# SPDX-License-Identifier: MIT
# Copyright (c) 2026 Abyssi.
# Native open-source reference only. Does not reproduce the private Abyssi engine.
set -euo pipefail
study_dir="$(cd "$(dirname "$0")/.." && pwd)"
work_dir="$(mktemp -d)"
trap 'rm -rf "$work_dir"' EXIT
pin=7f70ce0feba1b907c8baa18d7f3227c5e57050fe
git clone --no-checkout https://github.com/KG32/dive-deco.git "$work_dir/upstream"
git -C "$work_dir/upstream" checkout --detach "$pin"
cp "$study_dir/methods/capture_reference.rs" "$work_dir/upstream/examples/abyssi_study_reference.rs"
cargo run --locked --release --manifest-path "$work_dir/upstream/Cargo.toml" --example abyssi_study_reference > "$study_dir/data/dive-deco-native-rerun.json"
printf '%s\n' 'Native Rust capture written to data/dive-deco-native-rerun.json.'
printf '%s\n' 'This reruns only the open-source reference, not Abyssi or the adapted DecoTengu fixtures.'
