Day 7

Governance, generated documents, and a freeze hiding in plain sight

The platform went from "it surfaces problems" to "it helps you decide and produce" — and ended with a bug it had already warned me about. In a document it wrote. About itself.

This stretch turned the platform from "it surfaces problems" into "it helps you decide and produce" — and ended with a bug that the platform had, amusingly, already warned me about itself.

The decision layer

The platform could find conflicting rules. Red edges in the graph, warning badges, a panel showing which file each clashing rule came from. But finding isn't governing. The question a real user asked was the right one: "so how does someone decide which rule wins, and where's the audit?"

So I built the decision step. You pick the authoritative rule. The others are marked superseded — kept, never deleted. The platform writes a decision record, an audit-trail entry, and a supersedes edge in the graph.

The whole thing rests on two small tables: generated artifacts, and an append-only audit log. Those two turned out to be the foundation for everything after.

Documents that persist

With that primitive in place, "analyze the codebase and write me a document" became cheap. An endpoint retrieves a slice of the corpus, runs a kind-shaped pass, and saves the result as an artifact — a design doc, a user guide, a recommendations report, a bugs report. Not an ephemeral chat answer you copy-paste. A durable, auditable document you can come back to.

Then the fun part

I had the platform write its own user guide through that feature. It produced a clean 188-line guide in under a minute.

It also quietly demonstrated the honest limitation. Because this is retrieval over the corpus, and the corpus includes design docs and a dummy demo scenario, the generated guide confidently described features that don't exist yet — a dashboard we'd only designed, a live telemetry integration we'd only sketched.

Generated docs are great drafts. The corpus shapes them. Which is exactly why the feature saves a draft you curate, rather than publishing an answer. Same "AI drafts, human approves" thesis — one level up.

The freeze it warned me about

Then the platform stopped responding. "Why isn't it working anymore?" — right after adding files and hitting ingest. Health checks timed out. The port was listening but dead.

The cause: ingestion embedded chunks synchronously, and embeddings are CPU-bound tensor work. On a single worker, that one blocking call froze the entire async event loop — health, chat, the UI, everything — for the whole duration of the ingest.

The fix was one line: run the embedding in a worker thread. Verified — health now stays responsive during an ingest, where before it hung completely.

The punchline

The recommendations document that the platform generated about its own codebase listed this exact issue as finding number one. Something to the effect of: make the health endpoint non-blocking; the embedding blocks the single worker.

The tool found its own bug. I shipped the finding as a feature. Two days later the bug bit me.

Dapat binabasa ko yung sarili kong generated docs (I should read my own generated docs).

What I learned

The shared-primitive bet paid off. Build the documents-plus-audit foundation once, and conflict resolution, document generation, and outbound mirroring all fall out of it cheaply.

And the loop is closing in a satisfying way: the platform analyzes the code, writes the recommendations, and the recommendations are correct enough to fix real bugs. That's the whole pitch, demonstrated on itself.

The decision flow, the freeze, and the tables underneath

The endpoints, the code, and the specific tooling. Same password as the other Knowledge Platform posts — or request access below.

Build log entry from a daily journal. Written the evening of the work, lightly edited.