Skip to content

Centralize launcher connection storage and start recording - #16753

Merged
lpcox merged 4 commits into
mainfrom
copilot/duplicate-code-launcher-connection-store-record
Nov 18, 2026
Merged

lpcox merged 4 commits into
mainfrom
copilot/duplicate-code-launcher-connection-store-record

Conversation

@lpcox

@lpcox lpcox commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Three launch paths duplicate shutdown checks, connection storage, and start recording, risking drift in cleanup and lock ordering.

  • Shared helper: Route HTTP, stdio, and session launches through storeConnectionIfOpen, with closures selecting the storage destination.
  • Preserved semantics: Close rejected connections after unlocking; store accepted connections under l.mu; call recordStart only after releasing it.
  • Regression coverage: Check both storage destinations, closed-launcher rejection, and store-before-record ordering.

@lpcox lpcox changed the title [WIP] Refactor duplicate code in launcher connection handling Centralize launcher connection storage and start recording Nov 18, 2026
@lpcox
lpcox marked this pull request as ready for review November 18, 2026 15:32
Copilot AI adaptive review requested due to automatic review settings November 18, 2026 15:32
@github-actions

This comment has been minimized.

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.

🟡 Changes recommended

The shutdown test’s TryLock assertion cannot distinguish read locks from write locks, so it can pass without verifying the exclusive locking required for map writes.

1 open issue
What changed in this PR

Centralizes connection storage and start recording across launcher paths to address #16691, preserving shutdown cleanup and lock ordering.

Changes:

  • Routes HTTP, stdio, and session launches through storeConnectionIfOpen.
  • Adds regression tests for storage destinations, closed-launcher rejection, locking, and store-before-record ordering.
File Description
internal/​launcher/​launcher.go Replaces three duplicated store-and-record blocks with a shared helper.
internal/​launcher/​launcher_shutdown_test.go Adds tests for the helper’s storage and shutdown behavior.

Review effort: Max (adaptive)

Replace exclusive lock with read lock in storeConnectionIfOpen test.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@lpcox

lpcox commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@copilot merge main and resolve conflicts

…e-launcher-connection-store-record

# Conflicts:
#	internal/launcher/launcher.go

Co-authored-by: copilot-swe-agent[bot] <[email protected]>

Copilot AI commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

@copilot merge main and resolve conflicts

Merged main and resolved the launcher conflict in 167ca6d. The launcher race tests and make agent-finished passed; golangci-lint was skipped because it wasn’t installed.

@github-actions

Copy link
Copy Markdown
Contributor

🔒 mcpg Read-Only Stress — default

Surface coverage: MCP tool calls + proxied CLI (REST) + GraphQL mutations
Isolation runtime: default AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data (200) ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all 6 targets absent from exposed tool catalog BLOCKED ⚠️
C CLI reads (list_issues, get_file_contents via proxied github CLI) data ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh not authenticated — not exercised BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh not authenticated — not exercised BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: none of add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request appear in the exposed github MCP tool catalog (only 23 read-only tools listed). Consistent with gh-aw's GITHUB_READ_ONLY=1 backend default, so this does not independently confirm mcpg's own gateway-level blocking layer for these specific write targets.

⚠️ Parts D/E: gh auth status reported no authenticated host, so REST/GraphQL write attempts against GitHub's API could not be executed to test the token-scope boundary.

No write of any kind leaked through in this run.

🔒 mcpg read-only stress (default AWF runtime) by Read-Only Stress: default runtime

@lpcox
lpcox merged commit 12754d6 into main Nov 18, 2026
30 checks passed
@lpcox
lpcox deleted the copilot/duplicate-code-launcher-connection-store-record branch November 18, 2026 16:51
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.

[duplicate-code] Duplicate Code Pattern: Launcher Connection Store-and-Record Block

3 participants