beads/memoryops/errors.go
Julian Knutsen 4e8b017fd4
Put the memory plane behind memoryops, conformance-tested at three backends (#5387)
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.
2026-08-07 03:57:04 -07:00

29 lines
1.5 KiB
Go

package memoryops
import "github.com/steveyegge/beads/issueops"
// ErrValidation classifies this role's deterministic request-validation
// failures. It is an ALIAS of issueops.ErrValidation, not a second sentinel,
// and the identity is the point: the HTTP problem classifier, cmd/bd's error
// handling and every conformance suite already errors.Is against that one
// value, so a memoryops-flavored twin would make each of them double-match
// forever — one vocabulary with two doorplates instead of two vocabularies.
//
// It is re-exported here rather than left for callers to reach through
// issueops so that code holding only the Memories interface can classify a
// refusal without knowing the issue package exists, which is the courtesy
// issueops.ErrUnsupported's doc extends for the same reason.
var ErrValidation = issueops.ErrValidation
// THERE IS DELIBERATELY NO ErrNotFound ON THIS ROLE.
//
// The storage seam beneath it cannot tell an absent config row from a row
// stored as the empty string (issueops/workspaceconfig.go:41-52 states the same
// conflation for settings, and it is the same table). A role that answered a
// Recall of an unknown key with ErrNotFound would be minting an error out of a
// distinction it cannot actually see, and the first out-of-band empty write
// would make it a lie.
//
// Misses are RESULT-CARRIED instead — RecallResult.Found, ForgetResult.Found —
// and the front doors translate: the CLI to its SilentExit contract, an HTTP
// door to its 404. That keeps the invention where a door can justify it.