Task Tracking on Trails

In June I wrote that task tracking belonged in plain text: markdown RFCs and stories in a git repo, no service, no database. It was an on-ramp. It got the work out of the code repo and in front of agents with zero setup, and it did that job. Then it outgrew itself. The prose still lives in markdown. Everything else moved, and where it ended up is the best test my Rails port has had.

That place is trailmap, the first real application built on trails.

Outgrowing the on-ramp

The plain-text tasks repo carried the project from May 28 to August 25 and racked up 27,838 commits. Most of those weren't writing. They were status flips. Every time an agent claimed a story or marked one done, it ran pull --rebase, committed and pushed, racing every other agent doing the same, with an advisory lock file to keep them from stepping on each other. Burndown charts came from parsing commit messages.

By then git was working as a transaction log and an event store, and it isn't either one. Plain text was the right way to start, and the wrong way to keep going. Transactions want a database. Prose doesn't.

ActiveRecord on its own

So the tasks repo split in two. Markdown keeps the fields people and agents write by hand: titles, dependencies, estimates, the body text. SQLite holds the fields the CLI changes: status, claims, PR numbers, priority. Each field has exactly one owner, so there's nothing to sync and nothing to conflict.

Keeping the prose in markdown matters because agents can grep it. Finding every story that touches a package, mentions a method, or cites an RFC is one command against a directory of files, not a crawl through a database. That was the best part of the on-ramp, and it's the part I kept.

The CLI that reads and writes that database uses trails' own ActiveRecord. That was the first time trails ran a real workload, with real concurrent writers.

It found a gap on day one. I had 20 agents try to claim the same story at once. One won, seven correctly heard "already claimed," and twelve crashed with database is locked. Rails ships SQLite pragmas for WAL mode and synchronous writes but no busy_timeout, and trails had copied that faithfully. WAL allows concurrent readers, but writers still take turns, and a claim storm is all writers. A ten-second timeout turned the crashes into correct answers.

Ringo, and the migration

Trailmap isn't my first dashboard. Before trails could run anything, I needed a tool to help me build trails, so I wrote one: ringo. It spawns agents into tmux panes, shows me their live output, tracks their PRs, and sweeps merged work.

I wrote ringo in Go on purpose. I wanted to find out how capable I could be, working with coding agents, in a language I didn't know well. It did that job. But as more of trails started working, I wished I'd written ringo in JavaScript so the two could share code. Ringo ranked the ready queue with a Go read model carrying a comment that it "must reproduce readmodel.ts exactly," so every change to the ranking had to be made twice. Counting a JSON index republished for readers, the task domain lived in three places.

On September 2 I scaffolded trailmap with trails new and started moving ringo into it, one feature at a time: the ready queue, the story and RFC pages, PR timelines, transcripts, deploy logs, the pane views. Trailmap owns the tasks database and serves a JSON API on loopback, so the CLI and what's left of ringo call it and don't carry copies of their own.

WebAssembly became the bridge. Not all of ringo is framework code, and the parts that aren't didn't need to be rewritten. They're compiled to WebAssembly and shared, so Go and the trails app run the same logic while the migration is in progress.

From models to an app

This is where trails stopped being a library and became a framework. The CLI only needed models. Trailmap needs everything else Rails gives you: routes, controllers, views, helpers, a server, asset fingerprinting, and a deploy.

It also uses two databases on purpose. The task domain is SQLite. The owner and repository hierarchy behind the GitHub-style pages is PostgreSQL, because trails had a PostgreSQL adapter that no application had ever driven. It found three defects in its first afternoon.

Trailmap has one rule that matters more than any feature: a framework bug gets fixed in trails, never patched in the app. A workaround fixes it for one app and leaves it broken for the next one, for the generator's output, and for the test suite. And it quietly becomes permanent, because nothing ever tells you to delete it. The first time this came up, helpers weren't reachable from views, and the first attempt patched around it in trailmap's ApplicationController. I closed that PR. The real cause was three separate bugs in trails.

The Rails twin

Trailmap has a twin: the same site, written in Rails 8.0.2, in the same repo. It uses the same databases, routes, pages and JSON, and every TypeScript file has a matching Ruby file, so rfc-pages-controller.ts sits across from rfc_pages_controller.rb. When a feature lands in one, it lands in the other.

The twin is how I keep trailmap looking like a Rails app. A trails app could drift into being a TypeScript app that happens to use trails, with JavaScript idioms where Rails ones should be, and nothing would catch it. Writing every feature in Ruby too makes the Rails way of doing it concrete, and a script compares the two running apps path by path. Every difference gets filed as one of three things: a trails bug, an app bug that both frameworks reproduce, or a real gap between JavaScript and Ruby that the port has to bridge.

Because the twins share databases, they can also share work. A job enqueued by trails can be picked up by Rails, and the other way around, which tests ActiveJob's serialization against the real thing and not against my reading of it. The basic tests pass. It has also caught one difference already: a serialized job's timezone came through as null.

It's also a stricter test than parity. Parity compares Rails' source to trails' source. The twin compares what the two frameworks actually do, given the same app.

Workers, mail and websockets

The last layer is the work that happens when nobody is looking at a page.

The parity stats sync runs every hour as a Solid Queue recurring job. When it fails three times in a row, ActionMailer sends me an email. When any job fails for good, I get mail about that too. The fleet dashboard streams live events, and each agent's tmux pane has a live view over websockets, served through rack, where I can type a line and send it straight to the agent.

None of this had run outside a test suite before trailmap. It found:

  • trails/all didn't load the ActionMailer railtie.
  • queue_adapter = :solid_queue didn't find the adapter.
  • SQLite's busy wait blocked the event loop.
  • trails server didn't await server blocks.
  • trails-tsc, the type generator for models, broke on a real schema.
  • Prepare callbacks weren't awaited, and a serialized job's timezone came through as null.

Every one of those had a passing test suite behind it.

What I use it for

Trailmap is where I spend my day now. I check the ready queue and the stories, and keep agents moving. When one of them is stuck on a question, I answer it from the pane view. Then I review and merge their PRs. It's behind SSO for now. The repo is public.

The trailmap dashboard: a list of agent sessions, two collapsed and one expanded to show the agent's live terminal and a side panel with its RFC, branch, PR and CI.

Each row is an agent working on a story. The first two are still drafting. The third has a PR in review, and it's expanded: the agent's terminal, live, where it has just answered the reviewer, marked its PR ready, and told me what to run once it merges. The side panel has the RFC, branch, PR and CI status, and a button to open the pane itself.

A trailmap pane page: an agent's live terminal, a message sent into it telling the agent a CI failure was a flake, the agent's reply, and a text box at the bottom to send the next line.

Opening the pane gives the whole terminal, with a box at the bottom that types a line straight into it. The highlighted message is one of those: a note that a red CI run was a flake, not the agent's change. The agent's reply comes right after. Answering a stuck agent takes a sentence, without leaving the page.

The point

Each step up the stack exercised code the step below never touched. The CLI found what the unit tests couldn't. The app found what the CLI couldn't. Workers and mail found what the app couldn't. Parity tells you the methods exist. An app you depend on every day tells you whether they work.

Comments

Leave a Comment

Used for confirmation only. Not displayed publicly.