Skip to content

sdk: round-4 CLI follow-ups — PM intent tokenAmount guard + resolveExpiration/collection-options specs (#0431-#0433)#244

Merged
trevormil merged 1 commit into
mainfrom
feat/0431-cli-followups-r4
May 15, 2026
Merged

sdk: round-4 CLI follow-ups — PM intent tokenAmount guard + resolveExpiration/collection-options specs (#0431-#0433)#244
trevormil merged 1 commit into
mainfrom
feat/0431-cli-followups-r4

Conversation

@trevormil
Copy link
Copy Markdown
Collaborator

Summary

Stacked on #243 (base feat/0428-cli-followups-r3). Round-4 of the rolling audit — the codebase is converging; this is a tight batch (1 producer-correctness bug + 2 real coverage gaps, one a self-caught round-2 miss).

  • #0431 Canonical buildPredictionMarketBuyIntent / buildPredictionMarketSellIntent now throw on non-positive tokenAmount. Previously the slim bb build pm-*-intent builders guarded amount>0 but the end-user bb prediction-markets buy/sell called the canonical fn directly with BigInt(opts.tokenAmount)--token-amount 0/-5 flowed through. Guard now lives at the producer root (the #0422 pattern), so both surfaces enforce it. Also: isUserRecurringApproval's charge-period cap is now bigint-exact (was BigInt(Math.min(Number(intervalLength), …)) — lossy; now matches the producer userRecurringApproval's pure-bigint cap — same producer↔recognizer-drift class as #0425).
  • #0432 Direct resolveExpiration unit spec. The duration branch (now + parseDuration) was only exercised indirectly via a determinism row that normalizes the time window out; now all three branches + the ≥10-digit ms-since-epoch heuristic boundary + invalid input are directly asserted.
  • #0433 collection-options.spec.tsnormalizeCollection (envelope unwrap / never-throws / raw-fallback) + validateCollectionOrExit (not-found→exit2 / errors+warnings→exit2 / BB_QUIET gate / silent-when-valid). The #0429 ticket scoped this spec but it wasn't written (round-2 miss; caught by the round-3 audit).

Scope notes

  • 0431: the slim builders' redundant pre-check left in place (no churn). bb nfts bid/list --token-amount/--max-fills/--max-sales left permissive — symmetric across build & end-user (≤0 → chain-accepted no-op), not an asymmetry; broad count-flag validation would be speculative.
  • 0433: bigint-value assertions intentionally omitted — BitBadgesCollection.convert(BigIntify) is that class's own separately-tested concern and needs a full fixture; the boundary contract (unwrap/never-throw/fallback) is what #0429 actually fixed and is schema-independent.
  • The round-3 CLI-DRY audit reported converged (the only residue — 2 callApi copies vs shared callIndexer — is below the ≥3 dedup bar; not filed, per no-churn).

Validation

  • Build clean — tsc ×2, no circular dependencies.
  • Unit: 143 suites / 3108 tests green (+1 suite, +16 tests).
  • Integration: 20 suites / 186 tests green.

Test plan

  • bb prediction-markets buy-yes … --token-amount 0 now errors (parity with bb build pm-buy-intent)
  • bun run build / test:unit / test:integration green

🤖 Generated with Claude Code

Stack: main ← #242#243this.

…piration/collection-options specs (#0431-#0433)

0431 canonical buildPredictionMarket{Buy,Sell}Intent now throw on
     non-positive tokenAmount — closes the asymmetry where `bb build
     pm-*-intent` rejected amount≤0 but `bb prediction-markets
     buy/sell` (calling the canonical fn directly) silently accepted
     it. Plus isUserRecurringApproval charge-period cap is now
     bigint-exact (was a lossy Number() round-trip; matches the
     producer userRecurringApproval).
0432 direct resolveExpiration unit spec — the duration branch value
     was only tested indirectly (the ms-since-epoch + default branches
     were); now all three branches + the ≥10-digit ms heuristic
     boundary + invalid-input are asserted.
0433 collection-options.spec.ts — normalizeCollection (unwrap /
     never-throw / raw-fallback) + validateCollectionOrExit (not-found
     / errors+warnings / BB_QUIET gate / silent-valid). Closes the
     #0429 round-2 spec miss.

Build clean (no circular deps); unit 143 suites / 3108 tests;
integration 20 suites / 186 tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Base automatically changed from feat/0428-cli-followups-r3 to main May 15, 2026 19:25
@trevormil trevormil merged commit 386b416 into main May 15, 2026
1 check passed
@trevormil trevormil deleted the feat/0431-cli-followups-r4 branch May 15, 2026 19:26
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