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>
59 lines
1.7 KiB
Rust
59 lines
1.7 KiB
Rust
//! p10-2: dockerfile whole-file chunker (Tier 2).
|
|
//!
|
|
//! Reads entire Dockerfile content and emits a single Chunk with symbol
|
|
//! "<dockerfile>", code_lang "dockerfile", line range 1..EOF.
|
|
//! Oversize >200 lines splits into line-windows sharing the symbol via
|
|
//! tier2_shared::push_chunks_with_oversize.
|
|
|
|
use crate::tier2_shared::{policy_hash, push_chunks_with_oversize};
|
|
use anyhow::Result;
|
|
use kebab_core::{Block, CanonicalDocument, Chunk, ChunkPolicy, Chunker, ChunkerVersion};
|
|
|
|
pub const VERSION_LABEL: &str = "dockerfile-file-v1";
|
|
|
|
#[derive(Clone, Copy, Debug, Default)]
|
|
pub struct DockerfileFileV1Chunker;
|
|
|
|
impl Chunker for DockerfileFileV1Chunker {
|
|
fn chunker_version(&self) -> ChunkerVersion {
|
|
ChunkerVersion(VERSION_LABEL.to_string())
|
|
}
|
|
|
|
fn policy_hash(&self, policy: &ChunkPolicy) -> String {
|
|
policy_hash(policy)
|
|
}
|
|
|
|
fn chunk(&self, doc: &CanonicalDocument, policy: &ChunkPolicy) -> Result<Vec<Chunk>> {
|
|
// Expect a single Block::Code carrying the full Dockerfile text.
|
|
let text = match doc.blocks.first() {
|
|
Some(Block::Code(cb)) => cb.code.as_str(),
|
|
_ => return Ok(vec![]),
|
|
};
|
|
|
|
let total_lines = text.lines().count().max(1) as u32;
|
|
let mut chunks = Vec::new();
|
|
|
|
push_chunks_with_oversize(
|
|
&mut chunks,
|
|
doc,
|
|
policy,
|
|
text,
|
|
1,
|
|
total_lines,
|
|
"<dockerfile>",
|
|
"dockerfile",
|
|
VERSION_LABEL,
|
|
None,
|
|
)?;
|
|
|
|
tracing::debug!(
|
|
target: "kebab-chunk",
|
|
doc_id = %doc.doc_id,
|
|
chunks = chunks.len(),
|
|
"dockerfile-file-v1 chunked",
|
|
);
|
|
|
|
Ok(chunks)
|
|
}
|
|
}
|