Skip to content

Commit dc24b7c

Browse files
etrclaude
andcommitted
Merge TASK-071: wire install_not_found_alias_ and remove dead lambda_handler variant arm
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2 parents 12bcbb8 + 28bd5b6 commit dc24b7c

14 files changed

Lines changed: 482 additions & 99 deletions

File tree

specs/architecture/04-components/route-table.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
A `route_entry` carries:
1212
- `method_set methods` — which methods this entry serves
13-
- `std::variant<lambda_handler, std::shared_ptr<http_resource>>` — the actual handler (lambda or class)
13+
- `std::shared_ptr<http_resource>` — the actual handler; always a class-derived `http_resource` or a `lambda_resource` shim (the `lambda_handler` variant arm was removed in TASK-071; every lambda path already went through `lambda_resource`, so no call-site behaviour changed)
1414
- `bool is_prefix` — radix node bookkeeping
1515

1616
**Cache:** an LRU cache (256 entries) sits in front of all three structures, keyed by full path (and method, for per-method-handler entries). After warm-up, hot paths bypass even the hash lookup.
@@ -27,6 +27,6 @@ A `route_entry` carries:
2727

2828
**Related requirements:** PRD-HDL-REQ-002, PRD-HDL-REQ-004, PRD-HDL-REQ-006.
2929

30-
**Implementation status:** TASK-025 introduced `detail::route_entry` and the `lambda_resource` shim into the existing v1 three-map storage shape. TASK-027 wired `route_entry` into the full 3-tier table described above (hash map for exact paths, radix tree for parameterized/prefix paths, regex chain for regex routes). TASK-053 retired the v1 dispatch path: `webserver_impl::resolve_resource_for_request` now consults `lookup_v2()` (cache → exact → radix → regex) directly, the v1 LRU cache and the four v1 lookup helpers (`lookup_route_cache`, `scan_regex_routes`, `store_route_cache`, `apply_extracted_params`) are deleted, and the LRU cache field is renamed `route_lru_cache`. **TASK-067** deleted the v1 registration-side maps (`registered_resources`, `registered_resources_str`, `registered_resources_regex`) and their shared mutex; the v2 3-tier table is now the only routing surface end-to-end. Lambda/class path-conflict detection (`prepare_or_create_lambda_shim`) probes the v2 tiers via `find_v2_entry_by_path_`; the WebSocket registration map keeps its own `registered_ws_handlers_mutex_`. TASK-056 swapped the radix-node child container from `std::unordered_map` to `std::map<…, std::less<>>` for CWE-407 immunity and added registration-time detection of prefix-vs-exact terminus collisions (`reject_terminus_collision`).
30+
**Implementation status:** TASK-025 introduced `detail::route_entry` and the `lambda_resource` shim into the existing v1 three-map storage shape. TASK-027 wired `route_entry` into the full 3-tier table described above (hash map for exact paths, radix tree for parameterized/prefix paths, regex chain for regex routes). TASK-053 retired the v1 dispatch path: `webserver_impl::resolve_resource_for_request` now consults `lookup_v2()` (cache → exact → radix → regex) directly, the v1 LRU cache and the four v1 lookup helpers (`lookup_route_cache`, `scan_regex_routes`, `store_route_cache`, `apply_extracted_params`) are deleted, and the LRU cache field is renamed `route_lru_cache`. **TASK-067** deleted the v1 registration-side maps (`registered_resources`, `registered_resources_str`, `registered_resources_regex`) and their shared mutex; the v2 3-tier table is now the only routing surface end-to-end. Lambda/class path-conflict detection (`prepare_or_create_lambda_shim`) probes the v2 tiers via `find_v2_entry_by_path_`; the WebSocket registration map keeps its own `registered_ws_handlers_mutex_`. TASK-056 swapped the radix-node child container from `std::unordered_map` to `std::map<…, std::less<>>` for CWE-407 immunity and added registration-time detection of prefix-vs-exact terminus collisions (`reject_terminus_collision`). **TASK-071** collapsed `route_entry::handler` from `std::variant<lambda_handler, std::shared_ptr<http_resource>>` to a bare `std::shared_ptr<http_resource>`; the `lambda_handler` variant arm was dead (every writer already went through the `lambda_resource` shim), so removing it simplified dispatch without changing any observable behaviour.
3131

3232
---

specs/tasks/M7-v2-cleanup/TASK-071.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Two related forward-debt items in the alias/dispatch plumbing:
1010
2. `src/detail/webserver_dispatch.cpp:260, 313-318` — dead `lambda_handler` variant arm kept "for a future task" that may store lambdas directly. Either land the lambda-storage path or remove the dead arm.
1111

1212
**Action Items:**
13-
- [ ] In `install_not_found_alias_`, replace the empty stub callback with the real `route_resolved`-phase hook that builds the 404 response matching v1 behaviour, mirroring the structure of `install_method_not_allowed_alias_` and `install_internal_error_alias_`.
14-
- [ ] Add an integ test covering the alias path end-to-end (request a missing route, expect 404 with the alias-built body).
15-
- [ ] In `webserver_dispatch.cpp:260, 313-318`: decide whether the `lambda_handler` variant arm is needed. If yes, land the lambda-storage path so the arm is exercised. If no, remove the arm and update the variant's `std::variant` parameter list.
16-
- [ ] Update Doxygen on `webserver::route(...)` if the variant shape changed.
13+
- [x] In `install_not_found_alias_`, replace the empty stub callback with the real `route_resolved`-phase hook that builds the 404 response matching v1 behaviour, mirroring the structure of `install_method_not_allowed_alias_` and `install_internal_error_alias_`.
14+
- [x] Add an integ test covering the alias path end-to-end (request a missing route, expect 404 with the alias-built body).
15+
- [x] In `webserver_dispatch.cpp:260, 313-318`: decide whether the `lambda_handler` variant arm is needed. If yes, land the lambda-storage path so the arm is exercised. If no, remove the arm and update the variant's `std::variant` parameter list.
16+
- [x] Update Doxygen on `webserver::route(...)` if the variant shape changed (no public Doxygen referenced the variant; internal code comments updated in route_entry.hpp).
1717

1818
**Dependencies:**
1919
- Blocked by: TASK-048 (route_resolved/before_handler firing, Done)
@@ -28,4 +28,4 @@ Two related forward-debt items in the alias/dispatch plumbing:
2828
**Related Requirements:** PRD-HOOK-REQ-009 (v1 setters as aliases)
2929
**Related Decisions:** DR-012
3030

31-
**Status:** Backlog
31+
**Status:** Done

specs/tasks/M7-v2-cleanup/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ TASK-093).
3535
| TASK-068 | `connection_state` hardening — CWE-226 / CWE-14 | MED | S | Done |
3636
| TASK-069 | Remove transitional two-arg `http_request_impl` constructor | MED | S | Done |
3737
| TASK-070 | Migrate `hook_table_` to `std::atomic<std::shared_ptr<T>>` | MED | M | Backlog |
38-
| TASK-071 | Wire `install_not_found_alias_` stub and remove dead `lambda_handler` arm | MED | S | Backlog |
38+
| TASK-071 | Wire `install_not_found_alias_` stub and remove dead `lambda_handler` arm | MED | S | Done |
3939
| TASK-072 | Arena-allocated unescape on the warm path | MED | M | Backlog |
4040
| TASK-073 | Revisit libmicrohttpd v0.99 unescape workaround | LOW | S | Backlog |
4141
| TASK-074 | Gate DEBUG raw-body printing behind explicit opt-in | LOW (sec) | S | Backlog |

0 commit comments

Comments
 (0)