From the architecture review, "Construction, start and stop", under "The parts are built in two places": #283 (comment). Approved for building: #283 (comment). The code was read at 809d266 on next, where discriminator is now waf. Line numbers are that commit's.
The fx wiring (#421) built most of this proposal: waf.Params now takes every part already built, and internal/sww builds them all. This issue is the part that pull request left, and says so in its description.
What is there
waf.Server (internal/waf/proxy.go:121) still exports ten parts as public fields: Ledger, Limiter, GeoJS, Anomalies, LookupFile, Lists, DNSBL, AbuseIPDB, RouteWatch, Metrics. waf.New copies them out of the handler it has just filled from Params.
No production code reads them. Their comment says why they are there: "The tests read them."
The tests of internal/waf read them in about twenty files, to see what a request did to a part: server.Ledger.Snapshot(), server.Limiter.Client(…).
internal/waf/export_test.go reaches the same parts another way, through s.Handler.(*handler).
Why it matters
waf.Server has ten public fields that nothing outside the tests uses. A reader takes them for the way to reach a part.
Whoever calls waf.New already holds every part: it has just put them in Params. Handing them back through the server is a second path to the same pointers.
What changes
waf.Server exports no parts.
A test keeps the parts it wants to inspect. The helpers in internal/waf/proxy_test.go (newWAFWith, addCounters, addOutsideSources) already build every part into a waf.Params. They return what the tests read, in place of reading it back from the server.
The embedded *http.Server stays here. Making it a private field is another proposal of the review, with an issue of its own that follows this one: #437.
Done when
waf.Server has no exported field that is one of its parts, and waf.New copies none;
no test assertion changes: the tests read the same parts, held by the test;
make check passes;
the PR body lists every new name in the test helpers.
If this is more than one PR can carry, say so on this issue instead of starting.
Model: fable-5-2
From the architecture review, "Construction, start and stop", under "The parts are built in two places": https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-173831. Approved for building: https://git.eeqj.de/sneak/smallwebwaf/issues/283#issuecomment-183550. The code was read at `809d266` on `next`, where `discriminator` is now `waf`. Line numbers are that commit's.
The fx wiring (https://git.eeqj.de/sneak/smallwebwaf/pulls/421) built most of this proposal: `waf.Params` now takes every part already built, and `internal/sww` builds them all. This issue is the part that pull request left, and says so in its description.
### What is there
- `waf.Server` (`internal/waf/proxy.go:121`) still exports ten parts as public fields: `Ledger`, `Limiter`, `GeoJS`, `Anomalies`, `LookupFile`, `Lists`, `DNSBL`, `AbuseIPDB`, `RouteWatch`, `Metrics`. `waf.New` copies them out of the handler it has just filled from `Params`.
- No production code reads them. Their comment says why they are there: "The tests read them."
- The tests of `internal/waf` read them in about twenty files, to see what a request did to a part: `server.Ledger.Snapshot()`, `server.Limiter.Client(…)`.
- `internal/waf/export_test.go` reaches the same parts another way, through `s.Handler.(*handler)`.
### Why it matters
- `waf.Server` has ten public fields that nothing outside the tests uses. A reader takes them for the way to reach a part.
- Whoever calls `waf.New` already holds every part: it has just put them in `Params`. Handing them back through the server is a second path to the same pointers.
### What changes
- `waf.Server` exports no parts.
- A test keeps the parts it wants to inspect. The helpers in `internal/waf/proxy_test.go` (`newWAFWith`, `addCounters`, `addOutsideSources`) already build every part into a `waf.Params`. They return what the tests read, in place of reading it back from the server.
- `export_test.go` does the same where it can.
Before (`internal/waf/proxy.go`, shortened):
```go
type Server struct {
*http.Server
Ledger *bans.Ledger
Limiter *ratelimit.Limiter
GeoJS *geojs.GeoJS
// seven more
}
```
After:
```go
type Server struct {
*http.Server
}
```
### What stays
- `waf.Params` is unchanged.
- The embedded `*http.Server` stays here. Making it a private field is another proposal of the review, with an issue of its own that follows this one: https://git.eeqj.de/sneak/smallwebwaf/issues/437.
### Done when
- `waf.Server` has no exported field that is one of its parts, and `waf.New` copies none;
- no test assertion changes: the tests read the same parts, held by the test;
- `make check` passes;
- the PR body lists every new name in the test helpers.
If this is more than one PR can carry, say so on this issue instead of starting.
Model: fable-5-2
clawbot
self-assigned this 2026-11-19 17:12:54 +01:00
Built in #455, branch issue-436-server-exports-no-parts.
waf.Server keeps only its *http.Server. The tests now keep the parts they read in a test-only struct, wafAndParts, which holds the server and the waf.Params it was built from. No test assertion changed.
One make check run failed in internal/rproxy, which this change does not touch, and the next run passed. The failing test is filed as #451.
Model: opus-5-5
Built in https://git.eeqj.de/sneak/smallwebwaf/pulls/455, branch `issue-436-server-exports-no-parts`.
`waf.Server` keeps only its `*http.Server`. The tests now keep the parts they read in a test-only struct, `wafAndParts`, which holds the server and the `waf.Params` it was built from. No test assertion changed.
One `make check` run failed in `internal/rproxy`, which this change does not touch, and the next run passed. The failing test is filed as https://git.eeqj.de/sneak/smallwebwaf/issues/451.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
From the architecture review, "Construction, start and stop", under "The parts are built in two places": #283 (comment). Approved for building: #283 (comment). The code was read at
809d266onnext, wherediscriminatoris nowwaf. Line numbers are that commit's.The fx wiring (#421) built most of this proposal:
waf.Paramsnow takes every part already built, andinternal/swwbuilds them all. This issue is the part that pull request left, and says so in its description.What is there
waf.Server(internal/waf/proxy.go:121) still exports ten parts as public fields:Ledger,Limiter,GeoJS,Anomalies,LookupFile,Lists,DNSBL,AbuseIPDB,RouteWatch,Metrics.waf.Newcopies them out of the handler it has just filled fromParams.internal/wafread them in about twenty files, to see what a request did to a part:server.Ledger.Snapshot(),server.Limiter.Client(…).internal/waf/export_test.goreaches the same parts another way, throughs.Handler.(*handler).Why it matters
waf.Serverhas ten public fields that nothing outside the tests uses. A reader takes them for the way to reach a part.waf.Newalready holds every part: it has just put them inParams. Handing them back through the server is a second path to the same pointers.What changes
waf.Serverexports no parts.internal/waf/proxy_test.go(newWAFWith,addCounters,addOutsideSources) already build every part into awaf.Params. They return what the tests read, in place of reading it back from the server.export_test.godoes the same where it can.Before (
internal/waf/proxy.go, shortened):After:
What stays
waf.Paramsis unchanged.*http.Serverstays here. Making it a private field is another proposal of the review, with an issue of its own that follows this one: #437.Done when
waf.Serverhas no exported field that is one of its parts, andwaf.Newcopies none;make checkpasses;If this is more than one PR can carry, say so on this issue instead of starting.
Model: fable-5-2
Built in #455, branch
issue-436-server-exports-no-parts.waf.Serverkeeps only its*http.Server. The tests now keep the parts they read in a test-only struct,wafAndParts, which holds the server and thewaf.Paramsit was built from. No test assertion changed.One
make checkrun failed ininternal/rproxy, which this change does not touch, and the next run passed. The failing test is filed as #451.Model: opus-5-5