From 477908074d33b7d821aa0ae60a5b9c04a6fa302a Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 07:27:49 -0600 Subject: [PATCH] fix(pm-stack): parse DRY_RUN explicitly (#5421) --- pm-stack/ready-for-agent/apply-config.sh | 4 ++- pm-stack/ready-for-agent/test-apply-config.sh | 32 +++++++++++++++++++ pm-stack/ready-for-agent/test-install.sh | 13 +++++++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/pm-stack/ready-for-agent/apply-config.sh b/pm-stack/ready-for-agent/apply-config.sh index 81ccfd6693..2b1e7fda53 100755 --- a/pm-stack/ready-for-agent/apply-config.sh +++ b/pm-stack/ready-for-agent/apply-config.sh @@ -15,6 +15,8 @@ # # ./apply-config.sh apply config.json next to this script # DRY_RUN=1 ./apply-config.sh print the mutations it would send +# DRY_RUN accepts only "1" or "true" (case-insensitive) as dry-run; +# "0", "false", "no", empty, and unset apply the config for real. # # Overrides: RFA_CONFIG (config path), RFA_GRAPHQL_URL (endpoint), # RFA_REPOS_DIR (clone root, default ./repos next to the config). @@ -35,7 +37,7 @@ with open(config_path) as f: config = json.load(f) url = os.environ.get("GRAPHQL_URL") or config.get("graphqlUrl") or "http://127.0.0.1:6056/graphql" repos_dir = os.environ["REPOS_DIR"] -dry_run = bool(os.environ.get("DRY_RUN")) +dry_run = os.environ.get("DRY_RUN", "").strip().lower() in {"1", "true"} def gql(query, variables=None): body = {"query": query} diff --git a/pm-stack/ready-for-agent/test-apply-config.sh b/pm-stack/ready-for-agent/test-apply-config.sh index b346d34a67..1afa69b2f3 100755 --- a/pm-stack/ready-for-agent/test-apply-config.sh +++ b/pm-stack/ready-for-agent/test-apply-config.sh @@ -110,6 +110,14 @@ grep -q "would register" "$WORK/dry-run.out" } echo "ok: dry run plans registration and mutates nothing" +DRY_RUN=TrUe ./apply-config.sh >"$WORK/true-dry-run.out" +grep -q "would register" "$WORK/true-dry-run.out" +[[ ! -s "$WORK/mutations.log" ]] || { + echo "FAIL: DRY_RUN=true mutated the harness" + exit 1 +} +echo "ok: DRY_RUN=true is accepted case-insensitively" + ./apply-config.sh >"$WORK/first.out" grep -q "addLocalRepository" "$WORK/mutations.log" grep -q "updateRepositorySettings" "$WORK/mutations.log" @@ -126,4 +134,28 @@ grep -q "already match config" "$WORK/second.out" } echo "ok: second apply is a no-op (idempotent)" +# A conventional false-y string must not suppress a real config update. +python3 - "$WORK/config.json" <<'PYEOF' +import json, sys + +with open(sys.argv[1]) as f: + config = json.load(f) +config["repositories"][0]["defaultModel"] = "opencode-go/dry-run-falsey-test" +with open(sys.argv[1], "w") as f: + json.dump(config, f) +PYEOF + +: >"$WORK/mutations.log" +DRY_RUN=0 ./apply-config.sh >"$WORK/falsey.out" +grep -q "updated developing-today/code settings: defaultModel" "$WORK/falsey.out" +grep -Fxq "updateRepositorySettings" "$WORK/mutations.log" || { + echo "FAIL: DRY_RUN=0 did not send the config mutation to the harness" + exit 1 +} +if grep -q "DRY-RUN" "$WORK/falsey.out"; then + echo "FAIL: DRY_RUN=0 was treated as dry-run" + exit 1 +fi +echo "ok: DRY_RUN=0 applies config mutations" + echo "apply-config.test: PASS" diff --git a/pm-stack/ready-for-agent/test-install.sh b/pm-stack/ready-for-agent/test-install.sh index f9ad1808e1..75aeb2b7d5 100755 --- a/pm-stack/ready-for-agent/test-install.sh +++ b/pm-stack/ready-for-agent/test-install.sh @@ -22,6 +22,14 @@ run_case() { mkdir -p "${home}/.local/bin" "${home}/.config/systemd/user" "${deploy}/systemd" "${stub_bin}" "${state}" cp "${REPO_ROOT}/pm-stack/ready-for-agent/install.sh" "${deploy}/install.sh" + cat >"${deploy}/apply-config.sh" <<'APPLY_CONFIG' +#!/usr/bin/env bash +set -euo pipefail +printf 'apply-config\n' >>"${STUB_LOG}" +APPLY_CONFIG + cat >"${deploy}/config.json" <<'JSON' +{"repositories":[{"projectPath":"developing-today/code","localDir":"code","cloneUrl":"https://github.com/developing-today/code.git"}]} +JSON cp "${REPO_ROOT}/pm-stack/ready-for-agent/systemd/ready-for-agent.service" \ "${deploy}/systemd/ready-for-agent.service" if [[ ${unit_matches} == true ]]; then @@ -34,7 +42,7 @@ run_case() { printf '%s\n' "${initial_version}" >"${home}/.ready-agent-version" cat >"${home}/.local/bin/ready-for-agent" <<'LAUNCHER' #!/usr/bin/env bash -printf 'ready-for-agent %s\n' "$(cat "${HOME}/.ready-agent-version")" + printf 'ready-for-agent %s\n' "$(cat "${HOME}/.ready-agent-version")" LAUNCHER chmod +x "${home}/.local/bin/ready-for-agent" fi @@ -126,6 +134,7 @@ CURL exit 0 SLEEP chmod +x "${stub_bin}/systemctl" "${stub_bin}/npm" "${stub_bin}/git" "${stub_bin}/curl" "${stub_bin}/sleep" + chmod +x "${deploy}/apply-config.sh" if [[ ${name} == clone-fail-retry ]]; then # #4839: npm upgrades the package, then the clone step fails; the @@ -146,6 +155,7 @@ SLEEP fail "${name}: retry exited unsuccessfully" fi grep -Fxq restart "${log}" || fail "${name}: retry did not restart" + grep -Fxq apply-config "${log}" || fail "${name}: config helper was not invoked after retry" printf '%s\n' "${retry_output}" | grep -Fq 'after restart' || fail "${name}: retry missing after-restart report" printf '%s\n' "${retry_output}" | grep -Fq 'already running' && fail "${name}: retry falsely reported no-op" [[ ! -f ${marker} ]] || fail "${name}: marker not cleared after verified restart" @@ -160,6 +170,7 @@ SLEEP fi printf '%s\n' "${output}" | grep -Fq 'ready-for-agent@1.1.0' + grep -Fxq apply-config "${log}" || fail "${name}: config helper was not invoked" case "${name}" in package-change-active) grep -Fxq restart "${log}" || fail "${name}: expected restart"