Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(schema-pack): declare the question page type in gbrain-base-v2 1.4.0 (#6742)

garrytan9cc84754ce09
diff --git a/docs/.wave18-fragments/lane3.md b/docs/.wave18-fragments/lane3.md
index b9716f0b50..cc1d79da5a 100644
--- a/docs/.wave18-fragments/lane3.md
+++ b/docs/.wave18-fragments/lane3.md
@@ -17,3 +17,20 @@ Lane 3 branch: capy/wave18-lane3. Each section names the target file, the place
### Deferred list (PR body)
- #6740: cleanup of stale "Discussed in" timeline bullets already written; preview-first repair, next wave.
+
+## #6742 question type in gbrain-base-v2 (pack 1.4.0)
+
+### src/core/behavior-change-notice.ts (append to BEHAVIOR_CHANGES)
+
+```ts
+ { since: '<WAVE>', text: 'The bundled `gbrain-base-v2` schema pack (the `init` default, also inherited by `company-brain`) is now version 1.4.0 and declares the `question` page type the pinned-question writer stamps, so a pinned question no longer makes doctor `schema_pack_consistency` warn `page_type_undeclared` (#6742). Existing question pages keep their type; no data changes. The active pack identity reads `[email protected]+<hash>`.' },
+```
+
+### Regenerate (integrator)
+
+- Doctor goldens: the `pack_upgrade_available` message changes from `[email protected]+a50a67b9` to `[email protected]+1c5ba903` in test/fixtures/goldens/doctor/{content-pglite-human,content-pglite-json,hot-checks-pglite-json,hot-checks-postgres-json,json-pglite-degraded,json-pglite-fresh,json-postgres-fresh}.json. Regenerate with the goldens script rather than hand-editing.
+- Plugin trees / template repo if they embed the pack (none found by grep for `a50a67b9` outside the doctor goldens).
+
+### CHANGELOG.md (wave entry, Fixed)
+
+- Pinning a question no longer makes doctor warn about an undeclared `question` page type on the default schema pack (#6742). `gbrain-base-v2` is now 1.4.0.
diff --git a/docs/architecture/type-taxonomy.md b/docs/architecture/type-taxonomy.md
index b092e3009d..ecce8c61da 100644
--- a/docs/architecture/type-taxonomy.md
+++ b/docs/architecture/type-taxonomy.md
@@ -51,6 +51,10 @@ rows for edge-shaped pages.
binds any uncovered legacy type to `note` with
`frontmatter.legacy_type = <original>` preserved for rollback.
+The pack also declares `question`, the owner-private annotation type
+the pinned-question writer stamps on its pages (non-extractable, no
+folder prefix), so pinned questions never read as undeclared types.
+
## Subtypes (declared in frontmatter post-unify)
| Canonical | Subtype field | Values |
diff --git a/src/core/schema-pack/base/gbrain-base-v2.yaml b/src/core/schema-pack/base/gbrain-base-v2.yaml
index 4ad59ef86f..a04a2031a5 100644
--- a/src/core/schema-pack/base/gbrain-base-v2.yaml
+++ b/src/core/schema-pack/base/gbrain-base-v2.yaml
@@ -7,6 +7,9 @@
# v1.3.0 adds `account` (a customer or CRM record, alias `crm`): an entity
# type, so documents that name an account link to it, kept out of expert
# routing.
+# v1.4.0 adds `question`, the type the pinned-question writer stamps on
+# questions/ pages (#6742), mirroring gbrain-base: a non-extractable
+# annotation outside the canonical 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,
@@ -29,7 +32,7 @@
api_version: gbrain-schema-pack-v1
name: gbrain-base-v2
-version: 1.3.0
+version: 1.4.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
@@ -361,6 +364,16 @@ page_types:
extractable: false
expert_routing: false
+ # A pinned question's page (src/core/questions/pages.ts); the answer
+ # lives in pinned_questions. Owner-private and never evidence. Set via
+ # frontmatter only, so an existing questions/ folder keeps its own types.
+ - name: question
+ primitive: annotation
+ path_prefixes: []
+ aliases: []
+ extractable: false
+ expert_routing: false
+
link_types:
- name: partner_of
inverse: partner_of
diff --git a/test/lens-pack-manifests.test.ts b/test/lens-pack-manifests.test.ts
index 8791394f6b..05fb0fe861 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.3.0 (account entity type; 1.2.0 added open-loop link verbs)', () => {
- expect(pack.version).toBe('1.3.0');
+ test('version bumped to 1.4.0 (question page type; 1.3.0 added account, 1.2.0 open-loop link verbs)', () => {
+ expect(pack.version).toBe('1.4.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 a0a97aa1b5..07df8e8596 100644
--- a/test/schema-cli-db-config.test.ts
+++ b/test/schema-cli-db-config.test.ts
@@ -61,7 +61,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.3.0');
+ expect((r.stdout ?? '').split('\n')[0]).toBe('# gbrain-base-v2 v1.4.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 92c1d1d843..e6cd8c8e19 100644
--- a/test/schema-cli.test.ts
+++ b/test/schema-cli.test.ts
@@ -131,7 +131,8 @@ describe('gbrain schema CLI (Phase C)', () => {
// v1.2.0 (v0.47 open-loop engine): +owes_to +awaiting_reply_from — 15
// link verbs became 17. (#2117 history: 14 became 15 with `advises`.)
// v1.3.0 (entity recall): +account page type (alias crm).
- expect(r.stdout).toContain('gbrain-base-v2 v1.3.0');
+ // v1.4.0 (#6742): +question page type (the pinned-question writer's).
+ expect(r.stdout).toContain('gbrain-base-v2 v1.4.0');
expect(r.stdout).toContain('Page types (');
expect(r.stdout).toContain('Link verbs (17)');
});
diff --git a/test/schema-pack-question-type.test.ts b/test/schema-pack-question-type.test.ts
new file mode 100644
index 0000000000..6d0ea59d94
--- /dev/null
+++ b/test/schema-pack-question-type.test.ts
@@ -0,0 +1,58 @@
+/**
+ * #6742: the pinned-question writer stamps `type: question`
+ * (QUESTION_PAGE_TYPE), so the stock base pack (gbrain-base-v2, the init
+ * default) and packs extending it (company-brain) must declare it.
+ *
+ * Protects: a pinned question on a default brain never trips doctor
+ * `schema_pack_consistency` (`page_type_undeclared`), whose advice to retype
+ * or declare the type is wrong because the writer restores `question`.
+ * Regression: a pack edit that drops the `question` page type.
+ */
+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 { QUESTION_PAGE_TYPE } from '../src/core/questions/identity.ts';
+import { pinQuestion } from '../src/core/questions/service.ts';
+import { withEnv } from './helpers/with-env.ts';
+import { ENTITY, MODEL, QUESTION, localCtx, seedBrain, stubChat } from './helpers/pinned-questions-fixture.ts';
+
+let engine: PGLiteEngine;
+
+beforeAll(async () => {
+ engine = new PGLiteEngine();
+ await engine.connect({});
+ await engine.initSchema();
+ await engine.setConfig('schema_pack', 'gbrain-base-v2');
+ await engine.setConfig('models.standing_questions', MODEL);
+}, 120_000);
+
+afterAll(async () => {
+ await engine?.disconnect();
+}, 60_000);
+
+describe('#6742 question page type in the stock base pack', () => {
+ test('a pinned question on a gbrain-base-v2 brain is a declared type and the consistency check stays ok', async () => {
+ const s = await seedBrain(engine);
+ await withEnv({ ANTHROPIC_API_KEY: 'sk-test-pinned-questions' }, () =>
+ pinQuestion(localCtx(engine, s.sourceId), { question: QUESTION, scope: { entity: ENTITY } }, { chat: stubChat().fn }));
+ const rows = await engine.executeRaw<{ type: string }>(`SELECT type FROM pages WHERE source_id = $1 AND slug LIKE 'questions/%'`, [s.sourceId]);
+ expect(rows.map(r => r.type)).toEqual([QUESTION_PAGE_TYPE]);
+ const check = await checkSchemaPackConsistency(engine, { sourceIds: [s.sourceId] });
+ expect(check.message).toBe('All pages match the active schema pack across every source.');
+ expect(check.status).toBe('ok');
+ }, 60_000);
+
+ test('gbrain-base-v2 declares question as a non-extractable annotation, and company-brain inherits it', () => {
+ const base = loadPackFromFile(bundledPackPath('gbrain-base-v2')!);
+ expect(classifyStoredType(QUESTION_PAGE_TYPE, base)).toEqual({ kind: 'canonical' });
+ expect(base.page_types.find(t => t.name === QUESTION_PAGE_TYPE)).toMatchObject({
+ primitive: 'annotation', path_prefixes: [], extractable: false, expert_routing: false,
+ });
+ const company = mergeInheritedManifest([base], loadPackFromFile(bundledPackPath('company-brain')!), { page_types: [], link_types: [] });
+ expect(classifyStoredType(QUESTION_PAGE_TYPE, company)).toEqual({ kind: 'canonical' });
+ });
+});
diff --git a/test/schema-pack-stats.test.ts b/test/schema-pack-stats.test.ts
index 929105a15c..8b29103f9b 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]');
});
});
});