Dear Pulsar Community,

We merged about 1,900 PRs to master in the last 12 months, against
about 700 the year before. October and November alone had more than
800, which is more than the whole previous year.

We now write code much faster than a year ago. How we verify it has
not changed much in the Apache Pulsar project.

For several core parts of the broker (message dispatch, managed
ledger writes, topic loading and unloading, topic policies) I cannot
find a current statement of what correct means: the states, who owns
them, and the invariants. A PIP lets us discuss and agree on a
design, but in my experience it is rarely updated afterwards to
match the implementation. A reviewer, or an AI agent assisting one,
has to piece the intended design together from PIPs, tests and code.

To me this says that verification, not writing code, is now what
limits how much we can safely merge, and that we have invested far
less in it than in producing changes.

Several recent accounts of the same shift helped me put my concern
into words:

- Two Anthropic reports. One, about migrating a production API to
  Rust with AI agents, puts it as "Verification is the new
  bottleneck": when writing code is no longer the constraint, what
  limits us is how quickly we can verify the result [1]. The other,
  on formal verification at scale, finds that the hard part is
  writing down precisely what correct means [2].

- Lauren Tan's talk "All Code Is Slop (Except Mine)" [3]. She points
  out that the code base is one of the largest inputs an AI agent
  sees, so a workaround that is already there gets copied until it
  looks like the pattern, and that a revert rate does not count the
  bugs that a later PR quietly fixes. In her team's experience,
  written guidelines and human review were the weakest safeguards at
  high volume. She concludes that every recurring review correction
  should become a deterministic check, or the design should make the
  mistake impossible.

- Tobi Lütke, Shopify's co-founder, in a recent interview [4]. He
  likens code review to formal verification done by hand, which
  worked while people could reread all the code. Agents now produce
  more than can be reviewed, so he expects formal verification to
  become the most important part of engineering. His practical
  advice is to ask an AI agent to find the state machines implicit
  in a code base, make the states and transitions explicit, and then
  check a model of them (he names TLA+) so that every state the
  system can reach is specified and tested.

Speaking for myself: I have worked on Pulsar since 2019, and I find
it a challenge to keep up with the volume of PRs and to judge
whether patching and working around individual bugs is taking Pulsar
in the right direction. It feels as if we are not addressing the
fundamental issues of state handling and correctness. Many of the
AI-assisted PRs I see, some of my own included, match what Lauren
Tan describes: the change patches the local symptom and leaves the
underlying architectural problem in place, and the next change
copies the workaround.

Whoever or whatever writes the change, state accumulates. In 12
months ManagedLedgerImpl grew from 90 to 133 fields and from about
5,100 to 7,300 lines. It has a State enum, yet 8 of the 12 mutable
flags and futures that carry state next to that enum first appeared
in the last year. Across 16 selected hotspot classes, 59 of 124 such
fields first appeared in the last year, 37 of them in a commit
labelled as a fix. Some of those fields record distinctions that a
correct fix needs. What I find hard to recover in a review is which
combinations the design allows. These counts cannot tell us whether
quality fell or what part AI assistance played.

I have long wanted us to have proper models of the end-to-end
flows in Pulsar, well before AI agents. By a flow I mean the path
an operation takes through all the components it touches. The two
central ones are the publish flow, from the producer through the
broker to storage, and the consume flow, from a subscription's
cursor through dispatch, acknowledgment and redelivery.
Transactions tie the two together, and geo-replication carries
messages on to another cluster. Around them are the data management
flows (retention, backlog quotas and TTL, compaction, offloading to
tiered storage, trimming and deleting ledgers) and the control
flows (lookup and topic ownership, loading and unloading topics,
load balancing). The client specification that was recently
contributed for scalable topics is a good example of such a model
for one area.

In my view these flows should be modelled and documented, together
with the main components they pass through and how state is handled
in each of them. Each description should also cover backpressure
(flow control): how the flow avoids accepting more work than it can
handle. That is central to how Pulsar behaves under load, and
ARCHITECTURE.md notes that it is not yet documented beyond the
memory side [5].

AI agents can help here: they can reverse-engineer a first version
of such models from the code, as documents that both people and AI
agents can read, for maintainers to correct. How to do this so that
it serves our goals without costing more than it gives back is open
to discussion: how much to model, in what form, and how to keep it
current.

It helps to say what those goals are. People run Pulsar for data
they cannot afford to lose, and their applications depend on its
ordering and delivery guarantees. What they need from us first is
reliability. I use the word broadly: durability, correctness of
ordering and delivery, liveness (the system keeps making progress:
no stuck consumers, hung operations or deadlocks), availability,
resilience when brokers, bookies or the network fail, security
(authentication, authorization and tenant isolation hold,
vulnerabilities are fixed promptly, and dependencies with known
CVEs are upgraded), and stable, predictable behaviour under load
and across upgrades.

What they need second is efficiency. Performance (low latency,
high throughput) alone is not the goal. What matters to the people
who run Pulsar is cost efficiency: how much compute, memory and
storage and how much operational effort it takes to serve their
workload at the latency and throughput they need.

I think of our work as serving two purposes:

- Maintenance should make Pulsar more reliable and more efficient
  for the people who run it. A fix serves that when it removes a
  class of failure. A fix that adds one more flag next to the others
  can close one bug and make the next one more likely.

- Feature work should close gaps in existing use cases and open up
  new ones. Scalable topics are an example of the latter: a topic
  can scale out and back in while per-key ordering is preserved for
  the consumers that rely on it. Much feature work also serves
  reliability directly, for example observability and monitoring,
  which make a problem visible to operators.

The same holds for both kinds of work. If we cannot say how a
component is supposed to handle its state, every change built on top
of it carries the same unknown corner cases. And we can promise
users a guarantee only to the extent that we can check that the code
keeps it. Verification is how we know that a change moves us toward
those goals.

The outcome I'd like us to aim for is that users can upgrade with
confidence, that a contributor or an AI agent can find out what
correct means for the code they are changing, and that a reviewer
can check a change against that, without relying on their memory of
the code or reverse-engineering the intended behaviour from the code
base each time.

Our test suite does not give us this by itself. It catches many
regressions, but most tests replay one scenario: the inputs or the
interleaving of the bug they were written for. They say nothing
about the cases nobody thought of, which is where our concurrency
bugs are. Many tests also pin implementation details through
mocks, reflection and sleeps, so they break when the code is
restructured and make the structural fix more expensive than the
local patch. And test code needs review too. It grew by 45% in
three months, and AI agents reproduce whatever test style they
find, good and bad.

Before proposing anything, I'd like to hear whether this matches
your experience. Do you also find it hard to verify that the changes
we make take us closer to our goals of making Pulsar more reliable
and efficient? Where is it hardest for you?

-Lari

[1] https://www.anthropic.com/research/migrating-api-to-rust
[2] https://www.anthropic.com/research/formal-verification
[3] https://ai.engineer/talks/O_zcc6Xl12g-all-code-is-slop-except-mine
[4] https://www.davidsenra.com/episode/tobi-lutke-2
[5] https://github.com/apache/pulsar/blob/master/ARCHITECTURE.md#backpressure

Reply via email to