Your LLM Wiki Should Collect the Questions It Can't Answer. I Wrote a Gap Queue for That.
DEV Community

Your LLM Wiki Should Collect the Questions It Can't Answer. I Wrote a Gap Queue for That.

Harrison Chase published How to build a knowledge factory on November 21. By this week it was all over my feed, and the useful part was not a new model.

The missing bit, as he puts it, is not more context. It is a system that collects, curates, and maintains the knowledge of how your company actually works: skills, domain facts, and guidance on where current data lives.

Two moving parts do the collecting. Working agents flag what is missing or wrong while they work. A curator later turns those flags into knowledge the next agent can use.

That is the opposite of how most LLM wiki setups I see behave. People ingest more notes, hook up a retriever, and treat a fluent answer as proof the wiki is complete. The miss - "I could not find this," or "these two pages disagree" - dies in a chat log. The next session starts from the same hole.

So this post builds the boring local version of the flag-and-curate loop: a ~530-line, stdlib-only Python script called gap_queue.py. It searches a Markdown wiki, and when the search is not good enough it files a ticket under gaps/. A later pass clusters related tickets and drafts a page under proposals/. It never writes to wiki/. A human still owns the merge.

The miss is the valuable part

A retriever is good at hiding gaps. If two pages are lexically close to the question, the agent gets two passages and is asked to "be helpful." Sometimes it quotes a near-miss as if it were the answer. Sometimes it says it does not know. Either way, nothing is added to the wiki.

Chase's factory starts from the other end. The goal is not to document everything before agents can work. It is to make the work itself reveal what is missing, and to have a place for that revelation to live.

A gap ticket is that place: the question, the pages that were searched, the evidence, and a kind - missing, stale, or conflict.

I also wanted the decision to be testable without calling a model. Scoring, staleness, and claim conflicts are deterministic. The curator draft is a stub with open questions, not a guessed policy.

The sample wiki

The fixture in this post is made up: 17 wiki pages and 2 raw sources for a fictional field-service company I called Harborline. These pages are not real policy. I seeded it with the kind of mess a working wiki actually has.

Clear, recently reviewed pages for the questions a dispatcher would expect to answer: invoice terms, the after-hours roster, the workmanship warranty.

A close lexical distractor for travel billing. The cancellation policy has a trip fee, but only for missed appointments. The travel policy is an employee expense page, not a customer rate card. The SLA talks about emergency response windows, not commercial adjustments.

A stale rate card. emergency-rates.md still says after-hours work is 1.5×, last reviewed March 12, 2024, citing a 2024 source.

A real disagreement in frontmatter. overtime.md claims overtime starts after 8 hours. union-addendum.md claims it starts after 10 hours. Both were reviewed on the same day. Nobody reconciled them into one payroll rule.

Raw sources live in sources/ and are never searched. Wiki pages may cite them. That split stays the same as in an LLM wiki: compiled pages are what the agent may use; the sources stay read-only.

How a question is classified

Each ask run does four checks, in this order.

BM25 over the page title (boosted 3×) and the body, with a coordination factor so a page that only matches two of six query terms cannot win just because it is short.

Coverage. A hit also needs the best page to match at least 55% of the query terms. This is the check that stops cancellation-policy.md from answering a question about a travel trip fee on an emergency job. The page talks about a trip fee. It does not talk about travel, after-hours work, or emergency jobs enough to count as an answer.

Conflicts. If two pages that both cleared the floor disagree on a structured claims: key, the script files a conflict ticket and refuses to answer. It does not pick a winner.

Staleness. If the best page is otherwise a hit, but last_reviewed is older than 180 days, the script files a stale ticket and prints the page as a lead only. A stale lead is not current policy.

Anything that fails the score or coverage check becomes a missing ticket. In every case, wiki/ is left untouched.

Core of gap_queue.py

Core of gap_queue.py (hit, miss, stale, and conflict):

qn = max ( len ( list ( dict . fromkeys ( qtokens ) ) ) , 1 )
best_cov = ( ranked [ 0 ] [ 1 ] / qn ) if ranked else 0.0
if not ranked or ranked [ 0 ] [ 0 ] < min_score or best_cov < min_coverage :
  path = write_ticket ( root , "missing" , question , evidence , searched , today )
  return 2 # MISS
