Skip to content

fix(memory-ingest): switch writer to gbrain put, retire legacy put_page#1341

Open
AZ-1224 wants to merge 1 commit intogarrytan:mainfrom
AZ-1224:fix-gbrain-put-page
Open

fix(memory-ingest): switch writer to gbrain put, retire legacy put_page#1341
AZ-1224 wants to merge 1 commit intogarrytan:mainfrom
AZ-1224:fix-gbrain-put-page

Conversation

@AZ-1224
Copy link
Copy Markdown

@AZ-1224 AZ-1224 commented May 6, 2026

Summary

bin/gstack-memory-ingest.ts calls the legacy flag-based gbrain put_page --slug X --title Y --type Z --tags T form. gbrain v0.27 retired it for the positional put <slug> (content via stdin, YAML frontmatter for metadata). Against any current gbrain, every page errors [put-error] ... Unknown command: put_page and bulk ingest produces 0 successful writes.

This PR:

  • Rewrites gbrainPutPage to invoke gbrain put <slug>, injecting title/type/tags as YAML frontmatter when the page body does not already start with one. The transcript builder already prepends frontmatter; the writer-side injection only fires for raw artifact pages.
  • Bumps gbrainAvailable() to probe gbrain --help for the put subcommand. If a future gbrain renames or removes it, the script fails fast with one clean error rather than N copies of "Unknown command: ...".
  • Adds two regression tests in test/gstack-memory-ingest.test.ts that stand up a fake gbrain shim on PATH:
    1. Writer hits gbrain put <slug> with stdin body + frontmatter and never invokes put_page.
    2. Pointing the writer at a legacy-only shim surfaces a single missing-put error from the availability probe.

Scope is intentionally tight: one function rewrite, one availability probe, two tests. No refactor of the writer abstraction.

Repro (before the fix)

# With gbrain v0.27.0+ on PATH and any transcripts in ~/.claude/projects/.../*.jsonl:
bun bin/gstack-memory-ingest.ts --bulk
# Every page errors: [put-error] ... Unknown command: put_page

Verified

  • bun test test/gstack-memory-ingest.test.ts — 17/17 pass (15 existing + 2 new regression tests).
  • Real-world: 61/62 pages ingested cleanly post-patch on a v0.27.0 install. The single failure was a within-batch slug collision unrelated to the writer.

Notes

  • The V1.5 NOTE block at the top of the file referenced put_page in prose. Updated to describe the current gbrain put <slug> (stdin, frontmatter) shape so the doc stays accurate; the future put_file blob-routing TODO is unchanged.
  • Section comment // ── Writer (calls gbrain put_page) ── updated to // ── Writer (calls \gbrain put`) ──`.

Test plan

  • bun test test/gstack-memory-ingest.test.ts passes
  • Manual --bulk run on a real gbrain v0.27.0 install ingests pages successfully
  • Fake-shim test catches a regression to put_page (verified: rolling back the writer makes the new test fail)

View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

…_page`

gbrain v0.27 retired the flag-based `put_page --slug X --title Y` form for
the positional `put <slug>` (content via stdin, YAML frontmatter for metadata).
Against any current gbrain, the writer returned `[put-error] Unknown command:
put_page` for every page; bulk ingest produced 0 successful writes.

Switch `gbrainPutPage` to `gbrain put <slug>`, injecting `title`/`type`/`tags`
as YAML frontmatter when the page body does not already start with one (the
transcript builder already prepends frontmatter on its own; artifact pages
get the writer-side injection).

Also bump `gbrainAvailable()` to probe `gbrain --help` for the `put`
subcommand. If a future gbrain renames or removes it, every page now fails
fast with one clean error instead of N copies of "Unknown command".

Regression coverage: two new tests in `test/gstack-memory-ingest.test.ts`
stand up a fake `gbrain` shim on PATH. The first asserts the writer hits
`put <slug>` with stdin body + frontmatter and never invokes `put_page`;
the second points the writer at a legacy-only shim and asserts the
availability probe surfaces a single missing-subcommand error.

Tested on gbrain v0.27.0 (61/62 pages ingested cleanly post-patch; the
one failure was a within-batch slug collision unrelated to the writer).

Reproduced by:
  bun ~/.claude/skills/gstack/bin/gstack-memory-ingest.ts --bulk
  # before: every page errors `[put-error] ... Unknown command: put_page`
  # after:  pages land via `gbrain put <slug>`
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