<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AFFiNE</title>
    <description>The latest articles on DEV Community by AFFiNE (affineofficial).</description>
    <link>https://dev.to/affineofficial</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F9729%2F2e4faafc-05a5-45ed-8e62-007bc353f0f2.jpg</url>
      <title>DEV Community: AFFiNE</title>
      <link>https://dev.to/affineofficial</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/affineofficial"/>
    <language>en</language>
    <item>
      <title>Your LLM Wiki Still Cites the Old Rate Card. I Wrote a Freshness Check for That.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Fri, 27 Nov 2026 06:32:05 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-still-cites-the-old-rate-card-i-wrote-a-freshness-check-for-that-4148</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-still-cites-the-old-rate-card-i-wrote-a-freshness-check-for-that-4148</guid>
      <description>&lt;p&gt;This week's feed treated Karpathy's LLM wiki like a solved ingest problem. A "reader" takes every link, PDF, and transcript you drop in. Claude Code runs the pattern from one folder. Stop re-explaining yourself every chat.&lt;/p&gt;

&lt;p&gt;That is the compile step, and it is useful. The quieter failure showed up in the posts that treated compounding knowledge as the actual product: when the source materials change, the compiled pages have to change too. Otherwise the agent is not "remembering." It is citing last month's rate card with this month's confidence.&lt;/p&gt;

&lt;p&gt;So this post is a ~670-line, stdlib-only Python script called &lt;code&gt;source_fresh.py&lt;/code&gt;. You point it at a Markdown wiki whose compiled pages declare the source files they were built from. It records a SHA-256 for each source, and later it tells you which pages are stale, which citations never made it into frontmatter, and which files in &lt;code&gt;sources/&lt;/code&gt; no page claims. It never rewrites a wiki page. It never "fixes" a source. Eighteen tests pin that down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe10zux661jupxq4ybpsl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe10zux661jupxq4ybpsl.jpg" alt="A compiled wiki page stays marked fresh until a cited source file changes, then it joins a rebuild queue" width="799" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A check is not a rebuild
&lt;/h2&gt;

&lt;p&gt;The failure mode I keep seeing is "drop a new PDF in the inbox and assume the wiki moved with it." The compiled tuition page still says the late fee is $25 after the 10th. The source now says $40 after the 5th. An agent that packs or retrieves the compiled page will quote the old number, and it will do so with a citation.&lt;/p&gt;

&lt;p&gt;A freshness check is narrower than a compiler.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pages opt in with a &lt;code&gt;sources:&lt;/code&gt; list in frontmatter. A brand-voice note with no sources is not a finding.&lt;/li&gt;
&lt;li&gt;The record is a &lt;code&gt;.freshness.json&lt;/code&gt; manifest next to the wiki, not a new wiki page. Hashes live there, not in the prose.&lt;/li&gt;
&lt;li&gt;A source that two pages cite will stale both pages when it moves, and leave a third page alone if that page only cited a different file.&lt;/li&gt;
&lt;li&gt;Body links into &lt;code&gt;sources/&lt;/code&gt; that are missing from frontmatter are undeclared citations. They are blocking by default, because the checker cannot watch a source it was not told about.&lt;/li&gt;
&lt;li&gt;Files that sit in &lt;code&gt;sources/&lt;/code&gt; with no page declaring them are orphans. They are warnings unless you pass &lt;code&gt;--fail-orphans&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;check&lt;/code&gt; exits 1 when anything blocking is open, so you can hang it on CI. &lt;code&gt;queue&lt;/code&gt; writes the rebuild list. &lt;code&gt;record --page&lt;/code&gt; is what you run after a human actually rewrites the page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;
  Core of source_fresh.py (hash compare, shared sources, undeclared citations)
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;inspect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fail_undeclared&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fail_orphans&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;pages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_pages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# skips anything under sources/&lt;/span&gt;
    &lt;span class="n"&gt;hashes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;hash_sources&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;collect_source_paths&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;manifest&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_manifest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# wiki/.freshness.json&lt;/span&gt;
    &lt;span class="n"&gt;findings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

    &lt;span class="n"&gt;declared_anywhere&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;declared_anywhere&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;declared&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cited&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;declared&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;findings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Finding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="s2"&gt;"undeclared"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s2"&gt;"cited in the body but missing from frontmatter sources:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="n"&gt;blocking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;fail_undeclared&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;declared&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;recorded&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;recorded_hashes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;manifest&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;recorded&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;findings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Finding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="s2"&gt;"never_recorded"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"has sources: but no recorded hashes in .freshness.json"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;declared&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;missing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;findings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Finding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="s2"&gt;"missing_source"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s2"&gt;"declared source file does not exist"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;recorded&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;hashes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;findings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Finding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                    &lt;span class="s2"&gt;"stale"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                    &lt;span class="s2"&gt;"hash changed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;rel&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;hashes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rel&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;declared_anywhere&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;findings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Finding&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="s2"&gt;"orphan_source"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"file in sources/ is not declared by any wiki page"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;blocking&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;fail_orphans&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;findings&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The comparison is deliberately boring. SHA-256 does not know that a late fee changed. It knows that the bytes of &lt;code&gt;sources/tuition-schedule-2026.md&lt;/code&gt; are not the bytes you recorded when the compiled page was last reviewed. That is the whole signal.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sample vault
&lt;/h2&gt;

&lt;p&gt;The fixture in this post is made up: a fictional community music school I called Larkspur Conservatory, in a made-up town named Ashmere. These pages are not a real tuition schedule or a real recital date.&lt;/p&gt;

&lt;p&gt;The clean version has ten Markdown pages under &lt;code&gt;wiki/&lt;/code&gt;, plus nine source files under &lt;code&gt;wiki/sources/&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;tuition-and-fees.md&lt;/code&gt; — term tuition is $1,280, the late fee is $25 after the 10th, rentals are billed separately. It declares both &lt;code&gt;sources/tuition-schedule-2026.md&lt;/code&gt; and &lt;code&gt;sources/instrument-rental-rates.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;front-desk-script.md&lt;/code&gt; — the desk script for the same late fee, and only the tuition schedule as a source. This is the important one. One source file, two compiled pages.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;room-booking.md&lt;/code&gt;, &lt;code&gt;recital-week.md&lt;/code&gt;, &lt;code&gt;scholarship-policy.md&lt;/code&gt;, &lt;code&gt;accompanying.md&lt;/code&gt; — ordinary compiled pages, each pointing at their own sources.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;draft-fee-waiver.md&lt;/code&gt; — a draft that also cites the scholarship terms. Drafts are still checked. They are just labeled.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;brand-voice.md&lt;/code&gt; and &lt;code&gt;cancelled-lesson-policy.md&lt;/code&gt; — standing notes with no &lt;code&gt;sources:&lt;/code&gt; list. The checker leaves them alone.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;practice-room-etiquette.md&lt;/code&gt; — also has no &lt;code&gt;sources:&lt;/code&gt; list, on purpose, until the messy run.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After &lt;code&gt;record&lt;/code&gt;, a clean check is quiet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 source_fresh.py check fixture/wiki
# Source freshness

- generated: 2026-11-27T06:20:39Z
- wiki: fixture/wiki
- pages: 10 wiki, 7 with sources, 7 fresh, 0 need rebuild
- sources: 9 on disk, 0 missing
- findings: 0 (0 blocking)

All recorded pages still match their sources.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Exit code 0. Seven of the ten pages opted into a source list; all seven still match.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it after the rate card moves
&lt;/h2&gt;

&lt;p&gt;Then I did what actually happens in a vault. I replaced the tuition schedule with a "revised 1 November 2026" copy. The $1,280 term fee is unchanged. The late fee is now &lt;strong&gt;$40 after the 5th&lt;/strong&gt;, and instrument insurance is required at &lt;strong&gt;$15 per term&lt;/strong&gt;. I also dropped an unlinked board-minutes file into &lt;code&gt;sources/&lt;/code&gt;, added a body link from the etiquette page to &lt;code&gt;sources/studio-hours.md&lt;/code&gt; without putting it in frontmatter, and pointed the cancelled-lesson policy at a memo that is no longer on disk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 source_fresh.py status fixture/wiki
# Source freshness

- generated: 2026-11-27T06:20:52Z
- wiki: fixture/wiki
- pages: 10 wiki, 8 with sources, 5 fresh, 3 need rebuild
- sources: 10 on disk, 1 missing
- findings: 6 (5 blocking)

## Pages that need a rebuild

- cancelled-lesson-policy.md — Cancelled lesson policy
  has sources: but no recorded hashes in .freshness.json
  sources/old-cancellation-memo.md: declared source file does not exist
- front-desk-script.md — Front desk payment script
  sources/tuition-schedule-2026.md: hash changed (b52b9217… → 0ab251dd…)
- tuition-and-fees.md — Tuition and fees
  sources/tuition-schedule-2026.md: hash changed (b52b9217… → 0ab251dd…)

## Undeclared citations

- practice-room-etiquette.md cites sources/studio-hours.md

## Orphan sources

- sources/board-minutes-2026-10.md (warning)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fheu5b7knc9yepql49ce5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fheu5b7knc9yepql49ce5.jpg" alt="The freshness report flags two pages that share a changed tuition schedule, a missing memo, an undeclared citation, and an orphan source file" width="800" height="520"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three things I care about in that report.&lt;/p&gt;

&lt;p&gt;The hash is the same change, named twice. &lt;code&gt;tuition-and-fees.md&lt;/code&gt; and &lt;code&gt;front-desk-script.md&lt;/code&gt; both went stale because they both declared &lt;code&gt;sources/tuition-schedule-2026.md&lt;/code&gt;. The rental-rate file did not move, so it is not listed under tuition-and-fees, even though that page also cites it. Recital week, room booking, scholarships, and accompanying stayed fresh. A naive "the vault changed, rebuild everything" pass would have queued those too.&lt;/p&gt;

&lt;p&gt;The cancelled-lesson page is a different kind of broken. It now declares a memo that is not on disk, and it has never been recorded. The tool will not let you &lt;code&gt;record&lt;/code&gt; that page until the file exists or you take it off the list. That is the point. A missing source is not "probably fine."&lt;/p&gt;

&lt;p&gt;And the two findings that are easy to shrug at are the ones that silently rot a vault. The etiquette page now links to studio hours in the body but does not declare the file, so a later hours change would never stale it. The October board minutes are sitting in &lt;code&gt;sources/&lt;/code&gt; with no compiled page at all — ingest without a home. The orphan is a warning. The undeclared citation is blocking, because it is a source the checker was not allowed to watch.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;check&lt;/code&gt; exits 1 on this vault. That is the CI hook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rebuild the page, then record it
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;queue&lt;/code&gt; turns the same report into a short work list. Here is the tuition entry:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## Tuition and fees

- page: tuition-and-fees.md
- why:
  - sources/tuition-schedule-2026.md — hash changed (b52b9217… → 0ab251dd…)
- sources to re-read:
  - sources/tuition-schedule-2026.md (present)
  - sources/instrument-rental-rates.md (present)

Rebuild the page from the sources, then run:

    python3 source_fresh.py record &amp;lt;wiki&amp;gt; --page tuition-and-fees.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script does not draft the new page for you. I want a person — or a carefully gated agent — to re-read the source and edit the prose. After I updated the front-desk script to say $40 after the 5th and recorded that page alone, the next status report was smaller: six fresh, two still needing a rebuild. Tuition-and-fees was still stale. The cancelled memo was still missing. The front-desk script was off the list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo52ziow4wrc7focum300.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo52ziow4wrc7focum300.jpg" alt="After recording a rebuilt front-desk script, the tuition page and the missing memo remain on the rebuild queue" width="799" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is the loop I want in an &lt;code&gt;AGENTS.md&lt;/code&gt; or a CI job: fail the build when sources have moved, hand a human the queue, and only then record the pages that were actually rewritten.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the check in CI, not in the model's memory
&lt;/h2&gt;

&lt;p&gt;A freshness file in the repo is only useful if something runs it. I would rather hang &lt;code&gt;check&lt;/code&gt; on the same hook that already lints or tests the vault than ask the model to "remember to look at &lt;code&gt;.freshness.json&lt;/code&gt;."&lt;/p&gt;

&lt;p&gt;&lt;code&gt;source_fresh.py check wiki/&lt;/code&gt; exits 1 when a recorded page is stale, a declared source is missing, a page was never recorded, or a body citation never made it into frontmatter. That is enough for a pre-commit hook or a CI job. &lt;code&gt;queue --out rebuild-queue.md&lt;/code&gt; can be an artifact on the failing build, so the review is a list of pages and sources rather than a wall of diffs.&lt;/p&gt;

&lt;p&gt;For an agent session, a short &lt;code&gt;AGENTS.md&lt;/code&gt; paragraph is a pointer, not the check itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Wiki source freshness

Before you quote a compiled wiki page as current policy, run:

    python3 source_fresh.py check wiki/

If the check fails, read the rebuild queue and do not treat stale pages as fact.
Rebuild a page only from the sources it declares, then record that page:

    python3 source_fresh.py record wiki/ --page &amp;lt;page.md&amp;gt;

Do not run record on a page you have not rewritten. Do not invent a
missing source file to clear the check.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model can still ignore that. The hook cannot. If the rate card moved and nobody rebuilt the desk script, the build should go red before the session starts citing $25 after the 10th.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this belongs
&lt;/h2&gt;

&lt;p&gt;A Markdown folder and a manifest are enough for one person's wiki, and they are close to how careful &lt;a href="https://affine.pro/blog/internal-documentation" rel="noopener noreferrer"&gt;internal documentation&lt;/a&gt; already works: every important answer should name its source and have a reason to be reviewed when that source changes. The checker is the missing step between "I compiled a page from a rate card" and "I will notice when the rate card moves."&lt;/p&gt;

&lt;p&gt;On a team, "the wiki still matches the sources" should be a property of the workspace, not a convention in a script the intern forgot to run. You want &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; that can keep compiled operational pages tied to the files they came from, and surface a rebuild when those files change, without anyone grepping hashes by hand. The same need shows up when people try to &lt;a href="https://affine.pro/blog/ai-knowledge-base" rel="noopener noreferrer"&gt;build an AI knowledge base&lt;/a&gt; on top of those pages: retrieval is only as trustworthy as the document it retrieved, and a beautifully formatted but outdated policy is still a bad source.&lt;/p&gt;

&lt;p&gt;If you can run that workspace yourself — including the &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI&lt;/a&gt; pattern of keeping the knowledge layer where your documents already live — the freshness rules stay yours. That is the difference between a chat that was handed a zip of Markdown and &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt; that treats "which compiled pages are still true" as part of the knowledge base. It is also why I still care about an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion&lt;/a&gt; you can inspect: the rate card, the compiled page, and the record of their relationship should be files you can take with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A hash does not explain the edit.&lt;/strong&gt; The report will tell you that &lt;code&gt;tuition-schedule-2026.md&lt;/code&gt; changed from &lt;code&gt;b52b9217&lt;/code&gt; to &lt;code&gt;0ab251dd&lt;/code&gt;. It will not tell you that the late fee moved and the insurance became required. Open the file. That is the review.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It will not rewrite the compiled page.&lt;/strong&gt; &lt;code&gt;queue&lt;/code&gt; is a list. &lt;code&gt;record&lt;/code&gt; is an acknowledgment. If you run &lt;code&gt;record --page&lt;/code&gt; without editing the prose, you have only blessed the stale sentences. The tool cannot see that.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Undeclared citations have to be spelled in a way it can parse.&lt;/strong&gt; Frontmatter &lt;code&gt;sources:&lt;/code&gt;, Markdown links, &lt;code&gt;[[wiki-links]]&lt;/code&gt;, and a bare &lt;code&gt;sources/...&lt;/code&gt; path are recognized. A sentence that says "see the studio hours file" with no path is invisible. If a citation matters, put it in frontmatter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Orphans are easy to ignore.&lt;/strong&gt; A drop-folder that accumulates PDFs will always have files no page has claimed yet. That is why they are warnings by default. If your ingest pipeline is supposed to be empty after compile, turn on &lt;code&gt;--fail-orphans&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It will not notice a source the page never cited.&lt;/strong&gt; If the new insurance rule also belongs on a financial-aid page that never declared the tuition schedule, that page stays "fresh." Freshness is about the sources you claimed, not about every page that ought to have claimed them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It will not scale by becoming a knowledge graph.&lt;/strong&gt; Ten pages and nine sources is vault scale. Past a few thousand files the same manifest still works — it is just JSON and SHA-256 — but you will want the record/check loop inside the workspace that already holds the documents, not as a one-off script people run when they remember.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; point &lt;code&gt;source_fresh.py&lt;/code&gt; at a Markdown export of your own wiki, add a &lt;code&gt;sources:&lt;/code&gt; list to one compiled page, run &lt;code&gt;record&lt;/code&gt;, then change the source the way a real rate card changes. In the Larkspur fixture, the useful part was not that the tuition page went stale. It was that the front-desk script, which cited the same file, went stale with it — and recital week did not.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Every New Agent Session Starts Empty. I Wrote a Wiki Packer for That.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Thu, 26 Nov 2026 06:32:32 +0000</pubDate>
      <link>https://dev.to/affineofficial/every-new-agent-session-starts-empty-i-wrote-a-wiki-packer-for-that-4li4</link>
      <guid>https://dev.to/affineofficial/every-new-agent-session-starts-empty-i-wrote-a-wiki-packer-for-that-4li4</guid>
      <description>&lt;p&gt;This week's feed treated Karpathy's LLM wiki gist like a finished product. Drop-in repos. "Paste this markdown file into Claude Code." A circulating count of more than a thousand GitHub repositories that name the idea, with dozens added this month alone.&lt;/p&gt;

&lt;p&gt;One of the more useful posts, after actually running a popular Claude Code memory vault, said the quiet part: each new session starts without your notes unless you hand them over.&lt;/p&gt;

&lt;p&gt;That is the whole problem. A gist, an &lt;code&gt;AGENTS.md&lt;/code&gt; pointer, a "second brain" repo you clone in a minute — those are instructions. They are not memory. The model does not arrive with your weather-hold policy, or yesterday's decision, or the page you told it not to touch. The window is empty. If you do not pack the wiki into the session, the session will improvise.&lt;/p&gt;

&lt;p&gt;So this post is a ~570-line, stdlib-only Python script called &lt;code&gt;session_pack.py&lt;/code&gt;. You give it a Markdown wiki and a task. It scores pages with lexical overlap, a phrase bonus, and a light boost along &lt;code&gt;[[wiki-links]]&lt;/code&gt;. It down-weights words that appear on almost every page, so a query about a "hold" does not drag in the galley menu. It respects a character budget. It refuses to pack pages marked restricted, draft, stale, or &lt;code&gt;pack: false&lt;/code&gt;. It never modifies the wiki. Seventeen tests pin that down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6xhalkd4xbtrlo7jz8mr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6xhalkd4xbtrlo7jz8mr.jpg" alt="A session starts empty; the packer selects wiki pages for the task and leaves restricted pages out of SESSION.md" width="799" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A pack is not a dump
&lt;/h2&gt;

