lean-ctx-server 3.12.2

The LeanCTX MCP server and its tools on top of LeanCTX | OSS.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
// SPDX-License-Identifier: Apache-2.0
use rmcp::ErrorData;
use rmcp::model::Tool;
use serde_json::{Map, Value, json};

use crate::server::tool_trait::{
    McpTool, ToolContext, ToolOutput, get_bool, get_int, get_str, get_str_array, get_usize,
    tool_execution_error,
};
use lean_ctx::tool_defs::tool_def;

pub struct CtxPackTool;

impl McpTool for CtxPackTool {
    fn name(&self) -> &'static str {
        "ctx_pack"
    }

    fn tool_def(&self) -> Tool {
        tool_def(
            "ctx_pack",
            "WORKFLOW: create -> export -> import -> install for sharing context state.\n\
            ANTIPATTERN: NOT for ephemeral session save (use ctx_session).\n\
            Context Package Manager — create, install, manage portable context packages\n\
            with knowledge, graph, session patterns, and gotchas.\n\
            Actions: pr, create, list, info, remove, install, export, import, auto_load, summary, bundle.\n\
            create: select layers/categories/keys/facts; preview:true lists what would be packed, writes nothing.\n\
            bundle: one budgeted XML document (task-ranked files, signatures, tree) that fits a chat input box.\n\
            Saves tokens: pre-built context state (avoids re-building).",
            json!({
                "type": "object",
                "properties": {
                    "action": {
                        "type": "string",
                        "enum": ["pr", "create", "list", "info", "remove", "install", "export", "import", "auto_load", "summary", "bundle"],
                        "description": "Pack action to perform"
                    },
                    "path": {
                        "type": "string",
                        "description": "Directory or file to bundle (bundle; default: project root)"
                    },
                    "limit": {
                        "type": "string",
                        "description": "Hard size cap, e.g. 128k, 2M, 32000 (bundle; default 128k)"
                    },
                    "unit": {
                        "type": "string",
                        "enum": ["chars", "tokens"],
                        "description": "What limit counts (bundle; default chars)"
                    },
                    "intent": {
                        "type": "string",
                        "description": "Task the bundle is for; ranks files (bundle; default: session task)"
                    },
                    "emit": {
                        "type": "string",
                        "enum": ["xml", "plain", "both"],
                        "description": "xml bundle, plain allocation report, or both (bundle)"
                    },
                    "include": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Globs to include (bundle)"
                    },
                    "ignore": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Globs to exclude (bundle)"
                    },
                    "with_knowledge": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Knowledge categories to append, e.g. decision, architecture, or all (bundle)"
                    },
                    "knowledge_limit": {
                        "type": "integer",
                        "description": "Max knowledge facts (bundle; default 10)"
                    },
                    "with_auto": {
                        "type": "boolean",
                        "description": "Also include machine-derived auto:* facts (bundle)"
                    },
                    "project_root": {
                        "type": "string",
                        "description": "Project root directory"
                    },
                    "name": {
                        "type": "string",
                        "description": "Package name"
                    },
                    "version": {
                        "type": "string",
                        "description": "Package version (semver)"
                    },
                    "description": {
                        "type": "string",
                        "description": "Package description (for create)"
                    },
                    "author": {
                        "type": "string",
                        "description": "Package author (for create)"
                    },
                    "tags": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Tags for categorization (for create)"
                    },
                    "layers": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Layers to include: knowledge|graph|session|patterns|gotchas"
                    },
                    "categories": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Only facts of these categories (create)"
                    },
                    "keys": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Only facts with these keys (create)"
                    },
                    "facts": {
                        "type": "array",
                        "items": { "type": "string" },
                        "description": "Explicit facts as category/key (create)"
                    },
                    "preview": {
                        "type": "boolean",
                        "description": "Show what create would pack (items, status, sources, validity); writes nothing"
                    },
                    "redistributable": {
                        "type": "boolean",
                        "description": "Grant recipients the right to pass the package on (create)"
                    },
                    "level": {
                        "type": "integer",
                        "description": "Detail level 1-3 (higher = more detail)"
                    },
                    "scope": {
                        "type": "string",
                        "description": "Package scope (e.g. @org/name)"
                    },
                    "base": {
                        "type": "string",
                        "description": "Git base ref for PR diff"
                    },
                    "format": {
                        "type": "string",
                        "enum": ["markdown", "json"],
                        "description": "Output format: markdown|json"
                    },
                    "depth": {
                        "type": "integer",
                        "description": "Impact depth for pr action (default: 3)"
                    },
                    "diff": {
                        "type": "string",
                        "description": "Git diff --name-status text input"
                    },
                    "file": {
                        "type": "string",
                        "description": "File path for import/export; bundle output file"
                    },
                    "apply": {
                        "type": "boolean",
                        "description": "Apply after import (default: false)"
                    },
                    "enable": {
                        "type": "boolean",
                        "description": "Enable auto-load (default: true)"
                    }
                },
                "required": ["action"],
                "allOf": [
                    {
                        "if": { "properties": { "action": { "const": "create" } }, "required": ["action"] },
                        "then": { "required": ["action", "name"] }
                    },
                    {
                        "if": { "properties": { "action": { "const": "info" } }, "required": ["action"] },
                        "then": { "required": ["action", "name"] }
                    },
                    {
                        "if": { "properties": { "action": { "const": "remove" } }, "required": ["action"] },
                        "then": { "required": ["action", "name"] }
                    },
                    {
                        "if": { "properties": { "action": { "const": "install" } }, "required": ["action"] },
                        "then": { "required": ["action", "name"] }
                    },
                    {
                        "if": { "properties": { "action": { "const": "export" } }, "required": ["action"] },
                        "then": { "required": ["action", "name"] }
                    },
                    {
                        "if": { "properties": { "action": { "const": "import" } }, "required": ["action"] },
                        "then": { "required": ["action", "file"] }
                    }
                ]
            }),
        )
    }

    fn handle(
        &self,
        args: &Map<String, Value>,
        ctx: &ToolContext,
    ) -> Result<ToolOutput, ErrorData> {
        let action = get_str(args, "action")
            .ok_or_else(|| ErrorData::invalid_params("action is required", None))?;

        let project_root = if let Some(p) = ctx
            .resolved_path("project_root")
            .or(ctx.resolved_path("root"))
        {
            p.to_string()
        } else if let Some(err) = ctx.path_error("project_root").or(ctx.path_error("root")) {
            return Err(ErrorData::invalid_params(
                format!("project_root: {err}"),
                None,
            ));
        } else {
            ctx.project_root.clone()
        };

        let result = match action.as_str() {
            "pr" => {
                let base = get_str(args, "base");
                let format = get_str(args, "format");
                let depth = get_usize(args, "depth").map(|d| d.min(64));
                let diff = get_str(args, "diff");
                crate::tools::ctx_pack::handle(
                    "pr",
                    &project_root,
                    base.as_deref(),
                    format.as_deref(),
                    depth,
                    diff.as_deref(),
                )
            }
            "create" => {
                let name = get_str(args, "name")
                    .ok_or_else(|| ErrorData::invalid_params("name is required for create", None))?;
                use lean_ctx::core::context_package::selection::{PackRequest, PackSelection};
                let request = PackRequest {
                    name,
                    version: get_str(args, "version").unwrap_or_else(|| "1.0.0".into()),
                    description: get_str(args, "description").unwrap_or_default(),
                    author: get_str(args, "author"),
                    tags: get_str_array(args, "tags").unwrap_or_default(),
                    level: get_int(args, "level")
                        .and_then(|l| u32::try_from(l).ok())
                        .unwrap_or(1)
                        .clamp(1, 3),
                    scope: get_str(args, "scope"),
                    private: false,
                    redistributable: get_bool(args, "redistributable").unwrap_or(false),
                    selection: PackSelection {
                        layers: get_str_array(args, "layers").unwrap_or_default(),
                        categories: get_str_array(args, "categories").unwrap_or_default(),
                        keys: get_str_array(args, "keys").unwrap_or_default(),
                        facts: get_str_array(args, "facts").unwrap_or_default(),
                    },
                };
                let preview = get_bool(args, "preview").unwrap_or(false);
                crate::tools::ctx_pack::handle_create(&project_root, &request, preview)
            }
            "list" => crate::tools::ctx_pack::handle_list(),
            "info" => {
                let name = get_str(args, "name")
                    .ok_or_else(|| ErrorData::invalid_params("name is required for info", None))?;
                let version = get_str(args, "version");
                crate::tools::ctx_pack::handle_info(&name, version.as_deref())
            }
            "remove" => {
                let name = get_str(args, "name")
                    .ok_or_else(|| ErrorData::invalid_params("name is required for remove", None))?;
                let version = get_str(args, "version");
                crate::tools::ctx_pack::handle_remove(&name, version.as_deref())
            }
            "install" => {
                let name = get_str(args, "name").ok_or_else(|| {
                    ErrorData::invalid_params("name is required for install", None)
                })?;
                let version = get_str(args, "version");
                crate::tools::ctx_pack::handle_install(&name, version.as_deref(), &project_root)
            }
            "export" => {
                let name = get_str(args, "name").ok_or_else(|| {
                    ErrorData::invalid_params("name is required for export", None)
                })?;
                let version = get_str(args, "version");
                let file = get_str(args, "file")
                    .map(|raw| lean_ctx::core::workspace_authority::confine(&raw, &project_root, true))
                    .transpose()
                    .map_err(|error| ErrorData::invalid_params(error, None))?;
                crate::tools::ctx_pack::handle_export(&name, version.as_deref(), file.as_deref())
            }
            "import" => {
                let file = get_str(args, "file")
                    .ok_or_else(|| ErrorData::invalid_params("file is required for import", None))?;
                let file = lean_ctx::core::workspace_authority::confine(&file, &project_root, false)
                    .map_err(|error| ErrorData::invalid_params(error, None))?;
                let apply = get_bool(args, "apply").unwrap_or(false);
                crate::tools::ctx_pack::handle_import(&file, apply, &project_root)
            }
            "auto_load" => {
                let name = get_str(args, "name");
                let version = get_str(args, "version");
                let enable = get_bool(args, "enable").unwrap_or(true);
                crate::tools::ctx_pack::handle_auto_load(
                    &project_root,
                    name.as_deref(),
                    version.as_deref(),
                    enable,
                )
            }
            "summary" => crate::tools::ctx_pack::handle_summary(&project_root),
            "bundle" => handle_bundle(args, ctx, &project_root)?,
            _ => "Unknown action. Use: pr, create, list, info, remove, install, export, import, auto_load, summary, bundle".to_string(),
        };

        Ok(ToolOutput::simple(result))
    }
}

