You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gbrain call --source has no effect on code_def and code_refs; no per-call way to scope them
#9010
gbrain call --source <id> code_def and code_refs give no way to scope the read to one source, and nothing tells the caller that --source did not apply. On a brain with several code sources the output can look like an answer about the source that was named.
This is not a report that brain-wide is wrong. It is documented and tested: docs/architecture/key-files/commands-1.md:39 says the trusted-local wrappers keep brain-wide behaviour, and test/code-intel-source-scope.test.ts:139, test/code-read-currency.test.ts:122 and test/e2e/code-intel-mcp-ops-pglite.test.ts:253 pin it. #4749, adopted through #4790, left the operations out on purpose, and #4747's item on declaring source_id on them was not adopted. The gap is only on a source the caller named. The flag is accepted and resolves the named source (src/commands/call.ts:31), and src/mcp/server.ts:634-635 says it is there so gbrain call --source X <op> <json> can scope the op handler. The header of src/core/ops/code-intel.ts:34-35 also describes these operations as source-scoped with per-call source_id. The handlers pass {} to readPolicyOpts for trusted local callers (src/core/ops/code-intel.ts:134, :161), so ctx.sourceId has no effect, and they cannot tell an explicit source from an ambient one.
It matters more while remote code reads are suspended (#5052, discussion #8171), because gbrain call is the route the refusal names.
Measured on 0.60.602.0, Postgres, with masked source names; the symbol is defined only in source-b. Code read at master d253ec0.
gbrain call --source source-a code_refs on a common word returned the first 50 rows (the default limit), all from source-b.
What does the solution look like?
Any one of these, with an unqualified call staying brain-wide as the tests pin:
Declare optional source_id and all_sources on code_def and code_refs, honoured for trusted local callers, matching code_callers and code_callees.
Have gbrain call print a one-line note on stderr when it was given --source for an operation that does not apply it.
Add a docs line saying these two operations ignore --source on gbrain call, and that gbrain code-def and gbrain code-refs are the scoped route.
Alternatives considered
The dedicated gbrain code-def --source and gbrain code-refs --source are scoped and work. The cost is knowing that the two commands differ, since gbrain call gives no sign of it.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
What problem does this solve?
gbrain call --source <id> code_defandcode_refsgive no way to scope the read to one source, and nothing tells the caller that--sourcedid not apply. On a brain with several code sources the output can look like an answer about the source that was named.This is not a report that brain-wide is wrong. It is documented and tested:
docs/architecture/key-files/commands-1.md:39says the trusted-local wrappers keep brain-wide behaviour, andtest/code-intel-source-scope.test.ts:139,test/code-read-currency.test.ts:122andtest/e2e/code-intel-mcp-ops-pglite.test.ts:253pin it. #4749, adopted through #4790, left the operations out on purpose, and #4747's item on declaringsource_idon them was not adopted. The gap is only on a source the caller named. The flag is accepted and resolves the named source (src/commands/call.ts:31), andsrc/mcp/server.ts:634-635says it is there sogbrain call --source X <op> <json>can scope the op handler. The header ofsrc/core/ops/code-intel.ts:34-35also describes these operations as source-scoped with per-callsource_id. The handlers pass{}toreadPolicyOptsfor trusted local callers (src/core/ops/code-intel.ts:134,:161), soctx.sourceIdhas no effect, and they cannot tell an explicit source from an ambient one.It matters more while remote code reads are suspended (#5052, discussion #8171), because
gbrain callis the route the refusal names.Measured on 0.60.602.0, Postgres, with masked source names; the symbol is defined only in
source-b. Code read at master d253ec0.gbrain call --source source-a code_def '{"symbol":"<symbol>"}'source_id: source-bgbrain call code_def '{"symbol":"<symbol>","source_id":"source-a"}'source_id: source-b, no warninggbrain code-def <symbol> --source source-a --jsonscope: single, count 0gbrain code-def <symbol> --source source-b --jsonscope: single, count 1gbrain call --source source-a code_refson a common word returned the first 50 rows (the default limit), all fromsource-b.What does the solution look like?
Any one of these, with an unqualified call staying brain-wide as the tests pin:
source_idandall_sourcesoncode_defandcode_refs, honoured for trusted local callers, matchingcode_callersandcode_callees.gbrain callprint a one-line note on stderr when it was given--sourcefor an operation that does not apply it.--sourceongbrain call, and thatgbrain code-defandgbrain code-refsare the scoped route.Alternatives considered
The dedicated
gbrain code-def --sourceandgbrain code-refs --sourceare scoped and work. The cost is knowing that the two commands differ, sincegbrain callgives no sign of it.All reactions