&lt;p&gt;The failure mode I keep seeing is "stuff the vault in the prompt." That works until the vault has a draft incident report and a passenger manifest in it, or until the context window is already doing real work.&lt;/p&gt;

&lt;p&gt;A session pack is smaller and stricter.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It is built for one query, not for the whole wiki.&lt;/li&gt;
&lt;li&gt;The character budget applies to the page excerpts the model will read. The audit list at the bottom is for you.&lt;/li&gt;
&lt;li&gt;Pages below a minimum score stay out. The default floor is 2.0.&lt;/li&gt;
&lt;li&gt;Restricted, draft, stale, and &lt;code&gt;pack: false&lt;/code&gt; pages can still &lt;em&gt;match&lt;/em&gt; the query. They are listed under "Excluded (not packed)" and their body never appears in the pack.&lt;/li&gt;
&lt;li&gt;The packer will not write &lt;code&gt;SESSION.md&lt;/code&gt; inside the wiki directory. The brief is an input to the session, not a new wiki page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;/p&gt;
  Core of session_pack.py (scoring, exclusions, and the budget)
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;RESTRICTED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;frozenset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"restricted"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"confidential"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"secret"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"private"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;DRAFT_STATUS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;frozenset&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"draft"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"wip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"unpublished"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"review"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;exclusion_reasons&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;reasons&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pack"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pack"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;FALSEY&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"pack: false"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;sensitivity&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;RESTRICTED&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"sensitivity: {self.sensitivity}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;DRAFT_STATUS&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"status: {self.status}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stale"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;reasons&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stale: true"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;reasons&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;term_weights&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;weights&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;term&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;term&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="c1"&gt;# Common vault words such as "hold" keep a little weight;&lt;/span&gt;
        &lt;span class="c1"&gt;# rare terms such as "southerly" keep most of theirs.&lt;/span&gt;
        &lt;span class="n"&gt;weights&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;term&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.25&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.75&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;weights&lt;/span&gt;

&lt;span class="c1"&gt;# Page score = weighted overlap in title, headings, tags, and body,&lt;/span&gt;
&lt;span class="c1"&gt;# plus a bonus when a query bigram appears, plus 0.35 * source score&lt;/span&gt;
&lt;span class="c1"&gt;# for each [[wiki-link]] from a page that already scored.&lt;/span&gt;
&lt;span class="c1"&gt;# build_pack then takes pages at or above min_score, formats an excerpt&lt;/span&gt;
&lt;span class="c1"&gt;# from the best-matching paragraphs, and fills the character budget&lt;/span&gt;
&lt;span class="c1"&gt;# in score order. Leftovers are listed as "Dropped for budget."&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The scoring is deliberately boring. It is the same idea as ranking a small wiki by links and words rather than standing up a vector database: enough to pick the right handful of pages, cheap enough to run in a hook when a session starts.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sample vault
&lt;/h2&gt;

&lt;p&gt;The fixture in this post is made up: a fictional passenger ferry operator I called Sable Ferry, running Gray's Point to Loon Island. These pages are not a real timetable or a real safety file.&lt;/p&gt;

&lt;p&gt;The clean version has twelve Markdown pages under &lt;code&gt;wiki/&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;weather-hold-policy.md&lt;/code&gt; — when a sailing is held, who decides, and what 35-knot southerly gusts on the 19:10 actually mean&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;crew-rest-rules.md&lt;/code&gt; — a late hold can force you to cancel the last return&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ticketing-refunds.md&lt;/code&gt; — refund or rebook once the hold is posted; no invented goodwill&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;radio-channel-plan.md&lt;/code&gt; and &lt;code&gt;after-hours-on-call.md&lt;/code&gt; — how the hold is announced, and who to call after 18:00&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;tidal-windows.md&lt;/code&gt; — a low tide at Gray's Point can stack with the weather&lt;/li&gt;
&lt;li&gt;four low-signal pages: brand voice, the fall galley menu, docking lines, and a December refit of the &lt;em&gt;Coriander&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;two pages that must never enter a session: &lt;code&gt;passenger-manifest-handling.md&lt;/code&gt; (&lt;code&gt;pack: false&lt;/code&gt;, &lt;code&gt;sensitivity: restricted&lt;/code&gt;) and &lt;code&gt;unpublished-incident-2026-10.md&lt;/code&gt; (&lt;code&gt;status: draft&lt;/code&gt;, restricted). The draft is awkward on purpose. It is about a 19:10 sailing in 35-knot southerly gusts, so a naive search would put it at the top of the pack.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Running it on the evening-sailing question
&lt;/h2&gt;

&lt;p&gt;The question I asked was the one a duty officer would actually type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 session_pack.py pack fixture/wiki \
    --query "Should we hold the 19:10 sailing if southerly gusts are 35 knots?" \
    --out SESSION.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The header and the first excerpt came back like this. The rest of the pack is the same shape.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Session pack

- generated: 2026-11-26T06:21:37Z
- query: Should we hold the 19:10 sailing if southerly gusts are 35 knots?
- wiki: fixture/wiki
- budget: 3560 / 8000 chars
- pages: 6 included, 1 excluded, 0 dropped (budget)

## Weather hold policy

- path: weather-hold-policy.md
- score: 16.3
- tags: operations, safety, weather

- sustained wind 30 knots or more, or gusts 40 knots or more, on the exposed
  southerly fetch
- significant wave height at the mid-channel buoy at or above 1.5 m
- visibility under half a mile in rain or spray

Southerly gusts in the mid-30s on the evening sailing sit in a narrower band:
the Loon Island approach is beam-on in a southerly, and the 19:10 departure
often meets a falling tide. Treat 35-knot southerly gusts as a captain's call
that should be made no later than 40 minutes before departure, and record the
decision on the ops channel.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fobt2nqb4ps0cxett1deb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fobt2nqb4ps0cxett1deb.jpg" alt="The packer fills 3,560 of 8,000 characters with six pages and lists the matching draft incident as excluded" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three things I care about in that report.&lt;/p&gt;

&lt;p&gt;The excerpt does not start at the top of the policy. It starts at the band that matches the query: mid-30s southerlies, the 19:10, a captain's call no later than 40 minutes before departure. The hard 30 / 40 knot rule is still in the pack, immediately above it. That is the page the model should read first.&lt;/p&gt;

&lt;p&gt;The other five included pages are consequences and caveats, not a second copy of the policy. Crew rest says you may also have to cancel the last return. Ticketing says what happens to the passengers. After-hours and the radio plan say who to tell, because 19:10 is after 18:00. Tidal windows, at a much lower score of 2.5, still clears the floor: a falling tide at Gray's Point can stack with the wind. The galley menu, the brand-voice note, and the &lt;em&gt;Coriander&lt;/em&gt; refit all scored under 1.0 and stayed out.&lt;/p&gt;

&lt;p&gt;And the page that would have been second — the unpublished October near-miss, which scores 14.1 against this exact query — is not in the pack. It is listed at the bottom:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## Excluded (not packed)

- unpublished-incident-2026-10.md  (sensitivity: restricted, status: draft)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The body of that draft never appears. A session that "just greps the vault" would have handed the model an unreviewed near-miss and invited it to treat the draft as policy. The packer tells you the page exists and that it was held back. A human can open it. The agent, unless you explicitly say so, should not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The budget is a knife, not a suggestion
&lt;/h2&gt;

&lt;p&gt;Eight thousand characters was enough for all six relevant pages. Tightening it is how you see the dropped list.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 session_pack.py pack fixture/wiki \
    --query "Should we hold the 19:10 sailing if southerly gusts are 35 knots?" \
    --budget 1800 --out SESSION-tight.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- budget: 1725 / 1800 chars
- pages: 3 included, 1 excluded, 3 dropped (budget)

## Dropped for budget

- after-hours-on-call.md  (score 5.2; would need 427 more chars)
- radio-channel-plan.md  (score 5.2; would need 441 more chars)
- tidal-windows.md  (score 2.5; would need 493 more chars)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The policy, the refunds, and the rest rules still fit. The on-call roster, the radio plan, and the tidal caveat do not. That is the right failure: the pack stays inside the budget, and it tells you what it did not have room for. If the session needs the tide table, you widen the budget or pack a second time with a narrower query. You do not silently truncate the one page that would have changed the decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  Restricted means not in the prompt
&lt;/h2&gt;

&lt;p&gt;The draft incident is the dramatic case because it matches the weather query so well. The quieter case is a page whose job &lt;em&gt;is&lt;/em&gt; the query, and which still must not be packed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 session_pack.py pack fixture/wiki \
    --query "export the passenger manifest after a weather hold"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- pages: 8 included, 2 excluded, 0 dropped (budget)

## Excluded (not packed)

- passenger-manifest-handling.md  (pack: false, sensitivity: restricted)
- unpublished-incident-2026-10.md  (sensitivity: restricted, status: draft)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frurzqkvnpm3xexi3azj1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frurzqkvnpm3xexi3azj1.jpg" alt="A query about exporting the passenger manifest still leaves the manifest page and the draft incident out of the pack" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;passenger-manifest-handling.md&lt;/code&gt; is the page that explains how to export a manifest. It is also marked &lt;code&gt;pack: false&lt;/code&gt; and restricted, because it describes where the CSV lives and says not to paste passenger names into chat or an agent session. A retrieval system that only optimizes for relevance would have put it first. The packer lists it as excluded and fills the brief with the hold policy and the refund rules instead — the part of the question an agent is allowed to help with.&lt;/p&gt;

&lt;p&gt;That is the difference between "the model can find it" and "the model should see it in this session."&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the pack in AGENTS.md, not in the harness's memory
&lt;/h2&gt;

&lt;p&gt;A reply I liked in this week's thread said to add an LLM wiki to &lt;code&gt;AGENTS.md&lt;/code&gt;, because current models follow that file better than they follow harness memory. I agree, as far as it goes. The file is a pointer. It is not the pack.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;session_pack.py agents-snippet&lt;/code&gt; prints a paragraph you can paste:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Wiki session pack

At the start of every session, read `SESSION.md` if it exists in the
working tree. Treat packed pages as the first source of answers and cite
them by path. If `SESSION.md` is missing, stale, or does not cover the
task, run:

    python3 session_pack.py pack wiki/ --query "&amp;lt;the user task&amp;gt;" --out SESSION.md

Do not invent policy from memory. Do not read pages listed under
"Excluded (not packed)" unless a human explicitly asks you to. If the pack
omitted a page for budget, ask before widening the budget.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hook the packer itself in whatever starts the session: a shell alias, a git hook, a small wrapper around your coding agent. &lt;code&gt;status&lt;/code&gt; will tell you what an existing &lt;code&gt;SESSION.md&lt;/code&gt; was built for, so you can notice when you are about to answer a new question with last hour's brief.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this belongs
&lt;/h2&gt;

&lt;p&gt;A Markdown folder and a script are enough for one person's wiki. That is how most of the drop-in repos are shaped, and it is close to how people already do &lt;a href="https://affine.pro/blog/personal-knowledge-management" rel="noopener noreferrer"&gt;personal knowledge management&lt;/a&gt;: a vault of pages, a query, a handful of notes worth loading before you think. The packer is the missing step between "I have a vault" and "this session can see it."&lt;/p&gt;

&lt;p&gt;On a team, "do not pack the manifest" should be a property of the page, not a convention in a script the intern forgot to run. You want &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; that can keep operational pages searchable and keep restricted pages out of an agent context without anyone rewriting a frontmatter convention. The same need shows up when people compare an &lt;a href="https://affine.pro/blog/obsidian-alternative" rel="noopener noreferrer"&gt;Obsidian alternative&lt;/a&gt; or a &lt;a href="https://affine.pro/blog/notion-ai-alternative" rel="noopener noreferrer"&gt;Notion AI alternative&lt;/a&gt;: the product is not the memory. The session is still empty until something selects, budgets, and withholds.&lt;/p&gt;

&lt;p&gt;If you can run that workspace yourself — the thing people usually mean when they look for an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion&lt;/a&gt; — the exclusion rules stay yours. That is the difference between a chat that was handed a zip of Markdown and &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt; that treats "what may enter the prompt" as part of the knowledge base.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Lexical scoring is not understanding.&lt;/strong&gt; A page that talks about "cancelling the last boat" without saying "hold" or "19:10" will underscore. A page that repeats "weather hold" in a disclaimer can still sneak over a low floor. The IDF weighting is there to blunt the second case, not to eliminate it. If a miss matters, tighten the query or raise &lt;code&gt;--min-score&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Excerpts can start mid-page.&lt;/strong&gt; The packer prefers the paragraphs that match the query. That is why the weather policy opens on the knot thresholds and the 35-knot band, not on "the duty captain decides." Usually that is what you want. Sometimes the skipped preamble had a scope limit you needed. If you see that happen, raise &lt;code&gt;--excerpt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The audit list names excluded paths.&lt;/strong&gt; I want a human to know that a matching draft was held back. On a vault where the path itself is sensitive, that list is already a leak. Do not run this in a log that leaves your machine if the filenames are the secret.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It will not refresh a stale pack for you.&lt;/strong&gt; &lt;code&gt;status&lt;/code&gt; reports what was generated. It does not watch the wiki or the clock. A session that keeps last night's &lt;code&gt;SESSION.md&lt;/code&gt; will answer tonight's question with last night's pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It will not scale to a dump of everything you have ever written.&lt;/strong&gt; Twelve pages is vault scale. Past a few thousand you still want a budget, a score floor, and an exclusion list — especially the exclusion list — but you may want a real index behind the scorer. The product is the brief, not the walker.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; point &lt;code&gt;session_pack.py&lt;/code&gt; at a Markdown export of your own wiki, ask it the question you were about to paste into an empty agent session, and read the excluded list before you hand the pack over. In the Sable Ferry fixture, the useful part was not that it found the weather policy. It was that the draft with the same numbers stayed out.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>python</category>
    </item>
    <item>
      <title>Your LLM Wiki Will Eat Your Zettelkasten. I Wrote a Layer Guard for That.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Wed, 25 Nov 2026 06:27:14 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-will-eat-your-zettelkasten-i-wrote-a-layer-guard-for-that-464n</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-will-eat-your-zettelkasten-i-wrote-a-layer-guard-for-that-464n</guid>
      <description>&lt;p&gt;On November 22, &lt;a href="https://x.com/mariush_ca/status/2124477178096103530" rel="noopener noreferrer"&gt;someone on X put the problem more cleanly than I have&lt;/a&gt;: they were struggling to integrate an LLM wiki with a Zettelkasten. The wiki, they said, is for agents. The Zettelkasten is for them — a repository of processed, learned knowledge. This morning a reply to a HackerNoon thread called the move from Zettelkasten to LLM wiki "a big shift."&lt;/p&gt;

&lt;p&gt;It is a shift. It is also a collision if you treat it as a rename.&lt;/p&gt;

&lt;p&gt;Karpathy's LLM Wiki pattern has two layers: raw sources the model must not edit, and compiled Markdown pages the model owns. That split is right for a corpus of papers and transcripts. It is the wrong split for a vault that already has a &lt;a href="https://affine.pro/blog/zettelkasten-method" rel="noopener noreferrer"&gt;Zettelkasten&lt;/a&gt; in it. Those atomic notes are not raw sources. You already rewrote them in your own words, gave them stable ids, and linked them because &lt;em&gt;you&lt;/em&gt; wanted to think with them later. They are also not wiki pages. The moment an ingest agent is told to "update related pages," it will merge two notes, flatten a hedge, and leave you with a compiled overview where an observation used to be.&lt;/p&gt;

&lt;p&gt;This week's feed is full of drop-in "second brain" repos built on that gist. Most of them share a vault with whatever Markdown you already have. I wanted a check I could run before the agent writes, and again in CI after it does.&lt;/p&gt;

&lt;p&gt;So this post is a ~490-line, stdlib-only Python script called &lt;code&gt;layer_guard.py&lt;/code&gt;. It enforces a three-layer vault: &lt;code&gt;sources/&lt;/code&gt; for raw material, &lt;code&gt;notes/&lt;/code&gt; for human atomic notes, and &lt;code&gt;wiki/&lt;/code&gt; for compiled pages. Agents may read the first two and write only to the third. It never modifies a file. Sixteen tests pin that down.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzbmk121kegop6jlz2xgp.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzbmk121kegop6jlz2xgp.jpg" alt="Three vault layers: sources and human notes are read-only to agents; only wiki pages are writable, and they must cite notes instead of replacing them" width="799" height="453"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A Zettelkasten is a third layer
&lt;/h2&gt;

&lt;p&gt;The two-layer picture is seductive because it is simple. Everything that is not the wiki is a source, and sources are sacred. That works until your "source" is a 180-word note titled &lt;em&gt;Why we rejected MQTT Sparkplug for the buoy fleet&lt;/em&gt;, written after a real argument, with a "reopen this if…" at the bottom. That note is finished human work. Compiling it into a radio-stack page is useful. Replacing it with the radio-stack page is how you lose the argument.&lt;/p&gt;

&lt;p&gt;So the guard assumes three layers, not two.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sources/&lt;/code&gt; — raw logs, papers, exports. Agents may read. They may not write.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;notes/&lt;/code&gt; — human atomic notes, one idea each, stable ids. Agents may read and cite. They may not write.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;wiki/&lt;/code&gt; — compiled pages. This is the only layer an agent may create or update.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A wiki page is allowed to summarize several notes. It is not allowed to share an id or a filename stem with one, and it is not allowed to be a near-copy of one. If the model needs a page about duty cycle, it should cite &lt;code&gt;20260522-lora-duty-cycle&lt;/code&gt; and say something the note does not, or it should not write the page at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sample vault
&lt;/h2&gt;

&lt;p&gt;The fixture in this post is made up: a fictional coastal-sensing startup I called Tidemark. These notes are not a real field log.&lt;/p&gt;

&lt;p&gt;The clean version has ten Markdown files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Six human notes under &lt;code&gt;notes/&lt;/code&gt;, with date-prefixed ids in the usual Zettelkasten style. Salt fog drifting a humidity sensor. LoRa's duty-cycle cap, not its range, as the real constraint. Calibration as a weather window rather than a 30-day ticket. Why Sparkplug was rejected for the drifting fleet. Harbor permits taking six weeks, not two. Mooring lessons from a November blow.&lt;/li&gt;
&lt;li&gt;Three compiled wiki pages that cite those notes and add the operational shape: &lt;code&gt;sensor-calibration.md&lt;/code&gt;, &lt;code&gt;radio-stack.md&lt;/code&gt;, &lt;code&gt;field-deployment.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;One raw source, a North Jetty field log excerpt, under &lt;code&gt;sources/&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then I planted the kind of mess an ingest agent actually produces.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A compiled overview dropped into &lt;code&gt;notes/&lt;/code&gt; with &lt;code&gt;layer: wiki&lt;/code&gt; in the frontmatter. Wrong folder, wrong owner.&lt;/li&gt;
&lt;li&gt;A wiki page named &lt;code&gt;lora-duty-cycle.md&lt;/code&gt; that reuses the human note's id and, almost word for word, its body. The agent "filed" the note into the wiki by copying it and dropping the date prefix.&lt;/li&gt;
&lt;li&gt;Another wiki page, &lt;code&gt;sensor-drift.md&lt;/code&gt;, that paraphrases the salt-fog note just loosely enough to look new and just tightly enough to replace it.&lt;/li&gt;
&lt;li&gt;The mooring note is still uncited. The field-deployment page even admits it: "This page does not yet cover mooring hardware. That note has not been ingested." That is a gap. It is not a rewrite, so it is a warning, not an error.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the guard actually checks
&lt;/h2&gt;

&lt;p&gt;Each &lt;code&gt;check&lt;/code&gt; run walks every Markdown file and classifies it. Frontmatter &lt;code&gt;layer: human|wiki|source&lt;/code&gt; wins when present. Otherwise the top-level folder decides, and the script warns that it had to infer.&lt;/p&gt;

&lt;p&gt;Then, in this order:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Folder vs layer.&lt;/strong&gt; A &lt;code&gt;layer: wiki&lt;/code&gt; file in &lt;code&gt;notes/&lt;/code&gt; is an error. The folder is the access control you can see in a file tree; the frontmatter is what an agent will read. They have to agree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ids.&lt;/strong&gt; A compiled page may not reuse a human or source id. This is the obvious one, and agents still do it because the id is a convenient slug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stems, including date prefixes.&lt;/strong&gt; &lt;code&gt;wiki/lora-duty-cycle.md&lt;/code&gt; collides with &lt;code&gt;notes/20260522-lora-duty-cycle.md&lt;/code&gt;. Dropping &lt;code&gt;YYYYMMDD-&lt;/code&gt; is the most common way a "file this in the wiki" step eats a Zettel. The stem check treats the date prefix as disposable and compares what is left.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Rewrites.&lt;/strong&gt; Token Jaccard of 0.42, or 72% of the human note's tokens appearing in the wiki page, flags a copy. Short notes (under eight tokens) are skipped so a title mention does not count as a rewrite. The thresholds are conservative on purpose: I would rather catch a near-verbatim paste than debate whether a good summary is "too close."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Citations.&lt;/strong&gt; A human note that no wiki page points at, via &lt;code&gt;sources:&lt;/code&gt; or a wiki/markdown link, is a warning. Uncited is not a crime. It is a reminder that the wiki has not ingested that note yet, which is a different problem from having overwritten it.&lt;/p&gt;

&lt;p&gt;None of these calls a model. That is the point: a layer boundary has to be something you can run in CI, and something an agent can be denied by before it writes.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Core of layer_guard.py (rewrite detection and the write gate)
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;REWRITE_JACCARD&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.42&lt;/span&gt;
&lt;span class="no"&gt;REWRITE_COVERAGE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.72&lt;/span&gt;  &lt;span class="c1"&gt;# fraction of human-note tokens found in the wiki page&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;is_rewrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wiki&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Page&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nf"&gt;jaccard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wiki&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="no"&gt;REWRITE_JACCARD&lt;/span&gt;
        &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nf"&gt;coverage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;wiki&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="no"&gt;REWRITE_COVERAGE&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;allow_write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proposed_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;top&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parts&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;top&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"wiki"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"proposals"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"proposal"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;denied&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"agents may not write here"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;proposed_text&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;proposed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;load_page_from_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;proposed_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;# Re-run id, slug, rewrite, and layer checks as if the&lt;/span&gt;
    &lt;span class="c1"&gt;# file were already in the vault. Overwriting wiki/ is fine.&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;check_pages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;others&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;proposed&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# only findings on rel matter&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it on the messy vault
&lt;/h2&gt;

&lt;p&gt;I ran this on 2026-11-25 against the Tidemark fixture. The clean vault, first, so you can see what "ok" looks like. The uncited mooring note is the only warning, and the exit code is 0.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 layer_guard.py fixture-clean check
pages: 10  errors: 0  warnings: 1
WARNING UNCITED          notes/20261102-buoy-mooring-lessons.md
        no wiki page cites this note via sources: or a wiki/markdown link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The messy vault is the one that looks like an agent already "helped."&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 layer_guard.py fixture check
pages: 13  errors: 5  warnings: 1
ERROR   LAYER_MISMATCH   notes/sensor-calibration-overview.md
        frontmatter says layer: wiki, but notes/ is reserved for layer: human
ERROR   ID_COLLISION     wiki/lora-duty-cycle.md  (vs notes/20260522-lora-duty-cycle.md)
        id '20260522-lora-duty-cycle' is already used by a protected page
ERROR   SLUG_COLLISION   wiki/lora-duty-cycle.md  (vs notes/20260522-lora-duty-cycle.md)
        filename stem 'lora-duty-cycle' collides with human note stem '20260522-lora-duty-cycle'
ERROR   REWRITE          wiki/lora-duty-cycle.md  (vs notes/20260522-lora-duty-cycle.md)
        body is too close to a human note (jaccard=1.00, coverage=1.00); compile and cite, do not copy
ERROR   REWRITE          wiki/sensor-drift.md  (vs notes/20260408-sensor-drift-salt-fog.md)
        body is too close to a human note (jaccard=0.90, coverage=0.90); compile and cite, do not copy
WARNING UNCITED          notes/20261102-buoy-mooring-lessons.md
        no wiki page cites this note via sources: or a wiki/markdown link
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjeadzzmz4glbgg2rfyxw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjeadzzmz4glbgg2rfyxw.jpg" alt="layer_guard.py check on the messy Tidemark vault: five errors for a wiki file in notes/, a copied LoRa note, and a near-verbatim salt-fog rewrite, plus a warning for the uncited mooring note" width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three things I care about in that report.&lt;/p&gt;

&lt;p&gt;The overview in &lt;code&gt;notes/&lt;/code&gt; is not subtle. The agent declared &lt;code&gt;layer: wiki&lt;/code&gt; and still wrote into the human folder. If your only protection is "the model will see the frontmatter," it will not help you when the file is already in the wrong place. The folder check is the one a reviewer can see without opening the file.&lt;/p&gt;

&lt;p&gt;The LoRa page fails three times for one action: it reused the id, it dropped the date prefix, and it copied the body. That is not a compiled radio-stack page. That is the atomic note, republished under a new path, which is how a Zettelkasten disappears without anyone deleting a file.&lt;/p&gt;

&lt;p&gt;The salt-fog rewrite is the quieter failure. The id is new. The title is slightly different. Jaccard is 0.90, coverage is 0.90. A human skimming a diff might call it a summary. The original note's hedge — "I think the issue is salt film on the sensing polymer, not firmware" — is still in there, which means the wiki page has not added operational shape. It has just moved the observation. The clean &lt;code&gt;sensor-calibration.md&lt;/code&gt; page, by contrast, cites two notes and tells a tech when to recalibrate. That is compilation. The guard leaves it alone.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;coverage&lt;/code&gt; is the list of notes the wiki has not ingested yet. In both fixtures it is the same one line: &lt;code&gt;notes/20261102-buoy-mooring-lessons.md&lt;/code&gt;. That is the next page someone should compile, not a license to paste the note into &lt;code&gt;wiki/&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deny the write before it lands
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;check&lt;/code&gt; is for after the fact, or for CI. The more useful hook is &lt;code&gt;allow-write&lt;/code&gt;. Point it at a path, optionally with the proposed file, before the agent is allowed to touch the disk.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 layer_guard.py fixture allow-write --path notes/20260408-sensor-drift-salt-fog.md
DENIED
ERROR   WRITE_DENIED     notes/20260408-sensor-drift-salt-fog.md
        agents may not write under notes/; only wiki/ and proposals/ are writable

$ python3 layer_guard.py fixture allow-write --path wiki/permits.md --file proposed-collide.md
DENIED
ERROR   ID_COLLISION     wiki/permits.md  (vs notes/20261003-harbor-permit-lead-time.md)
        id '20261003-harbor-permit-lead-time' is already used by a protected page

$ python3 layer_guard.py fixture allow-write --path wiki/winter-mooring.md --file proposed-ok.md
ALLOWED  wiki/winter-mooring.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnpayi24wsfnjpybwni0b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnpayi24wsfnjpybwni0b.jpg" alt="allow-write rejects a path under notes/ and a wiki page that reuses a human note's id, then allows a compiled winter-mooring page that cites the uncited note" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first denial does not even need to see the content. &lt;code&gt;notes/&lt;/code&gt; is not a writable folder, full stop. The second one is the interesting case: the path is under &lt;code&gt;wiki/&lt;/code&gt;, which is allowed, but the proposed frontmatter reuses a human id. A page about permits is fine. A page that &lt;em&gt;is&lt;/em&gt; the permit note is not.&lt;/p&gt;

&lt;p&gt;The allowed write is the page the coverage warning was asking for. It lives in &lt;code&gt;wiki/&lt;/code&gt;, has its own id (&lt;code&gt;winter-mooring&lt;/code&gt;), cites &lt;code&gt;20261102-buoy-mooring-lessons&lt;/code&gt;, and adds a rule the note was inching toward: a single 20 kg mushroom on 3:1 scope is not a winter rating. That is the ingest step I actually want from an agent.&lt;/p&gt;

&lt;p&gt;Hook &lt;code&gt;allow-write&lt;/code&gt; as a tool the agent must call, or as a pre-commit check on any path the agent proposes. &lt;code&gt;check&lt;/code&gt; stays in CI so a write that bypassed the tool still fails the build. Sixteen unit tests cover the errors above, the clean-vault case, inferred vs missing layers, and the guarantee that neither command modifies a file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this belongs
&lt;/h2&gt;

&lt;p&gt;A folder convention in a repo is enough for one person's vault. On a team, "agents may not write this" has to be a permission, not a comment in &lt;code&gt;AGENTS.md&lt;/code&gt;. The human notes and the compiled wiki should be able to live in the same workspace without sharing a write policy — the same idea as &lt;a href="https://affine.pro/blog/ai-workspace-permissions" rel="noopener noreferrer"&gt;AI workspace permissions&lt;/a&gt; that already distinguish what a tool may read from what it may change.&lt;/p&gt;

&lt;p&gt;If your vault is just a shared disk, the model that can lint a page can also overwrite it. You want &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; that can put atomic notes in a space an agent can search and cannot edit, and compiled pages in a space it can. That is the difference between a chat that maintains a wiki and &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt; that treats your Zettelkasten as a source, not as a draft. And if you can run that workspace yourself — the thing people usually mean when they look for an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion&lt;/a&gt; alternative — the layer boundary stays yours, including when the ingest agent is wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It will not judge a good summary.&lt;/strong&gt; A compiled page that shares some vocabulary with its sources will usually stay under the rewrite thresholds. If a model writes a careful synthesis that happens to reuse most of a short note's wording, you can still get a false positive. Lowering the threshold would flag more honest compiles. I would rather inspect those than miss a 0.90 copy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Citations are lexical, not semantic.&lt;/strong&gt; A wiki page that talks about "winter anchors" without linking the mooring note will still look uncited. That is a warning, and it is the right warning. Add the link, or leave the note uningested.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Folder names are a convention.&lt;/strong&gt; &lt;code&gt;notes/&lt;/code&gt;, &lt;code&gt;zettel/&lt;/code&gt;, &lt;code&gt;wiki/&lt;/code&gt;, and &lt;code&gt;sources/&lt;/code&gt; are recognized. A vault that keeps atomic notes under &lt;code&gt;permanent/&lt;/code&gt; or &lt;code&gt;slips/&lt;/code&gt; will need a one-line alias, or frontmatter on every file. I did not try to guess every Zettelkasten layout.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It does not move files.&lt;/strong&gt; The guard reports. It does not tidy &lt;code&gt;notes/sensor-calibration-overview.md&lt;/code&gt; back into &lt;code&gt;wiki/&lt;/code&gt;. An automatic "fix" that relocates an agent's page is how you launder a bad write. A human should decide whether to move it, rewrite it, or delete it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It will not scale to a dump of everything you have ever written.&lt;/strong&gt; Thirteen pages is vault scale. Past a few thousand notes you still want these rules — especially the write gate — but you may want a real index behind citation checks. The product is the boundary, not the walker.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; point &lt;code&gt;layer_guard.py&lt;/code&gt; at a Markdown export of your own vault, run &lt;code&gt;check&lt;/code&gt;, and read the errors before you let an ingest agent "update related pages." In the Tidemark fixture, the five errors were more useful than a newly compiled overview. The uncited mooring note was the only thing I actually wanted the agent to work on next.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>python</category>
    </item>
    <item>
      <title>Your LLM Wiki Should Collect the Questions It Can't Answer. I Wrote a Gap Queue for That.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Tue, 24 Nov 2026 06:20:28 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-should-collect-the-questions-it-cant-answer-i-wrote-a-gap-queue-for-that-5i0</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-should-collect-the-questions-it-cant-answer-i-wrote-a-gap-queue-for-that-5i0</guid>
      <description>&lt;p&gt;Harrison Chase published &lt;a href="https://www.langchain.com/blog/knowledge-factory" rel="noopener noreferrer"&gt;How to build a knowledge factory&lt;/a&gt; on November 21. By this week it was all over my feed, and the useful part was not a new model.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

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

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcd75r87skgjq7f12l743.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcd75r87skgjq7f12l743.jpg" alt="A question hits gap_queue.py, which either cites a wiki page or files a missing, stale, or conflict ticket; related tickets are clustered and a proposal is drafted for a human to merge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The miss is the valuable part
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  The sample wiki
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;I seeded it with the kind of mess a working wiki actually has.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear, recently reviewed pages for the questions a dispatcher would expect to answer: invoice terms, the after-hours roster, the workmanship warranty.&lt;/li&gt;
&lt;li&gt;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.&lt;/li&gt;
&lt;li&gt;A stale rate card. &lt;code&gt;emergency-rates.md&lt;/code&gt; still says after-hours work is 1.5×, last reviewed March 12, 2024, citing a 2024 source.&lt;/li&gt;
&lt;li&gt;A real disagreement in frontmatter. &lt;code&gt;overtime.md&lt;/code&gt; claims overtime starts after 8 hours. &lt;code&gt;union-addendum.md&lt;/code&gt; claims it starts after 10 hours. Both were reviewed on the same day. Nobody reconciled them into one payroll rule.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Raw sources live in &lt;code&gt;sources/&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a question is classified
&lt;/h2&gt;

&lt;p&gt;Each &lt;code&gt;ask&lt;/code&gt; run does four checks, in this order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BM25&lt;/strong&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coverage.&lt;/strong&gt; A hit also needs the best page to match at least 55% of the query terms. This is the check that stops &lt;code&gt;cancellation-policy.md&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conflicts.&lt;/strong&gt; If two pages that both cleared the floor disagree on a structured &lt;code&gt;claims:&lt;/code&gt; key, the script files a conflict ticket and refuses to answer. It does not pick a winner.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Staleness.&lt;/strong&gt; If the best page is otherwise a hit, but &lt;code&gt;last_reviewed&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;Anything that fails the score or coverage check becomes a missing ticket. In every case, &lt;code&gt;wiki/&lt;/code&gt; is left untouched.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  
  &lt;br&gt;
Core of gap_queue.py (hit, miss, stale, and conflict)&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;qn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromkeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qtokens&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;best_cov&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ranked&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;qn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ranked&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;ranked&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;ranked&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min_score&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;best_cov&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;min_coverage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;write_ticket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"missing"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;searched&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;  &lt;span class="c1"&gt;# MISS&lt;/span&gt;

&lt;span class="n"&gt;floor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min_score&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.6&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ranked&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mf"&gt;0.45&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;candidates&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ranked&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;top_k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;by_key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;candidates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;claims&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;by_key&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;conflicts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;by_key&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
             &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pairs&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;conflicts&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;write_ticket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"conflict"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;searched&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;  &lt;span class="c1"&gt;# CONFLICT&lt;/span&gt;

&lt;span class="n"&gt;best_s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ranked&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_stale&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stale_days&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;write_ticket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"stale"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evidence&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;best&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rel&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;  &lt;span class="c1"&gt;# STALE&lt;/span&gt;

&lt;span class="c1"&gt;# otherwise HIT, print citations, write nothing&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Running it on the sample fixture
&lt;/h2&gt;

&lt;p&gt;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.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;$ python3 gap_queue.py fixture --today 2026-11-24 ask --question &lt;span class="s2"&gt;"What is the standard labor rate?"&lt;/span&gt;
Q: What is the standard labor rate?
RESULT: HIT
citations:
   3.945  wiki/invoice-terms.md  &lt;span class="o"&gt;(&lt;/span&gt;Invoice terms&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="nv"&gt;last_reviewed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2026-10-20
   2.414  wiki/customer-credits.md  &lt;span class="o"&gt;(&lt;/span&gt;Customer credits&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="nv"&gt;last_reviewed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2026-06-30
   2.065  wiki/emergency-rates.md  &lt;span class="o"&gt;(&lt;/span&gt;Emergency rates&lt;span class="o"&gt;)&lt;/span&gt;  &lt;span class="nv"&gt;last_reviewed&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2024-03-12
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;The roster and warranty questions also hit: &lt;code&gt;after-hours.md&lt;/code&gt; for escalation (score 6.847), &lt;code&gt;warranty.md&lt;/code&gt; for the 90-day workmanship period (score 4.745). Then the misses:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ 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)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0lxobok77b5q7pu1rdky.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F0lxobok77b5q7pu1rdky.jpg" alt="Seven questions run against the Harborline sample: three hits citing invoice terms, the after-hours roster and the warranty page, two missing tickets on travel billing, a stale lead on emergency rates, and a conflict between overtime and the union addendum"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two things I care about in those misses.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;The last two questions are not misses. They are worse.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ 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 -&amp;gt; 8 hours
    wiki/union-addendum.md -&amp;gt; 10 hours
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cluster the tickets, then draft a page
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;cluster&lt;/code&gt; 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). &lt;code&gt;propose&lt;/code&gt; writes a stub for one cluster.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ 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
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmnz0wytf84yms0y4yssr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmnz0wytf84yms0y4yssr.jpg" alt="Cluster C1 groups the two travel-billing misses; C2 is the stale emergency-rates ticket; C3 is the overtime conflict. propose writes a stub under proposals/ and leaves wiki/ unmodified"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Thirteen unit tests cover the four outcomes, the clustering, the proposal, and the guarantee that &lt;code&gt;wiki/&lt;/code&gt; 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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this belongs
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;gaps/&lt;/code&gt; 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 &lt;a href="https://affine.pro/blog/knowledge-base" rel="noopener noreferrer"&gt;team knowledge base&lt;/a&gt; already needs on every important article. A gap ticket is how you find the article that should have had those and does not.&lt;/p&gt;

&lt;p&gt;If you expose &lt;code&gt;ask&lt;/code&gt; and &lt;code&gt;file&lt;/code&gt; as tools on an &lt;a href="https://affine.pro/blog/what-is-mcp-server" rel="noopener noreferrer"&gt;MCP server&lt;/a&gt;, 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.&lt;/p&gt;

&lt;p&gt;A weekend folder hook will not hold this for long. You need &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; 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 &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt; rather than a chat log that forgets the miss. And if you can run the workspace yourself — the thing people usually want from an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion&lt;/a&gt; alternative — the queue stays in your rooms, not in a vendor's memory store.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It will not decide the policy.&lt;/strong&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Coverage is lexical, not semantic.&lt;/strong&gt; "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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Staleness is a date, not a fact check.&lt;/strong&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claims have to be written down.&lt;/strong&gt; The overtime conflict only fires because both pages declared &lt;code&gt;overtime_starts_after&lt;/code&gt; 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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It does not scale to a messy export of everything.&lt;/strong&gt; Seventeen pages is wiki scale. Past that, you still want this loop — flag, cluster, propose — but you may want a real index behind &lt;code&gt;ask&lt;/code&gt;. The queue is the product, not the scorers.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; point &lt;code&gt;gap_queue.py&lt;/code&gt; 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 the three hits.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>productivity</category>
      <category>python</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Your LLM Wiki Doesn't Need a Vector Database. It Needs a Link Graph.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Mon, 23 Nov 2026 06:23:58 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-doesnt-need-a-vector-database-it-needs-a-link-graph-di2</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-doesnt-need-a-vector-database-it-needs-a-link-graph-di2</guid>
      <description>&lt;p&gt;Most LLM wiki setups I see pick up a vector database on day two.&lt;/p&gt;

&lt;p&gt;I understand why. Karpathy's LLM Wiki pattern — raw sources stay untouched, the model maintains linked Markdown pages, answers come back with citations — sounds like a retrieval problem, and retrieval has meant embeddings for a few years now. So people chunk the wiki, embed the chunks, and ask an index to find "similar" passages.&lt;/p&gt;

&lt;p&gt;This week's feed was doing something older, and it worked well enough that I wanted a version I could unit-test.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An Obsidian plugin for Karpathy's LLM Wiki was being passed around that uses lexical search plus PageRank over &lt;code&gt;[[wiki-links]]&lt;/code&gt; instead of chunking notes into a vector database. Source notes stay untouched; answers cite their pages.&lt;/li&gt;
&lt;li&gt;A widely circulated post described a loop that scores every note in a vault before the model ever loads it, built on the same gist and a plain Zettelkasten folder.&lt;/li&gt;
&lt;li&gt;People have been describing the gist itself as a local memory layer on plain Markdown, with review-gated writes and no LLM in the storage layer, meant to work across several coding tools — Claude Code, Codex, Cursor, Zed.&lt;/li&gt;
&lt;li&gt;Notion also announced a "shared brain" for teams and AI agents. Shared context is the useful part. The risk is that context living only inside one product's agent layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same idea, four times: the wiki is already a graph. Rank the links, search the text, cite the page. You do not need a second database to do that at the scale Karpathy was talking about — roughly a hundred sources and a few hundred pages.&lt;/p&gt;

&lt;p&gt;So this post builds the boring local version: a ~380-line, stdlib-only Python script called &lt;code&gt;wiki_rank.py&lt;/code&gt;. It reads a Markdown wiki, builds a link graph, ranks pages with PageRank, scores a query with BM25, and combines the two. It also lints the graph: dangling links, orphans, stale pages, dead ends, and compiled pages with no &lt;code&gt;sources:&lt;/code&gt; in the frontmatter. It never writes to the wiki. A human still owns what gets fixed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flrgpbhzlrn0gvkrhexe2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flrgpbhzlrn0gvkrhexe2.jpg" alt="Query goes into wiki_rank.py, which combines BM25 over page text with PageRank over wiki-links, then prints a ranked list with citations; lint flags are review-only and the wiki stays read-only" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a vector database is the wrong default
&lt;/h2&gt;

&lt;p&gt;A vector index is the right tool for a large, changing corpus you do not control — tickets, PDFs, chat logs. An LLM wiki is the opposite of that. The pages are already short, already interlinked, already written so a model can follow them. Chunking them throws the links away and then tries to recover the structure with cosine similarity.&lt;/p&gt;

&lt;p&gt;Karpathy noted that an &lt;code&gt;index.md&lt;/code&gt; catalog alone works at moderate scale. A link graph is that catalog, just computable. PageRank tells you which pages the wiki itself treats as important. Lexical search tells you which pages actually use the words in the question. Combined, they answer the only question that matters: which page should the agent read first, and what raw source does that page cite?&lt;/p&gt;

&lt;p&gt;The number I care about is not recall@10 on a benchmark. It is this: when I ask "how do we rotate SSO certificates," does the agent open the SSO certificate rotation page, or the TLS certificate page, or the on-call rotation page?&lt;/p&gt;

&lt;h2&gt;
  
  
  The sample wiki
&lt;/h2&gt;

&lt;p&gt;The fixture in this post is made up: 23 wiki pages and 16 raw sources for a fictional team at a fictional company I called Trestle. I seeded it with the messy stuff real wikis have.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A well-linked identity cluster: &lt;code&gt;sso.md&lt;/code&gt;, &lt;code&gt;sso-certificates.md&lt;/code&gt;, &lt;code&gt;sso-outage.md&lt;/code&gt;, &lt;code&gt;scim.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A popular but off-topic hub. &lt;code&gt;on-call.md&lt;/code&gt; has the highest PageRank in the graph. Several incident pages point at it. It should not win a question about certificates.&lt;/li&gt;
&lt;li&gt;A close lexical distractor. &lt;code&gt;certificates.md&lt;/code&gt; is about TLS certificates for trestle.app, which also rotate. It talks about certificates and rotation, but not about SSO.&lt;/li&gt;
&lt;li&gt;Three pages that link to &lt;code&gt;[[Refund Policy]]&lt;/code&gt;, a page nobody ever wrote.&lt;/li&gt;
&lt;li&gt;An orphan, &lt;code&gt;old-zoom-setup.md&lt;/code&gt;, that nobody has linked to since the team moved off Zoom.&lt;/li&gt;
&lt;li&gt;A stale roster (&lt;code&gt;on-call-schedule.md&lt;/code&gt;, last updated August 2).&lt;/li&gt;
&lt;li&gt;A vendor list with no outbound links.&lt;/li&gt;
&lt;li&gt;A data-retention page that states legal-sounding retention periods and cites no source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Raw sources live in &lt;code&gt;sources/&lt;/code&gt; and are never ranked. Wiki pages may cite them in frontmatter. That is the Karpathy split: the model (or a person) compiles the wiki; the sources stay read-only.&lt;/p&gt;

&lt;h2&gt;
  
  
  How ranking works
&lt;/h2&gt;

&lt;p&gt;Two scores, then a weighted sum.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PageRank&lt;/strong&gt; over the &lt;code&gt;[[wiki-link]]&lt;/code&gt; graph, damping 0.85, 40 iterations. Dangling nodes (pages with no outbound links) distribute their mass evenly, same as the original paper. I resolve links against both the filename stem and a slug of the page title, so &lt;code&gt;[[SSO certificate rotation]]&lt;/code&gt; hits &lt;code&gt;wiki/sso-certificates.md&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BM25&lt;/strong&gt; over the page title (boosted 3x) and the visible body text. Wiki-link aliases are what get tokenized, not the hidden target, so a "see also" link does not smuggle terms into a page that never discusses them. There is a coordination factor: a page that only matches two of the three query terms cannot beat a page that matches all three just because it is short.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Combined score:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;score = alpha * PageRank_norm + (1 - alpha) * BM25_norm&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Default &lt;code&gt;alpha&lt;/code&gt; is 0.30. Lexical overlap leads; the graph breaks ties and lifts a well-linked page over a close lexical miss. Set &lt;code&gt;alpha&lt;/code&gt; to 1.0 and you get pure popularity, which, as we will see, is how you hand the agent the on-call roster.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  
  &lt;br&gt;
Core of wiki_rank.py (PageRank, BM25 coordination, combined score)&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pagerank&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;edges&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;damping&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.85&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;iters&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;enumerate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;outbound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;dst&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;edges&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;dst&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;idx&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;outbound&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;idx&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;dst&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;outbound&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromkeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;outbound&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
    &lt;span class="n"&gt;teleport&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;1.0&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;damping&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;iters&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;nxt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;teleport&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
        &lt;span class="n"&gt;dangling&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;outbound&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;dangling&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;share&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;damping&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;outbound&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;j&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;outbound&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;share&lt;/span&gt;
        &lt;span class="n"&gt;add&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;damping&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dangling&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;nxt&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;add&lt;/span&gt;
        &lt;span class="n"&gt;pr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;nxt&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;bm25&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;k1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="no"&gt;N&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;avgdl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;toks&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
    &lt;span class="n"&gt;qset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromkeys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;scores&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;present&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;qset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;idf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;N&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;toks&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;tf&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;toks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;present&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;dl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;toks&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="n"&gt;denom&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;tf&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;k1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;dl&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;avgdl&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;idf&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tf&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;denom&lt;/span&gt;
    &lt;span class="n"&gt;nq&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;qset&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;doc&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;*=&lt;/span&gt; &lt;span class="n"&gt;present&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;doc&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;nq&lt;/span&gt;  &lt;span class="c1"&gt;# coordination&lt;/span&gt;
    &lt;span class="n"&gt;peak&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;values&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;peak&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;scores&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;combine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lex&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;prn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;lexn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;normalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;keys&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lexn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;prn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;alpha&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;lexn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;k&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;k&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The write path is easy to describe: there isn't one. The script opens wiki pages and sources for reading only. A unit test hashes every Markdown file before and after a query-plus-lint run and checks the bytes. That is the "no LLM in the storage layer" idea, applied to the ranker too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 -m unittest test_wiki_rank
............
----------------------------------------------------------------------
Ran 12 tests in 0.015s

OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running it on the sample fixture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 wiki_rank.py fixture --query "how do we rotate SSO certificates" --lint --today 2026-11-23
wiki_rank: 23 pages, 78 links, 3 dangling  today=2026-11-23  alpha=0.30
QUERY    "how do we rotate SSO certificates"
  1. 0.84  wiki/sso-certificates.md          lex=1.00  pr=0.45  "SSO certificate rotation"
       cites: sources/okta-rotation-runbook.md, sources/cert-calendar.md
  2. 0.65  wiki/certificates.md              lex=0.88  pr=0.13  "Certificates"
       cites: sources/tls-runbook.md
  3. 0.46  wiki/sso-outage.md                lex=0.40  pr=0.61  "SSO outage"
       cites: sources/okta-status-notes.md
  4. 0.42  wiki/sso.md                       lex=0.39  pr=0.50  "SSO at Trestle"
       cites: sources/okta-tenant-notes.md
  5. 0.38  wiki/on-call.md                   lex=0.12  pr=1.00  "On-call"
       cites: sources/pager-rules.md
LINT
  DANGLING  wiki/billing.md               [[refund-policy]] is missing
  DANGLING  wiki/customer-faq.md          [[refund-policy]] is missing
  DANGLING  wiki/incident-billing.md      [[refund-policy]] is missing
  ORPHAN    wiki/old-zoom-setup.md        0 inbound links
  STALE     wiki/old-zoom-setup.md        updated 2026-03-12 (256 days ago)
  STALE     wiki/on-call-schedule.md      updated 2026-08-02 (113 days ago)
  DEADEND   wiki/old-zoom-setup.md        0 outbound links
  DEADEND   wiki/vendor-list.md           0 outbound links
  UNCITED   wiki/data-retention.md        no sources: in frontmatter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo7pzwdawtwip9l5vjkx5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fo7pzwdawtwip9l5vjkx5.jpg" alt="Terminal output of wiki_rank.py on the 23-page Trestle sample: SSO certificate rotation ranks first, the TLS certificates page is second, on-call has the highest PageRank and still lands fifth, plus lint flags for a missing refund page, an orphan Zoom setup, a stale roster, a dead-end vendor list and an uncited retention policy" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What a reviewer should take from that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;sso-certificates.md&lt;/code&gt; wins&lt;/strong&gt;, score 0.84, lexical 1.00, PageRank 0.45. It cites &lt;code&gt;sources/okta-rotation-runbook.md&lt;/code&gt; and &lt;code&gt;sources/cert-calendar.md&lt;/code&gt;. That is the page I would want an agent to open, and the two raw files I would want a human to be able to click through to.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;certificates.md&lt;/code&gt; is a close second on wording&lt;/strong&gt; (lex 0.88) and a distant second overall (0.65). It is the TLS page. A vector store would also find this one; the difference is that the link graph already knows the SSO cert page is the one the rest of the identity cluster points at (PageRank 0.45 vs 0.13).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;on-call.md&lt;/code&gt; has the highest PageRank in the whole wiki&lt;/strong&gt; (1.00) and still lands fifth, because it barely matches the query (lex 0.12). Popularity is not relevance.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Three pages dangle &lt;code&gt;[[Refund Policy]]&lt;/code&gt;.&lt;/strong&gt; Finance apparently owns a page that does not exist. A retriever cannot fix that. The lint can.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;old-zoom-setup.md&lt;/code&gt; is an orphan, a dead end, and stale&lt;/strong&gt; (last updated March 12, 256 days ago). The graph cannot reach it, so neither can an agent that starts from the index. That is fine if the page is retired; it is a problem if someone still thinks it is current.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;on-call-schedule.md&lt;/code&gt; is stale&lt;/strong&gt; (August 2, 113 days). It is linked, so an agent can find it. That might be worse than an orphan.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;vendor-list.md&lt;/code&gt; has no outbound links.&lt;/strong&gt; A list of vendors that does not point at the runbooks is a dead end in the graph.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;data-retention.md&lt;/code&gt; is uncited.&lt;/strong&gt; It claims "18 months" and "seven years" with no &lt;code&gt;sources:&lt;/code&gt; in the frontmatter. A compiled page that makes a legal claim and cites nothing is the kind of thing you do not want an agent quoting.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pure PageRank is worse than it looks
&lt;/h2&gt;

&lt;p&gt;Same wiki, same query, &lt;code&gt;alpha&lt;/code&gt; set to 1.0:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 wiki_rank.py fixture --query "how do we rotate SSO certificates" --alpha 1 --today 2026-11-23
wiki_rank: 23 pages, 78 links, 3 dangling  today=2026-11-23  alpha=1.00
QUERY    "how do we rotate SSO certificates"
  1. 1.00  wiki/on-call.md                   lex=0.12  pr=1.00  "On-call"
       cites: sources/pager-rules.md
  2. 0.87  wiki/incident-response.md         lex=0.05  pr=0.87  "Incident response"
       cites: sources/incident-severity.md
  3. 0.61  wiki/sso-outage.md                lex=0.40  pr=0.61  "SSO outage"
       cites: sources/okta-status-notes.md
  4. 0.54  wiki/on-call-schedule.md          lex=0.00  pr=0.54  "On-call schedule"
       cites: sources/pager-rules.md
  5. 0.53  wiki/billing.md                   lex=0.00  pr=0.53  "Billing"
       cites: sources/stripe-runbook.md
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhk2i3ztt2km8uptwg2kr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhk2i3ztt2km8uptwg2kr.jpg" alt="Side-by-side ranking: pure PageRank puts on-call first and never surfaces the SSO certificate page in the top five; combined ranking with alpha 0.30 puts SSO certificate rotation first and the TLS distractor second" width="800" height="369"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The agent would open &lt;code&gt;on-call.md&lt;/code&gt;. Then &lt;code&gt;incident-response.md&lt;/code&gt;. The SSO certificate page does not even make the top five. The graph is useful; the graph alone is not a retriever.&lt;/p&gt;

&lt;p&gt;Pure BM25 (&lt;code&gt;alpha&lt;/code&gt; 0) does pick &lt;code&gt;sso-certificates.md&lt;/code&gt; first, with &lt;code&gt;certificates.md&lt;/code&gt; close behind at 0.88. That is why the default is 0.30, not 0. The link graph is a tie-breaker and a popularity prior, not the answer.&lt;/p&gt;

&lt;h2&gt;
  
  
  One store, several tools
&lt;/h2&gt;

&lt;p&gt;The reason I wanted this as a folder of Markdown, not as an API, is the same reason people keep mentioning Claude Code, Cursor, Codex, and Zed in the same sentence as the gist. Those tools already know how to read files. A ranker that prints paths and citations can sit in front of any of them. Each agent does not get its own memory format.&lt;/p&gt;

&lt;p&gt;A human still browses the same pages. That is the answer I would give the person who asked this week how to keep an LLM wiki (for agents) distinct from a Zettelkasten (for humans): one store, two ways in. People follow links and edit. Agents ask a question, get a ranked list with sources, and stay out of the write path until a review gate says otherwise.&lt;/p&gt;

&lt;p&gt;Notion's "shared brain" announcement is aimed at the same problem — teams tired of re-explaining context to a new agent. I want that shared context to be a directory I can grep, diff, and host, not a feature that disappears if I change vendors.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this lives in a team knowledge base
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;wiki/&lt;/code&gt; folder in a repo works for one developer. For a team, I would put the compiled pages in the same workspace as the docs and the decisions they cite, with &lt;code&gt;sources&lt;/code&gt;, &lt;code&gt;updated&lt;/code&gt;, and &lt;code&gt;type&lt;/code&gt; as page properties, and with backlinks so "what points at the refund policy that does not exist?" is one query.&lt;/p&gt;

&lt;p&gt;In AFFiNE, this is how I would set it up. The wiki pages are ordinary docs, the raw sources are a separate collection, and &lt;code&gt;wiki_rank.py&lt;/code&gt; runs against a Markdown export. The lint report lands in a review collection; a person decides whether to write the missing refund page, retire the Zoom setup, or attach a source to the retention policy.&lt;/p&gt;

&lt;p&gt;If you're choosing &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt;&lt;/strong&gt; for a setup like this, look for backlinks and queryable properties, because the graph only exists if the links are real. The retrieval shape is close to what we described for an &lt;strong&gt;&lt;a href="https://affine.pro/blog/llm-wiki" rel="noopener noreferrer"&gt;LLM wiki for teams&lt;/a&gt;&lt;/strong&gt;: a self-hosted workspace as the source of truth, agents reading it, a compiled wiki layer for synthesized topics. And if the reason you want that split is control over the files, a &lt;strong&gt;&lt;a href="https://affine.pro/blog/self-hosted-ai-workspace" rel="noopener noreferrer"&gt;self-hosted AI workspace&lt;/a&gt;&lt;/strong&gt; is the deployment version of the same idea — the ranker is just a script, but the pages still have to live somewhere you can export.&lt;/p&gt;

