"""Build a local business-output preview and verify evidence/arithmetic, not insight quality.""" from pathlib import Path from decimal import Decimal from collections import Counter from datetime import datetime import hashlib import html import json import re import unicodedata WORK = Path(__file__).resolve().parent ROOT = WORK.parents[1] SKILL = ROOT / 'skills/ksf-workshop-runtime' load = lambda p: json.loads(p.read_text(encoding='utf-8')) sha = lambda p: hashlib.sha256(p.read_bytes()).hexdigest() inputs = load(WORK / 'probe-inputs.json') outputs = load(WORK / 'probe-outputs.json') raw = load((WORK / inputs['rawConsumerAndCostFixture']).resolve()) samples = {s['id']: s for s in outputs['samples']} checks = [] def check(name, passed, actual=None): checks.append({'name': name, 'passed': bool(passed), 'actual': actual}) assert passed, (name, actual) market = inputs['marketFixture'] prior, current = market['periods'] check('同一固定面板', set(prior['panelIds']) == set(current['panelIds'])) facts = samples['trend']['facts'] prior_n, current_n, denominator = len(prior['adjustableClaimIds']), len(current['adjustableClaimIds']), len(current['panelIds']) check('趋势分子分母来自原始列表', (facts['priorClaimCount'], facts['currentClaimCount'], facts['panelSize']) == (prior_n, current_n, denominator)) check('占比与百分点分别计算', facts['priorShare'] == prior_n / denominator and facts['currentShare'] == current_n / denominator and Decimal(str(facts['changePercentagePoints'])) == (Decimal(current_n) - Decimal(prior_n)) / Decimal(denominator) * 100) check('同源转载未计作独立资料', facts['independentNewsOrigins'] == len({n['original'] for n in market['news']})) check('目录范围不同且没有需求增长数', market['broadSearch'][0]['catalogueScope'] != market['broadSearch'][1]['catalogueScope'] and market['sales'] is None and not facts['demandGrowthKnown']) reviews = {r['id']: r for r in raw['reviews']} seen = set() duplicates = [] for r in raw['reviews']: if r['upstreamId'] in seen: duplicates.append(r['id']) seen.add(r['upstreamId']) cf = samples['consumer']['facts'] check('原始记录规模与重复取得', cf['rawReviewCount'] == len(reviews) and cf['repeatedAcquisitionIds'] == duplicates) check('占位记录依据原文', [reviews[x]['text'] for x in cf['placeholderIds']] == ['此用户没有填写评价']) check('物流用途排除保留原件', cf['logisticsOnlyIds'] == ['E10'] and reviews['E10']['text'] == '发来外箱压了,面没破,味道还没吃。') excluded = set(duplicates + cf['placeholderIds'] + cf['logisticsOnlyIds']) check('口味/使用集合没有混入重复占位物流', set(cf['tasteUsageIds']) == set(reviews) - excluded and len(cf['tasteUsageIds']) == len(set(cf['tasteUsageIds'])), len(cf['tasteUsageIds'])) check('关键原句逐字对应', samples['consumer']['rows'][0][0] == 'E02:' + reviews['E02']['text'] and samples['consumer']['rows'][1][0] == 'E03:' + reviews['E03']['text']) check('相反取舍索引回查', cf['counterexampleIds'] == ['E05', 'E06'] and all(x in cf['tasteUsageIds'] for x in cf['counterexampleIds'])) conditions = raw['scenarioConditions'] dec = lambda n: Decimal(str(n)) revenue, base, margin = map(dec, (conditions['netRevenuePerServing'], conditions['baseUnitCost'], conditions['minimumGrossMargin'])) ceiling = revenue * (1 - margin) rf = samples['rd']['facts'] check('成本上限与增量空间', dec(rf['costCeiling']) == ceiling and dec(rf['incrementalHeadroom']) == ceiling - base, {'ceiling': str(ceiling), 'headroom': str(ceiling - base)}) estimates = {v['change']: dec(v['extraCost']) for v in conditions['incrementalCostEstimates']} for option in rf['options']: cost = base + estimates[option['change']] gross = (revenue - cost) / revenue check('情景成本与毛利:' + option['change'], dec(option['cost']) == cost and abs(dec(option['grossMargin']) - gross) < Decimal('0.000000000001')) rev = samples['revision']['facts'] check('修订保留经营与设备条件', dec(rev['netRevenue']) == revenue and dec(rev['minimumGrossMargin']) == margin and dec(rev['costCeiling']) == ceiling and rev['noodleEquipmentChangeAllowed'] == conditions['noodleEquipmentChangeAllowed']) check('修订没有假称新路线已核价或实测', rev['noNewSachet'] and not rev['newRecipeCostVerified'] and not rev['physicalTestPerformed']) before = load(WORK / 'before-fingerprints.json') runtime = {n: h for n, h in before.items() if n.startswith('scripts/') or n == 'runtime-lock.json'} check('七个运行/锁定文件未变', len(runtime) == 7 and all(sha(SKILL / n) == h for n, h in runtime.items())) old_course = WORK / 'before/references/workshop-course-flow.md' new_course = SKILL / 'references/workshop-course-flow.md' check('课表映射文件原字节未变', sha(old_course) == sha(new_course)) check('13个研究环节顺序保留', re.findall(r'^\| (D[12]-(?:\d\d|N)) \| \d\d \|', new_course.read_text(encoding='utf-8'), re.M) == ['D1-01','D1-02','D1-03','D1-04','D1-N','D2-01','D2-02','D2-03','D2-04','D2-05','D2-06','D2-07','D2-08']) # Check real relative resources. Fragment anchors are checked for the newly introduced reference. links = [] for p in SKILL.rglob('*.md'): for target in re.findall(r'(?
查看同一组构造素材怎样形成趋势判断、消费者洞察、研发比较,以及用户提出修改后怎样接续。业务回复便于快速讨论,评审底表保留具体对照。