mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-14 00:48:18 +00:00
* feat(mcp,context): ambient recall — context_pack + delta frozen verbs + boundary runtime (#1) Two new frozen MEMORY_VERBS (context_pack, delta) on the pull surface + a Claude Code hook boundary runtime on the push surface, sharing one stateless assembler core (assembleTurnContext mode: turn|pack|delta) and a keyset session cursor (migration v126). World-only by default; include_private gated fail-closed to trusted-local. protocol_version stays 1 (additive 5→7 verbs). Survived three adversarial review waves. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * v0.45.7.0 feat(mcp,context): ambient recall — context_pack + delta frozen verbs + boundary runtime (#1) Two new frozen MEMORY_VERBS (context_pack, delta) grow the frozen set 5→7 without a wire bump — all seven stamp protocol_version: 1. context_pack assembles a deterministic, zero-LLM, budget-packed bundle (entity cards + open threads + hot facts) for a set of standing entities; delta returns only what changed since a timestamp for cheap heartbeats, with a per-session keyset cursor for at-least-once delivery. A boundary runtime wires these into Claude Code lifecycle hooks (SessionStart warm pack, PreCompact entity banking for post-compaction rehydration); Codex and any MCP host pull the same verbs at their own boundaries. World-only by default on all arms; include_private widens only for local trusted callers. Migration v126 adds session_context_state (additive). Includes the coverage close-out wave (~55 tests): real-serve compact→ session-start round trip over the live socket, --surface verbs stdio session pinning exactly 7 tools fail-closed, HTTP-transport verb calls with per-token cursor isolation, Postgres engine-parity for keyset pagination + the session-cursor table, migration v126 shape + rewind test, sub-second latency gates, CLI-level invocations, rendered-protocol boundary assertions, and a live-Codex boundary-call check. The wave caught and fixed three real bugs: the delta CLI wedging on first wake (floating GC promise racing engine teardown), the compact hook probing the PGLite socket on a Postgres config with a leftover database_path, and the verbs-surface banner hardcoding a stale verb count. Also the /document-release sweep: stale "five verbs" → seven across the protocol doc, README, INSTALL, DEPLOY, the Claude Code MCP guide, and the query skill; deferred scope filed in TODOS. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * fix(release): bump openclaw.plugin.json to 0.45.7.0 — the sixth version location The #4033 merge auto-resolved the OpenClaw plugin manifest at master's version while the trio moved to 0.45.7.0, failing the manifest drift test on CI shard 4. Register the file in CLAUDE.md's version-locations table (five → six) so every future ship and merge re-bumps it with the trio. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
61 lines
2.4 KiB
TypeScript
61 lines
2.4 KiB
TypeScript
/**
|
|
* Ambient recall (v0.45.7) — template + doc content pins.
|
|
*
|
|
* The context_pack/delta verbs only deliver value if the shipped guidance
|
|
* points agents at them. These pins keep the four guidance surfaces from
|
|
* silently dropping the boundary instructions:
|
|
* - HEARTBEAT.md.template carries the ambient-delta row (heartbeats pull
|
|
* `gbrain delta`; session start / post-compaction pairs with
|
|
* `gbrain context-pack`)
|
|
* - the RENDERED template-repo HEARTBEAT.md carries the same row
|
|
* - docs/mcp/CODEX.md names context_pack for the session boundary (Codex
|
|
* has no lifecycle hooks — the pull path is the only path)
|
|
* - docs/guides/ambient-recall.md exists and names both verbs
|
|
*
|
|
* Assertions pin stable substrings (verb + command names), not full sentences.
|
|
*/
|
|
import { describe, expect, test } from 'bun:test';
|
|
import { readFileSync, existsSync } from 'node:fs';
|
|
import { dirname, join } from 'node:path';
|
|
|
|
const ROOT = dirname(import.meta.dir);
|
|
|
|
function read(rel: string): string {
|
|
return readFileSync(join(ROOT, rel), 'utf8');
|
|
}
|
|
|
|
describe('HEARTBEAT ambient-delta row', () => {
|
|
test('source template points heartbeats at gbrain delta + context-pack', () => {
|
|
const tpl = read('templates/bootstrap/HEARTBEAT.md.template');
|
|
expect(tpl).toContain('ambient-delta');
|
|
expect(tpl).toContain('gbrain delta');
|
|
expect(tpl).toContain('gbrain context-pack');
|
|
expect(tpl).toContain('docs/guides/ambient-recall.md');
|
|
});
|
|
|
|
test('rendered template-repo HEARTBEAT.md carries the same row', () => {
|
|
const rendered = read('templates/bootstrap/template-repo/HEARTBEAT.md');
|
|
expect(rendered).toContain('ambient-delta');
|
|
expect(rendered).toContain('gbrain delta');
|
|
expect(rendered).toContain('gbrain context-pack');
|
|
});
|
|
});
|
|
|
|
describe('docs surfaces', () => {
|
|
test('CODEX.md session-boundary instruction names both verbs (pull path)', () => {
|
|
const codex = read('docs/mcp/CODEX.md');
|
|
expect(codex).toContain('context_pack');
|
|
expect(codex).toContain('delta');
|
|
// Codex has no lifecycle hooks, so the doc must route boundary calls to
|
|
// the guide's placement frontier.
|
|
expect(codex).toContain('ambient-recall.md');
|
|
});
|
|
|
|
test('ambient-recall guide exists and names both verbs', () => {
|
|
expect(existsSync(join(ROOT, 'docs/guides/ambient-recall.md'))).toBe(true);
|
|
const guide = read('docs/guides/ambient-recall.md');
|
|
expect(guide).toContain('context_pack');
|
|
expect(guide).toContain('delta');
|
|
});
|
|
});
|