Conversation
Closes gap 1 from the Wk4 balance display surfaces audit. GET /v1/balance is already built and tested on mallcop.app; this adds the customer-facing `mallcop balance` CLI command that calls it. - balance.go: runBalance() — calls <MALLCOP_APP_URL>/v1/balance, converts JSON to human-readable donut output; --json for machine use. Reads MALLCOP_APP_URL and MALLCOP_SERVICE_TOKEN from env (consistent with charts/vertical-slice.toml naming). - balance_test.go: 7 tests — missing token, 401, human readable, JSON output, no pools, env vars, live Forge integration smoke. Live Forge test runs when FORGE_API_KEY + FORGE_BASE_URL are set; confirmed 70000 donuts returned from forge.3dl.dev. - main.go: wire balance case + update usage string. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…llcoppro-718)
Veracity rework addressing findings 1 and 2:
Finding 1 — all 5 unit tests (Unauthorized, HumanReadable, JSONOutput, NoPools,
EnvVars) now use testutil.FakeForge + testutil.NewServer from mallcop-pro/testutil.
Mock boundary is at Forge's HTTP API (GET /v1/keys, GET /v1/accounts/{id}/balance),
not at the mallcop.app surface. Real handleBalance, real pricing.MicroToDonuts, and
real config-driven costPerDonutMicro run in every unit test.
Finding 2 — TestBalance_LiveForge rewritten to use testutil.NewServerWithForgeURL.
No handler logic reimplemented. Real forge.Client + real pricing.MicroToDonuts
route through the actual server.handleBalance. costPerDonutMicro is a parameter,
not a hardcoded constant.
Finding 3 — test still t.Skips when env unset. Runs unconditionally when
FORGE_API_KEY + FORGE_BASE_URL are set. CI secret prereq filed as mallcoppro-fd3.
Added github.com/thirdiv/mallcop-pro as a go.mod dependency (replace directive
pointing to local path) to import the new testutil package.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Veracity rework (mallcoppro-718 findings 1+2)This push addresses the veracity adversary's HIGH findings: Finding 1 resolved — All 5 unit tests ( Finding 2 resolved — Finding 3 (MEDIUM) — Test still New dependency — Added All 7 tests green: 6 unit (including live Forge at 70000 🍩) + TestBalance_MissingToken. |
…1 (mallcoppro-718) Update go.mod to use the corrected module path github.com/3dl-dev/mallcop-pro@v0.1.1 instead of the dead github.com/thirdiv/mallcop-pro path. Update the testutil import in balance_test.go accordingly. Removes need for local replace directive. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4f7055e to
a0696cf
Compare
Summary
mallcop balanceCLI subcommand that callsGET /v1/balanceon mallcop.appMALLCOP_APP_URLandMALLCOP_SERVICE_TOKENfrom env; both consistent with existing chart naming conventionsWhat this does
The endpoint
GET /v1/balancewas already built and tested on mallcop.app (mallcop-pro). This PR adds the customer-facing CLI surface that calls it.Output example:
Test plan
TestBalance_MissingToken— error when no tokenTestBalance_Unauthorized— error on 401TestBalance_HumanReadable— pool breakdown in human outputTestBalance_JSONOutput—--jsonflag produces parseable JSONTestBalance_NoPools— total-only responseTestBalance_EnvVars— MALLCOP_APP_URL + MALLCOP_SERVICE_TOKEN env varsTestBalance_LiveForge— live integration test against forge.3dl.dev (returned 70000 donuts, confirmed passing)All 7 tests pass. Run:
go test ./cmd/mallcop/... -run TestBalanceAudit context
Full audit at
mallcop-pro/docs/audit/2026-05-06-balance-display-surfaces.md:mallcop balanceCLI subcommandmallcop init --prokey storage🤖 Generated with Claude Code