create-principles-disciple 1.147.8 → 1.147.10

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 (73) hide show
  1. package/_release/product-identity.json +2 -2
  2. package/core/dist/runtime-v2/activation/adaptive-delivery-record.d.ts +37 -0
  3. package/core/dist/runtime-v2/activation/adaptive-delivery-record.d.ts.map +1 -0
  4. package/core/dist/runtime-v2/activation/adaptive-delivery-record.js +126 -0
  5. package/core/dist/runtime-v2/activation/adaptive-delivery-record.js.map +1 -0
  6. package/core/dist/runtime-v2/activation/adaptive-principle-intervention.d.ts +46 -0
  7. package/core/dist/runtime-v2/activation/adaptive-principle-intervention.d.ts.map +1 -0
  8. package/core/dist/runtime-v2/activation/adaptive-principle-intervention.js +91 -0
  9. package/core/dist/runtime-v2/activation/adaptive-principle-intervention.js.map +1 -0
  10. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts +2 -0
  11. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.d.ts.map +1 -1
  12. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js +2 -0
  13. package/core/dist/runtime-v2/activation/prompt-activation-reader-contract.js.map +1 -1
  14. package/core/dist/runtime-v2/index.d.ts +4 -0
  15. package/core/dist/runtime-v2/index.d.ts.map +1 -1
  16. package/core/dist/runtime-v2/index.js +3 -0
  17. package/core/dist/runtime-v2/index.js.map +1 -1
  18. package/core/dist/runtime-v2/store/sqlite-connection.js +1 -1
  19. package/core/dist/runtime-v2/store/sqlite-connection.js.map +1 -1
  20. package/core/dist/runtime-v2/store/workspace-leak-guard.d.ts.map +1 -1
  21. package/core/dist/runtime-v2/store/workspace-leak-guard.js +8 -2
  22. package/core/dist/runtime-v2/store/workspace-leak-guard.js.map +1 -1
  23. package/core/dist/runtime-v2/types/event-types.d.ts +6 -3
  24. package/core/dist/runtime-v2/types/event-types.d.ts.map +1 -1
  25. package/core/dist/runtime-v2/types/event-types.js +2 -0
  26. package/core/dist/runtime-v2/types/event-types.js.map +1 -1
  27. package/core/package.json +5 -1
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +9 -0
  30. package/dist/index.js.map +1 -1
  31. package/dist/install-summary.d.ts +3 -0
  32. package/dist/install-summary.d.ts.map +1 -1
  33. package/dist/install-summary.js +17 -9
  34. package/dist/install-summary.js.map +1 -1
  35. package/dist/installers/workbuddy-host-installer.d.ts +20 -1
  36. package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
  37. package/dist/installers/workbuddy-host-installer.js +75 -14
  38. package/dist/installers/workbuddy-host-installer.js.map +1 -1
  39. package/host-runtime/dist/active-principle-prompt.d.ts +28 -0
  40. package/host-runtime/dist/active-principle-prompt.js +163 -50
  41. package/host-runtime/dist/adaptive-journal-reconciliation.d.ts +205 -0
  42. package/host-runtime/dist/adaptive-journal-reconciliation.js +1050 -0
  43. package/host-runtime/dist/adaptive-principle-revalidation.d.ts +8 -0
  44. package/host-runtime/dist/adaptive-principle-revalidation.js +52 -0
  45. package/host-runtime/dist/index.d.ts +17 -0
  46. package/host-runtime/dist/index.js +35 -0
  47. package/host-runtime/dist/prompt-activation-authority.d.ts +7 -0
  48. package/host-runtime/dist/prompt-activation-authority.js +16 -0
  49. package/host-runtime/package.json +1 -1
  50. package/package.json +3 -3
  51. package/pd-cli/dist/commands/runtime-activation.d.ts +18 -0
  52. package/pd-cli/dist/commands/runtime-activation.d.ts.map +1 -1
  53. package/pd-cli/dist/commands/runtime-activation.js +73 -1
  54. package/pd-cli/dist/commands/runtime-activation.js.map +1 -1
  55. package/pd-cli/dist/index.js +3 -1
  56. package/pd-cli/dist/index.js.map +1 -1
  57. package/pd-cli/package.json +1 -1
  58. package/plugin/dist/bundle.js +457 -455
  59. package/plugin/dist/core/adaptive-config-identity.d.ts +106 -0
  60. package/plugin/dist/core/event-log.d.ts +3 -0
  61. package/plugin/dist/governance-audit.js +3 -3
  62. package/plugin/dist/hooks/adaptive-activation-config.d.ts +8 -0
  63. package/plugin/dist/hooks/prompt-helpers.d.ts +5 -0
  64. package/plugin/dist/hooks/prompt-types.d.ts +3 -0
  65. package/plugin/dist/hooks/prompt.d.ts +8 -1
  66. package/plugin/dist/host-runtime/openclaw-host-runtime.d.ts +13 -0
  67. package/plugin/dist/openclaw-sdk.d.ts +4 -0
  68. package/plugin/dist/openclaw.plugin.json +33 -1
  69. package/plugin/dist/rulehost-evidence.js +1 -1
  70. package/plugin/openclaw.plugin.json +33 -1
  71. package/plugin/package.json +1 -1
  72. package/release-manager/dist/installers/workbuddy-host-installer.js +75 -14
  73. package/release-manager/package.json +1 -1
