Skip to content

Add glob/auto/manual inclusion modes for memory entries - #1628

Merged
currentbits merged 2 commits into
mainfrom
coder/memory-injection-modes-glob-matched-and--a9086c
Oct 13, 2026
Merged

currentbits merged 2 commits into
mainfrom
coder/memory-injection-modes-glob-matched-and--a9086c

Conversation

@currentbits

Copy link
Copy Markdown
Owner

What changed

Memory entries can now set an inclusion mode that controls when bootstrap injects them (#271). Before this, every live entry rode every bootstrap.

Mode Loads when
always (default, stored as NULL) every bootstrap, same as before
glob (needs globs) a file in bootstrap's files, or a path-like token in its prompt, matches. A glob with no slash also matches basenames
auto at least half the title's non-stopword words appear in the prompt
manual the prompt mentions #<first 8 chars of id>

Conditional entries can still be found with search.

memory-server

  • Schema: adds inclusion and globs columns to entries via addColumnIfMissing.
  • Store and supersede:
    • memory_store / memory_supersede accept inclusion and globs, checked by cleanInclusion. glob needs at least one glob, and globs are rejected on any other mode.
    • A superseding entry keeps its parent's mode. Switching away from glob drops the old globs.
    • memory_get returns inclusion and globs.
  • Bootstrap inputs:
    • bootstrap() takes prompt, files and matchedOnly.
    • Matched entries go at the front of their section. The response gains deferred, the count of conditional entries that didn't match.
    • matchedOnly: true returns only the matched entries and skips the wiki.
  • Bootstrap internals: the four always-on section queries are now one section() helper.
  • Interfaces:
    • The MCP memory_bootstrap schema and description cover the new inputs.
    • GET /api/bootstrap accepts prompt, file (repeatable) and matchedOnly=1.
    • One new line in the usage protocol tells agents to pull scoped entries before working in a new area.
    • The README documents the modes.

electron

  • memory-proxy.bootstrap: builds its query with URLSearchParams and forwards prompt (capped at 2000 chars), file and matchedOnly. They go in the query string so an older server simply ignores them.
  • prefetchBootstrapNote:
    • Now receives the turn's prompt.
    • Turn one gets the full pack plus entries matching that prompt.
    • Follow-up turns used to get nothing. They now send matchedOnly and inject only matched entries the thread hasn't seen yet, via the new formatMatchedNote.
    • Rows without an inclusion field are skipped, so an older server that returns the full pack injects nothing on follow-up turns.
  • Seen-entry tracking: runner.js keeps a per-thread Set of entry ids already injected. It lives in memory only, so after a restart each matched entry is sent once more.
  • Ask runs: runner-ask-runs.js passes the ask prompt or card question.
  • Deferred hint: formatBootstrapNote adds a line when deferred > 0, pointing at memory_bootstrap with matchedOnly.

Why

Entries that only matter for one area of the code or one topic used up bootstrap budget on every run. With these modes they load only when the current files or prompt make them relevant, and agents can still ask for them on demand.

Tests

  • New memory-server/test/inclusion.test.js covers validation, glob/auto/manual matching, deferred and matchedOnly.
  • electron/test/ask.test.js covers matched-note formatting and the follow-up-turn path.
  • Small updates to memory-proxy.test.js and stop-during-prepare.test.js.

🤖 Generated with Claude Code

Solenta-Message-Id: c20932fb-822f-45a9-989d-e7f6fba28d17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de3e96669b

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread electron/ask.js
Comment on lines +189 to +191
if (seen) {
seen.clear();
formatMatchedNote(boot, seen);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve unsent matches for later turns

When an initial bootstrap returns more than 12 conditional rows in one section, formatBootstrapNote injects only the first 12, but this call runs formatMatchedNote over every returned row and marks all of their IDs as seen. Any rows beyond the display cap are therefore suppressed from subsequent matchedOnly turns even though the thread never received them; only mark IDs that were actually included in the initial note.

Useful? React with 👍 / 👎.

Comment on lines +169 to +170
function autoTokens(text) {
return new Set([...contentTokens(text)].filter((t) => !AUTO_STOPWORDS.has(t)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Count short keywords when matching auto entries

For auto-mode titles containing meaningful one- or two-character terms, reusing contentTokens silently discards those terms because that helper only keeps tokens of length three or more. For example, Go build should match a prompt containing Go compiler under the documented half-of-title-words rule, while the current code reduces the title to only build and misses it; tokenize auto-mode text without dropping short non-stopwords.

Useful? React with 👍 / 👎.

Comment on lines 1524 to +1525
ORDER BY importance DESC, created_at DESC
LIMIT 50`,
)
.all(project, project)

const tasksRaw = this.db
.prepare(
`SELECT id, title, body, status, agent, source, project, created_at, updated_at, citations FROM entries
WHERE type = 'task' AND ${liveSql()}
AND COALESCE(status, 'active') = 'active'
AND (? IS NULL OR project = ?)
ORDER BY updated_at DESC, created_at DESC
LIMIT 50`,
LIMIT ${CONDITIONAL_SCAN_CAP}`,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match conditional entries before applying the scan cap

Once a project has more than 500 live conditional entries, this limit is applied before any glob, auto, or manual predicate. An older or lower-importance entry beyond the first 500 can never be returned even when the prompt explicitly names its manual ID or its glob exactly matches, and deferred also omits all rows beyond the cap. The matching query needs to consider all eligible entries or provide a lookup path that cannot hide an explicit match.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T14:37:26.766941Z de3e966 PR opened
ℹ️ 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.

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