fix(gstack-config): accept @local endpoint ids for brain_trust_policy

endpoint-hash returns "local" for stdio/PGLite, but validators only
allowed hex suffixes, so setup-gbrain could not persist trust policy.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Sina
2026-07-10 11:21:19 -07:00
parent 7c9df1c568
commit db149a6162
3 changed files with 37 additions and 15 deletions
+13
View File
@@ -108,6 +108,13 @@ describe('gstack-config', () => {
expect(existsSync(join(nestedDir, 'config.yaml'))).toBe(true);
});
test('brain trust policy accepts local endpoint suffix', () => {
const { exitCode, stderr } = run(['set', 'brain_trust_policy@local', 'personal']);
expect(exitCode).toBe(0);
expect(stderr).toBe('');
expect(run(['get', 'brain_trust_policy@local']).stdout).toBe('personal');
});
// ─── list ─────────────────────────────────────────────────
test('list shows all keys', () => {
writeFileSync(join(stateDir, 'config.yaml'), 'auto_upgrade: true\nupdate_check: false\n');
@@ -139,6 +146,12 @@ describe('gstack-config', () => {
expect(stderr).toContain('alphanumeric');
});
test('set rejects endpoint suffix with punctuation', () => {
const { exitCode, stderr } = run(['set', 'brain_trust_policy@local-dev', 'personal']);
expect(exitCode).toBe(1);
expect(stderr).toContain('endpoint-id');
});
test('set preserves value with sed special chars', () => {
run(['set', 'test_special', 'a/b&c\\d']);
const { stdout } = run(['get', 'test_special']);