refactor(reader): extract.rs moves into ledger-reader (U0d)
D-61 (Q-9): the writer sheds the typesetter and the crate map is layered again. The PDF/XLSX reader (extract.rs, plan P6) is now the plain library crate ledger-reader, moved whole with git mv and no behavior change. ledger-store depends on it instead of ledger-import, so the store no longer builds Typst or the fonts; ledger-import re-exports it as ledger_import::extract so gui, mcp, host and the fuzz targets compile unchanged, and still never depends on the store. New crate carries only the dependencies extract.rs imports (hayro, hayro-interpret, kurbo, zip, quick-xml, thiserror); fuzz/Cargo.lock gains the new package. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
This commit is contained in:
1 parent
f98471516e
commit
bb1eb84200
15 files changed
+344
-68
No files matched your search
@@ -8,11 +8,11 @@ description = "Durable persistence for wanderbooks: a hash-chained JSONL journal
|
||||
|
||||
[dependencies]
|
||||
ledger-core = { path = "../ledger-core" }
|
||||
# The one extractor (plan P6 step 1, D-53): the writer journals a file's
|
||||
# The one reader (plan P6 step 1, D-53, D-61: its own crate): the writer journals a file's
|
||||
# text at attach time and on `wanderbooks books extract`, so the extractor
|
||||
# must be callable here rather than only from the server. It is pure and
|
||||
# deterministic (no I/O, no network, no time source).
|
||||
ledger-import = { path = "../ledger-import" }
|
||||
ledger-reader = { path = "../ledger-reader" }
|
||||
rusqlite = { version = "0.32", features = ["bundled"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
@@ -45,7 +45,7 @@ use ledger_core::{
|
||||
payroll::{PayrollAccounts, payroll_entry_plan, payroll_remit_plan},
|
||||
reports,
|
||||
};
|
||||
use ledger_import::extract::{EXTRACTOR as E_EXTRACTOR, VERSION as E_VERSION};
|
||||
use ledger_reader::{EXTRACTOR as E_EXTRACTOR, VERSION as E_VERSION};
|
||||
use rusqlite::{Connection, OptionalExtension, params};
|
||||
use rust_decimal::Decimal;
|
||||
use serde_json::{Value, json};
|
||||
@@ -368,7 +368,7 @@ pub struct Extraction {
|
||||
pub attachment_id: u64,
|
||||
/// The text's blob (its SHA-256), when there is text.
|
||||
pub text_sha256: Option<String>,
|
||||
/// What read it (`ledger_import::extract::EXTRACTOR`).
|
||||
/// What read it (`ledger_reader::EXTRACTOR`).
|
||||
pub extractor: String,
|
||||
/// That extractor's version.
|
||||
pub version: String,
|
||||
@@ -4620,7 +4620,7 @@ impl Store {
|
||||
if let Some(already) = self.extraction_for(attachment_id, E_EXTRACTOR, E_VERSION)? {
|
||||
return Ok(already);
|
||||
}
|
||||
let got = ledger_import::extract::extract(bytes, mime_type, file_name);
|
||||
let got = ledger_reader::extract(bytes, mime_type, file_name);
|
||||
let text_sha = match &got.text {
|
||||
Some(text) => Some(self.blobs.put(text.as_bytes())?.0),
|
||||
None => None,
|
||||
@@ -4644,9 +4644,9 @@ impl Store {
|
||||
version: E_VERSION.into(),
|
||||
pages: got.pages,
|
||||
status: match got.status {
|
||||
ledger_import::extract::ExtractStatus::Ok => ExtractionStatus::Ok,
|
||||
ledger_import::extract::ExtractStatus::None => ExtractionStatus::None,
|
||||
ledger_import::extract::ExtractStatus::Failed => ExtractionStatus::Failed,
|
||||
ledger_reader::ExtractStatus::Ok => ExtractionStatus::Ok,
|
||||
ledger_reader::ExtractStatus::None => ExtractionStatus::None,
|
||||
ledger_reader::ExtractStatus::Failed => ExtractionStatus::Failed,
|
||||
},
|
||||
seq: line.seq,
|
||||
})
|
||||
|
||||
@@ -1471,8 +1471,8 @@ fn extraction_is_journaled_once_per_version() {
|
||||
let x = s.extraction(id).unwrap().expect("an extraction record");
|
||||
assert_eq!(x.status, ExtractionStatus::Ok);
|
||||
assert_eq!(x.pages, 1);
|
||||
assert_eq!(x.extractor, ledger_import::extract::EXTRACTOR);
|
||||
assert_eq!(x.version, ledger_import::extract::VERSION);
|
||||
assert_eq!(x.extractor, ledger_reader::EXTRACTOR);
|
||||
assert_eq!(x.version, ledger_reader::VERSION);
|
||||
assert_eq!(
|
||||
s.extraction_text(id).unwrap().as_deref(),
|
||||
Some(String::from_utf8_lossy(text).as_ref())
|
||||
|
||||
Reference in new issue
Block a user