Skip to content

Re-organized file layout#40

Merged
mwfj merged 3 commits into
mainfrom
reorganize-file-layout
May 25, 2026
Merged

Re-organized file layout#40
mwfj merged 3 commits into
mainfrom
reorganize-file-layout

Conversation

@mwfj
Copy link
Copy Markdown
Owner

@mwfj mwfj commented May 25, 2026

refactor: reorganize server/ and test/ into feature subfolders mirroring include/

Summary

Flatten-to-subfolder refactor of the source and test trees to match include/'s established subdirectory organization. No behavior change — purely a structural move of ~190 files (104 in server/, 85 in test/) into 14 feature-aligned subfolders. All file moves done via git mv to preserve git blame/log history.

Motivation

include/ has been organized into per-feature subfolders (auth/, circuit_breaker/, grpc/, http/, http2/, observability/, upstream/, ws/, etc.) since early in the project's life. server/ and test/ remained flat — a single directory holding 100+ files each, making it hard to:

  • Locate the implementation file for a given header (include/auth/jwt_verifier.hserver/jwt_verifier.cc required a directory scan).
  • Reason about feature boundaries (everything looked equally weighted).
  • Onboard contributors (which test belongs to which subsystem?).

This change makes the source/test layout match the header layout 1:1.

Changes

server/ — 104 files reorganized into 14 subfolders

Subfolder Files moved
server/auth/ 15 (auth_*, jwks_*, jwt_verifier, oidc_discovery, introspection_*, issuer, token_hasher)
server/circuit_breaker/ 5 (circuit_breaker_*, retry_budget)
server/cli/ 4 (cli_parser, daemonizer, pid_file, signal_handler)
server/config/ 1 (config_loader)
server/grpc/ 4 (grpc_status, grpc_synthesis, grpc_timeout, grpc_web_bridge)
server/http/ 8 (http_*, body_stream, route_trie, http2_trailer_sanitizer)
server/http2/ 4 (http2_*, protocol_detector)
server/log/ 1 (logger)
server/net/ 1 (dns_resolver)
server/observability/ 25 (observability_*, exporters, propagators, span/tracer/meter/counter/...)
server/rate_limit/ 3 (rate_limit*, token_bucket)
server/tls/ 3 (tls_*)
server/upstream/ 14 (proxy_*, upstream_*, pool_partition, h2_connection_table, header_rewriter, retry_policy, http_request_serializer, grpc_web_inbound_body_stream)
server/ws/ 4 (websocket_*)
server/ (root) 12 (reactor core: dispatcher, event_handler, epoll_handler, kqueue_handler, channel, connection_handler, acceptor, socket_handler, buffer, net_server, inet_addr, main)

test/ — 85 files reorganized by feature

Subfolder Examples
test/auth/ 16 (auth_*, jwks_*, jwt_verifier, header_rewriter_auth, introspection_*, oidc_discovery)
test/circuit_breaker/ 7 (circuit_breaker_*)
test/cli/, test/config/, test/rate_limit/, test/tls/, test/ws/ 1 each
test/grpc/ 5 (grpc_*, grpc_web_*)
test/http/ 6 (http_*, route_*, streaming_request, timeout)
test/http2/ 3 (http2_*, h2_trailer)
test/net/ 2 (dns_resolver, dual_stack)
test/observability/ 25 (observability_*)
test/upstream/ 4 (h2_upstream, proxy_*, upstream_pool)
test/ (root) Cross-cutting infra: test_framework.{h,cc}, test_server_runner.h, mock_introspection_server.h, http_test_client.h, run_test.cc, plus basic_test, stress_test, race_condition_test, kqueue_test, sharded_lru_cache_test (no clean feature home)

Build / wiring updates

  • Makefile — every source-group variable (HTTP_SRCS, AUTH_SRCS, OBSERVABILITY_SRCS, etc.) updated to reference the new $(SERVER_DIR)/<subfolder>/<file>.cc paths. Header variables (*_HEADERS) unchanged — they already pointed at include/<subfolder>/. Root-level files (reactor core + main.cc) keep bare paths.
  • test/run_test.cc — every #include "foo_test.h" updated to #include "subfolder/foo_test.h" for moved tests. Includes for root-level shared headers unchanged (resolved via -Itest in CXXFLAGS).
  • Cross-test includes — 4 sites updated where one test header referenced another that crossed subfolders:
    • test/http/router_async_middleware_test.h: "http2_test.h""http2/http2_test.h"
    • test/grpc/grpc_proxy_test.h, grpc_obs_test.h, grpc_web_edge_test.h: "h2_trailer_test.h""http2/h2_trailer_test.h"
  • test/upstream/h2_upstream_test.h — code-inspection test that opens server/proxy_transaction.cc by literal path: updated to server/upstream/proxy_transaction.cc.
  • test/observability/observability_link_kill_test.h — added inline to 7 test functions (pre-existing convention violation made newly visible by the move; per CODE_CONVENTIONS.md, void Test*() in headers must be inline).

Not changed

  • include/ layout (already organized).
  • util/, thread_pool/, third_party/, docs/, config/ (separate subprojects / out of scope).
  • .github/workflows/ (no path references — uses make + ./test_runner <suite> flags).
  • Any C++ #include from .cc to include/ headers — those already used full paths (#include "http/http_server.h"), unaffected by the source-file move.

Test plan

  • make clean && make -j4 clean build, no warnings.
  • ./test_runner full sweep: 1901/1901 passing.
  • Second consecutive full sweep: 1901/1901 passing.
  • Targeted re-verification post-inline fix: ./test_runner obs_linkkill → 100%.
  • git status confirms every move shows as rename (R), not delete+add — history preserved.
  • Reviewer to verify CI matrix (Linux gcc/clang/ASan/TSan-heavy/TSan-rest + macOS + weekly-valgrind) passes — CI uses make and suite flags, no path-specific references, so should be green by construction.

Risk

Low. Purely structural — zero semantic change. The risk surface is:

  1. Stale tooling caches — clangd's index needs a full refresh post-merge; existing stale paths show transient "file not found" diagnostics until LSP reindexes. Build itself is clean.
  2. Future-PR diff readability — in-flight branches that touch the moved files will conflict; reviewers will need to rebase. Worth coordinating with active branches.
  3. External tooling — any out-of-tree script that hardcodes server/foo.cc paths will break. None known in this repo.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request performs a significant reorganization of the project structure by moving source and test files into feature-aligned subdirectories such as auth, http, and observability. The Makefile and include paths across the codebase have been updated to reflect these changes. Feedback suggests improving the maintainability of the test runner by grouping and alphabetically sorting its include list to match the new directory organization.

Comment thread test/run_test.cc Outdated
@mwfj mwfj merged commit cdd18dc into main May 25, 2026
6 checks passed
@mwfj mwfj deleted the reorganize-file-layout branch May 25, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant