refactor(data): 收口关系表运行时数据源
Some checks failed
Deploy Production / Build, push, deploy, verify (push) Has been cancelled

- 移除已迁移业务 AppData 运行时 fallback,改走领域 API 和关系表快读
- 补齐需求产品负责人、版本计划任务 JSON 和成员 username 回填迁移
- 统一治理字典入口,并补充 AI provider、数据源契约和领域服务测试

Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
2026-07-09 14:59:49 +08:00
parent 1e6fb0c7aa
commit 2e595c7e72
98 changed files with 2938 additions and 1441 deletions

View File

@@ -5,6 +5,11 @@ import test from 'node:test';
const planStore = () => readFileSync(join(process.cwd(), 'stores/useVersionPlanStore.ts'), 'utf8');
const taskStore = () => readFileSync(join(process.cwd(), 'stores/useDevTaskStore.ts'), 'utf8');
const versionDetailPage = () => readFileSync(join(process.cwd(), 'app/versions/[id]/page.tsx'), 'utf8');
const workspacePage = () => readFileSync(join(process.cwd(), 'app/workspace/page.tsx'), 'utf8');
const devTaskTab = () => readFileSync(join(process.cwd(), 'components/dev-task/DevTaskTab.tsx'), 'utf8');
const projectListPage = () => readFileSync(join(process.cwd(), 'app/projects/page.tsx'), 'utf8');
const projectDetailPage = () => readFileSync(join(process.cwd(), 'app/projects/[id]/page.tsx'), 'utf8');
function storeMethodBody(text: string, name: string) {
const implementationStart = text.indexOf('export const');
@@ -37,12 +42,52 @@ test('version plan store uses domain APIs for version-scoped writes', () => {
assert.match(storeMethodBody(text, 'completePlan'), /completeVersionPlanByVersionId\(versionId, id,/);
assert.doesNotMatch(storeMethodBody(text, 'createPlan'), /saveServerData\('version-plans'/);
assert.doesNotMatch(storeMethodBody(text, 'updatePlan'), /saveServerData\('version-plans'/);
assert.doesNotMatch(text, /saveServerData\('version-plans'/);
assert.doesNotMatch(text, /saveVersionPlansFallback/);
});
test('version plan domain API preserves research direction tasks', () => {
const text = readFileSync(join(process.cwd(), 'lib/domain-api.ts'), 'utf8');
assert.match(text, /data\.tasks !== undefined && \{ tasks: data\.tasks \}/);
assert.match(text, /tasks: asArray<PlanTask>\(row\.tasks\)/);
});
test('version plan reads for version detail use version-scoped relation data', () => {
const store = planStore();
const fetchPlans = storeMethodBody(store, 'fetchPlans');
const page = versionDetailPage();
assert.match(fetchPlans, /listVersionPlansByVersionId\(options\.versionId\)/);
assert.match(fetchPlans, /!options\?\.versionId && !options\?\.force/);
assert.match(fetchPlans, /mergeVersionPlansForVersion/);
assert.doesNotMatch(fetchPlans, /listVersionPlansByVersionId\(options\.versionId\)\.catch\(loadStored\)/);
assert.match(page, /fetchPlans\(\{ versionId \}\);/);
assert.match(page, /v22Scope,\s*\}\)/);
assert.doesNotMatch(page, /versionWriteStoresReady \? null : v22Scope/);
assert.match(page, /const displayRequirements = scopedVersionData\.requirements/);
assert.match(page, /const displayRequirementIds = scopedVersionData\.requirementIds/);
assert.match(page, /const displayPlans = scopedVersionData\.plans/);
assert.match(page, /const displayDevTasks = scopedVersionData\.devTasks/);
assert.match(page, /const displayTestCases = scopedVersionData\.testCases/);
assert.match(page, /const displayBugs = scopedVersionData\.bugs/);
});
test('workspace plan drawer loads version-scoped relation data', () => {
const page = workspacePage();
assert.match(page, /fetchPlans\(\{ versionId: item\.versionId \}\)/);
assert.doesNotMatch(page, /&& !plansLoaded\) \{\s*pendingLoads\.push\(fetchPlans\(\{ versionId: item\.versionId \}\)\);/);
assert.doesNotMatch(page, /pendingLoads\.push\(fetchPlans\(\)\);/);
});
test('dev task store uses domain APIs for version-scoped writes', () => {
const text = taskStore();
const fetchTasks = storeMethodBody(text, 'fetchTasks');
assert.match(text, /from '@\/lib\/domain-api'/);
assert.match(fetchTasks, /listDevTasksByVersionId\(options\.versionId\)/);
assert.match(fetchTasks, /!options\?\.versionId && !options\?\.force/);
assert.match(storeMethodBody(text, 'createTask'), /createDevTaskByVersionId\(task\.versionId,/);
assert.match(storeMethodBody(text, 'updateTask'), /updateDevTaskByVersionId\(versionId, id,/);
assert.match(storeMethodBody(text, 'changeStatus'), /updateDevTaskStatusByVersionId\(task\.versionId,/);
@@ -50,3 +95,39 @@ test('dev task store uses domain APIs for version-scoped writes', () => {
assert.doesNotMatch(storeMethodBody(text, 'createTask'), /saveServerData\('dev-tasks'/);
assert.doesNotMatch(storeMethodBody(text, 'updateTask'), /saveServerData\('dev-tasks'/);
});
test('workspace dev task drawer loads version-scoped relation data', () => {
const page = workspacePage();
assert.match(page, /fetchTasks\(\{ versionId: item\.versionId \}\)/);
assert.doesNotMatch(page, /item\.type === 'devTask' && !devTasksLoaded/);
assert.doesNotMatch(page, /pendingLoads\.push\(fetchTasks\(\)\);/);
});
test('dev task tab fallback fetches the current version relation partition', () => {
const text = devTaskTab();
assert.match(text, /fetchTasks\(\{ versionId \}\)/);
assert.doesNotMatch(text, /if \(!scopedVersionTasks\) fetchTasks\(\);/);
});
test('project pages hydrate version summaries through version-scoped relation partitions', () => {
const listPage = projectListPage();
const detailPage = projectDetailPage();
assert.match(listPage, /fetchPlans\(\{ versionId: version\.id \}\)/);
assert.match(listPage, /fetchDevTasks\(\{ versionId: version\.id \}\)/);
assert.match(listPage, /fetchTestCases\(\{ versionId: version\.id \}\)/);
assert.doesNotMatch(listPage, /fetchPlans\(\);/);
assert.doesNotMatch(listPage, /fetchDevTasks\(\);/);
assert.doesNotMatch(listPage, /fetchTestCases\(\);/);
assert.match(detailPage, /fetchPlans\(\{ versionId: version\.id \}\)/);
assert.match(detailPage, /fetchDevTasks\(\{ versionId: version\.id \}\)/);
assert.match(detailPage, /fetchTestCases\(\{ versionId: version\.id \}\)/);
assert.match(detailPage, /fetchBugs\(\{ versionId: version\.id \}\)/);
assert.doesNotMatch(detailPage, /fetchPlans\(\);/);
assert.doesNotMatch(detailPage, /fetchDevTasks\(\);/);
assert.doesNotMatch(detailPage, /fetchTestCases\(\);/);
assert.doesNotMatch(detailPage, /fetchBugs\(\);/);
});