gander: preserve row 196 human boundary build for rebase
This commit is contained in:
1 parent
a365237133
commit
64539c96bb
97 files changed
+10407
-182
No files matched your search
+54
-22
@@ -37,14 +37,14 @@ source scripts/instance.sh
|
||||
COPIES="${XDG_DATA_HOME:-$HOME/.local/share}/mosaic-stack/copies"
|
||||
BIN="$HOME/.npm-global/bin"
|
||||
UNIT_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/systemd/user"
|
||||
TIMEOUT=60 WANT_PM=0 AFTER_HARNESS=0 MIGRATE=0 PLAN=0 RESTORE="" EVENTS="" TESTER_PORT=""
|
||||
TIMEOUT=60 WANT_PM=0 AFTER_HARNESS=0 MIGRATE=0 PLAN=0 RESTORE="" EVENTS="" TESTER_PORT="" TESTER_SOCKET=0 EXPECTED_INTERPRETER=""
|
||||
PROOF_HEADER="" PROOF_FILE="" NO_PROOF=0 NO_SEND=0 SSO=0 R_BACKUP="" R_PORT=""
|
||||
UNITS=user TO_FLAG="" EXPECT_FROM="" SINCE="" ROLLBACK_OLD="" CAUSE=""
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'USAGE'
|
||||
usage: stack-release.sh adopt BUSINESS
|
||||
stack-release.sh activate ID BUSINESS [--pm | --pm-after-harness] [--migrate] [--tester-port N]
|
||||
stack-release.sh activate ID BUSINESS [--pm | --pm-after-harness] [--migrate] [--tester-socket | --tester-port N (legacy copies)]
|
||||
[--proof-header NAME --proof-file PATH | --no-proof | --sso] [--no-send] [--timeout S] [--plan]
|
||||
stack-release.sh pm-on BUSINESS [--timeout S]
|
||||
stack-release.sh rollback BUSINESS [--restore ACTIVATION [--events N]] [--timeout S] [--plan]
|
||||
@@ -122,6 +122,7 @@ parse_opts() {
|
||||
--plan) [ "$OP" = activate ] || [ "$OP" = rollback ] || usage; PLAN=1; shift ;;
|
||||
--pm) [ "$OP" = activate ] || usage; WANT_PM=1; shift ;;
|
||||
--pm-after-harness) [ "$OP" = activate ] || usage; AFTER_HARNESS=1; shift ;;
|
||||
--tester-socket) [ "$OP" = activate ] || usage; TESTER_SOCKET=1; shift ;;
|
||||
--tester-port) [ "$OP" = activate ] && [ $# -ge 2 ] && [ -n "$2" ] || usage; TESTER_PORT="$2"; shift 2 ;;
|
||||
--proof-header) [ "$OP" = activate ] && [ $# -ge 2 ] && [ -n "$2" ] || usage; PROOF_HEADER="$2"; shift 2 ;;
|
||||
--proof-file) [ "$OP" = activate ] && [ $# -ge 2 ] && [ -n "$2" ] || usage; PROOF_FILE="$2"; shift 2 ;;
|
||||
@@ -149,11 +150,12 @@ parse_opts() {
|
||||
[ "$OP" != confirm ] && [ "$OP" != revert ] && [ "$OP" != gate ] && [ -z "$TO_FLAG" ] && [ -z "$EXPECT_FROM" ] || usage
|
||||
else
|
||||
[ "$OP" != rollback ] || [ -n "$TO_FLAG" ] || usage
|
||||
[ "$WANT_PM" = 0 ] && [ -z "$TESTER_PORT" ] && [ -z "$PROOF_HEADER" ] && [ -z "$PROOF_FILE" ] && [ "$NO_PROOF" = 0 ] && [ "$NO_SEND" = 0 ] && [ "$SSO" = 0 ] || usage
|
||||
[ "$TESTER_SOCKET" = 0 ] && [ "$WANT_PM" = 0 ] && [ -z "$TESTER_PORT" ] && [ -z "$PROOF_HEADER" ] && [ -z "$PROOF_FILE" ] && [ "$NO_PROOF" = 0 ] && [ "$NO_SEND" = 0 ] && [ "$SSO" = 0 ] || usage
|
||||
fi
|
||||
[ "$OP" != gate ] || [ -n "$SINCE" ] || usage
|
||||
[ -z "$EXPECT_FROM" ] || [ "$PLAN" = 1 ] || usage
|
||||
[ "${ROLLBACK_OLD:+1}" = "${CAUSE:+1}" ] || usage
|
||||
[ "$TESTER_SOCKET" = 0 ] || [ -z "$TESTER_PORT" ] || usage
|
||||
[ -z "$EVENTS" ] || [ -n "$RESTORE" ] || usage
|
||||
[ "$OP" != rehearse ] || { [ -n "$R_BACKUP" ] && [ -n "$R_PORT" ]; } || usage
|
||||
# A bad tester port is a usage error; --plan lists it as tester-port-invalid instead (row 180).
|
||||
@@ -567,6 +569,10 @@ gate_once() {
|
||||
[ "$out" -ge "$FLOOR" ] || { GATE_WHY="the bus started at @$out, before @$FLOOR"; return 1; }
|
||||
START_MS=$((out * 1000))
|
||||
fi
|
||||
if [ -f "$copy/packages/bus/src/interpreter.mjs" ]; then
|
||||
GATE=interpreter-receipt
|
||||
node -e 'import(require("url").pathToFileURL(process.argv[1]).href).then(m=>{const expected=m.inspectInterpreter();if(process.argv[4]&&JSON.stringify(expected)!==process.argv[4])process.exit(1);m.verifyInterpreterReceipt(process.argv[2],expected,process.argv[3]);}).catch(()=>process.exit(1));' -- "$copy/packages/bus/src/interpreter.mjs" "$DATA/bus" "$START_MS" "$EXPECTED_INTERPRETER" || return 1
|
||||
fi
|
||||
GATE=bus-status
|
||||
main="$(sc show "$BUS_UNIT" -p MainPID | sed -n 's/^MainPID=//p')" || return 1
|
||||
out="$("$copy/scripts/mosaic" bus status --json 2>/dev/null)" || { GATE_WHY="bus status failed"; return 1; }
|
||||
@@ -783,22 +789,39 @@ flags_drift() {
|
||||
# unit still refuses drift and a failed attempt can restore exactly the captured stack.
|
||||
# Read the target's own Console, because old copies cannot start with the new flag.
|
||||
console_for_target() {
|
||||
local supported=0 main=7332 inherited="" i
|
||||
local supported=0 socket_supported=0 main=7332 inherited="" inherited_socket=0 i
|
||||
local cli="$COPIES/$TO/packages/webui/src/cli.mjs"
|
||||
local -a without_tester=()
|
||||
sso_base
|
||||
grep -q -- '--tester-port' "$COPIES/$TO/packages/webui/src/cli.mjs" && supported=1
|
||||
if grep -q 'MOSAIC_TESTER_SOCKET_V1' "$cli"; then socket_supported=1
|
||||
elif grep -q -- '--tester-port' "$cli"; then supported=1; fi
|
||||
for ((i = 0; i < ${#BASE_CONSOLE[@]}; i++)); do
|
||||
if [ "${BASE_CONSOLE[i]}" = --tester-port ]; then
|
||||
i=$((i + 1)); inherited="${BASE_CONSOLE[i]:-}"
|
||||
else
|
||||
without_tester+=("${BASE_CONSOLE[i]}")
|
||||
if [ "${BASE_CONSOLE[i]}" = --port ]; then main="${BASE_CONSOLE[i+1]:-7332}"; fi
|
||||
fi
|
||||
case "${BASE_CONSOLE[i]}" in
|
||||
--tester-port) i=$((i + 1)); inherited="${BASE_CONSOLE[i]:-}" ;;
|
||||
--tester-socket) inherited_socket=1 ;;
|
||||
*) without_tester+=("${BASE_CONSOLE[i]}")
|
||||
if [ "${BASE_CONSOLE[i]}" = --port ]; then main="${BASE_CONSOLE[i+1]:-7332}"; fi ;;
|
||||
esac
|
||||
done
|
||||
RUN_CONSOLE=("${BASE_CONSOLE[@]}")
|
||||
DROP_TESTER=""
|
||||
if [ -n "$TESTER_PORT" ]; then
|
||||
# --plan lists both with its other refusals (row 180); outside it they end the run.
|
||||
RUN_CONSOLE=("${BASE_CONSOLE[@]}") DROP_TESTER="" EXPECTED_INTERPRETER=""
|
||||
if [ "$socket_supported" = 1 ]; then
|
||||
[ -z "$TESTER_PORT" ] || check_refuse tester-port-target "$TO retires tester TCP; use --tester-socket"
|
||||
if [ -n "$inherited" ] && [ "$TESTER_SOCKET" = 0 ]; then
|
||||
check_refuse tester-transport-migration "inherited tester TCP requires explicit --tester-socket conversion"
|
||||
fi
|
||||
if [ "$TESTER_SOCKET" = 1 ] || [ "$inherited_socket" = 1 ]; then
|
||||
RUN_CONSOLE=("${without_tester[@]}" --tester-socket)
|
||||
[ -z "$inherited" ] || DROP_TESTER="--tester-port $inherited (replaced by private Unix socket)"
|
||||
node -e 'const fs=require("fs"),p=require("path"),root=process.argv[1],parent=p.join(root,"console");if(!p.isAbsolute(root)||Buffer.byteLength(p.join(parent,"tester.sock"))>107)process.exit(1);try{const s=fs.lstatSync(parent);if(!s.isDirectory()||s.isSymbolicLink()||s.uid!==process.getuid()||(s.mode&0o077))process.exit(1);}catch(e){if(e.code!=="ENOENT")process.exit(1);}' -- "$DATA" || check_refuse tester-socket-path "private tester path is too long or its parent is unsafe"
|
||||
fi
|
||||
local module="$COPIES/$TO/packages/bus/src/interpreter.mjs"
|
||||
[ -f "$module" ] || check_refuse interpreter-unsafe "$TO lacks its interpreter verifier"
|
||||
if [ -f "$module" ]; then
|
||||
EXPECTED_INTERPRETER="$(node -e 'import(require("url").pathToFileURL(process.argv[1]).href).then(m=>console.log(JSON.stringify(m.inspectInterpreter())),()=>process.exit(1)).catch(()=>process.exit(1))' -- "$module")" || check_refuse interpreter-unsafe "system Python preflight refused"
|
||||
fi
|
||||
elif [ "$TESTER_SOCKET" = 1 ]; then
|
||||
check_refuse tester-socket-target "$TO does not support --tester-socket"
|
||||
elif [ -n "$TESTER_PORT" ]; then
|
||||
if ! valid_tester_port "$TESTER_PORT" "$main"; then
|
||||
[ "$PLAN" = 1 ] || usage
|
||||
local other=""
|
||||
@@ -808,9 +831,10 @@ console_for_target() {
|
||||
fi
|
||||
[ "$supported" = 1 ] || check_refuse tester-port-target "$TO's Console does not support --tester-port"
|
||||
RUN_CONSOLE=("${without_tester[@]}" --tester-port "$TESTER_PORT")
|
||||
elif [ "$inherited_socket" = 1 ]; then
|
||||
RUN_CONSOLE=("${without_tester[@]}") DROP_TESTER="--tester-socket (tester disabled; no TCP fallback)"
|
||||
elif [ -n "$inherited" ] && [ "$supported" = 0 ]; then
|
||||
RUN_CONSOLE=("${without_tester[@]}")
|
||||
DROP_TESTER="--tester-port $inherited"
|
||||
RUN_CONSOLE=("${without_tester[@]}") DROP_TESTER="--tester-port $inherited"
|
||||
fi
|
||||
if [ "$SSO" = 1 ]; then sso_for_target; else proof_for_target; fi
|
||||
send_for_target
|
||||
@@ -859,6 +883,7 @@ sso_base() {
|
||||
case "${SERVE_FLAGS[i]}" in
|
||||
--send) ;;
|
||||
--tester-port) i=$((i + 1)) ;;
|
||||
--tester-socket) ;;
|
||||
*) BASE_CONSOLE+=("${SERVE_FLAGS[i]}") ;;
|
||||
esac
|
||||
done
|
||||
@@ -866,6 +891,7 @@ sso_base() {
|
||||
case "${P_CONSOLE[i]}" in
|
||||
--send) BASE_CONSOLE+=(--send) ;;
|
||||
--tester-port) i=$((i + 1)); BASE_CONSOLE+=(--tester-port "${P_CONSOLE[i]:-}") ;;
|
||||
--tester-socket) BASE_CONSOLE+=(--tester-socket) ;;
|
||||
esac
|
||||
done
|
||||
SSO_PLAN="sso: dropped; $TO's Console does not support --sso, so the rollback takes the Console flags from $set/$f, with --send and --tester-port as the pointer has them"
|
||||
@@ -890,7 +916,7 @@ sso_for_target() {
|
||||
done
|
||||
RUN_CONSOLE=()
|
||||
for ((i = 0; i < ${#kept[@]}; i++)); do
|
||||
case "${kept[i]}" in --send | --tester-port) break ;; esac
|
||||
case "${kept[i]}" in --send | --tester-port | --tester-socket) break ;; esac
|
||||
RUN_CONSOLE+=("${kept[i]}")
|
||||
done
|
||||
RUN_CONSOLE+=(--sso "${kept[@]:i}")
|
||||
@@ -1044,10 +1070,10 @@ proof_for_target() {
|
||||
fi
|
||||
if [ -n "$PROOF_HEADER" ]; then
|
||||
# webui-service.sh renders the pair after the preview flags and before --send and
|
||||
# --tester-port, and flags_drift compares the pointer with that argv as it stands.
|
||||
# tester flags, and flags_drift compares the pointer with that argv as it stands.
|
||||
header="$PROOF_HEADER" file="$PROOF_FILE" RUN_CONSOLE=()
|
||||
for ((i = 0; i < ${#without_proof[@]}; i++)); do
|
||||
case "${without_proof[i]}" in --send | --tester-port) break ;; esac
|
||||
case "${without_proof[i]}" in --send | --tester-port | --tester-socket) break ;; esac
|
||||
RUN_CONSOLE+=("${without_proof[i]}")
|
||||
done
|
||||
RUN_CONSOLE+=(--proof-header "$header" --proof-file "$file" "${without_proof[@]:i}")
|
||||
@@ -1297,6 +1323,7 @@ plan() {
|
||||
echo "Console: scripts/webui-service.sh install $flags--copy $TO --copies $COPIES${RUN_CONSOLE[*]:+ ${RUN_CONSOLE[*]}}"
|
||||
fi
|
||||
echo "CLI: scripts/stack-copy.sh wrapper $TO $flags--copies $COPIES --bin $BIN"
|
||||
[ -z "$EXPECTED_INTERPRETER" ] || echo "interpreter: $EXPECTED_INTERPRETER"
|
||||
local r
|
||||
for r in "${PLAN_REFUSE[@]}"; do echo "refuses $r"; done
|
||||
[ "${#PLAN_REFUSE[@]}" = 0 ] || exit 3
|
||||
@@ -1304,7 +1331,10 @@ plan() {
|
||||
|
||||
# Steps 4.1 to 4.5 and the gate for target $TO. $1 is the store step: migrate or restore.
|
||||
run_steps() {
|
||||
log_line result started
|
||||
if [ -n "$EXPECTED_INTERPRETER" ]; then
|
||||
log_line result started interpreter "$EXPECTED_INTERPRETER"
|
||||
say "interpreter: $EXPECTED_INTERPRETER"
|
||||
else log_line result started; fi
|
||||
capture || refuse capture-failed "could not write the rollback set $RS; nothing was stopped"
|
||||
[ -z "$DROP_TESTER" ] || say "drop $DROP_TESTER; the target Console does not support it"
|
||||
[ -z "$PROOF_STEP" ] || say "$PROOF_STEP"
|
||||
@@ -2120,7 +2150,9 @@ do_rehearse() {
|
||||
# itself (env execs scripts/mosaic, which execs node), for the bus-status pid check and the stop.
|
||||
env -i HOME="$HOME" PATH="$PATH" MOSAIC_CONFIG="$R/config/config.json" "$COPIES/$TO/scripts/mosaic" bus start "$BUSINESS" --no-launch > "$R/host.log" 2>&1 &
|
||||
R_HOST_PID=$!
|
||||
env -i HOME="$HOME" PATH="$PATH" MOSAIC_CONFIG="$R/config/config.json" node "$COPIES/$TO/packages/webui/src/cli.mjs" serve --port "$R_PORT" --business "$BUSINESS" > "$R/console.log" 2>&1 &
|
||||
local -a tester_rehearsal=()
|
||||
if grep -q 'MOSAIC_TESTER_SOCKET_V1' "$COPIES/$TO/packages/webui/src/cli.mjs"; then tester_rehearsal=(--tester-socket); fi
|
||||
env -i HOME="$HOME" PATH="$PATH" MOSAIC_CONFIG="$R/config/config.json" node "$COPIES/$TO/packages/webui/src/cli.mjs" serve --port "$R_PORT" --business "$BUSINESS" "${tester_rehearsal[@]}" > "$R/console.log" 2>&1 &
|
||||
R_CONSOLE_PID=$!
|
||||
if r_gate; then r_no_session; fi
|
||||
r_end
|
||||
|
||||
Reference in new issue
Block a user