Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pm-stack/aggregator/scripts/age-feed-drill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 6 additions & 0 deletions pm-stack/aggregator/scripts/kill-collector-drill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 6 additions & 0 deletions pm-stack/aggregator/scripts/push-fleet-feed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions pm-stack/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions pm-stack/grist/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions pm-stack/grist/seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 15 additions & 4 deletions pm-stack/kaneo-sync-guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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())
8 changes: 8 additions & 0 deletions pm-stack/opencode-claimant/poll.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
9 changes: 9 additions & 0 deletions pm-stack/pad/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions pm-stack/pad/seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
6 changes: 6 additions & 0 deletions pm-stack/projector/scripts/setup-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
13 changes: 12 additions & 1 deletion pm-stack/tests/test_kaneo_sync_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down