Repository navigation
feat(extraction): route Next.js App Router handlers (#759) - #2747
Conversation
app/**/route.{ts,js} files produced 0 Route nodes, so cross-repo
intelligence found no edges into a Next.js backend (DeusData#759).
cbm_extract_nextjs_routes fills route_path/route_method on the
existing Function definition for each exported HTTP-verb handler.
It adds no pass and no synthetic definitions; the route-node pass
builds the Route and HANDLES edge as it does for other frameworks.
CBM_SEMANTIC_INDEX_VERSION goes from 9 to 10 so existing indexes
re-extract once.
Fixes DeusData#759
Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
|
Thanks for opening this — it has been seen, and it is queued. This note is automated, but it is not a brush-off: it exists so you know where your PR stands instead of having to guess from silence. Current review status: working through a backlog. What that means for this PR, concretely:
Things that will genuinely speed it up whenever review does happen:
If this fixes a bug, a reproduction we can run is worth more than a description of the symptom. Thanks for contributing, and sorry in advance for the wait. |
Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
|
Both failing CI jobs on the latest push look unrelated to this change:
Could you re-run the failed jobs when convenient? #2738, which this PR stacks on, is green. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thank you, @petterip, for this careful, well-tested App Router change and for splitting the JSON groundwork into #2738 first. You were right that both red jobs were unrelated to this PR (a registry timeout and a known intermittent probe). Main has moved since that run, so we merged current main into your branch (one signed-off merge commit, 674b088; your commits are untouched) to get a fresh CI run on top of #2738. Please pull before pushing again. We are also running a quick route census on a real App Router app before merging. |
Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
|
Thanks again, @petterip. Main moved once more (another change touched tests/test_pipeline.c), so we merged current main into your branch again (one signed-off merge commit, da5db34; your commits are untouched). The route census on a real App Router app is prepared and runs on this head next; we will report the numbers here before merging. Please pull before pushing again. |
Main has used semantic index versions 10 and 11 since this branch took 10, so the Next.js App Router routes move to version 12 with their own history entry: an index main wrote at 11 rebuilds once for the new Routes. pipeline_nextjs_semantic_upgrade_issue759 now starts from a version-11 index. The other conflicts were tests both sides added at the same place; both kept. Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
|
Main moved again and now conflicts with this branch, so I merged current main ( |
Main took semantic index version 12 for its Markdown section change, so the Next.js App Router routes move to version 13 with their own history entry. pipeline_nextjs_semantic_upgrade_issue759 now starts from a version-12 index. Signed-off-by: Petteri Ponsimaa <petterip@gmail.com>
|
Main took index version 12 for the Markdown section change, so I merged current main ( If the number collides again before you merge, feel free to renumber it yourself: the history line and |
|
Merged - thank you very much, @petterip! This is a careful, well-scoped change: App Router handlers now become real Route nodes with HANDLES edges from the exported verb functions, with no new pass and no synthetic definitions, and the paths are spelled the same way as our SvelteKit routes, so they line up with everything else in the graph. Splitting the JSON groundwork into #2738 first, keeping the index version and its upgrade test current through several main merges, and listing exactly what this increment does not route made it a pleasure to review. As promised, here is the route census we ran on this head (6e54ac3) against current main, each corpus indexed from scratch with both builds:
Apart from those Routes, their HANDLES edges, that one DATA_FLOWS edge and the route_path/route_method properties on the handler functions, nothing in any of the three graphs changed, and indexing again gave identical results. Thanks again for the thorough tests and for staying with this through all the main moves. |
Brings the branch up to main 9c19b5d. Two same-spot insertion conflicts, each resolved as the main version of the file plus the own diff of this branch: - src/daemon/application.c: the job struct gained watch_owners on main and request_started_ms plus the request facts here; both kept. - tests/test_daemon_application.c: main added the DeusData#1818 autoindex-skipped helpers where this branch added the worker resource failure test; both kept, the test placed after the doc_candidates test. Everything else merged cleanly. src/main.c changed on both sides: main (DeusData#2838) lowers the worker CPU priority inside the worker role block, and this branch strips the publication fence flag before that block and installs the fence after the worker role options; the hunks are disjoint and both are kept. tests/test_pipeline.c gained the Next.js route tests (DeusData#2747) on main and the publication gate test here, also disjoint. No call site needed adapting: no new main code calls a function this branch re-signed, and main re-signed none that this branch calls. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
What does this PR do?
Fixes #759: Next.js App Router
app/**/route.tshandlers now produce Route nodes and HANDLES edges, so cross-repo intelligence has something to match against. It follows the approach approved in the issue.Stacked on #2738, which makes the route pass read and write route properties as valid JSON. Without it, a route directory with a quote in its name gets a second Route cut at the quote and HANDLES properties that are not valid JSON, on the first full index already (
pipeline_nextjs_quoted_route_round_trip_issue759fails atASSERT(full.read)with the route pass from before #2738). Until #2738 merges, this PR also shows its commits; the change here is the top commit, fa331ed.internal/cbm/extract_nextjs.c(new), called fromcbm.caftercbm_extract_openapi, setsroute_path/route_methodon the existing Function definition. The existing route-node pass then creates the Route nodes and HANDLES edges. It adds no pass, no Variables and no synthetic definitions.export [async] function GET,export const GET[: Type] = [async] (...) => ..., andexport { GET }of such a declaration, inroute.ts/route.jsunderapp/orsrc/app/.sveltekit_route_path):[id]is:id,[...slug]is*slug, a route group(x)adds no segment, and the root route is/. Route nodes carry the handler'sfile_path, sosearch_graph --file-patternfinds them (search_graph: Route nodes have empty file_path, so label=Route + file_pattern always returns 0 — and the hint blames the label #1366).CBM_SEMANTIC_INDEX_VERSION12 → 13, with a history entry, so a v12 index is rebuilt once.Not routed by this increment (each covered by a test)
export const GET = function () {}(the TS/JS extractor makes no Function for it today); renamedexport { h as GET }; re-exports (export { GET } from,export *); destructured or wrapped handlers (auth(handler),as/satisfies); optional catch-all[[...x]]; private_x; parallel@slot; intercepting(.)x; workspace roots (apps/web/app/...);route.tsx/jsx/mjs. Each file is judged on its own, sosrc/app/is routed even where a rootapp/makes Next.js ignore it. HEAD is not derived from GET. Pages Router, Convex and cross-repo matching stay out of scope, as agreed in the issue.Size
+883 / −2: 288 source lines and 595 test lines added. That's over the 500-line guideline because of the lifecycle and upgrade tests; the source alone is under it. I can split the tests out if you'd prefer.
Evidence
Tested on main
3457b21bwith #2738 (d9766ae8). After merging main587f134e(6e54ac3c), thepipeline,extractionandinfrascansuites were re-run: 983 passed, 0 failed (ASan+UBSan). Machine: x86_64, 16 cores, WSL2 (Linux 6.18) on Ubuntu 22.04, gcc 11.4; clang-format 20.1.8, cppcheck 2.20.0 and clang-tidy 21.1.8, the versions CI uses.extract_nextjs_route_metadata_contract_issue759extract_nextjs_rejects_nonroutes_issue759pipeline_nextjs_persisted_route_contract_issue759CBM_WORKERS=4,mode=parallelin the log)pipeline_nextjs_persisted_route_contract_parallel_issue759pipeline_nextjs_incremental_lifecycle_issue759pipeline_nextjs_semantic_upgrade_issue759pipeline_nextjs_quoted_route_round_trip_issue759(SKIP_PLATFORMon Windows)CBM_TEST_ONLY, 10 s timeout) in 2.3 s or less; the six fix(pipeline): emit and reconstruct route properties as valid JSON #2738 infrascan tests pass beside them.scripts/test.sh: rc 0, 9918 passed, 0 failed, 9 skipped (SKIP_PLATFORM), 191 suites. Run with step 0w (published language-count contract) removed, because that step fails on main itself; fix(ci): repair language count and Windows CodeQL retrace contracts #2732 fixes it.scripts/lint.sh --ci CLANG_FORMAT=clang-format-20: rc 0, "All linters passed".make -f Makefile.cbm lint-tidy-diff CC=clang-21 CLANG_TIDY=clang-tidy-21on the staged change: rc 0.make -f Makefile.cbm lint-mem-ci CC=clang-21 CLANG_TIDY=clang-tidy-21: rc 0, "memory gate clean".make -f Makefile.cbm security: rc 0, "All security checks passed".cli index_repositorythenquery_graphon HANDLES → Route, isolated cache:examples/cms-contentful(dd904bb7): 2 Routes,GET /api/disable-draftandPOST /api/revalidate, each handled by itsroute.tsFunction (188 nodes, 259 edges); indexing it again unchanged gives the same Routes and counts.pipeline_nextjs_semantic_upgrade_issue759.AI assistance
Implementation and tests were written with AI assistance (Claude Code; planning with Codex). I reviewed the change, ran the commands listed above, and take responsibility for it under my DCO sign-off.
Checklist
git commit -s)make -f Makefile.cbm test)make -f Makefile.cbm lint-ci)