create-principles-disciple 1.148.1 → 1.148.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "productVersion": "2.8.4",
4
- "sourceCommit": "1dd3b8e871ed88bac3cf2cc3a7dcaea9838271ba"
3
+ "productVersion": "2.8.5",
4
+ "sourceCommit": "8a791cfcfb34ec1a70dcdf392f4afc86c1a278c8"
5
5
  }
@@ -115,6 +115,32 @@ export interface SharedDirectivePacking {
115
115
  dropped: string[];
116
116
  oversized: string[];
117
117
  }
118
+ /**
119
+ * PRI-1140: resolve a configured principle identity to the AT MOST ONE
120
+ * currently-authorized prompt activation of that principle, so a delivery
121
+ * mapping survives Owner revisions (the prompt-replacement flow deactivates
122
+ * the pinned activation) without editing plugin config per revision. Read-only
123
+ * over the SAME candidates reader the shared assembly uses — selection never
124
+ * creates authorization, and the downstream guards in
125
+ * `buildActivePrinciplePromptContext` re-verify authority/content before any
126
+ * injection. Errors fail closed to Native: the caller gets a structured
127
+ * reason, never a guess.
128
+ */
129
+ export type ResolveCurrentAuthorizedActivationResult = {
130
+ ok: true;
131
+ principleId: string;
132
+ artifactId: string;
133
+ activationId: string;
134
+ warnings: string[];
135
+ } | {
136
+ ok: false;
137
+ reason: 'principle_not_currently_authorized' | 'ambiguous_current_activations' | 'candidates_unavailable';
138
+ warnings: string[];
139
+ };
140
+ export declare function resolveCurrentAuthorizedActivationByPrincipleId(input: {
141
+ workspaceDir: string;
142
+ principleId: string;
143
+ }): Promise<ResolveCurrentAuthorizedActivationResult>;
118
144
  /**
119
145
  * PRI-1137 final review P1-5: did the AUTHORIZATION FACTS of the adaptive
120
146
  * priority target change between the native snapshot (first read) and the
@@ -197,6 +223,18 @@ export declare function buildActivePrinciplePromptContext(input: {
197
223
  artifactId: string;
198
224
  activationId: string;
199
225
  };
226
+ /**
227
+ * PRI-1140 (Owner supplementary condition): additive-only adaptive packing.
228
+ * Only meaningful together with `adaptivePriority`. When true, the
229
+ * prioritized repack is accepted ONLY if it keeps every activation the
230
+ * native baseline already assembled (a pure superset — the target may be
231
+ * placed first, but nothing native-included may be squeezed out); otherwise
232
+ * the native baseline is kept and the would-be displacement is recorded via
233
+ * `adaptivePacking.reason='would_displace_native_assembly'` +
234
+ * `displacedActivationIds`. The legacy pinned-identity path is unaffected
235
+ * (its budget-driven displacement semantics are preserved verbatim).
236
+ */
237
+ additiveOnly?: boolean;
200
238
  /** Principles in the native pack that adaptive packing must preserve. */
201
239
  mandatoryPrincipleIds?: string[];
202
240
  /** Request cancellation forwarded to the final read-only target revalidation. */
@@ -95,6 +95,42 @@ export async function readPromptActivationCandidates(input) {
95
95
  }
96
96
  return { principles, warnings, aborted: false, selfReportEnabled };
97
97
  }
