diff --git a/pm-stack/aggregator/scripts/age-feed-drill.sh b/pm-stack/aggregator/scripts/age-feed-drill.sh index 45ff83b77..ff36c5669 100755 --- a/pm-stack/aggregator/scripts/age-feed-drill.sh +++ b/pm-stack/aggregator/scripts/age-feed-drill.sh @@ -69,6 +69,12 @@ # PM_DRILL_NO_POST=1 skip the GitHub comment/issue side effects set -uo pipefail +# Argument contract (#3352): this script takes no command-line +# arguments; anything given is a usage error before any work runs. +if [ "$#" -gt 0 ]; then + echo "age-feed-drill.sh: unexpected argument '$1'; usage: bash scripts/age-feed-drill.sh (knobs are PM_DRILL_* environment variables)" >&2 + exit 2 +fi STATE_DIR="${PM_DRILL_STATE_DIR:-$HOME/.local/state/pm-drills}" INCIDENT_FLAG="${PM_DRILL_INCIDENT_FLAG:-$STATE_DIR/incident.flag}" diff --git a/pm-stack/aggregator/scripts/kill-collector-drill.sh b/pm-stack/aggregator/scripts/kill-collector-drill.sh index 76d4aaa17..60e2c7fd4 100755 --- a/pm-stack/aggregator/scripts/kill-collector-drill.sh +++ b/pm-stack/aggregator/scripts/kill-collector-drill.sh @@ -43,6 +43,12 @@ # PM_DRILL_NO_POST=1 skip the GitHub comment/issue side effects set -uo pipefail +# Argument contract (#3352): this script takes no command-line +# arguments; anything given is a usage error before any work runs. +if [ "$#" -gt 0 ]; then + echo "kill-collector-drill.sh: unexpected argument '$1'; usage: bash scripts/kill-collector-drill.sh (knobs are PM_DRILL_* environment variables)" >&2 + exit 2 +fi STATE_DIR="${PM_DRILL_STATE_DIR:-$HOME/.local/state/pm-drills}" INCIDENT_FLAG="${PM_DRILL_INCIDENT_FLAG:-$STATE_DIR/incident.flag}" diff --git a/pm-stack/aggregator/scripts/push-fleet-feed.sh b/pm-stack/aggregator/scripts/push-fleet-feed.sh index 4572378b6..a7692df32 100755 --- a/pm-stack/aggregator/scripts/push-fleet-feed.sh +++ b/pm-stack/aggregator/scripts/push-fleet-feed.sh @@ -24,6 +24,12 @@ # ran this script every ~5 min is deleted. Kept for manual/emergency use # only -- running it overwrites the laptop feed with this host's collection. set -euo pipefail +# Argument contract (#3352): this script takes no command-line +# arguments; anything given is a usage error before any work runs. +if [ "$#" -gt 0 ]; then + echo "push-fleet-feed.sh: unexpected argument '$1'; usage: bash scripts/push-fleet-feed.sh" >&2 + exit 2 +fi # Systemd system services get a minimal PATH (and no HOME); bun lives # in the image bin. diff --git a/pm-stack/deploy.sh b/pm-stack/deploy.sh index ff44ad4ee..1e0e1b15a 100755 --- a/pm-stack/deploy.sh +++ b/pm-stack/deploy.sh @@ -24,6 +24,15 @@ # The stack itself binds 127.0.0.1:5173 and stores data in the Docker # named volume pm-stack_postgres_data on this host. set -euo pipefail +# Argument contract (#3352): at most one command, deploy (the default), +# render or restart; anything else is a usage error before any work. +case "$#:${1-deploy}" in +0:deploy | 1:deploy | 1:render | 1:restart) ;; +*) + echo "$0: unexpected arguments '$*'; usage: $0 [deploy|render|restart]" >&2 + exit 2 + ;; +esac cd "$(dirname "$0")" STACK_DIR="$PWD" diff --git a/pm-stack/grist/deploy.sh b/pm-stack/grist/deploy.sh index 06dbbc9d6..171d1a00f 100644 --- a/pm-stack/grist/deploy.sh +++ b/pm-stack/grist/deploy.sh @@ -27,6 +27,15 @@ # (see compose.yml) and stores data in the Docker named volume # grist_grist_data on this host. set -euo pipefail +# Argument contract (#3352): at most one command, deploy (the default), +# render or restart; anything else is a usage error before any work. +case "$#:${1-deploy}" in +0:deploy | 1:deploy | 1:render | 1:restart) ;; +*) + echo "$0: unexpected arguments '$*'; usage: $0 [deploy|render|restart]" >&2 + exit 2 + ;; +esac cd "$(dirname "$0")" STACK_DIR="$PWD" diff --git a/pm-stack/grist/seed.sh b/pm-stack/grist/seed.sh index f4968e192..ce47f3d70 100644 --- a/pm-stack/grist/seed.sh +++ b/pm-stack/grist/seed.sh @@ -8,6 +8,12 @@ # The API key is read from SOPS (grist_api_key) — it is the Grist # admin account's API key, also filed in Bitwarden + 1Password. set -euo pipefail +# Argument contract (#3352): this script takes no command-line +# arguments; anything given is a usage error before any work runs. +if [ "$#" -gt 0 ]; then + echo "seed.sh: unexpected argument '$1'; usage: ./seed.sh" >&2 + exit 2 +fi cd "$(dirname "$0")" if ! command -v bun >/dev/null 2>&1; then diff --git a/pm-stack/kaneo-sync-guard.py b/pm-stack/kaneo-sync-guard.py index 07b1362a6..bffa74c7d 100644 --- a/pm-stack/kaneo-sync-guard.py +++ b/pm-stack/kaneo-sync-guard.py @@ -81,11 +81,14 @@ def main(): if val in FORBIDDEN_TARGETS and key not in EXPECTED: problems.append(f"{key} targets forbidden state {val!r}") format_bad = raw.strip() != json.dumps( - cfg, separators=(",", ":"), ensure_ascii=False) + cfg, separators=(",", ":"), ensure_ascii=False + ) if format_bad: - problems.append("config text is not in JSON.stringify " - "compact form (breaks outbound state sync; " - "see KANEO-GITHUB-SYNC.md)") + problems.append( + "config text is not in JSON.stringify " + "compact form (breaks outbound state sync; " + "see KANEO-GITHUB-SYNC.md)" + ) if not problems: print(f"OK {repo}: statusTransitions conform") continue @@ -140,4 +143,12 @@ def main(): if __name__ == "__main__": + # Argument contract (#3352): no command-line arguments; anything given + # is a usage error before any work runs. + if len(sys.argv) > 1: + print( + f"kaneo-sync-guard.py: unexpected argument {sys.argv[1]!r}; usage: python3 kaneo-sync-guard.py", + file=sys.stderr, + ) + sys.exit(2) sys.exit(main()) diff --git a/pm-stack/opencode-claimant/poll.py b/pm-stack/opencode-claimant/poll.py index 3e7e57a07..6ae610b52 100755 --- a/pm-stack/opencode-claimant/poll.py +++ b/pm-stack/opencode-claimant/poll.py @@ -924,4 +924,12 @@ def main(): if __name__ == "__main__": + # Argument contract (#3352): no command-line arguments; anything given + # is a usage error before any work runs. + if len(sys.argv) > 1: + print( + f"poll.py: unexpected argument {sys.argv[1]!r}; usage: python3 poll.py", + file=sys.stderr, + ) + sys.exit(2) sys.exit(main()) diff --git a/pm-stack/pad/deploy.sh b/pm-stack/pad/deploy.sh index 749fa8b29..47c1f9bb2 100644 --- a/pm-stack/pad/deploy.sh +++ b/pm-stack/pad/deploy.sh @@ -27,6 +27,15 @@ # (see compose.yml) and stores data in the Docker named volume # pad_pad_data on this host. set -euo pipefail +# Argument contract (#3352): at most one command, deploy (the default), +# render or restart; anything else is a usage error before any work. +case "$#:${1-deploy}" in +0:deploy | 1:deploy | 1:render | 1:restart) ;; +*) + echo "$0: unexpected arguments '$*'; usage: $0 [deploy|render|restart]" >&2 + exit 2 + ;; +esac cd "$(dirname "$0")" STACK_DIR="$PWD" diff --git a/pm-stack/pad/seed.sh b/pm-stack/pad/seed.sh index 293c2e227..a0f3f1fe6 100644 --- a/pm-stack/pad/seed.sh +++ b/pm-stack/pad/seed.sh @@ -7,6 +7,12 @@ # does not depend on any CLI session state. Idempotent: items whose # title already exists in the target collection are skipped. set -euo pipefail +# Argument contract (#3352): this script takes no command-line +# arguments; anything given is a usage error before any work runs. +if [ "$#" -gt 0 ]; then + echo "seed.sh: unexpected argument '$1'; usage: ./seed.sh" >&2 + exit 2 +fi cd "$(dirname "$0")" SECRETS_FILE="${PM_STACK_SECRETS:-$PWD/../../secrets/pm-stack.sops.yaml}" diff --git a/pm-stack/projector/scripts/setup-deps.sh b/pm-stack/projector/scripts/setup-deps.sh index 412bafd3e..bdc111f23 100755 --- a/pm-stack/projector/scripts/setup-deps.sh +++ b/pm-stack/projector/scripts/setup-deps.sh @@ -7,6 +7,12 @@ # needed packages from there into ./node_modules. When network is available, # `bun install` in this directory is the normal path instead. set -euo pipefail +# Argument contract (#3352): this script takes no command-line +# arguments; anything given is a usage error before any work runs. +if [ "$#" -gt 0 ]; then + echo "setup-deps.sh: unexpected argument '$1'; usage: bash scripts/setup-deps.sh" >&2 + exit 2 +fi cd "$(dirname "$0")/.." SRC="${LIBXML_SRC:-$HOME/.cache/opencode/npm/opencode-mem@latest/1792868233137/node_modules}" diff --git a/pm-stack/tests/test_kaneo_sync_guard.py b/pm-stack/tests/test_kaneo_sync_guard.py index 7110c89cf..ce2e07307 100644 --- a/pm-stack/tests/test_kaneo_sync_guard.py +++ b/pm-stack/tests/test_kaneo_sync_guard.py @@ -48,13 +48,24 @@ def __init__(self, store, apply_updates=True): def __call__(self, sql): if sql.startswith("SELECT id ||"): return "\n".join( - f"{integ_id}\t{json.dumps(cfg)}" for integ_id, cfg in self.store.items() + # Stored text is Kaneo's JSON.stringify compact form + # (#10140); a spaced form is itself drift. + f"{integ_id}\t{json.dumps(cfg, separators=(',', ':'), ensure_ascii=False)}" + for integ_id, cfg in self.store.items() ) if sql.startswith("UPDATE integration"): self.updates += 1 if not self.apply_updates: return "" integ_id = re.search(r"WHERE id='([^']+)'", sql).group(1) + if "jsonb_set(" not in sql: + # The compaction rewrite (#10140): the whole config, as + # compact JSON text, replaces the stored row. + raw = re.search(r"SET config = '(.*)' WHERE id=", sql, re.DOTALL).group( + 1 + ) + self.store[integ_id] = json.loads(raw) + return "" raw = re.search( r"'\{statusTransitions\}', '(.*)'::jsonb", sql, re.DOTALL ).group(1)