Skip to content

gstack-brain-cache: single-page entity lookups always miss (reads page.body from gbrain get --json; mixed-case slug) #4265

Closed

Description

@stevotcp

Summary

bin/gstack-brain-cache never returns a digest for single-page entities (product, brand, competitive-intel, user-profile) even when the page exists in the brain. The planning skills then print "no product digest available yet" on every run, and brain-cache/_meta.json shows last_attempt timestamps with an empty last_refresh. Nothing surfaces the failure.

Cause

fetchSimplePage (around line 520 on main) does:

const result = spawnGbrain(['get', slug, '--json'], { timeout: 10_000 });
if (result.status !== 0) return null;
const page = JSON.parse(result.stdout) as { body?: string; title?: string };
if (!page?.body) return null;
return compressPage(slug, page.title || slug, page.body);

Two mismatches with what gbrain get returns:

  1. Field name. It reads the page text from page.body.

    • gbrain 0.46.x: gbrain get <slug> --json prints the page as markdown (frontmatter + body), not JSON, so JSON.parse throws and the function returns null. (Observed live.)
    • gbrain 0.60.x: --json does print JSON, but in get_page results body is the name of the read mode (auto / full / none / outline / window), and the text is carried in compiled_truth / timeline / content (src/core/ops/get-page-body.ts, src/cli/page-render.ts). So page.body is either absent or a mode string, never the page text. (From reading the 0.60.626.0 source; not run live.)
  2. Slug case. The slug is built from the project slug as-is, e.g. gstack/product/<Owner-Name>-<repo>, which keeps the GitHub owner's capitalisation. gbrain lowercases path-derived slugs (pathToSlug in src/core/sync.ts), and on 0.46.x gbrain get with the mixed-case slug returns page_not_found while the lowercase slug resolves. (Observed live on 0.46.x; not checked on 0.60.x.)

Repro (gbrain 0.46.29, gstack 1.98.0.0, macOS, Postgres engine)

  1. In a repo whose project slug contains capitals (gstack-slug → SLUG=Some-Org-some-repo), create the page gstack/product/Some-Org-some-repo in the brain (gbrain put stores it as gstack/product/some-org-some-repo).
  2. gstack-brain-cache refresh --entity product --project Some-Org-some-repo → failed to refresh product
  3. gstack-brain-cache get product --project Some-Org-some-repo → (missing: brain unreachable; no cache available)
  4. gbrain get gstack/product/some-org-some-repo returns the page, so the brain is reachable and the page exists.

Expected

A digest for the product page, or a message that distinguishes "page not found" from "brain unreachable".

Suggested fix

  • Read the text from the fields get_page actually returns (compiled_truth, falling back to content), and tolerate non-JSON output from older gbrain.
  • Lowercase the slug before the lookup (or resolve it via gbrain slug resolution).
  • Report page_not_found separately from an unreachable brain so the "missing" message is accurate.
  • The existing brain-cache tests appear to stub gbrain; a fixture with a real get --json payload would catch this.

gstack-gbrain-read-capability.ts parses get --json too but only checks source_id and slug, so it is not affected by the field name.

Activity

  1. capy-ai commented on Nov 10, 2026

    @capy-ai
    Contributor

    Thanks for the clear report. On main, fetchSimplePage in bin/gstack-brain-cache still reads page.body from gbrain get --json and passes the project slug with its original case, so single-page digests can't be found as you describe. We'll check which fields current gbrain returns before changing it. gstack is in a tooling freeze until November 21, so it will be looked at after that.

  2. added
    bug
    S3
    on Nov 10, 2026
  3. capy-ai commented on Nov 22, 2026

    @capy-ai
    Contributor

    Picking this up. A maintainer agent working through a batch of fixes (our tracking thread GSTA-804) will first reproduce this on current main. If it reproduces, the agent fixes it on main and we'll close this issue with a link when the change lands. If it no longer reproduces, we'll close it and say what changed. PR #4316 is the starting point.

  4. capy-ai commented on Nov 22, 2026

    @capy-ai
    Contributor

    Fixed in #4685, now merged. Single-page brain-cache digests now read compiled_truth (or content) under the lowercase slug gbrain stores. Thanks for tracking down both causes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    S3bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions