T-163: M2.1m — Filesystem library adapter for the MCP copilot read_knowledge tool: KnowledgePort.listLibraryCards over library.yml + cards/<section>/*.md in libs/research/src/mcp/adapters/library-cards.ts (injected read-only fs port, strict front-matter parser, no new deps)
This commit is contained in:
parent
a255191b66
commit
e80b224e9b
3 changed files with 113 additions and 140 deletions
|
|
@ -267,7 +267,7 @@ Server-only, dependency-free JSON-RPC 2.0 / Model Context Protocol core exported
|
|||
### Filesystem Library Cards Adapter
|
||||
|
||||
- **`createLibraryCardReader({ root, fs })`** (exported from `@stock-bot/research/mcp` alongside `createNodeLibraryCardFs`, `LibraryCardFs`, `LibraryCardDirHandle`, `LibraryCardDirEntry`, `LibraryCardReaderOptions`, `LibraryCardReader`, `LibraryCardError`, and `LibraryCardErrorCode`) implements `Pick<KnowledgePort, 'listLibraryCards'>` over a configured read-only library root (`<root>/library.yml` and `<root>/cards/<sectionId>/<slug>.md`) with zero new dependencies.
|
||||
- **Read-only boundary, fresh reads & symlink safety:** Resolves `root` once at construction, reads `library.yml` and eligible cards fresh on every call (no cache), anchors listings and file reads to opened directory handles (`openDir` / `/proc/self/fd/<fd>` in `createNodeLibraryCardFs()`), enforces `O_NOFOLLOW` on every component below the configured root with `fstat` regular-file/directory verification, and fails closed if the runtime cannot enforce that boundary.
|
||||
- **Read-only boundary, fresh reads & symlink safety:** Resolves `root` once at construction, reads `library.yml` and eligible cards fresh on every call (no cache), requires anchored directory operations (`LibraryCardFs.openDir`, backed by `/proc/self/fd/<fd>` in `createNodeLibraryCardFs()`) with no pathname fallback, enforces `O_NOFOLLOW` on every component below the configured root with `fstat` regular-file/directory verification, and fails closed if the adapter or runtime cannot enforce that boundary.
|
||||
- **Exact-ID narrowing & unverified-card assumption:** Returns all eligible cards in manifest section order and code-unit slug order without pre-slicing or truncating text, narrowing only on exact case-sensitive `q.id` (malformed or unknown IDs return an empty frozen array without opening card files) so `createReadKnowledgeTool` owns `query`/`tags` filtering, ranking, truncation, and `limit`. All eligible cards are returned regardless of `verified` status, and callers must bind `root` to a research-visible corpus free of holdout or Vault-only observations.
|
||||
|
||||
### Copilot Server
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue