The memory commands get the treatment the sixteen issue commands got in #5378: a role interface in a leaf package, conformance-tested at all three backends, with the CLI routes and the HTTP handlers as thin callers over one implementation. memoryops is its own namespace rather than an addition to issueops. The two planes share a config table and nothing else; a memory whose key shadows a settings name is still a memory, and that separation is now the role's, pinned by its contract, rather than a filter each caller reapplies. Closes an unauthenticated disclosure found on the way: memory content was served in cleartext on GET /v0/beads/config, and reachable through two more doors — `bd config show` and `bd info --json`, the latter republished into agent transcripts by MCP get_schema_info. Enumeration is now filtered at the shared seam (workapi.FilterSettingsEnumeration); `bd config show` is left alone deliberately, since an operator asks for it by name. Two wire contracts were settled after the review council, recorded in full on the PR: the search parameter is spelled `search` rather than `q`, because issues:query already publishes `q` as a boolean expression and one surface must not spell two questions one name; and getMemory keeps its 404, because the status reports the distinction the front door already reports and `bd recall` exits 1 on a miss where `bd config get` exits 0.
47 lines
1.8 KiB
Go
47 lines
1.8 KiB
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/steveyegge/beads/internal/storage/kvkeys"
|
|
"github.com/steveyegge/beads/internal/workapi"
|
|
)
|
|
|
|
// TestInfoConfigExcludesTheKVPlane pins that `bd info --json` does not serve
|
|
// memories.
|
|
//
|
|
// It asserts the FILTER both info routes now apply, rather than shelling out:
|
|
// the two call sites differ only in which seam supplies the map, and the thing
|
|
// that can regress is somebody re-inlining GetAllConfig at one of them.
|
|
//
|
|
// Why it matters more than an ordinary config read: the beads MCP server's
|
|
// get_schema_info tool runs `bd info --schema --json` and returns the parsed
|
|
// dict whole, so every memory key and VALUE landed in the transcript of any
|
|
// agent that asked a schema question — and `bd info` is the diagnostic people
|
|
// paste into bug reports.
|
|
func TestInfoConfigExcludesTheKVPlane(t *testing.T) {
|
|
stored := map[string]string{
|
|
"issue_prefix": "bd",
|
|
"custom.statuses": "awaiting_review",
|
|
kvkeys.MemoryConfigKeyPrefix + "deploy-notes": "the staging deploy token is sk-live-000",
|
|
kvkeys.Prefix + "release.channel": "beta",
|
|
// Near misses that must SURVIVE: the rule is a prefix, not a substring.
|
|
"kvetch": "not under the kv prefix",
|
|
"custom.mentions.kv.inside": "kept",
|
|
}
|
|
|
|
got := workapi.FilterSettingsEnumeration(stored)
|
|
|
|
for key := range got {
|
|
if strings.HasPrefix(key, kvkeys.Prefix) {
|
|
t.Errorf("bd info would serve %q: the kv plane is not settings, and this map reaches "+
|
|
"agent transcripts through the MCP get_schema_info tool", key)
|
|
}
|
|
}
|
|
for _, want := range []string{"issue_prefix", "custom.statuses", "kvetch", "custom.mentions.kv.inside"} {
|
|
if _, ok := got[want]; !ok {
|
|
t.Errorf("%q was dropped; only keys under %q may be", want, kvkeys.Prefix)
|
|
}
|
|
}
|
|
}
|