Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
b64bcba
feat(agent-reply-validator): [#2904] parse the names of agent reply f…
josecelano-bot Nov 18, 2026
a724ec3
feat(agent-reply-validator): [#2904] read the content of agent reply …
josecelano-bot Nov 18, 2026
6416dca
feat(agent-reply-validator): [#2904] check the location, name and con…
josecelano-bot Nov 18, 2026
4e68a58
feat(agent-reply-validator): [#2904] add the agent-reply-validator co…
josecelano-bot Nov 18, 2026
ecf7bb3
feat(agent-reply-validator): [#2904] generate the agent-reply-v1 JSON…
josecelano-bot Nov 18, 2026
4ce05ce
ci(agent-reply-validator): [#2904] check agent reply files in the pre…
josecelano-bot Nov 18, 2026
d4b086d
docs(agent-reply-validator): [#2904] document the agent reply schema …
josecelano-bot Nov 18, 2026
c0e3fab
docs(index): [#2904] say the schemas page covers the agent reply sche…
josecelano-bot Nov 18, 2026
286a5cb
docs(issues): [#2904] mark task T3 done and record its independent re…
josecelano-bot Nov 18, 2026
f196339
docs(agent-reply-validator): [#2904] say that the command has no --ve…
josecelano-bot Nov 18, 2026
348f438
test(agent-reply-validator): [#2904] say the pattern tests use the Ru…
josecelano-bot Nov 18, 2026
5545a03
docs(pr-reviews): [#2904] record round 1 in the review audit of PR #2952
josecelano-bot Nov 18, 2026
9c3dce7
fix(agent-reply-validator): [#2904] read verdicts and severities from…
josecelano-bot Nov 18, 2026
e3760b4
fix(agent-reply-validator): [#2904] reject a reply file staged as a s…
josecelano-bot Nov 18, 2026
6dedbd8
docs(pr-reviews): [#2904] record round 2 in the review audit of PR #2952
josecelano-bot Nov 18, 2026
09d2544
docs(pr-reviews): [#2904] record round 3 in the review audit of PR #2952
josecelano-bot Nov 19, 2026
ed09f5c
docs(schemas): [#2904] say in which direction the reply validator dif…
josecelano-bot Nov 19, 2026
39df36a
test(agent-reply-validator): [#2904] name the 32-bit limit of a subje…
josecelano-bot Nov 19, 2026
51eb2bc
test(agent-reply-validator): [#2904] observe a write of the schema bi…
josecelano-bot Nov 19, 2026
2feb9ad
docs(pr-reviews): [#2904] record round 4 in the review audit of PR #2952
josecelano-bot Nov 19, 2026
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
16 changes: 10 additions & 6 deletions .claude/skills/run-pre-commit-checks/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,16 @@ The script runs these steps in order:
5. `cargo run --quiet --package frontmatter-validator --bin frontmatter-validator -- --skill-descriptions` -
check of each skill's `description` in the index: whole as YAML reads it (not cut by a `#`
comment) and 200 characters or less. See the `add-new-skill` skill's description rules.
6. `cargo machete --with-metadata` - unused dependency check
7. `cargo deny check bans` - workspace layer-boundary dependency check
8. `cargo +nightly fmt --all -- --check` - nightly Rust formatting check
9. `linter all` - all linters (markdown, lychee local links, YAML, TOML, clippy, rustfmt, shellcheck, cspell)
10. `./contrib/dev-tools/checks/lint-containerfile.sh` - hadolint check of the `Containerfile`
11. `cargo test --doc --workspace` - documentation tests
6. `cargo run --quiet --package agent-reply-validator --bin agent-reply-validator -- --all` -
check of the staged content of every agent reply file in the index: every file in an
`agent-replies/` folder or named like a reply file. See the `agent-reply-v1` schema in
`docs/schemas/README.md`.
7. `cargo machete --with-metadata` - unused dependency check
8. `cargo deny check bans` - workspace layer-boundary dependency check
9. `cargo +nightly fmt --all -- --check` - nightly Rust formatting check
10. `linter all` - all linters (markdown, lychee local links, YAML, TOML, clippy, rustfmt, shellcheck, cspell)
11. `./contrib/dev-tools/checks/lint-containerfile.sh` - hadolint check of the `Containerfile`
12. `cargo test --doc --workspace` - documentation tests

If the formatter changes the dictionary, the hook exits non-zero before the verification steps.
Stage `project-words.txt` and retry the commit. Run the formatter independently with:
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
# never compiled into container test archives. Remove each entry when the crate
# leaves the tracker workspace (EPIC #2003 harness-workspace sub-issue).
!/contrib/dev-tools/analysis/workspace-coupling/
!/contrib/dev-tools/checks/agent-reply-validator/
!/contrib/dev-tools/checks/agent-review-report-contract/
!/contrib/dev-tools/checks/ci-gate/
!/contrib/dev-tools/checks/clippy-allow-reasons/
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/docs-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,11 @@ jobs:
- id: skill-descriptions
name: Check Agent Skill Descriptions
run: cargo run --quiet --package frontmatter-validator --bin frontmatter-validator -- --skill-descriptions

# issue: #2904
# Agents write one JSON reply file per reply in `agent-replies/` of an issue specification
# (D18). The check validates every such file: its place, its name, its content against the
# `agent-reply-v1` schema, and that the name agrees with the content.
- id: agent-replies
name: Check Agent Reply Files
run: cargo run --quiet --package agent-reply-validator --bin agent-reply-validator -- --all
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ members = [
".claude/skills/wait-for-pr-review/tool",
"console/tracker-client",
"contrib/dev-tools/analysis/workspace-coupling",
"contrib/dev-tools/checks/agent-reply-validator",
"contrib/dev-tools/checks/agent-review-report-contract",
"contrib/dev-tools/checks/ci-gate",
"contrib/dev-tools/checks/clippy-allow-reasons",
Expand Down
28 changes: 28 additions & 0 deletions contrib/dev-tools/checks/agent-reply-validator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
description = "Validates the JSON reply files that AI agents write in agent-replies/ folders."
name = "agent-reply-validator"
publish = false

authors.workspace = true
edition.workspace = true
rust-version.workspace = true
version = "0.1.0"

[lints]
workspace = true

[dependencies]
# No color or suggestion features: every clap message is rendered into an NDJSON record.
clap = { version = "4.6.8", default-features = false, features = [ "derive", "error-context", "help", "std", "usage" ] }
schemars = "1.2.3"
serde = { version = "1", features = [ "derive" ] }
# Keep field order: the NDJSON key order is part of the output contract.
serde_json = { version = "1", features = [ "preserve_order" ] }
serde_path_to_error = "0.1.20"
thiserror = "2"

[dev-dependencies]
# Checks that the schema patterns accept and reject the same samples as the Rust checks.
regex = "1.13.2"
rstest = "0.28.0"
tempfile = "3"
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//! Writes the `agent-reply-v1` JSON Schema to its tracked path.
//!
//! Run `cargo run --package agent-reply-validator --bin agent-reply-schema`. The file is written
//! in the repository this crate was built from, whatever the working directory. The test
//! `tests/schema.rs` fails when the tracked file differs from the model, so a model change cannot
//! be pushed with a stale schema.
//!
//! Output class `no-stdout-result`: stdout stays empty; one NDJSON record goes to stderr; exit
//! codes are `0` when the file is written, `1` when it cannot be, and `2` for any argument.

use std::io::{self, Write};
use std::path::Path;
use std::process::ExitCode;
use std::{env, fs};

use agent_reply_validator::schema::{ARTIFACT_PATH, reply_schema_json};
use serde_json::json;

fn main() -> ExitCode {
let (record, exit_code) = if env::args_os().len() > 1 {
(
json!({
"kind": "usage_error",
"message": "agent-reply-schema takes no arguments",
"exit_code": 2
}),
2,
)
} else {
let artifact = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../../..").join(ARTIFACT_PATH);
match fs::write(artifact, reply_schema_json()) {
Ok(()) => (json!({ "kind": "written", "path": ARTIFACT_PATH }), 0),
Err(error) => (
json!({
"kind": "runtime_error",
"path": ARTIFACT_PATH,
"message": error.to_string(),
"exit_code": 1
}),
1,
),
}
};
let mut stderr = io::stderr().lock();
match writeln!(stderr, "{record}") {
Ok(()) => ExitCode::from(exit_code),
Err(_) => ExitCode::FAILURE,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//! Read-only access to the repository that contains the working directory.

use std::path::{Path, PathBuf};
use std::process::Command;

/// A git repository, addressed by its top-level directory.
#[derive(Debug)]
pub struct Git {
root: PathBuf,
}

impl Git {
/// Finds the repository that contains `working_directory`.
pub fn discover(working_directory: &Path) -> Result<Self, String> {
let output = run_git(working_directory, &["rev-parse", "--show-toplevel"])?;
let root = String::from_utf8(output).map_err(|error| format!("`git rev-parse` output was not UTF-8: {error}"))?;

Ok(Self {
root: PathBuf::from(root.trim_end_matches('\n')),
})
}

pub fn root(&self) -> &Path {
&self.root
}

/// The entries of the index: each file's mode and its repository-relative path, as git
/// stores them. The path is bytes, because it need not be UTF-8.
pub fn index_entries(&self) -> Result<Vec<IndexEntry>, String> {
let output = run_git(&self.root, &["ls-files", "--stage", "-z"])?;
output
.split(|byte| *byte == 0)
.filter(|entry| !entry.is_empty())
.map(IndexEntry::parse)
.collect()
}

/// The content of a repository-relative path in the index.
pub fn index_content(&self, path: &str) -> Result<Vec<u8>, String> {
run_git(&self.root, &["show", &format!(":0:{path}")])
}
}

/// One entry of `git ls-files --stage -z`: `<mode> <object> <stage>\t<path>`.
#[derive(Debug)]
pub struct IndexEntry {
pub mode: String,
pub path: Vec<u8>,
}

impl IndexEntry {
/// The mode git gives a symbolic link.
const SYMBOLIC_LINK_MODE: &'static str = "120000";

fn parse(entry: &[u8]) -> Result<Self, String> {
let tab = entry
.iter()
.position(|byte| *byte == b'\t')
.ok_or_else(|| "`git ls-files --stage` printed an entry without a tab".to_owned())?;
let (fields, path) = (&entry[..tab], &entry[tab + 1..]);
let mode = fields
.split(|byte| *byte == b' ')
.next()
.and_then(|mode| std::str::from_utf8(mode).ok())
.ok_or_else(|| "`git ls-files --stage` printed an entry without a mode".to_owned())?;
Ok(Self {
mode: mode.to_owned(),
path: path.to_vec(),
})
}

pub fn is_symbolic_link(&self) -> bool {
self.mode == Self::SYMBOLIC_LINK_MODE
}
}

/// Variables that can redirect a Git subprocess to a different repository.
///
/// `GIT_INDEX_FILE` is kept: a pre-commit hook receives it for the index `commit --all`/`--only` prepared.
const GIT_REPOSITORY_REDIRECT_ENVIRONMENT: &[&str] = &[
"GIT_DIR",
"GIT_WORK_TREE",
"GIT_OBJECT_DIRECTORY",
"GIT_ALTERNATE_OBJECT_DIRECTORIES",
"GIT_COMMON_DIR",
];

/// `--no-optional-locks` keeps read commands from refreshing the index; `--literal-pathspecs` keeps
/// names from being expanded as globs.
fn run_git(directory: &Path, arguments: &[&str]) -> Result<Vec<u8>, String> {
let mut command = Command::new("git");
command.args(["--no-optional-locks", "--literal-pathspecs"]);
command.args(arguments);
command.current_dir(directory);
for variable in GIT_REPOSITORY_REDIRECT_ENVIRONMENT {
command.env_remove(variable);
}
let output = command.output().map_err(|error| format!("could not run `git`: {error}"))?;

if output.status.success() {
Ok(output.stdout)
} else {
Err(format!(
"`git {}` failed: {}",
arguments.join(" "),
String::from_utf8_lossy(&output.stderr).trim()
))
}
}
Loading
Loading