Skip to content

Adds the HTTP transport seam under statifier/basichttp - #26

Merged
johnnyt merged 1 commit into
mainfrom
srb-x2q-http-transport-seam
Oct 24, 2026
Merged

johnnyt merged 1 commit into
mainfrom
srb-x2q-http-transport-seam

Conversation

@johnnyt

@johnnyt johnnyt commented Oct 24, 2026

Copy link
Copy Markdown
Member

Adds the HTTP transport, the seam the Basic HTTP processor will make its requests through. Refs: srb-x2q.

What it adds

  • require "statifier/basichttp" (lib/statifier/basichttp.rb) loads Statifier::BasicHTTP. require "statifier" alone loads none of it and no HTTP library. The Basic HTTP processor on an opt-in require with an injected transport, Net::HTTP the default, was ruled by the operator, 2026-10-23.
  • The seam. A transport is anything that responds to call. It takes one Statifier::BasicHTTP::Request and answers a Statifier::BasicHTTP::Response whatever its status, or raises Statifier::BasicHTTP::TransportError when no response came back.
    • Request: http_method, url, headers (name and value pairs, in order), body. It is a frozen Data value built from copies. It refuses a method or header name that is not an HTTP token, and a header value holding CR, LF or NUL.
    • Response: status (an Integer from 100 to 599), headers, body. Also frozen and built from copies. A status outside 2xx is a response, not an error.
    • TransportError: the one error class. The error that caused it is its cause.
  • The default transport. Statifier::BasicHTTP::NetHTTPTransport, on the standard library's Net::HTTP (the net-http default gem). The gemspec is unchanged, so predicator is still the one runtime dependency. Each call makes one attempt. Opening the connection, writing and reading are each bounded by timeout: seconds, five when absent, which is the reference's bound in Statifier.Send.BasicHTTP.Transport.Httpc at v2.16.0. A URL that is not an absolute http or https URL with a host raises before any connection is opened. NetHTTPTransport.connection(uri, timeout:) builds the default connection (not started), and connect: takes a host's own.
  • The README has a new section, "The HTTP transport", which states the seam, both values and the error contract. No processor code exists yet. CLAUDE.md's "What this project is" names the new surface. The changelog fragment is changelog.d/srb-x2q.md.

How the tests avoid the network

The default transport's tests (test/basichttp/net_http_transport_test.rb) pass connect: a test double, BasicHTTPHelper::Connection in test/basichttp/basichttp_helper.rb. The double's request takes the request Net::HTTP built and writes it into a string through Net::HTTP's own serializer (Net::HTTPGenericRequest#exec over a Net::BufferedIO on a StringIO). It then answers a response that Net::HTTP's own parser (Net::HTTPResponse.read_new and reading_body) reads from canned bytes. No socket is opened and no server is started.

test/basichttp/load_test.rb asks a fresh Ruby process two things: that require "statifier" loads neither net/http nor Net::HTTP nor Statifier::BasicHTTP, and that require "statifier/basichttp" loads all three.

Provenance

  • The request's method member is http_method, not method. A Data member named method overrides Object#method, and the lint configuration refuses that (Lint/DataDefineOverride). This was decided by the conductor under a standing consent, 2026-10-23.
  • The connection factory connect: is an option a host passes to set a proxy or certificate settings, and it is also how the tests reach below Net::HTTP without a socket. NetHTTPTransport#connect(uri) answers the connection a call would open, either the host's or the default. Both are public and documented. Neither is a test-only path in lib/. This was decided by the conductor under a standing consent, 2026-10-23.

Gate

mise exec -- bundle exec rake green on the committed tree: rubocop, corpus:check, registry, then 650 runs with 0 failures, line coverage 99.82% and branch coverage 96.56%. Every new test that asserts library behaviour carries a one-line sabotage note, and each of those mutations was applied, turned its test red on an assertion, and was then restored.

The Basic HTTP processor needs a way to make a request that a host can
replace and that the tests can drive without a network. A transport is
any callable that takes a frozen Request (http_method, url, headers,
body) and answers a frozen Response (status, headers, body), whatever
its status, or raises TransportError when no response came back.

NetHTTPTransport is the default, on the standard library's Net::HTTP,
so the gem keeps its one runtime dependency. It makes one attempt,
bounds each step by five seconds unless told otherwise, and takes a
host's own connection through connect:.

All of it loads only on require "statifier/basichttp"; a test asks a
fresh process that require "statifier" alone loads no HTTP library.
The transport's tests run Net::HTTP's own request writer and response
parser against in-memory bytes, so no socket is opened.

Refs: srb-x2q
@johnnyt
johnnyt merged commit bed85ee into main Oct 24, 2026
4 checks passed
@johnnyt
johnnyt deleted the srb-x2q-http-transport-seam branch October 24, 2026 22:29
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