@sidurijs/core 1.0.0 → 1.0.1

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,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.settleMemoryProposals = void 0;
4
+ exports.settleInteractionProposals = settleInteractionProposals;
5
+ /**
6
+ * Persists source events to ArchiveLedger and behavioral directive proposals directly to SelfRepository.
7
+ * Direct Domain Routing under RFC VX-26-13: Deconstructing Memory into Sovereign Primitives.
8
+ */
9
+ async function settleInteractionProposals(params) {
10
+ const { companionId, perceivedText, role, requestContext, archive, self, explicitTeaching, plan, effectiveMode, } = params;
11
+ // Zero Drift: Casual mode completely suppresses all proposal generation
12
+ const mode = effectiveMode || requestContext.mode || 'hybrid';
13
+ if (mode === 'casual') {
14
+ return {
15
+ createdMemoryProposals: [],
16
+ memoryProposalReceipts: [],
17
+ };
18
+ }
19
+ const createdMemoryProposals = [];
20
+ let sourceEventId;
21
+ const hasTeaching = explicitTeaching.claims.length > 0 ||
22
+ explicitTeaching.behaviorProposals.length > 0;
23
+ const hasPlanProposals = Boolean(plan.memoryProposals?.length) ||
24
+ Boolean(plan.behaviorProposals?.length);
25
+ if (archive && typeof archive.recordEvent === 'function') {
26
+ if (hasTeaching || hasPlanProposals) {
27
+ const sourceEvent = {
28
+ id: `evt-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
29
+ sourceType: 'user_chat_explicit',
30
+ occurredAt: new Date().toISOString(),
31
+ payload: {
32
+ message: perceivedText,
33
+ role,
34
+ companionId,
35
+ actorId: requestContext.actor?.actorId || 'owner-user',
36
+ channel: requestContext.conversation?.channel || 'direct',
37
+ },
38
+ };
39
+ await archive.recordEvent(sourceEvent);
40
+ sourceEventId = sourceEvent.id;
41
+ }
42
+ }
43
+ for (const claim of explicitTeaching.claims) {
44
+ let proposal;
45
+ if (params.memory && typeof params.memory.proposeClaim === 'function') {
46
+ proposal = await params.memory.proposeClaim({
47
+ companionId,
48
+ subject: claim.subject,
49
+ predicate: claim.predicate,
50
+ value: claim.value,
51
+ scope: claim.subject?.startsWith('companion:') ? 'companion' : 'user',
52
+ provenance: claim.provenance || 'deterministic_teaching',
53
+ sourceEventId,
54
+ claimType: claim.claimType || 'preference',
55
+ authority: 'user_explicit',
56
+ userConfirmation: 'none',
57
+ sensitivity: claim.sensitivity ||
58
+ (requestContext.conversation?.channel === 'public' ? 'public' : 'private'),
59
+ });
60
+ }
61
+ if (!proposal) {
62
+ proposal = {
63
+ id: `claim-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
64
+ companionId,
65
+ subject: claim.subject,
66
+ predicate: claim.predicate,
67
+ value: claim.value,
68
+ scope: claim.subject?.startsWith('companion:') ? 'companion' : 'user',
69
+ provenance: claim.provenance || 'deterministic_teaching',
70
+ sourceEventId,
71
+ claimType: claim.claimType || 'preference',
72
+ authority: 'user_explicit',
73
+ userConfirmation: 'none',
74
+ status: 'pending',
75
+ sensitivity: claim.sensitivity ||
76
+ (requestContext.conversation?.channel === 'public' ? 'public' : 'private'),
77
+ };
78
+ }
79
+ if (proposal) {
80
+ createdMemoryProposals.push(proposal);
81
+ }
82
+ }
83
+ if (plan.memoryProposals && plan.memoryProposals.length > 0) {
84
+ for (const p of plan.memoryProposals) {
85
+ let proposal;
86
+ if (params.memory && typeof params.memory.proposeClaim === 'function') {
87
+ proposal = await params.memory.proposeClaim({
88
+ companionId,
89
+ subject: p.subject || `actor:${requestContext.actor?.actorId || 'unknown'}`,
90
+ predicate: p.predicate,
91
+ value: p.value,
92
+ scope: p.subject?.startsWith('companion:') ? 'companion' : 'user',
93
+ provenance: p.provenance || 'llm_proposal',
94
+ sourceEventId: sourceEventId || p.sourceEventId,
95
+ claimType: p.claimType || 'semantic',
96
+ sensitivity: p.sensitivity || 'private',
97
+ });
98
+ }
99
+ if (!proposal) {
100
+ proposal = {
101
+ id: `claim-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
102
+ companionId,
103
+ subject: p.subject || `actor:${requestContext.actor?.actorId || 'unknown'}`,
104
+ predicate: p.predicate,
105
+ value: p.value,
106
+ scope: p.subject?.startsWith('companion:') ? 'companion' : 'user',
107
+ provenance: p.provenance || 'llm_proposal',
108
+ sourceEventId: sourceEventId || p.sourceEventId,
109
+ claimType: p.claimType || 'semantic',
110
+ status: 'pending',
111
+ sensitivity: p.sensitivity || 'private',
112
+ };
113
+ }
114
+ if (proposal) {
115
+ createdMemoryProposals.push(proposal);
116
+ }
117
+ }
118
+ }
119
+ const createdBehavioralProposals = [];
120
+ const behavioralProposalReceipts = [];
121
+ const allBehaviorProposals = [
122
+ ...explicitTeaching.behaviorProposals,
123
+ ...(plan.behaviorProposals || []),
124
+ ];
125
+ for (const bp of allBehaviorProposals) {
126
+ const directive = {
127
+ id: `dir-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
128
+ companionId,
129
+ directive: bp.directive,
130
+ priority: bp.priority || 50,
131
+ status: 'pending',
132
+ category: (bp.category || 'behavioral'),
133
+ scopeActor: bp.scopeActor,
134
+ supersedesId: bp.supersedesId,
135
+ createdAt: new Date().toISOString(),
136
+ };
137
+ createdBehavioralProposals.push(directive);
138
+ if (self && typeof self.commitDirectives === 'function') {
139
+ await self.commitDirectives(companionId, [directive]);
140
+ }
141
+ behavioralProposalReceipts.push({
142
+ directive_id: directive.id,
143
+ domain: 'behavioral',
144
+ knowledge_domain: 'behavioral',
145
+ memory_class: bp.memoryClass || 'behavioral',
146
+ runtime_effect: bp.memoryClass || 'behavioral',
147
+ subject: bp.subject || `companion:${companionId}`,
148
+ predicate: bp.predicate || 'rule',
149
+ value: bp.value || bp.directive,
150
+ status: 'pending',
151
+ behavior: {
152
+ instruction: bp.directive,
153
+ frequency: 'continuous',
154
+ preferred_positions: [],
155
+ },
156
+ });
157
+ }
158
+ const memoryProposalReceipts = createdMemoryProposals.map((p) => ({
159
+ proposal_id: p.id,
160
+ subject: p.subject,
161
+ predicate: p.predicate,
162
+ value: p.value,
163
+ status: (p.status || 'pending').toLowerCase().replace(/_/g, '-'),
164
+ claim_type: p.claimType,
165
+ content: p.content,
166
+ }));
167
+ return {
168
+ createdMemoryProposals,
169
+ memoryProposalReceipts,
170
+ createdBehavioralProposals,
171
+ behavioralProposalReceipts,
172
+ };
173
+ }
174
+ /**
175
+ * @deprecated Use `settleInteractionProposals` instead. RFC VX-26-13.
176
+ */
177
+ exports.settleMemoryProposals = settleInteractionProposals;
@@ -1,49 +1,5 @@
1
- import { MemoryOrgan, SelfRepository, Claim, BehaviorDirective, ResponsePlan, RequestContext, InteractionMode } from './index';
2
- import { extractDeterministicTeaching } from './teaching';
3
- export interface MemorySettlementParams {
4
- companionId: string;
5
- perceivedText: string;
6
- role: 'OWNER' | 'VIEWER' | 'OPERATOR';
7
- requestContext: RequestContext;
8
- memory?: MemoryOrgan;
9
- self?: SelfRepository;
10
- explicitTeaching: ReturnType<typeof extractDeterministicTeaching>;
11
- plan: ResponsePlan;
12
- effectiveMode?: InteractionMode;
13
- }
14
- export interface MemoryProposalReceipt {
15
- proposal_id: string;
16
- subject: string;
17
- predicate: string;
18
- value: string;
19
- status: string;
20
- claim_type?: string;
21
- content?: string;
22
- }
23
- export interface BehavioralProposalReceipt {
24
- directive_id: string;
25
- domain?: string;
26
- knowledge_domain?: string;
27
- memory_class?: string;
28
- runtime_effect?: string;
29
- subject?: string;
30
- predicate?: string;
31
- value?: string;
32
- status: string;
33
- behavior?: {
34
- instruction: string;
35
- frequency?: string;
36
- preferred_positions?: string[];
37
- };
38
- }
39
- export interface MemorySettlementResult {
40
- createdMemoryProposals: Claim[];
41
- memoryProposalReceipts: MemoryProposalReceipt[];
42
- createdBehavioralProposals?: BehaviorDirective[];
43
- behavioralProposalReceipts?: BehavioralProposalReceipt[];
44
- }
45
1
  /**
46
- * Persists source events, deterministic teaching claims, LLM memory proposals,
47
- * and LLM behavior proposals to the MemoryOrgan.
2
+ * @deprecated RFC VX-26-13: Deconstructing Memory into Sovereign Primitives.
3
+ * Use `@sidurijs/core/interaction-settler` instead.
48
4
  */
49
- export declare function settleMemoryProposals(params: MemorySettlementParams): Promise<MemorySettlementResult>;
5
+ export * from './interaction-settler';
@@ -1,161 +1,21 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settleMemoryProposals = settleMemoryProposals;
4
17
  /**
5
- * Persists source events, deterministic teaching claims, LLM memory proposals,
6
- * and LLM behavior proposals to the MemoryOrgan.
18
+ * @deprecated RFC VX-26-13: Deconstructing Memory into Sovereign Primitives.
19
+ * Use `@sidurijs/core/interaction-settler` instead.
7
20
  */
8
- async function settleMemoryProposals(params) {
9
- const { companionId, perceivedText, role, requestContext, memory, self, explicitTeaching, plan, effectiveMode, } = params;
10
- // Zero Memory Drift: Casual mode completely suppresses all proposal generation
11
- const mode = effectiveMode || requestContext.mode || 'hybrid';
12
- if (mode === 'casual') {
13
- return {
14
- createdMemoryProposals: [],
15
- memoryProposalReceipts: [],
16
- };
17
- }
18
- const createdMemoryProposals = [];
19
- let sourceEventId;
20
- const hasTeaching = explicitTeaching.claims.length > 0 ||
21
- explicitTeaching.behaviorProposals.length > 0;
22
- const hasPlanProposals = Boolean(plan.memoryProposals?.length) ||
23
- Boolean(plan.behaviorProposals?.length);
24
- if (memory &&
25
- (hasTeaching || hasPlanProposals) &&
26
- typeof memory.addSourceEvent === 'function') {
27
- const sourceEvent = {
28
- id: `evt-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
29
- sourceType: 'user_chat_explicit',
30
- occurredAt: new Date().toISOString(),
31
- payload: {
32
- message: perceivedText,
33
- role,
34
- companionId,
35
- actorId: requestContext.actor?.actorId || 'owner-user',
36
- channel: requestContext.conversation?.channel || 'direct',
37
- },
38
- };
39
- await memory.addSourceEvent(sourceEvent);
40
- sourceEventId = sourceEvent.id;
41
- }
42
- // Persist deterministic memory proposals as PENDING if memory is available
43
- if (memory && typeof memory.proposeClaim === 'function') {
44
- for (const claim of explicitTeaching.claims) {
45
- const proposal = await memory.proposeClaim({
46
- companionId,
47
- subject: claim.subject,
48
- predicate: claim.predicate,
49
- value: claim.value,
50
- scope: claim.subject?.startsWith('companion:') ? 'companion' : 'user',
51
- provenance: claim.provenance || 'deterministic_teaching',
52
- sourceEventId,
53
- claimType: claim.claimType || 'preference',
54
- authority: 'user_explicit',
55
- userConfirmation: 'none',
56
- sensitivity: claim.sensitivity ||
57
- (requestContext.conversation?.channel === 'public' ? 'public' : 'private'),
58
- });
59
- createdMemoryProposals.push(proposal);
60
- }
61
- // Also persist plan memory proposals if model returned structured proposals
62
- if (plan.memoryProposals && plan.memoryProposals.length > 0) {
63
- for (const p of plan.memoryProposals) {
64
- const proposal = await memory.proposeClaim({
65
- companionId,
66
- subject: p.subject || `actor:${requestContext.actor.actorId}`,
67
- predicate: p.predicate,
68
- value: p.value,
69
- scope: p.subject?.startsWith('companion:') ? 'companion' : 'user',
70
- provenance: p.provenance || 'llm_proposal',
71
- sourceEventId: sourceEventId || p.sourceEventId,
72
- claimType: p.claimType || 'semantic',
73
- sensitivity: p.sensitivity || 'private',
74
- });
75
- createdMemoryProposals.push(proposal);
76
- }
77
- }
78
- }
79
- const createdBehavioralProposals = [];
80
- const behavioralProposalReceipts = [];
81
- const allBehaviorProposals = [
82
- ...explicitTeaching.behaviorProposals,
83
- ...(plan.behaviorProposals || []),
84
- ];
85
- for (const bp of allBehaviorProposals) {
86
- let directive;
87
- if (memory && typeof memory.proposeDirective === 'function') {
88
- directive = await memory.proposeDirective({
89
- companionId,
90
- directive: bp.directive,
91
- priority: bp.priority || 50,
92
- category: bp.category || 'behavioral',
93
- supersedesId: bp.supersedesId,
94
- scopeActor: bp.scopeActor || (bp.subject?.startsWith('actor:') ? bp.subject.slice(6) : undefined),
95
- memoryClass: bp.memoryClass,
96
- subject: bp.subject,
97
- predicate: bp.predicate,
98
- value: bp.value,
99
- sourceEventId: sourceEventId || bp.sourceEventId,
100
- });
101
- }
102
- if (!directive || !directive.id) {
103
- directive = {
104
- id: directive?.id || `dir-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`,
105
- companionId,
106
- directive: bp.directive,
107
- priority: bp.priority || 50,
108
- status: 'pending',
109
- category: (bp.category || 'behavioral'),
110
- scopeActor: bp.scopeActor,
111
- supersedesId: bp.supersedesId,
112
- createdAt: new Date().toISOString(),
113
- };
114
- }
115
- createdBehavioralProposals.push(directive);
116
- if (self && typeof self.commitDirectives === 'function') {
117
- await self.commitDirectives(companionId, [{
118
- id: directive.id,
119
- companionId,
120
- directive: bp.directive,
121
- priority: bp.priority || 50,
122
- status: 'pending',
123
- category: (bp.category || 'behavioral'),
124
- scopeActor: bp.scopeActor,
125
- supersedesId: bp.supersedesId,
126
- createdAt: new Date().toISOString(),
127
- }]);
128
- }
129
- behavioralProposalReceipts.push({
130
- directive_id: directive.id,
131
- domain: 'behavioral',
132
- knowledge_domain: 'behavioral',
133
- memory_class: bp.memoryClass || 'behavioral',
134
- runtime_effect: bp.memoryClass || 'behavioral',
135
- subject: bp.subject || `companion:${companionId}`,
136
- predicate: bp.predicate || 'rule',
137
- value: bp.value || bp.directive,
138
- status: 'pending',
139
- behavior: {
140
- instruction: bp.directive,
141
- frequency: 'continuous',
142
- preferred_positions: [],
143
- },
144
- });
145
- }
146
- const memoryProposalReceipts = createdMemoryProposals.map((p) => ({
147
- proposal_id: p.id,
148
- subject: p.subject,
149
- predicate: p.predicate,
150
- value: p.value,
151
- status: (p.status || 'pending').toLowerCase().replace(/_/g, '-'),
152
- claim_type: p.claimType,
153
- content: p.content,
154
- }));
155
- return {
156
- createdMemoryProposals,
157
- memoryProposalReceipts,
158
- createdBehavioralProposals,
159
- behavioralProposalReceipts,
160
- };
161
- }
21
+ __exportStar(require("./interaction-settler"), exports);
@@ -1,9 +1,9 @@
1
- import { BrainOrgan, MemoryOrgan, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, Message, RequestContext, ActionPolicyEngine, ResponseGatingEngine, ExperienceDispatcher, ExperienceAdapter, StagedResponsePlan, ResponseGateEvaluation, MouthOrgan, MouthMedium, FormattedMouthOutput, SelfRepository, EKnowledgeOrgan, ActionExecutionResult, ResponsePlan } from './index';
1
+ import { BrainOrgan, ArchiveLedger, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, Message, RequestContext, ActionPolicyEngine, ResponseGatingEngine, ExperienceDispatcher, ExperienceAdapter, StagedResponsePlan, ResponseGateEvaluation, MouthOrgan, MouthMedium, FormattedMouthOutput, SelfRepository, EKnowledgeOrgan, ActionExecutionResult, ResponsePlan } from './index';
2
2
  import { NormalizedInput } from './input-normalizer';
3
3
  import { IntentClassification } from './intent-classifier';
4
4
  import { RetrievedContext } from './context-retriever';
5
5
  import { CompiledPrompts } from './prompt-compiler';
6
- import { MemorySettlementResult } from './memory-settler';
6
+ import { MemorySettlementResult } from './interaction-settler';
7
7
  import { ExperienceEmissionResult } from './experience-emitter';
8
8
  import { SessionHistoryManager } from './session-history';
9
9
  export interface CompanionPerception {
@@ -24,7 +24,8 @@ export interface PerceptionPipelineContext {
24
24
  perception: CompanionPerception;
25
25
  organs: {
26
26
  brain?: BrainOrgan;
27
- memory?: MemoryOrgan;
27
+ archive?: ArchiveLedger;
28
+ memory?: any;
28
29
  voice?: VoiceOrgan | ExperienceAdapter;
29
30
  knowledge?: KnowledgeOrgan;
30
31
  vision?: VisionOrgan;
@@ -69,6 +70,7 @@ export declare const contextRetrievalStage: PerceptionPipelineStage;
69
70
  export declare const promptCompilationStage: PerceptionPipelineStage;
70
71
  export declare const cognitionPlanningStage: PerceptionPipelineStage;
71
72
  export declare const responseGatingStage: PerceptionPipelineStage;
73
+ export declare const interactionSettlementStage: PerceptionPipelineStage;
72
74
  export declare const memorySettlementStage: PerceptionPipelineStage;
73
75
  export declare const actionExecutionStage: PerceptionPipelineStage;
74
76
  export declare const experienceEmissionStage: PerceptionPipelineStage;
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.envelopeAssemblyStage = exports.mouthDeliveryStage = exports.experienceEmissionStage = exports.actionExecutionStage = exports.memorySettlementStage = exports.responseGatingStage = exports.cognitionPlanningStage = exports.promptCompilationStage = exports.contextRetrievalStage = exports.intentClassificationStage = exports.inputNormalizationStage = exports.earTranscriptionStage = exports.PerceptionPipeline = void 0;
3
+ exports.envelopeAssemblyStage = exports.mouthDeliveryStage = exports.experienceEmissionStage = exports.actionExecutionStage = exports.memorySettlementStage = exports.interactionSettlementStage = exports.responseGatingStage = exports.cognitionPlanningStage = exports.promptCompilationStage = exports.contextRetrievalStage = exports.intentClassificationStage = exports.inputNormalizationStage = exports.earTranscriptionStage = exports.PerceptionPipeline = void 0;
4
4
  exports.createDefaultPerceptionPipeline = createDefaultPerceptionPipeline;
5
5
  const input_normalizer_1 = require("./input-normalizer");
6
6
  const intent_classifier_1 = require("./intent-classifier");
7
7
  const context_retriever_1 = require("./context-retriever");
8
8
  const prompt_compiler_1 = require("./prompt-compiler");
9
9
  const cognition_planner_1 = require("./cognition-planner");
10
- const memory_settler_1 = require("./memory-settler");
10
+ const interaction_settler_1 = require("./interaction-settler");
11
11
  const action_executor_1 = require("./action-executor");
12
12
  const experience_emitter_1 = require("./experience-emitter");
13
13
  const response_envelope_1 = require("./response-envelope");
@@ -97,6 +97,7 @@ const contextRetrievalStage = async (context) => {
97
97
  memoryQueries: context.intent.memoryQueries,
98
98
  isSelfIdentityRequest: context.intent.isSelfIdentityRequest,
99
99
  knowledge: context.organs.knowledge,
100
+ archive: context.organs.archive,
100
101
  memory: context.organs.memory,
101
102
  self: context.organs.self,
102
103
  externalKnowledge: context.organs.externalKnowledge,
@@ -174,23 +175,25 @@ const responseGatingStage = async (context) => {
174
175
  context.sessionHistory.append('default', { role: 'assistant', content: context.plan.speech });
175
176
  };
176
177
  exports.responseGatingStage = responseGatingStage;
177
- const memorySettlementStage = async (context) => {
178
+ const interactionSettlementStage = async (context) => {
178
179
  if (!context.input || !context.plan || !context.intent)
179
180
  return;
180
- const memorySettlement = await (0, memory_settler_1.settleMemoryProposals)({
181
+ const settlement = await (0, interaction_settler_1.settleInteractionProposals)({
181
182
  companionId: context.companionId,
182
183
  perceivedText: context.input.perceivedText,
183
184
  role: context.input.role,
184
185
  requestContext: context.input.requestContext,
185
- memory: context.organs.memory,
186
+ archive: context.organs.archive,
186
187
  self: context.organs.self,
187
188
  explicitTeaching: context.intent.explicitTeaching,
188
189
  plan: context.plan,
189
190
  effectiveMode: context.intent.effectiveMode,
191
+ memory: context.organs.memory,
190
192
  });
191
- context.memorySettlement = memorySettlement;
193
+ context.memorySettlement = settlement;
192
194
  };
193
- exports.memorySettlementStage = memorySettlementStage;
195
+ exports.interactionSettlementStage = interactionSettlementStage;
196
+ exports.memorySettlementStage = exports.interactionSettlementStage;
194
197
  const actionExecutionStage = async (context) => {
195
198
  if (!context.input || !context.plan)
196
199
  return;
@@ -1,5 +1,5 @@
1
1
  import { StagedResponsePlan, ResponseGateEvaluation, Claim, ResponseCitation, ExperienceEvent, ActionExecutionResult, InteractionMode } from './index';
2
- import { MemoryProposalReceipt } from './memory-settler';
2
+ import { MemoryProposalReceipt } from './interaction-settler';
3
3
  import { FormattedMouthOutput } from './mouth-types';
4
4
  export interface AssembleResponseEnvelopeParams {
5
5
  stagedPlan: StagedResponsePlan;
@@ -63,6 +63,7 @@ function assembleResponseEnvelope(params) {
63
63
  mode: effectiveMode ?? 'hybrid',
64
64
  language,
65
65
  proposals: createdMemoryProposals,
66
+ directive_proposals: behavioralProposalReceipts || [],
66
67
  memory_proposals: memoryProposalReceipts,
67
68
  behavioral_proposals: behavioralProposalReceipts || [],
68
69
  action_results: actionResults,
@@ -27,44 +27,21 @@ describe('CompanionContainer & Direct Domain Access', () => {
27
27
  const cleared = container.observation.clearExpired();
28
28
  expect(cleared).toBe(1);
29
29
  });
30
- test('delegates memory operations directly on the memory organ', async () => {
31
- const mockMemory = {
32
- initialize: jest.fn().mockResolvedValue(undefined),
33
- getClaims: jest.fn().mockResolvedValue([{ id: 'claim-1' }]),
34
- getPendingClaims: jest.fn().mockResolvedValue([{ id: 'claim-pending-1' }]),
35
- getDirectives: jest.fn().mockResolvedValue([{ id: 'dir-1' }]),
36
- approveClaim: jest.fn().mockResolvedValue(undefined),
37
- rejectClaim: jest.fn().mockResolvedValue(undefined),
38
- updateClaim: jest.fn().mockResolvedValue({ id: 'claim-1', value: 'updated' }),
39
- approveDirective: jest.fn().mockResolvedValue(undefined),
40
- rejectDirective: jest.fn().mockResolvedValue(undefined),
41
- revokeDirective: jest.fn().mockResolvedValue(undefined),
42
- disableDirective: jest.fn().mockResolvedValue(undefined),
43
- resetMemory: jest.fn().mockResolvedValue(undefined),
30
+ test('delegates archive operations directly on the archive organ', async () => {
31
+ const mockArchive = {
32
+ recordEvent: jest.fn().mockResolvedValue(undefined),
33
+ getRecentEvents: jest.fn().mockResolvedValue([{ id: 'evt-1' }]),
34
+ searchEvents: jest.fn().mockResolvedValue([{ id: 'evt-1' }]),
44
35
  };
45
36
  const container = new container_1.CompanionContainer('test-comp', { name: 'Test' }, {
46
- memory: mockMemory,
37
+ archive: mockArchive,
47
38
  });
48
- expect(await container.memory.getClaims(10)).toEqual([{ id: 'claim-1' }]);
49
- expect(mockMemory.getClaims).toHaveBeenCalledWith(10);
50
- expect(await container.memory.getPendingClaims()).toEqual([{ id: 'claim-pending-1' }]);
51
- expect(await container.memory.getDirectives()).toEqual([{ id: 'dir-1' }]);
52
- await container.memory.approveClaim('c-1');
53
- expect(mockMemory.approveClaim).toHaveBeenCalledWith('c-1');
54
- await container.memory.rejectClaim('c-2');
55
- expect(mockMemory.rejectClaim).toHaveBeenCalledWith('c-2');
56
- await container.memory.updateClaim('c-1', { value: 'updated' });
57
- expect(mockMemory.updateClaim).toHaveBeenCalledWith('c-1', { value: 'updated' });
58
- await container.memory.approveDirective('d-1');
59
- expect(mockMemory.approveDirective).toHaveBeenCalledWith('d-1');
60
- await container.memory.rejectDirective('d-2');
61
- expect(mockMemory.rejectDirective).toHaveBeenCalledWith('d-2');
62
- await container.memory.revokeDirective('d-3');
63
- expect(mockMemory.revokeDirective).toHaveBeenCalledWith('d-3');
64
- await container.memory.disableDirective('d-4');
65
- expect(mockMemory.disableDirective).toHaveBeenCalledWith('d-4');
66
- await container.memory.resetMemory();
67
- expect(mockMemory.resetMemory).toHaveBeenCalled();
39
+ expect(await container.archive.getRecentEvents('test-comp', 10)).toEqual([{ id: 'evt-1' }]);
40
+ expect(mockArchive.getRecentEvents).toHaveBeenCalledWith('test-comp', 10);
41
+ expect(await container.archive.searchEvents('test-comp', 'query', 5)).toEqual([{ id: 'evt-1' }]);
42
+ expect(mockArchive.searchEvents).toHaveBeenCalledWith('test-comp', 'query', 5);
43
+ await container.archive.recordEvent({ id: 'evt-2' });
44
+ expect(mockArchive.recordEvent).toHaveBeenCalledWith({ id: 'evt-2' });
68
45
  });
69
46
  test('configures SqliteActionStore when actionStore is sqlite', () => {
70
47
  const container = new container_1.CompanionContainer('comp-sqlite', {
package/dist/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BrainOrgan, MemoryOrgan, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, MouthOrgan, SelfRepository, EKnowledgeOrgan, Message, RequestContext, MouthMedium, ResponseGatingEngine, ActionPolicyEngine, ExperienceDispatcher } from './index';
1
+ import { BrainOrgan, ArchiveLedger, VoiceOrgan, KnowledgeOrgan, VisionOrgan, BehaviorOrgan, BodyOrgan, HandsOrgan, EarOrgan, ObservationOrgan, MouthOrgan, SelfRepository, EKnowledgeOrgan, Message, RequestContext, MouthMedium, ResponseGatingEngine, ActionPolicyEngine, ExperienceDispatcher } from './index';
2
2
  import { SiduriDatabase, LogLevel, SystemLog } from './siduri-db';
3
3
  import { SessionHistoryManager } from './session-history';
4
4
  import { CompanionPerception, PerceptionPipeline } from './perception-pipeline';
@@ -17,7 +17,7 @@ export declare class SiduriRuntime {
17
17
  constructor(id: string, config: SiduriRuntimeConfig, containerOrOrgans?: CompanionContainer | RuntimeOrgans, pipeline?: PerceptionPipeline);
18
18
  get organs(): RuntimeOrgans;
19
19
  get brain(): BrainOrgan | undefined;
20
- get memory(): MemoryOrgan | undefined;
20
+ get archive(): ArchiveLedger | undefined;
21
21
  get voice(): VoiceOrgan | undefined;
22
22
  get knowledge(): KnowledgeOrgan | undefined;
23
23
  get vision(): VisionOrgan | undefined;
@@ -51,8 +51,9 @@ export declare class SiduriRuntime {
51
51
  getSessionHistory(sessionKey: string): Message[];
52
52
  clearHistory(sessionKey?: string): void;
53
53
  /**
54
- * Approves a memory proposal or behavior proposal and canonically promotes
55
- * Self-affecting mutations to SelfRepository.
54
+ * Approves a proposal using Direct Domain Routing (RFC VX-26-13):
55
+ * - Behavioral & relational directives route directly to SelfRepository.
56
+ * - Life state facts route directly to Knowledge / Life DB.
56
57
  */
57
58
  approveProposal(proposalId: string, options?: {
58
59
  companionId?: string;
@@ -62,7 +63,7 @@ export declare class SiduriRuntime {
62
63
  name?: string;
63
64
  }>;
64
65
  /**
65
- * Rejects a memory or behavior proposal.
66
+ * Rejects a proposal.
66
67
  */
67
68
  rejectProposal(proposalId: string, options?: {
68
69
  companionId?: string;
@@ -70,7 +71,7 @@ export declare class SiduriRuntime {
70
71
  success: boolean;
71
72
  }>;
72
73
  /**
73
- * Approves a behavioral directive in Self and Memory.
74
+ * Approves a behavioral directive directly in Self.
74
75
  */
75
76
  approveDirective(directiveId: string, options?: {
76
77
  companionId?: string;
@@ -79,7 +80,7 @@ export declare class SiduriRuntime {
79
80
  name?: string;
80
81
  }>;
81
82
  /**
82
- * Rejects a behavioral directive in Self and Memory.
83
+ * Rejects a behavioral directive in Self.
83
84
  */
84
85
  rejectDirective(directiveId: string, options?: {
85
86
  companionId?: string;
@@ -87,7 +88,7 @@ export declare class SiduriRuntime {
87
88
  success: boolean;
88
89
  }>;
89
90
  /**
90
- * Revokes a behavioral directive in Self and Memory.
91
+ * Revokes a behavioral directive in Self.
91
92
  */
92
93
  revokeDirective(directiveId: string, options?: {
93
94
  companionId?: string;
@@ -105,12 +106,17 @@ export declare class SiduriRuntime {
105
106
  handleUserMessage(message: string, roleOrContext?: 'OWNER' | 'VIEWER' | 'OPERATOR' | RequestContext | string, history?: Message[], medium?: MouthMedium, signal?: AbortSignal, subtitleLanguage?: string): Promise<any>;
106
107
  }
107
108
  /**
108
- * Canonically promotes an approved Claim into SelfRepository state.
109
+ * @deprecated RFC VX-26-13: Deconstructing Memory.
110
+ * Prefer Direct Domain Routing: behavioral directives, identity mutations, and relational
111
+ * stances should route directly to SelfRepository (`commitDirectives`, `setIdentity`, `updateRelationship`)
112
+ * rather than being staged in memory_claims and promoted downstream.
109
113
  */
110
114
  export declare function promoteApprovedClaimToSelf(claim: any, self: SelfRepository, companionId?: string): Promise<void>;
111
115
  export declare function isSelfAffectingClaim(claim: any): boolean;
112
116
  export declare function isKnowledgeAffectingClaim(claim: any): boolean;
113
117
  /**
114
- * Canonically promotes an approved Claim into Knowledge / LifeDatabase state.
118
+ * @deprecated RFC VX-26-13: Deconstructing Memory.
119
+ * Prefer Direct Domain Routing: user life facts (entities, inventory, finances, schedule, preferences)
120
+ * should route directly to Knowledge / LifeDatabase rather than being staged as generic memory claims.
115
121
  */
116
122
  export declare function promoteApprovedClaimToKnowledge(claim: any, knowledge: any, companionId?: string): Promise<boolean>;