Commit graph

144 commits

Author SHA1 Message Date
357f0e1035
Fix YAML indentation in facilitator check step
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 1m8s
2026-09-04 22:56:17 +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
c8b313a9f6
Add facilitator supported networks check to CI workflow
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m29s
CI/CD Go Verification / build_and_test (push) Successful in 1m8s
- New step 'Check Facilitator Supported Networks' queries CDP facilitator /supported endpoint with proper auth
- Uses same CDP auth logic as server (JWT with keyName/privateKey)
- Prints supported networks/kinds to verify Base Sepolia (eip155:84532) support
- Runs before starting test server to catch facilitator config issues early
2026-09-04 22:13:29 +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
b6daa0efcc
Add HTTP settlement logging and CI server log capture
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m27s
CI/CD Go Verification / build_and_test (push) Successful in 1m8s
- x402: add detailed settlement success/error logging per tool (network, tx, payer, amount) and ErrorHandler for settlement failures that currently return a new 402
- server_init: log persisting HTTP and MCP settlements with transaction details
- workflow: dump /tmp/mcpserver-test.log on failure and tail 500 lines on always for debugging Base Sepolia exact/upto flows
2026-09-04 16:06:51 +00:00
28b65cd1bf
Update testclient to register both exact and upto EVM schemes
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m25s
CI/CD Go Verification / build_and_test (push) Successful in 1m4s
The test client now registers both 'exact' and 'upto' EVM payment schemes
for the test network (eip155:84532 / Base Sepolia) to match the server's
scheme registration. This allows the x402 HTTP client wrapper to
automatically handle 402 Payment Required responses by selecting and
paying with a supported scheme, then retrying the request.
2026-09-04 14:44:42 +00:00
9cee30ff70
Fix x402 scheme registration for all active networks
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m33s
CI/CD Go Verification / build_and_test (push) Successful in 1m7s
The HTTP middleware in AddPayableTool was hardcoded to only register
the exact scheme for eip155:8453 (Base mainnet), while the MCP handler
registered both exact and upto schemes for all networks from ACTIVE_NETWORKS.
This mismatch caused 'no scheme server for exact on eip155:84532' errors
when testing with Sepolia.

Changes:
- Added networks field to X402Server struct to store active networks
- Store networks in NewX402Server constructor
- In AddPayableTool, dynamically register both exact and upto EVM
  schemes for all configured networks instead of hardcoding eip155:8453
- Updated tests to pass correct network configuration
2026-09-04 13:29:38 +00:00
6dc5b3c3f0
fix: testclient fails on non-2xx (except 402)
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m24s
CI/CD Go Verification / build_and_test (push) Successful in 1m6s
callEndpoint now returns error for any HTTP status >= 400 except 402,
which is the expected status for payable endpoints. Previously 500
errors were treated as success, masking server errors like
'no scheme server for exact on eip155:84532'.
2026-09-04 12:11:06 +00:00
443ecce9c2
fix: register all active networks in x402 server for eip155:84532 support
All checks were successful
Test Every Endpoint on Base Sepolia / test_endpoints (push) Successful in 2m3s
CI/CD Go Verification / build_and_test (push) Successful in 1m5s
- x402.NewX402Server now accepts networks []string parameter to register
  exact/upto EVM schemes for each network
- server_init.go passes resolved active networks (from resolveActiveNetworks)
  to x402 server - includes eip155:84532 (sepolia), eip155:8453 (base),
  and any other configured networks
