Commit graph naco-api/internal/server/settlement.go
Author SHA1 Message Date
9825c45350
fix(server): surface and log settlement persistence errors
persistSettlement now returns the write error instead of swallowing it, and
both the HTTP and MCP settlement hooks log failures instead of silently
dropping them. Also remove the dead function_runtime_ms webhook field and a
stale log value.
2026-09-13 22:24:37 +00:00
f4ae7d9c9f
refactor(x402): fold resolver into AddPayableTool and honor per-tool timeouts
Simplify the payable-tool registration API by merging
AddPayableToolWithResolver into AddPayableTool, and thread a configurable
MaxTimeoutSeconds plus Extra through the payment options. getStyleProfile
keeps its 600s advertise timeout.
2026-09-13 22:24:34 +00:00
76d337f54c
fix: bump MaxTimeoutSeconds for upto scheme
All checks were successful
Test Every Endpoint on Base Sepolia / test_endpoints (push) Successful in 6m39s
CI/CD Go Verification / build_and_test (push) Successful in 1m18s
2026-09-06 22:44:59 +00:00
78ec4af4ee
Use upto scheme for getStyleProfile variable pricing
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 5m31s
CI/CD Go Verification / build_and_test (push) Successful in 1m15s
- Added Scheme field to payableDef struct in tools.go
- getStyleProfile now uses 'upto' scheme (variable pricing: base + per-post)
- Modified buildRequirements in settlement.go to accept scheme parameter
- Default scheme is 'exact' for backwards compatibility
- getStyleProfile uses 'upto' scheme to match its variable pricing model
  (base /bin/bash.10 + /bin/bash.01 user lookup + /bin/bash.005 per post)
- This fixes 'invalid_exact_evm_payload_authorization_value' error from facilitator
  which expected upto scheme for variable pricing
2026-09-05 10:27:19 +00:00
a218b8fbf5
refactor(server): split server.go into focused modules (phases 1-4)
Phase 1: mechanical splits
- platform.go: determinePlatform
- settlement.go: settleHook, buildRequirements, parseActiveNetworks
- posts_convert.go: bsky/ap/nostr/twitter single converters
- actors.go: searchActorsAll, dedupeActors, normalizeHandle
- posts.go: fetchSinglePost/fetchLatestPosts/fetchPostsInTime/fetchFeed
- style.go: getStyleProfile, requestStyleProfile*, enrichCrossPlatform,
  getSimilarProfiles, buildStyleProfile, fetchProfilePosts, toItems
- prewarm.go: StartPrewarm, discoverInterestingAuthors, prewarmOne, startPostPruner

Phase 2: deduplicate registerTools
- tools.go: table-driven payableDef + schemaExtra helper, analyticsInput reuse
- server.go 1814 -> 180 lines, registerTools 470 -> 150 lines

Phase 3: unify platform dispatch
- cache.go: generic cachedFetch[T]
- posts_convert.go: batch converters (blueskyFeedViewsToResponses,
  apPosts*ToResponses, nostr/twitter variants) and clustering Item
  variants (blueskyFeedViewsToAnalyticsItems etc.)
- posts.go: use cachedFetch + batch helpers, fetchFeed via helper
- style.go: fetchProfilePosts via *ToItems helpers
- analytics.go: fetchPostsInTimeForAnalytics/fetchTwitterFromAPI via analytics helpers

Phase 4: slim bootstrap
- server_init.go: buildMiddleware, resolveActiveNetworks, newX402Server,
  persistSettlement, sendSettlementWebhook (deduplicate settleHook)
- server.go: New 120 -> 32 lines, grouped Server fields by
  Transport/Dependencies/Cache/Payments, keep struct compat for tests
- verified: gofmt clean, go build/vet pass, go test ./... pass
2026-09-03 23:59:16 +00:00