98
+ export async function resolveCurrentAuthorizedActivationByPrincipleId(input) {
99
+ const principleId = typeof input.principleId === 'string' ? input.principleId.trim() : '';
100
+ if (!principleId) {
101
+ return { ok: false, reason: 'principle_not_currently_authorized', warnings: [] };
102
+ }
103
+ // Mirrors the adaptive authority re-read (noBusyWait): an optional
104
+ // enhancement must not hold the host behind the synchronous busy wait; a
105
+ // read warning means the candidate set itself is not trustworthy, so the
106
+ // resolution fails closed instead of selecting from a degraded list.
107
+ const candidates = await readPromptActivationCandidates({
108
+ workspaceDir: input.workspaceDir,
109
+ includeAuthority: true,
110
+ noBusyWait: true,
111
+ });
112
+ if (candidates.aborted || candidates.warnings.length > 0) {
113
+ return { ok: false, reason: 'candidates_unavailable', warnings: candidates.warnings };
114
+ }
115
+ const matches = candidates.principles.filter((principle) => principle.principleId === principleId);
116
+ if (matches.length === 0) {
117
+ return { ok: false, reason: 'principle_not_currently_authorized', warnings: candidates.warnings };
118
+ }
119
+ if (matches.length > 1) {
120
+ return { ok: false, reason: 'ambiguous_current_activations', warnings: candidates.warnings };
121
+ }
122
+ const [resolved] = matches;
123
+ if (!resolved) {
124
+ return { ok: false, reason: 'principle_not_currently_authorized', warnings: candidates.warnings };
125
+ }
126
+ return {
127
+ ok: true,
128
+ principleId: resolved.principleId,
129
+ artifactId: resolved.artifactId,
130
+ activationId: resolved.activationId,
131
+ warnings: candidates.warnings,
132
+ };
133
+ }
98
134
  /**
99
135
  * PRI-1137 final review P1-5: did the AUTHORIZATION FACTS of the adaptive
100
136
  * priority target change between the native snapshot (first read) and the
@@ -390,13 +426,23 @@ export async function buildActivePrinciplePromptContext(input) {
390
426
  || mandatoryIds.some((id) => !prioritizedPacking.included.some((principle) => principle.principleId === id))) {
391
427
  return { ...nativeResult, adaptivePacking: report('unavailable', 'mandatory_constraint_displaced') };
392
428
  }
393
- const stillValid = await revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal);
394
- if (!stillValid)
395
- return { ...nativeResult, adaptivePacking: report('unavailable', 'target_changed') };
396
429
  const prioritizedActivationIds = new Set(prioritizedPacking.included.map((principle) => principle.activationId));
397
430
  const displacedActivationIds = nativePacking.included
398
431
  .filter((principle) => !prioritizedActivationIds.has(principle.activationId))
399
432
  .map((principle) => principle.activationId);
433
+ // PRI-1140: an additive-only target may never squeeze out content the
434
+ // native baseline already assembled. Decided BEFORE the revalidation read so
435
+ // a refused placement costs no further I/O; the would-be displacement is the
436
+ // recorded reason (bounded like the other diagnostic id lists).
437
+ if (input.additiveOnly === true && displacedActivationIds.length > 0) {
438
+ return {
439
+ ...nativeResult,
440
+ adaptivePacking: report('unavailable', 'would_displace_native_assembly', displacedActivationIds.slice(0, MAX_SHARED_DIAGNOSTIC_IDS)),
441
+ };
442
+ }
443
+ const stillValid = await revalidateAdaptivePrinciple(input.workspaceDir, authorizedTarget, signal);
444
+ if (!stillValid)
445
+ return { ...nativeResult, adaptivePacking: report('unavailable', 'target_changed') };
400
446
  const result = makeResult(prioritizedPacking, principles, prepared('prioritized', displacedActivationIds));
401
447
  // Adaptive assembly is deliberately limited to the existing renderer's Native budget cap.
402
448
  return result;
@@ -91,12 +91,23 @@ export declare function createProductionHostRuntime(options?: Partial<Pick<HostR
91
91
  adaptivePriorityProvider?: (event: HostEvent) => {
92
92
  artifactId: string;
93
93
  activationId: string;
94
+ /**
95
+ * PRI-1140: true when the provider resolved the target by CURRENT
96
+ * principle identity (revision-resilient selection). The shared
97
+ * assembly then runs its prioritized repack additively — it may place
98
+ * the target first, but must never squeeze out content the native
99
+ * baseline already assembled (otherwise the native baseline is kept and
100
+ * `would_displace_native_assembly` is recorded). Absent/false keeps the
101
+ * legacy pinned-identity semantics untouched.
102
+ */
103
+ additiveOnly?: boolean;
94
104
  hookInvocationId?: string;
95
105
  signal?: AbortSignal;
96
106
  deadlineAt?: number;
97
107
  } | undefined | Promise<{
98
108
  artifactId: string;
99
109
  activationId: string;
110
+ additiveOnly?: boolean;
100
111
  hookInvocationId?: string;
101
112
  signal?: AbortSignal;
102
113
  deadlineAt?: number;
@@ -249,6 +249,7 @@ export function createProductionHostRuntime(options = {}) {
249
249
  adaptivePriority = await options.adaptivePriorityProvider(event);
250
250
  if (adaptivePriority && (typeof adaptivePriority.artifactId !== 'string' || !adaptivePriority.artifactId.trim()
251
251
  || typeof adaptivePriority.activationId !== 'string' || !adaptivePriority.activationId.trim()
252
+ || (adaptivePriority.additiveOnly !== undefined && typeof adaptivePriority.additiveOnly !== 'boolean')
252
253
  || (adaptivePriority.deadlineAt !== undefined && !Number.isFinite(adaptivePriority.deadlineAt)))) {
253
254
  adaptivePriority = undefined;
254
255
  }
@@ -268,6 +269,7 @@ export function createProductionHostRuntime(options = {}) {
268
269
  ...(roundKey !== undefined ? { roundKey } : {}),
269
270
  ...(adaptivePriority ? {
270
271
  adaptivePriority: { artifactId: adaptivePriority.artifactId, activationId: adaptivePriority.activationId },
272
+ ...(adaptivePriority.additiveOnly === true ? { additiveOnly: true } : {}),
271
273
  ...(adaptivePriority.signal ? { signal: adaptivePriority.signal } : {}),
272
274
  ...(adaptivePriority.deadlineAt !== undefined ? { deadlineAt: adaptivePriority.deadlineAt } : {}),
273
275
  ...(adaptivePriority.hookInvocationId ? { hookInvocationId: adaptivePriority.hookInvocationId } : {}),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-principles-disciple",
3
- "version": "1.148.1",
3
+ "version": "1.148.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": "3.1.1"
103
103
  },
104
- "gitHead": "1dd3b8e871ed88bac3cf2cc3a7dcaea9838271ba"
104
+ "gitHead": "8a791cfcfb34ec1a70dcdf392f4afc86c1a278c8"
105
105
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principles/pd-cli",
3
- "version": "1.168.0",
3
+ "version": "1.168.1",
4
4
  "description": "PD CLI — Pain recording, sample management, and governance tasks for Principles Disciple",
5
5
  "type": "module",
6
6
  "bin": {