create-principles-disciple 1.152.4 → 1.153.0

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 (149) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/agent-skill/pd-setup/SKILL.md +70 -0
  3. package/codex-adapter/dist/background-selection.d.ts +9 -0
  4. package/codex-adapter/dist/background-selection.js +142 -0
  5. package/codex-adapter/dist/ingestion/adaptive-append-state.d.ts +209 -0
  6. package/codex-adapter/dist/ingestion/adaptive-append-state.js +544 -0
  7. package/codex-adapter/dist/pd-hook.js +329 -5
  8. package/codex-adapter/package.json +1 -1
  9. package/console/dist/server/config/pd-config-store.d.ts +11 -15
  10. package/console/dist/server/config/pd-config-store.js +92 -17
  11. package/console/dist/server/models/AdaptiveActivationConsoleModel.d.ts +43 -4
  12. package/console/dist/server/models/AdaptiveActivationConsoleModel.js +36 -7
  13. package/console/dist/server/routes/config.js +34 -8
  14. package/console/dist/web/assets/app.css +6 -0
  15. package/console/dist/web/assets/app.js +22 -22
  16. package/core/dist/runtime/activation/sqlite-approval-store.d.ts.map +1 -1
  17. package/core/dist/runtime/activation/sqlite-approval-store.js +7 -1
  18. package/core/dist/runtime/activation/sqlite-approval-store.js.map +1 -1
  19. package/core/dist/runtime/config/pd-config-feature-flags.d.ts +10 -0
  20. package/core/dist/runtime/config/pd-config-feature-flags.d.ts.map +1 -1
  21. package/core/dist/runtime/config/pd-config-feature-flags.js +14 -0
  22. package/core/dist/runtime/config/pd-config-feature-flags.js.map +1 -1
  23. package/core/dist/runtime/config/pd-config-types.d.ts +9 -0
  24. package/core/dist/runtime/config/pd-config-types.d.ts.map +1 -1
  25. package/core/dist/runtime/config/pd-config-types.js.map +1 -1
  26. package/core/dist/runtime/config/pd-config-validate.d.ts.map +1 -1
  27. package/core/dist/runtime/config/pd-config-validate.js +10 -2
  28. package/core/dist/runtime/config/pd-config-validate.js.map +1 -1
  29. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.d.ts.map +1 -1
  30. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js +13 -2
  31. package/core/dist/runtime/feature-flags/feature-flag-lifecycle.js.map +1 -1
  32. package/core/dist/runtime/intent/intent-doc.d.ts +22 -0
  33. package/core/dist/runtime/intent/intent-doc.d.ts.map +1 -1
  34. package/core/dist/runtime/intent/intent-doc.js +79 -0
  35. package/core/dist/runtime/intent/intent-doc.js.map +1 -1
  36. package/core/dist/runtime/intent/intent-friction-block.d.ts +7 -0
  37. package/core/dist/runtime/intent/intent-friction-block.d.ts.map +1 -1
  38. package/core/dist/runtime/intent/intent-friction-block.js +34 -1
  39. package/core/dist/runtime/intent/intent-friction-block.js.map +1 -1
  40. package/core/dist/runtime/intent/intent-snapshot.d.ts +44 -5
  41. package/core/dist/runtime/intent/intent-snapshot.d.ts.map +1 -1
  42. package/core/dist/runtime/intent/intent-snapshot.js +83 -15
  43. package/core/dist/runtime/intent/intent-snapshot.js.map +1 -1
  44. package/core/dist/runtime/intent/strategic-conflict-gate.d.ts +19 -0
  45. package/core/dist/runtime/intent/strategic-conflict-gate.d.ts.map +1 -1
  46. package/core/dist/runtime/intent/strategic-conflict-gate.js +94 -26
  47. package/core/dist/runtime/intent/strategic-conflict-gate.js.map +1 -1
  48. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts +22 -11
  49. package/core/dist/runtime/internalization/diag-rootcause-runner.d.ts.map +1 -1
  50. package/core/dist/runtime/internalization/diag-rootcause-runner.js +101 -28
  51. package/core/dist/runtime/internalization/diag-rootcause-runner.js.map +1 -1
  52. package/core/dist/runtime/internalization/dreamer-prompt-builder.d.ts.map +1 -1
  53. package/core/dist/runtime/internalization/dreamer-prompt-builder.js +1 -0
  54. package/core/dist/runtime/internalization/dreamer-prompt-builder.js.map +1 -1
  55. package/core/dist/runtime/internalization/dreamer-runner.d.ts +9 -2
  56. package/core/dist/runtime/internalization/dreamer-runner.d.ts.map +1 -1
  57. package/core/dist/runtime/internalization/dreamer-runner.js +11 -1
  58. package/core/dist/runtime/internalization/dreamer-runner.js.map +1 -1
  59. package/core/dist/runtime/internalization/evaluator-runner.d.ts.map +1 -1
  60. package/core/dist/runtime/internalization/evaluator-runner.js +7 -0
  61. package/core/dist/runtime/internalization/evaluator-runner.js.map +1 -1
  62. package/core/dist/runtime/internalization/formation-context.d.ts +16 -0
  63. package/core/dist/runtime/internalization/formation-context.d.ts.map +1 -1
  64. package/core/dist/runtime/internalization/formation-context.js +109 -8
  65. package/core/dist/runtime/internalization/formation-context.js.map +1 -1
  66. package/core/dist/runtime/internalization/index.d.ts +2 -2
  67. package/core/dist/runtime/internalization/index.d.ts.map +1 -1
  68. package/core/dist/runtime/internalization/index.js +1 -1
  69. package/core/dist/runtime/internalization/index.js.map +1 -1
  70. package/core/dist/runtime/internalization/intent-contract.d.ts +55 -4
  71. package/core/dist/runtime/internalization/intent-contract.d.ts.map +1 -1
  72. package/core/dist/runtime/internalization/intent-contract.js +111 -30
  73. package/core/dist/runtime/internalization/intent-contract.js.map +1 -1
  74. package/core/dist/runtime/internalization/philosopher-runner.d.ts +9 -2
  75. package/core/dist/runtime/internalization/philosopher-runner.d.ts.map +1 -1
  76. package/core/dist/runtime/internalization/philosopher-runner.js +11 -1
  77. package/core/dist/runtime/internalization/philosopher-runner.js.map +1 -1
  78. package/core/dist/runtime/internalization/scribe-runner.d.ts.map +1 -1
  79. package/core/dist/runtime/internalization/scribe-runner.js +17 -7
  80. package/core/dist/runtime/internalization/scribe-runner.js.map +1 -1
  81. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts +10 -0
  82. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.d.ts.map +1 -1
  83. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js +15 -4
  84. package/core/dist/runtime/store/intent/sqlite-intent-decision-store.js.map +1 -1
  85. package/core/dist/telemetry-event.d.ts +2 -2
  86. package/core/dist/telemetry-event.d.ts.map +1 -1
  87. package/core/dist/telemetry-event.js +6 -0
  88. package/core/dist/telemetry-event.js.map +1 -1
  89. package/core/package.json +1 -1
  90. package/dist/agent-skill.d.ts +59 -0
  91. package/dist/agent-skill.d.ts.map +1 -0
  92. package/dist/agent-skill.js +198 -0
  93. package/dist/agent-skill.js.map +1 -0
  94. package/dist/i18n.d.ts.map +1 -1
  95. package/dist/i18n.js +12 -0
  96. package/dist/i18n.js.map +1 -1
  97. package/dist/index.d.ts +3 -1
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +171 -3
  100. package/dist/index.js.map +1 -1
  101. package/dist/install-summary.d.ts +52 -0
  102. package/dist/install-summary.d.ts.map +1 -1
  103. package/dist/install-summary.js +104 -0
  104. package/dist/install-summary.js.map +1 -1
  105. package/dist/update/release-metadata-publisher.d.ts +3 -1
  106. package/dist/update/release-metadata-publisher.d.ts.map +1 -1
  107. package/dist/update/release-metadata-publisher.js +33 -2
  108. package/dist/update/release-metadata-publisher.js.map +1 -1
  109. package/dist/update/trust-metadata.d.ts +21 -0
  110. package/dist/update/trust-metadata.d.ts.map +1 -1
  111. package/dist/update/trust-metadata.js +192 -4
  112. package/dist/update/trust-metadata.js.map +1 -1
  113. package/host-runtime/dist/adaptive-background-append.d.ts +70 -0
  114. package/host-runtime/dist/adaptive-background-append.js +165 -0
  115. package/host-runtime/dist/index.d.ts +1 -0
  116. package/host-runtime/dist/index.js +5 -0
  117. package/host-runtime/package.json +1 -1
  118. package/package.json +3 -2
  119. package/pd-cli/dist/commands/health-console.d.ts +21 -0
  120. package/pd-cli/dist/commands/health-console.d.ts.map +1 -0
  121. package/pd-cli/dist/commands/health-console.js +106 -0
  122. package/pd-cli/dist/commands/health-console.js.map +1 -0
  123. package/pd-cli/dist/commands/health.d.ts +159 -0
  124. package/pd-cli/dist/commands/health.d.ts.map +1 -1
  125. package/pd-cli/dist/commands/health.js +162 -2
  126. package/pd-cli/dist/commands/health.js.map +1 -1
  127. package/pd-cli/dist/commands/mcp-probe.d.ts +48 -0
  128. package/pd-cli/dist/commands/mcp-probe.d.ts.map +1 -0
  129. package/pd-cli/dist/commands/mcp-probe.js +479 -0
  130. package/pd-cli/dist/commands/mcp-probe.js.map +1 -0
  131. package/pd-cli/dist/commands/runtime-internalization-run-once.js +2 -2
  132. package/pd-cli/dist/commands/runtime-internalization-run-once.js.map +1 -1
  133. package/pd-cli/dist/program.d.ts.map +1 -1
  134. package/pd-cli/dist/program.js +57 -0
  135. package/pd-cli/dist/program.js.map +1 -1
  136. package/pd-cli/dist/services/console-launcher.d.ts +3 -0
  137. package/pd-cli/dist/services/console-launcher.d.ts.map +1 -1
  138. package/pd-cli/dist/services/console-launcher.js +3 -2
  139. package/pd-cli/dist/services/console-launcher.js.map +1 -1
  140. package/pd-cli/package.json +1 -1
  141. package/plugin/dist/bundle.js +533 -449
  142. package/plugin/dist/openclaw.plugin.json +1 -1
  143. package/plugin/openclaw.plugin.json +1 -1
  144. package/plugin/package.json +1 -1
  145. package/release-manager/dist/i18n.js +12 -0
  146. package/release-manager/dist/update/trust-metadata.js +192 -4
  147. package/release-manager/package.json +2 -1
  148. package/workbuddy-adapter/dist/pd-hook.js +37 -3
  149. package/workbuddy-adapter/package.json +1 -1
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
- "version": "4.1.4",
5
+ "version": "4.1.5",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
@@ -2,7 +2,7 @@
2
2
  "id": "principles-disciple",
3
3
  "name": "Principles Disciple",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
- "version": "4.1.4",
5
+ "version": "4.1.5",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "4.1.4",
3
+ "version": "4.1.5",
4
4
  "description": "Principles Disciple is an AI Agent Governance System. Stop correcting the same AI behavior across sessions. Turn repeated Agent corrections into Owner-approved, observable, reversible behavior principles.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,6 +28,12 @@ const translations = {
28
28
  existing_install_detected: 'Existing install detected — will use smart merge mode',
29
29
  existing_core_files: 'Existing core files:',
30
30
  install_complete: 'Install complete!',
31
+ post_install_checklist: 'Post-install checklist (for you or your agent):',
32
+ agent_skill_source_label: 'Skill source',
33
+ agent_skill_refused_label: 'Refused',
34
+ agent_skill_state_installed: 'installed',
35
+ agent_skill_state_foreign: 'FOREIGN — occupied by a non-PD file',
36
+ agent_skill_state_not_installed: 'not installed',
31
37
  principles_disciple_setup: 'Principles Disciple Setup',
32
38
  detecting_environment: 'Detecting environment',
33
39
  openclaw_target_found: 'OpenClaw integration target found',
@@ -152,6 +158,12 @@ const translations = {
152
158
  existing_install_detected: '检测到现有安装 — 将使用智能合并模式',
153
159
  existing_core_files: '现有核心文件:',
154
160
  install_complete: '安装完成!',
161
+ post_install_checklist: '安装后验收清单(给你或你的智能体执行):',
162
+ agent_skill_source_label: '技能来源',
163
+ agent_skill_refused_label: '已拒绝',
164
+ agent_skill_state_installed: '已安装',
165
+ agent_skill_state_foreign: '外来占用(非 PD 文件)',
166
+ agent_skill_state_not_installed: '未安装',
155
167
  principles_disciple_setup: 'Principles Disciple 安装',
156
168
  detecting_environment: '检测环境',
157
169
  openclaw_target_found: 'OpenClaw 集成目标已找到',
@@ -1,4 +1,10 @@
1
1
  import { Updater } from 'tuf-js';
2
+ // tuf-js publishes no `exports` map, so these are the only reachable paths to
3
+ // the classes its own loader matches on: `Updater#loadRoot` treats a root
4
+ // probe as "absent" ONLY for a `DownloadHTTPError` whose statusCode is 403/404,
5
+ // and every other error is rethrown (PRI-1219).
6
+ import { DownloadHTTPError } from 'tuf-js/dist/error.js';
7
+ import { DefaultFetcher } from 'tuf-js/dist/fetcher.js';
2
8
  export class ReleaseTrustError extends Error {
3
9
  code;
4
10
  nextAction;
@@ -9,6 +15,165 @@ export class ReleaseTrustError extends Error {
9
15
  this.nextAction = options.nextAction;
10
16
  }
11
17
  }
18
+ /**
19
+ * TUF client workflow 5.3.3 makes every refresh probe `<current+1>.root.json`
20
+ * and defines ONLY 403/404 as "the trusted root is already the newest one".
21
+ * A carrier that answers a non-existent object with 5xx therefore fails the
22
+ * whole refresh even though the signed chain is intact (PRI-1219: GitHub Pages
23
+ * served `503 / Server: Varnish` for `2.root.json`, and every update check on
24
+ * a healthy 2.8.5 install reported a trust failure that never happened).
25
+ *
26
+ * A persistent 5xx on that OPTIONAL probe carries no information about whether
27
+ * a newer root exists, so it is read as "no newer root" here. The root that
28
+ * stays pinned is the one the install ALREADY trusts, so this never widens what
29
+ * is trusted — but it DEFERS a rotation instead of evaluating it, and the two
30
+ * rotation shapes behave differently:
31
+ * - rotation to a key the held root does not name still fails closed: tuf-js
32
+ * rejects the new timestamp/snapshot/targets signatures;
33
+ * - a version-only rotation, or one that revokes a key while keeping the
34
+ * signing key, is NOT detected here — the held root keeps accepting the
35
+ * signatures it names until the carrier answers the probe again.
36
+ * That gap is why every suppression is reported on the resolved target through
37
+ * `retainedTrustAnchor` instead of disappearing.
38
+ *
39
+ * A transient 5xx is not evidence of an outage either, so the default fetcher
40
+ * retries a bounded number of times before the probe is read as absent or the
41
+ * failure is reported.
42
+ */
43
+ const ROOT_ROTATION_PROBE_PATTERN = /\/\d+\.root\.json$/;
44
+ const TRUST_FETCH_RETRIES = 2;
45
+ const TRUST_FETCH_MIN_TIMEOUT_MS = 250;
46
+ const TRUST_FETCH_MAX_TIMEOUT_MS = 2_000;
47
+ function isServerErrorStatus(statusCode) {
48
+ return statusCode >= 500 && statusCode <= 599;
49
+ }
50
+ function isRootRotationProbe(url) {
51
+ return ROOT_ROTATION_PROBE_PATTERN.test(url);
52
+ }
53
+ function describeMetadataObject(url) {
54
+ const name = url.slice(url.lastIndexOf('/') + 1);
55
+ if (/^\d+\.root\.json$/.test(name))
56
+ return 'trusted-root rotation probe';
57
+ if (name === 'timestamp.json')
58
+ return 'timestamp document';
59
+ if (name === 'snapshot.json')
60
+ return 'snapshot document';
61
+ if (name === 'targets.json')
62
+ return 'targets document';
63
+ return `metadata object ${name}`;
64
+ }
65
+ /**
66
+ * Fetcher used by every TUF refresh in this module unless a caller injects
67
+ * its own. Wraps tuf-js's default fetcher (bounded retry for transient
68
+ * delivery faults) and applies the root-probe rule above.
69
+ */
70
+ class ResilientTrustFetcher {
71
+ inner;
72
+ failure;
73
+ // Deliberately NOT reset per download: it describes a policy decision that
74
+ // applies to the whole refresh, so it must survive to the success path.
75
+ suppressedRootProbe;
76
+ constructor(inner) {
77
+ // No timeout is configured on purpose: an existing install's check
78
+ // behaviour must not change beyond the retry/root-probe policy.
79
+ this.inner = inner ?? new DefaultFetcher({
80
+ retry: {
81
+ retries: TRUST_FETCH_RETRIES,
82
+ minTimeout: TRUST_FETCH_MIN_TIMEOUT_MS,
83
+ maxTimeout: TRUST_FETCH_MAX_TIMEOUT_MS,
84
+ },
85
+ });
86
+ }
87
+ get lastDownloadFailure() {
88
+ return this.failure;
89
+ }
90
+ get retainedRootProbe() {
91
+ return this.suppressedRootProbe;
92
+ }
93
+ async downloadBytes(url, maxLength) {
94
+ return this.guard(url, () => this.inner.downloadBytes(url, maxLength));
95
+ }
96
+ async downloadFile(url, maxLength, handler) {
97
+ return this.guard(url, () => this.inner.downloadFile(url, maxLength, handler));
98
+ }
99
+ async guard(url, download) {
100
+ this.failure = undefined;
101
+ try {
102
+ return await download();
103
+ }
104
+ catch (error) {
105
+ this.failure = {
106
+ url,
107
+ statusCode: error instanceof DownloadHTTPError ? error.statusCode : undefined,
108
+ };
109
+ if (error instanceof DownloadHTTPError
110
+ && isServerErrorStatus(error.statusCode)
111
+ && isRootRotationProbe(url)) {
112
+ this.suppressedRootProbe = this.failure;
113
+ // Rethrown as the "absent" status `loadRoot` breaks on. The message
114
+ // names the real status so a log never loses the cause.
115
+ throw new DownloadHTTPError(`HTTP ${error.statusCode} for ${url} — no newer trusted root could be confirmed, keeping the installed root`, 404);
116
+ }
117
+ throw error;
118
+ }
119
+ }
120
+ }
121
+ /**
122
+ * Not exported: a caller-built fetcher would be created OUTSIDE
123
+ * `resolveTrustedReleaseTarget`, whose success path is what reports a retained
124
+ * trust anchor, so its suppressions would silently vanish. Callers that need
125
+ * their own fetcher pass one through `options.fetcher` and accept the reduced
126
+ * diagnosis.
127
+ */
128
+ function createTrustMetadataFetcher() {
129
+ return new ResilientTrustFetcher();
130
+ }
131
+ /**
132
+ * Flattens an error and its `cause` chain. Node's `fetch` reports a transport
133
+ * fault as `TypeError: fetch failed` and puts the actionable text
134
+ * (`connect ECONNREFUSED …`, `getaddrinfo ENOTFOUND …`) one level down, so the
135
+ * top-level message alone is useless to an Owner.
136
+ */
137
+ function describeErrorChain(error) {
138
+ const messages = [];
139
+ let current = error;
140
+ for (let depth = 0; depth < 4; depth += 1) {
141
+ if (current === undefined || current === null)
142
+ break;
143
+ const message = current instanceof Error ? current.message : String(current);
144
+ if (message.length > 0 && !messages.includes(message))
145
+ messages.push(message);
146
+ current = current instanceof Error ? current.cause : undefined;
147
+ }
148
+ return messages.length > 0 ? messages.join(' → ') : String(error);
149
+ }
150
+ /**
151
+ * Turns a failed refresh into an Owner-facing diagnosis. A download fault must
152
+ * never be reported as "could not be verified against the trusted root": that
153
+ * wording sent the reporter of PRI-1219 chasing a trust-root problem (and a
154
+ * VPN) while the metadata carrier was returning 503.
155
+ */
156
+ function describeRefreshFailure(error, failure) {
157
+ const cause = describeErrorChain(error);
158
+ const detail = cause.length > 300 ? `${cause.slice(0, 297)}...` : cause;
159
+ if (failure !== undefined) {
160
+ const object = describeMetadataObject(failure.url);
161
+ // A transport failure has no status code. Say so AND keep the underlying
162
+ // message: "no HTTP response" alone would hide a DNS/TLS/socket error that
163
+ // the Owner needs to tell a dead network apart from a dead repository.
164
+ const status = failure.statusCode === undefined
165
+ ? `no HTTP response (${detail})`
166
+ : `HTTP ${failure.statusCode}`;
167
+ return {
168
+ message: `Release metadata refresh failed while downloading the ${object}: ${status} from ${failure.url}. The signed chain could not be fully evaluated — this is a delivery failure on the metadata carrier, not a signature or trust-root failure.`,
169
+ nextAction: `Retry the update check. If the metadata carrier keeps failing for ${failure.url}, the release repository is unhealthy and needs repair; re-pinning the trust root would not help.`,
170
+ };
171
+ }
172
+ return {
173
+ message: `Release metadata could not be verified against the trusted root: ${detail}`,
174
+ nextAction: 'Do not install this release. Check the signed release repository and retry after the metadata issue is resolved.',
175
+ };
176
+ }
12
177
  function isNonEmptyString(value) {
13
178
  return typeof value === 'string' && value.trim().length > 0;
14
179
  }
@@ -43,6 +208,25 @@ function readArtifactSha256(hashes) {
43
208
  }
44
209
  return sha256.toLowerCase();
45
210
  }
