Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the LogExistenceRule to exempt synthetic KHI metadata spans—such as scene/inspection IDs, URLs, pointer expressions, wildcard globs, standard Kubernetes kinds/paths, and UTC time ranges—from log existence validation, and adds corresponding unit tests. The review feedback points out a potential issue in isKHIPointerExpression where spaces around the '=' sign are not handled correctly, and suggests trimming spaces from both the key and value after splitting.
| for _, raw := range segments { | ||
| key, val, ok := strings.Cut(strings.TrimSpace(raw), "=") | ||
| if !ok || !isKHIPointerKey(key) || !isASCIIDigits(val) { | ||
| return false | ||
| } | ||
| } |
There was a problem hiding this comment.
In isKHIPointerExpression, spaces are trimmed from the raw segment before calling strings.Cut. However, if there are spaces around the = sign (e.g., timelineId = 42), strings.Cut will produce a key with a trailing space ("timelineId ") and a value with a leading space (" 42"). This causes isKHIPointerKey and isASCIIDigits to return false, resulting in false positives during validation.
Trimming spaces from both the key and value after splitting is more robust and correctly handles spaces around the = sign.
| for _, raw := range segments { | |
| key, val, ok := strings.Cut(strings.TrimSpace(raw), "=") | |
| if !ok || !isKHIPointerKey(key) || !isASCIIDigits(val) { | |
| return false | |
| } | |
| } | |
| for _, raw := range segments { | |
| key, val, ok := strings.Cut(raw, "=") | |
| if !ok || !isKHIPointerKey(strings.TrimSpace(key)) || !isASCIIDigits(strings.TrimSpace(val)) { | |
| return false | |
| } | |
| } |
Go Quality Report (
|
| Metric | Result |
|---|---|
| Changed Scope | 1 prod file(s), 1 test file(s), 16 unit(s) |
| Patch Coverage | 99.2% (120/121 lines) |
| Mutation Score | 89.7% (157/175 killed, 18 survived) |
| Function Similarity | Advisory (2/12 new unit(s) matched across 3194 corpus units) |
Quality Rule Violations
| # | Rule | Status | Value (Limit) | Location | Subject |
|---|---|---|---|---|---|
[Q1] |
func_surviving_mutants |
ADVISORY |
1 (<= 0) |
pkg/server/workbench/log_existence_rule.go:166 |
isValidGlobToken |
[Q2] |
func_surviving_mutants |
ADVISORY |
6 (<= 0) |
pkg/server/workbench/log_existence_rule.go:187 |
buildWildcardGlobPattern |
[Q3] |
func_surviving_mutants |
ADVISORY |
1 (<= 0) |
pkg/server/workbench/log_existence_rule.go:198 |
isGlobChar |
[Q4] |
func_surviving_mutants |
ADVISORY |
2 (<= 0) |
pkg/server/workbench/log_existence_rule.go:261 |
parseDottedFieldPath |
[Q5] |
func_surviving_mutants |
ADVISORY |
4 (<= 0) |
pkg/server/workbench/log_existence_rule.go:276 |
stripFieldSubscripts |
[Q6] |
func_surviving_mutants |
ADVISORY |
3 (<= 0) |
pkg/server/workbench/log_existence_rule.go:300 |
isValidFieldKey |
[Q7] |
func_surviving_mutants |
ADVISORY |
1 (<= 0) |
pkg/server/workbench/log_existence_rule.go:388 |
(*logTermMatcher).logMatchesPattern |
[Q8] |
func_uncovered_lines |
ADVISORY |
1 (<= 0) |
pkg/server/workbench/log_existence_rule.go:389 |
(*logTermMatcher).logMatchesPattern |
[Q1] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:166 (isValidGlobToken)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 1 mutant(s) survived unit tests
- return false
+ return true[Q2] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:187 (buildWildcardGlobPattern)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 6 mutant(s) survived unit tests
- if i < len(rawParts)-1 && (i == 0 || part != "") {
+ if i < len(rawParts)-1 || (i == 0 || part != "") {- if i < len(rawParts)-1 && (i == 0 || part != "") {
+ if i <= len(rawParts)-1 && (i == 0 || part != "") {- if i < len(rawParts)-1 && (i == 0 || part != "") {
+ if i < len(rawParts) + 1 && (i == 0 || part != "") {- if i < len(rawParts)-1 && (i == 0 || part != "") {
+ if i < len(rawParts)-1 && (i == 0 && part != "") {- if i < len(rawParts)-1 && (i == 0 || part != "") {
+ if i < len(rawParts)-1 && (i != 0 || part != "") {- if i < len(rawParts)-1 && (i == 0 || part != "") {
+ if i < len(rawParts)-1 && (i == 0 || part == "") {[Q3] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:198 (isGlobChar)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 1 mutant(s) survived unit tests
- return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') ||
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c < 'Z') || (c >= '0' && c <= '9') ||[Q4] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:261 (parseDottedFieldPath)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 2 mutant(s) survived unit tests
- return nil, false
+ return nil, true- return nil, false
+ return nil, true[Q5] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:276 (stripFieldSubscripts)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 4 mutant(s) survived unit tests
- if idx < 0 {
+ if idx <= 0 {- return "", false
+ return "", true- return "", false
+ return "", true- return "", false
+ return "", true[Q6] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:300 (isValidFieldKey)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 3 mutant(s) survived unit tests
- return false
+ return true- if !((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z') || first == '_') {
+ if !((first >= 'a' && first <= 'z') || (first >= 'A' && first < 'Z') || first == '_') {- isValid := (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_'
+ isValid := (c >= 'a' && c <= 'z') || (c >= 'A' && c < 'Z') || (c >= '0' && c <= '9') || c == '-' || c == '_'[Q7] func_surviving_mutants — pkg/server/workbench/log_existence_rule.go:388 ((*logTermMatcher).logMatchesPattern)
- Why: Mutating operators or branches in this touched function did not cause any unit test to fail.
- Fix: Delete redundant guards first, or strengthen assertions (cmp.Diff on full outputs and boundary inputs).
- Detail: 1 mutant(s) survived unit tests
- if l == nil || l.ID == 0 {
+ if l == nil && l.ID == 0 {[Q8] func_uncovered_lines — pkg/server/workbench/log_existence_rule.go:389 ((*logTermMatcher).logMatchesPattern)
- Why: Substantive branches in touched functions were never executed by unit tests (boilerplate error guards are already excluded).
- Fix: Add focused table-driven test cases covering the unexecuted branch, or delete unreachable production code.
- Detail: 1 substantive uncovered line(s) across 1 span(s)
388 | if l == nil || l.ID == 0 {
389 | return falseSimilar Existing Go Functions (Advisory)
| New Unit | Top Existing Candidate | AST-Norm Score | Action |
|---|---|---|---|
isASCIIDigits (pkg/server/workbench/log_existence_rule.go:316) |
isAllDigits (pkg/task/inspection/common/csmcp/pod_identifier.go:138) |
0.947 |
Similar logic exists in another module; extract a shared helper or verify intentional symmetry. |
logTermMatcher.logMatchesPattern (pkg/server/workbench/log_existence_rule.go:387) |
logTermMatcher.logContainsTerm (pkg/server/workbench/log_existence_rule.go:368) |
0.973 |
Existing implementation in the same module; reuse or parameterize the existing code. |
Commit: 9db8f5a88ba7 · Cloud Build Logs
…ed field paths in logs
Summary
Part 1/5 of the
render_timelinesvisual clarity, evidence manifest, andkhi-investigationskill stack.LogExistenceRule(validate_report): single-token globs such asfrontend-pod-*orfrontend-*-7f8b9care compiled to token-scoped regexes and verified against actual inspection logs viaTrigramIndex+ regex matching (rejecting ungrounded prefixes likehallucinated-pod-*, bare*, or invalid characters).LogExistenceRuleto support dotted YAML/JSON field paths (e.g.,status.exitCode,$.metadata.labels.app,spec.containers[0].resources.limits.memory) by stripping optional$.and array subscripts ([0],[*]) and verifying every field key exists as an actual serialized YAML key (key:) in the inspection logs—with zero hardcoded Kubernetes kind or field-name allowlists and zero blind synthetic-ID/URL/time-range exemptions.pkg/server/workbench/log_existence_rule_test.go(both with and withoutTrigramIndex).Stack
feat(workbench): support log-grounded globs and dotted YAML field paths in validate_report(main<-push-qylzxxkzxpry)feat(mcp): unify annotation string IDs, fix subtree highlights, and emit resolved evidence manifest(push-qylzxxkzxpry<-push-zxtpyqnnnxrr)fix(mcp): harden Chrome timeline renderer timeouts, pixel cap, and warm session reuse(push-zxtpyqnnnxrr<-push-yyqtuxrlvmvt)feat(web): improve static timeline export clarity, leader routing, and inspection caching(push-yyqtuxrlvmvt<-push-yowxrnppozmk)feat(skills): guide visual-first two-layer reporting in khi-investigation skill(push-yowxrnppozmk<-push-nywmlvytopkk)Verification
go test -race ./pkg/server/workbench/...— PASSmake qa-fast-must QA_LANG=go— PASS (0 mustfix, 0 advisory, 0 skipped)make qa-slow-must QA_LANG=go— PASS (0 mustfix, 0 advisory, 0 skipped)make lint-go LINT_PKGS=./pkg/server/workbench/...— PASS (0 issues)