style: cargo fmt --all (round 4 ingest log feature follow-up)

Phase C4 executor 의 마지막 `fix(test): clippy + fmt fixes` commit 이
test file 부분만 fmt 적용. workspace 전체 fmt 누락 발견 → cargo fmt --all
적용. 모든 import alphabetical reorder + line wrapping 정합.

추가 untracked artifact 동시 commit:
- docs/superpowers/specs/2026-05-28-v0.20-ingest-log-spec.md (491 line, ACCEPT)
- docs/superpowers/plans/2026-05-28-v0.20-ingest-log-plan.md (616 line, ACCEPT)

workspace test: 1370 passed / 0 failed / 50 ignored, ingest_log_smoke green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-28 04:18:40 +00:00
parent 445b096215
commit 685007789a
235 changed files with 6520 additions and 3955 deletions

View File

@@ -44,8 +44,16 @@ fn copy_mode_writes_file_with_0o644_and_correct_bytes() {
// Path: data_dir/assets/aa/aaaaaa…aa
let aa = &asset.asset_id.0[..2];
let dest = env.data_dir().join("assets").join(aa).join(&asset.asset_id.0);
assert!(dest.exists(), "asset file not written at {}", dest.display());
let dest = env
.data_dir()
.join("assets")
.join(aa)
.join(&asset.asset_id.0);
assert!(
dest.exists(),
"asset file not written at {}",
dest.display()
);
let on_disk = std::fs::read(&dest).unwrap();
assert_eq!(on_disk, bytes);
@@ -82,10 +90,16 @@ fn reference_mode_does_not_write_file_but_records_path() {
let mut asset = fixed_asset(bytes, 1, &cs);
asset.source_uri = SourceUri::File(PathBuf::from("/path/to/original.md"));
store.put_asset_with_bytes(&asset, bytes).expect("ref write");
store
.put_asset_with_bytes(&asset, bytes)
.expect("ref write");
let aa = &asset.asset_id.0[..2];
let dest = env.data_dir().join("assets").join(aa).join(&asset.asset_id.0);
let dest = env
.data_dir()
.join("assets")
.join(aa)
.join(&asset.asset_id.0);
assert!(!dest.exists(), "reference mode must not copy bytes");
let (storage_kind, storage_path): (String, String) = env.with_conn(|c| {
@@ -161,11 +175,18 @@ fn put_asset_with_bytes_sweeps_workspace_path_orphan() {
|row| row.get(0),
)
});
assert_eq!(new_count, 1, "new asset_id must own the workspace_path slot");
assert_eq!(
new_count, 1,
"new asset_id must own the workspace_path slot"
);
// New asset's bytes published at the final destination.
let aa = &asset.asset_id.0[..2];
let dest = env.data_dir().join("assets").join(aa).join(&asset.asset_id.0);
let dest = env
.data_dir()
.join("assets")
.join(aa)
.join(&asset.asset_id.0);
assert!(
dest.exists(),
"new asset bytes must be visible at {}",
@@ -185,7 +206,11 @@ fn put_asset_with_bytes_rejects_invalid_asset_id() {
// 32 chars but contains a `/` — would let `assets_path_for` stitch
// together a path outside the shard tree.
let evil_id = "../etc/passwd_padded_to_xx_xxxxx".to_string();
assert_eq!(evil_id.len(), 32, "test fixture must be 32 chars to exercise length-only checks");
assert_eq!(
evil_id.len(),
32,
"test fixture must be 32 chars to exercise length-only checks"
);
let mut asset = fixed_asset(b"x", 1, &b3_full_hex(b"x"));
asset.asset_id = AssetId(evil_id.clone());

View File

@@ -49,7 +49,10 @@ fn create_get_roundtrip() {
let store = open_store(&tmp);
let session = make_session("sess-1");
store.create_session(&session).unwrap();
let fetched = store.get_session("sess-1").unwrap().expect("session present");
let fetched = store
.get_session("sess-1")
.unwrap()
.expect("session present");
assert_eq!(fetched, session);
}
@@ -112,20 +115,16 @@ fn append_turn_bumps_session_updated_at() {
let store = open_store(&tmp);
let session = make_session("bump");
store.create_session(&session).unwrap();
let pre = store
.get_session("bump")
.unwrap()
.unwrap()
.updated_at;
let pre = store.get_session("bump").unwrap().unwrap().updated_at;
let mut t = make_turn("bump", 0);
t.created_at = pre + 100;
store.append_turn(&t).unwrap();
let post = store
.get_session("bump")
.unwrap()
.unwrap()
.updated_at;
assert_eq!(post, pre + 100, "updated_at must follow latest turn's created_at");
let post = store.get_session("bump").unwrap().unwrap().updated_at;
assert_eq!(
post,
pre + 100,
"updated_at must follow latest turn's created_at"
);
}
#[test]
@@ -168,7 +167,9 @@ fn list_sessions_respects_limit() {
let tmp = TempDir::new().unwrap();
let store = open_store(&tmp);
for i in 0..5 {
store.create_session(&make_session(&format!("s{i}"))).unwrap();
store
.create_session(&make_session(&format!("s{i}")))
.unwrap();
}
assert_eq!(store.list_sessions(2).unwrap().len(), 2);
assert_eq!(store.list_sessions(100).unwrap().len(), 5);

View File

@@ -10,7 +10,7 @@ use std::path::PathBuf;
use kebab_chunk::MdHeadingV1Chunker;
use kebab_core::{
AssetId, AssetStorage, Checksum, ChunkPolicy, ChunkerVersion, Chunker, DocumentStore,
AssetId, AssetStorage, Checksum, ChunkPolicy, Chunker, ChunkerVersion, DocumentStore,
MediaType, ParserVersion, RawAsset, SourceUri, WorkspacePath,
};
use kebab_parse_md::{BodyHints, build_canonical_document, parse_blocks, parse_frontmatter};
@@ -58,8 +58,7 @@ fn document_and_chunks_round_trip_through_sqlite() {
fs_mtime: asset.discovered_at,
fallback_lang: Some("en".into()),
};
let (mut metadata, _fm_span, _fm_warns) =
parse_frontmatter(&bytes, &hints).unwrap();
let (mut metadata, _fm_span, _fm_warns) = parse_frontmatter(&bytes, &hints).unwrap();
let (parsed_blocks, parse_warns) = parse_blocks(&bytes, 1).unwrap();
metadata.aliases.sort();
@@ -91,9 +90,7 @@ fn document_and_chunks_round_trip_through_sqlite() {
store
.put_blocks(&doc.doc_id, &doc.blocks)
.expect("put_blocks");
store
.put_chunks(&doc.doc_id, &chunks)
.expect("put_chunks");
store.put_chunks(&doc.doc_id, &chunks).expect("put_chunks");
// ── Read back ────────────────────────────────────────────────────
let loaded = store

View File

@@ -334,9 +334,7 @@ fn normalize_ws(s: &str) -> String {
/// - no `CREATE VIRTUAL TABLE chunks_fts` inside that block
/// - no `END;` after the virtual-table line
fn extract_design_5_5_fts_block() -> String {
let doc = include_str!(
"../../../docs/superpowers/specs/2026-04-27-kebab-final-form-design.md"
);
let doc = include_str!("../../../docs/superpowers/specs/2026-04-27-kebab-final-form-design.md");
let heading_idx = doc
.find("### 5.5 Chunks + FTS5")
.expect("design doc must contain `### 5.5 Chunks + FTS5` heading");
@@ -394,9 +392,7 @@ fn extract_migration_5_5_verbatim_block() -> String {
.expect("V007 must carry the `End §5.5 verbatim block` closing anchor")
+ after_open_line;
// Walk back from the close marker to the start of its comment line.
let close_line_start = migration[..close_idx]
.rfind('\n')
.map_or(0, |n| n + 1);
let close_line_start = migration[..close_idx].rfind('\n').map_or(0, |n| n + 1);
migration[after_open_line..close_line_start].to_string()
}
@@ -476,8 +472,7 @@ fn fts_store_drop_releases_wal_files() {
}
// The main DB file should likewise be removable.
if db_path.exists() {
std::fs::remove_file(&db_path)
.expect("main DB file should be removable after store drop");
std::fs::remove_file(&db_path).expect("main DB file should be removable after store drop");
}
}
@@ -584,11 +579,7 @@ fn fts_trigram_english_substring_hits() {
1,
"substring of 'tokenizer' — trigram recall"
);
assert_eq!(
count_match(&conn, "izer"),
1,
"substring of 'tokenizer'"
);
assert_eq!(count_match(&conn, "izer"), 1, "substring of 'tokenizer'");
// 3-char-minimum applies to English too.
assert_eq!(count_match(&conn, "to"), 0, "2-char English query");
}

View File

@@ -5,10 +5,9 @@
use std::path::PathBuf;
use kebab_core::{
AssetId, AssetStorage, Block, CanonicalDocument, Checksum, Chunk, ChunkerVersion,
CommonBlock, DocumentId, DocumentStore, HeadingBlock, Lang, MediaType, Metadata,
ParserVersion, Provenance, RawAsset, SourceSpan, SourceType, SourceUri, TextBlock,
TrustLevel, WorkspacePath,
AssetId, AssetStorage, Block, CanonicalDocument, Checksum, Chunk, ChunkerVersion, CommonBlock,
DocumentId, DocumentStore, HeadingBlock, Lang, MediaType, Metadata, ParserVersion, Provenance,
RawAsset, SourceSpan, SourceType, SourceUri, TextBlock, TrustLevel, WorkspacePath,
};
use kebab_store_sqlite::SqliteStore;
use time::OffsetDateTime;
@@ -66,7 +65,7 @@ fn make_doc() -> CanonicalDocument {
block_id: kebab_core::BlockId("c".repeat(32)),
heading_path: vec!["Title".into()],
source_span: span,
},
},
text: "body".into(),
inlines: vec![],
});
@@ -138,8 +137,7 @@ fn put_document_idempotent_bumps_doc_version() {
// Tags were re-derived: still exactly the two original tags.
let tags: Vec<String> = env.with_conn(|c| {
let mut stmt =
c.prepare("SELECT tag FROM document_tags WHERE doc_id = ? ORDER BY tag")?;
let mut stmt = c.prepare("SELECT tag FROM document_tags WHERE doc_id = ? ORDER BY tag")?;
let rows = stmt.query_map([&doc.doc_id.0], |r| r.get::<_, String>(0))?;
rows.collect::<rusqlite::Result<Vec<String>>>()
});
@@ -158,7 +156,9 @@ fn put_blocks_and_put_chunks_replace_not_duplicate() {
store.put_document(&doc).unwrap();
store.put_blocks(&doc.doc_id, &doc.blocks).unwrap();
store.put_chunks(&doc.doc_id, &make_chunks(&doc.doc_id)).unwrap();
store
.put_chunks(&doc.doc_id, &make_chunks(&doc.doc_id))
.unwrap();
let (b1, ch1): (i64, i64) = env.with_conn(|c| {
Ok((
@@ -179,7 +179,9 @@ fn put_blocks_and_put_chunks_replace_not_duplicate() {
// Re-put same data → counts unchanged (DELETE-then-INSERT).
store.put_blocks(&doc.doc_id, &doc.blocks).unwrap();
store.put_chunks(&doc.doc_id, &make_chunks(&doc.doc_id)).unwrap();
store
.put_chunks(&doc.doc_id, &make_chunks(&doc.doc_id))
.unwrap();
let (b2, ch2): (i64, i64) = env.with_conn(|c| {
Ok((
c.query_row(
@@ -214,9 +216,8 @@ fn put_blocks_transactional_rollback_on_fk_violation() {
store.put_document(&doc).unwrap();
// Establish a baseline row in `blocks`.
store.put_blocks(&doc.doc_id, &doc.blocks).unwrap();
let baseline: i64 = env.with_conn(|c| {
c.query_row("SELECT COUNT(*) FROM blocks", [], |r| r.get(0))
});
let baseline: i64 =
env.with_conn(|c| c.query_row("SELECT COUNT(*) FROM blocks", [], |r| r.get(0)));
assert_eq!(baseline, 2);
// Now ask put_blocks to write to a doc_id that does NOT exist.
@@ -237,9 +238,8 @@ fn put_blocks_transactional_rollback_on_fk_violation() {
let res = store.put_blocks(&phantom, &phantom_blocks);
assert!(res.is_err(), "FK violation must surface as Err");
let after: i64 = env.with_conn(|c| {
c.query_row("SELECT COUNT(*) FROM blocks", [], |r| r.get(0))
});
let after: i64 =
env.with_conn(|c| c.query_row("SELECT COUNT(*) FROM blocks", [], |r| r.get(0)));
assert_eq!(
after, baseline,
"transaction must roll back; blocks count must be unchanged"

View File

@@ -9,8 +9,8 @@
use std::path::PathBuf;
use kebab_core::{
AssetId, ChunkerVersion, DocumentId, IngestItem, IngestItemKind, IngestReport,
ParserVersion, SourceScope, WorkspacePath,
AssetId, ChunkerVersion, DocumentId, IngestItem, IngestItemKind, IngestReport, ParserVersion,
SourceScope, WorkspacePath,
};
use serde_json::Value;

View File

@@ -29,9 +29,7 @@ fn create_then_progress_then_finish() {
assert_eq!(row[0].progress.as_ref().unwrap()["total"], json!(10));
// Finish with success.
store
.finish(&id, JobStatus::Succeeded, None)
.unwrap();
store.finish(&id, JobStatus::Succeeded, None).unwrap();
let row = store.list(&JobFilter::default()).unwrap();
assert_eq!(row[0].status, JobStatus::Succeeded);
assert!(row[0].finished_at.is_some());

View File

@@ -3,9 +3,9 @@
use std::path::PathBuf;
use kebab_core::{
AssetId, AssetStorage, Block, CanonicalDocument, Checksum, CommonBlock, DocFilter,
DocumentId, DocumentStore, HeadingBlock, Lang, MediaType, Metadata, ParserVersion,
Provenance, RawAsset, SourceSpan, SourceType, SourceUri, TrustLevel, WorkspacePath,
AssetId, AssetStorage, Block, CanonicalDocument, Checksum, CommonBlock, DocFilter, DocumentId,
DocumentStore, HeadingBlock, Lang, MediaType, Metadata, ParserVersion, Provenance, RawAsset,
SourceSpan, SourceType, SourceUri, TrustLevel, WorkspacePath,
};
use kebab_store_sqlite::SqliteStore;
use time::OffsetDateTime;
@@ -84,7 +84,13 @@ fn list_documents_filters_lang_and_tags() {
store.run_migrations().unwrap();
for (asset, doc) in [
make_doc('a', "notes/a.md", "en", vec!["rust", "kb"], TrustLevel::Primary),
make_doc(
'a',
"notes/a.md",
"en",
vec!["rust", "kb"],
TrustLevel::Primary,
),
make_doc('b', "notes/b.md", "ko", vec!["rust"], TrustLevel::Secondary),
make_doc('c', "papers/c.md", "en", vec!["bio"], TrustLevel::Generated),
] {

View File

@@ -23,5 +23,8 @@ fn open_existing_does_not_create_missing_db() {
let dir = tempfile::tempdir().unwrap();
let nonexistent_db = dir.path().join("does-not-exist.sqlite");
let _ = SqliteStore::open_existing(&nonexistent_db);
assert!(!nonexistent_db.exists(), "open_existing must NOT create the file");
assert!(
!nonexistent_db.exists(),
"open_existing must NOT create the file"
);
}