| 操作 | 原子性 | approvals | audit_events | bot_loaded_tools | bots | condition_states | delegation_dek | delegation_removal_watch | delegations | model_credential | owner | profile_entries | quota_counters | routines | run_tool_calls | runs | schema_migrations | thread_heads | thread_versions | trading_policy | venue_executions | ws_tickets |
| migrateOwnerSchema contexts/bot/src/infrastructure/sqlite/migrate.ts 每版 DDL + 版本行一个 transactionSync;DO 构造期跑 | batch | | | | | | | | | | | | | | | | ● | | | | | |
| OwnerRepository.ensure contexts/bot/src/infrastructure/sqlite/repositories/OwnerRepository.ts 首次连上建行,已存在不动 | single | | | | | | | | | | ● | | | | | | | | | | | |
| OwnerRepository.setStatus contexts/bot/src/infrastructure/sqlite/repositories/OwnerRepository.ts 停用 / 休眠 / 恢复 / 补 purge_at | single | | | | | | | | | | ● | | | | | | | | | | | |
| OwnerRepository.markConnected contexts/bot/src/infrastructure/sqlite/repositories/OwnerRepository.ts /me 或 WS 连上
| single | | | | | | | | | | ● | | | | | | | | | | | |
| OwnerPurge.purgeNow(硬删) apps/bot/src/owner/ownerPurge.ts 先经 Think 删各 bot 线程,再 deleteAlarm + storage.deleteAll() 清空整库 | single | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● | ● |
| ModelCredentialRepository.save contexts/bot/src/infrastructure/sqlite/repositories/ModelCredentialRepository.ts 新建 / 轮换整把覆盖,状态回 ok | single | | | | | | | | | ● | | | | | | | | | | | | |
| ModelCredentialRepository.replaceSealedKey contexts/bot/src/infrastructure/sqlite/repositories/ModelCredentialRepository.ts KEK 轮换后惰性重包 | single | | | | | | | | | ● | | | | | | | | | | | | |
| ModelCredentialRepository.setModels contexts/bot/src/infrastructure/sqlite/repositories/ModelCredentialRepository.ts 只换模型槽 | single | | | | | | | | | ● | | | | | | | | | | | | |
| ModelCredentialRepository.setStatus contexts/bot/src/infrastructure/sqlite/repositories/ModelCredentialRepository.ts 同值不写,返回是否变化 | single | | | | | | | | | ● | | | | | | | | | | | | |
| ModelCredentialRepository.delete contexts/bot/src/infrastructure/sqlite/repositories/ModelCredentialRepository.ts 删行 = 销毁独立 DEK | single | | | | | | | | | ● | | | | | | | | | | | | |
| ProfileRepository.add / update / remove contexts/bot/src/infrastructure/sqlite/repositories/ProfileRepository.ts add 先数条数;update 即改归用户 | single | | | | | | | | | | | ● | | | | | | | | | | |
| BotRepository.create / update contexts/bot/src/infrastructure/sqlite/repositories/BotRepository.ts update 用 COALESCE 打补丁 | single | | | | ● | | | | | | | | | | | | | | | | | |
| BotRepository.recordMessage / markRead contexts/bot/src/infrastructure/sqlite/repositories/BotRepository.ts 线程摘要与已读游标,不动 updated_at | single | | | | ● | | | | | | | | | | | | | | | | | |
| BotRepository.delete contexts/bot/src/infrastructure/sqlite/repositories/BotRepository.ts 先断开画像来源再删 bot;外键级联带走 routines / condition_states / runs / run_tool_calls / approvals / venue_executions / audit_events / bot_loaded_tools / thread_heads / thread_versions | batch | | | | ● | | | | | | | ● | | | | | | | | | | |
| LoadedToolRepository.add contexts/bot/src/infrastructure/sqlite/repositories/LoadedToolRepository.ts 多条 INSERT OR IGNORE 一个事务 | batch | | | ● | | | | | | | | | | | | | | | | | | |
| ThreadVersionRepository.bump contexts/bot/src/infrastructure/sqlite/repositories/ThreadVersionRepository.ts 计数器 +1 后逐条 upsert 消息版本 | batch | | | | | | | | | | | | | | | | | ● | ● | | | |
| ThreadVersionRepository.markReset contexts/bot/src/infrastructure/sqlite/repositories/ThreadVersionRepository.ts 计数器 +1 并记为重置点 | batch | | | | | | | | | | | | | | | | | ● | | | | |
| WsTicketRepository.issue contexts/bot/src/infrastructure/sqlite/repositories/WsTicketRepository.ts 签发前调用方先 deleteExpired | single | | | | | | | | | | | | | | | | | | | | | ● |
| WsTicketRepository.consumeWithSession contexts/bot/src/infrastructure/sqlite/repositories/WsTicketRepository.ts DELETE … RETURNING,过期的也删掉
| single | | | | | | | | | | | | | | | | | | | | | ● |
| WsTicketRepository.deleteExpired contexts/bot/src/infrastructure/sqlite/repositories/WsTicketRepository.ts 只在 issueWsTicket 时顺带清 | single | | | | | | | | | | | | | | | | | | | | | ● |
| RoutineRepository.create / update contexts/bot/src/infrastructure/sqlite/repositories/RoutineRepository.ts 条件 Routine 新建 / 触发器变化时同事务 rebuildConditionStates | batch | | | | | ● | | | | | | | | ● | | | | | | | | |
| RoutineRepository.setEnabled / setAutoTrade / setNextFireAt contexts/bot/src/infrastructure/sqlite/repositories/RoutineRepository.ts 开关 / 自动下单预算 / 下次触发 | single | | | | | | | | | | | | | ● | | | | | | | | |
| RoutineRepository.recordCheck / markPushed contexts/bot/src/infrastructure/sqlite/repositories/RoutineRepository.ts 检查结果与推送冷却 | single | | | | | | | | | | | | | ● | | | | | | | | |
| RoutineRepository.delete contexts/bot/src/infrastructure/sqlite/repositories/RoutineRepository.ts 级联删 condition_states;runs.routine_id 置 NULL | single | | | | | | | | | | | | | ● | | | | | | | | |
| ConditionStateRepository.save contexts/bot/src/infrastructure/sqlite/repositories/ConditionStateRepository.ts 每次检查后 upsert 一条条件 | single | | | | | ● | | | | | | | | | | | | | | | | |
| ConditionStateRepository.resetRoutineToBaseline / resetAllToBaseline contexts/bot/src/infrastructure/sqlite/repositories/ConditionStateRepository.ts Routine 重开 / 所有者恢复或唤醒 | single | | | | | ● | | | | | | | | | | | | | | | | |
| RunRepository.start contexts/bot/src/infrastructure/sqlite/repositories/RunRepository.ts 插入 running | single | | | | | | | | | | | | | | | ● | | | | | | |
| RunRepository.addUsage contexts/bot/src/infrastructure/sqlite/repositories/RunRepository.ts 读当前花费 → BigNumber 相加 → 写回,一个事务 | batch | | | | | | | | | | | | | | | ● | | | | | | |
| RunRepository.appendToolCall contexts/bot/src/infrastructure/sqlite/repositories/RunRepository.ts 取 seq → 插明细 → 改计数与污染标记 | batch | | | | | | | | | | | | | | ● | ● | | | | | | |
| RunRepository.finish / attachLastMessage contexts/bot/src/infrastructure/sqlite/repositories/RunRepository.ts 只改 running / 只填空 | single | | | | | | | | | | | | | | | ● | | | | | | |
| RunRepository.deleteStartedBefore contexts/bot/src/infrastructure/sqlite/repositories/RunRepository.ts 90 天保留期清理(明细级联);当前生产代码没有调用方 | single | | | | | | | | | | | | | | | ● | | | | | | |
| QuotaCounterRepository.increment / incrementIfBelow contexts/bot/src/infrastructure/sqlite/repositories/QuotaCounterRepository.ts 生产只用 incrementIfBelow(检索 / 推送) | single | | | | | | | | | | | | ● | | | | | | | | | |
| QuotaCounterRepository.deleteBefore contexts/bot/src/infrastructure/sqlite/repositories/QuotaCounterRepository.ts 今天 − 2 天前清理;当前生产代码没有调用方 | single | | | | | | | | | | | | ● | | | | | | | | | |
| ApprovalRepository.create contexts/bot/src/infrastructure/sqlite/repositories/ApprovalRepository.ts 插入 pending | single | ● | | | | | | | | | | | | | | | | | | | | |
| ApprovalRepository.transition contexts/bot/src/infrastructure/sqlite/repositories/ApprovalRepository.ts 条件 UPDATE,进结算态同条记 resolved_at | single | ● | | | | | | | | | | | | | | | | | | | | |
| VenueExecutionRepository.register contexts/bot/src/infrastructure/sqlite/repositories/VenueExecutionRepository.ts ON CONFLICT DO NOTHING,已有即不再尝试
| single | | | | | | | | | | | | | | | | | | | | ● | |
| VenueExecutionRepository.advance contexts/bot/src/infrastructure/sqlite/repositories/VenueExecutionRepository.ts 按 nextExecution 条件推进 | single | | | | | | | | | | | | | | | | | | | | ● | |
| AuditEventRepository.append contexts/bot/src/infrastructure/sqlite/repositories/AuditEventRepository.ts 只追加 | single | | ● | | | | | | | | | | | | | | | | | | | |
| TradingPolicyRepository.savePolicy / setKillSwitch contexts/bot/src/infrastructure/sqlite/repositories/TradingPolicyRepository.ts 单行 upsert;首次只拉 kill switch 时连默认策略一起写入 | single | | | | | | | | | | | | | | | | | | | ● | | |
| DelegationRepository.saveDek contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 首次写入或 KEK 轮换重包 | single | | | | | | ● | | | | | | | | | | | | | | | |
| DelegationRepository.create contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 插入 requested:密文 + 签发请求 | single | | | | | | | | ● | | | | | | | | | | | | | |
| DelegationRepository.attachRequest contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 给没有未完结请求的委托挂请求(撤销 / 续签) | single | | | | | | | | ● | | | | | | | | | | | | | |
| DelegationRepository.saveSubmission / clearSubmission contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 扣着 / 挡着的提交与退避 | single | | | | | | | | ● | | | | | | | | | | | | | |
| DelegationRepository.markExpiryNoticed contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 到期前 7 天提醒,只推一次 | single | | | | | | | | ● | | | | | | | | | | | | | |
| DelegationRepository.transition contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 条件 UPDATE:进 active 清请求,进 revoking / 终态同时销毁 key | single | | | | | | | | ● | | | | | | | | | | | | | |
| DelegationRepository.setRemovalWatch / clearRemovalWatch contexts/bot/src/infrastructure/sqlite/repositories/DelegationRepository.ts 顶替成功后盯旧地址;核到注销 / 超 1 h 删行 | single | | | | | | | ● | | | | | | | | | | | | | | |