Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions deploy/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,40 @@ else
info "Pack requests no data volume — skipping mount"
fi

# ---- KiroCrew workspace data-volume mapping ----
step "KiroCrew Workspace Mount"
if [[ "${PACK_NAME}" == "kirocrew" && "${DATA_VOL_GB}" -gt 0 && -d /mnt/ebs-data ]]; then
mkdir -p /mnt/ebs-data/workplace
if ! mountpoint -q /home/ec2-user/workplace; then
if [[ -L /home/ec2-user/workplace ]]; then
rm -f /home/ec2-user/workplace
elif [[ -d /home/ec2-user/workplace ]]; then
if find /home/ec2-user/workplace -mindepth 1 -maxdepth 1 -print -quit | grep -q .; then
cp -a /home/ec2-user/workplace/. /mnt/ebs-data/workplace/
fi
rm -rf /home/ec2-user/workplace
elif [[ -e /home/ec2-user/workplace ]]; then
fail "KiroCrew workspace path exists but is not a directory"
exit 1
fi
mkdir -p /home/ec2-user/workplace
mount --bind /mnt/ebs-data/workplace /home/ec2-user/workplace
fi
WORKPLACE_FSTAB_ENTRY="/mnt/ebs-data/workplace /home/ec2-user/workplace none bind,nofail,x-systemd.requires-mounts-for=/mnt/ebs-data 0 0"
sed -i '\|^/mnt/ebs-data/workplace /home/ec2-user/workplace none bind 0 0$|d' /etc/fstab
if ! grep -qF "${WORKPLACE_FSTAB_ENTRY}" /etc/fstab; then
printf '%s\n' "${WORKPLACE_FSTAB_ENTRY}" >> /etc/fstab
fi
chown ec2-user:ec2-user /mnt/ebs-data/workplace /home/ec2-user/workplace
ok "Bind-mounted KiroCrew workplace -> /mnt/ebs-data/workplace"
elif [[ "${PACK_NAME}" == "kirocrew" ]]; then
mkdir -p /home/ec2-user/workplace
chown ec2-user:ec2-user /home/ec2-user/workplace
info "KiroCrew workspace uses the root volume because no data volume is available"
else
info "KiroCrew workspace mount: skipped for ${PACK_NAME}"
fi

# ---- Enable systemd user session for ec2-user (needed by openclaw gateway) ----
loginctl enable-linger ec2-user 2>/dev/null || true
# Wait for user runtime dir — linger starts the user manager asynchronously
Expand Down
2 changes: 1 addition & 1 deletion packs/kirocrew/PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ provides:

instance_type: t4g.medium
root_volume_gb: 40
data_volume_gb: 0
data_volume_gb: 80

experimental: true
```
Expand Down
2 changes: 1 addition & 1 deletion packs/kirocrew/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ provides:

instance_type: t4g.medium
root_volume_gb: 40
data_volume_gb: 0
data_volume_gb: 80

experimental: true
1 change: 1 addition & 0 deletions packs/kirocrew/resources/kirocrew-gateway.service
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ProtectHome=read-only
# that kiro-cli subprocesses (spawned via ACP) may write to.
ReadWritePaths=/home/ec2-user/.kiro
ReadWritePaths=/home/ec2-user/.local
ReadWritePaths=/home/ec2-user/workplace
ReadWritePaths=__HOME__
PrivateTmp=true

Expand Down
2 changes: 1 addition & 1 deletion packs/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"deps": [],
"instance_type": "t4g.medium",
"root_volume_gb": 40,
"data_volume_gb": 0,
"data_volume_gb": 80,
"ports": {
"gateway": 5476
},
Expand Down
2 changes: 1 addition & 1 deletion packs/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ packs:
deps: []
instance_type: t4g.medium
root_volume_gb: 40
data_volume_gb: 0
data_volume_gb: 80
ports:
gateway: 5476
brain: false
Expand Down
83 changes: 83 additions & 0 deletions tests/test-kirocrew-ebs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
# tests/test-kirocrew-ebs.sh — KiroCrew EBS workspace contract
# Verifies the pack requests a data volume and bootstrap maps the agent workspace
# onto that volume. The test is static because mounting requires a live EC2 host.

set -euo pipefail

ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
MANIFEST="${ROOT_DIR}/packs/kirocrew/manifest.yaml"
REGISTRY_YAML="${ROOT_DIR}/packs/registry.yaml"
REGISTRY_JSON="${ROOT_DIR}/packs/registry.json"
BOOTSTRAP="${ROOT_DIR}/deploy/bootstrap.sh"
SERVICE="${ROOT_DIR}/packs/kirocrew/resources/kirocrew-gateway.service"

PASS=0
FAIL=0

pass() { printf '[PASS] %s\n' "$1"; PASS=$((PASS + 1)); }
fail() { printf '[FAIL] %s\n' "$1"; FAIL=$((FAIL + 1)); }

if python3 - "$MANIFEST" <<'PY'
import sys
import yaml

with open(sys.argv[1], encoding="utf-8") as stream:
data = yaml.safe_load(stream)
assert data["data_volume_gb"] == 80
PY
then
pass "KiroCrew manifest requests an 80 GB data volume"
else
fail "KiroCrew manifest must request an 80 GB data volume"
fi

if grep -A12 '^ kirocrew:' "$REGISTRY_YAML" | grep -q '^ data_volume_gb: 80$'; then
pass "KiroCrew YAML registry requests an 80 GB data volume"
else
fail "KiroCrew YAML registry must request an 80 GB data volume"
fi

if python3 - "$REGISTRY_JSON" <<'PY'
import json
import sys

with open(sys.argv[1], encoding="utf-8") as stream:
data = json.load(stream)
assert data["packs"]["kirocrew"]["data_volume_gb"] == 80
PY
then
pass "KiroCrew generated registry requests an 80 GB data volume"
else
fail "KiroCrew generated registry must request an 80 GB data volume"
fi

assert_bootstrap_contains() {
local pattern="$1"
local description="$2"
if grep -Fq "$pattern" "$BOOTSTRAP"; then
pass "$description"
else
fail "$description"
fi
}

assert_bootstrap_contains \
'if [[ "${PACK_NAME}" == "kirocrew" && "${DATA_VOL_GB}" -gt 0 && -d /mnt/ebs-data ]]; then' \
"bootstrap gates the workspace mapping on KiroCrew and a mounted data volume"
assert_bootstrap_contains \
'mount --bind /mnt/ebs-data/workplace /home/ec2-user/workplace' \
"bootstrap bind-mounts the EBS workplace directory"
assert_bootstrap_contains \
'/mnt/ebs-data/workplace /home/ec2-user/workplace none bind,nofail,x-systemd.requires-mounts-for=/mnt/ebs-data 0 0' \
"bootstrap persists a non-fatal workplace bind mount after the data volume"
if grep -Fq 'ReadWritePaths=/home/ec2-user/workplace' "$SERVICE"; then
pass "KiroCrew gateway can write to the EBS-backed workplace"
else
fail "KiroCrew gateway must allow writes to the EBS-backed workplace"
fi

printf '\nResults: PASS=%d FAIL=%d\n' "$PASS" "$FAIL"
if (( FAIL > 0 )); then
exit 1
fi