dsh-biocore 0.2.0 → 0.3.0
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/README.md +11 -0
- package/lib/core-worker.js +268 -0
- package/lib/index.js +160 -70
- package/lib/modules/autonomy.js +125 -0
- package/lib/modules/cache-stats.js +48 -0
- package/lib/modules/core-turn.js +24 -6
- package/lib/modules/expression-inject.js +0 -10
- package/lib/modules/expression-refresh.js +0 -9
- package/lib/modules/memory-capture.js +2 -1
- package/lib/modules/memory-inject.js +50 -5
- package/lib/modules/memory-tools.js +7 -4
- package/lib/modules/python-env.js +46 -0
- package/lib/modules/safety-gate.js +0 -3
- package/lib/modules/series.js +54 -0
- package/lib/modules/switch.js +16 -0
- package/lib/py-bridge.js +81 -15
- package/package.json +1 -1
- package/python/biocore_memory/core/config.py +138 -127
- package/python/biocore_memory/engine.py +2653 -2476
- package/python/biocore_memory/recall/embedding.py +129 -0
- package/python/biocore_memory/recall/feedback.py +202 -0
- package/python/biocore_model/preference_drift.py +255 -0
- package/python/biocore_model/tests/__init__.py +1 -0
- package/python/biocore_model/tests/core_mode_ui_check.mjs +63 -0
- package/python/biocore_model/tests/core_status_check.mjs +29 -0
- package/python/biocore_model/tests/dom_safe_check.mjs +22 -0
- package/python/biocore_model/tests/leak_samples_run.py +18 -0
- package/python/biocore_model/tests/orb_ring_check.mjs +20 -0
- package/python/biocore_model/tests/panel_html_check.mjs +63 -0
- package/python/biocore_model/tests/persona_flow_check.mjs +17 -0
- package/python/biocore_model/tests/render_guard_check.mjs +19 -0
- package/python/biocore_model/tests/switch_groups_check.mjs +94 -0
- package/python/biocore_model/tests/tabs_state_check.mjs +24 -0
- package/python/biocore_model/tests/test_affective_labor.py +102 -0
- package/python/biocore_model/tests/test_appraisal.py +137 -0
- package/python/biocore_model/tests/test_appraisal_action.py +55 -0
- package/python/biocore_model/tests/test_arch_convergence.py +35 -0
- package/python/biocore_model/tests/test_attachment_behavior.py +95 -0
- package/python/biocore_model/tests/test_attachment_regulation.py +63 -0
- package/python/biocore_model/tests/test_attachment_state.py +29 -0
- package/python/biocore_model/tests/test_attribution.py +56 -0
- package/python/biocore_model/tests/test_attributor.py +108 -0
- package/python/biocore_model/tests/test_autonomic.py +69 -0
- package/python/biocore_model/tests/test_autonomy_accumulator.py +84 -0
- package/python/biocore_model/tests/test_autonomy_affect.py +62 -0
- package/python/biocore_model/tests/test_autonomy_blame.py +44 -0
- package/python/biocore_model/tests/test_autonomy_caps.py +29 -0
- package/python/biocore_model/tests/test_autonomy_check.py +40 -0
- package/python/biocore_model/tests/test_autonomy_clingy.py +41 -0
- package/python/biocore_model/tests/test_autonomy_cooldown_selfcontact.py +138 -0
- package/python/biocore_model/tests/test_autonomy_frustration.py +42 -0
- package/python/biocore_model/tests/test_autonomy_hourly_limit.py +46 -0
- package/python/biocore_model/tests/test_autonomy_loop.py +64 -0
- package/python/biocore_model/tests/test_autonomy_mode.py +37 -0
- package/python/biocore_model/tests/test_autonomy_model.py +60 -0
- package/python/biocore_model/tests/test_autonomy_model_v2.py +68 -0
- package/python/biocore_model/tests/test_autonomy_module_text.py +104 -0
- package/python/biocore_model/tests/test_autonomy_params.py +163 -0
- package/python/biocore_model/tests/test_autonomy_reason.py +34 -0
- package/python/biocore_model/tests/test_autonomy_self.py +153 -0
- package/python/biocore_model/tests/test_autonomy_send_gate.py +38 -0
- package/python/biocore_model/tests/test_autonomy_silence.py +37 -0
- package/python/biocore_model/tests/test_autonomy_status.py +35 -0
- package/python/biocore_model/tests/test_autonomy_test_trigger.py +24 -0
- package/python/biocore_model/tests/test_autonomy_tick.py +148 -0
- package/python/biocore_model/tests/test_autonomy_v4.py +64 -0
- package/python/biocore_model/tests/test_autonomy_v5.py +43 -0
- package/python/biocore_model/tests/test_autonomy_v7.py +48 -0
- package/python/biocore_model/tests/test_autonomy_v_theta.py +85 -0
- package/python/biocore_model/tests/test_batch1_wiring.py +231 -0
- package/python/biocore_model/tests/test_batch2_wiring.py +231 -0
- package/python/biocore_model/tests/test_batch3_wiring.py +223 -0
- package/python/biocore_model/tests/test_bio_tick.py +202 -0
- package/python/biocore_model/tests/test_boundary.py +183 -0
- package/python/biocore_model/tests/test_boundary_gate.py +295 -0
- package/python/biocore_model/tests/test_brain_split.py +99 -0
- package/python/biocore_model/tests/test_co_recall.py +350 -0
- package/python/biocore_model/tests/test_commitment_extractor.py +197 -0
- package/python/biocore_model/tests/test_compassion_fatigue.py +84 -0
- package/python/biocore_model/tests/test_connection_bids.py +69 -0
- package/python/biocore_model/tests/test_core_bridge.py +88 -0
- package/python/biocore_model/tests/test_core_bridge_episode.py +14 -0
- package/python/biocore_model/tests/test_core_bridge_forget.py +17 -0
- package/python/biocore_model/tests/test_core_bridge_identity.py +15 -0
- package/python/biocore_model/tests/test_core_bridge_media.py +17 -0
- package/python/biocore_model/tests/test_core_bridge_relation.py +17 -0
- package/python/biocore_model/tests/test_core_bridge_summary.py +17 -0
- package/python/biocore_model/tests/test_core_client.py +156 -0
- package/python/biocore_model/tests/test_core_commands.py +146 -0
- package/python/biocore_model/tests/test_core_mode.py +161 -0
- package/python/biocore_model/tests/test_core_state.py +240 -0
- package/python/biocore_model/tests/test_criticality.py +61 -0
- package/python/biocore_model/tests/test_cross_session_copy.py +67 -0
- package/python/biocore_model/tests/test_debug_values.py +169 -0
- package/python/biocore_model/tests/test_defense_mechanisms.py +177 -0
- package/python/biocore_model/tests/test_delta_budget.py +157 -0
- package/python/biocore_model/tests/test_diag_trace.py +201 -0
- package/python/biocore_model/tests/test_directives_compat.py +698 -0
- package/python/biocore_model/tests/test_dissonance.py +97 -0
- package/python/biocore_model/tests/test_drift_sign.py +87 -0
- package/python/biocore_model/tests/test_embedding_fallback.py +277 -0
- package/python/biocore_model/tests/test_embedding_local.py +279 -0
- package/python/biocore_model/tests/test_embedding_mode.py +175 -0
- package/python/biocore_model/tests/test_embedding_modes.py +342 -0
- package/python/biocore_model/tests/test_emotion_geometry.py +114 -0
- package/python/biocore_model/tests/test_emotion_probe.py +214 -0
- package/python/biocore_model/tests/test_emotion_probe_concurrency.py +128 -0
- package/python/biocore_model/tests/test_entity_graph.py +198 -0
- package/python/biocore_model/tests/test_entity_resolve.py +446 -0
- package/python/biocore_model/tests/test_envy.py +173 -0
- package/python/biocore_model/tests/test_exit_or_silence.py +209 -0
- package/python/biocore_model/tests/test_expr_guard.py +1 -0
- package/python/biocore_model/tests/test_expr_intent.py +66 -0
- package/python/biocore_model/tests/test_expr_state.py +66 -0
- package/python/biocore_model/tests/test_expr_template.py +71 -0
- package/python/biocore_model/tests/test_expr_tone.py +41 -0
- package/python/biocore_model/tests/test_extreme_scenarios.py +147 -0
- package/python/biocore_model/tests/test_feedback_flow.py +185 -0
- package/python/biocore_model/tests/test_feedback_guard.py +65 -0
- package/python/biocore_model/tests/test_feedback_llm.py +59 -0
- package/python/biocore_model/tests/test_feedback_llm_inferred.py +140 -0
- package/python/biocore_model/tests/test_feedback_memory.py +63 -0
- package/python/biocore_model/tests/test_feedback_user.py +61 -0
- package/python/biocore_model/tests/test_frustration_curve.py +66 -0
- package/python/biocore_model/tests/test_global_bio_state.py +116 -0
- package/python/biocore_model/tests/test_governance.py +181 -0
- package/python/biocore_model/tests/test_granularity.py +133 -0
- package/python/biocore_model/tests/test_graph_extract.py +224 -0
- package/python/biocore_model/tests/test_graph_recall.py +226 -0
- package/python/biocore_model/tests/test_graph_sqlite.py +298 -0
- package/python/biocore_model/tests/test_growth.py +301 -0
- package/python/biocore_model/tests/test_intent_render.py +60 -0
- package/python/biocore_model/tests/test_intero_regulation.py +224 -0
- package/python/biocore_model/tests/test_intero_style.py +146 -0
- package/python/biocore_model/tests/test_item3_numeric.py +105 -0
- package/python/biocore_model/tests/test_item6_numeric.py +116 -0
- package/python/biocore_model/tests/test_layered_memory.py +174 -0
- package/python/biocore_model/tests/test_leak_guard.py +75 -0
- package/python/biocore_model/tests/test_learning_probe.py +93 -0
- package/python/biocore_model/tests/test_life_loop.py +222 -0
- package/python/biocore_model/tests/test_life_loop_10s.py +131 -0
- package/python/biocore_model/tests/test_local_embedding_health.py +258 -0
- package/python/biocore_model/tests/test_memory_affect_encoding.py +79 -0
- package/python/biocore_model/tests/test_memory_backend.py +332 -0
- package/python/biocore_model/tests/test_memory_dedup.py +316 -0
- package/python/biocore_model/tests/test_memory_dual.py +219 -0
- package/python/biocore_model/tests/test_memory_dual_wiring.py +219 -0
- package/python/biocore_model/tests/test_memory_feedback.py +241 -0
- package/python/biocore_model/tests/test_memory_fixes.py +84 -0
- package/python/biocore_model/tests/test_memory_forgetting.py +58 -0
- package/python/biocore_model/tests/test_memory_inject.py +211 -0
- package/python/biocore_model/tests/test_memory_mood_recall.py +118 -0
- package/python/biocore_model/tests/test_memory_store.py +372 -0
- package/python/biocore_model/tests/test_metacog.py +103 -0
- package/python/biocore_model/tests/test_migrate.py +245 -0
- package/python/biocore_model/tests/test_migrate_store.py +194 -0
- package/python/biocore_model/tests/test_mind_wander.py +65 -0
- package/python/biocore_model/tests/test_mood.py +35 -0
- package/python/biocore_model/tests/test_narrative.py +114 -0
- package/python/biocore_model/tests/test_needs_esteem.py +51 -0
- package/python/biocore_model/tests/test_needs_events.py +205 -0
- package/python/biocore_model/tests/test_needs_sleep.py +54 -0
- package/python/biocore_model/tests/test_noise_bank.py +54 -0
- package/python/biocore_model/tests/test_numeric_schema.py +98 -0
- package/python/biocore_model/tests/test_output_protocol.py +65 -0
- package/python/biocore_model/tests/test_page_debug.py +147 -0
- package/python/biocore_model/tests/test_page_status_autonomy.py +215 -0
- package/python/biocore_model/tests/test_pipeline.py +345 -0
- package/python/biocore_model/tests/test_pipeline_api.py +192 -0
- package/python/biocore_model/tests/test_pipeline_mode.py +222 -0
- package/python/biocore_model/tests/test_plugin_config.py +85 -0
- package/python/biocore_model/tests/test_policy_learning.py +116 -0
- package/python/biocore_model/tests/test_possible_selves.py +88 -0
- package/python/biocore_model/tests/test_predictor.py +227 -0
- package/python/biocore_model/tests/test_preference_drift.py +142 -0
- package/python/biocore_model/tests/test_preset.py +142 -0
- package/python/biocore_model/tests/test_proactive_context.py +70 -0
- package/python/biocore_model/tests/test_proactive_history.py +90 -0
- package/python/biocore_model/tests/test_proactive_memory.py +141 -0
- package/python/biocore_model/tests/test_proactive_send_record.py +88 -0
- package/python/biocore_model/tests/test_probe_contract.py +71 -0
- package/python/biocore_model/tests/test_prospective.py +154 -0
- package/python/biocore_model/tests/test_provider_fallback.py +89 -0
- package/python/biocore_model/tests/test_reconstruction.py +111 -0
- package/python/biocore_model/tests/test_regulation_strategies.py +228 -0
- package/python/biocore_model/tests/test_relation_stage.py +114 -0
- package/python/biocore_model/tests/test_relationship_stage.py +59 -0
- package/python/biocore_model/tests/test_release_140.py +55 -0
- package/python/biocore_model/tests/test_repair_after_boundary.py +249 -0
- package/python/biocore_model/tests/test_reply_limit.py +86 -0
- package/python/biocore_model/tests/test_reply_limit_persist.py +48 -0
- package/python/biocore_model/tests/test_reply_split.py +52 -0
- package/python/biocore_model/tests/test_reply_split_astrbot.py +66 -0
- package/python/biocore_model/tests/test_reply_split_inject.py +53 -0
- package/python/biocore_model/tests/test_rerank.py +229 -0
- package/python/biocore_model/tests/test_rollback.py +175 -0
- package/python/biocore_model/tests/test_runtime.py +175 -0
- package/python/biocore_model/tests/test_runtime_active.py +205 -0
- package/python/biocore_model/tests/test_runtime_pipeline.py +1583 -0
- package/python/biocore_model/tests/test_runtime_proactive.py +231 -0
- package/python/biocore_model/tests/test_scheduler.py +79 -0
- package/python/biocore_model/tests/test_secrecy.py +105 -0
- package/python/biocore_model/tests/test_self_esteem.py +45 -0
- package/python/biocore_model/tests/test_self_intent.py +347 -0
- package/python/biocore_model/tests/test_self_interest.py +183 -0
- package/python/biocore_model/tests/test_self_layer_wiring.py +198 -0
- package/python/biocore_model/tests/test_self_verification.py +113 -0
- package/python/biocore_model/tests/test_situation.py +142 -0
- package/python/biocore_model/tests/test_sleep_circadian.py +41 -0
- package/python/biocore_model/tests/test_social_pain.py +49 -0
- package/python/biocore_model/tests/test_social_repair.py +67 -0
- package/python/biocore_model/tests/test_social_theory.py +78 -0
- package/python/biocore_model/tests/test_source_monitoring.py +204 -0
- package/python/biocore_model/tests/test_speak_like_group.py +36 -0
- package/python/biocore_model/tests/test_stages.py +226 -0
- package/python/biocore_model/tests/test_state_tag.py +86 -0
- package/python/biocore_model/tests/test_template_expr.py +65 -0
- package/python/biocore_model/tests/test_text_inference.py +70 -0
- package/python/biocore_model/tests/test_theta_params.py +115 -0
- package/python/biocore_model/tests/test_topic_control.py +200 -0
- package/python/biocore_model/tests/test_turn_memory.py +105 -0
- package/python/biocore_model/tests/test_turn_memory_panel.py +174 -0
- package/python/biocore_model/tests/test_ui_settings.py +84 -0
- package/python/biocore_model/tests/test_ui_settings_authority.py +179 -0
- package/python/biocore_model/tests/test_user_appraisal_async.py +155 -0
- package/python/biocore_model/tests/test_user_classify.py +122 -0
- package/python/biocore_model/tests/test_value_order.py +117 -0
- package/python/biocore_model/tests/test_voice_bank.py +105 -0
- package/python/biocore_model/tests/test_waiting_sense.py +216 -0
- package/python/biocore_model/tests/test_x_directives.py +101 -0
- package/python/biocore_model/tests/ui_compat_check.mjs +22 -0
- package/python/biocore_model/tests/view_mode_check.mjs +17 -0
- package/python/biocore_runtime/autonomy.py +208 -0
- package/python/biocore_runtime/core_state.py +302 -0
- package/python/biocore_runtime/governance.py +495 -0
- package/python/biocore_runtime/growth.py +528 -0
- package/python/biocore_runtime/pipeline.py +850 -23
- package/python/biocore_runtime/relationship_state.py +214 -0
- package/python/biocore_runtime/self_layer.py +103 -0
- package/python/biocore_runtime/service.py +162 -0
- package/python/biocore_runtime/standby.py +472 -0
- package/ui/panel-layout.js +83 -39
- package/ui/panel.css +885 -743
- package/ui/panel.html +356 -296
- package/ui/panel.js +739 -865
package/lib/py-bridge.js
CHANGED
|
@@ -3,6 +3,8 @@ import { execFile, spawn } from 'node:child_process'
|
|
|
3
3
|
import { fileURLToPath } from 'node:url'
|
|
4
4
|
import { homedir } from 'node:os'
|
|
5
5
|
import { join } from 'node:path'
|
|
6
|
+
import { embeddingEnv } from './modules/python-env.js'
|
|
7
|
+
import { WorkerUnavailable, callCoreWorker, isWorkerRunning } from './core-worker.js'
|
|
6
8
|
|
|
7
9
|
export const BRIDGE_PATH = fileURLToPath(new URL('./py/bridge.py', import.meta.url))
|
|
8
10
|
export const PACKAGE_ROOT = fileURLToPath(new URL('..', import.meta.url))
|
|
@@ -10,6 +12,35 @@ export const BUNDLED_PYTHON_DIR = join(PACKAGE_ROOT, 'python')
|
|
|
10
12
|
export const DEFAULT_ADAPTER_DIR = join(BUNDLED_PYTHON_DIR, 'dsh_adapter')
|
|
11
13
|
export const BRIDGE_TIMEOUT_MS = 20000
|
|
12
14
|
|
|
15
|
+
let bridgeDataDir = ''
|
|
16
|
+
/** Configure embedding env for all later python subprocesses. */
|
|
17
|
+
export function configureBridge(dataDir) {
|
|
18
|
+
bridgeDataDir = String(dataDir || '').trim()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** task-223: worker first, spawn-per-call only as a fallback. */
|
|
22
|
+
async function workerOrFallback(action, payload) {
|
|
23
|
+
if (isWorkerRunning()) {
|
|
24
|
+
try {
|
|
25
|
+
return await callCoreWorker(action, payload || {})
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (!(error instanceof WorkerUnavailable)) throw error
|
|
28
|
+
try {
|
|
29
|
+
console.error('__bioWorker fallback action=' + String(action)
|
|
30
|
+
+ ' reason=' + String(error.reason || error.message))
|
|
31
|
+
} catch { /* ignore */ }
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return runBridge(['runtime_action', String(action || ''),
|
|
35
|
+
JSON.stringify(payload && typeof payload === 'object' ? payload : {})])
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function bridgeEnv(base) {
|
|
39
|
+
let embedding = {}
|
|
40
|
+
try { embedding = bridgeDataDir ? embeddingEnv(bridgeDataDir) : {} } catch { embedding = {} }
|
|
41
|
+
return Object.assign({}, base, embedding)
|
|
42
|
+
}
|
|
43
|
+
|
|
13
44
|
export function adapterDir() {
|
|
14
45
|
return process.env.BIOCORE_ADAPTER_DIR || DEFAULT_ADAPTER_DIR
|
|
15
46
|
}
|
|
@@ -32,11 +63,11 @@ function runBridge(args, timeoutMs) {
|
|
|
32
63
|
cwd,
|
|
33
64
|
timeout: Number(timeoutMs) || BRIDGE_TIMEOUT_MS,
|
|
34
65
|
maxBuffer: 1024 * 1024,
|
|
35
|
-
env: Object.assign({}, process.env, {
|
|
66
|
+
env: bridgeEnv(Object.assign({}, process.env, {
|
|
36
67
|
BIOCORE_ADAPTER_DIR: cwd,
|
|
37
68
|
BIOCORE_PLUGIN_DIR: pluginDir(),
|
|
38
69
|
PYTHONIOENCODING: 'utf-8',
|
|
39
|
-
}),
|
|
70
|
+
})),
|
|
40
71
|
},
|
|
41
72
|
(error, stdout, stderr) => {
|
|
42
73
|
if (error) {
|
|
@@ -82,11 +113,11 @@ export function compilePersona(profilePath, personaPath, text) {
|
|
|
82
113
|
[BRIDGE_PATH, 'persona_compile', String(profilePath), String(personaPath)],
|
|
83
114
|
{
|
|
84
115
|
cwd,
|
|
85
|
-
env: Object.assign({}, process.env, {
|
|
116
|
+
env: bridgeEnv(Object.assign({}, process.env, {
|
|
86
117
|
BIOCORE_ADAPTER_DIR: cwd,
|
|
87
118
|
BIOCORE_PLUGIN_DIR: pluginDir(),
|
|
88
119
|
PYTHONIOENCODING: 'utf-8',
|
|
89
|
-
}),
|
|
120
|
+
})),
|
|
90
121
|
},
|
|
91
122
|
)
|
|
92
123
|
let stdout = ''
|
|
@@ -129,35 +160,70 @@ export function memoryCapture(storeRoot, sessionId, role, text, config) {
|
|
|
129
160
|
JSON.stringify(config && typeof config === 'object' ? config : {})])
|
|
130
161
|
}
|
|
131
162
|
|
|
132
|
-
export function memoryInject(storeRoot, sessionId, maxChars, topK
|
|
163
|
+
export async function memoryInject(storeRoot, sessionId, maxChars, topK, rerankConfig,
|
|
164
|
+
query, mode) {
|
|
165
|
+
const payload = {
|
|
166
|
+
session_id: String(sessionId || 'default'),
|
|
167
|
+
store: String(storeRoot),
|
|
168
|
+
max_chars: maxChars,
|
|
169
|
+
top_k: topK,
|
|
170
|
+
rerank_config: rerankConfig && typeof rerankConfig === 'object' ? rerankConfig : undefined,
|
|
171
|
+
}
|
|
172
|
+
if (query !== undefined && query !== null && String(query).trim()) {
|
|
173
|
+
payload.query = String(query).slice(0, 2000)
|
|
174
|
+
}
|
|
175
|
+
if (mode !== undefined && mode !== null && String(mode).trim()) {
|
|
176
|
+
payload.mode = String(mode).trim().toLowerCase()
|
|
177
|
+
}
|
|
178
|
+
// Query recall / rerank need the JSON action; the legacy argv form stays for
|
|
179
|
+
// the old 5-argument call so nothing else changes.
|
|
180
|
+
if (payload.rerank_config || payload.query || payload.mode) {
|
|
181
|
+
return workerOrFallback('memory_inject', payload)
|
|
182
|
+
}
|
|
133
183
|
return runBridge(['memory_inject', String(storeRoot), String(sessionId || 'default'),
|
|
134
184
|
maxChars === undefined ? '' : String(maxChars),
|
|
135
185
|
topK === undefined ? '' : String(topK)])
|
|
136
186
|
}
|
|
137
187
|
|
|
138
|
-
export function memoryTool(storeRoot, sessionId, name, args) {
|
|
188
|
+
export async function memoryTool(storeRoot, sessionId, name, args, rerankConfig) {
|
|
189
|
+
const merged = Object.assign({}, args && typeof args === 'object' ? args : {})
|
|
190
|
+
if (rerankConfig && typeof rerankConfig === 'object') merged.rerank_config = rerankConfig
|
|
191
|
+
if (isWorkerRunning()) {
|
|
192
|
+
try {
|
|
193
|
+
return await callCoreWorker('tool', {
|
|
194
|
+
store: String(storeRoot),
|
|
195
|
+
session_id: String(sessionId || 'default'),
|
|
196
|
+
name: String(name || ''),
|
|
197
|
+
args: merged,
|
|
198
|
+
})
|
|
199
|
+
} catch (error) {
|
|
200
|
+
if (!(error instanceof WorkerUnavailable)) throw error
|
|
201
|
+
try { console.error('__bioWorker fallback action=tool reason=' + String(error.reason)) } catch { /* ignore */ }
|
|
202
|
+
}
|
|
203
|
+
}
|
|
139
204
|
return runBridge(['memory_tool', String(storeRoot), String(sessionId || 'default'),
|
|
140
|
-
String(name || ''), JSON.stringify(
|
|
205
|
+
String(name || ''), JSON.stringify(merged)])
|
|
141
206
|
}
|
|
142
207
|
|
|
143
208
|
export function runtimePrompt(payload) {
|
|
144
|
-
return
|
|
145
|
-
JSON.stringify(payload && typeof payload === 'object' ? payload : {})])
|
|
209
|
+
return workerOrFallback('inject', payload)
|
|
146
210
|
}
|
|
147
211
|
|
|
148
212
|
export function runtimeGate(payload) {
|
|
149
|
-
return
|
|
150
|
-
|
|
213
|
+
return workerOrFallback('gate', payload)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/** task-223: whole config arrives once; the core owns every decision. */
|
|
217
|
+
export function configureCore(payload) {
|
|
218
|
+
return workerOrFallback('configure', payload)
|
|
151
219
|
}
|
|
152
220
|
|
|
153
221
|
/** Contract entry for boot/turn_start/turn_end/state/switches_get/switches_set. */
|
|
154
222
|
export function runtimeAction(action, payload) {
|
|
155
|
-
return
|
|
156
|
-
JSON.stringify(payload && typeof payload === 'object' ? payload : {})])
|
|
223
|
+
return workerOrFallback(action, payload)
|
|
157
224
|
}
|
|
158
225
|
|
|
159
226
|
// ---- proactive (task-205): policy lives in biocore_runtime/pipeline.py ----
|
|
160
227
|
export function proactiveTick(payload) {
|
|
161
|
-
return
|
|
162
|
-
JSON.stringify(payload && typeof payload === 'object' ? payload : {})])
|
|
228
|
+
return workerOrFallback('proactive_tick', payload)
|
|
163
229
|
}
|
package/package.json
CHANGED
|
@@ -1,127 +1,138 @@
|
|
|
1
|
-
# -*- coding: utf-8 -*-
|
|
2
|
-
"""All memory-layer thresholds/defaults in one place."""
|
|
3
|
-
from __future__ import annotations
|
|
4
|
-
|
|
5
|
-
SCHEMA_VERSION = 1
|
|
6
|
-
MAX_VERSIONS = 8
|
|
7
|
-
TOMBSTONE_LIMIT = 100
|
|
8
|
-
DEFAULT_BUDGET = 3
|
|
9
|
-
MAX_BUDGET = 5
|
|
10
|
-
|
|
11
|
-
# recall fusion / tiers (M2)
|
|
12
|
-
CUE_WEIGHT = 0.50
|
|
13
|
-
SEM_WEIGHT = 0.30
|
|
14
|
-
IMPORTANCE_WEIGHT = 0.10
|
|
15
|
-
TIME_BONUS = 0.10
|
|
16
|
-
HIGH_TIER = 0.55
|
|
17
|
-
MID_TIER = 0.35
|
|
18
|
-
|
|
19
|
-
# source credibility gate (separate from importance)
|
|
20
|
-
SOURCE_MIN_CONFIDENCE = 0.55
|
|
21
|
-
SOURCE_CONFIDENCE_DEFAULT = 0.70
|
|
22
|
-
|
|
23
|
-
# memory value formula (deterministic; trust is NOT part of value)
|
|
24
|
-
VALUE_BASE = 0.20
|
|
25
|
-
VALUE_W_INTENSITY = 0.30
|
|
26
|
-
VALUE_W_VALENCE = 0.20
|
|
27
|
-
VALUE_W_SELF = 0.15
|
|
28
|
-
VALUE_W_MAINLINE = 0.15
|
|
29
|
-
VALUE_W_ROUTINE = 0.20
|
|
30
|
-
|
|
31
|
-
# eviction weights (read-only score)
|
|
32
|
-
EVICT_W_SALIENCE = 0.30
|
|
33
|
-
EVICT_W_POSITION = 0.20
|
|
34
|
-
EVICT_W_REDUNDANCY = 0.20
|
|
35
|
-
EVICT_W_CONFIDENCE = 0.15
|
|
36
|
-
EVICT_W_STALENESS = 0.15
|
|
37
|
-
|
|
38
|
-
# identity write-back gate
|
|
39
|
-
SAME_DIRECTION_MIN = 3
|
|
40
|
-
MAX_STEP = 0.02
|
|
41
|
-
MAJOR_EVENT_STEP = 0.02
|
|
42
|
-
|
|
43
|
-
# thread card
|
|
44
|
-
THREAD_TTL = 21600.0
|
|
45
|
-
THREAD_LIMIT = 3
|
|
46
|
-
|
|
47
|
-
# memory-point gate (OR): value >= MIN_VALUE or importance >= MIN_IMPORTANCE or self >= MIN_SELF
|
|
48
|
-
# (event centrality / emotional intensity; self-reference effect; engineering thresholds)
|
|
49
|
-
MEMORY_POINT_MIN_VALUE = 0.60
|
|
50
|
-
MEMORY_POINT_MIN_SELF = 0.45
|
|
51
|
-
MEMORY_POINT_MIN_IMPORTANCE = 0.75
|
|
52
|
-
|
|
53
|
-
# engine wiring knobs (all read by MemoryEngine only)
|
|
54
|
-
RATE_LIMIT_PER_MIN = 30
|
|
55
|
-
COMPRESS_MAX_CHARS = 200
|
|
56
|
-
AUDIT_TAIL = 50
|
|
57
|
-
COOC_MAX_ENTRIES = 400
|
|
58
|
-
# after-turn auto consolidation: every N successful remember() calls
|
|
59
|
-
CONSOLIDATE_AUTO_TURNS = 10
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
"
|
|
78
|
-
#
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
#
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
#
|
|
120
|
-
"
|
|
121
|
-
"
|
|
122
|
-
"
|
|
123
|
-
"
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
"""All memory-layer thresholds/defaults in one place."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
SCHEMA_VERSION = 1
|
|
6
|
+
MAX_VERSIONS = 8
|
|
7
|
+
TOMBSTONE_LIMIT = 100
|
|
8
|
+
DEFAULT_BUDGET = 3
|
|
9
|
+
MAX_BUDGET = 5
|
|
10
|
+
|
|
11
|
+
# recall fusion / tiers (M2)
|
|
12
|
+
CUE_WEIGHT = 0.50
|
|
13
|
+
SEM_WEIGHT = 0.30
|
|
14
|
+
IMPORTANCE_WEIGHT = 0.10
|
|
15
|
+
TIME_BONUS = 0.10
|
|
16
|
+
HIGH_TIER = 0.55
|
|
17
|
+
MID_TIER = 0.35
|
|
18
|
+
|
|
19
|
+
# source credibility gate (separate from importance)
|
|
20
|
+
SOURCE_MIN_CONFIDENCE = 0.55
|
|
21
|
+
SOURCE_CONFIDENCE_DEFAULT = 0.70
|
|
22
|
+
|
|
23
|
+
# memory value formula (deterministic; trust is NOT part of value)
|
|
24
|
+
VALUE_BASE = 0.20
|
|
25
|
+
VALUE_W_INTENSITY = 0.30
|
|
26
|
+
VALUE_W_VALENCE = 0.20
|
|
27
|
+
VALUE_W_SELF = 0.15
|
|
28
|
+
VALUE_W_MAINLINE = 0.15
|
|
29
|
+
VALUE_W_ROUTINE = 0.20
|
|
30
|
+
|
|
31
|
+
# eviction weights (read-only score)
|
|
32
|
+
EVICT_W_SALIENCE = 0.30
|
|
33
|
+
EVICT_W_POSITION = 0.20
|
|
34
|
+
EVICT_W_REDUNDANCY = 0.20
|
|
35
|
+
EVICT_W_CONFIDENCE = 0.15
|
|
36
|
+
EVICT_W_STALENESS = 0.15
|
|
37
|
+
|
|
38
|
+
# identity write-back gate
|
|
39
|
+
SAME_DIRECTION_MIN = 3
|
|
40
|
+
MAX_STEP = 0.02
|
|
41
|
+
MAJOR_EVENT_STEP = 0.02
|
|
42
|
+
|
|
43
|
+
# thread card
|
|
44
|
+
THREAD_TTL = 21600.0
|
|
45
|
+
THREAD_LIMIT = 3
|
|
46
|
+
|
|
47
|
+
# memory-point gate (OR): value >= MIN_VALUE or importance >= MIN_IMPORTANCE or self >= MIN_SELF
|
|
48
|
+
# (event centrality / emotional intensity; self-reference effect; engineering thresholds)
|
|
49
|
+
MEMORY_POINT_MIN_VALUE = 0.60
|
|
50
|
+
MEMORY_POINT_MIN_SELF = 0.45
|
|
51
|
+
MEMORY_POINT_MIN_IMPORTANCE = 0.75
|
|
52
|
+
|
|
53
|
+
# engine wiring knobs (all read by MemoryEngine only)
|
|
54
|
+
RATE_LIMIT_PER_MIN = 30
|
|
55
|
+
COMPRESS_MAX_CHARS = 200
|
|
56
|
+
AUDIT_TAIL = 50
|
|
57
|
+
COOC_MAX_ENTRIES = 400
|
|
58
|
+
# after-turn auto consolidation: every N successful remember() calls
|
|
59
|
+
CONSOLIDATE_AUTO_TURNS = 10
|
|
60
|
+
|
|
61
|
+
# recall -> affect feedback (task-218): a recalled memory nudges the live
|
|
62
|
+
# affect a little. Engine owns the state; recall/feedback.py owns the guards.
|
|
63
|
+
FEEDBACK_MAX_STEP = 0.02 # per-turn cap on |delta valence| and |delta arousal|
|
|
64
|
+
FEEDBACK_GAIN = 0.50 # share of (recalled - current) that flows back
|
|
65
|
+
FEEDBACK_COOLDOWN = 1800.0 # same entry: no second feedback inside 30 minutes
|
|
66
|
+
FEEDBACK_NEG_FLOOR = -0.40 # at/below this valence a further negative pull is dropped
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# Per-mechanism flags: safety/read-path filters default ON; every optional
|
|
70
|
+
# mechanism defaults OFF and must keep the old code path when disabled.
|
|
71
|
+
# A flags.json in the data directory overrides these booleans at engine start
|
|
72
|
+
# (and MemoryEngine.set_flags(..., persist=True) rewrites it).
|
|
73
|
+
FLAGS = {
|
|
74
|
+
# safety / read-path (default ON)
|
|
75
|
+
# GA-03: keep engine default ON. DSH private mode disables it per-store via
|
|
76
|
+
# <dsh store>/flags.json; the shared engine must not be relaxed globally.
|
|
77
|
+
"security": True, # store/security.should_reject before write
|
|
78
|
+
"provenance": True, # provenance hash tag + chained tombstones
|
|
79
|
+
"source_filter": True, # low-confidence candidates are counted/dropped
|
|
80
|
+
"temporal_filter": True, # honour valid_at/invalid_at on recall
|
|
81
|
+
"dedupe": True, # remember-side L0-L3 dedupe
|
|
82
|
+
"relay": True, # relay card
|
|
83
|
+
"thread": True, # thread card / TTL expiry
|
|
84
|
+
"embedding": True, # optional embedding provider
|
|
85
|
+
# attention / model features (default OFF)
|
|
86
|
+
"slots": False,
|
|
87
|
+
"boundary": False, # slots/boundary.py event-boundary switching
|
|
88
|
+
"three_channel": False,
|
|
89
|
+
"eviction_readonly": False,
|
|
90
|
+
"identity": False,
|
|
91
|
+
"identity_writeback": False,
|
|
92
|
+
"due_hints": False,
|
|
93
|
+
# recall extensions (default OFF)
|
|
94
|
+
"bm25": False,
|
|
95
|
+
"bm25_multi": False,
|
|
96
|
+
"ppr": False,
|
|
97
|
+
"mmr": False,
|
|
98
|
+
"mood_recall": False,
|
|
99
|
+
"affect_encoding": False,
|
|
100
|
+
"memory_feedback": False, # task-218: recalled affect nudges the live affect
|
|
101
|
+
"preference_drift": False, # task-219: repeated topics drift value_order weights
|
|
102
|
+
"complexity": False,
|
|
103
|
+
"constraints": False,
|
|
104
|
+
"tiering": False,
|
|
105
|
+
"entity_boost": False,
|
|
106
|
+
"inhibition": False,
|
|
107
|
+
"retrieval_practice": False,
|
|
108
|
+
"compress": False, # output-only summary, never mutates the store
|
|
109
|
+
"source_consistency": False, # source-rank marking/downweight on recall
|
|
110
|
+
# eviction extension modules (default OFF)
|
|
111
|
+
"heat": False,
|
|
112
|
+
"consequence": False,
|
|
113
|
+
"tiering_exec": False,
|
|
114
|
+
"apply_evictions": False, # tick() may really soft-delete archived entries
|
|
115
|
+
"deletion_audit": False, # derived-data coverage audit after forget()
|
|
116
|
+
"adaptive_evict": False, # adaptive_score replaces the tick eviction score
|
|
117
|
+
|
|
118
|
+
# write-path extensions (default OFF)
|
|
119
|
+
"consistency": False, # old/new fact conflict annotation on remember
|
|
120
|
+
"rate_limit": False,
|
|
121
|
+
"audit": False,
|
|
122
|
+
"permissions": False,
|
|
123
|
+
"notes": False,
|
|
124
|
+
"media": False,
|
|
125
|
+
"notes_link": False,
|
|
126
|
+
"ledger": False,
|
|
127
|
+
# index / graph
|
|
128
|
+
"graph": False,
|
|
129
|
+
"cue_writeback": True, # store cue_index fields on each new entry (index-only, no recall change)
|
|
130
|
+
# consolidation modules (default OFF)
|
|
131
|
+
"consolidate_auto": False, # after-turn auto consolidate every CONSOLIDATE_AUTO_TURNS remembers
|
|
132
|
+
"consolidate_gated": False,
|
|
133
|
+
"consolidate_tree": False,
|
|
134
|
+
"consolidate_reflection": False,
|
|
135
|
+
"consolidate_neighbors": False,
|
|
136
|
+
"consolidate_writeback": False,
|
|
137
|
+
"narrative": False, # identity narrative update at consolidate end
|
|
138
|
+
}
|