deploy: ship SYSTEM.md and CHANGELOG entries from repo prompts/ dir

This commit is contained in:
Damocles 2026-05-01 15:03:18 +02:00
parent 4c19a4b0e9
commit 994835d1db
5 changed files with 271 additions and 7 deletions

View file

@ -33,12 +33,43 @@ echo "==> fixing state tree ownership (muede:users)"
# ends up root-owned and unwritable by the daemon. Bulk-fix every time we deploy.
chown -R muede:users "$STATE"
# SYSTEM.md is the harness contract. Daemon must read it but not write it -
# it ships as part of the system prompt on each shard spawn. Restore root:root 644.
if [ -f "$STATE/identity/SYSTEM.md" ]; then
chown root:root "$STATE/identity/SYSTEM.md"
chmod 644 "$STATE/identity/SYSTEM.md"
# SYSTEM.md ships from the repo and is the harness contract. Replacing on
# every deploy guarantees it matches the binary's actual capabilities (no
# stale references to tools that aren't enabled). Locked root:root 644 so
# the daemon (running as muede) can read but not edit it.
echo "==> shipping SYSTEM.md from repo"
install -m 644 -o root -g root "$REPO/prompts/SYSTEM.md" "$STATE/identity/SYSTEM.md"
# Append pending CHANGELOG entries (new tool announcements etc.) to the live
# CHANGELOG.md and then clear the pending file. This guarantees the shard
# only sees announcements AFTER the binary supporting them is deployed.
PENDING="$REPO/prompts/pending_changelog.md"
LIVE="$STATE/CHANGELOG.md"
# Extract everything after the closing --> of the header comment, trim
# whitespace. If there's anything left, we have actual entries to append.
PENDING_BODY=$(awk '/^-->$/{p=1; next} p' "$PENDING" | sed -e 's/^[[:space:]]*$//' | grep -v '^$' || true)
if [ -n "$PENDING_BODY" ]; then
echo "==> appending pending CHANGELOG entries"
{
echo
awk '/^-->$/{p=1; next} p' "$PENDING"
} >> "$LIVE"
chown muede:users "$LIVE"
# reset the pending file to just the header comment
cat > "$PENDING" <<'EOF'
<!--
Pending CHANGELOG entries. Edit this file to queue announcements to the shard
about new capabilities/behavior shipped in the next deploy. The deploy script
appends this content to /persist/damocles-lab/state/CHANGELOG.md and clears
this file. That way CHANGELOG entries can never reference tools that aren't
actually in the deployed binary yet.
Format: same as live CHANGELOG entries - heading + body, ending with a
"Capability addition:" line for the shard to lift into notes.md.
-->
EOF
fi
echo " state tree fixed"
echo "==> done. restart daemon to pick up new binary:"