Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix: pre-landing review fixes (managed turn-rule entry never makes the lane yield to itself; loops notice tests and guide)

garrytan9f80af00d1d4
diff --git a/docs/guides/open-loops.md b/docs/guides/open-loops.md
index 4dc7c10ec6..01a9de49da 100644
--- a/docs/guides/open-loops.md
+++ b/docs/guides/open-loops.md
@@ -372,10 +372,11 @@ an empty inbox. Any Google access path works to fix it: `gbrain google setup`
(BYO OAuth) or `--access command|env` on `sources add` (an existing Google
CLI or token-minting gateway; see
[google-connect.md](google-connect.md#other-ways-to-reach-google-no-gbrain-oauth)).
-A remote caller (MCP) gets no digest, so it gets a `loops_no_google_in_scope`
-notice instead: the answer covered only the sources the call read (named, all
-inside the grant), pass `source_id` for a granted google source, and the fix
-lists them.
+A remote caller (MCP) gets no digest, so when its answer is empty and its
+scope holds no google source it gets a `loops_no_google_in_scope` notice
+instead: the answer covered only the sources the call read (named, all inside
+the grant), pass `source_id` for a granted google source, and the fix lists
+them.
The notice never names a source outside the grant, so it reads the same
whether or not one exists.
diff --git a/src/core/setup/turn-hook.ts b/src/core/setup/turn-hook.ts
index c613eb7fcb..648fd2f00a 100644
--- a/src/core/setup/turn-hook.ts
+++ b/src/core/setup/turn-hook.ts
@@ -123,7 +123,7 @@ export function turnRuleHookYields(harness: string, cwd: string, managedDir?: st
return claudePromptEntries(claudeUserSettingsPath()).some((e) => isOtherGbrainEntry(e))
|| claudePromptEntries(join(cwd, '.claude', 'settings.local.json')).some((e) => isOtherGbrainEntry(e))
|| claudePromptEntries(join(cwd, '.claude', 'settings.json')).some((e) => isOtherGbrainEntry(e, true))
- || claudeManagedSettingsPaths(managedDir).some((path) => claudePromptEntries(path).some((e) => isTurnRuleEntry(e) || isOtherGbrainEntry(e)));
+ || claudeManagedSettingsPaths(managedDir).some((path) => claudePromptEntries(path).some((e) => isOtherGbrainEntry(e)));
}
/** Install or refresh the turn-rule hook. Never throws; anything it cannot write safely comes back as `print` with the command that wires it. */
diff --git a/test/loops-remote-scope-notice-7286.test.ts b/test/loops-remote-scope-notice-7286.test.ts
index 54e81d384f..3560e739b4 100644
--- a/test/loops-remote-scope-notice-7286.test.ts
+++ b/test/loops-remote-scope-notice-7286.test.ts
@@ -70,6 +70,15 @@ describe('#7286 open_loops for a remote caller bound to a non-google source', ()
expect(notices.map(n => n.code)).not.toContain('loops_no_google_in_scope');
});
+ test('a non-google scope that returns loops carries no such notice', async () => {
+ await upsertOpenLoop(engine, { sourceId: 'source-a', dedupKey: 'thread:2b7c1d0e9f8a6b54:unanswered_inbound', loopType: 'unanswered_inbound',
+ counterpartyEmail: '[email protected]', summary: 'Reply owed to [email protected]', evidence: [{ message_id: '2b7c1d0e9f8a6b54', quote: 'Any update?' }],
+ threadId: '2b7c1d0e9f8a6b54', detector: 'deterministic_thread' } as Parameters<typeof upsertOpenLoop>[1]);
+ const { result, notices } = await call({});
+ expect(result.count).toBeGreaterThan(0);
+ expect(notices.map(n => n.code)).not.toContain('loops_no_google_in_scope');
+ });
+
test('a failed google-source read carries no such notice (it is not a grant problem)', async () => {
const notices: Notice[] = [];
const failing = new Proxy(engine, { get(t, k, r) {
diff --git a/test/turn-hook-managed-settings-8057.test.ts b/test/turn-hook-managed-settings-8057.test.ts
index b20fc8446e..8e0f1fad53 100644
--- a/test/turn-hook-managed-settings-8057.test.ts
+++ b/test/turn-hook-managed-settings-8057.test.ts
@@ -55,12 +55,12 @@ describe('Claude Code managed-settings hooks (#8057)', () => {
});
});
- test('a gbrain turn-rule hook in managed settings makes the user turn-rule lane yield', async () => {
+ test('a turn-rule hook in managed settings never makes the turn-rule lane yield to itself', async () => {
const s = sandbox();
- const turnRule = { hooks: { UserPromptSubmit: [{ hooks: [{ type: 'command', command: '/opt/gbrain/bin/gbrain hook user-prompt', _gbrain: 'turn-rule-v1' }] }] } };
+ const turnRule = { hooks: { UserPromptSubmit: [{ hooks: [{ type: 'command', command: 'env GBRAIN_HOOK_LANE=turn-rule /opt/gbrain/bin/gbrain hook user-prompt', _gbrain: 'turn-rule-v1' }] }] } };
writeFileSync(join(s.managed, 'managed-settings.json'), JSON.stringify(turnRule));
await withEnv(s.env, async () => {
- expect(turnRuleHookYields('claude-code', s.project, s.managed)).toBe(true);
+ expect(turnRuleHookYields('claude-code', s.project, s.managed)).toBe(false);
});
});