2025-04-17 15:24:08 +02:00
|
|
|
|
|
|
|
|
|
2026-11-16 14:09:31 +01:00
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-08-05 19:47:22 +02:00
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-07-28 12:32:21 +02:00
|
|
|
|
2026-06-05 13:44:28 +02:00
|
|
|
|
2026-07-28 12:32:21 +02:00
|
|
|
|
2026-09-09 16:18:13 +02:00
|
|
|
|
|
|
|
|
|
2026-10-18 21:38:35 +04:00
|
|
|
|
|
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
2025-09-03 14:06:11 +02:00
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
2026-09-09 16:18:13 +02:00
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
|
|
|
|
|
2026-10-26 16:59:30 +01:00
|
|
|
|
feat(storage): add LibSQL and PostgreSQL Knowledge v2 schema (#26018)
> Supersedes #22507, closed during the Knowledge pause. GitHub cannot
reopen it because the branch was rebased onto current `main`; its review
history stays on #22507.
Wave: 1 of 4
Segment: W1.2 of 8
Purpose: Add normalized Knowledge v2 physical storage and explicit
reset-safe schema negotiation for LibSQL and PostgreSQL while preserving
MySQL and MongoDB v1 compatibility.
Previous PR: https://github.com/mastra-ai/mastra/pull/26017
Next PR: https://github.com/mastra-ai/mastra/pull/26019
Previous wave: None
Next wave: feat/knowledge-v2-w2-contract (planned)
## Summary
- creates and indexes all 15 Knowledge-owned v2 tables in LibSQL and
PostgreSQL
- requires every expected table/column plus an adapter-owned completion
marker before treating a schema as compatible
- keeps normalized node/record scope projections, activity linkage, CAS
versions, mentions, and semantic outbox writes transactionally coherent
- integrates PostgreSQL schema inspection with the shared init snapshot
and keeps explicit reset limited to Knowledge-owned objects
- registers normalized tables in Core and InMemory without changing
MySQL/MongoDB v1 schemas
## Test plan
- `pnpm build:core`
- `pnpm --filter ./packages/core check`
- `pnpm --dir packages/core exec vitest run
src/storage/domains/knowledge/__tests__/base.test.ts
src/storage/domains/knowledge/__tests__/scope.test.ts --reporter=dot
--bail 1`
- `pnpm --filter ./stores/libsql test -- --reporter=dot --bail 1` (997
passed, 19 skipped)
- `pnpm --dir stores/libsql exec vitest run
src/storage/domains/knowledge/index.test.ts --reporter=dot --bail 1` (29
passed)
- `pnpm --dir stores/pg exec vitest run
src/storage/domains/knowledge/index.test.ts
src/storage/db/schema-snapshot.test.ts
src/storage/db/schema-snapshot.stress.test.ts --reporter=dot --bail 1`
(46 passed)
- MySQL v1 Knowledge focused suite (27 passed)
- Turbo builds for LibSQL, PostgreSQL, MySQL, and MongoDB
- Prettier, Oxlint, and `git diff --check`
## Known unrelated baseline evidence
- PostgreSQL full suite passed 2,038 tests with 121 skipped; one
workflow planner-index assertion selected a different valid index.
- MongoDB focused v1 Knowledge testing exposed the shipped
unified-collection unique-index collision for record documents with null
node-only keys; this PR does not modify MongoDB.
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## ELI5
This update gives Knowledge a more organized way to store its data in
LibSQL and PostgreSQL. It creates the new tables when Knowledge is first
used, and it stops if it finds a database layout it cannot safely
recognize.
## Changes
- Added Knowledge v2 schemas and compatibility checks. Initialization
verifies all required tables and columns, plus a schema-version marker.
- Added normalized storage for scopes, grants, addresses, imports,
proposals, activity, and other Knowledge data. LibSQL and PostgreSQL
maintain scope links and record versions during Knowledge updates.
- Made Knowledge initialization lazy. `storage.init()` skips Knowledge.
When automatic initialization is enabled,
`storage.getStore('knowledge')` activates it. Call
`storage.initKnowledge()` to activate it explicitly.
- Added guarded handling for recognized published v1 schemas. The
adapter drops those tables without migrating their data. Unrecognized
layouts remain unchanged and require an explicit reset.
- Limited `dangerouslyReset()` to Knowledge-owned data. PostgreSQL reset
fails if dependencies prevent the operation.
- Removed the `maxScope` ceiling from Knowledge storage and
`Subconscious` configuration. Knowledge writes can use any scope visible
to the conversation.
- Preserved MySQL and MongoDB Knowledge schemas.
## Validation
The PR description reports passing build, type-check, lint, formatting,
and focused storage tests. Reported results include 997 LibSQL tests, 46
PostgreSQL Knowledge and schema-snapshot tests, and 27 MySQL v1
Knowledge tests. The PostgreSQL full suite reportedly passed 2,038
tests, with 121 skipped.
The description also reports a MongoDB focused-test unique-index
collision involving record documents with null node-only keys. This PR
does not change MongoDB’s schema. These test results are author-reported
and were not independently verified here.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: remy-builder[bot] <324360501+remy-builder[bot]@users.noreply.github.com>
Co-authored-by: Jamie Lee Nichols <10267569+CodingButter@users.noreply.github.com>
2026-10-08 23:34:57 -07:00
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
2025-04-17 17:23:16 +02:00
|
|
|
|
2025-11-14 01:03:06 +01:00
|
|
|
|
2025-06-11 16:09:11 +02:00
|
|
|
|
2026-10-20 14:07:43 -07:00
|
|
|
|
2026-10-26 16:59:30 +01:00
|
|
|
|
2025-11-14 01:03:06 +01:00
|
|
|
|
|
|
|
|
|
2026-10-22 05:33:21 -07:00
|
|
|
|
2026-06-05 13:44:28 +02:00
|
|
|
|
2026-01-05 16:09:44 +01:00
|
|
|
|
2025-11-14 01:03:06 +01:00
|
|
|
|
2025-05-19 15:08:48 +02:00
|
|
|
|
|
|
|
|
|
2026-11-04 22:12:40 +02:00
|
|
|
|
2025-09-03 14:06:11 +02:00
|
|
|
|
|
|
|
|
|
2026-09-01 10:47:20 +02:00
|
|
|
|
2025-09-03 14:06:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-11-04 15:15:18 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-17 15:24:08 +02:00
|
|
|
|
2026-06-17 17:40:24 +02:00
|
|
|
|