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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ All notable changes to this project are documented here. The format follows
`invalid_document` errors name these roots. Old rubric history stays readable.

### Fixed
- Core reads: one mistyped value in a node text field no longer fails the
whole exploration tree with `ARA100` (0.1.35, plan 24, #130). `evidence:`
keeps a plain scalar's source spelling like every other text field, so an
all-digit commit SHA (`7258910`) or `0123456` stays text. A value the parser
cannot take as text (a bare numeric `evidence:` scalar, or a mapping or list
such as the plain item `- a (rejected: b)`) is read as its exact source text
and warns `ARA230 non-text-tree-field`; reads stay complete and exit 0.
Identity fields stay strict. New fixable format rule `ARA008
unquoted-tree-scalar`: `ara check --fix` single-quotes one-line values.
- Core reads: experiment and heuristic headings accept the separators claims
accept (`## E01 — Title`, `## H03 – Title`, `## E02 - Title`) and a bracketed
status before the separator (`## E02 [in progress]: Title`), which becomes
Expand Down
8 changes: 4 additions & 4 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resolver = "3"
members = ["crates/*"]

[workspace.package]
version = "0.1.34"
version = "0.1.35"
edition = "2024"
license = "MPL-2.0"
repository = "https://github.com/ARA-Labs/ara-cli"
Expand Down
4 changes: 3 additions & 1 deletion crates/ara-cli/tests/agent_reads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,9 @@ fn identity_lookup_does_not_require_a_representable_current_body() {
artifact(dir.path(), "Parent");
std::fs::write(
dir.path().join("trace/exploration_tree.yaml"),
"tree:\n - id: N01\n type: question\n title: Retained identity\n description: {opaque: invalid-shape}\n",
// `isolated` is a boolean, not a text field, so a mapping there still
// fails the tree load; text fields read such values as text (#130).
"tree:\n - id: N01\n type: question\n title: Retained identity\n isolated: {opaque: invalid-shape}\n",
)
.unwrap();
let before = std::fs::read(dir.path().join("trace/exploration_tree.yaml")).unwrap();
Expand Down
80 changes: 80 additions & 0 deletions crates/ara-cli/tests/agent_tree_field_tolerance.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//! #130: one mistyped value in `trace/exploration_tree.yaml` no longer fails
//! the whole tree (`ARA100`). Reads go through and exit 0; a value read as
//! its source text warns `ARA230`.
use assert_cmd::Command;
use serde_json::Value;
use std::path::Path;
use tempfile::TempDir;

fn ara() -> Command {
let mut command = Command::cargo_bin("ara").unwrap();
command.env_remove("ARA_DIR");
command
}
fn tree(node_fields: &str) -> TempDir {
let dir = TempDir::new().unwrap();
let path = dir.path().join("trace/exploration_tree.yaml");
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
let source = format!("tree:\n - id: N01\n type: decision\n title: Q\n{node_fields}");
std::fs::write(path, source).unwrap();
dir
}
/// `show N01 --full --json` stdout; panics with stderr on a refusal.
fn show(root: &Path) -> Value {
let output = ara()
.arg("-C")
.arg(root)
.args(["show", "N01", "--full", "--json"])
.output()
.unwrap();
assert!(
output.status.success(),
"{}",
String::from_utf8_lossy(&output.stderr)
);
serde_json::from_slice(&output.stdout).unwrap()
}
fn decision(shown: &Value) -> &Value {
&shown["entries"][0]["fields"]["decision"]
}

#[test]
fn text_fields_already_keep_scalar_spelling() {
// Guard: plain text fields take a numeric scalar's source spelling.
let dir = tree(" rationale: 1e5\n alternatives: [0x1F, 1.50, true]\n");
let shown = show(dir.path());
assert_eq!(decision(&shown)["rationale"], "1e5");
assert_eq!(
decision(&shown)["alternatives"],
serde_json::json!(["0x1F", "1.50", "true"])
);
}

#[test]
fn all_digit_commit_sha_in_evidence_keeps_its_spelling() {
let dir = tree(" evidence:\n - be13e96\n - 7258910\n - 0123456\n");
let shown = show(dir.path());
let notes = shown["entries"][0]["evidence_notes"].to_string();
for sha in ["be13e96", "7258910", "0123456"] {
assert!(notes.contains(sha), "{sha} missing from {notes}");
}
}

#[test]
fn colon_in_plain_alternative_does_not_fail_the_tree() {
let dir = tree(
" alternatives:\n - Build on Debian 12 like the task images (rejected: its glibc is above the floor).\n - Static linking\n",
);
let shown = show(dir.path());
assert_eq!(
decision(&shown)["alternatives"],
serde_json::json!([
"Build on Debian 12 like the task images (rejected: its glibc is above the floor).",
"Static linking"
])
);
let warning = &shown["diagnostics"]["warnings"][0];
assert_eq!(warning["code"], "ARA230");
assert_eq!(warning["path"], "trace/exploration_tree.yaml:6");
assert!(shown.get("incomplete").is_none(), "{shown}");
}
27 changes: 27 additions & 0 deletions crates/ara-core/src/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ impl Applier {
LintRuleId::ClaimHeaderStyle => {
self.guard_ara004(diag, &base, &cand, new_claims.as_deref())
}
LintRuleId::UnquotedTreeScalar => guard_ara008(&base, &cand),
};
if !accept {
self.fail(diag, guard_rejection_reason(diag.rule, &base, &cand));
Expand Down Expand Up @@ -441,6 +442,23 @@ impl Applier {

/// ARA001 structural guard: both parses must be clean normalized outcomes and
/// the root→tree rewrite must be a semantic no-op.
/// Quoting a recovered value keeps every normalized field: the quoted text is
/// the text the parser already recovered. It adds no error and removes one
/// `ARA230`.
fn guard_ara008(base: &ParseOutcome, cand: &ParseOutcome) -> bool {
let (ParseOutcome::Normalized(mb, rb), ParseOutcome::Normalized(mc, rc)) = (base, cand) else {
return false;
};
let recovered = |report: &crate::ParseReport| {
report
.warnings()
.iter()
.filter(|d| d.code == crate::RuleCode::NonTextTreeField)
.count()
};
errors_subset(cand, base) && mb == mc && recovered(rc) < recovered(rb)
}

fn guard_ara001(base: &ParseOutcome, cand: &ParseOutcome) -> bool {
match (base, cand) {
(ParseOutcome::Normalized(mb, rb), ParseOutcome::Normalized(mc, rc)) => {
Expand Down Expand Up @@ -698,6 +716,9 @@ fn applied_desc(rule: LintRuleId) -> String {
LintRuleId::PivotTriggerAlias => {
"renamed `trigger:` to `reason:` on a pivot node".to_string()
}
LintRuleId::UnquotedTreeScalar => {
"quoted a node text value YAML did not read as a string".to_string()
}
}
}

Expand Down Expand Up @@ -725,6 +746,9 @@ fn guard_rejection_reason(rule: LintRuleId, base: &ParseOutcome, cand: &ParseOut
"claim-header rewrite would introduce a new parse error occurrence; left unchanged"
.to_string()
}
LintRuleId::UnquotedTreeScalar => {
"quoting would introduce a new parse error occurrence; left unchanged".to_string()
}
LintRuleId::RootDialect => guard_reason(rule),
};
}
Expand All @@ -749,6 +773,9 @@ fn guard_reason(rule: LintRuleId) -> String {
"claim-header rewrite would change more than the recovered claim; left unchanged"
.to_string()
}
LintRuleId::UnquotedTreeScalar => {
"quoting would change the parsed manifest; left unchanged".to_string()
}
}
}

Expand Down
Loading
Loading