refactor(chunk): 9개 동일 code AST chunker → CodeAstV1Chunker 통합 #220
Reference in New Issue
Block a user
Delete Branch "refactor/code-ast-chunker-consolidation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
요약
code_{c,cpp,go,java,js,kotlin,python,rust,ts}_ast_v1.rs9개는 struct 이름 +const VERSION_LABEL문자열만 다른 byte-identical 복붙이었다 (chunker 는 tree-sitter 를 쓰지 않고,lang은 struct 가 아니라SourceSpan::Code { lang }데이터에서 흘러나온다 —#[cfg(test)]앞 production 본문이 언어 토큰 정규화 후 diff 완전 비어있음). 단일CodeAstV1Chunker로 통합한다.ponytail-audit 의 최대 단일 절단(net −3030줄, 무손실). 코어 청킹 동작은 byte-identical — chunk_id 까지 변하지 않아 재인덱싱·임베딩 드리프트 0.
변경
CodeAstV1Chunker { version_label: &'static str }+for_lang(lang)생성자. 9개 lang → 기존VERSION_LABEL을 verbatim 매핑 (rust→code-rust-ast-v1,typescript→code-ts-ast-v1,javascript→code-js-ast-v1,c→code-c-ast-v1…).chunker_version()이 라벨을 그대로 반환 →id_for_chunk(...)의 입력 불변 → chunk_id byte-identical.chunk/policy_hash/make_chunk/split_oversize는code_rust_ast_v1.rs에서 verbatim 이식. 인라인 유닛 테스트 1세트 + 9-lang 라벨 매핑 테스트 +for_langpanic 테스트 추가.lib.rs의 9mod+9pub use→ 1.ingest.rs의 두 디스패치(chunker_version스탬프 ~2700 +.chunk()~3298)에서 9개 AST arm 을 단일 arm 으로 collapse,for_lang(code_lang)사용.비범위 / 가드레일
K8sManifestResourceV1Chunker/DockerfileFileV1Chunker/ManifestFileV1Chunker/CodeTextParagraphV1Chunker는 같은 arm·같은.context()문자열로 그대로.other => anyhow::bail!가드도 유지.검증
tests/code_*_ast_snapshot.rs가 assertion/expected chunk text/expected chunk_id/fixture 수정 0으로 통과 — construction/import 줄만 바뀜. (스냅샷이 기대 JSON 을 fixture 에서 로드해 새 chunker 출력과 byte 대조하므로, 무수정 통과 = 출력 무드리프트.)typescript→code-ts-ast-v1등 약어 케이스 포함) + completeness(9 src 삭제·비-AST 무손상·잔존 참조 0) 통과.cargo test -p kebab-chunk -p kebab-app녹색,cargo clippy -D warnings클린. net −3030줄 (20파일 +143/−3173).시험 항목 (Test Plan)
kebab search결과 동일.kebab ingest가 rust/python/ts/js/go/java/kotlin/c/cpp 소스를 이전과 동일하게 청킹.Assisted-by: Claude Code
code_{c,cpp,go,java,js,kotlin,python,rust,ts}_ast_v1.rs 9개는 struct 이름과 const VERSION_LABEL 문자열만 다른 byte-identical 복붙이었다 (chunker 는 tree-sitter 를 안 쓰고 lang 은 SourceSpan::Code 데이터에서 흘러나옴). 하나로 통합: - 신규 CodeAstV1Chunker { version_label: &'static str } + for_lang(lang) 생성자. 9개 lang → 기존 VERSION_LABEL 문자열을 verbatim 매핑 (rust→code-rust-ast-v1, typescript→code-ts-ast-v1, javascript→code-js-ast-v1, ...). chunker_version() 이 라벨을 그대로 반환 → chunk_id (id_for_chunk) byte-identical → 재인덱싱· 버전 캐스케이드 0. - chunk/policy_hash/make_chunk/split_oversize 는 code_rust_ast_v1.rs 에서 verbatim 이식. 인라인 유닛 테스트 1세트 + 9-lang 라벨 매핑 테스트 추가. - 9개 src 파일 삭제, lib.rs 9 mod+pub use → 1. - ingest.rs 의 두 디스패치(chunker_version 스탬프 ~2700 + .chunk() ~3298)에서 9개 AST arm 을 단일 arm 으로 collapse, for_lang(code_lang) 사용. 비-AST chunker(K8s/Dockerfile/Manifest/TextParagraph) arm 은 무손상. byte-identical 증명: 9개 골든 스냅샷 테스트(tests/code_*_ast_snapshot.rs)가 assertion/expected-data 수정 0으로 통과 — construction/import 줄만 변경. net −3030줄 (20파일 +143/−3173). 적대적 검증 3렌즈(byte-identical-proof + version-string-integrity[9 라벨 old==new] + completeness) 통과, clippy -D warnings 클린. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Mc6W1fgsrbFKTsqA6P8La회차 2 — 회차 1 의 actionable nit(.context(format!) → .with_context(|| format!), 성공 경로 alloc 회피) 반영 확인. 다른 nit(일반화된 error-text)은 의도된 통일이라 no-action.
하드 게이트 경험적 충족: 9개 골든 스냅샷이 커밋된 baseline JSON(옛 per-lang chunker 생성본)과 byte 대조해 통과(UPDATE_SNAPSHOTS 미설정 → drift 시 panic). chunker_version 라벨 9개 old==new(typescript→code-ts-ast-v1 등 약어 케이스 포함) → chunk_id 불변 → 재인덱싱 0. 비-AST chunker 무손상, panic 경로 unreachable.
clippy -D warnings 클린. 머지 동의합니다.