build-configurations.sh (3287B)
1 #!/usr/bin/env bash 2 # Example selection data; shared result/bin/tricu scp owns process/deadline handling. 3 # 4 # Read this as two separate operations: build reusable code, then explicitly 5 # run configuration exports. Building an export does NOT invoke it. 6 # STORE is a CAS directory; COMPILER_DIGEST is the caller-declared compiler 7 # identity (see docs/consumers.md for a recipe), not a compiler attestation. 8 # PHASE_SECONDS bounds each child process, not the complete script or a proof 9 # that the program terminates. This script prepares programs; it runs no input. 10 # 11 # From the repository root, with COMPILER_DIGEST already set: 12 # < bash demos/consumers/configurations/build-configurations.sh /tmp/scp-demo "$COMPILER_DIGEST" 240 configureData 13 # > code-manifest=<hash>, code-receipt=<hash>, selection=configureData, 14 # > workers=<hash>, invocations=<hash>, configuration-receipt=<hash> 15 # The actual output is one key=value per line; hashes are not fixed answers. 16 set -euo pipefail 17 if [[ $# -lt 3 ]]; then 18 printf 'Usage: %s STORE COMPILER_DIGEST PHASE_SECONDS [ENTRY ...]\n' "$0" >&2 19 exit 2 20 fi 21 store="$1"; compiler="$2"; seconds="$3"; shift 3 22 repo="$(cd "$(dirname "$0")/../../.." && pwd)" 23 bootstrap="${SCP_BOOTSTRAP:-$repo/.bootstrap-run/scp-bootstrap}" 24 tricu="${TRICU:-$repo/result/bin/tricu}" 25 # Omit entry names to prepare all three examples, or name only the desired 26 # configuration. These are configuration exports, not runtime input handlers. 27 selections=("$@") 28 if [[ ${#selections[@]} == 0 ]]; then selections=(configureData configureNonempty configureCounter); fi 29 # 1. The workspace request selects source paths/frontends and the root unit. 30 # Its shared graph resolves dependencies and publishes compiled open entries. 31 # code-manifest identifies exact exported trees; code-receipt records build 32 # inputs/provenance. A comment edit can change the receipt without changing code. 33 code="$("$tricu" scp build --bootstrap "$bootstrap" --store "$store" --compiler "$compiler" \ 34 --seconds "$seconds" --directory "$repo" --workspace demos.consumer-configuration-workspace)" 35 printf '%s\n' "$code" 36 manifest="$(printf '%s\n' "$code" | sed -n 's/^code-manifest=//p')" 37 # 2. Each configuration computes its worker wiring in SCP from the SAME code 38 # manifest. These particular exports ignore input/state; --input-leaf and 39 # --state-leaf still supply both explicitly rather than inventing defaults. 40 # workers names the descriptors (initial state + entry); invocations names 41 # callable wrappers preserving success/failure Result data. The configuration 42 # receipt relates these outputs to the selected code, input and state. 43 for entry in "${selections[@]}"; do 44 printf 'selection=%s\n' "$entry" 45 "$tricu" scp configure --bootstrap "$bootstrap" --store "$store" --seconds "$seconds" \ 46 --code "$manifest" --entry "$entry" --input-leaf --state-leaf 47 done 48 # Try configureNonempty instead: the shared dataLines entry is unchanged, 49 # but its configured predicate retains #-prefixed lines as well as data lines. 50 # For runtime calls, use the printed invocations hash, not the workers hash: 51 # < result/bin/tricu scp --help 52 # < result/bin/tricu arboricx run --store /tmp/scp-demo --module INVOCATIONS_HASH --name dataLines --arg $'alpha\n\n# note\nbeta\n' --format decode 53 # > [t t, ["alpha", "beta"]]