embeddenator 0.20.0-alpha.1

Sparse ternary VSA holographic computing substrate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
# ARM64 Self-Hosted Runner Setup Guide

This guide covers setting up self-hosted GitHub Actions runners for building ARM64 images, either on native ARM64 hardware or using QEMU emulation on a powerful x86_64 host.

## Hardware Requirements

### Option 1: One Large Runner (Recommended for Desktop)
- **CPU:** 10 cores dedicated
- **RAM:** 16GB
- **Disk:** 100GB free space
- **OS:** Ubuntu 22.04+ or Debian 12+
- **Best for:** Building all ARM64 configs in parallel

### Option 2: Multiple Small Runners
- **Per Runner:**
  - CPU: 4 cores
  - RAM: 6GB
  - Disk: 30GB free space each
- **Quantity:** 4 runners
- **Total Resources:** 16 cores, 24GB RAM, 120GB disk
- **Best for:** Distributing load across multiple VMs/containers

### Option 3: Native ARM64 Hardware Options

#### Cloud Providers:
- **AWS Graviton (t4g/c7g):** Cost-effective ARM64 instances
- **Oracle Cloud ARM:** Free tier available with Ampere CPUs
- **Azure Dpsv5:** ARM64-based VMs
- **Google Cloud Tau T2A:** ARM64 instances

#### On-Premise/Edge:
- **Raspberry Pi 5:** 4-8GB RAM, suitable for light workloads
- **Rock5 Model B:** Up to 32GB RAM, powerful SBC
- **NVIDIA Jetson:** GPU-enabled ARM64 (future use)
- **Apple Silicon (M1/M2/M3):** Via macOS runners (requires additional setup)

## Setup Instructions

### QEMU Emulation Setup (x86_64 Host)

If you're running on x86_64 hardware and want to emulate ARM64:

1. **Install QEMU and KVM:**
```bash
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y qemu-system-aarch64 qemu-user-static binfmt-support

# Enable ARM64 emulation
sudo update-binfmts --enable qemu-aarch64

# Verify
docker run --rm --platform linux/arm64 arm64v8/ubuntu uname -m
# Should output: aarch64
```

2. **Install Docker with multi-platform support:**
```bash
# Enable Docker buildx
docker buildx create --name multiarch --driver docker-container --use
docker buildx inspect --bootstrap
```

### Option 1: Single Large Runner Setup

1. **Create runner directory:**
```bash
mkdir -p ~/actions-runner-arm64-large && cd ~/actions-runner-arm64-large
```

2. **Download GitHub Actions runner:**
```bash
# For x86_64 host (QEMU emulation)
curl -o actions-runner-linux-x64.tar.gz -L \
  https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-x64-2.311.0.tar.gz
tar xzf ./actions-runner-linux-x64.tar.gz

# For native ARM64 host
curl -o actions-runner-linux-arm64.tar.gz -L \
  https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-arm64-2.311.0.tar.gz
tar xzf ./actions-runner-linux-arm64.tar.gz
```

3. **Configure the runner:**
```bash
# Get token from: https://github.com/tzervas/embeddenator/settings/actions/runners/new
./config.sh \
  --url https://github.com/tzervas/embeddenator \
  --token YOUR_RUNNER_TOKEN \
  --name arm64-large-runner \
  --labels self-hosted,linux,ARM64,large \
  --work _work
```

4. **Configure resource limits (systemd service):**
```bash
sudo ./svc.sh install

# Edit service file to set resource limits
sudo systemctl edit actions.runner.tzervas-embeddenator.arm64-large-runner.service
```

Add this content:
```ini
[Service]
# CPU limit: 10 cores
CPUQuota=1000%

# Memory limit: 16GB
MemoryMax=16G
MemoryHigh=15G

# Disk I/O priority
IOWeight=500
```

5. **Start the runner:**
```bash
sudo ./svc.sh start
sudo ./svc.sh status
```

### Option 2: Multiple Small Runners Setup

For 4 runners (runner-1 through runner-4):

