feat(pipeline): the pure pipeline, checked against its goldens

The modules that turn a frozen range into passes and passes into a
verdict: :Schema, :Tools (the DENY, git and base lists, a leaf, so the
config and the pool both read them), :Plan, :Artifact, :Inventory,
:Dispositions, :State, :Normalize, :Stream, :Prompt, :Config, and the URL
half of :PgWire. Units, jobs, results, the config and the claude stream
stay JSON from end to end, so every key keeps its place; :Text gives JSON
values truthiness, get, ==, membership and Str(), and throws Dyn::Error
under a name for each kind of unexpected data.

Exactness where the bytes are seen:
- the stream classifiers are hand-written scanners with case-insensitive
  folds (the Kelvin sign is a k), Unicode \b and \s, and `.` stopping at
  \n; the SQL call detection takes `<exe> sql` with any path before it;
- config problems carry the JSON scanner's and the UTF-8 decoder's own
  texts, positions included;
- a float total is Neumaier's compensated sum, and the build passes
  -ffp-contract=off: -march=native would fuse a*b+c;
- `crafter-review inventory` and `config` print what the goldens record,
  byte for byte (the fixture and 14 configs, broken ones included); a
  message names this binary as the command to run.

tests/Goldens: the recorded answers over the fixtures next to them (the
commits fixture, a rich versioned series with CRLF, a folded subject,
Markdown headings in and out of fences, the code-key rewrites); the suite
compares 2304 results as DumpFile writes them, so a key out of order fails
too. All agree.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jorijn van der Graaf 2026-10-31 06:48:55 +01:00
commit 741e3a656d
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
70 changed files with 30565 additions and 21 deletions

View file

@ -6,8 +6,12 @@ import :Driver;
import :Core;
import :Platform;
import :Process;
import :Inventory;
import :Config;
import std;
namespace fs = std::filesystem;
namespace Crafter::Review {
namespace {
constexpr std::string_view Usage =
@ -28,6 +32,11 @@ inventory unit, against a frozen commit range.)";
}
return 0;
}
std::int32_t UsageError(std::string_view message) {
std::println(std::cerr, "{}\ncrafter-review: error: {}", Usage, message);
return 3;
}
}
std::int32_t Main(std::span<const std::string_view> args) {
@ -37,12 +46,44 @@ inventory unit, against a frozen commit range.)";
// command anyone types.
if (!rest.empty() && rest.front() == Process::SuperviseVerb) return Process::SuperviseMain(rest.subspan(1));
Platform::Init();
if (!rest.empty() && rest.front() == "--version") return PrintVersion();
if (!rest.empty() && (rest.front() == "-h" || rest.front() == "--help")) {
// The options before the command: --config FILE or --config=FILE, and
// any unique prefix of a long option.
std::optional<std::string> configPath;
std::size_t at = 0;
while (at < rest.size() && rest[at].starts_with("--") && rest[at] != "--") {
const std::string_view arg = rest[at];
const std::size_t equals = arg.find('=');
const std::string_view name = arg.substr(0, equals);
if (name.size() > 2 && std::string_view("--config").starts_with(name)) {
if (equals != std::string_view::npos) {
configPath = std::string(arg.substr(equals + 1));
} else if (at + 1 < rest.size()) {
configPath = std::string(rest[++at]);
} else {
return UsageError("argument --config: expected one argument");
}
} else if (name.size() > 2 && std::string_view("--version").starts_with(name)) {
return PrintVersion();
} else if (name.size() > 2 && std::string_view("--help").starts_with(name)) {
std::println("{}", Usage);
return 0;
} else {
return UsageError(std::format("unrecognized arguments: {}", arg));
}
++at;
}
if (at < rest.size() && rest[at] == "-h") {
std::println("{}", Usage);
return 0;
}
std::println(std::cerr, "{}", Usage);
return 3;
if (at >= rest.size()) return UsageError("a command is required");
const std::string_view command = rest[at];
const std::span<const std::string_view> after = rest.subspan(at + 1);
if (command == "inventory" && !configPath) return Inventory::Main(after);
if (command == "config") {
if (!after.empty()) return UsageError(std::format("unrecognized arguments: {}", after.front()));
return Config::Main(fs::current_path(), configPath ? fs::path(*configPath) : fs::path());
}
return UsageError(std::format("argument cmd: invalid choice: '{}'", command));
}
}