Beside the push gates, crafter-review runs the pre-send review of a kernel contributor's workbench: --mode series over a format-patch export with its cover letter, --mode reply over a mail draft. The inventory partitions a cover letter, a plain mail and the camera review's shape; ten kernel lenses join the table with their gates (structure, code, artifact truth) and the persona gate - one maintainer-persona instance per --reviewers entry, its whole pass gating its blocks and pruning the units that are not theirs. A series' code units are keyed on the code like the push gates'; every text unit on its text, the references it cites and the anchor when it is dated. The references an artifact cites are prefetched through utilities/lore.py into the gate-state, with a digest in the run layer, and a persona's calibration map is its lore listing. The kernel schema carries the persona vocabulary, the kernel note kinds, the predicted review and the not-mine list; the matrix the persona holes, the thin and the modelled units; gates clean without a persona pass is GATES CLEAN. A reply's gate-state sits beside the draft and is read once; a kernel mode needs --subsystem, defaults the effort to max and the trees to work/linux,work/milos-linux, and excuses no unit from the holes. The kernel lenses and the common text ship verbatim; the table lists them after the push gates' lenses and the config template holds them off, so a repository that never turns them on changes nothing. Prompts, keys and plans were checked byte for byte against the pipeline these modes replace, on its own artifacts: two replies and a series, every system prompt, user prompt, job and reuse key identical.
57 lines
3.6 KiB
C++
57 lines
3.6 KiB
C++
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
export module Crafter.Review:Refs;
|
|
import std;
|
|
import :Json;
|
|
|
|
// The kernel modes' references: gate 0's prefetch of the lore messages an
|
|
// artifact cites (a cache addressed by message id, shared across hashes),
|
|
// the per-hash index, the digest the run layer carries, and a light persona
|
|
// corpus (a lore search listing). lore.kernel.org is reached only through
|
|
// `python3 utilities/lore.py` in the working directory, the one way past its
|
|
// proof-of-work wall; a fetch never raises - a failure is a `failed` index
|
|
// row the lenses are told about, never synthesized.
|
|
export namespace Crafter::Review::Refs {
|
|
// {reference: url}, in order of first appearance: the [n] lines of a
|
|
// reply's reference list ("1", "2", ...), else every lore URL in the text
|
|
// ("L1", "L2", ...).
|
|
using Table = std::vector<std::pair<std::string, std::string>>;
|
|
Table ParseRefs(std::string_view text);
|
|
// The url reference n names, when the table is a numbered list.
|
|
std::optional<std::string> UrlOf(const Table& refs, std::int64_t n);
|
|
// The message id a lore URL names: https?://lore.kernel.org/(r|all|<list>)/<msgid>/
|
|
std::optional<std::string> MsgidOf(std::string_view url);
|
|
// The file a message id is cached under: every character outside
|
|
// [A-Za-z0-9._@-] an underscore, 200 characters at most.
|
|
std::string SafeName(std::string_view msgid);
|
|
// From, Date and Subject of a raw mail's header block, the first of each.
|
|
std::map<std::string, std::string> Headers(std::string_view raw);
|
|
|
|
using Log = std::function<void(const std::string&)>;
|
|
// (status, error) of one fetch: "fetched" with the bytes written to
|
|
// `path`, or "failed" with the last error. The test seam: a fetcher set
|
|
// here replaces the lore.py subprocess.
|
|
using Fetcher = std::function<std::pair<std::string, std::string>(const std::filesystem::path& repo, const std::string& url, const std::filesystem::path& path)>;
|
|
void SetFetcher(Fetcher fetcher);
|
|
// `python3 utilities/lore.py fetch <url>/raw` in `repo`, three tries.
|
|
std::pair<std::string, std::string> Fetch(const std::filesystem::path& repo, const std::string& url, const std::filesystem::path& path);
|
|
// The index of every reference - {n: {url, msgid, path, status, error?,
|
|
// From?, Date?, Subject?, bytes?}} - written to indexPath, the raw mails
|
|
// under refsDir; `workers` fetches at once.
|
|
Json Prefetch(const std::filesystem::path& repo, const Table& refs, const std::filesystem::path& refsDir, const std::filesystem::path& indexPath, const Log& log,
|
|
std::int32_t workers = 4);
|
|
// REFERENCES prefetched: one line per entry, numbered ones first.
|
|
std::string Digest(const Json& index);
|
|
|
|
// A lore search listing (subjects, dates, links) of the persona's own
|
|
// mail since `since` (YYYYMMDD): the calibration map, cached under
|
|
// refsDir as persona-<slug>.txt. (nullopt, "") when lore has none - an
|
|
// empty corpus is never cached, so the next run retries.
|
|
using Searcher = std::function<std::pair<std::string, std::string>(const std::filesystem::path& repo, const std::string& query)>;
|
|
void SetSearcher(Searcher searcher);
|
|
std::pair<std::optional<std::filesystem::path>, std::string> PersonaCorpus(const std::filesystem::path& repo, std::string_view name, const std::filesystem::path& refsDir,
|
|
std::string_view since, const Log& log);
|
|
// YYYYMMDD of the day 365 days before an ISO date.
|
|
std::string SinceOf(std::string_view isoDate);
|
|
}
|