/// `action=bundle` (#1885): one budgeted XML document for a chat product.
/// Returns the XML (or only the report for `emit=plain`); with `file` the XML
/// is written there and only the report comes back. The secret scan is
/// always on over MCP.
fn handle_bundle(
    args: &Map<String, Value>,
    ctx: &ToolContext,
    project_root: &str,
) -> Result<String, ErrorData> {
    use lean_ctx::core::context_bundle::{self, BundleOptions, Unit, parse_limit};
    let invalid = |msg: String| ErrorData::invalid_params(msg, None);

    let mut opts = BundleOptions::new(project_root.into());
    if let Some(path) = ctx.resolved_path("path") {
        opts.scope = Some(path.into());
    } else if let Some(err) = ctx.path_error("path") {
        return Err(invalid(format!("path: {err}")));
    }
    match args.get("limit") {
        Some(Value::String(raw)) => opts.limit = parse_limit(raw).map_err(invalid)?,
        Some(Value::Number(n)) => {
            opts.limit = n
                .as_u64()
                .and_then(|n| usize::try_from(n).ok())
                .filter(|n| *n > 0)
                .ok_or_else(|| invalid("limit must be a positive integer".into()))?;
        }
        Some(_) => {
            return Err(invalid(
                "limit must be a number or a string like 128k".into(),
            ));
        }
        None => {}
    }
    if let Some(unit) = get_str(args, "unit") {
        opts.unit = Unit::parse(&unit).map_err(invalid)?;
    }
    opts.intent = get_str(args, "intent");
    opts.include = get_str_array(args, "include").unwrap_or_default();
    opts.exclude = get_str_array(args, "ignore").unwrap_or_default();
    opts.knowledge = get_str_array(args, "with_knowledge").filter(|c| !c.is_empty());
    if let Some(n) = get_usize(args, "knowledge_limit") {
        opts.knowledge_limit = n;
    }
    opts.knowledge_auto = get_bool(args, "with_auto").unwrap_or(false);

    let emit = get_str(args, "emit").unwrap_or_else(|| "xml".into());
    if !matches!(emit.as_str(), "xml" | "plain" | "both") {
        return Err(invalid(format!(
            "emit must be xml, plain or both (got '{emit}')"
        )));
    }
    // The reads of the build run in the request's project scope and source
    // capture (dispatch binds both). A bundle is a mixed output — tree,
    // summary, task and knowledge text around the files — so `build` marks
    // the capture incomplete and this tool declares no source set
    // (`publishes_every_source` stays `false`). A bundle that could not be
    // built, or that does not fit its limit, is an error result.
    let bundle = context_bundle::build(&opts).map_err(tool_execution_error)?;
    let report = bundle.report();
    if !bundle.fits() {
        return Err(tool_execution_error(format!(
            "{report}bundle is {} {} but the limit is {} — raise limit or narrow path",
            bundle.size, bundle.unit, bundle.limit
        )));
    }

    if let Some(file) = ctx.resolved_path("file") {
        if emit == "plain" {
            return Err(invalid("emit=plain writes no bundle; drop file".into()));
        }
        // A file leaves the delivery path of this result: it stays inside
        // the project (the export rule) and receives the released text.
        let output = context_bundle::export::destination(
            "ctx_pack",
            std::path::Path::new(project_root),
            std::path::Path::new(file),
        )
        .map_err(invalid)?;
        let released = released_bundle(bundle.xml).map_err(tool_execution_error)?;
        std::fs::write(&output, released)
            .map_err(|e| tool_execution_error(format!("cannot write {file}: {e}")))?;
        return Ok(format!("{report}written: {file}"));
    } else if let Some(err) = ctx.path_error("file") {
        return Err(invalid(format!("file: {err}")));
    }
    Ok(match emit.as_str() {
        "plain" => report,
        "both" => format!("{report}\n{}", bundle.xml),
        _ => bundle.xml,
    })
}

