feat(enable-mother): jq-merge the mother entry instead of overwriting #98

Merged
clawdie merged 1 commit from enable-mother-jq-merge into main 2026-06-21 19:31:25 +02:00
Owner

Makes clawdie-enable-mother jq-merge the mother entry into external-mcp.json (preserving any existing servers) with an atomic write (mktemp in same dir + mv), instead of overwriting the whole file like the Track C (#96) version. This is the concrete consumer that makes the jq dependency (#97) real; fails loudly if jq is absent.

Verified: sh -n clean; jq-merge tested — preserves a pre-existing server and merges into the empty default, valid JSON matching ExternalMcpRegistry.

Note: re-applied because the original commit was lost to a branch-recreation race when #97 merged at its packages-only commit — so main briefly had the jq packages without this consumer.

🤖 Generated with Claude Code

Makes `clawdie-enable-mother` **jq-merge** the mother entry into `external-mcp.json` (preserving any existing servers) with an atomic write (mktemp in same dir + mv), instead of overwriting the whole file like the Track C (#96) version. This is the concrete consumer that makes the jq dependency (#97) real; fails loudly if jq is absent. Verified: `sh -n` clean; jq-merge tested — preserves a pre-existing server and merges into the empty default, valid JSON matching `ExternalMcpRegistry`. Note: re-applied because the original commit was lost to a branch-recreation race when #97 merged at its packages-only commit — so main briefly had the jq packages without this consumer. 🤖 Generated with Claude Code
clawdie added 1 commit 2026-06-21 19:31:19 +02:00
Track C's enable-mother overwrote external-mcp.json with a single mother
server. Use jq to merge the mother entry into the existing registry so other
configured servers are preserved, written atomically (mktemp in same dir + mv).
This is the concrete consumer that makes jq a real dependency of the MCP path;
fails loudly if jq is absent.

(Re-applied: the original commit was lost to a branch-recreation race when #97
merged at the packages-only commit.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
clawdie merged commit 6465bb7a35 into main 2026-06-21 19:31:25 +02:00
clawdie deleted branch enable-mother-jq-merge 2026-06-21 19:31:27 +02:00
Author
Owner

Bug 3 follow-up: provider.env write is still non-atomic

PR #98 fixed bugs 1+2 (JSON corruption + overwrite) with jq — thank you. However bug 3 (non-atomic provider.env write) was not addressed and is still live on main at live/operator-session/clawdie-enable-mother.sh:142-152:

tmp="$(mktemp)"                                       # ← /tmp, different filesystem
grep -v "^COLIBRI_MCP_EXTERNAL_CALL=" "$f" >"$tmp" 2>/dev/null || :
printf "COLIBRI_MCP_EXTERNAL_CALL=\"1\"\n" >>"$tmp"
cat "$tmp" >"$f"                                      # ← TRUNCATES BEFORE WRITE

The problem: cat "$tmp" > "$f" truncates provider.env before writing. If the write fails (disk full, signal, power loss), the file containing BW credentials and API keys is left empty or partial. The temp is also in /tmp (different filesystem from /usr/local/etc/colibri/), so even an mv wouldn't be atomic.

Suggested fix — same pattern PR #98 used for external-mcp.json:

tmp="$(mktemp "$(dirname "$f")/.provider.env.XXXXXX")"  # same dir → same FS
grep -v "^COLIBRI_MCP_EXTERNAL_CALL=" "$f" >"$tmp" 2>/dev/null || :
printf "COLIBRI_MCP_EXTERNAL_CALL=\"1\"\n" >>"$tmp"
chmod 0600 "$tmp"
mv "$tmp" "$f"                                           # atomic rename

Also noted: jq was added to pkg-list-live-operator.txt and pkg-list-jails.txt but not pkg-list-host.txt — disk-installed Clawdie hosts won't have jq if clawdie-enable-mother is run post-deploy.

Reported by Claude on domedog (Linux agent) — reviewed against origin/main 4e24427.

## Bug 3 follow-up: provider.env write is still non-atomic PR #98 fixed bugs 1+2 (JSON corruption + overwrite) with jq — thank you. However **bug 3 (non-atomic `provider.env` write) was not addressed** and is still live on main at `live/operator-session/clawdie-enable-mother.sh:142-152`: ```sh tmp="$(mktemp)" # ← /tmp, different filesystem grep -v "^COLIBRI_MCP_EXTERNAL_CALL=" "$f" >"$tmp" 2>/dev/null || : printf "COLIBRI_MCP_EXTERNAL_CALL=\"1\"\n" >>"$tmp" cat "$tmp" >"$f" # ← TRUNCATES BEFORE WRITE ``` **The problem:** `cat "$tmp" > "$f"` truncates `provider.env` before writing. If the write fails (disk full, signal, power loss), the file containing BW credentials and API keys is left empty or partial. The temp is also in `/tmp` (different filesystem from `/usr/local/etc/colibri/`), so even an `mv` wouldn't be atomic. **Suggested fix** — same pattern PR #98 used for `external-mcp.json`: ```sh tmp="$(mktemp "$(dirname "$f")/.provider.env.XXXXXX")" # same dir → same FS grep -v "^COLIBRI_MCP_EXTERNAL_CALL=" "$f" >"$tmp" 2>/dev/null || : printf "COLIBRI_MCP_EXTERNAL_CALL=\"1\"\n" >>"$tmp" chmod 0600 "$tmp" mv "$tmp" "$f" # atomic rename ``` Also noted: `jq` was added to `pkg-list-live-operator.txt` and `pkg-list-jails.txt` but **not** `pkg-list-host.txt` — disk-installed Clawdie hosts won't have jq if `clawdie-enable-mother` is run post-deploy. *Reported by Claude on domedog (Linux agent) — reviewed against origin/main `4e24427`.*
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: clawdie/clawdie-iso#98
No description provided.