78e6858751
RegisterStore(reg, StoreDeps) registers the persistent-memory tools over the host's KV and/or File backends: - kv_get/set/list/delete (KVStorage seam) - file_save/get/get_text/get_metadata/list/delete (FileStorage seam), plus file_search (FileSearcher) and create_file_url (FileTokenMinter) when wired. Near-zero-config: Quota defaults to a generous static cap (staticQuota), the per-value/per-file caps default, and the kv vs file groups register independently (a host can take just one). Seams moved clean (interface-only): kv_storage.go, quota_provider.go, file_descendant_grant.go. The default in-memory KV/File backends come with contrib/store at P4. Core go.sum still free of gorm/redis/discordgo/sqlite. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33 lines
1.6 KiB
Go
33 lines
1.6 KiB
Go
// quota_provider.go declares the narrow QuotaProvider interface used by
|
|
// kv_set and file_save to enforce per-skill byte quotas at write time.
|
|
//
|
|
// Why a narrow interface (vs importing pkg/logic/skills directly): same
|
|
// cycle constraint as kv_storage.go and file_storage.go — pkg/logic/skills
|
|
// already imports pkg/skilltools, so importing skills back here would
|
|
// form an import cycle. Production wiring (pkg/logic/mort.go) supplies
|
|
// *skills.System, which satisfies QuotaProvider via its EffectiveQuota
|
|
// method.
|
|
//
|
|
// Why a separate interface vs adding the method to KVStorage/FileStorage:
|
|
// quota resolution is a system-level policy (combining override + convar
|
|
// + default), not a pure storage read. Keeping it separate lets a tool
|
|
// constructor accept a nil QuotaProvider when an integrator wants to
|
|
// skip enforcement (e.g. an admin-only skill that bypasses caps).
|
|
package tools
|
|
|
|
import "context"
|
|
|
|
// QuotaProvider returns effective per-skill quotas for the storage
|
|
// tools' write-path enforcement. Production wires *skills.System, which
|
|
// satisfies this via its EffectiveQuota method.
|
|
//
|
|
// nil-safe: tools constructed against a nil QuotaProvider do NOT enforce
|
|
// per-skill quotas. That mode is useful for tests and for environments
|
|
// where quota enforcement is intentionally disabled.
|
|
type QuotaProvider interface {
|
|
// EffectiveQuota returns the effective KV and file byte caps for the
|
|
// skill. The two values resolve admin overrides + convar defaults +
|
|
// package constants in that order.
|
|
EffectiveQuota(ctx context.Context, skillID string) (kvMax, filesMax int64, err error)
|
|
}
|