/// The bundle as the release point lets it leave, for a destination that is
/// not this call's result (the `file`): the same sequence every tool result
/// passes — release, then the output redaction. `Err` is the content-free
/// notice of a refused release; nothing is written then.
fn released_bundle(xml: String) -> Result<String, String> {
    use rmcp::model::{CallToolResult, ContentBlock};
    let released = crate::server::policy_guard::release_result(
        "ctx_pack",
        CallToolResult::success(vec![ContentBlock::text(xml)]),
    );
    let text = released
        .content
        .iter()
        .filter_map(|block| block.as_text().map(|text| text.text.clone()))
        .collect::<Vec<_>>()
        .join("\n");
    if released.is_error == Some(true) {
        return Err(text);
    }
    Ok(crate::server::policy_guard::redact_model_text(&text))
}

#[cfg(test)]
mod tests {
    use super::*;

    fn project() -> tempfile::TempDir {
        let dir = tempfile::tempdir().unwrap();
        std::fs::write(dir.path().join("main.rs"), "fn main() {}\n").unwrap();
        dir
    }

    fn ctx_for(root: &std::path::Path, file: Option<&std::path::Path>) -> ToolContext {
        let mut ctx = ToolContext {
            project_root: root.to_string_lossy().into_owned(),
            ..Default::default()
        };
        if let Some(file) = file {
            ctx.resolved_paths
                .insert("file".into(), file.to_string_lossy().into_owned());
        }
        ctx
    }

