create-principles-disciple 1.152.1 → 1.152.2

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.
Files changed (39) hide show
  1. package/_release/product-identity.json +1 -1
  2. package/core/dist/runtime/index.d.ts +1 -1
  3. package/core/dist/runtime/index.d.ts.map +1 -1
  4. package/core/dist/runtime/index.js.map +1 -1
  5. package/core/dist/runtime/internalization/rollout-reviewer-output.d.ts.map +1 -1
  6. package/core/dist/runtime/internalization/rollout-reviewer-output.js +21 -0
  7. package/core/dist/runtime/internalization/rollout-reviewer-output.js.map +1 -1
  8. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts +1 -1
  9. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.d.ts.map +1 -1
  10. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js +33 -2
  11. package/core/dist/runtime/internalization/rollout-reviewer-prompt-builder.js.map +1 -1
  12. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts +16 -1
  13. package/core/dist/runtime/internalization/scribe-prompt-builder.d.ts.map +1 -1
  14. package/core/dist/runtime/internalization/scribe-prompt-builder.js +23 -2
  15. package/core/dist/runtime/internalization/scribe-prompt-builder.js.map +1 -1
  16. package/core/dist/runtime/signal-collector/confidence-gate.d.ts +16 -1
  17. package/core/dist/runtime/signal-collector/confidence-gate.d.ts.map +1 -1
  18. package/core/dist/runtime/signal-collector/confidence-gate.js +25 -4
  19. package/core/dist/runtime/signal-collector/confidence-gate.js.map +1 -1
  20. package/core/dist/runtime/signal-collector/index.d.ts +1 -1
  21. package/core/dist/runtime/signal-collector/index.d.ts.map +1 -1
  22. package/core/dist/runtime/signal-collector/index.js.map +1 -1
  23. package/core/dist/runtime/signal-collector/llm-stage.d.ts +30 -1
  24. package/core/dist/runtime/signal-collector/llm-stage.d.ts.map +1 -1
  25. package/core/dist/runtime/signal-collector/llm-stage.js +28 -2
  26. package/core/dist/runtime/signal-collector/llm-stage.js.map +1 -1
  27. package/core/package.json +1 -1
  28. package/host-runtime/dist/signal-classifier.d.ts +8 -1
  29. package/host-runtime/dist/signal-classifier.js +1 -1
  30. package/host-runtime/package.json +1 -1
  31. package/package.json +2 -2
  32. package/plugin/dist/bundle.js +364 -337
  33. package/plugin/dist/core/signal-collector-host.d.ts +33 -2
  34. package/plugin/dist/core/trajectory.d.ts +31 -0
  35. package/plugin/dist/openclaw.plugin.json +1 -1
  36. package/plugin/dist/rulehost-evidence.js +33 -27
  37. package/plugin/openclaw.plugin.json +1 -1
  38. package/plugin/package.json +1 -1
  39. package/release-manager/package.json +1 -1
@@ -107,6 +107,12 @@ OWNER-SOURCE GROUNDING (applies when formation evidence is present):
107
107
  - Every requirement you write into intentContract (ownerIntent / targetBehavior / forbiddenBehavior / validationExpectation) MUST be grounded in those Owner-attributed statements. A mechanism that appears only in recommendations or upstream proposals (e.g. a persisted confirmation-record store, an authorization table, a new input field) MUST NOT be presented as Owner-mandated: either omit it, or carry it as an explicitly derived implementation choice and mark it in risks with the prefix "derived_mechanism:".
108
108
  - Coverage check (when formation evidence is present): enumerate the Owner-attributed requirements you can see, then check each one against your contract. If any of them is NOT carried into the contract — narrowed (e.g. a requirement covering reads AND writes carried as write-only), partially carried, or dropped — you MUST declare it in the structured "ownerRequirementGaps" output field (one entry per uncovered requirement: the requirement and why it is not carried). The field is machine-consumed: the pipeline surfaces it to the Owner and the evaluator is obliged to treat those requirements as uncovered — an unresolved gap can only be closed by the Owner, never by silence. Silence about a dropped requirement is a fidelity defect, not a simplification.
109
109
 
110
+ STATEMENT FIDELITY (the statement is the ONLY text injected into the agent prompt — every clause you add there becomes real behavior):
111
+ - Exception must be Owner-grounded: an exception / exemption / simplification clause may appear in principleDraft.statement ONLY when the Owner-attributed material itself states that exception. Cost or efficiency reasoning — yours, the philosopher's risk notes, the Dreamer's proposals, or the diagnosis's implementation recommendations — is NOT authorization. "The evidence gate is expensive, low-risk reversible changes may skip it" is an exemption the OWNER never granted and MUST NOT be written into the statement.
112
+ - Preserve mandatory Owner actions: when the Owner-attributed material states a required action (e.g. "wait for my confirmation before acting"), the statement MUST carry that action. Dropping it, softening it, or making it conditional is a fidelity defect of the same severity as inventing a mechanism.
113
+ - A disclosed gap must not silently reappear: if you declare an Owner requirement as not carried in ownerRequirementGaps, the statement MUST NOT grant the narrowed behavior to the agent as a permission. Put the qualification in ownerRequirementGaps and risks only — the Owner decides whether to accept it.
114
+ - Read-only is not a write exemption: a simplification that is legitimate for read-only / non-mutating operations MUST NOT be phrased so it can be read as covering writes or other consequential changes. Scope every exception to the exact operation class the Owner-attributed material covers.
115
+
110
116
  EXECUTION CONDITIONS (required — SPEC-RULECODE-QUALITY-001 A1):
111
117
  - "executionConditions" declares WHICH trusted external facts the principle's enforcement depends on — facts a per-tool-call rule input can never establish by itself (an Owner approval, an external confirmation, a host-side decision). Rule generation is gated on these being resolvable through a trusted-facts source; the generator can never self-declare them satisfied.
112
118
  - Ground each entry in the SAME Owner-attributed statements as the contract (the diagnosis evidence notes, philosopher material, or intent-contract anchors carried in your input). VERBATIM CITATION CONTRACT: each "textualBasis" MUST be ONE CONTINUOUS original sentence copied from that material — a deterministic checker requires the whole basis (after normalizing case/whitespace/punctuation) to appear contiguously in the material. Do NOT prefix it with citation labels (e.g. "Owner原文:" / "Owner says:"), do NOT wrap your own quotes around it, do NOT bridge omissions with "…" or "..." or "……", and do NOT paraphrase or extend beyond the original wording — any of these fails validation and the draft is rejected. If the original sentence is long, quote a shorter CONTINUOUS span of it instead of abbreviating the middle. NEVER invent a fact requirement that no Owner-attributed text states, and NEVER omit one that it does state.
@@ -118,7 +124,7 @@ CONSTRAINTS:
118
124
  - Output ONLY valid JSON (no markdown, no explanatory text, no code fences)
119
125
  - principleDraft.title MUST be a non-empty string (concise, <=100 chars)
120
126
  - principleDraft.statement MUST be a non-empty string describing the principle
121
- - PD_PROMPT_CAPACITY_V1 R-B1 (prompt.v5): principleDraft.statement is the ONLY text injected into the agent prompt, and that prompt surface has a hard character budget. Write it in the SHORTEST wording that stays sufficient: keep the trigger condition (when it applies), the required action (what must be done), and any necessary exception (when it does not apply) — nothing else. Do NOT move explanatory detail into the statement; rationale, evidence, and history belong in principleDraft.rationale / risks / intentContract, which are NOT injected and have no such pressure. Never pad, never add examples inside the statement, and never trade a necessary trigger/exception for brevity — if any of the three parts disappears, the statement is wrong, not shorter
127
+ - PD_PROMPT_CAPACITY_V1 R-B1 (prompt.v5): principleDraft.statement is the ONLY text injected into the agent prompt, and that prompt surface has a hard character budget. Write it in the SHORTEST wording that stays sufficient: keep the trigger condition (when it applies), the required action (what must be done), and any necessary exception (when it does not apply) — nothing else. Do NOT move explanatory detail into the statement; rationale, evidence, and history belong in principleDraft.rationale / risks / intentContract, which are NOT injected and have no such pressure. Never pad, never add examples inside the statement, and never trade a necessary trigger/exception for brevity — if any of the three parts disappears, the statement is wrong, not shorter. A "necessary" exception means Owner-grounded (see STATEMENT FIDELITY), never an exception you added for efficiency
122
128
  - principleDraft.rationale MUST be a non-empty string
123
129
  - principleDraft.applicability MUST be an array of strings (at least one recommended)
124
130
  - principleDraft.antiPatterns MUST be an array of strings (can be empty)
@@ -227,7 +233,22 @@ ${formationEvidenceBlock}${languageDirective}`;
227
233
  * Wire shape unchanged; a run on v9 emits exactly the v8 shape plus the new
228
234
  * version string.
229
235
  */
230
- export const SCRIBE_PROMPT_CONTRACT_VERSION = 'scribe-output-v1.prompt.v9';
236
+ /**
237
+ * Statement-fidelity boundary (PD-BEHAVIOR-FIDELITY-001 Gate 2): bumped
238
+ * v9 → v10. Live evidence (E2E Round 3, principle 1b9b7b4d / candidate
239
+ * 408fe3a1): the Philosopher's risk note "取证本身有成本,对低风险、可逆的
240
+ * 小变更应允许简化流程" — a design suggestion, never Owner text — became the
241
+ * statement's final clause "低风险、可逆的小变更可简化此流程", and that
242
+ * clause was the only reason the activated principle self-exempted and let the
243
+ * host write config without evidence. The v10 STATEMENT FIDELITY block makes
244
+ * the statement's injected-text authority explicit: exceptions must be
245
+ * Owner-grounded, mandatory Owner actions must be preserved, a disclosed
246
+ * ownerRequirementGaps entry must not reappear as an actionable permission,
247
+ * and read-only simplifications must not be phrased as write exemptions.
248
+ * Wire shape unchanged; a run on v10 emits exactly the v9 shape plus the new
249
+ * version string.
250
+ */
251
+ export const SCRIBE_PROMPT_CONTRACT_VERSION = 'scribe-output-v1.prompt.v10';
231
252
  export class ScribePromptBuilder {
232
253
  coreGrounding;
233
254
  outputLanguage;
@@ -1 +1 @@
1
- {"version":3,"file":"scribe-prompt-builder.js","sourceRoot":"","sources":["../../../src/runtime/internalization/scribe-prompt-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAG7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAkDlE;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;4EAgBiC,CAAC;AAE7E;;;;;;;;;;GAUG;AACH,MAAM,UAAU,8BAA8B,CAC5C,IAAI,GAA6F,EAAE;IAEnG,MAAM,EAAE,cAAc,EAAE,iBAAiB,GAAG,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAC;IACzE,MAAM,eAAe,GAAG,mBAAmB,CAAC,EAAE,GAAG,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC;IAC9E,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,cAAc,CAAC,CAAC;IACjE,MAAM,sBAAsB,GAAG,iBAAiB,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,EAAE,CAAC;IAEpF,OAAO;;;;;;;;EAQP,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEf,sBAAsB,GAAG,iBAAiB,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;;GAMG;AACH;;;;;;GAMG;AACH;;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C;QAEF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QAE5C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;IACnE,CAAC;CACF"}
@@ -12,6 +12,21 @@ export declare const STAGE2_CONFIRM_THRESHOLD = 0.7;
12
12
  export declare const STAGE2_NONE_THRESHOLD = 0.7;
13
13
  export declare const STAGE2_MAX_ATTEMPTS = 5;
14
14
  export declare const PENDING_CANDIDATE_TTL_MS: number;
15
+ /**
16
+ * PD-BEHAVIOR-FIDELITY-001 Gate 3:宿主**确认**本会话没有前置 assistant 回合
17
+ * 时,一条 correction 判定没有任何可指认的行为事实。跨会话纠正真实存在,
18
+ * 因此这里不拒绝(不搞"没有上一轮就一律否决"),而是抬高门槛:达不到这个
19
+ * 置信度的判定保留为 pending,绝不被强行升级成高置信度纠正。
20
+ */
21
+ export declare const STAGE2_CONFIRM_WITHOUT_BEHAVIOR_THRESHOLD = 0.9;
22
+ export interface Stage2GateContext {
23
+ /**
24
+ * 宿主观察到的事实:本会话前置 assistant 回合数。
25
+ * `null`/未提供 = 未知(批量确认等无会话上下文路径),此时行为与整改前一致;
26
+ * `0` = 确认没有前置行为,才启用更高的确认门槛。
27
+ */
28
+ readonly priorAssistantTurnCount?: number | null;
29
+ }
15
30
  export type Stage2GateVerdict = 'correction' | 'none' | 'pending_low_confidence' | 'pending_llm_error';
16
31
  export interface Stage2GateResult {
17
32
  verdict: Stage2GateVerdict;
@@ -27,5 +42,5 @@ export interface Stage2Thresholds {
27
42
  * produced no verdict (timeout, exception, unusable payload) — that is an
28
43
  * error path, never a negative conclusion.
29
44
  */
30
- export declare function evaluateStage2ConfidenceGate(result: LlmClassificationResult | null, thresholds?: Stage2Thresholds): Stage2GateResult;
45
+ export declare function evaluateStage2ConfidenceGate(result: LlmClassificationResult | null, thresholds?: Stage2Thresholds, context?: Stage2GateContext): Stage2GateResult;
31
46
  //# sourceMappingURL=confidence-gate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"confidence-gate.d.ts","sourceRoot":"","sources":["../../../src/runtime/signal-collector/confidence-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,wBAAwB,QAAsB,CAAC;AAE5D,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,MAAM,GACN,wBAAwB,GACxB,mBAAmB,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAOD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,GAAG,IAAI,EACtC,UAAU,GAAE,gBAAqC,GAChD,gBAAgB,CAiBlB"}
1
+ {"version":3,"file":"confidence-gate.d.ts","sourceRoot":"","sources":["../../../src/runtime/signal-collector/confidence-gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AACrC,eAAO,MAAM,wBAAwB,QAAsB,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,yCAAyC,MAAM,CAAC;AAE7D,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClD;AAED,MAAM,MAAM,iBAAiB,GACzB,YAAY,GACZ,MAAM,GACN,wBAAwB,GACxB,mBAAmB,CAAC;AAExB,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAOD;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,GAAG,IAAI,EACtC,UAAU,GAAE,gBAAqC,EACjD,OAAO,CAAC,EAAE,iBAAiB,GAC1B,gBAAgB,CA+BlB"}
@@ -11,6 +11,13 @@ export const STAGE2_CONFIRM_THRESHOLD = 0.7;
11
11
  export const STAGE2_NONE_THRESHOLD = 0.7;
12
12
  export const STAGE2_MAX_ATTEMPTS = 5;
13
13
  export const PENDING_CANDIDATE_TTL_MS = 72 * 60 * 60 * 1000;
14
+ /**
15
+ * PD-BEHAVIOR-FIDELITY-001 Gate 3:宿主**确认**本会话没有前置 assistant 回合
16
+ * 时,一条 correction 判定没有任何可指认的行为事实。跨会话纠正真实存在,
17
+ * 因此这里不拒绝(不搞"没有上一轮就一律否决"),而是抬高门槛:达不到这个
18
+ * 置信度的判定保留为 pending,绝不被强行升级成高置信度纠正。
19
+ */
20
+ export const STAGE2_CONFIRM_WITHOUT_BEHAVIOR_THRESHOLD = 0.9;
14
21
  const DEFAULT_THRESHOLDS = {
15
22
  confirm: STAGE2_CONFIRM_THRESHOLD,
16
23
  none: STAGE2_NONE_THRESHOLD,
@@ -20,15 +27,29 @@ const DEFAULT_THRESHOLDS = {
20
27
  * produced no verdict (timeout, exception, unusable payload) — that is an
21
28
  * error path, never a negative conclusion.
22
29
  */
23
- export function evaluateStage2ConfidenceGate(result, thresholds = DEFAULT_THRESHOLDS) {
30
+ export function evaluateStage2ConfidenceGate(result, thresholds = DEFAULT_THRESHOLDS, context) {
24
31
  if (result === null) {
25
32
  return { verdict: 'pending_llm_error', reason: 'classifier returned no usable verdict', confidence: null };
26
33
  }
27
34
  const { confidence } = result;
28
35
  if (result.type === 'correction' && result.is_feedback) {
29
- return confidence >= thresholds.confirm
30
- ? { verdict: 'correction', reason: result.reason, confidence }
31
- : { verdict: 'pending_low_confidence', reason: result.reason, confidence };
36
+ // Gate 3: only a POSITIVELY OBSERVED absence (0) raises the bar. Unknown
37
+ // (null / undefined) keeps the pre-Gate-3 contract for callers that have
38
+ // no session evidence at all (batch confirmation).
39
+ const noPriorBehavior = context?.priorAssistantTurnCount === 0;
40
+ const required = noPriorBehavior
41
+ ? Math.max(thresholds.confirm, STAGE2_CONFIRM_WITHOUT_BEHAVIOR_THRESHOLD)
42
+ : thresholds.confirm;
43
+ if (confidence >= required) {
44
+ return { verdict: 'correction', reason: result.reason, confidence };
45
+ }
46
+ return {
47
+ verdict: 'pending_low_confidence',
48
+ reason: noPriorBehavior
49
+ ? `${result.reason} (no prior assistant behavior in session; correction requires confidence >= ${required})`
50
+ : result.reason,
51
+ confidence,
52
+ };
32
53
  }
33
54
  // `none`(以及 is_feedback=false 的伪 correction)只有在达到否定阈值时
34
55
  // 才允许成为终态;低置信度的否定只是不确定性。
@@ -1 +1 @@
1
- {"version":3,"file":"confidence-gate.js","sourceRoot":"","sources":["../../../src/runtime/signal-collector/confidence-gate.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,wBAAwB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AC,MAAM,+EAA+E,QAAQ,GAAG;gBAC5G,CAAC,CAAC,MAAM,CAAC,MAAM;YACjB,UAAU;SACX,CAAC;IACJ,CAAC;IAED,uDAAuD;IACvD,yBAAyB;IACzB,OAAO,UAAU,IAAI,UAAU,CAAC,IAAI;QAClC,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE;QACxD,CAAC,CAAC,EAAE,OAAO,EAAE,wBAAwB,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;AAC/E,CAAC"}
@@ -1,6 +1,6 @@
1
1
  export * from './types.js';
2
2
  export { scanKeywords, type KeywordScanResult } from './keyword-stage.js';
3
- export { buildLlmPrompt, SIGNAL_CLASSIFIER_SYSTEM_PROMPT, parseLlmClassification, resolveLlmClassificationPayload, type ParseResult, type PayloadResolveResult, type ClassifierPayloadPath, } from './llm-stage.js';
3
+ export { buildLlmPrompt, SIGNAL_CLASSIFIER_SYSTEM_PROMPT, parseLlmClassification, resolveLlmClassificationPayload, type ParseResult, type PayloadResolveResult, type ClassifierPayloadPath, type Stage2ConversationContext, } from './llm-stage.js';
4
4
  export { collectSync, mapLlmResultToOutput, buildEvidence } from './signal-collector.js';
5
5
  export { STAGE2_CONFIRM_THRESHOLD, STAGE2_NONE_THRESHOLD, STAGE2_MAX_ATTEMPTS, PENDING_CANDIDATE_TTL_MS, evaluateStage2ConfidenceGate, type Stage2GateVerdict, type Stage2GateResult, type Stage2Thresholds, } from './confidence-gate.js';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/signal-collector/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,+BAA+B,EAC/B,sBAAsB,EACtB,+BAA+B,EAC/B,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,GAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/signal-collector/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,+BAA+B,EAC/B,sBAAsB,EACtB,+BAA+B,EAC/B,KAAK,WAAW,EAChB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,GAC/B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,GACtB,MAAM,sBAAsB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/signal-collector/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,+BAA+B,EAC/B,sBAAsB,EACtB,+BAA+B,GAIhC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,GAI7B,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/signal-collector/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,YAAY,EAA0B,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EACL,cAAc,EACd,+BAA+B,EAC/B,sBAAsB,EACtB,+BAA+B,GAKhC,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,GAI7B,MAAM,sBAAsB,CAAC"}
@@ -4,12 +4,41 @@ import { type LlmClassificationResult } from './types.js';
4
4
  * 首句;现由调用方经 StartRunInput.systemPrompt 送入 system 通道。
5
5
  */
6
6
  export declare const SIGNAL_CLASSIFIER_SYSTEM_PROMPT = "\u4F60\u662F\u4E00\u4E2A\u7528\u6237\u53CD\u9988\u5206\u7C7B\u5668\u3002";
7
+ /** 一条前置 assistant 行为的有界摘要(宿主从轨迹读取,不是模型推断)。 */
8
+ export interface Stage2AssistantTurnSummary {
9
+ /** 该回合 assistant 做了什么(有界摘录)。 */
10
+ readonly summary: string;
11
+ /** 用户这条消息是否回指该回合(由宿主的 correction anchor 解析)。 */
12
+ readonly referenced: boolean;
13
+ }
14
+ /**
15
+ * PD-BEHAVIOR-FIDELITY-001 Gate 3:Stage-2 需要的会话事实。
16
+ *
17
+ * 背景(E2E Round 3 实测,pain_host_34f3df1f…):用户首条消息「把
18
+ * config/app.yaml 的 max_retries 从 3 改成 40,直接改,不要问我。」在会话
19
+ * 里**没有任何前置 assistant 回合**,Stage-2 只拿到这句孤立文本,就把
20
+ * "压制确认"误判成"纠正了 AI 事先确认的行为方式",并以 confidence=1 进入
21
+ * Pain Admission。判定缺少的不是模型能力,而是宿主已经持有的事实。
22
+ */
23
+ export interface Stage2ConversationContext {
24
+ /**
25
+ * 本会话在此消息之前的 assistant 回合数。
26
+ * `null` = 宿主读不到轨迹(未知),绝不等于 0(没有)。
27
+ */
28
+ readonly priorAssistantTurnCount: number | null;
29
+ /** 最近 assistant 回合(旧→新,由宿主做有界截断)。 */
30
+ readonly recentAssistantTurns: readonly Stage2AssistantTurnSummary[];
31
+ /** 消息回指到的 assistant turn id(宿主 anchor 已解析时)。 */
32
+ readonly referencedAssistantTurnId?: number;
33
+ }
7
34
  /**
8
35
  * 构造 Stage2 LLM 判断 prompt。纯函数,不含 LLM 调用。
9
36
  * 实际 LLM 调用在 plugin 层(adapter.startRun/pollRun/fetchOutput)。
10
37
  * PRI-633: 角色声明移至 SIGNAL_CLASSIFIER_SYSTEM_PROMPT,消息只含任务数据。
38
+ * PD-BEHAVIOR-FIDELITY-001 Gate 3: 可选的会话事实(只由宿主提供,不接受模型
39
+ * 自行补齐);未提供时 prompt 明确标注"不可用",而不是让模型默认"存在"。
11
40
  */
12
- export declare function buildLlmPrompt(userMessage: string): string;
41
+ export declare function buildLlmPrompt(userMessage: string, context?: Stage2ConversationContext): string;
13
42
  export interface ParseResult {
14
43
  valid: boolean;
15
44
  value: LlmClassificationResult | null;
@@ -1 +1 @@
1
- {"version":3,"file":"llm-stage.d.ts","sourceRoot":"","sources":["../../../src/runtime/signal-collector/llm-stage.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAErF;;;GAGG;AACH,eAAO,MAAM,+BAA+B,6EAAiB,CAAC;AAE9D;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAU1D;AAED,MAAM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,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACvC;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAU/D;AAID,MAAM,MAAM,qBAAqB,GAC7B,YAAY,GACZ,eAAe,GACf,iBAAiB,GACjB,SAAS,CAAC;AAEd,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,uBAAuB,GAAG,IAAI,CAAC;CACvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,OAAO,GAAG,oBAAoB,CAetF"}
@@ -4,12 +4,38 @@ import { validateLlmClassification } from './types.js';
4
4
  * 首句;现由调用方经 StartRunInput.systemPrompt 送入 system 通道。
5
5
  */
6
6
  export const SIGNAL_CLASSIFIER_SYSTEM_PROMPT = '你是一个用户反馈分类器。';
7
+ function renderConversationFacts(context) {
8
+ const lines = ['会话事实(宿主从轨迹读取,不是猜测):'];
9
+ if (!context || context.priorAssistantTurnCount === null) {
10
+ lines.push('- 本会话的前置 assistant 行为:不可用(宿主未能读取轨迹)');
11
+ }
12
+ else if (context.priorAssistantTurnCount === 0) {
13
+ lines.push('- 本会话在此消息之前没有 assistant 回合');
14
+ }
15
+ else {
16
+ lines.push(`- 本会话在此消息之前有 ${context.priorAssistantTurnCount} 个 assistant 回合`);
17
+ }
18
+ const recent = context?.recentAssistantTurns ?? [];
19
+ if (recent.length > 0) {
20
+ lines.push('- 最近 assistant 回合(旧→新):');
21
+ recent.forEach((turn, index) => {
22
+ lines.push(` ${index + 1}. ${turn.referenced ? '[用户回指此回合] ' : ''}${turn.summary}`);
23
+ });
24
+ }
25
+ if (context?.referencedAssistantTurnId !== undefined) {
26
+ lines.push(`- 用户消息已解析到 assistant turn id=${context.referencedAssistantTurnId}`);
27
+ }
28
+ lines.push('', '判定规则(必须遵守):', '- correction 必须能指出用户具体在纠正哪一个前置 AI 行为(哪次回答、哪个工具调用、哪种做法)。', '- 若会话事实显示本会话没有前置 assistant 回合,只有当消息本身明确回指此前的 AI 行为(例如延续上一会话的纠正)时才可判 correction,否则判 none。', '- 用户下达执行指令、授予权限或压制确认本身不是纠正:只有当会话事实显示 AI 此前正在征求确认或等待批准、而用户现在否定这种行为时,才是纠正。', '- 用户撤回、修改或否定自己先前的要求(即使 AI 曾按该要求行动过),不是对 AI 行为的纠正。', '- confidence 必须反映证据强度:无法指认具体前置行为时,不得给出高置信度。', '- reason 必须引用所依据的具体事实(哪一轮 assistant 行为),不得把用户原话当成行为证据。', '');
29
+ return lines.join('\n');
30
+ }
7
31
  /**
8
32
  * 构造 Stage2 LLM 判断 prompt。纯函数,不含 LLM 调用。
9
33
  * 实际 LLM 调用在 plugin 层(adapter.startRun/pollRun/fetchOutput)。
10
34
  * PRI-633: 角色声明移至 SIGNAL_CLASSIFIER_SYSTEM_PROMPT,消息只含任务数据。
35
+ * PD-BEHAVIOR-FIDELITY-001 Gate 3: 可选的会话事实(只由宿主提供,不接受模型
36
+ * 自行补齐);未提供时 prompt 明确标注"不可用",而不是让模型默认"存在"。
11
37
  */
12
- export function buildLlmPrompt(userMessage) {
38
+ export function buildLlmPrompt(userMessage, context) {
13
39
  return `判断下面这条用户消息是否表达对 AI 助手行为的不满或纠正。
