#ActivityPub 57 hashtags

Todd Sundsted
Release v2.4.10 of Ktistec

I'm trying to get through the backlog of bugs and features in my to-do list. Release v2.4.10 of Ktistec packages up several important improvements. The most impactful change is graceful server shutdown—I've never had a problem with shutdown leaving the database in a broken state, but prevention is the best cure.

Added

  • Support manually refreshing actor information. (fixes #112)
  • Add link to log level settings to the navigation bar.

Fixed

  • Enable dragging source links to the address bar. (fixes #109)
  • Fix missing reply/mention notifications for non-create activities.
  • Ensure the network is up before attempting to refresh a page.

Changed

  • Block actor handle and display name when actor or post is blocked.
  • Gracefully shut down the server.

I'm considering adding lightweight multi-user support (invitation-only, not open registration). I'm interested in your thoughts on whether this would be useful.

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted
Release v3.0.0 of Ktistec

I've been running v3.0.0 of Ktistec in production for the last few weeks, and it seems stable and I’m using it every day, so it’s time to release it!

This release adds:

  • Model Context Protocol (MCP) support. Ktistec can act as an MCP Server.
  • OAuth2 authentication support. Ktistec can act as both an OAuth2 authentication server and a resource server.

Model Context Protocol (MCP) is a simple, general API that exposes Ktistec ActivityPub collections (timeline, notifications, likes, announces, etc.) to MCP clients. To be fully transparent about what this means, MCP clients are shells for Large Language Models (LLMs).

When building this, I focused on a few use cases that are important to me: content summarization, content prioritization (or filtering) based on my interests or the content's structure (well-constructed arguments vs. low-signal opinions) or its tone, especially when it comes to shared posts. Ktistec is a single user ActivityPub server and Epiktistes (my instance) gets a lot of traffic. I want to build the “algorithms” that surface the content I want to see.

Of note, there’s currently no support for content generation.

While I work on this, I’m not abandoning the 2.x line. I’ll continue to add compatible features and fix bugs as long as I'm able. I realize the use of LLMs, and MCP by extension, and therefore the 3.x branch, is controversial—I don’t intend to push v3 on anyone.

If you're still with me, Ktistec now exposes:

  • MCP Resources
    • ActivityPub actors (ktistec://actors/{id*})
    • ActivityPub objects (ktistec://objects/{id*})
    • registered users (ktistec://users/{id})
    • server information (ktistec://information)
  • Tools
    • count_collection_since(name, since)
    • paginate_collection(name, page, size)
    • read_resources(uris)
  • Prompts
    • whats_new

Supported collections include:

  • timeline, notifications, posts, drafts, likes, announces, followers, following
  • collections of hashtags of the form hashtag#<name> (e.g., "hashtag#technology")
  • collections of mentions of the form mention@<name> (e.g., "mention@euripides")

There is more detail in the README.

TL;DR Add a remote MCP connector in your MCP client of choice: supply the URL of your instance including the /mcp path (e.g. "https://epiktistes.com/mcp").

Screenshot of the MCP Inspector connected to Epiktistes


#ktistec #fediverse #activitypub #crystallang #mcp #llm

Todd Sundsted
Release v2.4.9 of Ktistec

Release v2.4.9 of Ktistec fixes two significant bugs. From the changelog:

  • Don't reset next_attempt_at in tasks when server restarts.
  • Fix incorrect syntax for inline tags in Slang templates.

The first bug resulted in server maintenance tasks running immediately, every time the server restarted, and then beginning their cadence of scheduled runs from there. The second bug surfaced after I released a new version of Slang that itself included a bug fix.

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted
Release v2.4.8 of Ktistec

Ktistec v2.4.8 has many small fixes and improvements, but includes one significant fix to ActivityPub garbage collection, which was the major feature introduced in the last release.

⚠️ Important Note: Building with Crystal Language version 1.17.x is not supported due to two breaking changes. See:

(Maybe it's three changes—compile times are also far slower and executable sizes are much larger.)

Added

  • Send "User-Agent" header identifying Ktistec on outbound HTTP requests.
  • Add accept/reject action buttons to top panel on actor pages.

Fixed

  • Add index on "username" on "actors" table. (Fixes a regression introduced in e659e84a.)
  • Rejection now correctly sets follow relationships as confirmed (previously they remained pending).
  • Fix garbage collection issues with threads created in earlier versions.

Changed

  • Prioritize the author's self-replies in thread view.

Enjoy!

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted
Release v2.4.7 of Ktistec

After a mental health break, release v2.4.7 of Ktistec is out. The biggest improvement is the addition of a command line switch/option to run garbage collection on startup. Garbage collection, in this context, trims down your database by deleting old ActivityPub objects that are not connected to your user through:

  • Attribution: Objects attributed to you or actors you follow
  • Activities: Objects referenced by your activities or activities of actors you follow
  • Collections: Objects in your timeline, notifications, or outbox
  • Content: Objects with hashtags, mentions, or in threads you follow

It reduced the size of my database ~24%. Details on usage, warnings, etc. are in the README.

Other changes:

Fixed

  • Use single quotes for string literals in SQLite queries.
  • Fix WITH RECURSIVE queries.
  • Fix broken CI workflow.

Changed

  • Present local internal URLs as external URLs in posts.
  • Limit pagination size for unauthenticated users.
  • Better convey actor/object deleted/blocked status on index pages.
  • Improve presentation of inline code and code blocks.
  • Clip alt text on thumbnail images.

Other

  • Update cached copy of Lemmy's JSON-LD context.

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted
Release v2.4.6 of Ktistec

Release v2.4.6 of Ktistec is out. As mentioned in an earlier post, this release focuses on database performance improvements. This means caching the results of expensive queries (like counting all posts with a particular hashtag or mention). On my instance at least, pages like the notifications page are now snappier.

There are still slow queries (queries that take more than 50msec). Most of those are requests for pages of old posts where none of the necessary database pages are in the page cache. I have increased the page cache size, and that reduces the frequency, but I don't see an immediate fix.

Fixed

  • Add missing database query logging.

Changed

  • Improve query performance for hashtags and mentions.
  • Make less costly updates to tag statistics.
  • Improve anonymous session management.
  • Cache the Nodeinfo count of local posts.

Removed

  • Remove support for X-Auth-Token.

Other

  • Add timeout values for POST socket operations.

I don't have an immediate plan for the next release. There have been a bunch of feature requests that I think have merit. I'll probably get started on some of those.

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted

You can specify the SQLite database and pass options (pragmas like cache_size, journal_mode, ...) on the command line when you start the Ktistec server. The following example sets the cache size to 20,000 pages (up from the default of 2,000 pages) which improves performance on larger instances.

KTISTEC_DB=~/ktistec.db\?cache_size=-20000 ./server

You can also enable the write-ahead log (but make sure you know what that means).

KTISTEC_DB=~/ktistec.db\?journal_mode=wal\&synchronous=normal ./server

Pragmas supported are limited to those listed here.

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted

A new release of ktistec that improves database performance is imminent. In the past, database optimization usually meant "fixing a bunch of poorly constructed queries", and I'm sure there's more of that to do—I'm not an expert. But this time, I found most of the queries were as good as they were going to get on my watch (I'm not an expert). If you have a million records and you need to filter and count them, that's just going to take some time...

So this time, I focused on caching the results of queries like that (which really means I focused on cache invalidation, right). A case in point is commit d544b1af. Previously, the nodeinfo endpoint filtered and counted posts on every request, and it took +80msec to do that. Worse, the filtering pushed everything else out of the sqlite page cache, which made the next, unrelated database query slow!

Caching this value, and only recounting when I post something, not only dropped the service time for the request to ~1msec but actually improved database performance, generally!

More to come...

#ktistec #fediverse #activitypub #crystallang

Todd Sundsted

If you're running an instance of Ktistec and want to see what other ActivityPub instances are sending you, turn on JSON-LD processing debug logging.

  1. Go the the /system URL.
  2. Find the ktistec.json_ld setting.
  3. Select "Debug" and save.

Ktistec will dump received activities to the log, after the activity has been parsed into JSON but before JSON-LD expansion.

2025-01-22 14:53:17 UTC 409 POST /actors/toddsundsted/inbox 4.29ms
2025-01-22T14:53:17.597172Z  DEBUG - ktistec.json_ld: {"@context" => ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
"id" => "https://random.site/users/FooBar#delete", "type" => "Delete", "actor" => "https://random.site/users/FooBar", "object" => "https://random.site/users/FooBar", "to" => ["https://www.w3.org/ns/activitystreams#Public"], 
"signature" => {"type" => "RsaSignature2017", "creator" => "https://random.site/users/FooBar#main-key", "created" => "2025-01-22T14:52:40Z", "signatureValue" => "01234567890abcdefghijklmnopqrstuvwxyz=="}}

Answer to a FAQ:
The server returns HTTP status code 409 ("Conflict") if it has already received an activity.

#ktistec #fediverse #activitypub

Todd Sundsted
Release v2.4.5 of Ktistec

Ktistec release v2.4.5 rolls out the build time and executable size optimizations I've been blogging about here. It also fixes a few small bugs.

Fixed

  • Handle @-mentions with hosts in new posts.
  • Handle HEAD requests for pages with pretty URLs.
  • Destroy session after running scripts.

Changed

  • Delete old authenticated sessions.

I've started a branch full of query optimizations. My general rule—as highlighted in the server logs—is if a query takes longer than 50msec, it takes too long. It's time to address some problems...

#ktistec #fediverse #activitypub #crystallang