feat(seatpool): the seat pool and the board several drivers share
The seats of .env and the ledger, the probe, placement, settling a finished pass, the child's credentials, the OpenRouter seats, and the board every driver on the machine shares, in one shape and under one lock. A driver is alive while its lifetime lock is held; with no lock file natively its pid and start time decide, and in the sandbox it is taken for alive. :Http is the HTTP the driver needs, on FetchHTTP1: a status outside 2xx is HttpError, every other failure carries a fixed text. :Platform gains MakeDirs, with the last directory's own mode, and errno texts for its writes and locks. The tests cover the seat pool and several drivers at once, less the checks that drive the pool's Scheduler, Admission and Stacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8ffbd6cf5d
commit
c63c898833
10 changed files with 2562 additions and 8 deletions
49
interfaces/Crafter.Review-Http.cppm
Normal file
49
interfaces/Crafter.Review-Http.cppm
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
||||
|
||||
export module Crafter.Review:Http;
|
||||
import std;
|
||||
import :Json;
|
||||
|
||||
// The HTTP the driver needs: app_ready's preflight, the OpenRouter catalogue
|
||||
// and key probe. On Crafter.Network's FetchHTTP1, which follows redirects; on
|
||||
// top of it a status outside 2xx thrown as HttpError, and every other failure
|
||||
// as Error with a fixed text, because those texts reach the run log and
|
||||
// app_ready's detail. Proxies are not consulted (AGENTS.md).
|
||||
export namespace Crafter::Review::Http {
|
||||
struct Response {
|
||||
std::int32_t status = 0;
|
||||
std::string body;
|
||||
};
|
||||
|
||||
// A status outside 2xx. what(): "HTTP Error 404: Not Found", with the
|
||||
// standard reason phrase rather than the server's.
|
||||
class HttpError : public std::runtime_error {
|
||||
public:
|
||||
HttpError(std::int32_t code, const std::string& message);
|
||||
explicit HttpError(std::int32_t code);
|
||||
std::int32_t Code() const;
|
||||
|
||||
private:
|
||||
std::int32_t code;
|
||||
};
|
||||
|
||||
// Every other failure. What fails while the request goes out reads
|
||||
// "<urlopen error [Errno 111] Connection refused>" or "<urlopen error
|
||||
// timed out>"; what fails while the response comes in reads as it is:
|
||||
// "timed out".
|
||||
class Error : public std::runtime_error {
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
};
|
||||
|
||||
// A GET of `url`, read whole. Header names in any case; Accept-Encoding:
|
||||
// identity and Connection: close always go out, and a User-Agent unless
|
||||
// one is given.
|
||||
Response UrlOpen(std::string_view url, const std::map<std::string, std::string>& headers, double timeout);
|
||||
// The body as JSON: Dyn::Error JSONDecodeError (or UnicodeDecodeError)
|
||||
// with the scanner's message for a body that is not.
|
||||
Json JsonBody(const Response& response);
|
||||
// http.HTTPStatus(code).phrase, "" for a code it does not know.
|
||||
std::string_view Reason(std::int32_t code);
|
||||
}
|
||||
Loading…
Reference in a new issue