Conversation
…eckFlowHelper Improve test coverage for internal/difc from 93.8% to 99.7%. Functions targeted (previously under-covered): - getItems (58.3% → 95.8%): add tests for all error paths (path not found in map, final path not array, array navigation success, out-of-bounds index, non-numeric index, unexpected type, empty path segment) - AddIntegrityTags (0% → 100%): add basic and edge-case tests - Intersect (66.7% → 100%): add tests for non-nil intersection with tag removal - checkFlowHelper (90.9% → 100%): add nil-source/non-empty-target integrity case - resolve (88.5% → 100%): add tests for already-resolved early return and non-matching labeled path skip - Overall, GetItems, ToCollectionLabeledData: cover lazy-resolve branches - extractIndexFromPath: cover third HasPrefix branch and empty-remainder case - pathEntryToResource: cover nil-entry path - ParsePathLabels: cover invalid JSON error case - NewPathLabeledData: cover resolve-error propagation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds additional DIFC unit tests to increase branch/edge-case coverage for path-based labeling, label set operations, and agent integrity tag mutation.
Changes:
- Introduces a new
path_labels_coverage_test.gosuite covering numerousPathLabeledData/getItems/MCP unwrap branches. - Adds coverage for
Label.Intersectand an untestedcheckFlowHelperintegrity edge case. - Adds coverage for
AgentLabels.AddIntegrityTags, including duplicate/no-op scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| internal/difc/path_labels_coverage_test.go | New coverage-focused tests for path label resolution, MCP unwrap behavior, and several error branches. |
| internal/difc/labels_test.go | Adds tests for Label.Intersect and an uncovered checkFlowHelper integrity case. |
| internal/difc/agent_test.go | Adds tests for AgentLabels.AddIntegrityTags behavior and isolation from secrecy labels. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Comment on lines
+301
to
+306
| // HasPrefix("/items3", "/items/") = false | ||
| // HasPrefix("/items3", "/items") = true AND len > len → third branch | ||
| pld := &PathLabeledData{} | ||
| idx, err := pld.extractIndexFromPath("items3", "items") | ||
| require.NoError(t, err) | ||
| assert.Equal(t, 3, idx) |
Comment on lines
+387
to
+389
| items1 := pld.GetItems() | ||
|
|
||
| // Call GetItems again — hits the p.resolved guard (early return in resolve) |
internal/difc/labels_test.go
Outdated
| } | ||
|
|
||
| // TestLabel_Intersect tests the Intersect method which keeps only tags present | ||
| // in both labels. Previous coverage was 66.7%. |
internal/difc/agent_test.go
Outdated
Comment on lines
+1086
to
+1090
| // TestAgentLabels_AddIntegrityTags tests the AddIntegrityTags method which was | ||
| // previously at 0% coverage. | ||
| func TestAgentLabels_AddIntegrityTags(t *testing.T) { | ||
| tests := []struct { | ||
| name string |
Collaborator
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Contributor
…ments Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
…omments (#1863) `extractIndexFromPath` had a buggy third `HasPrefix` branch that matched `/items3` against itemsPath `/items`, incorrectly associating it as index 3. Per RFC 6901, `/items3` is a distinct key — only paths separated by `/` (e.g., `/items/3`) should match. ## Changes - **`path_labels.go`**: Remove the erroneous third branch; valid matches now require `itemsPath + "/"` prefix - **`path_labels_coverage_test.go`**: - Rename `TestExtractIndexFromPath_ThirdHasPrefix` → `TestExtractIndexFromPath_NoSlashSeparator`; flip expectation from success to error - Fix `TestPathLabeledData_ResolveNotCalledTwice` comment — the guard being exercised is in `GetItems()`, not inside `resolve()` - **`labels_test.go`**, **`agent_test.go`**: Remove stale historical coverage percentages from test comments ```go // Before: "/items3" incorrectly matched itemsPath "/items" → index 3 } else if strings.HasPrefix(path, itemsPath+"/") { remainder = strings.TrimPrefix(path, itemsPath) } else if strings.HasPrefix(path, itemsPath) && len(path) > len(itemsPath) { // removed remainder = path[len(itemsPath):] // removed } else { // After: only explicit "/" separator matches } else if strings.HasPrefix(path, itemsPath+"/") { remainder = strings.TrimPrefix(path, itemsPath) } else { ``` <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)
This was referenced Mar 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Test Coverage Improvement:
internal/difcpackageSummary
Comprehensive test coverage improvement for the
internal/difcpackage, focusing ongetItemsas the primary target (most complex function with lowest coverage) plus several closely related under-tested functions.getItemsAddIntegrityTagsIntersectcheckFlowHelperresolveOverallGetItemsToCollectionLabeledDataextractIndexFromPathpathEntryToResourceParsePathLabelsNewPathLabeledDataWhy
getItems?getItems(internal/difc/path_labels.go:192) was selected as the primary target:resolve()which drives the entire path-label systemTests Added
New file:
internal/difc/path_labels_coverage_test.go(28 test functions)Covers all missing branches in
getItems:[]interface{}→ successCovers lazy-resolve branches:
Overall()called beforeGetItems()— lazy resolveGetItems()called on unresolved data — lazy resolveToCollectionLabeledData()on unresolved data — lazy resolveCovers other gaps:
resolve()early return when already resolved (direct call)resolve()skips labeled paths that don't match items_pathpathEntryToResource(nil)→ "unlabeled" resourceParsePathLabelswith invalid JSON → errorNewPathLabeledDataresolve-error propagationextractIndexFromPaththird HasPrefix branch (no slash separator)extractIndexFromPathempty remainder → "no index" errorunwrapMCPResponsewhen content[0] is not a mapOverall()with empty items collectionOverall()union semantics across multiple itemsToResult()preserves original MCP-wrapped dataAdditions to
internal/difc/agent_test.goAddIntegrityTags— was at 0% coverage; now 100%Additions to
internal/difc/labels_test.goIntersect— covers the non-nil intersection path with tag removalcheckFlowHelpernil-source + non-empty-target + integrity mode (lines 213-215 previously untested)Coverage Report
Remaining gap (0.3%):
GetOrCreate.double-check-after-write-lock— the concurrent double-check-locking pattern that requires precise goroutine race timing to cover deterministically. This is intentional defensive code and the existing 100-goroutine concurrent test provides sufficient confidence.Test Execution
All 3 modified/new test files compile and pass cleanly. Tests follow the project's conventions:
requirefor critical assertions (stop on failure)assertfor non-critical assertions (continue on failure)TestFunctionName_ScenariopatternGenerated by Test Coverage Improver
Previous run:
internal/guard.parseLabelAgentResponse(2026-03-12, 43.3% → 100%)This run:
internal/difc.getItems+ difc package (2026-03-13, 93.8% → 99.7%)Warning
The following domains were blocked by the firewall during workflow execution:
go.yaml.ingolang.orggopkg.ininvalidhostthatdoesnotexist12345.comproxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.