Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(access): shared-agent doctor entry in the registry's literal form; goldens and frozen-byte helpers carry B's additive _meta.access

garrytanc89510bd0e39
diff --git a/scripts/module-size-limits.tsv b/scripts/module-size-limits.tsv
index 320c031ef6..d1080854e5 100644
--- a/scripts/module-size-limits.tsv
+++ b/scripts/module-size-limits.tsv
@@ -47,4 +47,4 @@ src/commands/doctor/checks/extraction-sync.ts 1500 ratchet +7 GBRA-130 A-1: link
src/core/search/evidence-delivery.ts 1755 ratchet +5 W5: EvidencePlan.rankCut resolved with the plan (logic in search/page-rank-cut.ts); +20 W5 whole_pages: wholeCost prices a block as delivery would emit it whole (needs the private Block/enrichBlock internals) and the cut is wired before allocate (cutWholePages lives in search/page-rank-cut.ts); new row: crossed the 1500 unlisted cap at the #6367 merge (master 1479, its explicit-budget cap) by the C1 date header threaded through every block path, cap included; pagePlanHits (search/page-plan-hits.ts) and the header loader (evidence-date.ts blockDateHeaders) were peeled first; peel candidate: allocateCapped; +8 at the #6396 merge: page evidence text cut through the fence-chunk trust overlay and the caller minTrust floor (re-summed: our 1504 + master +8); +119 Cat 40 next wave F2: the search.long_page_unit policy (withLongPagePolicy, selectLongPages size preflight with page/byte/deadline limits) and the long-page fetch and fallback in deliverEvidence, kept in the shared seam the plan names (gbrain-evals docs/plans/2026-10-11-cat40-next-wave, F2); +17 F2 rework to the frozen-comparison policy: search.long_page_min_chars (rendered-body characters, default 20,000) read in withLongPagePolicy, a character count in the preflight, the rendered-body confirmation in deliverEvidence, and the long-page row exemption in capDeliveredSnippets (re-summed at the 0.60.225.0 merge: master 1537 + F2 136); +39 Wave B PR 2 lane 2b: planSegmentedBlock joins the windows search/segmented-evidence.ts reads around a segmented page's hits into one run-marked document (needs the private Doc/Piece/buildDoc/locateAnchor internals), planBlock's unit cut split into blockFromDoc for both, sections bounded by their run, selectionCost counts a gap between runs, and the fetch skips the whole-body fence overlay for a segmented page; +4 segmented pages read at once before planning (segmentedReads; the read is search/segmented-evidence.ts, the statements page-body/read-range.ts); +17 GBRA-156: tail trim plan flag, DeliverOptions.query, DeliveryMeta.tail_trim, the trim call and the frozen-hit score/query library fields (logic in search/evidence-tail-trim.ts; interface fields cannot move); +7 GBRA-205: EvidencePlan.titleHeader and DeliveryMeta.title_header (interface fields cannot move) and the titles option on the header loader (logic in search/evidence-date.ts; the query budget key lives in search/evidence-packing.ts); +11 #7600: assemble_evidence quotes conversation rows and capEvidenceToBudget counts the quote fence (logic in search/transcript-quote.ts); +2 GBRA-156 /ship review: the cut-path admission and title room count the quote fence; +2 GBRA-156 /ship review pass 2: capEvidenceToBudget counts the fence only for the paths that fence (quote flag; recall counts the text as returned)
src/commands/config.ts 1524 ratchet new row: crossed the 1500 unlisted cap in wave 15 P7.4 #5461: set-time validation of think.pages_budget_chars / think.excerpt_ceiling_chars (range + parser live in core/think/pages-budget.ts), mirroring the cycle.consolidate.cluster_threshold hook; +1 wave 16 G5.1 (#6495): set-time refusal hook for search.keyword_statement_timeout_ms (check lives in commands/config/keyword-timeout-value.ts); +1 wave 18b lane 5 (#5012 item 6): search.contextual_retrieval prints the existing-pages hint after the write (text lives in commands/config/contextual-mode-hint.ts); +1 #6712 PR 2: retired/rollback sync key dispatch line (logic in core/sync-config-keys.ts handleSyncKeyConfig); +1 #6865: sync.slug_conflicts.auto_remove boolean validation at set time (refusal text in repair/slug-autoheal.ts); +1 #6948: sync.origin_twins.auto_resolve boolean validation at set time (refusal text in repair/origin-twins-heal.ts); +2 #6795: config set chat_model/expansion_model help line and the model-pin import (shadow report and file-pin unset live in commands/config/model-pin-shadow.ts); +1 #6712 PR 4b: sync.admission set-time hook (value logic in commands/config/sync-admission-value.ts); +4 #7130: set-time refusal hook for sync.max_deletes / sync.max_delete_ratio (and .source.<id>) / purge.retention_hours (check lives in core/sync-reconcile.ts deleteSafetyConfigRefusal); +1 GBRA-150: sync.metafile_pages set-time route (body in config/sync-metafile-pages-value.ts); re-summed at the v0.60.330.0 merge (1520 measured); +2 #7242 minions.terminal_hook file-plane key and its set branch (logic in minions/terminal-hook.ts); +1 GBRA-161: generations.* set-time route (refusal in commands/config/generations-values.ts); +1 GBRA-207 #7630: sync.repo_path set-time refusal hook (refusal in core/sync-config-keys.ts syncRepoPathRefusal)
src/commands/mcp-expose.ts 1519 ratchet hosted_option: Session carries the gbrain.io coaching notice on the first-receipt run and Tailscale/service friction exits (copy, refs and gating live in core/onboard/hosted-option.ts); +7 GBRA-199: --surface help lines, surfaceChosen option field and the advertise pass-through (registrationAdvertise in core/mcp-registration.ts)
-src/core/behavior-change-notice.ts 1574 ratchet the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +1 GBRA-156 #7593: private_pages_granted_sources row; +2 GBRA-218 A1: member_read_access_gbra218 and member_access_hatch_scope_gbra218 rows (re-summed at the #7593 merge: 1571 + 2); +1 GBRA-218 A2: folder_access_rules_gbra218 row (1574 measured)
+src/core/behavior-change-notice.ts 1575 ratchet the BEHAVIOR_CHANGES table grows by one row per disclosed change: +4 the #7891 provenance-drift and #7917/#7918 maintenance-lowering rows and their comments (re-summed at the 0.60.495.0 merge: 1547 + 4); +2 GBRA-205 saved_facts_stems row and its comment (re-summed at the #7901 0.60.492.0 merge: 1541 + 2); +2 GBRA-205 search.query_facts_block default-on row and its approval comment (re-summed at the #7610 0.60.490.0 merge: 1539 + 2); +2 the #7900 content checkpoint host-move row (since TBD until the merge slot), +2 the #7897 private-hold sweep row (since TBD until the merge slot), +2 the #7880 ingest_capture and company-brain private-hold row (since TBD until the merge slot), +5 the frozen-source wave comment and four rows (#7868, #7850, #7869/#7870, #7871), +2 the #7848 visibility_noncanonical hold row (since TBD until the merge slot), +2 the #7846 extract_atoms session-source row (re-summed at the 0.60.481.0 merge: master 1524 + 2), +2 the #7805 synthesize session-source and #7841 visibility_not_applied rows (re-summed at the 0.60.480.0 merge: master 1522 + 2), +2 strict door planned-state row (#7705, re-summed at the 0.60.470.0 merge: master 1514 + 2), +2 Bun floor 1.4.4 row (#7644), the GBRA-95 RLS backfill row (+2), +3 rows for #7596 pass_interrupted, #7599 read-only serve and the --access=read-only ceiling, +1 G5 lane C trust_release row, +1 #7619 cli_flag_equals, +3 GBRA-207 #7630 relative-anchor and stalled-write rows, +2 the #7632 function search_path disclosure row and +2 the #7679 orphaned worktree refresh row (re-summed at the 0.60.471.0 merge: master 1516 + 2), +2 the #7814 retired v0.13.1 grandfather row, +2 the #7618 conversion withhold/progress/push row (master 1520 + 2); the behavior-change table split (#7607) retires this row; +4 GBRA-188 #7489: the wave comment and three rows (brain-first instructions, starter surface default, per-turn rule); +1 GBRA-188 plugin_turn_hook_gbra188 row; +1 GBRA-242 provider_key_rules_7959 row (#7959), +2 the GBRA-199 registration_lists_verbs row (since TBD until the merge slot); +2 GBRA-133 #7652: the #7611 pass_abandoned reader row and the lean read-only serve socket row (re-summed at the 0.60.503.0 merge: master 1555 + 2); +1 GBRA-243: the per-turn hook disclosure row (rows are data and cannot move); +4 GBRA-156 #7598 harness wave comment and rows (remote page cap, sources_not_readable refusal, sources add next step); +4 GBRA-156 #7601 search_quotes_transcript_rows comment and row; +1 GBRA-175 #7475 autopilot_restarts_serve_7475 row (re-summed at the #8012 merge: 1566 + 1); +3 #7997/#8014/#8015 rows (redaction markers, company db_only keep, ignored supabase_only scope); +1 GBRA-156 #7593: private_pages_granted_sources row; +2 GBRA-218 A1: member_read_access_gbra218 and member_access_hatch_scope_gbra218 rows (re-summed at the #7593 merge: 1571 + 2); +1 GBRA-218 A2: folder_access_rules_gbra218 row (1574 measured); +1 GBRA-231: shared_agent_audience_gbra231 row (1575 measured)
diff --git a/src/commands/doctor/checks/shared-agent-access.ts b/src/commands/doctor/checks/shared-agent-access.ts
index 8ff39a6dae..8ced4c21a0 100644
--- a/src/commands/doctor/checks/shared-agent-access.ts
+++ b/src/commands/doctor/checks/shared-agent-access.ts
@@ -18,10 +18,10 @@ import { STDIO_MAY_ACT_FOR_KEY } from '../../../core/access/audience.ts';
const name = 'access_may_act_for_wildcard';
const SAMPLE = 20;
-async function runSharedAgentAccess(ctx: DoctorContext): Promise<Check[]> {
+async function sharedAgentVerdict(ctx: DoctorContext): Promise<Check> {
const engine = connectedEngine(ctx);
if (!(await accessRestrictionsPresent(engine).catch(() => true))) {
- return [infoCheck(name, 'Not applicable: no page names readers and no member exists.', 'not_applicable')];
+ return infoCheck(name, 'Not applicable: no page names readers and no member exists.', 'not_applicable');
}
try {
const rows = await engine.executeRaw<{ kind: 'token' | 'client'; id: string; name: string }>(
@@ -34,22 +34,29 @@ async function runSharedAgentAccess(ctx: DoctorContext): Promise<Check[]> {
const stdioWild = (stdio?.value ?? '').split(',').map(s => s.trim()).includes('*');
const named = [...rows.map(r => `${r.kind} ${r.name}`), ...(stdioWild ? [`config ${STDIO_MAY_ACT_FOR_KEY}`] : [])];
const details = { credentials: rows.map(r => ({ kind: r.kind, name: r.name })), stdio: stdioWild, truncated: rows.length === SAMPLE };
- if (!named.length) return [{ name, status: 'ok', details, message: 'No credential may act for every member (no may_act_for holds *).' }];
+ if (!named.length) return { name, status: 'ok', details, message: 'No credential may act for every member (no may_act_for holds *).' };
const first = rows[0];
- return [{ name, status: 'warn', details,
+ return { name, status: 'warn', details,
message: `${named.length} credential(s) may act for any member (may_act_for holds *): ${named.slice(0, 5).join(', ')}. `
+ 'A harness using one can name any enabled member as its audience and read what that member reads. List the people it serves instead.',
fix: first
? agentFix(['gbrain', 'access', 'check', first.kind === 'token' ? '--token' : '--client', first.kind === 'token' ? first.name : first.id, '--json'],
'Read-only: shows the credential\'s grant and may_act_for. Ask the user which members, groups or guest it serves before narrowing it with gbrain auth rescope ... --may-act-for <list>.', name, { ask_user: true })
- : agentFix(['gbrain', 'config', 'get', STDIO_MAY_ACT_FOR_KEY], `Read-only: shows ${STDIO_MAY_ACT_FOR_KEY}. Ask the user whom the stdio server serves before replacing * with that list.`, name, { ask_user: true }) }];
+ : agentFix(['gbrain', 'config', 'get', STDIO_MAY_ACT_FOR_KEY], `Read-only: shows ${STDIO_MAY_ACT_FOR_KEY}. Ask the user whom the stdio server serves before replacing * with that list.`, name, { ask_user: true }) };
} catch (error) {
- return [checkError(name, `run ${name}`, error)];
+ return checkError(name, `run ${name}`, error);
}
}
+async function runSharedAgentAccess(ctx: DoctorContext): Promise<Check[]> {
+ const checks: Check[] = [];
+ const { name: _name, ...verdict } = await sharedAgentVerdict(ctx);
+ checks.push({ name: 'access_may_act_for_wildcard', ...verdict });
+ return checks;
+}
+
export const sharedAgentAccessEntry: DoctorEntry = {
- name,
- emits: [name],
+ name: 'access_may_act_for_wildcard',
+ emits: ['access_may_act_for_wildcard'],
run: runSharedAgentAccess,
};
diff --git a/test/e2e/facts-context-injection-postgres.test.ts b/test/e2e/facts-context-injection-postgres.test.ts
index 76a42edeb9..8fdd1d82af 100644
--- a/test/e2e/facts-context-injection-postgres.test.ts
+++ b/test/e2e/facts-context-injection-postgres.test.ts
@@ -58,7 +58,7 @@ d('_meta injection on Postgres', () => {
remote: true, sourceId: 'default', metaHook: failHook,
});
expect(r.isError).toBeFalsy();
- expect(r._meta).toBeUndefined();
+ expect(Object.keys(r._meta ?? {})).toEqual(['access']);
});
test('recall op itself does NOT get _meta injection (anti-loop)', async () => {
diff --git a/test/fixtures/agent-contract/v1/journey/caller-mistake.json b/test/fixtures/agent-contract/v1/journey/caller-mistake.json
index 3867837c5c..b4d1e118ad 100644
--- a/test/fixtures/agent-contract/v1/journey/caller-mistake.json
+++ b/test/fixtures/agent-contract/v1/journey/caller-mistake.json
@@ -1,4 +1,13 @@
{
+ "_meta": {
+ "access": {
+ "member": null,
+ "groups": [],
+ "audience": null,
+ "policy_rev": null,
+ "relaxation": "none"
+ }
+ },
"content": [
{
"type": "text",
diff --git a/test/fixtures/agent-contract/v1/journey/recall-degraded.json b/test/fixtures/agent-contract/v1/journey/recall-degraded.json
index 91e4c8ab76..b6ea1f96eb 100644
--- a/test/fixtures/agent-contract/v1/journey/recall-degraded.json
+++ b/test/fixtures/agent-contract/v1/journey/recall-degraded.json
@@ -39,7 +39,14 @@
},
"contract_version": 1
}
- ]
+ ],
+ "access": {
+ "member": null,
+ "groups": [],
+ "audience": null,
+ "policy_rev": null,
+ "relaxation": "none"
+ }
},
"content": [
{
diff --git a/test/fixtures/goldens/doctor/registry-build-checks.json b/test/fixtures/goldens/doctor/registry-build-checks.json
index f3396287cc..d417e3992e 100644
--- a/test/fixtures/goldens/doctor/registry-build-checks.json
+++ b/test/fixtures/goldens/doctor/registry-build-checks.json
@@ -385,6 +385,10 @@
"category": "brain",
"name": "access_policy_store_mismatch"
},
+ {
+ "category": "brain",
+ "name": "access_may_act_for_wildcard"
+ },
{
"category": "ops",
"name": "rls"
diff --git a/test/helpers/evidence-delivery-fixture.ts b/test/helpers/evidence-delivery-fixture.ts
index fcae34f52e..b45a048ffa 100644
--- a/test/helpers/evidence-delivery-fixture.ts
+++ b/test/helpers/evidence-delivery-fixture.ts
@@ -100,7 +100,8 @@ export function offPathMcpBytes(res: { content: { type: string; text: string }[]
// Cat 40 Hard F2's keyword count line and fields and F4's row-date line are additive too
// (pinned in test/search-keyword-paging.test.ts and test/search-date-labels.test.ts).
const content = res.content.filter(c => !/^\[gbrain (notice |search\] |dates\] )/.test(c.text));
- const { gbrain_notices: _notices, ...meta } = res._meta ?? {};
+ // GBRA-231's additive `_meta.access` (the caller's applied view) is pinned in test/access-on-behalf-of.test.ts.
+ const { gbrain_notices: _notices, access: _access, ...meta } = res._meta ?? {};
if (meta.retrieval) meta.retrieval = withoutCounts(withoutTimings(meta.retrieval) as Record<string, unknown>);
return JSON.stringify({ ...res, content, ...(res._meta ? { _meta: Object.keys(meta).length > 0 ? meta : undefined } : {}) });
}