feat(deploy): implement lib_ownership, registry merge, and deployment test suite

This commit is contained in:
2026-08-07 23:48:49 +09:00
parent cc11a02784
commit 399242dac5
11 changed files with 939 additions and 172 deletions
+61
View File
@@ -81,6 +81,14 @@ if [ "$SRC_DIR" = "$TARGET_DIR" ]; then
exit 1
fi
OWNERSHIP_LIB="$SRC_DIR/deploy/lib_ownership.sh"
if [ ! -f "$OWNERSHIP_LIB" ]; then
log_error "Missing $OWNERSHIP_LIB; refusing to install with unknown ownership rules."
exit 1
fi
# shellcheck source=deploy/lib_ownership.sh
. "$OWNERSHIP_LIB"
# 1. Dependency Checks
log_info "Verifying host dependencies..."
DEPS=(herdr python3 rsync uuidgen)
@@ -147,6 +155,59 @@ if [ -f "$SRC_DIR/deploy/INSTALL.md" ]; then
log_ok "Copied INSTALL.md user manual into target .agents/"
fi
# Record an install manifest (.mam/install_manifest.txt) and state hashes (R-5, F14)
log_info "Recording install manifest (.mam/install_manifest.txt)..."
mkdir -p "$TARGET_DIR/.mam"
MANIFEST_FILE="$TARGET_DIR/.mam/install_manifest.txt"
: > "$MANIFEST_FILE"
( cd "$TARGET_DIR" && find .agents -type f -print ) >> "$MANIFEST_FILE"
for extra in ".mam.env.example" ".mam_deploy/remove.sh" ".mam_deploy/update.sh" \
"scripts/generate-env.sh"; do
if [ -e "$TARGET_DIR/$extra" ]; then
echo "$extra" >> "$MANIFEST_FILE"
fi
done
log_ok "Recorded $(wc -l < "$MANIFEST_FILE" | tr -d ' ') manifest entries."
OWNED_LIST="$TARGET_DIR/.mam/.owned_paths.tmp"
: > "$OWNED_LIST"
while IFS= read -r rel; do
rel="${rel#./}"
if is_framework_owned "$rel"; then
echo "$rel" >> "$OWNED_LIST"
if is_registry_file "$rel"; then
mkdir -p "$TARGET_DIR/.mam/base/$(dirname "$rel")"
cp -f "$TARGET_DIR/$rel" "$TARGET_DIR/.mam/base/$rel"
fi
fi
done < <( cd "$TARGET_DIR" && find .agents -type f -print )
python3 - "$TARGET_DIR" "$OWNED_LIST" <<'MAMSTATE'
import hashlib, os, sys
target, listing = sys.argv[1], sys.argv[2]
def sha(path):
h = hashlib.sha256()
with open(path, "rb") as f:
while chunk := f.read(65536):
h.update(chunk)
return h.hexdigest()
rows = []
with open(listing) as f:
for rel in f:
rel = rel.strip()
full = os.path.join(target, rel)
if rel and os.path.isfile(full):
rows.append("%s %s\n" % (sha(full), rel))
with open(os.path.join(target, ".mam", "asset_hashes.txt"), "w") as f:
f.writelines(sorted(rows))
MAMSTATE
rm -f "$OWNED_LIST"
log_ok "Recorded asset hashes and registry base under .mam/."
# 3. Copy AGENTS.md to root or inject guidelines pointer
log_info "Configuring developer guidelines (AGENTS.md)..."
AGENTS_FILE="$TARGET_DIR/AGENTS.md"