feat(routes): cora routes command + fix route detection - #454
Merged
Conversation
Implements the primary acceptance criterion of #438: list detected HTTP endpoints as first-class graph data. Route detection (Axum, Actix-web, Go net/http/chi, Express/Fastify, Flask/FastAPI) already existed and was wired into indexing, but (a) the handler name and HTTP method were extracted incorrectly, and (b) there was no CLI to surface the results. Detection fixes (index/extract.rs::detect_routes): - Axum/Actix handler is now capture group 3 (the actual handler), not group 2 (the method fn like get/post). Previously every route source was the literal string "get". - HTTP method is now captured and prefixed to the target, so routes read "GET /api/users" instead of a bare "/api/users". - Fully-qualified handler paths (e.g. routes::health::health_check) are now captured in full and reduced to their final segment, so the edge source matches the indexed function symbol (health_check). - Removed the dead/buggy extract_http_method helper: it checked the regex string for a label substring that never appeared, so it always returned "". New command (commands/routes.rs, wired in main.rs + commands/mod.rs): - cora routes list all detected endpoints - cora routes --method GET filter by HTTP method (case-insensitive) - cora routes --prefix /api filter by path prefix - cora routes --json structured output Routes already appear in `cora arch` edge distribution (kind = ROUTE). Tests: +6 detect_routes tests (axum simple/FQ handler, actix, express, empty, unknown language) and +4 routes command tests (target splitting). Full suite green (785 tests), clippy clean (-D warnings), fmt clean. Verified end-to-end against the hompimpah Axum backend: 10 routes detected with correct handlers (health_check, submit_progress, login, ...) and methods. Refs #438.
CI runs a newer rustfmt than my local 1.9.0-stable (2026-05-25); the Format check flagged chain-breaking differences in the new detect_routes tests. Updated local toolchain to rustc 1.97.1 (2026-07-14, matches CI) and re-applied cargo fmt. No logic change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the primary acceptance criterion of #438 — a
cora routescommand that lists detected HTTP endpoints — and fixes two correctness bugs in the existing route detection that produced wrong handler names and dropped the HTTP method.Closes #438.
What changed
Detection fixes (
src/index/extract.rs::detect_routes)Route detection already existed and was wired into indexing, but the extracted data was wrong:
source = "get"for every Axum route (group 2 = method fn)source = "health_check"(group 3 = handler)target = "/api/health"(method dropped)target = "GET /api/health"source = "routes"forroutes::health::health_checksource = "health_check"(final segment)get/post).routes::health::health_check) are captured in full ([\w:]+) and reduced to the final segment so the edge source matches the indexed function symbol.extract_http_methodhelper — it checked the regex string for a label substring that never appeared, so it always returned"".New command (
src/commands/routes.rs)Routes already appear in
cora archedge distribution (kind = ROUTE).Verification
End-to-end against the hompimpah Axum backend (10 routes):
Checks
cargo fmt --all -- --check✅cargo clippy --all-targets -- -D warnings✅cargo test✅ (785 tests, including +6detect_routesand +4routestests)cora review✅ passed on this diffOut of scope (follow-ups)
Two secondary criteria from #438 are not addressed here and warrant separate work:
brainsearch — routes are currently edges, andbrainsearches thesymbolstable. Surfacing them needs aRoutesymbol kind.cora query "/api/users -> *"tracing route → handler —cora queryreads thecall_graphtable, while ROUTE edges live inedges. Onlycora trace/cora impact(the_edgesvariants) traverse ROUTE today.These are tracked conceptally in #438 and can be follow-up issues.
Related
cora dead-code~82% false positives on framework-called methods (Phaser/SvelteKit); needs symbol-level skip #452 —cora dead-codefalse positives on route handlers. Note:find_dead_codereadscall_graphonly, so ROUTE edges inedgesdo not yet suppress handlers — that fix is part of enhancement:cora dead-code~82% false positives on framework-called methods (Phaser/SvelteKit); needs symbol-level skip #452, not this PR.