Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(types): gbrain's own outputs use page types the default pack declares (#5881)
garrytanaa0d7fa7bc9c
diff --git a/skills/meeting-ingestion/SKILL.md b/skills/meeting-ingestion/SKILL.mdindex 29f82efcdf..6475263678 100644--- a/skills/meeting-ingestion/SKILL.md+++ b/skills/meeting-ingestion/SKILL.md@@ -119,8 +119,10 @@ source_url: "..." # link back to the source platform, if anyfrom it into the brain.Retain the raw transcript when the source provides one: file it as a sidecar-page (e.g. `meetings/YYYY-MM-DD-{slug}-transcript`) or keep the source file-reachable, and link it from the meeting page. The transcript is the canonical+page with `type: source` at `sources/meetings/YYYY-MM-DD-{slug}-transcript`+(the default pack files raw evidence as `source` under `sources/`; never+invent `meeting-transcript`, and don't write the `transcript` alias) or keep+the source file reachable, and link it from the meeting page. The transcript is the canonicalevidence for every quote and claim check downstream.**Redact before you retain.** A raw transcript routinely captures pasted@@ -415,7 +417,7 @@ Phase 4. An unflagged anonymous label means speaker resolution was skipped.quote still shares a long contiguous run of content words, a fabricated onedoes not.```bash- gbrain get meetings/{date}-{slug}-transcript # then locate each quote span+ gbrain get sources/meetings/{date}-{slug}-transcript # then locate each quote span```- **Prompt checklist (no transcript retained):** re-read the source notes andattest that each quote traces to them word-for-word.diff --git a/skills/reports/SKILL.md b/skills/reports/SKILL.mdindex 5f6363df71..dde5e89139 100644--- a/skills/reports/SKILL.md+++ b/skills/reports/SKILL.md@@ -39,7 +39,8 @@ This skill guarantees:```yaml---title: {report title}- type: report+ type: note # a type the default pack declares; `report` is undeclared+ report_type: {category name}category: {category name}date: {YYYY-MM-DD}time: {HH:MM PT}diff --git a/src/commands/report.ts b/src/commands/report.tsindex 76242bc48f..f0802ba020 100644--- a/src/commands/report.ts+++ b/src/commands/report.ts@@ -65,7 +65,7 @@ export async function runReport(args: string[]) {const page = `---title: "${title} -- ${dateStr}"-type: report+type: notereport_type: ${reportType}date: ${dateStr}time: "${timePretty}"diff --git a/src/core/cycle/drift.ts b/src/core/cycle/drift.tsindex 0ff2ec2cde..c9f729ecbf 100644--- a/src/core/cycle/drift.ts+++ b/src/core/cycle/drift.ts@@ -363,15 +363,17 @@ export async function runPhaseDrift(if (judged.length > 0) {reportSlug = `reports/drift-${cycleDate}`;// Report-only v1: the report page is the ONLY write this phase makes.+ // Typed `note` (+ report_type) so the default pack declares it (#5881).// Lands in the default source (brain-global artifact, same-day re-runs// upsert the same slug).if (maintenance) {const snapshot = await engine.readPageSnapshot(reportSlug, { sourceId: 'default' });- await publishMaintenancePage(engine, maintenance, reportSlug, serializeMarkdown({}, buildReportBody(judged, config, modelId), '',- { type: 'report', title: `Drift report ${cycleDate}`, tags: [] }), { expectedRevision: snapshot?.revision ?? null, file: false });+ await publishMaintenancePage(engine, maintenance, reportSlug, serializeMarkdown({ report_type: 'drift' }, buildReportBody(judged, config, modelId), '',+ { type: 'note', title: `Drift report ${cycleDate}`, tags: [] }), { expectedRevision: snapshot?.revision ?? null, file: false });} else {await engine.putPage(reportSlug, {- type: 'report',+ type: 'note',+ frontmatter: { report_type: 'drift' },title: `Drift report ${cycleDate}`,compiled_truth: buildReportBody(judged, config, modelId),});diff --git a/test/gbrain-owned-page-types.test.ts b/test/gbrain-owned-page-types.test.tsnew file mode 100644index 0000000000..dff549b037--- /dev/null+++ b/test/gbrain-owned-page-types.test.ts@@ -0,0 +1,83 @@+/**+ * #5881 — gbrain's own outputs use page types the bundled default pack+ * (gbrain-base-v2) declares. Pre-fix the drift phase and `gbrain report`+ * stamped `type: report`, which base-v2 neither declares nor aliases, so+ * `schema lint --with-db` flagged gbrain's own pages as+ * `stored_type_undeclared`; the meeting-ingestion skill named no type for+ * its transcript sidecar, and agents improvised undeclared ones.+ */+import { afterAll, beforeAll, describe, expect, test } from 'bun:test';+import { mkdtempSync, readdirSync, readFileSync, rmSync } from 'node:fs';+import { join } from 'node:path';+import { tmpdir } from 'node:os';+import { PGLiteEngine } from '../src/core/pglite-engine.ts';+import { runPhaseDrift } from '../src/core/cycle/drift.ts';+import { runReport } from '../src/commands/report.ts';+import { loadResolvedPackByName } from '../src/core/schema-pack/load-active.ts';+import { classifyStoredType } from '../src/core/schema-pack/type-usage.ts';+import { parseMarkdown } from '../src/core/markdown.ts';++const ROOT = join(import.meta.dir, '..');++async function basePackKind(type: string): Promise<string> {+ const pack = await loadResolvedPackByName('gbrain-base-v2');+ return classifyStoredType(type, pack.manifest).kind;+}++describe('#5881 gbrain-owned page types are declared by gbrain-base-v2', () => {+ let engine: PGLiteEngine;+ beforeAll(async () => {+ engine = new PGLiteEngine();+ await engine.connect({});+ await engine.initSchema();+ }, 60_000);+ afterAll(async () => {+ await engine.disconnect();+ });++ test('the drift phase report page', async () => {+ const page = await engine.putPage('people/erin-example', { title: 'Erin', type: 'person', compiled_truth: 'Erin' });+ await engine.addTakesBatch([{ page_id: page.id, row_num: 1, claim: 'Careful operator', kind: 'take', holder: 'brain', weight: 0.6 }]);+ await engine.addTimelineEntriesBatch([{ slug: 'people/erin-example', date: '2030-01-15', source: 'meeting', summary: 'Changed roles' }]);+ await engine.setConfig('dream.drift.enabled', 'true');+ await engine.setConfig('models.drift', 'anthropic:claude-sonnet-4-6');+ const r = await runPhaseDrift(engine, {+ dryRun: false,+ cycleDate: '2030-01-20',+ auditPath: join(tmpdir(), `drift-owned-type-${process.pid}.jsonl`),+ judge: async () => ({ drifted: true, confidence: 0.9, reasoning: 'moved' }),+ });+ expect(r.status).toBe('complete');+ const report = await engine.getPage('reports/drift-2030-01-20');+ expect(report).not.toBeNull();+ expect(await basePackKind(report!.type)).toBe('canonical');+ expect(report!.frontmatter?.report_type).toBe('drift');+ }, 30_000);++ test('`gbrain report` page frontmatter', async () => {+ const dir = mkdtempSync(join(tmpdir(), 'gbrain-report-type-'));+ const log = console.log;+ console.log = () => {};+ try {+ await runReport(['--type', 'maintenance', '--title', 'Maintenance', '--content', 'Swept 3 pages.', '--dir', dir]);+ } finally {+ console.log = log;+ }+ const reportDir = join(dir, 'reports', 'maintenance');+ const [file] = readdirSync(reportDir);+ const parsed = parseMarkdown(readFileSync(join(reportDir, file), 'utf8'), `reports/maintenance/${file}`);+ expect(await basePackKind(parsed.type)).toBe('canonical');+ expect(parsed.frontmatter.report_type).toBe('maintenance');+ rmSync(dir, { recursive: true, force: true });+ });++ test('skills name declared types for gbrain-owned pages', async () => {+ const meeting = readFileSync(join(ROOT, 'skills/meeting-ingestion/SKILL.md'), 'utf8');+ const sidecar = /sidecar[^\n]*\n?[^\n]*`type: ([a-z-]+)`/i.exec(meeting);+ expect(sidecar).not.toBeNull();+ expect(await basePackKind(sidecar![1])).toBe('canonical');+ const reports = readFileSync(join(ROOT, 'skills/reports/SKILL.md'), 'utf8');+ const reportType = /^\s*type: ([a-z-]+)/m.exec(reports);+ expect(await basePackKind(reportType![1])).toBe('canonical');+ });+});