Documentation
¶
Overview ¶
Package httpx is the SINGLE egress chokepoint for qmax-code. Every outbound HTTP request in the codebase must be built with NewRequest and sent through a client from NewClient, so that the Exposure Receipt records it — destination, category, byte size, and content SHA-256, never content itself.
The static guard in guard_test.go enforces that no other package constructs HTTP clients/requests or imports a third-party HTTP library, making an un-receipted egress path impossible to merge — the load-bearing half of the "Receipts, not promises" guarantee.
Quality commitments enforced here:
- Stream, don't buffer: request bodies are hashed by a streaming reader as the transport sends them, so a multi-MB prompt (inlined files, images) is never doubled in memory (io.ReadAll on the request body is forbidden).
- Never silent: every attempt is recorded, including transport errors. The receipt module routes entries to the process-global session receipt when no receipt-bearing context is present, so even a plain context.Background request is accounted for.
Index ¶
- func DialWebSocket(ctx context.Context, url string, opts *websocket.DialOptions) (*websocket.Conn, *http.Response, error)
- func NewClient(timeout time.Duration) *http.Client
- func NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)
- func WithCategory(ctx context.Context, category string) context.Context
- func WithModel(ctx context.Context, model string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DialWebSocket ¶
func DialWebSocket(ctx context.Context, url string, opts *websocket.DialOptions) (*websocket.Conn, *http.Response, error)
DialWebSocket performs a WebSocket handshake through the recording HTTP client. The WebSocket protocol itself uses the upgraded connection, while the destination and handshake egress are captured in the session receipt.
func NewClient ¶
NewClient returns an *http.Client whose Transport records every request into the active Exposure Receipt. Timeout semantics are unchanged from a plain &http.Client{Timeout: timeout}.
func NewRequest ¶
NewRequest builds an *http.Request bound to ctx. It is the only sanctioned way to construct an outbound request outside this package: callers that need to set custom headers or stream the response (LLM SSE) use NewRequest + NewClient.Do rather than a raw http.NewRequest, which the egress guard forbids.
Pass context.Background() when no request-scoped context is available; the receipt still routes to the process-global session run.
func WithCategory ¶
WithCategory annotates ctx with an explicit receipt category. Most HTTP callers rely on exposure.Classify; use this only for protocol handshakes.
Types ¶
This section is empty.