- Registers both exact and upto schemes per network
- Updates x402_test.go calls to pass []string{}
- Fixes: 'no scheme server for exact on eip155:84532' error
2026-09-04 09:09:00 +00:00
281c1b55eb
fix: combine listen address and port for TCP (not unix socket)
All checks were successful
Test Every Endpoint on Base Sepolia / test_endpoints (push) Successful in 2m0s
CI/CD Go Verification / build_and_test (push) Successful in 1m3s
Server was passing only ListenAddress (127.0.0.1) without port to x402.Start,
causing 'listen tcp: address 127.0.0.1: missing port in address'.
Now combines address:port for TCP when no port already present and
not a unix socket. Keeps unix socket paths unchanged.
2026-09-04 08:04:41 +00:00
6f6b952e46
fix: handle single-line PEM with \n and make MATRIX optional
Some checks failed
CI/CD Go Verification / build_and_test (push) Successful in 1m0s
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m22s
- config: MATRIX_WEBHOOK_URL / MATRIX_SERVER_ID via os.Getenv (optional),
  keep hostname fallback for MatrixServerID, avoid Fatal when webhook
  not configured (test-endpoints omits it, webhook.go nil-safe)
- auth: NewCDPAuth converts literal \n to real newlines before
  pem.Decode, so Forgejo single-line secret
  -----BEGIN EC PRIVATE KEY-----\n... works while malformed
  still returns error and CI fails via log.Fatal (as required)
2026-09-04 00:46:26 +00:00
6be20e0b83
ci: add BLUESKY_HOST
Some checks failed
CI/CD Go Verification / build_and_test (push) Successful in 59s
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m45s
2026-09-04 00:27:58 +00:00
541af5f8cf
ci: add AP_HOST
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m45s
CI/CD Go Verification / build_and_test (push) Successful in 58s
2026-09-04 00:21:46 +00:00
6e5670f69e
ci: make ollama service not block job, handle localhost vs service names
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1m46s
CI/CD Go Verification / build_and_test (push) Successful in 59s
- ollama image takes >60s and healthcheck curl fails inside container
  (marking service not healthy and aborting job before steps run).
  Remove ollama healthcheck from services, let Wait steps poll.
- Wait for PostgreSQL/Ollama try both localhost and service hostnames
  (postgres / ollama) for 60-90 retries, as Act network is
  WORKFLOW-* where localhost != service.
- Pull models via HTTP POST /api/pull to whichever host responds
  (no docker exec needed for services).
- start-test-server.sh: respect GOOSE_DBSTRING/OLLAMA_HOST from env,
  auto-detect postgres/ollama service hostnames if localhost not reachable.
2026-09-04 00:17:19 +00:00
9d911a9227
ci: use workflow services for postgres/ollama, no nested dockerd
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 2m55s
CI/CD Go Verification / build_and_test (push) Successful in 1m0s
setup-docker-action requires --privileged + iptables + bridge NAT
(failed: Permission denied, nft netlink Operation not permitted,
iptables v1.8.9 nf_tables even as root). Runner job container is
unprivileged, and host dind socket not mounted (/var/run/docker.sock
no such file). Switch to services: postgres pgvector/pg16 and
ollama/ollama:latest as job services on node20 (has node for checkout),
so no docker CLI/daemon needed inside job. Wait via pg_isready
(apt install postgresql-client if missing) and curl /api/tags, pull
models via Ollama HTTP API POST /api/pull (no docker exec). Keeps
manual wallet funding, self-contained via services.
2026-09-04 00:09:00 +00:00
5cd3b8d316
ci: fix docker iptables for setup-docker (privileged + iptables)
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 35s
CI/CD Go Verification / build_and_test (push) Successful in 58s
setup-docker-action starts dockerd inside job requiring bridge
NAT chain (iptables) and --privileged. node:20-bookworm has no
sudo/iptables, causing iptables not found / bridge driver failure.
Add apt install sudo+iptables before setup and run job container
privileged so self-contained dockerd can start; keeps host dind
fallback not needed. Host dind socket not mounted (no such file),
so nested daemon is required.
2026-09-04 00:07:22 +00:00
4fb665da51
ci: use host dind via docker client + compose, not nested dockerd
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 40s
CI/CD Go Verification / build_and_test (push) Successful in 58s
setup-docker-action@v5 starts dockerd inside job requiring
--privileged + iptables (failed: iptables not found / bridge driver).
Runner already provides dind via host socket, so use
docker/setup-compose-action@v2 + docker.io client via apt.
Keeps runs-on: node20 (has node for checkout) self-contained via host.
2026-09-04 00:05:11 +00:00
f80e23c722
ci: install sudo before setup-docker (node:20-bookworm has no sudo)
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 32s
CI/CD Go Verification / build_and_test (push) Has been cancelled
setup-docker-action@v5 starts dockerd via sudo; node:20-bookworm
image runs as root without sudo binary, causing
/bin/sh: 1: sudo: not found / exit 1. Install sudo via apt-get when
missing so self-contained dockerd can start. Keeps runs-on: node20
(has node for checkout) + dind host, no custom image needed.
2026-09-04 00:03:39 +00:00
ec93468fec
fix: docker action
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 35s
CI/CD Go Verification / build_and_test (push) Successful in 59s
2026-09-04 00:01:10 +00:00
a59cee1d2a
chore: cleanup manual funding scripts and docs
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 1s
CI/CD Go Verification / build_and_test (push) Successful in 1m8s
- cdpScripts/listServices.py: fix filter to only api.naco.li resources
  (remove stray type != http check)