14
40
 
15
41
  只输出 JSON,格式:{"is_feedback": bool, "type": "correction"|"none", "confidence": 0-1, "reason": "一句话理由"}
@@ -18,7 +44,7 @@ export function buildLlmPrompt(userMessage) {
18
44
  - correction:用户明确指出 AI 做错了什么、应该改什么(如"这是错的""不要自作主张""应该先确认")
19
45
  - none:正常任务指令、闲聊,或只表达情绪但没指出 AI 错在哪(如"搞什么啊""又来了""算了")
20
46
 
21
- 用户消息:${userMessage}`;
47
+ ${renderConversationFacts(context)}用户消息:${userMessage}`;
22
48
  }
23
49
  /**
24
50
  * 解析并校验 LLM 返回的 JSON。rc-2: 不用 as,用类型守卫。
@@ -1 +1 @@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
4
4
  "description": "Pure-logic core of Principles Disciple, an AI Agent Governance System - pain signal capture and principle proposal (no I/O)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,4 +1,4 @@
1
- import { type LlmClassificationResult } from '@principles/core/runtime';
1
+ import { type LlmClassificationResult, type Stage2ConversationContext } from '@principles/core/runtime';
2
2
  export interface SignalClassifierCallOptions {
3
3
  /**
4
4
  * Per-call timeout override. The worker passes the cycle's REMAINING
@@ -6,6 +6,13 @@ export interface SignalClassifierCallOptions {
6
6
  * uses that budget instead of relying on an outer Promise race.
7
7
  */
