Skip to content

gstack-gbrain-sync: generated code source ID exceeds gbrain 32-char alnum-hyphen limit (and contains periods) #1434

@agile-operators

Description

@agile-operators

Repro

Running /sync-gbrain (gstack v1.26.4.0, gbrain v0.27.0) on a repo whose origin is https://github.com/agile-operators/Social-Samurai.git produces this error on the code stage:

ERR   code         source registration failed: gbrain sources add gstack-code-github.com-agile-operators-social-samurai failed:
Invalid source id "gstack-code-github.com-agile-operators-social-samurai". Must be 1-32 lowercase alnum chars with optional interior hyphens (e.g. "wiki", "yc-media").

Memory + brain-sync stages still complete OK, but no code corpus gets registered for this repo. Capability check correctly drops to 0 and /sync-gbrain (correctly) skips writing the ## GBrain Search Guidance block to CLAUDE.md.

Root cause

gstack-gbrain-sync.ts builds the source ID by concatenating gstack-code- with the origin URL host and path. For any GitHub origin the result is well over 32 chars and includes a period (github.com), neither of which gbrain accepts.

The generated form: gstack-code-<host>-<org>-<repo>gstack-code-github.com-agile-operators-social-samurai (53 chars, contains .).

gbrain's source-id rule (per the error): 1-32 lowercase alnum with optional interior hyphens.

Suggested fix

Two-step normalization on the auto-generated ID:

  1. Slugify — lowercase, replace any non-alnum-or-hyphen with hyphens, collapse runs of hyphens, trim leading/trailing hyphens.
  2. Truncate to 32 chars — but truncate the middle of the org/repo portion, not the gstack-code- prefix (which is the discriminator). Or use a short stable hash suffix when the slugified form is too long, e.g. gstack-code-<repo>-<short-hash>.

For monorepo / multi-product setups, an optional per-repo override via ~/.gstack/config.json or a .gstack/code-source-id file would let users pick a meaningful short code instead of relying on the generated slug. For example, the user filing this issue wants:

  • SS for Social Samurai (this repo)
  • SPS for Speaker Scout (sibling repo)

Both well under 32 chars, both readable when later running gbrain sources list or gbrain search --source <id>.

A config schema like:

{
  "gbrain_code_source_id": "ss"
}

would let the user opt into the short form; absent config, the slugify+truncate fallback kicks in.

Environment

  • gstack v1.26.4.0
  • gbrain v0.27.0 (postgres engine, PgBouncer transaction mode on port 6543)
  • macOS

Related (separate issue likely warranted)

gbrain capability check (gbrain put + gbrain search round-trip) fails under PgBouncer transaction mode — search returns "No results" for a value that was successfully put. The [gbrain] Prepared statements disabled warning hints at the root cause; GBRAIN_PREPARE=true override is mentioned in the warning but does not appear to be threaded through the gstack env. Happy to file separately if useful.

Filed via Claude Code at the user's request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions