Repository navigation
Session Framework: Revised Scope #10
Replies: 1 comment
ReviewThe core argument is sound. Hobby 0.4.0 closes all three gaps that forced the fork. Async handlers, response buffering, after-middleware header injection — all verified in the 0.4.0 source and PR #42. Sessions belonging in hobby follows universal precedent (Plug, Rack, Django middleware, Express). The dependency direction reversal is well-motivated and the revised scope boundary is clean. That said, there are several things the discussion doesn't address that will matter during implementation. Hobby gains an
|
Uh oh!
There was an error while loading. Please reload this page.
The previous session framework design was built on the premise that pyrois had to own its own request pipeline. Hobby couldn't do async work in handlers, couldn't buffer responses, and couldn't let after-middleware inject headers. All three of those were required for server-side sessions. So the plan was: pyrois builds directly on stallion, reimplements routing, middleware, context, and chain execution, and implements sessions on top of its own pipeline. Hobby becomes a peer project sharing stallion as a foundation, not a dependency.
Hobby 0.4.0 eliminates every gap that forced that fork.
What changed in Hobby
Hobby's actor-per-request redesign rewrote the handler model from the ground up. The three specific problems:
Async handlers. Hobby now spawns an actor per request. The handler factory creates a handler actor that can do arbitrary async work — query a database, call an external service, wait for callbacks — and respond when it's ready. The connection waits. This is just how Pony works, and the framework finally stopped fighting it.
Response buffering. Responses are held in a
_BufferedResponseuntil after-middleware completes.ctx.respond()no longer sends bytes to the wire immediately. The connection controls when the response goes out.After-middleware header injection.
AfterContextexposesset_header()andadd_header()on the buffered response. Session middleware can injectSet-Cookieafter the handler runs. This was the specific thing that made sessions impossible in old Hobby.Hobby's Discussion #41 goes further. It explicitly designs for async session loading at the connection level. The connection reads the session cookie, sends
loadto the session store, buffers incoming pipelined requests while waiting for the callback, and creates the handler actor only after the session arrives. From the handler's perspective, the session is just there.Discussion #41 also states the conclusion directly: "Sessions belong in hobby. Sessions aren't a 'Phoenix-like framework' feature. They're a web framework feature."
What this means for pyrois
The session framework doesn't belong here. The entire request pipeline that Discussion #8 designed — Handler, Middleware, Context, Application, Router, ChainRunner, Connection, Listener — is Hobby's job. The session types — SessionData, SessionEditor, MemorySessionStore, SessionMiddleware, SessionConfig — also belong in Hobby.
The signed cookie code already in pyrois (
cookie_signing_key.pony,signed_cookie.pony,signed_cookie_error.pony) needs to move to Hobby. Sessions need signed cookies, and sessions are a Hobby feature.The design work in Discussion #8 isn't wasted. The session architecture is sound and transfers directly to Hobby's implementation: immutable
SessionData valsnapshots, mutableSessionEditor refwrappers,MemorySessionStoreactor with fire-and-forget saves using causal messaging, cookie security defaults (__Host-prefix,Secure,HttpOnly,SameSite=Lax), session fixation prevention viaregenerate_id(). All of that was good work. It just goes in the wrong repo now.Revised scope
The build plan described pyrois as the connective tissue that ties the Pony web ecosystem together. That hasn't changed. What's changed is where the boundary falls between Hobby and pyrois.
Hobby handles the web framework layer: routing, middleware, async handlers, response buffering, sessions, CSRF protection. Everything a server-side web application needs for request/response HTTP.
Pyrois handles the real-time layer and the integration between HTTP and WebSocket worlds:
What needs to happen
Pyrois's
corral.jsonwill depend on Hobby rather than stallion directly. Hobby is the framework layer; pyrois builds on it.All reactions