@@ -0,0 +1,8 @@
1
+ import { type PromptActivationCandidates } from './active-principle-prompt.js';
2
+ import type { ActivatedPrinciple } from '@principles/core/runtime-v2';
3
+ export type AdaptivePrincipleReader = (input: {
4
+ workspaceDir: string;
5
+ }) => Promise<PromptActivationCandidates>;
6
+ /** Bind a test or host-specific reader while keeping the production call signature minimal. */
7
+ export declare function createAdaptivePrincipleRevalidator(reader: AdaptivePrincipleReader): (workspaceDir: string, expected: ActivatedPrinciple, signal: AbortSignal) => Promise<boolean>;
8
+ export declare function revalidateAdaptivePrinciple(workspaceDir: string, expected: ActivatedPrinciple, signal: AbortSignal): Promise<boolean>;
@@ -0,0 +1,52 @@
1
+ import { readPromptActivationCandidates, } from './active-principle-prompt.js';
2
+ /**
3
+ * Rechecks the rendered principle's identity, body, and authorization at the
4
+ * adaptive-intervention return boundary. A full artifact digest is required;
5
+ * legacy snapshots without it cannot certify a stable artifact revision.
6
+ */
7
+ async function revalidateWithReader(input, reader) {
8
+ const { workspaceDir, expected, signal } = input;
9
+ if (signal.aborted || !expected.artifactContentSha256 || !/^[a-f0-9]{64}$/.test(expected.artifactContentSha256))
10
+ return false;
11
+ let onAbort;
12
+ const aborted = new Promise((resolve) => {
13
+ onAbort = () => resolve(null);
14
+ signal.addEventListener('abort', onAbort, { once: true });
15
+ if (signal.aborted)
16
+ onAbort();
17
+ });
18
+ try {
19
+ const result = await Promise.race([reader({ workspaceDir }), aborted]);
20
+ if (!result || signal.aborted || result.aborted || result.warnings.length > 0)
21
+ return false;
22
+ const matches = result.principles.filter((candidate) => candidate.artifactId === expected.artifactId && candidate.activationId === expected.activationId);
23
+ if (matches.length !== 1)
24
+ return false;
25
+ const [current] = matches;
26
+ if (!current)
27
+ return false;
28
+ // Duplicate principle identity is ambiguous even if one activation pair matches.
29
+ if (result.principles.filter((candidate) => candidate.principleId === expected.principleId).length !== 1)
30
+ return false;
31
+ return current.principleId === expected.principleId
32
+ && current.artifactContentSha256 === expected.artifactContentSha256
33
+ && current.text === expected.text
34
+ && current.authority === expected.authority
35
+ && current.approvedBy === expected.approvedBy;
36
+ }
37
+ catch {
38
+ return false;
39
+ }
40
+ finally {
41
+ if (onAbort)
42
+ signal.removeEventListener('abort', onAbort);
43
+ }
44
+ }
45
+ /** Bind a test or host-specific reader while keeping the production call signature minimal. */
46
+ export function createAdaptivePrincipleRevalidator(reader) {
47
+ return (workspaceDir, expected, signal) => revalidateWithReader({ workspaceDir, expected, signal }, reader);
48
+ }
49
+ export function revalidateAdaptivePrinciple(workspaceDir, expected, signal) {
50
+ const readWithAuthority = ({ workspaceDir: currentWorkspaceDir }) => readPromptActivationCandidates({ workspaceDir: currentWorkspaceDir, includeAuthority: true });
51
+ return revalidateWithReader({ workspaceDir, expected, signal }, readWithAuthority);
52
+ }
@@ -5,6 +5,7 @@ import type { RuleImplementationRuntime } from './rule-implementation-runtime.js
5
5
  import { type PainDatabaseFactory, type PainEnrichmentProvider } from './production-pain-evidence.js';
