Skip to content

gstack-memory-ingest: colliding path-derived slugs overwrite in staging, then fail the whole batch #2653

Closed

Description

@rayers

What breaks

gstack-memory-ingest derives a page slug from lossy inputs:

  • transcripts: transcripts/<agent>/<repo>/<date>-<session_id[:12]>
  • artifacts: <type>s/<repo>/<date>-<baseName>

Two distinct source files can therefore collapse to one slug (a session resumed under the same session_id on the same day, or two sessions whose session_id shares a 12-char prefix on the same day).

writeStaged() names each staged file ${slug}.md, so the second file overwrites the first on disk. written still counts both, but only one file lands in the staging dir. gbrain's batch import then collects fewer files than were staged, and the staged-vs-collected reconciliation guard refuses to advance state:

[memory-ingest] ERR: gbrain import accounted for 21 of 22 staged page(s) (imported=7, unchanged=14).
gbrain collected 21 file(s) from the staging dir. Refusing to advance state ...
[memory-ingest] 0 written, 22 failed
ISSUE [transcripts]: gstack-memory-ingest exit 1

The guard is correct (no silent loss), but the batch fails on every run until the colliding inputs age out of the window. Note the message's .gitignore hint is a red herring for this case: the ingester already passes --include-gitignored and sets GIT_CEILING_DIRECTORIES, and a gitignore drop collects 0 files, not 21 of 22.

Reproduction

Two prepared pages with the same path-derived slug and distinct source_path values. writeStaged() writes 2 but only 1 file exists on disk; the reconciliation guard then fails the batch.

Proposed fix

Disambiguate colliding slugs in preparePages() before staging: keep the first page's slug, give each later collider a stable per-source suffix -<sha8(source_path)>. Deterministic across runs (same source -> same slug -> gbrain sees it unchanged, no churn), unique because source_path is unique per prepared page. Mutate slug and page_slug together to preserve the stagedRelPath() single-source-of-truth contract (staging path, #1802 resume reconstruction, and state recording stay in lockstep).

PR to follow.

Activity

  1. rayers commented on Aug 20, 2026

    @rayers
    ContributorAuthor

    Abandoning this. Not pursuing a fix upstream right now. The root cause (colliding path-derived slugs overwriting in the memory-ingest staging dir) is real, but I'm closing my own report rather than leaving it open.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions