diff --git a/README.md b/README.md index 33de81b8..ce8c7111 100644 --- a/README.md +++ b/README.md @@ -148,3 +148,5 @@ docker compose -f docker-compose.dev.yml up --build ## Licence Fabled Grimoire is free software under the [GNU Affero General Public License v3.0 only](LICENSE) (`AGPL-3.0-only`). If you run a modified version for other people over a network, the licence requires you to offer them its source. + +The Claude Code plugin in [`plugin/`](plugin/) is a separate work under the [MIT License](plugin/LICENSE) (`MIT`), so you can adapt it inside your own tooling freely. diff --git a/alembic/versions/0139_embedding_vectors_inline.py b/alembic/versions/0139_embedding_vectors_inline.py new file mode 100644 index 00000000..a705e9bc --- /dev/null +++ b/alembic/versions/0139_embedding_vectors_inline.py @@ -0,0 +1,42 @@ +"""embedding vectors stored inline, not in TOAST + +Revision ID: 0139 +Revises: 0138 +Create Date: 2026-11-28 + +Every semantic search ranks its in-scope chunks exactly, one distance per +chunk (see embeddings._rank_scoped). pgvector's `vector` type defaults to +EXTERNAL storage, and a chunk row (a 384-dimension vector, about 1.5 KB, plus +the chunk's text) is over Postgres's 2 KB toast threshold, so the vector was +moved out of line and every distance paid a TOAST lookup: several buffer +reads per chunk, on every search. + +`STORAGE MAIN` keeps the vector in the row. When a row is still too wide, the +chunk text (EXTENDED) is compressed or moved out instead, which costs nothing +on the ranking path: the text is read only for the rows a search returns. + +A storage change applies to rows written after it, so the existing rows are +rewritten once. Casting through `real[]` produces a fresh value, which the +row is stored with under the new setting; assigning the column to itself +would keep the old out-of-line pointer. +""" +from alembic import op + +revision = "0139" +down_revision = "0138" +branch_labels = None +depends_on = None + +TABLES = ("note_embeddings", "rule_embeddings", "milestone_embeddings", "system_embeddings") + + +def upgrade() -> None: + for table in TABLES: + op.execute(f"ALTER TABLE {table} ALTER COLUMN embedding SET STORAGE MAIN") + op.execute(f"UPDATE {table} SET embedding = embedding::real[]::vector") + + +def downgrade() -> None: + # Rows already inline stay inline; new rows follow the type's default. + for table in TABLES: + op.execute(f"ALTER TABLE {table} ALTER COLUMN embedding SET STORAGE EXTERNAL") diff --git a/frontend/src/api/moments.ts b/frontend/src/api/moments.ts index b4628a8c..dd9c7778 100644 --- a/frontend/src/api/moments.ts +++ b/frontend/src/api/moments.ts @@ -297,9 +297,17 @@ export interface RecordKindsDoor { evidence: Record; } +/** Which kinds a door may offer from the user's other projects. */ +export interface RecordKindsReach { + kinds: string[]; + default: string[]; + changed: boolean; +} + export interface RecordKindsTable { days: number; evidence_failed: boolean; + reach: RecordKindsReach; kinds: { kind: string; label: string }[]; doors: RecordKindsDoor[]; } @@ -313,6 +321,11 @@ export function setRecordKinds(door: string, kinds: string[] | null): Promise { + return apiPut("/api/retrieval/record-kinds/reach", { kinds }); +} + /** How a record arrived in front of a session. */ export type RecordWay = "pushed" | "pointed" | "asked" | "direct"; diff --git a/frontend/src/api/systems.ts b/frontend/src/api/systems.ts index 38977203..7e5718f4 100644 --- a/frontend/src/api/systems.ts +++ b/frontend/src/api/systems.ts @@ -21,6 +21,12 @@ export interface System { * everything under it. Empty means the area has not named its files. */ path_patterns: string[]; + /** + * How many rulings the description carries. With no `path_patterns`, + * none of them is delivered: rulings reach a session when a command or + * edit touches the area's files. Present on the list read only. + */ + ruling_count?: number; open_issue_count: number; /** * How often this area's rulings were shown to a session because its files diff --git a/frontend/src/components/RecordKinds.vue b/frontend/src/components/RecordKinds.vue index 0f61a4c1..bca811d9 100644 --- a/frontend/src/components/RecordKinds.vue +++ b/frontend/src/components/RecordKinds.vue @@ -1,7 +1,7 @@