Add ARM64 automation scripts — close WO-1 without AWS console interaction
Browse filesscripts/aws-setup.sh: one-time credential setup using read -s (silent prompts);
writes ~/.aws/credentials via aws configure, verifies with sts get-caller-identity,
accepts PEM key via stdin cat redirect to ~/.ssh/beryl-aws-key.pem, auto-discovers
running t4g.small IP and saves to ~/.miranda-ec2-ip
scripts/provision-ec2.sh: launches t4g.small if none exists; imports SSH key pair,
creates security group (SSH from current IP only), finds latest AL2023 ARM64 AMI,
bootstraps Rust install + git clone via user-data
scripts/arm64-verify.sh: full ARM64 verification — SSH in, git pull, cargo build,
cargo test -p miranda-ipc --nocapture, MIRI check; all output pasted back locally
tasks.md T7: updated ARM64 section to reference scripts + clarify this does not
block WO-2; WO-2 can start in parallel with the ARM64 gap being closed
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Files changed (4)
- .kiro/specs/wo1-workspace-ipc-backbone/tasks.md+16-7
- scripts/arm64-verify.shAdded+109
- scripts/aws-setup.shAdded+93
- scripts/provision-ec2.shAdded+114
345 unmodified lines346347348349350351352353354355356357358359360345 unmodified linesgit commit -m "WO-1 complete: lock-free IPC backbone, 3 ring buffers, MIRI clean, concurrent test, ≤50μs latency verified"```**After committing — ARM64 verification:**SSH into the t4g.small EC2 instance, clone the repo (or `git pull` if already cloned), and run:```cargo test -p miranda-ipc -- --nocapture```natively on the Graviton box. Re-run the latency benchmark result. Paste the output as a comment on this commit or in the Kiro session. The ≤50 μs target applies on both platforms — if ARM64 fails, apply the `#[repr(align(64))]` fix from T5 and re-run.WO-1 is done. Read `.kiro/steering/pipeline-1-aws-native.md` now — it tells you exactly what the Pipeline 1 implementations of WO-2 through WO-5 look like and which AWS services fill each node role. WO-2 (acoustic ingress) can begin.---345 unmodified lines346347348349350351352353354355356357358359360361362363364365366367368369345 unmodified linesgit commit -m "WO-1 complete: lock-free IPC backbone, 3 ring buffers, MIRI clean, concurrent test, ≤50μs latency verified"```**After committing — ARM64 verification (automated):**The ARM64 cross-check does not block WO-2. It runs in parallel once AWS credentials are configured. Three scripts in `scripts/` handle the entire flow — no manual AWS console interaction required:| Script | What it does ||---|---|| `scripts/aws-setup.sh` | One-time credential setup: silent-read prompts for AWS key ID + secret → writes `~/.aws/credentials`, verifies with `aws sts get-caller-identity`, accepts PEM key via stdin → `~/.ssh/beryl-aws-key.pem`, auto-discovers the EC2 instance IP || `scripts/provision-ec2.sh` | If no t4g.small exists yet: launches one, installs Rust, clones the repo via user-data. Run once, wait ~3 minutes. || `scripts/arm64-verify.sh` | SSHes into the instance, syncs the repo via `git pull`, runs `cargo build`, `cargo test -p miranda-ipc -- --nocapture`, and the MIRI check — pastes real ARM64 output. |**To close the ARM64 gap:**1. Run `bash scripts/aws-setup.sh` once from your local terminal (adds AWS credentials + PEM key — keys go directly to disk, never through chat)2. If no EC2 instance exists: run `bash scripts/provision-ec2.sh` once (launches the t4g.small automatically, wait 3 minutes)3. Run `bash scripts/arm64-verify.sh` — it handles SSH, repo sync, and all tests, and pastes the results back hereIf the latency benchmark fails on ARM64 (> 50 μs): add `#[repr(align(64))]` to the `AtomicUsize` control structs and re-run. The ARM64 fix does not require a model switch — it's a CAT 1 change (adding a repr attribute).**WO-1 is done and WO-2 can begin.** The ARM64 verification runs in parallel. Read `.kiro/steering/pipeline-1-aws-native.md` now — it defines exactly what WO-2 through WO-5 look like for Pipeline 1 (AWS managed services, no custom Rust for the first pass). WO-2 (acoustic ingress) starts next.---
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109#!/usr/bin/env bash# ARM64 (Graviton) verification for WO-1.# SSHes into the t4g.small, syncs the repo, runs cargo test and the# latency benchmark natively on ARM64, and prints results to close WO-1.## Prerequisites: aws-setup.sh must have been run. Instance must be running.# Usage: bash scripts/arm64-verify.sh [optional-ip-override]
set -e
KEY="$HOME/.ssh/beryl-aws-key.pem"EC2_USER="ec2-user"
# Resolve IPif [ -n "$1" ]; then EC2_IP="$1"elif [ -f ~/.miranda-ec2-ip ]; then EC2_IP=$(cat ~/.miranda-ec2-ip)else echo "✗ No EC2 IP found. Run aws-setup.sh or: echo '<ip>' > ~/.miranda-ec2-ip" exit 1fi
SSH="ssh -i $KEY -o StrictHostKeyChecking=no $EC2_USER@$EC2_IP"
echo ""echo "=== WO-1 ARM64 verification ==="echo "Target: $EC2_IP | Key: $KEY"echo ""
# --- Check instance is reachable ---echo "Checking SSH connectivity..."$SSH "echo '✓ SSH connection successful'" || { echo "✗ Cannot reach $EC2_IP. Check that the instance is running and the PEM key is correct." exit 1}
# --- Sync the repo ---echo ""echo "Syncing miranda-engine repo on the instance..."$SSH " set -e if [ ! -d /home/ec2-user/miranda-engine ]; then git clone https://github.com/tyronne-os/Miranda.git /home/ec2-user/miranda-engine echo '✓ Repo cloned' else cd /home/ec2-user/miranda-engine && git pull --rebase echo '✓ Repo updated' fi"
# --- Ensure Rust is installed ---echo ""echo "Checking Rust toolchain on ARM64..."$SSH " set -e if ! command -v cargo &>/dev/null; then curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -q echo '✓ Rust installed' else echo \"✓ Rust already installed: \$(cargo --version)\" fi source \$HOME/.cargo/env rustup show"
# --- cargo build ---echo ""echo "--- cargo build (ARM64) ---"$SSH " set -e source \$HOME/.cargo/env cd /home/ec2-user/miranda-engine cargo build 2>&1 echo '✓ cargo build exit 0'"
# --- cargo test miranda-ipc with output ---echo ""echo "--- cargo test -p miranda-ipc (ARM64) ---"$SSH " set -e source \$HOME/.cargo/env cd /home/ec2-user/miranda-engine cargo test -p miranda-ipc -- --nocapture 2>&1"
# --- MIRI check (nightly required) ---echo ""echo "--- MIRI undefined-behaviour check (ARM64) ---"$SSH " set -e source \$HOME/.cargo/env cd /home/ec2-user/miranda-engine if ! rustup toolchain list | grep -q nightly; then rustup toolchain install nightly --component miri -q echo '✓ nightly + MIRI installed' fi cargo +nightly miri test -p miranda-ipc 2>&1" || echo "⚠ MIRI reported issues on ARM64 — see output above. Fix before closing WO-1."
echo ""echo "=== ARM64 verification complete ==="echo "If all tests passed and MIRI is clean: WO-1 is fully closed."echo "If the latency benchmark exceeded 50 μs: add #[repr(align(64))] to the"echo " AtomicUsize control structs and re-run."echo ""echo "Next: run 'node scripts/cat-router-check.mjs' to confirm WO-1 is done,"echo "then begin WO-2 per .kiro/specs/wo2-acoustic-ingress-routing/tasks.md"123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293#!/usr/bin/env bash# One-time AWS credential + SSH key setup for Miranda-Engine.# Run this script ONCE from your own terminal. Your keys never appear# in any chat session or log — they go from your clipboard → this script → disk only.## Usage: bash scripts/aws-setup.sh
set -e
echo ""echo "=== Miranda-Engine: AWS credential setup ==="echo "Your keys will be written to ~/.aws/credentials and ~/.aws/config."echo "They will not be printed to the screen."echo ""
# --- AWS credentials ---printf "AWS Access Key ID: "read -r -s AWS_ACCESS_KEY_IDecho ""
printf "AWS Secret Access Key: "read -r -s AWS_SECRET_ACCESS_KEYecho ""
printf "AWS default region [us-east-1]: "read -r AWS_REGIONAWS_REGION="${AWS_REGION:-us-east-1}"
aws configure set aws_access_key_id "$AWS_ACCESS_KEY_ID"aws configure set aws_secret_access_key "$AWS_SECRET_ACCESS_KEY"aws configure set default.region "$AWS_REGION"aws configure set default.output "json"
echo ""echo "Verifying credentials with AWS STS..."IDENTITY=$(aws sts get-caller-identity 2>&1)if echo "$IDENTITY" | grep -q '"UserId"'; then ACCOUNT=$(echo "$IDENTITY" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['Account'])") ARN=$(echo "$IDENTITY" | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['Arn'])") echo "✓ Connected. Account: $ACCOUNT | ARN: $ARN"else echo "✗ Credential verification failed. Output was:" echo "$IDENTITY" exit 1fi
# --- SSH PEM key ---echo ""echo "=== SSH key setup ==="echo "Paste your EC2 PEM key below."echo "Start pasting now, then press Ctrl+D on a NEW blank line when done:"echo ""
mkdir -p ~/.sshcat > ~/.ssh/beryl-aws-key.pemchmod 400 ~/.ssh/beryl-aws-key.pemecho "✓ Key saved to ~/.ssh/beryl-aws-key.pem (chmod 400)"
# --- EC2 instance discovery ---echo ""echo "=== EC2 instance discovery ==="echo "Looking for a running t4g.small or t3.small in $AWS_REGION..."EC2_IP=$(aws ec2 describe-instances \ --filters "Name=instance-state-name,Values=running" \ "Name=instance-type,Values=t4g.small,t3.small" \ --query "Reservations[0].Instances[0].PublicIpAddress" \ --output text 2>/dev/null || echo "")
if [ -n "$EC2_IP" ] && [ "$EC2_IP" != "None" ]; then echo "✓ Found instance at $EC2_IP" # Trust the host key ssh-keyscan -H "$EC2_IP" >> ~/.ssh/known_hosts 2>/dev/null echo "✓ Host key added to ~/.ssh/known_hosts" # Save IP for the verify script echo "$EC2_IP" > ~/.miranda-ec2-ip echo "✓ Instance IP saved to ~/.miranda-ec2-ip"else echo " No running instance found automatically." printf " Enter the EC2 instance public IP manually (or leave blank to skip): " read -r MANUAL_IP if [ -n "$MANUAL_IP" ]; then ssh-keyscan -H "$MANUAL_IP" >> ~/.ssh/known_hosts 2>/dev/null echo "✓ Host key added for $MANUAL_IP" echo "$MANUAL_IP" > ~/.miranda-ec2-ip echo "✓ Instance IP saved to ~/.miranda-ec2-ip" else echo " Skipped. Run: echo '<ip>' > ~/.miranda-ec2-ip before running arm64-verify.sh" fifi
echo ""echo "=== Setup complete ==="echo "Run 'bash scripts/arm64-verify.sh' to start the ARM64 verification."123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114#!/usr/bin/env bash# Launch the Miranda-Engine t4g.small EC2 instance if it doesn't exist yet.# Installs Rust and clones the repo automatically on first boot.## Prerequisites: aws-setup.sh must have been run first (credentials configured).# Usage: bash scripts/provision-ec2.sh
set -e
REGION=$(aws configure get default.region || echo "us-east-1")KEY_NAME="beryl-miranda-key"INSTANCE_TYPE="t4g.small"AMI_SEARCH="al2023-ami-*-arm64" # Amazon Linux 2023, ARM64
echo ""echo "=== Miranda-Engine: EC2 provisioning ==="echo "Region: $REGION | Type: $INSTANCE_TYPE"echo ""
# --- Import or check key pair ---PEM_PATH="$HOME/.ssh/beryl-aws-key.pem"if [ ! -f "$PEM_PATH" ]; then echo "✗ PEM key not found at $PEM_PATH. Run aws-setup.sh first." exit 1fi
KEY_EXISTS=$(aws ec2 describe-key-pairs --key-names "$KEY_NAME" --query "KeyPairs[0].KeyName" --output text 2>/dev/null || echo "")if [ -z "$KEY_EXISTS" ] || [ "$KEY_EXISTS" = "None" ]; then echo "Importing public key as $KEY_NAME in AWS..." # Extract public key from the PEM, import it PUBLIC_KEY=$(ssh-keygen -y -f "$PEM_PATH" 2>/dev/null) aws ec2 import-key-pair \ --key-name "$KEY_NAME" \ --public-key-material "$(echo "$PUBLIC_KEY" | base64)" \ --output text > /dev/null echo "✓ Key pair imported"else echo "✓ Key pair $KEY_NAME already exists in AWS"fi
# --- Security group ---SG_NAME="miranda-engine-sg"SG_ID=$(aws ec2 describe-security-groups \ --filters "Name=group-name,Values=$SG_NAME" \ --query "SecurityGroups[0].GroupId" --output text 2>/dev/null || echo "")
if [ -z "$SG_ID" ] || [ "$SG_ID" = "None" ]; then echo "Creating security group $SG_NAME..." SG_ID=$(aws ec2 create-security-group \ --group-name "$SG_NAME" \ --description "Miranda-Engine dev/test instance" \ --query "GroupId" --output text) # SSH only from current IP MY_IP=$(curl -s https://checkip.amazonaws.com) aws ec2 authorize-security-group-ingress \ --group-id "$SG_ID" \ --protocol tcp --port 22 --cidr "${MY_IP}/32" > /dev/null echo "✓ Security group created: $SG_ID (SSH from $MY_IP only)"else echo "✓ Security group already exists: $SG_ID"fi
# --- Find AMI ---AMI_ID=$(aws ec2 describe-images \ --owners amazon \ --filters "Name=name,Values=${AMI_SEARCH}" \ "Name=state,Values=available" \ --query "sort_by(Images, &CreationDate)[-1].ImageId" \ --output text)echo "✓ Latest ARM64 AMI: $AMI_ID"
# --- Launch instance ---# User data: install Rust and clone the repo on first bootUSER_DATA=$(cat <<'USERDATA'#!/bin/bashset -eyum update -yyum install -y git gcccurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -ysource "$HOME/.cargo/env"git clone https://github.com/tyronne-os/Miranda.git /home/ec2-user/miranda-enginechown -R ec2-user:ec2-user /home/ec2-user/miranda-engineUSERDATA)
echo "Launching $INSTANCE_TYPE instance..."INSTANCE_ID=$(aws ec2 run-instances \ --image-id "$AMI_ID" \ --instance-type "$INSTANCE_TYPE" \ --key-name "$KEY_NAME" \ --security-group-ids "$SG_ID" \ --user-data "$USER_DATA" \ --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=miranda-engine-arm64}]" \ --query "Instances[0].InstanceId" \ --output text)
echo "✓ Instance launched: $INSTANCE_ID"echo " Waiting for it to reach 'running' state (takes ~30s)..."aws ec2 wait instance-running --instance-ids "$INSTANCE_ID"
PUBLIC_IP=$(aws ec2 describe-instances \ --instance-ids "$INSTANCE_ID" \ --query "Reservations[0].Instances[0].PublicIpAddress" \ --output text)
echo "✓ Instance is running at $PUBLIC_IP"ssh-keyscan -H "$PUBLIC_IP" >> ~/.ssh/known_hosts 2>/dev/nullecho "$PUBLIC_IP" > ~/.miranda-ec2-ipecho "✓ IP saved to ~/.miranda-ec2-ip"
echo ""echo "=== Provisioning complete ==="echo "Wait ~3 minutes for the user-data bootstrap (Rust install + git clone) to finish."echo "Then run: bash scripts/arm64-verify.sh"