latest-form-index-smoke.js 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. #!/usr/bin/env node
  2. const fs = require('fs');
  3. const os = require('os');
  4. const path = require('path');
  5. const { spawnSync } = require('child_process');
  6. const ROOT = path.resolve(__dirname, '..');
  7. function main() {
  8. const bundleResult = spawnSync(process.execPath, [
  9. 'scripts/real-proof-intake-bundle.js',
  10. '--output',
  11. path.join(ROOT, 'outputs', 'real-proof-intake-bundle-latest'),
  12. '--strict'
  13. ], {
  14. cwd: ROOT,
  15. encoding: 'utf8',
  16. shell: false
  17. });
  18. if (bundleResult.stdout) process.stdout.write(bundleResult.stdout);
  19. if (bundleResult.stderr) process.stderr.write(bundleResult.stderr);
  20. assert(bundleResult.status === 0, 'real proof intake bundle should pass before latest form index smoke');
  21. const operatorPackResult = spawnSync(process.execPath, [
  22. 'scripts/proof-gap-operator-pack.js',
  23. '--output',
  24. path.join(ROOT, 'outputs', 'proof-gap-operator-pack-latest'),
  25. '--strict'
  26. ], {
  27. cwd: ROOT,
  28. encoding: 'utf8',
  29. shell: false
  30. });
  31. if (operatorPackResult.stdout) process.stdout.write(operatorPackResult.stdout);
  32. if (operatorPackResult.stderr) process.stderr.write(operatorPackResult.stderr);
  33. assert(operatorPackResult.status === 0, 'proof gap operator pack should pass before latest form index smoke');
  34. const businessExecutionResult = spawnSync(process.execPath, [
  35. 'scripts/business-execution-index.js',
  36. '--output',
  37. path.join(ROOT, 'outputs', 'business-execution-index-latest'),
  38. '--strict'
  39. ], {
  40. cwd: ROOT,
  41. encoding: 'utf8',
  42. shell: false
  43. });
  44. if (businessExecutionResult.stdout) process.stdout.write(businessExecutionResult.stdout);
  45. if (businessExecutionResult.stderr) process.stderr.write(businessExecutionResult.stderr);
  46. assert(businessExecutionResult.status === 0, 'business execution index should pass before latest form index smoke');
  47. const planExecutionResult = spawnSync(process.execPath, [
  48. 'scripts/plan-execution-status.js',
  49. '--outputs',
  50. path.join(ROOT, 'outputs'),
  51. '--output',
  52. path.join(ROOT, 'outputs', 'plan-execution-status-latest'),
  53. '--strict'
  54. ], {
  55. cwd: ROOT,
  56. encoding: 'utf8',
  57. shell: false
  58. });
  59. if (planExecutionResult.stdout) process.stdout.write(planExecutionResult.stdout);
  60. if (planExecutionResult.stderr) process.stderr.write(planExecutionResult.stderr);
  61. assert(planExecutionResult.status === 0, 'plan execution status should pass before latest form index smoke');
  62. const nextActionsResult = spawnSync(process.execPath, [
  63. 'scripts/business-proof-next-actions.js',
  64. '--outputs',
  65. path.join(ROOT, 'outputs'),
  66. '--output',
  67. path.join(ROOT, 'outputs', 'business-proof-next-actions-latest')
  68. ], { cwd: ROOT, encoding: 'utf8', shell: false });
  69. if (nextActionsResult.stdout) process.stdout.write(nextActionsResult.stdout);
  70. if (nextActionsResult.stderr) process.stderr.write(nextActionsResult.stderr);
  71. assert(nextActionsResult.status === 0, 'business proof next actions should pass before latest form index smoke');
  72. const localSeedWorklistResult = spawnSync(process.execPath, [
  73. 'scripts/local-seed-to-intake-worklist.js',
  74. '--outputs',
  75. path.join(ROOT, 'outputs'),
  76. '--output',
  77. path.join(ROOT, 'outputs', 'local-seed-to-intake-worklist-latest')
  78. ], { cwd: ROOT, encoding: 'utf8', shell: false });
  79. if (localSeedWorklistResult.stdout) process.stdout.write(localSeedWorklistResult.stdout);
  80. if (localSeedWorklistResult.stderr) process.stderr.write(localSeedWorklistResult.stderr);
  81. assert(localSeedWorklistResult.status === 0, 'local seed to intake worklist should pass before latest form index smoke');
  82. const realProofClosureWorkOrderResult = spawnSync(process.execPath, [
  83. 'scripts/real-proof-closure-work-order.js',
  84. '--outputs',
  85. path.join(ROOT, 'outputs'),
  86. '--output',
  87. path.join(ROOT, 'outputs', 'real-proof-closure-work-order-latest'),
  88. '--strict'
  89. ], { cwd: ROOT, encoding: 'utf8', shell: false });
  90. if (realProofClosureWorkOrderResult.stdout) process.stdout.write(realProofClosureWorkOrderResult.stdout);
  91. if (realProofClosureWorkOrderResult.stderr) process.stderr.write(realProofClosureWorkOrderResult.stderr);
  92. assert(realProofClosureWorkOrderResult.status === 0, 'real proof closure work order should pass before latest form index smoke');
  93. const outputDir = fs.mkdtempSync(path.join(os.tmpdir(), 'tihao-latest-form-index-'));
  94. const result = spawnSync(process.execPath, [
  95. 'scripts/latest-form-index.js',
  96. '--output',
  97. outputDir,
  98. '--strict'
  99. ], {
  100. cwd: ROOT,
  101. encoding: 'utf8',
  102. shell: false
  103. });
  104. if (result.stdout) process.stdout.write(result.stdout);
  105. if (result.stderr) process.stderr.write(result.stderr);
  106. assert(result.status === 0, 'latest form index should pass against current outputs');
  107. const summaryPath = path.join(outputDir, 'latest-form-index-summary.json');
  108. const reportPath = path.join(outputDir, 'latest-form-index.md');
  109. assert(fs.existsSync(summaryPath), 'summary should exist');
  110. assert(fs.existsSync(reportPath), 'report should exist');
  111. const summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8'));
  112. const report = fs.readFileSync(reportPath, 'utf8').replace(/^\uFEFF/, '');
  113. const operatorOwnerArtifactCount = Number(summary.proofGapOperatorPack?.ownerArtifactCount || 0);
  114. const workOrderCount = Number(summary.realProofClosureWorkOrder?.workOrderCount || 0);
  115. const nextActionCount = Number(summary.nextActions?.actionCount || 0);
  116. const nextActionSourceState = summary.nextActions?.sourceState || {};
  117. assert(summary.passed === true, 'summary should pass');
  118. assert(summary.primaryForm.csv?.includes('tihao-proof-gap-software-form.csv'), 'primary form csv should point to proof gap software form');
  119. assert(summary.primaryForm.passed === true, 'primary form should be passed');
  120. assert(summary.primaryForm.rowCount === 5, 'primary form should have five proof gap rows');
  121. assert(summary.primaryForm.directCustomerProof === false, 'primary form must not be treated as customer proof');
  122. assert(summary.clientList.csv?.includes('software-client-list.final.csv'), 'client list csv should be indexed');
  123. assert(summary.clientList.directCustomerProof === false, 'client list must still require review/customer proof');
  124. assert(summary.clientList.sourceDuplicateRemovedCount >= 0, 'client list should expose source duplicate rows removed');
  125. assert(summary.clientList.duplicateCountMeaning === 'source_duplicate_removed_count', 'client list should define legacy duplicateCount meaning');
  126. assert(summary.clientList.finalDuplicateGroupCount === 0, 'client list should expose zero final duplicate groups');
  127. assert(summary.clientList.rankContinuous === true, 'client list should expose continuous rank status');
  128. assert(summary.businessExecutionIndex?.markdown?.includes('business-execution-index.md'), 'business execution index report should be indexed');
  129. assert(summary.businessExecutionIndex?.csv?.includes('business-execution-index.csv'), 'business execution index csv should be indexed');
  130. assert(summary.businessExecutionIndex?.directCustomerProof === false, 'business execution index must not be treated as customer proof');
  131. assert(summary.businessExecutionIndex?.operatorPackOwnerArtifactCount === operatorOwnerArtifactCount, 'business execution index should expose operator pack owner artifact count');
  132. assert(summary.businessExecutionIndex?.operatorPackOwnerArtifactRowCount === operatorOwnerArtifactCount, 'business execution index should expose operator pack owner artifact rows');
  133. assert(summary.businessExecutionIndex?.operatorPackOwnerArtifacts?.some(item => item.owner === '商务' && item.markdown?.includes('by-owner/business.md') && item.csv?.includes('by-owner/business.csv')), 'business execution index should expose business operator owner files');
  134. assert(summary.businessExecutionIndex?.fieldOwnerRowCount >= 1, 'business execution index should expose field owner rows');
  135. assert(summary.businessExecutionIndex?.recheckCommandRowCount >= 1, 'business execution index should expose recheck command rows');
  136. assert(summary.planExecutionStatus?.markdown?.includes('plan-execution-status.md'), 'plan execution status report should be indexed');
  137. assert(summary.planExecutionStatus?.csv?.includes('plan-execution-status.csv'), 'plan execution status csv should be indexed');
  138. assert(summary.planExecutionStatus?.summary?.includes('plan-execution-status-summary.json'), 'plan execution status summary should be indexed');
  139. assert(summary.planExecutionStatus?.directCustomerProof === false, 'plan execution status must not be treated as customer proof');
  140. assert(summary.planExecutionStatus?.rowCount === 8, 'plan execution status should expose eight plan sections');
  141. assert(summary.planExecutionStatus?.complete === false, 'plan execution status should keep incomplete boundary while proof gaps remain');
  142. assert(summary.planExecutionStatus?.proofOpenCount >= 1, 'plan execution status should expose open proof gap count');
  143. assert(summary.planExecutionStatus?.operatorPackOwnerArtifactCount === operatorOwnerArtifactCount, 'plan execution status should expose operator pack owner artifact count');
  144. assert(summary.planExecutionStatus?.operatorPackOwnerArtifacts?.some(item => item.markdown?.includes('by-owner/business.md') && item.csv?.includes('by-owner/business.csv')), 'plan execution status should expose business operator owner files');
  145. assert(summary.planExecutionStatus?.businessExecutionOperatorPackOwnerArtifactRowCount === operatorOwnerArtifactCount, 'plan execution status should expose business execution operator artifact rows');
  146. assert(summary.proofGapRequest?.markdown?.includes('proof-gap-request-report.md'), 'proof gap request report should be indexed');
  147. assert(summary.proofGapRequest?.csv?.includes('proof-gap-request-table.csv'), 'proof gap request csv should be indexed');
  148. assert(summary.proofGapRequest?.summary?.includes('proof-gap-request-summary.json'), 'proof gap request summary should be indexed');
  149. assert(summary.proofGapRequest?.directCustomerProof === false, 'proof gap request must not be treated as customer proof');
  150. assert(summary.proofGapRequest?.proofLevel === 'smoke_or_local', 'proof gap request should keep smoke/local proof level');
  151. assert(summary.proofGapRequest?.unresolvedCount >= 1, 'proof gap request should expose unresolved count');
  152. assert(summary.proofGapClosure?.summary?.includes('proof-gap-closure-summary.json'), 'proof gap closure summary should be indexed');
  153. assert(summary.proofGapClosure?.markdown?.includes('proof-gap-closure-report.md'), 'proof gap closure report should be indexed');
  154. assert(summary.proofGapClosure?.directCustomerProof === false, 'proof gap closure must not be treated as direct customer proof');
  155. assert(summary.proofGapClosure?.businessOpenCount === summary.proofGapClosure?.openCount, 'proof gap closure should keep openCount as businessOpenCount alias');
  156. assert(summary.proofGapClosure?.businessClosedCount === summary.proofGapClosure?.closedCount, 'proof gap closure should keep closedCount as businessClosedCount alias');
  157. assert(summary.proofGapClosure?.precheckRowCount >= 1, 'proof gap closure should expose precheck rows separately');
  158. assert(summary.proofGapClosure?.countSemantics?.openCount === 'business_gap_open_count_excludes_precheck_rows', 'proof gap closure should expose count semantics');
  159. assert(summary.proofGapOperatorPack?.markdown?.includes('proof-gap-operator-pack.md'), 'proof gap operator pack report should be indexed');
  160. assert(summary.proofGapOperatorPack?.csv?.includes('proof-gap-operator-pack.csv'), 'proof gap operator pack csv should be indexed');
  161. assert(summary.proofGapOperatorPack?.summary?.includes('proof-gap-operator-pack-summary.json'), 'proof gap operator pack summary should be indexed');
  162. assert(summary.proofGapOperatorPack?.directCustomerProof === false, 'proof gap operator pack must not be treated as customer proof');
  163. assert(summary.proofGapOperatorPack?.proofLevel === 'not_business_proof', 'proof gap operator pack should keep not-business-proof level');
  164. assert(summary.proofGapOperatorPack?.openCount >= 1, 'proof gap operator pack should expose open count');
  165. assert(summary.proofGapOperatorPack?.rowCount === 5, 'proof gap operator pack should expose five rows');
  166. assert(summary.proofGapOperatorPack?.ownerGroupCount >= operatorOwnerArtifactCount, 'proof gap operator pack should expose owner group count');
  167. assert(summary.proofGapOperatorPack?.ownerArtifactCount === operatorOwnerArtifactCount, 'proof gap operator pack should expose owner artifact count');
  168. assert(Array.isArray(summary.proofGapOperatorPack?.ownerArtifacts) && summary.proofGapOperatorPack.ownerArtifacts.length === operatorOwnerArtifactCount, 'proof gap operator pack should expose owner artifacts');
  169. assert(summary.proofGapOperatorPack.ownerArtifacts.some(item => item.owner === '商务' && item.markdown?.includes('by-owner/business.md') && item.csv?.includes('by-owner/business.csv')), 'proof gap operator pack should expose business owner files');
  170. assert(summary.proofGapOperatorPack.ownerArtifacts.some(item => item.owner === '技术/AI' && item.markdown?.includes('by-owner/tech-ai.md') && item.csv?.includes('by-owner/tech-ai.csv')), 'proof gap operator pack should expose tech/AI owner files');
  171. if (summary.proofGapOperatorPack.ownerArtifacts.some(item => item.owner === '商务/投放')) {
  172. assert(summary.proofGapOperatorPack.ownerArtifacts.some(item => item.markdown?.includes('by-owner/business-media.md') && item.csv?.includes('by-owner/business-media.csv')), 'proof gap operator pack should expose business/media owner files when present');
  173. }
  174. assert(summary.proofGapOperatorPack?.recheckCommandCount >= 5, 'proof gap operator pack should expose recheck command count');
  175. assert(summary.proofGapOperatorPack?.evidenceRowCount === 5, 'proof gap operator pack should expose evidence row count');
  176. assert(summary.proofGapOperatorPack?.nextActionCount === 5, 'proof gap operator pack should expose next action count');
  177. assert(summary.proofGapOperatorPack?.missingProofRequirementCount >= 1, 'proof gap operator pack should expose missing proof requirement count');
  178. assert(Array.isArray(summary.proofGapOperatorPack?.gapIds) && summary.proofGapOperatorPack.gapIds.includes('historical-dataset') && summary.proofGapOperatorPack.gapIds.includes('manual-review-and-customer-effect'), 'proof gap operator pack should expose stable gap ids');
  179. assert(summary.realProofIntakeBundle?.markdown?.includes('real-proof-intake-bundle.md'), 'real proof intake bundle report should be indexed');
  180. assert(summary.realProofIntakeBundle?.csv?.includes('real-proof-intake-bundle.csv'), 'real proof intake bundle csv should be indexed');
  181. assert(summary.realProofIntakeBundle?.directCustomerProof === false, 'real proof intake bundle must not be treated as customer proof');
  182. assert(summary.realProofIntakeBundle?.proofLevel === 'not_business_proof', 'real proof intake bundle should keep not-business-proof level');
  183. assert(summary.realProofIntakeBundle?.proofOpenCount >= 1, 'real proof intake bundle should expose open proof count');
  184. assert(summary.realProofIntakeBundle?.fillRowCount >= 3, 'real proof intake bundle should expose fill rows');
  185. assert(summary.realProofIntakeBundle?.recheckCommandCount >= 5, 'real proof intake bundle should expose recheck commands');
  186. assert(summary.realProofIntakeBundle?.operatorPackEvidenceRowCount === 5, 'real proof intake bundle should expose operator pack evidence row count');
  187. assert(summary.realProofIntakeBundle?.operatorPackNextActionCount === 5, 'real proof intake bundle should expose operator pack next action count');
  188. assert(summary.realProofIntakeBundle?.operatorPackMissingProofRequirementCount >= 1, 'real proof intake bundle should expose operator pack missing proof requirement count');
  189. assert(summary.realProofIntakeBundle?.operatorPackOwnerArtifactCount === operatorOwnerArtifactCount, 'real proof intake bundle should expose operator pack owner artifact count');
  190. assert(Array.isArray(summary.realProofIntakeBundle?.operatorPackOwnerArtifacts) && summary.realProofIntakeBundle.operatorPackOwnerArtifacts.length === operatorOwnerArtifactCount, 'real proof intake bundle should expose operator pack owner artifacts');
  191. assert(summary.realProofIntakeBundle.operatorPackOwnerArtifacts.some(item => item.owner === '商务' && item.markdown?.includes('by-owner/business.md') && item.csv?.includes('by-owner/business.csv')), 'real proof intake bundle should expose business owner operator files');
  192. assert(summary.realProofClosureWorkOrder?.markdown?.includes('real-proof-closure-work-order.md'), 'real proof closure work order report should be indexed');
  193. assert(summary.realProofClosureWorkOrder?.csv?.includes('real-proof-closure-work-order.csv'), 'real proof closure work order csv should be indexed');
  194. assert(summary.realProofClosureWorkOrder?.summary?.includes('real-proof-closure-work-order-summary.json'), 'real proof closure work order summary should be indexed');
  195. assert(summary.realProofClosureWorkOrder?.directCustomerProof === false, 'real proof closure work order must not be direct customer proof');
  196. assert(summary.realProofClosureWorkOrder?.proofLevel === 'not_business_proof', 'real proof closure work order should keep not-business-proof level');
  197. assert(summary.realProofClosureWorkOrder?.materialType === 'real_proof_closure_work_order', 'real proof closure work order should expose material type');
  198. assert(summary.realProofClosureWorkOrder?.complete === false, 'real proof closure work order should not claim completion');
  199. assert(summary.realProofClosureWorkOrder?.canCloseProofGap === false, 'real proof closure work order must not close proof gaps');
  200. assert(summary.realProofClosureWorkOrder?.workOrderCount >= 5, 'real proof closure work order should expose work orders');
  201. assert(summary.realProofClosureWorkOrder?.ownerGroupCount >= 1, 'real proof closure work order should expose owner groups');
  202. assert(summary.realProofClosureWorkOrder?.proofGapOpenCount >= 1, 'real proof closure work order should expose open proof gaps');
  203. assert(summary.realProofClosureWorkOrder?.intakeFailureCount >= 1, 'real proof closure work order should expose intake failures');
  204. assert(summary.realProofClosureWorkOrder?.realCandidateRows >= 0, 'real proof closure work order should expose real candidate rows');
  205. assert(Array.isArray(summary.realProofClosureWorkOrder?.ownerArtifacts) && summary.realProofClosureWorkOrder.ownerArtifacts.length === summary.realProofClosureWorkOrder.ownerGroupCount, 'real proof closure work order should expose owner artifacts');
  206. assert(summary.realProofClosureWorkOrder.ownerArtifacts.some(item => item.markdown?.includes('by-owner/business.md') && item.csv?.includes('by-owner/business.csv')), 'real proof closure work order should expose business owner files');
  207. assert(summary.realProofClosureWorkOrder.ownerArtifacts.some(item => item.markdown?.includes('by-owner/tech-ai.md') && item.csv?.includes('by-owner/tech-ai.csv')), 'real proof closure work order should expose tech/AI owner files');
  208. if (summary.realProofClosureWorkOrder.ownerArtifacts.some(item => item.owner === '商务/投放')) {
  209. assert(summary.realProofClosureWorkOrder.ownerArtifacts.some(item => item.markdown?.includes('by-owner/business-media.md') && item.csv?.includes('by-owner/business-media.csv')), 'real proof closure work order should expose business/media owner files when present');
  210. }
  211. assert(summary.localSeedToIntakeWorklist?.markdown?.includes('local-seed-to-intake-worklist.md'), 'seed-to-intake worklist report should be indexed');
  212. assert(summary.localSeedToIntakeWorklist?.csv?.includes('local-seed-to-intake-worklist.csv'), 'seed-to-intake worklist csv should be indexed');
  213. assert(summary.localSeedToIntakeWorklist?.summary?.includes('local-seed-to-intake-worklist-summary.json'), 'seed-to-intake worklist summary should be indexed');
  214. assert(summary.localSeedToIntakeWorklist?.historyDraft?.includes('history-intake-draft.csv'), 'seed-to-intake history draft should be indexed');
  215. assert(summary.localSeedToIntakeWorklist?.videoWorklist?.includes('video-resource-worklist.csv'), 'seed-to-intake video worklist should be indexed');
  216. assert(summary.localSeedToIntakeWorklist?.candidateWorklist?.includes('candidate-seed-worklist.csv'), 'seed-to-intake candidate worklist should be indexed');
  217. assert(summary.localSeedToIntakeWorklist?.directCustomerProof === false, 'seed-to-intake worklist must not be direct customer proof');
  218. assert(summary.localSeedToIntakeWorklist?.proofLevel === 'not_business_proof', 'seed-to-intake worklist should keep not-business-proof level');
  219. assert(summary.localSeedToIntakeWorklist?.materialType === 'seed_to_intake_worklist', 'seed-to-intake worklist should classify material type');
  220. assert(summary.localSeedToIntakeWorklist?.complete === false, 'seed-to-intake worklist should not claim completion');
  221. assert(summary.localSeedToIntakeWorklist?.canCloseProofGap === false, 'seed-to-intake worklist must not close proof gaps');
  222. assert(summary.localSeedToIntakeWorklist?.historyDraftRows >= 1, 'seed-to-intake worklist should expose history draft rows');
  223. assert(summary.localSeedToIntakeWorklist?.candidateSeedRows >= 1, 'seed-to-intake worklist should expose candidate seed rows');
  224. assert(summary.localSeedToIntakeWorklist?.videoWorklistRows >= 1, 'seed-to-intake worklist should expose video worklist rows');
  225. assert(summary.localSeedToIntakeWorklist?.videoCandidateNeedsResourceRows >= 1, 'seed-to-intake worklist should expose candidate videos needing resources');
  226. assert(summary.localSeedToIntakeWorklist?.missingProofRequirementCount >= 1, 'seed-to-intake worklist should expose missing proof requirements');
  227. assert(summary.localSeedToIntakeWorklist?.nextActionCount >= 1, 'seed-to-intake worklist should expose next actions');
  228. assert(summary.optimizationCompletion?.markdown?.includes('optimization-completion-report.md'), 'optimization completion report should be indexed');
  229. assert(summary.optimizationCompletion?.summary?.includes('optimization-completion-summary.json'), 'optimization completion summary should be indexed');
  230. assert(summary.optimizationCompletion?.directCustomerProof === false, 'optimization completion audit must not be direct customer proof');
  231. assert(summary.optimizationCompletion?.proofLevel === 'not_business_proof', 'optimization completion should keep not-business-proof level while not ready');
  232. assert(summary.optimizationCompletion?.readyForClaim === false, 'optimization completion should keep readyForClaim false while proof gaps remain');
  233. assert(summary.optimizationCompletion?.proofGapOpenCount >= 1, 'optimization completion should expose open proof gap count');
  234. assert(summary.optimizationCompletion?.blockingReasonCount >= 1, 'optimization completion should expose blocking reasons');
  235. assert(summary.optimizationCompletion?.blockingReasonsWithMissingProofRequirements >= 1, 'optimization completion should expose blockers with missing proof requirements');
  236. assert(summary.optimizationCompletion?.missingProofRequirementCount >= 1, 'optimization completion should expose missing proof requirement count');
  237. assert(summary.optimizationCompletion?.videoAbPreflightReadyForVideoAb === false, 'optimization completion should expose video A/B preflight readiness');
  238. assert(Number.isFinite(Number(summary.optimizationCompletion?.videoAbPreflightFailureCount)), 'optimization completion should expose video A/B preflight failure count');
  239. assert(summary.optimizationCompletion?.canClaim?.tihaoRateImproved === false, 'optimization completion must not allow tihao-rate claim while incomplete');
  240. assert(summary.optimizationCompletion?.canClaim?.customerEffectAchieved === false, 'optimization completion must not allow customer-effect claim while incomplete');
  241. assert(summary.optimizationCompletion?.canClaim?.manualSupplementReduced === false, 'optimization completion must not allow manual-supplement claim while incomplete');
  242. assert(summary.longRunReadiness?.report?.includes('long-run-readiness-report.md'), 'long-run readiness report should be indexed');
  243. assert(summary.longRunReadiness?.summary?.includes('long-run-readiness-summary.json'), 'long-run readiness summary should be indexed');
  244. assert(summary.longRunReadiness?.directCustomerProof === false, 'long-run readiness must not be treated as customer proof');
  245. assert(summary.longRunReadiness?.proofLevel === 'not_business_proof', 'long-run readiness should keep not-business-proof level while blocked');
  246. assert(summary.longRunReadiness?.ready === false, 'long-run readiness should expose ready=false while proof gaps remain');
  247. assert(summary.longRunReadiness?.failCount >= 1, 'long-run readiness should expose failing preflight checks');
  248. assert(summary.nextActions.actionCount >= 1, 'index should expose current action queue count');
  249. assert(summary.nextActions.complete === false, 'index should expose next action queue incomplete state');
  250. assert(summary.nextActions.proofOpenCount >= 1, 'index should expose next action proof gap open count');
  251. assert(summary.nextActions.ownerGroupCount >= 1, 'index should expose next action owner group count');
  252. assert(summary.nextActions.ownerArtifactCount >= summary.nextActions.ownerGroupCount, 'index should expose next action owner artifact count');
  253. assert(summary.nextActions.sourceState?.proofGapOpenCount >= 1, 'index should expose next action source proof gap open count');
  254. assert(nextActionSourceState.pipelineStale === true, 'index should expose stale pipeline state for current next actions');
  255. assert(Number(nextActionSourceState.pipelineNextActionCount || 0) === 0, 'index should expose zero current pipeline actions when stale');
  256. assert(Number(nextActionSourceState.pipelineRawNextActionCount || 0) >= 1, 'index should retain raw stale pipeline action count');
  257. assert(Number(nextActionSourceState.pipelineSuppressedNextActionCount || 0) === Number(nextActionSourceState.pipelineRawNextActionCount || 0), 'index should suppress every stale pipeline action');
  258. assert(String(nextActionSourceState.pipelineStaleReason || '').includes('stale'), 'index should expose stale pipeline reason');
  259. assert(Array.isArray(nextActionSourceState.pipelineStaleMissingProofRequirements) && nextActionSourceState.pipelineStaleMissingProofRequirements.includes('optimizationPipeline.readyForClaim=true'), 'index should expose stale pipeline missing proof requirements');
  260. assert(Array.isArray(summary.nextActions.topActions) && summary.nextActions.topActions.length >= Math.min(5, Number(summary.nextActions.actionCount || 0)), 'index should expose top next actions');
  261. assert(summary.nextActions.topActions.every(item => !String(item.source || '').includes('optimization-pipeline')), 'index should not expose stale optimization-pipeline top actions');
  262. assert(summary.nextActions.topActions.some(item => item.id === 'step-03' && item.command?.includes('history-data-template.csv')), 'index should expose top historical data action');
  263. assert(summary.nextActions.topActions.some(item => item.id === 'gap-video-ab-live-proof' && item.command?.includes('acceptance:video-ab')), 'index should expose top video A/B action');
  264. assert(summary.nextActions.ownerArtifacts.some(item => item.owner === '商务' && item.markdown?.includes('by-owner/business.md')), 'business owner markdown should be indexed');
  265. assert(summary.nextActions.ownerArtifacts.some(item => item.owner === '技术/AI' && item.csv?.includes('by-owner/tech-ai.csv')), 'tech owner csv should be indexed');
  266. assert(summary.nextActions.ownerArtifacts.some(item => item.owner === '商务' && item.repairArtifacts?.some(artifact => artifact.csv.includes('intake-readiness-repair-actions.csv'))), 'business owner repair artifact should be indexed');
  267. assert(summary.nextActions.ownerArtifacts.some(item => item.repairArtifacts?.some(artifact => artifact.csv.includes('homepage-evidence-repair-actions.csv'))) || summary.nextActions.ownerArtifacts.some(item => item.repairArtifacts?.some(artifact => artifact.csv.includes('video-resource-repair-actions.csv'))), 'owner repair artifacts should be indexed');
  268. assert(summary.repairActions?.dataIntake?.csv?.includes('intake-readiness-repair-actions.csv'), 'data intake repair actions csv should be indexed');
  269. assert(summary.repairActions.dataIntake.repairActionCount >= 1, 'data intake repair actions should expose action count');
  270. assert(summary.repairActions?.videoResource?.csv?.includes('video-resource-repair-actions.csv'), 'video resource repair actions csv should be indexed');
  271. assert(summary.repairActions.videoResource.repairActionCount >= 0, 'video resource repair actions should expose action count');
  272. assert(summary.repairActions?.homepageEvidence?.csv?.includes('homepage-evidence-repair-actions.csv'), 'homepage evidence repair actions csv should be indexed');
  273. assert(summary.repairActions.homepageEvidence.repairActionCount >= 1, 'homepage evidence repair actions should expose action count');
  274. assert(summary.repairActions.homepageEvidence.directCustomerProof === false, 'homepage evidence repair actions should not be direct customer proof');
  275. assert(summary.recommendedNextCommand.includes('round:refresh'), 'index should recommend round refresh');
  276. assert(report.includes('# 最新提号表单索引'), 'report should be Chinese');
  277. assert(report.includes('最新提号补证表单'), 'report should include proof gap form');
  278. assert(report.includes('最新软件端候选名单'), 'report should include client candidate list');
  279. assert(report.includes('最终重复组'), 'report should clarify final duplicate group count');
  280. assert(report.includes('源表去重丢弃'), 'report should clarify source duplicate rows removed');
  281. assert(report.includes('## 下一步行动队列摘要'), 'report should include next action queue summary');
  282. assert(report.includes(`actionCount:${nextActionCount}`), 'report should include next action count');
  283. assert(report.includes('pipelineStale:true'), 'report should include stale pipeline state');
  284. assert(report.includes(`pipelineSuppressedNextActionCount:${nextActionSourceState.pipelineSuppressedNextActionCount}`), 'report should include suppressed stale pipeline action count');
  285. assert(report.includes('pipelineStaleReason:'), 'report should include stale pipeline reason');
  286. assert(report.includes('step-03'), 'report should include top historical data action id');
  287. assert(report.includes('gap-video-ab-live-proof'), 'report should include top video A/B action id');
  288. assert(report.includes('acceptance:video-ab'), 'report should include top video A/B command');
  289. assert(report.includes('business-execution-index.md'), 'report should include business execution index');
  290. assert(report.includes('plan-execution-status.md'), 'report should include plan execution status');
  291. assert(report.includes('proof-gap-request-report.md'), 'report should include proof gap request report');
  292. assert(report.includes('真实证明缺口请求包'), 'report should include proof gap request title');
  293. assert(report.includes('proof-gap-closure-report.md'), 'report should include proof gap closure report');
  294. assert(report.includes('提号真实证明缺口关闭审计'), 'report should include proof gap closure title');
  295. assert(report.includes('businessOpenCount='), 'report should include business proof gap open count semantics');
  296. assert(report.includes('precheckOpenCount='), 'report should include precheck count separately');
  297. assert(report.includes('proof-gap-operator-pack.md'), 'report should include proof gap operator pack report');
  298. assert(report.includes('提号补证操作包'), 'report should include proof gap operator pack title');
  299. assert(report.includes('gapIds=historical-dataset'), 'report should include proof gap operator stable ids');
  300. assert(report.includes(`ownerArtifactCount=${operatorOwnerArtifactCount}`), 'report should include proof gap operator owner artifact count');
  301. assert(report.includes('## proof-gap 操作包负责人文件'), 'report should include proof gap operator owner files section');
  302. assert(report.includes('by-owner/business.csv'), 'report should include business owner csv');
  303. if (summary.proofGapOperatorPack.ownerArtifacts.some(item => item.owner === '商务/投放')) {
  304. assert(report.includes('by-owner/business-media.md'), 'report should include business/media owner markdown when present');
  305. }
  306. assert(report.includes('by-owner/tech-ai.csv'), 'report should include tech/AI owner csv');
  307. assert(report.includes('evidenceRowCount=5'), 'report should include proof gap operator evidence row count');
  308. assert(report.includes('nextActionCount=5'), 'report should include proof gap operator next action count');
  309. assert(report.includes('real-proof-intake-bundle.md'), 'report should include real proof intake bundle');
  310. assert(report.includes('真实验收材料收集总包'), 'report should include real proof intake bundle title');
  311. assert(report.includes('operatorPackEvidenceRowCount=5'), 'report should include real proof bundle operator evidence row count');
  312. assert(report.includes('operatorPackNextActionCount=5'), 'report should include real proof bundle operator next action count');
  313. assert(report.includes(`operatorPackOwnerArtifactCount=${operatorOwnerArtifactCount}`), 'report should include real proof bundle operator owner artifact count');
  314. assert(report.includes('## 真实验收总包操作包负责人附件'), 'report should include real proof bundle operator owner artifact section');
  315. assert(report.includes('by-owner/business.csv'), 'report should include real proof bundle business owner csv');
  316. assert(report.includes('real-proof-closure-work-order.md'), 'report should include real proof closure work order');
  317. assert(report.includes('真实证明闭环工单'), 'report should include real proof closure work order title');
  318. assert(report.includes(`workOrderCount=${workOrderCount}`), 'report should include real proof closure work order count');
  319. assert(report.includes('canCloseProofGap=false'), 'report should include real proof closure work order boundary');
  320. assert(report.includes('## 真实证明闭环工单负责人附件'), 'report should include real proof closure work order owner artifact section');
  321. if (summary.realProofClosureWorkOrder.ownerArtifacts.some(item => item.owner === '商务/投放')) {
  322. assert(report.includes('by-owner/business-media.csv'), 'report should include real proof closure work order business/media csv when present');
  323. }
  324. assert(report.includes('by-owner/tech-ai.md'), 'report should include real proof closure work order tech owner markdown');
  325. assert(report.includes('本地种子转 intake 补表 worklist'), 'report should include seed-to-intake worklist title');
  326. assert(report.includes('local-seed-to-intake-worklist.md'), 'report should include seed-to-intake worklist report');
  327. assert(report.includes('history-intake-draft.csv'), 'report should include seed-to-intake history draft');
  328. assert(report.includes('video-resource-worklist.csv'), 'report should include seed-to-intake video worklist');
  329. assert(report.includes('candidate-seed-worklist.csv'), 'report should include seed-to-intake candidate worklist');
  330. assert(report.includes('seed_to_intake_worklist'), 'report should include seed-to-intake material type');
  331. assert(report.includes('optimization-completion-report.md'), 'report should include optimization completion report');
  332. assert(report.includes('readyForClaim=false'), 'report should include optimization completion readyForClaim boundary');
  333. assert(report.includes('missingProofRequirementCount='), 'report should include optimization completion missing proof requirement count');
  334. assert(report.includes('videoAbPreflightReadyForVideoAb='), 'report should include optimization completion video A/B preflight readiness');
  335. assert(report.includes('videoAbPreflightFailureCount='), 'report should include optimization completion video A/B preflight failure count');
  336. assert(report.includes('proofGapOpenCount'), 'report should include optimization completion proof gap count');
  337. assert(report.includes('long-run-readiness-report.md'), 'report should include long-run readiness report');
  338. assert(report.includes('ready=false'), 'report should include long-run readiness ready=false boundary');
  339. assert(report.includes('长跑前置门禁'), 'report should include long-run readiness title');
  340. assert(report.includes('proofOpenCount'), 'report should show plan proof open count');
  341. assert(report.includes(`operatorPackOwnerArtifactCount=${operatorOwnerArtifactCount}`), 'report should show plan execution operator owner attachment count');
  342. assert(report.includes(`操作包负责人附件 ${operatorOwnerArtifactCount}`), 'report should show business execution operator owner attachment count');
  343. assert(report.includes('## 商务执行总表操作包负责人附件'), 'report should include business execution operator owner artifact section');
  344. assert(report.includes('字段负责人'), 'report should show business execution index field owner count');
  345. assert(report.includes('复验命令'), 'report should show business execution index recheck command count');
  346. assert(report.includes('修复附件'), 'report should include owner repair artifact column');
  347. assert(report.includes('## 修复清单入口'), 'report should include repair action section');
  348. assert(report.includes('intake-readiness-repair-actions.csv'), 'report should include data intake repair action csv');
  349. assert(report.includes('video-resource-repair-actions.csv'), 'report should include video resource repair action csv');
  350. assert(report.includes('homepage-evidence-repair-actions.csv'), 'report should include homepage evidence repair action csv');
  351. assert(report.includes('不能把 sample、smoke、模板'), 'report should include proof guardrail');
  352. assert(!/sk-[A-Za-z0-9_-]{10,}/.test(report), 'report should not contain model token patterns');
  353. assert(!/r:[A-Za-z0-9]{20,}/.test(report), 'report should not contain Parse sessionToken patterns');
  354. assert(!/Authorization/i.test(report), 'report should not expose Authorization text');
  355. assert(summary.supportDocs?.some(item => item.path?.includes('tihao-experience-optimization-plan.zh-CN.md')), 'Chinese optimization plan should be indexed');
  356. assert(summary.supportDocs?.some(item => item.path?.includes('tihao-experience-optimization-plan.md')), 'main optimization plan should be indexed');
  357. assert(summary.supportDocs?.some(item => item.path?.includes('business-proof-action-order.zh-CN.md')), 'Chinese proof action order should be indexed');
  358. assert(summary.supportDocs?.some(item => item.path?.includes('tihao-handoff-index.md')), 'task handoff index should be indexed');
  359. assert(summary.intakeFieldChecklist?.markdown?.includes('intake-field-checklist.md'), 'intake field checklist markdown should be indexed');
  360. assert(summary.intakeFieldChecklist?.csv?.includes('intake-field-checklist.csv'), 'intake field checklist csv should be indexed');
  361. assert(summary.intakeFieldChecklist?.directCustomerProof === false, 'intake field checklist must not be treated as customer proof');
  362. assert(summary.manualReviewLabelGuide?.markdown?.includes('manual-review-label-guide.md'), 'manual review label guide markdown should be indexed');
  363. assert(summary.manualReviewLabelGuide?.csv?.includes('manual-review-label-guide.csv'), 'manual review label guide csv should be indexed');
  364. assert(summary.manualReviewLabelGuide?.directCustomerProof === false, 'manual review label guide must not be treated as customer proof');
  365. assert(summary.manualReviewLabelGuide?.negativeLabelsRequireAttribution === true, 'manual review label guide should require negative attribution');
  366. assert(summary.manualReviewLabelGuide?.attributionTypeCount >= 8, 'manual review label guide should expose attribution types');
  367. assert(Array.isArray(summary.intakeFieldChecklist?.ownerGroups) && summary.intakeFieldChecklist.ownerGroups.length >= 1, 'intake field checklist owner groups should be indexed');
  368. assert(summary.intakeFieldChecklist.ownerGroups.some(item => item.owner === '商务' && item.files?.some(file => file.includes('history-data-template.csv'))), 'business history owner group should expose history template');
  369. assert(Array.isArray(summary.intakeFieldChecklist?.recheckCommands) && summary.intakeFieldChecklist.recheckCommands.length >= 1, 'intake field checklist recheck commands should be indexed');
  370. assert(summary.intakeFieldChecklist.recheckCommands.some(item => item.command.includes('intake:readiness')), 'intake readiness recheck command should be indexed');
  371. assert(summary.intakeFieldChecklist.recheckCommands.some(item => item.command.includes('acceptance:video-ab')), 'video A/B recheck command should be indexed');
  372. assert(summary.businessFillGuide?.directCustomerProof === false, 'business fill guide must not be treated as customer proof');
  373. assert(summary.businessFillGuide?.rowCount >= 3, 'business fill guide should expose owner fill rows');
  374. assert(summary.businessFillGuide.rows.some(item => item.owner === '商务' && item.section === 'history' && item.file.includes('history-data-template.csv')), 'business fill guide should expose history template row');
  375. assert(summary.businessFillGuide.rows.some(item => item.section === 'video' && item.recheckCommand.includes('video:resource-readiness')), 'business fill guide should expose video readiness recheck command');
  376. assert(summary.businessFillGuide.rows.every(item => String(item.boundary || '').includes('不证明客户效果')), 'business fill guide rows should keep proof boundary');
  377. assert(report.includes('## 中文 SOP 入口'), 'report should include Chinese SOP section');
  378. assert(report.includes('tihao-experience-optimization-plan.zh-CN.md'), 'report should include Chinese optimization plan');
  379. assert(report.includes('tihao-experience-optimization-plan.md'), 'report should include main optimization plan');
  380. assert(report.includes('business-proof-action-order.zh-CN.md'), 'report should include Chinese proof action order');
  381. assert(report.includes('tihao-handoff-index.md'), 'report should include task handoff index');
  382. assert(report.includes('intake-field-checklist.md'), 'report should include intake field checklist');
  383. assert(report.includes('manual-review-label-guide.md'), 'report should include manual review label guide');
  384. assert(report.includes('人工复核标签与归因指南'), 'report should include manual review label guide title');
  385. assert(report.includes('## 字段补齐负责人顺序'), 'report should include field checklist owner group section');
  386. assert(report.includes('history-data-template.csv'), 'report should include history template in owner group section');
  387. assert(report.includes('## 商务填表执行视图'), 'report should include business fill guide section');
  388. assert(report.includes('本视图只帮助商务按表补齐真实材料'), 'report should include business fill guide guardrail');
  389. assert(report.includes('## 补齐后复验命令'), 'report should include recheck command section');
  390. assert(report.includes('npm run intake:readiness'), 'report should include intake readiness recheck command');
  391. assert(report.includes('npm run acceptance:video-ab'), 'report should include video A/B recheck command');
  392. console.log(JSON.stringify({
  393. ok: true,
  394. outputDir,
  395. actionCount: summary.nextActions.actionCount,
  396. topActionCount: summary.nextActions.topActions.length,
  397. primaryForm: summary.primaryForm.csv
  398. }, null, 2));
  399. }
  400. function assert(condition, message) {
  401. if (!condition) throw new Error(message);
  402. }
  403. if (require.main === module) main();