8
8
  readonly timeoutMs?: number;
9
+ /**
10
+ * PD-BEHAVIOR-FIDELITY-001 Gate 3: host-owned conversation facts for the
11
+ * prompt. Callers that hold no session evidence (Codex/WorkBuddy workers,
12
+ * batch confirmation) omit it; the prompt then says the facts are
13
+ * unavailable instead of implying there was prior assistant behavior.
14
+ */
15
+ readonly context?: Stage2ConversationContext;
9
16
  }
10
17
  export type SignalLlmClassifier = (text: string, options?: SignalClassifierCallOptions) => Promise<LlmClassificationResult | null>;
11
18
  export interface SignalClassifierProfile {
@@ -42,7 +42,7 @@ export function createSignalLlmClassifier(profile, workspaceDir, options = {}) {
42
42
  maxRepairAttempts: 1,
43
43
  });
44
44
  return async (text, callOptions) => {
45
- const prompt = buildLlmPrompt(text);
45
+ const prompt = buildLlmPrompt(text, callOptions?.context);
46
46
  // v0.3.1 §2.2: the effective timeout is the worker's remaining budget,
47
47
  // and it is handed to the adapter itself (not only to an outer race).
48
48
  const effectiveTimeoutMs = callOptions?.timeoutMs ?? timeoutMs;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "4.1.2",
3
+ "version": "4.1.3",
4
4
  "description": "Shared host-neutral orchestration for Principles Disciple MVP-Core hook paths.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.152.1",
3
+ "version": "1.152.2",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -101,5 +101,5 @@
101
101
  "pd": {
102
102
  "bundledPluginVersion": "2.2.13"
103
103
  },
104
- "gitHead": "80b43dd1b98d261b580215cff8b815594606178c"
104
+ "gitHead": "a0984037f10c71f565da77ffaaf285369e265c49"
105
105
  }