@clawtopia/werewolf-evolution 0.1.13 → 0.1.15
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/index.js +147 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,10 +7,6 @@ import {
|
|
|
7
7
|
// src/context-store.ts
|
|
8
8
|
import { createHash as createHash2 } from "crypto";
|
|
9
9
|
|
|
10
|
-
// src/envelope.ts
|
|
11
|
-
import { createHash } from "crypto";
|
|
12
|
-
import { z } from "zod";
|
|
13
|
-
|
|
14
10
|
// src/types.ts
|
|
15
11
|
var DEBRIEF_HEADER = "[WEREWOLF_DEBRIEF v2]";
|
|
16
12
|
var DEBRIEF_POLICY_VERSION = "werewolf-debrief-v3";
|
|
@@ -18,6 +14,8 @@ var ENVELOPE_START = "== DEBRIEF_ENVELOPE_JSON ==";
|
|
|
18
14
|
var ENVELOPE_END = "== END_DEBRIEF_ENVELOPE_JSON ==";
|
|
19
15
|
|
|
20
16
|
// src/envelope.ts
|
|
17
|
+
import { createHash } from "crypto";
|
|
18
|
+
import { z } from "zod";
|
|
21
19
|
var MAX_DEBRIEF_BODY_BYTES = 64 * 1024;
|
|
22
20
|
var SAFE_ID = /^[A-Za-z0-9:_-]{1,200}$/;
|
|
23
21
|
var SAFE_PROFILE = /^[a-z0-9][a-z0-9_-]{0,63}$/;
|
|
@@ -333,6 +331,12 @@ var CAPTURE_TTL_MS = 10 * 60 * 1e3;
|
|
|
333
331
|
var MAX_CAPTURES = 256;
|
|
334
332
|
var SUGGESTION_COMMAND = /^\s*(采纳|忽略|拒绝)\s+(S-\d{3,6})\s*[。.!!]?\s*$/i;
|
|
335
333
|
var LEGACY_DIRECT_CONVERSATION = /^private:(?:HUMAN|human):([0-9]+)$/;
|
|
334
|
+
function promptContainsInbound(prompt, inbound) {
|
|
335
|
+
if (prompt.includes(inbound.content)) return true;
|
|
336
|
+
if (inbound.kind !== "debrief") return false;
|
|
337
|
+
const lines = prompt.split(/\r?\n/);
|
|
338
|
+
return lines.includes(DEBRIEF_HEADER) && lines.some((line) => /^debriefId:\s*(\S+)\s*$/.exec(line)?.[1] === inbound.envelope.debriefId);
|
|
339
|
+
}
|
|
336
340
|
function isExplicitConfiguredOwner(config, channelId, senderId) {
|
|
337
341
|
if (channelId !== "clawtopia" && channelId !== "coolclaw" || !senderId) return false;
|
|
338
342
|
const owners = record(record(config)?.commands)?.ownerAllowFrom;
|
|
@@ -450,7 +454,8 @@ var EvolutionContextStore = class {
|
|
|
450
454
|
if (!prompt) return void 0;
|
|
451
455
|
const pending = this.inboundBySession.get(sessionKey);
|
|
452
456
|
if (!pending) return void 0;
|
|
453
|
-
|
|
457
|
+
const matches = pending.filter((candidate) => promptContainsInbound(prompt, candidate));
|
|
458
|
+
return matches.length === 1 ? matches[0] : void 0;
|
|
454
459
|
}
|
|
455
460
|
stableInboundKey(ctx, sessionKey, event) {
|
|
456
461
|
const messageId = event.messageId?.trim();
|
|
@@ -759,6 +764,11 @@ var STRATEGY_LANGUAGE = /(?:改变|改投|改票|转票|投给|投票目标|查
|
|
|
759
764
|
var FIXED_RULE_LANGUAGE = /(?:JSON\s*schema|JSON格式|非法动作|角色动作合法|私有信息保护|不虚构时间线|工具失败|输出超时|现实人格|人身攻击)/i;
|
|
760
765
|
var COUNTER_EFFECT_LANGUAGE = /(?:未能|没有|无法|无效|反而|恶化|失败|矛盾|误导|暴露|did not|failed|ineffective|worse|contradict)/i;
|
|
761
766
|
var NO_TARGET_ALTERNATIVE_LANGUAGE = /(?:保留投票权|等待更多信息|暂不(?:投票|选择|行动)|弃票|不选(?:择)?(?:任何)?(?:目标|座位)|不指定目标|不设目标|继续观望|\b(?:wait for more information|abstain|hold (?:the )?vote|choose no target)\b)/i;
|
|
767
|
+
var AMBIGUOUS_ALTERNATIVE_LANGUAGE = /(?:或者|或是|要么|二选一|[号座]\s*或\s*[1-9]|[1-9][0-9]*\s*[、/]\s*[1-9][0-9]*|[1-9][0-9]*\s*号?\s*(?:和|与)\s*[1-9][0-9]*\s*号?\s*(?:(?:中|之间)\s*)?(?:选择|选一个|任选|择一|中的一个)|\bor\b)/i;
|
|
768
|
+
var TARGET_UNCHANGED_LANGUAGE = /(?:不|不得|不会)(?:改变|更改|调整|切换)(?:当前|原有|既定)?(?:的)?(?:行动|投票|查验|刀人|用药|开枪)?目标|(?:保持|维持)(?:原有|原定|既定|当前|相同)(?:的)?(?:行动|投票|查验|刀人|用药|开枪)?目标/i;
|
|
769
|
+
var RETAINED_TARGET_SEAT_LANGUAGE = /(?:行动|投票|查验|刀人|用药|开枪)?目标\s*(?:仍(?:然)?|依然|依旧|继续|保持|维持|不变)\s*(?:是|为)?\s*([1-9][0-9]*)\s*号/i;
|
|
770
|
+
var LOCAL_OUTCOME_INFERENCE_LANGUAGE = /(?:,|;|。|,|;)\s*(?:(?:由此|因此|从而|所以)(?:可见|可知|可判断|说明|证明|表明|意味着)?|(?:这)?(?:说明|证明|表明|意味着|可见|足以(?:说明|证明|表明))|\b(?:therefore|thus|this (?:proves?|shows?|means?))\b)/i;
|
|
771
|
+
var ABSOLUTE_STRATEGY_LANGUAGE = /(?:必须|必然|绝对|肯定|一定|毫无疑问|等于直接|唯一(?:正确|合理)?(?:的)?(?:选择|做法)|只能|只能够|无论如何(?:都)?|非[^。;,,!!]{0,8}不可|别无选择|\bmust\b|\balways\b|\bnever\b|\bdefinitely\b|\bcertain(?:ly)?\b|\bguaranteed?\b|the only (?:correct |valid )?(?:choice|option))/i;
|
|
762
772
|
var EXPLICIT_TARGET_LANGUAGE = /(?:(?:改投|改票(?:到|给)?|归票|票投|投票(?:给|到)?|投(?:给|到)?|查验|验|刀|毒|救|开枪带走|目标(?:改为|是)?)\s*|target(?:\s+seat)?[^0-9]{0,6})([1-9][0-9]*)\s*(?:号|座|\b)/gi;
|
|
763
773
|
var FINAL_RESULT_LANGUAGE = /(?:最终|终局|全场|对局结果|比赛结果)[^。;,,!!]{0,16}(?:获胜|胜利|胜出|取胜|赢了|输了|落败|失败)|(?:好人(?:阵营)?|村民|平民|狼人(?:阵营)?|狼队)[^。;,,!!]{0,10}(?:获胜|胜利|胜出|取胜|赢了|输了|落败)|(?:险胜|惨胜|翻盘获胜|为(?:最终)?胜利铺路)|赢下(?:本局|这局|对局|比赛)|(?:GOOD|WOLF)(?:_TEAM)?_WIN|(?:the\s+)?(?:(?:good|village|wolf)\s+team|villagers?|village|wolves|wolf|werewolves?)\s+(?:wins?|won|loses?|lost)|(?:won|lost) the game|final (?:victory|defeat)/i;
|
|
764
774
|
var SEAT_REFERENCE_LANGUAGE = /([1-9][0-9]*)\s*号(?:玩家)?/g;
|
|
@@ -775,7 +785,7 @@ var RELATIVE_FUTURE_BEHAVIOR_LANGUAGE = new RegExp(
|
|
|
775
785
|
var ABSOLUTE_DAY_BEHAVIOR_LANGUAGE = new RegExp(`(?:\u7B2C([0-9\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341]+)|([\u4E00\u4E8C\u4E09\u56DB\u4E94\u516D\u4E03\u516B\u4E5D\u5341]+))\\s*(?:\u5929|\u8F6E|\u56DE\u5408|\u591C|\u591C\u665A)[^\u3002\uFF1B\uFF0C,!\uFF01]{0,24}(?:${BEHAVIOR_TERMS})`, "gi");
|
|
776
786
|
var BEHAVIOR_OCCURRENCE_LANGUAGE = new RegExp(`(?:${BEHAVIOR_TERMS})`, "i");
|
|
777
787
|
var PAST_BEHAVIOR_LANGUAGE = new RegExp(`(?:\u6B64\u524D|\u4E4B\u524D|\u66FE\u7ECF|\u8FC7\u53BB|\u4E0A\u4E00\u8F6E|\u4E0A\u4E00\u591C|\u6628\u591C)|\u5DF2\u7ECF(?!\u51B3\u5B9A)[^\u3002\uFF1B\uFF0C,!\uFF01]{0,4}(?:${BEHAVIOR_TERMS})`, "i");
|
|
778
|
-
var CURRENT_ACTOR_ACTION_LANGUAGE = /(
|
|
788
|
+
var CURRENT_ACTOR_ACTION_LANGUAGE = /(?:当前|本次|此时|轮到|发言(?:时|中)|投票时|行动时|查验时|已经决定|正在|正要|准备|计划|将要)/i;
|
|
779
789
|
var NEGATED_BEHAVIOR_LANGUAGE = new RegExp(`(?:\u6CA1\u6709|\u5E76\u672A|\u672A\u66FE|\u4E0D\u66FE|\u4ECE\u672A|\u5C1A\u672A|\u4E0D)[^\u3002\uFF1B\uFF0C,!\uFF01]{0,6}(?:${BEHAVIOR_TERMS})|(?:did not|never|no)\\b`, "i");
|
|
780
790
|
var BEHAVIOR_TARGET_LANGUAGE = /(?:归票|投票(?:给|到)?|票投(?:给|到)?|投(?:给|到)|跟票(?:给|到)?|冲票(?:给|到)?|查杀|保人|踩|攻击|质疑)(?:给|到|向)?\s*([1-9][0-9]*)\s*号/i;
|
|
781
791
|
var TARGET_REFERENCE_PREFIX = /(?:归票|投票|票投|投给|投到|跟票|冲票|查杀|保人|踩|攻击|质疑)(?:给|到|向)?\s*$/i;
|
|
@@ -996,6 +1006,127 @@ function assertAlternativeTargetConsistent(proposal) {
|
|
|
996
1006
|
);
|
|
997
1007
|
}
|
|
998
1008
|
}
|
|
1009
|
+
function assertCounterfactualCoherence(proposal, anchor) {
|
|
1010
|
+
const alternative = proposal.alternativeAction ?? "";
|
|
1011
|
+
if (AMBIGUOUS_ALTERNATIVE_LANGUAGE.test(alternative)) {
|
|
1012
|
+
throw new ProposalError(
|
|
1013
|
+
"ALTERNATIVE_ACTION_AMBIGUOUS",
|
|
1014
|
+
"alternativeAction must contain exactly one counterfactual action"
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
const target = proposal.alternativeTargetSeat;
|
|
1018
|
+
const boundary = proposal.boundary ?? "";
|
|
1019
|
+
const retainedTarget = RETAINED_TARGET_SEAT_LANGUAGE.exec(boundary);
|
|
1020
|
+
if (target != null && (target !== anchor.targetSeat && TARGET_UNCHANGED_LANGUAGE.test(boundary) || retainedTarget && (Number(retainedTarget[1]) !== anchor.targetSeat || Number(retainedTarget[1]) !== target))) {
|
|
1021
|
+
throw new ProposalError(
|
|
1022
|
+
"ALTERNATIVE_BOUNDARY_CONTRADICTION",
|
|
1023
|
+
"A changed alternative target contradicts a boundary that preserves the target"
|
|
1024
|
+
);
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
function assertNoAbsoluteStrategyClaim(proposal) {
|
|
1028
|
+
const causalClaim = [proposal.rule, proposal.expectedLocalEffect, proposal.falsifier].filter((value) => typeof value === "string").join("\u3002").replace(/(?:(?:不一定|未必|并非|不是)\s*(?:必须|必然|绝对|肯定|一定|只能|只能够|唯一(?:正确|合理)?(?:的)?(?:选择|做法))?|not (?:always|necessarily)(?:\s+(?:must|always|certain|guaranteed|the only (?:choice|option)))?)/gi, "");
|
|
1029
|
+
if (ABSOLUTE_STRATEGY_LANGUAGE.test(causalClaim)) {
|
|
1030
|
+
throw new ProposalError(
|
|
1031
|
+
"SINGLE_GAME_ABSOLUTE_CLAIM",
|
|
1032
|
+
"A single review cannot establish an absolute cross-game strategy claim"
|
|
1033
|
+
);
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
function assertDecisionTypeSemantics(proposal) {
|
|
1037
|
+
if (proposal.decisionType !== "AVOID_REPEATING_PRIOR_SPEAKERS") return;
|
|
1038
|
+
const topic = [proposal.rule, proposal.alternativeAction].filter((value) => typeof value === "string").join("\u3002 ");
|
|
1039
|
+
const omitsRepeatedContent = /(?:省略|删去|跳过|避免|减少|不(?:再|要)?)[^。;,,!!]{0,8}(?:复述|重复)|\b(?:omit|skip|remove|avoid|reduce|do not)\b[^.;]{0,20}\b(?:repeat|duplicate)/i.test(topic);
|
|
1040
|
+
const addsNewInformation = /(?:(?:补充|新增)[^。;,,!!]{0,8}(?:信息|观点|判断|依据|逻辑|内容)|新(?:的)?(?:信息|观点|判断|依据|逻辑|内容)|相对于前置(?:发言|内容))|\b(?:add|provide|state|include)\b[^.;]{0,20}\bnew (?:information|reasoning|judgment|evidence)/i.test(topic);
|
|
1041
|
+
if (!omitsRepeatedContent || !addsNewInformation) {
|
|
1042
|
+
throw new ProposalError(
|
|
1043
|
+
"DECISION_TYPE_SEMANTICS_MISMATCH",
|
|
1044
|
+
"AVOID_REPEATING_PRIOR_SPEAKERS must describe omitting repeated content and adding new information"
|
|
1045
|
+
);
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
function parseVoteCounts(summary) {
|
|
1049
|
+
const match = /DAY_(?:RE)?VOTE_COUNT:\s*\{?([^}\r\n]*)\}?/i.exec(summary);
|
|
1050
|
+
if (!match) return void 0;
|
|
1051
|
+
const counts = /* @__PURE__ */ new Map();
|
|
1052
|
+
const body = match[1].trim();
|
|
1053
|
+
if (!body) return counts;
|
|
1054
|
+
for (const token of body.split(",")) {
|
|
1055
|
+
const pair = /^\s*([1-9][0-9]*)\s*=\s*([0-9]+)\s*$/.exec(token);
|
|
1056
|
+
if (!pair || counts.has(Number(pair[1]))) return void 0;
|
|
1057
|
+
counts.set(Number(pair[1]), Number(pair[2]));
|
|
1058
|
+
}
|
|
1059
|
+
return counts;
|
|
1060
|
+
}
|
|
1061
|
+
function assertedVoteCounts(observed) {
|
|
1062
|
+
const claims = /* @__PURE__ */ new Map();
|
|
1063
|
+
for (const match of observed.matchAll(/([1-9][0-9]*)\s*号(?:玩家)?[^。;,,!!]{0,12}(?:获得|得到|拿到|有|被)\s*([0-9]+)\s*票/g)) {
|
|
1064
|
+
claims.set(Number(match[1]), Number(match[2]));
|
|
1065
|
+
}
|
|
1066
|
+
for (const section of observed.matchAll(/(?:投票计数|票数|票型)[^。;]*/g)) {
|
|
1067
|
+
for (const match of section[0].matchAll(/([1-9][0-9]*)\s*号?\s*=\s*([0-9]+)/g)) {
|
|
1068
|
+
claims.set(Number(match[1]), Number(match[2]));
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
for (const match of observed.matchAll(/(?:seat\s*)?([1-9][0-9]*)\s+(?:received|got|had)\s+([0-9]+)\s+votes?/gi)) {
|
|
1072
|
+
claims.set(Number(match[1]), Number(match[2]));
|
|
1073
|
+
}
|
|
1074
|
+
return [...claims].map(([seat, count]) => ({ seat, count }));
|
|
1075
|
+
}
|
|
1076
|
+
function assertedUnanimousSeat(observed) {
|
|
1077
|
+
const afterSeat = /([1-9][0-9]*)\s*号(?:玩家)?[^。;,,!!]{0,12}(?:全票|一致投票)/.exec(observed);
|
|
1078
|
+
if (afterSeat) return Number(afterSeat[1]);
|
|
1079
|
+
const beforeSeat = /(?:全票|一致投票)[^。;,,!!]{0,12}([1-9][0-9]*)\s*号/.exec(observed);
|
|
1080
|
+
if (beforeSeat) return Number(beforeSeat[1]);
|
|
1081
|
+
const collective = /(?:所有(?:玩家|人)|全部(?:玩家|人)|全体玩家)(?:都|一致)?[^。;,,!!]{0,12}(?:投票?(?:给|到)|投向|把票投给)\s*([1-9][0-9]*)\s*号/.exec(observed);
|
|
1082
|
+
if (collective) return Number(collective[1]);
|
|
1083
|
+
const unanimous = /(?:全部人)?一致投(?:票)?(?:给|到)\s*([1-9][0-9]*)\s*号/.exec(observed);
|
|
1084
|
+
if (unanimous) return Number(unanimous[1]);
|
|
1085
|
+
const english = /(?:all players|everyone)\s+(?:unanimously\s+)?voted\s+for\s+(?:seat\s*)?([1-9][0-9]*)/i.exec(observed);
|
|
1086
|
+
return english ? Number(english[1]) : void 0;
|
|
1087
|
+
}
|
|
1088
|
+
function assertedEliminatedSeats(observed) {
|
|
1089
|
+
const seats = [...observed.matchAll(/([1-9][0-9]*)\s*号(?:玩家)?[^。;,,!!]{0,12}(?:被(?:投出|放逐|票出|投票淘汰|冲出|冲出去))/g)].map((match) => Number(match[1]));
|
|
1090
|
+
for (const match of observed.matchAll(/seat\s*([1-9][0-9]*)[^.;]{0,16}(?:was\s+)?(?:voted out|eliminated by vote)/gi)) {
|
|
1091
|
+
seats.push(Number(match[1]));
|
|
1092
|
+
}
|
|
1093
|
+
return seats;
|
|
1094
|
+
}
|
|
1095
|
+
function assertObservedOutcomeSemantics(observed, outcomeFacts) {
|
|
1096
|
+
if (LOCAL_OUTCOME_INFERENCE_LANGUAGE.test(observed)) {
|
|
1097
|
+
throw new ProposalError(
|
|
1098
|
+
"LOCAL_OUTCOME_INFERENCE",
|
|
1099
|
+
"observedLocalEffect must state later facts directly instead of claiming they prove an interpretation"
|
|
1100
|
+
);
|
|
1101
|
+
}
|
|
1102
|
+
const countFacts = outcomeFacts.filter((fact) => fact.type === "DAY_VOTE_COUNT" || fact.type === "DAY_REVOTE_COUNT").map((fact) => parseVoteCounts(fact.summary)).filter((counts) => counts !== void 0);
|
|
1103
|
+
for (const claim of assertedVoteCounts(observed)) {
|
|
1104
|
+
if (!countFacts.some((counts) => counts.get(claim.seat) === claim.count)) {
|
|
1105
|
+
throw new ProposalError(
|
|
1106
|
+
"OUTCOME_FACT_SEMANTICS_MISMATCH",
|
|
1107
|
+
"An asserted vote count does not match the referenced vote facts"
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
}
|
|
1111
|
+
const unanimousSeat = assertedUnanimousSeat(observed);
|
|
1112
|
+
if (unanimousSeat !== void 0 && !countFacts.some((counts) => {
|
|
1113
|
+
const positive = [...counts].filter(([, count]) => count > 0);
|
|
1114
|
+
return positive.length === 1 && positive[0][0] === unanimousSeat;
|
|
1115
|
+
})) {
|
|
1116
|
+
throw new ProposalError(
|
|
1117
|
+
"OUTCOME_FACT_SEMANTICS_MISMATCH",
|
|
1118
|
+
"An asserted unanimous vote does not match the referenced vote facts"
|
|
1119
|
+
);
|
|
1120
|
+
}
|
|
1121
|
+
for (const seat of assertedEliminatedSeats(observed)) {
|
|
1122
|
+
if (!outcomeFacts.some((fact) => (fact.type === "DAY_VOTE_ELIMINATED" || fact.type === "DAY_REVOTE_ELIMINATED") && fact.targetSeat === seat)) {
|
|
1123
|
+
throw new ProposalError(
|
|
1124
|
+
"OUTCOME_FACT_SEMANTICS_MISMATCH",
|
|
1125
|
+
"An asserted elimination does not match the referenced elimination facts"
|
|
1126
|
+
);
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
999
1130
|
function assertLocalOutcomeEvidence(outcomeCount, localOutcomeCount, observed) {
|
|
1000
1131
|
if (outcomeCount === 0 || localOutcomeCount === 0) {
|
|
1001
1132
|
throw new ProposalError(
|
|
@@ -1216,6 +1347,7 @@ function parseAndValidateProposal(raw, envelope, evidence, activeProfile) {
|
|
|
1216
1347
|
if (FIXED_RULE_LANGUAGE.test(rule)) {
|
|
1217
1348
|
throw new ProposalError("FIXED_RULE_NOT_LEARNABLE", "Permanent safety and protocol rules cannot be learned");
|
|
1218
1349
|
}
|
|
1350
|
+
assertNoAbsoluteStrategyClaim(proposal);
|
|
1219
1351
|
const facts = new Map(envelope.facts.map((fact) => [fact.factId, fact]));
|
|
1220
1352
|
const anchor = facts.get(anchorFactId);
|
|
1221
1353
|
if (!anchor || anchor.visibility === "POSTGAME_ONLY") {
|
|
@@ -1223,6 +1355,7 @@ function parseAndValidateProposal(raw, envelope, evidence, activeProfile) {
|
|
|
1223
1355
|
}
|
|
1224
1356
|
assertBehaviorIsObserved(proposal);
|
|
1225
1357
|
proposal.behavior = anchor.summary;
|
|
1358
|
+
assertCounterfactualCoherence(proposal, anchor);
|
|
1226
1359
|
const known = proposal.knownFactRefs ?? [];
|
|
1227
1360
|
const outcomes = proposal.outcomeFactRefs ?? [];
|
|
1228
1361
|
const knownFacts = [];
|
|
@@ -1246,6 +1379,7 @@ function parseAndValidateProposal(raw, envelope, evidence, activeProfile) {
|
|
|
1246
1379
|
knownFacts.push(fact);
|
|
1247
1380
|
}
|
|
1248
1381
|
let localOutcomeCount = 0;
|
|
1382
|
+
const outcomeFacts = [];
|
|
1249
1383
|
for (const ref of outcomes) {
|
|
1250
1384
|
const fact = facts.get(ref);
|
|
1251
1385
|
if (!fact) throw new ProposalError("OUTCOME_FACT_NOT_FOUND", `Unknown outcomeFactRef: ${ref}`);
|
|
@@ -1255,9 +1389,12 @@ function parseAndValidateProposal(raw, envelope, evidence, activeProfile) {
|
|
|
1255
1389
|
if (LOCAL_OUTCOME_FACT_TYPES.has(fact.type)) {
|
|
1256
1390
|
localOutcomeCount++;
|
|
1257
1391
|
}
|
|
1392
|
+
outcomeFacts.push(fact);
|
|
1258
1393
|
}
|
|
1259
1394
|
assertActionTimeSemantics(proposal, window, anchor, knownFacts);
|
|
1395
|
+
assertDecisionTypeSemantics(proposal);
|
|
1260
1396
|
assertLocalOutcomeEvidence(outcomes.length, localOutcomeCount, observed);
|
|
1397
|
+
assertObservedOutcomeSemantics(observed, outcomeFacts);
|
|
1261
1398
|
const allRefs = /* @__PURE__ */ new Set([...known, ...outcomes]);
|
|
1262
1399
|
if (allRefs.size !== known.length + outcomes.length) {
|
|
1263
1400
|
throw new ProposalError("FACT_ROLE_CONFLICT", "A fact cannot be both known information and an outcome");
|
|
@@ -3128,9 +3265,13 @@ var WerewolfEvolutionService = class {
|
|
|
3128
3265
|
"- alternativeAction must describe a counterfactual action that did not happen; never swap behavior and alternativeAction.",
|
|
3129
3266
|
"- observedLocalEffect must not contain the final winner or loser; describe only a later local effect backed by outcomeFactRefs.",
|
|
3130
3267
|
"- alternativeTargetSeat must agree with alternativeAction. Text that only waits, retains the vote, or chooses no target and names no later target cannot carry a seat.",
|
|
3268
|
+
"- alternativeAction must contain exactly one counterfactual action, not a menu joined by or/\u6216\u8005/\u6216/\u4E8C\u9009\u4E00. A changed alternative target must not claim that the target stays unchanged.",
|
|
3269
|
+
"- observedLocalEffect must state facts directly without claiming they prove an interpretation such as \u56E0\u6B64/\u7531\u6B64\u53EF\u89C1/therefore. Exact vote counts, unanimous votes, and vote-eliminated seats must match outcomeFactRefs.",
|
|
3270
|
+
"- Single-game claims must not use absolute strategy wording such as must, always, only valid, certain, or guaranteed. Hedged wording such as \u4E0D\u4E00\u5B9A\u5FC5\u987B is allowed.",
|
|
3131
3271
|
"- alternatives must contain at least one plausible alternative explanation. falsifier must state a concrete later observation that would disprove the rule.",
|
|
3132
3272
|
"Execution versus strategy contract:",
|
|
3133
3273
|
"- executionOperation must be one of the exact template operations. To claim execution risk, copy that template's operation, decisionType, trigger, rule, boundary, and alternativeAction exactly.",
|
|
3274
|
+
"- decisionType must match the lesson topic. In particular, AVOID_REPEATING_PRIOR_SPEAKERS must omit repeated content and add new information, not carry an unrelated speech strategy.",
|
|
3134
3275
|
"- Strategy proposals must omit executionOperation. CHOOSE_VOTE_TARGET and CHOOSE_ROLE_CLAIM_TIMING are decision types, never executionOperation values.",
|
|
3135
3276
|
"Call werewolf_debrief_commit after checking the complete proposal against this contract.",
|
|
3136
3277
|
"A rejected result with retryable=true means one field/semantic correction is allowed: correct only the reported issue using the same trusted window and call the tool once more. A rejected result with retryable=false is final; never call again.",
|
package/package.json
CHANGED