Crafter.Review/interfaces/Crafter.Review-Schema.cppm
Jorijn van der Graaf 339f4b9b40
feat(modes): the kernel modes - a patch series and a mailing-list reply
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.
2026-10-31 22:56:12 +01:00

47 lines
3 KiB
C++

// SPDX-License-Identifier: AGPL-3.0-only
// SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
export module Crafter.Review:Schema;
import std;
import :Json;
// The structured output a pass returns: FINDING, NOTE, COVERAGE and the
// verdict. One block schema and one whole schema per run, the union of every
// lens's vocabulary, so the tool block ahead of the user message is
// byte-identical across lenses and the prompt cache is shared. The bytes are
// fixed: SchemaJson() is the schema in DumpCompactSorted's form, and the
// goldens hold the descriptions. The kernel modes have a schema of their
// own: their note kinds, the persona vocabulary, and the whole pass's
// predicted review and not-mine list.
export namespace Crafter::Review::Schema {
constexpr std::array<std::string_view, 10> NoteKinds = {
"reserve-answer", "invariant", "pre-existing", "residual-risk", "hold", "info", "immaterial",
"send-time-check", "refutation-verified", "unverified",
};
constexpr std::array<std::string_view, 10> KernelNoteKinds = {
"reserve-answer", "ledger-row", "pre-existing", "residual-risk", "hold", "info", "immaterial",
"disposition-review", "send-time-check", "refutation-verified",
};
// The vocabulary of a maintainer or recipient persona.
constexpr std::array<std::string_view, 9> PersonaVerdicts = {"would-require", "no-comment", "would-object", "incomplete", "not-mine", "can-act", "ambiguous", "would-push-back", "already-known"};
constexpr std::array<std::string_view, 4> GenericVerdicts = {"clear", "defect", "immaterial", "n/a"};
constexpr std::array<std::string_view, 4> CoverageVerdicts = GenericVerdicts;
// The union, for the kernel modes' schema.
constexpr std::array<std::string_view, 13> KernelCoverageVerdicts = {"would-require", "no-comment", "would-object", "incomplete", "not-mine", "can-act", "ambiguous", "would-push-back", "already-known",
"clear", "defect", "immaterial", "n/a"};
// Blocking and unowned, across both vocabularies: a lens that speaks the
// generic one never emits a persona verdict, so the union judges either.
constexpr std::array<std::string_view, 5> CoverageBlocking = {"would-object", "incomplete", "ambiguous", "would-push-back", "defect"};
constexpr std::array<std::string_view, 3> CoverageUnowned = {"not-mine", "n/a", "MISSING"};
constexpr std::array<std::string_view, 2> VerdictEnum = {"FIX FIRST", "SEND-READY"};
// kernel: the kernel modes' texts and vocabulary.
Json Finding(bool kernel = false);
Json Note(bool kernel = false);
Json Coverage(bool kernel = false);
Json BlockSchema(bool kernel = false);
Json WholeSchema(bool kernel = false);
// The schema of `kind` ("block", anything else the whole one) as it goes
// to claude, for a mode (reply, series: the kernel schema).
std::string SchemaJson(std::string_view kind, std::string_view mode = "commits");
}