Skip to content

feat(workbench): support log-grounded globs and dotted YAML field paths in validate_report - #1314

Open
kyasbal wants to merge 2 commits into
mainfrom
push-qylzxxkzxpry
Open

kyasbal wants to merge 2 commits into
mainfrom
push-qylzxxkzxpry

Conversation

@kyasbal

@kyasbal kyasbal commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Part 1/5 of the render_timelines visual clarity, evidence manifest, and khi-investigation skill stack.

  • Adds log-grounded wildcard glob matching in LogExistenceRule (validate_report): single-token globs such as frontend-pod-* or frontend-*-7f8b9c are compiled to token-scoped regexes and verified against actual inspection logs via TrigramIndex + regex matching (rejecting ungrounded prefixes like hallucinated-pod-*, bare *, or invalid characters).
  • Extends composite span verification in LogExistenceRule to 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.
  • Adds comprehensive unit test coverage in pkg/server/workbench/log_existence_rule_test.go (both with and without TrigramIndex).

Stack

  1. This PR (feat(workbench): support log-grounded globs and dotted YAML field paths in validate_report #1314): feat(workbench): support log-grounded globs and dotted YAML field paths in validate_report (main <- push-qylzxxkzxpry)
  2. feat(mcp): unify annotation string IDs, fix subtree highlights, and emit resolved evidence manifest #1315: feat(mcp): unify annotation string IDs, fix subtree highlights, and emit resolved evidence manifest (push-qylzxxkzxpry <- push-zxtpyqnnnxrr)
  3. fix(mcp): harden Chrome timeline renderer timeouts, pixel cap, and warm session reuse #1316: fix(mcp): harden Chrome timeline renderer timeouts, pixel cap, and warm session reuse (push-zxtpyqnnnxrr <- push-yyqtuxrlvmvt)
  4. feat(web): improve static timeline export clarity, leader routing, and inspection caching #1317: feat(web): improve static timeline export clarity, leader routing, and inspection caching (push-yyqtuxrlvmvt <- push-yowxrnppozmk)
  5. feat(skills): guide visual-first two-layer reporting in khi-investigation skill #1313: feat(skills): guide visual-first two-layer reporting in khi-investigation skill (push-yowxrnppozmk <- push-nywmlvytopkk)

Verification

  • go test -race ./pkg/server/workbench/... — PASS
  • make 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)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +493 to +498
for _, raw := range segments {
key, val, ok := strings.Cut(strings.TrimSpace(raw), "=")
if !ok || !isKHIPointerKey(key) || !isASCIIDigits(val) {
return false
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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
}
}
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Go Quality Report (origin/main) — ✅ PASS (0 blocking, 8 advisory finding(s))

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 false

Similar 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

@kyasbal kyasbal changed the title fix(workbench): exempt KHI synthetic IDs, globs, and K8s refs in validate_report Dec 1, 2026
@kyasbal
kyasbal added this pull request to stack #1322 December 1, 2026 04:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant