Validate memory consolidation artifacts before succeeding (#32193)

## Why

A completed Phase 2 agent run does not guarantee that its required outputs were
created correctly. Treating a clean workspace as success can also preserve a
state where those outputs are missing.

## What changed

- Require `MEMORY.md` to be a file and `memory_summary.md` to start with `v1`
  before marking consolidation successful.
- Fail completed runs with invalid artifacts without resetting the workspace
  baseline, allowing the job to be retried.
- Run consolidation for a clean workspace when its required artifacts are
  invalid instead of taking the no-change success path.

## Testing

Added coverage for rejecting an invalid summary and retrying a clean workspace
whose consolidation artifacts are missing.

GitOrigin-RevId: ac57b2ba9d062c5203ca51afd716795a91814bb3
This commit is contained in:
jif authored and copyberry committed 2026-07-10 15:40:35 +00:00
1 parent 6138909d6e
commit 52c9605dc7
4 files changed
+153 -6

No files matched your search

@@ -76,3 +76,18 @@ fn previous_char_boundary_handles_multibyte_text() {
let text = "aé";
assert_eq!(previous_char_boundary(text, /*max_bytes*/ 2), 1);
}
#[tokio::test]
async fn validate_consolidation_artifacts_rejects_invalid_summary() {
let home = TempDir::new().expect("tempdir");
let root = home.path().join("memories");
fs::create_dir_all(&root).expect("create memory root");
fs::write(root.join("MEMORY.md"), "memory").expect("write memory");
fs::write(root.join("memory_summary.md"), "outdated\n").expect("write summary");
let err = validate_consolidation_artifacts(&root)
.await
.expect_err("invalid summary should fail validation");
assert!(err.to_string().contains("does not start with v1"));
}