```bash
for i in {1..4}; do
  mkdir -p ~/actions-runner-arm64-$i && cd ~/actions-runner-arm64-$i
  
  # Download and extract (use appropriate architecture)
  curl -o actions-runner.tar.gz -L \
    https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-x64-2.311.0.tar.gz
  tar xzf ./actions-runner.tar.gz
  
  # Configure (get separate token for each runner)
  ./config.sh \
    --url https://github.com/tzervas/embeddenator \
    --token YOUR_RUNNER_TOKEN_$i \
    --name arm64-runner-$i \
    --labels self-hosted,linux,ARM64 \
    --work _work
  
  # Install and start service
  sudo ./svc.sh install
  sudo ./svc.sh start
done
```

Add resource limits for each runner:
```bash
for i in {1..4}; do
  sudo systemctl edit actions.runner.tzervas-embeddenator.arm64-runner-$i.service
done
```

Per-runner limits:
```ini
[Service]
# CPU limit: 4 cores
CPUQuota=400%

# Memory limit: 6GB
MemoryMax=6G
MemoryHigh=5.5G

# Disk I/O priority
IOWeight=250
```

## Disk Management Strategy

To prevent disk space issues during builds:

### 1. Regular Cleanup Cron Job

Create `/etc/cron.daily/docker-cleanup`:
```bash
#!/bin/bash
# Clean up Docker resources daily

# Remove stopped containers older than 1 day
docker container prune -f --filter "until=24h"

# Remove dangling images
docker image prune -f

# Remove unused build cache older than 3 days
docker builder prune -f --filter "until=72h"

# Remove unused volumes
docker volume prune -f

# Log disk usage
df -h >> /var/log/docker-cleanup.log
docker system df >> /var/log/docker-cleanup.log
```

Make it executable:
```bash
sudo chmod +x /etc/cron.daily/docker-cleanup
```

## Automated Runner Management (Recommended)

The Embeddenator project includes a comprehensive Python-based automation system that handles runner lifecycle management automatically. This is the **recommended approach** for production deployments.

### Why Use Automation?

✅ **Automatic registration** with short-lived tokens  
✅ **Health monitoring** and auto-recovery  
✅ **Auto-scaling** with idle timeout  
✅ **Multi-runner coordination**  
✅ **Zero manual intervention** required  

### Quick Start with runner_manager.py

#### 1. Configure Environment
```bash
# In the embeddenator repository root
cp .env.example .env

# Edit .env and set:
GITHUB_REPOSITORY=tzervas/embeddenator
GITHUB_TOKEN=ghp_your_personal_access_token
RUNNER_LABELS=self-hosted,linux,ARM64
RUNNER_TARGET_ARCHITECTURES=arm64
```

#### 2. Run in Auto Mode (Cost Optimized)
```bash
# Single runner with auto-deregistration after 5 minutes idle
python3 runner_manager.py run

# Multiple runners for parallel builds
RUNNER_COUNT=4 python3 runner_manager.py run
```

#### 3. Run in Manual Mode (Persistent)
```bash
# Keep runner alive until manually stopped
RUNNER_MODE=manual python3 runner_manager.py run
```

### Configuration Options

Key environment variables for ARM64 runners:

```bash
# Runner Configuration
RUNNER_NAME=arm64-runner-1           # Unique name for each runner
RUNNER_LABELS=self-hosted,linux,ARM64  # Required labels for workflow
RUNNER_COUNT=1                       # Number of runners to deploy

# Architecture Support
RUNNER_TARGET_ARCHITECTURES=arm64    # Target architecture
RUNNER_ENABLE_EMULATION=true         # Enable QEMU if on x86_64
RUNNER_EMULATION_AUTO_INSTALL=false  # Auto-install QEMU (requires sudo)

# Lifecycle Management
RUNNER_MODE=auto                     # auto|manual
RUNNER_IDLE_TIMEOUT=300              # Auto-deregister after 5 min idle
RUNNER_EPHEMERAL=false               # Single-use runners (deregister after 1 job)

# Resource Management
RUNNER_WORK_DIR=_work                # Working directory for jobs
RUNNER_CLEANUP_ON_EXIT=true          # Clean up on shutdown
```

### Advanced Deployment Scenarios

#### Scenario 1: ARM64 with QEMU Emulation (Development)
```bash
# On x86_64 host, emulate ARM64 runners
RUNNER_TARGET_ARCHITECTURES=arm64 \
RUNNER_ENABLE_EMULATION=true \
RUNNER_EMULATION_METHOD=docker \
RUNNER_COUNT=2 \
python3 runner_manager.py run
```

#### Scenario 2: Native ARM64 (Production)
```bash
# On ARM64 hardware (or Graviton/Oracle Cloud)
RUNNER_TARGET_ARCHITECTURES=arm64 \
RUNNER_MODE=manual \
RUNNER_COUNT=4 \
python3 runner_manager.py run
```

#### Scenario 3: Auto-Scaling for CI/CD
```bash
# Auto-register on demand, auto-deregister when idle
RUNNER_MODE=auto \
RUNNER_IDLE_TIMEOUT=300 \
RUNNER_COUNT=2 \
python3 runner_manager.py run
```

### Monitoring and Management

#### Check Runner Status
```bash
python3 runner_manager.py status
```

#### View Logs
```bash
# Real-time logs
python3 runner_manager.py run --verbose

# Check runner_manager logs
tail -f logs/runner_manager.log
```

#### Stop Runners
```bash
# Graceful shutdown
python3 runner_manager.py stop

# Or Ctrl+C in the terminal running the manager
```

### Integration with Systemd (Production)

For production deployments, run runner_manager.py as a systemd service:

```bash
# Create service file
sudo tee /etc/systemd/system/github-runner-manager.service > /dev/null <<EOF
[Unit]
Description=GitHub Actions Runner Manager for Embeddenator
After=network.target docker.service

[Service]
Type=simple
User=github-runner
WorkingDirectory=/home/github-runner/embeddenator
EnvironmentFile=/home/github-runner/embeddenator/.env
ExecStart=/usr/bin/python3 /home/github-runner/embeddenator/runner_manager.py run
Restart=on-failure
RestartSec=10

[Install]
WantedBy=multi-user.target
EOF

# Enable and start
sudo systemctl daemon-reload
sudo systemctl enable github-runner-manager
sudo systemctl start github-runner-manager

# Check status
sudo systemctl status github-runner-manager
```

### Comparison: Manual vs Automated Setup

| Feature | Manual Setup | Automated (runner_manager.py) |
|---------|-------------|-------------------------------|
| Registration | Manual token management | Automatic with short-lived tokens |
| Lifecycle | Manual start/stop | Fully automated |
| Health Monitoring | External monitoring needed | Built-in |
| Multi-Runner | Complex scripting | Simple config |
| Auto-Scaling | Not supported | Built-in with idle timeout |
| Recovery | Manual intervention | Automatic restart |
| Emulation | Manual QEMU setup | Auto-detected and configured |
| **Recommended For** | Quick testing, learning | Production & active development |

### Further Documentation

For complete automation features, see:
- [Runner Automation Guide]../../docs/RUNNER_AUTOMATION.md
- [Self-Hosted CI Project Spec]../../docs/SELF_HOSTED_CI_PROJECT_SPEC.md

### 2. Docker Daemon Configuration

Edit `/etc/docker/daemon.json`:
```json
{
  "data-root": "/path/to/large/disk",
  "storage-driver": "overlay2",
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  },
  "default-ulimits": {
    "nofile": {
      "Name": "nofile",
      "Hard": 64000,
      "Soft": 64000
    }
  }
}
```

Restart Docker:
```bash
sudo systemctl restart docker
```

### 3. Monitoring Disk Usage

Add to runner's crontab:
```bash
crontab -e
```

Add:
```
# Check disk space every hour, alert if < 20GB free
0 * * * * df -h / | awk 'NR==2 {if ($4 < 20) print "Low disk space: "$4" free"}' | logger -t github-runner
```

## Workflow Usage

### Triggering ARM64 Builds

1. **Go to:** https://github.com/tzervas/embeddenator/actions/workflows/build-push-arm64.yml
2. **Click:** "Run workflow"
3. **Select:**
   - Runner type: `large` or `multi` based on your setup
   - OS selections: e.g., `debian-stable-arm64,ubuntu-stable-arm64`
   - Push to GHCR: `true`
