Repository navigation
fix: keep a small agent-memory instance safe to prune and search - #68
Merged
Merged
Conversation
Prune no longer retires markdown sources that have no recorded root unless --prune-legacy is set, and an empty folder is refused unless --force. Corpora under six records skip the centroid margin so an exact match can be strong. Search can return no cards when grounding is none. The owner CLI can remember, restore a retirement, and see token use. Co-authored-by: Nick Kosarev <nick@kosarev.space>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the feedback from a small agent-memory instance (processor off, notes written with
remember, a few markdown imports). No MCP tools were added. The public tools staysearch,remember,read, andtimeline.Done
P1. Prune no longer wipes rootless imports.
import markdown --pruneretires only sources whose recorded root is that directory. Sources imported before roots were stored are left alone unless--prune-legacyis passed. An existing folder with no markdown files is refused unless--force. A missing path is refused even with--force, and nothing is retired.context doc restore <doc id|source id>andcontext source restore <source id>undo a retirement.P2. Tiny corpora can be strong. Below
CONTEXT_GROUNDING_MARGIN_MIN_CORPUSrecords (default 6) the centroid margin is skipped and the lexical-only rules apply, so an exact match can bestrongand an off-topic query staysnone. Corpora of 6 or more, including the existing 7-passage margin tests, keep the margin.P3. Search can withhold ungrounded cards.
searchacceptswhenNone: "empty"or"keep". Omitting it followsCONTEXT_SEARCH_WHEN_NONE, which defaults tokeep.emptyclears sources, items, and relations, leavesgrounding: "none", and setscardsOmitted: "grounding-none".P4. Owner CLI.
context rememberuses the same validation and write path as MCPremember(--area, repeatable--project,--kind note, text from arguments or stdin).context token listshows the token name,used, andlastUsed.context token revoke --name <name>revokes every token for that client name. An accepted access or CLI token, including a successfulremember, setsusedandlastUsed. The OAuth one-timeusedbit on codes and refresh tokens is unchanged.Cheap extras.
--help, no args, and an unknown command print the command list. Real command errors print their message.context project createexplains the id character rules, suggests a slug when the id contains a dot, and lists existing project ids.context statusprints active and retired sources, documents, knowledge items, tokens, projects, and processor on/off. Source excerpts end on a sentence or word boundary. Whenitemsis empty and the processor is off, search addsitemsHint.Skipped
None of the requested items. A missing folder is not prunable with
--force; there is no import root to match, so the command refuses and retires nothing.Evidence
pnpm run check(lint, typecheck, tests): 55 files, 283 tests, all passed.Friction
usedis stored. On the order of a quarter hour, insrc/auth-store.tsandsrc/oauth.ts, not waiting on a tool.TokenRecord.usedis the one-time replay bit for authorization codes and refresh tokens.lastUsedlived only on the client and was updated for every accepted bearer token.context token listshowedusedand hid both the name and any timestamp, so a CLI token that had successfully calledrememberstill looked unused. Setup,pnpm install, andpnpm run checkwere fast (install about 4s, full check about 27s). One CLI test failed because the help text saysremember, notcontext remember; that was a one-line assertion fix.scripts/context.tsturned almost every failure intoContext command failed, including the usage error it had just built, soCLI requires CONTEXT_PUBLIC_URLnever reached the terminal.docs/imports.mddocumented the fix: report processor-off and prune removed markdown #67 regression as intended behavior: a rootless source was treated as part of whichever folder was pruned. Import failures still emit a fixed JSON reason unless the message matches a small allowlist, so a new import error can stay opaque.vp checkandvp testprint a note that the built-in command is not the npm script. That did not block the run.markdownPruneCandidatesthat rootless rows are not members of every folder, and a comment that the public margin tests assume a corpus of at least 7, would have made the two constants obvious. Separating the OAuth replay bit from a displaylastUsedon the token record would have made the token-list bug a direct edit instead of a cross-file read.