211
+ /**
212
+ * Reports a suppressed root-rotation probe on the SUCCESS path. Absent when the
213
+ * caller injected its own fetcher (no suppression is observable there).
214
+ */
215
+ function retainedAnchorReport(fetcher) {
216
+ if (!(fetcher instanceof ResilientTrustFetcher))
217
+ return {};
218
+ const probe = fetcher.retainedRootProbe;
219
+ if (probe === undefined || probe.statusCode === undefined)
220
+ return {};
221
+ return {
222
+ retainedTrustAnchor: {
223
+ probeUrl: probe.url,
224
+ statusCode: probe.statusCode,
225
+ message: `The ${describeMetadataObject(probe.url)} answered HTTP ${probe.statusCode}, so the installed trusted root was kept without checking for a newer one. This release is still verified against that root, but a root rotation or key revocation published meanwhile has NOT been applied.`,
226
+ nextAction: `Repair the metadata carrier so ${probe.url} answers 403/404 when no newer root exists. Until then, keep publishing under the installed root and do not rely on root rotation reaching existing installs.`,
227
+ },
228
+ };
229
+ }
46
230
  /**
47
231
  * Resolves a release target only after the official TUF client verifies the
48
232
  * trusted-root → timestamp → snapshot → targets metadata chain.
@@ -60,20 +244,23 @@ export async function resolveTrustedReleaseTarget(options) {
60
244
  });
61
245
  }
62
246
  let target;
247
+ const fetcher = options.fetcher ?? createTrustMetadataFetcher();
63
248
  try {
64
249
  const updater = new Updater({
65
250
  metadataDir: options.metadataDir,
66
251
  metadataBaseUrl: options.metadataBaseUrl,
67
- fetcher: options.fetcher,
252
+ fetcher,
68
253
  });
69
254
  await updater.refresh();
70
255
  target = await updater.getTargetInfo(options.targetPath);
71
256
  }
72
257
  catch (error) {
258
+ const failure = fetcher instanceof ResilientTrustFetcher ? fetcher.lastDownloadFailure : undefined;
259
+ const diagnosis = describeRefreshFailure(error, failure);
73
260
  throw new ReleaseTrustError({
74
261
  code: 'metadata_refresh_failed',
75
- message: 'Release metadata could not be verified against the trusted root.',
76
- nextAction: 'Do not install this release. Check the signed release repository and retry after the metadata issue is resolved.',
262
+ message: diagnosis.message,
263
+ nextAction: diagnosis.nextAction,
77
264
  cause: error,
78
265
  });
79
266
  }
@@ -99,6 +286,7 @@ export async function resolveTrustedReleaseTarget(options) {
99
286
  platform: identity.platform,
100
287
  releaseId: identity.releaseId,
101
288
  targetPath: target.path,
289
+ ...retainedAnchorReport(fetcher),
102
290
  };
103
291
  }
104
292
  function destinationDirOf(destinationPath) {
@@ -128,7 +316,7 @@ export async function downloadTrustedReleasePayload(options) {
128
316
  metadataDir: options.metadataDir,
129
317
  metadataBaseUrl: options.metadataBaseUrl,
130
318
  targetBaseUrl: `${options.metadataBaseUrl.replace(/\/+$/, '')}/targets`,
131
- fetcher: options.fetcher,
319
+ fetcher: options.fetcher ?? createTrustMetadataFetcher(),
132
320
  });
133
321
  await updater.refresh();
134
322
  const target = await updater.getTargetInfo(options.targetPath);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.152.4",
3
+ "version": "1.153.0",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -19,6 +19,7 @@
19
19
  },
20
20
  "files": [
21
21
  "dist",
22
+ "agent-skill",
22
23
  "plugin",
23
24
  "pd-cli",
24
25
  "console",
@@ -71,15 +71,31 @@ function redactStringFields(data) {
71
71
  * core writer, so the WorkBuddy host path carries the host's natural ids
72
72
  * (generation_id → runId/turnId, call_id → toolCallId).
73
73
  */
