Files
Dicklesworthstone 357cd1776d fix(merge): restore the post-v0.6.23 main line clobbered by stale-clone merges
The merge series 9fe26cc5 -> 63533a35 -> 47332ca5 integrated a June-26-era
stale working line (56020f59..71938040, the v0.6.12 line) into main and
resolved conflicts by keeping the stale blobs wholesale. That silently
reverted ~2 months of released work on 86 files, including:

- Cargo.toml/package identity regressed 0.6.23 -> 0.6.12, asupersync pin
  regressed =0.3.9 -> =0.3.4, and the dependency graph no longer resolved
  (cargo could not select a version for asupersync) — main was unbuildable.
- src/lib.rs lost ~38 module declarations and the entire post-v0.6.23
  triage wave, including the GH #353 forever-defer fix (aa03fd06), the
  GH #374 doctor/authority fixes (7327191f, 56bf1a01, 43ab9235), the
  GH #364 false-OOM quarantine fix (ef7e2595), and the GH #368 series.
- src/indexer/mod.rs lost the quarantine_retry module wiring.
- Golden robot fixtures, doctor/health schemas, and install scripts
  regressed to their June shapes.

This commit restores all 86 clobbered paths to their state at 8e308ea3
(the last good main commit, v0.6.23 lineage), with three exceptions kept
from the merged side: .beads/cli-robot-enhancements.md (new note),
tests/e2e_resilience_scenario_runner.rs (new suite), and
.beads/issues.jsonl (merged as a union by bead id, newer updated_at wins,
preserving the local kupq4 bead alongside the remote gh-wave beads).

Additional repairs required to make --all-targets compile again:

- tests/connector_{aider,amp,antigravity,claude,cline,codex,gemini,
  opencode,pi_agent}.rs, tests/{fs_errors,logging,parse_errors}.rs: add
  `progress_tick: None` to every franken_agent_detection ScanContext
  struct literal. The restored FAD pin (dd2c694, 0.1.10) added the
  cass#373 progress_tick field, and these suites still used the
  three-field literal — `cargo check --tests` was red on main even
  before the bad merges (independently reported in PR #376).
- tests/e2e_resilience_scenario_runner.rs: temporarily disabled via
  `#![cfg(any())]` with an explanatory header. It was authored against
  the e2e_runner artifact APIs from f6cd6376, which are not on the
  restored line yet.

NOT restored (needs deliberate re-landing, tracked in beads): the genuine
feature work from f6cd6376 (CLI wall-clock budgets --timeout/budget_ms/
per_host_budget_ms, robot budget envelopes, search refresh-order rework,
encrypt metadata taxonomy tests). Its diff remains intact in history at
f6cd6376 and must be rebased onto this repaired line rather than merged
blob-wise.

Verification: cargo check --all-targets exits 0 (previously failed at
dependency resolution); version string back at 0.6.23 matching the
latest release tag.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-04 08:45:18 -04:00

88 lines
3.7 KiB
Rust

//! Golden coverage for the `pack` command's error envelopes (gauntlet F7-3).
//!
//! `pack` (the deterministic answer-pack builder for agent handoffs) previously
//! had zero golden coverage despite being a high-traffic agent-facing surface.
//! These freeze the two deterministic, corpus-independent error contracts so
//! agent error-handling branches that key on `{code, kind, message, hint,
//! retryable}` can't silently drift:
//!
//! - empty query (`pack ""`) -> code 2, `pack-empty-query` (usage)
//! - missing index (empty data dir) -> code 3, `missing-index` (retryable)
//!
//! Goldens live at `tests/golden/robot/pack_*.json.golden`. Error envelopes are
//! emitted on stderr (stdout stays data-only). This lives in its own test
//! binary (not `golden_robot_json.rs`) to keep the file small and lint-clean.
//!
//! Regenerate:
//! UPDATE_GOLDENS=1 rch exec -- env CARGO_TARGET_DIR=/data/tmp/cass-golden-target \
//! cargo test --test golden_robot_pack
//! git diff tests/golden/ # review, then commit
use std::path::{Path, PathBuf};
use assert_cmd::Command;
/// Run `cass <args> --data-dir <data_dir>`, parse the stderr error envelope,
/// pretty-print it, and scrub the (volatile) data-dir path to `[TEST_HOME]` so
/// the golden is host-independent. This matches the scrubbing the shared
/// `golden_robot_json` harness applies to the same envelopes.
fn pack_error_envelope(data_dir: &Path, args: &[&str]) -> String {
let dir = data_dir.to_str().expect("utf8 data dir path");
let output = Command::cargo_bin("cass")
.expect("cass binary builds")
.env("CODING_AGENT_SEARCH_NO_UPDATE_PROMPT", "1")
.args(args)
.args(["--data-dir", dir])
.output()
.expect("run cass pack");
let stderr = String::from_utf8(output.stderr).expect("utf8 stderr");
let parsed: serde_json::Value =
serde_json::from_str(stderr.trim()).expect("pack error envelope is JSON on stderr");
let pretty = serde_json::to_string_pretty(&parsed).expect("pretty-print JSON");
pretty.replace(dir, "[TEST_HOME]")
}
/// Compare `actual` against `tests/golden/<name>`; overwrite when
/// `UPDATE_GOLDENS=1` is set (mirrors the shared harness helper).
fn assert_golden(name: &str, actual: &str) {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests")
.join("golden")
.join(name);
if std::env::var("UPDATE_GOLDENS").is_ok() {
std::fs::create_dir_all(path.parent().unwrap()).expect("create golden dir");
std::fs::write(&path, actual).expect("write golden");
return;
}
// A missing golden falls through to an empty `expected`, so the assert_eq
// below fails loudly with an actionable message. Using assert_eq rather
// than a bare `panic!` keeps this file critical-clean under `ubs --ci`.
let expected = std::fs::read_to_string(&path).unwrap_or_default();
assert_eq!(
actual,
expected,
"GOLDEN MISMATCH or MISSING for {name} at {} — if this change is \
intentional (or the golden is new), regenerate with UPDATE_GOLDENS=1 and review the diff.",
path.display()
);
}
#[test]
fn pack_empty_query_error_envelope_matches_golden() {
let dir = tempfile::tempdir().expect("temp dir");
let actual = pack_error_envelope(dir.path(), &["pack", "", "--json"]);
assert_golden("robot/pack_empty_query.json.golden", &actual);
}
#[test]
fn pack_missing_index_error_envelope_matches_golden() {
let dir = tempfile::tempdir().expect("temp dir");
let actual = pack_error_envelope(
dir.path(),
&["pack", "checkout failure root cause", "--json"],
);
assert_golden("robot/pack_missing_index.json.golden", &actual);
}