floor = max ( min_score * 0.6 , ranked [ 0 ] [ 0 ] * 0.45 )
candidates = [ ( s , p ) for s , _ , p in ranked if s >= floor ] [ : top_k ]
by_key = defaultdict ( list )
for _ , p in candidates :
  for k , v in p . claims . items ( ) :
    by_key [ k ] . append ( ( v , p ) )
conflicts = [ ( k , pairs ) for k , pairs in by_key . items ( ) if len ( { v for v , _ in pairs } ) > 1 ]
if conflicts :
  path = write_ticket ( root , "conflict" , question , evidence , searched , today )
  return 3 # CONFLICT
best_s , _ , best = ranked [ 0 ]
if best . is_stale ( today , stale_days ) :
  path = write_ticket ( root , "stale" , question , evidence , [ best . rel ] , today )
  return 4 # STALE
# otherwise HIT, print citations, write nothing
return 0

Running it on the sample fixture

Seven questions. Three of them the wiki can already answer. Four of them should become tickets. I ran this on 2026-11-24 against the Harborline fixture, with the default 180-day stale window.

$ python3 gap_queue.py fixture --today 2026-11-24 ask --question "What is the standard labor rate?"
Q: What is the standard labor rate?
RESULT: HIT
citations:
3.945 wiki/invoice-terms.md (Invoice terms) last_reviewed = 2026-10-20
2.414 wiki/customer-credits.md (Customer credits) last_reviewed = 2026-06-30
2.065 wiki/emergency-rates.md (Emergency rates) last_reviewed = 2024-03-12

Invoice terms wins, as it should: the standard labor rate is $145 per hour, reviewed October 20. The stale emergency-rates page is in the list, but it did not win, and a hit does not file a ticket about a runner-up.

The roster and warranty questions also hit: after-hours.md for escalation (score 6.847), warranty.md for the 90-day workmanship period (score 4.745).

Then the misses:

$ python3 gap_queue.py fixture --today 2026-11-24 ask --question "How do we bill travel time for after-hours emergency calls?"
Q: How do we bill travel time for after-hours emergency calls?
RESULT: MISS (filed as missing)
ticket: gaps/gap-0001.md
top scores (below threshold):
2.525 wiki/sla.md (Service level agreement)
1.987 wiki/index.md (Harborline wiki index)
1.679 wiki/after-hours.md (After hours roster)
1.662 wiki/emergency-rates.md (Emergency rates)
1.630 wiki/overtime.md (Overtime)
$ python3 gap_queue.py fixture --today 2026-11-24 ask --question "Do we bill a travel trip fee on after-hours emergency jobs?"
Q: Do we bill a travel trip fee on after-hours emergency jobs?
RESULT: MISS (filed as missing)
ticket: gaps/gap-0002.md
top scores (below threshold):
4.631 wiki/cancellation-policy.md (Cancellation policy)
1.865 wiki/index.md (Harborline wiki index)
1.595 wiki/dispatch-rules.md (Dispatch rules)
1.583 wiki/emergency-rates.md (Emergency rates)
1.488 wiki/travel-policy.md (Travel policy)

Two things I care about in those misses. The SLA is the closest page to the travel-time question, and it still fails the threshold. It is about response windows, not billing. A weaker check would have handed the agent a fluent "the SLA does not set commercial adjustments" and called the job done. The ticket keeps the question around until someone writes the commercial page.

The cancellation policy scores 4.631 on the trip-fee question - above the raw score cutoff - and still does not count as a hit. Coverage saves you here. That page's trip fee is for a cancelled or missed appointment. Treating it as a yes to "do we bill a travel trip fee on an emergency job" would be the classic near-miss, the one a helpful agent would quote.

The last two questions are not misses. They are worse.

$ python3 gap_queue.py fixture --today 2026-11-24 ask --question "What is the after-hours emergency labor multiplier?"
Q: What is the after-hours emergency labor multiplier?
RESULT: STALE (filed, page shown as a lead only)
ticket: gaps/gap-0003.md
lead: wiki/emergency-rates.md last_reviewed=2024-03-12 score=7.989
$ python3 gap_queue.py fixture --today 2026-11-24 ask --question "When does overtime start for a technician?"
Q: When does overtime start for a technician?
RESULT: CONFLICT (filed, no answer)
ticket: gaps/gap-0004.md
claim overtime_starts_after:
wiki/overtime.md -> 8 hours
wiki/union-addendum.md -> 10 hours

Emergency rates is the right page, and it is 622 days old. The script will show it as a lead. It will not let an agent quote 1.5× as current policy.

