fix: patch 3 bugs found in release review

- ingress.sh: pass status-update note via argv instead of triple-quoted
  heredoc to prevent Python syntax error when note contains quotes
- ingress.sh: warn clearly when AGENT_CONTEXT.md missing (bootstrap
  not run) instead of silent failure in garc ingress context
- daemon.sh: replace export$(xargs) with set -a/source/set +a so
  config.env values containing spaces are loaded correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
林 駿甫 (Shunsuke Hayashi) 2026-04-15 09:09:26 +09:00
parent 931384d671
commit 4028c7f47a
2 changed files with 20 additions and 8 deletions

View file

@ -117,7 +117,13 @@ _start_gmail_poller() {
# Export needed env vars for subprocess
export GARC_DIR GARC_LIB GARC_CONFIG GARC_CACHE_DIR GARC_DEFAULT_AGENT
[[ -f "${GARC_CONFIG}/config.env" ]] && export $(grep -v '^#' "${GARC_CONFIG}/config.env" | xargs) 2>/dev/null || true
# Use set -a/+a instead of export $(xargs) to handle values with spaces
if [[ -f "${GARC_CONFIG:-${HOME}/.garc}/config.env" ]]; then
set -a
# shellcheck disable=SC1090
source "${GARC_CONFIG:-${HOME}/.garc}/config.env" 2>/dev/null || true
set +a
fi
( _gmail_poller_loop "${agent_id}" "${interval}" "${label}" "${max_msgs}" \
>> "${GMAIL_POLLER_LOG}" 2>&1 ) &

View file

@ -394,7 +394,13 @@ _ingress_context() {
[[ -z "${queue_file}" ]] && { echo "Queue item not found: ${queue_id}" >&2; return 1; }
local agent_id="${GARC_DEFAULT_AGENT:-main}"
local context_path="${GARC_CACHE_DIR}/workspace/${agent_id}/AGENT_CONTEXT.md"
local context_path="${GARC_CACHE_DIR:-${HOME}/.garc/cache}/workspace/${agent_id}/AGENT_CONTEXT.md"
if [[ ! -f "${context_path}" ]]; then
echo "⚠️ Agent context not found: ${context_path}" >&2
echo " Run 'garc bootstrap --agent ${agent_id}' first." >&2
echo " Continuing without agent context." >&2
fi
python3 "${INGRESS_HELPER}" build-prompt \
--queue-file "${queue_file}" \
@ -629,13 +635,13 @@ _ingress_update_status() {
queue_file=$(_find_queue_file "${queue_id}")
[[ -z "${queue_file}" ]] && return 1
python3 - <<PY
import json
f = "${queue_file}"
# Pass note via argv to avoid shell→Python string injection
python3 - "${queue_file}" "${new_status}" "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" "${note}" <<'PY'
import json, sys
f, new_status, updated_at, note = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
q = json.loads(open(f).readline())
q["status"] = "${new_status}"
q["updated_at"] = "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
note = """${note}"""
q["status"] = new_status
q["updated_at"] = updated_at
if note:
q["note"] = note
with open(f, "w") as fh: