Commit graph naco-api/cmd
Author SHA1 Message Date
67d35a0a2f
fix: harden Ollama client embeddings, truncation, and retries
- embed posts in a bounded worker pool while preserving index order,
  with per-post error context and transient (429/5xx) retry backoff
- SummarizeStyle errors when the stream ends before a done chunk or the
  model truncates at its context limit (done_reason length) instead of
  returning a partial summary for a payable tool
- New() drops the unused ctx param and names its model params; callers
  in main.go updated
2026-09-09 23:18:01 +00:00
b27108467e
fix: harden main entrypoint — graceful shutdown, context handling, readyz binding
- Add Server.Shutdown() method delegating to X402Server
- Wire main-server graceful shutdown with 15s bounded timeout
- Derive long-lived clients (bluesky, ollama) from backgroundCtx instead of
  signal context to prevent poisoned sessions on SIGTERM during startup
- Remove empty errgroup goroutine that only logged on cancellation
- Bind readyz sidecar to configurable READYZ_ADDRESS (default 127.0.0.1)
  instead of 0.0.0.0
- Validate port strings (ReadyzPort, MetricsPort, ListenPort) at config load
- Fix ready-check Ollama probe: use defer for body drain, guard nil resp
2026-09-09 15:07:27 +00:00
3b443eff36
refactor: harden HTTP clients with timeouts, per-relay ctx, rate-limit handling 2026-09-08 01:11:13 +00:00
6e0a57063c
Increase all timeouts to 600s for CPU-only Ollama
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
- internal/x402/x402.go: x402 middleware timeout 240s -> 600s; facilitator client timeout 30s default -> 600s
- testClient/main.go: test client HTTP timeout 240s -> 600s
- cmd/server/main.go: Ollama HTTP client timeout 120s -> 600s

All timeouts increased to 10 minutes to accommodate CPU-only Ollama inference.
Calls return as soon as possible; timeouts only act as safety net.
2026-09-05 08:52:06 +00:00
f1a2a2c827
Increase timeout for Ollama embedding generation
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 3m43s
CI/CD Go Verification / build_and_test (push) Successful in 1m14s
- internal/x402/x402.go: Added 120s timeout to nethttp.Config for payment middleware
  (was defaulting to 30s, which was too short for Ollama embeddings)
- cmd/server/main.go: Created custom HTTP client with 120s timeout for Ollama client
- Both changes ensure slow tools (getStyleProfile, findSimilarUsers) complete without timeout
2026-09-05 01:23:38 +00:00
fe22a9779f
Add comprehensive debugging for CDP auth 401 issue
Some checks failed
CI/CD Go Verification / build_and_test (push) Successful in 1m11s
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m40s
- Workflow: Debug CDP Secret Format step prints secret characteristics (length, newlines, first/last chars)
- check-facilitator: Added extensive debug logging:
  - Key name, secret length, first 80 chars
  - Literal vs actual newline detection
  - PEM block parsing (SEC1 vs PKCS8 detection)
  - Signing method used
  - JWT claims decoded from generated tokens
  - Full request/response logging