4. **Click:** "Run workflow"

### Example Configurations

**Quick test (single config):**
```
os_selections: debian-stable-arm64
runner_type: large
push_to_ghcr: false
run_tests: true
```

**Production build (all configs):**
```
os_selections: debian-stable-arm64,debian-testing-arm64,ubuntu-stable-arm64,ubuntu-testing-arm64
runner_type: large
push_to_ghcr: true
run_tests: true
```

**Distributed build (multiple runners):**
```
os_selections: debian-stable-arm64,debian-testing-arm64,ubuntu-stable-arm64,ubuntu-testing-arm64
runner_type: multi
push_to_ghcr: true
run_tests: false
```

## Troubleshooting

### Check Runner Status
```bash
# Via systemd
sudo systemctl status actions.runner.tzervas-embeddenator.arm64-*

# Via runner script
cd ~/actions-runner-arm64-*/
./run.sh --check
```

### View Runner Logs
```bash
# Systemd logs
sudo journalctl -u actions.runner.tzervas-embeddenator.arm64-large-runner -f

# Runner logs
tail -f ~/actions-runner-arm64-*/_diag/*.log
```

### Check Disk Space
```bash
df -h
docker system df
docker system df -v
```

### Clean Everything (Emergency)
```bash
# Stop all runners
sudo systemctl stop actions.runner.tzervas-embeddenator.arm64-*

# Clean Docker
docker system prune -a -f --volumes

# Restart runners
sudo systemctl start actions.runner.tzervas-embeddenator.arm64-*
```

### QEMU Performance Issues

If builds are too slow with QEMU emulation:

1. **Reduce parallelism:** Use `max-parallel: 1` or `2`
2. **Increase CPU allocation:** Dedicate more cores
3. **Use KVM acceleration:** Ensure `/dev/kvm` is accessible
4. **Consider native ARM64:** Cloud instances (AWS Graviton, Oracle ARM) or SBC (Raspberry Pi 5, Rock5)

## Performance Expectations

### Native ARM64:
- Build time per image: 8-12 minutes
- 4 images in parallel: ~15 minutes total

### QEMU Emulation (10 cores):
- Build time per image: 25-35 minutes
- 4 images with max-parallel: 2: ~60 minutes total
- 4 images with max-parallel: 4: ~45 minutes total (higher load)

### Resource Usage During Build:
- CPU: 80-100% of allocated cores
- RAM: 4-8GB per parallel build
- Disk: 15-25GB per build (cleaned up after)

## Security Considerations

1. **Runner Isolation:** Each runner should run in its own user context
2. **Network Access:** Runners need access to GitHub and GHCR
3. **Secrets:** Never log secrets; use GitHub's secret management
4. **Updates:** Keep runner software updated
5. **Monitoring:** Set up alerts for unusual activity

### Best Practices:

#### 1. Use Dedicated User Account
```bash
# Create dedicated user for runners
sudo useradd -m -s /bin/bash github-runner
sudo usermod -aG docker github-runner

# Run runner installation as this user
sudo -u github-runner bash
```

#### 2. Network Firewall Configuration
```bash
# Only allow outbound HTTPS to GitHub
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow from 192.168.1.0/24 to any port 22  # SSH from local network only
sudo ufw enable
```

#### 3. Rotate Registration Tokens
- Never use long-lived tokens
- Tokens expire after 1 hour
- Use the runner_manager.py automation for automatic token management

#### 4. Secure Secrets Storage
```bash
# Store GitHub PAT securely
chmod 600 ~/.env
# Never commit .env to version control
```

## Maintenance

### Weekly Tasks:
- Check disk usage
- Review runner logs for errors
- Update runner software if new version available

### Monthly Tasks:
- Prune Docker system completely
- Review and optimize resource allocations
- Check for OS/package updates

## Uninstalling

```bash
# Stop and remove service
cd ~/actions-runner-arm64-*
sudo ./svc.sh stop
sudo ./svc.sh uninstall

# Remove runner from GitHub (--token needed)
./config.sh remove --token YOUR_TOKEN

# Clean up
cd ~
rm -rf ~/actions-runner-arm64-*
```

## Validation and Testing

After setting up your ARM64 runner, follow these validation steps to ensure everything works correctly.

### Phase 1: Basic Validation

#### 1.1 Verify Runner Registration
```bash
# Check runner appears in GitHub
# Go to: https://github.com/tzervas/embeddenator/settings/actions/runners
# Look for your runner name (e.g., arm64-runner-1) with "Idle" status
```

#### 1.2 Test Architecture Detection
```bash
# Create a simple test workflow or manually trigger ci-arm64.yml
# Check the "Verify Architecture" step output
# Expected: uname -m shows "aarch64" or "arm64"
```

#### 1.3 Verify Docker Access
```bash
# On the runner machine
docker run --rm hello-world
docker run --rm --platform linux/arm64 arm64v8/ubuntu uname -m
# Should output: aarch64
```

### Phase 2: CI Workflow Testing

#### 2.1 Manual Workflow Trigger
1. Navigate to: https://github.com/tzervas/embeddenator/actions/workflows/ci-arm64.yml
2. Click "Run workflow" button
3. Select branch (e.g., `main`)
4. Click "Run workflow"

#### 2.2 Monitor Execution
Watch the workflow run and verify:
- ✅ Runner picks up the job (status changes from "Queued" to "Running")
- ✅ Architecture detection shows aarch64
- ✅ Rust build completes successfully
- ✅ All tests pass
- ✅ Integration tests complete
- ✅ Build artifacts are uploaded (if job fails)

#### 2.3 Expected Timings
- **Native ARM64:** 8-15 minutes for full test suite
- **QEMU Emulation:** 25-45 minutes (depending on CPU cores)

### Phase 3: Performance Validation

#### 3.1 Run Benchmarks
```bash
# On the runner machine, clone and test locally
git clone https://github.com/tzervas/embeddenator.git
cd embeddenator
time cargo build --release
time cargo test --all --verbose
```

#### 3.2 Check Resource Usage During Build
```bash
# In another terminal while build is running
htop  # Monitor CPU usage
free -h  # Monitor memory
df -h  # Monitor disk space
docker stats  # Monitor Docker containers
```

#### 3.3 Expected Resource Usage
- **CPU:** 80-100% of allocated cores during compilation
- **Memory:** 4-8GB during peak (with 4-8 cores)
- **Disk I/O:** Moderate to high during dependency downloads
- **Network:** Spikes during crate downloads from crates.io

### Phase 4: Multi-Runner Testing (if applicable)

#### 4.1 Deploy Multiple Runners
```bash
# Using runner_manager.py
RUNNER_COUNT=2 python3 runner_manager.py run

# Or manually deploy 2 separate runners
```

#### 4.2 Trigger Parallel Workflows
Create 2-3 workflow runs simultaneously and verify:
- ✅ Jobs are distributed across runners
- ✅ Both runners show "Busy" status
- ✅ No job failures due to resource contention
- ✅ Build times are consistent across runners

### Phase 5: Failure Recovery Testing

#### 5.1 Test Runner Crash Recovery (with automation)
```bash
# If using runner_manager.py with auto mode
# Find the runner process and kill it
ps aux | grep runner
kill -9 <PID>

# Verify:
# - runner_manager.py detects failure
# - Automatic restart attempt (if configured)
# - Runner re-registers and becomes available
```

#### 5.2 Test Network Interruption
```bash
# Simulate network loss
sudo iptables -A OUTPUT -p tcp --dport 443 -j DROP

# Wait 2 minutes, then restore
sudo iptables -D OUTPUT -p tcp --dport 443 -j DROP

# Verify:
# - Runner reconnects automatically
# - Queued jobs execute after reconnection
```

#### 5.3 Test Disk Space Exhaustion
```bash
# Fill disk to >90% (create large file in /tmp)
dd if=/dev/zero of=/tmp/largefile bs=1M count=10000

# Trigger a build and verify:
# - Build fails gracefully with clear error
# - Cleanup scripts run (if configured)
# - After cleanup, runner becomes available again

# Clean up test file
rm /tmp/largefile
```

### Phase 6: Security Validation

#### 6.1 Verify Runner Isolation
```bash
# During a workflow run, check process ownership
ps aux | grep runner

# Verify runner process runs as non-root user
# Verify Docker containers run in separate namespace
```

#### 6.2 Check Secret Handling
```bash
# Add a test secret to repository
# Create a workflow that uses the secret
# After workflow completes, verify:
# - Secret not visible in logs
# - Secret not persisted in filesystem
# - Environment cleaned after job
```

#### 6.3 Audit Runner Logs
```bash
# Check for security events
sudo journalctl -u actions.runner.* | grep -i "error\|fail\|security"

# Review runner diagnostic logs
ls -la ~/actions-runner-*/_diag/
tail -100 ~/actions-runner-*/_diag/Runner_*.log
```

### Phase 7: Production Readiness Checklist

Before enabling automatic triggering on the main branch:

- [ ] ✅ Manual workflow runs complete successfully 3+ times
- [ ] ✅ All tests pass consistently
- [ ] ✅ Build time within acceptable range (<15 min for native ARM64)
- [ ] ✅ Resource usage monitored and within limits
- [ ] ✅ Disk cleanup automation working
- [ ] ✅ Security validation passed
- [ ] ✅ Failure recovery tested
- [ ] ✅ Runner uptime >99% over 1 week test period
- [ ] ✅ Documentation reviewed and accurate
- [ ] ✅ Team trained on monitoring and troubleshooting

### Troubleshooting Validation Issues

#### Issue: Runner doesn't pick up jobs
**Diagnosis:**
```bash
# Check runner status
sudo systemctl status actions.runner.*

# Check runner connectivity
curl -I https://api.github.com

# Verify labels match workflow requirements
# Workflow requires: ["self-hosted", "linux", "ARM64"]
```

**Resolution:**
- Verify runner is online in GitHub UI
- Check runner labels match workflow exactly
- Restart runner service
- Check firewall rules

#### Issue: Tests fail on ARM64 but pass on AMD64
**Diagnosis:**
```bash
# Run specific failing test locally
cargo test <test_name> --verbose -- --nocapture

# Check for architecture-specific code
grep -r "cfg(target_arch" src/
```

**Resolution:**
- Review test output for architecture-specific failures
- Check for endianness issues
- Verify all dependencies support ARM64
- Report architecture-specific bugs in GitHub issues

#### Issue: Build times too slow
**Diagnosis:**
```bash
# Check if using emulation vs native
uname -m  # Should show "aarch64" for native

# Check CPU allocation
nproc
lscpu

# Check for throttling
dmesg | grep -i throttl
```

**Resolution:**
- If emulated: Consider native ARM64 hardware
- Increase CPU core allocation
- Enable build caching
- Reduce parallelism if memory constrained

## Post-Setup Next Steps

After validation is complete:

1. **Enable Auto-Trigger** (see TASK-005 in TASK_REGISTRY.md):
   ```yaml
   # In .github/workflows/ci-arm64.yml
   on:
     push:
       branches: [main]  # Enable automatic runs on main
     workflow_dispatch:  # Keep manual trigger option
   ```

2. **Set up Monitoring**:
   - GitHub Actions dashboard for run history
   - Runner health checks (if using runner_manager.py)
   - Disk space alerts
   - Build time tracking

3. **Document Your Setup**:
   - Record runner configuration details
   - Document any custom modifications
   - Note performance characteristics
   - Create runbook for common operations

4. **Train Team**:
   - Share troubleshooting procedures
   - Document escalation paths
   - Establish maintenance schedule

## Additional Resources

- [GitHub Actions Self-Hosted Runner Docs]https://docs.github.com/en/actions/hosting-your-own-runners
- [Runner Automation Guide]../../docs/RUNNER_AUTOMATION.md
- [Self-Hosted CI Project Spec]../../docs/SELF_HOSTED_CI_PROJECT_SPEC.md
- [CI/CD Workflow Documentation]./README.md
- [Embeddenator Task Registry]../../TASK_REGISTRY.md

---

**Last Updated:** 2025-12-22  
**Document Version:** 2.0  
**Status:** Production Ready