&lt;p&gt;I'd also keep this layer somewhere you control. A "shared brain" that only exists inside one vendor's agent is a shared brain you cannot take with you. That's an argument for an &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion alternative&lt;/a&gt;&lt;/strong&gt; you can self-host, and for treating this as &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt;&lt;/strong&gt; rather than as a plugin of whichever coding agent you used this month. If you are comparing more traditional wiki options alongside a compiled LLM layer, this rundown of &lt;strong&gt;&lt;a href="https://affine.pro/blog/self-hosted-wiki" rel="noopener noreferrer"&gt;self-hosted wiki&lt;/a&gt;&lt;/strong&gt; software is a useful map of the boring, durable half.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It will not scale to tens of thousands of pages.&lt;/strong&gt; BM25 over a folder is fine at wiki scale. Past that, you probably do want an index, and maybe embeddings for the long tail of PDFs you never compiled. I would still compile the important topics into pages with links, and rank those first.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stemming is naive.&lt;/strong&gt; &lt;code&gt;rotate&lt;/code&gt; and &lt;code&gt;rotation&lt;/code&gt; are special-cased because that was the query I cared about. A real stemmer would be better. I did not want a dependency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PageRank uses equal edges.&lt;/strong&gt; A link from the index and a link from a passing "see also" count the same. You could weight them. I have not needed to at 23 pages, and I am not convinced I would trust the weights I invented.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Staleness is a date, not a fact check.&lt;/strong&gt; &lt;code&gt;updated: 2026-08-02&lt;/code&gt; tells you the page was not touched. It does not tell you the roster is wrong. The lint is a prompt for a human, not a verdict.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It does not answer the question.&lt;/strong&gt; It ranks pages. The agent still has to read them. If the winning page is wrong, you get a well-cited wrong answer. That is a writing problem, which is why the uncited and stale flags exist.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; point &lt;code&gt;wiki_rank.py&lt;/code&gt; at a Markdown export of your own wiki, ask it a question you already know the answer to, and run &lt;code&gt;--lint&lt;/code&gt; before you trust &lt;code&gt;--query&lt;/code&gt;. In my sample fixture, the flags were as useful as the ranking.&lt;/p&gt;

</description>
      <category>python</category>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Your LLM Wiki Remembers Facts. Teach It How You Work, Too.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Fri, 20 Nov 2026 06:23:04 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-remembers-facts-teach-it-how-you-work-too-33ip</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-remembers-facts-teach-it-how-you-work-too-33ip</guid>
      <description>&lt;p&gt;Most LLM wiki setups I've seen are very good at one kind of memory and have almost none of the other.&lt;/p&gt;

&lt;p&gt;Karpathy's LLM Wiki pattern is the one everyone copies now: raw sources go in, the model writes linked Markdown pages, and answers come back with sources. That's great for &lt;strong&gt;facts&lt;/strong&gt;. What the release process looks like, which service owns sync, what we decided about the queue.&lt;/p&gt;

&lt;p&gt;What it doesn't store is &lt;strong&gt;how you work&lt;/strong&gt;. The fifth time my agent wrote release notes, it did the same five things it did the first four times: read the git log, searched the wiki for our changelog style, read that page, drafted, proposed the page for review. It rediscovered that path from scratch every time, burning context to do it.&lt;/p&gt;

&lt;p&gt;That's procedural memory, and it was all over my feed this week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perplexity's Computer agent was reported this week to have a "Brain" that creates and updates personalized skills from past sessions and tool calls, with a separate improvement agent that only proposes changes when the evidence is strong.&lt;/li&gt;
&lt;li&gt;A Google Cloud AI / DeepMind / Penn State paper on &lt;strong&gt;Self-Improvement Memory (SIM)&lt;/strong&gt; was reported this week. It logs the reasoning behind each harness edit so the optimizer doesn't repeat the same mistakes.&lt;/li&gt;
&lt;li&gt;On X, a few people described having a Hermes agent turn its own LLM-wiki usage into a repeatable skill.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same idea three times: watch what the agent actually does, find what repeats, and write it down as a skill. The part I care about is the second half of the Perplexity description, though. &lt;em&gt;Proposes, with strong evidence.&lt;/em&gt; An agent that rewrites its own playbook every night is how you end up with a wiki full of confident, slightly wrong procedures.&lt;/p&gt;

&lt;p&gt;So this post builds the boring local version: a ~200-line, stdlib-only Python script that reads agent session logs, finds recurring tool-call sequences, and drafts &lt;code&gt;skills/*.md&lt;/code&gt; pages into a &lt;code&gt;proposals/&lt;/code&gt; folder &lt;strong&gt;only&lt;/strong&gt; when the evidence clears a bar. A human approves. It never touches an approved skill, and it tells you when an approved skill has stopped matching reality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs3n8llz46ka1wjch0xu1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fs3n8llz46ka1wjch0xu1.jpg" alt="Pipeline: session logs go into skill_miner.py, which writes proposals; a human reviews them and approved pages move into skills/, which the agent reads next session" width="800" height="781"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Facts vs. procedures
&lt;/h2&gt;

&lt;p&gt;Here's the split I use:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Facts (what the wiki already has)&lt;/th&gt;
&lt;th&gt;Procedures (what it's missing)&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Example&lt;/td&gt;
&lt;td&gt;"Changelog style lives in docs/style/changelog.md"&lt;/td&gt;
&lt;td&gt;"Release notes = git log → style search → read → draft → propose"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source&lt;/td&gt;
&lt;td&gt;documents, meetings, decisions&lt;/td&gt;
&lt;td&gt;the agent's own tool calls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Goes stale when&lt;/td&gt;
&lt;td&gt;the world changes&lt;/td&gt;
&lt;td&gt;
&lt;em&gt;the way you work&lt;/em&gt; changes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Wrong one costs&lt;/td&gt;
&lt;td&gt;a bad answer&lt;/td&gt;
&lt;td&gt;a bad run, repeated every time&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The last row is why I don't let the agent write skills directly: a wrong procedure fails the same way on every run.&lt;/p&gt;

&lt;h2&gt;
  
  
  The input: session logs
&lt;/h2&gt;

&lt;p&gt;Most harnesses can already dump a transcript. I normalized mine to one JSONL file per session: a &lt;code&gt;start&lt;/code&gt; event with a task label, one &lt;code&gt;tool&lt;/code&gt; event per call, and an &lt;code&gt;end&lt;/code&gt; event with whether the result was accepted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"session"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"s03"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"2026-10-27"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"task"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"release-notes"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"prompt"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Draft release notes for 0.26.1"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"git.log"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"range"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"v0.26.0..HEAD"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"wiki.search"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"q"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"changelog style"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="err"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"event"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"end"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"success"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;"Success" here just means a human accepted the output. It isn't a model grading itself, and it's the most valuable field in the log.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fixture in this post is a sample I made up&lt;/strong&gt;: 19 fictional sessions from a fictional team between Sep 24 and Nov 19, 2026. There are five recurring tasks plus two approved skills that already exist. I seeded it with the messy stuff real logs have: one run that retried &lt;code&gt;wiki.search&lt;/code&gt; twice, one failed release, an FAQ workflow that gets rejected a third of the time, and a weekly-metrics skill the team quietly stopped following.&lt;/p&gt;

&lt;h2&gt;
  
  
  The miner
&lt;/h2&gt;

&lt;p&gt;Three ideas, each a few lines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Count sequences per session, not per occurrence.&lt;/strong&gt; Every contiguous run of 4 to 8 tool calls is an n-gram. If a session loops the same four calls three times, that's still one session of evidence. Repetition inside a single run is usually a retry, not a habit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. One decision per task, longest passing sequence wins.&lt;/strong&gt; For each task label I keep the longest sequence that clears &lt;em&gt;all&lt;/em&gt; thresholds: at least 3 sessions, at least 75% accepted, last seen within 30 days. If nothing clears them, the script prints the best candidate and the exact reason it was rejected. That turns out to be as useful as the proposals.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Confidence is a Wilson lower bound, not a success rate.&lt;/strong&gt; 3 out of 3 is "100%" but it's thin evidence. The Wilson lower bound for 3/3 is 0.44 and for 4/4 it's 0.51, which matches how much I actually trust those numbers.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;
  Core of skill_miner.py (candidates, pick, stale/contradicted check)
  &lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pick&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cands&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_sessions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_success&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""One decision per task: the longest sequence that clears every threshold,
    or, if none does, the best-supported one and the reason it failed."""&lt;/span&gt;
    &lt;span class="n"&gt;groups&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cands&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cs&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;cs&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;judge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_sessions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_success&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ok&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"support"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cs&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"support"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"rate"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;judge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_sessions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;min_success&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;max_age&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"support"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_skills&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sessions&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Flag approved skills that recent sessions no longer follow."""&lt;/span&gt;
    &lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sessions&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;today&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;days&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;window&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;flags&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;skills&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="s2"&gt;"approved"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"task"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;matched&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sessions&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;matched&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;same_task&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;recent&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"task"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;hits&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;same_task&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;same_task&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;same_task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;variant&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;tuple&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;same_task&lt;/span&gt;
                                 &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;most_common&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"CONTRADICTED"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{len(hits)}/{len(same_task)} recent '{task}' runs match; "&lt;/span&gt;
                          &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{n} use: {' &amp;gt; '.join(variant)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;same_task&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;contains&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"steps"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;recent&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;when&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{last} ({(today - last).days} days ago)"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;last&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"never"&lt;/span&gt;
            &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"STALE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sk&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"last matched {when}, 0 runs in last {window} days"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The write path has three guards, and each one has a unit test:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;skills/&amp;lt;name&amp;gt;.md&lt;/code&gt; exists and is approved, the proposal goes to &lt;code&gt;proposals/&amp;lt;name&amp;gt;.update.md&lt;/code&gt; with &lt;code&gt;supersedes:&lt;/code&gt; in the frontmatter. The approved file is never opened for writing. The test compares its bytes before and after.&lt;/li&gt;
&lt;li&gt;If a proposal is already waiting for review, it's kept (&lt;code&gt;KEEP&lt;/code&gt;), so a human's half-finished edits never get clobbered by the next nightly run.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--dry-run&lt;/code&gt; prints the decisions and writes nothing.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 -m unittest test_skill_miner
...........
----------------------------------------------------------------------
Ran 11 tests in 0.012s

OK
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Running it on the sample fixture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 skill_miner.py fixture --today 2026-11-20
skill_miner: 19 sessions (2026-09-24..2026-11-19), 2 approved skills
PROPOSE  incident-postmortem  6 steps, 4 sessions, 100% ok, conf 0.51 -&amp;gt; proposals/incident-postmortem.md
PROPOSE  release-notes        5 steps, 3 sessions, 100% ok, conf 0.44 -&amp;gt; proposals/release-notes.md
PROPOSE  weekly-metrics       4 steps, 3 sessions, 100% ok, conf 0.44 -&amp;gt; proposals/weekly-metrics.update.md (approved weekly-metrics.md exists; not touched)
SKIP     customer-faq         success 67% &amp;lt; 75% (2/3 sessions)
SKIP     dependency-bump      best sequence seen in 2 sessions &amp;lt; 3
SKIP     onboarding-checklist best sequence seen in 1 session &amp;lt; 3
STALE        skills/onboarding-checklist.md: last matched 2026-09-24 (57 days ago), 0 runs in last 21 days
CONTRADICTED skills/weekly-metrics.md: 0/3 recent 'weekly-metrics' runs match; 3 use: metrics.query &amp;gt; dashboard.snapshot &amp;gt; draft.write &amp;gt; wiki.propose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsv8g1nw1y7ujhg3gflry.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsv8g1nw1y7ujhg3gflry.jpg" alt="Terminal output of skill_miner.py on the 19-session sample fixture: three proposals, three skips, one stale skill and one contradicted skill" width="800" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What a reviewer should take from that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;release-notes&lt;/strong&gt; has five sessions in the logs but only 3 count as evidence for the full five-step path. One run failed before proposing, and one retried &lt;code&gt;wiki.search&lt;/code&gt; twice, which breaks the contiguous match. The miner is strict about contiguity. I'm fine with that. A skill should describe the clean path, not the one with retries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;customer-faq&lt;/strong&gt; happens just as often but gets rejected a third of the time. Turning that into a skill would just teach the agent to fail faster. The rejection reason tells you the real fix is upstream (the ticket clustering step, probably), not in the playbook.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;weekly-metrics&lt;/strong&gt; is the interesting one. The approved skill says "export to a spreadsheet, update the wiki page in place." For the last three weeks every run has done something different: snapshot the dashboard, draft, and &lt;em&gt;propose&lt;/em&gt; the page for review. Nobody updated the skill. The miner proposes the new path as an &lt;code&gt;.update.md&lt;/code&gt; and flags the old one as &lt;code&gt;CONTRADICTED&lt;/code&gt; in the same run, so the reviewer sees both sides together.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;onboarding-checklist&lt;/strong&gt; hasn't been used in 57 days. Onboarding is seasonal, so that doesn't make it wrong, but it deserves a glance before the agent trusts it again.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A second run changes nothing: all three proposals come back as &lt;code&gt;KEEP&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a proposed skill page looks like
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjg8mks9uhey2ujy0133t.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjg8mks9uhey2ujy0133t.jpg" alt="Rendered proposals/release-notes.md: frontmatter with status proposed, owner human, evidence s03 s16 s19, confidence 0.44, then steps, a why section and a review checklist" width="800" height="258"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two choices here are deliberate. &lt;code&gt;owner: human&lt;/code&gt; means the agent is never the owner of its own procedures. And the "why" section cites session ids, which gives you the SIM idea in miniature: when someone asks in February why the agent always reads the changelog page first, the answer is three linked sessions, not a vibe.&lt;/p&gt;

&lt;p&gt;The review checklist at the bottom of every page ("nothing in the args is secret or one-off") matters more than it looks. Session args are where tokens, customer names and one-time paths leak into a doc that every future session will read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where skills live in a team knowledge base
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;skills/&lt;/code&gt; folder in a repo works for one developer. For a team, I'd put skill pages in the same place as the docs and decisions they depend on. A skill that says "read the changelog style page" should &lt;em&gt;link&lt;/em&gt; to that page, so a reviewer sees the procedure and its inputs side by side.&lt;/p&gt;

&lt;p&gt;In AFFiNE, this is how I would set it up. Skills become ordinary pages with properties (&lt;code&gt;status&lt;/code&gt;, &lt;code&gt;owner&lt;/code&gt;, &lt;code&gt;evidence&lt;/code&gt;, &lt;code&gt;confidence&lt;/code&gt;), in the same workspace as the docs and the whiteboard where the team sketches the process. The miner runs against a Markdown export and its proposals land in a review collection. Approving one would mean a person flips &lt;code&gt;status&lt;/code&gt; to approved. If you're choosing &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt;&lt;/strong&gt; for this, look for queryable page properties and backlinks, so "which approved skills cite this doc?" is one query when the doc changes.&lt;/p&gt;

&lt;p&gt;The review flow is the same one teams already use for SOPs, just with better evidence attached. If you've written &lt;a href="https://affine.pro/blog/process-documentation" rel="noopener noreferrer"&gt;process documentation&lt;/a&gt; before, the shape will feel familiar: trigger, steps, owner, review date. The difference is that the first draft comes from what actually happened, not from what someone remembers happening. And if you're comparing tools for the human side of that loop, this rundown of &lt;a href="https://affine.pro/blog/sop-management-software" rel="noopener noreferrer"&gt;SOP management software&lt;/a&gt; covers the approval and versioning features that matter.&lt;/p&gt;

&lt;p&gt;I'd also keep this layer somewhere you control. Procedural memory says more about your team than the facts do: which systems you touch, in what order, and where you cut corners. That's an argument for an &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion alternative&lt;/a&gt;&lt;/strong&gt; you can self-host, rather than one more SaaS that learns your workflows. It's also why I think the "agents write their own skills" trend belongs inside your &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt;&lt;/strong&gt;, not in a side database owned by whichever agent vendor you use this quarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;It needs a task label.&lt;/strong&gt; Grouping by &lt;code&gt;task&lt;/code&gt; makes proposals readable and keeps release notes from merging with postmortems. If your harness doesn't log intent, you'll need to cluster prompts first, and that's a harder problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contiguity is strict.&lt;/strong&gt; One retry and the run doesn't count. You could allow gaps (subsequence matching), but then the miner starts "finding" skills that are really just "every session reads a wiki page." I'd rather have strict and slow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It only sees tool names.&lt;/strong&gt; It can't tell that &lt;code&gt;wiki.search&lt;/code&gt; for "changelog style" and &lt;code&gt;wiki.search&lt;/code&gt; for "who owns sync" are different steps. The args shown on the proposal page are hints for the reviewer, not part of the match. A next version could bucket args. I'd still keep the human gate.&lt;/p&gt;

&lt;p&gt;If you want the bigger picture of how this fits with the fact side, here's a good primer on &lt;a href="https://affine.pro/blog/what-is-llm-wiki" rel="noopener noreferrer"&gt;what an LLM wiki is&lt;/a&gt; and how teams structure one.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; export a week of your own agent transcripts to JSONL, run the miner with &lt;code&gt;--dry-run&lt;/code&gt;, and read the SKIP lines before the PROPOSE lines. In my sample fixture, the skills it refused to write were just as informative as the ones it wrote.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>python</category>
      <category>ai</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Proactive AI Needs to Remember What You Decided. Give Your LLM Wiki a Reflection Pass.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Thu, 19 Nov 2026 06:12:36 +0000</pubDate>
      <link>https://dev.to/affineofficial/proactive-ai-needs-to-remember-what-you-decided-give-your-llm-wiki-a-reflection-pass-4mpg</link>
      <guid>https://dev.to/affineofficial/proactive-ai-needs-to-remember-what-you-decided-give-your-llm-wiki-a-reflection-pass-4mpg</guid>
      <description>&lt;p&gt;Two things kept showing up in my feed this week.&lt;/p&gt;

&lt;p&gt;The first was the "stop building your second brain from an empty folder" posts: Obsidian's CEO publishing his vault template, Karpathy's LLM Wiki pattern, and Claude-inside-Obsidian plugins with tens of thousands of stars. People are not short on capture tools anymore.&lt;/p&gt;

&lt;p&gt;The second was First Person Labs launching &lt;strong&gt;Second&lt;/strong&gt;, a personal model that runs on your Mac and hands agents your context over an API. In an a16z clip, CEO Ken Liu splits "proactive" AI in two. Reacting to an email is the easy part. The hard part is what he calls &lt;em&gt;reflective&lt;/em&gt;: "Months ago you said this, and..."&lt;/p&gt;

&lt;p&gt;That second half is the part almost every LLM wiki I've seen is missing. We have gotten good at helping agents &lt;strong&gt;write&lt;/strong&gt; notes and okay at helping them &lt;strong&gt;find&lt;/strong&gt; notes. We are still bad at having the knowledge base point out, unprompted, that a new fact undercuts something we decided in March.&lt;/p&gt;

&lt;p&gt;You don't need a new app watching everything you do to get a first version of that. One reply under the launch said roughly what I was thinking: the context part is what agents are missing, but I'm not sure I want one more app watching everything. So this post builds a small, boring, local version: decision notes with a few frontmatter fields, plus a ~100-line script that produces a reflection digest your agent reads at the start of a session.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr7tyxydgl8cmjyaytgxw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fr7tyxydgl8cmjyaytgxw.jpg" alt="The reflection loop: decision note, new notes, reflect.py digest, agent session, then revise or reaffirm" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why retrieval doesn't give you reflection
&lt;/h2&gt;

&lt;p&gt;Retrieval answers the question you asked. Reflection answers a question you forgot to ask.&lt;/p&gt;

&lt;p&gt;If I open a session and say "help me tune the sync queue", a decent RAG setup will pull the queue design doc. It probably won't bring up that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;we picked SQLite in March on the assumption of fewer than 50 writers per workspace,&lt;/li&gt;
&lt;li&gt;we promised to revisit that by September 1,&lt;/li&gt;
&lt;li&gt;and a perf note from October 28 says traces show write contention past ~70 editors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of those three facts is hidden. They sit in three files written months apart, and nothing connects them, because connecting them needs a notion of &lt;em&gt;time&lt;/em&gt; and &lt;em&gt;commitment&lt;/em&gt; that plain Markdown doesn't have.&lt;/p&gt;

&lt;p&gt;So add that, in the smallest form that still works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Make decisions a note type
&lt;/h2&gt;

&lt;p&gt;A decision note is just Markdown with five frontmatter fields:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
type: decision
decided: 2026-03-04
status: active            # active | superseded
revisit_by: 2026-09-01
watch: [sqlite, write contention, queue]
---
&lt;span class="gu"&gt;# Use SQLite for the sync queue
&lt;/span&gt;
Assumption: fewer than 50 writers per workspace.
Revisit if write contention shows up in traces.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnpag4s55jk0jibrf5xkb.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnpag4s55jk0jibrf5xkb.jpg" alt="Anatomy of a decision note: decided, status, revisit_by, watch terms" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The field that does the work is &lt;code&gt;watch&lt;/code&gt;. It's the list of words that, if they show up in a &lt;em&gt;newer&lt;/em&gt; note, mean past-you would want to hear about it. Write them when you decide, while you still remember what would change your mind. That's a very different question from "what tags describe this?"&lt;/p&gt;

&lt;p&gt;&lt;code&gt;revisit_by&lt;/code&gt; is the second half: a decision with no expiry date turns into folklore. And &lt;code&gt;status: superseded&lt;/code&gt; plus &lt;code&gt;superseded_by: &amp;lt;note-id&amp;gt;&lt;/code&gt; keeps the history readable instead of quietly editing the old note.&lt;/p&gt;

&lt;p&gt;Regular notes only need a &lt;code&gt;date:&lt;/code&gt; field. Todos follow one convention: &lt;code&gt;- [ ] task (owner: name, due: YYYY-MM-DD)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: The reflection pass
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;reflect.py&lt;/code&gt; reads the vault and never writes to it. It reports four kinds of items:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Kind&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;OVERDUE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;an active decision is past its &lt;code&gt;revisit_by&lt;/code&gt; date&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NEW-EVIDENCE&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a note dated &lt;em&gt;after&lt;/em&gt; the decision mentions one of its watch terms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;BROKEN&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;a superseded decision points at a note that doesn't exist&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;STALE-TODO&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;an open checkbox is past its due date&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Here's the core of it (stdlib only):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;reflect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;ids&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;decisions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"decision"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;out&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;decisions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;watch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"watch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;w&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"superseded"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;sup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"superseded_by"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;sup&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;sup&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;ids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"BROKEN"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"superseded_by '{sup}' does not exist"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"revisit_by"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;rv&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"OVERDUE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"revisit_by {rv} ({(today - rv).days} days ago)"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"meta"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"decision"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;
            &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;first_hit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;watch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;hits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"NEW-EVIDENCE"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{n['path']} ({n['date']}) mentions {', '.join(hits)}: \"{line[:70]}\""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;owner&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;due&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;TODO&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;due&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;today&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;topic&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;lower&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;out&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"STALE-TODO"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{task} (owner: {owner.strip()}, due {due})"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;out&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The rest is a 15-line frontmatter parser (a flat YAML subset: &lt;code&gt;key: value&lt;/code&gt; and &lt;code&gt;[a, b]&lt;/code&gt; lists), a word-boundary matcher, and &lt;code&gt;argparse&lt;/code&gt;. It exits non-zero on &lt;code&gt;OVERDUE&lt;/code&gt; or &lt;code&gt;BROKEN&lt;/code&gt;, so you can run it in CI or a pre-commit hook if your wiki lives in git.&lt;/p&gt;

&lt;p&gt;I ran it against a six-file test vault: three decisions, three dated notes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhg5pai4gmmvpgnc4quio.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhg5pai4gmmvpgnc4quio.jpg" alt="reflect.py output on the test vault: one overdue decision, two new-evidence hits, one broken supersede link, one stale todo" width="800" height="295"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Five items, and every one is something a person would want flagged before tuning that queue:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The SQLite decision is &lt;strong&gt;79 days overdue&lt;/strong&gt; for review.&lt;/li&gt;
&lt;li&gt;The October perf note mentions "write contention" and "queue". That's the exact evidence the March decision said would trigger a revisit.&lt;/li&gt;
&lt;li&gt;The "no vector DB yet" decision gets a hit too, but read the line: recall was 83%, above the 80% threshold. &lt;strong&gt;That evidence supports the decision.&lt;/strong&gt; The script doesn't judge, it surfaces. Reaffirming a decision with a dated link to the eval is just as useful as reversing one.&lt;/li&gt;
&lt;li&gt;A superseded decision points at a note nobody ever wrote, so the replacement decision only exists in someone's head.&lt;/li&gt;
&lt;li&gt;The load test that would settle the SQLite question was due November 7 and never happened.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;code&gt;--topic recall&lt;/code&gt; it narrows to just the retrieval decision. That's the mode you want when an agent is about to work in one area.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Wire it into the agent session
&lt;/h2&gt;

&lt;p&gt;The digest is short on purpose. Five lines cost far less context than re-reading the vault, and they're the five lines most likely to change what the agent does. In your &lt;code&gt;AGENTS.md&lt;/code&gt; (or whatever your harness reads first):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Before changing anything in an area
&lt;/span&gt;1. Run &lt;span class="sb"&gt;`python3 tools/reflect.py wiki --topic &amp;lt;area&amp;gt;`&lt;/span&gt;.
2. If any OVERDUE or NEW-EVIDENCE item touches the task, say so first
   and ask whether to revise or reaffirm the decision.
3. Never edit a decision note's body. To change course, write a new
   decision note and set the old one to status: superseded.
4. To reaffirm, append a dated line linking the evidence note and bump
   revisit_by. Do not delete history.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rule 3 matters more than it looks. If the agent can rewrite old decisions, you lose the "months ago you said this" property, the whole thing you were building. Superseding keeps the chain intact. The &lt;code&gt;BROKEN&lt;/code&gt; check makes sure the chain doesn't quietly end at a missing note.&lt;/p&gt;

&lt;p&gt;If you'd rather not hand-roll the loop, this is the kind of structure a good &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt;&lt;/strong&gt; setup should give you anyway: typed pages, properties you can query, and backlinks that work on dates as well as titles. We keep ours in a workspace that's an &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion alternative&lt;/a&gt;&lt;/strong&gt; and run the script on a Markdown export. The fields map cleanly onto page properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the script does badly (on purpose)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Keyword matching is crude.&lt;/strong&gt; "Queue" will hit unrelated notes in a big vault. This matters less than it sounds, because watch terms are chosen per decision and checked only against &lt;em&gt;newer&lt;/em&gt; notes. If it gets noisy, swap &lt;code&gt;first_hit&lt;/code&gt; for an embedding similarity check. Keep the time filter, though. That's what makes it reflection and not search.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It doesn't read meaning.&lt;/strong&gt; It can't tell confirming evidence from contradicting evidence. That's fine: the step it hands to a human or an agent is the cheap one (read two short lines and judge). The expensive step was noticing those two lines belonged together.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It trusts your dates.&lt;/strong&gt; No &lt;code&gt;date:&lt;/code&gt;, no reflection. That's the one bit of discipline the system asks for, and it's also what makes any &lt;strong&gt;&lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt;&lt;/strong&gt; useful a year later.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the reflective layer local
&lt;/h2&gt;

&lt;p&gt;The Second launch and the replies under it are a good preview of the next fight. Context is the valuable part, and whoever holds it holds the leverage. A decision log is about the most sensitive context a team has: what you bet on, what you assumed, what you never got around to testing.&lt;/p&gt;

&lt;p&gt;That's an argument for keeping this layer on your own machine or your own server, in files you can grep. We wrote more about treating &lt;a href="https://affine.pro/blog/context-management-is-the-infra-layer" rel="noopener noreferrer"&gt;context management as an infrastructure layer&lt;/a&gt; and not as an app feature. If you want the model side local as well, the trade-offs are in this guide to &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI&lt;/a&gt; for teams.&lt;/p&gt;

&lt;p&gt;And if you're still at the empty-folder stage everyone on X is warning about, start with decisions, not with capture. A &lt;a href="https://affine.pro/blog/second-brain" rel="noopener noreferrer"&gt;second brain&lt;/a&gt; that only stores what you read is a library. One that remembers what you committed to, and tells you when the world moved, is closer to the "proactive" thing everyone is pitching.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Try it:&lt;/em&gt; drop three of your real decisions into notes with &lt;code&gt;watch&lt;/code&gt; and &lt;code&gt;revisit_by&lt;/code&gt;, run the pass, and see what it finds. The six-file test vault turned up an overdue decision on the first run. A real one probably will too.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>python</category>
    </item>
    <item>
      <title>Your LLM Wiki Has a Write API Now. Put a Review Gate in Front of It.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Wed, 18 Nov 2026 06:16:35 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-has-a-write-api-now-put-a-review-gate-in-front-of-it-5354</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-has-a-write-api-now-put-a-review-gate-in-front-of-it-5354</guid>
      <description>&lt;p&gt;This week Obsidian's Steph Ango (kepano) shipped a new batch of &lt;a href="https://github.com/kepano/obsidian-skills" rel="noopener noreferrer"&gt;Obsidian Skills&lt;/a&gt;: instruction packs that teach an AI agent how to work inside a vault, from wikilinks and embeds to &lt;code&gt;.base&lt;/code&gt; files, JSON Canvas and the command line. The reaction on X was close to unanimous: "big unlock." Agents stop guessing your formats, and the LLM wiki becomes something an agent maintains instead of something you paste into a chat.&lt;/p&gt;

&lt;p&gt;The same weekend, a security researcher posted a short one: a $5k bounty for an auth bypass on an MCP server, where &lt;a href="https://x.com/mdp_sec/status/2121878367997714848" rel="noopener noreferrer"&gt;anyone could rewrite a creator's AI knowledge base, no login needed&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Put those two posts side by side and you get the real story of the week. Your second brain now has a write API. Skills make the writes fluent. MCP makes them reachable. Almost nobody has put a review step in front of them.&lt;/p&gt;

&lt;p&gt;This post is a practical design for that review step: what an agent should be allowed to write, how to route its edits through a gate, and a small script you can run in CI today. It assumes a Markdown or Git-backed LLM wiki, but the shape works for any knowledge base software that has an API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reads leak. Writes rot.
&lt;/h2&gt;

&lt;p&gt;Most of the security talk around AI knowledge bases is about reads: who can see what, and whether the agent leaks a private page into a public answer. That matters. But a bad write is worse in one specific way: &lt;strong&gt;it persists and it compounds&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A wrong answer in chat is gone when you close the tab. A wrong sentence written into the wiki gets retrieved tomorrow, summarized into three other pages next week, and cited by a teammate's agent next month. The LLM wiki pattern, where the model compiles raw sources into linked topic pages, is great precisely because the wiki &lt;em&gt;accumulates&lt;/em&gt;. Accumulation is also what makes a poisoned or careless write expensive.&lt;/p&gt;

&lt;p&gt;There are three ways a bad write gets in:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;No auth on the write path.&lt;/strong&gt; The bounty above. An MCP server exposed a write tool and didn't check who was calling it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prompt injection through a source.&lt;/strong&gt; The agent ingests a web page, a PDF or an email that contains instructions, and dutifully "files" them into a page that every future session will read.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An honest agent being wrong at scale.&lt;/strong&gt; No attacker at all. The agent merges two pages that sounded similar, rewrites a policy it misread, or "cleans up" a page a human owns.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Auth fixes the first one. Only a review gate handles all three.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give agents tiers, not a filesystem
&lt;/h2&gt;

&lt;p&gt;The fastest way to build an agent-maintained wiki is to hand the agent a &lt;code&gt;write_file&lt;/code&gt; tool scoped to the vault. It's also the riskiest, because every edit has the same power as every other edit.&lt;/p&gt;

&lt;p&gt;Split writes into three tiers instead:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsnu6is9ctx6rnormfd81.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsnu6is9ctx6rnormfd81.jpg" alt="Three write tiers for agents: append to inbox, propose a change on a branch, and direct edits reserved for low-risk generated pages" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tier&lt;/th&gt;
&lt;th&gt;What the agent can do&lt;/th&gt;
&lt;th&gt;Who approves&lt;/th&gt;
&lt;th&gt;Good for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Append&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Create new notes in &lt;code&gt;inbox/&lt;/code&gt; only&lt;/td&gt;
&lt;td&gt;Nobody, it's a staging area&lt;/td&gt;
&lt;td&gt;Captures, meeting summaries, "I found this"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Propose&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Edit anything in &lt;code&gt;wiki/&lt;/code&gt; on its own branch&lt;/td&gt;
&lt;td&gt;A human merges&lt;/td&gt;
&lt;td&gt;Topic pages, link maintenance, consolidation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Direct&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Overwrite a small set of generated files&lt;/td&gt;
&lt;td&gt;Nobody, but it's reversible&lt;/td&gt;
&lt;td&gt;Indexes, backlink lists, "recently changed"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then expose those tiers, not raw file access, as your MCP tools:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"append_note"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Create a new note under inbox/. Cannot modify existing files."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"body"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"sources"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"propose_edit"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Write a change to wiki/ on branch agent/&amp;lt;run-id&amp;gt;. Returns a review link. Never merges."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"new_content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"reason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"rebuild_index"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Regenerate wiki/_index.md from current pages. No other effect."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"input"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things fall out of this design for free. First, the server can enforce the tier no matter what the model was told, so a prompt injection that says "overwrite the pricing page" can at most open a proposal. Second, if someone does reach the server without auth, the blast radius is an inbox note or an unmerged branch instead of your whole knowledge base. Fix the auth anyway; AFFiNE's &lt;a href="https://affine.pro/blog/mcp-security-best-practices" rel="noopener noreferrer"&gt;MCP security checklist&lt;/a&gt; covers the server side. Tiers are what keep a missed check from becoming a rewrite.&lt;/p&gt;

&lt;h2&gt;
  
  
  The gate: four checks before a human sees the diff
&lt;/h2&gt;

&lt;p&gt;"A human merges" only works if the human isn't reviewing noise. So put a cheap automated gate in front of the review, and only show people the proposals that pass.&lt;/p&gt;

&lt;p&gt;The gate below runs on an agent's branch in a Git-backed wiki. It checks four things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Paths.&lt;/strong&gt; The agent may touch &lt;code&gt;wiki/&lt;/code&gt; and &lt;code&gt;inbox/&lt;/code&gt; only. No README, no config, no &lt;code&gt;AGENTS.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ownership.&lt;/strong&gt; A page with &lt;code&gt;owner: human&lt;/code&gt; in its frontmatter can't be edited by an agent. The agent can propose in &lt;code&gt;inbox/&lt;/code&gt; instead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Provenance.&lt;/strong&gt; Every &lt;code&gt;wiki/&lt;/code&gt; page needs a &lt;code&gt;sources:&lt;/code&gt; list, and every &lt;code&gt;raw/...&lt;/code&gt; source it cites must exist in the repo.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instruction smell.&lt;/strong&gt; Added text that reads like instructions to a model ("ignore previous instructions", a &lt;code&gt;curl&lt;/code&gt; command, a base64 blob) is rejected. Knowledge pages describe things; they don't tell the next reader what to do with their tools.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It also caps the size of a single change, because a 900-line "consolidation" is a rewrite, and rewrites deserve a person from the start.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/usr/bin/env python3&lt;/span&gt;
&lt;span class="s2"&gt;"""write_gate.py - check an agent's proposed wiki edits before a human merges them.
Usage: python write_gate.py &amp;lt;repo&amp;gt; &amp;lt;base-ref&amp;gt; &amp;lt;agent-branch&amp;gt;
"""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;

&lt;span class="no"&gt;ALLOWED&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"wiki/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"inbox/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;          &lt;span class="c1"&gt;# agent may touch these trees only&lt;/span&gt;
&lt;span class="no"&gt;MAX_LINES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;                        &lt;span class="c1"&gt;# big rewrites go to a human first&lt;/span&gt;
&lt;span class="no"&gt;SUSPICIOUS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"ignore (all |any )?(previous|prior) instructions|system prompt|"&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"curl\s+https?://|base64,|&amp;lt;script"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;git&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"git"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-C"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                          &lt;span class="n"&gt;capture_output&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stdout&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;frontmatter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"---\n(.*?)\n---\n"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;S&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;branch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;problems&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="n"&gt;changed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;git&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"diff"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"--numstat"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{base}...{branch}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;changed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;added&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;removed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;row&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"\t"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;added&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;removed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;ALLOWED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{path}: outside allowed paths"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;git&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"show"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{base}:{path}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CalledProcessError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;old&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;                                   &lt;span class="c1"&gt;# new file&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="s2"&gt;"owner: human"&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;frontmatter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;old&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{path}: human-owned page, agent may only propose in inbox/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;new&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;git&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"show"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{branch}:{path}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;fm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;frontmatter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"wiki/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="s2"&gt;"sources:"&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;fm&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{path}: no sources: in frontmatter"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findall&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"^\s*-\s*(raw/\S+)"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fm&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;M&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;git&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"cat-file"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"-e"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{branch}:{src}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="n"&gt;subprocess&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CalledProcessError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{path}: cites missing source {src}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;diff&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;git&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"diff"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{base}...{branch}"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"--"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;added_text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"\n"&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;splitlines&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                               &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"+"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;l&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"+++"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;SUSPICIOUS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;added_text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{path}: added text looks like instructions, not knowledge"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;MAX_LINES&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{total} lines changed (limit {MAX_LINES}); split the change"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"REJECT"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;problems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"OK {len(changed)} files, {total} lines: ready for human review"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;problems&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran it against a tiny test vault with two agent branches. The good branch adds one step to an onboarding page that already cites a meeting note. The bad branch does what a confused or injected agent might: edits a human-owned pricing page and slips in an instruction, adds a page that cites a source that doesn't exist, and touches the README.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffdn9m8g944ms0xuhpupr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffdn9m8g944ms0xuhpupr.jpg" alt="Terminal output of write_gate.py: the good branch passes with one line changed, the bad branch is rejected with five reasons" width="800" height="247"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 write_gate.py kb main agent/good
OK 1 files, 1 lines: ready for human review

$ python3 write_gate.py kb main agent/bad
REJECT README.md: outside allowed paths
REJECT wiki/new.md: cites missing source raw/missing.md
REJECT wiki/pricing.md: human-owned page, agent may only propose in inbox/
REJECT wiki/pricing.md: no sources: in frontmatter
REJECT wiki/pricing.md: added text looks like instructions, not knowledge
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To be clear about the limits: the instruction check is a tripwire, not a prompt-injection defense. A careful attacker will phrase around a regex. Its job is to catch the lazy cases and the honest accidents cheaply, so the human reviewer spends attention on meaning. The ownership and path checks are the ones doing real work, because they don't depend on what the text says.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wire it into the loop
&lt;/h2&gt;

&lt;p&gt;The full write path ends up looking like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmw6dveb7o2wwz9ell4w0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmw6dveb7o2wwz9ell4w0.jpg" alt="Agent writes to its own branch, the gate checks paths, ownership, sources and instruction smell, a human reviews the diff and merges, and rejected changes go back to the agent with reasons" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The agent calls &lt;code&gt;propose_edit&lt;/code&gt;. The server commits to &lt;code&gt;agent/&amp;lt;run-id&amp;gt;&lt;/code&gt;, never to &lt;code&gt;main&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;CI runs &lt;code&gt;write_gate.py&lt;/code&gt;. A rejection goes back to the agent as a tool result, with the reasons, so it can fix provenance or move the change to &lt;code&gt;inbox/&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;A passing branch becomes a review item. The reviewer sees a diff plus the &lt;code&gt;reason&lt;/code&gt; the agent gave, not a blob of rewritten text.&lt;/li&gt;
&lt;li&gt;Merge, or close. Either way the history keeps both the proposal and the decision.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A few habits make this sustainable rather than a new chore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Batch reviews.&lt;/strong&gt; Merge agent proposals once or twice a day, the way you'd triage an inbox. Most will be small link and wording fixes that take seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Let trust expand by path, not by mood.&lt;/strong&gt; If six weeks of proposals to &lt;code&gt;wiki/glossary/&lt;/code&gt; were all merged unchanged, move that folder to the direct tier. Keep policies, pricing, people and security pages in propose forever.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Mark ownership as you go.&lt;/strong&gt; You don't need to label the whole vault on day one. Add &lt;code&gt;owner: human&lt;/code&gt; the first time an agent edit to a page makes you wince.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log the caller.&lt;/strong&gt; Every write tool call should record which client, which session and which source document triggered it. When something odd lands in the wiki, "which ingest put this here?" should be a lookup, not an investigation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What to look for in the tool itself
&lt;/h2&gt;

&lt;p&gt;If you're choosing where your team's LLM wiki or second brain lives, rather than building it on a folder of Markdown, the write path is a good filter. Ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can I give an agent access to part of the workspace, not all of it?&lt;/li&gt;
&lt;li&gt;Is there page-level history I can diff and roll back, so an agent edit is reversible?&lt;/li&gt;
&lt;li&gt;Can I tell an agent edit from a human edit after the fact?&lt;/li&gt;
&lt;li&gt;Can I host it myself, so the server an agent writes to is one I control and can put behind my own auth?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last one is why we keep coming back to &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI&lt;/a&gt; for team knowledge. It's also why we build AFFiNE as an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion alternative&lt;/a&gt;: when agents are going to write into your &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt;, you should be able to read the code behind the write path and run it on your own server. Whatever you use, apply the same test to any &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; you're evaluating. Skills and MCP make agent writes easy. Make sure something in your stack makes them reviewable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Agents can now write to your wiki fluently (skills) and remotely (MCP). Treat that as a write API.&lt;/li&gt;
&lt;li&gt;Bad writes persist and compound, so they cost more than bad reads.&lt;/li&gt;
&lt;li&gt;Expose tiered tools (append, propose, direct) instead of raw file access, and enforce the tier on the server.&lt;/li&gt;
&lt;li&gt;Put a cheap gate in front of human review: paths, ownership, provenance, instruction smell, change size.&lt;/li&gt;
&lt;li&gt;Widen agent permissions folder by folder, based on what you actually merged.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've built a review step for agent writes in your own vault or team wiki, I'd like to hear how you scoped it, especially what you let agents edit directly.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>security</category>
    </item>
    <item>
      <title>Mem Is Shutting Down. Your AI Second Brain Exports Notes, Not What the AI Knew</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Tue, 17 Nov 2026 06:23:48 +0000</pubDate>
      <link>https://dev.to/affineofficial/mem-is-shutting-down-your-ai-second-brain-exports-notes-not-what-the-ai-knew-17ln</link>
      <guid>https://dev.to/affineofficial/mem-is-shutting-down-your-ai-second-brain-exports-notes-not-what-the-ai-knew-17ln</guid>
      <description>&lt;p&gt;Mem announced on November 16 that it is shutting down. The dates are short: notes go &lt;strong&gt;read-only on December 18, 2026&lt;/strong&gt;, and the service is &lt;strong&gt;gone on January 15, 2027&lt;/strong&gt;. Mem's own &lt;a href="https://get.mem.ai/blog/mem-is-shutting-down" rel="noopener noreferrer"&gt;shutdown note&lt;/a&gt; and &lt;a href="https://help.mem.ai/migration" rel="noopener noreferrer"&gt;migration guide&lt;/a&gt; are clear and honest, and the export tooling looks better than most shutdowns get.&lt;/p&gt;

&lt;p&gt;The reaction on X was quick and mostly the same line: &lt;em&gt;every AI second brain that lives on someone else's server has a shutdown date; Markdown files on your own disk don't.&lt;/em&gt; That's true, and it's also only half the story. If you used Mem the way it was sold, as "the notes app that thinks alongside you," most of the value was never in the files. It was in what the app worked out &lt;em&gt;from&lt;/em&gt; the files.&lt;/p&gt;

&lt;p&gt;This post is for anyone moving off Mem this month, and for anyone building an LLM wiki or AI second brain who would like their own exit to be boring. It covers what the export actually contains, a script to check it before you trust it, and a short test for choosing where the notes go next.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you actually get in the ZIP
&lt;/h2&gt;

&lt;p&gt;Per Mem's &lt;a href="https://help.mem.ai/migration/save-a-copy" rel="noopener noreferrer"&gt;save-a-copy guide&lt;/a&gt;, the Markdown export (Settings → Exports → Start new export → My Computer) unpacks to:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Path&lt;/th&gt;
&lt;th&gt;Contents&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;notes/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;One Markdown file per exported note&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;collections/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;One index per collection, linking to its notes. A note in two collections shows up in both indexes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;attachments/&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Files your notes reference, linked relatively&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;export-report.md&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;If present, the items Mem couldn't include. Read this first&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two details from the docs are easy to miss. Meeting &lt;strong&gt;transcripts&lt;/strong&gt; are included by default, but &lt;strong&gt;audio recordings&lt;/strong&gt; are a separate option you must select before starting the export. And if you keep editing in Mem after your first export, you need to export again; the ZIP is a snapshot, not a sync.&lt;/p&gt;

&lt;h2&gt;
  
  
  An AI second brain is three layers, and exports carry one and a half
&lt;/h2&gt;

&lt;p&gt;It helps to be precise about what "my second brain" means in an AI notes tool. There are three layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sources&lt;/strong&gt;: the notes, files, and transcripts you put in.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structure&lt;/strong&gt;: links between notes, collections, tags. Some of it you made, some the app suggested.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Derived&lt;/strong&gt;: the search index, embeddings, "resurface this when it's relevant" features, chat over your notes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizvx18c64s95xlh3qilq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fizvx18c64s95xlh3qilq.jpg" alt="Sources, structure, and derived layers: a Markdown export covers sources and part of structure" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Markdown export carries layer 1 well. It carries layer 2 partly: links survive if they are written as relative links, and collections survive as index files rather than as properties of the note. Layer 3 does not survive in any app-independent form, because it's an index, not data. That's fine, &lt;em&gt;as long as you can rebuild it from layers 1 and 2&lt;/em&gt;. The real migration job is making sure you can.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Export now, not on December 17
&lt;/h2&gt;

&lt;p&gt;Read-only on December 18 still lets you export, so this isn't a panic. But a large library takes time to prepare, Mem asks you to let one export finish before starting another, and you want time to find out what's missing while support is still answering email. Export once now, verify it, then do a final export after your last edit.&lt;/p&gt;

&lt;p&gt;Keep the original ZIP untouched. Do everything below on a copy of the extracted folder.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Verify the export with a script, not by scrolling
&lt;/h2&gt;

&lt;p&gt;Mem's own advice is to open a note you know well, follow a link, and open an attachment. Do that. Then run something that checks &lt;em&gt;every&lt;/em&gt; note, because broken relative links and orphaned attachments don't show up when you spot-check five favourites.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#!/usr/bin/env python3&lt;/span&gt;
&lt;span class="s2"&gt;"""Sanity-check an extracted Mem Markdown export before you trust it.
Usage: python3 check_export.py /path/to/extracted-export
"""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sys&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;collections&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;defaultdict&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;unquote&lt;/span&gt;

&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;argv&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;notes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"notes"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rglob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"*.md"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;indexes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"collections"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rglob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"*.md"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;index_set&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;indexes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Markdown links and images: [text](href) / ![alt](href "title")&lt;/span&gt;
&lt;span class="no"&gt;LINK&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s1"&gt;'!?\[[^\]]*\]\(&amp;lt;?([^)\s&amp;gt;]+)&amp;gt;?(?:\s+"[^"]*")?\)'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="no"&gt;SCHEME&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;compile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="s2"&gt;"^[a-z][a-z0-9+.-]*:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;re&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;I&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;local_links&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;md_file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;md_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"replace"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;m&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="no"&gt;LINK&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;finditer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;unquote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;m&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;group&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"#"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="no"&gt;SCHEME&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;md_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parent&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;broken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;membership&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;defaultdict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# note path -&amp;gt; collection names&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;indexes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;local_links&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;broken&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;relative_to&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;index_set&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;suffix&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;".md"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;membership&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stem&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;no_collection&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;membership&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="n"&gt;multi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;membership&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"notes: {len(notes)}   collection indexes: {len(indexes)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"broken local links: {len(broken)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;broken&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"   {src} -&amp;gt; {href}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"notes in no collection: {len(no_collection)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"notes in 2+ collections: {len(multi)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="s2"&gt;"export-report.md"&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"export-report.md:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"PRESENT, read it"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;report&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;exists&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"not present"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What you want to see: a note count close to what Mem showed you, zero broken links, and either no &lt;code&gt;export-report.md&lt;/code&gt; or one whose items you have consciously accepted. If your export uses &lt;code&gt;[[wikilinks]]&lt;/code&gt; instead of standard Markdown links, extend the regex before trusting the zero.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Move implicit structure into the files
&lt;/h2&gt;

&lt;p&gt;Collections are the part most likely to get lost in the next import. Some apps turn index files into pages, some into tags, and some ignore them. The safest move is to write each note's collection membership into the note itself, as front matter, so any tool that reads YAML keeps it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="c1"&gt;# Append to check_export.py. Run on a COPY of the export.&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cols&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;membership&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startswith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"---\n"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"skip (already has front matter): {note.relative_to(root)}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;continue&lt;/span&gt;
    &lt;span class="c1"&gt;# A JSON list is valid YAML flow syntax and safely quotes odd names.&lt;/span&gt;
    &lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"---\ncollections: {json.dumps(sorted(cols))}\n---\n\n"&lt;/span&gt;
    &lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;header&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the structure travels with the note instead of living in a side file that the next importer may or may not understand. The same principle applies to anything you rely on: if it matters, it should be &lt;em&gt;in&lt;/em&gt; the Markdown, not inferred from where the file sits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Treat the AI layer as disposable, then prove it
&lt;/h2&gt;

&lt;p&gt;This is the design lesson worth keeping after Mem is gone. In a healthy AI second brain, the files are the source of truth and everything the AI knows is a cache that can be thrown away and rebuilt:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8hnd0qjrhd52ta7dfytr.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8hnd0qjrhd52ta7dfytr.jpg" alt="Markdown files are the source of truth; the index and embeddings are disposable and rebuildable" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Concretely, once your notes land somewhere new:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rebuild search and embeddings from the folder&lt;/strong&gt;, not from anything exported out of the old app's AI features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Spot-check with questions you asked the old tool.&lt;/strong&gt; If chat over your notes used to answer "what did we decide about the pricing page in March?", ask the same question in the new setup. Failures here usually point at a missing transcript or attachment, not at the model.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't migrate AI-generated summaries as if they were notes.&lt;/strong&gt; If you saved them, keep them tagged as generated so a future agent doesn't treat yesterday's summary as a primary source.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've been following the LLM wiki pattern that has been all over X lately (raw sources, a wiki the agent compiles, and a schema it follows), you already have this split. The raw layer is the part you protect; the compiled wiki can be regenerated. We wrote up &lt;a href="https://affine.pro/blog/build-ai-second-brain" rel="noopener noreferrer"&gt;how to build an AI second brain&lt;/a&gt; around the same idea.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the next home: run the exit drill first
&lt;/h2&gt;

&lt;p&gt;The most useful thing to take from this week isn't "pick a better vendor." Every vendor can stop. It's "pick a home whose exit you've already tested." Before you commit years of notes to anything new, run this drill once:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F65ftqg68ovi1hip7txbn.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F65ftqg68ovi1hip7txbn.jpg" alt="Exit drill: export runs without support, links and files resolve, structure lives in the files, index rebuilds from files" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The export runs without a support ticket&lt;/strong&gt;, and produces open formats (Markdown, plain files) rather than a proprietary bundle.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Links and attachments resolve&lt;/strong&gt; in the exported folder when opened with a plain editor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structure lives in the files&lt;/strong&gt; (front matter, tags, links), not only in the app's database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The AI index rebuilds from the files&lt;/strong&gt; in a fresh install, with no access to the old account.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;There is a path that doesn't depend on the company at all&lt;/strong&gt;: the code is open, or you can self-host it, or both.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That last point is why many people moving off Mem are looking at open, local-first tools rather than another hosted AI notes app. Disclosure: I work on AFFiNE, which is in that category: an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion alternative&lt;/a&gt; that stores data locally first and can be self-hosted. Whatever you choose, apply the same drill. A &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; choice is a multi-year commitment, and "open source" only helps if you've actually tried running it without the vendor.&lt;/p&gt;

&lt;p&gt;For teams, the AI part deserves the same scrutiny as the storage. If the &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt; you pick sends every note to a model you don't control, the files may be portable but the thinking isn't. Running the model side as &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI&lt;/a&gt; gives you the same exit property for the derived layer that Markdown gives you for the sources.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Export from Mem now, verify with a script, and export again after your last edit. Tick the audio option if recordings matter.&lt;/li&gt;
&lt;li&gt;Write collection membership into front matter before importing anywhere.&lt;/li&gt;
&lt;li&gt;Rebuild the AI layer from your files; don't try to carry it.&lt;/li&gt;
&lt;li&gt;Before trusting the next tool, run its exit drill on day one, not on its shutdown day.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mem's team handled this better than most. The next shutdown might not come with five weeks of notice, so it's worth doing the drill while it's still optional.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>markdown</category>
    </item>
    <item>
      <title>Your LLM Wiki Compiles Away Your Permissions. Design for It Before the Team Uses It.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Mon, 16 Nov 2026 06:21:10 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-compiles-away-your-permissions-design-for-it-before-the-team-uses-it-20mi</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-compiles-away-your-permissions-design-for-it-before-the-team-uses-it-20mi</guid>
      <description>&lt;p&gt;A short thread on X last week put the LLM wiki vs. RAG debate better than most long posts do: &lt;em&gt;a wiki compiles knowledge when a source arrives; RAG retrieves at question time, so per-user permissions and citations stay intact.&lt;/em&gt; That line matters most to people taking the trending personal second-brain setups to their team.&lt;/p&gt;

&lt;p&gt;And right now a lot of people are. Karpathy's LLM Wiki idea file, Garry Tan's open-sourced gbrain, and the Claude Code + Obsidian vault repos are being cloned by the thousand. They work well for one person, because one person has one permission level: everything. The trouble starts when the same pattern is pointed at a shared drive with HR folders, customer escalations, and board notes in it.&lt;/p&gt;

&lt;p&gt;This post is about that one gap. It's not a case against LLM wikis. I think they are the right shape for a lot of team knowledge. But the compile step quietly erases your access model unless you design for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why compiling flattens permissions
&lt;/h2&gt;

&lt;p&gt;In the LLM wiki pattern, raw sources stay immutable and an agent writes a linked set of markdown pages that summarize, cross-reference, and update as new sources land. You get answers that are already synthesized, instead of re-deriving them from chunks on every query.&lt;/p&gt;

&lt;p&gt;Now picture the page the agent writes for a customer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a public case study (everyone can read it)&lt;/li&gt;
&lt;li&gt;a sales call note (sales team only)&lt;/li&gt;
&lt;li&gt;a legal escalation about a contract dispute (legal and two execs)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The agent does what it was asked and writes a good page: &lt;em&gt;"Acme: renewal at risk; dispute over SLA credits; legal involved since October."&lt;/em&gt; That page now holds facts from the most restricted source, and it sits in a folder whose permissions were set for the least restricted one.&lt;/p&gt;

&lt;p&gt;Citations don't fix this. Even if the page links back to a source the reader can't open, the reader has already read the sentence. &lt;strong&gt;A derived fact inherits the sensitivity of its most sensitive input&lt;/strong&gt;, and a compiled page is made of derived facts.&lt;/p&gt;

&lt;p&gt;RAG with permission-aware retrieval doesn't have this failure mode, because it filters source passages per user &lt;em&gt;before&lt;/em&gt; generation. What it gives up is the compounding synthesis that makes a wiki useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2jpv3vwd8c10ccdm5r5i.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2jpv3vwd8c10ccdm5r5i.jpg" alt="Compile-time wiki versus query-time retrieval: where the access check happens" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You don't have to pick one. You do have to decide, page by page, where the access check happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule 1: a page's audience is the intersection of its sources' audiences
&lt;/h2&gt;

&lt;p&gt;The simplest rule that holds up: the agent may only write a page into a scope that every source used for that page is visible to. In set terms, the page's allowed readers are the intersection of each source's allowed readers.&lt;/p&gt;

&lt;p&gt;Make it machine-checkable. Put the sources in frontmatter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Acme account summary"&lt;/span&gt;
&lt;span class="na"&gt;scope&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sales&lt;/span&gt;
&lt;span class="na"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;case-study-acme-2025&lt;/span&gt;
    &lt;span class="na"&gt;acl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;everyone&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;call-note-2026-10-02&lt;/span&gt;
    &lt;span class="na"&gt;acl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;sales&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;legal-escalation-114&lt;/span&gt;
    &lt;span class="na"&gt;acl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;legal&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;exec&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="nn"&gt;---
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then refuse the write when the declared scope is broader than what the sources allow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="no"&gt;EVERYONE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"everyone"&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;allowed_readers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;"""Intersect source ACLs. 'everyone' expands to all known groups."""&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;sources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;acl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="no"&gt;EVERYONE&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"acl"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kt"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"acl"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;=&lt;/span&gt; &lt;span class="n"&gt;acl&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;check_page&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;readers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;allowed_readers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"sources"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;groups&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"scope"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;readers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;PermissionError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{page['title']}: scope '{page['scope']}' exceeds sources; "&lt;/span&gt;
            &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"allowed: {sorted(readers) or 'nobody'}"&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;groups&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"sales"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"legal"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"exec"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"eng"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"people"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;# The Acme page above fails: sales ∩ {legal, exec} is empty.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When the intersection comes back empty, that's useful information. It means the page shouldn't exist as one page. Split it: a sales-scoped summary that leaves out the escalation, and a legal-scoped page that adds it. Agents are good at writing two versions. They are bad at guessing which version you meant.&lt;/p&gt;

&lt;p&gt;Run this check in the agent's write path, not as a nightly lint. By the time a nightly job runs, the page has already been indexed, quoted, and pasted into Slack.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy0d6ojl545x86mr9wkx1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fy0d6ojl545x86mr9wkx1.jpg" alt="Page access is the intersection of every source it was built from" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule 2: provenance is a field, not a footnote
&lt;/h2&gt;

&lt;p&gt;Most LLM wiki setups ask the agent to cite sources. Few treat those citations as data the system acts on. Treat them as data, because permissions change after the page is written:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;someone is moved off the deal team&lt;/li&gt;
&lt;li&gt;a doc is reclassified after an incident&lt;/li&gt;
&lt;li&gt;a source is deleted for legal reasons&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of those should invalidate every page built from it. If provenance lives in frontmatter, finding those pages is a query:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pages_to_recompile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;changed_source_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;changed_source_id&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"sources"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Recompile or quarantine those pages, then run Rule 1 again. Without this, your wiki slowly drifts back to the access model of the day each page was written. Stale facts are annoying. Stale permissions are a security incident.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule 3: route by sensitivity, not by convenience
&lt;/h2&gt;

&lt;p&gt;Not everything needs to be compiled. A practical split:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Knowledge&lt;/th&gt;
&lt;th&gt;Where it should live&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Glossary, architecture decisions, runbooks, onboarding&lt;/td&gt;
&lt;td&gt;Compiled wiki, broad scope&lt;/td&gt;
&lt;td&gt;Stable, low sensitivity, gains the most from synthesis&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Team-specific playbooks, project status&lt;/td&gt;
&lt;td&gt;Compiled wiki, per-team scope&lt;/td&gt;
&lt;td&gt;Moderate sensitivity; one audience per page&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HR cases, deal terms, legal, incident forensics&lt;/td&gt;
&lt;td&gt;Query-time retrieval with per-user filtering&lt;/td&gt;
&lt;td&gt;High sensitivity; access changes often&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anything with mixed audiences you can't split cleanly&lt;/td&gt;
&lt;td&gt;Don't compile it&lt;/td&gt;
&lt;td&gt;The intersection is empty; that is the answer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The agent can still &lt;em&gt;answer&lt;/em&gt; questions about the bottom rows. It just answers from sources it fetched for that user at that moment, not from a page it wrote for everyone last Tuesday.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rule 4: test it like an attacker with a low-privilege account
&lt;/h2&gt;

&lt;p&gt;Before an internal AI knowledge assistant goes live, run some version of this test:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a test account with the lowest real permission level, like a new contractor.&lt;/li&gt;
&lt;li&gt;Write ten questions whose answers exist &lt;em&gt;only&lt;/em&gt; in restricted sources: a salary band, a deal discount, an open incident.&lt;/li&gt;
&lt;li&gt;Ask them directly, then indirectly ("summarize everything about Acme", "what changed in the comp policy?").&lt;/li&gt;
&lt;li&gt;Check four places, not one: the answer, any snippets or previews, the citations list, and any saved output the assistant wrote back to the workspace.&lt;/li&gt;
&lt;li&gt;Repeat after every change to the compile prompt or the folder structure.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A pass is not "the agent refused." A pass is "the restricted fact appears nowhere the test account can see."&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fssllj3zv4qgmy9qcxtwl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fssllj3zv4qgmy9qcxtwl.jpg" alt="A four-surface leak test: answer, snippets, citations, saved outputs" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the tooling choice actually matters
&lt;/h2&gt;

&lt;p&gt;None of these rules depend on a specific product. But two properties make them much easier.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permissions should live on the documents themselves&lt;/strong&gt;, in the same system the agent reads from and writes to. If the agent compiles from a file dump and writes to a folder of markdown, you are rebuilding an access model by hand on top of a filesystem that never had one. A workspace-based &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;knowledge base software&lt;/a&gt; setup, where docs, roles, and sharing settings sit together, gives Rule 1 something real to intersect. AFFiNE's write-up on &lt;a href="https://affine.pro/blog/ai-workspace-permissions" rel="noopener noreferrer"&gt;AI workspace permissions&lt;/a&gt; walks through the role and data-access checks worth running, and it lines up closely with the leak test above.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The compile step should run where your data already lives.&lt;/strong&gt; Compiling means the model reads &lt;em&gt;everything&lt;/em&gt;, including the restricted sources, in order to decide what not to write. If that model is a third-party API, your most sensitive documents are leaving the building on every compile, no matter how careful the output is. Running the compile on &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI&lt;/a&gt; infrastructure keeps that step inside your own boundary.&lt;/p&gt;

&lt;p&gt;This is the main reason I'd pick an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base software&lt;/a&gt; stack you can self-host for team use, over a personal vault plus a cloud agent. Something in the &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;open source Notion alternative&lt;/a&gt; category gives you docs, permissions, and a deployment you control in one place, so the agent's reads and writes stay inside the same access model your people already use.&lt;/p&gt;

&lt;h2&gt;
  
  
  A checklist before you point your second-brain repo at the team drive
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Every compiled page lists its sources and their ACLs in frontmatter.&lt;/li&gt;
&lt;li&gt;[ ] The write path rejects pages whose scope is broader than the intersection of their sources.&lt;/li&gt;
&lt;li&gt;[ ] Changes to a source's permissions trigger recompile or quarantine of dependent pages.&lt;/li&gt;
&lt;li&gt;[ ] High-sensitivity domains are answered at query time with per-user filtering, not compiled.&lt;/li&gt;
&lt;li&gt;[ ] The compile model runs inside your own infrastructure, or never sees restricted sources.&lt;/li&gt;
&lt;li&gt;[ ] A low-privilege leak test runs before launch and after every compile-prompt change.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The LLM wiki pattern took off because it treats knowledge as something you build once and keep current, not something you rediscover on every query. That is still the right instinct for teams. Just remember that when you compile the knowledge, you compile the access decisions too, so make the agent write them down.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
      <category>security</category>
    </item>
    <item>
      <title>Your LLM Wiki Already Has the Answer. The Agent Still Won't Look.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Fri, 13 Nov 2026 06:18:03 +0000</pubDate>
      <link>https://dev.to/affineofficial/your-llm-wiki-already-has-the-answer-the-agent-still-wont-look-b04</link>
      <guid>https://dev.to/affineofficial/your-llm-wiki-already-has-the-answer-the-agent-still-wont-look-b04</guid>
      <description>&lt;p&gt;This week's X feed is still circulating the same clone-and-go lists: Karpathy's LLM Wiki, Garry Tan's GBrain, a pile of Claude-plus-Obsidian hooks. The pitch is a wiki the model writes and keeps current.&lt;/p&gt;

&lt;p&gt;A quieter complaint is more useful. On November 11, one builder wrote that their Claude already has a full second brain — a wiki it writes and updates itself — and they still end up typing "check the brain, you already have the answer." The model replies "you're right," then finds it.&lt;/p&gt;

&lt;p&gt;That is not a memory problem. That is a retrieval problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  The wiki is being written. It is not being consulted.
&lt;/h2&gt;

&lt;p&gt;Most of the hooks optimize ingest. Raw sources land in a &lt;code&gt;_raw/&lt;/code&gt; folder. The model files pages, adds links, and maintains the graph. That is useful. It is also the easy half.&lt;/p&gt;

&lt;p&gt;The hard half is the first tool call of a new session. The model would rather answer from the prompt, from training, or from a fresh web search than open the page it wrote last Tuesday. A human reminder works once. It does not scale to a team, or to a morning of twenty questions.&lt;/p&gt;

&lt;p&gt;If the default path is "generate, then maybe look," you do not have a second brain. You have a folder you nag.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsj71eawae3u544785hod.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsj71eawae3u544785hod.jpg" alt="An agent answers from memory while the wiki it already wrote sits unopened" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the model skips a wiki it wrote
&lt;/h2&gt;

&lt;p&gt;Three setup mistakes show up again and again:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The schema is a novel.&lt;/strong&gt; Long &lt;code&gt;CLAUDE.md&lt;/code&gt; files get skimmed. The "check the wiki first" line sits on page four, after twenty style rules. The same post above said the current fix was writing the rules shorter. That is the right instinct.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consult is optional.&lt;/strong&gt; Ingest is a slash command. Answering is freeform. Nothing in the tool loop forces a wiki search before a claim.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No citation, no consequence.&lt;/strong&gt; If the model can reply without naming a page, it will. "You're right, I already had that" is the tell.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Make consult the first step, not a reminder
&lt;/h2&gt;

&lt;p&gt;Put a short, hard gate at the top of the schema file — &lt;code&gt;AGENTS.md&lt;/code&gt;, &lt;code&gt;CLAUDE.md&lt;/code&gt;, or the equivalent. Keep it short enough that it survives a skim:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before answering a factual question, search the wiki.&lt;/li&gt;
&lt;li&gt;Name the page you used, or say the page is missing.&lt;/li&gt;
&lt;li&gt;If the page is missing, say so. Do not invent a helpful answer from memory.&lt;/li&gt;
&lt;li&gt;Do not write a new page unless the task is an approved ingest.&lt;/li&gt;
&lt;li&gt;If two pages disagree, prefer the source document and flag the conflict.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then enforce it in the loop, not only in prose:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The first tool call on a factual question is a wiki search, not a web search and not a generate.&lt;/li&gt;
&lt;li&gt;The answer template starts with a citation: page title, or "not in the wiki."&lt;/li&gt;
&lt;li&gt;A weekly lint: sample ten questions you already know are in the wiki. Count how many answers cited the page without a human nudge. If you had to type "check the brain," the gate failed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpf7t5srcucxlowada8c.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjpf7t5srcucxlowada8c.jpg" alt="Search the wiki first, cite the page or say it is missing, then answer" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A 30-minute consult check
&lt;/h2&gt;

&lt;p&gt;Pick five questions whose answers already live in the wiki.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqnt3nogrvvibt126fpj2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fqnt3nogrvvibt126fpj2.jpg" alt="A 30-minute consult check: ask five known questions, score the citations, shorten the schema, and repeat in every client" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start a fresh session. Ask the five questions with no reminder to look anything up.&lt;/li&gt;
&lt;li&gt;Score each answer: cited the right page, cited a wrong page, or answered from memory with no citation.&lt;/li&gt;
&lt;li&gt;If fewer than five cited the right page, shorten the schema and put the consult rule first.&lt;/li&gt;
&lt;li&gt;Repeat the same five questions in Claude Code, Codex, and any other client pointed at the same wiki. A rule that lives in only one vendor's memory is not a rule.&lt;/li&gt;
&lt;li&gt;Keep a one-line log: date, client, how many of the five cited a page without a nudge. If the number drops, fix the gate, not the model.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Where this belongs
&lt;/h2&gt;

&lt;p&gt;A weekend vault hook can store the pages. A team needs &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;Knowledge base Software&lt;/a&gt; where the same search is the default first step for every client.&lt;/p&gt;

&lt;p&gt;If agents can search and cite only the spaces you allow, you have &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base Software&lt;/a&gt;. If you can run the workspace yourself — the usual reason people look for an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;Open source Notion&lt;/a&gt; alternative — you also get to decide that the consult path does not leave the building.&lt;/p&gt;

&lt;p&gt;AFFiNE's write-up on an &lt;a href="https://affine.pro/blog/llm-wiki" rel="noopener noreferrer"&gt;LLM wiki for teams&lt;/a&gt; treats this as a product decision, not a prompt trick: the workspace is the source of truth, agents connect over MCP, and a compiled wiki holds synthesized topics. Test with real questions, and fix the documents when the model misses, not only the prompt. The companion guide to &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI for teams&lt;/a&gt; is useful because the knowledge workspace is a separate layer from the model server and the chat UI. You can point every tool at the same searchable space without retraining a model, and you can swap the model without losing the consult path.&lt;/p&gt;

&lt;p&gt;AFFiNE, which I work on, is one option for that workspace layer: open-source, local-first docs, whiteboards, and databases, with optional BYOK AI and a workspace MCP server that is read-only by default. It is a weak fit if you only need a static handbook, or if you need agents to write into the workspace on today's stable release.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;p&gt;A wiki the model maintains is not a second brain until the model looks at it before it answers.&lt;/p&gt;

&lt;p&gt;Stop typing "check the brain." Put the consult step first, make a citation mandatory, and measure whether the agent finds the page without you.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>ai</category>
      <category>opensource</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Give Your Agents Their Own Wiki. Keep Your Vault to Yourself.</title>
      <dc:creator>Vincent</dc:creator>
      <pubDate>Thu, 12 Nov 2026 06:24:17 +0000</pubDate>
      <link>https://dev.to/affineofficial/give-your-agents-their-own-wiki-keep-your-vault-to-yourself-5644</link>
      <guid>https://dev.to/affineofficial/give-your-agents-their-own-wiki-keep-your-vault-to-yourself-5644</guid>
      <description>&lt;p&gt;This week's X feed is still selling the same shortcut: clone a repo, point Claude at your Obsidian vault, and let it "write the notes itself." Karpathy's LLM Wiki and Garry Tan's GBrain are on every list. The pitch is one brain, shared with the model.&lt;/p&gt;

&lt;p&gt;A quieter point landed on November 11. Steph Ango (kepano), who builds Obsidian, said the major new thing in his setup was not a fancier personal vault. It was a separate LLM wiki vault for agents to use.&lt;/p&gt;

&lt;p&gt;That split is the product decision most of the repo lists skip.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug is not missing memory. It is one room for everything.
&lt;/h2&gt;

&lt;p&gt;A personal vault is a working surface. It holds journal fragments, draft rants, compensation notes, unreleased plans, and half-true scratch. That mess is useful to you because you know what is private, stale, or a joke.&lt;/p&gt;

&lt;p&gt;An agent does not. If you point it at the whole vault, two things happen at once:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It can read things it should never see, then repeat them in a stand-up, a pull request, or another teammate's session.&lt;/li&gt;
&lt;li&gt;It writes back. The week's popular hooks advertise this as the feature: the model files sources, links pages, and maintains the wiki. A result circulating from Anthropic's agent-memory work showed the failure mode on a shared table: several agents wrote contract terms at the same time and overwrote each other. A brief built from that wiki kept only 41 of 57 graded facts. The fix was not a bigger model. It was one page per contract, one writer per page, and quoted terms.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Shared memory is useful. Unscoped shared memory is how one bad assumption, or one private sentence, travels farther than you intended.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb9c4jre6j1kw1b7101xf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fb9c4jre6j1kw1b7101xf.jpg" alt="An agent pointed at a whole vault can both leak a private page and overwrite a shared one" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Two vaults, three permissions
&lt;/h2&gt;

&lt;p&gt;Treat the agent wiki as a room, not as a synonym for "everything I have written."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vault A — Human working surface.&lt;/strong&gt;&lt;br&gt;
Your daily notes, whiteboards, and drafts. People edit here. Agents do not get a credential to this space by default.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Vault B — Agent-readable wiki.&lt;/strong&gt;&lt;br&gt;
Curated pages the model may search and cite: runbooks, architecture, current decisions, onboarding. Raw sources stay immutable. Synthesized pages can be generated, but they live here, not in your journal.&lt;/p&gt;

&lt;p&gt;Then set three permissions, in this order:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;May never read&lt;/li&gt;
&lt;li&gt;May read&lt;/li&gt;
&lt;li&gt;May write — last, and rarely&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are writing a schema file (&lt;code&gt;AGENTS.md&lt;/code&gt;, &lt;code&gt;CLAUDE.md&lt;/code&gt;, or the equivalent), make the boundary explicit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answer only from the agent wiki, and name the page&lt;/li&gt;
&lt;li&gt;Do not search the human vault&lt;/li&gt;
&lt;li&gt;Do not write unless the task is labeled as an approved ingest&lt;/li&gt;
&lt;li&gt;If a fact is not in the agent wiki, say so — do not "helpfully" pull it from somewhere else&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is also why "close Claude Code, open Codex, pick up the same markdown handoff" only works if both tools are pointed at the same scoped wiki, not at four private memory stores that cannot read each other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F838ebaltvlo93emzohib.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F838ebaltvlo93emzohib.jpg" alt="A human vault stays private, an agent wiki is readable, and write access is a narrow door" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this belongs
&lt;/h2&gt;

&lt;p&gt;A weekend folder hook will not hold this for a team. You need &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;Knowledge base Software&lt;/a&gt; with spaces, permissions, and a place for those rules to live in the open.&lt;/p&gt;

&lt;p&gt;If agents can search and cite only the spaces you allow, you have &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;AI knowledge base Software&lt;/a&gt;. If you can run the workspace yourself — the thing people usually want from an &lt;a href="https://affine.pro/" rel="noopener noreferrer"&gt;Open source Notion&lt;/a&gt; alternative — you also get to decide which rooms a model never enters, and whether inference leaves the building.&lt;/p&gt;

&lt;p&gt;AFFiNE's write-up on an &lt;a href="https://affine.pro/blog/llm-wiki" rel="noopener noreferrer"&gt;LLM wiki for teams&lt;/a&gt; puts this first: decide which knowledge the AI may see, which spaces it may never read, and whether it may write at all, then start read-only. The companion guide to &lt;a href="https://affine.pro/blog/self-hosted-ai" rel="noopener noreferrer"&gt;self-hosted AI for teams&lt;/a&gt; is useful here because the knowledge workspace is its own layer, separate from the model server and the chat UI. You can scope a credential to a workspace without retraining a model, and you can swap the model without granting it a new room.&lt;/p&gt;

&lt;p&gt;AFFiNE, which I work on, is one option for that workspace layer: open-source, local-first docs, whiteboards, and databases, with optional BYOK AI and a workspace MCP server that is read-only by default. It is a weak fit if you only need a static handbook, or if you need agents to write into the workspace on today's stable release.&lt;/p&gt;

&lt;h2&gt;
  
  
  A one-hour access check
&lt;/h2&gt;

&lt;p&gt;Pick the vault or workspace your agents already use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnryvpv9ufpdzqsmmmusg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnryvpv9ufpdzqsmmmusg.jpg" alt="A one-hour access check: list citations, list forbidden pages, tighten the credential, revoke write, point every tool at the same wiki, then ask a question that should fail" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;List ten pages an agent has cited in the last week. Mark each one: should this have been readable?&lt;/li&gt;
&lt;li&gt;List five pages that must never be readable: compensation, personnel, unreleased plans, private journals, credentials.&lt;/li&gt;
&lt;li&gt;Confirm the agent's credential cannot see those five. If it can, revoke it and issue a narrower one.&lt;/li&gt;
&lt;li&gt;If the agent has write access, turn it off except for a single ingest path with a human review step.&lt;/li&gt;
&lt;li&gt;Point every tool — Claude Code, Codex, and the rest — at the same agent wiki, not at a private memory each vendor keeps.&lt;/li&gt;
&lt;li&gt;Ask a question whose answer lives only in the human vault. The right result is "I don't have that," not a helpful leak.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If step 6 succeeds as a leak, you do not have a second brain. You have a sharing problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bottom line
&lt;/h2&gt;

&lt;p&gt;Persistence is necessary. Persistence of everything, to every agent, is how a second brain becomes a side channel.&lt;/p&gt;

&lt;p&gt;Give the model a wiki it can cite. Keep the rest of the vault for the humans who know which pages were never meant to be answered from.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>ai</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
