Phase 6, the last of the fresh-install spec. 159 scripts lose their .sh: 110 contracts, 47 Vicinae commands, 2 compositor contracts. A shebang and the executable bit already select the interpreter. The extension only ever added something that had to stay in sync, and the rename proved the point twice over in the space of an hour. The spec's stated risk was Vicinae's script discovery. One script was renamed and reloaded on its own before the other 46 followed; it came back as scripts:panama.capture and all 47 resolve. What the probe turned up instead is that the extension was never only a filename: Vicinae's command IDs embed it, so every ID changed. Nothing in this repository refers to them, so nothing breaks. The only trace is Vicinae's metadata.json, whose visited map had two Panama entries that are now orphaned -- two commands lost their usage ranking and will earn it back. Worth knowing before anyone renames these again on a machine that has a keybind pointing at one. Rewriting the references by exact filename missed two things it structurally could not see: a name built from a variable, settings-$page.sh, and a glob, -name '*.sh'. Both were in the contract that counts the generated commands, which promptly reported 47 expected and 0 found. The mechanical part of a rename is the part that looks finished. The three subcommands. panama doctor fronts a health check that already existed and already ran at the end of every install but could not be reached from a terminal. panama upgrade re-runs the installer from anywhere. panama test runs the suite, which had no entry point at all -- 121 files that were the main safety net in this repository and were invisible in it. Writing that runner found three tests nothing was running. calendar_agenda_bridge_test, home_assistant_bridge_test and kdeconnect_bridge_test are unittest suites without the executable bit, so no contract invoked them and the first draft of the runner skipped them silently. All three pass, and have passed unobserved for weeks. The runner collects *_test.py as well now, because a runner with a blind spot is worse than no runner for the same reason a dependency checker with one is: it reports PASS. Six worktrees pruned. Each was re-checked rather than trusted to the spec's list, and two needed it: panama-commands is not on feat/panama-commands but on feat/gnome-tweaks-parity, and fix/panama-displays-review reads [ahead 3] -- ahead of its remote, not of main, with every commit patch-equivalent to landed work. roadmap-completion stays; it has five commits that are genuinely unlanded. The branches are left alone: pruning a worktree costs nothing, deleting a branch is a decision. 121 contracts pass. Claude-Session: https://claude.ai/code/session_01NvgBuSWB5sE43yWmg21ozj
150 lines
6.8 KiB
Bash
Executable File
150 lines
6.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# The preference store is derived from config/PreferenceSchema.qml rather than
|
|
# restating each key. This contract pins the properties that derivation is
|
|
# supposed to buy, so that a future change cannot quietly reintroduce the
|
|
# hand-maintained variant:
|
|
#
|
|
# * every schema key round-trips through disk
|
|
# * out-of-range numbers are clamped, not stored raw and not rejected
|
|
# * unknown keys in the file are preserved across a write
|
|
# * set() refuses a key that is not in the schema
|
|
# * reset() restores *every* schema default with no hand-written list
|
|
# * a corrupt file yields shipped defaults rather than a broken shell
|
|
|
|
set -euo pipefail
|
|
|
|
repo_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
harness="$repo_dir/config/dot/quickshell/preference-schema-harness.qml"
|
|
state_home="$(mktemp -d /tmp/panama-schema-state.XXXXXX)"
|
|
config_home="$(mktemp -d /tmp/panama-schema-config.XXXXXX)"
|
|
store="$config_home/panama/settings.json"
|
|
|
|
fail() {
|
|
printf 'preference schema contract: %s\n' "$1" >&2
|
|
exit 1
|
|
}
|
|
|
|
qs_for_harness() {
|
|
XDG_STATE_HOME="$state_home" XDG_CONFIG_HOME="$config_home" qs -p "$harness" "$@"
|
|
}
|
|
|
|
cleanup() {
|
|
qs_for_harness kill >/dev/null 2>&1 || true
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
start_harness() {
|
|
XDG_STATE_HOME="$state_home" XDG_CONFIG_HOME="$config_home" qs -p "$harness" --daemonize >/dev/null
|
|
for _ in $(seq 1 40); do
|
|
if qs_for_harness ipc show 2>/dev/null | rg -q '^target preference-schema-test$'; then
|
|
return
|
|
fi
|
|
sleep 0.1
|
|
done
|
|
fail 'test IPC target did not start'
|
|
}
|
|
|
|
stop_harness() {
|
|
qs_for_harness kill >/dev/null 2>&1 || true
|
|
for _ in $(seq 1 40); do
|
|
# A bare `return` would propagate the failed `ipc show` status, which
|
|
# under `set -e` ends the whole contract instead of the function.
|
|
qs_for_harness ipc show >/dev/null 2>&1 || return 0
|
|
sleep 0.1
|
|
done
|
|
fail 'test shell did not stop cleanly'
|
|
}
|
|
|
|
wait_for_store() {
|
|
for _ in $(seq 1 40); do
|
|
[[ -f "$store" ]] && jq -e . "$store" >/dev/null 2>&1 && return
|
|
sleep 0.1
|
|
done
|
|
fail 'preferences file was not written'
|
|
}
|
|
|
|
# ── A fresh store reports schema defaults ────────────────────────────────────
|
|
start_harness
|
|
key_count="$(qs_for_harness ipc call preference-schema-test keyCount)"
|
|
[[ "$key_count" -gt 0 ]] || fail 'schema is empty'
|
|
|
|
initial="$(qs_for_harness ipc call preference-schema-test dump | jq -cS .)"
|
|
defaults="$(qs_for_harness ipc call preference-schema-test defaults | jq -cS .)"
|
|
[[ "$initial" == "$defaults" ]] || fail "a fresh store did not report schema defaults: $initial"
|
|
|
|
# ── Out-of-range numbers are clamped, not stored raw ─────────────────────────
|
|
qs_for_harness ipc call preference-schema-test applyJson \
|
|
'{"dockHideDelayMs": 99999, "nightLightTemperature": 100, "focusDurationMinutes": 45}' >/dev/null
|
|
clamped="$(qs_for_harness ipc call preference-schema-test dump)"
|
|
[[ "$(jq -r .dockHideDelayMs <<<"$clamped")" == "2000" ]] \
|
|
|| fail "an above-range value was not clamped to the schema maximum: $(jq -r .dockHideDelayMs <<<"$clamped")"
|
|
[[ "$(jq -r .nightLightTemperature <<<"$clamped")" == "2000" ]] \
|
|
|| fail "a below-range value was not clamped to the schema minimum: $(jq -r .nightLightTemperature <<<"$clamped")"
|
|
|
|
# ── An unknown key is refused rather than silently accepted ──────────────────
|
|
verdict="$(qs_for_harness ipc call preference-schema-test applyJson '{"__not_a_setting__": 1}')"
|
|
[[ "$(jq -r .__not_a_setting__ <<<"$verdict")" == "false" ]] || fail 'set() accepted a key outside the schema'
|
|
qs_for_harness ipc call preference-schema-test dump | jq -e 'has("__not_a_setting__") | not' >/dev/null \
|
|
|| fail 'a key outside the schema entered the store'
|
|
|
|
# ── An out-of-range enum value is refused ────────────────────────────────────
|
|
verdict="$(qs_for_harness ipc call preference-schema-test applyJson '{"vrrPolicy": 7}')"
|
|
[[ "$(jq -r .vrrPolicy <<<"$verdict")" == "false" ]] || fail 'set() accepted an enum value outside its options'
|
|
|
|
# ── Every schema key round-trips across a restart ────────────────────────────
|
|
qs_for_harness ipc call preference-schema-test applyJson \
|
|
'{"use24Hour": true, "showSeconds": false, "showWeekday": false, "showCpu": false,
|
|
"showMemory": false, "showGpu": false, "dockAutohide": false, "dockRevealDelayMs": 75,
|
|
"dockHideDelayMs": 400, "focusDurationMinutes": 25, "autoHdr": false, "vrrPolicy": 0,
|
|
"directScanoutPolicy": 0, "nightLightEnabled": true, "nightLightAutomatic": true,
|
|
"nightLightTemperature": 4100, "lastPage": "desktop"}' >/dev/null
|
|
wait_for_store
|
|
before="$(qs_for_harness ipc call preference-schema-test dump | jq -cS .)"
|
|
[[ "$before" != "$defaults" ]] || fail 'the fixture did not change anything'
|
|
|
|
stop_harness
|
|
start_harness
|
|
after=""
|
|
for _ in $(seq 1 40); do
|
|
after="$(qs_for_harness ipc call preference-schema-test dump | jq -cS .)"
|
|
[[ "$after" == "$before" ]] && break
|
|
sleep 0.1
|
|
done
|
|
[[ "$after" == "$before" ]] || fail "values did not survive a restart: $after"
|
|
|
|
# ── A key this build does not know is carried through, not dropped ───────────
|
|
stop_harness
|
|
jq '. + {"__future_setting__": "keep me"}' "$store" >"$store.tmp" && mv "$store.tmp" "$store"
|
|
start_harness
|
|
qs_for_harness ipc call preference-schema-test applyJson '{"dockHideDelayMs": 500}' >/dev/null
|
|
for _ in $(seq 1 40); do
|
|
jq -e '.__future_setting__ == "keep me" and .dockHideDelayMs == 500' "$store" >/dev/null 2>&1 && break
|
|
sleep 0.1
|
|
done
|
|
jq -e '.__future_setting__ == "keep me"' "$store" >/dev/null \
|
|
|| fail 'a setting from a newer build was dropped on write'
|
|
|
|
# ── reset() restores every schema key, with no hand-maintained list ──────────
|
|
qs_for_harness ipc call preference-schema-test reset >/dev/null
|
|
restored=""
|
|
for _ in $(seq 1 40); do
|
|
restored="$(qs_for_harness ipc call preference-schema-test dump | jq -cS .)"
|
|
[[ "$restored" == "$defaults" ]] && break
|
|
sleep 0.1
|
|
done
|
|
[[ "$restored" == "$defaults" ]] || fail "reset did not restore every schema default: $restored"
|
|
jq -e '.__future_setting__ == "keep me"' "$store" >/dev/null \
|
|
|| fail 'reset discarded a setting it does not own'
|
|
|
|
# ── A corrupt file degrades to defaults instead of breaking the shell ────────
|
|
stop_harness
|
|
printf '{ this is not json' >"$store"
|
|
start_harness
|
|
corrupt="$(qs_for_harness ipc call preference-schema-test dump | jq -cS .)"
|
|
[[ "$corrupt" == "$defaults" ]] || fail "a corrupt store did not fall back to defaults: $corrupt"
|
|
|
|
trap - EXIT
|
|
cleanup
|
|
printf 'preference schema contract: PASS\n'
|