- auth.go: Added GetSigningMethod() for debugging
- All tests pass, gofmt/go vet clean
2026-09-05 00:25:59 +00:00
bf7a91ca89
Switch CI to PayAI facilitator (supports exact + upto)
Some checks failed
test-endpoints.yaml / Switch CI to PayAI facilitator (supports exact + upto) (push) Failing after 0s
CI/CD Go Verification / build_and_test (push) Has been cancelled
- PayAI facilitator supports both exact and upto schemes on Base Sepolia
- Workflow and start-test-server.sh: X402_FACILITATOR_URL -> https://facilitator.payai.network
- check-facilitator: handles payai.network as no-auth facilitator like Mogami
2026-09-04 23:06:42 +00:00
3717a37748
Switch CI to Mogami facilitator for testing (no auth)
Some checks failed
test-endpoints.yaml / Switch CI to Mogami facilitator for testing (no auth) (push) Failing after 0s
CI/CD Go Verification / build_and_test (push) Successful in 1m9s
- Workflow: X402_FACILITATOR_URL -> https://v2.facilitator.mogami.tech/
- start-test-server.sh: same facilitator URL
- check-facilitator: auto-detects facilitator type, skips auth for Mogami
- This unblocks CI testing while CDP facilitator auth is investigated
2026-09-04 22:51:54 +00:00
832bbba8ed
Add check-facilitator binary for CI facilitator verification
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m17s
CI/CD Go Verification / build_and_test (push) Successful in 1m6s
- New cmd/check-facilitator/main.go uses internal/server auth package (same logic as server)
- CI workflow builds and runs binary instead of inline script
- Ensures auth logic matches server exactly, eliminates drift
- Prints supported networks/kinds from facilitator /supported endpoint
2026-09-04 22:22:08 +00:00
4c723445e0
Fix log capture and add verify failure logging
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m28s
CI/CD Go Verification / build_and_test (push) Successful in 1m10s
- x402: wrap payment middleware to log verify failures (decoded PAYMENT-REQUIRED with scheme/network/asset/amount/payTo per accept) and settlement errors
- x402: add verifyErrorCapture and decodePaymentRequiredHeader for structured error logging
- start-test-server.sh: build binary first (go build -o /tmp/mcpserver), run with output redirected to log file, wait 2s on shutdown for log flush
- workflow: Cleanup uses kill -TERM + sleep 2 to let server flush logs
- main.go: defer log.Close() to flush slog handlers on shutdown
- All tests pass, gofmt/go vet clean
2026-09-04 18:13:28 +00:00
d3845671b4 ollama: fix EmbedTexts signature, add model config, use clustering package
- ollama/client.go: EmbedTexts accepts []clustering.Item, returns [][]float64
- backends.go: ollamaBackend interface uses clustering.Item
- utils/styleProfiles.go: remove duplicate KMeans, normalize, cosineSimilarity
- clustering/: new package with Item, Result types and KMeans
- config.go: add EmbeddingModel, StyleModel env vars
- main.go: pass model config to ollama.New()
- go.mod: add github.com/ethereum/go-ethereum for test client
2026-09-01 23:40:21 +02:00
3c024d668e Add observability, post caching, dedup, Bluesky refresh, Twitter backoff, MCP tests
- Per-tool Prometheus-style metrics via /metrics and error logging on failures
- In-memory TTL post cache for getPost/getLatestPosts/getPostsInTime/getFeed
- searchActors dedupes cross-platform duplicates by normalized handle
- Bluesky client refreshes session on auth/expired-token errors (retry once)
- Twitter client backs off on HTTP 429 honoring Retry-After
- MCP tests with fake platform backends (dispatch, caching, dedup, partial/full failure)

Co-Authored-By: Claude (AI assistant) <noreply@anthropic.com>
2026-08-29 02:46:17 +02:00
8cfb1291aa ops: migrator, enrichment backpressure, ollama fallback, readiness
- Add dependency-free in-process schema migrator (internal/store/migrate.go) that applies
  sql/schema/*.sql in order, tracking versions in schema_migrations. Gated by MIGRATE_ON_START
  and MIGRATIONS_DIR (default sql/schema).
- Fix migration ordering: 002 now creates the 'vector' extension before defining the
  user_style_profiles table (previously the extension was only created later in 003).
- Bound concurrent background enrichment with a 4-slot semaphore so bursts of live
  getStyleProfile calls cannot overwhelm Ollama.
- buildStyleProfile degrades gracefully when Ollama is down: stores a zero embedding and a
  keyword-based fallback summary instead of failing the whole request.
- Add a /readyz side server (READYZ_PORT, default 9090) that checks DB connectivity and
  Ollama availability.

Co-Authored-By: Claude (AI assistant) <noreply@anthropic.com>
2026-08-29 02:09:50 +02:00
e5168e33f3 add: multi-platform getStyleProfile with slow, discovery-based prewarmer
- Nostr client (fiatjaf.com/nostr) fetching kind:1 notes from relays
- Twitter client using raw Twitter API v2 (no external X library), optional (no token = lazy error)
- getStyleProfile dispatches by platform; a profile is updated only when a request is
  made and the cached profile is older than a week (served from cache otherwise)
- shared requestStyleProfile path used by both the tool and the prewarmer
- StartPrewarm discovers interesting authors (from a feed URI or seed list) and
  pre-fetches at most one profile per minute; fresh profiles are never re-embedded
2026-08-29 01:07:47 +02:00
fed1a8d294 feat: add activitypub 2026-07-18 22:42:44 +00:00
9f116d82d2 refactor: module name 2026-02-04 00:16:15 +00:00
2b4980edab Major changes 2025-12-19 00:05:45 +00:00
b87910d1c4 Major changes 2025-12-02 19:33:03 +00:00
5b409678ad First release build 2025-12-02 19:32:47 +00:00
af58fdeeab initial commit 2025-10-25 01:06:02 +00:00