@wowok/agent-mcp 3.3.6 → 3.3.8
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/eval-order.js +1 -1
- package/dist/chain-semantics/field-capability.js +1 -1
- package/dist/chain-semantics/fund-flow.js +1 -1
- package/dist/chain-semantics/guard-verbs.js +1 -1
- package/dist/chain-semantics/object-graph.js +1 -1
- package/dist/communication/message-cursors.d.ts +35 -0
- package/dist/communication/message-cursors.js +1 -0
- package/dist/communication/wts-attestation.d.ts +5 -0
- package/dist/communication/wts-attestation.js +1 -1
- package/dist/composition/audit.js +1 -1
- package/dist/composition/compile.d.ts +3 -2
- package/dist/composition/compile.js +1 -1
- package/dist/composition/inflight.d.ts +7 -0
- package/dist/composition/inflight.js +1 -1
- package/dist/composition/materialize.d.ts +4 -1
- package/dist/composition/materialize.js +1 -1
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +1 -1
- package/dist/config/store-policy.d.ts +14 -0
- package/dist/config/store-policy.js +1 -0
- package/dist/config/store-policy.spec.d.ts +1 -0
- package/dist/config/store-policy.spec.js +1 -0
- package/dist/customer/industry-risks.js +1 -1
- package/dist/customer/user-preferences.js +1 -1
- package/dist/data/projection/facets.spec.js +1 -1
- package/dist/evaluation/builtins/graph-service.spec.js +1 -1
- package/dist/evaluation/engine.js +1 -1
- package/dist/evaluation/match-policy.d.ts +30 -6
- package/dist/evaluation/match-policy.js +1 -1
- package/dist/evaluation/match-policy.spec.js +1 -1
- package/dist/experience/realtime-feedback.js +1 -1
- package/dist/extensions/business-modules.d.ts +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/analyze.js +1 -1
- package/dist/graph/onchain/expand.js +1 -1
- package/dist/graph/onchain/exposure.js +1 -1
- package/dist/graph/onchain/facts.d.ts +1 -0
- package/dist/graph/onchain/facts.js +1 -1
- package/dist/graph/onchain/facts.spec.js +1 -1
- package/dist/harness/recover.js +1 -1
- package/dist/intent/types.d.ts +1 -1
- package/dist/intent/types.js +1 -1
- package/dist/keeper/detectors.d.ts +3 -0
- package/dist/keeper/detectors.js +1 -1
- package/dist/keeper/keeper.spec.js +1 -1
- package/dist/knowledge/acquisition-flywheel.js +1 -1
- package/dist/knowledge/allocation-ledger.d.ts +1 -0
- package/dist/knowledge/allocation-ledger.js +1 -1
- package/dist/knowledge/allocator-rail-verifier.d.ts +6 -2
- package/dist/knowledge/allocator-rail-verifier.js +1 -1
- package/dist/knowledge/arbitration-ledger.js +1 -1
- package/dist/knowledge/audit-rules.d.ts +37 -0
- package/dist/knowledge/audit-rules.js +1 -1
- package/dist/knowledge/baselines/rules/plan.json +128 -3
- package/dist/knowledge/builtin-templates.d.ts +18 -1
- package/dist/knowledge/builtin-templates.js +1 -1
- package/dist/knowledge/commission-landing.d.ts +26 -0
- package/dist/knowledge/commission-landing.js +1 -0
- package/dist/knowledge/discount-threshold.js +1 -1
- package/dist/knowledge/event-semantics.js +1 -1
- package/dist/knowledge/fund-layer.d.ts +7 -0
- package/dist/knowledge/fund-layer.js +1 -1
- package/dist/knowledge/getting-started.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-puzzle.js +1 -1
- package/dist/knowledge/guard-render.d.ts +7 -0
- package/dist/knowledge/guard-render.js +1 -1
- package/dist/knowledge/guard-risk.js +1 -1
- package/dist/knowledge/guard-templates.d.ts +1 -1
- package/dist/knowledge/guard-templates.js +1 -1
- package/dist/knowledge/guard-translation.js +1 -1
- package/dist/knowledge/index.js +1 -1
- package/dist/knowledge/industry-generalizer.d.ts +4 -0
- package/dist/knowledge/industry-generalizer.js +1 -1
- package/dist/knowledge/industry-registry.d.ts +1 -1
- package/dist/knowledge/industry-registry.js +1 -1
- package/dist/knowledge/industry-strategy.js +1 -1
- package/dist/knowledge/jsonrpc-enum.js +1 -1
- package/dist/knowledge/machine-fork-watch.d.ts +9 -0
- package/dist/knowledge/machine-fork-watch.js +1 -0
- package/dist/knowledge/migration-preflight.js +1 -1
- package/dist/knowledge/projection.spec.js +1 -1
- package/dist/knowledge/scenario-modes.d.ts +8 -2
- package/dist/knowledge/scenario-modes.js +1 -1
- package/dist/knowledge/semantic-ir.d.ts +132 -0
- package/dist/knowledge/semantic-ir.js +1 -0
- package/dist/knowledge/service-ledger.js +1 -1
- package/dist/knowledge/strategy-manuals.js +1 -1
- package/dist/knowledge/template-index.js +1 -1
- package/dist/knowledge/template-loader.d.ts +45 -0
- package/dist/knowledge/template-loader.js +1 -1
- package/dist/knowledge/template-prose.d.ts +50 -0
- package/dist/knowledge/template-prose.js +1 -0
- package/dist/knowledge/template-registry.js +1 -1
- package/dist/knowledge/template-scanner.d.ts +5 -3
- package/dist/knowledge/template-scanner.js +1 -1
- package/dist/knowledge/template-validation.js +1 -1
- package/dist/knowledge/tools-reference.js +1 -1
- package/dist/monitor/MonitorLoop.js +1 -1
- package/dist/monitor/normalize.d.ts +1 -1
- package/dist/monitor/normalize.js +1 -1
- package/dist/monitor/types.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.d.ts +16 -6
- package/dist/playbooks/service-build/merchant-guide.js +1 -1
- package/dist/playbooks/service-build/migration-planner.d.ts +11 -2
- package/dist/playbooks/service-build/migration-planner.js +1 -1
- package/dist/playbooks/service-build/mode-actions.d.ts +8 -0
- package/dist/playbooks/service-build/mode-actions.js +1 -1
- package/dist/playbooks/service-build/object-panorama.d.ts +22 -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/reverse-mapping-nk4.spec.js +1 -1
- package/dist/playbooks/service-build/reverse-mapping.d.ts +1 -0
- package/dist/playbooks/service-build/reverse-mapping.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.js +1 -1
- package/dist/review/index.js +1 -1
- package/dist/safety/confirm-gate.js +1 -1
- package/dist/schema/benchmark-migration/index.d.ts +135 -10
- package/dist/schema/benchmark-migration/index.js +1 -1
- package/dist/schema/call/allocation.d.ts +3 -0
- package/dist/schema/call/allocation.js +1 -1
- package/dist/schema/call/arbitration.js +1 -1
- package/dist/schema/call/base.d.ts +32 -0
- package/dist/schema/call/bridge.d.ts +8 -0
- package/dist/schema/call/error-codes.d.ts +1 -1
- package/dist/schema/call/error-codes.js +1 -1
- package/dist/schema/call/order.js +1 -1
- package/dist/schema/call/reward.d.ts +10 -0
- package/dist/schema/call/reward.js +1 -1
- package/dist/schema/call/semantic.js +1 -1
- package/dist/schema/call/service.js +1 -1
- package/dist/schema/common/index.js +1 -1
- package/dist/schema/config/index.d.ts +24 -0
- package/dist/schema/config/index.js +1 -1
- package/dist/schema/evaluation/index.d.ts +152 -0
- package/dist/schema/evaluation/index.js +1 -1
- package/dist/schema/goal/index.d.ts +16 -0
- package/dist/schema/goal/planning.d.ts +29 -0
- package/dist/schema/goal/planning.js +1 -1
- package/dist/schema/industry-pack/index.d.ts +70 -0
- package/dist/schema/industry-pack/modes.d.ts +70 -0
- package/dist/schema/industry-pack/modes.js +1 -1
- package/dist/schema/intent-radar/index.d.ts +3 -0
- package/dist/schema/intent-radar/index.js +1 -1
- package/dist/schema/local/index.d.ts +80 -0
- package/dist/schema/local/index.js +1 -1
- package/dist/schema/messenger/index.d.ts +278 -1
- package/dist/schema/messenger/index.js +1 -1
- package/dist/schema/operations.d.ts +6 -0
- package/dist/schema/query/bi.d.ts +38 -0
- package/dist/schema/query/bi.js +1 -1
- package/dist/schema/query/index.d.ts +148 -47
- package/dist/schema/query/index.js +1 -1
- package/dist/schema/schema-version.js +1 -1
- package/dist/schema/service-clone/index.d.ts +17 -0
- package/dist/schema/service-clone/index.js +1 -1
- package/dist/schema-query-impl/index.js +1 -1
- package/dist/schemas/account_operation.output.json +8 -0
- package/dist/schemas/benchmark_migration_operation.output.json +296 -2
- package/dist/schemas/benchmark_migration_operation.schema.json +292 -7
- package/dist/schemas/bridge_operation.output.json +8 -0
- package/dist/schemas/config_operation.output.json +95 -0
- package/dist/schemas/config_operation.schema.json +16 -1
- package/dist/schemas/evaluation_operation.output.json +240 -0
- package/dist/schemas/evaluation_operation.schema.json +397 -1
- package/dist/schemas/goal_operation.schema.json +40 -10
- package/dist/schemas/index.json +1 -1
- package/dist/schemas/industry_pack_operation.output.json +90 -2
- package/dist/schemas/industry_pack_operation.schema.json +236 -0
- package/dist/schemas/intent_radar.output.json +2 -0
- package/dist/schemas/intent_radar.schema.json +1 -0
- package/dist/schemas/local_cache_operation.output.json +8 -0
- package/dist/schemas/local_history_operation.output.json +8 -0
- package/dist/schemas/local_info_operation.output.json +8 -0
- package/dist/schemas/local_mark_operation.output.json +8 -0
- package/dist/schemas/messenger_operation.output.json +609 -1
- package/dist/schemas/messenger_operation.schema.json +96 -1
- package/dist/schemas/onchain_events.output.json +281 -11
- package/dist/schemas/onchain_events.schema.json +5 -1
- package/dist/schemas/onchain_operations.output.json +8 -0
- package/dist/schemas/onchain_operations.schema.json +371 -10
- package/dist/schemas/onchain_operations_allocation.schema.json +10 -1
- package/dist/schemas/onchain_operations_arbitration.schema.json +1 -1
- package/dist/schemas/onchain_operations_guard.schema.json +318 -0
- package/dist/schemas/onchain_operations_order.schema.json +1 -1
- package/dist/schemas/onchain_operations_reward.schema.json +35 -1
- package/dist/schemas/onchain_operations_service.schema.json +6 -6
- package/dist/schemas/query_toolkit.output.json +305 -8
- package/dist/schemas/service_clone_operation.output.json +79 -0
- package/dist/tools/handlers/benchmark-migration.d.ts +15 -0
- package/dist/tools/handlers/benchmark-migration.js +1 -1
- package/dist/tools/handlers/config.js +1 -1
- package/dist/tools/handlers/evaluation.js +1 -1
- package/dist/tools/handlers/evaluation.spec.js +1 -1
- package/dist/tools/handlers/intent-radar.js +1 -1
- package/dist/tools/handlers/messenger.d.ts +1 -0
- package/dist/tools/handlers/messenger.js +1 -1
- package/dist/tools/handlers/onchain.d.ts +20 -1
- package/dist/tools/handlers/onchain.js +1 -1
- package/dist/tools/handlers/query.d.ts +1 -0
- package/dist/tools/handlers/query.js +1 -1
- package/dist/tools/handlers/service-clone.d.ts +18 -0
- package/dist/tools/handlers/service-clone.js +1 -1
- package/dist/tools/handlers/wip.js +1 -1
- package/dist/tools/registry/agent.js +1 -1
- package/dist/tools/registry/business.js +1 -1
- package/dist/tools/registry/query.js +1 -1
- package/dist/tools/wip-verify-ledger.d.ts +14 -0
- package/dist/tools/wip-verify-ledger.js +1 -0
- package/dist/tools/wrap.d.ts +4 -0
- package/dist/tools/wrap.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{describe,it,expect,beforeAll,afterAll}from'vitest';import*as
|
|
1
|
+
import{describe,it,expect,beforeAll,afterAll}from'vitest';import*as a283a from'node:fs';import*as a283b from'node:os';import*as a283c from'node:path';import{projectionUpsert,projectionServe,projectionStats,__projectionSetWriteClock}from'./projection.js';const SCRATCH_DB=a283c['join'](a283b['tmpdir'](),'wowok-projection-spec-'+process['pid']+'-'+Date['now']()+'.db'),PREV_DB=process['env']['WOWOK_PROJECTION_DB'],PREV_TTL=process['env']['WOWOK_PROJECTION_TTL_MS'];beforeAll(()=>{process['env']['WOWOK_PROJECTION_DB']=SCRATCH_DB,process['env']['WOWOK_PROJECTION_TTL_MS']='120000',__projectionSetWriteClock(0x0);}),afterAll(()=>{if(PREV_DB===undefined)delete process['env']['WOWOK_PROJECTION_DB'];else process['env']['WOWOK_PROJECTION_DB']=PREV_DB;if(PREV_TTL===undefined)delete process['env']['WOWOK_PROJECTION_TTL_MS'];else process['env']['WOWOK_PROJECTION_TTL_MS']=PREV_TTL;__projectionSetWriteClock(undefined);try{a283a['rmSync'](SCRATCH_DB,{'force':!![]}),a283a['rmSync'](SCRATCH_DB+'-wal',{'force':!![]}),a283a['rmSync'](SCRATCH_DB+'-shm',{'force':!![]});}catch{}});function svcRow(a,b={}){const {payloadJson:c,...d}=b;return{'object_id':a,'payload':JSON['stringify']({'object':a,...c??{}}),...d};}describe('projection\x20cache\x20(K5\x20doc\x2017\x20B-tier)',()=>{it('returns\x20undefined\x20without\x20a\x20watermark\x20(never\x20fabricates\x20coverage)',()=>{const a=projectionServe('chain-empty-proj','Service',{},0xc8);expect(a)['toBeUndefined'](),expect(projectionStats('chain-empty-proj')['every'](b=>b['rows']===0x0))['toBe'](!![]);}),it('serves\x20a\x20fresh\x20projection\x20with\x20SQL\x20filters\x20and\x20pre-filter\x20totals',()=>{const a='chain-proj-serve',b=[svcRow('0xa1',{'name':'Alpha\x20Music','location':'Shanghai,\x20CN','coin_type':'0x2::wow::WOW','published':0x1,'paused':0x0,'payloadJson':{'object':'0xa1','name':'Alpha\x20Music','location':'Shanghai,\x20CN'}}),svcRow('0xa2',{'name':'Beta\x20Design','location':'Beijing,\x20CN','coin_type':'0x2::wow::WOW','published':0x1,'paused':0x0,'payloadJson':{'object':'0xa2','name':'Beta\x20Design','location':'Beijing,\x20CN'}}),svcRow('0xa3',{'name':'Gamma\x20Food','location':'Shanghai,\x20CN','coin_type':'0x2::sui::SUI','published':0x1,'paused':0x0,'payloadJson':{'object':'0xa3','name':'Gamma\x20Food','location':'Shanghai,\x20CN'}})];projectionUpsert(a,'Service',b,{'hasMore':![],'maxObjects':0xc8});const c=projectionServe(a,'Service',{},0xc8);expect(c)['toBeDefined'](),expect(c['items'])['toHaveLength'](0x3),expect(c['meta']['total_rows'])['toBe'](0x3),expect(c['meta']['watermark']['has_more'])['toBe'](0x0),expect(c['items']['map'](h=>h['object'])['sort']())['toEqual'](['0xa1','0xa2','0xa3']);const d=projectionServe(a,'Service',{'coin_type':'0x2::wow::WOW'},0xc8);expect(d['items']['map'](h=>h['object'])['sort']())['toEqual'](['0xa1','0xa2']),expect(d['meta']['total_rows'])['toBe'](0x3);const e=projectionServe(a,'Service',{'name_contains':'beta'},0xc8);expect(e['items']['map'](h=>h['object']))['toEqual'](['0xa2']);const f=projectionServe(a,'Service',{'location_any':['shanghai']},0xc8);expect(f['items']['map'](h=>h['object'])['sort']())['toEqual'](['0xa1','0xa3']);const g=projectionServe(a,'Service',{'location_any':['paris']},0xc8);expect(g['items'])['toHaveLength'](0x0),expect(g['meta']['total_rows'])['toBe'](0x3),expect(projectionStats(a)['find'](h=>h['kind']==='Service')?.['rows'])['toBe'](0x3),expect(projectionStats(a)['find'](h=>h['kind']==='Service')?.['refreshed_at'])['toBeGreaterThan'](0x0);}),it('upserts\x20cumulatively:\x20rows\x20update\x20in\x20place\x20and\x20accumulate\x20across\x20windows',()=>{const a='chain-proj-cumulative';projectionUpsert(a,'Demand',[{'object_id':'0xd1','payload':JSON['stringify']({'object':'0xd1','description':'v1'})}],{'hasMore':!![],'maxObjects':0xc8}),projectionUpsert(a,'Demand',[{'object_id':'0xd1','payload':JSON['stringify']({'object':'0xd1','description':'v2'})},{'object_id':'0xd2','payload':JSON['stringify']({'object':'0xd2','description':'new'})}],{'hasMore':![],'maxObjects':0xc8});const b=projectionServe(a,'Demand',{},0xc8);expect(b['items'])['toHaveLength'](0x2);const c=b['items']['find'](d=>d['object']==='0xd1');expect(c?.['description'])['toBe']('v2'),expect(b['meta']['watermark']['has_more'])['toBe'](0x0);}),it('declines\x20to\x20serve\x20when\x20stale\x20by\x20TTL',async()=>{const a='chain-proj-stale-ttl',b=process['env']['WOWOK_PROJECTION_TTL_MS'];process['env']['WOWOK_PROJECTION_TTL_MS']='20';try{projectionUpsert(a,'Service',[svcRow('0xs1')],{'hasMore':![],'maxObjects':0xc8}),expect(projectionServe(a,'Service',{},0xc8))['toBeDefined'](),await new Promise(c=>setTimeout(c,0x28)),expect(projectionServe(a,'Service',{},0xc8))['toBeUndefined']();}finally{process['env']['WOWOK_PROJECTION_TTL_MS']=b;}}),it('declines\x20to\x20serve\x20when\x20a\x20local\x20on-chain\x20write\x20postdates\x20the\x20watermark',()=>{const a='chain-proj-stale-write';projectionUpsert(a,'Service',[svcRow('0xs2')],{'hasMore':![],'maxObjects':0xc8}),__projectionSetWriteClock(Date['now']()+0x1);try{expect(projectionServe(a,'Service',{},0xc8))['toBeUndefined']();}finally{__projectionSetWriteClock(0x0);}}),it('filters\x20arb\x20payloads\x20post-SQL\x20for\x20parity\x20with\x20the\x20legacy\x20post-hydration\x20filter',()=>{const a='chain-proj-arb';projectionUpsert(a,'Arb',[{'object_id':'0xb1','payload':JSON['stringify']({'object':'0xb1','arbitration':'0xarb1','order':'0xo1','status':0x2})},{'object_id':'0xb2','payload':JSON['stringify']({'object':'0xb2','arbitration':'0xarb1','order':'0xo2','status':0x5})},{'object_id':'0xb3','payload':JSON['stringify']({'object':'0xb3','arbitration':'0xarb2','order':'0xo1','status':0x2})}],{'hasMore':![],'maxObjects':0xc8});const b=projectionServe(a,'Arb',{'arbitration':'0xarb1'},0xc8);expect(b['items']['map'](f=>f['object'])['sort']())['toEqual'](['0xb1','0xb2']),expect(b['meta']['total_rows'])['toBe'](0x3);const c=projectionServe(a,'Arb',{'order':'0xo1'},0xc8);expect(c['items']['map'](f=>f['object'])['sort']())['toEqual'](['0xb1','0xb3']);const d=projectionServe(a,'Arb',{'status':[0x5]},0xc8);expect(d['items']['map'](f=>f['object']))['toEqual'](['0xb2']);const e=projectionServe(a,'Arb',{'arbitration':'0xarb2','status':[0x5]},0xc8);expect(e['items'])['toHaveLength'](0x0);}),it('respects\x20the\x20limit\x20on\x20the\x20SQL\x20path',()=>{const a='chain-proj-limit';projectionUpsert(a,'Demand',Array['from']({'length':0x5},(c,d)=>({'object_id':'0xL'+d,'payload':JSON['stringify']({'object':'0xL'+d})})),{'hasMore':![],'maxObjects':0xc8});const b=projectionServe(a,'Demand',{},0x3);expect(b['items'])['toHaveLength'](0x3),expect(b['meta']['total_rows'])['toBe'](0x5);});});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type IndustryModeName = "freelance" | "rental" | "education" | "travel" | "subscription" | "retail" | "licensing" | "crowdfunding" | "general";
|
|
1
|
+
export type IndustryModeName = "freelance" | "rental" | "education" | "travel" | "subscription" | "retail" | "licensing" | "crowdfunding" | "delivery" | "group_buy" | "general";
|
|
2
2
|
export interface ScenarioTraits {
|
|
3
3
|
has_logistics: boolean;
|
|
4
4
|
communication_heavy: boolean;
|
|
@@ -14,6 +14,7 @@ export interface ModeAllocatorRow {
|
|
|
14
14
|
mode: "amount" | "rate" | "surplus";
|
|
15
15
|
value?: string | number;
|
|
16
16
|
value_from?: string;
|
|
17
|
+
value_from_complement?: string;
|
|
17
18
|
fix?: string | number;
|
|
18
19
|
fix_from?: string;
|
|
19
20
|
guard_key?: string;
|
|
@@ -39,6 +40,9 @@ export interface ModeGuardRef {
|
|
|
39
40
|
description?: string;
|
|
40
41
|
id_from?: string;
|
|
41
42
|
value_type?: string;
|
|
43
|
+
id_from_submission?: string;
|
|
44
|
+
data_from_submission?: number;
|
|
45
|
+
write_once?: boolean;
|
|
42
46
|
};
|
|
43
47
|
params?: Record<string, unknown>;
|
|
44
48
|
}
|
|
@@ -46,6 +50,7 @@ export interface ModeMachineNode {
|
|
|
46
50
|
name: string;
|
|
47
51
|
role: string;
|
|
48
52
|
operator?: "merchant" | "order_payer";
|
|
53
|
+
named_operator?: string;
|
|
49
54
|
semantic_role?: "draft" | "active" | "delivered" | "final" | "cancelled";
|
|
50
55
|
optional?: boolean;
|
|
51
56
|
threshold?: number;
|
|
@@ -55,6 +60,7 @@ export interface ModeMachineEdge {
|
|
|
55
60
|
prev: string;
|
|
56
61
|
forward?: string;
|
|
57
62
|
operator?: "merchant" | "order_payer";
|
|
63
|
+
named_operator?: string;
|
|
58
64
|
permission_index?: number;
|
|
59
65
|
guard_key?: string;
|
|
60
66
|
}
|
|
@@ -89,4 +95,4 @@ export declare function getScenarioMode(name: IndustryModeName): ScenarioMode |
|
|
|
89
95
|
export declare function listScenarioModes(): ScenarioMode[];
|
|
90
96
|
export declare function getShippedModes(): ScenarioMode[];
|
|
91
97
|
export declare function getModeCompositions(name: IndustryModeName): ModeComposition[];
|
|
92
|
-
export declare const SCENARIO_MODES_VERSION =
|
|
98
|
+
export declare const SCENARIO_MODES_VERSION = 10;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUYER_ACTION_NODE_RE=/^(reviewed|return_requested|guest_cancelled|withdrawn|charging|cancelled|closed_cancel)$/i;export function unannotatedBuyerActionNodes(a){return a['filter'](b=>!b['operator']&&BUYER_ACTION_NODE_RE['test'](b['name']))['map'](b=>b['name']);}export const SCENARIO_MODES=[{'name':'freelance','phase':0x1,'industry':'Design\x20/\x20dev\x20/\x20consulting\x20/\x20writing','trust_pattern':'Milestone\x20allocation,\x20acceptance\x20gate','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':!![],'long_cycle':!![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'freelance/enterprise-talent-market','key_risk':'Customer\x20never\x20accepts\x20delivery\x20—\x20provider\x20cannot\x20get\x20paid','build_notes':['Use\x20Service\x20`setting_lock_duration`\x20to\x20lock\x20rules\x20for\x20the\x20engagement\x20duration','WIP\x20hash\x20on\x20every\x20milestone\x20deliverable\x20is\x20mandatory\x20—\x20protects\x20provider\x20in\x20disputes','Acceptance\x20gate\x20is\x20the\x20trust\x20pivot\x20—\x20both\x20parties\x20must\x20agree\x20on\x20criteria\x20per\x20milestone','Milestones\x20map\x20to\x20deliverable-Guarded\x20forwards;\x20each\x20accepted\x20milestone\x20releases\x20its\x20escrowed\x20slice\x20(allocation.distribute_milestone)','Scope\x20changes\x20are\x20recorded\x20as\x20WTS\x20change-requests\x20at\x20kickoff/throughout\x20—\x20never\x20silent','R-M1-11:\x20no\x20\x27refunded\x27/\x27disputed\x27/\x27arb\x27/\x27cancelled\x27\x20nodes\x20—\x20refunds\x20route\x20via\x20Allocator\x20(to\x20OrderHolder)\x20triggered\x20by\x20\x27closed_cancel\x27,\x20disputes\x20via\x20Arbitration','Payment\x20exception\x20compensation\x20for\x20delivery\x20delays\x20—\x20provider\x20Treasury\x20auto-compensates\x20customer\x20(§2.13)','Project-Catalog\x20orders\x20have\x20NO\x20milestones\x20(single\x20funded\x20order\x20+\x20steps\x20timeline);\x20milestones\x20here\x20model\x20fixed-price\x20CONTRACTS.\x20For\x20catalog-style\x20listings\x20(tiered\x20pricing\x20+\x20add-ons\x20+\x20buyer\x20requirements)\x20use\x20the\x20freelance/catalog-tiers\x20template\x20instead','Time-bound\x20catalog\x20rules\x20(24h\x20instant\x20cancel,\x2048h\x20requirements\x20timeout,\x2014-day\x20auto-accept)\x20need\x20a\x20time\x20Guard\x20PLUS\x20an\x20off-chain\x20keeper\x20per\x20window\x20-\x20Guards\x20take\x20an\x20immutable\x20duration\x20constant']},{'name':'rental','phase':0x1,'industry':'Equipment\x20/\x20vehicle\x20/\x20property\x20rental','trust_pattern':'Deposit\x20escrow,\x20return\x20inspection','traits':{'has_logistics':!![],'communication_heavy':!![],'pure_digital':![],'long_cycle':![],'deposit_required':!![],'multi_tier_allocation':![]},'default_template':'rental/institutional-longstay','key_risk':'Owner\x20claims\x20damage\x20without\x20pre-rental\x20WIP\x20—\x20customer\x20loses\x20deposit\x20unfairly','build_notes':['Pre-rental\x20WIP\x20is\x20non-negotiable\x20—\x20without\x20it,\x20damage\x20claims\x20fail','Deposit\x20must\x20be\x20escrowed,\x20not\x20direct-transferred\x20—\x20enables\x20fair\x20deduction','Inspection\x20gate\x20prevents\x20customer\x20from\x20denying\x20damage','Overdue\x20handling\x20uses\x20a\x20time-lock\x20Guard\x20(clock)\x20—\x20the\x20Guard\x20only\x20ALLOWS\x20the\x20overdue\x20transition;\x20automatic\x20advancement\x20needs\x20an\x20off-chain\x20keeper\x20(see\x20DESIGN-REVIEW\x20C-3)','Extensions\x20are\x20modeled\x20as\x20separate\x20sub-orders\x20(REUSE\x20pattern),\x20not\x20as\x20machine\x20cycles\x20—\x20an\x20in-order\x20loop\x20replays\x20its\x20forwards\x27\x20fund\x20rails\x20every\x20lap','R-M1-11:\x20no\x20\x27deposit_refunded\x27/\x27deposit_deducted\x27/\x27refunded\x27\x20nodes\x20—\x20deposit\x20refund/deduction\x20flows\x20through\x20Allocator\x20triggered\x20by\x20return_approved/damage_confirmed\x20business\x20states','Payment\x20exception\x20compensation\x20for\x20return\x20delays\x20—\x20Treasury\x20withdraws\x20scene-bound\x20Payment\x20(§2.13)','Repository\x20quote_guard\x20for\x20weather/usage\x20data\x20subscription\x20revenue\x20(§2.11)']},{'name':'education','phase':0x2,'industry':'Courses\x20/\x20training\x20/\x20tutoring','trust_pattern':'Periodic\x20release\x20per\x20session,\x20attendance\x20Guard','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':![],'long_cycle':!![],'deposit_required':!![],'multi_tier_allocation':![]},'default_template':'education/live-class-cohort','key_risk':'Tutoring\x20institutions\x20run\x20away\x20with\x20prepaid\x20tuition','build_notes':['Use\x20Service\x20`setting_lock_duration`\x20to\x20lock\x20rules\x20for\x20the\x20entire\x20term\x20(regulatory\x20compliance,\x20>=90d)','Attendance\x20Guard\x20needs\x20WIP\x20hash\x20for\x20session\x20content\x20commitment;\x20attendance\x20evidence\x20lives\x20in\x20the\x20class\x20Repository','Per-session\x20release\x20requires\x20threshold-based\x20trigger\x20—\x20each\x20attended\x20session\x20releases\x201/N','session_1..session_3\x20are\x20representative\x20—\x20configure\x20the\x20real\x20session\x20count\x20(session_N)\x20at\x20build\x20time;\x20each\x20session\x20=\x20one\x20attendance-Guarded\x20forward','Pause/deferral\x20is\x20a\x20terminal\x20node\x20+\x20new\x20sub-order\x20(REUSE\x20pattern)\x20—\x20never\x20a\x20loop\x20back\x20into\x20the\x20session\x20chain\x20(a\x20loop\x20replays\x20the\x20session\x20forwards\x27\x20fund\x20rails\x20every\x20lap;\x20if\x20a\x20loop\x20is\x20unavoidable\x20it\x20must\x20keep\x20a\x20cycle-breaking\x20exit)','Supply\x20chain\x20sub-orders\x20for\x20course\x20module\x20progressive\x20unlock\x20—\x20each\x20module\x20=\x20sub-service\x20with\x20buy_guard\x20verifying\x20previous\x20module\x20completion\x20(§2.12)','Repository\x20for\x20learning\x20progress\x20collaboration\x20data\x20—\x20progress\x20as\x20key,\x20session\x20data\x20as\x20value\x20(§2.10)']},{'name':'travel','phase':0x2,'industry':'Custom\x20tours\x20/\x20multi-segment\x20trips','trust_pattern':'Multi-tier\x20allocation\x20per\x20segment','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':![],'long_cycle':!![],'deposit_required':!![],'multi_tier_allocation':!![]},'default_template':'travel/destination-experience','key_risk':'Paid\x20in\x20full\x20then\x20service\x20shrinks\x20—\x20multi-tier\x20transparency\x20prevents\x20this','build_notes':['Multi-tier\x20Allocation\x20is\x20WoWok\x27s\x20unique\x20advantage\x20over\x20traditional\x20travel\x20platforms','segment_guard\x20needs\x20standardized\x20WIP\x20templates\x20per\x20segment\x20type\x20(hotel,\x20transport,\x20activity)','Multi-tier\x20waterfall\x20needs\x20guard\x20chaining\x20validation','Weather/force-majeure\x20branches\x20enter\x20reschedule\x20(terminal)\x20or\x20partial-refund\x20interrupted\x20terminal\x20—\x20never\x20loop\x20back\x20into\x20the\x20segment\x20chain\x20(a\x20loop\x20replays\x20the\x20segment\x20forwards\x27\x20fund\x20rails\x20every\x20lap;\x20if\x20a\x20loop\x20is\x20unavoidable\x20it\x20must\x20keep\x20a\x20cycle-breaking\x20exit)','Supplier\x20sub-orders\x20each\x20carry\x20their\x20own\x20machine\x20—\x20hotel/guide/driver\x20fulfill\x20independently\x20(§2.12)','Supply\x20chain\x20sub-orders\x20—\x20each\x20tour\x20segment\x20=\x20sub-service\x20with\x20buy_guard\x20verifying\x20main\x20tour\x20order\x20(§2.12)','Payment\x20exception\x20compensation\x20for\x20flight/segment\x20delays\x20(§2.13)','Repository\x20quote_guard\x20for\x20weather/travel\x20data\x20subscription\x20revenue\x20(§2.11)']},{'name':'subscription','phase':0x3,'industry':'SaaS\x20/\x20content\x20membership\x20/\x20periodic\x20service','trust_pattern':'Periodic\x20charge,\x20cancel\x20Guard','traits':{'has_logistics':![],'communication_heavy':![],'pure_digital':!![],'long_cycle':!![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'subscription/creator-membership','key_risk':'Auto-renew\x20trap\x20and\x20platform-takes-30%\x20—\x20WoWok\x20native\x20solution','build_notes':['Pure\x20digital\x20—\x20native\x20WoWok\x20soil','charge_guard\x20needs\x20periodic\x20trigger\x20(off-chain\x20scheduler\x20+\x20on-chain\x20Guard)','Renewal\x20is\x20an\x20explicit\x20buyer-side\x20forward\x20(or\x20a\x20Guard-gated\x20auto-renew\x20WITH\x20WTS\x20notice)\x20—\x20never\x20silent','Cancellation\x20is\x20frictionless\x20and\x20next-period\x20effective;\x20pro-rata\x20refund\x20for\x20unearned\x20periods','Forbid\x20dead-end\x20nodes\x20(prevent\x20lock-in);\x20every\x20state\x20must\x20have\x20a\x20forward\x20or\x20be\x20an\x20intended\x20terminal','Targets\x20indie\x20creators,\x20niche\x20SaaS,\x20paid\x20newsletters','Repository\x20quote_guard\x20for\x20creator\x20data\x20subscription\x20revenue\x20—\x20creators\x20publish\x20paid\x20data,\x20users\x20pay\x20to\x20access\x20(§2.11)']},{'name':'retail','phase':0x1,'industry':'Goods\x20retail\x20/\x20marketplace\x20/\x20e-commerce','trust_pattern':'Escrow\x20+\x20confirm-on-receipt\x20release','traits':{'has_logistics':!![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'retail/scale-marketplace','key_risk':'Products\x20don\x27t\x20match\x20description\x20—\x20no\x20refund\x20path\x20for\x20returns','build_notes':['Logistics\x20WIP\x20(tracking\x20number)\x20is\x20essential\x20—\x20shipping\x20evidence\x20protects\x20both\x20parties\x20in\x20return\x20disputes','Confirm\x20gate\x20prevents\x20merchant\x20from\x20self-confirming\x20receipt','Refund\x20path\x20must\x20support\x20return-and-exchange\x20flow;\x20refund_window\x20>=\x207d','Return\x20request\x20is\x20time-lock\x20gated\x20—\x20after\x20the\x20window\x20closes,\x20returns\x20need\x20merchant\x20permission\x20or\x20arbitration','Compensation\x20fund\x20covers\x20return/exchange\x20disputes','R-M1-11:\x20no\x20\x27refunded\x27\x20node\x20—\x20refunds\x20route\x20via\x20Allocator\x20triggered\x20by\x20returned/cancelled\x20business\x20states;\x20disputes\x20go\x20to\x20Arbitration']},{'name':'licensing','phase':0x1,'industry':'IP\x20/\x20royalty\x20licensing\x20/\x20metered\x20asset\x20licenses','trust_pattern':'Terms\x20hash-anchored,\x20on-chain\x20royalty\x20split,\x20territory/term\x20Guard','traits':{'has_logistics':![],'communication_heavy':![],'pure_digital':!![],'long_cycle':!![],'deposit_required':![],'multi_tier_allocation':!![]},'default_template':'licensing/royalty-stream-auction','key_risk':'Buyer\x20trusts\x20the\x20seller\x27s\x20royalty/usage\x20reporting\x20—\x20without\x20an\x20on-chain\x20meter\x20the\x20accounting\x20honesty\x20is\x20only\x20as\x20good\x20as\x20the\x20attestation\x20and\x20the\x20compensation\x20backstop','build_notes':['Anchor\x20the\x20license\x20terms\x20(territory,\x20term,\x20media,\x20caps,\x20exclusivity)\x20as\x20a\x20WIP\x20hash\x20—\x20the\x20granted\x20rights\x20must\x20be\x20provable\x20in\x20a\x20dispute,\x20not\x20prose','Royalty\x20/\x20purchase-proceeds\x20split\x20is\x20an\x20Allocation\x20Rate\x20plan\x20(bps\x20summing\x20to\x2010000\x20across\x20rights-holders\x20+\x20platform);\x20the\x20split\x20is\x20frozen\x20at\x20publish\x20and\x20auditable\x20by\x20every\x20recipient','Recurring\x20royalty:\x20the\x20Allocation\x20pool\x20is\x20re-fillable\x20(order_renew\x20top-ups)\x20and\x20a\x20guard-keyed\x20periodic\x20alloc\x20with\x20a\x20period-N\x20once-key\x20(identifier\x20255)\x20releases\x20each\x20period\x20—\x20payroll-style\x20repeat\x20runs\x20stay\x20possible\x20without\x20the\x20once-slot','Territory\x20is\x20enforced\x20by\x20a\x20Service\x20buy_guard\x20running\x20pattern.identity_check_allowlist\x20(allowlist\x20as\x20an\x20Address-vector\x20table\x20constant);\x20term\x20/\x20inspection\x20window\x20is\x20a\x20tpl_time_lock_progress\x20forward\x20guard\x20(Clock\x20>=\x20entry_time\x20+\x20duration)','Time-lock\x20duration\x20is\x20an\x20IMMUTABLE\x20table\x20constant\x20fixed\x20at\x20publish\x20—\x20an\x20expired\x20window\x20only\x20BLOCKS\x20the\x20forward,\x20it\x20never\x20auto-refunds;\x20automatic\x20advancement\x20on\x20timeout\x20needs\x20an\x20off-chain\x20keeper','🔴\x20AUCTION\x20GAP:\x20there\x20is\x20NO\x20on-chain\x20ascending-auction\x20/\x20bid-ledger\x20/\x20highest-bidder\x20primitive.\x20Model\x20a\x20competitive\x20sale\x20as:\x20winner\x20resolved\x20OFF-CHAIN\x20(prose),\x20then\x20the\x20winner\x20calls\x20buy\x20like\x20any\x20buyer\x20—\x20optionally\x20gate\x20buy\x20with\x20an\x20allowlist\x20guard\x20carrying\x20the\x20attested\x20winner\x20address.\x20Never\x20claim\x20the\x20chain\x20runs\x20the\x20auction','🔴\x20METERED-CAPS\x20GAP:\x20there\x20is\x20NO\x20usage\x20oracle/meter.\x20A\x20\x27limited\x20to\x20N\x20streams/sales\x27\x20cap\x20can\x20only\x20be\x20an\x20ATTESTED\x20Repository\x20counter\x20that\x20a\x20forward\x20guard\x20reads\x20via\x20the\x20repository.data\x20count-where\x20query\x20—\x20the\x20count\x20is\x20only\x20as\x20trustworthy\x20as\x20its\x20write-guard\x20(self/attested),\x20never\x20an\x20oracle\x20feed.\x20Disclose\x20this\x20honestly;\x20never\x20present\x20a\x20cap\x20as\x20chain-enforced\x20metering','R-M1-11:\x20no\x20\x27refunded\x27/\x27cancelled\x27\x20fund\x20terminals\x20—\x20refunds\x20route\x20via\x20the\x20Allocator\x20triggered\x20by\x20a\x20business\x20state\x20(e.g.\x20inspection_failed);\x20disputes\x20go\x20to\x20Arbitration']},{'name':'crowdfunding','phase':0x1,'industry':'All-or-nothing\x20threshold\x20campaigns\x20/\x20flexible\x20keep-it-all\x20fundraising','trust_pattern':'Per-contributor\x20escrow\x20(unpooled)\x20+\x20on-chain\x20aggregate\x20threshold\x20+\x20deadline\x20two-leg\x20release/refund','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':!![],'long_cycle':!![],'deposit_required':!![],'multi_tier_allocation':!![]},'default_template':'crowdfunding/all-or-nothing-threshold','key_risk':'The\x20funding\x20threshold\x20is\x20an\x20aggregate\x20read\x20over\x20a\x20shared\x20campaign\x20ledger\x20—\x20each\x20contribution\x20row\x20is\x20writer-bound\x20to\x20its\x20funder,\x20but\x20the\x20aggregate\x20is\x20a\x20read-only\x20sum\x20of\x20declared\x20rows,\x20not\x20an\x20independent\x20re-computation\x20of\x20every\x20escrow;\x20roster\x20completeness\x20is\x20keeper-attested.\x20Funders\x20also\x20trust\x20eventual\x20project\x20delivery,\x20backed\x20only\x20by\x20compensation_fund\x20+\x20arbitration','build_notes':['Per-contributor\x20escrow,\x20NEVER\x20pooled:\x20each\x20funder\x27s\x20Order\x20holds\x20its\x20OWN\x20Allocation\x20with\x20payment_info.for_object\x20bound\x20to\x20that\x20Order\x20—\x20because\x20the\x20money\x20is\x20never\x20balance::join-ed\x20into\x20one\x20pot,\x20attribution\x20survives\x20and\x20each\x20contribution\x20is\x20refundable\x20to\x20its\x20own\x20funder','Threshold\x20gate\x20=\x20an\x20on-chain\x20aggregate:\x20a\x20shared\x20campaign\x20Repository\x20holds\x20one\x20numeric\x20row\x20per\x20contribution\x20(keyed\x20by\x20the\x20contribution,\x20tagged\x20with\x20a\x20campaign\x20id);\x20the\x20settlement\x20Guard\x20reads\x20it\x20back\x20with\x20the\x20repository.data\x20sum-where\x20query\x20(1174\x20→\x20U256,\x20overflow-safe)\x20and\x20compares\x20against\x20the\x20threshold\x20constant','Write-side\x20binding\x20is\x20MANDATORY:\x20contribution\x20rows\x20are\x20written\x20under\x20pattern.repository_write_authorization\x20with\x20an\x20identity\x20leaf\x20(order.owner\x20==\x20Signer\x20/\x20order.agent\x20has\x20Signer)\x20so\x20a\x20funder\x20can\x20only\x20record\x20their\x20OWN\x20contribution\x20—\x20existence-is-not-trust\x20(R-X1-17),\x20an\x20unbound\x20write_guard\x20makes\x20the\x20aggregate\x20forgeable','Deadline\x20=\x20a\x20time-lock:\x20both\x20settlement\x20legs\x20require\x20Clock\x20>=\x20deadline\x20via\x20pattern.time_lock_progress\x20(query\x201280,\x20node-ENTRY\x20anchored);\x20BEFORE\x20the\x20deadline\x20a\x20funder\x20may\x20withdraw\x20(buyer-self-service\x20withdrawn\x20rail:\x20removes\x20their\x20writer-bound\x20row\x20+\x20full\x20refund\x20—\x20A12\x20fix,\x20was\x20wrongly\x20\x27no\x20early\x20withdrawal\x27);\x20AFTER\x20the\x20deadline\x20funds\x20are\x20committed\x20to\x20the\x20threshold\x20outcome','Two-leg\x20escrow\x20exit\x20(D-BUG-2\x20polarity):\x20release\x20leg\x20(→\x20project\x20Entity)\x20gated\x20logic_and[sum_where\x20>=\x20threshold,\x20clock\x20>=\x20deadline];\x20refund\x20leg\x20(→\x20for_object,\x20the\x20funder\x27s\x20own\x20Order)\x20gated\x20logic_and[sum_where\x20<\x20threshold,\x20clock\x20>=\x20deadline]\x20—\x20mutually\x20exclusive\x20on\x20the\x20aggregate\x20comparison,\x20so\x20exactly\x20one\x20is\x20satisfiable\x20once\x20the\x20deadline\x20passes','Keeper\x20batch\x20settlement:\x20on\x20a\x20missed\x20campaign\x20a\x20keeper\x20enumerates\x20every\x20contributor\x20via\x20repository.data\x20find-where\x20(1176\x20→\x20VectorAddress)\x20/\x20keys-where\x20(1177\x20→\x20VectorString)\x20and\x20advances\x20each\x20funder\x27s\x20refund\x20leg\x20in\x20one\x20PTB\x20(or\x20N\x20PTBs)\x20—\x20an\x20ops\x20efficiency,\x20not\x20a\x20chain\x20capability','🔴\x20AGGREGATE\x20TRUST\x20BOUNDARY:\x20the\x20sum\x20is\x20only\x20as\x20honest\x20as\x20the\x20writer-bound\x20rows;\x20it\x20is\x20NOT\x20independently\x20re-derivable\x20on-chain\x20without\x20reading\x20every\x20escrow\x20balance.\x20Disclose\x20this\x20honestly\x20(L-04);\x20never\x20present\x20the\x20threshold\x20as\x20a\x20chain-verified\x20total-custody\x20proof','🔴\x20L-01\x20NON-INVESTMENT:\x20crowdfunding\x20copy\x20must\x20never\x20promise\x20investment\x20returns,\x20yield,\x20or\x20token-price\x20appreciation\x20—\x20it\x20is\x20a\x20threshold\x20purchase/preorder/donation,\x20not\x20a\x20security','🔴\x20L-05\x20KYC/AML:\x20pooled\x20fundraising\x20is\x20high\x20regulatory\x20intensity\x20—\x20cross-border\x20funds\x20and\x20reward\x20tiers\x20may\x20trigger\x20securities/money-transmission\x20rules;\x20flag\x20for\x20compliance,\x20do\x20not\x20automate\x20around\x20them','R-M1-11:\x20no\x20\x27refunded\x27/\x27cancelled\x27\x20fund\x20terminals\x20—\x20the\x20refund\x20leg\x20routes\x20via\x20the\x20Allocator\x20triggered\x20by\x20the\x20missed-threshold\x20business\x20state\x20at\x20deadline;\x20disputes\x20go\x20to\x20Arbitration']},{'name':'general','phase':0x1,'industry':'Anything\x20not\x20covered\x20/\x20hybrid','trust_pattern':'User-defined\x20from\x20scratch','traits':{'has_logistics':![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':null,'key_risk':'No\x20safety\x20net\x20—\x20user\x20must\x20design\x20all\x20trust\x20mechanisms\x20manually','build_notes':['Escape\x20hatch:\x20any\x20user\x20can\x20switch\x20to\x20general\x20mode\x20at\x20any\x20time','Already-created\x20objects\x20under\x20a\x20previous\x20mode\x20remain\x20on-chain\x20(REUSE\x20pattern)','wowok-machine\x20/\x20wowok-guard\x20/\x20wowok-provider\x20become\x20primary\x20references']}];export function matchScenarioMode(a){const b=a['toLowerCase'](),c=inferScenarioTraits(a),e=SCENARIO_MODES['map'](h=>{let i=0x0,j=0x0;for(const k of Object['keys'](c)){j+=0x1;if(h['traits'][k]===c[k])i+=0x1;}if(h['name']!=='general'){const l=MODE_KEYWORDS[h['name']]??[];for(const m of l){if(b['includes'](m))i+=0.5;}}return{'mode':h,'score':i,'total':j};});let f=e[0x0];for(const h of e){if(h['score']>f['score'])f=h;}const g=f['total']>0x0?Math['min'](0x1,f['score']/f['total']):0x0;return{'mode':f['mode'],'confidence':g};}const MODE_KEYWORDS={'freelance':['freelance','design','develop','consult','write','consulting'],'rental':['rent','rental','lease','borrow','equipment','vehicle','property'],'education':['course','training','tutor','teach','education','class'],'travel':['tour','travel','trip','itinerary','vacation'],'subscription':['subscribe','subscription','membership','saas','newsletter','recurring'],'retail':['retail','shop','store','marketplace','sell\x20goods','ecommerce','e-commerce'],'licensing':['license','licensing','royalty','royalties','ip','intellectual\x20property','music\x20rights','sync','beat','franchise','rights'],'crowdfunding':['crowdfunding','crowdfund','fundraising','pledge','backer','kickstarter','campaign','all-or-nothing','threshold\x20goal','presale\x20campaign','raise\x20funds']};export function inferScenarioTraits(a){const b=a['toLowerCase']();return{'has_logistics':/ship|delivery|equipment|vehicle|physical|goods/['test'](b),'communication_heavy':/consult|discuss|back-and-forth|custom|bespoke|negotiate/['test'](b),'pure_digital':/digital|file|download|online|software|code|design|content/['test'](b),'long_cycle':/month|long-term|engagement|project|semester|period/['test'](b),'deposit_required':/deposit|escrow|prepay|tuition|reserve/['test'](b),'multi_tier_allocation':/tier|segment|multi-|agency|hotel|guide|driver/['test'](b)};}export const MODE_COMPOSITIONS=[{'modes':['freelance','subscription'],'use_case':'Retainer\x20consulting\x20(monthly\x20+\x20milestone)','conflict_resolution':'Allocator:\x20split\x20into\x20retainer\x20(subscription)\x20+\x20milestone\x20(freelance)'},{'modes':['rental','education'],'use_case':'Equipment\x20training\x20rental','conflict_resolution':'Machine:\x20extend\x20rental\x20nodes\x20with\x20attendance\x20gates'},{'modes':['travel','rental'],'use_case':'Tour\x20with\x20equipment','conflict_resolution':'Allocator:\x20segment\x20allocation\x20+\x20deposit\x20escrow\x20side-by-side'}];export function getScenarioMode(a){return SCENARIO_MODES['find'](b=>b['name']===a);}export function listScenarioModes(){return SCENARIO_MODES;}export function getShippedModes(){return SCENARIO_MODES['filter'](a=>a['phase']===0x1);}export function getModeCompositions(a){return MODE_COMPOSITIONS['filter'](b=>b['modes']['includes'](a));}export const SCENARIO_MODES_VERSION=0x9;
|
|
1
|
+
export const BUYER_ACTION_NODE_RE=/^(reviewed|return_requested|guest_cancelled|withdrawn|charging|cancelled|closed_cancel)$/i;export function unannotatedBuyerActionNodes(a){return a['filter'](b=>!b['operator']&&BUYER_ACTION_NODE_RE['test'](b['name']))['map'](b=>b['name']);}export const SCENARIO_MODES=[{'name':'freelance','phase':0x1,'industry':'Design\x20/\x20dev\x20/\x20consulting\x20/\x20writing','trust_pattern':'Milestone\x20allocation,\x20acceptance\x20gate','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':!![],'long_cycle':!![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'freelance/enterprise-talent-market','key_risk':'Customer\x20never\x20accepts\x20delivery\x20—\x20provider\x20cannot\x20get\x20paid','build_notes':['Use\x20Service\x20`setting_lock_duration`\x20to\x20lock\x20rules\x20for\x20the\x20engagement\x20duration','WIP\x20hash\x20on\x20every\x20milestone\x20deliverable\x20is\x20mandatory\x20—\x20protects\x20provider\x20in\x20disputes','Acceptance\x20gate\x20is\x20the\x20trust\x20pivot\x20—\x20both\x20parties\x20must\x20agree\x20on\x20criteria\x20per\x20milestone','Milestones\x20map\x20to\x20deliverable-Guarded\x20forwards;\x20each\x20accepted\x20milestone\x20releases\x20its\x20escrowed\x20slice\x20(allocation.distribute_milestone)','Scope\x20changes\x20are\x20recorded\x20as\x20WTS\x20change-requests\x20at\x20kickoff/throughout\x20—\x20never\x20silent','R-M1-11:\x20no\x20\x27refunded\x27/\x27disputed\x27/\x27arb\x27/\x27cancelled\x27\x20nodes\x20—\x20refunds\x20route\x20via\x20Allocator\x20(to\x20OrderHolder)\x20triggered\x20by\x20\x27closed_cancel\x27,\x20disputes\x20via\x20Arbitration','Payment\x20exception\x20compensation\x20for\x20delivery\x20delays\x20—\x20provider\x20Treasury\x20auto-compensates\x20customer\x20(§2.13)','Project-Catalog\x20orders\x20have\x20NO\x20milestones\x20(single\x20funded\x20order\x20+\x20steps\x20timeline);\x20milestones\x20here\x20model\x20fixed-price\x20CONTRACTS.\x20For\x20catalog-style\x20listings\x20(tiered\x20pricing\x20+\x20add-ons\x20+\x20buyer\x20requirements)\x20use\x20the\x20freelance/catalog-tiers\x20template\x20instead','Time-bound\x20catalog\x20rules\x20(24h\x20instant\x20cancel,\x2048h\x20requirements\x20timeout,\x2014-day\x20auto-accept)\x20need\x20a\x20time\x20Guard\x20PLUS\x20an\x20off-chain\x20keeper\x20per\x20window\x20-\x20Guards\x20take\x20an\x20immutable\x20duration\x20constant']},{'name':'rental','phase':0x1,'industry':'Equipment\x20/\x20vehicle\x20/\x20property\x20rental','trust_pattern':'Deposit\x20escrow,\x20return\x20inspection','traits':{'has_logistics':!![],'communication_heavy':!![],'pure_digital':![],'long_cycle':![],'deposit_required':!![],'multi_tier_allocation':![]},'default_template':'rental/institutional-longstay','key_risk':'Owner\x20claims\x20damage\x20without\x20pre-rental\x20WIP\x20—\x20customer\x20loses\x20deposit\x20unfairly','build_notes':['Pre-rental\x20WIP\x20is\x20non-negotiable\x20—\x20without\x20it,\x20damage\x20claims\x20fail','Deposit\x20must\x20be\x20escrowed,\x20not\x20direct-transferred\x20—\x20enables\x20fair\x20deduction','Inspection\x20gate\x20prevents\x20customer\x20from\x20denying\x20damage','Overdue\x20handling\x20uses\x20a\x20time-lock\x20Guard\x20(clock)\x20—\x20the\x20Guard\x20only\x20ALLOWS\x20the\x20overdue\x20transition;\x20automatic\x20advancement\x20needs\x20an\x20off-chain\x20keeper\x20(see\x20DESIGN-REVIEW\x20C-3)','Extensions\x20are\x20modeled\x20as\x20separate\x20sub-orders\x20(REUSE\x20pattern),\x20not\x20as\x20machine\x20cycles\x20—\x20an\x20in-order\x20loop\x20replays\x20its\x20forwards\x27\x20fund\x20rails\x20every\x20lap','R-M1-11:\x20no\x20\x27deposit_refunded\x27/\x27deposit_deducted\x27/\x27refunded\x27\x20nodes\x20—\x20deposit\x20refund/deduction\x20flows\x20through\x20Allocator\x20triggered\x20by\x20return_approved/damage_confirmed\x20business\x20states','Payment\x20exception\x20compensation\x20for\x20return\x20delays\x20—\x20Treasury\x20withdraws\x20scene-bound\x20Payment\x20(§2.13)','Repository\x20quote_guard\x20for\x20weather/usage\x20data\x20subscription\x20revenue\x20(§2.11)']},{'name':'education','phase':0x2,'industry':'Courses\x20/\x20training\x20/\x20tutoring','trust_pattern':'Periodic\x20release\x20per\x20session,\x20attendance\x20Guard','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':![],'long_cycle':!![],'deposit_required':!![],'multi_tier_allocation':![]},'default_template':'education/live-class-cohort','key_risk':'Tutoring\x20institutions\x20run\x20away\x20with\x20prepaid\x20tuition','build_notes':['Use\x20Service\x20`setting_lock_duration`\x20to\x20lock\x20rules\x20for\x20the\x20entire\x20term\x20(regulatory\x20compliance,\x20>=90d)','Attendance\x20Guard\x20needs\x20WIP\x20hash\x20for\x20session\x20content\x20commitment;\x20attendance\x20evidence\x20lives\x20in\x20the\x20class\x20Repository','Per-session\x20release\x20requires\x20threshold-based\x20trigger\x20—\x20each\x20attended\x20session\x20releases\x201/N','session_1..session_3\x20are\x20representative\x20—\x20configure\x20the\x20real\x20session\x20count\x20(session_N)\x20at\x20build\x20time;\x20each\x20session\x20=\x20one\x20attendance-Guarded\x20forward','Pause/deferral\x20is\x20a\x20terminal\x20node\x20+\x20new\x20sub-order\x20(REUSE\x20pattern)\x20—\x20never\x20a\x20loop\x20back\x20into\x20the\x20session\x20chain\x20(a\x20loop\x20replays\x20the\x20session\x20forwards\x27\x20fund\x20rails\x20every\x20lap;\x20if\x20a\x20loop\x20is\x20unavoidable\x20it\x20must\x20keep\x20a\x20cycle-breaking\x20exit)','Supply\x20chain\x20sub-orders\x20for\x20course\x20module\x20progressive\x20unlock\x20—\x20each\x20module\x20=\x20sub-service\x20with\x20buy_guard\x20verifying\x20previous\x20module\x20completion\x20(§2.12)','Repository\x20for\x20learning\x20progress\x20collaboration\x20data\x20—\x20progress\x20as\x20key,\x20session\x20data\x20as\x20value\x20(§2.10)']},{'name':'travel','phase':0x2,'industry':'Custom\x20tours\x20/\x20multi-segment\x20trips','trust_pattern':'Multi-tier\x20allocation\x20per\x20segment','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':![],'long_cycle':!![],'deposit_required':!![],'multi_tier_allocation':!![]},'default_template':'travel/destination-experience','key_risk':'Paid\x20in\x20full\x20then\x20service\x20shrinks\x20—\x20multi-tier\x20transparency\x20prevents\x20this','build_notes':['Multi-tier\x20Allocation\x20is\x20WoWok\x27s\x20unique\x20advantage\x20over\x20traditional\x20travel\x20platforms','segment_guard\x20needs\x20standardized\x20WIP\x20templates\x20per\x20segment\x20type\x20(hotel,\x20transport,\x20activity)','Multi-tier\x20waterfall\x20needs\x20guard\x20chaining\x20validation','Weather/force-majeure\x20branches\x20enter\x20reschedule\x20(terminal)\x20or\x20partial-refund\x20interrupted\x20terminal\x20—\x20never\x20loop\x20back\x20into\x20the\x20segment\x20chain\x20(a\x20loop\x20replays\x20the\x20segment\x20forwards\x27\x20fund\x20rails\x20every\x20lap;\x20if\x20a\x20loop\x20is\x20unavoidable\x20it\x20must\x20keep\x20a\x20cycle-breaking\x20exit)','Supplier\x20sub-orders\x20each\x20carry\x20their\x20own\x20machine\x20—\x20hotel/guide/driver\x20fulfill\x20independently\x20(§2.12)','Supply\x20chain\x20sub-orders\x20—\x20each\x20tour\x20segment\x20=\x20sub-service\x20with\x20buy_guard\x20verifying\x20main\x20tour\x20order\x20(§2.12)','Payment\x20exception\x20compensation\x20for\x20flight/segment\x20delays\x20(§2.13)','Repository\x20quote_guard\x20for\x20weather/travel\x20data\x20subscription\x20revenue\x20(§2.11)']},{'name':'subscription','phase':0x3,'industry':'SaaS\x20/\x20content\x20membership\x20/\x20periodic\x20service','trust_pattern':'Periodic\x20charge,\x20cancel\x20Guard','traits':{'has_logistics':![],'communication_heavy':![],'pure_digital':!![],'long_cycle':!![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'subscription/creator-membership','key_risk':'Auto-renew\x20trap\x20and\x20platform-takes-30%\x20—\x20WoWok\x20native\x20solution','build_notes':['Pure\x20digital\x20—\x20native\x20WoWok\x20soil','charge_guard\x20needs\x20periodic\x20trigger\x20(off-chain\x20scheduler\x20+\x20on-chain\x20Guard)','Renewal\x20is\x20an\x20explicit\x20buyer-side\x20forward\x20(or\x20a\x20Guard-gated\x20auto-renew\x20WITH\x20WTS\x20notice)\x20—\x20never\x20silent','Cancellation\x20is\x20frictionless\x20and\x20next-period\x20effective;\x20pro-rata\x20refund\x20for\x20unearned\x20periods','Forbid\x20dead-end\x20nodes\x20(prevent\x20lock-in);\x20every\x20state\x20must\x20have\x20a\x20forward\x20or\x20be\x20an\x20intended\x20terminal','Targets\x20indie\x20creators,\x20niche\x20SaaS,\x20paid\x20newsletters','Repository\x20quote_guard\x20for\x20creator\x20data\x20subscription\x20revenue\x20—\x20creators\x20publish\x20paid\x20data,\x20users\x20pay\x20to\x20access\x20(§2.11)']},{'name':'retail','phase':0x1,'industry':'Goods\x20retail\x20/\x20marketplace\x20/\x20e-commerce','trust_pattern':'Escrow\x20+\x20confirm-on-receipt\x20release','traits':{'has_logistics':!![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'retail/scale-marketplace','key_risk':'Products\x20don\x27t\x20match\x20description\x20—\x20no\x20refund\x20path\x20for\x20returns','build_notes':['Logistics\x20WIP\x20(tracking\x20number)\x20is\x20essential\x20—\x20shipping\x20evidence\x20protects\x20both\x20parties\x20in\x20return\x20disputes','Confirm\x20gate\x20prevents\x20merchant\x20from\x20self-confirming\x20receipt','Refund\x20path\x20must\x20support\x20return-and-exchange\x20flow;\x20refund_window\x20>=\x207d','Return\x20request\x20is\x20time-lock\x20gated\x20—\x20after\x20the\x20window\x20closes,\x20returns\x20need\x20merchant\x20permission\x20or\x20arbitration','Compensation\x20fund\x20covers\x20return/exchange\x20disputes','R-M1-11:\x20no\x20\x27refunded\x27\x20node\x20—\x20refunds\x20route\x20via\x20Allocator\x20triggered\x20by\x20returned/cancelled\x20business\x20states;\x20disputes\x20go\x20to\x20Arbitration']},{'name':'licensing','phase':0x1,'industry':'IP\x20/\x20royalty\x20licensing\x20/\x20metered\x20asset\x20licenses','trust_pattern':'Terms\x20hash-anchored,\x20on-chain\x20royalty\x20split,\x20territory/term\x20Guard','traits':{'has_logistics':![],'communication_heavy':![],'pure_digital':!![],'long_cycle':!![],'deposit_required':![],'multi_tier_allocation':!![]},'default_template':'licensing/royalty-stream-auction','key_risk':'Buyer\x20trusts\x20the\x20seller\x27s\x20royalty/usage\x20reporting\x20—\x20without\x20an\x20on-chain\x20meter\x20the\x20accounting\x20honesty\x20is\x20only\x20as\x20good\x20as\x20the\x20attestation\x20and\x20the\x20compensation\x20backstop','build_notes':['Anchor\x20the\x20license\x20terms\x20(territory,\x20term,\x20media,\x20caps,\x20exclusivity)\x20as\x20a\x20WIP\x20hash\x20—\x20the\x20granted\x20rights\x20must\x20be\x20provable\x20in\x20a\x20dispute,\x20not\x20prose','Royalty\x20/\x20purchase-proceeds\x20split\x20is\x20an\x20Allocation\x20Rate\x20plan\x20(bps\x20summing\x20to\x2010000\x20across\x20rights-holders\x20+\x20platform);\x20the\x20split\x20is\x20frozen\x20at\x20publish\x20and\x20auditable\x20by\x20every\x20recipient','Recurring\x20royalty:\x20the\x20Allocation\x20pool\x20is\x20re-fillable\x20(order_renew\x20top-ups)\x20and\x20a\x20guard-keyed\x20periodic\x20alloc\x20with\x20a\x20period-N\x20once-key\x20(identifier\x20255)\x20releases\x20each\x20period\x20—\x20payroll-style\x20repeat\x20runs\x20stay\x20possible\x20without\x20the\x20once-slot','Territory\x20is\x20enforced\x20by\x20a\x20Service\x20buy_guard\x20running\x20pattern.identity_check_allowlist\x20(allowlist\x20as\x20an\x20Address-vector\x20table\x20constant);\x20term\x20/\x20inspection\x20window\x20is\x20a\x20tpl_time_lock_progress\x20forward\x20guard\x20(Clock\x20>=\x20entry_time\x20+\x20duration)','Time-lock\x20duration\x20is\x20an\x20IMMUTABLE\x20table\x20constant\x20fixed\x20at\x20publish\x20—\x20an\x20expired\x20window\x20only\x20BLOCKS\x20the\x20forward,\x20it\x20never\x20auto-refunds;\x20automatic\x20advancement\x20on\x20timeout\x20needs\x20an\x20off-chain\x20keeper','🔴\x20AUCTION\x20GAP:\x20there\x20is\x20NO\x20on-chain\x20ascending-auction\x20/\x20bid-ledger\x20/\x20highest-bidder\x20primitive.\x20Model\x20a\x20competitive\x20sale\x20as:\x20winner\x20resolved\x20OFF-CHAIN\x20(prose),\x20then\x20the\x20winner\x20calls\x20buy\x20like\x20any\x20buyer\x20—\x20optionally\x20gate\x20buy\x20with\x20an\x20allowlist\x20guard\x20carrying\x20the\x20attested\x20winner\x20address.\x20Never\x20claim\x20the\x20chain\x20runs\x20the\x20auction','🔴\x20METERED-CAPS\x20GAP:\x20there\x20is\x20NO\x20usage\x20oracle/meter.\x20A\x20\x27limited\x20to\x20N\x20streams/sales\x27\x20cap\x20can\x20only\x20be\x20an\x20ATTESTED\x20Repository\x20counter\x20that\x20a\x20forward\x20guard\x20reads\x20via\x20the\x20repository.data\x20count-where\x20query\x20—\x20the\x20count\x20is\x20only\x20as\x20trustworthy\x20as\x20its\x20write-guard\x20(self/attested),\x20never\x20an\x20oracle\x20feed.\x20Disclose\x20this\x20honestly;\x20never\x20present\x20a\x20cap\x20as\x20chain-enforced\x20metering','R-M1-11:\x20no\x20\x27refunded\x27/\x27cancelled\x27\x20fund\x20terminals\x20—\x20refunds\x20route\x20via\x20the\x20Allocator\x20triggered\x20by\x20a\x20business\x20state\x20(e.g.\x20inspection_failed);\x20disputes\x20go\x20to\x20Arbitration']},{'name':'crowdfunding','phase':0x1,'industry':'All-or-nothing\x20threshold\x20campaigns\x20/\x20flexible\x20keep-it-all\x20fundraising','trust_pattern':'Per-contributor\x20escrow\x20(unpooled)\x20+\x20on-chain\x20aggregate\x20threshold\x20+\x20deadline\x20two-leg\x20release/refund','traits':{'has_logistics':![],'communication_heavy':!![],'pure_digital':!![],'long_cycle':!![],'deposit_required':!![],'multi_tier_allocation':!![]},'default_template':'crowdfunding/all-or-nothing-threshold','key_risk':'The\x20funding\x20threshold\x20is\x20an\x20aggregate\x20read\x20over\x20a\x20shared\x20campaign\x20ledger\x20—\x20each\x20contribution\x20row\x20is\x20writer-bound\x20to\x20its\x20funder,\x20but\x20the\x20aggregate\x20is\x20a\x20read-only\x20sum\x20of\x20declared\x20rows,\x20not\x20an\x20independent\x20re-computation\x20of\x20every\x20escrow;\x20roster\x20completeness\x20is\x20keeper-attested.\x20Funders\x20also\x20trust\x20eventual\x20project\x20delivery,\x20backed\x20only\x20by\x20compensation_fund\x20+\x20arbitration','build_notes':['Per-contributor\x20escrow,\x20NEVER\x20pooled:\x20each\x20funder\x27s\x20Order\x20holds\x20its\x20OWN\x20Allocation\x20with\x20payment_info.for_object\x20bound\x20to\x20that\x20Order\x20—\x20because\x20the\x20money\x20is\x20never\x20balance::join-ed\x20into\x20one\x20pot,\x20attribution\x20survives\x20and\x20each\x20contribution\x20is\x20refundable\x20to\x20its\x20own\x20funder','Threshold\x20gate\x20=\x20an\x20on-chain\x20aggregate:\x20a\x20shared\x20campaign\x20Repository\x20holds\x20one\x20numeric\x20row\x20per\x20contribution\x20(keyed\x20by\x20the\x20contribution,\x20tagged\x20with\x20a\x20campaign\x20id);\x20the\x20settlement\x20Guard\x20reads\x20it\x20back\x20with\x20the\x20repository.data\x20sum-where\x20query\x20(1174\x20→\x20U256,\x20overflow-safe)\x20and\x20compares\x20against\x20the\x20threshold\x20constant','Write-side\x20binding\x20is\x20MANDATORY:\x20contribution\x20rows\x20are\x20written\x20under\x20pattern.repository_write_authorization\x20with\x20an\x20identity\x20leaf\x20(order.owner\x20==\x20Signer\x20/\x20order.agent\x20has\x20Signer)\x20so\x20a\x20funder\x20can\x20only\x20record\x20their\x20OWN\x20contribution\x20—\x20existence-is-not-trust\x20(R-X1-17),\x20an\x20unbound\x20write_guard\x20makes\x20the\x20aggregate\x20forgeable','Deadline\x20=\x20a\x20time-lock:\x20both\x20settlement\x20legs\x20require\x20Clock\x20>=\x20deadline\x20via\x20pattern.time_lock_progress\x20(query\x201280,\x20node-ENTRY\x20anchored);\x20BEFORE\x20the\x20deadline\x20a\x20funder\x20may\x20withdraw\x20(buyer-self-service\x20withdrawn\x20rail:\x20removes\x20their\x20writer-bound\x20row\x20+\x20full\x20refund\x20—\x20A12\x20fix,\x20was\x20wrongly\x20\x27no\x20early\x20withdrawal\x27);\x20AFTER\x20the\x20deadline\x20funds\x20are\x20committed\x20to\x20the\x20threshold\x20outcome','Two-leg\x20escrow\x20exit\x20(D-BUG-2\x20polarity):\x20release\x20leg\x20(→\x20project\x20Entity)\x20gated\x20logic_and[sum_where\x20>=\x20threshold,\x20clock\x20>=\x20deadline];\x20refund\x20leg\x20(→\x20for_object,\x20the\x20funder\x27s\x20own\x20Order)\x20gated\x20logic_and[sum_where\x20<\x20threshold,\x20clock\x20>=\x20deadline]\x20—\x20mutually\x20exclusive\x20on\x20the\x20aggregate\x20comparison,\x20so\x20exactly\x20one\x20is\x20satisfiable\x20once\x20the\x20deadline\x20passes','Keeper\x20batch\x20settlement:\x20on\x20a\x20missed\x20campaign\x20a\x20keeper\x20enumerates\x20every\x20contributor\x20via\x20repository.data\x20find-where\x20(1176\x20→\x20VectorAddress)\x20/\x20keys-where\x20(1177\x20→\x20VectorString)\x20and\x20advances\x20each\x20funder\x27s\x20refund\x20leg\x20in\x20one\x20PTB\x20(or\x20N\x20PTBs)\x20—\x20an\x20ops\x20efficiency,\x20not\x20a\x20chain\x20capability','🔴\x20AGGREGATE\x20TRUST\x20BOUNDARY:\x20the\x20sum\x20is\x20only\x20as\x20honest\x20as\x20the\x20writer-bound\x20rows;\x20it\x20is\x20NOT\x20independently\x20re-derivable\x20on-chain\x20without\x20reading\x20every\x20escrow\x20balance.\x20Disclose\x20this\x20honestly\x20(L-04);\x20never\x20present\x20the\x20threshold\x20as\x20a\x20chain-verified\x20total-custody\x20proof','🔴\x20L-01\x20NON-INVESTMENT:\x20crowdfunding\x20copy\x20must\x20never\x20promise\x20investment\x20returns,\x20yield,\x20or\x20token-price\x20appreciation\x20—\x20it\x20is\x20a\x20threshold\x20purchase/preorder/donation,\x20not\x20a\x20security','🔴\x20L-05\x20KYC/AML:\x20pooled\x20fundraising\x20is\x20high\x20regulatory\x20intensity\x20—\x20cross-border\x20funds\x20and\x20reward\x20tiers\x20may\x20trigger\x20securities/money-transmission\x20rules;\x20flag\x20for\x20compliance,\x20do\x20not\x20automate\x20around\x20them','R-M1-11:\x20no\x20\x27refunded\x27/\x27cancelled\x27\x20fund\x20terminals\x20—\x20the\x20refund\x20leg\x20routes\x20via\x20the\x20Allocator\x20triggered\x20by\x20the\x20missed-threshold\x20business\x20state\x20at\x20deadline;\x20disputes\x20go\x20to\x20Arbitration']},{'name':'delivery','phase':0x1,'industry':'Restaurant\x20food-delivery\x20/\x20on-demand\x20errand\x20(local\x20fulfillment)','trust_pattern':'Escrow-through-delivery\x20+\x20roster-authorized\x20per-order\x20rider\x20+\x20serial\x20claim\x20window','traits':{'has_logistics':!![],'communication_heavy':!![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':'delivery/restaurant-marketplace','key_risk':'Per-order\x20dispatched\x20riders\x20have\x20no\x20on-chain\x20identity\x20—\x20the\x20named-operator\x20roster\x20is\x20their\x20ONLY\x20authorized\x20forward\x20and\x20the\x20roster\x20writer\x20is\x20the\x20de-facto\x20rider\x20admitter\x20(undisclosed,\x20a\x20silent\x20centralization);\x20handover\x20records\x20are\x20unwitnessable\x20by\x20the\x20buyer;\x20rider\x20pay\x20is\x20the\x20platform\x27s\x20off-chain\x20payroll\x20BY\x20DESIGN\x20(T-06\x20correction,\x20sso-tn-261027-7f3a91:\x20a\x20Signer\x20allocator\x20leg\x20CAN\x20pay\x20a\x20per-order\x20rider\x20directly\x20—\x20allocation.move:625-630\x20bypasses\x20the\x20for_object\x20lock\x20that\x20binds\x20only\x20GuardIdentifier\x20submissions)','build_notes':['Hours-scale\x20windows,\x20not\x20retail\x20DAYS:\x20auto-confirm\x201-2h,\x20claim\x20window\x2024h,\x20settlement\x2024h\x20—\x20food\x20is\x20perishable;\x20anchor\x20every\x20relative\x20gate\x20on\x20progress.history.time\x20(query\x201280,\x20find=last),\x20never\x201272\x20current_time','Dispatch\x20is\x20OFF-CHAIN\x20(K-4):\x20the\x20chain\x20has\x20no\x20dispatch/scheduling\x20primitive\x20—\x20the\x20rider\x27s\x20only\x20chain\x20footprint\x20is\x20the\x20per-order\x20namedOperator\x20roster\x20(permission\x20index\x20221);\x20the\x20roster\x27s\x20write\x20power\x20is\x20the\x20rider-admission\x20power\x20and\x20MUST\x20be\x20disclosed\x20(NAMED_OPERATOR_ROSTER_UNDISCLOSED)','Riders\x20are\x20paid\x20by\x20the\x20platform\x20in\x20this\x20shape\x20(T-06\x20correction,\x20sso-tn-261027-7f3a91):\x20a\x20GuardIdentifier\x20leg\x20pays\x20the\x20order\x27s\x20own\x20CoinWrapper\x20(allocation.move:621),\x20so\x20a\x20slot\x20leg\x20is\x20unfundable\x20for\x20a\x20person\x20—\x20but\x20a\x20Signer\x20leg\x20IS\x20an\x20on-chain\x20payee\x20shape\x20for\x20the\x20rostered\x20rider\x20(allocation.move:625-630,\x20proven\x20live);\x20the\x20shipped\x20default\x20routes\x20pay\x20through\x20the\x20commission\x20leg\x20as\x20off-chain\x20payroll\x20instead','Serial\x20claim\x20window\x20(TPL-09):\x20settlement\x20departs\x20a\x20mandatory\x20claim_window\x20node\x20so\x20no\x20release\x20can\x20fire\x20while\x20a\x20dispute\x20could\x20still\x20be\x20filed\x20(FACT-ALLOC-03);\x20assert\x20settle_hours\x20>=\x20claim_window_hours\x20at\x20generation','Fee-graded\x20cancellation:\x20a\x20pre-acceptance\x20cancel\x20refunds\x20in\x20full,\x20a\x20post-acceptance\x20kill\x20pays\x20a\x20prep\x20fee\x20—\x20distinct\x20closed_cancel\x20/\x20closed_kill\x20terminals\x20so\x20fee\x20and\x20full\x20refund\x20never\x20share\x20a\x20rail','Transit\x20loss\x20has\x20a\x20buyer\x20rail:\x20an\x20identity-only\x20ReportTransitLoss\x20declaration\x20into\x20the\x20dispute\x20waypoint\x20(no\x20window\x20mid-transit\x20—\x20the\x20anchor\x20row\x20does\x20not\x20exist\x20yet,\x20F-TPL-01\x20trap);\x20the\x20remedy\x20route\x20is\x20arbitration\x20into\x20the\x20full-refund\x20rail,\x20disclosed']},{'name':'group_buy','phase':0x1,'industry':'Community\x20group-buying\x20(leader\x20consolidation\x20+\x20neighborhood\x20pickup)','trust_pattern':'Shared\x20ABSOLUTE\x20batch\x20cutoff\x20+\x20batch\x20consolidation\x20+\x20threshold-gated\x20release\x20(challenger:\x20per-backer\x20unpooled\x20escrow)','traits':{'has_logistics':!![],'communication_heavy':!![],'pure_digital':![],'long_cycle':![],'deposit_required':!![],'multi_tier_allocation':!![]},'default_template':'group_buy/platform-supplied-pickup','key_risk':'The\x20buyer\x20pre-pays\x20against\x20a\x20batch\x20that\x20may\x20never\x20form,\x20and\x20the\x20challenger\x27s\x20supply\x20chain\x20is\x20OFF-CHAIN\x20(undiligence-able\x20before\x20purchase\x20—\x20the\x20trust\x20gap\x20and\x20the\x20main\x20arbitration\x20evidence\x20source);\x20the\x20batch\x20cutoff\x20must\x20be\x20ONE\x20shared\x20absolute\x20timestamp\x20(keeper-written\x20Repository\x20row),\x20never\x20a\x20per-order\x20entry+duration\x20lock;\x20multi-level\x20commission\x20schemes\x20are\x20NOT\x20expressible\x20(single-layer\x20commission\x20only)','build_notes':['The\x20batch\x20cutoff\x20is\x20a\x20SHARED\x20ABSOLUTE\x20timestamp\x20(pattern.time_lock_absolute):\x20one\x20clock\x20for\x20every\x20buyer\x20in\x20the\x20batch,\x20keeper-written\x20per\x20batch\x20into\x20a\x20Repository\x20row\x20—\x20chain\x20Clock\x20is\x20block-driven,\x20so\x20a\x20real-world\x20calendar\x20cutoff\x20(23:00\x20daily)\x20needs\x20pattern.time_source_repository_oracle;\x20a\x20per-order\x20entry+duration\x20lock\x20gives\x20every\x20buyer\x20a\x20DIFFERENT\x20cutoff\x20and\x20is\x20not\x20a\x20batch','Supply-chain\x20suborder\x20commitment\x20(leader):\x20the\x20supplier\x27s\x20sub-service\x20address\x20is\x20a\x20FIXED\x20promise\x20in\x20the\x20ConsolidateBatch\x20guard\x20table\x20(b_submission\x20false,\x20value_type\x20Address)\x20—\x20the\x20whole\x20procurement\x20graph\x20is\x20enumerable\x20and\x20diligence-able\x20BEFORE\x20any\x20buyer\x20pays\x20(the\x20structural\x20trust\x20advantage);\x20the\x20challenger\x20(leader-sourced)\x20has\x20NO\x20such\x20commitment\x20—\x20disclose\x20it\x20as\x20the\x20structural\x20trust\x20gap','Threshold\x20mode\x20reuses\x20the\x20crowdfunding\x20construction\x20wholesale:\x20unpooled\x20per-backer\x20escrow\x20(for_object\x20=\x20the\x20backer\x27s\x20own\x20order),\x20ORDER-keyed\x20contribution\x20rows,\x20the\x20escrow-bound\x20aggregate\x20(per-row\x20min(row,\x20order.amount))\x20and\x20the\x20live-escrow\x20+\x20claimed_by-false\x20legs\x20—\x20the\x20three\x20CROWDFUNDING_*\x20blockers\x20apply\x20automatically','Pickup-point\x20topology:\x20staffed\x20points\x20ride\x20the\x20named-operator\x20leader\x20rail\x20(ShelveAtPoint\x20+\x20HandOverByPoint);\x20AUTOMATED\x20lockers\x20drop\x20both\x20(a\x20locker\x20cannot\x20sign\x20—\x20the\x20buyer\x27s\x20own\x20Collect\x20signature\x20is\x20the\x20stronger\x20handover\x20proof);\x20the\x20unclaimed-goods\x20exit\x20window\x20is\x20mandatory\x20(goods\x20never\x20picked\x20up\x20must\x20refund\x20at\x20a\x20bounded\x20deadline)','Leader\x20commission\x20is\x20a\x20single-layer\x20rate\x20leg\x20paid\x20to\x20the\x20platform\x20Entity\x20with\x20OFF-CHAIN\x20pass-through\x20(a\x20per-order\x20third\x20party\x20has\x20no\x20on-chain\x20payee\x20shape\x20—\x20for_object\x20lock,\x20allocation.move:621);\x20multi-level/regional\x20commission\x20is\x20NOT\x20expressible\x20—\x20disclose','Delay\x20compensation\x20pays\x20from\x20the\x20compensation_fund,\x20NEVER\x20from\x20the\x20buyer\x27s\x20escrow\x20(Order\x20binds\x20<=\x201\x20allocator);\x20the\x20fund\x20must\x20be\x20pre-locked\x20to\x203x\x20the\x20largest\x20order\x20(B2)\x20or\x20higher\x20tiers\x20are\x20silently\x20unsellable']},{'name':'general','phase':0x1,'industry':'Anything\x20not\x20covered\x20/\x20hybrid','trust_pattern':'User-defined\x20from\x20scratch','traits':{'has_logistics':![],'communication_heavy':![],'pure_digital':![],'long_cycle':![],'deposit_required':![],'multi_tier_allocation':![]},'default_template':null,'key_risk':'No\x20safety\x20net\x20—\x20user\x20must\x20design\x20all\x20trust\x20mechanisms\x20manually','build_notes':['Escape\x20hatch:\x20any\x20user\x20can\x20switch\x20to\x20general\x20mode\x20at\x20any\x20time','Already-created\x20objects\x20under\x20a\x20previous\x20mode\x20remain\x20on-chain\x20(REUSE\x20pattern)','wowok-machine\x20/\x20wowok-guard\x20/\x20wowok-provider\x20become\x20primary\x20references']}];export function matchScenarioMode(a){const b=a['toLowerCase'](),c=inferScenarioTraits(a),e=SCENARIO_MODES['map'](h=>{let i=0x0,j=0x0;for(const k of Object['keys'](c)){j+=0x1;if(h['traits'][k]===c[k])i+=0x1;}if(h['name']!=='general'){const l=MODE_KEYWORDS[h['name']]??[];for(const m of l){if(b['includes'](m))i+=0.5;}}return{'mode':h,'score':i,'total':j};});let f=e[0x0];for(const h of e){if(h['score']>f['score'])f=h;}const g=f['total']>0x0?Math['min'](0x1,f['score']/f['total']):0x0;return{'mode':f['mode'],'confidence':g};}const MODE_KEYWORDS={'freelance':['freelance','design','develop','consult','write','consulting'],'rental':['rent','rental','lease','borrow','equipment','vehicle','property'],'education':['course','training','tutor','teach','education','class'],'travel':['tour','travel','trip','itinerary','vacation'],'subscription':['subscribe','subscription','membership','saas','newsletter','recurring'],'retail':['retail','shop','store','marketplace','sell\x20goods','ecommerce','e-commerce'],'licensing':['license','licensing','royalty','royalties','ip','intellectual\x20property','music\x20rights','sync','beat','franchise','rights'],'crowdfunding':['crowdfunding','crowdfund','fundraising','pledge','backer','kickstarter','campaign','all-or-nothing','threshold\x20goal','presale\x20campaign','raise\x20funds'],'delivery':['delivery','food\x20delivery','takeout','takeaway','errand','on-demand','rider','courier\x20delivery','waimai','last\x20mile'],'group_buy':['group\x20buy','group-buy','groupbuy','community\x20group','team\x20purchase','batch\x20cutoff','neighborhood\x20pickup','pickup\x20point','tuangou']};export function inferScenarioTraits(a){const b=a['toLowerCase']();return{'has_logistics':/ship|delivery|equipment|vehicle|physical|goods/['test'](b),'communication_heavy':/consult|discuss|back-and-forth|custom|bespoke|negotiate/['test'](b),'pure_digital':/digital|file|download|online|software|code|design|content/['test'](b),'long_cycle':/month|long-term|engagement|project|semester|period/['test'](b),'deposit_required':/deposit|escrow|prepay|tuition|reserve/['test'](b),'multi_tier_allocation':/tier|segment|multi-|agency|hotel|guide|driver/['test'](b)};}export const MODE_COMPOSITIONS=[{'modes':['freelance','subscription'],'use_case':'Retainer\x20consulting\x20(monthly\x20+\x20milestone)','conflict_resolution':'Allocator:\x20split\x20into\x20retainer\x20(subscription)\x20+\x20milestone\x20(freelance)'},{'modes':['rental','education'],'use_case':'Equipment\x20training\x20rental','conflict_resolution':'Machine:\x20extend\x20rental\x20nodes\x20with\x20attendance\x20gates'},{'modes':['travel','rental'],'use_case':'Tour\x20with\x20equipment','conflict_resolution':'Allocator:\x20segment\x20allocation\x20+\x20deposit\x20escrow\x20side-by-side'}];export function getScenarioMode(a){return SCENARIO_MODES['find'](b=>b['name']===a);}export function listScenarioModes(){return SCENARIO_MODES;}export function getShippedModes(){return SCENARIO_MODES['filter'](a=>a['phase']===0x1);}export function getModeCompositions(a){return MODE_COMPOSITIONS['filter'](b=>b['modes']['includes'](a));}export const SCENARIO_MODES_VERSION=0xa;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type DomainPriorMatch, type TraitInferenceResult } from "./industry-generalizer.js";
|
|
3
|
+
import { type IndustryTraits } from "./industry-registry.js";
|
|
4
|
+
export declare const SEMANTIC_IR_SCHEMA_VERSION: 2;
|
|
5
|
+
export declare const SEMANTIC_IR_ACCEPTED_INPUT_VERSIONS: readonly [1, 2];
|
|
6
|
+
export declare const TRAIT_KEYS: Array<keyof IndustryTraits>;
|
|
7
|
+
export declare const SEMANTIC_CLAIM_KEYS: readonly ["reward_pool_amount", "funding_threshold_amount", "min_order_price_amount"];
|
|
8
|
+
export type SemanticClaimKey = (typeof SEMANTIC_CLAIM_KEYS)[number];
|
|
9
|
+
export declare const SemanticIRInputSchema: z.ZodObject<{
|
|
10
|
+
schema_version: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>]>;
|
|
11
|
+
locale: z.ZodString;
|
|
12
|
+
traits: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
13
|
+
trait: z.ZodString;
|
|
14
|
+
value: z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>;
|
|
15
|
+
confidence: z.ZodNumber;
|
|
16
|
+
span: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
start: z.ZodNumber;
|
|
18
|
+
end: z.ZodNumber;
|
|
19
|
+
}, z.core.$strict>>;
|
|
20
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strict>>>;
|
|
22
|
+
domains: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
23
|
+
domain: z.ZodString;
|
|
24
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
span: z.ZodOptional<z.ZodObject<{
|
|
26
|
+
start: z.ZodNumber;
|
|
27
|
+
end: z.ZodNumber;
|
|
28
|
+
}, z.core.$strict>>;
|
|
29
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>>>;
|
|
31
|
+
claims: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
32
|
+
key: z.ZodString;
|
|
33
|
+
value: z.ZodNumber;
|
|
34
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
span: z.ZodOptional<z.ZodObject<{
|
|
36
|
+
start: z.ZodNumber;
|
|
37
|
+
end: z.ZodNumber;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
quote: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strict>>>;
|
|
41
|
+
discovery: z.ZodOptional<z.ZodObject<{
|
|
42
|
+
industry: z.ZodOptional<z.ZodString>;
|
|
43
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
44
|
+
product_ref: z.ZodOptional<z.ZodString>;
|
|
45
|
+
english_summary: z.ZodOptional<z.ZodString>;
|
|
46
|
+
confidence: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
}, z.core.$strict>>;
|
|
48
|
+
provenance: z.ZodObject<{
|
|
49
|
+
source: z.ZodEnum<{
|
|
50
|
+
human: "human";
|
|
51
|
+
caller_llm: "caller_llm";
|
|
52
|
+
}>;
|
|
53
|
+
model: z.ZodOptional<z.ZodString>;
|
|
54
|
+
prompt_version: z.ZodOptional<z.ZodString>;
|
|
55
|
+
generated_at: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
}, z.core.$strict>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export type SemanticIRInput = z.infer<typeof SemanticIRInputSchema>;
|
|
59
|
+
export interface SemanticIRTraitEvidence {
|
|
60
|
+
trait: keyof IndustryTraits;
|
|
61
|
+
value: boolean | string;
|
|
62
|
+
confidence: number;
|
|
63
|
+
span?: {
|
|
64
|
+
start: number;
|
|
65
|
+
end: number;
|
|
66
|
+
};
|
|
67
|
+
quote?: string;
|
|
68
|
+
}
|
|
69
|
+
export interface SemanticIRDomainEvidence {
|
|
70
|
+
domain: string;
|
|
71
|
+
confidence: number;
|
|
72
|
+
span?: {
|
|
73
|
+
start: number;
|
|
74
|
+
end: number;
|
|
75
|
+
};
|
|
76
|
+
quote?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface SemanticIRClaim {
|
|
79
|
+
key: SemanticClaimKey;
|
|
80
|
+
value: number;
|
|
81
|
+
confidence: number;
|
|
82
|
+
span?: {
|
|
83
|
+
start: number;
|
|
84
|
+
end: number;
|
|
85
|
+
};
|
|
86
|
+
quote?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface SemanticIRDiscovery {
|
|
89
|
+
industry?: string;
|
|
90
|
+
tags: string[];
|
|
91
|
+
product_ref?: string;
|
|
92
|
+
english_summary?: string;
|
|
93
|
+
confidence?: number;
|
|
94
|
+
}
|
|
95
|
+
export interface CanonicalSemanticIR {
|
|
96
|
+
schema_version: typeof SEMANTIC_IR_SCHEMA_VERSION;
|
|
97
|
+
locale: string;
|
|
98
|
+
traits: SemanticIRTraitEvidence[];
|
|
99
|
+
domains: SemanticIRDomainEvidence[];
|
|
100
|
+
claims: SemanticIRClaim[];
|
|
101
|
+
discovery: SemanticIRDiscovery;
|
|
102
|
+
provenance: {
|
|
103
|
+
source: "caller_llm" | "human";
|
|
104
|
+
model?: string;
|
|
105
|
+
prompt_version?: string;
|
|
106
|
+
generated_at?: number;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
export interface NormalizedSemanticIR {
|
|
110
|
+
ir: CanonicalSemanticIR;
|
|
111
|
+
digest: string;
|
|
112
|
+
issues: string[];
|
|
113
|
+
}
|
|
114
|
+
export declare function semanticIrDigest(ir: CanonicalSemanticIR): string;
|
|
115
|
+
export declare function normalizeSemanticIR(raw: unknown, options?: {
|
|
116
|
+
source_text?: string;
|
|
117
|
+
}): NormalizedSemanticIR;
|
|
118
|
+
export declare function discoverySignal(ir: CanonicalSemanticIR): SemanticIRDiscovery | undefined;
|
|
119
|
+
export declare function claimNumber(ir: CanonicalSemanticIR, key: SemanticClaimKey): number | undefined;
|
|
120
|
+
export interface SemanticIRConflict {
|
|
121
|
+
trait: string;
|
|
122
|
+
keyword_value: boolean | string;
|
|
123
|
+
keyword_confidence: number;
|
|
124
|
+
ir_value: boolean | string;
|
|
125
|
+
ir_confidence: number;
|
|
126
|
+
}
|
|
127
|
+
export interface MergedTraitInference extends TraitInferenceResult {
|
|
128
|
+
conflicts: SemanticIRConflict[];
|
|
129
|
+
}
|
|
130
|
+
export declare function mergeSemanticIR(base: TraitInferenceResult, ir: CanonicalSemanticIR): MergedTraitInference;
|
|
131
|
+
export declare function domainPriorsFromIR(ir: CanonicalSemanticIR): DomainPriorMatch[];
|
|
132
|
+
export declare function mergeDomainPriors(keywordPriors: DomainPriorMatch[], irPriors: DomainPriorMatch[]): DomainPriorMatch[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createHash}from'node:crypto';import{z}from'zod';import{DISCOVERY_PRODUCT_REFS,DISCOVERY_TAG_VOCABULARY,isDiscoveryTag}from'./builtin-templates.js';import{BOOLEAN_TRAIT_KEYS,DOMAIN_PRIORS,ENUM_TRAIT_SCALES,EVIDENCE_THRESHOLD}from'./industry-generalizer.js';import{isRegisteredIndustry,resolveIndustryName}from'./industry-registry.js';export const SEMANTIC_IR_SCHEMA_VERSION=0x2;export const SEMANTIC_IR_ACCEPTED_INPUT_VERSIONS=[0x1,0x2];export const TRAIT_KEYS=[...BOOLEAN_TRAIT_KEYS,...Object['keys'](ENUM_TRAIT_SCALES)];export const SEMANTIC_CLAIM_KEYS=['reward_pool_amount','funding_threshold_amount','min_order_price_amount'];const SpanSchema=z['object']({'start':z['number']()['int']()['nonnegative'](),'end':z['number']()['int']()['nonnegative']()})['strict'](),TraitEvidenceSchema=z['object']({'trait':z['string']()['max'](0x40),'value':z['union']([z['boolean'](),z['string']()['max'](0x20)]),'confidence':z['number'](),'span':SpanSchema['optional'](),'quote':z['string']()['max'](0x12c)['optional']()})['strict'](),DomainEvidenceSchema=z['object']({'domain':z['string']()['max'](0x40),'confidence':z['number']()['optional'](),'span':SpanSchema['optional'](),'quote':z['string']()['max'](0x12c)['optional']()})['strict'](),ClaimEvidenceSchema=z['object']({'key':z['string']()['max'](0x40),'value':z['number'](),'confidence':z['number']()['optional'](),'span':SpanSchema['optional'](),'quote':z['string']()['max'](0x12c)['optional']()})['strict'](),ProvenanceSchema=z['object']({'source':z['enum'](['caller_llm','human']),'model':z['string']()['max'](0x78)['optional'](),'prompt_version':z['string']()['max'](0x3c)['optional'](),'generated_at':z['number']()['int']()['nonnegative']()['optional']()})['strict'](),DiscoveryEvidenceSchema=z['object']({'industry':z['string']()['max'](0x40)['optional'](),'tags':z['array'](z['string']()['max'](0x40))['max'](0x14)['optional'](),'product_ref':z['string']()['max'](0x40)['optional'](),'english_summary':z['string']()['max'](0x258)['optional'](),'confidence':z['number']()['optional']()})['strict']();export const SemanticIRInputSchema=z['object']({'schema_version':z['union']([z['literal'](0x1),z['literal'](0x2)]),'locale':z['string']()['min'](0x2)['max'](0x23),'traits':z['array'](TraitEvidenceSchema)['max'](0x14)['optional'](),'domains':z['array'](DomainEvidenceSchema)['max'](0xa)['optional'](),'claims':z['array'](ClaimEvidenceSchema)['max'](0xa)['optional'](),'discovery':DiscoveryEvidenceSchema['optional'](),'provenance':ProvenanceSchema})['strict']();export function semanticIrDigest(a){return createHash('sha256')['update'](JSON['stringify'](a))['digest']('hex');}function traitOrder(a){return TRAIT_KEYS['indexOf'](a);}function vocabularyPreview(a,b=0xc){const c=a['slice'](0x0,b)['join'](',\x20');return a['length']>b?c+',\x20…\x20('+a['length']+'\x20total)':c;}function normalizeDiscovery(a,b){const c=new Set();for(const h of a?.['tags']??[]){const i=h['trim']()['toLowerCase']();if(!i)continue;if(!isDiscoveryTag(i)){b['push']('unknown\x20discovery\x20tag\x20\x27'+h+'\x27\x20ignored\x20(vocabulary:\x20'+vocabularyPreview(DISCOVERY_TAG_VOCABULARY)+')');continue;}c['add'](i);}let d;if(a?.['industry']!==undefined){const j=resolveIndustryName(a['industry']);!j||!isRegisteredIndustry(j)?b['push']('unknown\x20discovery\x20industry\x20\x27'+a['industry']+'\x27\x20ignored\x20(not\x20a\x20registered\x20industry)'):d=j;}let e;if(a?.['product_ref']!==undefined){const k=a['product_ref']['trim']()['toLowerCase']();!DISCOVERY_PRODUCT_REFS['includes'](k)?b['push']('unknown\x20discovery\x20product_ref\x20\x27'+a['product_ref']+'\x27\x20ignored\x20'+('(builtin\x20benchmark\x20products:\x20'+vocabularyPreview(DISCOVERY_PRODUCT_REFS)+')')):e=k;}const f=a?.['english_summary']?.['trim'](),g={'tags':[...c]['sort']()};if(d)g['industry']=d;if(e)g['product_ref']=e;if(f)g['english_summary']=f;if(a?.['confidence']!==undefined){if(!Number['isFinite'](a['confidence']))b['push']('discovery\x20confidence\x20is\x20not\x20finite;\x20discovery\x20evidence\x20ignored\x20at\x20match\x20time');else{const l=Math['max'](0x0,Math['min'](0x1,a['confidence']));l!==a['confidence']&&b['push']('discovery\x20confidence\x20'+a['confidence']+'\x20clamped\x20to\x20'+l),l<EVIDENCE_THRESHOLD&&b['push']('discovery\x20confidence\x20'+l+'\x20is\x20below\x20the\x20evidence\x20threshold\x20'+(EVIDENCE_THRESHOLD+';\x20recorded\x20but\x20not\x20applied')),g['confidence']=l;}}return g;}function anchorEvidence(a,b,c,d){if(a===undefined)return{'span':c['span'],'quote':c['quote']};if(c['quote']!==undefined){const e=a['indexOf'](c['quote']);if(e<0x0)return d['push'](b+'\x20quote\x20was\x20not\x20found\x20verbatim\x20in\x20the\x20source\x20text;\x20evidence\x20dropped'),undefined;const f={'start':e,'end':e+c['quote']['length']};return c['span']&&(c['span']['start']!==f['start']||c['span']['end']!==f['end'])&&d['push'](b+'\x20span\x20re-anchored\x20to\x20the\x20quoted\x20text\x20('+f['start']+'-'+f['end']+')'),{'span':f,'quote':c['quote']};}if(c['span']){if(c['span']['end']>a['length'])return d['push'](b+'\x20span\x20ends\x20past\x20the\x20source\x20text\x20('+c['span']['end']+'\x20>\x20'+a['length']+');\x20evidence\x20dropped'),undefined;if(!a['slice'](c['span']['start'],c['span']['end'])['trim']())return d['push'](b+'\x20span\x20covers\x20no\x20text;\x20evidence\x20dropped'),undefined;return{'span':c['span']};}return{};}export function normalizeSemanticIR(a,b={}){const e=SemanticIRInputSchema['safeParse'](a);if(!e['success']){const x=e['error']['issues']['map'](y=>(y['path']['length']>0x0?y['path']['join']('.'):'(root)')+':\x20'+y['message'])['join'](';\x20');throw new Error('semantic_ir\x20rejected:\x20'+x);}const f=[],g=[];for(const y of e['data']['traits']??[]){if(!TRAIT_KEYS['includes'](y['trait'])){f['push']('unknown\x20trait\x20\x27'+y['trait']+'\x27\x20ignored\x20(vocabulary:\x20'+TRAIT_KEYS['join'](',\x20')+')');continue;}const A=y['trait'],B=BOOLEAN_TRAIT_KEYS['includes'](A);if(B){if(typeof y['value']!=='boolean'){f['push']('trait\x20\x27'+A+'\x27\x20is\x20boolean;\x20value\x20\x27'+String(y['value'])+'\x27\x20ignored');continue;}}else{const F=ENUM_TRAIT_SCALES[A];if(!F||typeof y['value']!=='string'||!F['includes'](y['value'])){f['push']('trait\x20\x27'+A+'\x27\x20expects\x20one\x20of\x20['+(F??[])['join'](',\x20')+'];\x20'+('value\x20\x27'+String(y['value'])+'\x27\x20ignored'));continue;}}if(!Number['isFinite'](y['confidence'])){f['push']('trait\x20\x27'+A+'\x27\x20confidence\x20is\x20not\x20finite;\x20evidence\x20ignored');continue;}const C=Math['max'](0x0,Math['min'](0x1,y['confidence']));C!==y['confidence']&&f['push']('trait\x20\x27'+A+'\x27\x20confidence\x20'+y['confidence']+'\x20clamped\x20to\x20'+C);C<EVIDENCE_THRESHOLD&&f['push']('trait\x20\x27'+A+'\x27\x20confidence\x20'+C+'\x20is\x20below\x20the\x20evidence\x20threshold\x20'+(EVIDENCE_THRESHOLD+';\x20recorded\x20but\x20not\x20applied'));let D;y['span']&&(y['span']['end']<y['span']['start']?f['push']('trait\x20\x27'+A+'\x27\x20span\x20has\x20end\x20<\x20start;\x20span\x20dropped'):D={'start':y['span']['start'],'end':y['span']['end']});const E={'trait':A,'value':y['value'],'confidence':C};if(D)E['span']=D;if(y['quote']!==undefined)E['quote']=y['quote'];g['push'](E);}g['sort']((G,H)=>{const I=traitOrder(G['trait'])-traitOrder(H['trait']);if(I!==0x0)return I;if(H['confidence']!==G['confidence'])return H['confidence']-G['confidence'];return JSON['stringify'](G['value'])['localeCompare'](JSON['stringify'](H['value']));});const h=[],i=new Map();for(const G of g){const H=i['get'](G['trait']);if(!H){i['set'](G['trait'],G),h['push'](G);continue;}H['value']!==G['value']&&f['push']('conflicting\x20evidence\x20for\x20\x27'+G['trait']+'\x27:\x20'+('kept\x20\x27'+String(H['value'])+'\x27\x20(confidence\x20'+H['confidence']+')\x20over\x20')+('\x27'+String(G['value'])+'\x27\x20(confidence\x20'+G['confidence']+')'));}const j=[];for(const I of e['data']['domains']??[]){if(!DOMAIN_PRIORS['some'](M=>M['domain']===I['domain'])){f['push']('unknown\x20domain\x20\x27'+I['domain']+'\x27\x20ignored\x20(vocabulary:\x20'+DOMAIN_PRIORS['map'](M=>M['domain'])['join'](',\x20')+')');continue;}const J=I['confidence']??0x1;if(!Number['isFinite'](J)){f['push']('domain\x20\x27'+I['domain']+'\x27\x20confidence\x20is\x20not\x20finite;\x20evidence\x20ignored');continue;}const K=Math['max'](0x0,Math['min'](0x1,J));K!==J&&f['push']('domain\x20\x27'+I['domain']+'\x27\x20confidence\x20'+J+'\x20clamped\x20to\x20'+K);K<EVIDENCE_THRESHOLD&&f['push']('domain\x20\x27'+I['domain']+'\x27\x20confidence\x20'+K+'\x20is\x20below\x20the\x20evidence\x20threshold\x20'+(EVIDENCE_THRESHOLD+';\x20recorded\x20but\x20not\x20applied'));const L={'domain':I['domain'],'confidence':K};if(I['span']&&I['span']['end']>=I['span']['start'])L['span']={'start':I['span']['start'],'end':I['span']['end']};else{if(I['span'])f['push']('domain\x20\x27'+I['domain']+'\x27\x20span\x20has\x20end\x20<\x20start;\x20span\x20dropped');}if(I['quote']!==undefined)L['quote']=I['quote'];j['push'](L);}j['sort']((M,N)=>{if(N['confidence']!==M['confidence'])return N['confidence']-M['confidence'];return M['domain']['localeCompare'](N['domain']);});const k=[],l=new Set();for(const M of j){if(l['has'](M['domain']))continue;l['add'](M['domain']),k['push'](M);}const m=[];for(const N of e['data']['claims']??[]){if(!SEMANTIC_CLAIM_KEYS['includes'](N['key'])){f['push']('unknown\x20claim\x20\x27'+N['key']+'\x27\x20ignored\x20(vocabulary:\x20'+SEMANTIC_CLAIM_KEYS['join'](',\x20')+')');continue;}const O=N['key'];if(!Number['isFinite'](N['value'])){f['push']('claim\x20\x27'+O+'\x27\x20value\x20is\x20not\x20finite;\x20ignored');continue;}if(N['value']<0x0){f['push']('claim\x20\x27'+O+'\x27\x20value\x20'+N['value']+'\x20is\x20negative;\x20ignored');continue;}const P=N['confidence']??0x1;if(!Number['isFinite'](P)){f['push']('claim\x20\x27'+O+'\x27\x20confidence\x20is\x20not\x20finite;\x20claim\x20ignored');continue;}const Q=Math['max'](0x0,Math['min'](0x1,P));Q!==P&&f['push']('claim\x20\x27'+O+'\x27\x20confidence\x20'+P+'\x20clamped\x20to\x20'+Q);Q<EVIDENCE_THRESHOLD&&f['push']('claim\x20\x27'+O+'\x27\x20confidence\x20'+Q+'\x20is\x20below\x20the\x20evidence\x20threshold\x20'+(EVIDENCE_THRESHOLD+';\x20recorded\x20but\x20not\x20applied'));const R={'key':O,'value':N['value'],'confidence':Q};N['span']&&(N['span']['end']<N['span']['start']?f['push']('claim\x20\x27'+O+'\x27\x20span\x20has\x20end\x20<\x20start;\x20span\x20dropped'):R['span']={'start':N['span']['start'],'end':N['span']['end']});if(N['quote']!==undefined)R['quote']=N['quote'];m['push'](R);}m['sort']((S,T)=>{if(S['key']!==T['key'])return S['key']<T['key']?-0x1:0x1;return T['confidence']-S['confidence'];});const n=[],o=new Map();for(const S of m){const T=o['get'](S['key']);if(!T){o['set'](S['key'],S),n['push'](S);continue;}T['value']!==S['value']&&f['push']('conflicting\x20evidence\x20for\x20claim\x20\x27'+S['key']+'\x27:\x20'+('kept\x20'+T['value']+'\x20(confidence\x20'+T['confidence']+')\x20over\x20')+(S['value']+'\x20(confidence\x20'+S['confidence']+')'));}const p=b['source_text']&&b['source_text']['trim']()?b['source_text']:undefined,q=[];for(const U of h){const V=anchorEvidence(p,'trait\x20\x27'+U['trait']+'\x27',U,f);if(!V)continue;if(V['span'])U['span']=V['span'];else delete U['span'];if(V['quote']!==undefined)U['quote']=V['quote'];q['push'](U);}const r=[];for(const W of k){const X=anchorEvidence(p,'domain\x20\x27'+W['domain']+'\x27',W,f);if(!X)continue;if(X['span'])W['span']=X['span'];else delete W['span'];if(X['quote']!==undefined)W['quote']=X['quote'];r['push'](W);}const s=[];for(const Y of n){const Z=anchorEvidence(p,'claim\x20\x27'+Y['key']+'\x27',Y,f);if(!Z)continue;if(Z['span'])Y['span']=Z['span'];else delete Y['span'];if(Z['quote']!==undefined)Y['quote']=Z['quote'];s['push'](Y);}const t=normalizeDiscovery(e['data']['discovery'],f),u=t['industry']!==undefined||t['product_ref']!==undefined||t['english_summary']!==undefined||t['tags']['length']>0x0;q['length']===0x0&&r['length']===0x0&&s['length']===0x0&&!u&&f['push']('semantic_ir\x20carries\x20no\x20usable\x20evidence;\x20keyword\x20inference\x20is\x20the\x20only\x20signal');const v={'source':e['data']['provenance']['source']};if(e['data']['provenance']['model']!==undefined)v['model']=e['data']['provenance']['model'];e['data']['provenance']['prompt_version']!==undefined&&(v['prompt_version']=e['data']['provenance']['prompt_version']);e['data']['provenance']['generated_at']!==undefined&&(v['generated_at']=e['data']['provenance']['generated_at']);const w={'schema_version':SEMANTIC_IR_SCHEMA_VERSION,'locale':e['data']['locale'],'traits':q,'domains':r,'claims':s,'discovery':t,'provenance':v};return{'ir':w,'digest':semanticIrDigest(w),'issues':f};}export function discoverySignal(a){const b=a['discovery'];if((b['confidence']??0x1)<EVIDENCE_THRESHOLD)return undefined;if(b['industry']===undefined&&b['product_ref']===undefined&&b['english_summary']===undefined&&b['tags']['length']===0x0)return undefined;return b;}export function claimNumber(a,b){const c=a['claims']['find'](d=>d['key']===b&&d['confidence']>=EVIDENCE_THRESHOLD);return c?.['value'];}export function mergeSemanticIR(a,b){const c={...a['traits']},d={...a['trait_confidence']},e=[];for(const h of b['traits']){if(h['confidence']<EVIDENCE_THRESHOLD)continue;const i=a['trait_confidence'][h['trait']],j=a['traits'][h['trait']];i!==undefined&&j!==h['value']?(e['push']({'trait':h['trait'],'keyword_value':j,'keyword_confidence':i,'ir_value':h['value'],'ir_confidence':h['confidence']}),d[h['trait']]=h['confidence']):d[h['trait']]=Math['max'](i??0x0,h['confidence']),c[h['trait']]=h['value'];}const f=Object['values'](d)['filter'](k=>(k??0x0)>=EVIDENCE_THRESHOLD)['length'],g=Math['min'](0x1,Math['max'](a['confidence'],f/TRAIT_KEYS['length']));return{'traits':c,'confidence':g,'matched_keywords':[...a['matched_keywords']],'trait_confidence':d,'conflicts':e};}export function domainPriorsFromIR(a){const b=[];for(const c of a['domains']){if(c['confidence']<EVIDENCE_THRESHOLD)continue;const e=DOMAIN_PRIORS['find'](f=>f['domain']===c['domain']);if(!e)continue;b['push']({'domain':e['domain'],'matched_keywords':[],'industries':[...e['industries']],'boost':e['boost'],'source':'semantic_ir'});}return b;}export function mergeDomainPriors(a,b){const c=new Map();for(const d of a){c['set'](d['domain'],{...d,'source':d['source']??'keyword'});}for(const e of b){const f=c['get'](e['domain']);if(!f){c['set'](e['domain'],e);continue;}c['set'](e['domain'],{...f,'matched_keywords':[...new Set([...f['matched_keywords'],...e['matched_keywords']])],'industries':[...new Set([...f['industries'],...e['industries']])],'boost':Math['max'](f['boost'],e['boost']),'source':'both'});}return Array['from'](c['values']());}
|