Skip to content

Verified full API coverage matrix (CLI + SDK, positive + negative) + working-order execute fix#28

Merged
SimonTarara62 merged 13 commits into
mainfrom
api-coverage-test-matrix
Jun 14, 2026
Merged

Verified full API coverage matrix (CLI + SDK, positive + negative) + working-order execute fix#28
SimonTarara62 merged 13 commits into
mainfrom
api-coverage-test-matrix

Conversation

@SimonTarara62

Copy link
Copy Markdown
Owner

Summary

Proves capctl covers the complete Capital.com Open API surface with a verifiable test matrix, and fixes a real bug that the matrix uncovered.

  • Canonical endpoint registry (tests/e2e/endpoints.py): all 41 REST + WebSocket operations, each mapped to its CLI command and SDK method. An offline cross-check asserts the registry equals the documented Capital.com surface and that every command/method exists. Finding: nothing was missing — every endpoint already has a CLI command and an SDK method (the CLI surface even exceeds the official MCP toolset).
  • Per-endpoint test matrix — CLI positive, CLI negative, SDK positive, SDK negative — filled to 158/158 applicable cells (100%). The 3 CLI-only connectivity primitives (GET /time, GET /session, GET /session/encryptionKey) are marked N/A in the SDK columns by design.
  • Generated, drift-guarded docs: make coverage-doc renders the matrix into docs/api-coverage.md and a shields.io endpoint JSON (docs/coverage-badge.json); a README API coverage badge links to the proof table. A drift test keeps the doc/badge in sync with the registry, and a completeness gate fails if any cell regresses.

Bug fixed (found by the live matrix)

trade execute-order crashed with INTERNAL_ERROR: 'type'. Working-order previews were persisted to the state file before the working-order type/level fields were attached, so executing a previewed working order from a separate CLI invocation (which reloads the preview from disk) hit a KeyError. The in-process SDK path kept the in-memory copy and worked, which is why it was never caught — working-order execute had no e2e coverage before. Fixed in core/risk.py (re-save the preview after adding the fields) with a TDD regression test that exercises the state-file round-trip.

Safety note

Negative tests use no-network failure modes (missing-config → exit 3 / ConfigMissingError, Typer type-errors → exit 2, and guard rejections that short-circuit before any HTTP). An earlier draft used wrong-password logins, which tripped the demo login rate limit and risked locking the account — that approach was removed.

Test Plan

  • Offline: ruff + mypy clean, 302 passed, 6 skipped.
  • Live demo (read-only, real keys): 137 passed, 0 failed.
  • Live demo (full trading lifecycle, real keys): 150 passed, 1 env skip, 0 failed; account verified flat (no positions/orders/leftover watchlists) afterward.
  • Coverage matrix 158/158 (100%); badge + drift guards green.
  • CI (ubuntu + windows × 3.10/3.11/3.12) — to confirm on this PR.

🤖 Generated with Claude Code

SimonTarara62 and others added 13 commits June 14, 2026 19:06
…e cell check

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…streams)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… (fixes login rate-limit cascade)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e-order

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@SimonTarara62 SimonTarara62 merged commit bb799c1 into main Jun 14, 2026
6 checks passed
@SimonTarara62 SimonTarara62 deleted the api-coverage-test-matrix branch June 14, 2026 17:42
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.

1 participant