@siduri-x/self 2.0.12 → 2.0.13

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,4 +1,4 @@
1
-
2
- > @siduri-x/self@2.0.12 build /home/zagin/Projects/vxnus-studio/projects/siduri-x/packages/self
3
- > tsc
4
-
1
+
2
+ > @siduri-x/self@2.0.12 build /home/zagin/Projects/vxnus-studio/projects/siduri-x/packages/self
3
+ > tsc
4
+
@@ -20,8 +20,18 @@ const self_parser_1 = require("./self-parser");
20
20
  * 5. If Brain is unavailable or offline, gracefully falls back to deterministic YAML/JSON parser.
21
21
  */
22
22
  async function compilePersonaDocument(content, options = {}) {
23
- const { brain, companionId, fallbackToParser = true } = options;
23
+ const { brain, companionId, fallbackToParser = false } = options;
24
24
  // 1. Try Brain Cognitive Compiler if available
25
+ if (!brain || typeof brain.compilePersona !== 'function') {
26
+ if (!fallbackToParser) {
27
+ return {
28
+ isValid: false,
29
+ compiledBy: 'none',
30
+ scannedDirectives: [],
31
+ errors: ['Brain organ with compilePersona capability is required. Falling back to static parsing is prohibited to enforce Truth Gate distillation.'],
32
+ };
33
+ }
34
+ }
25
35
  if (brain && typeof brain.compilePersona === 'function') {
26
36
  try {
27
37
  const compilation = await brain.compilePersona(content, { companionId });
@@ -92,7 +102,15 @@ async function compilePersonaDocument(content, options = {}) {
92
102
  }
93
103
  }
94
104
  }
95
- // 2. Fallback to deterministic parser
105
+ // 2. Fallback to deterministic parser (strictly gated by fallbackToParser)
106
+ if (!fallbackToParser) {
107
+ return {
108
+ isValid: false,
109
+ compiledBy: 'none',
110
+ scannedDirectives: [],
111
+ errors: ['Brain organ compilation failed or produced an invalid manifest. Static parser fallback is prohibited to preserve Truth Gate integrity.'],
112
+ };
113
+ }
96
114
  try {
97
115
  const parsed = self_parser_1.SelfPackageParser.parse(content);
98
116
  return {
@@ -63,20 +63,26 @@ directives:
63
63
  expect(result.scannedDirectives[1].scanResult.safe).toBe(false);
64
64
  expect(result.scannedDirectives[1].approvedByDefault).toBe(false);
65
65
  });
66
- it('falls back to deterministic YAML/JSON parser when Brain is not provided', async () => {
67
- const result = await (0, cognitive_compiler_1.compilePersonaDocument)(validYaml);
66
+ it('falls back to deterministic YAML/JSON parser when fallbackToParser is true and Brain is not provided', async () => {
67
+ const result = await (0, cognitive_compiler_1.compilePersonaDocument)(validYaml, { fallbackToParser: true });
68
68
  expect(result.isValid).toBe(true);
69
69
  expect(result.compiledBy).toBe('parser');
70
70
  expect(result.manifest?.identity.name).toBe('Elena');
71
71
  expect(result.scannedDirectives).toHaveLength(1);
72
72
  expect(result.scannedDirectives[0].id).toBe('dir-1');
73
73
  });
74
- it('falls back to deterministic parser when Brain throws an error', async () => {
74
+ it('rejects without Brain by default (no fallback)', async () => {
75
+ const result = await (0, cognitive_compiler_1.compilePersonaDocument)(validYaml);
76
+ expect(result.isValid).toBe(false);
77
+ expect(result.compiledBy).toBe('none');
78
+ expect(result.errors[0]).toContain('Brain organ with compilePersona capability is required');
79
+ });
80
+ it('falls back to deterministic parser when Brain throws an error and fallbackToParser is true', async () => {
75
81
  const failingBrain = {
76
82
  generatePlan: jest.fn(),
77
83
  compilePersona: jest.fn().mockRejectedValue(new Error('API quota exceeded')),
78
84
  };
79
- const result = await (0, cognitive_compiler_1.compilePersonaDocument)(validYaml, { brain: failingBrain });
85
+ const result = await (0, cognitive_compiler_1.compilePersonaDocument)(validYaml, { brain: failingBrain, fallbackToParser: true });
80
86
  expect(result.isValid).toBe(true);
81
87
  expect(result.compiledBy).toBe('parser');
82
88
  expect(result.manifest?.identity.name).toBe('Elena');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siduri-x/self",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "Siduri Self domain: Identity, personality, directional relationships, directives, ActiveSelfCompiler, and .self asset parser",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -69,8 +69,8 @@ directives:
69
69
  expect(result.scannedDirectives[1].approvedByDefault).toBe(false);
70
70
  });
71
71
 
72
- it('falls back to deterministic YAML/JSON parser when Brain is not provided', async () => {
73
- const result = await compilePersonaDocument(validYaml);
72
+ it('falls back to deterministic YAML/JSON parser when fallbackToParser is true and Brain is not provided', async () => {
73
+ const result = await compilePersonaDocument(validYaml, { fallbackToParser: true });
74
74
 
75
75
  expect(result.isValid).toBe(true);
76
76
  expect(result.compiledBy).toBe('parser');
@@ -79,13 +79,20 @@ directives:
79
79
  expect(result.scannedDirectives[0].id).toBe('dir-1');
80
80
  });
81
81
 
82
- it('falls back to deterministic parser when Brain throws an error', async () => {
82
+ it('rejects without Brain by default (no fallback)', async () => {
83
+ const result = await compilePersonaDocument(validYaml);
84
+ expect(result.isValid).toBe(false);
85
+ expect(result.compiledBy).toBe('none');
86
+ expect(result.errors[0]).toContain('Brain organ with compilePersona capability is required');
87
+ });
88
+
89
+ it('falls back to deterministic parser when Brain throws an error and fallbackToParser is true', async () => {
83
90
  const failingBrain: BrainOrgan = {
84
91
  generatePlan: jest.fn(),
85
92
  compilePersona: jest.fn().mockRejectedValue(new Error('API quota exceeded')),
86
93
  };
87
94
 
88
- const result = await compilePersonaDocument(validYaml, { brain: failingBrain });
95
+ const result = await compilePersonaDocument(validYaml, { brain: failingBrain, fallbackToParser: true });
89
96
 
90
97
  expect(result.isValid).toBe(true);
91
98
  expect(result.compiledBy).toBe('parser');
@@ -29,10 +29,22 @@ export async function compilePersonaDocument(
29
29
  content: string,
30
30
  options: CompilePersonaOptions = {}
31
31
  ): Promise<SelfPackageParseResult> {
32
- const { brain, companionId, fallbackToParser = true } = options;
32
+ const { brain, companionId, fallbackToParser = false } = options;
33
33
 
34
34
  // 1. Try Brain Cognitive Compiler if available
35
+ if (!brain || typeof brain.compilePersona !== 'function') {
36
+ if (!fallbackToParser) {
37
+ return {
38
+ isValid: false,
39
+ compiledBy: 'none',
40
+ scannedDirectives: [],
41
+ errors: ['Brain organ with compilePersona capability is required. Falling back to static parsing is prohibited to enforce Truth Gate distillation.'],
42
+ };
43
+ }
44
+ }
45
+
35
46
  if (brain && typeof brain.compilePersona === 'function') {
47
+
36
48
  try {
37
49
  const compilation = await brain.compilePersona(content, { companionId });
38
50
  if (compilation && compilation.isValid && compilation.manifest) {
@@ -106,7 +118,16 @@ export async function compilePersonaDocument(
106
118
  }
107
119
  }
108
120
 
109
- // 2. Fallback to deterministic parser
121
+ // 2. Fallback to deterministic parser (strictly gated by fallbackToParser)
122
+ if (!fallbackToParser) {
123
+ return {
124
+ isValid: false,
125
+ compiledBy: 'none',
126
+ scannedDirectives: [],
127
+ errors: ['Brain organ compilation failed or produced an invalid manifest. Static parser fallback is prohibited to preserve Truth Gate integrity.'],
128
+ };
129
+ }
130
+
110
131
  try {
111
132
  const parsed = SelfPackageParser.parse(content);
112
133
  return {