Four months and 354 comments
I opened #171856 against the public elastic/kibana repository on 23 November 2023. It merged on 4 April 2024, four months and twelve days later, with 354 comments on it. Two files changed. One of them was a single line added to CODEOWNERS. The other was a Markdown document 2,799 lines long.
Between August 2022 and December 2024 I opened 133 pull requests against that repository. That one collected more than double the comments of the next most discussed, and it contains no code.
I think the four months were worth spending, and I do not think that generalises into "always write the design document first". The document cost four months of calendar time before anyone wrote a line of the thing it described, and I want to be honest about what that bought and what it did not.
What the document was for
None of this means anything outside the product, so the vocabulary comes first.
Kibana is the user interface for Elasticsearch. Elastic sells a security product on top of it, a SIEM, short for security information and event management, which is the screen a security team watches to find out that something is wrong. The unit of work in that product is a detection rule: a saved query plus a schedule. Kibana runs the query against the customer's logs every few minutes and writes an alert whenever it matches. A rule has a name, a description, a severity, a query, the indices it searches, and around forty other fields.
Elastic writes several hundred of these rules itself and ships them as a versioned package. Those are prebuilt rules, and until late 2024 the customer could not edit them. That restriction is not arbitrary. A rule you cannot edit is a rule Elastic can keep updating, because there is nothing of yours in it to overwrite. If you wanted a change, you cloned the rule and edited your clone, and from that moment the clone never received another Elastic update. You had a rule tuned to your network and frozen in time.
Removing that trade-off means letting people edit a document that you also keep publishing new versions of. So you need a three-way merge across the version Elastic originally shipped, the version the customer has now including their edits, and the new version Elastic just published. The document names those the base, current and target versions, and I use those names from here on.
It is git merge for a security rule. What gets merged is a structured record, though, and each field in it has its own idea of what a change means.
That is what the RFC specified. RFC is Kibana's name for a design proposal that is reviewed and merged into the repository before anyone builds the thing. The implementation it specified then ran from June to October 2024 and shipped across the 8.16 and 9.0 releases.
Where the argument actually was
I expected, going in, that this would be a schema document. The table of contents opens with schema changes. The summary at the top lists rule schema changes first. The project was called Prebuilt Rules Customization, and customization sounds like a field you add.
The line counts say otherwise. An RFC grows where reviewers push back, so section size is a decent map of where the difficulty sat.
| Lines | Section |
|---|---|
| 831 | Concrete field diff algorithms by type |
| 392 | Customizing prebuilt rules: endpoints |
| 355 | Importing rules |
| 276 | Technical implementation of migration-on-write |
| 179 | Changes needed in rule schema |
| 122 | Migration strategy |
| 98 | In the UI |
| 87 | Prebuilt rules endpoints |
The schema change is 179 lines, and most of that is the shape of one new field. The merge algorithms are 831, almost a third of the document, and they are not specified once generically. They are specified separately for single-line string fields, multi-line string fields, number fields, arrays of scalar values, and arrays of objects, each with its own table of what happens when the base, current and target versions disagree.
The reason they had to be separate is the part I would not have predicted. Here is an invented rule, cut down to two fields, with the real field types:
{
"base": { "name": "Suspicious PowerShell", "tags": ["windows"] },
"current": { "name": "Suspicious PowerShell (tuned)", "tags": ["windows", "tuned"] },
"target": { "name": "Suspicious PowerShell Encoded Command", "tags": ["windows", "powershell"] }
}
The tags array resolves on its own. Set union gives ["windows", "tuned", "powershell"], and there is no input where that fails. The name never resolves. You cannot concatenate two names, and the fact that both sides renamed it probably means the two versions of the rule are about different things now, so a person has to look at it. A multi-line description sits between those two cases, because a line-based merge works there exactly as it does in a text file.
So a conflict is not one thing. It has to carry whether the algorithm produced an answer it trusts, and which answers are even possible depends on the field's type. Writing that down took 831 lines because every reviewer who read it had a field in mind that the current draft handled badly.
The migration that could not be a migration
The second-largest cluster, 398 lines across two sections, is about changing the stored shape of every existing rule.
Rules are stored as saved objects, which is Kibana's term for a document it keeps in Elasticsearch with a versioned schema and a defined upgrade path. Kibana has a mechanism for exactly this: you describe the transformation, and it runs when the customer upgrades Kibana. Except the team that owned that mechanism had stopped supporting it, and its replacement, the Model Version API, did not support encrypted saved objects. Alerting rules are encrypted saved objects. The obvious answer was not available.
What we landed on was to migrate each rule the next time an endpoint touched it, and to convert the old shape to the new one in memory on every read in the meantime. That means a customer can sit indefinitely with some rules migrated and some not, and both shapes have to keep working, forever as far as any endpoint is concerned.
The consequence is a table in the RFC with a row for every endpoint that reads or writes a rule and two columns, normalize on read and migrate on write. About twenty rows. Bulk actions gets its own block of rows because its dry-run mode must never write, so it must never migrate. Duplicating a rule needs no migration at all, because a duplicate is by definition a new custom rule. Delete needs normalize-on-read only, because it returns the deleted rule's data on the way out.
Nobody derives that table in a pull request review. You only get it by sitting down and enumerating, and enumeration is the thing a long document is actually good at.
What four months of review did not catch
The document was not right about everything, and I think that is the more useful half of the story.
The review model it specified carried has_conflict as a boolean on each field. Four months, 354 comments, and a boolean. The 831 lines on diff algorithms in the same document already distinguish conflicts the algorithm can solve from conflicts it cannot, and already say that the merge proposal differs between the two cases. The document contained everything needed to know the boolean was wrong and shipped with the boolean anyway.
It got fixed in #187770 in July 2024, which replaced it with an enum of NONE, SOLVABLE and NON_SOLVABLE, and constrained the permitted values per algorithm so that a single-line string field can only ever come back as NONE or NON_SOLVABLE. The same pull request added has_base_version, because the base version can be missing entirely if the customer upgraded from a Kibana old enough not to have stored it, and comparing two versions is a different problem from reconciling three. Neither of those is in the RFC.
There is another admission in the timeline. On 2 February 2024, while the RFC was still in review, I opened #176156, a 1,004-line branch called "Per field diff" that never merged and has zero comments on it. I wrote code in the middle of the design review to find out whether the design was buildable. Four months of prose did not answer that question on its own.
And the document did not merge because it was approved. Its own status line, at the top of the merged file, reads "Completed, feedback addressed. Awaiting further feedback, or closing off." It merged because the argument stopped.
What a shorter version would have traded
The honest cost is four months of wall clock on a feature that then took five more months to build. That is real, and if the project had been the only thing the team was doing it would have been intolerable. It was not; the same period covers a flaky test campaign and a serverless test migration, so the document was competing with other work rather than blocking an idle team.
What a shorter document would have traded away is specific, and I can point at the pieces.
The per-endpoint migration table would not have existed. Migration would have been decided endpoint by endpoint as each pull request arrived, which is how you end up with a dry run that writes to Elasticsearch.
The per-type conflict semantics would have been discovered in review of the merge engine itself, #191439, which was already +3,202 lines across 43 files and open for seven weeks with 104 comments. Adding "and by the way, what is a conflict" to that review would have made it worse.
Buried in that same pull request is the change with the widest consequences, which is that rule upgrade moved from PATCH semantics to PUT semantics. Under PATCH, a field that disappears from the new Elastic version is left alone in the customer's rule. Under PUT, it is removed. So a user who adds a timeline to a rule and then accepts a full upgrade loses it. That is correct behaviour for a merge. It is also a real change in what the product does to your data, and it is the kind of thing you want argued out in a document with two teams listed as owners in CODEOWNERS, rather than in a comment thread on a 43-file diff.
The pattern I would keep is narrower than "write RFCs". The sections that grow under review are telling you where the feature actually lives, and the sections that stay short were never the hard part, whatever the title of the project says. The document I thought I was writing was about a schema field. The document that merged was mostly about what it means for two people to change the same thing.
I left this work in December 2024, so the details will have moved since. The pull requests are all public and the RFC is still in the repository under docs/rfcs/detection_response, a directory that pull request created.