返回 CodeWhale
session_export_surface_tests.rs
根目录 / crates / tui / src / commands / session_export_surface_tests.rs
1 //! FEAT-025 Phase 5: public command-surface parity coverage for `/export`.
2 //!
3 //! Phase 4 proved handler/rendering/adapter parity with fake facets and
4 //! relocated host regressions. This module proves the *observable command
5 //! surface* did not move when registration crossed the portable bridge:
6 //!
7 //! * registry metadata (name, alias, usage) and registry position,
8 //! * the `description_key` -> catalog bridge and its English/localized text,
9 //! * palette and slash-completion discovery, including the `/daochu` alias,
10 //! * least authority: exactly `SESSION_EXPORT` and no presentation facet,
11 //! * canonical-name/alias dispatch equivalence through the public `execute`
12 //! seam, with exact receipts and exact visible errors.
13 //!
14 //! Like the Phase 3 host regressions, this file deliberately lives at the
15 //! `commands` root — outside `groups/session`, which FEAT-043 moves into
16 //! `codewhale-commands`. No real terminal clipboard, GUI, or device is needed:
17 //! the harness uses the deterministic in-process clipboard and temporary
18 //! filesystem fixtures.
19
20 use tempfile::TempDir;
21
22 use codewhale_command_contract::handler::{CommandCapabilities, CommandHandler};
23
24 use crate::commands::session_export_test_support::{
25 assert_only_export_facet_exposed, normalize_export_time,
26 };
27 use crate::commands::{CommandResult, execute};
28 use crate::test_support::{EnvVarGuard, TestEnvLock};
29 use crate::tui::app::{App, TuiOptions};
30 use crate::tui::clipboard::ClipboardHandler;
31 use crate::tui::command_palette;
32 use codewhale_command_contract::CommandDiscovery;
33 use codewhale_config::ProviderKind;
34 use codewhale_localization::Locale;
35 use codewhale_models::{ContentBlock, Message, Role};
36 use codewhale_runtime::config::Config;
37
38 const EXPORT_NAME: &str = "export";
39 const EXPORT_ALIAS: &str = "daochu";
40 const EXPORT_USAGE: &str = "/export [clipboard|file [path]|turn [clipboard|file [path]]] [--format md|html|json] [--no-tools] [--force]";
41 // Pinned to the authoritative catalog values (`crates/localization/locales/{en,fr}.json`,
42 // key `CmdExportDescription`). The `description_key` bridge must keep resolving the
43 // `/export` metadata to this catalog entry; the wording itself is owned by the catalog.
44 const EXPORT_ENGLISH: &str = "Copy a safe export, or write it to a file";
45 const EXPORT_FRENCH: &str =
46 "Copier un export sûr de la conversation, ou l'écrire dans un fichier explicite";
47
48 /// Shared host-isolated harness (same isolation order as the Phase 3
49 /// `ExportHarness`: env guards, then the lock, then the temporary directory).
50 struct SurfaceHarness {
51 app: App,
52 _home: EnvVarGuard,
53 _codewhale_home: EnvVarGuard,
54 _env_lock: TestEnvLock,
55 temp: TempDir,
56 }
57
58 impl SurfaceHarness {
59 fn new() -> Self {
60 let env_lock = crate::test_support::lock_test_env();
61 let temp = TempDir::new().expect("tempdir");
62 let home = temp.path().join("home");
63 std::fs::create_dir_all(&home).expect("home dir");
64 let _home = EnvVarGuard::set("HOME", &home);
65 let _codewhale_home = EnvVarGuard::set("CODEWHALE_HOME", &home);
66 let options = TuiOptions {
67 skills_dir: temp.path().join("skills"),
68 memory_path: temp.path().join("memory.md"),
69 mcp_config_path: temp.path().join("mcp.json"),
70 ..crate::tui::test_support::test_tui_options(temp.path())
71 };
72 let app = App::new(options, &Config::default());
73 Self {
74 app,
75 _home,
76 _codewhale_home,
77 _env_lock: env_lock,
78 temp,
79 }
80 }
81
82 fn last_copy_path(&self) -> std::path::PathBuf {
83 self.temp
84 .path()
85 .join("home")
86 .join("exports")
87 .join("last-copy.md")
88 }
89 }
90
91 fn text_message(role: Role, text: &str) -> Message {
92 Message {
93 role,
94 content: vec![ContentBlock::Text {
95 text: text.to_string(),
96 cache_control: None,
97 }],
98 }
99 }
100
101 fn export_info() -> &'static crate::commands::CommandInfo {
102 crate::commands::get_command_info(EXPORT_NAME).expect("/export must be registered")
103 }
104
105 fn result_message(result: &CommandResult) -> &str {
106 result.message.as_deref().unwrap_or_default()
107 }
108
109 #[test]
110 fn export_registration_metadata_and_registry_position_are_unchanged() {
111 let info = export_info();
112 assert_eq!(info.name, EXPORT_NAME);
113 assert_eq!(info.aliases, &[EXPORT_ALIAS]);
114 assert_eq!(info.usage, EXPORT_USAGE);
115
116 // The alias resolves to the same registry entry and canonical metadata.
117 let registry = crate::commands::registry();
118 let via_alias = registry
119 .get(EXPORT_ALIAS)
120 .expect("/daochu must resolve to the export entry");
121 assert_eq!(via_alias.info().name, EXPORT_NAME);
122 assert_eq!(via_alias.info().usage, EXPORT_USAGE);
123 assert!(
124 registry.get(EXPORT_NAME).is_some(),
125 "canonical /export must remain registered"
126 );
127
128 // Registry order is preserved: remote-env -> export -> structcopy.
129 let names: Vec<&str> = crate::commands::command_infos()
130 .iter()
131 .map(|info| info.name)
132 .collect();
133 let position = |name: &str| {
134 names
135 .iter()
136 .position(|candidate| *candidate == name)
137 .unwrap_or_else(|| panic!("{name} must be registered; found {names:?}"))
138 };
139 assert!(
140 position("remote-env") < position(EXPORT_NAME),
141 "export must stay after remote-env in the session group order"
142 );
143 assert!(
144 position(EXPORT_NAME) < position("structcopy"),
145 "export must stay before structcopy in the session group order"
146 );
147 }
148
149 #[test]
150 fn export_declares_exactly_session_export_without_presentation_authority() {
151 let command = crate::commands::registry()
152 .get(EXPORT_NAME)
153 .expect("/export must be registered");
154 let handler = command
155 .contextual_handler()
156 .expect("/export must register through the portable bridge");
157 let CommandHandler::Contextual { capabilities, .. } = handler else {
158 panic!("/export must be a contextual handler")
159 };
160 assert_eq!(
161 capabilities,
162 CommandCapabilities::SESSION_EXPORT,
163 "/export declares exactly SESSION_EXPORT"
164 );
165 assert!(
166 !capabilities.contains(CommandCapabilities::PRESENTATION),
167 "export must not request presentation authority"
168 );
169
170 // The restricted projection exposes only the declared facet. The helper
171 // destructures all sixteen `ContextParts` slots, so this is exhaustive
172 // rather than a spot-check of the fields listed below by hand.
173 let mut harness = SurfaceHarness::new();
174 let mut bundle = harness.app.command_contexts();
175 let export_only = bundle
176 .contexts(CommandCapabilities::SESSION_EXPORT)
177 .into_parts();
178 assert_only_export_facet_exposed(export_only);
179 }
180
181 #[test]
182 fn export_description_bridge_preserves_english_localized_and_discovery_metadata() {
183 let info = export_info();
184
185 // `description_key` -> `key_to_message_id` -> catalog: English reference
186 // and the shipped French pack both resolve through the same bridge.
187 assert_eq!(&*info.description_for(Locale::En), EXPORT_ENGLISH);
188 assert_eq!(&*info.description_for(Locale::Fr), EXPORT_FRENCH);
189
190 // Palette text keeps the canonical description and advertises the alias.
191 let palette = info.palette_description_for(Locale::En);
192 assert!(
193 palette.contains(EXPORT_ENGLISH),
194 "palette description must keep the catalog text: {palette}"
195 );
196 assert!(
197 palette.contains(EXPORT_ALIAS),
198 "palette description must keep the alias: {palette}"
199 );
200
201 // Discovery classification and visibility are part of the surface.
202 assert_eq!(info.discovery(), CommandDiscovery::Primary);
203 assert!(!info.is_unlisted());
204 assert!(info.show_in_empty_discovery());
205 assert!(info.show_in_slash_completion("/exp"));
206 assert!(info.requires_argument());
207 }
208
209 #[test]
210 fn export_is_discoverable_by_name_and_alias_in_palette_and_slash_completion() {
211 // Pure discovery: a workspace path is all these surfaces need, so this test
212 // avoids the shared environment lock the host fixtures require.
213 let workspace_dir = TempDir::new().expect("tempdir");
214 let workspace = workspace_dir.path();
215 let skills_dir = workspace.join("skills");
216 let mcp_config = workspace.join("mcp.json");
217
218 let entries = command_palette::build_entries(
219 Locale::En,
220 &skills_dir,
221 &Default::default(),
222 workspace,
223 &mcp_config,
224 None,
225 );
226 let export_row = entries
227 .iter()
228 .find(|entry| entry.label == "/export")
229 .expect("/export must appear in the command palette");
230 assert!(
231 export_row.description.contains(EXPORT_ENGLISH),
232 "palette row must carry the catalog description: {}",
233 export_row.description
234 );
235 assert!(
236 export_row.description.contains(EXPORT_ALIAS),
237 "palette row must advertise /daochu: {}",
238 export_row.description
239 );
240
241 let by_prefix = crate::tui::widgets::slash_completion_hints(
242 "/exp",
243 64,
244 &[],
245 Locale::En,
246 Some(workspace),
247 ProviderKind::Deepseek,
248 );
249 assert!(
250 by_prefix.iter().any(|hint| hint.name == "/export"),
251 "/exp must complete to /export"
252 );
253
254 let by_alias = crate::tui::widgets::slash_completion_hints(
255 "/daoc",
256 64,
257 &[],
258 Locale::En,
259 Some(workspace),
260 ProviderKind::Deepseek,
261 );
262 let alias_row = by_alias
263 .iter()
264 .find(|hint| hint.name == "/export")
265 .expect("/daoc must surface the export command");
266 assert_eq!(
267 alias_row.alias_hint.as_deref(),
268 Some(EXPORT_ALIAS),
269 "slash completion must explain the alias match"
270 );
271
272 // The alias token is not a second registry entry.
273 assert!(
274 !entries.iter().any(|entry| entry.label == "/daochu"),
275 "the alias must not create a duplicate palette row"
276 );
277 }
278
279 #[test]
280 fn public_dispatch_canonical_name_and_alias_are_byte_equivalent() {
281 let mut harness = SurfaceHarness::new();
282 let last_copy = harness.last_copy_path();
283 let app = &mut harness.app;
284 app.current_session_id = Some("session-987654321".to_string());
285 app.api_messages = std::sync::Arc::new(vec![
286 text_message(Role::User, "Please export this conversation"),
287 text_message(Role::Assistant, "Exported on request."),
288 ]);
289 app.clipboard = ClipboardHandler::for_test(false, false);
290
291 let canonical = execute("/export clipboard", app);
292 assert!(!canonical.is_error, "{:?}", canonical.message);
293 let canonical_markdown = app
294 .clipboard
295 .last_written_text()
296 .expect("canonical clipboard payload")
297 .to_string();
298 let canonical_recovery = std::fs::read_to_string(&last_copy).expect("canonical recovery copy");
299
300 // Reset the deterministic clipboard so the second dispatch records its own
301 // delivery; state is otherwise identical.
302 app.clipboard = ClipboardHandler::for_test(false, false);
303
304 let alias = execute("/daochu clipboard", app);
305 assert!(!alias.is_error, "{:?}", alias.message);
306 let alias_markdown = app
307 .clipboard
308 .last_written_text()
309 .expect("alias clipboard payload")
310 .to_string();
311 let alias_recovery = std::fs::read_to_string(&last_copy).expect("alias recovery copy");
312
313 assert_eq!(
314 result_message(&canonical),
315 result_message(&alias),
316 "canonical and alias receipts must be identical"
317 );
318 assert_eq!(
319 normalize_export_time(&canonical_markdown),
320 normalize_export_time(&alias_markdown),
321 "canonical and alias clipboard payloads must be identical"
322 );
323 assert_eq!(
324 normalize_export_time(&canonical_recovery),
325 normalize_export_time(&alias_recovery),
326 "canonical and alias recovery copies must be identical"
327 );
328 assert!(canonical_markdown.contains("# Codewhale conversation export"));
329 assert!(canonical_markdown.contains("Please export this conversation"));
330 }
331
332 #[test]
333 fn public_dispatch_file_receipts_and_usage_errors_are_exact() {
334 let mut harness = SurfaceHarness::new();
335 let workspace = harness.temp.path().join("workspace");
336 std::fs::create_dir_all(&workspace).expect("workspace");
337 let app = &mut harness.app;
338 app.workspace = workspace.clone();
339 app.api_messages = std::sync::Arc::new(vec![text_message(Role::User, "file export body")]);
340
341 let resolved = std::fs::canonicalize(&workspace)
342 .expect("canonical workspace")
343 .join("transcript.md");
344
345 let first = execute("/export file transcript.md", app);
346 assert!(!first.is_error, "{:?}", first.message);
347 let lines = std::fs::read_to_string(&resolved)
348 .expect("exported file")
349 .lines()
350 .count();
351 assert_eq!(
352 result_message(&first),
353 format!(
354 "Conversation exported to {} (Markdown, {lines} lines)",
355 resolved.display()
356 )
357 );
358
359 let refused = execute("/export file transcript.md", app);
360 assert!(refused.is_error, "{:?}", refused.message);
361 assert_eq!(
362 result_message(&refused),
363 format!(
364 "Error: Failed to export Conversation to {}: destination already exists: {}. Re-run with `/export file --force <path>` to replace it",
365 resolved.display(),
366 resolved.display()
367 )
368 );
369
370 let forced = execute("/export file --force transcript.md", app);
371 assert!(!forced.is_error, "{:?}", forced.message);
372 assert_eq!(
373 result_message(&forced),
374 format!(
375 "Conversation exported to {} (Markdown, {lines} lines) (overwrite explicitly allowed)",
376 resolved.display()
377 )
378 );
379
380 let usage = export_info().usage;
381 let arg = "clipboard extra.md";
382 let reason = "clipboard does not accept a path";
383 let result = execute(&format!("/export {arg}"), app);
384 assert!(result.is_error, "{arg} must be rejected");
385 assert_eq!(
386 result_message(&result),
387 format!("Error: {reason}. Usage: {usage}"),
388 "{arg} must keep the baseline usage error"
389 );
390 }
391
392 // ---------------------------------------------------------------------------
393 // FEAT-025 Phase 7 (Task 7.2): extraction-readiness and scope audits.
394 //
395 // These audits protect the D4/D5/D8/D9 ownership contract that the portable
396 // source must satisfy before FEAT-043 can physically move the export slice into
397 // `codewhale-commands`. They are source-level checks, not runtime behavior
398 // tests, and they live at the `commands` root outside the movable group.
399 // ---------------------------------------------------------------------------
400
401 /// Production portion of the portable export source: everything before its
402 /// `#[cfg(test)]` module, with comments removed (full-line and trailing) so
403 /// rationale text (`Concrete `App`, clipboard, filesystem, ...`) is never
404 /// mistaken for an import or a concrete host symbol.
405 fn portable_production_source(source: &str) -> String {
406 let mut production = String::new();
407 for line in source.lines() {
408 if line.trim_start().starts_with("#[cfg(test)]") {
409 break;
410 }
411 let code = strip_line_comment(line);
412 if code.trim().is_empty() {
413 continue;
414 }
415 production.push_str(code.trim_end());
416 production.push('\n');
417 }
418 production
419 }
420
421 /// Strip a trailing `//` comment without touching `//` inside a string or
422 /// character literal.
423 ///
424 /// A naive strip would be wrong in both directions: portable code carries URL
425 /// literals such as `https://…`, and a marker string could hide a real token.
426 /// Lifetime ticks (`&'a str`) are not treated as character literals so a
427 /// following comment is still removed.
428 fn strip_line_comment(line: &str) -> &str {
429 let bytes = line.as_bytes();
430 let mut i = 0;
431 while i < bytes.len() {
432 match bytes[i] {
433 b'"' => {
434 i += 1;
435 while i < bytes.len() {
436 match bytes[i] {
437 b'\\' => i += 2,
438 b'"' => break,
439 _ => i += 1,
440 }
441 }
442 }
443 b'\'' => {
444 let opens_literal = matches!(
445 (bytes.get(i + 1), bytes.get(i + 2)),
446 (Some(b'\\'), _) | (Some(_), Some(b'\''))
447 );
448 if opens_literal {
449 i += 1;
450 while i < bytes.len() {
451 match bytes[i] {
452 b'\\' => i += 2,
453 b'\'' => break,
454 _ => i += 1,
455 }
456 }
457 }
458 }
459 b'/' if bytes.get(i + 1) == Some(&b'/') => return &line[..i],
460 _ => {}
461 }
462 i += 1;
463 }
464 line
465 }
466
467 /// Word-boundary identifier match.
468 ///
469 /// `production.contains("App")` fires on a legitimate `Append`, while an exact
470 /// equality check would miss `App::new`. `\b` matches the identifier token
471 /// only, so the audit fails for the right reason.
472 fn contains_identifier(haystack: &str, identifier: &str) -> bool {
473 let pattern = format!(r"\b{}\b", regex::escape(identifier));
474 regex::Regex::new(&pattern)
475 .expect("identifier regex")
476 .is_match(haystack)
477 }
478
479 /// The audits above are only as trustworthy as their scanners, so pin the two
480 /// behaviours that decide whether a finding is real: comment stripping must not
481 /// eat string literals, and identifier matching must not fire on a longer word.
482 #[test]
483 fn portable_source_audit_helpers_are_token_aware() {
484 assert_eq!(strip_line_comment("let x = 1; // App"), "let x = 1; ");
485 assert_eq!(strip_line_comment("// whole line"), "");
486 assert_eq!(
487 strip_line_comment("let url = \"https://example.test/a\";"),
488 "let url = \"https://example.test/a\";"
489 );
490 assert_eq!(
491 strip_line_comment("let c = '/'; let y = 1; // keep"),
492 "let c = '/'; let y = 1; "
493 );
494 // A lifetime tick must not swallow the rest of the line.
495 assert_eq!(
496 strip_line_comment("fn f<'a>(x: &'a str) {} // note"),
497 "fn f<'a>(x: &'a str) {} "
498 );
499
500 assert!(contains_identifier("let app = App::new();", "App"));
501 assert!(!contains_identifier("values.append(item);", "App"));
502 assert!(!contains_identifier("struct AppNew;", "App"));
503 assert!(contains_identifier("use ratatui::text::Line;", "ratatui"));
504 assert!(contains_identifier("unsafe { x }", "unsafe"));
505 }
506
507 #[test]
508 fn portable_export_source_has_no_host_dependency() {
509 let source = include_str!("groups/session/export.rs");
510 let production = portable_production_source(source);
511
512 // Only the external contract, the pure sanitizer, `serde_json`, `std`, and
513 // the shared session `CommandResult` may be imported.
514 let allowed_use_prefixes = [
515 "use std::",
516 "use codewhale_command_contract",
517 "use codewhale_sanitize",
518 "use serde_json",
519 "use super::CommandResult",
520 ];
521 for line in production.lines() {
522 let trimmed = line.trim_start();
523 if !trimmed.starts_with("use ") {
524 continue;
525 }
526 assert!(
527 allowed_use_prefixes
528 .iter()
529 .any(|prefix| trimmed.starts_with(prefix)),
530 "portable /export import is not allowed: {trimmed}"
531 );
532 }
533
534 // No concrete host module or type may appear in portable production code.
535 // Syntactic tokens are matched literally; bare identifiers are matched on
536 // word boundaries so `Append` cannot false-trigger on `App`.
537 for token in [
538 "use crate::",
539 "crate::tui",
540 "codewhale_engine::client",
541 "codewhale_runtime::config",
542 "codewhale_snapshot",
543 "codewhale_engine::session_manager",
544 "std::fs",
545 "std::net",
546 "std::process",
547 ] {
548 assert!(
549 !production.contains(token),
550 "portable /export must not reference {token}"
551 );
552 }
553 for identifier in [
554 "App",
555 "AppAction",
556 "ClipboardHandler",
557 "SnapshotRepo",
558 "SessionManager",
559 "HistoryCell",
560 "ContentBlock",
561 "OpenOptions",
562 "ratatui",
563 "crossterm",
564 ] {
565 assert!(
566 !contains_identifier(&production, identifier),
567 "portable /export must not reference {identifier}"
568 );
569 }
570
571 // The group result is shared; no concrete host type may cross the boundary.
572 assert!(
573 !production.contains("super::App"),
574 "portable export must not import a host type"
575 );
576 }
577
578 #[test]
579 fn portable_export_source_carries_no_hidden_authority() {
580 let source = include_str!("groups/session/export.rs");
581 let production = portable_production_source(source);
582
583 // Host authority must not hide behind a callback, boxed closure, erased
584 // receipt, or unsafe escape hatch.
585 for token in [
586 "Box<",
587 "dyn Fn",
588 "impl Fn",
589 "fn(&mut dyn",
590 "&mut dyn",
591 "transmute",
592 ] {
593 assert!(
594 !production.contains(token),
595 "portable /export must not contain {token}"
596 );
597 }
598 assert!(
599 !contains_identifier(&production, "unsafe"),
600 "portable /export must not contain unsafe"
601 );
602
603 // Missing authority fails with the exact safe error and never panics: the
604 // facet is destructured, not `.expect()`ed.
605 for token in [".expect(", ".unwrap(", "panic!(", "unreachable!(", "todo!("] {
606 assert!(
607 !production.contains(token),
608 "portable /export must not contain {token}"
609 );
610 }
611 assert!(
612 production.contains(
613 "return CommandResult::error(\"Command capability unavailable: session_export\".to_string());"
614 ),
615 "portable /export must keep the exact safe missing-authority error"
616 );
617 }
618
619 #[test]
620 fn shared_sanitizer_is_one_pure_acyclic_implementation() {
621 // Both portable commands consume the single pure implementation in
622 // codewhale-sanitize, independently of credential storage.
623 let export_source = include_str!("groups/session/export.rs");
624 let structcopy_source = include_str!("groups/session/structcopy.rs");
625 assert!(
626 export_source.contains("use codewhale_sanitize::sanitize::"),
627 "portable /export must consume the shared sanitizer"
628 );
629 assert!(
630 structcopy_source.contains("use codewhale_sanitize::sanitize::"),
631 "/structcopy must consume the same shared sanitizer"
632 );
633 // The module prose must name the new owner: a stale `export::<helper>` seam
634 // reference is exactly the comment drift inherited from PR #5525.
635 for stale in ["export::redact_json", "export::sanitize_text"] {
636 assert!(
637 !structcopy_source.contains(stale),
638 "/structcopy comments must not cite the removed {stale} seam"
639 );
640 }
641
642 // Fast local tripwire only. The authoritative check is the graph scan in
643 // `scripts/check-command-crate-boundaries.py`, which asserts that neither
644 // the contract nor the sanitizer reaches host services; this
645 // manifest read just fails sooner when someone edits the manifest by hand.
646 let sanitizer_manifest = std::fs::read_to_string(concat!(
647 env!("CARGO_MANIFEST_DIR"),
648 "/../sanitize/Cargo.toml"
649 ))
650 .expect("the shared sanitizer crate manifest must be readable");
651 assert!(
652 !sanitizer_manifest.contains("codewhale-tui"),
653 "the shared sanitizer crate must not depend on codewhale-tui"
654 );
655
656 for forbidden in [
657 "codewhale-secrets",
658 "codewhale-core",
659 "keyring",
660 "dbus",
661 "reqwest",
662 ] {
663 assert!(
664 !sanitizer_manifest.contains(forbidden),
665 "pure sanitizer must not import {forbidden}"
666 );
667 }
668
669 // There is no second sanitizer implementation hiding in the portable slice.
670 let production = portable_production_source(export_source);
671 for duplicated in [
672 "fn sanitize_text",
673 "fn redact_json",
674 "fn redact_url_for_display",
675 "fn strip_ansi",
676 ] {
677 assert!(
678 !production.contains(duplicated),
679 "portable /export must not duplicate {duplicated}"
680 );
681 }
682 }
683
684 #[test]
685 fn host_bound_fixtures_stay_outside_the_movable_group() {
686 // FEAT-043 moves `groups/session` into `codewhale-commands`. Real-host
687 // fixtures and the shared recovery writer must therefore stay at the
688 // `commands` root, and the portable slice must not embed host fixtures.
689 let manifest_dir = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
690 for relative in [
691 "src/commands/session_export_regression_tests.rs",
692 "src/commands/session_export_surface_tests.rs",
693 "src/commands/session_export_test_support.rs",
694 "src/commands/session_export_host.rs",
695 ] {
696 assert!(
697 manifest_dir.join(relative).exists(),
698 "host fixture {relative} must stay outside groups/session"
699 );
700 }
701
702 // The baseline-captured export goldens are host-bound (they include the
703 // host-derived metadata and redaction output only the real adapter can
704 // produce), so they must live at the `commands` root with the suites that
705 // consume them rather than inside the movable group.
706 for relative in [
707 "src/commands/fixtures/export_conversation_baseline.md",
708 "src/commands/fixtures/export_turn_baseline.md",
709 "src/commands/fixtures/export_history_fallback_recorded_baseline.md",
710 "src/commands/fixtures/export_correlation_recorded_baseline.md",
711 ] {
712 assert!(
713 manifest_dir.join(relative).exists(),
714 "baseline golden {relative} must stay outside groups/session"
715 );
716 }
717
718 let export_source = include_str!("groups/session/export.rs");
719 for host_fixture in [
720 "SessionExportAdapter",
721 "ExportHarness",
722 "tempfile",
723 "ClipboardHandler",
724 "SnapshotRepo",
725 "HistoryCell",
726 ] {
727 assert!(
728 !export_source.contains(host_fixture),
729 "portable /export must not embed the host fixture {host_fixture}"
730 );
731 }
732 }
733
733 lines RUST