mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-14 08:53:22 +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>
332 lines
7.3 KiB
JSON
332 lines
7.3 KiB
JSON
[
|
|
{
|
|
"name": "remember rejects missing provenance (provenance_required + suggestion)",
|
|
"verb": "remember",
|
|
"params": {
|
|
"fact": "conformance {{marker}} fact without provenance"
|
|
},
|
|
"expectErrorCode": "invalid_params",
|
|
"expectSuggestion": false
|
|
},
|
|
{
|
|
"name": "remember rejects empty provenance (provenance_required + suggestion)",
|
|
"verb": "remember",
|
|
"params": {
|
|
"fact": "conformance {{marker}} fact empty provenance",
|
|
"provenance": " "
|
|
},
|
|
"expectErrorCode": "provenance_required",
|
|
"expectSuggestion": true
|
|
},
|
|
{
|
|
"name": "remember rejects ISO-8601 duration ttl with a fix (P30D trap)",
|
|
"verb": "remember",
|
|
"params": {
|
|
"fact": "conformance {{marker}} ttl trap",
|
|
"provenance": "conformance run",
|
|
"ttl": "P30D"
|
|
},
|
|
"expectErrorCode": "invalid_params",
|
|
"expectSuggestion": true
|
|
},
|
|
{
|
|
"name": "remember writes a fact (string id, enum status, echoed nulls)",
|
|
"verb": "remember",
|
|
"params": {
|
|
"fact": "conformance {{marker}}: the protocol round-trip fact",
|
|
"provenance": "conformance run {{marker}}",
|
|
"entity": "people/conformance-{{marker}}",
|
|
"kind": "fact"
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "id",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"path": "status",
|
|
"oneOf": [
|
|
"inserted",
|
|
"duplicate",
|
|
"superseded"
|
|
]
|
|
},
|
|
{
|
|
"path": "protocol_version",
|
|
"equals": 1
|
|
}
|
|
],
|
|
"saveAs": {
|
|
"key": "fact1",
|
|
"path": "id"
|
|
}
|
|
},
|
|
{
|
|
"name": "remember with ttl returns ISO valid_until",
|
|
"verb": "remember",
|
|
"params": {
|
|
"fact": "conformance {{marker}}: expiring fact",
|
|
"provenance": "conformance run {{marker}}",
|
|
"entity": "people/conformance-{{marker}}",
|
|
"ttl": "30d"
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "valid_until",
|
|
"type": "string"
|
|
}
|
|
],
|
|
"saveAs": {
|
|
"key": "fact2",
|
|
"path": "id"
|
|
}
|
|
},
|
|
{
|
|
"name": "remember private fact (fence test setup)",
|
|
"verb": "remember",
|
|
"params": {
|
|
"fact": "conformance {{marker}} PRIVATE-SENTINEL commitment",
|
|
"provenance": "conformance run {{marker}}",
|
|
"entity": "people/conformance-{{marker}}",
|
|
"kind": "commitment",
|
|
"visibility": "private"
|
|
},
|
|
"validateSchema": true
|
|
},
|
|
{
|
|
"name": "recall by entity round-trips the remembered fact (superset envelope)",
|
|
"verb": "recall",
|
|
"params": {
|
|
"entity": "people/conformance-{{marker}}"
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "protocol_version",
|
|
"equals": 1
|
|
},
|
|
{
|
|
"path": "total",
|
|
"gte": 1
|
|
},
|
|
{
|
|
"path": "facts.0.fact_id",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"path": "facts.0.provenance",
|
|
"type": "string"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "recall with budget reports consistent budget meta",
|
|
"verb": "recall",
|
|
"params": {
|
|
"entity": "people/conformance-{{marker}}",
|
|
"budget_tokens": 10000
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "budget_tokens",
|
|
"equals": 10000
|
|
},
|
|
{
|
|
"path": "budget_used",
|
|
"gte": 0
|
|
},
|
|
{
|
|
"path": "budget_used",
|
|
"lte": 10000
|
|
},
|
|
{
|
|
"path": "dropped_count",
|
|
"gte": 0
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "recall with budget smaller than the first item drops everything",
|
|
"verb": "recall",
|
|
"params": {
|
|
"entity": "people/conformance-{{marker}}",
|
|
"budget_tokens": 1
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "total",
|
|
"equals": 0
|
|
},
|
|
{
|
|
"path": "dropped_count",
|
|
"gte": 1
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "recall with query returns the search arm (degradation allowed, never an error)",
|
|
"verb": "recall",
|
|
"params": {
|
|
"query": "conformance {{marker}} protocol round-trip",
|
|
"budget_tokens": 8000
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "results",
|
|
"type": "array"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "entity resolves the round-trip entity to a card",
|
|
"verb": "entity",
|
|
"params": {
|
|
"name": "people/conformance-{{marker}}"
|
|
},
|
|
"validateSchema": true,
|
|
"requiresSeededEntity": true,
|
|
"expect": [
|
|
{
|
|
"path": "found",
|
|
"equals": true
|
|
},
|
|
{
|
|
"path": "protocol_version",
|
|
"equals": 1
|
|
},
|
|
{
|
|
"path": "card.entity.slug",
|
|
"type": "string"
|
|
},
|
|
{
|
|
"path": "card.backlink_count",
|
|
"gte": 0
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "entity miss returns found:false + suggestions (never an error)",
|
|
"verb": "entity",
|
|
"params": {
|
|
"name": "zzz-no-such-entity-{{marker}}"
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "found",
|
|
"equals": false
|
|
},
|
|
{
|
|
"path": "suggestions",
|
|
"type": "array"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "entity card never leaks private facts to remote callers (fence test)",
|
|
"verb": "entity",
|
|
"params": {
|
|
"name": "people/conformance-{{marker}}"
|
|
},
|
|
"requiresSeededEntity": true,
|
|
"expect": [
|
|
{
|
|
"path": "card.open_threads",
|
|
"absentOrNotContains": "PRIVATE-SENTINEL"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "forget expires the remembered fact",
|
|
"verb": "forget",
|
|
"params": {
|
|
"id": "{{id:fact2}}",
|
|
"reason": "conformance cleanup"
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "expired",
|
|
"equals": true
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "forget again is idempotent (expired:false, success)",
|
|
"verb": "forget",
|
|
"params": {
|
|
"id": "{{id:fact2}}"
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "expired",
|
|
"equals": false
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "forget unknown id returns not_found with a suggestion",
|
|
"verb": "forget",
|
|
"params": {
|
|
"id": "999999999"
|
|
},
|
|
"expectErrorCode": "not_found",
|
|
"expectSuggestion": true
|
|
},
|
|
{
|
|
"name": "synthesize answers (or reports unavailable) — cost-gated, pass --synthesize",
|
|
"verb": "synthesize",
|
|
"params": {
|
|
"question": "What do we know about conformance {{marker}}?"
|
|
},
|
|
"requiresSynthesizeFlag": true
|
|
},
|
|
{
|
|
"name": "context_pack returns a schema-valid bundle for unknown entities (empty, not an error)",
|
|
"verb": "context_pack",
|
|
"params": {
|
|
"entities": "conformance-nonexistent-{{marker}}",
|
|
"budget_tokens": 500
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "protocol_version",
|
|
"equals": 1
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "delta with an explicit epoch since returns a schema-valid delta",
|
|
"verb": "delta",
|
|
"params": {
|
|
"since": "1970-01-01T00:00:00Z",
|
|
"budget_tokens": 500
|
|
},
|
|
"validateSchema": true,
|
|
"expect": [
|
|
{
|
|
"path": "protocol_version",
|
|
"equals": 1
|
|
},
|
|
{
|
|
"path": "since",
|
|
"equals": "1970-01-01T00:00:00.000Z"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "delta without since or session_id is invalid_params with a suggestion",
|
|
"verb": "delta",
|
|
"params": {},
|
|
"expectErrorCode": "invalid_params",
|
|
"expectSuggestion": true
|
|
}
|
|
]
|