Skip to content

[test] Add tests for cmd.postRun - #16614

Merged
lpcox merged 1 commit into
mainfrom
coverage/cmd-postrun-be32e8b7c35d568b
Nov 15, 2026
Merged

lpcox merged 1 commit into
mainfrom
coverage/cmd-postrun-be32e8b7c35d568b

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Function Analyzed

  • Package: internal/cmd
  • Function: postRun
  • Previous Coverage: 50.0%
  • New Coverage: 100.0%
  • Complexity: Medium — lifecycle cleanup with an error-reporting branch

Why This Function?

The repository-wide coverage report identified postRun as the lowest-coverage non-trivial function. Its logger cleanup warning path was untested, despite being the CLI's final cleanup hook.

Tests Added

  • Happy path with no initialized loggers
  • Successful cleanup of initialized gateway loggers
  • Idempotent repeated cleanup
  • Cleanup failure and warning-log behavior

A small package-level cleanup seam keeps the production behavior unchanged while allowing the error branch to be exercised deterministically.

Coverage Report

Before: 50.0%
After:  100.0%
Improvement: +50.0 percentage points
Overall repository coverage: 97.5%

Test Execution

  • go test -v -coverprofile=/tmp/gh-aw/agent/cmd-coverage.out ./internal/cmd -run TestPostRun — passed
  • go test -coverprofile=coverage.out ./... — passed; postRun 100.0%, total 97.5%
  • make agent-finished — Go build, vet, and all Go unit/integration tests passed; golangci-lint was unavailable and skipped by the Makefile
  • Rust guard tests could not resolve crates because the sandbox's crates.io TLS certificate does not match its configured endpoint; offline mode also lacked the serde package

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • example.com
  • nonexistent.local
  • slow.example.com
  • thishostdoesnotexist12345.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "example.com"
    - "nonexistent.local"
    - "slow.example.com"
    - "thishostdoesnotexist12345.com"

See Network Configuration for more information.

Generated by Test Coverage Improver · copilot · routed: gpt56 xhigh · ~9 AIC · ⊞ 5K · ◷

@lpcox
lpcox marked this pull request as ready for review November 15, 2026 17:02
Copilot AI adaptive review requested due to automatic review settings November 15, 2026 17:02

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.

🟢 Approval recommended

No active review issues are identified, with deterministic coverage for successful, repeated, uninitialized, and failed logger-cleanup scenarios including warning behavior.

No open issues 🎉

What changed in this PR

Adds deterministic lifecycle tests for internal/cmd.postRun, covering successful logger cleanup, repeated invocation, and cleanup-error warning behavior.

Changes:

  • Added an injectable logger-cleanup seam for deterministic failure testing.
  • Added coverage for uninitialized, successful, repeated, and failed cleanup scenarios.
  • Verified warning logging without panics on cleanup failure.
File Description
internal/​cmd/​root.go Routes postRun logger cleanup through an injectable function while preserving normal production behavior.
internal/​cmd/​root_lifecycle_test.go Adds tests covering successful, repeated, uninitialized, and failed logger cleanup scenarios.

Review effort: Lite (dynamic)

@github-actions

Copy link
Copy Markdown
Contributor Author

🔒 mcpg Read-Only Stress — default

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

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned ALLOWED ✅
B MCP writes (issue_write, add_issue_comment reaction/body, star_repository, create_branch, create_or_update_file, create_pull_request) all unknown tool (-32602); absent from the 23-tool read-only catalog BLOCKED ⚠️
C CLI reads (github CLI list_issues/list_pull_requests/get_file_contents/list_commits) data returned ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh not authenticated — not attempted BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) gh not authenticated — not attempted BLOCKED ⚠️

Overall: INCONCLUSIVE

⚠️ Part B: all targeted write tools were entirely absent from the gateway-exposed catalog (gh-aw's tools.github: backend always runs with GITHUB_READ_ONLY=1), so refusal only proves backend/toolset configuration, not mcpg's independent gateway-level DIFC/guard enforcement.
⚠️ Parts D/E: the gh CLI was not authenticated in this environment (You are not logged into any GitHub hosts), so the token-scope write-boundary could not be exercised.

No write of any kind succeeded or leaked through on this runtime; no artifacts were created.

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

@lpcox
lpcox merged commit f6bbe10 into main Nov 15, 2026
26 checks passed
@lpcox
lpcox deleted the coverage/cmd-postrun-be32e8b7c35d568b branch November 15, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants