Skip to content

Commit ce96a9e

Browse files
committed
docs: plan native WAF runtime integration
1 parent c292523 commit ce96a9e

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Native WAF Execution Plan — pd-edge
2+
3+
> **For Hermes:** Integrate only after pd-edge-waf differential tests and pd-vm plan validation are complete.
4+
5+
**Goal:** Load, publish, pool, execute, and observe native WAF plan artifacts alongside existing VMBC programs.
6+
7+
**Architecture:** `LoadedProgram` gains an optional validated rule-plan artifact owned by pd-vm. Program and plan publication is atomic and content-addressed. Request handlers construct typed transaction input, invoke the plan executor, and map the typed decision into the existing response/proxy flow.
8+
9+
**Tech Stack:** Rust, ArcSwap, pd-vm rule-plan API, existing admin upload and VM pool infrastructure.
10+
11+
---
12+
13+
## Stage 1: Versioned artifact upload
14+
15+
### Task 1: Define the upload envelope
16+
17+
**Files:**
18+
- Modify: `src/runtime.rs`
19+
- Modify: `src/admin.rs` or the current admin route owner
20+
- Test: existing admin/runtime tests
21+
22+
**Requirements:**
23+
- Envelope contains VMBC, optional native plan, schema version, and content hashes.
24+
- Validate both artifacts before publication.
25+
- Reject partial or incompatible uploads without replacing the active program.
26+
27+
### Task 2: Content-addressed publication
28+
29+
**Files:**
30+
- Modify: `src/runtime.rs`
31+
- Modify: `src/runtime/vm_runner.rs`
32+
33+
**Requirements:**
34+
- Re-upload of identical VMBC and plan hashes keeps the existing loaded object and VM pool.
35+
- Changed artifacts create a new loaded object.
36+
- No trace reuse across different hashes.
37+
38+
## Stage 2: Request execution path
39+
40+
1. Build typed transaction input from the existing HTTP request context.
41+
2. Execute the native plan before proxy forwarding.
42+
3. Map block status, score, HTTP status, and matched IDs into current response headers.
43+
4. Retain RSS execution as fallback during rollout.
44+
5. Add a runtime selector for RSS, native plan, and differential shadow mode.
45+
46+
## Stage 3: Pooling and observability
47+
48+
1. Share immutable plan/operator assets across all VMs for the loaded program.
49+
2. Keep VM-local dynamic assets local.
50+
3. Add counters for native-plan requests, rules evaluated, regex asset count, block point, execution latency, and RSS/native mismatches.
51+
4. Remove any separate warmed-pool design unless measurements show a scheduling issue.
52+
53+
## Verification
54+
55+
```bash
56+
cargo fmt --check
57+
cargo test --release
58+
cargo clippy --all-targets --all-features -- -D warnings
59+
```
60+
61+
From pd-edge-waf:
62+
63+
```bash
64+
cargo test --release --test e2e
65+
```
66+
67+
## Acceptance criteria
68+
69+
- Artifact publication is atomic.
70+
- Identical uploads retain the exact loaded object and pool.
71+
- Native and RSS decisions can run in shadow mode and report mismatches.
72+
- Blocked requests never reach upstream.
73+
- Existing VMBC-only uploads remain compatible.

0 commit comments

Comments
 (0)