test: add cross-boundary contract tests for VM agent ↔ API Worker#1019
test: add cross-boundary contract tests for VM agent ↔ API Worker#1019simple-agent-manager[bot] wants to merge 7 commits into
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds 32 tests covering 5 previously untested HTTP contracts: 1. Attachment Transfer: URL construction (ws-* subdomain, not nodeId.vm.*), terminal JWT auth as query param (not Bearer header), FormData payload, timeout handling 2. Agent Activity Callback: payload shape matches Go sender (session_host_reporting.go), URL construction, callback JWT auth 3. Credential Sync Callback: payload shape matches Go sender (workspace_callbacks.go), URL construction with path escaping 4. Send Prompt to Agent: JSON body structure, URL path, node management JWT auth, complex nested payload with MCP servers + overrides 5. Cancel/Stop Agent Session: 409 error handling (returns result instead of throwing), stop path verification, auth consistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- C1: Fix workspace ID to use ULID (not ws-prefixed), preventing double ws-ws- prefix - C2: Replace misleading "optional fields omitted" test with Go sender contract test - H1: Add opencodeProvider/opencodeBaseUrl to startAgentSessionOnNode test - H2: Add X-SAM-Node-Id/X-SAM-Workspace-Id header assertions - H3: Add clarifying comment for 204→200 status normalization - H4: Add opencodeProvider/opencodeBaseUrl to "omits optional fields" test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
All 16 implementation checklist items and 5 acceptance criteria were implemented and verified but never checked off in the task file. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract setupNodeAgentMocks() and setupNodeAgentMocksWithError() helpers to eliminate repeated vi.doMock boilerplate across Contract 4 & 5 tests. Reduces file from 857 to 736 lines and addresses SonarCloud duplication finding (25.6% → expected <3%). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
SonarCloud StatusSonarCloud reports 3 remaining quality gate issues:
All CI checks except SonarCloud pass. The SonarCloud findings are test-file false positives that don't affect runtime code quality. |




Summary
Contracts tested:
Validation
pnpm lintpnpm typecheckpnpm test— 32/32 tests passStaging Verification (REQUIRED for all code changes — merge-blocking)
N/A: test-only PR. No runtime code changes — only a new test file and task file updates. No code that runs in staging/production was modified.
UI Compliance Checklist (Required for UI changes)
N/A: no UI changes.
End-to-End Verification (Required for multi-component changes)
N/A: test-only PR — the tests themselves ARE the cross-boundary verification.
Data Flow Trace
N/A: test-only PR.
Untested Gaps
N/A: full flow covered by automated tests.
Post-Mortem (Required for bug fix PRs)
N/A: not a bug fix.
Specialist Review Evidence (Required for agent-authored PRs)
needs-human-reviewlabel added and merge deferred to human — all completedExceptions (If any)
Agent Preflight (Required)
Classification
External References
session_host_reporting.go,workspace_callbacks.go) read for contract verificationnode-agent-contract.test.ts) used as pattern referenceCodebase Impact Analysis
apps/api/tests/unit/— new test file addedtasks/archive/— task file archived with checklistDocumentation & Specs
N/A: test-only PR, no behavior changes.
Constitution & Risk Check
Principle XI checked — no hardcoded values in tests beyond test fixtures. All timeouts reference configurable constants.
🤖 Generated with Claude Code