Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions internal/intelligence/memory/yaad_bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ func NewYaadBridge() *YaadBridge {
return b
}

// yaadEncryptionKeyEnv names the environment variable supplying the
// at-rest encryption key for the yaad memory database. It is opt-in:
// without it, node content is stored in plaintext (the historical
// behaviour). Set it consistently on every process that opens the same
// database — content sealed without the key becomes unreadable.
const yaadEncryptionKeyEnv = "YAAD_ENCRYPTION_KEY"

func (b *YaadBridge) init() {
home, err := os.UserHomeDir()
if err != nil {
Expand All @@ -85,6 +92,18 @@ func (b *YaadBridge) init() {
return
}

// Opt-in at-rest encryption (PR yaad#59): when the key variable is set,
// node content is sealed with AES-256-GCM before writing. An invalid key
// disables the bridge entirely rather than silently storing plaintext
// the user did not ask for.
if v := strings.TrimSpace(os.Getenv(yaadEncryptionKeyEnv)); v != "" {
if err := store.EnableEncryption(storage.NewEnvKeyProvider(yaadEncryptionKeyEnv)); err != nil {
_ = store.Close()
slog.Warn("[hawk/memory] yaad encryption key invalid; memory disabled", "error", err)
return
}
}

g := yaadGraph.New(store, store.DB())
eng := yaadEngine.New(store, g)

Expand Down
Loading