create-principles-disciple 1.147.16 → 1.147.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_release/product-identity.json +2 -2
- package/codex-adapter/package.json +1 -1
- package/core/dist/host/host-installer.d.ts +11 -0
- package/core/dist/host/host-installer.d.ts.map +1 -1
- package/core/dist/host/host-installer.js.map +1 -1
- package/core/dist/runtime/index.d.ts +2 -2
- package/core/dist/runtime/index.d.ts.map +1 -1
- package/core/dist/runtime/index.js +1 -1
- package/core/dist/runtime/index.js.map +1 -1
- package/core/dist/runtime/types/event-types.d.ts +62 -3
- package/core/dist/runtime/types/event-types.d.ts.map +1 -1
- package/core/dist/runtime/types/event-types.js +43 -0
- package/core/dist/runtime/types/event-types.js.map +1 -1
- package/core/package.json +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -1
- package/dist/installer.d.ts +20 -0
- package/dist/installer.d.ts.map +1 -1
- package/dist/installer.js +75 -12
- package/dist/installer.js.map +1 -1
- package/dist/installers/codex-host-installer.d.ts +21 -0
- package/dist/installers/codex-host-installer.d.ts.map +1 -1
- package/dist/installers/codex-host-installer.js +105 -4
- package/dist/installers/codex-host-installer.js.map +1 -1
- package/dist/installers/workbuddy-host-installer.d.ts +2 -2
- package/dist/installers/workbuddy-host-installer.d.ts.map +1 -1
- package/dist/installers/workbuddy-host-installer.js +23 -7
- package/dist/installers/workbuddy-host-installer.js.map +1 -1
- package/host-runtime/dist/active-principle-prompt.d.ts +24 -0
- package/host-runtime/dist/active-principle-prompt.js +36 -0
- package/host-runtime/dist/product-telemetry/consent-store.d.ts +112 -14
- package/host-runtime/dist/product-telemetry/consent-store.js +343 -132
- package/host-runtime/dist/product-telemetry/control-state-lock.d.ts +99 -0
- package/host-runtime/dist/product-telemetry/control-state-lock.js +320 -0
- package/host-runtime/dist/product-telemetry/service.d.ts +26 -9
- package/host-runtime/dist/product-telemetry/service.js +90 -150
- package/host-runtime/dist/signal-stage2-cycle.js +8 -1
- package/host-runtime/package.json +1 -1
- package/install-layout/dist/index.d.ts +49 -0
- package/install-layout/dist/index.js +59 -0
- package/install-layout/package.json +1 -1
- package/package.json +4 -4
- package/pd-cli/dist/commands/health-workbuddy.d.ts +31 -0
- package/pd-cli/dist/commands/health-workbuddy.d.ts.map +1 -0
- package/pd-cli/dist/commands/health-workbuddy.js +192 -0
- package/pd-cli/dist/commands/health-workbuddy.js.map +1 -0
- package/pd-cli/dist/commands/health.d.ts.map +1 -1
- package/pd-cli/dist/commands/health.js +12 -0
- package/pd-cli/dist/commands/health.js.map +1 -1
- package/pd-cli/dist/commands/telemetry.d.ts.map +1 -1
- package/pd-cli/dist/commands/telemetry.js +3 -1
- package/pd-cli/dist/commands/telemetry.js.map +1 -1
- package/pd-cli/package.json +1 -1
- package/plugin/dist/bundle.js +429 -428
- package/plugin/dist/core/event-log.d.ts +8 -1
- package/plugin/dist/governance-audit.js +2 -2
- package/plugin/dist/hooks/llm-input-presence.d.ts +42 -0
- package/plugin/dist/hooks/prompt-presence-expectations.d.ts +6 -1
- package/plugin/dist/hooks/prompt-presence-lite.d.ts +53 -0
- package/plugin/dist/hooks/prompt-presence-measure.d.mts +1 -0
- package/plugin/dist/hooks/prompt-presence-registry.d.ts +150 -0
- package/plugin/dist/openclaw-sdk.d.ts +17 -0
- package/plugin/dist/openclaw.plugin.json +1 -1
- package/plugin/dist/types/event-types.d.ts +1 -1
- package/plugin/openclaw.plugin.json +1 -1
- package/plugin/package.json +1 -1
- package/release-manager/dist/installer.js +75 -12
- package/release-manager/dist/installers/codex-host-installer.js +105 -4
- package/release-manager/dist/installers/workbuddy-host-installer.js +23 -7
- package/release-manager/package.json +1 -1
- package/workbuddy-adapter/package.json +1 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PRI-1150 Path A: in-memory registry of frozen assembly snapshots for prompt
|
|
3
|
+
* presence forensics (design v2 §4, as amended by the owner's three revision
|
|
4
|
+
* constraints).
|
|
5
|
+
*
|
|
6
|
+
* Guarantees and honest limits:
|
|
7
|
+
* - Fully bounded: registry keys, snapshots per key, total snapshots, total
|
|
8
|
+
* body bytes and snapshot TTL are internal constants below; every eviction
|
|
9
|
+
* or expiry is counted and DEGRADES BINDING (history loss), never silently.
|
|
10
|
+
* - History loss is sticky for a key: once any snapshot of a key is dropped
|
|
11
|
+
* (TTL or capacity) the key can never regain unique-binding qualification —
|
|
12
|
+
* not by re-registration, not by remaining the only survivor. A bounded
|
|
13
|
+
* lossy-key marker set persists the fact after its entry is gone; it is NOT
|
|
14
|
+
* an unbounded tombstone table.
|
|
15
|
+
* - Late/duplicate/out-of-order llm_input callbacks are evaluated against the
|
|
16
|
+
* CURRENT live set under the same verdict rules; ordering is never assumed.
|
|
17
|
+
* - PD-internal assemblySeq numbers are diagnostic only; the official host
|
|
18
|
+
* event carries no assembly identity and none is claimed.
|
|
19
|
+
* - Memory only. Nothing here is persisted, logged or emitted with body text.
|
|
20
|
+
*/
|
|
21
|
+
/** Central bound constants (single authority; all limits observable via verdicts). */
|
|
22
|
+
export declare const PRESENCE_REGISTRY_LIMITS: {
|
|
23
|
+
/** Distinct runId+sessionId keys kept at once. Chosen above any plausible concurrent-run count on one host. */
|
|
24
|
+
readonly MAX_KEYS: 64;
|
|
25
|
+
/** Prompt builds (tool loops, compaction retries) retained per run. */
|
|
26
|
+
readonly MAX_SNAPSHOTS_PER_KEY: 8;
|
|
27
|
+
/** Global snapshot ceiling across all keys. */
|
|
28
|
+
readonly MAX_TOTAL_SNAPSHOTS: 128;
|
|
29
|
+
/** Aggregate bodyText bytes across the whole registry. */
|
|
30
|
+
readonly MAX_TOTAL_BODY_BYTES: number;
|
|
31
|
+
/** Snapshots older than this are expired (history loss — see below). */
|
|
32
|
+
readonly SNAPSHOT_TTL_MS: number;
|
|
33
|
+
/** Per-snapshot body-bytes ceiling; larger sets register as degraded. */
|
|
34
|
+
readonly MAX_SNAPSHOT_BODY_BYTES: number;
|
|
35
|
+
};
|
|
36
|
+
export interface RegisteredExpectation {
|
|
37
|
+
activationId: string;
|
|
38
|
+
bodyText: string;
|
|
39
|
+
bodyChars: number;
|
|
40
|
+
bodyComplete: boolean;
|
|
41
|
+
}
|
|
42
|
+
export interface PresenceSnapshot {
|
|
43
|
+
/** PD-internal per-key monotonic ordinal. Diagnostic only — the host event carries no assembly identity and none is claimed. */
|
|
44
|
+
assemblySeq: number;
|
|
45
|
+
frozenAtMs: number;
|
|
46
|
+
expectations: readonly RegisteredExpectation[];
|
|
47
|
+
/** Host-runtime-side overflow reported with this assembly (entries dropped at its own cap). */
|
|
48
|
+
overflowCount: number;
|
|
49
|
+
bodyBytes: number;
|
|
50
|
+
/**
|
|
51
|
+
* PRI-1150 review: present when this snapshot was registered DEGRADED —
|
|
52
|
+
* its expectation set exceeded the per-snapshot body cap, so the frozen
|
|
53
|
+
* set is empty and the observation can only be unknown:snapshot_over_limit.
|
|
54
|
+
* Distinguishes "over-limit" from "nothing injected" (empty_snapshot).
|
|
55
|
+
*/
|
|
56
|
+
degradedReason?: 'snapshot_over_limit';
|
|
57
|
+
/** Why this snapshot's expectation set is empty/degraded (design revision: distinct sources). */
|
|
58
|
+
emptyKind?: 'none_injected' | 'shared_field_absent' | 'target_removed_by_fallback' | 'generation_failed';
|
|
59
|
+
/** Canonical workspace identity this snapshot belongs to (existing path.resolve mechanism). */
|
|
60
|
+
workspaceId: string;
|
|
61
|
+
}
|
|
62
|
+
export type BindingStatus = 'no_key' | 'history_incomplete' | 'expired' | 'unique' | 'ambiguous' | 'empty_snapshot';
|
|
63
|
+
export type BindingVerdict = {
|
|
64
|
+
status: 'no_key';
|
|
65
|
+
} | {
|
|
66
|
+
status: 'history_incomplete';
|
|
67
|
+
} | {
|
|
68
|
+
status: 'expired';
|
|
69
|
+
} | {
|
|
70
|
+
status: 'empty_snapshot';
|
|
71
|
+
snapshot: PresenceSnapshot;
|
|
72
|
+
} | {
|
|
73
|
+
status: 'unique';
|
|
74
|
+
snapshot: PresenceSnapshot;
|
|
75
|
+
} | {
|
|
76
|
+
status: 'ambiguous';
|
|
77
|
+
liveSnapshots: number;
|
|
78
|
+
};
|
|
79
|
+
export declare class PromptPresenceRegistry {
|
|
80
|
+
private readonly now;
|
|
81
|
+
private readonly entries;
|
|
82
|
+
private totalSnapshots;
|
|
83
|
+
private totalBodyBytes;
|
|
84
|
+
private evictedCount;
|
|
85
|
+
private expiredCount;
|
|
86
|
+
/**
|
|
87
|
+
* PRI-1150 review (D2/D2b resolution, owner round-9 amendments): whole-key
|
|
88
|
+
* evictions keep a SCAR entry (snapshots=[], historyComplete=false) bounded
|
|
89
|
+
* by MAX_KEYS — the entry itself IS the loss marker; no tombstone table.
|
|
90
|
+
* When scars overflow (heavy churn beyond MAX_KEYS keys), the OLDEST scar is
|
|
91
|
+
* evicted: the registry then enters CAPACITY-EXHAUSTED mode (sticky, process
|
|
92
|
+
* scope) — entries created afterwards cannot prove candidate-history
|
|
93
|
+
* completeness, so they NEVER resolve unique (owner round-9 §一: no unique
|
|
94
|
+
* without provable complete history; degradation is process-scope, sticky
|
|
95
|
+
* until restart, and observable via stats). Entries that already held
|
|
96
|
+
* snapshots before exhaustion keep their provable continuity.
|
|
97
|
+
*/
|
|
98
|
+
private scarEvictions;
|
|
99
|
+
/** Sticky: true once any scar had to be evicted (bounded observation window begun). */
|
|
100
|
+
private capacityExhausted;
|
|
101
|
+
constructor(now?: () => number);
|
|
102
|
+
/** Observable counters (for events/diagnostics; no body content). */
|
|
103
|
+
stats(): {
|
|
104
|
+
keys: number;
|
|
105
|
+
snapshots: number;
|
|
106
|
+
totalBodyBytes: number;
|
|
107
|
+
evictedCount: number;
|
|
108
|
+
expiredCount: number;
|
|
109
|
+
scars: number;
|
|
110
|
+
scarEvictions: number;
|
|
111
|
+
capacityExhausted: boolean;
|
|
112
|
+
};
|
|
113
|
+
private keyOf;
|
|
114
|
+
private workspaceIdOf;
|
|
115
|
+
/** Drops TTL-expired snapshots; returns true when any expired (history loss). */
|
|
116
|
+
private sweepExpiredLocked;
|
|
117
|
+
/**
|
|
118
|
+
* PRI-1150 review (D2/D2b): whole-key evictions leave a bounded SCAR ENTRY
|
|
119
|
+
* (snapshots=[], historyComplete=false) — the entry itself carries the loss
|
|
120
|
+
* fact. Scar entries are bounded by MAX_KEYS; overflowing scars increment
|
|
121
|
+
* scarEvictions, flip the registry into CAPACITY-EXHAUSTED mode (sticky),
|
|
122
|
+
* and the affected keys become indistinguishable from brand-new keys —
|
|
123
|
+
* which post-exhaustion resolve conservatively (never unique).
|
|
124
|
+
*/
|
|
125
|
+
private pushScar;
|
|
126
|
+
/** Drops whole oldest entries / oldest snapshots until the global caps hold. */
|
|
127
|
+
private enforceGlobalCapsLocked;
|
|
128
|
+
registerAssemblySnapshot(params: {
|
|
129
|
+
runId: string;
|
|
130
|
+
sessionId: string;
|
|
131
|
+
expectations: readonly RegisteredExpectation[];
|
|
132
|
+
overflowCount?: number;
|
|
133
|
+
/** Canonical workspace identity (existing path.resolve mechanism); scopes the key. */
|
|
134
|
+
workspaceDir?: string;
|
|
135
|
+
/** Why this assembly's expectation set is empty/degraded (distinct sources, design revision). */
|
|
136
|
+
emptyKind?: PresenceSnapshot['emptyKind'];
|
|
137
|
+
}): {
|
|
138
|
+
registered: boolean;
|
|
139
|
+
degradedReason?: 'snapshot_over_limit';
|
|
140
|
+
assemblySeq?: number;
|
|
141
|
+
};
|
|
142
|
+
resolveBinding(params: {
|
|
143
|
+
runId: string;
|
|
144
|
+
sessionId: string;
|
|
145
|
+
workspaceDir?: string;
|
|
146
|
+
}): BindingVerdict;
|
|
147
|
+
/** Test/diagnostic reset (per-workspace isolation); never called in production paths. */
|
|
148
|
+
resetForTest(): void;
|
|
149
|
+
}
|
|
150
|
+
export declare function getPromptPresenceRegistry(): PromptPresenceRegistry;
|
|
@@ -193,6 +193,23 @@ export interface PluginHookBeforePromptBuildEvent {
|
|
|
193
193
|
currentUserMessageId?: string;
|
|
194
194
|
messages: unknown[];
|
|
195
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* PRI-1150: local mirror of the official llm_input observation contract
|
|
198
|
+
* (release/2026.11.1 `PluginHookLlmInputEvent`). systemPrompt is the FULL
|
|
199
|
+
* assembled system-prompt text (post-guard/post-fallback); historyMessages is
|
|
200
|
+
* the host's isolated snapshot. Read-only observation surface.
|
|
201
|
+
*/
|
|
202
|
+
export interface PluginHookLlmInputEvent {
|
|
203
|
+
runId: string;
|
|
204
|
+
sessionId: string;
|
|
205
|
+
provider: string;
|
|
206
|
+
model: string;
|
|
207
|
+
systemPrompt?: string;
|
|
208
|
+
prompt: string;
|
|
209
|
+
historyMessages: unknown[];
|
|
210
|
+
imagesCount: number;
|
|
211
|
+
tools?: unknown[];
|
|
212
|
+
}
|
|
196
213
|
export interface PluginHookBeforePromptBuildResult {
|
|
197
214
|
systemPrompt?: string;
|
|
198
215
|
prependContext?: string;
|
|
@@ -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": "3.0.
|
|
5
|
+
"version": "3.0.2",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { EventType, EventCategory, EventLogEntry, ToolCallEventData, PainSignalEventData, RulePromotionEventData, GovernanceActionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, EvolutionTaskEventData, EmpathyRollbackEventData, HeartbeatDiagnosisEventData, DiagnosisTaskEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimePromptActivationsInjectedEventData, RuleHostUnhealthyEventData, RuleHostSkippedEventData, TrajectoryObservabilityFailureEventData, ToolCallStats, ErrorStats, EmpathyEventStats, HookStats, DailyStats, } from '@principles/core/runtime';
|
|
1
|
+
export type { EventType, EventCategory, EventLogEntry, ToolCallEventData, PainSignalEventData, RulePromotionEventData, GovernanceActionEventData, HookExecutionEventData, GateBlockEventData, GateBypassEventData, EvolutionTaskEventData, EmpathyRollbackEventData, HeartbeatDiagnosisEventData, DiagnosisTaskEventData, DiagnosticianReportEventData, PrincipleCandidateEventData, RuleEnforcedEventData, RuleHostEvaluatedEventData, RuleHostBlockedEventData, RuleHostRequireApprovalEventData, RuleHostAutoCorrectProposedEventData, RuleHostAutoCorrectAppliedEventData, RuntimePromptActivationsInjectedEventData, PromptPresenceObservedEventData, RuleHostUnhealthyEventData, RuleHostSkippedEventData, TrajectoryObservabilityFailureEventData, ToolCallStats, ErrorStats, EmpathyEventStats, HookStats, DailyStats, } from '@principles/core/runtime';
|
|
2
2
|
export { createEmptyDailyStats, } from '@principles/core/runtime/types/event-types';
|
|
@@ -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": "3.0.
|
|
5
|
+
"version": "3.0.2",
|
|
6
6
|
"activation": {
|
|
7
7
|
"onStartup": true,
|
|
8
8
|
"onCapabilities": [
|
package/plugin/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "principles-disciple",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
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",
|
|
@@ -3563,6 +3563,28 @@ export async function ensureOpenClawWorkspaceDeclaration(workspaceDir, channels)
|
|
|
3563
3563
|
await fse.writeJson(inspection.configPath, config, { spaces: 2 });
|
|
3564
3564
|
return { configPath: inspection.configPath, action: 'created' };
|
|
3565
3565
|
}
|
|
3566
|
+
/**
|
|
3567
|
+
* Marketplace contract (2026-11-07): partition host installer results into
|
|
3568
|
+
* REAL failures and pending MANUAL actions (e.g. the Codex Marketplace
|
|
3569
|
+
* install). A real failure aborts the install transaction (atomic rollback);
|
|
3570
|
+
* a manual action is an explicit partial completion — it must NOT trigger the
|
|
3571
|
+
* other hosts' rollback (the OpenClaw `--host all` defect), but it does make
|
|
3572
|
+
* the aggregate result non-successful with a non-zero exit code so automation
|
|
3573
|
+
* cannot mistake partial for complete. Pure: unit-testable without I/O.
|
|
3574
|
+
*/
|
|
3575
|
+
export function partitionHostInstallResults(results) {
|
|
3576
|
+
const failures = [];
|
|
3577
|
+
const manualActions = [];
|
|
3578
|
+
for (const result of results) {
|
|
3579
|
+
if (result.success)
|
|
3580
|
+
continue;
|
|
3581
|
+
if (result.manualActionRequired === true)
|
|
3582
|
+
manualActions.push(result);
|
|
3583
|
+
else
|
|
3584
|
+
failures.push(result);
|
|
3585
|
+
}
|
|
3586
|
+
return { failures, manualActions };
|
|
3587
|
+
}
|
|
3566
3588
|
/**
|
|
3567
3589
|
* ADR-0020 §2.3: Run host installers for the selected HostTarget.
|
|
3568
3590
|
*
|
|
@@ -4293,24 +4315,41 @@ transaction) {
|
|
|
4293
4315
|
: undefined,
|
|
4294
4316
|
});
|
|
4295
4317
|
// Report host install results (rc-9: surface failures, don't silently swallow).
|
|
4296
|
-
// rc-9 propagation: if ANY host installer
|
|
4318
|
+
// rc-9 propagation: if ANY host installer FAILED, the aggregate install
|
|
4297
4319
|
// result is NOT successful — callers (CLI, tests) must see the failure.
|
|
4298
4320
|
// Previously failures were only logged, leaving `success: true` even when
|
|
4299
4321
|
// a host adapter failed to install (silent failure).
|
|
4300
|
-
|
|
4322
|
+
//
|
|
4323
|
+
// Marketplace contract (2026-11-07): a host result carrying
|
|
4324
|
+
// manualActionRequired (Codex Marketplace install pending) is NOT a
|
|
4325
|
+
// failure of the install transaction. It must not throw — throwing here
|
|
4326
|
+
// used to roll back the SHARED runtime and left the already-successful
|
|
4327
|
+
// OpenClaw install pointing at a restored-away runtime (the --host all
|
|
4328
|
+
// defect). Manual actions are surfaced as an explicit partial completion:
|
|
4329
|
+
// the runtime stays installed and usable, the manifest claims only hosts
|
|
4330
|
+
// that actually installed, and the exit code is non-zero so automation
|
|
4331
|
+
// cannot mistake partial for complete.
|
|
4332
|
+
const { failures: hostFailures, manualActions: hostManualActions } = partitionHostInstallResults(hostResults);
|
|
4333
|
+
const hostFailureMessages = hostFailures.map((hr) => `Host "${hr.hostId}": ${hr.reason ?? 'unknown failure'}. Next: ${hr.nextAction}`);
|
|
4334
|
+
for (const msg of hostFailureMessages) {
|
|
4335
|
+
logger.warn(msg);
|
|
4336
|
+
}
|
|
4301
4337
|
for (const hr of hostResults) {
|
|
4302
|
-
if (
|
|
4303
|
-
const msg = `Host "${hr.hostId}": ${hr.reason ?? 'unknown failure'}. Next: ${hr.nextAction}`;
|
|
4304
|
-
hostFailures.push(msg);
|
|
4305
|
-
logger.warn(msg);
|
|
4306
|
-
}
|
|
4307
|
-
else if (hr.configAction === 'skipped') {
|
|
4338
|
+
if (hr.success && hr.configAction === 'skipped') {
|
|
4308
4339
|
logger.info(`Host "${hr.hostId}" install: ${hr.reason ?? 'skipped'}. Next: ${hr.nextAction}`);
|
|
4309
4340
|
}
|
|
4310
4341
|
}
|
|
4311
4342
|
if (hostFailures.length > 0) {
|
|
4312
|
-
throw new Error(`Host installation failed: ${
|
|
4313
|
-
}
|
|
4343
|
+
throw new Error(`Host installation failed: ${hostFailureMessages.join(' | ')}`);
|
|
4344
|
+
}
|
|
4345
|
+
// Manual-action hosts (e.g. Codex awaiting the Marketplace step) STAY in
|
|
4346
|
+
// the install manifest: the manifest records the hosts PD serves on this
|
|
4347
|
+
// machine (uninstall reads it to decide shared-runtime removal), not a
|
|
4348
|
+
// per-run success ledger. Dropping a pending host here could let a later
|
|
4349
|
+
// sibling-host uninstall remove the shared runtime while the pending
|
|
4350
|
+
// host's registration still points at it — the exact A3 hazard class
|
|
4351
|
+
// this fix exists to close. Real install state remains file-based truth
|
|
4352
|
+
// (checkInstallStatus / host detect()).
|
|
4314
4353
|
writeInstallManifest(installManifestHosts, resolveInstallManifestWorkspaces(options.workspaceDir, options.host));
|
|
4315
4354
|
// PRI-709 P0-1: persist the metadata source after the manifest write, so
|
|
4316
4355
|
// the durable tier cannot be clobbered by the same install.
|
|
@@ -4410,7 +4449,16 @@ transaction) {
|
|
|
4410
4449
|
}
|
|
4411
4450
|
}
|
|
4412
4451
|
if (spinner) {
|
|
4413
|
-
|
|
4452
|
+
// rc-9: the runtime transaction IS committed here, but a pending host
|
|
4453
|
+
// manual action (e.g. the Codex Marketplace install) makes the run a
|
|
4454
|
+
// partial completion — "Install complete!" would be the exact
|
|
4455
|
+
// misleading-success texture this contract exists to remove.
|
|
4456
|
+
if (hostManualActions.length === 0) {
|
|
4457
|
+
spinner.succeed('Install complete!');
|
|
4458
|
+
}
|
|
4459
|
+
else {
|
|
4460
|
+
spinner.warn(`Install partially complete — ${hostManualActions.length} manual step(s) pending (details below)`);
|
|
4461
|
+
}
|
|
4414
4462
|
}
|
|
4415
4463
|
// P0-2: terminate + join the verified child before any later step that
|
|
4416
4464
|
// may touch the runtime tree (here: none destructive, but a wedged child
|
|
@@ -4429,7 +4477,18 @@ transaction) {
|
|
|
4429
4477
|
// requested config instead of the actual state).
|
|
4430
4478
|
const actualEnabledChannels = readEnabledChannelsFromConfigYaml(options.workspaceDir);
|
|
4431
4479
|
const cliWorking = components.cli === 'verified' || components.cli === 'verified_local_only';
|
|
4432
|
-
|
|
4480
|
+
// Marketplace contract (2026-11-07): a pending manual action (e.g. the
|
|
4481
|
+
// Codex Marketplace install) makes the run an explicit PARTIAL completion —
|
|
4482
|
+
// never a full success (no fake "Install complete!"), never a runtime
|
|
4483
|
+
// rollback either. The runtime component itself is verified; the pending
|
|
4484
|
+
// step is host-side and must be surfaced with a non-zero exit code.
|
|
4485
|
+
const isComplete = components.plugin === 'verified' && cliWorking && components.console === 'configured' && hostManualActions.length === 0;
|
|
4486
|
+
const manualActionReason = hostManualActions.length > 0
|
|
4487
|
+
? `Partial completion: ${hostManualActions.map((hr) => `host "${hr.hostId}" requires a manual step (${hr.reason ?? 'manual action required'})`).join('; ')}`
|
|
4488
|
+
: undefined;
|
|
4489
|
+
const manualActionNext = hostManualActions.length > 0
|
|
4490
|
+
? hostManualActions.map((hr) => `Host "${hr.hostId}": ${hr.nextAction}`).join(' | ')
|
|
4491
|
+
: undefined;
|
|
4433
4492
|
// A host installer failure means the install is not fully successful,
|
|
4434
4493
|
// even if all component verifications passed. The operator should see
|
|
4435
4494
|
// success=false and be guided to fix the failed host.
|
|
@@ -4453,6 +4512,9 @@ transaction) {
|
|
|
4453
4512
|
if (launchResult.fallbackAction) {
|
|
4454
4513
|
nextActions.push(launchResult.fallbackAction);
|
|
4455
4514
|
}
|
|
4515
|
+
if (manualActionNext !== undefined) {
|
|
4516
|
+
nextActions.push(manualActionNext);
|
|
4517
|
+
}
|
|
4456
4518
|
pendingResult = {
|
|
4457
4519
|
success: isComplete,
|
|
4458
4520
|
workspaceDir: options.workspaceDir,
|
|
@@ -4464,6 +4526,7 @@ transaction) {
|
|
|
4464
4526
|
nextAction: nextActions.join(' | '),
|
|
4465
4527
|
consoleUrl: launchResult.consoleUrl,
|
|
4466
4528
|
hostResults,
|
|
4529
|
+
...(manualActionReason !== undefined ? { reason: manualActionReason, manualActions: hostManualActions } : {}),
|
|
4467
4530
|
journal: installerJournalRecord(journal),
|
|
4468
4531
|
};
|
|
4469
4532
|
return pendingResult;
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* merge into it, never overwrite. The marker file is our own bookkeeping
|
|
24
24
|
* for precise uninstall.
|
|
25
25
|
*/
|
|
26
|
-
import { existsSync, readFileSync, writeFileSync } from 'fs';
|
|
26
|
+
import { existsSync, readdirSync, readFileSync, writeFileSync } from 'fs';
|
|
27
27
|
import { execSync } from 'child_process';
|
|
28
28
|
import * as path from 'path';
|
|
29
29
|
import * as os from 'os';
|
|
@@ -61,7 +61,12 @@ function getErrorCode(err) {
|
|
|
61
61
|
}
|
|
62
62
|
// ─── Path helpers ───────────────────────────────────────────────────────────
|
|
63
63
|
function getCodexDir() {
|
|
64
|
-
|
|
64
|
+
// Shared authority for Marketplace observation and the legacy hook detector.
|
|
65
|
+
// Codex accepts relative CODEX_HOME; path.resolve matches pd-cli's reader.
|
|
66
|
+
const override = process.env.CODEX_HOME;
|
|
67
|
+
return typeof override === 'string' && override.length > 0
|
|
68
|
+
? path.resolve(override)
|
|
69
|
+
: path.join(os.homedir(), '.codex');
|
|
65
70
|
}
|
|
66
71
|
function getCodexHooksJsonPath() {
|
|
67
72
|
return path.join(getCodexDir(), 'hooks.json');
|
|
@@ -209,6 +214,81 @@ export function detectLegacyCodexHookRegistration(hooksJsonPathOverride) {
|
|
|
209
214
|
}
|
|
210
215
|
return { detected, legacyAsyncPostToolUse };
|
|
211
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* Same resolution the pd-cli authority uses (resolveCodexHome): the Codex
|
|
219
|
+
* home may be redirected via CODEX_HOME and the Marketplace cache follows
|
|
220
|
+
* that redirect. Like the pd-cli authority, relative paths and parent
|
|
221
|
+
* components are resolved against the current working directory. This is
|
|
222
|
+
* read-only observation of a user-selected Codex home, not a filesystem write.
|
|
223
|
+
*/
|
|
224
|
+
function resolveCodexHomeForMarketplace() {
|
|
225
|
+
return getCodexDir();
|
|
226
|
+
}
|
|
227
|
+
export function detectCodexMarketplaceState(codexHome) {
|
|
228
|
+
const home = codexHome ?? resolveCodexHomeForMarketplace();
|
|
229
|
+
const cachePluginRoot = path.join(home, 'plugins', 'cache', 'principles', 'principles-disciple');
|
|
230
|
+
let entries;
|
|
231
|
+
try {
|
|
232
|
+
const read = readdirSync(cachePluginRoot);
|
|
233
|
+
// rc-4: validating "is array" before iteration — a non-array listing is
|
|
234
|
+
// unverifiable state, never an empty guess.
|
|
235
|
+
if (!Array.isArray(read)) {
|
|
236
|
+
return { state: 'unknown', reason: 'the Codex Marketplace cache listing is not a directory array: ' + cachePluginRoot };
|
|
237
|
+
}
|
|
238
|
+
entries = read;
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
if (getErrorCode(err) === 'ENOENT')
|
|
242
|
+
return { state: 'not_installed' };
|
|
243
|
+
return {
|
|
244
|
+
state: 'unknown',
|
|
245
|
+
reason: 'cache root unreadable: ' + cachePluginRoot + ' (' + String(err) + ')',
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
const semverPattern = /^(\d+)\.(\d+)\.(\d+)$/;
|
|
249
|
+
let best;
|
|
250
|
+
let unverifiableCandidate;
|
|
251
|
+
for (const versionDir of entries) {
|
|
252
|
+
const match = semverPattern.exec(versionDir);
|
|
253
|
+
if (match === null)
|
|
254
|
+
continue;
|
|
255
|
+
// Parity with the authority (selectMarketplaceCacheVersionDir): the pin
|
|
256
|
+
// must PARSE as a JSON object, not merely exist — a corrupt pin means the
|
|
257
|
+
// candidate is unusable, not installed (a bare existsSync here would
|
|
258
|
+
// claim installed state that pd-cli health refuses).
|
|
259
|
+
const pinFile = path.join(cachePluginRoot, versionDir, 'runtime-version.json');
|
|
260
|
+
let pinValid;
|
|
261
|
+
try {
|
|
262
|
+
const pin = JSON.parse(readFileSync(pinFile, 'utf-8'));
|
|
263
|
+
pinValid = isRecord(pin);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
pinValid = false;
|
|
267
|
+
}
|
|
268
|
+
if (!pinValid) {
|
|
269
|
+
// Presence of an apparently installed version with an unreadable or
|
|
270
|
+
// malformed pin is UNKNOWN, not proof that no plugin was installed.
|
|
271
|
+
unverifiableCandidate ??= pinFile;
|
|
272
|
+
continue;
|
|
273
|
+
}
|
|
274
|
+
const major = Number.parseInt(match[1] ?? '', 10);
|
|
275
|
+
const minor = Number.parseInt(match[2] ?? '', 10);
|
|
276
|
+
const patch = Number.parseInt(match[3] ?? '', 10);
|
|
277
|
+
if (![major, minor, patch].every((n) => Number.isFinite(n)))
|
|
278
|
+
continue;
|
|
279
|
+
if (best === undefined
|
|
280
|
+
|| major > best.parts[0]
|
|
281
|
+
|| (major === best.parts[0] && (minor > best.parts[1] || (minor === best.parts[1] && patch > best.parts[2])))) {
|
|
282
|
+
best = { dirName: versionDir, parts: [major, minor, patch] };
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
if (best === undefined) {
|
|
286
|
+
return unverifiableCandidate === undefined
|
|
287
|
+
? { state: 'not_installed' }
|
|
288
|
+
: { state: 'unknown', reason: 'Codex Marketplace version exists but runtime pin cannot be verified: ' + unverifiableCandidate };
|
|
289
|
+
}
|
|
290
|
+
return { state: 'installed', version: best.dirName, versionDir: path.join(cachePluginRoot, best.dirName) };
|
|
291
|
+
}
|
|
212
292
|
// ─── CodexHostInstaller ─────────────────────────────────────────────────────
|
|
213
293
|
export class CodexHostInstaller {
|
|
214
294
|
hostId = 'codex';
|
|
@@ -231,17 +311,38 @@ export class CodexHostInstaller {
|
|
|
231
311
|
hostId: this.hostId,
|
|
232
312
|
configPath: hooksJsonPath,
|
|
233
313
|
configAction: 'skipped',
|
|
314
|
+
manualActionRequired: true,
|
|
234
315
|
reason: 'A legacy PD global Codex hook registration was detected (async PostToolUse in ~/.codex/hooks.json). The legacy global installer is retired (SPEC rev 2 §17) and cannot update it.',
|
|
235
316
|
nextAction: 'Migrate to the Marketplace plugin: 1) npx create-principles-disciple uninstall --host codex (removes ONLY PD-owned entries; evidence is preserved); 2) codex plugin add principles-disciple@principles; 3) run the plugin setup ($pd-control setup) — it presents the ingestion disclosure and records consent.',
|
|
236
317
|
};
|
|
237
318
|
}
|
|
319
|
+
// Marketplace contract (2026-11-07): the retired global-hook installer
|
|
320
|
+
// never writes anything; the Codex end state is reported honestly in
|
|
321
|
+
// three states and never executes the retired registration logic.
|
|
322
|
+
const marketplace = detectCodexMarketplaceState();
|
|
323
|
+
if (marketplace.state === 'installed') {
|
|
324
|
+
return {
|
|
325
|
+
success: true,
|
|
326
|
+
hostId: this.hostId,
|
|
327
|
+
configAction: 'preserved',
|
|
328
|
+
reason: `Codex Marketplace plugin already installed and confirmable (cache version ${marketplace.version}).`,
|
|
329
|
+
nextAction: 'If not done yet, start a Codex session and run the plugin setup ($pd-control setup) — it verifies Node/runtime/workspace/trust and records the conversation-ingestion consent.',
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
// 'not_installed' and 'unknown' both leave a manual step pending. They are
|
|
333
|
+
// NOT failures of anything this installer attempted (it never writes), so
|
|
334
|
+
// they must not trigger other hosts' rollback — the manualActionRequired
|
|
335
|
+
// flag separates them from real failures (installer.ts aggregation).
|
|
238
336
|
return {
|
|
239
337
|
success: false,
|
|
240
338
|
hostId: this.hostId,
|
|
241
339
|
configPath: hooksJsonPath,
|
|
242
340
|
configAction: 'skipped',
|
|
243
|
-
|
|
244
|
-
|
|
341
|
+
manualActionRequired: true,
|
|
342
|
+
reason: marketplace.state === 'not_installed'
|
|
343
|
+
? 'New Codex global hook registrations are retired (SPEC rev 2 §17) and the Marketplace plugin is not installed on this machine. PD will not auto-execute the Marketplace install or edit the Codex plugin config without authorization.'
|
|
344
|
+
: 'New Codex global hook registrations are retired (SPEC rev 2 §17). The Codex Marketplace install state could not be verified: ' + marketplace.reason + '. PD will not guess the state or auto-execute the Marketplace install.',
|
|
345
|
+
nextAction: 'Install the plugin: codex plugin add principles-disciple@principles — then run its setup ($pd-control setup), which verifies Node/runtime/workspace/trust and records the conversation-ingestion consent. Re-run npx create-principles-disciple afterwards; the install is idempotent.',
|
|
245
346
|
};
|
|
246
347
|
}
|
|
247
348
|
async uninstall(_ctx) {
|
|
@@ -47,13 +47,15 @@ import * as path from 'node:path';
|
|
|
47
47
|
import * as yaml from 'js-yaml';
|
|
48
48
|
import semver from 'semver';
|
|
49
49
|
import { getInstallLayoutPaths, getWorkbuddyWorkspaceDir, installManifestHostsForPersist, mergeInstallManifestWorkspaces, parseInstallManifest, INSTALL_LAYOUT_VERSION, } from '@principles/install-layout';
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
//
|
|
50
|
+
// 2026-11-08: the shared state DEFINITIONS for pd-cli health live in
|
|
51
|
+
// @principles/install-layout (interpretWorkbuddyPluginState /
|
|
52
|
+
// getWorkbuddyHostConfigPaths). The installer does NOT import them at
|
|
53
|
+
// runtime: its packaged dist must keep loading against the PUBLISHED
|
|
54
|
+
// install-layout (registry-parity smoke, PRI-669/RF-02), and a normal PR
|
|
55
|
+
// cannot raise the version floor (release-intent guard N-version). The
|
|
56
|
+
// local constants/judgment below are the pinned mirror — a CI parity test
|
|
57
|
+
// pins installer state == install-layout state on a fixture matrix (the
|
|
58
|
+
// same discipline as the Codex legacy-registration parser mirror).
|
|
57
59
|
/** Plugin name inside the PD-owned marketplace (kebab-case per plugin.json contract). */
|
|
58
60
|
export const WORKBUDDY_PLUGIN_NAME = 'principles-disciple';
|
|
59
61
|
/** PD-owned local marketplace name. enabledPlugins keys use "plugin@marketplace". */
|
|
@@ -61,6 +63,12 @@ export const WORKBUDDY_MARKETPLACE_NAME = 'principles-disciple-market';
|
|
|
61
63
|
/** Registry/settings key: "principles-disciple@principles-disciple-market". */
|
|
62
64
|
export const WORKBUDDY_PLUGIN_KEY = `${WORKBUDDY_PLUGIN_NAME}@${WORKBUDDY_MARKETPLACE_NAME}`;
|
|
63
65
|
const WORKBUDDY_REQUIRED_SKILLS = ['pd-cli-operator', 'pd-pain-signal', 'pd-review', 'pd-control'];
|
|
66
|
+
import { atomicReplaceTextFile, errnoCode } from '../utils/config-file-io.js';
|
|
67
|
+
import { checkMcpRegistrationConflict } from './mcp-registration-conflict.js';
|
|
68
|
+
import { resolveMcpServerDir, resolveMcpServerEntry } from '../mcp-server-layout-compat.js';
|
|
69
|
+
import { getHomeDir, generateConfigYamlContent, getConfigYamlPath, resolveDefaultModelForProvider, isValidHttpBaseUrl } from '../mvp-config.js';
|
|
70
|
+
// Type-only import from @principles/core — erased at compile time; this
|
|
71
|
+
// package ships self-contained without @principles/core (PRI-625/PRI-669).
|
|
64
72
|
/**
|
|
65
73
|
* Files the host needs to load this plugin. One list serves both the
|
|
66
74
|
* "is the cached payload current?" comparison and the "did the staged copy
|
|
@@ -965,6 +973,14 @@ export function ensureWorkbuddyGovernanceEnabled(governanceDir, options = {}) {
|
|
|
965
973
|
* exactly one implementation.
|
|
966
974
|
*/
|
|
967
975
|
export function readWorkbuddyPluginState(p) {
|
|
976
|
+
// Pinned mirror of install-layout's interpretWorkbuddyPluginState — the
|
|
977
|
+
// shared judgment pd-cli health applies. A CI parity test
|
|
978
|
+
// (workbuddy-plugin-state-parity.test.ts) pins the two implementations to
|
|
979
|
+
// identical outputs on a fixture matrix; a runtime import cannot exist
|
|
980
|
+
// here because the packaged installer must keep loading against the
|
|
981
|
+
// PUBLISHED install-layout (registry-parity smoke, PRI-669/RF-02; the
|
|
982
|
+
// release-intent guard N-version forbids raising the version floor in a
|
|
983
|
+
// normal PR).
|
|
968
984
|
const registry = readHostJsonFile(p.registryPath);
|
|
969
985
|
const registered = registry.ok && registry.existed && isRecord(registry.value.plugins)
|
|
970
986
|
? Object.hasOwn(registry.value.plugins, WORKBUDDY_PLUGIN_KEY)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@principles/workbuddy-adapter",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.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",
|