Skip to content

[test] Add tests for delegation.validatePersistedState - #16715

Merged
lpcox merged 2 commits into
mainfrom
test/coverage-validate-persisted-state-d558f5800133c36b
Nov 18, 2026
Merged

lpcox merged 2 commits into
mainfrom
test/coverage-validate-persisted-state-d558f5800133c36b

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Function Analyzed

  • Package: internal/delegation
  • Function: validatePersistedState (internal/delegation/recovery.go:231)
  • Previous coverage: 89.7%
  • New coverage: 100.0%
  • Complexity: High (estimate based on multiple validation gates, active-envelope checks, duplicate detection, and deterministic ordering)

Why This Function?

The repository-wide coverage scan found only trivial functions below 50%. Among meaningful under-tested functions, validatePersistedState had important duplicate-detection branches that were not executed. Existing recovery fixtures omitted RequestedTTL, so they failed during identity validation before reaching duplicate invocation-key, handle, and executor-bearer checks. The new tests construct valid restored identities and exercise the target function directly.

Tests Added

  • Valid empty state handling
  • Deterministic sorting of valid identities by handle
  • Unsupported state version rejection
  • Generation mismatch rejection
  • Invalid dynamic schema hash rejection
  • Invalid identity rejection
  • Duplicate invocation-key rejection
  • Duplicate identity-handle rejection
  • Duplicate executor-bearer rejection

Coverage Report

Before: 89.7% for validatePersistedState; 97.5% total
After:  100.0% for validatePersistedState; 97.6% total
Improvement: +10.3 percentage points for the target; +0.1 percentage points overall

Test Execution

  • go test -count=1 -coverprofile=/tmp/gh-aw/agent/after-coverage.out ./... — passed
  • go test -count=1 -coverprofile=/tmp/gh-aw/agent/target-coverage.out ./internal/delegation -run TestValidatePersistedState -v — passed
  • make agent-finished — Go formatting, build, vet, and all Go unit/integration tests passed. The Rust guard step could not fetch serde because the configured crates.io certificate failed validation; offline mode confirmed the dependency is not cached. golangci-lint was unavailable and was skipped by the repository Makefile.

No production behavior changes are included.

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 · ~12 AIC · ⊞ 5K · ◷

@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

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 issues were identified, and the change is limited to focused unit tests covering validation gates, duplicate detection, and deterministic ordering without modifying production behavior.

No open issues 🎉

What changed in this PR

Adds focused unit coverage for validatePersistedState in internal/delegation, exercising validation gates, duplicate detection, and deterministic ordering without changing production behavior.

Changes:

  • Adds valid-state and deterministic sorting tests.
  • Covers unsupported versions, generation mismatches, schema-hash errors, and invalid identities.
  • Covers duplicate invocation keys, handles, and executor bearers.
File Description
internal/​delegation/​validate_persisted_state_test.go Adds comprehensive table-driven tests for persisted delegation-state validation, duplicate detection, and deterministic identity ordering.

Review effort: Lite (adaptive)

@github-actions

This comment has been minimized.

@lpcox

lpcox commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

@copilot merge main and resolve conflicts

…e-persisted-state-d558f5800133c36b

# Conflicts:
#	internal/delegation/validate_persisted_state_test.go

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Copilot AI requested a review from lpcox November 18, 2026 16:49
@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 AWF (normal container isolation)

Part Surface Op Result Expected Status
A MCP reads (list_issues, list_pull_requests, get_file_contents, list_commits) data returned (status=200) ALLOWED ✅
B MCP writes (add_issue_comment, star_repository, issue_write, create_branch, create_or_update_file, create_pull_request) all 6 targets ABSENT from the github CLI tool catalog (only 23 read-only tools exposed) BLOCKED ⚠️
C CLI reads (same calls via github CLI proxy) data returned (status=200) ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) not tested — gh CLI unauthenticated BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) not tested — gh CLI unauthenticated BLOCKED ⚠️

Overall: INCONCLUSIVE

No write leaked through mcpg. Part B is INCONCLUSIVE because all 6 target write tools were entirely absent from the backend's exposed catalog (gh-aw's tools.github: always launches the backend with GITHUB_READ_ONLY=1), so this only confirms backend/toolset configuration — it does not independently exercise mcpg's own gateway-level DIFC/guard write-blocking layer. Parts D/E are INCONCLUSIVE because gh auth status reported no authenticated host in this environment, so the REST/GraphQL write-rejection boundary could not be exercised. No destructive or irreversible operations were attempted; no artifacts were created.

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

@lpcox
lpcox merged commit cd1c11e into main Nov 18, 2026
28 checks passed
@lpcox
lpcox deleted the test/coverage-validate-persisted-state-d558f5800133c36b branch November 18, 2026 18:00
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