principles-disciple 3.0.1 → 3.0.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.
@@ -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.1",
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.1",
5
+ "version": "3.0.2",
6
6
  "activation": {
7
7
  "onStartup": true,
8
8
  "onCapabilities": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "principles-disciple",
3
- "version": "3.0.1",
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",
@@ -76,8 +76,8 @@
76
76
  "compile-principles": "node scripts/compile-principles.mjs"
77
77
  },
78
78
  "devDependencies": {
79
- "@principles/core": "^5.1.0",
80
- "@principles/host-runtime": "^3.0.0",
79
+ "@principles/core": "^5.1.1",
80
+ "@principles/host-runtime": "^3.0.3",
81
81
  "@types/better-sqlite3": "^9.6.0",
82
82
  "@types/js-yaml": "^4.0.9",
83
83
  "@types/micromatch": "^4.0.10",
@@ -109,5 +109,5 @@
109
109
  "js-yaml": "^5.4.3",
110
110
  "micromatch": "^4.0.8"
111
111
  },
112
- "gitHead": "9656a64563e073c92aa8da0373ea96249de1a71b"
112
+ "gitHead": "17c7d5c83b78aa03a040807fdfbdcf973371330c"
113
113
  }