    fn bundle(ctx: &ToolContext, extra: Value) -> Result<String, ErrorData> {
        let mut args = json!({ "action": "bundle", "limit": "8k" });
        if let (Some(args), Value::Object(extra)) = (args.as_object_mut(), extra) {
            args.extend(extra);
        }
        CtxPackTool
            .handle(args.as_object().unwrap(), ctx)
            .map(|out| out.text)
    }

    #[test]
    fn bundle_returns_xml_within_the_limit() {
        let _iso = lean_ctx::core::data_dir::isolated_data_dir();
        let dir = project();
        let xml = bundle(&ctx_for(dir.path(), None), json!({})).unwrap();
        assert!(xml.starts_with("<bundle "), "{xml}");
        assert!(xml.contains("fn main()"), "{xml}");
        assert!(xml.chars().count() <= 8000);
    }

    #[test]
    fn bundle_rejects_bad_emit_and_limit() {
        let _iso = lean_ctx::core::data_dir::isolated_data_dir();
        let dir = project();
        let ctx = ctx_for(dir.path(), None);
        assert!(bundle(&ctx, json!({ "emit": "html" })).is_err());
        assert!(bundle(&ctx, json!({ "limit": 0 })).is_err());
        assert!(bundle(&ctx, json!({ "limit": true })).is_err());
    }

    #[test]
    fn bundle_writes_the_file_and_returns_the_report() {
        let _iso = lean_ctx::core::data_dir::isolated_data_dir();
        let dir = project();
        let out = dir.path().join("bundle.xml");
        let report = bundle(&ctx_for(dir.path(), Some(&out)), json!({})).unwrap();
        assert!(report.contains("written:"), "{report}");
        let xml = std::fs::read_to_string(&out).unwrap();
        assert!(xml.starts_with("<bundle "), "{xml}");
    }

