Repository navigation
refactor(ingestion): cleanup — stdlib reuse and shared component names - #21149
Conversation
…omponent names Four zero-risk reuse/simplification items from the pipeline review: - component: drop the contains wrapper around slices.Contains and call the stdlib directly at the three tokenizer call sites. - knowledge_compiler: mapKeys is now slices.Sorted(maps.Keys(m)); the sorted output contract (deterministic diagnostics) is pinned by a new guard test. - component: extract newExtractorChatConfig from the two resolveExtractorChat*Config functions, whose apiKey/baseURL extraction and config construction were byte-identical. Both functions were previously untested; the new tests cover the composite and tenant-default paths, mixed-case driver names, nil api configs, resolver errors, and the no-tenant/no-state early returns. - pipeline + schema: canonical component names (Parser/Extractor/Compiler) now live in the schema package — the one package both the component and pipeline layers already import. The component-side constants alias them, and the pipeline's failure-message switch and param predicates reference them instead of inline literals. An AST-based guard test fails the build if a bare component-name literal reappears in the pipeline package.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
yuzhichang
left a comment
There was a problem hiding this comment.
LGTM. The shared component-name constants, slices/maps replacements, and chat-config extraction are behavior-preserving; the added tests cover the moved helpers. No blocking findings.
What
Second batch of zero-risk cleanups from the ingestion pipeline review (the P0 items; the deep-copy consolidation was deferred as P1):
containswrapper aroundslices.Contains; the three tokenizer call sites call the stdlib directly.mapKeysis nowslices.Sorted(maps.Keys(m))instead of a hand-written loop +sort.Strings.newExtractorChatConfigfromresolveExtractorChatConfig/resolveExtractorChatDefaultConfig, whose apiKey/baseURL extraction and config construction were byte-identical. Both functions were previously untested; the new tests cover the composite and tenant-default paths, mixed-case driver names, nil api configs, resolver errors, and the no-tenant/no-state early returns.Parser/Extractor/Compiler) now live ininternal/ingestion/component/schema— the one package both the component and pipeline layers already import (they deliberately do not import each other). The component-side constants alias them; the pipeline's failure-message switch and param predicates reference them instead of inline literals. cpnID namespace prefixes (extractor:etc.) stay as literals with their existing comments.Why
AGENTS.md: prefer existing utilities over hand-rolled code, reduce public surface, collapse duplicate paths. Each item was re-verified against current
upstream/mainbefore implementation (several sibling findings from the same review had already been resolved upstream by #21073).How it was tested
TDD in an isolated worktree (
refactor/ingestion-p0-cleanup, single commit):TestPipelineHasNoBareComponentNameLiterals) failed on the four bare component-name literals in the pipeline package before the constant consolidation, and passes after — it now fails the build if a literal reappears.TestFormatComponentFailure(10 subtests: nil error, per-component timeout guidance, wrapped/mixed-case timeout detection, prefix stripping, empty names — the function had no direct test before),TestMapKeysReturnsSortedKeys(unordered/empty/nil/single/unicode/100-key inputs), and the new extractor chat-config tests.bash build.sh --test ./internal/ingestion/...fully green;bash build.sh --test-integrationon the affected packages produces a failure set identical to a clean base checkout (6 pre-existing failures aroundTestPipelineRun_Template*/TestTokenizerComponent_Embedding_*, unrelated to this diff).Risk / notes
mapKeysnow returning nil (instead of an empty non-nil slice) for an empty map — the single caller logs it viazap.Strings, where both render as[].lefthookreports the known 706 pre-existingrufferrors repo-wide (local ruff is stricter than the repo baseline; CI does not run ruff). All Go-relevant checks (gofmt, file hygiene) pass; no Python files are touched.