Overtime vs the union addendum is a structured disagreement on the same claim key, so there is no answer at all - only a ticket naming both pages. Guessing 8 or 10 would have been the worst kind of fluency.

Cluster the tickets, then draft a page

Filing is the working agent's job. Curating is not. Chase is direct about this: the agents doing the work are good at flagging what is wrong or missing, and bad at maintaining the store, because they are trying to finish their own task. A separate curator pass, with access to the flags and the sources, does the drafting. A human still merges.

cluster groups open tickets by lexical overlap on the question, not on the evidence boilerplate (that boilerplate is shared across stale tickets and would otherwise glue unrelated gaps together). propose writes a stub for one cluster.

$ python3 gap_queue.py fixture cluster
open tickets: 4
clusters: 3
C1 (2 tickets, kind=missing)
  gap-0001 [missing] How do we bill travel time for after-hours emergency calls?
  gap-0002 [missing] Do we bill a travel trip fee on after-hours emergency jobs?
C2 (1 ticket, kind=stale)
  gap-0003 [stale] What is the after-hours emergency labor multiplier?
C3 (1 ticket, kind=conflict)
  gap-0004 [conflict] When does overtime start for a technician?
$ python3 gap_queue.py fixture propose --cluster C1
PROPOSAL proposals/bill-travel-time-for-after-hours-emergency-calls.md
cluster: C1 tickets: gap-0001, gap-0002 kind:missing
wiki/ was not modified.
$ python3 gap_queue.py fixture status
wiki pages: 17 tickets: 4 clustered 2 proposed 2
by kind: missing 2 stale 1 conflict 1
proposals: 1 (unmerged) proposals/bill-travel-time-for-after-hours-emergency-calls.md

The proposal lists both questions, excerpts the near-miss pages, and ends with open questions for a human owner: what is the authoritative source, who owns the merged page, when should it be reviewed. It is not a rate card. I would not want a model to invent one overnight from a cancellation policy and an employee mileage page.

The two travel tickets clustered because they are about the same missing commercial rule. The stale multiplier and the overtime conflict stayed in their own clusters. That is what you want: one proposed page per hole, not one page that tries to settle payroll and trip fees at once.

Thirteen unit tests cover the four outcomes, the clustering, the proposal, and the guarantee that wiki/ is never modified. There is no model in the loop, which is the point: the queue has to be something you can run in CI.

Where this belongs

A gaps/ folder in a repo works for one developer. For a team, the tickets and the proposals should live in the same workspace as the pages they will eventually become, with an owner, a status, and a review date - the same metadata a team knowledge base already needs on every important article. A gap ticket is how you find the article that should have had those and does not.

If you expose ask and file as tools on an MCP server, each agent gets its own credential and can file a ticket without getting write access to the wiki itself. That is the factory's split, expressed as permissions: working agents may flag; they may not merge.

A weekend folder hook will not hold this for long. You need knowledge base software with spaces, permissions, and a review queue the tickets can land in. If agents can search only the spaces you allow, file a gap when they miss, and leave the merge to a human, you have AI knowledge base software rather than a chat log that forgets the miss. And if you can run the workspace yourself - the thing people usually want from an open source Notion alternative - the queue stays in your rooms, not in a vendor's memory store.

What it does badly (on purpose)

It will not decide the policy. A proposal is a prompt for a human, not a new rate card. If you auto-merge curator output, you have built a very confident way to write fiction into the wiki.

Coverage is lexical, not semantic. "Trip fee" and "dispatch fee" will not cluster until someone files them with closer wording, or until you add a synonym list. I would rather miss a cluster than silently merge payroll and billing.

Staleness is a date, not a fact check. March 12, 2024 tells you the page was not touched. It does not tell you the 1.5× is wrong. The ticket is a prompt to go look at the current rate card.

Claims have to be written down. The overtime conflict only fires because both pages declared overtime_starts_after in frontmatter. Two pages that disagree in prose, with no structured claim, look like two ordinary hits. Start with the facts you cannot afford to guess.

It does not scale to a messy export of everything. Seventeen pages is wiki scale. Past that, you still want this loop - flag, cluster, propose - but you may want a real index behind ask. The queue is the product, not the scorers.

Try it: point gap_queue.py at a Markdown export of your own wiki, ask it the questions your agents already get wrong, and read the tickets before you let anyone merge a proposal. In the Harborline fixture, the four tickets were more useful than t

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.