Repository navigation
Refactor(task): collapse duplicated debug-result helpers - #17937
Conversation
- #2: export IsVectorKey from debug_result_dsl.go and have the golden compare tool reuse it instead of a weaker inline check that only caught q_<dim>_vec and let fixed legacy keys (vector/embedding/feature/q_vec) leak into the diff. - #3: parameterize deepCopy(v, stripVector) and delete the near-duplicate deepCopyStrip; vector stripping is now a single flag, no second walker. - #4: unify the two identical switch cases in lookupComponentOutput into a shared found/ok resolution; nested-state and flat-fallback semantics kept. Tests: add TestSanitizeProcessed_StripsVectorKeys (red->green) and update existing deepCopy / deepCopyStrip_call references. task/indexdoc/tool all pass. Co-Authored-By: CodeBuddy Code <[email protected]>
📝 WalkthroughWalkthroughThe PR consolidates vector-key detection into ChangesVector-aware debug output handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
internal/ingestion/task/tool/compare_pipeline_golden_test.go (1)
23-29: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration history from the test comment.
Describe the current
sanitizeProcessedcontract. Do not document the removed inline implementation.As per coding guidelines, Go doc comments must align with the current runtime path rather than migration history.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@internal/ingestion/task/tool/compare_pipeline_golden_test.go` around lines 23 - 29, Update the comment above TestSanitizeProcessed_StripsVectorKeys to describe only the current sanitizeProcessed behavior and its contract: vector keys are removed using the shared task.IsVectorKey logic. Remove references to the previous inline check, legacy keys, migration history, and implementation changes.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/ingestion/task/tool/compare_pipeline_golden_test.go`:
- Around line 34-37: Update the test fixture and expected-removal list in the
relevant comparison test to include the legacy vector key feature in both
places. Ensure the assertion loop verifies that feature is removed while
preserving the existing coverage for the other vector keys.
---
Nitpick comments:
In `@internal/ingestion/task/tool/compare_pipeline_golden_test.go`:
- Around line 23-29: Update the comment above
TestSanitizeProcessed_StripsVectorKeys to describe only the current
sanitizeProcessed behavior and its contract: vector keys are removed using the
shared task.IsVectorKey logic. Remove references to the previous inline check,
legacy keys, migration history, and implementation changes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2bee03e1-2475-423c-88e5-e830c1f703f7
📒 Files selected for processing (6)
internal/ingestion/task/debug_log_sink.gointernal/ingestion/task/debug_log_sink_test.gointernal/ingestion/task/debug_result_dsl.gointernal/ingestion/task/debug_result_dsl_test.gointernal/ingestion/task/tool/compare_pipeline_golden.gointernal/ingestion/task/tool/compare_pipeline_golden_test.go
| "vector": []float64{0.1}, | ||
| "embedding": []float64{0.2}, | ||
| "q_1024_vec": []float64{0.3}, | ||
| "q_vec": []float64{0.4}, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Cover the feature vector key.
The comment states that feature is a fixed legacy vector key. The fixture does not include it. The assertion loop does not verify that it is removed. Add feature to both lists so this test protects the full documented contract.
Proposed fix
"vector": []float64{0.1},
"embedding": []float64{0.2},
+ "feature": []float64{0.25},
"q_1024_vec": []float64{0.3},
"q_vec": []float64{0.4},
@@
- for _, k := range []string{"vector", "embedding", "q_1024_vec", "q_vec"} {
+ for _, k := range []string{"vector", "embedding", "feature", "q_1024_vec", "q_vec"} {Also applies to: 49-53
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/ingestion/task/tool/compare_pipeline_golden_test.go` around lines 34
- 37, Update the test fixture and expected-removal list in the relevant
comparison test to include the legacy vector key feature in both places. Ensure
the assertion loop verifies that feature is removed while preserving the
existing coverage for the other vector keys.
|
LGTM |
Summary
Collapses three duplicated/dead code smells in the canvas debug-result path of
internal/ingestion/task(remaining findings #2/#3/#4 from the package CTO review):isVectorKey(the full stripper: fixed legacy keysvector/embedding/feature/q_vecplus theq_<dim>_vecpattern) was re-implemented as a weaker inline copy in the golden-compare tool (tool/compare_pipeline_golden.go) that only matchedq_<dim>_vecand let real vectors leak into the diff. Exported asIsVectorKeyand reused by the tool.deepCopyanddeepCopyStripwere identical walkers differing only in vector stripping. ParameterizeddeepCopy(v any, stripVector bool) anyand deleteddeepCopyStrip.lookupComponentOutputhad two switch cases with identical bodies (both themap[string]map[string]anyandmap[string]anystate shapes). Unified into a singlefound/okresolution; nested-state and flat-fallback semantics unchanged.Why
These are the remaining items from the
internal/ingestion/taskreview. They remove duplicated logic, a second recursive walker, and copy-paste branching, and make the golden-compare tool agree with the production vector stripping rule.Test plan
internal/ingestion/task/tool/compare_pipeline_golden_test.go:TestSanitizeProcessed_StripsVectorKeys(red→green) asserts the tool now strips the full vector-key set (vector/embedding/feature/q_vec/q_<dim>_vec).debug_result_dsl_test.go/debug_log_sink_test.goupdated for the newdeepCopy(v, stripVector)signature../build.sh --test ./internal/ingestion/task/...passes; the full unit suite is green.Changes