interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / calibration / scripts / generate_sealed_data.sh

385 lines · 20359 bytes Raw Blame History
1#!/usr/bin/env bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Turing calibration (CAL-0 / EXP-001): generate the sealed test data AFTER the
18# candidate freeze. calibration/docs/BLINDING_PROTOCOL.md is the full procedure.
19#
20# usage:
21# generate_sealed_data.sh --commit FREEZE_SHA --profile-digest SHA256 [--n N] [--keep-learning] [--no-fetch]
22# generate_sealed_data.sh --derive-only --commit FREEZE_SHA --profile-digest SHA256 --n N
23# generate_sealed_data.sh --trial-seed S [--commit REF] (feasibility only; writes to the trial dir)
24# generate_sealed_data.sh --is-burned SEED (exit 0 and "burned" if the seed is refused, else exit 1)
25#
26# SEED RULE (turing.cal.sealed.v1). For group g in {1,2} and index j in 0..N-1:
27# msg = the ASCII bytes turing.cal.sealed.v1|<commit>|<digest>|g<g>|<j>
28# (<commit> = 40 lowercase hex, <digest> = 64 lowercase hex, <j> decimal,
29# no trailing newline)
30# h = SHA-256(msg), lowercase hex
31# seed = the first 16 hex chars of h read as a big-endian 64-bit integer with the
32# top bit cleared (so 0 <= seed < 2^63), printed in decimal.
33# A reader can recompute any seed with:
34# printf '%s' 'turing.cal.sealed.v1|<commit>|<digest>|g1|0' | sha256sum
35# Group 1 is the primary sealed test set; group 2 is the second-seed replication.
36# A seed equal to a burned seed (dev 0..10, 20260927, or for EXP_ID=EXP-001R one of the six EXP-001 sealed seeds in
37# burned_seeds_exp001.txt) or repeated is
38# refused (probability ~2^-59; the script stops rather than skip).
39#
40# GENERATOR (pinned): crumbs experiment --learner L --seed S --out DIR
41# crumbs = ~/workspace/hive-worktrees/crumbs-v1/target/release/crumbs, SHA-256 CRUMBS_SHA256 below
42# L = crumbline-learner built by `make crumbline-learner` from a clean
43# `git archive` export of the freeze commit, SHA-256 must equal
44# LEARNER_SHA256 below (the learner is part of the generator: a
45# different learner build changes trace.ctr).
46# Each seed runs inside a bubblewrap jail: no network, generator + learner
47# read-only, only that seed's group directory writable.
48#
49# REFUSES when: the freeze commit is not an ancestor of origin/main; the commit
50# lacks calibration/experiments/EXP-001/candidate_manifest.json or the profile;
51# SHA-256 of the profile bytes at the commit differs from --profile-digest (or its
52# .sha256 sidecar); the crumbs or learner binary hash differs from the pin;
53# the candidate manifest at the commit is not "status": "frozen" or the profile there still holds FILL_AT_FREEZE;
54# origin/main does not hold calibration/experiments/EXP-001/freeze_receipt.json with
55# "TURING_PROFILE_V1_FROZEN": "PASS", "freeze_commit" = this commit and "profile_sha256" = --profile-digest (the
56# freeze receipt is committed after C_f and before generation, BLINDING_PROTOCOL.md step 4);
57# sealed/<commit>/ already exists; N is missing or disagrees with the profile; a retry differs from the first
58# attempt; EXP-001 has already ended (final_receipt.json or three void receipts in the one VOID counter).
59#
60# FAILED ATTEMPTS (FAILURE_REPORTING.md section 2). A generation failure is an infrastructure failure: no score
61# exists yet, so it is a VOID attempt. Everything from the learner build on counts (learner build, generator or
62# learner pin mismatch, a seed that fails or whose jail does not start). The partial directory is renamed
63# sealed/<commit>.failed-<k> (k = 1, 2, 3: the generation attempt) with a FAILED note (reason, exact command,
64# time), kept and published with the results, never used; and a void receipt (stage "generation") is written into
65# the ONE counter of EXP-001, /<commit>/run/bundle/void_receipt_<n>.json (tc_void_lib.sh), which the
66# frozen-tree tests (record_void.sh) and the evaluator also use. A retry must be the byte-identical command. The
67# third void of the experiment, of any stage, writes final_receipt.json there (INCONCLUSIVE, reason INFRA); when a
68# generation failure is that third void, sealed/<commit>.INCONCLUSIVE_INFRA is written too.
69#
70# OUTPUT ~/aien-data/turing-cal/sealed/<commit>/
71# group-<g>/seed-<S>/control/{trace.ctr,samples.cts,evaluations.jsonl,ledger.jsonl,promotion.json}
72# group-<g>/seed-<S>/{report.json,control-outcomes.json}
73# seed_commitment.json seeds, rule, inputs, generator + learner hashes
74# manifest.json every file: SHA-256, bytes, records, volatile flag
75# generation.log per-seed wall time and exit code
76# COMPLETE written last; its absence means the set is unusable
77# The learning condition runs too (the generator always runs both, control first
78# and independently); its files are hashed into manifest.json and then deleted
79# unless --keep-learning. Directories end mode 0500 and files 0400.
80set -euo pipefail
81here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
82# shellcheck source=tc_jail_lib.sh
83. "$here/tc_jail_lib.sh"
84# shellcheck source=tc_void_lib.sh
85. "$here/tc_void_lib.sh"
86# shellcheck source=tc_exp.sh
87. "$here/tc_exp.sh"
88
89CRUMBS="${TC_CRUMBS:-$HOME/workspace/hive-worktrees/crumbs-v1/target/release/crumbs}"
90CRUMBS_SHA256=72e396b15532aa93afb1f215521e04dca8470f779f3de35c10b04b07bff96638
91# crumbline-learner built from omega 1b75aa8 (reproduces final-20260927 byte-exactly).
92LEARNER_SHA256="${TC_LEARNER_SHA256:-8159bdff248efa67fa2cf75bb0b506bc359f4a2269139d03479753c0fc393416}"
93TRIAL_ROOT="$HOME/aien-data/turing-cal/trial"
94DOMAIN="turing.cal.sealed.v1"
95PROFILE_PATH=$EXP_PROFILE
96SIDECAR_PATH=$EXP_SIDECAR
97CANDIDATE_MANIFEST=$EXP_DIR/candidate_manifest.json
98PROFILE_N_KEY=sealed_seeds_per_group
99
100die() { echo "generate_sealed_data: $*" >&2; exit 2; }
101sha() { sha256sum -- "$1" | cut -d' ' -f1; }
102
103is_burned_q=""
104commit="" digest="" n="" derive_only=0 trial_seed="" keep_learning=0 fetch=1
105orig_cmd="generate_sealed_data.sh $*"
106repo="$(git -C "$here" rev-parse --show-toplevel)"
107while [ $# -gt 0 ]; do
108 case "$1" in
109 --commit) commit="$2"; shift 2 ;;
110 --profile-digest) digest="$2"; shift 2 ;;
111 --n) n="$2"; shift 2 ;;
112 --derive-only) derive_only=1; shift ;;
113 --trial-seed) trial_seed="$2"; shift 2 ;;
114 --keep-learning) keep_learning=1; shift ;;
115 --no-fetch) fetch=0; shift ;;
116 --is-burned) is_burned_q="$2"; shift 2 ;;
117 --repo) repo="$2"; shift 2 ;;
118 *) die "unknown option '$1'" ;;
119 esac
120done
121
122derive_seed() { # commit digest group index
123 local h top
124 h="$(printf '%s' "$DOMAIN|$1|$2|g$3|$4" | sha256sum | cut -c1-16)"
125 top=$((16#${h:0:1} & 7))
126 printf '%d\n' "$((16#$(printf '%x' "$top")${h:1}))"
127}
128
129# Burned: dev seeds 0..10, 20260927, and (EXP-001R) the six EXP-001 sealed seeds (burned_seeds_exp001.txt).
130is_burned() { [ "$1" -le 10 ] || [ "$1" = 20260927 ] || { [ -n "$EXP_BURNED_FILE" ] && grep -qx -- "$1" "$here/../../$EXP_BURNED_FILE" 2>/dev/null; }; }
131# --is-burned SEED: self-test hook; exit 0 = burned (refused), 1 = usable.
132if [ -n "$is_burned_q" ]; then is_burned "$is_burned_q" && { echo "burned"; exit 0; }; echo "usable"; exit 1; fi
133
134# Build the learner from a clean export of REF into $1; echo its path.
135build_learner() {
136 local ref="$1" work="$2"
137 mkdir -p "$work/src" "$work/build" "$work/no-physics"
138 git -C "$repo" archive "$ref" | tar -x -C "$work/src"
139 make -s -C "$work/src" crumbline-learner OUT_DIR="$work/build" PHYSICS_DIR="$work/no-physics" \
140 >"$work/build.log" 2>&1 || { tail -20 "$work/build.log" >&2; die "learner build failed"; }
141 echo "$work/build/crumbline-learner"
142}
143
144check_binaries() { # learner
145 [ -x "$CRUMBS" ] || die "generator binary missing: $CRUMBS"
146 [ "$(sha "$CRUMBS")" = "$CRUMBS_SHA256" ] || die "generator SHA-256 $(sha "$CRUMBS") != pinned $CRUMBS_SHA256"
147 [ "$(sha "$1")" = "$LEARNER_SHA256" ] ||
148 die "learner SHA-256 $(sha "$1") != pinned $LEARNER_SHA256 (set TC_LEARNER_SHA256 only with a recorded reason)"
149}
150
151# Run one seed in the generation jail. Args: learner seed groupdir. Prints wall ns.
152run_seed() {
153 local learner="$1" seed="$2" gdir="$3" out t0 t1 rc
154 out="$gdir/seed-$seed"
155 [ -e "$out" ] && die "$out already exists (the generator appends; refusing)"
156 tc_base_args
157 TC_ARGS+=(--ro-bind "$(tc_real "$CRUMBS")" /opt/tc/crumbs --ro-bind "$(tc_real "$learner")" /opt/tc/crumbline-learner)
158 tc_rw "$gdir"
159 t0=$(date +%s%N)
160 set +e
161 "$TC_BWRAP" "${TC_ARGS[@]}" -- /opt/tc/crumbs experiment --learner /opt/tc/crumbline-learner \
162 --seed "$seed" --out "$(tc_real "$out")" >"$gdir/seed-$seed.stdout" 2>&1
163 rc=$?
164 set -e
165 t1=$(date +%s%N)
166 echo "$((t1 - t0)) $rc"
167}
168
169records_of() { # file -> record count (or -1 when the size is not a whole number of records)
170 local f="$1" b
171 b=$(stat -c %s "$f")
172 case "$f" in
173 *.ctr) [ $((b % 247)) = 0 ] && echo $((b / 247)) || echo -1 ;;
174 *.cts) [ $((b % 268)) = 0 ] && echo $((b / 268)) || echo -1 ;;
175 *.jsonl) wc -l <"$f" | tr -d ' ' ;;
176 *) echo null ;;
177 esac
178}
179
180volatile_of() { # files whose bytes carry uuid-v7 ids or wall-clock times
181 case "$1" in
182 */ledger.jsonl | */report.json | *-outcomes.json | *.stdout) echo true ;;
183 *) echo false ;;
184 esac
185}
186
187# ---------------------------------------------------------------- trial mode
188if [ -n "$trial_seed" ]; then
189 [[ "$trial_seed" =~ ^[0-9]+$ ]] || die "--trial-seed must be decimal"
190 is_burned "$trial_seed" && die "trial seed is a burned seed"
191 tc_have_bwrap
192 work="$(mktemp -d)"
193 trap 'rm -rf "$work"' EXIT
194 learner="$(build_learner "${commit:-HEAD}" "$work")"
195 check_binaries "$learner"
196 gdir="$TRIAL_ROOT/jail-trial"
197 mkdir -p "$gdir"
198 [ -e "$gdir/seed-$trial_seed" ] && die "$gdir/seed-$trial_seed already exists"
199 ns="" rc=""
200 read -r ns rc < <(run_seed "$learner" "$trial_seed" "$gdir") || true
201 [ -n "$rc" ] || die "generation jail did not start"
202 echo "trial seed $trial_seed rc=$rc wall_ms=$((ns / 1000000)) learner=$(sha "$learner")"
203 echo "control/trace.ctr $(sha "$gdir/seed-$trial_seed/control/trace.ctr")"
204 exit "$rc"
205fi
206
207# ------------------------------------------------------------- common checks
208[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || die "--commit must be a full 40-hex commit id"
209[[ "$digest" =~ ^[0-9a-f]{64}$ ]] || die "--profile-digest must be 64 lowercase hex"
210
211if [ "$derive_only" = 1 ]; then
212 [[ "$n" =~ ^[1-9][0-9]*$ ]] || die "--derive-only needs --n"
213 for g in 1 2; do
214 for ((j = 0; j < n; j++)); do echo "g$g $j $(derive_seed "$commit" "$digest" "$g" "$j")"; done
215 done
216 exit 0
217fi
218
219[ "$fetch" = 1 ] && git -C "$repo" fetch -q origin main
220git -C "$repo" cat-file -e "$commit^{commit}" 2>/dev/null || die "commit $commit not found"
221git -C "$repo" merge-base --is-ancestor "$commit" origin/main || die "commit $commit is not an ancestor of origin/main"
222git -C "$repo" cat-file -e "$commit:$CANDIDATE_MANIFEST" 2>/dev/null || die "$CANDIDATE_MANIFEST missing at $commit"
223git -C "$repo" cat-file -e "$commit:$PROFILE_PATH" 2>/dev/null || die "$PROFILE_PATH missing at $commit"
224pd="$(git -C "$repo" show "$commit:$PROFILE_PATH" | sha256sum | cut -d' ' -f1)"
225[ "$pd" = "$digest" ] || die "profile bytes at $commit hash to $pd, not --profile-digest $digest"
226# The freeze receipt (step 4) must already be on origin/main and name this commit (CAL-0 review 2 Q10).
227FR=$EXP_DIR/freeze_receipt.json
228fr="$(git -C "$repo" show "origin/main:$FR" 2>/dev/null)" || die "no $FR on origin/main: commit the freeze receipt (BLINDING_PROTOCOL.md step 4) first"
229grep -q '^ "TURING_PROFILE_V1_FROZEN": "PASS",$' <<<"$fr" || die "freeze receipt on origin/main is not TURING_PROFILE_V1_FROZEN = PASS"
230grep -q "^ \"freeze_commit\": \"$commit\",\$" <<<"$fr" || die "freeze receipt on origin/main names another freeze commit"
231grep -q "^ \"profile_sha256\": \"$digest\",\$" <<<"$fr" || die "freeze receipt on origin/main names another profile digest"
232cm_sha="$(git -C "$repo" show "$commit:$CANDIDATE_MANIFEST" | sha256sum | cut -d' ' -f1)"
233git -C "$repo" show "$commit:$CANDIDATE_MANIFEST" | grep -q "^ \"status\": \"frozen\"," ||
234 die "$CANDIDATE_MANIFEST at $commit is not frozen (the commit must be the freeze commit C_f)"
235git -C "$repo" show "$commit:$PROFILE_PATH" | grep -q FILL_AT_FREEZE && die "profile at $commit still holds FILL_AT_FREEZE"
236ctime_utc="$(date -u -d "@$(git -C "$repo" show -s --format=%ct "$commit")" +%Y-%m-%dT%H:%M:%SZ)"
237if git -C "$repo" cat-file -e "$commit:$SIDECAR_PATH" 2>/dev/null; then
238 sd="$(git -C "$repo" show "$commit:$SIDECAR_PATH" | awk '{print $1; exit}')"
239 [ "$sd" = "$digest" ] || die "sidecar digest $sd != --profile-digest $digest"
240else
241 die "$SIDECAR_PATH missing at $commit"
242fi
243pn="$(git -C "$repo" show "$commit:$PROFILE_PATH" | sed -n "s/^[[:space:]]*$PROFILE_N_KEY[[:space:]]*=[[:space:]]*\([0-9][0-9]*\).*/\1/p" | head -1)"
244if [ -n "$pn" ] && [ -n "$n" ] && [ "$pn" != "$n" ]; then die "--n $n disagrees with profile $PROFILE_N_KEY = $pn"; fi
245n="${n:-$pn}"
246[[ "$n" =~ ^[1-9][0-9]*$ ]] || die "N unknown: profile has no '$PROFILE_N_KEY = <int>' and no --n given"
247
248dest="$TC_SEALED_ROOT/$commit"
249[ -e "$dest.INCONCLUSIVE_INFRA" ] && die "three generation attempts already failed for $commit: $EXP_ID is INCONCLUSIVE (INFRA)"
250vdir="$(tc_void_dir "$commit")"
251tc_void_ended "$vdir" && die "$EXP_ID has ended: $vdir holds final_receipt.json or $TC_MAX_ATTEMPTS void receipts"
252attempt=1
253while [ -e "$dest.failed-$attempt" ]; do
254 first_cmd="$(sed -n "s/^command: //p" "$dest.failed-1/FAILED")"
255 [ "$first_cmd" = "$orig_cmd" ] || die "retry differs from attempt 1 ($first_cmd); a retry must be byte-identical"
256 attempt=$((attempt + 1))
257done
258[ "$attempt" -le "$TC_MAX_ATTEMPTS" ] || die "attempt $attempt: at most three attempts"
259[ -e "$dest" ] && die "$dest already exists (sealed data is generated exactly once per freeze commit)"
260tc_have_bwrap
261
262# Derive and check all seeds before generating anything.
263declare -A seen=()
264seeds=()
265for g in 1 2; do
266 for ((j = 0; j < n; j++)); do
267 s="$(derive_seed "$commit" "$digest" "$g" "$j")"
268 is_burned "$s" && die "derived seed g$g/$j = $s is a burned seed"
269 [ -n "${seen[$s]:-}" ] && die "derived seed $s repeats"
270 seen[$s]=1
271 seeds+=("$g $j $s")
272 done
273done
274
275work="$(mktemp -d)"
276trap 'rm -rf "$work"' EXIT
277learner=""
278
279# A failed attempt: keep the partial set under a numbered name with a FAILED note, write the void receipt into the
280# one $EXP_ID counter, then stop.
281fail_attempt() {
282 local k="$attempt" fd="$dest.failed-$attempt" n ls=NONE
283 [ -n "$learner" ] && [ -f "$learner" ] && ls="$(sha "$learner")"
284 mv "$dest" "$fd"
285 printf 'reason: %s\ncommand: %s\nattempt: %s\ntime_utc: %s\n' "$1" "$orig_cmd" "$k" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" >"$fd/FAILED"
286 n="$(tc_void_write "$commit" generation generate GENERATION "$1 (kept as $fd)" "$orig_cmd" \
287 "crumbs $CRUMBS_SHA256 learner $ls profile $digest" "$digest" "$cm_sha")" || die "cannot write the void receipt in $vdir"
288 if [ "$n" -ge "$TC_MAX_ATTEMPTS" ]; then
289 printf '$EXP_ID INCONCLUSIVE reason INFRA: void attempt %s of $EXP_ID was sealed generation attempt %s (%s)\n' "$n" "$k" "$vdir" >"$dest.INCONCLUSIVE_INFRA"
290 die "attempt $k failed ($1); void $n of $EXP_ID: $EXP_ID is INCONCLUSIVE (INFRA); publish every FAILED note and void receipt"
291 fi
292 die "attempt $k failed ($1); kept as $fd; void $n of $EXP_ID recorded in $vdir; retry with the byte-identical command"
293}
294umask 077
295mkdir -p "$TC_SEALED_ROOT"
296chmod 0700 "$TC_SEALED_ROOT"
297mkdir "$dest"
298learner="$(build_learner "$commit" "$work")" || fail_attempt "learner build failed"
299( check_binaries "$learner" ) || fail_attempt "generator or learner binary differs from its pin"
300log="$dest/generation.log"
301started="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
302echo "started $started commit $commit committed_utc $ctime_utc attempt $attempt profile_digest $digest n_per_group $n" >"$log"
303for row in "${seeds[@]}"; do
304 read -r g j s <<<"$row"
305 gdir="$dest/group-$g"
306 mkdir -p "$gdir"
307 [ -e "$gdir/seed-$s" ] && fail_attempt "$gdir/seed-$s already exists (the generator appends; refusing)"
308 ns="" rc=""
309 read -r ns rc < <(run_seed "$learner" "$s" "$gdir") || true
310 [ -n "$rc" ] || fail_attempt "generation jail did not start for seed $s"
311 echo "g$g j=$j seed=$s rc=$rc wall_ms=$((ns / 1000000))" >>"$log"
312 [ "$rc" = 0 ] || fail_attempt "generator failed for seed $s (rc $rc)"
313done
314
315# Manifest: every file, learning included, hashed before learning is dropped.
316seedlist_sha="$(printf '%s\n' "${seeds[@]}" | sha256sum | cut -d' ' -f1)"
317{
318 echo "{"
319 echo " \"schema\": \"turing.cal.sealed_manifest.v1\","
320 echo " \"freeze_commit\": \"$commit\","
321 echo " \"profile_digest\": \"$digest\","
322 echo " \"files\": ["
323 first=1
324 while IFS= read -r f; do
325 rel="${f#"$dest"/}"
326 [ "$rel" = generation.log ] && continue
327 kept=true
328 case "$rel" in */learning/* | */learning-outcomes.json) [ "$keep_learning" = 1 ] || kept=false ;; esac
329 [ "$first" = 1 ] || echo ","
330 first=0
331 printf ' {"path": "%s", "sha256": "%s", "bytes": %s, "records": %s, "volatile": %s, "kept": %s}' \
332 "$rel" "$(sha "$f")" "$(stat -c %s "$f")" "$(records_of "$f")" "$(volatile_of "$f")" "$kept"
333 done < <(find "$dest" -type f | LC_ALL=C sort)
334 echo
335 echo " ]"
336 echo "}"
337} >"$work/manifest.json"
338if [ "$keep_learning" = 0 ]; then
339 find "$dest" -mindepth 3 -maxdepth 3 -type d -name learning -exec rm -rf {} +
340 find "$dest" -mindepth 3 -maxdepth 3 -type f -name learning-outcomes.json -delete
341fi
342mv "$work/manifest.json" "$dest/manifest.json"
343
344{
345 echo "{"
346 echo " \"schema\": \"turing.cal.seed_commitment.v1\","
347 echo " \"rule\": \"seed = (first 16 hex of SHA-256(ASCII '$DOMAIN|<commit>|<profile_digest>|g<group>|<index>')) with top bit cleared, decimal\","
348 echo " \"domain\": \"$DOMAIN\","
349 echo " \"freeze_commit_time_utc\": \"$ctime_utc\","
350 echo " \"attempt\": $attempt,"
351 echo " \"freeze_commit\": \"$commit\","
352 echo " \"profile_digest\": \"$digest\","
353 echo " \"n_per_group\": $n,"
354 echo " \"groups\": {\"1\": \"primary sealed test\", \"2\": \"second-seed replication\"},"
355 echo " \"seeds\": ["
356 i=0
357 for row in "${seeds[@]}"; do
358 read -r g j s <<<"$row"
359 [ "$i" = 0 ] || echo ","
360 i=1
361 printf ' {"group": %s, "index": %s, "seed": %s}' "$g" "$j" "$s"
362 done
363 echo
364 echo " ],"
365 echo " \"seed_list_sha256\": \"$seedlist_sha\","
366 echo " \"seed_list_format\": \"one line per seed: '<g> <index> <seed>' in group then index order, LF-terminated\","
367 echo " \"generator\": {\"path\": \"$CRUMBS\", \"sha256\": \"$CRUMBS_SHA256\","
368 echo " \"command\": \"crumbs experiment --learner <learner> --seed <seed> --out <dir>\"},"
369 echo " \"learner\": {\"sha256\": \"$(sha "$learner")\", \"build\": \"git archive $commit | make crumbline-learner\"},"
370 echo " \"learning_condition_kept\": $([ "$keep_learning" = 1 ] && echo true || echo false),"
371 echo " \"started_utc\": \"$started\","
372 echo " \"finished_utc\": \"$(date -u +%Y-%m-%dT%H:%M:%SZ)\","
373 echo " \"manifest_sha256\": \"$(sha "$dest/manifest.json")\""
374 echo "}"
375} >"$dest/seed_commitment.json"
376
377# Hard links would let a path outside the sealed root reach sealed bytes.
378bad="$(find "$dest" -type f -links +1 | head -1)"
379[ -z "$bad" ] || die "sealed file has extra hard links: $bad"
380echo "complete $(date -u +%Y-%m-%dT%H:%M:%SZ) seed_commitment_sha256 $(sha "$dest/seed_commitment.json")" >>"$log"
381sha "$dest/seed_commitment.json" >"$dest/COMPLETE"
382find "$dest" -type f -exec chmod 0400 {} +
383find "$dest" -type d -exec chmod 0500 {} +
384echo "sealed data ready: $dest"
385echo "seed_commitment.json sha256 $(cat "$dest/COMPLETE")"