- cdpScripts/rescueFunds.py: add CDP export script for api-naco-li
- testClient/main.go: remove faucet/balance/funding logic (manual funding),
  drop go-ethereum abi/ethclient, big, json, context imports; keep
  x402 payment flow only
- AGENTS.md: document quick commands, architecture, codegen, migrations,
  testing patterns and gotchas
2026-09-03 23:59:22 +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
cd630a4fad
ci: use self-contained docker and remove wallet funding
- runs-on node20 has node for checkout, use docker/setup-docker-action@v5
  for self-contained dockerd (no host dind dependency) instead of
  setup-compose only
- install: drop foundry/cast and bc (manual funding) -> go mod download only
- remove Fund Test/Server Wallet steps, FUNDING_FAUCET_URL env
- docker-compose -> docker compose via setup-docker, add logs on wait failures
2026-09-03 23:59:11 +00:00
8bb4cb539c fix: runs-on
Some checks failed
Test Every Endpoint on Base Sepolia / test_endpoints (push) Failing after 28s
CI/CD Go Verification / build_and_test (push) Successful in 57s
2026-09-03 17:19:45 +00:00
07ab6a13af workflows on ai-main 2026-09-03 17:18:01 +00:00
ee0589c774 chore: tidy store integration test and deps
- remove tautological SaveTransaction SQL/Params constant checks (const string replay)
- go.mod tidy drops unused go-sqlmock indirect
- testClient/main.go: gofmt alignment
2026-09-03 17:00:45 +00:00
193184675e test(x402): cover Twitter style-profile cost passing and payable boundaries
- add ComputeTwitterStyleProfileCost table and AlwaysProfitable invariant
- add edge cases (case-insensitive, negative, large counts)
- cover MultipleTools and AddPayableTool validation, HTTP 402/MCP boundaries
2026-09-03 17:00:36 +00:00
90af0ec4fc refactor(server): split mcp_test into focused suites with fakeStore/fakeOllama
- extract analytics, searchactors, styleprofile, twitter_analytics, validation, storefake from mcp_test
- add fakeStore/fakeOllama harnesses, lastLimit tracking, sql.NullTime staleness
- expand mcp_test with per-platform GetPost/Latest/PostsInTime, actor and cache tests
- touch analytics/backends/cache_version/metrics/server for coverage
2026-09-03 17:00:32 +00:00
c8d1829172 test(clients): expand coverage for rate-limit, pagination and error paths
- nostr: variants for resolvePubkey/EventID, invalid ID/author checks, relay failure
- bluesky: add FeedGetPosts/getProfile/searchActors mocks, pagination and time-filtering with cursor
- twitter: add RateLimit retry (Reset/Retry-After), exhausted retries, lookup errors, context cancel
- activitypub: fix GetPostsInTimeframe to test 2-page pagination and start/end boundary
2026-09-03 17:00:28 +00:00
6477d5845f test: remove tautological stdlib-roundabout tests
Aggressive deletion of tests that only replay stdlib or copy impl:
- config/config_test.go: getEnvBool/splitComma/Load defaults (strings.* wrappers)
- utils/styleProfiles_test.go: ParseEmbedding type-switch
- store/migrate_test.go: extractUpSQL marker parsing
- clustering/kmeans_test.go: IdenticalVectors/SingleItem/DifferentSeeds (trivial)
- ollama/client_test.go: PromptStructure/UsesProvidedModels (setter replay)
2026-09-03 17:00:24 +00:00
0dcb74675e fix(analytics,x402): fix coverage gaps, engagement drivers, and Twitter cost passing
Analytics review fixes:
- Store Twitter analytics coverage as discrete intervals instead of a single
  contiguous window so disjoint fetch ranges no longer mask inner gaps as
  covered (fetch per uncovered range, add gap regression tests)
- Compute real AvgEngagement/Correlation in getEngagementDrivers instead of
  all-zero placeholders
- Make parseAnalyticsTimeRange surface invalid timestamps, cap merged analytics
  posts at limit, and normalize sentiment by timestamped posts only
- gofmt: fix misalignment in config.go and types.go
- Include Twitter in the default aggregate analytics scope; its API costs are
  passed to the caller through paid tool pricing

x402 cost passing:
- computeTwitterStyleProfileCost now charges base cost ($0.10) + user lookup
  ($0.01) + $0.005 per Twitter post, guaranteeing the charge always clears the
  underlying API cost (never break-even or loss)
- Return a $-prefixed dollar string for the settlement override, fixing the
  previously off-by-factor-100 raw-atomic-unit amount
- Raise getStyleProfile base registration to $0.36 to authorize the max Twitter
  charge
- Add tests for the cost formula, profitable floor, and dollar formatting
2026-09-02 22:44:02 +00:00
e4176f99ed chore: ignore local test-endpoints binaries 2026-09-02 23:50:02 +02:00
979cd92445 test: add coverage-range tests for twitter analytics caching 2026-09-02 23:49:57 +02:00
c6b73cba1f feat: add analytics tools with real engagement, pattern, topic and sentiment computation
Register five payable analytics MCP tools (engagement metrics, posting
patterns, topic modeling, sentiment trends, engagement drivers).

- Thread real post timestamps and engagement metrics through the compute
  functions instead of time.Now()/zero placeholders (enabled by the
  enriched clustering.Item).
- Report the requested author (args.Author) instead of a literal string.
- Implement sentiment shift detection (from/to/magnitude) ordered by time.
- Cache analytics results keyed by scope: a single "all" key for
  cross-platform aggregates and per-platform keys for single-platform
  queries, so aggregate results are not mixed with partial data.
- Use configurable per-tool cache TTLs stored on the Server.

Also cache Twitter post data permanently to avoid repeat paid API calls:
newly fetched posts are persisted, and a coverage watermark (analytics
coverage table) ensures the paid Twitter API is only called for time
ranges not already retrieved.
2026-09-02 23:49:54 +02:00
fbd74a37b5 clustering: enrich Item with timestamp and engagement fields
Carry post metadata (timestamp, likes, reposts, replies, quotes) through
the clustering pipeline so analytics compute functions can use real values
instead of placeholders. The clustering algorithm only consumes Text and
Embedding, so this is backward-compatible.
2026-09-02 23:49:41 +02:00
4e027ca857 config: add per-tool analytics cache TTL settings
Wire configurable cache TTLs for each analytics tool from environment
variables, and provide a helper for parsing duration env vars.
2026-09-02 23:49:38 +02:00
c851d0e50f store: add sqlc queries for analytics cache, posts and coverage 2026-09-02 23:49:35 +02:00
ab1eb634f9 schema: add analytics cache, posts and coverage tables
Add tables backing the analytics cache, the permanent per-platform post
store, and the coverage watermark used to avoid re-fetching paid Twitter
posts once a time range has already been retrieved.
2026-09-02 23:49:32 +02:00
686c7ca2b6 ci: use env vars for ollama model pulls in test workflow
- Pull Ollama Models step now uses ${EMBEDDING_MODEL} and ${STYLE_MODEL}
- Values sourced from config/models.env in Load model config step

