feat(config): lens sections - a repository's own text appended to a shipped charter

A lens has one charter, the one this pipeline ships; what a repository
knows that is not general to the lens - its platform and layers, the
record it keeps its decisions in, what its users already have, the
calibration entries that are its own - goes in a file the config names
for the lens (lenses.<name>.section), and Charter appends it after one
blank line. The charter sha in every reuse key covers the combined text.

The config refuses a path outside the repository - absolute, or
climbing out with `..` - by the check slots.dir had, now one both
settings share; a file missing or one the run could not use (a dangling
link, unreadable, not UTF-8) is a problem too, checked through the
reader Charter uses (Prompt::ReadSection), so a section is never
dropped in silence, and a name that is no lens is the unknown key it
always was. Nothing lists a directory, so what lies beside the files is
no concern of the config's: a directory listed would have to tolerate or
refuse every foreign entry. The run logs which charters got one.

The better-solution charter gains a consumer's general entry
(2026-10-31: a mechanism reworked a second time in one submission is the
signal to derive the fix at every layer the data crosses). The procedure
names the section wherever it names the charter: among the config's keys,
in the lens inputs, in the reuse rule (an edit to either re-runs the lens)
and in the feedback loop, which routes a repository's own lesson to its
section and a general one to the shipped charter.
This commit is contained in:
Jorijn van der Graaf 2026-11-01 01:30:22 +01:00
commit 6cf15919db
Signed by: jorijnvdgraaf
GPG key ID: 2937E59CDCC1BCFB
16 changed files with 1235 additions and 524 deletions

View file

@ -59,6 +59,13 @@ export namespace Crafter::Review::Config {
std::vector<std::string> SlotCommands(const Json& config, std::string_view which, std::span<const std::int64_t> slots);
// The first login fixture that exists, relative to the repository root.
std::optional<std::string> LoginFixture(const Json& config, const std::filesystem::path& repo);
// The repository's own lens sections (`lenses.<name>.section`, resolved
// against the repository root), keyed by lens file: each a file the
// config names inside the repository (a relative path, no `..` part).
std::map<std::string, std::filesystem::path> LensSectionsOf(const Json& config, const std::filesystem::path& repo);
// What is wrong with those files: one missing, or one
// Prompt::ReadSection cannot use.
std::vector<std::string> SectionProblems(const Json& config, const std::filesystem::path& repo);
// The example a consumer starts from (process/templates/config.json is
// this, rendered).
Json Example();

View file

@ -40,9 +40,10 @@ export namespace Crafter::Review {
void SetHome(std::filesystem::path home);
// Home()/process/lenses.
std::filesystem::path LensDir();
// The sha256 of each lens file — the text read with universal newlines,
// as UTF-8 — keyed by file name. Every charter's is part of its lens's
// reuse keys, so --version and the run log print them: a stale home shows
// up there before it shows up as nothing being reused.
// The sha256 of each shipped lens file — the text read with universal
// newlines, as UTF-8 — keyed by file name. A lens's reuse keys carry its
// charter's (the combined text's when lenses.<name>.section gives the
// lens a section of the repository's own), so --version prints these: a
// stale home shows up there before it shows up as nothing being reused.
std::vector<std::pair<std::string, std::string>> CharterHashes();
}

View file

@ -48,10 +48,29 @@ export namespace Crafter::Review::Prompt {
// question; empty for every other lens and slot.
std::string_view SlotDuty(std::string_view lensFile, std::string_view unitId);
// The repository's own section file per lens file (the config's
// lenses.<name>.section), appended to that charter by Charter. Empty:
// the shipped texts alone. Set by the run.
void SetLensSections(std::map<std::string, std::filesystem::path> files);
// A shipped lens text's path.
std::filesystem::path LensFile(std::string_view name);
// _common-repo.md with the artifact kind filled in; the kernel modes
// _common.md (a mailing-list reply, a patch series).
std::string SystemText(std::string_view mode = "commits");
// The lens's charter, read with universal newlines.
// A repository's section file as every reader takes it (2026-11-01, the
// self-review's round 16): absent (no entry at all), its text, or present
// but unusable - a dangling or looping link, no regular file, unreadable,
// not UTF-8 - with the problem said. The config reports a named file that
// is absent or unusable (Config::SectionProblems) and Charter refuses
// both, so a section is never dropped in silence.
struct Section {
bool present = false;
std::string text;
std::string problem;
};
Section ReadSection(const std::filesystem::path& file);
// The lens's charter, read with universal newlines: the shipped text,
// then one blank line and the repository's section when it has one.
std::string Charter(std::string_view lensFile);
// INPUTS, the artifact with line numbers, the inventory. trees: as they