74
- function workbuddyEventEmitter(stateDir, evidence) {
74
+ function workbuddyEventEmitter(stateDir, evidence, readAdaptiveFact) {
75
75
  return {
76
76
  recordRuntimeActivationsInjected(data) {
77
+ // PRI-1127: attach the Adaptive turn fact to the SAME injection event the
78
+ // Console already reads. Flag-off / Native turns produce NO fact at all,
79
+ // so `adaptive` stays absent (never a fabricated "no append" record).
80
+ // `appendedActivationId` is the FINAL ASSEMBLY basis: a selected id that
81
+ // did not reach activationIds (budget, dropped, failed packing) is not
82
+ // reported as appended.
83
+ const fact = readAdaptiveFact?.() ?? null;
84
+ const adaptive = fact === null
85
+ ? undefined
86
+ : {
87
+ resultCode: `${fact.status}:${fact.reason}`.slice(0, 240),
88
+ scored: fact.sends > 0,
89
+ ...(fact.targetActivationId !== null && data.activationIds.includes(fact.targetActivationId)
90
+ ? { appendedActivationId: fact.targetActivationId }
91
+ : {}),
92
+ };
77
93
  appendEventLogLine(stateDir, {
78
94
  ts: new Date().toISOString(),
79
95
  type: 'runtime_v2_prompt_activations_injected',
80
96
  category: 'injected',
81
97
  sessionId: data.sessionId,
82
- data,
98
+ data: adaptive === undefined ? data : { ...data, adaptive },
83
99
  });
84
100
  // Delivery evidence AFTER the durable source line exists; degrades to a
85
101
  // bounded diagnostic and never affects the hook result.
@@ -434,6 +450,10 @@ export async function processWorkbuddyHookInvocation(rawStdin, channelEventName,
434
450
  // defaults) and must be visible on stderr (rc-9).
435
451
  ? toolSemanticsResolution.warnings.map((warning) => diagnostic('degraded', warning, 're-run this host so it refreshes its persisted tool declaration'))
436
452
  : [diagnostic('degraded', toolSemanticsResolution.reason, toolSemanticsResolution.nextAction)];
453
+ // PRI-1127: capture the real selection outcome for THIS turn so the same
454
+ // injection event can carry the Adaptive fact the Console reads. Absent
455
+ // (flag off / Native) stays absent — no fabricated record.
456
+ let adaptiveTurnFact = null;
437
457
  const adaptive = event.kind === 'before_prompt_build' && flags['host.workbuddy.adaptive_activation']?.enabled === true
438
458
  ? createAdaptivePriorityProviderForConfig(config.effective.config, resolution.workspaceDir, {
439
459
  flag: 'host.workbuddy.adaptive_activation',
@@ -442,12 +462,26 @@ export async function processWorkbuddyHookInvocation(rawStdin, channelEventName,
442
462
  // work well inside that budget, including this process's startup.
443
463
  outerDeadlineAt: Date.now() + Math.max(0, 5000 - Math.round(process.uptime() * 1000)),
444
464
  onDiagnostic: (line) => {
465
+ adaptiveTurnFact = {
466
+ status: line.status,
467
+ reason: line.reason,
468
+ sends: line.sends,
469
+ targetActivationId: line.targetActivationId,
470
+ };
445
471
  if (line.status !== 'selected')
446
472
  evidenceDiagnostics.push(diagnostic(line.status === 'unavailable' ? 'degraded' : 'skipped', `adaptive_selection_${line.status}:${line.reason}`, 'Check Adaptive configuration or use Native assembly.'));
447
473
  },
448
474
  })
449
475
  : undefined;
450
476
  if (adaptive && !adaptive.ok) {
477
+ // `sends: 0` is a fact, not an assumption: no request can leave when the
478
+ // effective configuration cannot build a model (Codex precedent).
479
+ adaptiveTurnFact = {
480
+ status: 'needs_setup',
481
+ reason: adaptive.reason,
482
+ sends: 0,
483
+ targetActivationId: null,
484
+ };
451
485
  evidenceDiagnostics.push(diagnostic('degraded', `adaptive_activation_${adaptive.readiness}:${adaptive.reason}`, adaptive.nextAction));
452
486
  }
453
487
  const result = await createProductionHostRuntime({
@@ -455,7 +489,7 @@ export async function processWorkbuddyHookInvocation(rawStdin, channelEventName,
455
489
  ...(projectDir !== undefined ? { projectDir } : {}),
456
490
  hostKind: 'workbuddy',
457
491
  toolSemantics,
458
- events: workbuddyEventEmitter(stateDir, evidenceContext),
492
+ events: workbuddyEventEmitter(stateDir, evidenceContext, () => adaptiveTurnFact),
459
493
  // SPEC-RULECODE-HOST-PROMOTION-001 C: the V2 rule context provider over
460
494
  // WorkBuddy's own observable trajectory (same-session tool_calls rows
461
495
  // the shared afterToolCall path records). No designGate fact is
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/workbuddy-adapter",
3
- "version": "0.6.5",
3
+ "version": "0.6.6",
4
4
  "description": "WorkBuddy host adapter for Principles Disciple — implements the HostAdapter interface for WorkBuddy's Git Bash command-hook model (ADR-0020 third host, SPEC workbuddy-host-adapter v0.3.0).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",