From 43d89de0ed2d1d5e49f85669df7cf584936416d9 Mon Sep 17 00:00:00 2001 From: Rogee Date: Wed, 30 Sep 2026 11:04:51 +0800 Subject: [PATCH] Move current SQLite identity guards out of obsolete store --- docs/evidence/saas-dispatcher-implementation.md | 1 + internal/store/current.go | 11 ++++++++--- internal/store/identity.go | 3 --- internal/store/store.go | 2 -- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/evidence/saas-dispatcher-implementation.md b/docs/evidence/saas-dispatcher-implementation.md index 503db01..a210d7e 100644 --- a/docs/evidence/saas-dispatcher-implementation.md +++ b/docs/evidence/saas-dispatcher-implementation.md @@ -102,6 +102,7 @@ - Dispatcher 旧任务消费分支:删除 `task_runtime_v3`、`task_queue_v3`、`task_control_v3` 及其专属测试和仅依赖这些旧测试夹具的旧 Mock 恢复测试;当前 `CurrentRuntime`、`CurrentBootstrap`、`CurrentDiscoveryFollower` 和根命令隔离测试仍独立通过。 - Dispatcher 旧本地执行与控制分支:删除 `local_v01`、旧 Mock 呼叫/上传/恢复、旧路由与时间策略、旧 `Dispatcher`/lease 实现及依赖它们的测试;现行命令、任务消费、录音/结果链路的定向测试继续通过。 - Agent 会话共用边界:保留当前根命令使用的 `AgentCoordinator` 注册、状态探测、激活、最新会话授权和过期拒绝;移除仅供旧执行链路使用的 `ExecuteRaw`、旧控制、查询补偿与旧 SIP applied-config 核验及其测试。当前 SIP 门禁仍由现行加载回报与隔离测试校验,不冒充 Asterisk 实际加载;旧 MQ/Store 和其余契约尚待清理,不能将此批视为 P07 完成。 +- SQLite 代码归属:当前 Store 所需的 SQLite 驱动和 Dispatcher 身份/命令冲突错误已从旧 Store 迁到当前入口,保留拒绝旧布局及外来 Dispatcher 抢占的原测试。旧 Store 与迁移文件尚未删除;此改动只移动源码定义,不读取、改写或清理现存业务数据。 ## 验收台账 diff --git a/internal/store/current.go b/internal/store/current.go index 1bdcf31..73856f7 100644 --- a/internal/store/current.go +++ b/internal/store/current.go @@ -11,13 +11,18 @@ import ( "strings" "git.ipao.vip/rogee/go-sip/internal/configread" + _ "modernc.org/sqlite" ) -// CurrentStore is the authority for the new numeric-tenant task model. It -// deliberately refuses an old database instead of clearing or replaying data -// whose owner/message identity cannot be proved safe to convert. +// CurrentStore refuses an incompatible database instead of clearing or +// replaying data whose owner and message identity cannot be proved safe. type CurrentStore struct{ db *sql.DB } +var ( + ErrCommandConflict = errors.New("command id reused with different body") + ErrDispatcherIdentityMismatch = errors.New("database belongs to another dispatcher") +) + const currentSchema = ` CREATE TABLE IF NOT EXISTS dispatcher_state ( dispatcher_id TEXT PRIMARY KEY, diff --git a/internal/store/identity.go b/internal/store/identity.go index 967f0d3..f253575 100644 --- a/internal/store/identity.go +++ b/internal/store/identity.go @@ -1,15 +1,12 @@ package store import ( - "errors" "fmt" "time" "git.ipao.vip/rogee/go-sip/internal/tenant" ) -var ErrDispatcherIdentityMismatch = errors.New("database belongs to another dispatcher") - // DispatcherID returns the already-bound database identity, never a new identity. func (s *Store) DispatcherID() (string, error) { var id string diff --git a/internal/store/store.go b/internal/store/store.go index 013d735..96602b5 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -17,7 +17,6 @@ import ( "git.ipao.vip/rogee/go-sip/internal/contract" "git.ipao.vip/rogee/go-sip/internal/mq" "git.ipao.vip/rogee/go-sip/internal/tenant" - _ "modernc.org/sqlite" ) //go:embed migrations/*.sql @@ -25,7 +24,6 @@ var migrations embed.FS var ( ErrDuplicateCommand = errors.New("duplicate command") - ErrCommandConflict = errors.New("command id reused with different body") ErrNoCapacity = errors.New("quota capacity unavailable") ErrCASConflict = errors.New("control revision conflict") ErrLeaseHeld = errors.New("active lease held by another dispatcher")