@wowok/agent-mcp 3.2.2 → 3.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chain-semantics/field-capability.d.ts +11 -0
- package/dist/chain-semantics/field-capability.js +1 -0
- package/dist/chain-semantics/freeze-map.d.ts +11 -0
- package/dist/chain-semantics/freeze-map.js +1 -0
- package/dist/chain-semantics/fund-flow.d.ts +10 -0
- package/dist/chain-semantics/fund-flow.js +1 -0
- package/dist/chain-semantics/guard-verbs.d.ts +22 -0
- package/dist/chain-semantics/guard-verbs.js +1 -0
- package/dist/chain-semantics/index.d.ts +10 -0
- package/dist/chain-semantics/index.js +1 -0
- package/dist/chain-semantics/object-graph.d.ts +18 -0
- package/dist/chain-semantics/object-graph.js +1 -0
- package/dist/communication/proof-reuse.d.ts +9 -0
- package/dist/communication/proof-reuse.js +1 -0
- package/dist/composition/audit.d.ts +10 -0
- package/dist/composition/audit.js +1 -0
- package/dist/composition/compile.d.ts +38 -0
- package/dist/composition/compile.js +1 -0
- package/dist/composition/materialize.d.ts +64 -0
- package/dist/composition/materialize.js +1 -0
- package/dist/composition/plan.d.ts +92 -0
- package/dist/composition/plan.js +1 -0
- package/dist/composition/reflux.d.ts +28 -0
- package/dist/composition/reflux.js +1 -0
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/business-modules.js +1 -1
- package/dist/extensions/industry-pack.js +1 -1
- package/dist/extensions/modes.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/keeper/detectors.d.ts +7 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/types.d.ts +1 -1
- package/dist/keeper/types.js +1 -1
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocation-puzzle.js +1 -1
- package/dist/knowledge/allocation-risk.js +1 -1
- package/dist/knowledge/allocation-templates.js +1 -1
- package/dist/knowledge/arb-fund-facts.d.ts +31 -0
- package/dist/knowledge/arb-fund-facts.js +1 -0
- package/dist/knowledge/baselines/rules/allocation.json +44 -15
- package/dist/knowledge/baselines/rules/guard.json +27 -8
- package/dist/knowledge/baselines/rules/plan.json +161 -0
- package/dist/knowledge/baselines/semantic-facts.d.ts +12 -0
- package/dist/knowledge/baselines/semantic-facts.js +1 -0
- package/dist/knowledge/builtin-templates.d.ts +1 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/getting-started.js +1 -1
- package/dist/knowledge/guard-bindings.js +1 -1
- package/dist/knowledge/guard-design-patterns.d.ts +1 -1
- package/dist/knowledge/guard-design-patterns.js +1 -1
- package/dist/knowledge/guard-ledger.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-ledger.js +1 -1
- package/dist/knowledge/machine-templates.js +1 -1
- package/dist/knowledge/onchain-constants.d.ts +2 -2
- package/dist/knowledge/onchain-constants.js +1 -1
- package/dist/knowledge/progress-ledger.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +13 -0
- package/dist/knowledge/service-allocation-semantics.js +1 -1
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/service-templates.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-loader.d.ts +17 -1
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/knowledge/workflow-guidance.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/participation/radar-core.d.ts +6 -0
- package/dist/participation/radar-core.js +1 -1
- package/dist/playbooks/service-build/business-puzzle.js +1 -1
- package/dist/playbooks/service-build/machine-panorama.js +1 -1
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/object-panorama.js +1 -1
- package/dist/playbooks/service-build/participation-radar.js +1 -1
- package/dist/playbooks/service-build/relationship-profile.js +1 -1
- package/dist/playbooks/service-build/service-panorama.js +1 -1
- package/dist/playbooks/service-build/service-quote.js +1 -1
- package/dist/playbooks/service-build/service-quote.spec.d.ts +1 -0
- package/dist/playbooks/service-build/service-quote.spec.js +1 -0
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +4 -0
- package/dist/schema/call/base.js +1 -1
- package/dist/schema/call/bridge.d.ts +1 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/machine.js +1 -1
- package/dist/schema/call/order.d.ts +60 -0
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.d.ts +56 -0
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/index.d.ts +1 -0
- package/dist/schema/index.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +2 -0
- package/dist/schema/industry-pack/index.js +1 -1
- package/dist/schema/interaction/index.d.ts +1 -1
- package/dist/schema/local/index.d.ts +10 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/operations.d.ts +48 -0
- package/dist/schema/query/bi.d.ts +26 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/service-clone/index.d.ts +46 -0
- package/dist/schema/service-clone/index.js +1 -0
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +1 -0
- package/dist/schemas/bridge_operation.output.json +1 -0
- package/dist/schemas/index.json +7 -1
- package/dist/schemas/industry_pack_operation.output.json +4 -0
- package/dist/schemas/industry_pack_operation.schema.json +4 -0
- package/dist/schemas/local_cache_operation.output.json +1 -0
- package/dist/schemas/local_history_operation.output.json +1 -0
- package/dist/schemas/local_info_operation.output.json +1 -0
- package/dist/schemas/local_mark_operation.output.json +1 -0
- package/dist/schemas/onchain_operations.output.json +2 -1
- package/dist/schemas/onchain_operations.schema.json +408 -97
- package/dist/schemas/onchain_operations_allocation.schema.json +5 -5
- package/dist/schemas/onchain_operations_arbitration.schema.json +3 -3
- package/dist/schemas/onchain_operations_contact.schema.json +1 -1
- package/dist/schemas/onchain_operations_demand.schema.json +3 -3
- package/dist/schemas/onchain_operations_gen_passport.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +59 -59
- package/dist/schemas/onchain_operations_machine.schema.json +2 -2
- package/dist/schemas/onchain_operations_order.schema.json +133 -1
- package/dist/schemas/onchain_operations_progress.schema.json +1 -1
- package/dist/schemas/onchain_operations_proof.schema.json +1 -1
- package/dist/schemas/onchain_operations_repository.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +4 -4
- package/dist/schemas/onchain_operations_service.schema.json +187 -8
- package/dist/schemas/onchain_operations_treasury.schema.json +7 -7
- package/dist/schemas/query_toolkit.output.json +136 -52
- package/dist/schemas/service_clone_operation.output.json +168 -0
- package/dist/schemas/service_clone_operation.schema.json +49 -0
- package/dist/schemas/workflow_operation.schema.json +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/industry-pack.js +1 -1
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/service-clone.d.ts +2 -0
- package/dist/tools/handlers/service-clone.js +1 -0
- package/dist/tools/index.js +1 -1
- package/dist/tools/move-fn-index.gen.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/wrap.d.ts +6 -1
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as
|
|
1
|
+
import{describe,expect,it}from'vitest';import{ENTRYPOINT}from'@wowok/wowok';import{FakeDataPlane}from'../../graph/onchain/dataplane.js';import{expandTopology}from'../../graph/onchain/expand.js';import{FULL,GAP,fullServiceState,gapServiceState,truncatedServiceState}from'../../graph/onchain/fixtures.js';import{buildViewport}from'../../graph/onchain/viewport.js';import{runAnalyzers}from'../../graph/onchain/analyze.js';import{EVALUATION_SERVICE_INTENTS,resolveExpansionStrategy,withEvaluationBundle}from'../../graph/onchain/strategy.js';import{projectEvaluationFacts as a35a}from'../../graph/onchain/facts.js';import{evaluateGraphServiceFacts,GRAPH_RULE_INPUT_FACTS,registerGraphServiceEvaluations}from'./graph-service.js';async function evalState(a,b){registerGraphServiceEvaluations();const c=withEvaluationBundle(resolveExpansionStrategy({'intents':[...EVALUATION_SERVICE_INTENTS]})),d=await expandTopology(new FakeDataPlane(a),{'network':ENTRYPOINT['Mainnet'],'seed':b,'edges':c['edges'],'budget':c['budget']}),e=buildViewport(d,b,'neutral'),f=a35a(e,b,runAnalyzers(e));return{'projected':f,'r':await evaluateGraphServiceFacts(f)};}const scoreOf=(a,b,c)=>a[b]['breakdown']['find'](d=>d['rule_id']===c);describe('graph\x20service\x20evaluation\x20—\x20fully\x20hooked\x20shop\x20(TR-14.1)',()=>{it('scores\x20all\x20nine\x20dimensions\x20from\x20material\x20facts\x20with\x20no\x20default-low\x20deductions',async()=>{const {r:a}=await evalState(fullServiceState(),FULL['svc']);expect(a['unverified'])['toEqual']([]),expect(a['completeness'])['toBe'](0x64);const c=scoreOf(a,'trust','trust_arbitration');expect(c['score'])['toBe'](0x64),expect(c['matched'])['toEqual'](expect['arrayContaining'](['arbitrator\x20roster\x20configured','arbitration\x20fee\x20funded','arbitration\x20active'])),expect(c['reason'])['toContain']('Arbitration\x2020/20'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fulfillment')['score'])['toBe'](0x19);const d=scoreOf(a,'trust','trust_fund_safety');expect(d['score'])['toBe'](0x0),expect(d['mismatched'])['toContain']('compensation\x20fund\x20below\x20the\x20statutory\x203x\x20exposure\x20ceiling'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x64),expect(a['trust']['total'])['toBe'](0x31);const e=scoreOf(a,'risk','risk_fund');expect(e['score'])['toBeLessThan'](0x64),expect(e['mismatched'])['toContain']('Payout\x20exposure:\x20compensation\x20fund\x20is\x20below\x20the\x203x\x20ceiling\x20of\x20windowed\x20order\x20amounts'),expect(e['mismatched']?.['some'](h=>h['startsWith']('R2:')))['toBe'](![]),expect(e['finding_refs']?.['map'](h=>h['id']))['toContain']('R2:'+FULL['svc']['toLowerCase']());const f=scoreOf(a,'risk','risk_trust');expect(f['score'])['toBeLessThan'](0x64),expect(f['mismatched']?.['some'](h=>h['startsWith']('R1:')))['toBe'](![]),expect(f['mismatched']?.['length'])['toBeGreaterThan'](0x0),expect(f['finding_refs']?.['some'](h=>h['id']['startsWith']('R1:')))['toBe'](!![]);for(const h of[...a['trust']['breakdown'],...a['risk']['breakdown']]){for(const i of h['mismatched']??[])expect(i)['not']['toContain']('::node::');}expect(scoreOf(a,'risk','risk_workflow')['score'])['toBe'](0x64),expect(scoreOf(a,'risk','risk_behavior')['score'])['toBe'](0x64);for(const j of[...a['trust']['breakdown'],...a['risk']['breakdown']]){const k=(j['reason']??'')['toLowerCase']();expect(k)['not']['toContain']('no\x20data'),expect(k)['not']['toContain']('default\x20low');}const g=a['trust']['trace']['filter'](l=>l['kind']==='rule'&&l['detail']['startsWith']('score='));expect(g['map'](l=>l['id']))['toEqual'](expect['arrayContaining'](Object['keys'](GRAPH_RULE_INPUT_FACTS)['filter'](l=>l['startsWith']('trust_'))));}),it('keeps\x20the\x20injection\x20+\x20requirement\x20mechanisms\x20working',async()=>{const {projected:a}=await evalState(fullServiceState(),FULL['svc']),b=await evaluateGraphServiceFacts(a,{'overrides':{'rules':{'trust_arbitration':{'weight':0x28}}}});expect(b['trust']['total'])['toBe'](0x3a);const c=await evaluateGraphServiceFacts(a,{'requirements':[{'rule_id':'trust_fund_safety','condition':'require'}]});expect(c['trust']['blocked'])['toBe'](!![]),expect(c['trust']['red_flags']['length'])['toBeGreaterThan'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20configured-empty\x20shell\x20(TR-14.1)',()=>{it('scores\x20verified\x20absence\x20as\x20a\x20configured\x20fact\x20and\x20excludes\x20only\x20the\x20gap\x20dimension',async()=>{const {r:a}=await evalState(gapServiceState(),GAP['svc']),b=scoreOf(a,'trust','trust_arbitration');expect(b['score'])['toBe'](0x0),expect(b['reason'])['toContain']('verified\x20absence'),expect(scoreOf(a,'trust','trust_reviews')['score'])['toBe'](0x32),expect(a['unverified'])['toEqual'](['risk_workflow']),expect(scoreOf(a,'risk','risk_workflow'))['toBeUndefined'](),expect(a['risk']['unverified'])['toEqual'](['risk_workflow']),expect(a['trust']['unverified'])['toEqual'](['risk_workflow']);const c=a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']==='risk_workflow');expect(c?.['detail'])['toContain']('not\x20applicable'),expect(scoreOf(a,'trust','trust_transparency')['score'])['toBe'](0x28),expect(scoreOf(a,'trust','trust_fund_safety')['score'])['toBe'](0x0);});}),describe('graph\x20service\x20evaluation\x20—\x20truncated\x20order\x20window\x20(TR-14.1)',()=>{it('excludes\x20the\x20unverifiable\x20dimensions\x20and\x20renormalizes\x20the\x20weighted\x20total',async()=>{const {r:a}=await evalState(truncatedServiceState(),FULL['svc']);expect(a['unverified'])['toEqual'](expect['arrayContaining'](['trust_fulfillment','trust_fund_safety','risk_fund','risk_behavior'])),expect(scoreOf(a,'trust','trust_fulfillment'))['toBeUndefined'](),expect(scoreOf(a,'trust','trust_fund_safety'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_fund'))['toBeUndefined'](),expect(scoreOf(a,'risk','risk_behavior'))['toBeUndefined'](),expect(a['trust']['total'])['toBe'](0x44);for(const b of['trust_fulfillment','trust_fund_safety']){expect(a['trust']['trace']['find'](c=>c['kind']==='rule'&&c['id']===b)?.['detail'])['toContain']('not\x20applicable');}for(const c of['risk_fund','risk_behavior']){expect(a['risk']['trace']['find'](d=>d['kind']==='rule'&&d['id']===c)?.['detail'])['toContain']('not\x20applicable');}});}),describe('graph\x20service\x20evaluation\x20—\x20scoring\x20report\x20(TR-14.2)',()=>{it('renders\x20a\x20per-dimension\x20report\x20with\x20score,\x20weight,\x20state,\x20confidence\x20and\x20evidence',async()=>{const {projected:a,r:c}=await evalState(fullServiceState(),FULL['svc']),d=new Map(a['facts']['map'](g=>[g['key'],g])),e=[];for(const g of['trust','risk']){const h=c[g];e['push'](g['toUpperCase']()+'\x20'+h['total']+'/100\x20('+h['level']+')\x20—\x20'+h['summary']);for(const i of h['breakdown']){const j=GRAPH_RULE_INPUT_FACTS[i['rule_id']]??[],k=j['map'](o=>o+':state='+(d['get'](o)?.['state']??'missing')),l=j['map'](o=>d['get'](o)?.['provenance']['confidence']??'missing'),n=j['map'](o=>d['get'](o)?.['evidence']??'missing')['join']('\x20');e['push'](i['rule_id']+':\x20score='+i['score']+'\x20weight='+i['weight']+'\x20'+k['join'](',')+'\x20confidence='+[...new Set(l)]['join']('+')+'\x20evidence=\x22'+n+'\x22');}}expect(e)['toHaveLength'](0xb);const f=e['filter'](o=>o['includes']('score='));expect(f)['toHaveLength'](0x9);for(const o of f){expect(o)['toMatch'](/weight=\d+/),expect(o)['toContain']('state=present'),expect(o)['toMatch'](/confidence=(exact|bounded|windowed|derived)/);const p=o['match'](/evidence="(.*)"/);expect(p,o)['not']['toBeNull'](),expect(p[0x1]['length'],o)['toBeGreaterThan'](0x0);}expect(c['trust']['summary'])['toContain']('weakest\x20Fund\x20safety'),expect(c['trust']['summary'])['not']['toContain']('trust_fund_safety'),expect(c['trust']['summary'])['toMatch'](/grade: (strong|fair|weak)/),expect(c['trust']['summary'])['toContain']('Compensation\x20fund');});});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as
|
|
1
|
+
import{REQUIREMENT_PASS_THRESHOLD,effectiveWeight,isDataSourceEnabled,isRuleEnabled,normalizeInjection}from'./user-injection.js';import{levelFromScore as a41a}from'./standards.js';export function levelFromScore(a){return a41a(a);}function appliesTo(a,b){if(!a||a['length']===0x0)return!![];return a['includes'](b);}export class EvaluationEngine{static ['instance']=null;['dataSources']=new Map();['rules']=new Map();static['Instance'](){return!EvaluationEngine['instance']&&(EvaluationEngine['instance']=new EvaluationEngine()),EvaluationEngine['instance'];}['registerDataSource'](a){if(!a['id']||this['dataSources']['has'](a['id']))return![];return this['dataSources']['set'](a['id'],a),!![];}['unregisterDataSource'](a){return this['dataSources']['delete'](a);}['registerRule'](a){if(!a['id']||this['rules']['has'](a['id']))return![];return this['rules']['set'](a['id'],a),!![];}['unregisterRule'](a){return this['rules']['delete'](a);}['getRule'](a){return this['rules']['get'](a);}['listRules'](){return Array['from'](this['rules']['values']());}['getDataSource'](a){return this['dataSources']['get'](a);}['listDataSources'](){return Array['from'](this['dataSources']['values']());}async['evaluate'](a,b,c){const d=normalizeInjection(c),e={'evaluation_id':a,'entities':b,'facts':{},'injection':d,'now':Date['now']()},f=[],g=Array['from'](this['dataSources']['values']())['filter'](m=>appliesTo(m['evaluation_ids'],a))['sort']((m,n)=>(m['priority']??0x0)-(n['priority']??0x0));for(const m of g){if(!isDataSourceEnabled(m['id'],d)){f['push']({'kind':'override','id':m['id'],'detail':'data\x20source\x20disabled\x20by\x20user\x20override'});continue;}if(m['isEnabled']&&!m['isEnabled'](e))continue;const n=await m['extract'](e);Object['assign'](e['facts'],n),f['push']({'kind':'data_source','id':m['id'],'detail':'extracted\x20'+Object['keys'](n)['length']+'\x20fact(s)'});}const h=[],i=[];for(const o of this['rules']['values']()){if(!appliesTo(o['evaluation_ids'],a))continue;if(!isRuleEnabled(o['id'],d)){f['push']({'kind':'override','id':o['id'],'detail':'rule\x20disabled\x20by\x20user\x20override'});continue;}if(o['isEnabled']&&!o['isEnabled'](e))continue;const p=o['evaluate'](e);if(!p){f['push']({'kind':'rule','id':o['id'],'detail':'not\x20applicable\x20—\x20excluded\x20from\x20weighted\x20aggregation'});continue;}const q=effectiveWeight(o,d);h['push']({'rule_id':o['id'],'dimension':o['dimension'],'score':p['score'],'weight':q,'weight_source':q!==o['weight']?'override':'default','reason':p['reason'],'matched':p['matched'],'mismatched':p['mismatched'],'finding_refs':p['finding_refs'],'red_flag':p['red_flag']}),p['red_flag']&&i['push'](p['reason']??o['id']+'\x20triggered\x20a\x20hard\x20block'),f['push']({'kind':'rule','id':o['id'],'detail':'score='+p['score']+'\x20weight='+q});}const j=aggregateScore(h);let k=i['length']>0x0;for(const r of d['requirements']??[]){const s=h['find'](t=>t['rule_id']===r['rule_id']);if(r['condition']==='require')(!s||s['score']<REQUIREMENT_PASS_THRESHOLD||s['red_flag'])&&(k=!![],i['push'](r['note']??'Requirement\x20requires\x20rule\x20\x27'+r['rule_id']+'\x27\x20to\x20pass'));else r['condition']==='forbid'&&(s&&s['red_flag']&&(k=!![],i['push'](r['note']??'Requirement\x20forbids\x20rule\x20\x27'+r['rule_id']+'\x27\x20from\x20triggering')));}const l=e['facts']['summary']??buildSummary(a,j,h,i,k);return{'evaluation_id':a,'total':j,'level':levelFromScore(j),'breakdown':h,'red_flags':i,'blocked':k,'trace':f,'summary':l,'criterionScores':e['facts']['criterionScores'],'findings':e['facts']['findings'],'strengths':e['facts']['strengths'],'needsLlm':e['facts']['needsLlm'],'llmPrompt':e['facts']['llmPrompt']};}}function aggregateScore(a){if(a['length']===0x0)return 0x0;let c=0x0,d=0x0;for(const e of a){c+=e['score']*e['weight'],d+=e['weight'];}if(d<=0x0)return 0x0;return clamp(Math['round'](c/d),0x0,0x64);}function clamp(a,b,c){return Math['max'](b,Math['min'](c,a));}function buildSummary(a,b,c,d,e){const f=['Evaluation\x20\x27'+a+'\x27:\x20score\x20'+b+'/100'];return e?f['push']('BLOCKED\x20('+d['length']+'\x20red\x20flag(s))'):f['push'](c['length']+'\x20rule(s)\x20evaluated'),f['join']('\x20—\x20');}export function getEvaluationEngine(){return EvaluationEngine['Instance']();}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as
|
|
1
|
+
import{distillIntent,extractSignals}from'./intent-distill.js';import{getProfile,updateFromOperation}from'./user-profile.js';import{findMatches,recordSignature}from'./experience-reuse.js';import{EXPERIENCE_LAYER_VERSION}from'./types.js';import{isEnabled as a63a}from'../config/index.js';import{recordIndustrySignal}from'../knowledge/flywheel-loop.js';export{EXPERIENCE_LAYER_VERSION};export function getExperienceFeedback(a,b,c){try{const d=distillIntent(a,b,c),e=findMatches(d['primary_intent'],a,b,0x3);if(e['length']===0x0)return undefined;const f=e[0x0],g=getProfile();return formatFeedback(f,e,d['scenario'],g);}catch{return undefined;}}export function recordOperationOutcome(a,b,c,d,e,f=[]){try{const g=distillIntent(a,b,c),h=extractSignals(a,b);recordSignature({'intent':g['primary_intent'],'scenario':g['scenario'],'signals':h,'timestamp':Date['now'](),'outcome':d,'error_code':e}),updateFromOperation(g['primary_intent'],g['scenario'],d,e,f);try{if(a63a('industry_evolution')){const i=typeof b?.['industry']==='string'&&b['industry']['trim']()?b['industry']['trim']():undefined;if(i){const j=d==='success'?{'success':!![]}:{'success':![],'error_code':e};recordIndustrySignal(i,{'type':a,'data':b},j);}}}catch{}}catch{}}function formatFeedback(a,b,c,d){const e=buildAdviceText(a,b,d),f=collectAvoidList(b,d),g=a['relevance'],h=c??a['signature']['scenario'],i={};if(e)i['advice']=e;if(f['length']>0x0)i['avoid']=f;if(g>0x0)i['relevance']=Math['round'](g*0x64)/0x64;if(h)i['matched_scenario']=h;return i;}function buildAdviceText(a,b,c){const d=[];if(a['signature']['outcome']==='success')d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20succeeded');else a['signature']['outcome']==='failed'&&d['push']('Historically,\x20'+a['signature']['intent']+'\x20operation\x20failed\x20('+(a['signature']['error_code']??'unknown\x20error')+'),\x20pay\x20special\x20attention\x20to\x20parameters');return c['expertise_tier']==='novice'&&b['length']>0x0&&d['push']('It\x20is\x20recommended\x20to\x20carefully\x20check\x20parameters\x20before\x20executing'),d['join'](';\x20')||a['advice'];}function collectAvoidList(b,c){const d=new Set();for(const e of b){for(const f of e['avoid']){d['add'](f);}}for(const g of c['frequent_pitfalls']){d['add']('You\x20often\x20make\x20mistakes\x20at\x20the\x20'+g+'\x20step,\x20please\x20be\x20especially\x20careful');}return Array['from'](d)['slice'](0x0,0x5);}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const CORE_BUSINESS_MODULES=[{'id':'milestone_escrow','name':'Milestone\x20Escrow','description':'Funds\x20held\x20in\x20Order\x20and\x20released\x20per\x20milestone\x20completion.\x20Protects\x20both\x20merchant\x20and\x20user.','objectTypes':['service','machine','order','allocation'],'templateRefs':[{'template_id':'freelance-machine','object_type':'machine','purpose':'Milestone\x20workflow\x20with\x20accept/reject\x20nodes'},{'template_id':'milestone-allocation','object_type':'allocation','purpose':'Per-milestone\x20fund\x20release'}],'requiredConstraints':[{'constraint_id':'order_allocators_bound','description':'Order\x20must\x20have\x20allocators\x20bound\x20before\x20publish','level':'hard','blocking':!![]},{'constraint_id':'machine_published','description':'Machine\x20must\x20be\x20published\x20and\x20bound\x20to\x20Service','level':'hard','blocking':!![]},{'constraint_id':'milestone_forward_guarded','description':'Each\x20milestone\x20forward\x20must\x20have\x20a\x20guard','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'fund_safety','effect':'boost','description':'Escrow\x20ensures\x20funds\x20not\x20released\x20until\x20verification'},{'dimension':'escrow_quality','effect':'required','description':'Module\x20requires\x20proper\x20escrow\x20configuration'},{'dimension':'operational_risk','effect':'boost','description':'Milestones\x20reduce\x20single-point\x20delivery\x20risk'}],'industryFit':{'freelance':0x5f,'education':0x50,'rental':0x3c,'retail':0x28,'subscription':0x1e,'travel':0x32,'general':0x46},'addressesPainPoints':['Client\x20never\x20approves\x20deliverables','Merchant\x20delivers\x20but\x20cannot\x20get\x20paid','Full\x20upfront\x20payment\x20with\x20no\x20delivery\x20guarantee'],'userProtections':['Funds\x20held\x20in\x20escrow\x20until\x20milestone\x20verified','Can\x20reject\x20substandard\x20deliverables','Refund\x20for\x20unstarted\x20milestones'],'merchantObligations':['Must\x20deliver\x20each\x20milestone\x20to\x20defined\x20acceptance\x20criteria','Must\x20configure\x20Machine\x20with\x20proper\x20forward\x20guards'],'requiresKeeper':!![],'keeperHint':'Keeper\x20must\x20monitor\x20Machine\x20node\x20timeouts\x20and\x20trigger\x20adminUnhold\x20if\x20user\x20does\x20not\x20respond'},{'id':'independent_arbitration','name':'Independent\x20Arbitration','description':'Third-party\x20arbitration\x20with\x20Guard-weighted\x20voting.\x20Arbitration\x20Permission\x20MUST\x20differ\x20from\x20Service\x20Permission\x20(contract-enforced).','objectTypes':['arb','permission','guard'],'templateRefs':[{'template_id':'arbitration-3-voters','object_type':'arb','purpose':'3-voter\x20arbitration\x20with\x20weighted\x20voting'},{'template_id':'voting-guard-weighted','object_type':'guard','purpose':'Vote\x20weight\x20from\x20Guard\x20config'}],'requiredConstraints':[{'constraint_id':'arbitration_permission_independent','description':'Arbitration.permission\x20!=\x20Service.permission','level':'hard','blocking':!![]},{'constraint_id':'voting_guard_configured','description':'At\x20least\x20one\x20voting_guard\x20must\x20be\x20configured','level':'soft','blocking':![]},{'constraint_id':'arbitration_bound_to_service','description':'Arbitration\x20must\x20be\x20in\x20Service.arbitrations\x20list','level':'hard','blocking':!![]}],'evaluationImpact':[{'dimension':'arbitration_coverage','effect':'required','description':'Module\x20requires\x20arbitration\x20configuration'},{'dimension':'arbitration_fairness','effect':'required','description':'Independent\x20permission\x20ensures\x20neutrality'},{'dimension':'governance_risk','effect':'boost','description':'Reduces\x20platform-as-judge\x20risk'}],'industryFit':{'freelance':0x5a,'education':0x4b,'rental':0x55,'retail':0x4b,'subscription':0x3c,'travel':0x50,'general':0x46},'addressesPainPoints':['Platform\x20acts\x20as\x20both\x20judge\x20and\x20party','Arbitration\x20fees\x20too\x20high\x20for\x20small\x20claims','No\x20binding\x20dispute\x20resolution'],'userProtections':['Independent\x20arbitrators\x20(not\x20merchant\x20or\x20platform)','Guard-weighted\x20voting\x20prevents\x20Sybil\x20attacks','Micro-arbitration:\x20no\x20per-case\x20fees'],'merchantObligations':['Must\x20accept\x20arbitration\x20verdict','Must\x20maintain\x20compensation_fund\x20for\x20indemnities'],'requiresKeeper':![]},{'id':'wip_provenance','name':'WIP\x20Provenance','description':'Work-in-progress\x20hash\x20commitments\x20on-chain\x20via\x20Repository.\x20Prevents\x20tampering\x20of\x20delivery\x20evidence.','objectTypes':['repository','guard','proof'],'templateRefs':[{'template_id':'wip-hash-guard','object_type':'guard','purpose':'Verify\x20WIP\x20hash\x20matches\x20commitment'},{'template_id':'delivery-proof','object_type':'proof','purpose':'On-chain\x20delivery\x20confirmation'}],'requiredConstraints':[{'constraint_id':'repository_published','description':'Repository\x20must\x20be\x20published','level':'hard','blocking':!![]},{'constraint_id':'wip_hash_before_delivery','description':'WIP\x20hash\x20must\x20be\x20committed\x20before\x20delivery','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'proof_integrity','effect':'required','description':'WIP\x20hash\x20provides\x20tamper-proof\x20evidence'},{'dimension':'transparency','effect':'boost','description':'On-chain\x20commitment\x20is\x20publicly\x20verifiable'}],'industryFit':{'freelance':0x5a,'education':0x55,'rental':0x5f,'retail':0x46,'subscription':0x3c,'travel':0x46,'general':0x4b},'addressesPainPoints':['Evidence\x20stored\x20on\x20platform\x20servers\x20can\x20be\x20tampered','No\x20proof\x20of\x20pre-delivery\x20state\x20(e.g.\x20rental\x20condition)','Dispute\x20resolution\x20relies\x20on\x20trust\x20in\x20platform'],'userProtections':['WIP\x20hash\x20commitment\x20is\x20immutable\x20on-chain','Guard\x20automatically\x20verifies\x20hash\x20match','Repository\x20history\x20is\x20auditable'],'merchantObligations':['Must\x20commit\x20WIP\x20hash\x20at\x20defined\x20checkpoints','Must\x20use\x20Repository\x20for\x20evidence\x20storage'],'requiresKeeper':![]},{'id':'multi_tier_allocation','name':'Multi-Tier\x20Allocation','description':'Order\x20funds\x20automatically\x20split\x20among\x20multiple\x20recipients.\x20Fully\x20transparent\x20on-chain.','objectTypes':['allocation','treasury','payment'],'templateRefs':[{'template_id':'multi-tier-allocation','object_type':'allocation','purpose':'Waterfall\x20fund\x20distribution'},{'template_id':'supplier-waterfall','object_type':'allocation','purpose':'Supplier\x20payment\x20tiers'}],'requiredConstraints':[{'constraint_id':'allocators_configured','description':'Allocators\x20must\x20be\x20configured\x20with\x20recipients','level':'hard','blocking':!![]},{'constraint_id':'sharing_sum_100','description':'Allocation\x20percentages\x20must\x20sum\x20to\x20100%','level':'hard','blocking':!![]},{'constraint_id':'platform_fee_zero','description':'Platform\x20fee\x20should\x20be\x200\x20or\x20user-defined','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'fee_transparency','effect':'required','description':'All\x20allocations\x20visible\x20on-chain'},{'dimension':'supplier_visibility','effect':'boost','description':'Supplier\x20payments\x20are\x20auditable'}],'industryFit':{'freelance':0x3c,'education':0x32,'rental':0x28,'retail':0x50,'subscription':0x46,'travel':0x5f,'general':0x46},'addressesPainPoints':['Multi-layer\x20commission\x20hidden\x20from\x20users','Suppliers\x20paid\x20opaquely','Platform\x20takes\x20undisclosed\x20FX\x20spread'],'userProtections':['Full\x20allocation\x20waterfall\x20visible\x20on-chain','No\x20hidden\x20fees','Can\x20verify\x20supplier\x20payments'],'merchantObligations':['Must\x20declare\x20all\x20allocation\x20recipients\x20upfront','Cannot\x20change\x20allocation\x20after\x20publish'],'requiresKeeper':![]},{'id':'subscription_with_proof','name':'Subscription\x20with\x20Delivery\x20Proof','description':'Each\x20billing\x20cycle\x20requires\x20proof\x20of\x20content\x20delivery\x20before\x20charging.\x20Prevents\x20creator\x20abandonment.','objectTypes':['service','guard','repository','progress'],'templateRefs':[{'template_id':'subscription-machine','object_type':'machine','purpose':'Cycle-based\x20workflow'},{'template_id':'delivery-guard-cycle','object_type':'guard','purpose':'Verify\x20content\x20delivery\x20per\x20cycle'}],'requiredConstraints':[{'constraint_id':'delivery_guard_per_cycle','description':'Each\x20cycle\x20must\x20have\x20a\x20delivery\x20guard','level':'hard','blocking':!![]},{'constraint_id':'repository_updated','description':'Repository\x20must\x20be\x20updated\x20with\x20cycle\x20content\x20hash','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'content_commitment','effect':'required','description':'Delivery\x20proof\x20required\x20before\x20each\x20charge'},{'dimension':'timeout_protection','effect':'boost','description':'Cycles\x20enforce\x20regular\x20delivery'}],'industryFit':{'freelance':0x28,'education':0x55,'rental':0x1e,'retail':0x14,'subscription':0x62,'travel':0x1e,'general':0x32},'addressesPainPoints':['Creator\x20abandons\x20after\x20collecting\x20subscriptions','Silent\x20auto-renewal\x20with\x20no\x20delivery\x20proof','No\x20mechanism\x20to\x20hold\x20creators\x20accountable'],'userProtections':['Payment\x20only\x20after\x20delivery\x20proof\x20verified','Can\x20cancel\x20if\x20delivery\x20guard\x20fails','Cycle\x20history\x20on-chain'],'merchantObligations':['Must\x20deliver\x20content\x20and\x20commit\x20hash\x20each\x20cycle','Must\x20configure\x20delivery_guard\x20per\x20cycle'],'requiresKeeper':!![],'keeperHint':'Keeper\x20triggers\x20cycle\x20transitions\x20and\x20verifies\x20delivery_guard\x20conditions'},{'id':'accept_timeout_protection','name':'Accept\x20Timeout\x20Protection','description':'If\x20user\x20does\x20not\x20accept/reject\x20within\x20N\x20days,\x20auto-accept\x20advances\x20the\x20Machine.\x20Protects\x20merchant\x20from\x20indefinite\x20stalls.','objectTypes':['machine','guard'],'templateRefs':[{'template_id':'timeout-forward','object_type':'machine','purpose':'Forward\x20with\x20time_guard\x20+\x20adminUnhold\x20fallback'}],'requiredConstraints':[{'constraint_id':'time_guard_configured','description':'time_guard\x20must\x20be\x20set\x20on\x20accept\x20forward','level':'hard','blocking':!![]},{'constraint_id':'adminUnhold_permission','description':'Admin\x20must\x20have\x20PROGRESS_UNHOLD\x20(224)\x20permission','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'timeout_protection','effect':'required','description':'Auto-advance\x20prevents\x20indefinite\x20user\x20stalls'},{'dimension':'operational_risk','effect':'boost','description':'Reduces\x20delivery\x20timeline\x20uncertainty'}],'industryFit':{'freelance':0x5f,'education':0x46,'rental':0x50,'retail':0x3c,'subscription':0x28,'travel':0x3c,'general':0x4b},'addressesPainPoints':['Buyer\x20never\x20approves\x20deliverables\x20(common\x20on\x20incumbent\x20talent\x20marketplaces)','Merchant\x20cash\x20flow\x20blocked\x20by\x20inactive\x20buyer','Infinite\x20revision\x20loops\x20without\x20resolution'],'userProtections':['Still\x20has\x20full\x20N\x20days\x20to\x20review\x20and\x20reject','Rejection\x20triggers\x20arbitration\x20if\x20configured'],'merchantObligations':['Must\x20configure\x20time_guard\x20on\x20forward','Must\x20set\x20reasonable\x20timeout\x20(e.g.\x207\x20days)'],'requiresKeeper':!![],'keeperHint':'Keeper\x20monitors\x20time_guard\x20deadlines\x20and\x20triggers\x20adminUnhold\x20if\x20user\x20has\x20not\x20responded'},{'id':'refund_guarantee','name':'Refund\x20Guarantee','description':'Service\x20maintains\x20compensation_fund\x20for\x20refunds.\x20Refund_guard\x20validates\x20eligibility\x20and\x20transfers\x20funds\x20back\x20to\x20Order.','objectTypes':['service','guard','order'],'templateRefs':[{'template_id':'refund-guard','object_type':'guard','purpose':'Validate\x20refund\x20eligibility'}],'requiredConstraints':[{'constraint_id':'compensation_fund_positive','description':'compensation_fund_add\x20>\x200','level':'hard','blocking':!![]},{'constraint_id':'refund_guard_configured','description':'Service\x20must\x20have\x20refund_guard','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'fund_safety','effect':'boost','description':'Compensation\x20fund\x20backs\x20refund\x20promise'},{'dimension':'consumer_diligence','effect':'boost','description':'Shows\x20merchant\x20confidence\x20in\x20service\x20quality'}],'industryFit':{'freelance':0x46,'education':0x55,'rental':0x5a,'retail':0x5f,'subscription':0x50,'travel':0x55,'general':0x50},'addressesPainPoints':['Refund\x20trapped\x20in\x20incumbent\x20platform\x20balance','No\x20refund\x20mechanism\x20for\x20service\x20failure','Refund\x20decision\x20centralized\x20at\x20platform'],'userProtections':['Refund\x20goes\x20back\x20to\x20Order\x20(not\x20platform\x20balance)','Guard\x20validates\x20eligibility\x20(not\x20platform\x20discretion)','Compensation\x20fund\x20guarantees\x20liquidity'],'merchantObligations':['Must\x20maintain\x20compensation_fund\x20>\x200','Must\x20configure\x20refund_guard\x20rules'],'requiresKeeper':![]},{'id':'reputation_on_chain','name':'On-Chain\x20Reputation','description':'Merchant\x20and\x20user\x20behavior\x20permanently\x20recorded\x20on\x20Registrar.\x20Evaluations,\x20completions,\x20and\x20disputes\x20contribute\x20to\x20reputation\x20score.','objectTypes':['service','order','arb'],'templateRefs':[],'requiredConstraints':[{'constraint_id':'service_published','description':'Service\x20must\x20be\x20published\x20to\x20accumulate\x20reputation','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'reputation_verifiability','effect':'required','description':'On-chain\x20history\x20is\x20tamper-proof'},{'dimension':'trust','effect':'boost','description':'Reputation\x20signals\x20reduce\x20information\x20asymmetry'}],'industryFit':{'freelance':0x5a,'education':0x50,'rental':0x55,'retail':0x5a,'subscription':0x55,'travel':0x50,'general':0x55},'addressesPainPoints':['Fake\x20reviews\x20and\x20rating\x20manipulation','No\x20cross-platform\x20reputation\x20portability','Platform\x20can\x20delete\x20negative\x20reviews'],'userProtections':['Reputation\x20is\x20on-chain\x20and\x20immutable','Can\x20verify\x20merchant\x27s\x20complete\x20transaction\x20history','Dispute\x20outcomes\x20affect\x20reputation\x20permanently'],'merchantObligations':['All\x20service\x20interactions\x20become\x20part\x20of\x20permanent\x20record','Cannot\x20hide\x20negative\x20outcomes'],'requiresKeeper':![]},{'id':'supplier_collaboration','name':'Supplier\x20Collaboration','description':'Enable\x20merchant\x20to\x20delegate\x20sub-services\x20to\x20suppliers\x20with\x20transparent\x20payment\x20splitting.\x20No\x20platform\x20intermediary.','objectTypes':['service','allocation','demand'],'templateRefs':[{'template_id':'supplier-demand','object_type':'demand','purpose':'Create\x20sub-service\x20demand\x20for\x20suppliers'},{'template_id':'supplier-allocation','object_type':'allocation','purpose':'Split\x20order\x20payment\x20with\x20suppliers'}],'requiredConstraints':[{'constraint_id':'demand_configured','description':'Demand\x20must\x20reference\x20main\x20Service','level':'soft','blocking':![]},{'constraint_id':'allocation_sharing_configured','description':'Allocation\x20sharing\x20must\x20include\x20suppliers','level':'hard','blocking':!![]}],'evaluationImpact':[{'dimension':'supplier_visibility','effect':'required','description':'Supplier\x20payments\x20transparent\x20on-chain'},{'dimension':'governance_risk','effect':'boost','description':'No\x20platform\x20controls\x20supplier\x20relationships'}],'industryFit':{'freelance':0x3c,'education':0x46,'rental':0x28,'retail':0x55,'subscription':0x32,'travel':0x5a,'general':0x3c},'addressesPainPoints':['Supplier\x20payments\x20opaque\x20to\x20end\x20user','Platform\x20controls\x20supplier\x20relationships','No\x20direct\x20merchant-supplier\x20collaboration'],'userProtections':['Can\x20see\x20all\x20suppliers\x20involved\x20in\x20service','Supplier\x20payments\x20are\x20on-chain\x20auditable','Merchant\x20remains\x20accountable\x20for\x20supplier\x20quality'],'merchantObligations':['Must\x20declare\x20all\x20suppliers\x20upfront','Must\x20ensure\x20supplier\x20deliverables\x20meet\x20criteria'],'requiresKeeper':![]},{'id':'damage_attestation','name':'Damage\x20Attestation','description':'Rental-specific:\x20pre/post\x20condition\x20photos\x20hashed\x20to\x20Repository.\x20Guard\x20compares\x20hashes\x20to\x20automatically\x20enforce\x20damage\x20deductions.','objectTypes':['repository','guard','service'],'templateRefs':[{'template_id':'rental-condition-guard','object_type':'guard','purpose':'Compare\x20pre/post\x20rental\x20condition\x20hashes'},{'template_id':'condition-repository','object_type':'repository','purpose':'Store\x20rental\x20condition\x20evidence'}],'requiredConstraints':[{'constraint_id':'pre_rental_hash','description':'Pre-rental\x20condition\x20hash\x20must\x20be\x20committed','level':'hard','blocking':!![]},{'constraint_id':'post_rental_hash','description':'Post-rental\x20condition\x20hash\x20must\x20be\x20committed','level':'hard','blocking':!![]}],'evaluationImpact':[{'dimension':'proof_integrity','effect':'required','description':'Condition\x20hashes\x20prevent\x20tampering'},{'dimension':'arbitration_fairness','effect':'boost','description':'Objective\x20evidence\x20reduces\x20dispute\x20bias'}],'industryFit':{'freelance':0x14,'education':0x1e,'rental':0x62,'retail':0x28,'subscription':0x14,'travel':0x3c,'general':0x28},'addressesPainPoints':['Landlord\x20claims\x20damage\x20without\x20proof\x20(common\x20on\x20incumbent\x20short-stay\x20platforms)','No\x20mandatory\x20pre-rental\x20photo\x20(vehicle-rental\x20damage\x20claims\x20denied)','Platform\x20arbitrates\x20damage\x20disputes\x20opaquely'],'userProtections':['Pre-rental\x20hash\x20commits\x20baseline\x20condition','Guard\x20automatically\x20compares\x20post-rental\x20state','Cannot\x20be\x20charged\x20for\x20pre-existing\x20damage'],'merchantObligations':['Must\x20commit\x20pre-rental\x20condition\x20hash','Must\x20commit\x20post-rental\x20condition\x20hash','Must\x20use\x20Repository\x20for\x20evidence\x20storage'],'requiresKeeper':!![],'keeperHint':'Keeper\x20triggers\x20post-rental\x20hash\x20collection\x20and\x20initiates\x20damage\x20Guard\x20comparison'}];export function getBusinessModule(a){return CORE_BUSINESS_MODULES['find'](b=>b['id']===a);}export function getModulesForIndustry(a){return[...CORE_BUSINESS_MODULES]['sort']((c,d)=>(d['industryFit'][a]??0x0)-(c['industryFit'][a]??0x0));}export function recommendModules(a,b,c){const d=c?.['minFit']??0x32,e=c?.['maxModules']??0x5,f=CORE_BUSINESS_MODULES['map'](g=>{let h=g['industryFit'][a]??0x32;const i=b['toLowerCase']();for(const j of g['addressesPainPoints']){const k=j['toLowerCase']()['split'](/\s+/),l=k['filter'](n=>i['includes'](n))['length'];h+=l*0x5;}return{'module':g,'score':Math['min'](h,0x64)};});return f['filter'](g=>g['score']>=d)['sort']((g,h)=>h['score']-g['score'])['slice'](0x0,e)['map'](g=>g['module']);}export function checkModuleConstraints(a,b){const c=a['requiredConstraints']['filter'](f=>f['blocking']&&!b['has'](f['constraint_id']))['map'](f=>f['constraint_id']),d=c['length']===0x0,e=a['evaluationImpact']['filter'](f=>f['effect']==='boost'||f['effect']==='required')['reduce']((f,g)=>f+(g['effect']==='required'?0xf:0x8),0x0);return{'module':a['id'],'adopted':d,'reason':d?undefined:'Missing\x20required\x20constraints:\x20'+c['join'](',\x20'),'missingConstraints':c['length']>0x0?c:undefined,'estimatedScoreBoost':Math['min'](e,0x64)};}export function calculateModuleScoreBoost(a){const b={};for(const c of a){for(const d of c['evaluationImpact']){const e=d['effect']==='required'?0xf:d['effect']==='boost'?0x8:0x3;b[d['dimension']]=(b[d['dimension']]??0x0)+e;}}return b;}
|
|
1
|
+
export const CORE_BUSINESS_MODULES=[{'id':'milestone_escrow','name':'Milestone\x20Escrow','description':'Funds\x20held\x20in\x20Order\x20and\x20released\x20per\x20milestone\x20completion.\x20Protects\x20both\x20merchant\x20and\x20user.','objectTypes':['service','machine','order','allocation'],'templateRefs':[{'template_id':'freelance-machine','object_type':'machine','purpose':'Milestone\x20workflow\x20with\x20accept/reject\x20nodes'},{'template_id':'milestone-allocation','object_type':'allocation','purpose':'Per-milestone\x20fund\x20release'}],'requiredConstraints':[{'constraint_id':'order_allocators_bound','description':'Order\x20must\x20have\x20allocators\x20bound\x20before\x20publish','level':'hard','blocking':!![]},{'constraint_id':'machine_published','description':'Machine\x20must\x20be\x20published\x20and\x20bound\x20to\x20Service','level':'hard','blocking':!![]},{'constraint_id':'milestone_forward_guarded','description':'Each\x20milestone\x20forward\x20must\x20have\x20a\x20guard','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'fund_safety','effect':'boost','description':'Escrow\x20ensures\x20funds\x20not\x20released\x20until\x20verification'},{'dimension':'escrow_quality','effect':'required','description':'Module\x20requires\x20proper\x20escrow\x20configuration'},{'dimension':'operational_risk','effect':'boost','description':'Milestones\x20reduce\x20single-point\x20delivery\x20risk'}],'industryFit':{'freelance':0x5f,'education':0x50,'rental':0x3c,'retail':0x28,'subscription':0x1e,'travel':0x32,'general':0x46},'addressesPainPoints':['Client\x20never\x20approves\x20deliverables','Merchant\x20delivers\x20but\x20cannot\x20get\x20paid','Full\x20upfront\x20payment\x20with\x20no\x20delivery\x20guarantee'],'userProtections':['Funds\x20held\x20in\x20escrow\x20until\x20milestone\x20verified','Can\x20reject\x20substandard\x20deliverables','Refund\x20for\x20unstarted\x20milestones'],'merchantObligations':['Must\x20deliver\x20each\x20milestone\x20to\x20defined\x20acceptance\x20criteria','Must\x20configure\x20Machine\x20with\x20proper\x20forward\x20guards'],'requiresKeeper':!![],'keeperHint':'Keeper\x20must\x20monitor\x20Machine\x20node\x20timeouts\x20and\x20trigger\x20adminUnhold\x20if\x20user\x20does\x20not\x20respond'},{'id':'independent_arbitration','name':'Independent\x20Arbitration','description':'Third-party\x20arbitration\x20with\x20Guard-weighted\x20voting.\x20Arbitration\x20Permission\x20MUST\x20differ\x20from\x20Service\x20Permission\x20(contract-enforced).','objectTypes':['arb','permission','guard'],'templateRefs':[{'template_id':'arbitration-3-voters','object_type':'arb','purpose':'3-voter\x20arbitration\x20with\x20weighted\x20voting'},{'template_id':'voting-guard-weighted','object_type':'guard','purpose':'Vote\x20weight\x20from\x20Guard\x20config'}],'requiredConstraints':[{'constraint_id':'arbitration_permission_independent','description':'Arbitration.permission\x20!=\x20Service.permission','level':'hard','blocking':!![]},{'constraint_id':'voting_guard_configured','description':'At\x20least\x20one\x20voting_guard\x20must\x20be\x20configured','level':'soft','blocking':![]},{'constraint_id':'arbitration_bound_to_service','description':'Arbitration\x20must\x20be\x20in\x20Service.arbitrations\x20list','level':'hard','blocking':!![]}],'evaluationImpact':[{'dimension':'arbitration_coverage','effect':'required','description':'Module\x20requires\x20arbitration\x20configuration'},{'dimension':'arbitration_fairness','effect':'required','description':'Independent\x20permission\x20ensures\x20neutrality'},{'dimension':'governance_risk','effect':'boost','description':'Reduces\x20platform-as-judge\x20risk'}],'industryFit':{'freelance':0x5a,'education':0x4b,'rental':0x55,'retail':0x4b,'subscription':0x3c,'travel':0x50,'general':0x46},'addressesPainPoints':['Platform\x20acts\x20as\x20both\x20judge\x20and\x20party','Arbitration\x20fees\x20too\x20high\x20for\x20small\x20claims','No\x20binding\x20dispute\x20resolution'],'userProtections':['Independent\x20arbitrators\x20(not\x20merchant\x20or\x20platform)','Guard-weighted\x20voting\x20prevents\x20Sybil\x20attacks','Micro-arbitration:\x20no\x20per-case\x20fees'],'merchantObligations':['Must\x20accept\x20arbitration\x20verdict','Must\x20maintain\x20compensation_fund\x20for\x20indemnities'],'requiresKeeper':![]},{'id':'wip_provenance','name':'WIP\x20Provenance','description':'Work-in-progress\x20hash\x20commitments\x20on-chain\x20via\x20Repository.\x20Prevents\x20tampering\x20of\x20delivery\x20evidence.','objectTypes':['repository','guard','proof'],'templateRefs':[{'template_id':'wip-hash-guard','object_type':'guard','purpose':'Verify\x20WIP\x20hash\x20matches\x20commitment'},{'template_id':'delivery-proof','object_type':'proof','purpose':'On-chain\x20delivery\x20confirmation'}],'requiredConstraints':[{'constraint_id':'repository_published','description':'Repository\x20must\x20be\x20published','level':'hard','blocking':!![]},{'constraint_id':'wip_hash_before_delivery','description':'WIP\x20hash\x20must\x20be\x20committed\x20before\x20delivery','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'proof_integrity','effect':'required','description':'WIP\x20hash\x20provides\x20tamper-proof\x20evidence'},{'dimension':'transparency','effect':'boost','description':'On-chain\x20commitment\x20is\x20publicly\x20verifiable'}],'industryFit':{'freelance':0x5a,'education':0x55,'rental':0x5f,'retail':0x46,'subscription':0x3c,'travel':0x46,'general':0x4b},'addressesPainPoints':['Evidence\x20stored\x20on\x20platform\x20servers\x20can\x20be\x20tampered','No\x20proof\x20of\x20pre-delivery\x20state\x20(e.g.\x20rental\x20condition)','Dispute\x20resolution\x20relies\x20on\x20trust\x20in\x20platform'],'userProtections':['WIP\x20hash\x20commitment\x20is\x20immutable\x20on-chain','Guard\x20automatically\x20verifies\x20hash\x20match','Repository\x20history\x20is\x20auditable'],'merchantObligations':['Must\x20commit\x20WIP\x20hash\x20at\x20defined\x20checkpoints','Must\x20use\x20Repository\x20for\x20evidence\x20storage'],'requiresKeeper':![]},{'id':'multi_tier_allocation','name':'Multi-Tier\x20Allocation','description':'Order\x20funds\x20automatically\x20split\x20among\x20multiple\x20recipients.\x20Fully\x20transparent\x20on-chain.','objectTypes':['allocation','treasury','payment'],'templateRefs':[{'template_id':'multi-tier-allocation','object_type':'allocation','purpose':'Waterfall\x20fund\x20distribution'},{'template_id':'supplier-waterfall','object_type':'allocation','purpose':'Supplier\x20payment\x20tiers'}],'requiredConstraints':[{'constraint_id':'allocators_configured','description':'Allocators\x20must\x20be\x20configured\x20with\x20recipients','level':'hard','blocking':!![]},{'constraint_id':'sharing_sum_100','description':'Allocation\x20percentages\x20must\x20sum\x20to\x20100%','level':'hard','blocking':!![]},{'constraint_id':'platform_fee_zero','description':'Platform\x20fee\x20should\x20be\x200\x20or\x20user-defined','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'fee_transparency','effect':'required','description':'All\x20allocations\x20visible\x20on-chain'},{'dimension':'supplier_visibility','effect':'boost','description':'Supplier\x20payments\x20are\x20auditable'}],'industryFit':{'freelance':0x3c,'education':0x32,'rental':0x28,'retail':0x50,'subscription':0x46,'travel':0x5f,'general':0x46},'addressesPainPoints':['Multi-layer\x20commission\x20hidden\x20from\x20users','Suppliers\x20paid\x20opaquely','Platform\x20takes\x20undisclosed\x20FX\x20spread'],'userProtections':['Full\x20allocation\x20waterfall\x20visible\x20on-chain','No\x20hidden\x20fees','Can\x20verify\x20supplier\x20payments'],'merchantObligations':['Must\x20declare\x20all\x20allocation\x20recipients\x20upfront','Cannot\x20change\x20allocation\x20after\x20publish'],'requiresKeeper':![]},{'id':'subscription_with_proof','name':'Subscription\x20with\x20Delivery\x20Proof','description':'Each\x20billing\x20cycle\x20requires\x20proof\x20of\x20content\x20delivery\x20before\x20charging.\x20Prevents\x20creator\x20abandonment.','objectTypes':['service','guard','repository','progress'],'templateRefs':[{'template_id':'subscription-machine','object_type':'machine','purpose':'Cycle-based\x20workflow'},{'template_id':'delivery-guard-cycle','object_type':'guard','purpose':'Verify\x20content\x20delivery\x20per\x20cycle'}],'requiredConstraints':[{'constraint_id':'delivery_guard_per_cycle','description':'Each\x20cycle\x20must\x20have\x20a\x20delivery\x20guard','level':'hard','blocking':!![]},{'constraint_id':'repository_updated','description':'Repository\x20must\x20be\x20updated\x20with\x20cycle\x20content\x20hash','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'content_commitment','effect':'required','description':'Delivery\x20proof\x20required\x20before\x20each\x20charge'},{'dimension':'timeout_protection','effect':'boost','description':'Cycles\x20enforce\x20regular\x20delivery'}],'industryFit':{'freelance':0x28,'education':0x55,'rental':0x1e,'retail':0x14,'subscription':0x62,'travel':0x1e,'general':0x32},'addressesPainPoints':['Creator\x20abandons\x20after\x20collecting\x20subscriptions','Silent\x20auto-renewal\x20with\x20no\x20delivery\x20proof','No\x20mechanism\x20to\x20hold\x20creators\x20accountable'],'userProtections':['Payment\x20only\x20after\x20delivery\x20proof\x20verified','Can\x20cancel\x20if\x20delivery\x20guard\x20fails','Cycle\x20history\x20on-chain'],'merchantObligations':['Must\x20deliver\x20content\x20and\x20commit\x20hash\x20each\x20cycle','Must\x20configure\x20delivery_guard\x20per\x20cycle'],'requiresKeeper':!![],'keeperHint':'Keeper\x20triggers\x20cycle\x20transitions\x20and\x20verifies\x20delivery_guard\x20conditions'},{'id':'accept_timeout_protection','name':'Accept\x20Timeout\x20Protection','description':'If\x20user\x20does\x20not\x20accept/reject\x20within\x20N\x20days,\x20auto-accept\x20advances\x20the\x20Machine.\x20Protects\x20merchant\x20from\x20indefinite\x20stalls.','objectTypes':['machine','guard'],'templateRefs':[{'template_id':'timeout-forward','object_type':'machine','purpose':'Forward\x20with\x20time_guard\x20+\x20adminUnhold\x20fallback'}],'requiredConstraints':[{'constraint_id':'time_guard_configured','description':'time_guard\x20must\x20be\x20set\x20on\x20accept\x20forward','level':'hard','blocking':!![]},{'constraint_id':'adminUnhold_permission','description':'Admin\x20must\x20have\x20PROGRESS_UNHOLD\x20(224)\x20permission','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'timeout_protection','effect':'required','description':'Auto-advance\x20prevents\x20indefinite\x20user\x20stalls'},{'dimension':'operational_risk','effect':'boost','description':'Reduces\x20delivery\x20timeline\x20uncertainty'}],'industryFit':{'freelance':0x5f,'education':0x46,'rental':0x50,'retail':0x3c,'subscription':0x28,'travel':0x3c,'general':0x4b},'addressesPainPoints':['Buyer\x20never\x20approves\x20deliverables\x20(common\x20on\x20incumbent\x20talent\x20marketplaces)','Merchant\x20cash\x20flow\x20blocked\x20by\x20inactive\x20buyer','Infinite\x20revision\x20loops\x20without\x20resolution'],'userProtections':['Still\x20has\x20full\x20N\x20days\x20to\x20review\x20and\x20reject','Rejection\x20triggers\x20arbitration\x20if\x20configured'],'merchantObligations':['Must\x20configure\x20time_guard\x20on\x20forward','Timeout\x20value\x20comes\x20from\x20the\x20template\x27s\x20window\x20fee_params\x20(e.g.\x20escrow_release_days;\x20override\x20per\x20build\x20via\x20fee_overrides)\x20—\x20never\x20a\x20hardcoded\x20number'],'requiresKeeper':!![],'keeperHint':'Keeper\x20monitors\x20time_guard\x20deadlines\x20and\x20advances\x20the\x20timeout\x20forward\x20when\x20the\x20window\x20elapses\x20(adminUnhold\x20is\x20only\x20the\x20hold-release\x20escape\x20hatch,\x20never\x20the\x20timeout\x20path)'},{'id':'refund_guarantee','name':'Refund\x20Guarantee','description':'Service\x20maintains\x20compensation_fund\x20for\x20refunds.\x20Refund_guard\x20validates\x20eligibility\x20and\x20transfers\x20funds\x20back\x20to\x20Order.','objectTypes':['service','guard','order'],'templateRefs':[{'template_id':'refund-guard','object_type':'guard','purpose':'Validate\x20refund\x20eligibility'}],'requiredConstraints':[{'constraint_id':'compensation_fund_positive','description':'compensation_fund_add\x20>\x200','level':'hard','blocking':!![]},{'constraint_id':'refund_guard_configured','description':'Service\x20must\x20have\x20refund_guard','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'fund_safety','effect':'boost','description':'Compensation\x20fund\x20backs\x20refund\x20promise'},{'dimension':'consumer_diligence','effect':'boost','description':'Shows\x20merchant\x20confidence\x20in\x20service\x20quality'}],'industryFit':{'freelance':0x46,'education':0x55,'rental':0x5a,'retail':0x5f,'subscription':0x50,'travel':0x55,'general':0x50},'addressesPainPoints':['Refund\x20trapped\x20in\x20incumbent\x20platform\x20balance','No\x20refund\x20mechanism\x20for\x20service\x20failure','Refund\x20decision\x20centralized\x20at\x20platform'],'userProtections':['Refund\x20goes\x20back\x20to\x20Order\x20(not\x20platform\x20balance)','Guard\x20validates\x20eligibility\x20(not\x20platform\x20discretion)','Compensation\x20fund\x20guarantees\x20liquidity'],'merchantObligations':['Must\x20maintain\x20compensation_fund\x20>\x200','Must\x20configure\x20refund_guard\x20rules'],'requiresKeeper':![]},{'id':'reputation_on_chain','name':'On-Chain\x20Reputation','description':'Merchant\x20and\x20user\x20behavior\x20permanently\x20recorded\x20on\x20Registrar.\x20Evaluations,\x20completions,\x20and\x20disputes\x20contribute\x20to\x20reputation\x20score.','objectTypes':['service','order','arb'],'templateRefs':[],'requiredConstraints':[{'constraint_id':'service_published','description':'Service\x20must\x20be\x20published\x20to\x20accumulate\x20reputation','level':'soft','blocking':![]}],'evaluationImpact':[{'dimension':'reputation_verifiability','effect':'required','description':'On-chain\x20history\x20is\x20tamper-proof'},{'dimension':'trust','effect':'boost','description':'Reputation\x20signals\x20reduce\x20information\x20asymmetry'}],'industryFit':{'freelance':0x5a,'education':0x50,'rental':0x55,'retail':0x5a,'subscription':0x55,'travel':0x50,'general':0x55},'addressesPainPoints':['Fake\x20reviews\x20and\x20rating\x20manipulation','No\x20cross-platform\x20reputation\x20portability','Platform\x20can\x20delete\x20negative\x20reviews'],'userProtections':['Reputation\x20is\x20on-chain\x20and\x20immutable','Can\x20verify\x20merchant\x27s\x20complete\x20transaction\x20history','Dispute\x20outcomes\x20affect\x20reputation\x20permanently'],'merchantObligations':['All\x20service\x20interactions\x20become\x20part\x20of\x20permanent\x20record','Cannot\x20hide\x20negative\x20outcomes'],'requiresKeeper':![]},{'id':'supplier_collaboration','name':'Supplier\x20Collaboration','description':'Enable\x20merchant\x20to\x20delegate\x20sub-services\x20to\x20suppliers\x20with\x20transparent\x20payment\x20splitting.\x20No\x20platform\x20intermediary.','objectTypes':['service','allocation','demand'],'templateRefs':[{'template_id':'supplier-demand','object_type':'demand','purpose':'Create\x20sub-service\x20demand\x20for\x20suppliers'},{'template_id':'supplier-allocation','object_type':'allocation','purpose':'Split\x20order\x20payment\x20with\x20suppliers'}],'requiredConstraints':[{'constraint_id':'demand_configured','description':'Demand\x20must\x20reference\x20main\x20Service','level':'soft','blocking':![]},{'constraint_id':'allocation_sharing_configured','description':'Allocation\x20sharing\x20must\x20include\x20suppliers','level':'hard','blocking':!![]}],'evaluationImpact':[{'dimension':'supplier_visibility','effect':'required','description':'Supplier\x20payments\x20transparent\x20on-chain'},{'dimension':'governance_risk','effect':'boost','description':'No\x20platform\x20controls\x20supplier\x20relationships'}],'industryFit':{'freelance':0x3c,'education':0x46,'rental':0x28,'retail':0x55,'subscription':0x32,'travel':0x5a,'general':0x3c},'addressesPainPoints':['Supplier\x20payments\x20opaque\x20to\x20end\x20user','Platform\x20controls\x20supplier\x20relationships','No\x20direct\x20merchant-supplier\x20collaboration'],'userProtections':['Can\x20see\x20all\x20suppliers\x20involved\x20in\x20service','Supplier\x20payments\x20are\x20on-chain\x20auditable','Merchant\x20remains\x20accountable\x20for\x20supplier\x20quality'],'merchantObligations':['Must\x20declare\x20all\x20suppliers\x20upfront','Must\x20ensure\x20supplier\x20deliverables\x20meet\x20criteria'],'requiresKeeper':![]},{'id':'damage_attestation','name':'Damage\x20Attestation','description':'Rental-specific:\x20pre/post\x20condition\x20photos\x20hashed\x20to\x20Repository.\x20Guard\x20compares\x20hashes\x20to\x20automatically\x20enforce\x20damage\x20deductions.','objectTypes':['repository','guard','service'],'templateRefs':[{'template_id':'rental-condition-guard','object_type':'guard','purpose':'Compare\x20pre/post\x20rental\x20condition\x20hashes'},{'template_id':'condition-repository','object_type':'repository','purpose':'Store\x20rental\x20condition\x20evidence'}],'requiredConstraints':[{'constraint_id':'pre_rental_hash','description':'Pre-rental\x20condition\x20hash\x20must\x20be\x20committed','level':'hard','blocking':!![]},{'constraint_id':'post_rental_hash','description':'Post-rental\x20condition\x20hash\x20must\x20be\x20committed','level':'hard','blocking':!![]}],'evaluationImpact':[{'dimension':'proof_integrity','effect':'required','description':'Condition\x20hashes\x20prevent\x20tampering'},{'dimension':'arbitration_fairness','effect':'boost','description':'Objective\x20evidence\x20reduces\x20dispute\x20bias'}],'industryFit':{'freelance':0x14,'education':0x1e,'rental':0x62,'retail':0x28,'subscription':0x14,'travel':0x3c,'general':0x28},'addressesPainPoints':['Landlord\x20claims\x20damage\x20without\x20proof\x20(common\x20on\x20incumbent\x20short-stay\x20platforms)','No\x20mandatory\x20pre-rental\x20photo\x20(vehicle-rental\x20damage\x20claims\x20denied)','Platform\x20arbitrates\x20damage\x20disputes\x20opaquely'],'userProtections':['Pre-rental\x20hash\x20commits\x20baseline\x20condition','Guard\x20automatically\x20compares\x20post-rental\x20state','Cannot\x20be\x20charged\x20for\x20pre-existing\x20damage'],'merchantObligations':['Must\x20commit\x20pre-rental\x20condition\x20hash','Must\x20commit\x20post-rental\x20condition\x20hash','Must\x20use\x20Repository\x20for\x20evidence\x20storage'],'requiresKeeper':!![],'keeperHint':'Keeper\x20triggers\x20post-rental\x20hash\x20collection\x20and\x20initiates\x20damage\x20Guard\x20comparison'}];export function getBusinessModule(a){return CORE_BUSINESS_MODULES['find'](b=>b['id']===a);}export function getModulesForIndustry(a){return[...CORE_BUSINESS_MODULES]['sort']((c,d)=>(d['industryFit'][a]??0x0)-(c['industryFit'][a]??0x0));}export function recommendModules(a,b,c){const d=c?.['minFit']??0x32,e=c?.['maxModules']??0x5,f=CORE_BUSINESS_MODULES['map'](g=>{let h=g['industryFit'][a]??0x32;const i=b['toLowerCase']();for(const j of g['addressesPainPoints']){const k=j['toLowerCase']()['split'](/\s+/),l=k['filter'](n=>i['includes'](n))['length'];h+=l*0x5;}return{'module':g,'score':Math['min'](h,0x64)};});return f['filter'](g=>g['score']>=d)['sort']((g,h)=>h['score']-g['score'])['slice'](0x0,e)['map'](g=>g['module']);}export function checkModuleConstraints(a,b){const c=a['requiredConstraints']['filter'](f=>f['blocking']&&!b['has'](f['constraint_id']))['map'](f=>f['constraint_id']),d=c['length']===0x0,e=a['evaluationImpact']['filter'](f=>f['effect']==='boost'||f['effect']==='required')['reduce']((f,g)=>f+(g['effect']==='required'?0xf:0x8),0x0);return{'module':a['id'],'adopted':d,'reason':d?undefined:'Missing\x20required\x20constraints:\x20'+c['join'](',\x20'),'missingConstraints':c['length']>0x0?c:undefined,'estimatedScoreBoost':Math['min'](e,0x64)};}export function calculateModuleScoreBoost(a){const b={};for(const c of a){for(const d of c['evaluationImpact']){const e=d['effect']==='required'?0xf:d['effect']==='boost'?0x8:0x3;b[d['dimension']]=(b[d['dimension']]??0x0)+e;}}return b;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{seedBuiltinTemplates}from'../knowledge/template-loader.js';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{STRATEGY_MANUAL_FILENAME,renderStrategyManual,classifyManualFile}from'../knowledge/strategy-manuals.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryBaselines}from'./industry-layers.js';import{validateJudgmentFragment}from'../config/judgment.js';import{getIndustryProfile,registerIndustry}from'../knowledge/industry-registry.js';import{composeIndustries,DEFAULT_TRAITS,inferTraitsFromDescription,synthesizeProfile}from'../knowledge/industry-generalizer.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||typeof a?.['refund_window']?.['days']==='number'&&a['refund_window']['days']>0x0;}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulBaselines(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&Object['keys'](a)['length']>0x0;}const PLAYBOOK_PLACEHOLDER_RE=/\((?:Example|Add|Write)\b/,PLAYBOOK_SEEDED_BLOCK_HEADINGS=['##\x20Business\x20model\x20—\x20direct\x20sales'];function stripSeededPlaybookBlocks(a){const b=[];let c=![];for(const d of a['split'](/\r?\n/)){const e=d['trim'](),f=e['startsWith']('#');if(f){c=PLAYBOOK_SEEDED_BLOCK_HEADINGS['some'](g=>e===g||e===g['replace'](/^#+\s*/,'#')||normalizeHeading(e)===normalizeHeading(g));if(c)continue;}if(c)continue;b['push'](d);}return b;}function normalizeHeading(a){return a['replace'](/^#+\s*/,'')['trim']()['toLowerCase']()['replace'](/\s+/g,'\x20');}function isMeaningfulPlaybook(a){if(!a)return![];for(const b of stripSeededPlaybookBlocks(a['content']??'')){const c=b['trim']();if(c==='')continue;if(c['startsWith']('>'))continue;if(c['startsWith']('#'))continue;if(PLAYBOOK_PLACEHOLDER_RE['test'](c))continue;return!![];}return![];}const TRAIT_BOOLEAN_KEYS=['has_logistics','communication_heavy','pure_digital','long_cycle','deposit_required','multi_tier_allocation'],TRAIT_ENUM_KEYS=['regulatory_intensity','trust_sensitivity','consumption_frequency','avg_ticket_size'];function coerceTraits(a){if(!a||typeof a!=='object')return undefined;const b={...DEFAULT_TRAITS};let c=![];for(const d of TRAIT_BOOLEAN_KEYS){typeof a[d]==='boolean'&&(b[d]=a[d],c=!![]);}for(const e of TRAIT_ENUM_KEYS){typeof a[e]==='string'&&(b[e]=a[e],c=!![]);}return c?b:undefined;}export function ensureIndustryProfile(a,b){const c=a['manifest']['name'];if(getIndustryProfile(c))return;try{const d=(a['manifest']['depends_on']??[])['filter'](g=>typeof g==='string'&&g['length']>0x0);if(d['length']>0x0){const g=composeIndustries(d,c);if(!g)throw new Error('depends_on\x20parents\x20not\x20registered:\x20'+d['join'](',\x20'));g['display_name']=a['manifest']['display_name']||g['display_name'],g['source']='composed',registerIndustry(g);return;}const e=coerceTraits(a['manifest']['traits'])??inferTraitsFromDescription(a['manifest']['display_name']||c)['traits'],f=synthesizeProfile(e,c);f['display_name']=a['manifest']['display_name']||f['display_name'],f['source']='custom',registerIndustry(f);}catch(h){b['push']('industry\x20profile\x20registration\x20failed\x20for\x20\x27'+c+'\x27:\x20'+h['message']);}}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;ensureIndustryProfile(a,c);if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):d['push']('rules');}}if(e['layers']['includes']('baselines')){if(!a['baselines'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27baselines\x27\x20but\x20baselines.json\x20is\x20missing');else{if(!isMeaningfulBaselines(a['baselines'])){}else{const m=validateJudgmentFragment(a['baselines'],e['name']+'.baselines');if(m)c['push'](m);else!registerIndustryBaselines({'category':e['name'],'fragment':a['baselines']},i)?c['push']('baselines\x20for\x20\x27'+e['name']+'\x27\x20already\x20registered'):d['push']('baselines');}}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const q=b['manifest'],r={'layout':'merged','manifest':q};if(b['mode'])r['mode']=b['mode'];if(b['match'])r['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(r['personae']=b['personae']);if(b['dispute'])r['dispute']=b['dispute'];if(b['compliance'])r['compliance']=b['compliance'];if(b['supply'])r['supply']=b['supply'];if(b['rules'])r['rules']=b['rules'];if(b['baselines'])r['baselines']=b['baselines'];const s=join(a,'playbook.md');return existsSync(s)&&(r['playbook']={'category':q['name'],'content':readFileSync(s,'utf-8')}),r;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const t=[];for(const u of readdirSync(j)){if(!u['endsWith']('.json'))continue;t['push'](JSON['parse'](readFileSync(join(j,u),'utf-8')));}if(t['length']>0x0)g['personae']=t;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'baselines.json');existsSync(o)&&(g['baselines']=JSON['parse'](readFileSync(o,'utf-8')));const p=join(a,'playbook.md');return existsSync(p)&&(g['playbook']={'category':e['name'],'content':readFileSync(p,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),seedBuiltinTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export function seedBuiltinStrategyManuals(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();for(const d of a){const e=renderStrategyManual(d);if(!e)continue;const f=join(c,d,STRATEGY_MANUAL_FILENAME);try{const g=join(c,d);if(!existsSync(join(g,'manifest.json'))&&!existsSync(join(g,'pack.json'))){const j=scaffoldIndustryPack(d,c);if(!j['ok']){b['push']({'industry':d,'status':'error','path':f,'detail':j['errors']['join'](';\x20')});continue;}}if(!existsSync(f)){writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'written','path':f});continue;}const h=readFileSync(f,'utf-8'),i=classifyManualFile(d,h);if(i==='outdated')writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'updated','path':f});else{if(i==='current')b['push']({'industry':d,'status':'current','path':f});else i==='user_modified'?b['push']({'industry':d,'status':'skipped_user_modified','path':f,'detail':'strategy-manual.md\x20was\x20edited\x20locally;\x20keeping\x20user\x20content\x20and\x20not\x20upgrading'}):b['push']({'industry':d,'status':'skipped_user_file','path':f,'detail':'strategy-manual.md\x20exists\x20without\x20builtin\x20sentinel;\x20leaving\x20user\x20file\x20untouched'});}}catch(k){b['push']({'industry':d,'status':'error','path':f,'detail':k['message']});}}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode','baselines.json':'baselines'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'not_applicable':!![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'baselines':null,'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20Pack\x20layers\x20are\x20registered\x20into\x20the\x20runtime\x20registry\x20and','>\x20consumed\x20on\x20demand\x20by\x20the\x20build/recommendation\x20tools\x20(merchant_guide,','>\x20recommend_industry,\x20…);\x20a\x20compact\x20strategy\x20summary\x20for\x20the\x20active','>\x20merchant/supplier\x20lens\x20is\x20injected\x20into\x20every\x20chat\x20turn.','','##\x20Business\x20model\x20—\x20DIRECT\x20SALES,\x20freedom\x20for\x20the\x20merchant','','**WoWok\x20takes\x20no\x20platform\x20commission.\x20A\x20merchant\x20pays\x20only\x20gas.**\x20This\x20is','the\x20product\x27s\x20core\x20positioning,\x20and\x20every\x20template,\x20manual\x20and\x20playbook\x20in','this\x20tree\x20is\x20written\x20under\x20it.','','Three\x20layers,\x20do\x20not\x20conflate\x20them:','','-\x20**L1\x20Protocol\x20—\x20never\x20extracts.**\x20The\x20framework\x20has\x20no\x20platform-take','\x20\x20concept\x20at\x20all:\x20every\x20`order_allocators`\x20sharing\x20item\x20is\x20configured\x20by','\x20\x20the\x20merchant\x20and\x20every\x20recipient\x20is\x20chosen\x20by\x20the\x20merchant.','-\x20**L2\x20Template\x20default\x20—\x20100%\x20to\x20the\x20merchant.**\x20Built-in\x20templates','\x20\x20demonstrate\x20the\x20most\x20efficient\x20P2P\x20form:\x20a\x20single\x20`Rate\x2010000`\x20leg\x20to','\x20\x20the\x20merchant\x27s\x20own\x20Entity,\x20zero\x20platform\x20leg.\x20Never\x20copy\x20an\x20incumbent','\x20\x20marketplace\x20split\x20(host\x20commission\x20+\x20guest\x20service\x20fee)\x20into\x20an','\x20\x20allocator\x20—\x20under\x20this\x20model\x20nobody\x20receives\x20it.','-\x20**L3\x20Merchant\x20freedom\x20—\x20a\x20fee\x20is\x20allowed.**\x20When\x20the\x20merchant\x20IS\x20the','\x20\x20aggregator\x20(a\x20chain,\x20a\x20multi-supplier\x20orchestrator,\x20a\x20consortium),\x20it','\x20\x20may\x20charge\x20its\x20own\x20service\x20fee.\x20Three\x20constraints\x20make\x20that\x20honest:','\x20\x201.\x20**Explicit\x20number.**\x20Never\x20an\x20implicit\x20remainder\x20such\x20as','\x20\x20\x20\x20\x20`commission\x20=\x20order\x20total\x20-\x20segment\x20sums`.\x20A\x20buyer\x20must\x20be\x20able\x20to','\x20\x20\x20\x20\x20compute\x20the\x20take\x20BEFORE\x20ordering.','\x20\x202.\x20**Explicit\x20non-empty\x20recipient\x20Entity**\x20the\x20buyer\x20can\x20see\x20pre-order.','\x20\x20\x20\x20\x20An\x20EMPTY\x20Entity\x20(`\x22\x22`)\x20silently\x20routes\x20the\x20share\x20to\x20the\x20deploying','\x20\x20\x20\x20\x20AI/host\x27s\x20own\x20account\x20(`ts-sdk/packages/wowok/src/w/local/index.ts:89-91`).','\x20\x203.\x20**No\x20mandatory\x20transit.**\x20The\x20organizer\x20pool\x20must\x20not\x20be\x20a\x20required','\x20\x20\x20\x20\x20waypoint\x20for\x20the\x20merchant\x27s\x20own\x20payout,\x20and\x20a\x20`Surplus`\x20leg\x20must','\x20\x20\x20\x20\x20never\x20be\x20how\x20the\x20fee\x20is\x20taken\x20—\x20`Surplus`\x20calls','\x20\x20\x20\x20\x20`balance::withdraw_all`,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool.','','**Why\x20efficiency,\x20not\x20a\x20rate\x20cut.**\x20A\x20legacy\x20marketplace\x27s\x20edge\x20is\x20a\x20rate','cut.\x20WoWok\x27s\x20edge\x20is\x20that\x20a\x20merchant\x20keeps\x20the\x20whole\x20sale\x20AND\x20gets:','escrow\x20that\x20moves\x20only\x20between\x20the\x20two\x20parties,\x20an\x20independent\x20venue,','and\x20a\x20public\x20pre-order\x20outcome\x20ledger.\x20Compete\x20on\x20escrow/arbitration','value,\x20never\x20on\x20price.','','**Merchant-facing\x20audit\x20invariants**\x20(`template_scan`):','','-\x20`R-ECON-01`\x20any\x20`fee_params`\x20platform/commission\x20key\x20!=\x200\x20→\x20ERROR','-\x20`R-ECON-02`\x20fee\x20taken\x20as\x20an\x20implicit\x20remainder\x20/\x20`Surplus`\x20drain\x20→\x20ERROR','-\x20`R-ECON-03`\x20non-zero\x20third-party\x20share\x20with\x20an\x20EMPTY\x20recipient\x20→\x20ERROR','-\x20`R-ECON-04`\x20a\x20mandatory\x20transit\x20pool\x20on\x20the\x20payout\x20path\x20→\x20WARN','-\x20`R-ECON-05`\x20attribution-weighted\x20take\x20(attributed\x20>\x20base)\x20→\x20WARN','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files,\x20plus\x20an\x20optional\x20`templates/`\x20folder:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20Registered\x20on\x20scan\x20and\x20read\x20ON\x20DEMAND\x20via\x20industry_pack_operation','\x20\x20(action=\x27get\x27);\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for\x20this\x20account.','-\x20**`<pack>/templates/*.md`**\x20—\x20archetype\x20templates\x20(see\x20the\x20Templates','\x20\x20section\x20below).\x20The\x2012\x20built-in\x20variants\x20are\x20seeded\x20here\x20automatically.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20registered\x20layers\x20are\x20available\x20to\x20the','\x20\x20\x20on-demand\x20tools\x20(and\x20the\x20merchant/supplier\x20strategy\x20summary\x20is\x20fresh','\x20\x20\x20in\x20the\x20persona\x20context),\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules','\x20\x20\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Legal','\x20\x20layer\x20names:\x20`match`,\x20`personae`,\x20`dispute`,\x20`compliance`,\x20`supply`,','\x20\x20`rules`,\x20`baselines`,\x20`playbook`\x20(plus\x20`mode`\x20when\x20you\x20add\x20a\x20driving','\x20\x20mode).\x20Remove\x20a\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in','\x20\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20baselines\x20—\x20judgment\x20baselines\x20overlay\x20(Q12)','','`baselines`\x20carries\x20a\x20PARTIAL\x20judgment\x20baselines\x20document\x20(same\x20shape\x20as','the\x20user\x27s\x20judgment.json).\x20It\x20is\x20merged\x20into\x20the\x20judgment\x20chain','BETWEEN\x20the\x20factory\x20document\x20and\x20the\x20persona\x20fragment:','','\x20\x20\x20\x20factory\x20<\x20pack\x20baselines\x20<\x20persona\x20fragment\x20<\x20user\x20document\x20<\x20session\x20overrides','','A\x20pack\x20may\x20RETUNE\x20factory\x20parameters\x20or\x20DISABLE\x20factory\x20rules','(`enabled:\x20false`\x20—\x20a\x20disable\x20trace\x20is\x20recorded).\x20It\x20can\x20NEVER\x20invent\x20new','dimensions/rules\x20or\x20delete\x20factory\x20entries:\x20only\x20keys\x20and\x20ids\x20that\x20exist','in\x20the\x20factory\x20document\x20are\x20accepted.\x20Tuning\x20example:','','```json','\x22baselines\x22:\x20{','\x20\x20\x22version\x22:\x201,','\x20\x20\x22evaluation\x22:\x20{\x20\x22severity_deduction\x22:\x20{\x20\x22critical\x22:\x2040\x20}\x20},','\x20\x20\x22monitor\x22:\x20{\x20\x22thresholds\x22:\x20{\x20\x22messenger_timeout_hours\x22:\x2012\x20}\x20}','}','```','','Disabling\x20a\x20factory\x20rule\x20(the\x20rule\x20id\x20must\x20exist,\x20e.g.\x20in\x20the\x20`util`','domain):','','```json','{\x20\x22rules\x22:\x20{\x20\x22domains\x22:\x20{\x20\x22util\x22:\x20{\x20\x22rules\x22:\x20[','\x20\x20{\x20\x22rule_id\x22:\x20\x22R-UTIL-03\x22,\x20\x22enabled\x22:\x20false\x20}',']\x20}\x20}\x20}\x20}','```','','A\x20misspelled\x20dimension\x20or\x20an\x20invented\x20rule\x20id\x20is\x20REJECTED\x20at\x20registration','(and\x20on\x20every\x20scan/rescan)\x20with\x20a\x20visible\x20error\x20—\x20the\x20last\x20good','registration\x20stays\x20in\x20force\x20until\x20the\x20fragment\x20is\x20fixed.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','Registered\x20into\x20`IndustryModeRegistry`\x20on\x20scan\x20(manifest\x20must\x20list\x20the','`mode`\x20layer).\x20A\x20pack\x20mode\x20with\x20the\x20same\x20name\x20as\x20a\x20builtin\x20replaces\x20it\x20when','the\x20pack\x20version\x20changes\x20or\x20on\x20a\x20forced\x20rescan.','','###\x20How\x20the\x20mode\x20is\x20consumed','','-\x20**Service\x20build\x20(priors)**:\x20`merchant_guide`\x20resolves\x20the\x20confirmed','\x20\x20industry\x20to\x20a\x20mode\x20(user\x20mode\x20first,\x20then\x20pack\x20mode,\x20then\x20builtin)\x20and','\x20\x20feeds\x20`machine_shape`\x20/\x20`guards`\x20/\x20`allocator`\x20/\x20`key_risk`\x20into\x20the','\x20\x20SemanticObjectGraph\x20build.','-\x20**Evaluation**:\x20the\x20metric\x20+\x20constraint\x20registries\x20score\x20the\x20mode','\x20\x20(risk/benefit\x200-100,\x20hard\x20violations\x20block\x20adoption).\x20Custom\x20metrics\x20and','\x20\x20constraints\x20registered\x20via\x20`industry_pack_operation`\x20participate\x20too.','-\x20**Recommendation**:\x20`recommend_industry`\x20matches\x20trait\x20similarity\x20and,','\x20\x20when\x20a\x20merchant\x20strategy\x20is\x20given,\x20re-ranks\x20by\x20lever\x20alignment\x20(70%','\x20\x20similarity\x20+\x2030%\x20alignment).','','###\x20Field\x20reference','','-\x20**Identity**:\x20`name`\x20(snake_case),\x20`display_name`,\x20`version`\x20(e.g.\x20`v1`),','\x20\x20`source`\x20(`builtin`\x20|\x20`custom`).','-\x20`traits`:\x2010-dimension\x20industry\x20trait\x20vector\x20(logistics,\x20cycle,\x20deposit,','\x20\x20regulatory\x20intensity,\x20...).\x20Drives\x20`recommend_industry`\x20similarity.','-\x20`machine_shape`:\x20Machine\x20node\x20topology\x20—\x20`[{\x20name,\x20role\x20}]`.\x20Node\x20names\x20are','\x20\x20business\x20states.\x20R-M1-11:\x20NEVER\x20model\x20refund/dispute\x20terminals','\x20\x20(`refunded`,\x20`disputed`,\x20`arb_*`)\x20as\x20nodes\x20—\x20disputes\x20flow\x20through','\x20\x20Service.arbitrations\x20independently;\x20route\x20refunds\x20via\x20the\x20Allocator','\x20\x20triggered\x20by\x20business\x20states\x20(`cancelled`,\x20`returned`).','-\x20`guards`:\x20`[{\x20template_id,\x20host,\x20purpose\x20}]`\x20—\x20guard\x20templates\x20to\x20attach.','\x20\x20`host`\x20is\x20one\x20of\x20`service`\x20|\x20`machine`\x20|\x20`reward`\x20|\x20`repository`\x20|','\x20\x20`arbitration`.','-\x20`allocator`:\x20`{\x20recipient,\x20count,\x20mode,\x20description\x20}`\x20—\x20fund\x20split.','\x20\x20`recipient`:\x20`signer`\x20|\x20`entity`;\x20`count`\x20>\x201\x20switches\x20to\x20multi-party','\x20\x20distribution;\x20`mode`:\x20`surplus`\x20|\x20`rate`\x20|\x20`milestone`.','-\x20`risk_checks`\x20/\x20`needs`:\x20buyer-side\x20due-diligence\x20entries\x20surfaced\x20in','\x20\x20prospect\x20evaluation.','-\x20`flywheel`:\x20acquisition\x20flywheel\x20—\x20`rewardStrategy`\x20/\x20`discountStrategy`','\x20\x20/\x20`trustSellingPoints`.\x20A\x20concrete\x20(non-`User-defined`)\x20strategy\x20turns','\x20\x20the\x20`reward`/`discount`\x20levers\x20on\x20for\x20strategy\x20alignment.','-\x20`key_risk`\x20(string)\x20/\x20`build_notes`\x20(string[]):\x20the\x20headline\x20risk\x20and','\x20\x20actionable\x20build\x20guidance\x20shown\x20to\x20the\x20merchant.','-\x20`capabilities_used`:\x20CapabilityCard\x20IDs\x20(e.g.\x20`guard.validate_buy`,','\x20\x20`machine.node_topology`,\x20`allocation.distribute_milestone`).\x20Powers\x20the','\x20\x20`buy_guard`\x20/\x20`machine_design`\x20levers\x20and\x20constraint\x20checks.','-\x20`config_overrides`:\x20per-object\x20field\x20defaults,\x20e.g.','\x20\x20`{\x20service:\x20{\x20engagement_type:\x20\x27milestone\x27\x20},\x20machine:\x20{\x20wip_required:\x20true\x20}\x20}`.','-\x20`config_override_rules`:\x20conditional\x20overrides\x20—','\x20\x20`{\x20object_type,\x20field_path,\x20value\x20|\x20{\x20intent_contains,\x20then_value,\x20else_value\x20}\x20}`.','-\x20`expected_benefits`:\x20`[{\x20metric,\x20expected_value,\x20evidence\x20}]`\x20—\x20what\x20the','\x20\x20mode\x20is\x20supposed\x20to\x20buy\x20you.','-\x20`risk_appetite`:\x20`conservative`\x20|\x20`balanced`\x20|\x20`aggressive`\x20(thresholds','\x20\x20for\x20the\x20risk/benefit\x20verdict).','-\x20`risk_constraints`:\x20`{\x20require_arbitration,\x20require_compensation_fund,','\x20\x20require_wip_evidence,\x20max_single_transaction?,','\x20\x20compensation_fund_coverage_ratio?,\x20other_constraints?\x20}`.\x20Coverage\x20ratio','\x20\x20multiplies\x20max\x20single\x20order\x20to\x20size\x20the\x20compensation\x20fund\x20(retail\x205,','\x20\x20rental\x2010,\x20subscription\x203;\x20default\x205).','-\x20`applicable_conditions`:\x20`{\x20business_scale,\x20min_daily_orders?,','\x20\x20other_conditions?\x20}`\x20—\x20when\x20the\x20mode\x20fits.','-\x20`similar_industries`\x20/\x20`novel_capabilities`:\x20migration\x20hints.','-\x20`disabled_builtin_constraints`:\x20builtin\x20constraint\x20IDs\x20this\x20mode','\x20\x20deliberately\x20opts\x20out\x20of\x20(e.g.\x20retail_d2c\x20skips\x20`require_arbitration`).','\x20\x20Custom\x20constraints\x20are\x20never\x20skipped.','','###\x20Persona\x20integration\x20(strategy\x20→\x20levers)','','The\x20personae\x20section\x27s\x20`current.strategy`\x20statements\x20are\x20bridged\x20into\x20mode','ranking\x20(value\x20intent\x20↔\x20game\x20path\x20unification).\x20Deterministic\x20mapping\x20—','\x22enumerable\x20→\x20MCP,\x20not\x20prompt\x22:','','-\x20`sales_priority`\x20(volume\x20first)\x20→\x20levers\x20`discount`\x20+\x20`reward`','-\x20`profit_priority`\x20(margin\x20first)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','-\x20`buyer_screening`\x20(qualify\x20buyers)\x20→\x20lever\x20`buy_guard`','-\x20`gross_margin_control`\x20(margin\x20band)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','','A\x20mode\x20supports\x20a\x20lever\x20when\x20its\x20data\x20says\x20so:\x20`guard.validate_buy`','capability\x20or\x20a\x20buy-guard\x20template\x20enables\x20`buy_guard`;\x20a\x20concrete','flywheel\x20reward/discount\x20strategy\x20enables\x20`reward`/`discount`;\x20a','non-empty\x20`machine_shape`\x20with\x20`machine.node_topology`\x20enables','`machine_design`.\x20Pass\x20strategy\x20text\x20to\x20`recommend_industry`\x20and\x20each','recommendation\x20reports\x20`strategy_alignment`\x20(matched/missing\x20levers).','','##\x20custom-registry.json\x20—\x20your\x20custom\x20rules\x20(managed\x20by\x20the\x20AI)','','This\x20file\x20stores\x20customizations\x20that\x20apply\x20to\x20EVERY\x20industry\x20pack:','-\x20`metrics`\x20—\x20extra\x20scoring\x20dimensions\x20you\x20asked\x20the\x20AI\x20to\x20evaluate','\x20\x20(e.g.\x20\x22add\x20an\x20environmental-impact\x20metric\x20to\x20mode\x20evaluation\x22).','-\x20`constraints`\x20—\x20hard\x20rules\x20a\x20mode\x20must\x20satisfy\x20(e.g.\x20\x22must\x20always','\x20\x20include\x20arbitration\x22).','-\x20`user_modes`\x20—\x20your\x20own\x20industry\x20modes\x20derived\x20from\x20the\x20built-ins.','','You\x20normally\x20never\x20touch\x20this\x20file:\x20just\x20ask\x20the\x20AI\x20in\x20chat\x20(for','example\x20\x22register\x20a\x20custom\x20metric\x20...\x22),\x20and\x20it\x20writes\x20the\x20entry','here\x20for\x20you.\x20Deleting\x20an\x20entry\x20removes\x20that\x20customization.\x20If\x20you','edit\x20it\x20by\x20hand\x20anyway,\x20changes\x20take\x20effect\x20without\x20a\x20restart.','An\x20absent\x20or\x20empty\x20file\x20is\x20normal\x20—\x20it\x20simply\x20means\x20you\x20have\x20not','created\x20any\x20custom\x20metrics,\x20constraints\x20or\x20modes\x20yet.','','##\x20Templates\x20(`<pack>/templates/*.md`)','','Each\x20template\x20.md\x20has\x20two\x20parts:','','-\x20**Frontmatter**\x20(the\x20`---\x20...\x20---`\x20block):\x20machine-readable\x20settings\x20—','\x20\x20`id`,\x20`industry`,\x20`variant`,\x20`machine_shape`,\x20`guards`,\x20`allocator`,','\x20\x20`fee_params`,\x20…\x20In\x20the\x20client\x27s\x20VIEW\x20mode\x20these\x20render\x20as\x20a\x20table','\x20\x20(hover\x20a\x20key\x20for\x20its\x20meaning);\x20EDIT\x20mode\x20shows\x20the\x20raw\x20text.','-\x20**Markdown\x20body**:\x20free-form\x20guidance\x20for\x20the\x20AI\x20(Key\x20risk,','\x20\x20Differences,\x20Build\x20notes,\x20…).','','###\x20Impact\x20and\x20risks\x20of\x20editing\x20templates','','-\x20The\x20frontmatter\x20is\x20**strictly\x20validated\x20on\x20every\x20load**\x20by\x20the\x20AI','\x20\x20runtime\x20(allowed\x20keys,\x20value\x20types,\x20ranges,\x20`id`/`industry`/`variant`','\x20\x20consistency\x20with\x20the\x20file\x20location).\x20A\x20template\x20that\x20fails\x20validation','\x20\x20is\x20**skipped\x20with\x20a\x20loud\x20error**\x20—\x20tools\x20that\x20read\x20templates\x20report','\x20\x20the\x20file\x20and\x20the\x20exact\x20field\x20problem\x20until\x20you\x20fix\x20it.\x20Guidance\x20in','\x20\x20the\x20broken\x20template\x20will\x20NOT\x20reach\x20the\x20AI\x20while\x20it\x20is\x20invalid.','-\x20The\x20**client\x20editor\x20validates\x20on\x20save**\x20(same\x20rules)\x20and\x20blocks\x20the','\x20\x20write,\x20so\x20most\x20mistakes\x20never\x20reach\x20disk.\x20Edits\x20made\x20OUTSIDE\x20the','\x20\x20client\x20bypass\x20this\x20gate\x20—\x20run\x20a\x20Scan\x20afterwards\x20and\x20watch\x20for\x20errors.','-\x20Keep\x20the\x20Markdown\x20body\x20free-form\x20—\x20it\x20is\x20never\x20validated.\x20Breaking','\x20\x20the\x20`---`\x20structure\x20is\x20what\x20matters.','','###\x20How\x20to\x20recover\x20a\x20broken\x20template','','1.\x20Fix\x20the\x20field\x20named\x20in\x20the\x20error\x20(type/range/enum\x20mismatch),\x20or','2.\x20**Delete\x20the\x20.md\x20file**\x20—\x20the\x20built-in\x20version\x20is\x20re-seeded','\x20\x20\x20automatically\x20at\x20the\x20next\x20startup\x20/\x20template\x20scan\x20(seeding\x20never','\x20\x20\x20overwrites\x20an\x20existing\x20file,\x20so\x20your\x20other\x20edits\x20survive).','3.\x20Right-click\x20a\x20file\x20in\x20the\x20Industry\x20drawer\x20→\x20*Reset*\x20restores\x20the','\x20\x20\x20pristine\x20seeded\x20version\x20too.','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Business\x20model\x20—\x20direct\x20sales','','WoWok\x20takes\x20no\x20platform\x20commission\x20—\x20a\x20merchant\x20in\x20'+a+'\x20pays\x20only','gas,\x20and\x20the\x20default\x20payout\x20gives\x20the\x20merchant\x20the\x20whole\x20sale.\x20Never\x20copy','an\x20incumbent\x20marketplace\x20split\x20into\x20an\x20allocator:\x20that\x20share\x20is\x20displaced','by\x20design,\x20not\x20a\x20parameter,\x20and\x20nobody\x20would\x20receive\x20it.\x20If\x20the\x20merchant','IS\x20the\x20aggregator\x20(a\x20chain,\x20a\x20multi-supplier\x20orchestrator,\x20a\x20consortium)','it\x20may\x20charge\x20its\x20OWN\x20fee,\x20but\x20only\x20with:\x20an\x20explicit\x20number\x20the\x20buyer','can\x20compute\x20before\x20ordering;\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20(an','empty\x20one\x20silently\x20routes\x20the\x20share\x20to\x20the\x20deploying\x20AI/host\x20—\x20see','`ts-sdk/packages/wowok/src/w/local/index.ts:89-91`);\x20and\x20no\x20mandatory\x20transit\x20pool\x20on\x20the','payout\x20path\x20—\x20never\x20a\x20fee\x20via\x20a\x20`Surplus`\x20leg,\x20which\x20calls','`balance::withdraw_all`\x20and\x20so\x20doubles\x20as\x20draining\x20the\x20pool.\x20Compete\x20on','escrow/arbitration\x20value,\x20not\x20price.','','>\x20Rule\x20of\x20thumb\x20for\x20everything\x20below:\x20any\x20fee,\x20cut\x20or\x20margin\x20recorded\x20in','>\x20the\x20Experience\x20and\x20Strategy\x20sections\x20is\x20MERCHANT\x20REVENUE\x20—\x20an\x20explicit,','>\x20disclosed\x20number\x20in\x20an\x20allocator\x20leg\x20with\x20a\x20non-empty\x20recipient\x20Entity.','>\x20It\x20is\x20never\x20a\x20platform\x20share,\x20and\x20it\x20must\x20never\x20be\x20an\x20implicit\x20remainder','>\x20(order\x20total\x20minus\x20segment\x20sums)\x20or\x20a\x20`Surplus`\x20entry.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20assume\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event,\x20or\x20charge\x20YOUR\x20OWN\x20disclosed\x2015%\x20change\x20fee\x20(merchant\x20revenue,\x20not\x20a\x20platform\x20take;\x20explicit\x20number,\x20non-empty\x20recipient\x20Entity,\x20declared\x20before\x20ordering).\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to\x20never\x20concede\x20on.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(Add\x20when\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full\x20evidence\x20+\x20arbitration\x20—\x20call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Add\x20logo,\x20link-out\x20style,\x20forbidden\x20terminology,\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Add\x20non-negotiables.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Add\x20ethical\x20guardrails.\x20Example:\x20\x22If\x20a\x20customer\x20appears\x20intoxicated,\x20refuse\x20service\x20and\x20refer\x20to\x20a\x20supervisor.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
|
|
1
|
+
import{readdirSync,readFileSync,existsSync,mkdirSync,writeFileSync}from'node:fs';import{join}from'node:path';import{getWowokIndustryDir}from'@wowok/wowok';import{seedBuiltinTemplates}from'../knowledge/template-loader.js';import{getIndustryModeRegistry}from'./registry.js';import{BUILTIN_MODES}from'./modes.js';import{registerCategoryMatchRules}from'../evaluation/category-match-rules.js';import{registerIndustryPersonae,unregisterIndustryPersonae}from'../persona/pack-personae.js';import{PERSONA_ROLES,SUPPORTED_INDUSTRIES}from'../persona/types.js';import{UNIVERSAL_TEMPLATE}from'../knowledge/universal-template.js';import{STRATEGY_MANUAL_FILENAME,renderStrategyManual,classifyManualFile}from'../knowledge/strategy-manuals.js';import{registerDisputeRules,registerComplianceRules,registerSupplyRules,registerIndustryRules,registerIndustryPlaybook,registerIndustryBaselines}from'./industry-layers.js';import{validateJudgmentFragment}from'../config/judgment.js';import{getIndustryProfile,registerIndustry}from'../knowledge/industry-registry.js';import{composeIndustries,DEFAULT_TRAITS,inferTraitsFromDescription,synthesizeProfile}from'../knowledge/industry-generalizer.js';const FORBIDDEN_PRICING_MODES=new Set(UNIVERSAL_TEMPLATE['pricing_redlines']),packRegistry=new Map();export function validatePackManifest(a){const b=[];return(!a||a['pack']!=='industry-pack')&&b['push']('manifest.pack\x20must\x20be\x20\x27industry-pack\x27'),(!a['name']||typeof a['name']!=='string')&&b['push']('manifest.name\x20is\x20required'),(!a['version']||typeof a['version']!=='string')&&b['push']('manifest.version\x20is\x20required'),(!Array['isArray'](a['layers'])||a['layers']['length']===0x0)&&b['push']('manifest.layers\x20must\x20be\x20a\x20non-empty\x20array'),{'valid':b['length']===0x0,'errors':b};}function isMeaningfulMatch(a){if(!a)return![];return(a['hard_constraints']?.['length']??0x0)>0x0||Object['keys'](a['soft_weights']??{})['length']>0x0||(a['pricing_rules']?.['length']??0x0)>0x0||(a['highlight_fields']?.['length']??0x0)>0x0;}function isMeaningfulPersona(a){const b=a['long_term']??{},c=a['current']??{};return(c['strategy']?.['length']??0x0)>0x0||(c['requirements']?.['length']??0x0)>0x0||(c['rules']?.['length']??0x0)>0x0||(c['spec']?.['length']??0x0)>0x0||Object['keys'](c['preferences']??{})['length']>0x0||Object['keys'](b['preferences']??{})['length']>0x0||(b['identity']?.['region']?.['length']??0x0)>0x0||(b['identity']?.['languages']?.['length']??0x0)>0x0;}function isMeaningfulDispute(a){return(a?.['sla_tiers']?.['length']??0x0)>0x0||(a?.['fault_rules']?.['length']??0x0)>0x0;}function isMeaningfulCompliance(a){return!!a?.['prepay_mode']||(a?.['qualification']?.['length']??0x0)>0x0||(a?.['disclosure']?.['length']??0x0)>0x0||typeof a?.['refund_window']?.['days']==='number'&&a['refund_window']['days']>0x0;}function isMeaningfulSupply(a){return(a?.['supplier_qualification']?.['length']??0x0)>0x0||!!a?.['first_order_policy']||a?.['redundancy_required']===!![];}function isMeaningfulRules(a){return(a?.['rules']?.['length']??0x0)>0x0;}function isMeaningfulBaselines(a){return typeof a==='object'&&a!==null&&!Array['isArray'](a)&&Object['keys'](a)['length']>0x0;}const PLAYBOOK_PLACEHOLDER_RE=/\((?:Example|Add|Write)\b/,PLAYBOOK_SEEDED_BLOCK_HEADINGS=['##\x20Business\x20model\x20—\x20direct\x20sales'];function stripSeededPlaybookBlocks(a){const b=[];let c=![];for(const d of a['split'](/\r?\n/)){const e=d['trim'](),f=e['startsWith']('#');if(f){c=PLAYBOOK_SEEDED_BLOCK_HEADINGS['some'](g=>e===g||e===g['replace'](/^#+\s*/,'#')||normalizeHeading(e)===normalizeHeading(g));if(c)continue;}if(c)continue;b['push'](d);}return b;}function normalizeHeading(a){return a['replace'](/^#+\s*/,'')['trim']()['toLowerCase']()['replace'](/\s+/g,'\x20');}function isMeaningfulPlaybook(a){if(!a)return![];for(const b of stripSeededPlaybookBlocks(a['content']??'')){const c=b['trim']();if(c==='')continue;if(c['startsWith']('>'))continue;if(c['startsWith']('#'))continue;if(PLAYBOOK_PLACEHOLDER_RE['test'](c))continue;return!![];}return![];}const TRAIT_BOOLEAN_KEYS=['has_logistics','communication_heavy','pure_digital','long_cycle','deposit_required','multi_tier_allocation'],TRAIT_ENUM_KEYS=['regulatory_intensity','trust_sensitivity','consumption_frequency','avg_ticket_size'];function coerceTraits(a){if(!a||typeof a!=='object')return undefined;const b={...DEFAULT_TRAITS};let c=![];for(const d of TRAIT_BOOLEAN_KEYS){typeof a[d]==='boolean'&&(b[d]=a[d],c=!![]);}for(const e of TRAIT_ENUM_KEYS){typeof a[e]==='string'&&(b[e]=a[e],c=!![]);}return c?b:undefined;}export function ensureIndustryProfile(a,b){const c=a['manifest']['name'];if(getIndustryProfile(c))return;try{const d=(a['manifest']['depends_on']??[])['filter'](g=>typeof g==='string'&&g['length']>0x0);if(d['length']>0x0){const g=composeIndustries(d,c);if(!g)throw new Error('depends_on\x20parents\x20not\x20registered:\x20'+d['join'](',\x20'));g['display_name']=a['manifest']['display_name']||g['display_name'],g['source']='composed',registerIndustry(g);return;}const e=coerceTraits(a['manifest']['traits'])??inferTraitsFromDescription(a['manifest']['display_name']||c)['traits'],f=synthesizeProfile(e,c);f['display_name']=a['manifest']['display_name']||f['display_name'],f['source']='custom',registerIndustry(f);}catch(h){b['push']('industry\x20profile\x20registration\x20failed\x20for\x20\x27'+c+'\x27:\x20'+h['message']);}}export function registerIndustryPack(a,b=![]){const c=[],d=[],e=a['manifest'],f=validatePackManifest(e);c['push'](...f['errors']);if(!f['valid'])return{'ok':![],'errors':c,'registered':d};const g=packRegistry['get'](e['name']),h=g!==undefined&&g['version']!==e['version'],i=h||b;ensureIndustryProfile(a,c);if(e['layers']['includes']('mode')){if(!a['mode'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27mode\x27\x20but\x20mode.json\x20is\x20missing');else{const j=getIndustryModeRegistry();i&&j['hasMode'](a['mode']['name'])&&j['unregisterMode'](a['mode']['name']),!j['registerMode'](a['mode'])?c['push']('mode\x20\x27'+a['mode']['name']+'\x27\x20failed\x20to\x20register\x20(already\x20registered?).\x20'+'Unregister\x20first\x20or\x20upgrade\x20with\x20a\x20different\x20version.'):d['push']('mode');}}if(e['layers']['includes']('match')){if(!a['match'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27match\x27\x20but\x20match.json\x20is\x20missing');else{if(!isMeaningfulMatch(a['match'])){}else{const k=a['match']['pricing_rules']['filter'](l=>FORBIDDEN_PRICING_MODES['has'](l));if(k['length']>0x0)c['push']('match.pricing_rules\x20contains\x20forbidden\x20modes:\x20'+k['join'](',\x20')+'\x20'+'(violates\x20upper-layer\x20pricing\x20red\x20lines,\x20K3\x2015\x20§4.2)');else!registerCategoryMatchRules(a['match'],i)?c['push']('match\x20rules\x20for\x20\x27'+a['match']['category']+'\x27\x20already\x20registered'):d['push']('match');}}}if(e['layers']['includes']('personae')){if(!a['personae']||a['personae']['length']===0x0)c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27personae\x27\x20but\x20personae\x20are\x20missing');else{const l=a['personae']['filter'](isMeaningfulPersona);if(l['length']===0x0){}else registerIndustryPersonae(e['name'],l),d['push']('personae');}}if(e['layers']['includes']('dispute')){if(!a['dispute'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27dispute\x27\x20but\x20dispute.json\x20is\x20missing');else{if(!isMeaningfulDispute(a['dispute'])){}else!registerDisputeRules(a['dispute'],i)?c['push']('dispute\x20rules\x20for\x20\x27'+a['dispute']['category']+'\x27\x20already\x20registered'):d['push']('dispute');}}if(e['layers']['includes']('compliance')){if(!a['compliance'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27compliance\x27\x20but\x20compliance.json\x20is\x20missing');else{if(!isMeaningfulCompliance(a['compliance'])){}else!registerComplianceRules(a['compliance'],i)?c['push']('compliance\x20rules\x20for\x20\x27'+a['compliance']['category']+'\x27\x20already\x20registered'):d['push']('compliance');}}if(e['layers']['includes']('supply')){if(!a['supply'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27supply\x27\x20but\x20supply.json\x20is\x20missing');else{if(!isMeaningfulSupply(a['supply'])){}else!registerSupplyRules(a['supply'],i)?c['push']('supply\x20rules\x20for\x20\x27'+a['supply']['category']+'\x27\x20already\x20registered'):d['push']('supply');}}if(e['layers']['includes']('rules')){if(!a['rules'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27rules\x27\x20but\x20rules.json\x20is\x20missing');else{if(!isMeaningfulRules(a['rules'])){}else!registerIndustryRules(a['rules'],i)?c['push']('industry\x20rules\x20for\x20\x27'+a['rules']['category']+'\x27\x20already\x20registered'):d['push']('rules');}}if(e['layers']['includes']('baselines')){if(!a['baselines'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27baselines\x27\x20but\x20baselines.json\x20is\x20missing');else{if(!isMeaningfulBaselines(a['baselines'])){}else{const m=validateJudgmentFragment(a['baselines'],e['name']+'.baselines');if(m)c['push'](m);else!registerIndustryBaselines({'category':e['name'],'fragment':a['baselines']},i)?c['push']('baselines\x20for\x20\x27'+e['name']+'\x27\x20already\x20registered'):d['push']('baselines');}}}if(e['layers']['includes']('playbook')){if(!a['playbook'])c['push']('pack\x20\x27'+e['name']+'\x27\x20declares\x20layer\x20\x27playbook\x27\x20but\x20playbook.md\x20is\x20missing');else{if(!isMeaningfulPlaybook(a['playbook'])){}else!registerIndustryPlaybook(a['playbook'],i)?c['push']('playbook\x20for\x20\x27'+a['playbook']['category']+'\x27\x20already\x20registered'):d['push']('playbook');}}return c['length']===0x0&&packRegistry['set'](e['name'],{'version':e['version'],'layers':[...e['layers']],'registered_at':Date['now']()}),{'ok':c['length']===0x0,'errors':c,'registered':d};}let builtinModesAsPacksRegistered=![];function ensureBuiltinModesAsPacks(){if(builtinModesAsPacksRegistered)return;builtinModesAsPacksRegistered=!![];for(const a of BUILTIN_MODES){if(packRegistry['has'](a['name']))continue;packRegistry['set'](a['name'],{'version':a['version'],'layers':['mode','match'],'registered_at':Date['now']()});}}export function listRegisteredPacks(){return ensureBuiltinModesAsPacks(),Array['from'](packRegistry['entries']())['map'](([a,b])=>({'name':a,...b}));}export function unregisterIndustryPack(a){const b=new Set(BUILTIN_MODES['map'](c=>c['name']));if(b['has'](a))return![];if(!packRegistry['has'](a))return![];return packRegistry['delete'](a),unregisterIndustryPersonae(a),!![];}export function diffIndustryPack(a){const b=packRegistry['get'](a)??null,c=resolveIndustryPackDir(),d=join(c,a),e=readMergedPackIfPresent(d);let f=null;try{if(e&&e['manifest'])f={'version':e['manifest']['version'],'layers':e['manifest']['layers']??[]};else{const l=join(d,'manifest.json');if(existsSync(l)){const m=JSON['parse'](readFileSync(l,'utf-8'));f={'version':m['version'],'layers':m['layers']??[]};}}}catch{f=null;}const g=b?.['layers']??[],h=f?.['layers']??[],i=h['filter'](n=>!g['includes'](n)),j=g['filter'](n=>!h['includes'](n)),k=!!b&&!!f&&(b['version']!==f['version']||i['length']>0x0||j['length']>0x0);return{'name':a,'registered':b?{...b,'layers':[...b['layers']]}:null,'disk':f,'upgradable':k,'layer_diff':{'added':i,'removed':j}};}export function scanPacks(a){const b=[];if(!existsSync(a))return b;for(const c of readdirSync(a,{'withFileTypes':!![]})){if(!c['isDirectory']())continue;const d=join(a,c['name']);try{const e=loadPackFromDir(d);if(!e)continue;b['push'](registerIndustryPack(e));}catch(f){b['push']({'ok':![],'errors':['failed\x20to\x20load\x20pack\x20\x27'+c['name']+'\x27:\x20'+f['message']],'registered':[]});}}return b;}function loadPackFromDir(a){const b=readMergedPackIfPresent(a),c=join(a,'manifest.json'),d=existsSync(c);if(!b&&!d)return null;if(b){const q=b['manifest'],r={'layout':'merged','manifest':q};if(b['mode'])r['mode']=b['mode'];if(b['match'])r['match']=b['match'];b['personae']&&Array['isArray'](b['personae'])&&(r['personae']=b['personae']);if(b['dispute'])r['dispute']=b['dispute'];if(b['compliance'])r['compliance']=b['compliance'];if(b['supply'])r['supply']=b['supply'];if(b['rules'])r['rules']=b['rules'];if(b['baselines'])r['baselines']=b['baselines'];const s=join(a,'playbook.md');return existsSync(s)&&(r['playbook']={'category':q['name'],'content':readFileSync(s,'utf-8')}),r;}const e=JSON['parse'](readFileSync(c,'utf-8')),g={'layout':'legacy','manifest':e},h=join(a,'mode.json'),i=join(a,'match.json');existsSync(h)&&(g['mode']=JSON['parse'](readFileSync(h,'utf-8')));existsSync(i)&&(g['match']=JSON['parse'](readFileSync(i,'utf-8')));const j=join(a,'personae');if(existsSync(j)){const t=[];for(const u of readdirSync(j)){if(!u['endsWith']('.json'))continue;t['push'](JSON['parse'](readFileSync(join(j,u),'utf-8')));}if(t['length']>0x0)g['personae']=t;}const k=join(a,'dispute.json');existsSync(k)&&(g['dispute']=JSON['parse'](readFileSync(k,'utf-8')));const l=join(a,'compliance.json');existsSync(l)&&(g['compliance']=JSON['parse'](readFileSync(l,'utf-8')));const m=join(a,'supply.json');existsSync(m)&&(g['supply']=JSON['parse'](readFileSync(m,'utf-8')));const n=join(a,'rules.json');existsSync(n)&&(g['rules']=JSON['parse'](readFileSync(n,'utf-8')));const o=join(a,'baselines.json');existsSync(o)&&(g['baselines']=JSON['parse'](readFileSync(o,'utf-8')));const p=join(a,'playbook.md');return existsSync(p)&&(g['playbook']={'category':e['name'],'content':readFileSync(p,'utf-8')}),g;}export function rescanPack(a){const b=join(resolveIndustryPackDir(),a);try{const c=loadPackFromDir(b);if(!c)return{'ok':![],'errors':['no\x20pack\x20found\x20for\x20\x27'+a+'\x27'],'registered':[]};return registerIndustryPack(c,!![]);}catch(d){return{'ok':![],'errors':['failed\x20to\x20rescan\x20pack\x20\x27'+a+'\x27:\x20'+d['message']],'registered':[]};}}export function resolveIndustryPackDir(){return process['env']['WOWOK_INDUSTRY_DIR']||getWowokIndustryDir();}export function scanDefaultIndustryPacks(){return seedBuiltinIndustryTemplates(),seedBuiltinTemplates(),seedBuiltinStrategyManuals(),ensureIndustryReadme(),ensureBuiltinModesAsPacks(),scanPacks(resolveIndustryPackDir());}export function seedBuiltinIndustryTemplates(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();for(const d of a){const e=join(c,d);if(existsSync(join(e,'manifest.json'))||existsSync(join(e,'pack.json')))continue;const f=scaffoldIndustryPack(d,c);if(f['ok'])b['push'](d);}return b;}export function seedBuiltinStrategyManuals(a=SUPPORTED_INDUSTRIES){const b=[],c=resolveIndustryPackDir();for(const d of a){const e=renderStrategyManual(d);if(!e)continue;const f=join(c,d,STRATEGY_MANUAL_FILENAME);try{const g=join(c,d);if(!existsSync(join(g,'manifest.json'))&&!existsSync(join(g,'pack.json'))){const j=scaffoldIndustryPack(d,c);if(!j['ok']){b['push']({'industry':d,'status':'error','path':f,'detail':j['errors']['join'](';\x20')});continue;}}if(!existsSync(f)){writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'written','path':f});continue;}const h=readFileSync(f,'utf-8'),i=classifyManualFile(d,h);if(i==='outdated')writeFileSync(f,e,'utf-8'),b['push']({'industry':d,'status':'updated','path':f});else{if(i==='current')b['push']({'industry':d,'status':'current','path':f});else i==='user_modified'?b['push']({'industry':d,'status':'skipped_user_modified','path':f,'detail':'strategy-manual.md\x20was\x20edited\x20locally;\x20keeping\x20user\x20content\x20and\x20not\x20upgrading'}):b['push']({'industry':d,'status':'skipped_user_file','path':f,'detail':'strategy-manual.md\x20exists\x20without\x20builtin\x20sentinel;\x20leaving\x20user\x20file\x20untouched'});}}catch(k){b['push']({'industry':d,'status':'error','path':f,'detail':k['message']});}}return b;}export const LAYER_FILE_SECTION={'match.json':'match','dispute.json':'dispute','compliance.json':'compliance','supply.json':'supply','rules.json':'rules','mode.json':'mode','baselines.json':'baselines'};export const PERSONAE_DIR='personae';function manifestSection(a){return{'pack':'industry-pack','name':a,'display_name':a,'version':'0.1.0','layers':['match','personae','dispute','compliance','supply','rules','playbook']};}function matchSection(a){return{'category':a,'hard_constraints':[],'soft_weights':{},'highlight_fields':[],'calendar_mode':'none','geo_mode':'strict','pricing_rules':[]};}function personaPerRole(a,b){return{'role':a,'industry':b,'long_term':{'identity':{'self_description':b+'\x20'+a},'preferences':{}},'current':{'strategy':[],'requirements':[],'rules':[],'spec':'','preferences':{}}};}function disputeSection(a){return{'category':a,'sla_tiers':[],'fault_rules':[]};}function complianceSection(a){return{'category':a,'prepay_mode':'','qualification':[],'disclosure':[],'refund_window':{'not_applicable':!![]}};}function supplySection(a){return{'category':a,'supplier_qualification':[],'first_order_policy':'','redundancy_required':![]};}function rulesSection(a){return{'category':a,'rules':[]};}export function buildPristineMergedPack(a){const b=PERSONA_ROLES['map'](c=>personaPerRole(c,a));return{'manifest':manifestSection(a),'match':matchSection(a),'personae':b,'dispute':disputeSection(a),'compliance':complianceSection(a),'supply':supplySection(a),'rules':rulesSection(a),'baselines':null,'mode':null};}export function industryReadmeContent(){return['#\x20WoWok\x20Industry\x20Packs','','>\x20This\x20folder\x20is\x20the\x20WoWok\x20industry\x20knowledge\x20root.\x20Each\x20sub-folder\x20is\x20one','>\x20industry\x20pack.\x20Pack\x20layers\x20are\x20registered\x20into\x20the\x20runtime\x20registry\x20and','>\x20consumed\x20on\x20demand\x20by\x20the\x20build/recommendation\x20tools\x20(merchant_guide,','>\x20recommend_industry,\x20…);\x20a\x20compact\x20strategy\x20summary\x20for\x20the\x20active','>\x20merchant/supplier\x20lens\x20is\x20injected\x20into\x20every\x20chat\x20turn.','','##\x20Business\x20model\x20—\x20DIRECT\x20SALES,\x20freedom\x20for\x20the\x20merchant','','**WoWok\x20takes\x20no\x20platform\x20commission.\x20A\x20merchant\x20pays\x20only\x20gas.**\x20This\x20is','the\x20product\x27s\x20core\x20positioning,\x20and\x20every\x20template,\x20manual\x20and\x20playbook\x20in','this\x20tree\x20is\x20written\x20under\x20it.','','Three\x20layers,\x20do\x20not\x20conflate\x20them:','','-\x20**L1\x20Protocol\x20—\x20never\x20extracts.**\x20The\x20framework\x20has\x20no\x20platform-take','\x20\x20concept\x20at\x20all:\x20every\x20`order_allocators`\x20sharing\x20item\x20is\x20configured\x20by','\x20\x20the\x20merchant\x20and\x20every\x20recipient\x20is\x20chosen\x20by\x20the\x20merchant.','-\x20**L2\x20Template\x20default\x20—\x20100%\x20to\x20the\x20merchant.**\x20Built-in\x20templates','\x20\x20demonstrate\x20the\x20most\x20efficient\x20P2P\x20form:\x20a\x20single\x20`Rate\x2010000`\x20leg\x20to','\x20\x20the\x20merchant\x27s\x20own\x20Entity,\x20zero\x20platform\x20leg.\x20Never\x20copy\x20an\x20incumbent','\x20\x20marketplace\x20split\x20(host\x20commission\x20+\x20guest\x20service\x20fee)\x20into\x20an','\x20\x20allocator\x20—\x20under\x20this\x20model\x20nobody\x20receives\x20it.','-\x20**L3\x20Merchant\x20freedom\x20—\x20a\x20fee\x20is\x20allowed.**\x20When\x20the\x20merchant\x20IS\x20the','\x20\x20aggregator\x20(a\x20chain,\x20a\x20multi-supplier\x20orchestrator,\x20a\x20consortium),\x20it','\x20\x20may\x20charge\x20its\x20own\x20service\x20fee.\x20Three\x20constraints\x20make\x20that\x20honest:','\x20\x201.\x20**Explicit\x20number.**\x20Never\x20an\x20implicit\x20remainder\x20such\x20as','\x20\x20\x20\x20\x20`commission\x20=\x20order\x20total\x20-\x20segment\x20sums`.\x20A\x20buyer\x20must\x20be\x20able\x20to','\x20\x20\x20\x20\x20compute\x20the\x20take\x20BEFORE\x20ordering.','\x20\x202.\x20**Explicit\x20non-empty\x20recipient\x20Entity**\x20the\x20buyer\x20can\x20see\x20pre-order.','\x20\x20\x20\x20\x20An\x20EMPTY\x20Entity\x20(`\x22\x22`)\x20silently\x20routes\x20the\x20share\x20to\x20the\x20deploying','\x20\x20\x20\x20\x20AI/host\x27s\x20own\x20account\x20(`ts-sdk/packages/wowok/src/w/local/index.ts:89-91`).','\x20\x203.\x20**No\x20mandatory\x20transit.**\x20The\x20organizer\x20pool\x20must\x20not\x20be\x20a\x20required','\x20\x20\x20\x20\x20waypoint\x20for\x20the\x20merchant\x27s\x20own\x20payout,\x20and\x20a\x20`Surplus`\x20leg\x20must','\x20\x20\x20\x20\x20never\x20be\x20how\x20the\x20fee\x20is\x20taken\x20—\x20an\x20uncapped\x20`Surplus`\x20sweeps','\x20\x20\x20\x20\x20the\x20entire\x20remaining\x20pool,\x20so\x20it\x20doubles\x20as\x20draining\x20the\x20pool.','','**Why\x20efficiency,\x20not\x20a\x20rate\x20cut.**\x20A\x20legacy\x20marketplace\x27s\x20edge\x20is\x20a\x20rate','cut.\x20WoWok\x27s\x20edge\x20is\x20that\x20a\x20merchant\x20keeps\x20the\x20whole\x20sale\x20AND\x20gets:','escrow\x20that\x20moves\x20only\x20between\x20the\x20two\x20parties,\x20an\x20independent\x20venue,','and\x20a\x20public\x20pre-order\x20outcome\x20ledger.\x20Compete\x20on\x20escrow/arbitration','value,\x20never\x20on\x20price.','','**Merchant-facing\x20audit\x20invariants**\x20(`template_scan`):','','-\x20`R-ECON-01`\x20any\x20`fee_params`\x20platform/commission\x20key\x20!=\x200\x20→\x20ERROR','-\x20`R-ECON-02`\x20fee\x20taken\x20as\x20an\x20implicit\x20remainder\x20/\x20`Surplus`\x20drain\x20→\x20ERROR','-\x20`R-ECON-03`\x20non-zero\x20third-party\x20share\x20with\x20an\x20EMPTY\x20recipient\x20→\x20ERROR','-\x20`R-ECON-04`\x20a\x20mandatory\x20transit\x20pool\x20on\x20the\x20payout\x20path\x20→\x20WARN','-\x20`R-ECON-05`\x20attribution-weighted\x20take\x20(attributed\x20>\x20base)\x20→\x20WARN','','##\x20Pack\x20structure\x20(unified\x20layout)','','Every\x20pack\x20is\x20exactly\x20two\x20files,\x20plus\x20an\x20optional\x20`templates/`\x20folder:','','-\x20**`<pack>/pack.json`**\x20—\x20machine-checkable\x20**settings\x20only**.\x20No\x20comments,','\x20\x20no\x20documentation.\x20One\x20section\x20per\x20layer\x20(see\x20below).','-\x20**`<pack>/playbook.md`**\x20—\x20human\x20strategy,\x20tone\x20and\x20field-tested\x20experience.','\x20\x20Registered\x20on\x20scan\x20and\x20read\x20ON\x20DEMAND\x20via\x20industry_pack_operation','\x20\x20(action=\x27get\x27);\x20it\x20OVERRIDES\x20built-in\x20industry\x20data\x20for\x20this\x20account.','-\x20**`<pack>/templates/*.md`**\x20—\x20archetype\x20templates\x20(see\x20the\x20Templates','\x20\x20section\x20below).\x20The\x2012\x20built-in\x20variants\x20are\x20seeded\x20here\x20automatically.','','All\x20field\x20explanations\x20live\x20in\x20THIS\x20file,\x20so\x20pack.json\x20stays\x20small\x20and\x20you','can\x20focus\x20on\x20configuration.\x20The\x20editor\x20also\x20validates\x20JSON\x20on\x20save\x20—\x20a\x20file','that\x20fails\x20to\x20parse\x20(or\x20a\x20pack.json\x20missing\x20its\x20manifest)\x20is\x20blocked.','','##\x20How\x20changes\x20take\x20effect','','1.\x20**Save**\x20in\x20the\x20Editor\x20writes\x20bytes\x20to\x20disk.','2.\x20**Scan**\x20(Industry\x20drawer)\x20re-registers\x20each\x20pack\x20into\x20the\x20runtime\x20AI','\x20\x20\x20registry\x20(and\x20SQLite\x20cache).\x20A\x20save\x20of\x20an\x20industry\x20file\x20already\x20runs','\x20\x20\x20Scan\x20automatically.','3.\x20**Next\x20AI\x20chat\x20turn**\x20the\x20registered\x20layers\x20are\x20available\x20to\x20the','\x20\x20\x20on-demand\x20tools\x20(and\x20the\x20merchant/supplier\x20strategy\x20summary\x20is\x20fresh','\x20\x20\x20in\x20the\x20persona\x20context),\x20so\x20the\x20AI\x20reasons\x20against\x20your\x20edited\x20rules','\x20\x20\x20from\x20that\x20point\x20onward.','','##\x20manifest\x20—\x20pack\x20metadata\x20+\x20layer\x20ENABLE\x20flags','','-\x20`name`:\x20snake_case\x20identifier,\x20must\x20match\x20the\x20folder\x20name.','-\x20`version`:\x20bump\x20after\x20editing\x20content\x20so\x20the\x20registry\x20treats\x20it\x20as\x20an\x20upgrade.','-\x20`display_name`:\x20user-visible\x20label.','-\x20`layers`:\x20which\x20sections\x20are\x20validated\x20and\x20registered\x20on\x20scan.\x20Legal','\x20\x20layer\x20names:\x20`match`,\x20`personae`,\x20`dispute`,\x20`compliance`,\x20`supply`,','\x20\x20`rules`,\x20`baselines`,\x20`playbook`\x20(plus\x20`mode`\x20when\x20you\x20add\x20a\x20driving','\x20\x20mode).\x20Remove\x20a\x20layer\x20name\x20to\x20DISABLE\x20it\x20(the\x20section\x20stays\x20in','\x20\x20pack.json\x20but\x20is\x20ignored).','','##\x20match\x20—\x20category-match\x20rules','','Decides\x20whether\x20an\x20order/service/account\x20belongs\x20to\x20this\x20industry\x20pack:','-\x20`hard_constraints`:\x20array\x20of\x20REQUIRED\x20predicates;\x20ALL\x20must\x20match\x20before\x20the','\x20\x20pack\x20is\x20considered.\x20Example:','\x20\x20`[{\x20key:\x20\x27order.metadata.service_kind\x27,\x20equals:\x20\x27food_onsite\x27\x20}]`','-\x20`soft_weights`:\x20dict\x20`<heuristic_key:\x20number\x200..1>`;\x20higher\x20=\x20stronger\x20signal.','-\x20`pricing_rules`:\x20pricing\x20modes\x20this\x20industry\x20requires.','-\x20`highlight_fields`:\x20dot-paths\x20surfaced\x20in\x20the\x20UI\x20as\x20important\x20info.','-\x20`geo_mode`:\x20`\x27strict\x27`\x20(region\x20must\x20match)\x20|\x20`\x27none\x27`\x20(ignore\x20region).','-\x20`calendar_mode`:\x20`\x27seasonal\x27`\x20|\x20`\x27weekday\x27`\x20|\x20`\x27none\x27`.','','##\x20personae\x20—\x20per-role\x20AI\x20personas','','One\x20persona\x20per\x20role\x20(`merchant`,\x20`customer`,\x20`supplier`,\x20`collaborator`,','`arbitrator`,\x20`prospect`).\x20The\x20AI\x20uses\x20them\x20to\x20role-play\x20negotiation\x20posture:','-\x20`long_term`:\x20stable\x20properties\x20—\x20`identity.self_description`\x20(free-text\x20bio),','\x20\x20`identity.region/languages`,\x20`preferences`\x20(`<key:\x20string[]>`).','-\x20`current`:\x20per-negotiation\x20posture\x20—\x20`strategy`\x20(moves\x20to\x20make),','\x20\x20`requirements`\x20(non-negotiable\x20demands),\x20`rules`\x20(constraints/axioms),','\x20\x20`spec`\x20(free-form\x20text),\x20`preferences`\x20(per-turn\x20overrides).','','##\x20dispute\x20—\x20SLA\x20tiers\x20+\x20fault\x20assignment','','-\x20`sla_tiers[]`:\x20response/remedy\x20windows\x20per\x20severity\x20level.','\x20\x20Example:\x20`{\x20level:\x20\x27L1\x27,\x20response_hours:\x2024,\x20remedy:\x20\x27reply\x27\x20}`','-\x20`fault_rules[]`:\x20automatic\x20fault\x20attribution\x20—\x20a\x20condition\x20plus\x20the\x20side','\x20\x20that\x20bears\x20fault\x20(`merchant`/`customer`/`supplier`/`operator`/`shared`).','\x20\x20Example:\x20`{\x20when:\x20{\x20evidence_has:\x20[\x27late\x20delivery\x20photo\x27]\x20},\x20assign_to:\x20\x27merchant\x27,\x20weight:\x201.0\x20}`','','##\x20compliance\x20—\x20hard\x20requirements\x20before\x20checkout','','-\x20`prepay_mode`:\x20`\x27\x27`\x20|\x20`\x27full\x27`\x20|\x20`\x27partial\x27`\x20|\x20`\x27deposit\x27`.','-\x20`qualification[]`:\x20licenses/certifications\x20a\x20merchant\x20must\x20hold.','\x20\x20Example:\x20`{\x20label:\x20\x27Food\x20Service\x20License\x27,\x20required:\x20true,\x20region:\x20\x27CN\x27\x20}`','-\x20`disclosure[]`:\x20text\x20the\x20merchant\x20MUST\x20show\x20buyers\x20up-front.','-\x20`refund_window`:\x20`{\x20days:\x20number,\x20not_applicable:\x20boolean,\x20exceptions:\x20[...]\x20}`','','##\x20supply\x20—\x20supply-chain\x20/\x20supplier\x20qualification','','-\x20`supplier_qualification[]`:\x20same\x20shape\x20as\x20compliance\x20qualifications,\x20but','\x20\x20evaluated\x20on\x20the\x20SUPPLIER\x20side\x20(multi-party\x20orders).','-\x20`first_order_policy`:\x20policy\x20string\x20on\x20the\x20first\x20order\x20from\x20a\x20new\x20supplier','\x20\x20(e.g.\x20`\x27sample-only\x27`,\x20`\x27reduced-quantity\x27`).','-\x20`redundancy_required`:\x20true\x20=\x20require\x20≥2\x20eligible\x20suppliers\x20before\x20accepting','\x20\x20an\x20order\x20(mitigates\x20single-sourcing).','','##\x20rules\x20—\x20declarative\x20machine-checked\x20rules','','Each\x20rule\x20is\x20an\x20AST\x20node\x20compiled\x20into\x20the\x20evaluation\x20engine:','`{\x20id:\x20\x27rule_...\x27,\x20when:\x20<bool-condition>,\x20then:\x20\x27reject\x27\x20|\x20\x27warn\x27\x20|\x20\x27flag\x27,\x20message:\x20\x27Text\x27\x20}`','Use\x20`rules`\x20for\x20rules\x20that\x20must\x20be\x20machine-checked;\x20put\x20human\x20strategy\x20in','`playbook.md`.','','##\x20baselines\x20—\x20judgment\x20baselines\x20overlay\x20(Q12)','','`baselines`\x20carries\x20a\x20PARTIAL\x20judgment\x20baselines\x20document\x20(same\x20shape\x20as','the\x20user\x27s\x20judgment.json).\x20It\x20is\x20merged\x20into\x20the\x20judgment\x20chain','BETWEEN\x20the\x20factory\x20document\x20and\x20the\x20persona\x20fragment:','','\x20\x20\x20\x20factory\x20<\x20pack\x20baselines\x20<\x20persona\x20fragment\x20<\x20user\x20document\x20<\x20session\x20overrides','','A\x20pack\x20may\x20RETUNE\x20factory\x20parameters\x20or\x20DISABLE\x20factory\x20rules','(`enabled:\x20false`\x20—\x20a\x20disable\x20trace\x20is\x20recorded).\x20It\x20can\x20NEVER\x20invent\x20new','dimensions/rules\x20or\x20delete\x20factory\x20entries:\x20only\x20keys\x20and\x20ids\x20that\x20exist','in\x20the\x20factory\x20document\x20are\x20accepted.\x20Tuning\x20example:','','```json','\x22baselines\x22:\x20{','\x20\x20\x22version\x22:\x201,','\x20\x20\x22evaluation\x22:\x20{\x20\x22severity_deduction\x22:\x20{\x20\x22critical\x22:\x2040\x20}\x20},','\x20\x20\x22monitor\x22:\x20{\x20\x22thresholds\x22:\x20{\x20\x22messenger_timeout_hours\x22:\x2012\x20}\x20}','}','```','','Disabling\x20a\x20factory\x20rule\x20(the\x20rule\x20id\x20must\x20exist,\x20e.g.\x20in\x20the\x20`util`','domain):','','```json','{\x20\x22rules\x22:\x20{\x20\x22domains\x22:\x20{\x20\x22util\x22:\x20{\x20\x22rules\x22:\x20[','\x20\x20{\x20\x22rule_id\x22:\x20\x22R-UTIL-03\x22,\x20\x22enabled\x22:\x20false\x20}',']\x20}\x20}\x20}\x20}','```','','A\x20misspelled\x20dimension\x20or\x20an\x20invented\x20rule\x20id\x20is\x20REJECTED\x20at\x20registration','(and\x20on\x20every\x20scan/rescan)\x20with\x20a\x20visible\x20error\x20—\x20the\x20last\x20good','registration\x20stays\x20in\x20force\x20until\x20the\x20fragment\x20is\x20fixed.','','##\x20mode\x20—\x20IndustryMode\x20(deep\x20shape)','','Not\x20scaffolded\x20by\x20default.\x20Add\x20it\x20when\x20you\x20need\x20a\x20full\x20driving\x20mode\x20for\x20the','industry,\x20or\x20ask\x20the\x20AI:\x20\x22help\x20me\x20fill\x20mode\x20for\x20<industry>\x22.','','Registered\x20into\x20`IndustryModeRegistry`\x20on\x20scan\x20(manifest\x20must\x20list\x20the','`mode`\x20layer).\x20A\x20pack\x20mode\x20with\x20the\x20same\x20name\x20as\x20a\x20builtin\x20replaces\x20it\x20when','the\x20pack\x20version\x20changes\x20or\x20on\x20a\x20forced\x20rescan.','','###\x20How\x20the\x20mode\x20is\x20consumed','','-\x20**Service\x20build\x20(priors)**:\x20`merchant_guide`\x20resolves\x20the\x20confirmed','\x20\x20industry\x20to\x20a\x20mode\x20(user\x20mode\x20first,\x20then\x20pack\x20mode,\x20then\x20builtin)\x20and','\x20\x20feeds\x20`machine_shape`\x20/\x20`guards`\x20/\x20`allocator`\x20/\x20`key_risk`\x20into\x20the','\x20\x20SemanticObjectGraph\x20build.','-\x20**Evaluation**:\x20the\x20metric\x20+\x20constraint\x20registries\x20score\x20the\x20mode','\x20\x20(risk/benefit\x200-100,\x20hard\x20violations\x20block\x20adoption).\x20Custom\x20metrics\x20and','\x20\x20constraints\x20registered\x20via\x20`industry_pack_operation`\x20participate\x20too.','-\x20**Recommendation**:\x20`recommend_industry`\x20matches\x20trait\x20similarity\x20and,','\x20\x20when\x20a\x20merchant\x20strategy\x20is\x20given,\x20re-ranks\x20by\x20lever\x20alignment\x20(70%','\x20\x20similarity\x20+\x2030%\x20alignment).','','###\x20Field\x20reference','','-\x20**Identity**:\x20`name`\x20(snake_case),\x20`display_name`,\x20`version`\x20(e.g.\x20`v1`),','\x20\x20`source`\x20(`builtin`\x20|\x20`custom`).','-\x20`traits`:\x2010-dimension\x20industry\x20trait\x20vector\x20(logistics,\x20cycle,\x20deposit,','\x20\x20regulatory\x20intensity,\x20...).\x20Drives\x20`recommend_industry`\x20similarity.','-\x20`machine_shape`:\x20Machine\x20node\x20topology\x20—\x20`[{\x20name,\x20role\x20}]`.\x20Node\x20names\x20are','\x20\x20business\x20states.\x20R-M1-11:\x20NEVER\x20model\x20refund/dispute\x20terminals','\x20\x20(`refunded`,\x20`disputed`,\x20`arb_*`)\x20as\x20nodes\x20—\x20disputes\x20flow\x20through','\x20\x20Service.arbitrations\x20independently;\x20route\x20refunds\x20via\x20the\x20Allocator','\x20\x20triggered\x20by\x20business\x20states\x20(`cancelled`,\x20`returned`).','-\x20`guards`:\x20`[{\x20template_id,\x20host,\x20purpose\x20}]`\x20—\x20guard\x20templates\x20to\x20attach.','\x20\x20`host`\x20is\x20one\x20of\x20`service`\x20|\x20`machine`\x20|\x20`reward`\x20|\x20`repository`\x20|','\x20\x20`arbitration`.','-\x20`allocator`:\x20`{\x20recipient,\x20count,\x20mode,\x20description\x20}`\x20—\x20fund\x20split.','\x20\x20`recipient`:\x20`signer`\x20|\x20`entity`;\x20`count`\x20>\x201\x20switches\x20to\x20multi-party','\x20\x20distribution;\x20`mode`:\x20`surplus`\x20|\x20`rate`\x20|\x20`milestone`.','-\x20`risk_checks`\x20/\x20`needs`:\x20buyer-side\x20due-diligence\x20entries\x20surfaced\x20in','\x20\x20prospect\x20evaluation.','-\x20`flywheel`:\x20acquisition\x20flywheel\x20—\x20`rewardStrategy`\x20/\x20`discountStrategy`','\x20\x20/\x20`trustSellingPoints`.\x20A\x20concrete\x20(non-`User-defined`)\x20strategy\x20turns','\x20\x20the\x20`reward`/`discount`\x20levers\x20on\x20for\x20strategy\x20alignment.','-\x20`key_risk`\x20(string)\x20/\x20`build_notes`\x20(string[]):\x20the\x20headline\x20risk\x20and','\x20\x20actionable\x20build\x20guidance\x20shown\x20to\x20the\x20merchant.','-\x20`capabilities_used`:\x20CapabilityCard\x20IDs\x20(e.g.\x20`guard.validate_buy`,','\x20\x20`machine.node_topology`,\x20`allocation.distribute_milestone`).\x20Powers\x20the','\x20\x20`buy_guard`\x20/\x20`machine_design`\x20levers\x20and\x20constraint\x20checks.','-\x20`config_overrides`:\x20per-object\x20field\x20defaults,\x20e.g.','\x20\x20`{\x20service:\x20{\x20engagement_type:\x20\x27milestone\x27\x20},\x20machine:\x20{\x20wip_required:\x20true\x20}\x20}`.','-\x20`config_override_rules`:\x20conditional\x20overrides\x20—','\x20\x20`{\x20object_type,\x20field_path,\x20value\x20|\x20{\x20intent_contains,\x20then_value,\x20else_value\x20}\x20}`.','-\x20`expected_benefits`:\x20`[{\x20metric,\x20expected_value,\x20evidence\x20}]`\x20—\x20what\x20the','\x20\x20mode\x20is\x20supposed\x20to\x20buy\x20you.','-\x20`risk_appetite`:\x20`conservative`\x20|\x20`balanced`\x20|\x20`aggressive`\x20(thresholds','\x20\x20for\x20the\x20risk/benefit\x20verdict).','-\x20`risk_constraints`:\x20`{\x20require_arbitration,\x20require_compensation_fund,','\x20\x20require_wip_evidence,\x20max_single_transaction?,','\x20\x20compensation_fund_coverage_ratio?,\x20other_constraints?\x20}`.\x20Coverage\x20ratio','\x20\x20multiplies\x20max\x20single\x20order\x20to\x20size\x20the\x20compensation\x20fund\x20(retail\x205,','\x20\x20rental\x2010,\x20subscription\x203;\x20default\x205).','-\x20`applicable_conditions`:\x20`{\x20business_scale,\x20min_daily_orders?,','\x20\x20other_conditions?\x20}`\x20—\x20when\x20the\x20mode\x20fits.','-\x20`similar_industries`\x20/\x20`novel_capabilities`:\x20migration\x20hints.','-\x20`disabled_builtin_constraints`:\x20builtin\x20constraint\x20IDs\x20this\x20mode','\x20\x20deliberately\x20opts\x20out\x20of\x20(e.g.\x20retail_d2c\x20skips\x20`require_arbitration`).','\x20\x20Custom\x20constraints\x20are\x20never\x20skipped.','','###\x20Persona\x20integration\x20(strategy\x20→\x20levers)','','The\x20personae\x20section\x27s\x20`current.strategy`\x20statements\x20are\x20bridged\x20into\x20mode','ranking\x20(value\x20intent\x20↔\x20game\x20path\x20unification).\x20Deterministic\x20mapping\x20—','\x22enumerable\x20→\x20MCP,\x20not\x20prompt\x22:','','-\x20`sales_priority`\x20(volume\x20first)\x20→\x20levers\x20`discount`\x20+\x20`reward`','-\x20`profit_priority`\x20(margin\x20first)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','-\x20`buyer_screening`\x20(qualify\x20buyers)\x20→\x20lever\x20`buy_guard`','-\x20`gross_margin_control`\x20(margin\x20band)\x20→\x20levers\x20`discount`\x20+\x20`machine_design`','','A\x20mode\x20supports\x20a\x20lever\x20when\x20its\x20data\x20says\x20so:\x20`guard.validate_buy`','capability\x20or\x20a\x20buy-guard\x20template\x20enables\x20`buy_guard`;\x20a\x20concrete','flywheel\x20reward/discount\x20strategy\x20enables\x20`reward`/`discount`;\x20a','non-empty\x20`machine_shape`\x20with\x20`machine.node_topology`\x20enables','`machine_design`.\x20Pass\x20strategy\x20text\x20to\x20`recommend_industry`\x20and\x20each','recommendation\x20reports\x20`strategy_alignment`\x20(matched/missing\x20levers).','','##\x20custom-registry.json\x20—\x20your\x20custom\x20rules\x20(managed\x20by\x20the\x20AI)','','This\x20file\x20stores\x20customizations\x20that\x20apply\x20to\x20EVERY\x20industry\x20pack:','-\x20`metrics`\x20—\x20extra\x20scoring\x20dimensions\x20you\x20asked\x20the\x20AI\x20to\x20evaluate','\x20\x20(e.g.\x20\x22add\x20an\x20environmental-impact\x20metric\x20to\x20mode\x20evaluation\x22).','-\x20`constraints`\x20—\x20hard\x20rules\x20a\x20mode\x20must\x20satisfy\x20(e.g.\x20\x22must\x20always','\x20\x20include\x20arbitration\x22).','-\x20`user_modes`\x20—\x20your\x20own\x20industry\x20modes\x20derived\x20from\x20the\x20built-ins.','','You\x20normally\x20never\x20touch\x20this\x20file:\x20just\x20ask\x20the\x20AI\x20in\x20chat\x20(for','example\x20\x22register\x20a\x20custom\x20metric\x20...\x22),\x20and\x20it\x20writes\x20the\x20entry','here\x20for\x20you.\x20Deleting\x20an\x20entry\x20removes\x20that\x20customization.\x20If\x20you','edit\x20it\x20by\x20hand\x20anyway,\x20changes\x20take\x20effect\x20without\x20a\x20restart.','An\x20absent\x20or\x20empty\x20file\x20is\x20normal\x20—\x20it\x20simply\x20means\x20you\x20have\x20not','created\x20any\x20custom\x20metrics,\x20constraints\x20or\x20modes\x20yet.','','##\x20Templates\x20(`<pack>/templates/*.md`)','','Each\x20template\x20.md\x20has\x20two\x20parts:','','-\x20**Frontmatter**\x20(the\x20`---\x20...\x20---`\x20block):\x20machine-readable\x20settings\x20—','\x20\x20`id`,\x20`industry`,\x20`variant`,\x20`machine_shape`,\x20`guards`,\x20`allocator`,','\x20\x20`fee_params`,\x20…\x20In\x20the\x20client\x27s\x20VIEW\x20mode\x20these\x20render\x20as\x20a\x20table','\x20\x20(hover\x20a\x20key\x20for\x20its\x20meaning);\x20EDIT\x20mode\x20shows\x20the\x20raw\x20text.','-\x20**Markdown\x20body**:\x20free-form\x20guidance\x20for\x20the\x20AI\x20(Key\x20risk,','\x20\x20Differences,\x20Build\x20notes,\x20…).','','###\x20Impact\x20and\x20risks\x20of\x20editing\x20templates','','-\x20The\x20frontmatter\x20is\x20**strictly\x20validated\x20on\x20every\x20load**\x20by\x20the\x20AI','\x20\x20runtime\x20(allowed\x20keys,\x20value\x20types,\x20ranges,\x20`id`/`industry`/`variant`','\x20\x20consistency\x20with\x20the\x20file\x20location).\x20A\x20template\x20that\x20fails\x20validation','\x20\x20is\x20**skipped\x20with\x20a\x20loud\x20error**\x20—\x20tools\x20that\x20read\x20templates\x20report','\x20\x20the\x20file\x20and\x20the\x20exact\x20field\x20problem\x20until\x20you\x20fix\x20it.\x20Guidance\x20in','\x20\x20the\x20broken\x20template\x20will\x20NOT\x20reach\x20the\x20AI\x20while\x20it\x20is\x20invalid.','-\x20The\x20**client\x20editor\x20validates\x20on\x20save**\x20(same\x20rules)\x20and\x20blocks\x20the','\x20\x20write,\x20so\x20most\x20mistakes\x20never\x20reach\x20disk.\x20Edits\x20made\x20OUTSIDE\x20the','\x20\x20client\x20bypass\x20this\x20gate\x20—\x20run\x20a\x20Scan\x20afterwards\x20and\x20watch\x20for\x20errors.','-\x20Keep\x20the\x20Markdown\x20body\x20free-form\x20—\x20it\x20is\x20never\x20validated.\x20Breaking','\x20\x20the\x20`---`\x20structure\x20is\x20what\x20matters.','','###\x20How\x20to\x20recover\x20a\x20broken\x20template','','1.\x20Fix\x20the\x20field\x20named\x20in\x20the\x20error\x20(type/range/enum\x20mismatch),\x20or','2.\x20**Delete\x20the\x20.md\x20file**\x20—\x20the\x20built-in\x20version\x20is\x20re-seeded','\x20\x20\x20automatically\x20at\x20the\x20next\x20startup\x20/\x20template\x20scan\x20(seeding\x20never','\x20\x20\x20overwrites\x20an\x20existing\x20file,\x20so\x20your\x20other\x20edits\x20survive).','3.\x20Right-click\x20a\x20file\x20in\x20the\x20Industry\x20drawer\x20→\x20*Reset*\x20restores\x20the','\x20\x20\x20pristine\x20seeded\x20version\x20too.','','##\x20Reset','','Right-click\x20any\x20file/pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20and\x20choose\x20*Reset*','to\x20restore\x20the\x20pristine\x20template\x20at\x20any\x20time.','']['join']('\x0a');}export function ensureIndustryReadme(){const a=resolveIndustryPackDir();mkdirSync(a,{'recursive':!![]});const b=join(a,'README.md');return writeFileSync(b,industryReadmeContent(),'utf-8'),b;}export function scaffoldIndustryPack(a,b){const c=join(b??resolveIndustryPackDir(),a),d=[],e=[];if(!/^[a-z][a-z0-9_]*$/['test'](a))return{'ok':![],'dir':c,'files':d,'errors':['industry\x20name\x20\x27'+a+'\x27\x20must\x20be\x20lowercase\x20snake_case\x20(a-z,\x200-9,\x20_)']};try{mkdirSync(c,{'recursive':!![]}),ensureIndustryReadme();const f=buildPristineMergedPack(a);return writeFileSync(join(c,'pack.json'),JSON['stringify'](f,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(c,'playbook.md'),playbookTemplate(a)),d['push']('playbook.md'),{'ok':!![],'dir':c,'files':d,'errors':e};}catch(g){return{'ok':![],'dir':c,'files':d,'errors':['scaffold\x20failed:\x20'+g['message']]};}}export function readMergedPackIfPresent(a){const b=join(a,'pack.json');if(!existsSync(b))return null;try{const c=readFileSync(b,'utf-8');return JSON['parse'](c);}catch{return null;}}function playbookTemplate(a){return['#\x20'+a+'\x20—\x20Industry\x20Playbook','','>\x20📘\x20This\x20file\x20captures\x20human\x20business\x20intelligence\x20for\x20the\x20`'+a+'`','>\x20industry.\x20Content\x20here\x20is\x20READ\x20BY\x20THE\x20AI\x20AS\x20CONTEXT\x20on\x20every\x20turn,','>\x20and\x20OVERRIDES\x20WoWok\x27s\x20generic\x20built-in\x20industry\x20data/rules\x20for\x20this','>\x20account.\x20The\x20companion\x20`pack.json`\x20file\x20stores\x20machine-checkable','>\x20rules;\x20THIS\x20file\x20stores\x20human\x20strategy,\x20tone,\x20experience,\x20and\x20ethics.','','>\x20💡\x20Hint\x20for\x20the\x20AI:\x20when\x20the\x20user\x20asks\x20a\x20question\x20about\x20\x22how\x20to','>\x20handle\x20'+a+'\x22\x20or\x20\x22what\x20should\x20I\x20do?\x22,\x20check\x20this\x20file\x20first\x20for\x20the','>\x20merchant/customer\x20voice,\x20then\x20fall\x20back\x20to\x20your\x20built-in\x20data.\x20Cite','>\x20section\x20titles\x20in\x20your\x20reply\x20so\x20the\x20user\x20knows\x20where\x20advice\x20comes\x20from.','','##\x20Business\x20model\x20—\x20direct\x20sales','','WoWok\x20takes\x20no\x20platform\x20commission\x20—\x20a\x20merchant\x20in\x20'+a+'\x20pays\x20only','gas,\x20and\x20the\x20default\x20payout\x20gives\x20the\x20merchant\x20the\x20whole\x20sale.\x20Never\x20copy','an\x20incumbent\x20marketplace\x20split\x20into\x20an\x20allocator:\x20that\x20share\x20is\x20displaced','by\x20design,\x20not\x20a\x20parameter,\x20and\x20nobody\x20would\x20receive\x20it.\x20If\x20the\x20merchant','IS\x20the\x20aggregator\x20(a\x20chain,\x20a\x20multi-supplier\x20orchestrator,\x20a\x20consortium)','it\x20may\x20charge\x20its\x20OWN\x20fee,\x20but\x20only\x20with:\x20an\x20explicit\x20number\x20the\x20buyer','can\x20compute\x20before\x20ordering;\x20an\x20explicit\x20NON-EMPTY\x20recipient\x20Entity\x20(an','empty\x20one\x20silently\x20routes\x20the\x20share\x20to\x20the\x20deploying\x20AI/host\x20—\x20see','`ts-sdk/packages/wowok/src/w/local/index.ts:89-91`);\x20and\x20no\x20mandatory\x20transit\x20pool\x20on\x20the','payout\x20path\x20—\x20never\x20a\x20fee\x20via\x20a\x20`Surplus`\x20leg,\x20which\x20uncapped\x20sweeps','the\x20entire\x20remaining\x20pool\x20and\x20so\x20doubles\x20as\x20draining\x20the\x20pool.\x20Compete\x20on','escrow/arbitration\x20value,\x20not\x20price.','','>\x20Rule\x20of\x20thumb\x20for\x20everything\x20below:\x20any\x20fee,\x20cut\x20or\x20margin\x20recorded\x20in','>\x20the\x20Experience\x20and\x20Strategy\x20sections\x20is\x20MERCHANT\x20REVENUE\x20—\x20an\x20explicit,','>\x20disclosed\x20number\x20in\x20an\x20allocator\x20leg\x20with\x20a\x20non-empty\x20recipient\x20Entity.','>\x20It\x20is\x20never\x20a\x20platform\x20share,\x20and\x20it\x20must\x20never\x20be\x20an\x20implicit\x20remainder','>\x20(order\x20total\x20minus\x20segment\x20sums)\x20or\x20a\x20`Surplus`\x20entry.','','##\x20Experience\x20(Field-Tested\x20Rules\x20of\x20Thumb)','','>\x20Write\x20what\x20actually\x20works\x20in\x20this\x20industry\x20—\x20not\x20what\x20textbooks\x20say.','>\x20Short\x20bullet\x20points\x20preferred;\x20the\x20AI\x20reads\x20them\x20as\x20axioms.\x20Include','>\x20specific\x20numbers\x20when\x20you\x20have\x20them.','','-\x20(Example)\x20\x22Catering:\x20if\x20the\x20event\x20starts\x20before\x2010:00,\x20assume\x20breakfast\x20service\x20too\x20—\x20upsell\x20it\x20proactively.\x22','-\x20(Example)\x20\x22Common\x20pitfall:\x20last-minute\x20menu\x20swaps\x20on\x20Fridays\x20—\x20require\x20a\x20written\x20change\x20request\x2048\x20h\x20before\x20the\x20event,\x20or\x20charge\x20YOUR\x20OWN\x20disclosed\x2015%\x20change\x20fee\x20(merchant\x20revenue,\x20not\x20a\x20platform\x20take;\x20explicit\x20number,\x20non-empty\x20recipient\x20Entity,\x20declared\x20before\x20ordering).\x22','-\x20(Add\x20more\x20below\x20—\x20delete\x20the\x20examples\x20above\x20when\x20you\x20have\x20real\x20ones.)','','##\x20Strategy\x20(Competitive\x20/\x20Game-Theory)','','>\x20How\x20should\x20each\x20role\x20act\x20in\x20a\x20negotiation\x20/\x20dispute\x20/\x20supplier','>\x20relationship?\x20Think\x20in\x20\x22always\x20/\x20never\x20/\x20depends-on-X\x22\x20rules,\x20and\x20call','>\x20out\x20the\x20trade-offs.','','-\x20Merchant\x20strategy:\x20(Add\x20how\x20a\x20merchant\x20in\x20this\x20industry\x20should\x20act\x20—\x20price\x20anchoring,\x20which\x20concessions\x20to\x20give\x20early\x20vs\x20late,\x20what\x20to\x20never\x20concede\x20on.)','-\x20Customer\x20strategy:\x20(Add\x20what\x20a\x20smart\x20customer\x20should\x20push\x20for.)','-\x20Dispute\x20strategy:\x20(Add\x20when\x20to\x20settle\x20fast\x20vs\x20when\x20to\x20fight\x20for\x20full\x20evidence\x20+\x20arbitration\x20—\x20call\x20out\x20the\x20escalation\x20thresholds.)','','##\x20Personalization\x20(Tone,\x20Brand,\x20Ethics,\x20Red\x20Lines)','','-\x20Tone\x20/\x20voice:\x20(Write\x20one\x20sentence\x20describing\x20the\x20exact\x20conversational\x20voice\x20this\x20account\x20should\x20use\x20—\x20casual,\x20formal,\x20technical,\x20etc.)','-\x20Brand\x20rules:\x20(Add\x20logo,\x20link-out\x20style,\x20forbidden\x20terminology,\x20always-include\x20phrases,\x20etc.)','-\x20Red\x20lines:\x20(Add\x20non-negotiables.\x20Example:\x20\x22Never\x20make\x20a\x20refund\x20promise\x20larger\x20than\x2030%\x20without\x20arbitration\x20evidence.\x22)','-\x20Ethics:\x20(Add\x20ethical\x20guardrails.\x20Example:\x20\x22If\x20a\x20customer\x20appears\x20intoxicated,\x20refuse\x20service\x20and\x20refer\x20to\x20a\x20supervisor.\x22)','','##\x20Playbook\x20Maintenance','','>\x20You\x20don\x27t\x20need\x20to\x20be\x20perfect\x20on\x20day\x20one.\x20After\x20every\x20real\x20deal,\x20add\x20a','>\x20bullet\x20to\x20the\x20above\x20sections\x20with\x20what\x20worked\x20/\x20what\x20failed.\x20Every','>\x20entry\x20improves\x20the\x20AI\x27s\x20future\x20decisions.','','>\x20Right-click\x20the\x20file\x20or\x20this\x20pack\x20folder\x20in\x20the\x20Industry\x20drawer\x20at','>\x20any\x20time\x20and\x20choose\x20\x22Reset\x22\x20to\x20restore\x20this\x20annotated\x20template.','']['join']('\x0a');}export function locatePackAndRemainder(a){const b=a['replace'](/^[\\/]+/,'')['replace'](/[\\/]+$/,'');if(!b)return null;const [c,...d]=b['split'](/[\\/]+/);if(!c)return null;return{'packName':c,'remainder':d['join']('/')};}export function resetIndustryPath(a,b){const c=[],d=[],f=b??resolveIndustryPackDir(),g=locatePackAndRemainder(a),h=a;if(!g)return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['invalid\x20reset\x20path\x20\x27'+a+'\x27']};const {packName:i,remainder:j}=g,k=join(f,i);if(!existsSync(k))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20directory\x20\x27'+i+'\x27\x20does\x20not\x20exist']};if(!/^[a-z][a-z0-9_]*$/['test'](i))return{'ok':![],'layout':'merged','target':h,'restored_files':[],'errors':['pack\x20name\x20\x27'+i+'\x27\x20is\x20not\x20a\x20valid\x20snake_case\x20identifier']};const l=readMergedPackIfPresent(k),n=l?'merged':'legacy';if(j==='')try{mkdirSync(k,{'recursive':!![]});const s=buildPristineMergedPack(i);return writeFileSync(join(k,'pack.json'),JSON['stringify'](s,null,0x2)+'\x0a'),d['push']('pack.json'),writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':'merged','target':h,'restored_files':d,'errors':c};}catch(t){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['pack\x20reset\x20failed:\x20'+t['message']]};}const o=j['split']('/')['slice'](-0x1)[0x0],p=j==='playbook.md',q=j['startsWith'](PERSONAE_DIR+'/')&&o['endsWith']('.json');if(n==='merged'){if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(v){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['playbook\x20reset\x20failed:\x20'+v['message']]};}const u=LAYER_FILE_SECTION[j];if(u)try{const w=readMergedPackIfPresent(k)??buildPristineMergedPack(i);switch(u){case'match':w['match']=matchSection(i);break;case'dispute':w['dispute']=disputeSection(i);break;case'compliance':w['compliance']=complianceSection(i);break;case'supply':w['supply']=supplySection(i);break;case'rules':w['rules']=rulesSection(i);break;case'mode':w['mode']=null;break;}return writeFileSync(join(k,'pack.json'),JSON['stringify'](w,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(x){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['section\x20reset\x20failed:\x20'+x['message']]};}if(q){const y=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](y))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20role\x20\x27'+y+'\x27']};try{const z=readMergedPackIfPresent(k)??buildPristineMergedPack(i),A=z['personae']&&Array['isArray'](z['personae'])?[...z['personae']]:[],B=A['findIndex'](D=>D['role']===y),C=personaPerRole(y,i);if(B>=0x0)A[B]=C;else A['push'](C);return z['personae']=A,writeFileSync(join(k,'pack.json'),JSON['stringify'](z,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(D){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['persona\x20reset\x20failed:\x20'+D['message']]};}}if(j==='manifest.json'||j==='manifest')try{const E=readMergedPackIfPresent(k)??buildPristineMergedPack(i);return E['manifest']=manifestSection(i),writeFileSync(join(k,'pack.json'),JSON['stringify'](E,null,0x2)+'\x0a'),d['push']('pack.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(F){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['manifest\x20reset\x20failed:\x20'+F['message']]};}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['path\x20\x27'+j+'\x27\x20is\x20not\x20a\x20standard\x20section\x20file\x20of\x20pack\x20\x27'+i+'\x27.\x20Reset\x20is\x20only\x20provided\x20for\x20pack.json\x20standard\x20sections\x20and\x20playbook.md.']};}if(p)try{return writeFileSync(join(k,'playbook.md'),playbookTemplate(i)),d['push']('playbook.md'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(G){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20playbook\x20reset\x20failed:\x20'+G['message']]};}if(j==='manifest.json')try{const H=manifestSection(i);return writeFileSync(join(k,'manifest.json'),JSON['stringify'](H,null,0x2)+'\x0a'),d['push']('manifest.json'),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(I){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20manifest\x20reset\x20failed:\x20'+I['message']]};}const r=LAYER_FILE_SECTION[j];if(r)try{let J='';switch(r){case'match':J=JSON['stringify'](matchSection(i),null,0x2)+'\x0a';break;case'dispute':J=JSON['stringify'](disputeSection(i),null,0x2)+'\x0a';break;case'compliance':J=JSON['stringify'](complianceSection(i),null,0x2)+'\x0a';break;case'supply':J=JSON['stringify'](supplySection(i),null,0x2)+'\x0a';break;case'rules':J=JSON['stringify'](rulesSection(i),null,0x2)+'\x0a';break;case'mode':J=JSON['stringify']({},null,0x2)+'\x0a';break;}return writeFileSync(join(k,j),J),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(K){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20section\x20reset\x20failed:\x20'+K['message']]};}if(q){const L=o['replace'](/\.json$/,'');if(!PERSONA_ROLES['includes'](L))return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['unknown\x20persona\x20\x27'+L+'\x27']};try{return writeFileSync(join(k,j),JSON['stringify'](personaPerRole(L,i),null,0x2)+'\x0a'),d['push'](j),{'ok':!![],'layout':n,'target':h,'restored_files':d,'errors':c};}catch(M){return{'ok':![],'layout':n,'target':h,'restored_files':d,'errors':['legacy\x20persona\x20reset\x20failed:\x20'+M['message']]};}}return{'ok':![],'layout':n,'target':h,'restored_files':[],'errors':['cannot\x20reset\x20non-standard\x20file\x20\x27'+j+'\x27\x20in\x20legacy\x20layout.\x20Only\x20standard\x20layer\x20files,\x20personae/*.json,\x20manifest.json,\x20and\x20playbook.md\x20can\x20be\x20reset.']};}
|