technical

数据基础

围绕当前 migration 的真实 D1 对象模型,锁定 workflow / registry / ledger / reserved supply 的边界与查询规则。

Audience

开发者 / 后端设计

Updated

2026-03-26

Source

docs/data-foundation.md

当前结论

  • 模块三 Day 8 已完成,D1 当前已经是 workflow / profiles / targets 的默认主持久化层
  • run ledger、credit ledger、executionBoundary 与 creditBoundary 当前都已有稳定合同
  • local 与 staging 两条 query proof 已在 2026-03-26 闭环
  • 模块五 Day 4 已完成,默认下一步现已切到模块五 Day 5,而不是继续在模块三或模块四扩 scope

当前真相源

  • db/migrations/0001_workflow_foundation.sql
  • db/migrations/0002_developer_supply_foundation.sql
  • src/lib/server/d1-boundary-map.ts
  • scripts/module3-d1-query-proof.mjs
  • docs/data-foundation.md
  • docs/module-3-acceptance.zh-CN.md

2026-03-26 验收快照

  • local D1 proof:workflow=1、profiles=6、targets=3、runs=9、usage=15、wallet=464
  • remote D1 proof:workflow=4、profiles=3、targets=3、runs=6、usage=9、wallet=452
  • workflow_alpha 节点数量在 local / remote 两端都和 D1 一致
  • run detail 在 local / remote 两端都继续返回 executionBoundary 与 creditBoundary

已知待补点

  • local migrate 还不是幂等的,重复执行可能触发 table already exists
  • staging seed 仍然不适合盲目重复执行,因为当前还是普通 INSERT
  • target catalog 仍然是 global catalog,没有 project install / override
  • queued run 之后还缺真正执行器与 terminal receipt

当前层级

  • Account Foundation
  • Project Boundary
  • Workflow Objects
  • Registry Objects
  • Execution and Ledger Objects
  • Reserved Supply and Settlement Foundations

当前 migration 对应物

  • db/migrations/0001_workflow_foundation.sql
  • db/migrations/0002_developer_supply_foundation.sql
  • src/lib/server/d1-boundary-map.ts
  • workflows / workflow_nodes / workflow_edges / autofill_jobs
  • company_profiles / target_sites / target_site_versions
  • workflow_runs / workflow_run_steps / credit_wallets / credit_transactions / audit_events

当前规则

  • workflow、profiles、runs 走 project-first
  • target catalog 当前保持 global lookup
  • credit wallet 维持 account-owned
  • credit transactions 与 audit events 保持 account-backed 但 project-filterable
  • reserved supply tables 先保留,不提前混入买方 workspace 主线