Files
archie/internal/app/archied/binding_cipher.go
T
sam ae552db7e0 refactor(store)!: remove the SQLite task store, the PocketBase event store and the SQLite session store
The State Store, event capture and Gateway conversations already serve from
PostgreSQL. This deletes internal/store and internal/infrastructure/edastore,
the SQLite gateway session store and openProductionTaskStore, and the -db
recovery path on a legacy task file; backup, restore, validate and rollback
work on the database database_url names.

- The binding-secret cipher moves to internal/infrastructure/bindingcipher and
  ToolCall to internal/infrastructure/postgres.
- NewSessionStoreMemory is now a pure in-memory store that passes the shared
  SessionStore conformance suite.
- Tests run against PostgreSQL through internal/infrastructure/postgres/pgstore;
  legacyimport/legacyfixture writes the legacy files the import and the boot
  gate read.
- The cron dialect is owned in internal/domain/scheduling, so
  github.com/pocketbase/pocketbase and pocketbase/dbx leave go.mod.
  modernc.org/sqlite stays for the one-time import (legacyread).
- The UI and Messaging architecture gates ban the Postgres and legacy readers
  in place of internal/store.
2026-09-24 14:43:50 +10:00

41 lines
1.4 KiB
Go

package archied
import (
"fmt"
"strings"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/infrastructure/bindingcipher"
"github.com/samcharles93/archie-core/internal/secret"
)
// bindingCipherFromConfig resolves the binding at-rest encryption key from
// config through the secret registry and returns the EDA store's cipher. An unset
// encryption_key returns a nil cipher, keeping the legacy plaintext path (the
// store's default). See docs/prds/binding-secret-encryption.md.
func bindingCipherFromConfig(cfg config.Config, secrets *secret.Registry) (bindingcipher.BindingCipher, error) {
if cfg.Bindings.EncryptionKey == (secret.SecretRef{}) {
return nil, nil
}
active, err := secrets.Resolve(cfg.Bindings.EncryptionKey)
if err != nil {
return nil, fmt.Errorf("resolve bindings encryption_key: %w", err)
}
active = strings.TrimSpace(active)
if active == "" {
return nil, fmt.Errorf("bindings encryption_key resolved empty")
}
previous := make([]string, 0, len(cfg.Bindings.PreviousEncryptionKeys))
for _, ref := range cfg.Bindings.PreviousEncryptionKeys {
v, err := secrets.Resolve(ref)
if err != nil {
return nil, fmt.Errorf("resolve bindings previous_encryption_key: %w", err)
}
if v = strings.TrimSpace(v); v != "" {
previous = append(previous, v)
}
}
return bindingcipher.NewBindingCipher(active, previous)
}