Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions bots/rhodibot/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,12 @@ Each RSR check has a severity (Required, Recommended, Optional) that varies by p
| CONTRIBUTING.md | Optional | Recommended | Required | Required
| CODE_OF_CONDUCT.md | Optional | Optional | Recommended | Required
| .claude/CLAUDE.md | Optional | Optional | Recommended | Required
| STATE.scm | Optional | Recommended | Required | Required
| META.scm | Optional | Recommended | Required | Required
| ECOSYSTEM.scm | Optional | Optional | Recommended | Required
| `<repo>_chora.deed` | Optional | Recommended | Required | Required
| .editorconfig | Optional | Recommended | Required | Required
| .gitattributes | Optional | Recommended | Required | Required
| .gitignore | Optional | Recommended | Required | Required
| Justfile | Optional | Optional | Recommended | Required
| .bot_directives | Optional | Optional | Recommended | Required
| any `*.a2ml` (`no-*.a2ml`, P1) | Required | Required | Required | Required
|===

Repositories can override severity or skip checks entirely via `.rsr.toml`:
Expand Down Expand Up @@ -205,9 +203,11 @@ Options:
| .gitattributes | Structure | 2
| .gitignore | Structure | 2
| Justfile | Structure | 2
| .bot_directives | Structure | 2
|===

RSR-015 (`.machine_readable/bot_directives/`) is retired: its files were `.a2ml`, and
the bot directives are the chora deed's `(bot-directives ...)` clause.

=== Banned Patterns (6)

