Skip to content

fix(rag): import Layer B through the real schema boundary - #116

Merged
dmuhoro merged 2 commits into
mainfrom
fix/layer-b-real-schema-boundary
Dec 1, 2026
Merged

dmuhoro merged 2 commits into
mainfrom
fix/layer-b-real-schema-boundary

Conversation

@dmuhoro

@dmuhoro dmuhoro commented Dec 1, 2026

Copy link
Copy Markdown
Owner

What this fixes

The merged Layer B importer wrote columns that do not exist in the committed documents / document_chunks schema (source_status, provenance, chunk_id, chunk_index, size_chars, and others), and wrote chunk-… strings into UUID primary keys. Its tests passed only because the mock accepted arbitrary columns.

This change routes imports through the shipped storeChunks ingestion path in lib/knowledge.ts, which already owns documents / document_chunks governance. Document and chunk ids are now deterministic UUIDs via stableHashId, and import provenance is stored in the JSONB metadata column. Tests now assert the real schema column allowlist.

Two additional defects found by the red control are fixed:

  • Rejection messages return pattern labels only and never echo matched secret/PII material.
  • Chunk ids include the chunk ordinal, so repeated identical paragraphs cannot collide.

Proof

Red control on base 78f0b06 with the final test file: 5 failed / 20 passed (25 tests) across key/PII echo, duplicate chunk IDs, missing document UUID and missing chunk UUIDs.

Corrected tree: targeted suite 25/25; full suite 131 files / 722 tests passing.

Gates: typecheck 0; lint 0 errors; tests 131/722; architecture boundaries, i18n, no-raw-hex, governance audit, declared imports, AI boundary, secret/public-env/dist guards green; QA runner “All systems verified”; web export and perf budget passed.

Scope guard

No document was imported. docs/rag-sources/ remains empty. No version bump, tag or release. Layer B remains blocked on owner-supplied licence-cleared documents, a written licence/rights basis and a named reviewer.

Changed-content replacement is explicitly not claimed: stale-chunk cleanup after a changed source is not implemented and must be specified and tested before any real import.

The merged Layer B importer wrote columns that do not exist in the committed documents/document_chunks schema and used non-UUID chunk ids for UUID primary keys. Its tests passed only because the mock accepted arbitrary columns.\n\nRoute imports through the shipped storeChunks path, derive deterministic UUID ids, keep import provenance in JSONB metadata, and assert the real schema column allowlist. Also stop echoing matched secret/PII material in rejection labels and include the chunk ordinal in chunk ids so repeated paragraphs cannot collide.\n\nRed control on base 78f0b06: 5 failed / 20 passed (25 tests). Corrected tree: 25/25. Full gate: typecheck 0, lint 0 errors, 131 files / 722 tests, boundaries/i18n/raw-hex/governance/imports/AI boundary/secrets/dist guards green, QA all systems verified, web export OK. No document imported; no version/tag/release.
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
easytutor Ready Ready Preview Dec 1, 2026 10:03am UTC

A newly published advisory (GHSA-ghv9-86vm-4v8m) marks cross-spawn 7.0.0-7.0.6 critical for command injection on Windows. The CI production dependency audit gate began failing on the existing 7.0.6 lock entry. Pin the transitive dependency to 7.1.2 with an npm override and record the remaining audit surface in the changelog. No product source behaviour changed.
@dmuhoro
dmuhoro merged commit 0e1c88b into main Dec 1, 2026
6 checks passed
@dmuhoro
dmuhoro deleted the fix/layer-b-real-schema-boundary branch December 1, 2026 10:06

This branch was successfully deployed

1 active deployment
Preview – easytutor — 299042b5 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant