fix: require container scope on by-id memory routes; bump getmnemo to ^0.5.1 - #2
Merged
Merged
Conversation
…emo to ^0.5.1 GET/PATCH/DELETE /v1/memories/:id 400 without a containerTag or scopeType+scopeId query param (requireMemoryScope guard). The get and rm commands sent neither, so both failed against production. - add -C/--container to get and rm, resolved via the same resolveContainerTag precedence as add/search/list (flag > env > config) - exit 2 with the existing container-required message when nothing resolves - pass the env/config container into the Mnemo constructor as defaultContainerTag; per-call flag still wins - bump getmnemo ^0.2.0 -> ^0.5.1 for the options parameter on get/update/delete - tests assert the containerTag reaches the request query string
Independent review of the container-scope fix surfaced regressions the
getmnemo ^0.2.0 -> ^0.5.1 bump introduced beyond the by-id routes:
- login: the credential probe called list() with no container, which
0.5.1 rejects client-side — login failed for every user. Probe with a
synthetic read-only tag (cli:login-probe) instead.
- list: 0.5.1 list() throws without a container, so bare 'getmnemo list'
died with a raw SDK error at exit 1. Gate it with the same
container-required exit-2 message as the other commands.
- prod smoke: cleanup ran 'rm <id> --yes' with no --container (ids span
two containers), leaking memories into the prod test workspace every
CI run. Track id+container pairs and pass --container per delete.
- rm: 0.5.1 deletes are recoverable by default; surface the receipt
(restorable-until in human output, receipt in --json) and add
--permanent for an immediate purge.
- --json: container-required errors now emit {ok:false,error:
"container_required"} instead of ANSI prose, matching the sibling
error shapes.
- tests: exit-code assertions use rejects.toThrow (the try/catch form
passed vacuously when nothing threw); realistic delete fixtures; new
coverage for list, login probe, --json error shape, --permanent.
- dedupe the 5x-copied -C/--container option; fix stale comments;
update README for the required-container contract.
Deferred (tracked in PR body): workspaceId is deprecated/ignored by SDK
0.5.1 but still a hard CLI gate; add() strict receipt validation vs
lagging self-hosted APIs.
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.
Problem
The Mnemo API requires a container on by-id memory routes (
requireMemoryScopeguard): GET/PATCH/DELETE/v1/memories/:idreturn 400 without acontainerTag(orscopeType+scopeId) query param. Thegetandrmcommands sent neither, so both failed against production.Changes
Container scope fix
getandrmnow take-C/--container, resolved via the same precedence as the other commands (flag >GETMNEMO_CONTAINER> configdefaultContainerTag) and passed to the SDK call; exit 2 with the standard container-required message when nothing resolves ({ok:false,error:"container_required"}under--json).getmnemo^0.2.0→^0.5.1for theoptionsparameter onget/update/delete;getClient()also seedsdefaultContainerTagfrom env/config as a backstop (per-call values win).Regressions from the 0.5.1 bump, caught in review and fixed
loginwas broken for every user: its credential probe calledlist()with no container, which 0.5.1 rejects client-side. Now probes with a synthetic read-onlycli:login-probetag.getmnemo listthrew a raw SDK error at exit 1 (0.5.1 requires a container onlist). Now gated like the other commands; README updated.--container(ids span two containers), leaking memories into the prod test workspace every run. Now tracks id + container pairs.rmmisreported recoverable deletes as final: now prints the restorable-until window, includes the delete receipt in--json, and supports--permanentfor an immediate purge.Test plan
npm run lint(tsc --noEmit) greennpm test— 14/14, including: containerTag reaches the request query forget/rm/list; flag beatsGETMNEMO_CONTAINER; env fallback; exit-2 + message (human and--json) when nothing resolves;--permanentsendspermanent=true; login probe URLnpm run buildgreenDeferred
workspaceIdis@deprecatedand ignored by SDK 0.5.1 (identity comes from the API key), but the CLI still hard-requires it andworkspace switchis effectively a no-op — needs its own PR.add()validates a modern write receipt and can fail after a successful write against lagging self-hosted APIs — no CLI change for now.login --api-urlis silently ignored (readsopts.baseUrlinstead ofopts.apiUrl) — being fixed in a separate session.🤖 Generated with Claude Code