Skip to content

gstack-decision-search --semantic honors GSTACK_BRAIN_SOURCE_ID - #4328

Closed
exGeni wants to merge 1 commit into
garrytan:mainfrom
exGeni:semantic-source-id
Closed

exGeni wants to merge 1 commit into
garrytan:mainfrom
exGeni:semantic-source-id

Conversation

@exGeni

@exGeni exGeni commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Users can now set GSTACK_BRAIN_SOURCE_ID to point gstack-decision-search --semantic at a registered artifacts source outside ~/.gstack-brain-worktree, and its matching memory hits are appended to the decisions. Issue: #4327.

Why (in your own words)

The semantic lookup found the curated-memory source only by a local_path that ends in .gstack-brain-worktree. A source that holds the same artifacts repo elsewhere, such as a clone on a machine that is also the brain host, was never found, and the block was silently absent. gstack-gbrain-source-wireup and gstack-gbrain-sync already accept GSTACK_BRAIN_SOURCE_ID, but the semantic lookup did not read it.

This change gives the variable the precedence gstack-gbrain-sync.ts:274-275 uses:

  • When it is set, resolveMemorySourceId returns that id if a source with it is registered, and null otherwise.
  • When it is unset, the worktree match is unchanged.

The search stays scoped. An unregistered id degrades to the file results, never to an unscoped search, so the design test/gstack-decision-semantic.test.ts pins still holds. The doc comment that said "the caller then searches unscoped" is corrected, and the module header and the semanticRecall comment now describe the named source.

Live evidence

The two new tests fail on main and pass on this branch. Output trimmed to the result lines:

$ bun test test/gstack-decision-semantic.test.ts   # main's lib/, new tests
(fail) end-to-end with a fake gbrain shim > GSTACK_BRAIN_SOURCE_ID names a source outside the worktree and wins over it
(fail) end-to-end with a fake gbrain shim > an unregistered GSTACK_BRAIN_SOURCE_ID degrades to null (no fallback, no unscoped search)
 10 pass
 2 fail

$ bun test test/gstack-decision-semantic.test.ts   # this branch
 12 pass
 0 fail

On a real install whose artifacts source is a host-side clone, run from this branch's checkout (the decision text and slugs are replaced):

$ GSTACK_BRAIN_SOURCE_ID= bin/gstack-decision-search --query "<word>" --semantic
- <one decision line from the file store>

$ GSTACK_BRAIN_SOURCE_ID=<artifacts source id> bin/gstack-decision-search --query "<word>" --semantic
- <one decision line from the file store>

Related from memory (gbrain semantic recall):
  [0.52] projects/<slug>/checkpoints/<checkpoint>: ## Working on: ...
  [0.49] projects/<slug>/checkpoints/<checkpoint>: ## Working on: ...
  [0.49] projects/<slug>/checkpoints/<checkpoint>: ## Working on: ...

Scope

  • Changed:
    • lib/gstack-decision-semantic.ts: two lines in resolveMemorySourceId, and the three comments that describe how the source is found;
    • two tests in test/gstack-decision-semantic.test.ts;
    • test/gstack-decision-bins.test.ts: its --semantic helper drops an inherited GSTACK_BRAIN_SOURCE_ID, which would otherwise bypass the shim's worktree source on a developer machine that exports it;
    • the fragment changelog.d/semantic-source-id.md.
  • Verified live by:
    • the run above on gbrain 0.60.675.0;
    • the 8 decision test files (bun test test/*decision*.test.ts: 235 pass, 1 skip, 0 fail, both with the variable unset and with GSTACK_BRAIN_SOURCE_ID=zzz exported);
    • bun run typecheck:test (no new diagnostics);
    • bun run typecheck;
    • bin/gstack-prose-lint on the fragment.
  • Did NOT test:
    • the full free suite, which is left to CI;
    • macOS and Windows.
  • Behavior change: a set but unregistered GSTACK_BRAIN_SOURCE_ID now gives no related block, where it used to be ignored in favor of the worktree source. This matches gstack-gbrain-sync.ts:275.
  • Not changed:
    • matching the source by the id derive_source_id yields without a setting (option 2 in the issue);
    • GSTACK_BRAIN_WORKTREE, which the semantic lookup still does not read.

Liveness proof (required for external contributors)

image

Checklist

  • Liveness screenshot attached (GSTACK PR typed live into a real surface) or PR author is @garrytan (owner exemption)
  • This is not a generated-file-only diff (I edited the source/template and regenerated)
  • No ETHOS.md edits, and no changes to voice / founder perspective / YC references
  • New public command / external service / host adapter has an accepted issue linked (or N/A)
  • Linked issue or reproduction: [feature] gstack-decision-search --semantic: let GSTACK_BRAIN_SOURCE_ID name the memory source #4327

🤖 Generated with Claude Code

The semantic lookup found the artifacts source only by a local_path ending
in .gstack-brain-worktree. A source registered elsewhere never got the
related-from-memory block, and the override that gstack-gbrain-source-wireup
and gstack-gbrain-sync accept was not read. When GSTACK_BRAIN_SOURCE_ID is
set, use that source if it is registered and return null if it is not, the
precedence gstack-gbrain-sync uses; unset, keep the worktree match. The
search stays scoped. Also corrects the doc comment that said the caller
searches unscoped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trunk-io

trunk-io Bot commented Nov 13, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@exGeni
exGeni marked this pull request as ready for review November 13, 2026 02:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T02:08:53.434419Z b6c2a94 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@capy-ai

capy-ai Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Thank you, @exGeni. The gap is real on main at 1d3c63c: resolveMemorySourceId only matches a source by its worktree path, while the wireup and sync already honor GSTACK_BRAIN_SOURCE_ID. Since this adds a new way to pick the source, it goes through our short planning step first, and then a maintainer will land it on current main, crediting you. The tests you wrote help a lot.

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you for this. We're picking up the idea. A maintainer agent working through a batch of fixes (our tracking thread GSTA-804) will first reproduce the problem on current main. If it reproduces, the agent rebuilds the fix on main with you credited as co-author, because we don't merge outside branches directly, and we'll close this PR with a link when it lands. If it no longer reproduces, we'll close this and say what changed.

@capy-ai

capy-ai Bot commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Thank you! We rebuilt this change on current main in #4685, which is now merged, with you credited as co-author, so I'm closing this PR. Outside PRs get rebuilt rather than merged directly as part of our security process for code that runs.

@capy-ai capy-ai Bot closed this Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant