semantic cache: min similarity + fallback logging - #5742
kohlivrinda wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
🚧 Files skipped from review as they are similar to previous changes (10)
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change adds a configurable ChangesSemantic similarity threshold
Estimated code review effort: 3 (Moderate) | ~25 minutes Mergeability Score: ⚪ Minimal · up to The current changes introduce no evidenced merge-blocking risk, so the PR is merge-ready after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant RoutingEngine
participant SemanticClassifier
participant EmbeddingBackend
participant FallbackClassifier
participant RoutingLog
RoutingEngine->>SemanticClassifier: classify request
SemanticClassifier->>EmbeddingBackend: query nearest nonnegative-similarity exemplar
EmbeddingBackend-->>SemanticClassifier: return tier and similarity score
SemanticClassifier-->>RoutingEngine: return acceptance or timeout result
alt rejected or timed out
RoutingEngine->>FallbackClassifier: apply fallback classifier
RoutingEngine->>RoutingLog: record rejection or timeout diagnostic
else accepted
RoutingEngine->>RoutingLog: record matched exemplar
end
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
fad423e to
7166123
Compare
7d1b1d3 to
3767315
Compare
3767315 to
28e1a04
Compare
7166123 to
0f9b878
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@plugins/governance/main.go`:
- Around line 753-771: Preserve the rejected semanticResult state through the
fallback decision instead of treating it as unavailable when Fallback() is none.
Update the fallback-disabled handling near the semantic classification branch to
emit a message identifying the rejected result and its below-MinSimilarity
score, while retaining the existing unavailable message only for cases where
classification truly did not produce a result.
🪄 Autofix (Beta)
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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: e1837271-32b1-4b84-897e-8873ae059635
📒 Files selected for processing (6)
framework/configstore/complexityconfig.goframework/configstore/complexityconfig_test.goplugins/governance/complexity/semanticclassifier.goplugins/governance/complexity/semanticclassifier_test.goplugins/governance/main.gotransports/config.schema.json
0f9b878 to
70c8105
Compare
28e1a04 to
1f63f63
Compare
70c8105 to
3497493
Compare
1f63f63 to
05e4036
Compare
3497493 to
a0da8fb
Compare
a0da8fb to
d3e61c4
Compare
c62e576 to
f668fe4
Compare
03ac36e to
f7a2a26
Compare
f668fe4 to
1a0bc54
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
1a0bc54 to
b7f532c
Compare
f7a2a26 to
3b2841d
Compare
b7f532c to
ded8846
Compare
3b2841d to
879943d
Compare
879943d to
ac97779
Compare
ded8846 to
5fba23f
Compare
ac97779 to
abec8d9
Compare
5fba23f to
32b5ba8
Compare
32b5ba8 to
d1121fc
Compare
1c09e09 to
bd540fe
Compare
d1121fc to
c0f5bdd
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
framework/configstore/complexityconfig.go (1)
222-237: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winSerialize
Timeoutas milliseconds.Line 222 writes a duration string such as
"100ms". Config JSON duration fields must use milliseconds. Emitfloat64(c.Timeout) / float64(time.Millisecond)as the JSON value. Keep the current dual-format decoder so existing stored strings remain readable.As per coding guidelines, “Config duration fields serialized as JSON must use milliseconds even when represented as
time.Durationin Go.”Proposed fix
func (c ComplexitySemanticConfig) MarshalJSON() ([]byte, error) { type alias ComplexitySemanticConfig - var timeout string + var timeout float64 if c.Timeout != 0 { - timeout = c.Timeout.String() + timeout = float64(c.Timeout) / float64(time.Millisecond) } return json.Marshal(struct { - Timeout string `json:"timeout,omitempty"` + Timeout float64 `json:"timeout,omitempty"` alias }{🤖 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 `@framework/configstore/complexityconfig.go` around lines 222 - 237, Update ComplexitySemanticConfig.MarshalJSON to serialize Timeout as a numeric millisecond value using the time.Duration-to-milliseconds conversion, rather than a duration string. Preserve the existing omitempty behavior for zero Timeout and leave the dual-format decoder unchanged so previously stored strings remain readable.Source: Coding guidelines
ui/lib/types/complexityRouter.ts (1)
19-30: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPreserve
semantic.fallbackwhen saving the form.The resolver strips
fallbackbeforeupdateConfig(values), so saving a config with"none"restores the backend default"lexical".
- Add
fallback?: "lexical" | "none"toSemanticConfig.- Add
fallback: z.enum(["lexical", "none"]).optional()to the semantic schema.🤖 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 `@ui/lib/types/complexityRouter.ts` around lines 19 - 30, Preserve the semantic fallback value when saving by adding optional fallback support to SemanticConfig in ui/lib/types/complexityRouter.ts and to the semantic validation schema in ui/app/workspace/complexity-router/page.tsx (anchor lines 19-30; sibling lines 106-115), restricting values to "lexical" or "none" so the resolver passes it through to updateConfig(values).
🤖 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.
Outside diff comments:
In `@framework/configstore/complexityconfig.go`:
- Around line 222-237: Update ComplexitySemanticConfig.MarshalJSON to serialize
Timeout as a numeric millisecond value using the time.Duration-to-milliseconds
conversion, rather than a duration string. Preserve the existing omitempty
behavior for zero Timeout and leave the dual-format decoder unchanged so
previously stored strings remain readable.
In `@ui/lib/types/complexityRouter.ts`:
- Around line 19-30: Preserve the semantic fallback value when saving by adding
optional fallback support to SemanticConfig in ui/lib/types/complexityRouter.ts
and to the semantic validation schema in
ui/app/workspace/complexity-router/page.tsx (anchor lines 19-30; sibling lines
106-115), restricting values to "lexical" or "none" so the resolver passes it
through to updateConfig(values).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 111ddd87-fbb1-47d4-959f-8846e1ea2a56
📒 Files selected for processing (6)
framework/configstore/complexityconfig.goframework/configstore/complexityconfig_test.goplugins/governance/complexity/semanticclassifier.goplugins/governance/complexity/semanticclassifier_test.goui/app/workspace/complexity-router/page.tsxui/lib/types/complexityRouter.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- plugins/governance/complexity/semanticclassifier_test.go
- framework/configstore/complexityconfig_test.go
- plugins/governance/complexity/semanticclassifier.go
bd540fe to
6048a47
Compare
1f64df7 to
e459d95
Compare
6048a47 to
c439781
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |

Summary
Briefly explain the purpose of this PR and the problem it solves.
Changes
Type of change
Affected areas
How to test
Describe the steps to validate this change. Include commands and expected outcomes.
If adding new configs or environment variables, document them here.
Screenshots/Recordings
If UI changes, add before/after screenshots or short clips.
Breaking changes
If yes, describe impact and migration instructions.
Related issues
Link related issues and discussions. Example: Closes #123
Security considerations
Note any security implications (auth, secrets, PII, sandboxing, etc.).
Checklist
docs/contributing/README.mdand followed the guidelines