From a3de4183570d723482de5b464267e2f9eb2ec3a6 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 00:58:04 +0000 Subject: [PATCH 1/5] fix(rhodibot): stop demanding A2ML; make CONTRIBUTING/CODE_OF_CONDUCT .adoc|.md toggleable The estate has retired A2ML: repo facts are clauses of _chora.deed. rhodibot still demanded nine .a2ml files (0-AI-MANIFEST, STATE, META, ECOSYSTEM, AGENTIC, NEUROSYM, PLAYBOOK, ANCHOR, rsr-profile) and, in `canon`, CONTRIBUTING.md / CODE_OF_CONDUCT.md. - New src/deed.rs: read-only s-expression reader for the chora deed (top-level clauses, (rsr-profile ...), (bot-directives (bot :name rhodibot (config ...)))). deed_lint.js stays the conformance gate; rhodibot only reads structure. - New src/canon/overlay.rs: re-targets criteria 2.1.4, 2.1.5, 2.3.1, 3.1.2-3.1.8 and 3.2.2 as requirements (deed clause or descriptile .deed), suspends 3.1.9 and 3.2.1, and adds a chora-deed check. A legacy .a2ml is a read fallback only, reported as "migrate" and never named as the form to create. The vendored rsr-criteria-v2.a2ml is untouched; the divergence is recorded under [overlay] in canon/pin.toml and checked by a lockstep test. - The profile now comes from the deed's (rsr-profile ...) clause, with the legacy file read only when the deed has none. - CONTRIBUTING / CODE_OF_CONDUCT: either .adoc or .md satisfies, never both required. Default is .adoc; (config :community-doc-format md) in rhodibot's bot directive makes .md the named form. A bad value is an error. - `check` (rsr.rs), fleet rule ids/suggestions and the webhook checklist drop the .a2ml/.scm entries and require _chora.deed instead. - .claude/CLAUDE.md invariant 1 rewritten: deeds, not A2ML. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZmM7wgb8pXfyFEuRHQ --- .claude/CLAUDE.md | 23 +- bots/rhodibot/README.adoc | 46 ++- bots/rhodibot/canon/pin.toml | 20 + bots/rhodibot/src/canon.rs | 1 + bots/rhodibot/src/canon/local.rs | 36 +- bots/rhodibot/src/canon/overlay.rs | 300 ++++++++++++++ bots/rhodibot/src/canon/profile.rs | 28 ++ bots/rhodibot/src/canon/report.rs | 498 ++++++++++++++++++++--- bots/rhodibot/src/canon/verdict.rs | 68 ++++ bots/rhodibot/src/deed.rs | 430 +++++++++++++++++++ bots/rhodibot/src/fleet.rs | 26 +- bots/rhodibot/src/github.rs | 14 +- bots/rhodibot/src/lib.rs | 1 + bots/rhodibot/src/main.rs | 60 ++- bots/rhodibot/src/rsr.rs | 204 ++++++---- bots/rhodibot/src/webhook.rs | 4 +- bots/rhodibot/tests/canon_lockstep.rs | 36 ++ bots/rhodibot/tests/integration_tests.rs | 187 ++++++++- 18 files changed, 1798 insertions(+), 184 deletions(-) create mode 100644 bots/rhodibot/src/canon/overlay.rs create mode 100644 bots/rhodibot/src/deed.rs diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index 55db5d8b..1057e047 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -72,11 +72,24 @@ Control (report < 0.85) → Human review required ## Critical Invariants -1. The seven canonical A2ML files (`STATE`, `META`, `ECOSYSTEM`, - `AGENTIC`, `NEUROSYM`, `PLAYBOOK`, `ANCHOR`) live under - `.machine_readable/descriptiles/`, per the current estate-wide policy. - Earlier direct-under-`.machine_readable/`, `6scm/`, and `6a2/` layouts - are retired and must not be restored. +1. **A2ML is retired; repo facts are deeds.** No `.a2ml` file should exist, + and no bot, script or doc here may create, extend or recommend one. The + facts the seven canonical A2ML files held (`STATE`, `META`, `ECOSYSTEM`, + `AGENTIC`, `NEUROSYM`, `PLAYBOOK`, `ANCHOR`), and the manifest, the RSR + profile and the bot directives, are clauses of `_chora.deed` at the + repo root (one per repo), or of a descriptile deed such as + `.machine_readable/descriptiles/META.deed`, `STATE.deed` or `AGENTIC.deed` + as standards' A7 migration moves them out. Conformance is + `1-formats/deed/tools/deed_lint.js` in `metadatastician/standards`; bots + here only *read* deeds and never hand-convert A2ML (D313). + - **The only exception** is a deed-first **read fallback**: a shared reader + may still read a legacy `.a2ml` file after a deed source, and only while + A7's migration plan (M5–M7) requires it until its callers migrate. + Rhodibot's `canon` command does this (`src/canon/overlay.rs`), reporting a + legacy file as "migrate", never as "missing", and never naming an `.a2ml` + as the form to create. + - Earlier direct-under-`.machine_readable/`, `6scm/`, and `6a2/` layouts + are retired and must not be restored. 2. All shell scripts validate untrusted input before use. 3. No hardcoded secrets — use env vars with `${VAR:-}` defaults. 4. Fix scripts must be idempotent (safe to run multiple times). diff --git a/bots/rhodibot/README.adoc b/bots/rhodibot/README.adoc index 0f72e1a6..cce54ff4 100644 --- a/bots/rhodibot/README.adoc +++ b/bots/rhodibot/README.adoc @@ -80,6 +80,12 @@ its findings. | `fleet.rs` | gitbot-fleet integration: converts compliance reports to `Finding` structs, publishes to shared context +| `deed.rs` +| Read-only reader for the repo's chora deed: which clauses it carries, its `(rsr-profile ...)`, and rhodibot's `(bot-directives ...)` entry + +| `canon.rs`, `canon/` +| The vendored RSR criteria canon and the `rhodibot canon` command; `canon/overlay.rs` re-targets the criteria whose files the estate has retired (see below) + | `lib.rs` | Library root, re-exports all modules |=== @@ -191,12 +197,10 @@ Options: | README.adoc | Documentation | 5 | LICENSE.txt | Governance | 5 | SECURITY.md | Security | 5 -| CONTRIBUTING.md | Documentation | 3 -| CODE_OF_CONDUCT.md | Governance | 3 +| CONTRIBUTING.adoc (or .md) | Documentation | 3 +| CODE_OF_CONDUCT.adoc (or .md) | Governance | 3 | .claude/CLAUDE.md | Structure | 2 -| STATE.scm | Structure | 3 -| META.scm | Structure | 3 -| ECOSYSTEM.scm | Structure | 3 +| `_chora.deed` | Structure | 3 | .editorconfig | Structure | 2 | .gitattributes | Structure | 2 | .gitignore | Structure | 2 @@ -225,6 +229,38 @@ Options: * **Author attribution** -- flags Cargo.toml using "hyperpolymath" as author * **License type** -- validates against approved license list +=== The chora deed, and no A2ML + +A2ML is retired. The repo facts that used to be `.a2ml` files (manifest, state, +meta, ecosystem, agentic, neurosym, playbook, anchor, rsr-profile) are clauses of +`_chora.deed`, or of a descriptile deed (`STATE.deed`, `META.deed`, +`ECOSYSTEM.deed`, `AGENTIC.deed`). Rhodibot requires the chora deed and never +demands or suggests an `.a2ml` file. A legacy `.a2ml` that is still present is +read only as a fallback after the deed, and is reported as "migrate", never as +"missing". Whether a deed *conforms* is `deed_lint.js`'s job in +`metadatastician/standards`; rhodibot only reads its structure. + +The vendored criteria canon is itself still an `.a2ml` file; its deed form is a +separate piece of work. Until it lands, `canon/overlay.rs` re-targets the +affected criteria as requirements, and `canon/pin.toml` records the divergence +under `[overlay]` so the digest of the vendored copy stays honest. + +=== CONTRIBUTING and CODE_OF_CONDUCT: `.adoc` or `.md` + +Either spelling satisfies the check, and neither is ever required in addition +to the other. `.adoc` is the default, because the estate almost always uses it; +it decides which spelling a finding names first. A repository that prefers +`.md` says so in its chora deed's bot directives: + +[source] +---- +(bot-directives + (bot :name rhodibot + (config :community-doc-format md))) +---- + +A value other than `adoc` or `md` is an error rather than a silent default. + === Scoring Each check has a point value. The final score is `points_earned / max_points * 100`. diff --git a/bots/rhodibot/canon/pin.toml b/bots/rhodibot/canon/pin.toml index 5766b97c..54dbed7b 100644 --- a/bots/rhodibot/canon/pin.toml +++ b/bots/rhodibot/canon/pin.toml @@ -64,3 +64,23 @@ sha256 = "5c510bba025be718deebb12d0333bfe7db2da43c66578b728b1a334df65290b1" # inapplicable -- the failure mode is quiet, so the numbers are asserted. known = 28 presets = 11 + +# The overlay: where rhodibot DIVERGES from the vendored criteria, on purpose. +# +# The vendored `rsr-criteria-v2.a2ml` above is untouched -- its digest is still +# the standards copy's digest. But the estate has retired A2ML, so rhodibot no +# longer demands the `.a2ml` files that file names, and the .md/.adoc choice for +# CONTRIBUTING / CODE_OF_CONDUCT is toggleable. `src/canon/overlay.rs` re-targets +# these criteria as *requirements*; this table is the explicit record of that, +# and `tests/canon_lockstep.rs` fails if it and the module disagree. +# +# The criteria canon's own deed form is an A7 mapping-spec item (M5, converted +# under kyX or an owner-granted D313 exception, behind a parity gate, with +# `canon.lock` bumped in the same commit). When that lands, delete the overlay +# module and this table in the same commit that re-pins. +[overlay] +module = "src/canon/overlay.rs" +retargeted = ["2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.2.2"] +suspended = ["3.1.9", "3.2.1"] +extra_checks = ["rhodibot.chora-deed"] +removed_by = "the criteria-praxis-deed re-pin (A7 M5)" diff --git a/bots/rhodibot/src/canon.rs b/bots/rhodibot/src/canon.rs index fffab9b6..d78bec95 100644 --- a/bots/rhodibot/src/canon.rs +++ b/bots/rhodibot/src/canon.rs @@ -40,6 +40,7 @@ //! and reports every repository as compliant. pub mod local; +pub mod overlay; pub mod profile; pub mod report; pub mod requirement; diff --git a/bots/rhodibot/src/canon/local.rs b/bots/rhodibot/src/canon/local.rs index d1c88f1f..1d465d4c 100644 --- a/bots/rhodibot/src/canon/local.rs +++ b/bots/rhodibot/src/canon/local.rs @@ -20,8 +20,10 @@ use std::process::Command; use anyhow::{Context, Result, ensure}; -/// The two paths the canon's baseline allows for a profile, in preference -/// order: both are acceptable, and the first is the estate's. +/// Where a **legacy** `rsr-profile.a2ml` may still be, in preference order. +/// +/// A read fallback only, consulted when the chora deed has no +/// `(rsr-profile ...)` clause. Never a thing to create or ask for. const PROFILE_PATHS: [&str; 2] = [ ".machine_readable/rsr-profile.a2ml", "machine-readable/rsr-profile.a2ml", @@ -32,8 +34,10 @@ const PROFILE_PATHS: [&str; 2] = [ pub struct LocalSource { /// The repository's tracked files, relative to its root. pub files: Vec, - /// The text of its profile, when it has one. + /// The text of a legacy profile file, when it has one (a read fallback). pub profile: Option, + /// The text of the root `*_chora.deed`, when it has one. + pub chora_deed: Option, /// Whether the file list came from git or from a walk. from_git: bool, } @@ -49,10 +53,16 @@ impl LocalSource { /// Kept private so a `LocalSource` can only come from `read`, which is the /// only thing that knows whether the list is the tracked set. - fn new(files: Vec, profile: Option, from_git: bool) -> Self { + fn new( + files: Vec, + profile: Option, + chora_deed: Option, + from_git: bool, + ) -> Self { Self { files, profile, + chora_deed, from_git, } } @@ -78,7 +88,23 @@ pub fn read(root: &Path) -> Result { } }; - Ok(LocalSource::new(files, profile(root)?, from_git)) + let chora_deed = match super::overlay::find_chora_deed(&files)? { + Some(name) => { + let path = root.join(&name); + Some( + std::fs::read_to_string(&path) + .with_context(|| format!("reading {}", path.display()))?, + ) + } + None => None, + }; + + Ok(LocalSource::new( + files, + profile(root)?, + chora_deed, + from_git, + )) } /// The repository's tracked files, when git can be asked. diff --git a/bots/rhodibot/src/canon/overlay.rs b/bots/rhodibot/src/canon/overlay.rs new file mode 100644 index 00000000..9fad65d0 --- /dev/null +++ b/bots/rhodibot/src/canon/overlay.rs @@ -0,0 +1,300 @@ +// SPDX-License-Identifier: MPL-2.0 + +//! Rhodibot's overlay on the vendored criteria canon. +//! +//! The vendored `rsr-criteria-v2.a2ml` still names `.a2ml` files for the +//! machine-readable repo facts, and `CONTRIBUTING.md` / `CODE_OF_CONDUCT.md` +//! for the community documents. The estate has retired A2ML (those facts are +//! clauses of `_chora.deed`), and the community documents are almost +//! always `.adoc`. Converting the canon itself to a deed is not this crate's +//! to do -- that is an A7 mapping-spec item with a parity gate -- so the canon +//! is left byte-for-byte as it is, its digest stays honest, and this module +//! re-targets the affected criteria **as requirements**. The overlay is +//! recorded in `canon/pin.toml` under `[overlay]`, and a lockstep test fails +//! when the two disagree. When the canon gains its deed form, this module is +//! deleted in the same commit that re-pins. +//! +//! # What changes +//! +//! | criterion | now satisfied by | +//! |---|---| +//! | 2.1.4 `coc-md`, 2.1.5 `contributing-md` | `.adoc` **or** `.md`, never both required; the repo's `(bot :name rhodibot (config :community-doc-format ...))` only picks which one a report names first | +//! | 2.3.1 `ai-manifest` | the chora deed's `(manifest ...)` clause | +//! | 3.1.2-3.1.5 state, meta, ecosystem, agentic | the descriptile `.deed`, or the chora deed's clause of that name | +//! | 3.1.6-3.1.8 neurosym, playbook, anchor | the chora deed's clause of that name | +//! | 3.2.2 `rsr-profile` | the chora deed's `(rsr-profile ...)` clause | +//! | 3.1.9 `clade`, 3.2.1 `a2ml-valid` | suspended: not scored as file questions | +//! +//! Plus one check the canon does not carry: the chora deed itself must exist. +//! +//! # Legacy `.a2ml` is a read fallback, never a demand +//! +//! A repository that has not migrated yet still carries the old file. Where +//! the new form is absent and the old file is present, the verdict is +//! `elsewhere` ("present at X -- not Y"), i.e. *migrate*, and the expected +//! form it names is always the deed. No message here asks for an `.a2ml`. + +use std::collections::BTreeSet; + +use super::requirement::Requirement; +use super::{Criterion, Tier}; +use crate::deed::{Deed, DocFormat}; + +/// The criteria the overlay re-targets, for `pin.toml` to agree with. +pub const RETARGETED: &[&str] = &[ + "2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", + "3.2.2", +]; + +/// Criteria the overlay stops scoring as file questions. +/// +/// 3.1.9 asks for `CLADE.a2ml`, and the deed form of CLADE has not landed (A7 +/// M3), so there is nothing current to ask for. 3.2.1 is already not a file +/// question; it is listed so the intent is recorded rather than accidental. +pub const SUSPENDED: &[&str] = &["3.1.9", "3.2.1"]; + +/// The id of the check this overlay adds. +pub const CHORA_DEED_ID: &str = "rhodibot.chora-deed"; + +/// What a criterion is checked against instead of its own description. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Replacement { + pub requirement: Requirement, + /// Where a report says the canon keeps it. `-` for none: the canon's own + /// answer is the retired one, so it is never quoted. + pub template_ref: String, + /// Whether the criterion's own, original requirement is consulted as a + /// read fallback when the new form is absent. + pub legacy_fallback: bool, +} + +/// The overlay for one repository. +#[derive(Debug, Clone)] +pub struct Overlay { + chora_name: String, + format: DocFormat, + clauses: BTreeSet, +} + +impl Overlay { + /// `chora_name` is the root file name of the repository's chora deed, the + /// one that is expected even when it is missing (`_chora.deed`). + pub fn new(chora_name: &str, deed: Option<&Deed>, format: DocFormat) -> Self { + Self { + chora_name: chora_name.to_string(), + format, + clauses: deed.map(Deed::clauses).unwrap_or_default(), + } + } + + pub fn chora_name(&self) -> &str { + &self.chora_name + } + + /// One virtual path per top-level clause the deed carries. + /// + /// A clause is not a file, but the verdict machinery answers "is this + /// there?" over paths. `#meta` is a path no file can have, so + /// it cannot be satisfied by accident, and it reads as what it is in a + /// report. + pub fn virtual_files(&self) -> Vec { + self.clauses + .iter() + .map(|clause| clause_path(&self.chora_name, clause)) + .collect() + } + + pub fn is_suspended(id: &str) -> bool { + SUSPENDED.contains(&id) + } + + /// The replacement requirement for a criterion, when it is re-targeted. + pub fn replacement(&self, criterion: &Criterion) -> Option { + let clause = |name: &str| clause_path(&self.chora_name, name); + let descriptile = |name: &str| format!(".machine_readable/descriptiles/{name}.deed"); + let doc = |stem: &str| self.doc_alternatives(stem); + + let (groups, legacy_fallback): (Vec>, bool) = match criterion.id.as_str() { + "2.1.4" => (vec![doc("CODE_OF_CONDUCT")], false), + "2.1.5" => (vec![doc("CONTRIBUTING")], false), + "2.3.1" => (vec![vec![clause("manifest")]], true), + "3.1.2" => (vec![vec![descriptile("STATE"), clause("state")]], true), + "3.1.3" => (vec![vec![descriptile("META"), clause("meta")]], true), + "3.1.4" => ( + vec![vec![descriptile("ECOSYSTEM"), clause("ecosystem")]], + true, + ), + "3.1.5" => (vec![vec![descriptile("AGENTIC"), clause("agentic")]], true), + "3.1.6" => (vec![vec![clause("neurosym")]], true), + "3.1.7" => (vec![vec![clause("playbook")]], true), + "3.1.8" => (vec![vec![clause("anchor")]], true), + "3.2.2" => (vec![vec![clause("rsr-profile")]], true), + _ => return None, + }; + + Some(Replacement { + requirement: Requirement { all_of: groups }, + template_ref: "-".to_string(), + legacy_fallback, + }) + } + + /// `CONTRIBUTING.adoc` and `CONTRIBUTING.md`, the preferred spelling first. + /// + /// One group, so either satisfies it and neither is ever required in + /// addition to the other. GitHub honours both the root and `.github/`. + fn doc_alternatives(&self, stem: &str) -> Vec { + let first = self.format.extension(); + let second = self.format.other().extension(); + vec![ + format!("{stem}.{first}"), + format!("{stem}.{second}"), + format!(".github/{stem}.{first}"), + format!(".github/{stem}.{second}"), + ] + } + + /// Checks the canon does not carry: the chora deed has to exist. + pub fn extra_checks(&self) -> Vec<(Criterion, Replacement)> { + let criterion = Criterion { + id: CHORA_DEED_ID.to_string(), + name: "chora-deed".to_string(), + desc: format!( + "{} -- the repository's identity and facts (manifest, meta, ecosystem, agentic, \ + neurosym, playbook, anchor, rsr-profile, bot-directives)", + self.chora_name + ), + tier: Tier::Silver, + gate: "universal".to_string(), + detect: "rhodibot/chora-deed".to_string(), + template_ref: "-".to_string(), + }; + let replacement = Replacement { + requirement: Requirement { + all_of: vec![vec![self.chora_name.clone()]], + }, + template_ref: "-".to_string(), + legacy_fallback: false, + }; + vec![(criterion, replacement)] + } +} + +/// The virtual path of one clause of the chora deed. +pub fn clause_path(chora_name: &str, clause: &str) -> String { + format!("{chora_name}#{clause}") +} + +/// Pick the chora deed out of a file list: the root file ending `_chora.deed`. +/// +/// More than one is an error, because the estate has one per repository. +pub fn find_chora_deed(files: &[String]) -> anyhow::Result> { + let mut found: Vec<&String> = files + .iter() + .filter(|file| !file.contains('/') && file.ends_with("_chora.deed")) + .collect(); + found.sort(); + anyhow::ensure!( + found.len() <= 1, + "more than one chora deed at the root ({}); a repository has exactly one", + found + .iter() + .map(|file| file.as_str()) + .collect::>() + .join(", ") + ); + Ok(found.first().map(|file| (*file).clone())) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::canon::Canon; + + fn criterion(id: &str) -> Criterion { + Canon::vendored() + .expect("canon") + .criteria() + .find(|criterion| criterion.id == id) + .expect("criterion") + .clone() + } + + #[test] + fn no_replacement_names_an_a2ml_file() { + let overlay = Overlay::new("x_chora.deed", None, DocFormat::Adoc); + for id in RETARGETED { + let replacement = overlay + .replacement(&criterion(id)) + .unwrap_or_else(|| panic!("{id} is re-targeted")); + for path in replacement.requirement.paths() { + assert!(!path.ends_with(".a2ml"), "{id} still demands {path}"); + } + } + } + + #[test] + fn every_retargeted_id_has_a_replacement_and_nothing_else_does() { + let overlay = Overlay::new("x_chora.deed", None, DocFormat::Adoc); + let canon = Canon::vendored().unwrap(); + for criterion in canon.criteria() { + assert_eq!( + overlay.replacement(criterion).is_some(), + RETARGETED.contains(&criterion.id.as_str()), + "{}", + criterion.id + ); + } + } + + #[test] + fn the_default_prefers_adoc_and_the_override_prefers_md() { + let adoc = Overlay::new("x_chora.deed", None, DocFormat::Adoc); + let md = Overlay::new("x_chora.deed", None, DocFormat::Md); + let contributing = criterion("2.1.5"); + let first = |overlay: &Overlay| { + overlay + .replacement(&contributing) + .unwrap() + .requirement + .all_of[0][0] + .clone() + }; + assert_eq!(first(&adoc), "CONTRIBUTING.adoc"); + assert_eq!(first(&md), "CONTRIBUTING.md"); + } + + #[test] + fn a_document_is_one_group_so_both_forms_are_never_required() { + let overlay = Overlay::new("x_chora.deed", None, DocFormat::Adoc); + let replacement = overlay.replacement(&criterion("2.1.4")).unwrap(); + assert_eq!(replacement.requirement.all_of.len(), 1); + } + + #[test] + fn virtual_files_come_from_the_deed_clauses() { + let deed = Deed::parse("(repo-deed (meta :version \"1\") (anchor :id \"a\"))").unwrap(); + let overlay = Overlay::new("x_chora.deed", Some(&deed), DocFormat::Adoc); + assert_eq!( + overlay.virtual_files(), + vec![ + "x_chora.deed#anchor".to_string(), + "x_chora.deed#meta".to_string() + ] + ); + } + + #[test] + fn the_chora_deed_is_found_at_the_root_only() { + let files = |paths: &[&str]| paths.iter().map(|p| p.to_string()).collect::>(); + assert_eq!( + find_chora_deed(&files(&["a_chora.deed", "README.adoc"])).unwrap(), + Some("a_chora.deed".to_string()) + ); + assert_eq!( + find_chora_deed(&files(&["sub/a_chora.deed"])).unwrap(), + None + ); + assert!(find_chora_deed(&files(&["a_chora.deed", "b_chora.deed"])).is_err()); + } +} diff --git a/bots/rhodibot/src/canon/profile.rs b/bots/rhodibot/src/canon/profile.rs index f737dd0e..ab54fbb8 100644 --- a/bots/rhodibot/src/canon/profile.rs +++ b/bots/rhodibot/src/canon/profile.rs @@ -36,6 +36,7 @@ use std::collections::{BTreeMap, BTreeSet}; use anyhow::{Context, Result, ensure}; use super::{Canon, Criterion, VENDORED_GATES, split_assignment, strip_comment, unquote}; +use crate::deed::ProfileClause; /// The canon's gate table: the capabilities that exist, and what each preset /// expands to. @@ -230,6 +231,33 @@ impl Profile { "no [rsr-profile] section, capabilities or preset: this is not a profile" ); + Self::resolve(preset, declared_direct, add, remove, role, gates) + } + + /// The profile declared by the chora deed's `(rsr-profile ...)` clause. + /// + /// The deed is the current source; [`Profile::parse`] on the legacy file + /// is a read-only fallback. Both go through the same resolution, so a + /// misspelt capability is refused either way. + pub fn from_clause(clause: ProfileClause, gates: &GateTable) -> Result { + Self::resolve( + clause.preset, + clause.capabilities, + clause.add, + clause.remove, + clause.role, + gates, + ) + } + + fn resolve( + preset: Option, + declared_direct: Option>, + add: Vec, + remove: Vec, + role: Option, + gates: &GateTable, + ) -> Result { let mut declared = BTreeSet::new(); if let Some(name) = &preset { diff --git a/bots/rhodibot/src/canon/report.rs b/bots/rhodibot/src/canon/report.rs index 63f5e10c..b6e6ca79 100644 --- a/bots/rhodibot/src/canon/report.rs +++ b/bots/rhodibot/src/canon/report.rs @@ -15,12 +15,14 @@ use std::collections::BTreeMap; -use anyhow::Result; +use anyhow::{Context, Result}; use serde::Serialize; use super::Canon; +use super::overlay::{Overlay, find_chora_deed}; use super::profile::{GateTable, Profile}; use super::verdict::{Deprecation, GroupVerdict, Severity, Verdict}; +use crate::deed::{Deed, DocFormat}; /// What a repository would be told, if it asked. #[derive(Debug, Serialize)] @@ -46,6 +48,8 @@ pub struct CanonReport { pub retired_locations: Vec, /// Capabilities the repository declared, if it has a profile. pub declared_capabilities: Vec, + /// Checks rhodibot adds to the canon's (the chora deed), counted in `scored`. + pub extra_checks: usize, } #[derive(Debug, Default, Serialize, PartialEq, Eq)] @@ -153,12 +157,26 @@ impl FailOn { } } +/// Everything read from one repository, before any check runs. +#[derive(Debug, Default)] +pub struct RepoInput { + /// What the repository is called: the root file name its chora deed is + /// expected under when it has none. + pub name: String, + /// The repository's tracked files. + pub files: Vec, + /// The text of the root `*_chora.deed`, when there is one. + pub chora_deed: Option, + /// The text of a legacy `rsr-profile.a2ml`. A read fallback, consulted + /// only when the chora deed carries no `(rsr-profile ...)` clause. + pub legacy_profile: Option, +} + impl CanonReport { - /// Check one repository's file list against the canon. + /// Check one repository's file list against the canon, with no chora deed. /// - /// `profile_source` is the text of the repository's - /// `.machine_readable/rsr-profile.a2ml`, or `None` when it has none -- which - /// means it declares no capabilities, not that it is non-compliant. + /// Kept for callers that only have a file list. `profile_source` is the + /// text of a legacy profile, or `None`. pub fn build( subject: &str, canon: &Canon, @@ -166,12 +184,60 @@ impl CanonReport { files: &[String], profile_source: Option<&str>, ) -> Result { - let profile = match profile_source { - Some(source) => Profile::parse(source, gates)?, - None => Profile::default(), + Self::build_with( + subject, + canon, + gates, + &RepoInput { + name: subject + .rsplit(['/', '\\']) + .next() + .unwrap_or(subject) + .to_string(), + files: files.to_vec(), + chora_deed: None, + legacy_profile: profile_source.map(str::to_string), + }, + ) + } + + /// Check one repository against the canon, as overlaid by [`overlay`]. + /// + /// The profile comes from the chora deed's `(rsr-profile ...)` clause; a + /// legacy `rsr-profile.a2ml` is read only when the deed has none. No + /// profile at all means it declares no capabilities, not that it is + /// non-compliant. + pub fn build_with( + subject: &str, + canon: &Canon, + gates: &GateTable, + input: &RepoInput, + ) -> Result { + let deed = input + .chora_deed + .as_deref() + .map(Deed::parse) + .transpose() + .context("the chora deed does not read as an s-expression")?; + let format = DocFormat::from_deed(deed.as_ref())?; + let chora_name = + find_chora_deed(&input.files)?.unwrap_or_else(|| format!("{}_chora.deed", input.name)); + let overlay = Overlay::new(&chora_name, deed.as_ref(), format); + + let profile = match deed.as_ref().map(Deed::rsr_profile).transpose()?.flatten() { + Some(clause) => Profile::from_clause(clause, gates)?, + None => match input.legacy_profile.as_deref() { + Some(source) => Profile::parse(source, gates)?, + None => Profile::default(), + }, }; let deprecations = Deprecation::from_canon(canon)?; + // The files, plus one virtual path per clause of the chora deed. + let mut files = input.files.clone(); + files.extend(overlay.virtual_files()); + let files = files.as_slice(); + let mut report = Self { subject: subject.to_string(), criteria: canon.criterion_count(), @@ -189,6 +255,7 @@ impl CanonReport { }) .collect(), declared_capabilities: profile.declared().cloned().collect(), + extra_checks: 0, }; for criterion in canon.criteria() { @@ -197,18 +264,31 @@ impl CanonReport { continue; } - let Some(verdict) = Verdict::of(criterion, files, &deprecations) else { + if Overlay::is_suspended(&criterion.id) { report.not_file_questions += 1; continue; + } + + let verdict = match overlay.replacement(criterion) { + Some(replacement) => { + Verdict::of_replacement(criterion, &replacement, files, &deprecations) + } + None => match Verdict::of(criterion, files, &deprecations) { + Some(verdict) => verdict, + None => { + report.not_file_questions += 1; + continue; + } + }, }; - report.scored += 1; - let severity = verdict.severity(); - report.counts.record(severity); + report.record(criterion, &verdict); + } - if severity.is_finding() { - report.findings.push(Finding::of(criterion, &verdict)); - } + for (criterion, replacement) in overlay.extra_checks() { + let verdict = Verdict::of_replacement(&criterion, &replacement, files, &deprecations); + report.extra_checks += 1; + report.record(&criterion, &verdict); } // Worst first, and stable, so equal severities stay in canon order -- @@ -220,6 +300,15 @@ impl CanonReport { Ok(report) } + fn record(&mut self, criterion: &super::Criterion, verdict: &Verdict) { + self.scored += 1; + let severity = verdict.severity(); + self.counts.record(severity); + if severity.is_finding() { + self.findings.push(Finding::of(criterion, verdict)); + } + } + /// The report as a person reads it. pub fn render(&self) -> String { let mut out = String::new(); @@ -238,6 +327,12 @@ impl CanonReport { questions, not files)\n", self.scored, self.criteria, self.not_applicable, self.not_file_questions )); + if self.extra_checks > 0 { + out.push_str(&format!( + " (scored includes {} rhodibot check beyond the canon: the chora deed)\n", + self.extra_checks + )); + } out.push_str(&format!( " at path {} elsewhere {} deprecated location {} absent {}\n", self.counts.satisfied, @@ -319,7 +414,7 @@ impl Finding { found: elsewhere, deprecated_copies, } => { - expected.extend(alternatives.iter().cloned()); + expected.extend(alternatives.iter().map(|path| describe(path))); found.extend(elsewhere.iter().cloned()); if let Some(note) = super::verdict::canon_location_note(&verdict.template_ref, &elsewhere[0]) @@ -329,7 +424,7 @@ impl Finding { let mut line = format!( "present at {} — not {}", elsewhere.join(", "), - alternatives.join(" or ") + describe_all(alternatives, " or ") ); if !deprecated_copies.is_empty() { line.push_str(&format!( @@ -343,8 +438,9 @@ impl Finding { expected: alternatives, near_misses, } => { - expected.extend(alternatives.iter().cloned()); - let mut line = format!("absent — expected {}", alternatives.join(" or ")); + expected.extend(alternatives.iter().map(|path| describe(path))); + let mut line = + format!("absent — expected {}", describe_all(alternatives, " or ")); if !near_misses.is_empty() { line.push_str(&format!( "; there is a {} where the canon asks for one ending in {}", @@ -371,6 +467,22 @@ impl Finding { } } +/// A path as a person reads it: a virtual `#` path is the clause. +fn describe(path: &str) -> String { + match path.split_once('#') { + Some((deed, clause)) => format!("the ({clause} ...) clause of {deed}"), + None => path.to_string(), + } +} + +fn describe_all(paths: &[String], separator: &str) -> String { + paths + .iter() + .map(|path| describe(path)) + .collect::>() + .join(separator) +} + /// The extension a criterion asked for, for a line about near misses. fn extension_of(path: &str) -> String { match path.rsplit_once('.') { @@ -406,27 +518,38 @@ mod tests { "LICENSE", "LICENSES/MPL-2.0.txt", "SECURITY.md", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.md", + "CODE_OF_CONDUCT.adoc", + "CONTRIBUTING.adoc", ".gitignore", ".gitattributes", ".well-known/security.txt", - "0-AI-MANIFEST.a2ml", - ".machine_readable/rsr-profile.a2ml", - ".machine_readable/descriptiles/STATE.a2ml", - ".machine_readable/descriptiles/META.a2ml", - ".machine_readable/descriptiles/ECOSYSTEM.a2ml", - ".machine_readable/descriptiles/AGENTIC.a2ml", - ".machine_readable/descriptiles/NEUROSYM.a2ml", - ".machine_readable/descriptiles/PLAYBOOK.a2ml", - ".machine_readable/descriptiles/anchors/ANCHOR.a2ml", + "widgets_chora.deed", + // 3.1.1 asks for the descriptiles directory to exist. + ".machine_readable/descriptiles/STATE.deed", ]; + /// The chora deed of a repository that carries every fact the canon asks for. + const DEED: &str = "(repo-deed :schema-version \"1.0.0\" (manifest :version \"1\") (state :v 1) \ + (meta :version \"1\") (ecosystem :project \"w\") (agentic :version \"1\") (neurosym :version \"1\") \ + (playbook :version \"1\") (anchor :id \"a\") (rsr-profile :capabilities ()))"; + + fn input(paths: &[&str], deed: Option<&str>, legacy: Option<&str>) -> RepoInput { + RepoInput { + name: "widgets".to_string(), + files: files(paths), + chora_deed: deed.map(str::to_string), + legacy_profile: legacy.map(str::to_string), + } + } + + fn compliant() -> RepoInput { + input(COMPLIANT, Some(DEED), None) + } + #[test] fn a_compliant_repository_has_nothing_to_act_on() { - let report = - CanonReport::build("acme/widgets", &canon(), &gates(), &files(COMPLIANT), None) - .expect("the report builds"); + let report = CanonReport::build_with("acme/widgets", &canon(), &gates(), &compliant()) + .expect("the report builds"); assert_eq!(report.findings.len(), 0, "{:#?}", report.findings); assert_eq!(report.counts.missing, 0); @@ -436,14 +559,14 @@ mod tests { #[test] fn the_unapplicable_are_counted_and_not_reported() { - let report = - CanonReport::build("acme/widgets", &canon(), &gates(), &files(COMPLIANT), None) - .expect("the report builds"); + let report = CanonReport::build_with("acme/widgets", &canon(), &gates(), &compliant()) + .expect("the report builds"); // The vendored canon: 78 criteria, 30 gated on a capability. assert_eq!(report.criteria, 78); assert_eq!(report.not_applicable, 30); - assert_eq!(report.scored, 22); + assert_eq!(report.scored, 23, "22 canon criteria and the chora deed"); + assert_eq!(report.extra_checks, 1); assert_eq!(report.not_file_questions, 26); assert_eq!( report.findings.len() + report.counts.satisfied, @@ -465,24 +588,25 @@ mod tests { fn declaring_a_capability_brings_its_criteria_into_scope() { let profile = "[rsr-profile]\nversion = \"1.0.0\"\ncapabilities = [\"governance-tier\"]\n"; - let without = - CanonReport::build("acme/widgets", &canon(), &gates(), &files(COMPLIANT), None) - .expect("builds"); - let with = CanonReport::build( + let without = CanonReport::build_with("acme/widgets", &canon(), &gates(), &compliant()) + .expect("builds"); + // The legacy file is only a fallback: here the deed has no profile clause. + let deed_without_profile = DEED.replace(" (rsr-profile :capabilities ())", ""); + let with = CanonReport::build_with( "acme/widgets", &canon(), &gates(), - &files(COMPLIANT), - Some(profile), + &input(COMPLIANT, Some(&deed_without_profile), Some(profile)), ) .expect("builds"); - // Ten criteria gate on governance-tier; six of them ask about files - // and four ask content questions, so declaring the capability moves ten - // out of `na` and adds six to `scored`. + // Ten criteria gate on governance-tier; five of them ask about files, four + // ask content questions, and 3.1.9 (CLADE) is suspended by the overlay + // because its deed form has not landed. Declaring the capability moves + // ten out of `na` and adds five to `scored`. assert_eq!(without.not_applicable - with.not_applicable, 10); - assert_eq!(without.scored + 6, with.scored); - assert_eq!(without.not_file_questions + 4, with.not_file_questions); + assert_eq!(without.scored + 5, with.scored); + assert_eq!(without.not_file_questions + 5, with.not_file_questions); assert_eq!( with.declared_capabilities, vec!["governance-tier".to_string()] @@ -544,11 +668,12 @@ mod tests { #[test] fn a_near_miss_is_described_by_what_the_canon_asked_for() { + // 2.1.3 still asks for SECURITY.md; the near miss is named. let report = CanonReport::build( "acme/widgets", &canon(), &gates(), - &files(&["CODE_OF_CONDUCT.adoc"]), + &files(&["SECURITY.adoc"]), None, ) .expect("builds"); @@ -556,18 +681,280 @@ mod tests { let finding = report .findings .iter() - .find(|finding| finding.id == "2.1.4") - .expect("2.1.4 asks for CODE_OF_CONDUCT.md"); + .find(|finding| finding.id == "2.1.3") + .expect("2.1.3 asks for SECURITY.md"); assert_eq!(finding.severity, Severity::Missing); assert!( - finding.details[0].contains("CODE_OF_CONDUCT.adoc") - && finding.details[0].contains(".md"), + finding.details[0].contains("SECURITY.adoc") && finding.details[0].contains(".md"), "{:?}", finding.details ); } + fn finding<'a>(report: &'a CanonReport, id: &str) -> Option<&'a Finding> { + report.findings.iter().find(|finding| finding.id == id) + } + + fn report_for(paths: &[&str], deed: Option<&str>, legacy: Option<&str>) -> CanonReport { + CanonReport::build_with( + "acme/widgets", + &canon(), + &gates(), + &input(paths, deed, legacy), + ) + .expect("builds") + } + + #[test] + fn adoc_community_documents_are_not_missing() { + let report = report_for(&["CODE_OF_CONDUCT.adoc", "CONTRIBUTING.adoc"], None, None); + assert!( + finding(&report, "2.1.4").is_none(), + "{:#?}", + report.findings + ); + assert!( + finding(&report, "2.1.5").is_none(), + "{:#?}", + report.findings + ); + } + + #[test] + fn md_community_documents_are_not_missing() { + let report = report_for(&["CODE_OF_CONDUCT.md", "CONTRIBUTING.md"], None, None); + assert!( + finding(&report, "2.1.4").is_none(), + "{:#?}", + report.findings + ); + assert!( + finding(&report, "2.1.5").is_none(), + "{:#?}", + report.findings + ); + } + + #[test] + fn both_forms_present_is_fine_and_neither_is_required_alongside_the_other() { + let report = report_for( + &[ + "CODE_OF_CONDUCT.adoc", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.adoc", + "CONTRIBUTING.md", + ], + None, + None, + ); + assert!(finding(&report, "2.1.4").is_none() && finding(&report, "2.1.5").is_none()); + } + + #[test] + fn a_missing_document_names_adoc_first_by_default() { + let report = report_for(&[], None, None); + let missing = finding(&report, "2.1.5").expect("CONTRIBUTING is missing"); + assert_eq!(missing.severity, Severity::Missing); + assert_eq!(missing.expected[0], "CONTRIBUTING.adoc"); + assert!(missing.expected.contains(&"CONTRIBUTING.md".to_string())); + } + + #[test] + fn the_bot_directive_makes_md_the_named_form_but_adoc_still_satisfies() { + let deed = "(repo-deed (bot-directives (bot :name rhodibot \ + (config :community-doc-format md))))"; + + let missing = report_for(&[], Some(deed), None); + let finding_missing = finding(&missing, "2.1.4").expect("CODE_OF_CONDUCT is missing"); + assert_eq!(finding_missing.expected[0], "CODE_OF_CONDUCT.md"); + + // The override changes the wording, never whether the other form counts. + let adoc_present = report_for( + &["CODE_OF_CONDUCT.adoc", "CONTRIBUTING.adoc"], + Some(deed), + None, + ); + assert!(finding(&adoc_present, "2.1.4").is_none()); + assert!(finding(&adoc_present, "2.1.5").is_none()); + + let md_present = report_for(&["CODE_OF_CONDUCT.md", "CONTRIBUTING.md"], Some(deed), None); + assert!(finding(&md_present, "2.1.4").is_none()); + } + + #[test] + fn a_bad_doc_format_directive_is_an_error_not_a_default() { + let deed = "(repo-deed (bot-directives (bot :name rhodibot \ + (config :community-doc-format rst))))"; + assert!( + CanonReport::build_with( + "acme/widgets", + &canon(), + &gates(), + &input(&[], Some(deed), None) + ) + .is_err() + ); + } + + #[test] + fn nothing_the_report_expects_is_an_a2ml_file() { + // A bare repository is missing everything; none of it is an A2ML file. + let report = report_for(&[], None, None); + for finding in &report.findings { + for expected in &finding.expected { + assert!( + !expected.ends_with(".a2ml"), + "{} still expects {expected}", + finding.id + ); + } + for detail in &finding.details { + assert!( + !detail.contains(".a2ml"), + "{} still mentions an a2ml in {detail:?}", + finding.id + ); + } + } + let ids: Vec<&str> = report.findings.iter().map(|f| f.id.as_str()).collect(); + for id in [ + "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.2.2", + ] { + assert!( + ids.contains(&id), + "{id} should ask for its deed form: {ids:?}" + ); + } + } + + #[test] + fn the_chora_deed_is_required_and_named_after_the_repository() { + let report = report_for(&[], None, None); + let missing = finding(&report, super::super::overlay::CHORA_DEED_ID) + .expect("a repository with no chora deed is told so"); + assert_eq!(missing.severity, Severity::Missing); + assert_eq!(missing.expected, vec!["widgets_chora.deed".to_string()]); + } + + #[test] + fn a_deed_clause_satisfies_what_an_a2ml_file_used_to() { + let report = report_for(&["widgets_chora.deed"], Some(DEED), None); + for id in [ + "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.2.2", + ] { + assert!( + finding(&report, id).is_none(), + "{id}: {:#?}", + report.findings + ); + } + assert!(finding(&report, super::super::overlay::CHORA_DEED_ID).is_none()); + } + + #[test] + fn a_descriptile_deed_satisfies_state_meta_ecosystem_and_agentic() { + let report = report_for( + &[ + "widgets_chora.deed", + ".machine_readable/descriptiles/STATE.deed", + ".machine_readable/descriptiles/META.deed", + ".machine_readable/descriptiles/ECOSYSTEM.deed", + ".machine_readable/descriptiles/AGENTIC.deed", + ], + Some("(repo-deed)"), + None, + ); + for id in ["3.1.2", "3.1.3", "3.1.4", "3.1.5"] { + assert!( + finding(&report, id).is_none(), + "{id}: {:#?}", + report.findings + ); + } + } + + #[test] + fn a_legacy_a2ml_is_read_as_migrate_never_as_missing_and_never_recommended() { + let report = report_for( + &[ + "widgets_chora.deed", + ".machine_readable/descriptiles/STATE.a2ml", + ], + Some("(repo-deed)"), + None, + ); + let state = finding(&report, "3.1.2").expect("present only in the legacy form"); + assert_eq!(state.severity, Severity::Relocated, "{state:?}"); + // The form it is told to move to is the deed. + assert!( + state.expected.iter().all(|path| !path.ends_with(".a2ml")), + "{state:?}" + ); + assert!( + state + .expected + .iter() + .any(|path| path.contains("STATE.deed")) + ); + assert!( + state.canon_keeps_it_at.is_none(), + "the canon's own a2ml location must not be quoted: {state:?}" + ); + } + + #[test] + fn a_legacy_profile_is_read_only_when_the_deed_declares_none() { + let legacy = "[rsr-profile]\nversion = \"1.0.0\"\ncapabilities = [\"governance-tier\"]\n"; + // No deed profile: the fallback applies. + let fallback = report_for(&["widgets_chora.deed"], Some("(repo-deed)"), Some(legacy)); + assert_eq!( + fallback.declared_capabilities, + vec!["governance-tier".to_string()] + ); + // A deed profile wins over the legacy file. + let deed = "(repo-deed (rsr-profile :capabilities ()))"; + let first = report_for(&["widgets_chora.deed"], Some(deed), Some(legacy)); + assert!(first.declared_capabilities.is_empty()); + } + + #[test] + fn the_deed_profile_declares_capabilities() { + let deed = "(repo-deed (rsr-profile :capabilities (governance-tier)))"; + let report = report_for(&["widgets_chora.deed"], Some(deed), None); + assert_eq!( + report.declared_capabilities, + vec!["governance-tier".to_string()] + ); + } + + #[test] + fn a_misspelt_deed_capability_is_refused() { + let deed = "(repo-deed (rsr-profile :capabilities (governence-tier)))"; + assert!( + CanonReport::build_with( + "acme/widgets", + &canon(), + &gates(), + &input(&["widgets_chora.deed"], Some(deed), None) + ) + .is_err() + ); + } + + #[test] + fn an_unreadable_deed_is_an_error_not_an_absent_one() { + assert!( + CanonReport::build_with( + "acme/widgets", + &canon(), + &gates(), + &input(&["widgets_chora.deed"], Some("(repo-deed"), None) + ) + .is_err() + ); + } + #[test] fn fail_on_is_advisory_until_asked_otherwise() { let report = CanonReport::build( @@ -587,9 +974,8 @@ mod tests { assert!(FailOn::Deprecated.breached_by(&report)); assert!(FailOn::Missing.breached_by(&report)); - let satisfiable = - CanonReport::build("acme/widgets", &canon(), &gates(), &files(COMPLIANT), None) - .expect("builds"); + let satisfiable = CanonReport::build_with("acme/widgets", &canon(), &gates(), &compliant()) + .expect("builds"); assert!(!FailOn::Relocated.breached_by(&satisfiable)); assert!(!FailOn::Missing.breached_by(&satisfiable)); } diff --git a/bots/rhodibot/src/canon/verdict.rs b/bots/rhodibot/src/canon/verdict.rs index ffd4d478..0dad69f8 100644 --- a/bots/rhodibot/src/canon/verdict.rs +++ b/bots/rhodibot/src/canon/verdict.rs @@ -282,6 +282,69 @@ impl Verdict { }) } + /// Classify a criterion against an overlay's requirement instead of the + /// one its description gives (see [`super::overlay`]). + /// + /// When the replacement allows it and a group is absent in the new form, + /// the criterion's own original requirement is consulted as a **read + /// fallback**: a legacy file that is present makes the group `Elsewhere` + /// -- present, but not in the form the report names -- which reads as + /// "migrate", never as "missing". The expected form reported is always the + /// replacement's; the legacy name only ever appears as a fact found. + pub fn of_replacement( + criterion: &Criterion, + replacement: &super::overlay::Replacement, + files: &[String], + deprecations: &[Deprecation], + ) -> Self { + let original = replacement + .legacy_fallback + .then(|| requirement_from(&criterion.desc)) + .flatten(); + + let groups = replacement + .requirement + .all_of + .iter() + .enumerate() + .map(|(index, alternatives)| { + let current = + classify_group(alternatives, files, deprecations, &replacement.template_ref); + if !matches!(current, GroupVerdict::Absent { .. }) { + return current; + } + let Some(legacy_group) = original.as_ref().and_then(|r| r.all_of.get(index)) else { + return current; + }; + match classify_group(legacy_group, files, deprecations, &criterion.template_ref) { + GroupVerdict::AtPath { path, .. } => GroupVerdict::Elsewhere { + expected: alternatives.clone(), + found: vec![path], + deprecated_copies: Vec::new(), + }, + GroupVerdict::Elsewhere { + found, + deprecated_copies, + .. + } => GroupVerdict::Elsewhere { + expected: alternatives.clone(), + found, + deprecated_copies, + }, + // A copy only under a retired location is already "move + // it"; the new form is still what to move it to. + deprecated @ GroupVerdict::Deprecated { .. } => deprecated, + GroupVerdict::Absent { .. } => current, + } + }) + .collect(); + + Self { + groups, + template_ref: replacement.template_ref.clone(), + } + } + /// How much the canon objects, taking the worst group. pub fn severity(&self) -> Severity { if self @@ -448,6 +511,11 @@ fn near_misses_for(alternatives: &[String], files: &[String]) -> Vec { for alternative in alternatives.iter().filter(|path| !path.ends_with('/')) { let stem = stem_of(basename(alternative)); for file in files { + // A virtual clause path (`#`, see `overlay`) is not a + // file anyone could have misnamed. + if file.contains('#') || alternative.contains('#') { + continue; + } if alternatives.iter().any(|expected| expected == file) { continue; } diff --git a/bots/rhodibot/src/deed.rs b/bots/rhodibot/src/deed.rs new file mode 100644 index 00000000..c19e51f1 --- /dev/null +++ b/bots/rhodibot/src/deed.rs @@ -0,0 +1,430 @@ +// SPDX-License-Identifier: MPL-2.0 + +//! A minimal, read-only reader for the repository's chora deed +//! (`_chora.deed`). +//! +//! Repo facts that used to live in `.a2ml` files -- manifest, state, meta, +//! ecosystem, agentic, neurosym, playbook, anchor, the RSR profile and the +//! per-bot directives -- are clauses of the chora deed. Rhodibot asks three +//! things of it: *which top-level clauses are present*, *what the +//! `(rsr-profile ...)` clause declares*, and *what the `(bot-directives ...)` +//! clause says about rhodibot*. +//! +//! This is **not** the deed linter. Conformance to the normative grammar +//! (`1-formats/deed/spec/abnf/deed.abnf` in metadatastician/standards) is +//! `deed_lint.js`'s job and runs in standards' CI; rhodibot only needs the +//! s-expression structure, so this reads parentheses, strings, comments and +//! atoms and nothing else. A file that does not balance is refused rather than +//! guessed at. + +use std::collections::BTreeSet; + +use anyhow::{Result, bail, ensure}; + +/// One node of the s-expression tree. +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum Node { + /// A bare token: a symbol, a `:keyword`, a number, `#t`/`#f`, `#u8`. + Atom(String), + /// A double-quoted string, escapes resolved. + Str(String), + /// A parenthesised list. + List(Vec), +} + +impl Node { + /// The text of an atom or string, `None` for a list. + pub fn text(&self) -> Option<&str> { + match self { + Self::Atom(text) | Self::Str(text) => Some(text), + Self::List(_) => None, + } + } + + fn items(&self) -> &[Node] { + match self { + Self::List(items) => items, + _ => &[], + } + } + + /// The clause name: the first item when it is an atom. + fn head(&self) -> Option<&str> { + match self.items().first() { + Some(Self::Atom(name)) => Some(name), + _ => None, + } + } + + /// The members after the head. + fn members(&self) -> &[Node] { + self.items().get(1..).unwrap_or(&[]) + } + + /// The value following `:key` among this clause's own members. + fn field(&self, key: &str) -> Option<&Node> { + let members = self.members(); + members + .iter() + .position(|node| matches!(node, Node::Atom(atom) if atom == key)) + .and_then(|index| members.get(index + 1)) + } + + /// Direct child clauses with this name. + fn children<'a>(&'a self, name: &str) -> impl Iterator { + self.members() + .iter() + .filter(move |node| node.head() == Some(name)) + } +} + +/// A parsed chora deed. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct Deed { + root: Node, +} + +impl Deed { + /// Parse a deed. The file must hold exactly one top-level form. + pub fn parse(source: &str) -> Result { + let mut parser = Parser { + chars: source.chars().collect(), + at: 0, + }; + parser.skip_trivia(); + ensure!( + parser.peek() == Some('('), + "a deed starts with an opening parenthesis" + ); + let root = parser.node()?; + parser.skip_trivia(); + ensure!( + parser.peek().is_none(), + "text after the closing parenthesis of the deed: a deed is one form" + ); + Ok(Self { root }) + } + + /// The names of the top-level clauses, such as `meta` and `anchor`. + pub fn clauses(&self) -> BTreeSet { + self.root + .members() + .iter() + .filter_map(Node::head) + .map(str::to_string) + .collect() + } + + /// The first top-level clause with this name. + pub fn clause<'a>(&'a self, name: &str) -> Option<&'a Node> { + self.root.children(name).next() + } + + /// What the `(rsr-profile ...)` clause declares, if there is one. + pub fn rsr_profile(&self) -> Result> { + let Some(clause) = self.clause("rsr-profile") else { + return Ok(None); + }; + const KEYS: &[&str] = &[ + ":preset", + ":capabilities", + ":add", + ":remove", + ":role", + ":schema-version", + ":version", + ]; + let members = clause.members(); + for node in members { + if let Node::Atom(atom) = node + && atom.starts_with(':') + { + ensure!( + KEYS.contains(&atom.as_str()), + "unknown key {atom} in (rsr-profile ...); a misspelt key would declare no \ + capabilities and silently switch off every gated check" + ); + } + } + let list = |key: &str| -> Result> { + match clause.field(key) { + None => Ok(Vec::new()), + Some(Node::List(items)) => items + .iter() + .map(|item| { + item.text().map(str::to_string).ok_or_else(|| { + anyhow::anyhow!("(rsr-profile {key} ...) holds a nested list") + }) + }) + .collect(), + Some(_) => bail!("(rsr-profile {key} ...) must be a list"), + } + }; + let word = |key: &str| clause.field(key).and_then(Node::text).map(str::to_string); + Ok(Some(ProfileClause { + preset: word(":preset"), + capabilities: clause + .field(":capabilities") + .map(|_| list(":capabilities")) + .transpose()?, + add: list(":add")?, + remove: list(":remove")?, + role: word(":role"), + })) + } + + /// What `(bot-directives (bot :name ...))` says about one bot. + pub fn bot_directive<'a>(&'a self, bot: &str) -> Option> { + let directives = self.clause("bot-directives")?; + directives + .children("bot") + .find(|node| node.field(":name").and_then(Node::text) == Some(bot)) + .map(|node| BotDirective { node }) + } +} + +/// The `(rsr-profile ...)` clause, before it is checked against the gate table. +#[derive(Debug, Clone, PartialEq, Eq, Default)] +pub struct ProfileClause { + pub preset: Option, + pub capabilities: Option>, + pub add: Vec, + pub remove: Vec, + pub role: Option, +} + +/// One `(bot :name ...)` entry of the `(bot-directives ...)` clause. +#[derive(Debug, Clone, Copy)] +pub struct BotDirective<'a> { + node: &'a Node, +} + +impl<'a> BotDirective<'a> { + /// A symbol or string from the bot's `(config ...)`. + pub fn config(&self, key: &str) -> Option<&'a str> { + self.node + .children("config") + .find_map(|config| config.field(key)) + .and_then(Node::text) + } +} + +/// Which spelling of a community document a repository uses. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] +pub enum DocFormat { + /// `.adoc`: what the estate almost always uses, and the default. + #[default] + Adoc, + /// `.md`: a per-repo exception, declared through the bot directives. + Md, +} + +impl DocFormat { + pub fn extension(self) -> &'static str { + match self { + Self::Adoc => "adoc", + Self::Md => "md", + } + } + + pub fn other(self) -> Self { + match self { + Self::Adoc => Self::Md, + Self::Md => Self::Adoc, + } + } + + /// The `(config ...)` key rhodibot reads from its `(bot ...)` directive. + pub const KEY: &'static str = ":community-doc-format"; + + /// The repository's choice, from the deed. Absent means `.adoc`; a value + /// other than `adoc` or `md` is refused, because quietly falling back to + /// the default would hide a typo in a directive. + pub fn from_deed(deed: Option<&Deed>) -> Result { + let Some(value) = deed + .and_then(|deed| deed.bot_directive("rhodibot")) + .and_then(|directive| directive.config(Self::KEY)) + else { + return Ok(Self::default()); + }; + match value { + "adoc" => Ok(Self::Adoc), + "md" => Ok(Self::Md), + other => bail!( + "(bot :name rhodibot (config {} {other})): expected adoc or md", + Self::KEY + ), + } + } +} + +struct Parser { + chars: Vec, + at: usize, +} + +impl Parser { + fn peek(&self) -> Option { + self.chars.get(self.at).copied() + } + + /// Whitespace and `;` comments. + fn skip_trivia(&mut self) { + while let Some(c) = self.peek() { + if c.is_whitespace() { + self.at += 1; + } else if c == ';' { + while let Some(c) = self.peek() { + if c == '\n' { + break; + } + self.at += 1; + } + } else { + break; + } + } + } + + fn node(&mut self) -> Result { + self.skip_trivia(); + match self.peek() { + None => bail!("the deed ends inside an open form"), + Some('(') => { + self.at += 1; + let mut items = Vec::new(); + loop { + self.skip_trivia(); + match self.peek() { + None => bail!("unbalanced parentheses: a form is never closed"), + Some(')') => { + self.at += 1; + return Ok(Node::List(items)); + } + Some(_) => items.push(self.node()?), + } + } + } + Some(')') => bail!("unbalanced parentheses: a closing parenthesis with no opener"), + Some('"') => self.string(), + Some(_) => Ok(Node::Atom(self.atom())), + } + } + + fn string(&mut self) -> Result { + self.at += 1; + let mut text = String::new(); + while let Some(c) = self.peek() { + self.at += 1; + match c { + '"' => return Ok(Node::Str(text)), + '\\' => { + if let Some(escaped) = self.peek() { + self.at += 1; + text.push(escaped); + } + } + other => text.push(other), + } + } + bail!("a string is never closed") + } + + /// A run of characters up to whitespace, a parenthesis, a quote or a comment. + fn atom(&mut self) -> String { + let start = self.at; + while let Some(c) = self.peek() { + if c.is_whitespace() || matches!(c, '(' | ')' | '"' | ';') { + break; + } + self.at += 1; + } + self.chars[start..self.at].iter().collect() + } +} + +#[cfg(test)] +mod tests { + use super::*; + + const DEED: &str = r#" +;; SPDX-License-Identifier: MPL-2.0 +(repo-deed + :schema-version "1.0.0" + :repo-uuid #u8"gv-clade-index:github.com/o/r" ; trailing comment + (meta :version "0.1.0") + (anchor :id "x") + (rsr-profile :preset library :add (rust) :remove ()) + (bot-directives + (bot :name panicbot :allow (assail)) + (bot :name rhodibot (config :community-doc-format md)))) +"#; + + #[test] + fn it_lists_top_level_clauses_only() { + let deed = Deed::parse(DEED).expect("parses"); + let clauses = deed.clauses(); + assert!(clauses.contains("meta") && clauses.contains("anchor")); + assert!(clauses.contains("rsr-profile") && clauses.contains("bot-directives")); + // `bot` and `config` are nested, not top-level. + assert!(!clauses.contains("bot") && !clauses.contains("config")); + } + + #[test] + fn it_reads_the_profile_clause() { + let deed = Deed::parse(DEED).expect("parses"); + let profile = deed.rsr_profile().expect("reads").expect("present"); + assert_eq!(profile.preset.as_deref(), Some("library")); + assert_eq!(profile.add, vec!["rust".to_string()]); + assert!(profile.remove.is_empty()); + assert_eq!(profile.capabilities, None); + } + + #[test] + fn a_misspelt_profile_key_is_refused() { + let deed = Deed::parse("(repo-deed (rsr-profile :capabilites (rust)))").expect("parses"); + assert!(deed.rsr_profile().is_err()); + } + + #[test] + fn the_doc_format_defaults_to_adoc() { + assert_eq!(DocFormat::from_deed(None).unwrap(), DocFormat::Adoc); + let deed = Deed::parse("(repo-deed (bot-directives (bot :name rhodibot)))").unwrap(); + assert_eq!(DocFormat::from_deed(Some(&deed)).unwrap(), DocFormat::Adoc); + } + + #[test] + fn the_directive_selects_md_for_rhodibot_only() { + let deed = Deed::parse(DEED).expect("parses"); + assert_eq!(DocFormat::from_deed(Some(&deed)).unwrap(), DocFormat::Md); + // Another bot's config is not rhodibot's. + let other = Deed::parse( + "(repo-deed (bot-directives (bot :name panicbot (config :community-doc-format md))))", + ) + .unwrap(); + assert_eq!(DocFormat::from_deed(Some(&other)).unwrap(), DocFormat::Adoc); + } + + #[test] + fn a_bad_format_value_is_refused() { + let deed = Deed::parse( + "(repo-deed (bot-directives (bot :name rhodibot (config :community-doc-format rst))))", + ) + .unwrap(); + assert!(DocFormat::from_deed(Some(&deed)).is_err()); + } + + #[test] + fn unbalanced_input_is_refused() { + assert!(Deed::parse("(repo-deed (meta").is_err()); + assert!(Deed::parse("(repo-deed))").is_err()); + assert!(Deed::parse("repo-deed").is_err()); + assert!(Deed::parse("(repo-deed :x \"open)").is_err()); + } + + #[test] + fn parentheses_inside_strings_and_comments_do_not_count() { + let deed = Deed::parse("(repo-deed ; ) (\n (meta :note \"a ) b ( c\"))").unwrap(); + assert!(deed.clauses().contains("meta")); + } +} diff --git a/bots/rhodibot/src/fleet.rs b/bots/rhodibot/src/fleet.rs index de145f2a..d13f5f20 100644 --- a/bots/rhodibot/src/fleet.rs +++ b/bots/rhodibot/src/fleet.rs @@ -53,22 +53,15 @@ fn rule_id(check_name: &str) -> String { "CONTRIBUTING.md" | "CONTRIBUTING.adoc" => format!("{}-004", RULE_PREFIX), "CODE_OF_CONDUCT.md" | "CODE_OF_CONDUCT.adoc" => format!("{}-005", RULE_PREFIX), ".claude/CLAUDE.md" => format!("{}-006", RULE_PREFIX), - ".machine_readable/STATE.scm" | ".machine_readable/STATE.a2ml" => { - format!("{}-007", RULE_PREFIX) - } - ".machine_readable/META.scm" | ".machine_readable/META.a2ml" => { - format!("{}-008", RULE_PREFIX) - } - ".machine_readable/ECOSYSTEM.scm" | ".machine_readable/ECOSYSTEM.a2ml" => { - format!("{}-009", RULE_PREFIX) - } + // RSR-007..009 were the retired per-file state/meta/ecosystem checks; + // those facts are clauses of the chora deed (RSR-016) now. ".github/workflows" => format!("{}-010", RULE_PREFIX), ".editorconfig" => format!("{}-011", RULE_PREFIX), ".gitattributes" => format!("{}-012", RULE_PREFIX), ".gitignore" => format!("{}-013", RULE_PREFIX), "justfile" | "Justfile" => format!("{}-014", RULE_PREFIX), ".machine_readable/bot_directives" => format!("{}-015", RULE_PREFIX), - "0-AI-MANIFEST.a2ml" => format!("{}-016", RULE_PREFIX), + name if name.ends_with("_chora.deed") => format!("{}-016", RULE_PREFIX), "www/.well-known/security.txt" => format!("{}-017", RULE_PREFIX), ".machine_readable/root-allow.txt" => format!("{}-018", RULE_PREFIX), "no-.bot_directives" => format!("{}-LEGACY-001", RULE_PREFIX), @@ -90,12 +83,11 @@ fn suggestion_for(check_name: &str) -> Option { "README.adoc" => Some("Create a README.adoc file with project documentation".to_string()), "LICENSE.txt" | "LICENSE" => Some("Add a LICENSE file with MPL-2.0 (LICENSE is the current spelling)".to_string()), "SECURITY.adoc" | "SECURITY.md" => Some("Add a SECURITY.adoc with vulnerability reporting instructions".to_string()), - "CONTRIBUTING.adoc" | "CONTRIBUTING.md" => Some("Add a CONTRIBUTING.adoc with contribution guidelines".to_string()), - "CODE_OF_CONDUCT.adoc" | "CODE_OF_CONDUCT.md" => Some("Add a CODE_OF_CONDUCT.adoc (Contributor Covenant recommended)".to_string()), + "CONTRIBUTING.adoc" => Some("Add a CONTRIBUTING.adoc with contribution guidelines".to_string()), + "CONTRIBUTING.md" => Some("Add a CONTRIBUTING.md with contribution guidelines (this repository's bot directive prefers .md)".to_string()), + "CODE_OF_CONDUCT.adoc" => Some("Add a CODE_OF_CONDUCT.adoc (Contributor Covenant recommended)".to_string()), + "CODE_OF_CONDUCT.md" => Some("Add a CODE_OF_CONDUCT.md (Contributor Covenant recommended; this repository's bot directive prefers .md)".to_string()), ".claude/CLAUDE.md" => Some("Create .claude/CLAUDE.md with AI assistant instructions".to_string()), - ".machine_readable/STATE.a2ml" | ".machine_readable/STATE.scm" => Some("Add .machine_readable/STATE.a2ml with project state".to_string()), - ".machine_readable/META.a2ml" | ".machine_readable/META.scm" => Some("Add .machine_readable/META.a2ml with meta information".to_string()), - ".machine_readable/ECOSYSTEM.a2ml" | ".machine_readable/ECOSYSTEM.scm" => Some("Add .machine_readable/ECOSYSTEM.a2ml with ecosystem position".to_string()), ".github/workflows" => Some("Add GitHub Actions workflows in .github/workflows/".to_string()), ".editorconfig" => Some("Add .editorconfig for consistent formatting".to_string()), ".gitattributes" => Some("Add .gitattributes for line ending and diff config".to_string()), @@ -103,7 +95,9 @@ fn suggestion_for(check_name: &str) -> Option { "Justfile" | "justfile" => Some("Add a Justfile as the primary build system".to_string()), ".machine_readable/bot_directives" => Some("Create .machine_readable/bot_directives/ for bot configs".to_string()), "no-.bot_directives" => Some("Migrate legacy .bot_directives/ to .machine_readable/bot_directives/".to_string()), - "0-AI-MANIFEST.a2ml" => Some("Add a 0-AI-MANIFEST.a2ml machine-readable manifest at the repository root".to_string()), + name if name.ends_with("_chora.deed") => Some(format!( + "Add {name} (the chora deed): the repository's identity and facts, including its manifest, meta, ecosystem, agentic, anchor, rsr-profile and bot-directives clauses; check it with deed_lint.js from metadatastician/standards" + )), "www/.well-known/security.txt" => Some("Create www/.well-known/security.txt; run scripts/migrate-wellknown-to-www.sh to move an existing root .well-known/".to_string()), ".machine_readable/root-allow.txt" => Some("Add .machine_readable/root-allow.txt declaring the permitted root entries".to_string()), // Move, do not delete: the generic no- arm below would advise diff --git a/bots/rhodibot/src/github.rs b/bots/rhodibot/src/github.rs index 8a1df8e5..68b96581 100644 --- a/bots/rhodibot/src/github.rs +++ b/bots/rhodibot/src/github.rs @@ -246,7 +246,7 @@ impl GitHubClient { /// Read a file, treating "not found" as `None` rather than an error. /// /// The distinction matters for optional files: an absent - /// `.machine_readable/rsr-profile.a2ml` means a repository declares no + /// `.machine_readable/optional-fixture.txt` means a repository declares no /// capabilities, which is an answer. Only a 404 is absence; anything else /// is a real failure and is reported as one. pub async fn get_file_content_if_present( @@ -659,7 +659,7 @@ mod tests { { "path": "src", "type": "tree" }, { "path": "src/main.rs", "type": "blob" }, { "path": "README.adoc", "type": "blob" }, - { "path": ".machine_readable/descriptiles/STATE.a2ml", "type": "blob" } + { "path": ".machine_readable/descriptiles/STATE.deed", "type": "blob" } ] }))) .mount(&server) @@ -676,7 +676,7 @@ mod tests { vec![ "src/main.rs", "README.adoc", - ".machine_readable/descriptiles/STATE.a2ml" + ".machine_readable/descriptiles/STATE.deed" ], "directories are not files: counting `src` would not tell a check anything, and a \ criterion naming a directory is satisfied by what is inside it" @@ -715,7 +715,7 @@ mod tests { Mock::given(method("GET")) .and(path( - "/repos/acme/widgets/contents/.machine_readable/rsr-profile.a2ml", + "/repos/acme/widgets/contents/.machine_readable/optional-fixture.txt", )) .respond_with(ResponseTemplate::new(404).set_body_json(serde_json::json!({ "message": "Not Found" @@ -725,7 +725,7 @@ mod tests { Mock::given(method("GET")) .and(path( - "/repos/acme/widgets/contents/.machine_readable/STATE.a2ml", + "/repos/acme/widgets/contents/.machine_readable/STATE.deed", )) .respond_with(ResponseTemplate::new(500).set_body_string("boom")) .mount(&server) @@ -738,7 +738,7 @@ mod tests { .get_file_content_if_present( "acme", "widgets", - ".machine_readable/rsr-profile.a2ml" + ".machine_readable/optional-fixture.txt" ) .await .expect("a 404 is an answer, not a failure"), @@ -747,7 +747,7 @@ mod tests { ); let error = client - .get_file_content_if_present("acme", "widgets", ".machine_readable/STATE.a2ml") + .get_file_content_if_present("acme", "widgets", ".machine_readable/STATE.deed") .await .expect_err("a server error must not read as \"the file is absent\""); assert!(format!("{error:#}").contains("500"), "{error:#}"); diff --git a/bots/rhodibot/src/lib.rs b/bots/rhodibot/src/lib.rs index 9e3613fe..8c890ac0 100644 --- a/bots/rhodibot/src/lib.rs +++ b/bots/rhodibot/src/lib.rs @@ -14,6 +14,7 @@ pub mod app_auth; pub mod canon; pub mod config; +pub mod deed; pub mod fleet; pub mod github; pub mod graphql; diff --git a/bots/rhodibot/src/main.rs b/bots/rhodibot/src/main.rs index e091d7e2..ebb2192a 100644 --- a/bots/rhodibot/src/main.rs +++ b/bots/rhodibot/src/main.rs @@ -22,8 +22,9 @@ use tracing::{info, warn}; use rhodibot::canon::Canon; use rhodibot::canon::local; +use rhodibot::canon::overlay as local_overlay; use rhodibot::canon::profile::GateTable; -use rhodibot::canon::report::{CanonReport, FailOn}; +use rhodibot::canon::report::{CanonReport, FailOn, RepoInput}; use rhodibot::config; use rhodibot::github::GitHubClient; use rhodibot::rsr; @@ -71,8 +72,8 @@ enum Command { /// Check a repository against the RSR canon's file-presence criteria. /// /// Reads the canon vendored beside the rules (never a hardcoded list), - /// skips the criteria the repository's `.machine_readable/rsr-profile.a2ml` - /// does not declare a capability for, and reports what is present where the + /// skips the criteria the repository's chora deed `(rsr-profile ...)` + /// clause does not declare a capability for, and reports what is present where the /// canon records it, present elsewhere, present under a location the canon /// has retired, or absent. /// @@ -216,8 +217,9 @@ async fn main() -> Result<()> { /// One-shot RSR compliance check for CI. Prints a report and exits non-zero /// when required checks fail (so the caller's job fails too). -/// The file paths a repository's profile may live at, in preference order. -const PROFILE_PATHS: [&str; 2] = [ +/// Where a **legacy** profile file may still be: a read fallback, consulted +/// only when the chora deed has no `(rsr-profile ...)` clause. +const LEGACY_PROFILE_PATHS: [&str; 2] = [ ".machine_readable/rsr-profile.a2ml", "machine-readable/rsr-profile.a2ml", ]; @@ -237,38 +239,68 @@ async fn run_canon( ) -> Result<()> { let fail_on = FailOn::parse(fail_on)?; - let (subject, files, profile_source, from_git) = match (owner, repo, path) { + let (subject, input, from_git) = match (owner, repo, path) { (Some(owner), Some(repo), None) => { rhodibot::sanitize::validate_owner_repo(owner, repo)?; let client = GitHubClient::new(config); let files = client.tree_paths(owner, repo).await?; - // The profile decides which criteria apply, so a failure to read it - // must not pass as "declares nothing". - let mut profile = None; - for candidate in PROFILE_PATHS { + // The chora deed holds the profile and the bot directives, which + // decide which criteria apply and which document spelling is + // preferred, so a failure to read it must not pass as "declares + // nothing". + let chora_deed = match local_overlay::find_chora_deed(&files)? { + Some(name) => { + client + .get_file_content_if_present(owner, repo, &name) + .await? + } + None => None, + }; + + // A legacy profile file is a read fallback, used only when the + // deed has no (rsr-profile ...) clause. + let mut legacy_profile = None; + for candidate in LEGACY_PROFILE_PATHS { if let Some(text) = client .get_file_content_if_present(owner, repo, candidate) .await? { - profile = Some(text); + legacy_profile = Some(text); break; } } - (format!("{owner}/{repo}"), files, profile, true) + let input = RepoInput { + name: repo.clone(), + files, + chora_deed, + legacy_profile, + }; + (format!("{owner}/{repo}"), input, true) } (None, None, Some(path)) => { let source = local::read(std::path::Path::new(path))?; let from_git = source.from_git(); - (path.clone(), source.files, source.profile, from_git) + let name = std::path::Path::new(path) + .canonicalize() + .ok() + .and_then(|p| p.file_name().map(|n| n.to_string_lossy().into_owned())) + .unwrap_or_default(); + let input = RepoInput { + name, + files: source.files, + chora_deed: source.chora_deed, + legacy_profile: source.profile, + }; + (path.clone(), input, from_git) } _ => anyhow::bail!("give either --owner and --repo, or --path: one repository, one way"), }; let canon = Canon::vendored()?; let gates = GateTable::vendored()?; - let report = CanonReport::build(&subject, &canon, &gates, &files, profile_source.as_deref())?; + let report = CanonReport::build_with(&subject, &canon, &gates, &input)?; if format == "json" { println!("{}", serde_json::to_string_pretty(&report)?); diff --git a/bots/rhodibot/src/rsr.rs b/bots/rhodibot/src/rsr.rs index 18a1842c..05f207e1 100644 --- a/bots/rhodibot/src/rsr.rs +++ b/bots/rhodibot/src/rsr.rs @@ -4,11 +4,12 @@ //! //! Supports policy packs and opt-in severity levels for flexible compliance. -use anyhow::Result; +use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use crate::config::Config; +use crate::deed::{Deed, DocFormat}; use crate::github::GitHubClient; /// Severity levels for compliance checks @@ -124,6 +125,53 @@ pub async fn check_path_exists( (false, def.name.to_string()) } +/// Points for the chora deed check, as the manifest it replaced carried. +const CHORA_DEED_POINTS: u8 = 3; + +/// `CONTRIBUTING` or `CODE_OF_CONDUCT` when this check is one of the two +/// community documents whose spelling (`.adoc` or `.md`) is toggleable. +fn community_stem(name: &str) -> Option<&str> { + name.strip_suffix(".adoc") + .filter(|stem| matches!(*stem, "CONTRIBUTING" | "CODE_OF_CONDUCT")) +} + +/// The spellings to look for, the first being the one a report names. +/// +/// Every accepted spelling is always looked for, so a repository is never +/// reported missing a file it has in the other form. For the two community +/// documents the repository's own preference (from its bot directive, default +/// `.adoc`) goes first; it changes the wording of a finding, not whether there +/// is one. +pub fn candidates_for(def: &CheckDef, format: DocFormat) -> Vec { + let mut all: Vec = std::iter::once(def.name) + .chain(def.alternates.iter().copied()) + .map(str::to_string) + .collect(); + if let Some(stem) = community_stem(def.name) { + let preferred = format!("{stem}.{}", format.extension()); + if let Some(at) = all.iter().position(|name| *name == preferred) { + let name = all.remove(at); + all.insert(0, name); + } + } + all +} + +/// Whether any of the candidate paths exists, and which one. +pub async fn check_candidates_exist( + client: &GitHubClient, + owner: &str, + repo: &str, + candidates: &[String], +) -> (bool, String) { + for candidate in candidates { + if client.file_exists(owner, repo, candidate).await { + return (true, candidate.clone()); + } + } + (false, candidates[0].clone()) +} + /// Required files for RSR compliance with policy-based severity pub const REQUIRED_FILES: &[CheckDef] = &[ // NOTE ON THE 2026-09-18 REVISION @@ -223,64 +271,10 @@ pub const REQUIRED_FILES: &[CheckDef] = &[ Severity::Required, ), }, - CheckDef { - // The machine-readable manifest the estate actually ships: 261/269. - // The .scm state files below reached 1/269 and their .a2ml spelling - // 13/269, so neither is a fair Required check on its own. - name: "0-AI-MANIFEST.a2ml", - alternates: &[ - ".machine_readable/STATE.a2ml", - ".machine_readable/STATE.scm", - ], - description: "Machine-readable manifest at the repository root", - category: CheckCategory::Structure, - points: 3, - severity: ( - Severity::Optional, - Severity::Recommended, - Severity::Required, - Severity::Required, - ), - }, - CheckDef { - name: ".machine_readable/STATE.a2ml", - alternates: &[".machine_readable/STATE.scm"], - description: "Project state file in canonical machine-readable location", - category: CheckCategory::Structure, - points: 3, - severity: ( - Severity::Optional, - Severity::Optional, - Severity::Recommended, - Severity::Required, - ), - }, - CheckDef { - name: ".machine_readable/META.a2ml", - alternates: &[".machine_readable/META.scm"], - description: "Meta information in canonical machine-readable location", - category: CheckCategory::Structure, - points: 3, - severity: ( - Severity::Optional, - Severity::Optional, - Severity::Recommended, - Severity::Required, - ), - }, - CheckDef { - name: ".machine_readable/ECOSYSTEM.a2ml", - alternates: &[".machine_readable/ECOSYSTEM.scm"], - description: "Ecosystem position in canonical machine-readable location", - category: CheckCategory::Structure, - points: 3, - severity: ( - Severity::Optional, - Severity::Optional, - Severity::Recommended, - Severity::Required, - ), - }, + // The machine-readable repo facts (manifest, state, meta, ecosystem, ...) + // are clauses of the chora deed, not files. They are checked by the chora + // deed check in `check_compliance_with_policy`; no `.a2ml` or `.scm` file is + // demanded here. // Additional RSR template files CheckDef { name: ".editorconfig", @@ -597,12 +591,79 @@ pub async fn check_compliance_with_policy( let mut max_score = 0u8; let mut required_passed = true; + // The chora deed holds the repo facts and the bot directives. A deed that + // is present but does not read is an error, not "no directives". + let chora_name = format!("{repo}_chora.deed"); + let chora_text = client + .get_file_content_if_present(owner, repo, &chora_name) + .await?; + let deed = chora_text + .as_deref() + .map(Deed::parse) + .transpose() + .with_context(|| format!("{chora_name} does not read as an s-expression"))?; + let doc_format = DocFormat::from_deed(deed.as_ref())?; + + // The chora deed is required in place of the retired `.a2ml` files. + // Whether it conforms is `deed_lint.js`'s question (standards CI), not + // this check's. + { + let severity = repo_config + .severity_overrides + .get(&chora_name) + .copied() + .unwrap_or(match policy { + PolicyPack::Minimal => Severity::Optional, + PolicyPack::Standard | PolicyPack::Custom => Severity::Recommended, + PolicyPack::Strict | PolicyPack::Enterprise => Severity::Required, + }); + let present = deed.is_some(); + let counted = severity != Severity::Optional && !repo_config.skip.contains(&chora_name); + let points = if counted { CHORA_DEED_POINTS } else { 0 }; + if counted { + max_score += points; + } + let status = match (present, severity) { + (true, _) => CheckStatus::Pass, + (false, Severity::Required) if counted => { + required_passed = false; + CheckStatus::Fail + } + (false, Severity::Recommended) if counted => CheckStatus::Warn, + (false, _) => CheckStatus::Skip, + }; + if present && counted { + total_score += points; + } + checks.push(Check { + name: chora_name.clone(), + category: CheckCategory::Structure, + severity, + status, + points: if present { points } else { 0 }, + max_points: points, + message: if present { + format!("Chora deed (repo facts and bot directives) found at {chora_name}") + } else { + format!( + "Chora deed (repo facts and bot directives) missing - expected at {chora_name}" + ) + }, + }); + } + // Check required files for check_def in REQUIRED_FILES { + // The spellings to look for, the repository's preferred one first. + let candidates = candidates_for(check_def, doc_format); + let expected_name = candidates[0].clone(); + // Skip if explicitly configured to skip - if repo_config.skip.contains(&check_def.name.to_string()) { + if repo_config.skip.contains(&check_def.name.to_string()) + || repo_config.skip.contains(&expected_name) + { checks.push(Check { - name: check_def.name.to_string(), + name: expected_name.clone(), category: check_def.category, severity: Severity::Optional, status: CheckStatus::Skip, @@ -617,14 +678,16 @@ pub async fn check_compliance_with_policy( let severity = repo_config .severity_overrides .get(check_def.name) + .or_else(|| repo_config.severity_overrides.get(&expected_name)) .copied() .unwrap_or_else(|| check_def.severity_for(policy)); // Skip optional checks in scoring if severity == Severity::Optional { - let (exists, found_at) = check_path_exists(&client, owner, repo, check_def).await; + let (exists, found_at) = + check_candidates_exist(&client, owner, repo, &candidates).await; checks.push(Check { - name: check_def.name.to_string(), + name: expected_name.clone(), category: check_def.category, severity, status: if exists { @@ -644,17 +707,20 @@ pub async fn check_compliance_with_policy( } max_score += check_def.points; - let (exists, found_at) = check_path_exists(&client, owner, repo, check_def).await; - let accepted = if check_def.alternates.is_empty() { + let (exists, found_at) = check_candidates_exist(&client, owner, repo, &candidates).await; + let accepted = if candidates.len() < 2 { String::new() + } else if community_stem(check_def.name).is_some() { + // Either spelling satisfies it; neither is required as well. + format!(" (or {})", candidates[1..].join(", ")) } else { - format!(" (or, historically: {})", check_def.alternates.join(", ")) + format!(" (or, historically: {})", candidates[1..].join(", ")) }; if exists { total_score += check_def.points; checks.push(Check { - name: check_def.name.to_string(), + name: expected_name.clone(), category: check_def.category, severity, status: CheckStatus::Pass, @@ -673,7 +739,7 @@ pub async fn check_compliance_with_policy( }; checks.push(Check { - name: check_def.name.to_string(), + name: expected_name.clone(), category: check_def.category, severity, status, @@ -681,7 +747,7 @@ pub async fn check_compliance_with_policy( max_points: check_def.points, message: format!( "{} missing - expected at {}{}", - check_def.description, check_def.name, accepted + check_def.description, expected_name, accepted ), }); } diff --git a/bots/rhodibot/src/webhook.rs b/bots/rhodibot/src/webhook.rs index 7e712c78..c889e9ef 100644 --- a/bots/rhodibot/src/webhook.rs +++ b/bots/rhodibot/src/webhook.rs @@ -175,14 +175,14 @@ Welcome to the hyperpolymath organization! Please ensure your repository follows - [ ] `CONTRIBUTING.adoc` - Contribution guidelines (AsciiDoc) - [ ] `CODE_OF_CONDUCT.adoc` - Code of conduct (AsciiDoc) - [ ] `Justfile` - Just task runner (capital J) -- [ ] `0-AI-MANIFEST.a2ml` - Machine-readable manifest at the repository root +- [ ] `_chora.deed` - The chora deed: repository identity and facts (manifest, meta, ecosystem, agentic, anchor, rsr-profile, bot directives) - [ ] `.claude/CLAUDE.md` - AI assistant instructions - [ ] `.machine_readable/root-allow.txt` - Root-shape allowlist - [ ] `www/.well-known/security.txt` - Security contact in the canonical location Note: paths are given in the current convention. Superseded spellings (`LICENSE.txt`, `SECURITY.md`, `CONTRIBUTING.md`, `CODE_OF_CONDUCT.md`, -lowercase `justfile`, `.machine_readable/STATE.scm` and its siblings) are +lowercase `justfile`) are still accepted by the checker and are not compliance failures. ### Language Policy (CCCP) diff --git a/bots/rhodibot/tests/canon_lockstep.rs b/bots/rhodibot/tests/canon_lockstep.rs index a49e229b..5939e612 100644 --- a/bots/rhodibot/tests/canon_lockstep.rs +++ b/bots/rhodibot/tests/canon_lockstep.rs @@ -332,3 +332,39 @@ fn a_real_repository_classifies_the_way_the_pilot_recorded_it() { "the pilot's eleven, reclassified by the canon's own words" ); } + +/// The overlay is a deliberate divergence from the vendored canon, so it is +/// recorded in `canon/pin.toml` and the record has to match the code. +#[test] +fn the_overlay_is_recorded_in_the_pin_and_matches_the_module() { + use rhodibot::canon::overlay::{CHORA_DEED_ID, RETARGETED, SUSPENDED}; + + let text = + std::fs::read_to_string(PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("canon/pin.toml")) + .expect("pin.toml is readable"); + let pin: toml::Value = toml::from_str(&text).expect("pin.toml parses"); + let overlay = pin.get("overlay").expect("pin.toml records the overlay"); + + let list = |key: &str| -> Vec { + overlay + .get(key) + .and_then(|value| value.as_array()) + .unwrap_or_else(|| panic!("[overlay] {key} is a list")) + .iter() + .map(|item| item.as_str().expect("strings").to_string()) + .collect() + }; + + assert_eq!(list("retargeted"), RETARGETED); + assert_eq!(list("suspended"), SUSPENDED); + assert_eq!(list("extra_checks"), vec![CHORA_DEED_ID.to_string()]); + + // Every id it names is a real criterion of the vendored canon. + let canon = Canon::vendored().expect("parses"); + for id in RETARGETED.iter().chain(SUSPENDED) { + assert!( + canon.criteria().any(|c| c.id == *id), + "{id} is not in the canon" + ); + } +} diff --git a/bots/rhodibot/tests/integration_tests.rs b/bots/rhodibot/tests/integration_tests.rs index 5969f4bb..20cf93c0 100644 --- a/bots/rhodibot/tests/integration_tests.rs +++ b/bots/rhodibot/tests/integration_tests.rs @@ -87,6 +87,17 @@ mod rsr_tests { .await; } + /// The repository's chora deed, served raw. + async fn mount_deed(server: &MockServer, text: &str) { + Mock::given(method("GET")) + .and(path( + "/repos/test-org/test-repo/contents/test-repo_chora.deed", + )) + .respond_with(ResponseTemplate::new(200).set_body_string(text.to_string())) + .mount(server) + .await; + } + #[tokio::test] async fn test_all_required_files_present_high_score() { let server = MockServer::start().await; @@ -99,9 +110,6 @@ mod rsr_tests { "CONTRIBUTING.adoc", "CODE_OF_CONDUCT.adoc", ".claude/CLAUDE.md", - ".machine_readable/STATE.a2ml", - ".machine_readable/META.scm", - ".machine_readable/ECOSYSTEM.scm", ".github/workflows", ".editorconfig", ".gitattributes", @@ -111,6 +119,7 @@ mod rsr_tests { ]; mount_file_mocks(&server, "test-org", "test-repo", files).await; + mount_deed(&server, "(repo-deed :schema-version \"1.0.0\")").await; // Mock repository info with approved license Mock::given(method("GET")) @@ -261,6 +270,174 @@ mod rsr_tests { } } + /// Run the check against a repository with these files and this deed, and + /// return the check named `name`'s message and status. + async fn check_with( + files: &[&str], + deed: Option<&str>, + policy: PolicyPack, + ) -> ComplianceReport { + let server = MockServer::start().await; + let config = mock_config(&server.uri()); + mount_file_mocks(&server, "test-org", "test-repo", files).await; + if let Some(deed) = deed { + mount_deed(&server, deed).await; + } + let repo_config = RepoConfig { + policy, + ..Default::default() + }; + check_compliance_with_policy(&config, "test-org", "test-repo", &repo_config) + .await + .expect("compliance check should succeed") + } + + fn doc_check<'a>(report: &'a ComplianceReport, stem: &str) -> &'a Check { + report + .checks + .iter() + .find(|c| c.name.starts_with(stem)) + .unwrap_or_else(|| panic!("a {stem} check")) + } + + #[tokio::test] + async fn test_no_a2ml_or_scm_file_is_ever_demanded() { + // A bare repository under the strictest policy: everything missing. + let report = check_with(&[], None, PolicyPack::Enterprise).await; + for check in &report.checks { + assert!( + !check.name.contains("a2ml") + && !check.name.ends_with(".scm") + && !check.message.contains("a2ml") + && !check.message.contains(".scm"), + "{} / {}", + check.name, + check.message + ); + } + } + + #[tokio::test] + async fn test_chora_deed_is_required_in_place_of_a2ml_files() { + let missing = check_with(&["README.adoc"], None, PolicyPack::Strict).await; + let check = missing + .checks + .iter() + .find(|c| c.name == "test-repo_chora.deed") + .expect("a chora deed check"); + assert_eq!(check.status, CheckStatus::Fail); + assert!(!missing.required_passed); + + let present = check_with( + &["README.adoc"], + Some("(repo-deed :schema-version \"1.0.0\")"), + PolicyPack::Strict, + ) + .await; + let check = present + .checks + .iter() + .find(|c| c.name == "test-repo_chora.deed") + .expect("a chora deed check"); + assert_eq!(check.status, CheckStatus::Pass); + } + + #[tokio::test] + async fn test_adoc_community_documents_pass_by_default() { + let report = check_with( + &["CONTRIBUTING.adoc", "CODE_OF_CONDUCT.adoc"], + None, + PolicyPack::Strict, + ) + .await; + for stem in ["CONTRIBUTING", "CODE_OF_CONDUCT"] { + let check = doc_check(&report, stem); + assert_eq!(check.status, CheckStatus::Pass, "{}", check.message); + assert_eq!(check.name, format!("{stem}.adoc")); + } + } + + #[tokio::test] + async fn test_md_community_documents_pass_by_default() { + let report = check_with( + &["CONTRIBUTING.md", "CODE_OF_CONDUCT.md"], + None, + PolicyPack::Strict, + ) + .await; + for stem in ["CONTRIBUTING", "CODE_OF_CONDUCT"] { + let check = doc_check(&report, stem); + assert_eq!(check.status, CheckStatus::Pass, "{}", check.message); + } + } + + #[tokio::test] + async fn test_both_community_document_forms_are_never_both_required() { + // Only one form present, under the strictest policy: still a pass. + let report = check_with(&["CONTRIBUTING.adoc"], None, PolicyPack::Enterprise).await; + assert_eq!(doc_check(&report, "CONTRIBUTING").status, CheckStatus::Pass); + let message = &doc_check(&report, "CODE_OF_CONDUCT").message; + // The missing one names both spellings as alternatives ("or"), not two demands. + assert!( + message.contains("CODE_OF_CONDUCT.adoc") && message.contains("(or CODE_OF_CONDUCT.md)"), + "{message}" + ); + } + + const MD_DEED: &str = "(repo-deed (bot-directives (bot :name rhodibot \ + (config :community-doc-format md))))"; + + #[tokio::test] + async fn test_bot_directive_makes_md_the_named_form() { + let report = check_with(&[], Some(MD_DEED), PolicyPack::Strict).await; + let check = doc_check(&report, "CONTRIBUTING"); + assert_eq!(check.name, "CONTRIBUTING.md"); + assert_eq!(check.status, CheckStatus::Fail); + assert!( + check.message.contains("(or CONTRIBUTING.adoc)"), + "{}", + check.message + ); + } + + #[tokio::test] + async fn test_bot_directive_does_not_make_adoc_missing() { + // The repo prefers .md but carries .adoc: not missing. + let report = check_with( + &["CONTRIBUTING.adoc", "CODE_OF_CONDUCT.adoc"], + Some(MD_DEED), + PolicyPack::Strict, + ) + .await; + for stem in ["CONTRIBUTING", "CODE_OF_CONDUCT"] { + assert_eq!(doc_check(&report, stem).status, CheckStatus::Pass); + } + // And the reverse: prefers the default, carries .md. + let report = check_with( + &["CONTRIBUTING.md"], + Some("(repo-deed)"), + PolicyPack::Strict, + ) + .await; + assert_eq!(doc_check(&report, "CONTRIBUTING").status, CheckStatus::Pass); + } + + #[tokio::test] + async fn test_a_bad_directive_value_is_an_error() { + let server = MockServer::start().await; + let config = mock_config(&server.uri()); + mount_file_mocks(&server, "test-org", "test-repo", &[]).await; + mount_deed( + &server, + "(repo-deed (bot-directives (bot :name rhodibot (config :community-doc-format rst))))", + ) + .await; + let result = + check_compliance_with_policy(&config, "test-org", "test-repo", &RepoConfig::default()) + .await; + assert!(result.is_err()); + } + /// The estate has no `www/` tree at all yet (0/269 as of 2026-09-18), so /// the canonical-location check must be present and honest about that /// rather than silently passing. @@ -1420,13 +1597,13 @@ mod fleet_tests { message: "Go module (use Rust) detected - policy violation".to_string(), }, Check { - name: ".machine_readable/STATE.a2ml".to_string(), + name: ".editorconfig".to_string(), category: CheckCategory::Structure, severity: Severity::Recommended, status: CheckStatus::Skip, points: 0, max_points: 0, - message: "Project state file not present (optional)".to_string(), + message: "EditorConfig not present (optional)".to_string(), }, ], summary: "RSR standard policy: Required checks failed".to_string(), From 17bc1977b8d9222e29cbf577856251b23e87a15d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 00:59:22 +0000 Subject: [PATCH 2/5] fix(rhodibot): follow A7's deed shapes: string rsr-profile, no (state) clause - (rsr-profile ...) accepts :spec and :declares-against, is exactly once, and needs :capabilities or :preset. - 3.1.2 state: descriptile STATE.deed first, fallback chora (status ...) or (maturity ...); there is no (state ...) clause. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZmM7wgb8pXfyFEuRHQ --- bots/rhodibot/src/canon/overlay.rs | 11 +++++++-- bots/rhodibot/src/canon/report.rs | 2 +- bots/rhodibot/src/deed.rs | 38 ++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/bots/rhodibot/src/canon/overlay.rs b/bots/rhodibot/src/canon/overlay.rs index 9fad65d0..5f68d7eb 100644 --- a/bots/rhodibot/src/canon/overlay.rs +++ b/bots/rhodibot/src/canon/overlay.rs @@ -20,7 +20,7 @@ //! |---|---| //! | 2.1.4 `coc-md`, 2.1.5 `contributing-md` | `.adoc` **or** `.md`, never both required; the repo's `(bot :name rhodibot (config :community-doc-format ...))` only picks which one a report names first | //! | 2.3.1 `ai-manifest` | the chora deed's `(manifest ...)` clause | -//! | 3.1.2-3.1.5 state, meta, ecosystem, agentic | the descriptile `.deed`, or the chora deed's clause of that name | +//! | 3.1.2-3.1.5 state, meta, ecosystem, agentic | the descriptile `.deed`, or (fallback) the chora deed's clause of that name; state has no clause of its own: `(status ...)` or `(maturity ...)` | //! | 3.1.6-3.1.8 neurosym, playbook, anchor | the chora deed's clause of that name | //! | 3.2.2 `rsr-profile` | the chora deed's `(rsr-profile ...)` clause | //! | 3.1.9 `clade`, 3.2.1 `a2ml-valid` | suspended: not scored as file questions | @@ -118,7 +118,14 @@ impl Overlay { "2.1.4" => (vec![doc("CODE_OF_CONDUCT")], false), "2.1.5" => (vec![doc("CONTRIBUTING")], false), "2.3.1" => (vec![vec![clause("manifest")]], true), - "3.1.2" => (vec![vec![descriptile("STATE"), clause("state")]], true), + "3.1.2" => ( + vec![vec![ + descriptile("STATE"), + clause("status"), + clause("maturity"), + ]], + true, + ), "3.1.3" => (vec![vec![descriptile("META"), clause("meta")]], true), "3.1.4" => ( vec![vec![descriptile("ECOSYSTEM"), clause("ecosystem")]], diff --git a/bots/rhodibot/src/canon/report.rs b/bots/rhodibot/src/canon/report.rs index b6e6ca79..def31d8f 100644 --- a/bots/rhodibot/src/canon/report.rs +++ b/bots/rhodibot/src/canon/report.rs @@ -529,7 +529,7 @@ mod tests { ]; /// The chora deed of a repository that carries every fact the canon asks for. - const DEED: &str = "(repo-deed :schema-version \"1.0.0\" (manifest :version \"1\") (state :v 1) \ + const DEED: &str = "(repo-deed :schema-version \"1.0.0\" (manifest :version \"1\") (status :phase active) \ (meta :version \"1\") (ecosystem :project \"w\") (agentic :version \"1\") (neurosym :version \"1\") \ (playbook :version \"1\") (anchor :id \"a\") (rsr-profile :capabilities ()))"; diff --git a/bots/rhodibot/src/deed.rs b/bots/rhodibot/src/deed.rs index c19e51f1..4be7c38a 100644 --- a/bots/rhodibot/src/deed.rs +++ b/bots/rhodibot/src/deed.rs @@ -122,6 +122,10 @@ impl Deed { /// What the `(rsr-profile ...)` clause declares, if there is one. pub fn rsr_profile(&self) -> Result> { + ensure!( + self.root.children("rsr-profile").count() <= 1, + "more than one (rsr-profile ...) clause; a chora deed has exactly one" + ); let Some(clause) = self.clause("rsr-profile") else { return Ok(None); }; @@ -131,6 +135,8 @@ impl Deed { ":add", ":remove", ":role", + ":spec", + ":declares-against", ":schema-version", ":version", ]; @@ -161,6 +167,10 @@ impl Deed { } }; let word = |key: &str| clause.field(key).and_then(Node::text).map(str::to_string); + ensure!( + clause.field(":capabilities").is_some() || clause.field(":preset").is_some(), + "(rsr-profile ...) needs :capabilities or :preset" + ); Ok(Some(ProfileClause { preset: word(":preset"), capabilities: clause @@ -428,3 +438,31 @@ mod tests { assert!(deed.clauses().contains("meta")); } } + +#[cfg(test)] +mod profile_shape_tests { + use super::*; + + #[test] + fn the_real_string_shape_reads() { + let deed = Deed::parse( + "(repo-deed (rsr-profile :version \"1.0.0\" :spec \"rsr-criteria-v2\" \ + :declares-against \"2.1.1\" :role \"spine\" :capabilities (\"zig\" \"bash\") \ + :add (\"rust\") :remove (\"bash\")))", + ) + .unwrap(); + let p = deed.rsr_profile().unwrap().unwrap(); + assert_eq!(p.role.as_deref(), Some("spine")); + assert_eq!(p.capabilities, Some(vec!["zig".into(), "bash".into()])); + assert_eq!(p.add, vec!["rust".to_string()]); + } + + #[test] + fn two_clauses_or_an_empty_one_is_a_defect() { + let two = + Deed::parse("(repo-deed (rsr-profile :preset a) (rsr-profile :preset b))").unwrap(); + assert!(two.rsr_profile().is_err()); + let empty = Deed::parse("(repo-deed (rsr-profile :role \"x\"))").unwrap(); + assert!(empty.rsr_profile().is_err()); + } +} From f900e6dd471060fdb7282278b1e358201517a402 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:01:42 +0000 Subject: [PATCH 3/5] fix(rhodibot): read the real (rsr-profile) clause; SECURITY joins the doc toggle - (rsr-profile ...) known keys now include :policy and :omitted-rationale, as in the estate's real clauses; nested children are ignored. A test parses a verbatim copy of standards' own clause. - 2.1.3 / SECURITY follows the same .adoc|.md toggle as CONTRIBUTING and CODE_OF_CONDUCT, in both `canon` and `check`. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZmM7wgb8pXfyFEuRHQ --- bots/rhodibot/canon/pin.toml | 2 +- bots/rhodibot/src/canon/overlay.rs | 5 ++- bots/rhodibot/src/canon/report.rs | 37 +++++++---------- bots/rhodibot/src/deed.rs | 2 + bots/rhodibot/src/fleet.rs | 3 +- bots/rhodibot/src/rsr.rs | 2 +- .../fixtures/standards-rsr-profile.fragment | 40 +++++++++++++++++++ bots/rhodibot/tests/rsr_profile_shape.rs | 30 ++++++++++++++ 8 files changed, 93 insertions(+), 28 deletions(-) create mode 100644 bots/rhodibot/tests/fixtures/standards-rsr-profile.fragment create mode 100644 bots/rhodibot/tests/rsr_profile_shape.rs diff --git a/bots/rhodibot/canon/pin.toml b/bots/rhodibot/canon/pin.toml index 54dbed7b..76c2976b 100644 --- a/bots/rhodibot/canon/pin.toml +++ b/bots/rhodibot/canon/pin.toml @@ -80,7 +80,7 @@ presets = 11 # module and this table in the same commit that re-pins. [overlay] module = "src/canon/overlay.rs" -retargeted = ["2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.2.2"] +retargeted = ["2.1.3", "2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.2.2"] suspended = ["3.1.9", "3.2.1"] extra_checks = ["rhodibot.chora-deed"] removed_by = "the criteria-praxis-deed re-pin (A7 M5)" diff --git a/bots/rhodibot/src/canon/overlay.rs b/bots/rhodibot/src/canon/overlay.rs index 5f68d7eb..3aa59e77 100644 --- a/bots/rhodibot/src/canon/overlay.rs +++ b/bots/rhodibot/src/canon/overlay.rs @@ -42,8 +42,8 @@ use crate::deed::{Deed, DocFormat}; /// The criteria the overlay re-targets, for `pin.toml` to agree with. pub const RETARGETED: &[&str] = &[ - "2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", - "3.2.2", + "2.1.3", "2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", + "3.1.8", "3.2.2", ]; /// Criteria the overlay stops scoring as file questions. @@ -115,6 +115,7 @@ impl Overlay { let doc = |stem: &str| self.doc_alternatives(stem); let (groups, legacy_fallback): (Vec>, bool) = match criterion.id.as_str() { + "2.1.3" => (vec![doc("SECURITY")], false), "2.1.4" => (vec![doc("CODE_OF_CONDUCT")], false), "2.1.5" => (vec![doc("CONTRIBUTING")], false), "2.3.1" => (vec![vec![clause("manifest")]], true), diff --git a/bots/rhodibot/src/canon/report.rs b/bots/rhodibot/src/canon/report.rs index def31d8f..cc5d7e8f 100644 --- a/bots/rhodibot/src/canon/report.rs +++ b/bots/rhodibot/src/canon/report.rs @@ -667,29 +667,20 @@ mod tests { } #[test] - fn a_near_miss_is_described_by_what_the_canon_asked_for() { - // 2.1.3 still asks for SECURITY.md; the near miss is named. - let report = CanonReport::build( - "acme/widgets", - &canon(), - &gates(), - &files(&["SECURITY.adoc"]), - None, - ) - .expect("builds"); - - let finding = report - .findings - .iter() - .find(|finding| finding.id == "2.1.3") - .expect("2.1.3 asks for SECURITY.md"); - - assert_eq!(finding.severity, Severity::Missing); - assert!( - finding.details[0].contains("SECURITY.adoc") && finding.details[0].contains(".md"), - "{:?}", - finding.details - ); + fn security_follows_the_same_adoc_or_md_toggle() { + for file in ["SECURITY.adoc", "SECURITY.md"] { + let report = + CanonReport::build("acme/widgets", &canon(), &gates(), &files(&[file]), None) + .expect("builds"); + assert!( + report.findings.iter().all(|finding| finding.id != "2.1.3"), + "{file} satisfies 2.1.3" + ); + } + let missing = + CanonReport::build("acme/widgets", &canon(), &gates(), &files(&[]), None).unwrap(); + let finding = missing.findings.iter().find(|f| f.id == "2.1.3").unwrap(); + assert_eq!(finding.expected[0], "SECURITY.adoc"); } fn finding<'a>(report: &'a CanonReport, id: &str) -> Option<&'a Finding> { diff --git a/bots/rhodibot/src/deed.rs b/bots/rhodibot/src/deed.rs index 4be7c38a..ba8ddb90 100644 --- a/bots/rhodibot/src/deed.rs +++ b/bots/rhodibot/src/deed.rs @@ -137,6 +137,8 @@ impl Deed { ":role", ":spec", ":declares-against", + ":policy", + ":omitted-rationale", ":schema-version", ":version", ]; diff --git a/bots/rhodibot/src/fleet.rs b/bots/rhodibot/src/fleet.rs index d13f5f20..36cc5ff3 100644 --- a/bots/rhodibot/src/fleet.rs +++ b/bots/rhodibot/src/fleet.rs @@ -82,7 +82,8 @@ fn suggestion_for(check_name: &str) -> Option { match check_name { "README.adoc" => Some("Create a README.adoc file with project documentation".to_string()), "LICENSE.txt" | "LICENSE" => Some("Add a LICENSE file with MPL-2.0 (LICENSE is the current spelling)".to_string()), - "SECURITY.adoc" | "SECURITY.md" => Some("Add a SECURITY.adoc with vulnerability reporting instructions".to_string()), + "SECURITY.adoc" => Some("Add a SECURITY.adoc with vulnerability reporting instructions".to_string()), + "SECURITY.md" => Some("Add a SECURITY.md with vulnerability reporting instructions (this repository's bot directive prefers .md)".to_string()), "CONTRIBUTING.adoc" => Some("Add a CONTRIBUTING.adoc with contribution guidelines".to_string()), "CONTRIBUTING.md" => Some("Add a CONTRIBUTING.md with contribution guidelines (this repository's bot directive prefers .md)".to_string()), "CODE_OF_CONDUCT.adoc" => Some("Add a CODE_OF_CONDUCT.adoc (Contributor Covenant recommended)".to_string()), diff --git a/bots/rhodibot/src/rsr.rs b/bots/rhodibot/src/rsr.rs index 05f207e1..b0bf0ad1 100644 --- a/bots/rhodibot/src/rsr.rs +++ b/bots/rhodibot/src/rsr.rs @@ -132,7 +132,7 @@ const CHORA_DEED_POINTS: u8 = 3; /// community documents whose spelling (`.adoc` or `.md`) is toggleable. fn community_stem(name: &str) -> Option<&str> { name.strip_suffix(".adoc") - .filter(|stem| matches!(*stem, "CONTRIBUTING" | "CODE_OF_CONDUCT")) + .filter(|stem| matches!(*stem, "CONTRIBUTING" | "CODE_OF_CONDUCT" | "SECURITY")) } /// The spellings to look for, the first being the one a report names. diff --git a/bots/rhodibot/tests/fixtures/standards-rsr-profile.fragment b/bots/rhodibot/tests/fixtures/standards-rsr-profile.fragment new file mode 100644 index 00000000..ecbca030 --- /dev/null +++ b/bots/rhodibot/tests/fixtures/standards-rsr-profile.fragment @@ -0,0 +1,40 @@ + (rsr-profile + :version "1.0.0" + :spec "rsr-criteria-v2" + :declares-against "2.1.5" + :role "canon" + :capabilities ( + ; scripts/: the gate implementations (check-*.sh) + "bash" + ; .github/workflows/casket-pages.yml + pages.yml + "docs-site" + ; 0-canon/constitution/ + docs/{AUDIT,AFFIRMATION}.adoc + GOVERNANCE + MAINTAINERS + "governance-tier" + ; guix.scm: a real Guix manifest that pins the canon's own tooling + "reproducible-build" + ; tools/{uuid-v8,js-runtimes,hooks/playbook-to-recipe}, k9-init, the + ; inline-annotations extractor and .verisimdb's ingester are cargo crates + ; (declared since #1228 fixed the root-anchored src/**/*.rs row) + "rust") + (notes + ; Capabilities deliberately NOT declared, each for want of the artefact: + ; zig idris2 agda haskell gleam elixir julia ocaml affinescript + ; - no source in these; the compiled code is the Rust CI tools + ; cli - the check-*.sh scripts are CI steps, not a shipped binary + ; library - consumed as a document and a pin (canon.lock), not a library + ; ffi abi - no C-ABI seam and no formally specified ABI in this tree + ; api-service - the reusable workflows run on GitHub's runners, not served here + ; container - no Containerfile and no image + ; published-package - publishes specs (canon.lock + a tag), not packages; + ; the one omission to revisit if criteria go to a registry + ; formal-proofs - docs/proofs/ are proof artefacts OF THE ESTATE, not of + ; this repo's code: a [canon] carrier path in the gate table + ; mobile web-ui - no UI + ; benchmarks - benches/ holds no suite + ; plugin - not hosted in a third-party extension host + ; Carried but gated by no capability, so named in the gate table's [canon] + ; section instead: the criteria (0-canon/rsr/rsr-criteria-v2.a2ml), the + ; gate table, the applicability policy, the *-reusable.yml workflows, + ; docs/proofs/, and 9-archive/rhodium-standard-repositories/ (the last + ; copy; archived 2026-10-09, never to be deleted). + :omitted-rationale "The canon defines conformance; it is not an instance of it. Declaring a capability the canon lacks would make the oracle score it against a module it does not carry — the over-scaffolding failure the v2.0 capability model exists to prevent.")) diff --git a/bots/rhodibot/tests/rsr_profile_shape.rs b/bots/rhodibot/tests/rsr_profile_shape.rs new file mode 100644 index 00000000..43d2f6ee --- /dev/null +++ b/bots/rhodibot/tests/rsr_profile_shape.rs @@ -0,0 +1,30 @@ +// SPDX-License-Identifier: MPL-2.0 + +//! The `(rsr-profile ...)` clause as it really is in the estate: a verbatim +//! copy of the clause from `metadatastician/standards`' own chora deed +//! (`tests/fixtures/standards-rsr-profile.fragment`), with its comments, +//! nested `(notes ...)` and `:omitted-rationale`. + +use rhodibot::canon::profile::{GateTable, Profile}; +use rhodibot::deed::Deed; + +#[test] +fn the_real_clause_parses_and_resolves_against_the_gate_table() { + let fragment = include_str!("fixtures/standards-rsr-profile.fragment"); + let deed = Deed::parse(&format!("(repo-deed\n{fragment}\n)")).expect("the deed parses"); + let clause = deed.rsr_profile().expect("reads").expect("present"); + assert_eq!(clause.role.as_deref(), Some("canon")); + assert_eq!(clause.capabilities.as_ref().map(Vec::len), Some(5)); + + let profile = Profile::from_clause(clause, &GateTable::vendored().unwrap()).expect("resolves"); + for capability in [ + "bash", + "docs-site", + "governance-tier", + "reproducible-build", + "rust", + ] { + assert!(profile.declares(capability), "{capability}"); + } + assert_eq!(profile.capability_count(), 5); +} From 0e839665bd95ec36c05e5578fad7a700cc257694 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:05:58 +0000 Subject: [PATCH 4/5] fix(rhodibot): report 9.1.4 as a visible manual finding, not a missing-file error Criterion 9.1.4 ("Deployed site serves its .well-known/ over HTTPS") is a deployment question that the canon reader turned into a file check for `.well-known/`, flagging templates that serve it from www/. It is now listed in overlay::MANUAL_ONLY (recorded in pin.toml) and reported as a `manual` finding ("manual check: not verified by rhodibot"): visible, not graded, never tripping --fail-on. 1.2.4 (.tool-versions) is detect=manual but a real file question, so the list is explicit rather than a rule. The fleet report-back driver maps manual to info. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZmM7wgb8pXfyFEuRHQ --- bots/rhodibot/canon/pin.toml | 1 + bots/rhodibot/src/canon/overlay.rs | 12 +++++ bots/rhodibot/src/canon/report.rs | 70 +++++++++++++++++++++++++++ bots/rhodibot/src/canon/verdict.rs | 6 +++ bots/rhodibot/tests/canon_lockstep.rs | 1 + scripts/fleet-report-back.sh | 5 +- 6 files changed, 93 insertions(+), 2 deletions(-) diff --git a/bots/rhodibot/canon/pin.toml b/bots/rhodibot/canon/pin.toml index 76c2976b..e2ea0d85 100644 --- a/bots/rhodibot/canon/pin.toml +++ b/bots/rhodibot/canon/pin.toml @@ -82,5 +82,6 @@ presets = 11 module = "src/canon/overlay.rs" retargeted = ["2.1.3", "2.1.4", "2.1.5", "2.3.1", "3.1.2", "3.1.3", "3.1.4", "3.1.5", "3.1.6", "3.1.7", "3.1.8", "3.2.2"] suspended = ["3.1.9", "3.2.1"] +manual = ["9.1.4"] extra_checks = ["rhodibot.chora-deed"] removed_by = "the criteria-praxis-deed re-pin (A7 M5)" diff --git a/bots/rhodibot/src/canon/overlay.rs b/bots/rhodibot/src/canon/overlay.rs index 3aa59e77..9fc77a8d 100644 --- a/bots/rhodibot/src/canon/overlay.rs +++ b/bots/rhodibot/src/canon/overlay.rs @@ -53,6 +53,14 @@ pub const RETARGETED: &[&str] = &[ /// question; it is listed so the intent is recorded rather than accidental. pub const SUSPENDED: &[&str] = &["3.1.9", "3.2.1"]; +/// Criteria whose description is a deployment or content question that the +/// reader would otherwise turn into a file check. Reported as a visible +/// `manual` finding, never graded and never dropped. +/// +/// Not every `detect = manual` criterion belongs here: 1.2.4 (`.tool-versions`) +/// is `manual` yet a real file question, so this is a list, not a rule. +pub const MANUAL_ONLY: &[&str] = &["9.1.4"]; + /// The id of the check this overlay adds. pub const CHORA_DEED_ID: &str = "rhodibot.chora-deed"; @@ -104,6 +112,10 @@ impl Overlay { .collect() } + pub fn is_manual_only(id: &str) -> bool { + MANUAL_ONLY.contains(&id) + } + pub fn is_suspended(id: &str) -> bool { SUSPENDED.contains(&id) } diff --git a/bots/rhodibot/src/canon/report.rs b/bots/rhodibot/src/canon/report.rs index cc5d7e8f..4bac9676 100644 --- a/bots/rhodibot/src/canon/report.rs +++ b/bots/rhodibot/src/canon/report.rs @@ -58,6 +58,7 @@ pub struct Counts { pub relocated: usize, pub deprecated: usize, pub missing: usize, + pub manual: usize, } impl Counts { @@ -67,6 +68,7 @@ impl Counts { Severity::Relocated => self.relocated += 1, Severity::Deprecated => self.deprecated += 1, Severity::Missing => self.missing += 1, + Severity::Manual => self.manual += 1, } } } @@ -269,6 +271,12 @@ impl CanonReport { continue; } + if Overlay::is_manual_only(&criterion.id) { + report.counts.record(Severity::Manual); + report.findings.push(Finding::manual(criterion)); + continue; + } + let verdict = match overlay.replacement(criterion) { Some(replacement) => { Verdict::of_replacement(criterion, &replacement, files, &deprecations) @@ -390,6 +398,24 @@ impl CanonReport { } impl Finding { + /// A criterion rhodibot cannot decide from files: visible, not graded. + fn manual(criterion: &super::Criterion) -> Self { + Self { + id: criterion.id.clone(), + name: criterion.name.clone(), + tier: criterion.tier.to_string(), + severity: Severity::Manual, + canon_keeps_it_at: None, + expected: Vec::new(), + found: Vec::new(), + deprecated_copies: Vec::new(), + details: vec![format!( + "manual check: not verified by rhodibot ({})", + criterion.desc + )], + } + } + fn of(criterion: &super::Criterion, verdict: &Verdict) -> Self { let mut expected = Vec::new(); let mut found = Vec::new(); @@ -1043,3 +1069,47 @@ mod tests { assert!(format!("{error:#}").contains("critical"), "{error:#}"); } } + +#[cfg(test)] +mod manual_tests { + use super::*; + + #[test] + fn a_deployment_question_is_a_visible_manual_info_not_a_missing_file() { + let profile = "[rsr-profile]\nversion = \"1.0.0\"\ncapabilities = [\"docs-site\"]\n"; + let report = CanonReport::build( + "acme/widgets", + &Canon::vendored().unwrap(), + &GateTable::vendored().unwrap(), + // The site is served from www/, so .well-known/ is not at the root. + &["www/.well-known/security.txt".to_string()], + Some(profile), + ) + .unwrap(); + let finding = report + .findings + .iter() + .find(|f| f.id == "9.1.4") + .expect("still visible"); + assert_eq!(finding.severity, Severity::Manual); + assert!(finding.details[0].contains("manual check: not verified by rhodibot")); + assert!(report.counts.manual >= 1); + // Never trips a --fail-on threshold, even the lowest. + assert!(!FailOn::Relocated.breached_by(&report) || report.counts.relocated > 0); + } + + #[test] + fn a_manual_detect_file_question_is_still_graded() { + // 1.2.4 is detect = manual but names a file: it stays a real finding. + let report = CanonReport::build( + "acme/widgets", + &Canon::vendored().unwrap(), + &GateTable::vendored().unwrap(), + &[], + None, + ) + .unwrap(); + let tv = report.findings.iter().find(|f| f.id == "1.2.4").unwrap(); + assert_eq!(tv.severity, Severity::Missing); + } +} diff --git a/bots/rhodibot/src/canon/verdict.rs b/bots/rhodibot/src/canon/verdict.rs index 0dad69f8..c6e068c8 100644 --- a/bots/rhodibot/src/canon/verdict.rs +++ b/bots/rhodibot/src/canon/verdict.rs @@ -225,6 +225,10 @@ impl GroupVerdict { pub enum Severity { /// Every group is present where the canon records it. Satisfied, + /// A manual criterion: rhodibot cannot decide it from files, and says so + /// rather than grade it. Below `Relocated`, so no `--fail-on` threshold + /// trips on it. + Manual, /// Present, but somewhere the description does not name. Relocated, /// Present only under a location the canon has retired. @@ -237,6 +241,7 @@ impl Severity { pub fn as_str(self) -> &'static str { match self { Self::Satisfied => "satisfied", + Self::Manual => "manual", Self::Relocated => "relocated", Self::Deprecated => "deprecated", Self::Missing => "missing", @@ -375,6 +380,7 @@ impl Verdict { pub fn as_str(&self) -> &'static str { match self.severity() { Severity::Satisfied => "at path", + Severity::Manual => "manual check", Severity::Relocated => "elsewhere", Severity::Deprecated => "deprecated location", Severity::Missing => "absent", diff --git a/bots/rhodibot/tests/canon_lockstep.rs b/bots/rhodibot/tests/canon_lockstep.rs index 5939e612..166047af 100644 --- a/bots/rhodibot/tests/canon_lockstep.rs +++ b/bots/rhodibot/tests/canon_lockstep.rs @@ -357,6 +357,7 @@ fn the_overlay_is_recorded_in_the_pin_and_matches_the_module() { assert_eq!(list("retargeted"), RETARGETED); assert_eq!(list("suspended"), SUSPENDED); + assert_eq!(list("manual"), rhodibot::canon::overlay::MANUAL_ONLY); assert_eq!(list("extra_checks"), vec![CHORA_DEED_ID.to_string()]); // Every id it names is a real criterion of the vendored canon. diff --git a/scripts/fleet-report-back.sh b/scripts/fleet-report-back.sh index fc00b4cf..6b2a2135 100755 --- a/scripts/fleet-report-back.sh +++ b/scripts/fleet-report-back.sh @@ -639,7 +639,8 @@ run_member() { case "$m" in rhodibot) # canon --path: file-presence criteria against the vendored RSR canon. - # "satisfied" rows are not findings; missing > deprecated > relocated. + # "satisfied" rows are not findings; missing > deprecated > relocated; a + # "manual" row (not verifiable from files) is carried as info. run_adapter "$bin" canon --path "$repo" --format json translate_or_error "$m" "$SHAPE_OBJ_FINDINGS"' [ .findings[] @@ -651,7 +652,7 @@ run_member() { file: ((if .severity == "missing" then (.canon_keeps_it_at // (.expected // [])[0] // "") else ((.found // [])[0] // .canon_keeps_it_at // (.expected // [])[0] // "") end) | tostring), line: 0, - severity: ({missing: "error", deprecated: "warning", relocated: "info"}[.severity] // .severity), + severity: ({missing: "error", deprecated: "warning", relocated: "info", manual: "info"}[.severity] // .severity), message: ("\(.name): \(.severity)" + (if (.details // []) | length > 0 then " — " + ((.details // []) | join("; ")) else "" end)) } | .file |= rel ]' ;; panicbot) From d17c9955e24761242b4363f7ec59930a48616295 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:07:58 +0000 Subject: [PATCH 5/5] fix(rhodibot): give manual findings the path the criterion is about A manual finding had no path, so the fleet grid would grade it against every change. It now carries the first path its description names (`.well-known/` for 9.1.4), else the canon's template path. Test asserts every manual finding has a non-empty path. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0136P7ZmM7wgb8pXfyFEuRHQ --- bots/rhodibot/src/canon/report.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/bots/rhodibot/src/canon/report.rs b/bots/rhodibot/src/canon/report.rs index 4bac9676..9cfa1e5d 100644 --- a/bots/rhodibot/src/canon/report.rs +++ b/bots/rhodibot/src/canon/report.rs @@ -400,13 +400,19 @@ impl CanonReport { impl Finding { /// A criterion rhodibot cannot decide from files: visible, not graded. fn manual(criterion: &super::Criterion) -> Self { + // The path the criterion is about, so a consumer can place the finding: + // the first path its description names, else the canon's own template + // path. Never empty, or a grid would grade it against every change. + let about = super::requirement::requirement_from(&criterion.desc) + .and_then(|requirement| requirement.paths().next().cloned()) + .unwrap_or_else(|| criterion.template_ref.clone()); Self { id: criterion.id.clone(), name: criterion.name.clone(), tier: criterion.tier.to_string(), severity: Severity::Manual, canon_keeps_it_at: None, - expected: Vec::new(), + expected: vec![about], found: Vec::new(), deprecated_copies: Vec::new(), details: vec![format!( @@ -1093,6 +1099,17 @@ mod manual_tests { .expect("still visible"); assert_eq!(finding.severity, Severity::Manual); assert!(finding.details[0].contains("manual check: not verified by rhodibot")); + // Every manual finding carries a non-empty path, or a grid would grade + // it against every change. + for manual in report + .findings + .iter() + .filter(|f| f.severity == Severity::Manual) + { + let path = manual.expected.first().map(String::as_str).unwrap_or(""); + assert!(!path.is_empty() && path != "-", "{} has no path", manual.id); + } + assert_eq!(finding.expected, vec![".well-known/".to_string()]); assert!(report.counts.manual >= 1); // Never trips a --fail-on threshold, even the lowest. assert!(!FailOn::Relocated.breached_by(&report) || report.counts.relocated > 0);