6
6
  import type { GovernanceHostKind, ToolSemanticRegistry } from '@principles/core/runtime-v2';
7
7
  export * from './active-principle-prompt.js';
8
+ export * from './prompt-activation-authority.js';
8
9
  export * from './prompt-injection-projection.js';
9
10
  export * from './prompt-activation-deliverability.js';
10
11
  export * from './prompt-injection-status.js';
@@ -76,6 +77,20 @@ export declare function createProductionHostRuntime(options?: Partial<Pick<HostR
76
77
  projectDir?: string;
77
78
  /** PRI-634-F: host-declared tool semantics supplied by the constructing host adapter. */
78
79
  toolSemantics?: ToolSemanticRegistry;
80
+ /** Optional, already-scoped single prompt target from the host adapter. Errors fail closed to Native. */
81
+ adaptivePriorityProvider?: (event: HostEvent) => {
82
+ artifactId: string;
83
+ activationId: string;
84
+ hookInvocationId?: string;
85
+ signal?: AbortSignal;
86
+ deadlineAt?: number;
87
+ } | undefined | Promise<{
88
+ artifactId: string;
89
+ activationId: string;
90
+ hookInvocationId?: string;
91
+ signal?: AbortSignal;
92
+ deadlineAt?: number;
93
+ } | undefined>;
79
94
  /**
80
95
  * PRI-750: optional event emission port. When present, the shared-path
81
96
  * handlers record injection/tool events carrying the host's natural
@@ -96,3 +111,5 @@ export * from './explicit-owner-statement-prefix.js';
96
111
  export { listObservedDesignGateSessions } from './workspace-behavior-evidence.js';
97
112
  export { readDesignGateSpecSnapshot, describeCodexRuleContextFact } from './design-gate-facts.js';
98
113
  export { createCodexArtificerTrustedFactsPort } from './codex-artificer-trusted-facts.js';
114
+ export { revalidateAdaptivePrinciple, createAdaptivePrincipleRevalidator, type AdaptivePrincipleReader } from './adaptive-principle-revalidation.js';
115
+ export * from './adaptive-journal-reconciliation.js';
@@ -6,6 +6,7 @@ import { buildActivePrinciplePromptContext } from './active-principle-prompt.js'
6
6
  import { createProductionRuleHostGate } from './production-rulehost-gate.js';
7
7
  import { createProductionPainEvidenceHandler } from './production-pain-evidence.js';
8
8
  export * from './active-principle-prompt.js';
9
+ export * from './prompt-activation-authority.js';
9
10
  export * from './prompt-injection-projection.js';
10
11
  // SPEC PD_PROMPT_CAPACITY_V1: route-aware single-artifact deliverability
11
12
  // precheck (B1 write gate + A candidate fit) and the per-live-activation
@@ -225,8 +226,35 @@ export function createProductionHostRuntime(options = {}) {
225
226
  const declaredWindow = promptBudgetHostKind === undefined
226
227
  ? undefined
227
228
  : operatorDeclaredContextWindow(loadPdConfigForPlugin(event.context.workspaceDir).effective.config.promptBudget, promptBudgetHostKind);
229
+ let adaptivePriority;
230
+ let skippedPriority;
231
+ if (options.adaptivePriorityProvider) {
232
+ try {
233
+ adaptivePriority = await options.adaptivePriorityProvider(event);
234
+ if (adaptivePriority && (typeof adaptivePriority.artifactId !== 'string' || !adaptivePriority.artifactId.trim()
235
+ || typeof adaptivePriority.activationId !== 'string' || !adaptivePriority.activationId.trim()
236
+ || (adaptivePriority.deadlineAt !== undefined && !Number.isFinite(adaptivePriority.deadlineAt)))) {
237
+ adaptivePriority = undefined;
238
+ }
239
+ if (adaptivePriority?.signal?.aborted
240
+ || (adaptivePriority?.deadlineAt !== undefined && Date.now() >= adaptivePriority.deadlineAt)) {
241
+ skippedPriority = adaptivePriority;
242
+ adaptivePriority = undefined;
243
+ }
244
+ }
245
+ catch {
246
+ // An optional adaptive provider can never alter the ordinary Native path on failure.
247
+ adaptivePriority = undefined;
248
+ }
249
+ }
228
250
  const prompt = await buildActivePrinciplePromptContext({
229
251
  workspaceDir: event.context.workspaceDir,
252
+ ...(adaptivePriority ? {
253
+ adaptivePriority: { artifactId: adaptivePriority.artifactId, activationId: adaptivePriority.activationId },
254
+ ...(adaptivePriority.signal ? { signal: adaptivePriority.signal } : {}),
255
+ ...(adaptivePriority.deadlineAt !== undefined ? { deadlineAt: adaptivePriority.deadlineAt } : {}),
256
+ ...(adaptivePriority.hookInvocationId ? { hookInvocationId: adaptivePriority.hookInvocationId } : {}),
257
+ } : {}),
230
258
  promptBudget: resolvePromptBudget({
231
259
  // SPEC-PD-MODEL-AWARE-PROMPT-BUDGET-001: resolve ONCE per request
232
260
  // from the host's own hook facts (OpenClaw effective window /
@@ -250,6 +278,11 @@ export function createProductionHostRuntime(options = {}) {
250
278
  catalog: getPromptModelCatalog(),
251
279
  }),
252
280
  });
281
+ if (skippedPriority?.hookInvocationId)
282
+ prompt.adaptivePacking = {
283
+ status: 'unavailable', reason: 'deadline', targetActivationId: skippedPriority.activationId,
284
+ targetArtifactId: skippedPriority.artifactId, hookInvocationId: skippedPriority.hookInvocationId, displacedActivationIds: [],
285
+ };
253
286
  // PRI-750: record the injection event on the shared path with the host
254
287
  // turn id (Codex turn_id → runId) so receipt events carry a turn-level
255
288
  // anchor in the same events_*.jsonl format as the OpenClaw path. The
@@ -326,3 +359,5 @@ export * from './explicit-owner-statement-prefix.js';
326
359
  export { listObservedDesignGateSessions } from './workspace-behavior-evidence.js';
327
360
  export { readDesignGateSpecSnapshot, describeCodexRuleContextFact } from './design-gate-facts.js';
328
361
  export { createCodexArtificerTrustedFactsPort } from './codex-artificer-trusted-facts.js';
362
+ export { revalidateAdaptivePrinciple, createAdaptivePrincipleRevalidator } from './adaptive-principle-revalidation.js';
363
+ export * from './adaptive-journal-reconciliation.js';
@@ -0,0 +1,7 @@
1
+ import type { SqliteConnection } from '@principles/core/runtime-v2';
2
+ export interface PromptActivationAuthority {
3
+ authority?: 'owner' | 'system_policy';
4
+ approvedBy?: string;
5
+ }
6
+ /** Read the existing approval row without changing how activation is granted. */
7
+ export declare function readPromptActivationAuthority(sqliteConn: Pick<SqliteConnection, 'getDb'>, artifactId: string, channel: string): PromptActivationAuthority;
@@ -0,0 +1,16 @@
1
+ /** Read the existing approval row without changing how activation is granted. */
2
+ export function readPromptActivationAuthority(sqliteConn, artifactId, channel) {
3
+ const row = sqliteConn.getDb().prepare(`
4
+ SELECT decided_by FROM approvals
5
+ WHERE artifact_id = ? AND channel = ? AND status = 'approved'
6
+ ORDER BY decided_at DESC LIMIT 1
7
+ `).get(artifactId, channel);
8
+ if (row !== null && typeof row === 'object' && Object.hasOwn(row, 'decided_by')) {
9
+ const decidedBy = row.decided_by;
10
+ return {
11
+ authority: 'owner',
12
+ approvedBy: typeof decidedBy === 'string' && decidedBy.length > 0 ? decidedBy : undefined,
13
+ };
14
+ }
15
+ return { authority: 'system_policy' };
16
+ }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/host-runtime",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
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.147.8",
3
+ "version": "1.147.10",
4
4
  "description": "Interactive CLI installer for Principles Disciple OpenClaw plugin",
5
5
  "type": "module",
6
6
  "bin": {
@@ -99,7 +99,7 @@
99
99
  "directory": "packages/create-principles-disciple"
100
100
  },
101
101
  "pd": {
102
- "bundledPluginVersion": "2.6.1"
102
+ "bundledPluginVersion": "2.6.2"
103
103
  },
104
- "gitHead": "d9bbe994104eac08a8a41fa1c9374f28dc629aec"
104
+ "gitHead": "c0f9f8201e929c15f3af6018b37e7b5ebd9effd8"
105
105
  }
