Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: declare the storage shelf's stored-object type in the base pack

garrytan391de93a4996
diff --git a/behavior-changes.d/storage_shelf_stored_object_type_8894.md b/behavior-changes.d/storage_shelf_stored_object_type_8894.md
new file mode 100644
index 0000000000..e18199d471
--- /dev/null
+++ b/behavior-changes.d/storage_shelf_stored_object_type_8894.md
@@ -0,0 +1 @@
+The bundled `gbrain-base-v2` schema pack (the `init` default, also inherited by `company-brain`) is now version 1.6.0 and declares the `stored-object` page type the storage verbs stamp on every storage shelf card, so registering, adopting or importing a card no longer prints a `page_type_undeclared` notice, doctor `schema_pack_consistency` does not warn about the shelf, and `unify-types` never retypes cards to `note`. Existing pages keep their type; no data changes. The active pack identity reads `[email protected]+<hash>`.
diff --git a/changelog.d/capy-storage-manifest-adopt.md b/changelog.d/capy-storage-manifest-adopt.md
index 628fe30dbe..133307ae8b 100644
--- a/changelog.d/capy-storage-manifest-adopt.md
+++ b/changelog.d/capy-storage-manifest-adopt.md
@@ -1,6 +1,6 @@
**A storage manifest: agents can register what they archived to object storage and find it again later.** A new `storage` source holds one validated card per archived item: what it is, where every copy lives (store, bucket, path, restic repository and snapshot, size, file count, hash and its kind, when it was verified), where it came from and which skill restores it. `gbrain storage-register` adds a card (from stdin or `--card`) and never overwrites one; `gbrain storage-update <id> --expected-revision <rev>` patches a card bound to the revision it read, keeps the page's access labels and records restores newest first; `gbrain storage-find "<words>"` ranks the exact id, then an exact alias, then the cards holding most of the words, and a miss lists the closest cards; `gbrain storage-get` and `gbrain storage-list` read. On a brain with a Git checkout, `gbrain storage init` hosts the shelf in its own repository first (preview, then `--expect <plan_hash>`; it needs managed persistence), so each card is a commit before it is indexed. A repo-less brain gets a database-only shelf on the first register.
-Cards never carry credentials or commands. A card is refused when any field looks like a secret, an environment assignment, a credential variable, a URL with user info or a presigned URL, or when any key is named `command`, `cmd`, `script`, `exec`, `shell` or `instructions`; object keys are checked too, and the refusal never echoes the value. A first shelf creation that stopped part way is finished by the next register or `storage init`, and an archived shelf refuses until it is restored. A restore is `{ skill, args }` with flat scalar arguments. gbrain stamps `registered_by` and `origin` itself, and holds no store credentials.
+Cards never carry credentials or commands. A card is refused when any field looks like a secret, an environment assignment, a credential variable, a URL with user info or a presigned URL, or when any key is named `command`, `cmd`, `script`, `exec`, `shell` or `instructions`; object keys are checked too, a value under a key named for a credential (`password`, `application_key`, `secret_access_key`) refuses while a key naming where the credential lives (`token_env`, `password_file`) passes, and the refusal never echoes the value. A first shelf creation that stopped part way is finished by the next register or `storage init`, and an archived shelf refuses until it is restored. A restore is `{ skill, args }` with flat scalar arguments. gbrain stamps `registered_by` and `origin` itself, and holds no store credentials.
The shelf is written only through the storage verbs. `put_page`, `remember` and every other page writer are refused `storage_source_managed` there, a request parameter cannot open the door, register and update run only from the trusted local CLI, and a dream cycle or enrichment run scoped to the shelf skips it. The source is not federated, so a remote connection reads cards only when its grant names `storage`.
@@ -22,3 +22,7 @@ The shelf is written only through the storage verbs. `put_page`, `remember` and
- `src/commands/storage.ts`: `gbrain storage init`; the help separates the tiers report (`status`) from the shelf verbs.
- Goldens: `test/fixtures/goldens/cli/tools-json.json` gains the three read tools; `test/fixtures/goldens/exports/types.json` gains the new error codes in the `canonical` union and lists `ThinkSynthesisStatus` in a new order (the new schema module declares the `not_json` literal first; the type is unchanged).
- Tests: `test/storage-manifest.test.ts` (PGLite, repo-less) and `test/storage-manifest-hosted.test.ts` (managed PGLite with a Git checkout).
+- `src/core/schema-pack/base/gbrain-base-v2.yaml`: version 1.6.0 declares `stored-object`, so cards never read as an undeclared type and `unify-types` leaves them alone (`test/schema-pack-stored-object-type.test.ts`; doctor goldens regenerated for the new pack identity).
+- `src/core/engine-sql/sources.ts`: the local-path source list (autopilot's fan-out, `cycle_freshness`) leaves out the hosted shelf, whose cycle is always skipped. A register that loses a same-id race is refused `storage_card_exists`.
+
+<!-- behavior-change: storage_shelf_stored_object_type_8894 -->
diff --git a/docs/architecture/type-taxonomy.md b/docs/architecture/type-taxonomy.md
index 4f9a932888..c7b9da58fe 100644
--- a/docs/architecture/type-taxonomy.md
+++ b/docs/architecture/type-taxonomy.md
@@ -58,7 +58,9 @@ It also declares `code` (the code importer's page type, non-extractable
media, no folder prefix) and `extract_receipt` (the extract receipt
writer's page type under `extracts/`, a non-extractable annotation), so
imported code and extraction receipts never read as undeclared types and
-the catch-all retype leaves them alone.
+the catch-all retype leaves them alone. Since 1.6.0 it declares
+`stored-object` (a storage shelf card, a non-extractable annotation with no
+folder prefix) for the same reason.
## Subtypes (declared in frontmatter post-unify)
diff --git a/src/core/schema-pack/base/gbrain-base-v2.yaml b/src/core/schema-pack/base/gbrain-base-v2.yaml
index 443b31b005..30f32a568f 100644
--- a/src/core/schema-pack/base/gbrain-base-v2.yaml
+++ b/src/core/schema-pack/base/gbrain-base-v2.yaml
@@ -14,6 +14,9 @@
# (stamped by the extract receipt writer under extracts/), mirroring
# gbrain-base: non-extractable types outside the content taxonomy, so the
# catch-all retype rule leaves them alone.
+# v1.6.0 adds `stored-object`, the type the storage verbs stamp on each
+# card on the storage shelf (and on interim records storage adopt moves
+# onto it): a non-extractable annotation outside the content taxonomy.
#
# STANDALONE pack (D11/F1): NO `extends:` field. Declaring inheritance
# would compose gbrain-base's 24 types on top of the 16 declared here,
@@ -36,7 +39,7 @@
api_version: gbrain-schema-pack-v1
name: gbrain-base-v2
-version: 1.5.0
+version: 1.6.0
description: 15-type DRY/MECE canonical taxonomy + `note` catch-all (16 total). Successor to gbrain-base. Issue #1479.
gbrain_min_version: 0.42.0
extends: null
@@ -397,6 +400,15 @@ page_types:
extractable: false
expert_routing: false
+ # A storage shelf card (src/core/storage-manifest/schema.ts): where an
+ # archived item is stored and how to restore it. Set via frontmatter only.
+ - name: stored-object
+ primitive: annotation
+ path_prefixes: []
+ aliases: []
+ extractable: false
+ expert_routing: false
+
link_types:
- name: partner_of
inverse: partner_of
diff --git a/test/fixtures/goldens/doctor/content-pglite-human.json b/test/fixtures/goldens/doctor/content-pglite-human.json
index 7fa53c5fc3..5a424d9c08 100644
--- a/test/fixtures/goldens/doctor/content-pglite-human.json
+++ b/test/fixtures/goldens/doctor/content-pglite-human.json
@@ -55,7 +55,7 @@
" [INFO] harness_wiring: No agent harness was detected. Wire one when the user picks an agent app.",
" [OK] agent_contract: No agent dead ends in the last 7 days (0 non-success event(s) logged).",
" [OK] connection: Connected, 5 pages",
- " [OK] persistence_capacity: No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 115490 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
+ " [OK] persistence_capacity: No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 116115 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
" [OK] persistence_terminal_failures: No terminal write failures in the last 7 d.",
" [OK] managed_sync_not_moving: No managed sync is pending.",
" [OK] managed_sync_blocked: No managed sync run is blocked.",
@@ -307,8 +307,8 @@
" [OK] entity_link_coverage: Only 2 entity pages (< 5) — coverage ratio not meaningful at this scale",
" [OK] timeline_coverage: Only 2 entity pages (< 5) — coverage ratio not meaningful at this scale",
" [INFO] takes_count: 0 takes (takes.bootstrap_enabled is false; opt in to enable)",
- " [OK] pack_upgrade_available: Active pack [email protected]+4604112a is current (no successor declared)",
- " [OK] type_proliferation: 3 distinct typed values (pack gbrain-base-v2 declares 23)",
+ " [OK] pack_upgrade_available: Active pack [email protected]+b2cec967 is current (no successor declared)",
+ " [OK] type_proliferation: 3 distinct typed values (pack gbrain-base-v2 declares 24)",
" [OK] dangling_aliases: No dangling aliases",
"Brain checks: 60/100 (category penalty)",
"Skill checks: 95/100",
diff --git a/test/fixtures/goldens/doctor/content-pglite-json.json b/test/fixtures/goldens/doctor/content-pglite-json.json
index 4c09b484b6..3a7bd445c0 100644
--- a/test/fixtures/goldens/doctor/content-pglite-json.json
+++ b/test/fixtures/goldens/doctor/content-pglite-json.json
@@ -528,7 +528,7 @@
"explicit_retention_days": null,
"over_target": false,
"target_bytes": 8589934592,
- "used_bytes": 115490
+ "used_bytes": 116115
},
"inspected": 2,
"outstanding": [],
@@ -538,7 +538,7 @@
"verify": "gbrain doctor --only persistence_capacity --json"
},
"elapsed_ms": "<volatile>",
- "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 115490 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
+ "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 116115 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
"name": "persistence_capacity",
"status": "ok"
},
@@ -4576,14 +4576,14 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "3 distinct typed values (pack gbrain-base-v2 declares 23)",
+ "message": "3 distinct typed values (pack gbrain-base-v2 declares 24)",
"name": "type_proliferation",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
index 165fc69cc8..e7028f8562 100644
--- a/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-pglite-json.json
@@ -529,7 +529,7 @@
"explicit_retention_days": null,
"over_target": false,
"target_bytes": 8589934592,
- "used_bytes": 197727
+ "used_bytes": 198727
},
"inspected": 2,
"outstanding": [],
@@ -539,7 +539,7 @@
"verify": "gbrain doctor --only persistence_capacity --json"
},
"elapsed_ms": "<volatile>",
- "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 197727 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
+ "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 198727 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
"name": "persistence_capacity",
"status": "ok"
},
@@ -5007,14 +5007,14 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "5 distinct typed values (pack gbrain-base-v2 declares 23)",
+ "message": "5 distinct typed values (pack gbrain-base-v2 declares 24)",
"name": "type_proliferation",
"status": "ok"
},
@@ -5868,7 +5868,7 @@
"explicit_retention_days": null,
"over_target": false,
"target_bytes": 8589934592,
- "used_bytes": 197727
+ "used_bytes": 198727
},
"inspected": 2,
"outstanding": [],
@@ -5878,7 +5878,7 @@
"verify": "gbrain doctor --only persistence_capacity --json"
},
"elapsed_ms": "<volatile>",
- "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 197727 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
+ "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 198727 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
"name": "persistence_capacity",
"status": "ok"
},
@@ -10358,14 +10358,14 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "5 distinct typed values (pack gbrain-base-v2 declares 23)",
+ "message": "5 distinct typed values (pack gbrain-base-v2 declares 24)",
"name": "type_proliferation",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
index 3d28d18045..b51133f7c3 100644
--- a/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
+++ b/test/fixtures/goldens/doctor/hot-checks-postgres-json.json
@@ -523,7 +523,7 @@
"explicit_retention_days": null,
"over_target": false,
"target_bytes": 8589934592,
- "used_bytes": 198780
+ "used_bytes": 199780
},
"inspected": 2,
"outstanding": [],
@@ -533,7 +533,7 @@
"verify": "gbrain doctor --only persistence_capacity --json"
},
"elapsed_ms": "<volatile>",
- "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 198780 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
+ "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 199780 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
"name": "persistence_capacity",
"status": "ok"
},
@@ -5011,14 +5011,14 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "5 distinct typed values (pack gbrain-base-v2 declares 23)",
+ "message": "5 distinct typed values (pack gbrain-base-v2 declares 24)",
"name": "type_proliferation",
"status": "ok"
},
@@ -5866,7 +5866,7 @@
"explicit_retention_days": null,
"over_target": false,
"target_bytes": 8589934592,
- "used_bytes": 198780
+ "used_bytes": 199780
},
"inspected": 2,
"outstanding": [],
@@ -5876,7 +5876,7 @@
"verify": "gbrain doctor --only persistence_capacity --json"
},
"elapsed_ms": "<volatile>",
- "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 198780 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
+ "message": "No cumulative write cap is set (the default), so receipt storage never refuses or pauses a write; it holds 199780 reserved bytes, and receipts not yet compacted are under the housekeeping target of 8589934592.",
"name": "persistence_capacity",
"status": "ok"
},
@@ -10366,14 +10366,14 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "5 distinct typed values (pack gbrain-base-v2 declares 23)",
+ "message": "5 distinct typed values (pack gbrain-base-v2 declares 24)",
"name": "type_proliferation",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-pglite-degraded.json b/test/fixtures/goldens/doctor/json-pglite-degraded.json
index f4a49c81dc..e19b019391 100644
--- a/test/fixtures/goldens/doctor/json-pglite-degraded.json
+++ b/test/fixtures/goldens/doctor/json-pglite-degraded.json
@@ -4111,7 +4111,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-pglite-fresh.json b/test/fixtures/goldens/doctor/json-pglite-fresh.json
index 5268bbe090..c292b2b6ef 100644
--- a/test/fixtures/goldens/doctor/json-pglite-fresh.json
+++ b/test/fixtures/goldens/doctor/json-pglite-fresh.json
@@ -4198,7 +4198,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
diff --git a/test/fixtures/goldens/doctor/json-postgres-fresh.json b/test/fixtures/goldens/doctor/json-postgres-fresh.json
index 0f9003f167..4a12a42082 100644
--- a/test/fixtures/goldens/doctor/json-postgres-fresh.json
+++ b/test/fixtures/goldens/doctor/json-postgres-fresh.json
@@ -4202,7 +4202,7 @@
{
"category": "meta",
"elapsed_ms": "<volatile>",
- "message": "Active pack [email protected]+4604112a is current (no successor declared)",
+ "message": "Active pack [email protected]+b2cec967 is current (no successor declared)",
"name": "pack_upgrade_available",
"status": "ok"
},
diff --git a/test/fixtures/goldens/sql-text/sources.json b/test/fixtures/goldens/sql-text/sources.json
index 28e3adabf6..01f55376c6 100644
--- a/test/fixtures/goldens/sql-text/sources.json
+++ b/test/fixtures/goldens/sql-text/sources.json
@@ -10,8 +10,8 @@
"boolean",
"boolean"
],
- "sql": "SELECT id, name, local_path, last_sync_at, config FROM sources WHERE ($1 OR archived IS NOT TRUE) AND ($2 OR local_path IS NOT NULL) ORDER BY (id = 'default') DESC, id",
- "textSha256": "8f708b7f5bb279ea14ecc0f958457d31237d81a165a02fbc5f62339bba8b9291"
+ "sql": "SELECT id, name, local_path, last_sync_at, config FROM sources WHERE ($1 OR archived IS NOT TRUE) AND ($2 OR (local_path IS NOT NULL AND config->>'role' IS DISTINCT FROM 'storage_manifest')) ORDER BY (id = 'default') DESC, id",
+ "textSha256": "7a9f40530ae88bb9c1d059fb6b47a75e864c4e3a9579d0145dfdff0bfdae61ce"
}
]
},
diff --git a/test/lens-pack-manifests.test.ts b/test/lens-pack-manifests.test.ts
index e6beae09a4..29501e4b96 100644
--- a/test/lens-pack-manifests.test.ts
+++ b/test/lens-pack-manifests.test.ts
@@ -255,8 +255,8 @@ describe('v0.41 T4: gbrain-everything meta-pack shape', () => {
describe('#2117: gbrain-base-v2 ships link-inference regexes + explicit phases', () => {
const pack = loadPack('gbrain-base-v2');
- test('version bumped to 1.5.0 (code + extract_receipt page types; 1.4.0 added question, 1.3.0 account, 1.2.0 open-loop link verbs)', () => {
- expect(pack.version).toBe('1.5.0');
+ test('version bumped to 1.6.0 (stored-object page type; 1.5.0 added code + extract_receipt, 1.4.0 question, 1.3.0 account, 1.2.0 open-loop link verbs)', () => {
+ expect(pack.version).toBe('1.6.0');
});
test('declares the 4 v1 inference regexes (founded/invested_in/advises/works_at)', () => {
diff --git a/test/schema-cli-db-config.test.ts b/test/schema-cli-db-config.test.ts
index 376eb04958..8f5eaae920 100644
--- a/test/schema-cli-db-config.test.ts
+++ b/test/schema-cli-db-config.test.ts
@@ -63,7 +63,7 @@ describe('#4653 schema inspection verbs honor DB-config schema_pack (tier 4)', (
test('schema show prints the DB-configured pack header', () => {
const r = runSchema('show');
expect(r.status).toBe(0);
- expect((r.stdout ?? '').split('\n')[0]).toBe('# gbrain-base-v2 v1.5.0');
+ expect((r.stdout ?? '').split('\n')[0]).toBe('# gbrain-base-v2 v1.6.0');
}, 90_000);
test('schema explain <v2-only type> exits 0', () => {
diff --git a/test/schema-cli.test.ts b/test/schema-cli.test.ts
index 774ed6f4fa..184b11e4ef 100644
--- a/test/schema-cli.test.ts
+++ b/test/schema-cli.test.ts
@@ -132,7 +132,7 @@ describe('gbrain schema CLI (Phase C)', () => {
// link verbs became 17. (#2117 history: 14 became 15 with `advises`.)
// v1.3.0 (entity recall): +account page type (alias crm).
// v1.4.0 (#6742): +question page type (the pinned-question writer's).
- expect(r.stdout).toContain('gbrain-base-v2 v1.5.0');
+ expect(r.stdout).toContain('gbrain-base-v2 v1.6.0');
expect(r.stdout).toContain('Page types (');
expect(r.stdout).toContain('Link verbs (17)');
});
diff --git a/test/schema-pack-stats.test.ts b/test/schema-pack-stats.test.ts
index 2aa9665617..3e99c206f9 100644
--- a/test/schema-pack-stats.test.ts
+++ b/test/schema-pack-stats.test.ts
@@ -339,7 +339,7 @@ describe('runStatsCore — #4653 DB-plane schema_pack tier', () => {
await engine.setConfig('schema_pack', 'gbrain-base-v2');
const result = await runStatsCore(ctxOf());
// Pre-fix: loadActivePackBestEffort never read the engine → '[email protected]+…'.
- expect(result.pack_identity).toStartWith('[email protected]');
+ expect(result.pack_identity).toStartWith('[email protected]');
});
});
});
diff --git a/test/schema-pack-stored-object-type.test.ts b/test/schema-pack-stored-object-type.test.ts
new file mode 100644
index 0000000000..4e37174524
--- /dev/null
+++ b/test/schema-pack-stored-object-type.test.ts
@@ -0,0 +1,61 @@
+/**
+ * The stock base pack (gbrain-base-v2, the init default) and packs extending it (company-brain) declare
+ * `stored-object`, the type the storage verbs stamp on every storage shelf card.
+ *
+ * Protects: registering a card on a default brain never trips doctor `schema_pack_consistency`
+ * (`page_type_undeclared`), and the catch-all retype rule never turns cards into notes, which would hide them
+ * from storage_find and storage_list.
+ * Regression: a pack edit that drops the declaration.
+ */
+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
+import { PGLiteEngine } from '../src/core/pglite-engine.ts';
+import { checkSchemaPackConsistency } from '../src/commands/doctor/schema-pack-checks.ts';
+import { classifyStoredType } from '../src/core/schema-pack/type-usage.ts';
+import { bundledPackPath } from '../src/core/schema-pack/bundled-assets.ts';
+import { loadPackFromFile } from '../src/core/schema-pack/loader.ts';
+import { mergeInheritedManifest } from '../src/core/schema-pack/merge.ts';
+import { extractableTypesFromPack } from '../src/core/schema-pack/extractable.ts';
+import { operationsByName } from '../src/core/operations.ts';
+import type { OperationContext } from '../src/core/ops/contract.ts';
+import { disposePersistenceConsumer } from '../src/core/persistence/service.ts';
+import { STORED_OBJECT_TYPE } from '../src/core/storage-manifest/schema.ts';
+
+let engine: PGLiteEngine;
+
+beforeAll(async () => {
+ engine = new PGLiteEngine();
+ await engine.connect({});
+ await engine.initSchema();
+ await engine.setConfig('schema_pack', 'gbrain-base-v2');
+}, 120_000);
+
+afterAll(async () => {
+ await disposePersistenceConsumer(engine);
+ await engine?.disconnect();
+}, 60_000);
+
+describe('stored-object page type in the stock base pack', () => {
+ test('gbrain-base-v2 declares stored-object as a non-extractable annotation, and company-brain inherits it', () => {
+ const base = loadPackFromFile(bundledPackPath('gbrain-base-v2')!);
+ expect(classifyStoredType(STORED_OBJECT_TYPE, base)).toEqual({ kind: 'canonical' });
+ expect(base.page_types.find(t => t.name === STORED_OBJECT_TYPE)).toMatchObject({
+ primitive: 'annotation', path_prefixes: [], extractable: false, expert_routing: false,
+ });
+ expect(extractableTypesFromPack(base).has(STORED_OBJECT_TYPE)).toBe(false);
+ const company = mergeInheritedManifest([base], loadPackFromFile(bundledPackPath('company-brain')!), { page_types: [], link_types: [] });
+ expect(classifyStoredType(STORED_OBJECT_TYPE, company)).toEqual({ kind: 'canonical' });
+ });
+
+ test('a registered card keeps the consistency check ok on the shelf', async () => {
+ const ctx = { engine, config: { engine: engine.kind, embedding_disabled: true }, logger: { info() {}, warn() {}, error() {} },
+ dryRun: false, remote: false, sourceId: 'default' } as unknown as OperationContext;
+ await operationsByName.storage_register!.handler(ctx, { card: {
+ id: 'dataset-a', title: 'Dataset a', aliases: [], kind: 'directory', status: 'archived',
+ locations: [{ store: 'b2', bucket: 'bucket-a', path: '/archive/dataset-a', tool: 'restic', size_bytes: 1024 }],
+ restore: { skill: 'restore-data', args: { id: 'dataset-a' } },
+ } });
+ expect((await engine.getPage('dataset-a', { sourceId: 'storage' }))?.type).toBe(STORED_OBJECT_TYPE);
+ const check = await checkSchemaPackConsistency(engine, { sourceIds: ['storage'] });
+ expect({ status: check.status, message: check.message }).toEqual({ status: 'ok', message: 'All pages match the active schema pack across every source.' });
+ }, 60_000);
+});