diff options
| author | Your Name <you@example.com> | 2026-05-19 04:10:12 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-19 04:10:12 +0530 |
| commit | 2d78aadfd603fab9a9342b1281ad1d46ad82cf1d (patch) | |
| tree | 3e8875b7e0301ac6634548e186542e2d67a68f34 /RELAY_HARDENING_MERGE.md | |
| parent | abee221b0f0e5a4513ab126afbdfddc2728df6be (diff) | |
feat: relay hardening — restore build, add tests, negentropy adapter
Restores build broken by eeb9d2d (cvm-relay-stability removed deps):
- CMakeLists.txt: restore display.c, font.c, local_relay.c, relay_selector.c, sync_manager.c, axs15231b, qrcode, wisp_relay
- tollgate_main.c: restore display.h, local_relay.h, relay_selector.h, sync_manager.h includes and display calls
- cvm_server.c: kept master's keepalive/timeout/ping-pong fixes
New test infrastructure:
- test-local-relay, test-relay-nip11, test-cvm-roundtrip, test-cvm-mcp, test-cross-board make targets
- test-cvm-roundtrip.mjs: MCP get_config + get_balance via public relay
- test-cross-board.mjs: cross-board payment test
- test-cvm-mcp-relay.mjs: kept from master
New unit tests (35 tests):
- test_display.c: 22 tests for escape_wifi_field
- test_negentropy_adapter.c: 13 tests for negentropy adapter
New modules:
- negentropy_adapter.c/h: NIP-77 adapter skeleton
Docs:
- AGENTS.md: display module docs, new test commands
- RELAY_HARDENING_PLAN.md: hardening checklist
- RELAY_HARDENING_MERGE.md: merge plan and checklist
Cleanup:
- Removed CHECKLIST-CVM-RELAY.md, PLAN-SQUASH-MERGE.md (stale planning docs)
- Removed components/esp-miner submodule
Host unit tests: 63/63 pass
Diffstat (limited to 'RELAY_HARDENING_MERGE.md')
| -rw-r--r-- | RELAY_HARDENING_MERGE.md | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/RELAY_HARDENING_MERGE.md b/RELAY_HARDENING_MERGE.md new file mode 100644 index 0000000..036a96d --- /dev/null +++ b/RELAY_HARDENING_MERGE.md | |||
| @@ -0,0 +1,134 @@ | |||
| 1 | # Relay Hardening Merge Plan | ||
| 2 | |||
| 3 | ## Problem | ||
| 4 | |||
| 5 | Master at `abee221` is **broken** — the `eeb9d2d` commit (from cvm-relay-stability worktree) removed display/relay CMakeLists entries and tollgate_main includes because that worktree didn't have those modules. The hardening branch at `8d58cef` was based on `81f2dc5` which has the correct complete set. | ||
| 6 | |||
| 7 | ### Branch State | ||
| 8 | |||
| 9 | | Branch | HEAD | Based On | Status | | ||
| 10 | |--------|------|----------|--------| | ||
| 11 | | `master` | `abee221` | — | Broken (missing CMakeLists entries) | | ||
| 12 | | `feature/relay-hardening` | `8d58cef` | `81f2dc5` | 7 commits, all unit tests pass | | ||
| 13 | | `81f2dc5` | Original relay squash-merge | — | Last known-good build | | ||
| 14 | |||
| 15 | ### What `eeb9d2d` broke on master | ||
| 16 | - Removed `display.c`, `font.c`, `local_relay.c`, `relay_selector.c`, `sync_manager.c` from `main/CMakeLists.txt` SRCS | ||
| 17 | - Removed `axs15231b`, `qrcode`, `wisp_relay` from REQUIRES | ||
| 18 | - Removed `display.h`, `local_relay.h`, `relay_selector.h`, `sync_manager.h` includes from `tollgate_main.c` | ||
| 19 | - Removed `display_init()` and `display_set_state()` calls from `tollgate_main.c` | ||
| 20 | - BUT kept `relay_selector_t`, `sync_manager_t`, `local_relay_*()` calls that reference these modules | ||
| 21 | |||
| 22 | ### What `eeb9d2d` improved on master | ||
| 23 | - CVM server WS keepalive (ping/pong every 30s) | ||
| 24 | - TLS read timeout reduced from 15s to 1s | ||
| 25 | - Consecutive timeout counter (65s) for disconnect detection | ||
| 26 | - Relay close frame handling (opcode 0x08) | ||
| 27 | - Added `test-cvm-mcp-relay.mjs` integration test | ||
| 28 | - Added `CHECKLIST-CVM-RELAY.md` | ||
| 29 | |||
| 30 | --- | ||
| 31 | |||
| 32 | ## Strategy | ||
| 33 | |||
| 34 | **Soft-reset squash**: Reset hardening branch to master, manually compose the correct index, single-commit merge via fast-forward. | ||
| 35 | |||
| 36 | --- | ||
| 37 | |||
| 38 | ## Checklist | ||
| 39 | |||
| 40 | ### Step 1: Backup | ||
| 41 | - [x] Create backup tags | ||
| 42 | - [x] Create backup branch `feature/relay-hardening-backup` | ||
| 43 | |||
| 44 | ### Step 2: Compose Final State | ||
| 45 | - [ ] Soft-reset hardening worktree to master | ||
| 46 | - [ ] Restore `main/CMakeLists.txt` from `81f2dc5` (has all source files and deps) | ||
| 47 | - [ ] Restore `main/tollgate_main.c` from `81f2dc5` (has display + relay includes and calls) | ||
| 48 | - [ ] Keep `main/cvm_server.c` from master (has keepalive/timeout fixes) | ||
| 49 | - [ ] Keep `main/display.c` with non-static `escape_wifi_field` | ||
| 50 | - [ ] Stage new files: `negentropy_adapter.c/h`, `test_display.c`, `test_negentropy_adapter.c`, `test-cvm-roundtrip.mjs`, `test-cross-board.mjs`, `RELAY_HARDENING_PLAN.md` | ||
| 51 | - [ ] Stage updated files: `Makefile`, `AGENTS.md`, `tests/unit/Makefile` | ||
| 52 | - [ ] Delete `CHECKLIST-CVM-RELAY.md` | ||
| 53 | - [ ] Delete `PLAN-SQUASH-MERGE.md` | ||
| 54 | - [ ] Keep `test-cvm-mcp-relay.mjs` (from master) | ||
| 55 | - [ ] Keep `components/esp-miner` removed (from master) | ||
| 56 | |||
| 57 | ### Step 3: Verify | ||
| 58 | - [ ] `git diff --cached --stat` matches expected file list | ||
| 59 | - [ ] `git diff --cached -- main/cvm_server.c` shows master's keepalive version | ||
| 60 | - [ ] `git diff --cached -- main/CMakeLists.txt` shows all source files restored | ||
| 61 | - [ ] `git diff --cached -- main/tollgate_main.c` shows display + relay includes restored | ||
| 62 | - [ ] No `components/esp-miner` in staged diff | ||
| 63 | - [ ] `make test-unit` passes (all 63+ tests) | ||
| 64 | |||
| 65 | ### Step 4: Commit + Merge | ||
| 66 | - [ ] Create single squash commit on hardening branch | ||
| 67 | - [ ] Fast-forward merge to master | ||
| 68 | - [ ] Push master to origin | ||
| 69 | - [ ] Delete hardening worktree | ||
| 70 | - [ ] Delete `feature/relay-hardening` branch | ||
| 71 | |||
| 72 | --- | ||
| 73 | |||
| 74 | ## Expected Final Diff (master → new) | ||
| 75 | |||
| 76 | | File | Change | | ||
| 77 | |------|--------| | ||
| 78 | | `main/CMakeLists.txt` | **Restored** — add display.c, font.c, local_relay.c, relay_selector.c, sync_manager.c, axs15231b, qrcode, wisp_relay | | ||
| 79 | | `main/tollgate_main.c` | **Restored** — add display.h, local_relay.h, relay_selector.h, sync_manager.h includes + display calls | | ||
| 80 | | `main/cvm_server.c` | **Kept master's** — keepalive, timeout, ping/pong, close frame handling | | ||
| 81 | | `main/display.c` | `escape_wifi_field` made non-static | | ||
| 82 | | `main/negentropy_adapter.c/h` | **New** — negentropy adapter skeleton | | ||
| 83 | | `Makefile` | **New** — test-local-relay, test-relay-nip11, test-cvm-roundtrip, test-cross-board targets | | ||
| 84 | | `AGENTS.md` | **Updated** — display module docs, new test commands | | ||
| 85 | | `RELAY_HARDENING_PLAN.md` | **New** — this planning doc | | ||
| 86 | | `RELAY_HARDENING_MERGE.md` | **New** — this merge plan doc | | ||
| 87 | | `tests/integration/test-cvm-roundtrip.mjs` | **New** — CVM MCP roundtrip test | | ||
| 88 | | `tests/integration/test-cvm-mcp-relay.mjs` | **Kept** — from master's CVM stability commit | | ||
| 89 | | `tests/integration/test-cross-board.mjs` | **New** — cross-board payment test | | ||
| 90 | | `tests/unit/test_display.c` | **New** — 22 unit tests for escape_wifi_field | | ||
| 91 | | `tests/unit/test_negentropy_adapter.c` | **New** — 13 unit tests for negentropy adapter | | ||
| 92 | | `tests/unit/Makefile` | **Updated** — new test targets | | ||
| 93 | | `CHECKLIST-CVM-RELAY.md` | **Deleted** | | ||
| 94 | | `PLAN-SQUASH-MERGE.md` | **Deleted** | | ||
| 95 | |||
| 96 | --- | ||
| 97 | |||
| 98 | ## Commands | ||
| 99 | |||
| 100 | ```bash | ||
| 101 | # Step 1: Backups (from main repo) | ||
| 102 | cd /home/c03rad0r/esp32-tollgate | ||
| 103 | git tag backup/master-abee221 abee221 | ||
| 104 | git tag backup/hardening-8d58cef 8d58cef | ||
| 105 | git branch feature/relay-hardening-backup feature/relay-hardening | ||
| 106 | |||
| 107 | # Step 2: Soft-reset and compose (in hardening worktree) | ||
| 108 | cd /home/c03rad0r/esp32-tollgate-hardening | ||
| 109 | git reset --soft master | ||
| 110 | |||
| 111 | # Restore correct versions from last known-good commit | ||
| 112 | git checkout 81f2dc5 -- main/CMakeLists.txt main/tollgate_main.c | ||
| 113 | |||
| 114 | # Delete stale markdowns from index | ||
| 115 | git rm --cached CHECKLIST-CVM-RELAY.md PLAN-SQUASH-MERGE.md 2>/dev/null || true | ||
| 116 | |||
| 117 | # Verify and commit | ||
| 118 | git diff --cached --stat | ||
| 119 | git commit -m "feat: relay hardening — restore build, add tests, negentropy adapter" | ||
| 120 | |||
| 121 | # Step 3: Verify | ||
| 122 | make test-unit | ||
| 123 | |||
| 124 | # Step 4: Merge to master | ||
| 125 | cd /home/c03rad0r/esp32-tollgate | ||
| 126 | git checkout master | ||
| 127 | git merge --ff-only feature/relay-hardening | ||
| 128 | git push origin master | ||
| 129 | |||
| 130 | # Cleanup | ||
| 131 | git worktree remove /home/c03rad0r/esp32-tollgate-hardening | ||
| 132 | git branch -d feature/relay-hardening | ||
| 133 | git worktree prune | ||
| 134 | ``` | ||