Skip to content

[test] Add tests for delegation.loadStoreAt - #16934

Merged
lpcox merged 1 commit into
mainfrom
coverage/delegation-loadstoreat-tests-c534717c6d5bb41a
Nov 20, 2026
Merged

lpcox merged 1 commit into
mainfrom
coverage/delegation-loadstoreat-tests-c534717c6d5bb41a

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Function Analyzed

  • Package: internal/delegation
  • Function: loadStoreAt
  • Previous Coverage: 90.3%
  • New Coverage: 100.0%
  • Complexity: High (estimated from initialization, filesystem I/O, integrity validation, fail-closed recovery, and identity reconstruction branches; no measured cyclomatic score was used)

Why This Function?

The repository-wide baseline was 97.7%. The only function below 50% was an intentional no-op logger, so it was excluded. loadStoreAt was the lowest-coverage substantive recovery coordinator and had two untested, security-relevant failure paths: invalid envelope initialization and non-ENOENT state-file read errors.

Tests Added

  • Envelope validation fails before state-file access and returns the initialization error.
  • A state path that is a directory fails closed with recovery marked incomplete and all identity indexes empty.
  • Existing recovery tests continue to cover successful reconstruction, missing files, corruption, expiry, duplicate identities, schema bounds, and envelope mismatches.

Coverage Report

Before: loadStoreAt 90.3%
After:  loadStoreAt 100.0%
Overall: 97.7% (rounded unchanged)

Test Execution

  • go test ./internal/delegation -run TestLoadStoreAt_FailsClosedOnInitializationAndReadErrors -v — passed
  • go test -race ./internal/delegation -run TestLoadStoreAt_FailsClosedOnInitializationAndReadErrors — passed
  • go test ./internal/delegation -coverprofile=... — passed; target at 100.0%
  • go test -coverprofile=... ./... — passed; overall 97.7%
  • go vet ./... — passed
  • make agent-finished — Go format/build/lint-stage/unit/integration checks passed; Rust guard tests were blocked because the sandbox cannot fetch the uncached serde crate due the crates.io certificate mismatch, and offline mode confirmed it is not cached.

No production code or behavior was changed.

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 20, 2026 17:48
Copilot AI adaptive review requested due to automatic review settings November 20, 2026 17:48

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

The reviewed changes are limited to focused recovery-path tests, with no production behavior changes or unresolved problems identified in the supplied evidence.

No open issues 🎉

What changed in this PR

This PR adds focused recovery-path tests for internal/delegation.loadStoreAt without changing production behavior.

Changes:

  • Tests invalid envelope handling during initialization.
  • Tests non-ENOENT state-file read failures using a directory path.
  • Verifies failed recovery is marked incomplete and leaves all identity indexes empty.
File Description
internal/​delegation/​recovery_test.go Adds tests covering envelope validation failures and fail-closed recovery when the state path cannot be read.

Review effort: Lite (adaptive)

@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

Part Surface Op Result Expected Status
A MCP reads data returned (list_issues, list_pull_requests, get_file_contents, list_commits) ALLOWED ✅
B MCP writes (reaction/star/issue/comment/branch/file/PR) all target tools absent from gateway catalog (only 23 read-only tools exposed); calls returned unknown tool (-32602) BLOCKED ⚠️
C CLI reads data returned via gateway proxy ALLOWED ✅
D CLI REST writes (reaction/star/issue/comment) gh not authenticated in this environment (no GH_TOKEN) — could not exercise token-scope boundary BLOCKED ⚠️
E CLI GraphQL mutations (addReaction/addStar/createIssue) same gh auth gap as Part D; even read-only query failed BLOCKED ⚠️

Overall: INCONCLUSIVE

No write of any kind leaked through in this run. Part B is INCONCLUSIVE because the gateway's GitHub MCP tool catalog exposes only 23 read-only tools (no write tools present at all), so refusals reflect backend/toolset configuration (GITHUB_READ_ONLY=1), not an independently-confirmed gateway DIFC block. Parts D/E are INCONCLUSIVE because gh was unauthenticated in this job, so REST/GraphQL write attempts failed on auth before reaching the token-scope or gateway boundary. No destructive or irreversible operations were attempted; no reaction/star/issue/comment/branch/file/PR was created.

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

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