@cerefox/memory 1.15.0-beta.3 → 1.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,7 +15,7 @@
15
15
  href="https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&display=swap"
16
16
  />
17
17
  <title>Cerefox</title>
18
- <script type="module" crossorigin src="/app/assets/index-DUY9wimN.js"></script>
18
+ <script type="module" crossorigin src="/app/assets/index-xHSz7_7E.js"></script>
19
19
  <link rel="stylesheet" crossorigin href="/app/assets/index-Dm_zCch4.css">
20
20
  </head>
21
21
  <body>
@@ -18,7 +18,7 @@
18
18
  * doesn't touch `supabase/functions/` leaves it alone).
19
19
  */
20
20
 
21
- export const EF_VERSION = "1.14.5";
21
+ export const EF_VERSION = "1.15.1";
22
22
 
23
23
  /**
24
24
  * The Cerefox RELEASE version — what `cerefox --version` reports and what npm
@@ -36,7 +36,7 @@ export const EF_VERSION = "1.14.5";
36
36
  * is imported by the Deno Edge Functions, which cannot reach into the npm
37
37
  * package.
38
38
  */
39
- export const CEREFOX_VERSION = "1.15.0-beta.3";
39
+ export const CEREFOX_VERSION = "1.15.1";
40
40
 
41
41
  /**
42
42
  * The most recent version whose EF-side SOURCE actually changed (#127).
@@ -0,0 +1,55 @@
1
+ -- 0032_derive_grants.sql — derive the Data API grant list instead of listing it
2
+ --
3
+ -- Issue: the explicit-grant block (0013, #26) names its tables in a hand-written
4
+ -- ARRAY. That array has to match the set of `cerefox_*` tables, and it drifted:
5
+ -- `cerefox_document_relations` was added to schema.sql and never added to the
6
+ -- array. On an UPGRADE path that table is fine (0014 grants it inline), and on
7
+ -- the self-hosted stack `roles.sql` grants broadly via its own PostgREST wiring
8
+ -- — so the gap is invisible everywhere except the case nobody runs by hand: a
9
+ -- FRESH cloud deploy, where `ALTER DEFAULT PRIVILEGES` cannot help because it
10
+ -- only affects tables created AFTER it runs.
11
+ --
12
+ -- From 2026-10-30 Supabase stops granting Data API access to new tables in
13
+ -- `public` automatically, so a missing grant stops being cosmetic and becomes a
14
+ -- 42501 the first time anything reaches that table over PostgREST.
15
+ --
16
+ -- The fix is the one this project keeps arriving at: derive the list. Every
17
+ -- `cerefox_*` table in `public` is granted, so a new table cannot be forgotten.
18
+ -- Idempotent and safe to re-run.
19
+ --
20
+ -- `anon` and `authenticated` still get NOTHING, deliberately: every Cerefox
21
+ -- client authenticates with a service-role-equivalent key, and the RPCs are
22
+ -- SECURITY DEFINER. Supabase's migration note suggests granting all three
23
+ -- roles; doing so here would widen the surface for no caller.
24
+
25
+ DO $$
26
+ DECLARE t TEXT;
27
+ BEGIN
28
+ IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'service_role') THEN
29
+ RAISE NOTICE 'service_role absent (self-hosted stack) — grants skipped; roles.sql wires PostgREST';
30
+ RETURN;
31
+ END IF;
32
+
33
+ GRANT USAGE ON SCHEMA public TO service_role;
34
+
35
+ -- Derived from the catalogue, not from a list someone has to remember.
36
+ FOR t IN
37
+ SELECT c.relname
38
+ FROM pg_class c
39
+ JOIN pg_namespace n ON n.oid = c.relnamespace
40
+ WHERE n.nspname = 'public'
41
+ AND c.relkind = 'r'
42
+ AND c.relname LIKE 'cerefox\_%'
43
+ LOOP
44
+ EXECUTE format(
45
+ 'GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.%I TO service_role', t
46
+ );
47
+ END LOOP;
48
+
49
+ -- Tables created LATER by the deploying role inherit the same grants. This
50
+ -- is belt-and-braces next to the loop above, not a substitute for it: it
51
+ -- cannot retro-grant anything that already exists, which is exactly how
52
+ -- cerefox_document_relations slipped through.
53
+ ALTER DEFAULT PRIVILEGES IN SCHEMA public
54
+ GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO service_role;
55
+ END $$;
@@ -3091,6 +3091,11 @@ SET search_path = public, pg_catalog
3091
3091
  AS $$
3092
3092
  -- Keep in lockstep with the `@version:` marker in schema.sql (cut_release.ts
3093
3093
  -- enforces it). Bump whenever schema.sql OR rpcs.sql changes.
3094
+ -- 0.16.2 (#26 follow-up): the Data API grant list is DERIVED from pg_class
3095
+ -- rather than a hand-written array that has to match the set of tables. The
3096
+ -- array had drifted (cerefox_document_relations), which only a FRESH cloud
3097
+ -- deploy would have surfaced, and only after Supabase stops granting new
3098
+ -- public tables automatically on 2026-10-30. Migration 0032.
3094
3099
  -- 0.16.1 (v1.13.1): cerefox_ingest_document no longer consults
3095
3100
  -- `review_workflow_enabled` — review_status follows author_type whatever
3096
3101
  -- the flag says; the flag governs visibility/enforcement only. RPC-only,
@@ -3124,7 +3129,7 @@ AS $$
3124
3129
  -- 0.11.0 supersedes 0.10.6 (v1.2.1, #191): this branch carries that fix plus
3125
3130
  -- the partial-edit surface, and both migrations (0019, 0020) are in the
3126
3131
  -- sequence, so a store deploying this gets everything from both lines.
3127
- SELECT '0.16.1'::TEXT;
3132
+ SELECT '0.16.2'::TEXT;
3128
3133
  $$;
3129
3134
 
3130
3135
  -- ── cerefox_find_dead_links ──────────────────────────────────────────────────
@@ -5,7 +5,7 @@
5
5
  -- Requires extensions: vector (pgvector), uuid-ossp
6
6
  -- These are enabled at the top of db_deploy.py before this file is applied.
7
7
  --
8
- -- @version: 0.16.1
8
+ -- @version: 0.16.2
9
9
  -- The `@version` marker above is read by the schema-version-mismatch banner
10
10
  -- (see /api/v1/schema-version). Bump it whenever schema.sql OR rpcs.sql
11
11
  -- changes in a way that requires `cerefox server deploy` to be re-run —
@@ -482,21 +482,29 @@ ALTER TABLE cerefox_document_relations ENABLE ROW LEVEL SECURITY;
482
482
  -- Guarded: on the local (World B) stack this file deploys BEFORE roles.sql
483
483
  -- creates service_role, so missing-role must be a no-op (roles.sql re-runs the
484
484
  -- grants implicitly via its own PostgREST wiring; the next deploy picks them up).
485
+ -- DERIVED from the catalogue, never listed. The list used to be a hand-written
486
+ -- ARRAY and it drifted: cerefox_document_relations was added above and never
487
+ -- added to the array, so a FRESH cloud deploy left that table with no Data API
488
+ -- grant. Upgrades hid it (migration 0014 grants it inline) and the self-hosted
489
+ -- stack hid it (roles.sql grants broadly), which is why it survived unnoticed.
490
+ -- ALTER DEFAULT PRIVILEGES below cannot cover it either — that only affects
491
+ -- tables created AFTER it runs. See migration 0032.
485
492
  DO $$
486
493
  DECLARE t TEXT;
487
494
  BEGIN
488
495
  IF EXISTS (SELECT 1 FROM pg_roles WHERE rolname = 'service_role') THEN
489
496
  GRANT USAGE ON SCHEMA public TO service_role;
490
- FOREACH t IN ARRAY ARRAY[
491
- 'cerefox_projects', 'cerefox_documents', 'cerefox_document_versions',
492
- 'cerefox_audit_log', 'cerefox_document_projects', 'cerefox_chunks',
493
- 'cerefox_migrations', 'cerefox_config', 'cerefox_usage_log'
494
- ] LOOP
495
- IF to_regclass('public.' || t) IS NOT NULL THEN
496
- EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.%I TO service_role', t);
497
- END IF;
497
+ FOR t IN
498
+ SELECT c.relname
499
+ FROM pg_class c
500
+ JOIN pg_namespace n ON n.oid = c.relnamespace
501
+ WHERE n.nspname = 'public'
502
+ AND c.relkind = 'r'
503
+ AND c.relname LIKE 'cerefox\_%'
504
+ LOOP
505
+ EXECUTE format('GRANT SELECT, INSERT, UPDATE, DELETE ON TABLE public.%I TO service_role', t);
498
506
  END LOOP;
499
- -- Future cerefox_* tables created by the deploying role keep working.
507
+ -- Tables created LATER by the deploying role inherit the same grants.
500
508
  ALTER DEFAULT PRIVILEGES IN SCHEMA public
501
509
  GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO service_role;
502
510
  END IF;
@@ -230,6 +230,55 @@ The backup directory (`./backup-data/` by default) is gitignored. Back up the ba
230
230
 
231
231
  ---
232
232
 
233
+ ## cerefox_export.ts — Export every document as markdown files
234
+
235
+ A one-way dump for local browsing, grepping and offline copies. **Not** a restore
236
+ path: use `backup_create.ts` / `backup_restore.ts` for that.
237
+
238
+ ```bash
239
+ bun scripts/cerefox_export.ts <target-folder>
240
+ bun scripts/cerefox_export.ts <target-folder> --project "My Project"
241
+ bun scripts/cerefox_export.ts <target-folder> --force # allow a non-empty target
242
+ bun scripts/cerefox_export.ts <target-folder> --no-metadata # content only
243
+ ```
244
+
245
+ Layout — one folder per project, documents with no project at the root:
246
+
247
+ ```
248
+ <target>/<project-slug>/<title-slug>.md the reconstructed markdown
249
+ <target>/<project-slug>/<title-slug>-metadata.md the metadata sidecar
250
+ ```
251
+
252
+ A document in several projects is written **once per project** (copies), so each
253
+ folder stands alone.
254
+
255
+ ### The metadata sidecar
256
+
257
+ Each document gets a `-metadata.md` beside it, so an exported file is
258
+ self-describing rather than anonymous prose. It carries the document id, source,
259
+ **every** project membership (not just the folder that copy is in), created and
260
+ updated timestamps, character and chunk counts, the metadata keys as a table, and
261
+ the **`content_hash`** — the concurrency token, so an exported copy can be edited
262
+ and re-ingested with `expected_content_hash`.
263
+
264
+ `review_status` appears only when the store has the review workflow enabled; when
265
+ it is off the field is absent from every other surface, and an export is not the
266
+ place to resurrect it.
267
+
268
+ Markdown rather than JSON so the sidecars are readable in the same editor as the
269
+ documents. Pass `--no-metadata` for the older content-only behaviour.
270
+
271
+ Two naming details worth knowing:
272
+
273
+ - Title collisions get a numeric suffix (`doc-2.md`), and the sidecar follows the
274
+ file it describes (`doc-2-metadata.md`).
275
+ - A document whose own title ends in "metadata" produces a content file named
276
+ exactly like another document's sidecar (`foo-metadata.md` is both the export
277
+ of "Foo Metadata" and the sidecar of "Foo"). Sidecar names share the same
278
+ uniqueness domain as content files, so whichever is written second gets the
279
+ numeric suffix and neither can overwrite the other. A real store contains such
280
+ a pair.
281
+
233
282
  ## sync_docs.ts — Sync project documentation into Cerefox
234
283
 
235
284
  Ingests `README.md`, `AGENT_GUIDE.md`, `AGENT_QUICK_REFERENCE.md`, and every Markdown file under `docs/` into your Cerefox knowledge base, updating existing documents in-place. Run this any time after editing documentation so AI agents always have access to the current state of the project.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cerefox/memory",
3
- "version": "1.15.0-beta.3",
3
+ "version": "1.15.1",
4
4
  "description": "Cerefox \u2014 user-owned shared memory for AI agents. CLI + stdio MCP server + web UI + ingestion for a knowledge base on your own Supabase project (or fully self-hosted with Cerefox Local).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/fstamatelopoulos/cerefox",