design §3.7b 의 thin layer (ParsedBlock 류) 가 4 parser 중 1개 (markdown) 만 lift 를 경유하는 현실 — fan-in/fan-out 모두 1 → layer 의미 잃음. kebab-normalize (1097 LOC) + kebab-parse-types (98 LOC) 둘을 kebab-parse-md 로 흡수. 설계: docs/superpowers/specs/2026-05-26-normalize-absorption-spec.md 플랜: docs/superpowers/plans/2026-05-26-normalize-absorption-plan.md HOTFIXES: tasks/HOTFIXES.md 의 2026-05-26 entry (design deviation) - 5 사용 type + 3 forward-declared struct → kebab-parse-md::types module 의 pub explicit re-export. - build_canonical_document + derive_title + warning_agent → kebab-parse-md::normalize module. - 4 hard-coded agent literal (lib.rs:122/128/134/153) + warning_agent body return + tracing target literal 모두 보존 — stage label 일관성. - kebab-app callsite (lib.rs:51 use + :1119 context string) + Cargo.toml 의 2 dep (regular + dead) 제거. - kebab-chunk + kebab-store-sqlite 의 [dev-dependencies] kebab-normalize → 제거 (kebab-parse-md 로 갈음). 통합 test source 의 use shift. - test file 이동 (kebab-normalize/tests/normalize_snapshot.rs → kebab-parse-md/tests/). - workspace Cargo.toml: Hunk (a) members 2 entry 삭제 + Hunk (b) version 0.18.0 → 0.19.0 (frozen contract 변경). - design §3.7b 4-단락 재작성 (원래 intent 보존 + 현재 상태 + 보존된 surface + future re-extraction trigger). - design §8 graph 갱신 (3 edge 제거 + 2 forbidden bullet 의미 갱신 + commentary). - ARCHITECTURE.md crate graph + directory tree mechanical 갱신. - tasks/INDEX.md L169 closure mention + "Future work / deferred" 섹션 신설 (image/pdf normalize integration entry). - tasks/HOTFIXES.md 신규 entry (4-block — design deviation Symptom). - HANDOFF.md cross-link 한 줄. - 3 dead struct (ParsedImageRegion / ParsedPdfPage / ParsedAudioSegment) 는 보존 — v0.20+ image/pdf normalize integration 의 future surface (spec §11). Wire / surface impact: 0건. CLI / TUI / MCP / --json 출력 / config / XDG path / parser_version 모두 unchanged. wire-invisible provenance.events[].agent + tracing target literal "kb-normalize" 도 보존 — old DB row 와 new DB row 의 audit log 일관성. Verification: cargo test --workspace --no-fail-fast -j 1 → 1313 passed / 0 failed (172 result blocks). cargo clippy --workspace --all-targets -j 1 -- -D warnings → 0 warning (5m 46s). cargo metadata --no-deps --format-version 1 | jq '.workspace_members | length' = 22. cargo tree -p kebab-app --depth 2 | grep -E "kebab_(parse_types|normalize)" = 0 줄.
51 lines
2.4 KiB
Rust
51 lines
2.4 KiB
Rust
//! `kb-parse-md` — Markdown parsing + canonical-document lift for the KB pipeline (§3.7b).
|
|
//!
|
|
//! v0.19.0 부터 `types` + `normalize` module 은 in-crate 흡수
|
|
//! (`kebab-parse-types` + `kebab-normalize` 의 historical crate 가 본 crate 로
|
|
//! collapse — see HOTFIXES.md 2026-05-26).
|
|
//!
|
|
//! Public surface:
|
|
//!
|
|
//! * [`parse_frontmatter`] — pure function from Markdown bytes to
|
|
//! `(Metadata, Option<FrontmatterSpan>, Vec<Warning>)` (P1-2).
|
|
//! * [`BodyHints`] — caller-supplied fallbacks that feed the §0 Q9 derive
|
|
//! table when frontmatter is missing or partial (P1-2).
|
|
//! * [`FrontmatterSpan`] — byte offsets of the frontmatter region in the
|
|
//! input slice (returned by [`parse_frontmatter`]) (P1-2).
|
|
//! * [`parse_blocks`] — pure function from Markdown body bytes to
|
|
//! `(Vec<ParsedBlock>, Vec<Warning>)` with heading paths and 1-indexed
|
|
//! `SourceSpan::Line` ranges relative to the original file (P1-3).
|
|
//! * [`build_canonical_document`] / [`derive_title`] — lift a parsed
|
|
//! markdown document into a `kebab_core::CanonicalDocument` (absorbed
|
|
//! from `kebab-normalize` — P1-4 / p9-fb-07 frozen API).
|
|
//! * Parser intermediate types ([`ParsedBlock`], [`ParsedBlockKind`],
|
|
//! [`ParsedPayload`], [`Warning`], [`WarningKind`]) and 3 forward-declared
|
|
//! structs ([`ParsedImageRegion`], [`ParsedPdfPage`], [`ParsedAudioSegment`]) —
|
|
//! absorbed from `kebab-parse-types`.
|
|
//!
|
|
//! Anything else in this crate is `pub(crate)` and may change without notice.
|
|
|
|
pub mod blocks;
|
|
pub mod frontmatter;
|
|
mod normalize;
|
|
mod types;
|
|
|
|
pub use blocks::parse_blocks;
|
|
pub use frontmatter::{BodyHints, FrontmatterSpan, parse_frontmatter};
|
|
|
|
// Spec §3.3 의 surface 보존 정책 — explicit (NOT glob) 으로 future addition leak 방지.
|
|
pub use crate::normalize::{build_canonical_document, derive_title};
|
|
pub use crate::types::{
|
|
// 5 사용 type
|
|
ParsedBlock, ParsedBlockKind, ParsedPayload, Warning, WarningKind,
|
|
// 3 forward-declared struct (보존 — spec §3.3 + §11.5 future surface)
|
|
ParsedImageRegion, ParsedPdfPage, ParsedAudioSegment,
|
|
};
|
|
|
|
/// Parser-version label for Markdown files ingested through this crate.
|
|
/// Re-exported so `kebab-app::schema_with_config` can embed it in
|
|
/// `SchemaV1.models.parser_version` without duplicating the literal.
|
|
///
|
|
/// Kept in sync with `KEBAB_PARSE_MD_VERSION` in `kebab-app/src/lib.rs`.
|
|
pub const PARSER_VERSION: &str = "md-frontmatter-v2";
|