PLA-52: one owner for knowledge/ - #114
Merged
Merged
Conversation
notes/store.ts absorbs searchKnowledge and readKnowledgeFile and
packages/jinn/src/knowledge/ is deleted, so a single module owns the
directory instead of two with independent walkers, validators, and caps.
Search is reimplemented on the Notes walker, which listNotes and
searchKnowledge now share. Three intended behavior deltas, each covered by
a test that fails at the base SHA:
D1 nested knowledge/** files are searchable (the recorded defect:
create_note({ folder }) wrote files search could never return)
D2 nested docs/** files are searchable (same regime for both roots)
D3 in-root symlinked .md files are no longer searchable, unifying on the
stricter of the two symlink regimes
readKnowledgeFile moves unchanged. Every other search semantic is preserved
and every surviving test from the deleted store test moved across.
#113 relocated stripControlChars/hasControlBytes out of sessions/registry.ts into shared/sanitize.ts and left no re-export, so the absorbed knowledge code in notes/store.ts must import from the new owner. Also retarget the stale knowledge/store.ts reference in the mcp/knowledge-tools.ts header.
hristo2612
force-pushed
the
simplify/PLA-52-one-knowledge-owner
branch
from
August 3, 2026 10:10
7351082 to
da56169
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Selected area
<JINN_HOME>/knowledge/had two independent owners:packages/jinn/src/knowledge/store.ts(278 lines) — flat, non-recursivesearchKnowledgeoverknowledge/+docs/, gated bySEARCH_REL_PATH_PATTERN(exactly one/), plusreadKnowledgeFile.packages/jinn/src/notes/store.ts(581 lines) — recursive walker over the same directory, with its own validator, its own containment check, and its own byte caps.Each module carried a full parallel implementation of the same primitives: containment (
isInsideRealvsisRealpathContained), file-size caps (SEARCH_FILE_MAX_BYTESvsNOTE_FILE_MAX_BYTES— the same 2 MB value declared twice), and path validation.Evidence of blended concerns
create_note { folder: "product/research" }writesknowledge/product/research/<f>.md.search_knowledge— the verb every session is instructed to use (sessions/context.ts:926-929) — could never return that file, because the flat search's path gate admitted exactly one/. Notes could write where search could not read.docs/superpowers/plans/2026-07-14-notes-over-knowledge.md:178.packages/jinn/template/docs/company-doctrine.md:25rules out parallel concepts for one thing.Fixed constraint budget
Frozen during CONSTRAIN, before any implementation (
PLAN.md):Sub-caps:
notes/store.ts≤ 800 final lines;gateway/api.ts≤ 7584 (must not grow). No new dependencies, no new config options, no new single-caller abstractions, no public exports beyond the seven re-homed names.Measured budget (verbatim)
Sub-caps:
notes/store.ts= 783 (≤ 800);gateway/api.ts= 7576 (≤ 7584, shrank by 8 lines).What was deleted / clarified
notes/store.tsis now the only module that touches the directory.Deleted outright —
packages/jinn/src/knowledge/in full (502 lines:store.ts278 + its test file 224).Retired duplicate primitives —
SEARCH_REL_PATH_PATTERN,SEARCH_FILE_MAX_BYTES,isInsideReal,realRootOf,rootDir,ROOT_LABELS.grep -rnwfor those four names overpackages/jinn/srcnow prints nothing.Re-homed into
notes/store.ts—readKnowledgeFile(moved verbatim; scope, caps, and error contract unchanged) andsearchKnowledge(reimplemented on the existing notes walker, reusing its containment and itsNOTE_FILE_MAX_BYTEScap).Deliberately NOT collapsed (would triple the blast radius; deferred): the MCP tool families
mcp/knowledge-tools.tsandmcp/note-tools.ts, the HTTP routes, andsessions/context.ts. All ofpackages/webis untouched. The public surface is unchanged in shape — every MCP verb and every route still registered and served.Three intended behavior deltas
searchKnowledgenow returns nested files (e.g.knowledge/product/research/x.md)docs/subdirectories become searchable.mdfiles are no longer returned by searchO_NOFOLLOWEach has a test that fails at the base SHA and passes at HEAD. Everything else is behavior-preserved and still asserted by the moved tests: token-AND matching, case-insensitivity, filename matches, ≤20 hits sorted by matchCount desc then path, «»-marked snippets that never leak bodies, non-
.mdignored, >2 MB skipped, escape-symlink content never leaked, and control-byte/oversized/empty queries degrading to empty results. Everyit()title from the deleted test file survives innotes/__tests__/store.test.ts, except the D3 case, which appears inverted.readKnowledgeFileis behavior-preserved, full stop.Test results
Run from the worktree after the final commit (
7351082c):pnpm typecheckpnpm testpnpm buildPrivacy leak-grep over the
packages/**diff: clean.Follow-ups recorded, not done here
readKnowledgeFilereads any regular file in the instance, not just knowledge; the name understates its blast radius. Renaming touches two MCP tool modules and the web file viewer, so it is its own Todo.sessions/context.tsstill advertises onlysearch_knowledge/read_knowledge; adding the Note verbs re-pins the manifest-hash tests for zero line savings.listNotesstrips only the FIRST control byte of a query (CONTROL_BYTESlacks the/gflag). Pre-existing; deliberately preserved.mcp/knowledge-tools.ts:11andgateway/__tests__/knowledge-route.test.ts:12-13. Comment-only.workflows/__tests__/workflow-vertical.test.ts(theattemptInterruptionCause: "user-message"assertion) failed twice under a loaded full test run mid-implementation. It then passed 4/4 full runs at HEAD, 5/5 runs of that file alone, and 3/3 at the base SHA. It imports none of the moved code — pre-existing load-sensitive flake, worth its own Todo.