@@ -150,5 +150,23 @@ export declare function registerRuntimeActivationDeactivateCommand(parent: Comma
150
150
  export declare function registerRuntimeActivationListCommand(parent: Command): Command;
151
151
  export declare function registerRuntimeActivationDispatchCommand(parent: Command): Command;
152
152
  export declare function registerRuntimeActivationApproveCommand(parent: Command): Command;
153
+ export interface RuntimeActivationJournalOptions {
154
+ workspace?: string;
155
+ since?: string;
156
+ until?: string;
157
+ host?: string;
158
+ maxInvocations?: string;
159
+ maxDateFiles?: string;
160
+ maxFileBytes?: string;
161
+ maxTerminalVariants?: string;
162
+ }
163
+ /**
164
+ * PRI-1109: thin CLI wrapper over the read-only reconciler in
165
+ * @principles/host-runtime. All semantic decisions live in the library; this
166
+ * handler only parses options, prints the library's single JSON document to
167
+ * stdout, routes diagnostics to stderr, and sets the exit code.
168
+ */
169
+ export declare function handleRuntimeActivationJournal(opts: RuntimeActivationJournalOptions): Promise<void>;
170
+ export declare function registerRuntimeActivationJournalCommand(parent: Command): Command;
153
171
  export {};
154
172
  //# sourceMappingURL=runtime-activation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-activation.d.ts","sourceRoot":"","sources":["../../src/commands/runtime-activation.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,E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wBAAgB,0CAA0C,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAkBnF;AAED,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAgB7E;AAED,wBAAgB,wCAAwC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAoBjF;AAED,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAwBhF;AAED,MAAM,WAAW,+BAA+B;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED;;;;;GAKG;AACH,wBAAsB,8BAA8B,CAAC,IAAI,EAAE,+BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDzG;AAED,wBAAgB,uCAAuC,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAwBhF"}
@@ -2,7 +2,7 @@ import * as path from 'path';
2
2
  import * as fs from 'node:fs';
3
3
  import { createHash, randomUUID } from 'node:crypto';
4
4
  import { RuntimeStateManager, ActivationDispatcher, PromptWriter, DeferArchiveWriter, RuleHostWriter, createProductionGateDeps, SqliteActivationStateStore, SqliteApprovalQueueStore, SqlitePIArtifactStore, PrincipleTreeLedgerAdapter, ApprovalQueue, ApprovalCompletionService, isArtifactRevisionOf, extractEvidenceRefs, extractPrincipleId, isFeatureEnabled, RuleCodeOwnerDecisionService, PromotionReadinessReader, SqliteActivationSafetyStore, collectOpenClawPromotionChecks, summarizeRuleCodeShadowEvents, buildPromotionEvidenceSnapshot, detectPromptReplacementTarget, } from '@principles/core/runtime-v2';
5
- import { checkPromptArtifactDeliverabilityById, RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS } from '@principles/host-runtime';
5
+ import { checkPromptArtifactDeliverabilityById, RUNTIME_V2_EVENT_LOG_CANDIDATE_DIRS, reconcileAdaptiveJournal, } from '@principles/host-runtime';
6
6
  /**
7
7
  * I3 upgrade (Owner review of PR #1856, P1): ledger-aware identity deps for
8
8
  * the dispatcher. Membership is verified against the ledger SSOT at
@@ -1686,4 +1686,76 @@ export function registerRuntimeActivationApproveCommand(parent) {
1686
1686
  });
1687
1687
  });
1688
1688
  }
1689
+ /**
1690
+ * PRI-1109: thin CLI wrapper over the read-only reconciler in
1691
+ * @principles/host-runtime. All semantic decisions live in the library; this
1692
+ * handler only parses options, prints the library's single JSON document to
1693
+ * stdout, routes diagnostics to stderr, and sets the exit code.
1694
+ */
1695
+ export async function handleRuntimeActivationJournal(opts) {
1696
+ const workspaceDir = opts.workspace ? path.resolve(opts.workspace) : resolveWorkspaceDir();
1697
+ const limits = {};
1698
+ if (opts.maxInvocations !== undefined)
1699
+ limits.maxInvocations = Number(opts.maxInvocations);
1700
+ if (opts.maxDateFiles !== undefined)
1701
+ limits.maxDateFilesPerDir = Number(opts.maxDateFiles);
1702
+ if (opts.maxFileBytes !== undefined)
1703
+ limits.maxFileBytes = Number(opts.maxFileBytes);
1704
+ if (opts.maxTerminalVariants !== undefined)
1705
+ limits.maxTerminalVariantsPerInvocation = Number(opts.maxTerminalVariants);
1706
+ const result = reconcileAdaptiveJournal({
1707
+ workspaceDir,
1708
+ ...(opts.since !== undefined ? { since: opts.since } : {}),
1709
+ ...(opts.until !== undefined ? { until: opts.until } : {}),
1710
+ ...(opts.host !== undefined ? { host: opts.host } : {}),
1711
+ limits,
1712
+ });
1713
+ if (!result.ok) {
1714
+ // cli-1-strict-json: stdout carries exactly one machine-readable document.
1715
+ console.log(JSON.stringify(result, null, 2));
1716
+ console.error(`[activation journal] ${result.error.code}: ${result.error.message}`);
1717
+ console.error(`[activation journal] nextAction: ${result.error.nextAction}`);
1718
+ process.exitCode = 2;
1719
+ return;
1720
+ }
1721
+ const { report } = result;
1722
+ console.log(JSON.stringify(report, null, 2));
1723
+ console.error(`[activation journal] effective window: ${report.request.window.start} ~ ${report.request.window.end}`
1724
+ + ` (endIsNow=${report.request.window.endIsNow}, clampedByRetention=${report.request.window.clampedByRetention})`);
1725
+ console.error(`[activation journal] coverage=${report.coverage.status} filesRead=${report.coverage.filesRead}`
1726
+ + ` invocations=${report.totals.uniqueInvocations ?? 'unknown'}`);
1727
+ if (report.coverage.status === 'unavailable') {
1728
+ console.error('[activation journal] no readable log directory: result is unknown, not zero invocations');
1729
+ process.exitCode = 3;
1730
+ return;
1731
+ }
1732
+ if (report.outputTruncated) {
1733
+ console.error('[activation journal] output truncated: reported counts are lower bounds');
1734
+ }
1735
+ }
1736
+ export function registerRuntimeActivationJournalCommand(parent) {
1737
+ return parent
1738
+ .command('journal')
1739
+ .description('Read-only reconciliation of adaptive_delivery journal records (never writes, never runs a model)')
1740
+ .option('-w, --workspace <path>', 'Workspace directory')
1741
+ .option('--since <iso>', 'Explicit window start (ISO timestamp; default: 7 days before the window end)')
1742
+ .option('--until <iso>', 'Explicit window end (ISO timestamp; default: now)')
1743
+ .option('--host <host>', 'Host identity to reconcile', 'openclaw')
1744
+ .option('--max-invocations <n>', 'Maximum invocations emitted (default: 1000)')
1745
+ .option('--max-date-files <n>', 'Maximum date files read per log directory (default: 8)')
1746
+ .option('--max-file-bytes <n>', 'Maximum bytes read per file (default: 4194304)')
1747
+ .option('--max-terminal-variants <n>', 'Maximum terminal variants per invocation (default: 5)')
1748
+ .action(async (opts) => {
1749
+ await handleRuntimeActivationJournal({
1750
+ workspace: opts.workspace,
1751
+ since: opts.since,
1752
+ until: opts.until,
1753
+ host: opts.host,
1754
+ maxInvocations: opts.maxInvocations,
1755
+ maxDateFiles: opts.maxDateFiles,
1756
+ maxFileBytes: opts.maxFileBytes,
1757
+ maxTerminalVariants: opts.maxTerminalVariants,
1758
+ });
1759
+ });
1760
+ }
1689
1761
  //# sourceMappingURL=runtime-activation.js.map