Repository navigation
Description
Summary
gstack-config set brain_trust_policy@local personal fails with a validation error when gbrain is configured as a stdio (local PGLite) engine, making /setup-gbrain report DONE_WITH_CONCERNS and silently skip writing the trust policy.
Root cause
endpoint_hash() in bin/gstack-config intentionally falls back to the literal string "local" when no MCP URL is found (stdio engines have no URL to hash):
# bin/gstack-config ~L161
# MCP server URL. Falls back to the literal 'local' when no MCP is configured.
endpoint_hash() {
...
printf '%s' "local" # ← stdio fallback
}The comment at L138 even documents this intent:
# brain_trust_policy@<hash> — unset on fresh install; setup-gbrain
# writes 'personal' for local engines,
However, the key validator on both get and set only allows hex characters after @:
# get (L265) and set (L280) — same pattern in both
if ! printf '%s' "$KEY" | grep -qE '^[a-zA-Z0-9_]+(@[a-f0-9]+)?$'; then
echo "Error: key must contain only alphanumeric characters, underscores, and an optional @<hex-hash> suffix" >&2
exit 1
filocal contains l and o which are outside [a-f0-9], so the key brain_trust_policy@local is rejected even though endpoint_hash() produces it by design.
The same hex-only pattern also appears in the get value-lookup grep (L270).
Affected lines
| Line | Code |
|---|---|
| 265 | grep -qE '^[a-zA-Z0-9_]+(@[a-f0-9]+)?$' (get validator) |
| 270 | grep -E "^${KEY%@*}(@[a-f0-9]+)?:" (get value lookup) |
| 280 | grep -qE '^[a-zA-Z0-9_]+(@[a-f0-9]+)?$' (set validator) |
Fix
Change [a-f0-9]+ → [a-zA-Z0-9]+ at all three sites. This covers both sha8/sha16 hex hashes (remote endpoints) and the local fallback (stdio engines) without opening up anything unsafe.
# get + set validators
grep -qE '^[a-zA-Z0-9_]+(@[a-zA-Z0-9]+)?$'
# get value lookup
grep -E "^${KEY%@*}(@[a-zA-Z0-9]+)?:"Error message wording should also drop "hex-" from "optional @<hex-hash> suffix".
Observed behaviour
/setup-gbrain on a stdio/local-PGLite engine reports:
DONE_WITH_CONCERNS — minor:
gstack-config set brain_trust_policy@local personal fails validation because
the @<hash> suffix regex requires hex-only ([a-f0-9]+) and endpoint-hash
returns the literal 'local' for stdio engines.
The trust policy is never written; the concern is non-fatal but visible on every /setup-gbrain run.
Verified in
~/.claude/skills/gstack commits a5833c4 (v1.57.10.0) and 8241949 (v1.57.9.0) — present in both.
Activity
JonasFocus commentedon Jun 13, 2026
I opened a focused fix in #1992.
The change keeps the base key validation the same, but allows the endpoint suffix after
@to be an alphanumeric endpoint id sobrain_trust_policy@localcan round-trip for local/stdio gbrain setups. I also added regression coverage for@localand punctuation rejection.hexorcist404 commentedon Jul 3, 2026
Confirming this still reproduces on gstack 1.58.5.0 (Windows 11, Git Bash), hit today during a fresh
/setup-gbrainwith a local PGLite engine.Every stdio setup hits this: the skill's Step 9.5 explicitly runs
set brain_trust_policy@$_HASHwith the hashendpoint-hashreturns, and that's the literallocalfor stdio engines. The three affected grep sites in the issue body are unchanged at 1.58.5.0 (validator at get/set + the get value-lookup). The fix in #1992 would resolve it.