    /// #475: `file` must not write into a read-only root.
    #[test]
    fn bundle_refuses_to_write_into_a_read_only_root() {
        let _iso = lean_ctx::core::data_dir::isolated_data_dir();
        let dir = project();
        let ro = dir.path().join("refrepo");
        std::fs::create_dir_all(&ro).unwrap();
        let out = ro.join("bundle.xml");

        let ro_canon = lean_ctx::core::pathjail::canonicalize_or_self(&ro);
        lean_ctx::test_env::set_var(
            "LEAN_CTX_READ_ONLY_ROOTS",
            ro_canon.to_string_lossy().as_ref(),
        );
        let result = bundle(&ctx_for(dir.path(), Some(&out)), json!({}));
        lean_ctx::test_env::remove_var("LEAN_CTX_READ_ONLY_ROOTS");

        let err = result.expect_err("write into a read-only root must be refused");
        assert!(err.message.contains("read-only"), "{err:?}");
        assert!(
            !out.exists(),
            "no bundle may be written into a read-only root"
        );
    }

    /// V01: `create` with a selection packs exactly the selected facts, each
    /// with its status; `preview` lists exactly that and writes nothing. A
    /// fact merged from a package without a redistribution grant stays out
    /// (V02).
    #[test]
    fn create_packs_the_selection_and_preview_shows_it_without_writing() {
        use lean_ctx::core::context_package::LocalRegistry;
        use lean_ctx::core::knowledge::{FactStatus, ProjectKnowledge};
        let _iso = lean_ctx::core::data_dir::isolated_data_dir();
        let _community = lean_ctx::core::policy::runtime::TestPolicyOverride::set(None);
        let dir = project();
        let root = dir.path().to_string_lossy().into_owned();
        ProjectKnowledge::mutate_locked(&root, |k| {
            let policy = lean_ctx::core::memory_policy::MemoryPolicy::default();
            for (category, key, value) in [
                ("architecture", "db", "orders live in postgres 16"),
                ("architecture", "cache", "sessions are cached in redis"),
                ("architecture", "queue", "jobs run on a vendor queue"),
                ("decision", "style", "the parser is hand-written"),
            ] {
                k.remember(category, key, value, "fixture", 0.9, &policy);
                let fact = k.facts.last_mut().unwrap();
                match key {
                    "db" => fact.status = Some(FactStatus::Verified),
                    "queue" => fact.imported_from = Some("vendor-notes@1.0.0".into()),
                    _ => {}
                }
            }
        })
        .unwrap();
        let ctx = ctx_for(dir.path(), None);
        let create = |preview: bool| {
            let args = json!({
                "action": "create", "name": "selected", "layers": ["knowledge"],
                "categories": ["architecture"], "preview": preview,
            });
            CtxPackTool
                .handle(args.as_object().unwrap(), &ctx)
                .unwrap()
                .text
        };

        let preview = create(true);
        assert!(
            LocalRegistry::open().unwrap().list().unwrap().is_empty(),
            "a preview writes nothing: {preview}"
        );
        assert!(
            preview.contains("Knowledge facts: 2 (1 verified, 1 assumption)"),
            "{preview}"
        );
        assert!(preview.contains("[verified] architecture/db: orders live in postgres 16"));
        assert!(
            preview.contains("[assumption] architecture/cache"),
            "{preview}"
        );
        assert!(preview.contains("Not selected: 1 fact(s)"), "{preview}");
        assert!(
            preview.contains("Withheld: architecture/queue — merged from vendor-notes@1.0.0"),
            "{preview}"
        );
        assert!(!preview.contains("decision/style"), "{preview}");

        let created = create(false);
        let (_, content) = LocalRegistry::open()
            .unwrap()
            .load_package("selected", "1.0.0")
            .unwrap_or_else(|e| panic!("{e}: {created}"));
        let packed: Vec<_> = content
            .knowledge
            .unwrap()
            .facts
            .into_iter()
            .map(|f| (format!("{}/{}", f.category, f.key), f.status))
            .collect();
        assert_eq!(
            packed,
            [
                ("architecture/db".into(), Some(FactStatus::Verified)),
                ("architecture/cache".into(), Some(FactStatus::Assumption)),
            ]
        );
        for (fact, status) in &packed {
            let line = format!("[{}] {fact}:", status.unwrap().as_str());
            assert!(preview.contains(&line), "preview lacks {line}: {preview}");
        }
    }
}