Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
W1: beliefs in the flag registry, CLI help and thin-client goldens (69 cases); derived-link replacement's ledger source read in the SQL-text and gauge goldens
garrytance24f3fc5e55
diff --git a/src/core/cli-flag-registry.generated.ts b/src/core/cli-flag-registry.generated.tsindex 592308d809..47976f0b4f 100644--- a/src/core/cli-flag-registry.generated.ts+++ b/src/core/cli-flag-registry.generated.ts@@ -22,7 +22,7 @@ export const CLI_FLAG_REGISTRY: Record<string, readonly string[]> = {'autopilot': ['--apply', '--batch', '--brain', '--check', '--dimensions', '--dir', '--drain', '--dry-run', '--embedding-dimensions', '--embedding-model', '--exit-code', '--expect', '--explain', '--ff-only', '--force', '--force-retry', '--from-pages', '--help', '--inject-bootstrap', '--inline', '--install', '--interval', '--json', '--markdown', '--max-cost', '--max-rss', '--max-runtime', '--max-usd', '--migrate-only', '--model', '--no-autopilot-install', '--no-bun-floor-check', '--no-embed', '--no-embed-cache', '--no-inject', '--no-worker', '--non-interactive', '--now', '--once', '--only', '--output', '--params', '--path', '--pause', '--reader-mode', '--reason', '--refresh-cache', '--refs', '--remediation-plan', '--repo', '--resume', '--slot-a-model', '--slot-b-model', '--slot-c-model', '--source', '--stale', '--status', '--swap-only', '--tags', '--target', '--trust', '--uninstall', '--user', '--verify', '--version', '--yes'],'backfill': ['--batch-size', '--brain', '--concurrency', '--dry-run', '--fresh', '--help', '--json', '--keep-index', '--list', '--max-errors', '--max-rows', '--resume', '--source'],'backup': ['--accept-pending', '--background', '--brain', '--confirm-authority-reviewed', '--confirm-backup-compatible', '--confirm-quiesced', '--dir', '--explain', '--follow', '--full', '--help', '--into', '--json', '--mode', '--no-accept-pending', '--output', '--path', '--progress-interval', '--progress-json', '--quiet', '--restore-only', '--source', '--timeout', '--wait'],- 'beliefs': ['--brain', '--help', '--json', '--source'],+ 'beliefs': ['--brain', '--help', '--json', '--probe', '--source'],'bench': ['--baseline', '--brain', '--force', '--from', '--help', '--json', '--label', '--limit', '--source', '--threshold-jaccard', '--threshold-latency-multiplier', '--threshold-top1', '--to', '--tool'],'book-mirror': ['--accept-pending', '--access', '--add', '--allowed-operations', '--asof', '--author', '--background', '--bound-slug-prefixes', '--brain', '--chapters-dir', '--client', '--context-file', '--date', '--dated-since', '--days', '--dry-run', '--entities', '--explain', '--federated-read', '--follow', '--from-index', '--full', '--fuzzy', '--group', '--help', '--http', '--id', '--include-deleted', '--json', '--kind', '--limit', '--max-cost', '--max-cost-usd', '--max-turns', '--max-usd', '--model', '--multimodal', '--no-accept-pending', '--no-autopilot-install', '--no-confirm', '--no-follow', '--page', '--params', '--path', '--phase', '--prefer', '--progress-interval', '--progress-json', '--purge', '--quiet', '--recent', '--refresh-operations', '--row', '--scopes', '--session', '--since', '--slug', '--slugs', '--source', '--sources', '--stale', '--surface', '--timeout', '--timeout-ms', '--title', '--to', '--updated-after', '--url', '--wait', '--yes'],'bootstrap': ['--abbrev-ref', '--accept-visibility-change-consequences', '--active', '--adopt', '--all', '--allow-unverified-remote', '--auto', '--autostash', '--bearer-token-env-var', '--brain', '--branch', '--cached', '--confirm', '--count', '--delete-brain', '--diff-filter', '--dim', '--dry-run', '--enable', '--env', '--error-unmatch', '--exclude-standard', '--expect-remote', '--ff-only', '--file', '--force', '--gbrain-bin', '--get', '--git-dir', '--git-path', '--hard', '--harness', '--header', '--heads', '--help', '--home', '--hostname', '--http', '--id', '--init', '--install', '--is-inside-work-tree', '--issuer-url', '--jq', '--json', '--local', '--local-env-vars', '--mcp-even-if-plugin', '--mcp-only', '--mcp-url', '--minimal', '--name', '--name-only', '--no-autostash', '--no-capture', '--no-cron', '--no-hooks', '--no-seat', '--no-tags', '--no-verify', '--oauth-client-id', '--oauth-client-secret', '--only', '--operations', '--others', '--pat-file', '--path', '--pglite', '--porcelain', '--port', '--private', '--project', '--pull', '--pure', '--push-only', '--quiet', '--rebase', '--refresh-operations', '--refresh-skills', '--remove', '--repair', '--require-clean', '--resolve', '--scope', '--scopes', '--seat', '--set', '--short', '--show', '--show-toplevel', '--skills', '--skip', '--source', '--sources', '--status', '--surface', '--to', '--token', '--token-name', '--unset-all', '--url', '--verify', '--version', '--visibility', '--workspace', '--yes'],diff --git a/test/cli-thin-client-refusal-matrix.test.ts b/test/cli-thin-client-refusal-matrix.test.tsindex a37427cc1d..5551a90c67 100644--- a/test/cli-thin-client-refusal-matrix.test.ts+++ b/test/cli-thin-client-refusal-matrix.test.ts@@ -12,7 +12,7 @@* against a remote brain), routes a host-bound subcommand, changes a hint or* exit code, or moves a check across the connectEngine terminator.* Why new: test/cli-dispatch-thin-client.test.ts asserts refusal for a- * hand-picked subset by substring; nothing pins all 68 cases or the full+ * hand-picked subset by substring; nothing pins all 69 cases or the full* text. Seam: none.** Nothing leaves the machine: issuer and MCP URLs point at 127.0.0.1:1@@ -104,8 +104,8 @@ describe('A16b thin-client refusal matrix', () => {routing = await run(ROUTING_ROWS);}, 300_000);- test('the matrix covers all 68 handleCliOnly cases', () => {- expect(CASES.length).toBe(68);+ test('the matrix covers all 69 handleCliOnly cases', () => {+ expect(CASES.length).toBe(69);});test('every handleCliOnly case, run bare on a thin client, matches the golden', () => {diff --git a/test/fixtures/goldens/cli/help-and-errors.json b/test/fixtures/goldens/cli/help-and-errors.jsonindex 1573b226fa..dd41d9ad3b 100644--- a/test/fixtures/goldens/cli/help-and-errors.json+++ b/test/fixtures/goldens/cli/help-and-errors.json@@ -109,6 +109,7 @@" lint <dir|file> [--fix] Catch LLM artifacts, placeholder dates, bad frontmatter"," backfill <kind|list> v0.30.1: run a registered backfill (effective-date, ...)"," orphans [--json] [--count] Find pages with no inbound wikilinks",+ " beliefs <enable|status|...> Belief ledger coverage: enable, disable, status, reconcile, backfill"," salience [--days N] [--kind P] v0.29: pages ranked by emotional + activity salience"," anomalies [--since D] [--sigma N] v0.29: cohort-based statistical anomalies (tag, type)"," feedback <status|reset> retrieval feedback: learned page weights; rate answers with gbrain rate",@@ -333,6 +334,7 @@" lint <dir|file> [--fix] Catch LLM artifacts, placeholder dates, bad frontmatter"," backfill <kind|list> v0.30.1: run a registered backfill (effective-date, ...)"," orphans [--json] [--count] Find pages with no inbound wikilinks",+ " beliefs <enable|status|...> Belief ledger coverage: enable, disable, status, reconcile, backfill"," salience [--days N] [--kind P] v0.29: pages ranked by emotional + activity salience"," anomalies [--since D] [--sigma N] v0.29: cohort-based statistical anomalies (tag, type)"," feedback <status|reset> retrieval feedback: learned page weights; rate answers with gbrain rate",@@ -557,6 +559,7 @@" lint <dir|file> [--fix] Catch LLM artifacts, placeholder dates, bad frontmatter"," backfill <kind|list> v0.30.1: run a registered backfill (effective-date, ...)"," orphans [--json] [--count] Find pages with no inbound wikilinks",+ " beliefs <enable|status|...> Belief ledger coverage: enable, disable, status, reconcile, backfill"," salience [--days N] [--kind P] v0.29: pages ranked by emotional + activity salience"," anomalies [--since D] [--sigma N] v0.29: cohort-based statistical anomalies (tag, type)"," feedback <status|reset> retrieval feedback: learned page weights; rate answers with gbrain rate",diff --git a/test/fixtures/goldens/cli/thin-client-cases.json b/test/fixtures/goldens/cli/thin-client-cases.jsonindex cf77b584ec..ec962c9847 100644--- a/test/fixtures/goldens/cli/thin-client-cases.json+++ b/test/fixtures/goldens/cli/thin-client-cases.json@@ -747,6 +747,16 @@],"stdout": []},+ {+ "argv": "beliefs",+ "exitCode": 1,+ "stderr": [+ "Error [requires_local_engine]: `gbrain beliefs` requires a local engine. This install is a thin client of http://127.0.0.1:1/mcp.",+ "Fix: gbrain beliefs",+ "Docs: https://github.com/garrytan/gbrain/blob/master/docs/guides/error-codes.md#requires_local_engine"+ ],+ "stdout": []+ },{"argv": "trust","exitCode": 1,diff --git a/test/fixtures/goldens/postgres-engine-gauge/acquires-by-case.json b/test/fixtures/goldens/postgres-engine-gauge/acquires-by-case.jsonindex 0b835050b0..a4b422541b 100644--- a/test/fixtures/goldens/postgres-engine-gauge/acquires-by-case.json+++ b/test/fixtures/goldens/postgres-engine-gauge/acquires-by-case.json@@ -314,11 +314,11 @@"tx": 1},"replaceDerivedLinks#default": {- "raw": 12,+ "raw": 13,"tx": 1},"replaceDerivedLinksBatch#default": {- "raw": 12,+ "raw": 13,"tx": 1},"resolveSlugWithAlias#default": {},diff --git a/test/fixtures/goldens/sql-text/_driver.json b/test/fixtures/goldens/sql-text/_driver.jsonindex 11875497c2..897ab9d227 100644--- a/test/fixtures/goldens/sql-text/_driver.json+++ b/test/fixtures/goldens/sql-text/_driver.json@@ -2427,6 +2427,15 @@},"via": "unsafe"},+ {+ "paramCount": 2,+ "unsafeOptions": {+ "cancelFence": false,+ "prepare": true,+ "simple": false+ },+ "via": "unsafe"+ },{"paramCount": 1,"unsafeOptions": {@@ -2563,6 +2572,15 @@},"via": "unsafe"},+ {+ "paramCount": 2,+ "unsafeOptions": {+ "cancelFence": false,+ "prepare": true,+ "simple": false+ },+ "via": "unsafe"+ },{"paramCount": 1,"unsafeOptions": {diff --git a/test/fixtures/goldens/sql-text/links.json b/test/fixtures/goldens/sql-text/links.jsonindex 94515579ef..6d56a4c2a1 100644--- a/test/fixtures/goldens/sql-text/links.json+++ b/test/fixtures/goldens/sql-text/links.json@@ -343,6 +343,15 @@"sql": "WITH chosen AS ( SELECT p.* FROM pages p WHERE p.slug=$1 AND p.source_id=$2 AND p.deleted_at IS NULL ORDER BY (p.slug=$3) DESC, (p.source_id=$4) DESC, p.source_id ASC LIMIT 1 ) SELECT p.*, (SELECT s.incarnation FROM sources s WHERE s.id=p.source_id) AS source_incarnation, COALESCE((SELECT jsonb_agg(t.tag ORDER BY t.tag) FROM tags t WHERE t.page_id=p.id), '[]'::jsonb) AS snapshot_tags, wd.snapshot_withdrawals, wd.snapshot_global_purges, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.compiled_truth,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_body, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.timeline,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_timeline FROM chosen p CROSS JOIN LATERAL (SELECT COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',w.visibility,'fact_hash',w.fact_hash,'withdrawn_at',w.withdrawn_at) ORDER BY w.visibility,w.fact_hash) FROM (SELECT visibility,fact_hash,min(withdrawn_at) AS withdrawn_at FROM fact_withdrawals WHERE source_id=p.source_id AND (subject='*' OR subject=p.slug) GROUP BY visibility,fact_hash) w), '[]'::jsonb) || COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',x.visibility,'fact_hash',x.fact_hash,'withdrawn_at',x.purged_at,'purged',true) ORDER BY x.visibility,x.fact_hash) FROM (SELECT visibility,fact_hash,min(purged_at) AS purged_at FROM fact_purges WHERE source_id=p.source_id AND subject=p.slug GROUP BY visibility,fact_hash) x), '[]'::jsonb) AS snapshot_withdrawals, (SELECT jsonb_build_object('count',count(*),'latest',max(g.purged_at)) FROM fact_purges g WHERE g.source_id=p.source_id AND g.subject='*' ) AS snapshot_global_purges) wd","textSha256": "993c9cf80610982d62aaa83f0b1f333abd84a5c9e2783cece6875b37787c1e45"},+ {+ "lane": "tx",+ "params": [+ "string",+ "string"+ ],+ "sql": "SELECT s.incarnation::text AS incarnation, s.purge_epoch, (SELECT e.event_type FROM belief_events e WHERE e.source_id = s.id AND e.subject_kind = 'coverage' AND e.subject_key = $1 AND e.source_incarnation = s.incarnation ORDER BY e.id DESC LIMIT 1) AS coverage, (s.purge_epoch > 0 OR EXISTS (SELECT 1 FROM fact_purges WHERE source_id = s.id) OR EXISTS (SELECT 1 FROM take_purges WHERE source_id = s.id) OR EXISTS (SELECT 1 FROM page_purges WHERE source_id = s.id)) AS purges FROM sources s WHERE s.id = $2",+ "textSha256": "f000174df490aafd95dbf40666721cc0a652e36b0cfe51bc5ff285bf1941ae75"+ },{"lane": "tx","params": [@@ -519,6 +528,15 @@"sql": "WITH wanted AS ( SELECT v.slug AS batch_slug, v.source_id AS batch_source_id, v.n AS batch_n, p.id AS batch_page_id, COALESCE(sum(octet_length(p.compiled_truth) + COALESCE(octet_length(p.timeline), 0)) OVER (ORDER BY v.n ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0) AS batch_prior_bytes FROM unnest($1::text[], $2::text[]) WITH ORDINALITY AS v(slug, source_id, n) LEFT JOIN pages p ON p.slug = v.slug AND p.source_id = v.source_id AND ($3::boolean OR p.deleted_at IS NULL) ), chosen AS ( SELECT w.batch_n, w.batch_slug, w.batch_source_id, p.* FROM wanted w LEFT JOIN pages p ON p.id = w.batch_page_id WHERE w.batch_n = 1 OR w.batch_prior_bytes < $4 ) SELECT p.*, (SELECT s.incarnation FROM sources s WHERE s.id=p.source_id) AS source_incarnation, COALESCE((SELECT jsonb_agg(t.tag ORDER BY t.tag) FROM tags t WHERE t.page_id=p.id), '[]'::jsonb) AS snapshot_tags, wd.snapshot_withdrawals, wd.snapshot_global_purges, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.compiled_truth,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_body, CASE WHEN wd.snapshot_withdrawals <> '[]'::jsonb OR (wd.snapshot_global_purges->>'count')::int > 0 THEN (SELECT string_agg(regexp_replace(lower(line), '[[:space:]]+', ' ', 'g'), chr(10) ORDER BY ord) FROM unnest(string_to_array(p.timeline,chr(10))) WITH ORDINALITY AS lines(line,ord)) END AS fingerprint_timeline FROM chosen p CROSS JOIN LATERAL (SELECT COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',w.visibility,'fact_hash',w.fact_hash,'withdrawn_at',w.withdrawn_at) ORDER BY w.visibility,w.fact_hash) FROM (SELECT visibility,fact_hash,min(withdrawn_at) AS withdrawn_at FROM fact_withdrawals WHERE source_id=p.source_id AND (subject='*' OR subject=p.slug) GROUP BY visibility,fact_hash) w), '[]'::jsonb) || COALESCE((SELECT jsonb_agg(jsonb_build_object('visibility',x.visibility,'fact_hash',x.fact_hash,'withdrawn_at',x.purged_at,'purged',true) ORDER BY x.visibility,x.fact_hash) FROM (SELECT visibility,fact_hash,min(purged_at) AS purged_at FROM fact_purges WHERE source_id=p.source_id AND subject=p.slug GROUP BY visibility,fact_hash) x), '[]'::jsonb) AS snapshot_withdrawals, (SELECT jsonb_build_object('count',count(*),'latest',max(g.purged_at)) FROM fact_purges g WHERE g.source_id=p.source_id AND g.subject='*') AS snapshot_global_purges) wd ORDER BY p.batch_n","textSha256": "6697c4ea2aa0153ccf9a62abf45ec8a06ff1b51fcfb23edac1eed9ac61aaecf9"},+ {+ "lane": "tx",+ "params": [+ "string",+ "string"+ ],+ "sql": "SELECT s.incarnation::text AS incarnation, s.purge_epoch, (SELECT e.event_type FROM belief_events e WHERE e.source_id = s.id AND e.subject_kind = 'coverage' AND e.subject_key = $1 AND e.source_incarnation = s.incarnation ORDER BY e.id DESC LIMIT 1) AS coverage, (s.purge_epoch > 0 OR EXISTS (SELECT 1 FROM fact_purges WHERE source_id = s.id) OR EXISTS (SELECT 1 FROM take_purges WHERE source_id = s.id) OR EXISTS (SELECT 1 FROM page_purges WHERE source_id = s.id)) AS purges FROM sources s WHERE s.id = $2",+ "textSha256": "f000174df490aafd95dbf40666721cc0a652e36b0cfe51bc5ff285bf1941ae75"+ },{"lane": "tx","params": [