Skip to content

Add M-Team bonus catalog, review, and exchange - #31

Merged
tonycoder-hub merged 1 commit into
mainfrom
feat/mteam-bonus
Oct 16, 2026
Merged

tonycoder-hub merged 1 commit into
mainfrom
feat/mteam-bonus

Conversation

@tonycoder-hub

Copy link
Copy Markdown
Owner

Summary

M-Team gets the three bonus commands TJUPT already has, so a saved API key now covers every M-Team command except RSS, seeding lists, and messages.

  • site bonus-catalog mteam reads the balance (member/profile) and the shop (mall/list) on one client, three seconds apart.
  • site bonus review mteam GOODS_ID re-reads mall/list and reviews one goods item in one read-only POST.
  • site bonus exchange submit on M-Team sends at most one POST /api/mall/exchange with only goodsId and num=1. It only does this for goods that are plainly available and take no input. The API key is the only credential; M-Team asks for no password.

Goods status mapping and the exchange outcome table are in docs/MTEAM_ADAPTER.md → "Bonus shop".

Deliberate public changes

  • Capabilities: the M-Team descriptor grows from 5 to 8 (bonus.catalog.read, bonus.offer.review, bonus.exchange.submit_effectful). This changes site list (count 5 → 8) and the site capabilities mteam output, both text and JSON. The goldens in site_contract_test.go are updated.
  • New flag: --api-key-stdin on site bonus review and site bonus exchange submit. Without a stdin flag, both commands use the saved key.
    • Mixing credential flags is a usage error and never reads stdin.
    • So is sending a cookie to an API-key site, an API key to a cookie site, or a bundle to M-Team.
  • New stop reasons: site bonus exchange submit can now report server_refused, server_rate_limited, and server_authentication_rejected (all with outcome rejected).
  • Help text: the usage lines for bonus-catalog, review, and submit list the API-key alternative, and the submit help explains M-Team's no-password exchange.
  • Unchanged: TJUPT behavior, existing stop reasons and their order, exit codes, and route IDs.

Transport

  • httpguard.Client.PostEffectOnce is new. It shares the bounded single-POST path with PostReadOnce, but sends a User-Agent naming an explicit-effect client so the request is never mistaken for a read.
  • The adapter refuses a client that cannot send an effect, and a credential issued for another site.

Testing

  • gofmt, go vet ./..., go test -race ./..., and go build -trimpath ./cmd/ptctl all pass locally.
  • New offline tests cover:
    • the catalog and review paths, including failing closed;
    • exchange outcomes, and refusals that happen before the effect;
    • the request count, method, and User-Agent;
    • CLI credential selection for piped and saved keys, flag misuse, and the new stop reasons.
  • Fixtures are synthetic CANARY data.
  • Live, read-only (2026-10-16): with a throwaway HOME, bonus-catalog returned exit 0 and listed 6 goods, and bonus review returned exit 0 with 1 request. The API key did not appear in any output.
  • Live exchange: not run. The account balance is below the cheapest goods item, and no M-Team bonus budget has been approved.

🤖 Generated with Claude Code

M-Team now reads its bonus shop and exchanges goods through the same
at-most-once state machine TJUPT uses.

- bonus-catalog reads the balance (member/profile) and the shop
  (mall/list) on one client; review re-reads mall/list for one goods ID.
- exchange submit sends one mall/exchange POST with goodsId and num=1,
  only for goods that are plainly available and take no input. It goes
  through the new httpguard PostEffectOnce, whose User-Agent names an
  explicit-effect client. The API key is the only credential.
- bonus review and exchange submit accept --api-key-stdin or the saved
  key; submit adds the public stop reasons server_refused,
  server_rate_limited, and server_authentication_rejected.
- The M-Team descriptor grows from 5 to 8 capabilities, which changes
  site list and site capabilities output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tonycoder-hub
tonycoder-hub merged commit 45f6c94 into main Oct 16, 2026
5 checks passed
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