[cols="2,3"]
Expand Down Expand Up @@ -235,9 +235,23 @@ 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
`<repo>_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
demands or suggests an `.a2ml` file.

*Any `.a2ml` file is a priority-1 finding.* `canon` reports each tracked `.a2ml`
as `rhodibot.no-a2ml` with severity `retired` (above `missing`; `--fail-on
retired` gates on it), naming the deed form its family maps to under the
standards mapping specs and whether kyX can convert it today (only
`ECOSYSTEM.a2ml`, D313). The fleet report-back carries it as `critical`. The
GitHub App check reports `no-*.a2ml` (RSR-A2ML-001) as a Required failure in every
policy pack; `.rsr.toml` cannot skip or downgrade it, it scans the push or PR
head it reports on, and a tree it cannot list fails it closed. Rhodibot only
reports: conversion is kyX's (`kyx a2ml ecosystem SRC --chora CHORA ...`, D313),
run by the fleet's opportunistic fixer once that lands (proposed in #691), never
by hand.

Separately, a legacy `.a2ml` that is still present is read only as a fallback
after the deed, and the criterion it would satisfy 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
Expand Down
1 change: 1 addition & 0 deletions bots/rhodibot/src/canon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
//! The failure mode to avoid is the quiet one: a rule set that silently shrinks
//! and reports every repository as compliant.

pub mod a2ml;
pub mod local;
pub mod overlay;
pub mod profile;
Expand Down
234 changes: 234 additions & 0 deletions bots/rhodibot/src/canon/a2ml.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
// SPDX-License-Identifier: MPL-2.0

//! Any `.a2ml` file is a priority-1 finding.
//!
//! A2ML is retired (owner rulings D99, D269c, D312, D313): no `.a2ml` file
//! should exist anywhere in a repository. Rhodibot used to *expect* some of
//! them; now every tracked `*.a2ml` is reported as [`Severity::Retired`], the
//! worst a canon report holds, one finding per file so a grid can place each
//! one against a change.
//!
//! Each finding names the form the file's facts belong in, from the standards
//! mapping specs (`metadatastician/standards` `1-formats/deed/mappings/`), and
//! says how it gets there: conversion is kyX's front end (D313), never a hand
//! conversion, and a family with no mapping spec waits for one. Rhodibot only
//! reports; the fleet's `fix-a2ml-via-kyx.sh` is what tries the conversion.
//!
//! This is the report, not the read path: the legacy read fallback in
//! [`super::overlay`] (a legacy file read as "migrate" when its deed form is
//! absent) is unchanged.

use super::report::Finding;
use super::verdict::Severity;

/// The finding id. Not a canon criterion: a rhodibot rule on top of it.
pub const NO_A2ML_ID: &str = "rhodibot.no-a2ml";

/// Where one A2ML family's facts go, and whether kyX can take them there.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Destination {
/// The deed form, as a report names it.
pub form: &'static str,
/// The mapping spec that decides it, or `None` when there is none yet.
pub spec: Option<&'static str>,
/// Whether kyX has a front end for the family today.
pub kyx: bool,
}

/// The family a path belongs to, by its file name (and, for bot directives and
/// contractiles, its directory).
pub fn destination(path: &str) -> Destination {
let lower = path.to_ascii_lowercase();
let name = lower.rsplit('/').next().unwrap_or(&lower);
let d = |form, spec, kyx| Destination { form, spec, kyx };
match name {
"ecosystem.a2ml" => d(
".machine_readable/descriptiles/ECOSYSTEM.deed, or the chora (ecosystem ...) clause",
Some("meta-ecosystem-to-repo-deed.adoc"),
true,
),
"meta.a2ml" => d(
".machine_readable/descriptiles/META.deed, or the chora (meta ...) clause",
Some("meta-ecosystem-to-repo-deed.adoc"),
false,
),
"state.a2ml" => d(
".machine_readable/descriptiles/STATE.deed, or the chora (status ...) clause",
Some("state-v1-decision.adoc"),
false,
),
"agentic.a2ml" | "neurosym.a2ml" | "playbook.a2ml" => d(
"the chora (agentic ...) / (neurosym ...) / (playbook ...) clause",
Some("agentic-neurosym-playbook-to-repo-deed.adoc"),
false,
),
"clade.a2ml" => d(
"the chora (identity ...) (clade ...) (forges ...) (lineage ...) clauses",
Some("clade-to-repo-deed.adoc"),
false,
),
"0-ai-manifest.a2ml" => d(
"the chora (manifest ...) clause",
Some("ai-manifest-decision.adoc"),
false,
),
"anchor.a2ml" => d("the chora (anchor ...) clause", None, false),
"rsr-profile.a2ml" => d("the chora (rsr-profile ...) clause", None, false),
"rsr-criteria-v2.a2ml" => d(
"a criteria praxis deed",
Some("rsr-criteria-to-praxis-deed.adoc"),
false,
),
_ if lower.contains("bot_directives/") => {
d("the chora (bot-directives ...) clause", None, false)
}
_ if name.ends_with("file.a2ml") && lower.contains("contractiles/") => d(
"a contractile deed (<Verb>file.deed) attesting its .k9.ncl contract",
None,
false,
),
_ => d("a deed form a mapping spec has yet to decide", None, false),
}
}

/// Whether a tracked path is an A2ML file.
pub fn is_a2ml(path: &str) -> bool {
path.to_ascii_lowercase().ends_with(".a2ml")
Comment thread
hyperpolymath marked this conversation as resolved.
Resolved
}

/// One [`Severity::Retired`] finding per `.a2ml` file, in path order.
pub fn findings(files: &[String]) -> Vec<Finding> {
let mut paths: Vec<&String> = files.iter().filter(|p| is_a2ml(p)).collect();
paths.sort();
paths.dedup();
paths
.into_iter()
.map(|path| {
let dest = destination(path);
let how = match (dest.spec, dest.kyx) {
(Some(spec), true) => format!(
"convert it with kyX under {spec} (D313); a refusal is a P1 issue, never a \
hand conversion"
),
(Some(spec), false) => format!(
"{spec} decides it, but kyX has no front end for it yet: it waits for kyX \
(D313); do not hand-convert"
),
(None, _) => "no mapping spec decides it yet: it waits for one and for kyX \
(D313); do not hand-convert"
.to_string(),
};
Finding {
id: NO_A2ML_ID.to_string(),
name: "A2ML is retired (D99, D269c, D312, D313)".to_string(),
tier: "P1".to_string(),
severity: Severity::Retired,
canon_keeps_it_at: None,
expected: vec![dest.form.to_string()],
found: vec![path.clone()],
deprecated_copies: Vec::new(),
details: vec![format!(
"{path}: retired A2ML; its facts belong in {}; {how}",
dest.form
)],
}
})
.collect()
}

#[cfg(test)]
mod tests {
use super::*;

fn files(paths: &[&str]) -> Vec<String> {
paths.iter().map(|p| p.to_string()).collect()
}

#[test]
fn every_a2ml_is_one_retired_finding_and_nothing_else_is() {
let got = findings(&files(&[
"README.adoc",
".machine_readable/descriptiles/STATE.a2ml",
"0-AI-MANIFEST.a2ml",
"x_chora.deed",
"deep/nested/Thing.A2ML",
".machine_readable/descriptiles/STATE.a2ml",
]));
let paths: Vec<&str> = got.iter().map(|f| f.found[0].as_str()).collect();
assert_eq!(
paths,
[
".machine_readable/descriptiles/STATE.a2ml",
"0-AI-MANIFEST.a2ml",
"deep/nested/Thing.A2ML"
]
);
for f in &got {
assert_eq!(f.severity, Severity::Retired);
assert_eq!(f.id, NO_A2ML_ID);
assert_eq!(f.tier, "P1");
// Never asks for an .a2ml, never suggests a hand conversion.
assert!(f.expected.iter().all(|e| !e.ends_with(".a2ml")), "{f:?}");
assert!(f.details[0].contains("D313"), "{f:?}");
}
}

#[test]
fn only_ecosystem_is_routed_to_kyx_today() {
assert!(destination(".machine_readable/descriptiles/ECOSYSTEM.a2ml").kyx);
assert!(destination(".machine_readable/6a2/ECOSYSTEM.a2ml").kyx);
for path in [
"STATE.a2ml",
"META.a2ml",
"AGENTIC.a2ml",
"CLADE.a2ml",
"0-AI-MANIFEST.a2ml",
".machine_readable/bot_directives/coverage.a2ml",
"contractiles/must/Mustfile.a2ml",
"audits/assail-classifications.a2ml",
] {
assert!(!destination(path).kyx, "{path}");
}
}

#[test]
fn families_name_their_deed_form() {
assert!(
destination("x/bot_directives/debt.a2ml")
.form
.contains("(bot-directives")
);
assert!(
destination("contractiles/trust/Trustfile.a2ml")
.form
.contains("contractile deed")
);
assert!(destination("STATE.a2ml").form.contains("STATE.deed"));
assert_eq!(destination("odd.a2ml").spec, None);
// A name ending in "file" outside a contractiles directory is not a
// contractile: it waits for a mapping spec like any other stray file.
for stray in ["docs/profile.a2ml", "data/myfile.a2ml"] {
assert!(
destination(stray).form.contains("yet to decide"),
"{stray}: {}",
destination(stray).form
);
}
}

#[test]
fn a_finding_says_ecosystem_goes_through_kyx_and_others_wait() {
let got = findings(&files(&["ECOSYSTEM.a2ml", "META.a2ml", "odd.a2ml"]));
assert!(
got[0].details[0].contains("convert it with kyX"),
"{:?}",
got[0]
);
assert!(got[1].details[0].contains("waits for kyX"), "{:?}", got[1]);
assert!(
got[2].details[0].contains("no mapping spec"),
"{:?}",
got[2]
);
}
}
39 changes: 33 additions & 6 deletions bots/rhodibot/src/canon/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,22 @@ fn tracked_files(root: &Path) -> Option<Vec<String>> {
.arg("-C")
.arg(root)
.arg("ls-files")
.arg("-z")
.output()
.ok()?;

if !output.status.success() {
return None;
}

let listing = String::from_utf8(output.stdout).ok()?;
let mut files: Vec<String> = listing
.lines()
.map(str::trim)
.filter(|line| !line.is_empty())
.map(str::to_string)
// NUL-separated and raw: without `-z`, git C-quotes an unusual name (a
// newline, a quote, non-ASCII), and a quoted `"x.a2ml"` would slip past a
// suffix test. A name that is not UTF-8 is kept, lossily, rather than lost.
let mut files: Vec<String> = output
.stdout
.split(|b| *b == 0)
.filter(|name| !name.is_empty())
.map(|name| String::from_utf8_lossy(name).into_owned())
.collect();
files.sort();
files.dedup();
Expand Down Expand Up @@ -229,6 +232,30 @@ mod tests {
);
}

#[test]
fn git_listing_keeps_unusual_names_raw() {
// Without `ls-files -z`, git C-quotes a name with a newline in it and
// the quoted form no longer ends in `.a2ml`.
let scratch = Scratch::new("ls-files-z");
scratch.write("evil\nname.a2ml", "x");
scratch.write("plain.adoc", "x");
let git = |args: &[&str]| {
let ok = Command::new("git")
.arg("-C")
.arg(scratch.path())
.args(args)
.output()
.map(|o| o.status.success())
.unwrap_or(false);
assert!(ok, "git {args:?}");
};
git(&["init", "-q"]);
git(&["add", "-A"]);
let files = tracked_files(scratch.path()).expect("git can list the index");
assert!(files.contains(&"evil\nname.a2ml".to_string()), "{files:?}");
assert!(files.contains(&"plain.adoc".to_string()), "{files:?}");
}

#[test]
fn a_profile_is_read_from_either_allowed_path() {
let estate = Scratch::new("profile-estate");
Expand Down
Loading
Loading