Skip to content

Commit 2d6a17b

Browse files
author
ben
authored
Add KB setup contracts and Percolation V2 (#25)
* feat: add KB setup contracts and percolation v2 * fix: harden KB lifecycle compatibility contracts * fix: harden percolation compatibility and package output
1 parent 9bd0048 commit 2d6a17b

51 files changed

Lines changed: 4398 additions & 716 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 79 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ system.
1414
Bun 1.3.14 or newer is required.
1515

1616
```sh
17-
bun add --global @hraness/kb@0.18.1
17+
bun add --global @hraness/kb@0.19.0
1818
kb --help
1919
```
2020

@@ -188,6 +188,14 @@ Retrieval is bounded. The high-level `kb search` and `KnowledgeBaseSession.searc
188188

189189
Each note owns its outbound typed relationships in frontmatter. KB derives backlinks, inverse edges, and bounded traversal at read time, so parallel agents do not contend on one generated fact file. `kb percolate <note>` reports recurring concepts and missing-link candidates with inspectable support but writes nothing. An agent reads the cited notes before creating a reusable concept or relationship. Semantic similarity never creates an edge automatically.
190190

191+
Percolation Result V2 presents a missing relationship as an unordered pair of
192+
notes with a required predicate. It does not choose the source, direction, or a
193+
`related-to` fallback. Recommended authored predicates include `synthesizes`,
194+
`evidenced-by`, `informed-by`, `supersedes`, and `contradicts`; they are an
195+
advisory vocabulary, so a vault can use another canonical predicate when its
196+
prose and evidence define the claim. KB never infers reciprocal, inverse,
197+
transitive, or similarity-derived relationships.
198+
191199
Git provenance is opt-in. A search without `--history` performs no Git indexing. `--history` requests best-effort provenance, while `--require-history` rejects unavailable history or incomplete provenance for the selected notes. If one commit exceeds the 2,000-path detail limit, KB retains its identity and vault-local note associations, marks its co-change detail incomplete, and continues through later commits. Best-effort search reports that requested lane as partial.
192200

193201
Local attachment checks cover Markdown and Obsidian references to images, PDFs, and editable tldraw sources. They reject missing or escaping files while leaving external URLs alone. A source-inbox view separately lists recent captures that have no inbound disposition from maintained knowledge. It is an advisory, not an automatic backlink requirement: a saved source may intentionally remain a leaf.
@@ -204,6 +212,39 @@ The same mixed-cache, single-run test recorded p95 latencies of 44.345 milliseco
204212

205213
Search finds candidates. Similarity does not establish that a passage is current, correct, or supported by its sources. The Markdown, cited captures, explicit relationships, and requested Git history supply the material a reader must inspect.
206214

215+
### Customize through an approved proposal
216+
217+
The Agent Skill routes setup and evolution requests before it prepares a
218+
runtime. It inspects the proposed location without mutation, interviews the
219+
user about the memory questions the KB should answer, and presents exact read
220+
and write targets. Only the approved targets may be scaffolded. A changed path,
221+
repository, account, integration, or companion skill requires renewed
222+
approval.
223+
224+
The standard router may be enough. A recurring ritual can instead receive a
225+
companion skill with explicit inputs, authority, durable outputs, idempotence,
226+
failure behavior, and verification. These skills are inert instructions. They
227+
do not create a plugin runtime, execute vault metadata, inherit ambient account
228+
access, or couple application code to the KB. An exact repeat is a no-op;
229+
divergence, path escape, symbolic links, partial writes, and unapproved
230+
external surfaces stop the workflow.
231+
232+
The repository's fake-capability suite exercises those transitions. It is a
233+
tested contract example, not proof that every agent or host integration
234+
complies.
235+
236+
This workflow builds on Frank Chen's public notes about [designing a personal
237+
knowledge base with an
238+
agent](https://gist.github.com/fxchen/773397095d7a6bffda621e4237da0da9)
239+
and [extending it with
240+
skills](https://gist.github.com/fxchen/09cb410b22c9c5256d80243ee925b57e).
241+
242+
KB ships no `kb_role` metadata, lifecycle resolver or API, lifecycle CLI,
243+
compatibility diagnostic, or metadata migration. A frozen Phase 0 value gate
244+
must show that those surfaces improve deterministic agent decisions before they
245+
are introduced. Current and historical plan routing remains derived from
246+
existing type, path, and status conventions.
247+
207248
### Adopt the smallest useful split
208249

209250
Start with a short inherited `AGENTS.md` path for rules whose omission would make an edit wrong. A small knowledge base may need only Markdown, Git, an index page, and ordinary file search. Add source capture when evidence keeps disappearing. Add repository scopes when agents need to recover current memory from code paths. Add metadata or hybrid search when file search stops answering the repository's questions. Add links and graph views only when the relationships themselves help people make decisions.
@@ -219,43 +260,43 @@ Treat the knowledge base as repository-adjacent durable memory. Authored Markdow
219260
Copy this prompt into Codex, Claude Code, or another coding agent:
220261

221262
```text
222-
Install the `kb` Agent Skill from `hraness/kb#v0.18.1` with the standard skills
263+
Install the `kb` Agent Skill from `hraness/kb#v0.19.0` with the standard skills
223264
CLI. Use the skill's runtime instructions to install the exact
224-
`@hraness/kb@0.18.1` registry release only when the command is missing. Verify it
265+
`@hraness/kb@0.19.0` registry release only when the command is missing. Verify it
225266
with `kb doctor` and `kb --help`, but do not initialize or modify a vault until
226267
I ask.
227268
```
228269

229270
Install the single public skill with either runner:
230271

231272
```sh
232-
npx skills add hraness/kb#v0.18.1
233-
bunx skills add hraness/kb#v0.18.1
273+
npx skills add hraness/kb#v0.19.0
274+
bunx skills add hraness/kb#v0.19.0
234275
```
235276

236277
Both commands discover the same `kb` skill and install it into the selected
237278
agent runner. Skill installation is inert: it does not initialize a vault,
238279
refresh a catalog, or edit Markdown. When invoked, the skill uses an existing
239280
`kb` command or, when the command is missing, checks for Bun and installs the
240-
CLI from the immutable `@hraness/kb@0.18.1` npm version.
281+
CLI from the immutable `@hraness/kb@0.19.0` npm version.
241282

242283
The public skills CLI reads `skills/kb/` from the repository. The immutable
243-
`0.18.1` npm package includes the same tree under
284+
`0.19.0` npm package includes the same tree under
244285
`node_modules/@hraness/kb/skills/kb/`, and the package check verifies that the
245286
installed skill is byte-identical to the repository source.
246287

247288
Install the two global commands with Bun:
248289

249290
```sh
250-
bun add --global @hraness/kb@0.18.1
291+
bun add --global @hraness/kb@0.19.0
251292
kb --help
252293
kb-evaluation-builder --help
253294
```
254295

255296
The same registry package can be installed with npm:
256297

257298
```sh
258-
npm install --global --ignore-scripts @hraness/kb@0.18.1
299+
npm install --global --ignore-scripts @hraness/kb@0.19.0
259300
kb --help
260301
```
261302

@@ -268,20 +309,20 @@ reviewed and enabled; run `kb doctor` to inspect the resulting capabilities.
268309
For programmatic use, add the exact npm version to a Bun project:
269310

270311
```sh
271-
bun add --exact @hraness/kb@0.18.1
312+
bun add --exact @hraness/kb@0.19.0
272313
```
273314

274315
The resulting dependency should remain exact:
275316

276317
```json
277318
{
278319
"dependencies": {
279-
"@hraness/kb": "0.18.1"
320+
"@hraness/kb": "0.19.0"
280321
}
281322
}
282323
```
283324

284-
Version 0.18.1 retains three public GitHub dependencies: `@hraness/oh` at
325+
Version 0.19.0 retains three public GitHub dependencies: `@hraness/oh` at
285326
immutable release `v0.2.0` for closure verification,
286327
`@steipete/sweet-cookie` at Hraness release `v0.4.2` for the cookie-scope safety
287328
fork, and `@tobilu/qmd` at commit
@@ -467,7 +508,12 @@ Predicates use lower-kebab-case. Local targets use exact vault-root IDs without
467508
`.md`; cross-vault targets use canonical stable `kb://` URIs. `kb graph`, `kb backlinks`, `kb relation list`, and `kb links` derive
468509
inverse edges and bounded paths without injecting reciprocal or inferred facts into notes.
469510
`kb percolate` proposes reusable concepts and missing connections with explicit
470-
support; an agent reviews the cited prose before authoring anything.
511+
support; an agent reviews the cited prose before authoring anything. In its V2
512+
result, a missing relationship is an unordered endpoint pair with a required
513+
predicate, never an executable directed assertion or an automatic
514+
`related-to`. Common reviewed claims use `synthesizes`, `evidenced-by`,
515+
`informed-by`, `supersedes`, or `contradicts`; other canonical custom predicates
516+
remain valid when their meaning is supported.
471517

472518
Within a portfolio, a note can target a stable cross-vault identity such as
473519
`kb://hraness/sleepyland/sound-wellness-expansion`. The target vault must be
@@ -540,26 +586,38 @@ diffs, and the explicit local job ledger are available from
540586
The repository ships one reusable `kb` Agent Skill under `skills/kb/`. Its
541587
intent router loads focused references only when a task needs them: querying
542588
repository context and agent memory, capturing URLs or PDFs, writing durable
543-
plans, promoting concepts and typed relationships, or refreshing and checking
544-
a vault. The package smoke test keeps future tagged packages byte-identical to
589+
plans, promoting concepts and typed relationships, refreshing and checking a
590+
vault, or designing a setup through an interview and approved proposal. An
591+
approved setup may scaffold a bounded companion skill for a distinct recurring
592+
ritual. The package smoke test keeps future tagged packages byte-identical to
545593
that source tree.
546594

547595
```sh
548-
npx skills add hraness/kb#v0.18.1
596+
npx skills add hraness/kb#v0.19.0
549597
# or
550-
bunx skills add hraness/kb#v0.18.1
598+
bunx skills add hraness/kb#v0.19.0
551599
```
552600

553601
The skill invokes the installed `kb` command without depending on a repository
554-
checkout. Its runtime setup installs the pinned CLI only when the command is
555-
missing, and it never initializes or mutates a vault as an installation side
556-
effect. The repository's phase-orchestration skill remains available to local
557-
repository agents but is marked internal, so public skill discovery omits it.
602+
checkout. It routes setup and evolution before runtime preparation. For
603+
execution workflows, runtime setup installs the pinned CLI only when the
604+
command is missing, and it never initializes or mutates a vault as an
605+
installation side effect. The repository's phase-orchestration skill remains
606+
available to local repository agents but is marked internal, so public skill
607+
discovery omits it.
558608

559609
See [Design](docs/design.md), [Portfolio federation](docs/portfolio.md), [Agent workflow](docs/agent-workflow.md), [PDF capture](docs/pdf.md), and [Contributing](CONTRIBUTING.md) for the durable contracts and development gate. hraness/kb is available under the [MIT License](LICENSE).
560610

561611
## Release notes
562612

613+
### Upgrade to v0.19.0
614+
615+
Version 0.19.0 adds interview-first setup and evolution guidance, a bounded
616+
filesystem-only companion-skill scaffold contract, and Percolation Result V2.
617+
V2 requires an explicit predicate and leaves relationship ownership and
618+
direction to review. The release does not add lifecycle metadata, a resolver,
619+
a lifecycle CLI, inferred edges, or automatic account and network actions.
620+
563621
### Upgrade to v0.18.1
564622

565623
Version 0.18.1 restructures the public README and hosted projection around one

dist/authoring.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import {
1313
normalizeRelationPredicate,
1414
noteRevision,
1515
removeNoteRelation
16-
} from "./index-01jj6rbv.js";
16+
} from "./index-gxr0fctd.js";
1717
import"./index-3rm7cz6h.js";
18-
import"./index-cxfrakt7.js";
18+
import"./index-ekpwvbra.js";
1919
export {
2020
removeNoteRelation,
2121
noteRevision,

dist/benchmark.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import {
44
createSyntheticRankFusionFixture,
55
evaluateRanking,
66
evaluateRetrievalBenchmark
7-
} from "./index-s2gw5aw9.js";
8-
import"./index-cv6fh7z5.js";
7+
} from "./index-qwgsmtsz.js";
8+
import"./index-gm9t95d9.js";
99
import"./index-d13v9ckt.js";
1010
import"./index-48pz4jpc.js";
1111
import"./index-06c9ctr6.js";
1212
import"./index-5vwpzb5a.js";
13-
import"./index-cxfrakt7.js";
13+
import"./index-ekpwvbra.js";
1414
export {
1515
evaluateRetrievalBenchmark,
1616
evaluateRanking,

dist/cli.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
loadPortfolioRegistry,
1414
openKnowledgePortfolio,
1515
snapshotPortfolioRegistry
16-
} from "./index-jsmvyyvf.js";
16+
} from "./index-ey46z1zf.js";
1717
import {
1818
diffCaptureBundle
1919
} from "./index-j4zgmzjr.js";
@@ -34,19 +34,19 @@ import {
3434
MAX_PERCOLATION_NOTES,
3535
MAX_SCOPED_PERCOLATION_MENTION_PAIRS,
3636
percolateVault
37-
} from "./index-dyqwejk5.js";
37+
} from "./index-nd6nynv2.js";
3838
import {
3939
knowledgeBaseEvaluationRetrieverIds,
4040
openKnowledgeBaseEvaluation
41-
} from "./index-n5dd7r0v.js";
41+
} from "./index-xw9ac71d.js";
4242
import {
4343
DEFAULT_SEARCH_RESULTS,
4444
MAX_SEARCH_CANDIDATES,
4545
MAX_SEARCH_NOTE_REFERENCE_BYTES,
4646
MAX_SEARCH_RELATED_SEEDS,
4747
MAX_SEARCH_RESULTS,
4848
openKnowledgeBase
49-
} from "./index-zzhgcwyt.js";
49+
} from "./index-vxmf14m1.js";
5050
import {
5151
MAX_SEARCH_RULE_CONFIG_BYTES,
5252
parseSearchRules
@@ -59,7 +59,7 @@ import {
5959
refreshVault,
6060
scanVault,
6161
sha256EmbeddingModelFile
62-
} from "./index-zxdy5pby.js";
62+
} from "./index-5m2ydj5q.js";
6363
import"./index-4j3tt0c3.js";
6464
import"./index-1gwbassd.js";
6565
import {
@@ -79,11 +79,11 @@ import {
7979
addNoteRelation,
8080
createNote,
8181
removeNoteRelation
82-
} from "./index-01jj6rbv.js";
82+
} from "./index-gxr0fctd.js";
8383
import"./index-3rm7cz6h.js";
8484
import {
8585
validateSearchQuery
86-
} from "./index-cv6fh7z5.js";
86+
} from "./index-gm9t95d9.js";
8787
import {
8888
navigateLinks
8989
} from "./index-d13v9ckt.js";
@@ -111,7 +111,7 @@ import {
111111
lookupNote,
112112
parseVaultKey,
113113
renderCatalog
114-
} from "./index-cxfrakt7.js";
114+
} from "./index-ekpwvbra.js";
115115
import {
116116
main
117117
} from "./index-0kavxzqj.js";
@@ -2885,7 +2885,7 @@ function renderPercolation(result, note) {
28852885
if (candidate.kind === "missing-concept") {
28862886
lines.push(` concept #${safe(candidate.tag)} \u2192 ${safe(candidate.suggestedId)} (${candidate.support} supporting notes)` + (candidate.collidesWith === null ? "" : `; natural ID is occupied by ${safe(candidate.collidesWith)}`));
28872887
} else if (candidate.kind === "missing-relation") {
2888-
lines.push(` relation ${safe(candidate.source)} ${safe(candidate.suggestedPredicate)} ${safe(candidate.target)} (${candidate.support} shared signals)`);
2888+
lines.push(` relation pair {${safe(candidate.source)}, ${safe(candidate.target)}} (predicate required; ${candidate.support} shared signals)`);
28892889
} else if (candidate.kind === "unlinked-mention") {
28902890
lines.push(` mention ${safe(candidate.source)} \u2192 ${safe(candidate.target)} (${candidate.support})`);
28912891
} else {
@@ -2927,12 +2927,16 @@ async function runPercolate(command, output, dependencies) {
29272927
minSupport: command.minSupport,
29282928
limit: command.limit
29292929
});
2930-
output.stdout(command.json ? terminalSafeJson({
2930+
const jsonOutput = {
29312931
root: snapshot.root,
29322932
note: command.note ?? null,
29332933
minSupport: command.minSupport,
2934-
...result
2935-
}) : sanitizeTerminalText(renderPercolation(result, command.note)));
2934+
limit: command.limit,
2935+
schemaVersion: result.schemaVersion,
2936+
candidates: result.candidates,
2937+
truncated: result.truncated
2938+
};
2939+
output.stdout(command.json ? terminalSafeJson(jsonOutput) : sanitizeTerminalText(renderPercolation(result, command.note)));
29362940
return 0;
29372941
}
29382942
async function runList(command, output, dependencies) {

dist/evaluation-builder.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import {
44
knowledgeBaseEvaluationRetrieverIds,
55
openKnowledgeBaseEvaluation,
66
verifyFrozenEvaluationSnapshot
7-
} from "./index-n5dd7r0v.js";
8-
import"./index-zzhgcwyt.js";
7+
} from "./index-xw9ac71d.js";
8+
import"./index-vxmf14m1.js";
99
import"./index-adx6khj5.js";
1010
import {
1111
indexSemanticVault,
1212
recommendedEmbeddingModel,
1313
recommendedEmbeddingModelSha256,
1414
scanVault
15-
} from "./index-zxdy5pby.js";
15+
} from "./index-5m2ydj5q.js";
1616
import"./index-4j3tt0c3.js";
1717
import {
1818
runGitCommand
@@ -22,12 +22,12 @@ import {
2222
MAX_EVALUATION_EVIDENCE_BYTES,
2323
MAX_EVALUATION_RESULTS_PER_QUERY
2424
} from "./index-b88v3vtm.js";
25-
import"./index-cv6fh7z5.js";
25+
import"./index-gm9t95d9.js";
2626
import"./index-d13v9ckt.js";
2727
import"./index-48pz4jpc.js";
2828
import"./index-06c9ctr6.js";
2929
import"./index-5vwpzb5a.js";
30-
import"./index-cxfrakt7.js";
30+
import"./index-ekpwvbra.js";
3131
import"./index-1xxnjn0d.js";
3232

3333
// src/evaluation-builder.ts

dist/evaluation-kb.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import {
44
knowledgeBaseEvaluationRetrieverIds,
55
openKnowledgeBaseEvaluation,
66
verifyFrozenEvaluationSnapshot
7-
} from "./index-n5dd7r0v.js";
8-
import"./index-zzhgcwyt.js";
7+
} from "./index-xw9ac71d.js";
8+
import"./index-vxmf14m1.js";
99
import"./index-adx6khj5.js";
10-
import"./index-zxdy5pby.js";
10+
import"./index-5m2ydj5q.js";
1111
import"./index-4j3tt0c3.js";
1212
import"./index-1gwbassd.js";
1313
import"./index-b88v3vtm.js";
14-
import"./index-cv6fh7z5.js";
14+
import"./index-gm9t95d9.js";
1515
import"./index-d13v9ckt.js";
1616
import"./index-48pz4jpc.js";
1717
import"./index-06c9ctr6.js";
1818
import"./index-5vwpzb5a.js";
19-
import"./index-cxfrakt7.js";
19+
import"./index-ekpwvbra.js";
2020
import"./index-1xxnjn0d.js";
2121
export {
2222
verifyFrozenEvaluationSnapshot,

0 commit comments

Comments
 (0)