---

- Use $FORGEJO instead of $GITHUB variables
2026-09-02 02:00:59 +02:00
695e137915 config: single source of truth for model names via config/models.env
- config/models.env: EMBEDDING_MODEL and STYLE_MODEL defaults
- config.go: loads models.env by finding project root (go.mod), removes hardcoded defaults
- test-endpoints.yaml: sources config/models.env to set env vars for CI
- Works from any working directory (server, tests, CI)
2026-09-02 01:41:00 +02:00
4f56def00e config: switch STYLE_MODEL to qwen3:4b-instruct-2507-q4_K_M
- Instruction-tuned variant for reliable prompt following
- Q4_K_M quantization for CPU latency optimization
- Updated test workflow to pull correct model
2026-09-02 01:06:46 +02:00
3c0a7b9506 refactor: simplify ticker channel loop 2026-09-02 00:37:55 +02:00
248f738e07 deps: go mod tidy cleanup
- Remove unused indirect dependencies (fsnotify, oapi-codegen, influxdb, graphql-go, etc.)
- Kept: github.com/ethereum/go-ethereum for test client wallet funding
2026-09-02 00:30:37 +02:00
877f839926 test: add clustering KMeans tests and ollama client tests
- clustering/kmeans_test.go: TestKMeans (basic, empty, k>n, identical, single, deterministic, high-dim), TestCosineSimilarity, TestNormalize, TestInitializeKMeansPlusPlus
- ollama/client_test.go: TestEmbedTexts, TestSummarizeStyle (streaming, errors, empty input), TestNew_UsesProvidedModels
- ollama/client.go: early return for empty input in EmbedTexts/SummarizeStyle
2026-09-02 00:30:19 +02:00
ad67171f37 config: move Ollama model defaults to config package
- config.go: set EMBEDDING_MODEL=qwen3-embedding:0.6b, STYLE_MODEL=qwen3:4b as defaults
- ollama/client.go: remove hardcoded fallback logic, use passed values directly
- Single source of truth for model defaults in config package
2026-09-02 00:09:06 +02:00
5574a8596f db: update embedding dimension to 1024 for qwen3-embedding:0.6b
- Migration 002: VECTOR(768) -> VECTOR(1024) to match qwen3-embedding:0.6b default output
- integration_test.go: update test vector from 768 to 1024 dimensions
2026-09-02 00:00:10 +02:00
56f8625f05 ci: fix test workflow Ollama models to match project defaults
- Pull qwen3-embedding:0.6b and qwen3:4b instead of nomic-embed-text/llama3.1:8b
- Set EMBEDDING_MODEL and STYLE_MODEL env vars for test server
2026-09-01 23:53:09 +02:00
e2cd655bc1 ci: add docker-compose.test.yml for test infrastructure
- PostgreSQL with pgvector for migrations and tests
- Ollama for embedding/style models
- Used by test-endpoints.yaml workflow
2026-09-01 23:47:55 +02:00
63709524de db: make migrations idempotent, regenerate store, minor cleanup
- schema: add IF NOT EXISTS to CREATE TABLE/INDEX for idempotent migrations
- store: regenerate with sqlc v1.31.1 (adds UserStylePost, interface{} for Embedding)
- webhook: minor formatting cleanup
2026-09-01 23:42:23 +02:00
63f8756cc7 db: add user_style_posts table for post ID caching
- migration 004: create user_style_posts with user_id, platform, post_id, post_text, created_at
- queries: UpsertStylePosts, DeleteStylePosts (excludes Twitter), GetStylePosts, GetStylePostsByIDs, GetStylePostByID, PruneStylePosts
- activitypub: add ID field to Post struct
- server: fetchProfilePosts checks cache first, upserts on miss; buildStyleProfile deletes non-Twitter posts before rebuild; background pruner runs daily
2026-09-01 23:41:45 +02:00