Skip to content

Refactor DIFC helper placement and extract response content-rewrite helpers from jqschema middleware#8000

Merged
lpcox merged 1 commit into
mainfrom
copilot/refactor-semantic-function-clustering
Jun 23, 2026
Merged

Refactor DIFC helper placement and extract response content-rewrite helpers from jqschema middleware#8000
lpcox merged 1 commit into
mainfrom
copilot/refactor-semantic-function-clustering

Conversation

Copilot AI commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

This addresses two persistent structural outliers from semantic function clustering: a DIFC-only helper living in tool registration code, and a cohesive content-rewrite block embedded in the large jqschema.go middleware file. The refactor keeps behavior unchanged while tightening package boundaries and discoverability.

  • DIFC helper colocation (internal/server)

    • Moved isSingularReadTool(toolName string) bool into difc_log.go with the rest of DIFC filtering/error helpers.
    • Keeps DIFC classification logic and logging context (logDifcLog) in one module; tool_registry.go remains focused on registration responsibilities.
  • Content rewrite extraction (internal/middleware)

    • Extracted the rewrite cluster out of jqschema.go into content_rewrite.go:
      • rewriteFilteredTextPayload
      • rewriteEnvelopeTextPayload
      • rewriteFirstContentItem
      • rewriteContentItemText
    • Leaves jqschema.go centered on jq compile/apply flow and middleware orchestration.
  • Tests and module shape

    • Existing middleware and DIFC tests continue to exercise these paths; rewrite-helper coverage remains in dedicated rewrite-focused tests.
    • Resulting structure mirrors prior payload.go/schema.go separation and improves future maintainability of filtering logic.
// internal/server/difc_log.go
func isSingularReadTool(toolName string) bool {
	singular := !strings.HasPrefix(toolName, "list_") && !strings.HasPrefix(toolName, "search_")
	logDifcLog.Printf("isSingularReadTool: toolName=%s, singular=%v", toolName, singular)
	return singular
}

GitHub Advanced Security started work on behalf of lpcox June 23, 2026 22:22 View session
GitHub Advanced Security finished work on behalf of lpcox June 23, 2026 22:22
Copilot AI changed the title [WIP] Refactor semantic function clustering analysis to address outliers Refactor DIFC helper placement and extract response content-rewrite helpers from jqschema middleware Jun 23, 2026
Copilot AI requested a review from lpcox June 23, 2026 22:28
Copilot finished work on behalf of lpcox June 23, 2026 22:28
@lpcox lpcox marked this pull request as ready for review June 23, 2026 22:44
Copilot AI review requested due to automatic review settings June 23, 2026 22:44

Copilot AI 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.

Copilot wasn't able to review any files in this pull request.

@lpcox lpcox merged commit 9957c2f into main Jun 23, 2026
31 checks passed
@lpcox lpcox deleted the copilot/refactor-semantic-function-clustering branch June 23, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants