Skip to content

Commit 4da79f6

Browse files
committed
Merge trigger-vm-tests: fix Redis port conflict and merge conflicts in VM execution tests
2 parents 404771e + f91725d commit 4da79f6

3 files changed

Lines changed: 135 additions & 44 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Design: Enhance claude-log-analyzer with terraphim_automata
2+
3+
## Problem Statement
4+
5+
The claude-log-analyzer crate has terraphim_automata integration behind a feature flag, but underutilizes its capabilities:
6+
- Only uses `find_matches()` for basic pattern matching
7+
- Hardcodes concept definitions instead of dynamic extraction
8+
- Clones thesaurus on every call (inefficient)
9+
- Doesn't use fuzzy matching, autocomplete, or graph connectivity features
10+
11+
## Goals
12+
13+
1. Better text processing using terraphim_automata capabilities
14+
2. Dynamic concept/pattern learning from observed tool usage
15+
3. Efficient thesaurus management with caching
16+
4. Leverage graph connectivity for relationship inference
17+
18+
## Implementation Plan
19+
20+
### Step 1: Improve TerraphimMatcher Pattern Matching
21+
22+
**File**: `src/patterns/matcher.rs`
23+
24+
Current:
25+
```rust
26+
terraphim_find_matches(text, thesaurus.clone(), true)
27+
```
28+
29+
Changes:
30+
- Cache compiled automata instead of rebuilding
31+
- Use fuzzy matching for typo tolerance
32+
- Add context extraction for better pattern understanding
33+
34+
### Step 2: Dynamic Concept Building in KnowledgeGraphBuilder
35+
36+
**File**: `src/kg/builder.rs`
37+
38+
Current: Hardcoded concept lists (BUN, NPM, INSTALL, etc.)
39+
40+
Changes:
41+
- Learn concepts dynamically from observed patterns
42+
- Use terraphim_automata's thesaurus capabilities
43+
- Build hierarchical concept relationships
44+
45+
### Step 3: Enhanced Search with Graph Connectivity
46+
47+
**File**: `src/kg/search.rs`
48+
49+
Current: Manual proximity-based result merging
50+
51+
Changes:
52+
- Use `is_all_terms_connected_by_path()` for semantic relationships
53+
- Improve relevance scoring with concept graph distances
54+
- Cache search results for repeated queries
55+
56+
### Step 4: Integrate Learned Patterns with Terraphim
57+
58+
**File**: `src/patterns/knowledge_graph.rs`
59+
60+
Current: Separate learning system from terraphim
61+
62+
Changes:
63+
- Store learned patterns in terraphim thesaurus
64+
- Use graph structure for relationship inference
65+
- Export/import learned knowledge
66+
67+
## File Changes
68+
69+
| File | Action | Purpose |
70+
|------|--------|---------|
71+
| `src/patterns/matcher.rs:159-290` | Modify | Cache automata, add fuzzy matching |
72+
| `src/kg/builder.rs` | Modify | Dynamic concept learning |
73+
| `src/kg/search.rs` | Modify | Graph connectivity for search |
74+
| `src/patterns/knowledge_graph.rs` | Modify | Integrate with terraphim learning |
75+
76+
## Acceptance Criteria
77+
78+
1. Pattern matching uses cached automata (no clone per call)
79+
2. Concepts learned dynamically from tool observation
80+
3. Fuzzy matching available for typo-tolerant search
81+
4. Tests pass with `--features terraphim`

.github/workflows/vm-execution-tests.yml

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name: VM Execution Tests
44
# Firecracker is Linux-only - these tests will not work on macOS/Windows
55
# The scratchpad/firecracker-rust directory is gitignored (experimental code)
66
# Tests will skip gracefully if the directory is not present
7+
# Triggered manually for adaptive concurrency testing
78

89
on:
910
push:
@@ -94,18 +95,47 @@ jobs:
9495
runs-on: [self-hosted, linux, x64]
9596
timeout-minutes: 15
9697

97-
services:
98-
redis:
99-
image: redis:7-alpine
100-
ports:
101-
- 6379:6379
102-
options: >-
103-
--health-cmd "redis-cli ping"
104-
--health-interval 10s
105-
--health-timeout 5s
106-
--health-retries 5
98+
# NOTE: No services block - we check for existing Redis on self-hosted runner
99+
# and only start a container if none is available
107100

108101
steps:
102+
- name: Check for existing Redis
103+
id: redis_check
104+
run: |
105+
if redis-cli -h 127.0.0.1 -p 6379 ping 2>/dev/null | grep -q PONG; then
106+
echo "Redis is available on localhost:6379"
107+
echo "redis_available=true" >> $GITHUB_OUTPUT
108+
echo "redis_host=127.0.0.1" >> $GITHUB_OUTPUT
109+
echo "redis_port=6379" >> $GITHUB_OUTPUT
110+
echo "redis_started=false" >> $GITHUB_OUTPUT
111+
else
112+
echo "No Redis found, will start container on port 6380"
113+
echo "redis_available=false" >> $GITHUB_OUTPUT
114+
echo "redis_host=127.0.0.1" >> $GITHUB_OUTPUT
115+
echo "redis_port=6380" >> $GITHUB_OUTPUT
116+
echo "redis_started=true" >> $GITHUB_OUTPUT
117+
fi
118+
119+
- name: Start Redis container (if needed)
120+
if: steps.redis_check.outputs.redis_available == 'false'
121+
run: |
122+
docker run -d --name ci-redis-${{ github.run_id }} \
123+
-p 6380:6379 \
124+
--health-cmd "redis-cli ping" \
125+
--health-interval 10s \
126+
--health-timeout 5s \
127+
--health-retries 5 \
128+
redis:7-alpine
129+
# Wait for Redis to be healthy
130+
for i in {1..30}; do
131+
if redis-cli -h 127.0.0.1 -p 6380 ping 2>/dev/null | grep -q PONG; then
132+
echo "Redis container is ready"
133+
break
134+
fi
135+
echo "Waiting for Redis container... ($i/30)"
136+
sleep 2
137+
done
138+
109139
- name: Checkout code
110140
uses: actions/checkout@v6
111141

@@ -172,6 +202,10 @@ jobs:
172202
173203
- name: Run integration tests
174204
if: steps.check_fcctl.outputs.exists == 'true'
205+
env:
206+
REDIS_HOST: ${{ steps.redis_check.outputs.redis_host }}
207+
REDIS_PORT: ${{ steps.redis_check.outputs.redis_port }}
208+
REDIS_URL: redis://${{ steps.redis_check.outputs.redis_host }}:${{ steps.redis_check.outputs.redis_port }}
175209
run: |
176210
cd scratchpad/firecracker-rust/fcctl-web
177211
cargo test llm_api_tests \
@@ -180,6 +214,10 @@ jobs:
180214
181215
- name: Run HTTP API security tests
182216
if: steps.check_fcctl.outputs.exists == 'true'
217+
env:
218+
REDIS_HOST: ${{ steps.redis_check.outputs.redis_host }}
219+
REDIS_PORT: ${{ steps.redis_check.outputs.redis_port }}
220+
REDIS_URL: redis://${{ steps.redis_check.outputs.redis_host }}:${{ steps.redis_check.outputs.redis_port }}
183221
run: |
184222
cd scratchpad/firecracker-rust/fcctl-web
185223
cargo test security_tests \
@@ -197,6 +235,12 @@ jobs:
197235
kill $FCCTL_WEB_PID || true
198236
fi
199237
238+
- name: Stop Redis container (if started)
239+
if: always() && steps.redis_check.outputs.redis_started == 'true'
240+
run: |
241+
docker stop ci-redis-${{ github.run_id }} || true
242+
docker rm ci-redis-${{ github.run_id }} || true
243+
200244
websocket-tests:
201245
name: WebSocket Tests
202246
runs-on: [self-hosted, linux, x64]

scripts/test-vm-execution.sh

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,6 @@ check_dependencies() {
202202
exit 1
203203
fi
204204

205-
<<<<<<< HEAD
206-
# Check for fcctl-web binary if we need to start server
207-
if [ "$START_SERVER" = true ]; then
208-
if [ ! -f "scratchpad/firecracker-rust/fcctl-web/target/debug/fcctl-web" ] &&
209-
[ ! -f "scratchpad/firecracker-rust/fcctl-web/target/release/fcctl-web" ]; then
210-
log_info "Building fcctl-web server..."
211-
cd scratchpad/firecracker-rust/fcctl-web
212-
cargo build --release
213-
cd - > /dev/null
214-
=======
215205
# Check if fcctl-web directory exists
216206
if [ ! -d "scratchpad/firecracker-rust/fcctl-web" ]; then
217207
log_warning "fcctl-web directory not found (scratchpad/firecracker-rust/fcctl-web)"
@@ -228,7 +218,6 @@ check_dependencies() {
228218
cargo build --release
229219
cd - > /dev/null
230220
fi
231-
>>>>>>> origin/main
232221
fi
233222
fi
234223

@@ -241,14 +230,11 @@ start_server() {
241230
return
242231
fi
243232

244-
<<<<<<< HEAD
245-
=======
246233
if [ "${NO_FCCTL_WEB:-false}" = true ]; then
247234
log_warning "Skipping fcctl-web server start - directory not present (expected for CI)"
248235
return
249236
fi
250237

251-
>>>>>>> origin/main
252238
log_info "Starting fcctl-web server..."
253239

254240
cd scratchpad/firecracker-rust/fcctl-web
@@ -284,14 +270,11 @@ start_server() {
284270
check_server() {
285271
log_info "Checking fcctl-web server availability..."
286272

287-
<<<<<<< HEAD
288-
=======
289273
if [ "${NO_FCCTL_WEB:-false}" = true ]; then
290274
log_warning "Skipping server check - fcctl-web not present (expected for CI)"
291275
return
292276
fi
293277

294-
>>>>>>> origin/main
295278
if curl -s "$FCCTL_WEB_URL/health" > /dev/null 2>&1; then
296279
log_success "fcctl-web server is available at $FCCTL_WEB_URL"
297280
else
@@ -325,14 +308,11 @@ run_unit_tests() {
325308
run_integration_tests() {
326309
log_info "Running integration tests..."
327310

328-
<<<<<<< HEAD
329-
=======
330311
if [ "${NO_FCCTL_WEB:-false}" = true ]; then
331312
log_warning "Skipping integration tests - fcctl-web not present (expected for CI)"
332313
return 0
333314
fi
334315

335-
>>>>>>> origin/main
336316
cd scratchpad/firecracker-rust/fcctl-web
337317

338318
local test_args=()
@@ -356,14 +336,11 @@ run_integration_tests() {
356336
run_websocket_tests() {
357337
log_info "Running WebSocket tests..."
358338

359-
<<<<<<< HEAD
360-
=======
361339
if [ "${NO_FCCTL_WEB:-false}" = true ]; then
362340
log_warning "Skipping WebSocket tests - fcctl-web not present (expected for CI)"
363341
return 0
364342
fi
365343

366-
>>>>>>> origin/main
367344
cd scratchpad/firecracker-rust/fcctl-web
368345

369346
local test_args=("--ignored")
@@ -387,14 +364,11 @@ run_websocket_tests() {
387364
run_e2e_tests() {
388365
log_info "Running end-to-end tests..."
389366

390-
<<<<<<< HEAD
391-
=======
392367
if [ "${NO_FCCTL_WEB:-false}" = true ]; then
393368
log_warning "Skipping end-to-end tests - fcctl-web not present (expected for CI)"
394369
return 0
395370
fi
396371

397-
>>>>>>> origin/main
398372
local test_args=("--ignored")
399373
if [ "$VERBOSE" = true ]; then
400374
test_args+=("--" "--nocapture")
@@ -432,10 +406,6 @@ run_security_tests() {
432406
else
433407
log_warning "Skipping integration security tests - fcctl-web not present (expected for CI)"
434408
fi
435-
<<<<<<< HEAD
436-
cd - > /dev/null
437-
=======
438-
>>>>>>> origin/main
439409

440410
if [ $result -eq 0 ]; then
441411
log_success "Security tests passed"
@@ -467,10 +437,6 @@ run_performance_tests() {
467437
else
468438
log_warning "Skipping integration performance tests - fcctl-web not present (expected for CI)"
469439
fi
470-
<<<<<<< HEAD
471-
cd - > /dev/null
472-
=======
473-
>>>>>>> origin/main
474440

475441
# Agent performance tests
476442
if ! cargo test agent_performance_tests --ignored --release 2>&1 | tee -a "$LOG_FILE"; then

0 commit comments

Comments
 (0)