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:
parent
339f4b9b40
commit
6cf15919db
16 changed files with 1235 additions and 524 deletions
|
|
@ -323,5 +323,22 @@ int main() {
|
|||
&& charter.contains("Calibration (append dated entries at the bottom)"), Dyn::Join(banned, ", "));
|
||||
Check("the security charter names what the other lenses own and tells its blocks to route it as a note, never to suppress it", charter.contains("`repo-better-solution`")
|
||||
&& charter.contains("`repo-bug-prover`") && charter.contains("`repo-functional`") && charter.contains("instead of suppressing it"));
|
||||
// A repository's own section (2026-10-31): its file for a lens is
|
||||
// appended to the shipped charter after one blank line - the shipped
|
||||
// text first and unchanged - so the charter's hash, in every reuse key,
|
||||
// covers it; another lens's charter stays as shipped.
|
||||
const fs::path sectionsDir = fs::temp_directory_path() / std::format("crafter-review-sections-{}", Platform::PublishedPid());
|
||||
fs::remove_all(sectionsDir);
|
||||
fs::create_directories(sectionsDir);
|
||||
const std::string section = "## This repository's section\n\n- 2026-10-31: SECTION MARKER.\n";
|
||||
std::ofstream(sectionsDir / "repo-security.md", std::ios::binary) << section;
|
||||
Prompt::SetLensSections({{"repo-security.md", sectionsDir / "repo-security.md"}});
|
||||
const std::string withSection = Prompt::Charter("repo-security.md");
|
||||
const std::string untouched = Prompt::Charter("repo-facts.md");
|
||||
Prompt::SetLensSections({});
|
||||
Check("a repository's section is appended to the shipped charter after one blank line, the shipped text first and unchanged; a lens without a file stays as shipped; the hash differs",
|
||||
withSection == std::format("{}\n\n{}", charter.substr(0, charter.find_last_not_of('\n') + 1), section) && untouched == Prompt::Charter("repo-facts.md") && Plan::Sha(withSection) != Plan::Sha(charter)
|
||||
&& Prompt::Charter("repo-security.md") == charter);
|
||||
fs::remove_all(sectionsDir);
|
||||
return Failures ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,51 @@ int main() {
|
|||
missingCommand.size() == 1 && missingCommand[0].starts_with("functional.mcp.command '/nonexistent/bin/npx' is no program here")
|
||||
&& bad({{"functional", {{"mcp", {{"command", "/bin/sh"}}}}}}).empty() && bad({{"functional", {{"mcp", {{"command", "npx"}}}}}}).empty(),
|
||||
Show(missingCommand));
|
||||
// A lens's own section (lenses.<name>.section, 2026-11-01, Jorijn: a path
|
||||
// per lens rather than a directory listed): a file of the repository's,
|
||||
// appended to the shipped charter. Only the section problems and the
|
||||
// unknown keys count here: a config under test may turn no lens on.
|
||||
auto sectionProblems = [&](const Json& lenses) {
|
||||
std::vector<std::string> out;
|
||||
for (const std::string& problem : bad({{"lenses", lenses}})) {
|
||||
if (problem.contains("section") || problem.contains("unknown key lenses.")) out.push_back(problem);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
const std::string outside = "lenses.repo-facts.section must be null or a file inside the repository (a relative path)";
|
||||
Check("lenses.<name>.section: not a string, a blank one, an absolute path and one climbing out with .. are problems (slots.dir's rule) and resolve to nothing",
|
||||
Any(sectionProblems({{"repo-facts", {{"section", 5}}}}), outside) && Any(sectionProblems({{"repo-facts", {{"section", " "}}}}), outside)
|
||||
&& Any(sectionProblems({{"repo-facts", {{"section", "/elsewhere/facts.md"}}}}), outside) && Any(sectionProblems({{"repo-facts", {{"section", "../facts.md"}}}}), outside)
|
||||
&& Config::LensSectionsOf({{"lenses", {{"repo-facts", {{"section", "/elsewhere/facts.md"}}}}}}, td).empty()
|
||||
&& Config::LensSectionsOf({{"lenses", {{"repo-facts", {{"section", "a/../../facts.md"}}}}}}, td).empty());
|
||||
fs::create_directories(td / "sections" / "adir");
|
||||
std::ofstream(td / "sections" / "facts.md", std::ios::binary) << "## Ours\n";
|
||||
std::ofstream(td / "sections" / "README.md", std::ios::binary) << "beside the sections, no concern of the config's\n";
|
||||
std::ofstream(td / "sections" / "bad.md", std::ios::binary) << std::string("\xff\n", 2);
|
||||
fs::create_symlink("missing-target.md", td / "sections" / "dangling.md");
|
||||
const std::vector<std::string> named = sectionProblems({{"repo-facts", {{"section", "sections/facts.md"}}}, {"repo-bug-prover", {{"section", "sections/bad.md"}}},
|
||||
{"repo-security", {{"section", "sections/dangling.md"}}}, {"repo-functional", {{"section", "sections/adir"}}},
|
||||
{"facts", {{"section", "sections/nope.md"}}}});
|
||||
Check("lenses.<name>.section: a file that is there is fine, whatever lies beside it; one not UTF-8, a dangling link, a directory or a path to nothing is a problem naming the lens and the path",
|
||||
named.size() == 4 && Any(named, "lenses.repo-bug-prover.section: sections/bad.md is not UTF-8") && Any(named, "lenses.repo-security.section: sections/dangling.md cannot be read")
|
||||
&& Any(named, "lenses.repo-functional.section: sections/adir cannot be read") && Any(named, "lenses.facts.section: sections/nope.md does not exist"),
|
||||
Show(named));
|
||||
const std::vector<std::string> unknown = sectionProblems({{"repo-fact", {{"section", "sections/facts.md"}}}, {"_common", {{"section", "sections/facts.md"}}},
|
||||
{"repo-facts", {{"sectoin", "sections/facts.md"}}}});
|
||||
Check("lenses.<name>.section: a name that is no lens - the common text's too - and a misspelt key are unknown keys",
|
||||
Any(unknown, "unknown key lenses.repo-fact") && Any(unknown, "unknown key lenses._common") && Any(unknown, "unknown key lenses.repo-facts.sectoin"), Show(unknown));
|
||||
// A file that cannot be read - where permissions bind, as they do not for
|
||||
// root.
|
||||
std::ofstream(td / "sections" / "locked.md", std::ios::binary) << "## Ours\n";
|
||||
fs::permissions(td / "sections" / "locked.md", fs::perms::none);
|
||||
const bool unreadable = !Platform::ReadFile(td / "sections" / "locked.md");
|
||||
const std::vector<std::string> locked = sectionProblems({{"repo-facts", {{"section", "sections/locked.md"}}}});
|
||||
fs::permissions(td / "sections" / "locked.md", fs::perms::owner_all);
|
||||
Check("lenses.<name>.section: a file that cannot be read is a problem naming it", !unreadable || Any(locked, "lenses.repo-facts.section: sections/locked.md cannot be read"), Show(locked));
|
||||
const std::map<std::string, fs::path> resolved = Config::LensSectionsOf({{"lenses", {{"repo-facts", {{"section", "sections/facts.md"}}}}}}, td);
|
||||
Check("lenses.<name>.section: a file that is there has no problem and resolves against the repository, keyed by the lens's file; null is none",
|
||||
sectionProblems({{"repo-facts", {{"section", "sections/facts.md"}}}}).empty() && resolved.size() == 1 && resolved.at("repo-facts.md") == td / "sections" / "facts.md"
|
||||
&& Config::LensSectionsOf({{"lenses", {{"repo-facts", {{"section", nullptr}}}}}}, td).empty());
|
||||
std::ofstream(p, std::ios::binary) << "{not json";
|
||||
Check("not JSON -> one problem", load().problems.size() == 1);
|
||||
Check("--config to a missing file is a problem", Any(Config::Load(td, td / "none.json").problems, "no such file"));
|
||||
|
|
|
|||
|
|
@ -166,5 +166,6 @@ g['gates'] = new_gates
|
|||
|
||||
# ---- the charter ----------------------------------------------------------------------------
|
||||
g['prompts']['charterSha']['repo-facts.md'] = sha((W / 'process/lenses/repo-facts.md').read_text())
|
||||
g['prompts']['charterSha']['repo-better-solution.md'] = sha((W / 'process/lenses/repo-better-solution.md').read_text())
|
||||
G.write_text(json.dumps(g, indent=1, ensure_ascii=False) + '\n', encoding='utf-8')
|
||||
print('written', G)
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -598,6 +598,9 @@ echo "{\"type\":\"result\",\"subtype\":\"success\",\"is_error\":false,\"result\"
|
|||
Json lenses = Json::object();
|
||||
const std::array<std::string_view, 10> on = {"facts.md", "etiquette.md", "consistency.md", "conciseness.md", "better-solution.md", "code-quality.md", "minimalism.md", "bug-prover.md", "process-docs.md", Plan::PersonaLens};
|
||||
for (const std::string_view lf : on) lenses[Plan::LensName(lf)] = {{"run", true}};
|
||||
// The bench's own section for the facts lens (lenses.facts.section).
|
||||
Write(bench / "process" / "lens-sections" / "facts.md", "## The bench's own section\n\n- 2026-10-31: a section of the bench repository, appended to the facts charter.\n");
|
||||
lenses["facts"]["section"] = "process/lens-sections/facts.md";
|
||||
Write(bench / ".review-gates" / "config.json", DumpFile(Json({{"lenses", lenses}})));
|
||||
const fs::path fakeDir = base / "fake";
|
||||
const fs::path fake = fakeDir / "claude";
|
||||
|
|
@ -641,6 +644,10 @@ echo "{\"type\":\"result\",\"subtype\":\"success\",\"is_error\":false,\"result\"
|
|||
replyLog.contains(": reply journal/x/draft.eml @ ") && replyLog.contains("refs: 1 entries loaded from the existing index (dry run, no fetch)") && replyLog.contains("persona corpus: Some Maintainer -> NO RESULTS")
|
||||
&& replyLog.contains("Gate 3 — Artifact truth: facts, etiquette, consistency, conciseness") && replyLog.contains("Gate 4 — Personas: persona:Some Maintainer"),
|
||||
replyLog);
|
||||
Check("...the bench's section: appended to the facts charter in the system files, after the shipped text, and the log names the lens",
|
||||
replySystems.contains("- 2026-10-31: a section of the bench repository, appended to the facts charter.")
|
||||
&& replySystems.find("# Lens: facts") < replySystems.find("- 2026-10-31: a section of the bench repository")
|
||||
&& replyLog.contains("lenses: the repository's sections appended to facts"), replyLog);
|
||||
// The series: the fixture under the journal, its cover's
|
||||
// reference indexed.
|
||||
const fs::path seriesDir = bench / "journal" / "x" / "patch" / "widget" / "v1";
|
||||
|
|
|
|||
Loading…
Reference in a new issue