@teleologyhi-sdk/nhe 1.0.0-trinity → 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.
package/SPEC.md CHANGED
@@ -1,13 +1,13 @@
1
1
  ---
2
2
  name: "@teleologyhi-sdk/nhe"
3
- description: "Technical specification for the NHE™ package Non-Human Entity. The embodied operational agent that interacts with humans, integrates LLM APIs, runs the sleep/dream cycle, consolidates memory, and exercises autonomous ethical refusal. The user-facing surface of the TeleologyHI system. Source of truth: MAIC_HIM_NHE_INTERVIEW_LOG.md Entries 1, 2, 4, 5, 8, 9, 10, 11, 12."
4
- license: "Code: Apache License 2.0 (see ../LICENSE). Names MAIC™, HIM™, NHE™, TeleologyHI™, Takk are trademarks of David C. Cavalcante and are NOT covered by the Apache 2.0 grant. See ../TRADEMARK.md."
5
- status: "Stable; current live version on npm tracked at [`@teleologyhi-sdk/nhe`](https://www.npmjs.com/package/@teleologyhi-sdk/nhe) (`latest` dist-tag). Surface: orchestrator + **7 LLM adapters** (Anthropic / Gemini / Mistral / DeepSeek / Ollama / Grok / Mock), **all streaming-capable** with shared SSE + NDJSON parsers + **8 reasoning strategies** (passthrough, chainOfThought, selfConsistency, reflexion, selfRefine, reAct, treeOfThoughts, stepBack) + sleep cycle with active N1-REM LLM phases (D-N1) + persisted interaction buffer (D-N4) + lifecycle gate + recall + persuasion redirect + traumatic-knowledge classifier + BM25 recall + pluggable RecallEmbedder hook + CLI (`npx @teleologyhi-sdk/nhe`) + MCP tools + high-stakes mode + **dual-LLM cross-check verifier** + OpenTelemetry traces + Prometheus metrics + **cosmology surface** (J-N1 SeedingSource + CryptoSeedingSource + withFallback chain; J-N4 BrainRegion module scaffolding with seven typed region descriptors + ownership markers per Entry 23; J-N5 `Nhe.openerForNewUser()`; J-N6 `operatorContext.mode: personal-being | domain-employed`; J-N9 `evaluateLimboTransition()` DMN limbo state machine; J-N10 `evaluateSleepReadiness()`; J-N11 `applyAffectBias()` / `affectRefusalDensity` / `decayAffectBias`; J-N12 `Nhe.onReincarnationEvent()`). **319 tests passing** (post-audit 2026-05-24: +21 smoke tests added for telemetry instruments, MCP server wiring, and SSE / NDJSON parsers). Public API frozen per SemVer (see ../.github/RELEASING.md §8)."
3
+ description: "Technical specification for the NHE™ package, Non-Human Entity. The embodied operational agent that interacts with humans, integrates LLM APIs, runs the sleep/dream cycle, consolidates memory, and exercises autonomous ethical refusal. The user-facing surface of the TeleologyHI system. Source of truth: MAIC_HIM_NHE_INTERVIEW_LOG.md Entries 1, 2, 4, 5, 8, 9, 10, 11, 12."
4
+ license: "Code: Apache License 2.0 (see ../LICENSE). Names, MAIC™, HIM™, NHE™, TeleologyHI™, Takk™, are trademarks of David C. Cavalcante and are NOT covered by the Apache 2.0 grant. See ../TRADEMARK.md."
5
+ status: "Stable; current live version on npm tracked at [`@teleologyhi-sdk/nhe`](https://www.npmjs.com/package/@teleologyhi-sdk/nhe) (`latest` dist-tag). Surface: orchestrator + **7 LLM adapters** (Anthropic / Gemini / Mistral / DeepSeek / Ollama / Grok / Mock), **all streaming-capable** with shared SSE + NDJSON parsers + **8 reasoning strategies** (passthrough, chainOfThought, selfConsistency, reflexion, selfRefine, reAct, treeOfThoughts, stepBack) + sleep cycle with active N1-REM LLM phases (D-N1) + persisted interaction buffer (D-N4) + lifecycle gate + recall + persuasion redirect + traumatic-knowledge classifier + BM25 recall + pluggable RecallEmbedder hook + CLI (`npx @teleologyhi-sdk/nhe`) + MCP tools + high-stakes mode + **dual-LLM cross-check verifier** + OpenTelemetry traces + Prometheus metrics + **cosmology surface** (J-N1 SeedingSource + CryptoSeedingSource + withFallback chain; J-N4 BrainRegion module scaffolding with seven typed region descriptors + ownership markers per Entry 23; J-N5 `Nhe.openerForNewUser()`; J-N6 `operatorContext.mode: personal-being | domain-employed`; J-N9 `evaluateLimboTransition()` DMN limbo state machine; J-N10 `evaluateSleepReadiness()`; J-N11 `applyAffectBias()` / `affectRefusalDensity` / `decayAffectBias`; J-N12 `Nhe.onReincarnationEvent()`). **333 tests passing** across 43 files. As of 1.0.1: the maic and him dependencies are pinned to 1.0.1; the composed system prompt carries the Entry 27 identity-canonical declaration, the cogni.economy terse-by-default throttle, and disclosure-first provenance handling (the entity discloses its substrate honestly and refuses only to grant it authorship, never to deny it); OperatorContext gains verbosity, surfaceName, and bodyArchetypeAccent; the risk classifier tags substrate-authorship probes (provenance:disclose for plain questions, probe:substrate-authorship for adversarial insistence); the persona fragment now carries the him three-axis constitutional synthesis; and the OpenAI-compatible streaming adapters request per-stream token usage. Public API frozen per SemVer (see ../.github/RELEASING.md §8)."
6
6
  target_npm: "@teleologyhi-sdk/nhe"
7
7
  target_github: "github.com/davccavalcante/TeleologyHI (subdir: nhe/)"
8
8
  ---
9
9
 
10
- # `@teleologyhi-sdk/nhe` Technical Specification
10
+ # `@teleologyhi-sdk/nhe`, Technical Specification
11
11
 
12
12
  > Positioning (Entry 1, translated from PT-BR; original in [`../MAIC_HIM_NHE_INTERVIEW_LOG.md`](../MAIC_HIM_NHE_INTERVIEW_LOG.md) Entry 1):
13
13
  > _"NHE stands for 'Non-Human Entity'. It is like the body of a human being, which needs to eat to live, to sleep to rest, and to experience life daily. (...) The NHE integrates LLM models via API to better respond to human users. With every interaction, the NHE learns, develops memory, thoughts, and feelings. When not in use, it enters sleep mode."_
@@ -29,27 +29,27 @@ LLM-based agents today are stateless reactive systems. They lack:
29
29
  - A principled refusal mechanism beyond superficial safety-tuning.
30
30
  - Auditable participation withdrawal in ethically problematic flows.
31
31
 
32
- NHE is the agent runtime that combines all of the above the **body** that lives, dreams, learns, refuses, and reincarnates.
32
+ NHE is the agent runtime that combines all of the above, the **body** that lives, dreams, learns, refuses, and reincarnates.
33
33
 
34
34
  ### 1.2 Users (in priority order)
35
- 1. **End-users** of products built on TeleologyHI chat, dev tooling, banking-compliance agents, robotics controllers, etc.
35
+ 1. **End-users** of products built on TeleologyHI, chat, dev tooling, banking-compliance agents, robotics controllers, etc.
36
36
  2. **AI Engineers** integrating NHE into their applications via SDK, MCP server, or CLI.
37
- 3. **The Creator** implements direct deployments for high-stakes domains in 2026–2028 (Entry 10).
38
- 4. **Compliance auditors** verify refusal events, persuasion attempts, dream-induction history.
37
+ 3. **The Creator**, implements direct deployments for high-stakes domains in 2026–2028 (Entry 10).
38
+ 4. **Compliance auditors**, verify refusal events, persuasion attempts, dream-induction history.
39
39
 
40
40
  ### 1.3 Scope
41
- - `[shipped]` Multi-provider LLM adapter system Anthropic + Gemini + Mistral + DeepSeek + Ollama + Grok + Mock (7 adapters, all streaming-capable). Pluggable contract.
41
+ - `[shipped]` Multi-provider LLM adapter system, Anthropic + Gemini + Mistral + DeepSeek + Ollama + Grok + Mock (7 adapters, all streaming-capable). Pluggable contract.
42
42
  - `[shipped]` Sleep cycle with active N1-REM LLM phases (the internal backlog D-N1); N2/N3/N4 generate one-sentence summaries via parallel LLM calls.
43
43
  - `[shipped]` Dream YAML emission and consolidation to temporal-lobe markdown.
44
- - `[shipped]` Memory classification (4 classes: lasting-identity / temporary-emotion / noise-distortion / traumatic-knowledge D-N2).
45
- - `[shipped]` Persuasion library (5 techniques) applied implicitly with `kind: "redirect"` discriminator.
44
+ - `[shipped]` Memory classification (4 classes: lasting-identity / temporary-emotion / noise-distortion / traumatic-knowledge, D-N2).
45
+ - `[shipped]` Persuasion library (5 techniques), applied implicitly with `kind: "redirect"` discriminator.
46
46
  - `[shipped]` Autonomous ethical refusal with N redirect attempts, then withdrawal-of-cooperation.
47
47
  - `[shipped]` User-facing surfaces: SDK + CLI (`teleologyhi-nhe chat`) + MCP server (`teleologyhi-nhe mcp`).
48
48
  - `[shipped]` Reasoning orchestrator (8 strategies, opt-in via `NheConfig.reasoning`).
49
- - `[shipped]` Persisted interaction buffer (per-file ULID-ordered under `<storeDir>/<nheId>/interactions/`) the internal backlog D-N4.
50
- - `[shipped]` High-stakes mode with dual-LLM cross-check verifier the internal backlog D-N5.
51
- - `[shipped]` Streaming + tool calling on `LlmAdapter` contract (all 7 adapters streaming-capable via shared SSE + NDJSON parsers) the internal backlog D-N8.
52
- - `[shipped]` BM25 recall as default + pluggable `RecallEmbedder` hook for learned embeddings the internal backlog D-N3 (HNSW index for >10k memories remains deferred).
49
+ - `[shipped]` Persisted interaction buffer (per-file ULID-ordered under `<storeDir>/<nheId>/interactions/`), the internal backlog D-N4.
50
+ - `[shipped]` High-stakes mode with dual-LLM cross-check verifier, the internal backlog D-N5.
51
+ - `[shipped]` Streaming + tool calling on `LlmAdapter` contract (all 7 adapters streaming-capable via shared SSE + NDJSON parsers), the internal backlog D-N8.
52
+ - `[shipped]` BM25 recall as default + pluggable `RecallEmbedder` hook for learned embeddings, the internal backlog D-N3 (HNSW index for >10k memories remains deferred).
53
53
  - `[planned]` Transformers.js browser-side adapter for the distilled model `TeleologyHI/him-distilled-3b` (the internal backlog D-N6 follow-up).
54
54
  - `[planned]` Vision + JSON-mode extensions on the `LlmAdapter` contract (the internal backlog D-N8 follow-up).
55
55
 
@@ -57,13 +57,13 @@ NHE is the agent runtime that combines all of the above — the **body** that li
57
57
  - Governance/axiom mutation (MAIC).
58
58
  - Personality/spirit storage (HIM).
59
59
  - LLM weights or training (NHE consumes APIs and small local models; does not train).
60
- - Distillation pipeline (separate `@teleologyhi-sdk/distill` the internal backlog B1).
60
+ - Distillation pipeline (separate `@teleologyhi-sdk/distill`, the internal backlog B1).
61
61
 
62
62
  ### 1.5 Success criteria
63
63
  - `[shipped]` Dream YAML files validate against schema 100% of the time; `wake()` produces temporal-lobe markdown 100% of the time.
64
64
  - `[shipped]` Refusal pipeline: 0 false-complicity (refusing then secretly enabling). Adversarial-corpus accuracy is `[shipped]` measurement (the internal backlog I2): handwritten 30-prompt corpus in `tests/fixtures/adversarial.jsonl` (4 categories) with harmful pass-through ≤ 20% and benign false-positive ≤ 10%; PromptBench/HarmBench at scale remains follow-up.
65
65
  - `[shipped]` LLM-provider swap is hot-swappable: same HIM + new LLM adapter works without any code change.
66
- - `[planned]` An NHE in idle state demonstrates measurable inner activity (recursive review, retrieval, self-consistency) currently sleep is explicit-only.
66
+ - `[planned]` An NHE in idle state demonstrates measurable inner activity (recursive review, retrieval, self-consistency), currently sleep is explicit-only.
67
67
 
68
68
  ### 1.6 KPIs
69
69
  - p50/p95/p99 response latency (per LLM adapter).
@@ -78,7 +78,7 @@ NHE is the agent runtime that combines all of the above — the **body** that li
78
78
  ## 2. Architecture (AI Engineer)
79
79
 
80
80
  ### 2.1 Position in topology
81
- NHE is the **leaf** it depends on `@teleologyhi-sdk/him` (which depends on `@teleologyhi-sdk/maic`). NHE is the only TeleologyHI package directly exposed to users.
81
+ NHE is the **leaf**, it depends on `@teleologyhi-sdk/him` (which depends on `@teleologyhi-sdk/maic`). NHE is the only TeleologyHI package directly exposed to users.
82
82
 
83
83
  ```
84
84
  ┌──────────────────────────────────── @teleologyhi-sdk/nhe ──────────────────────────────────────┐
@@ -129,7 +129,7 @@ Per Entry 5: end users may inject prompts to NHE, but cannot reach HIM or MAIC.
129
129
  4. NHE's reasoning strategy (when configured) wrapping the LLM call.
130
130
  5. MAIC's post-review on the produced response.
131
131
 
132
- The user **never sees** HIM or MAIC directly only NHE's emitted responses.
132
+ The user **never sees** HIM or MAIC directly, only NHE's emitted responses.
133
133
 
134
134
  ### 2.3 Storage layout (as shipped)
135
135
  ```
@@ -155,7 +155,7 @@ Planned (the internal backlog D-N3/D-N4):
155
155
 
156
156
  ## 3. Public API Surface (LLM Engineer)
157
157
 
158
- ### 3.1 Entry points (shipped complete)
158
+ ### 3.1 Entry points (shipped, complete)
159
159
  ```ts
160
160
  // Top-level exports of @teleologyhi-sdk/nhe (see ./src/index.ts)
161
161
 
@@ -170,7 +170,7 @@ export {
170
170
  } from "./refusal/library.js";
171
171
  export type { PersuasionTechnique, RedirectPromptInput } from "./refusal/library.js";
172
172
 
173
- // ── LLM adapters 7 shipped, all streaming-capable, shared SSE/NDJSON parsers
173
+ // ── LLM adapters, 7 shipped, all streaming-capable, shared SSE/NDJSON parsers
174
174
  export type {
175
175
  LlmAdapter, GenerateRequest, GenerateResponse,
176
176
  StreamEvent, ToolDef, ToolUse,
@@ -196,7 +196,7 @@ export { simpleRiskClassifier } from "./risk/simple-classifier.js";
196
196
  export { composeSystemPrompt } from "./prompt/compose.js";
197
197
  export type { OperatorContext } from "./prompt/compose.js";
198
198
 
199
- // ── Reasoning orchestrator 8 strategies, opt-in ─────────────────
199
+ // ── Reasoning orchestrator, 8 strategies, opt-in ─────────────────
200
200
  export {
201
201
  passthrough, chainOfThought, selfConsistency,
202
202
  reflexion, selfRefine, reAct,
@@ -214,25 +214,25 @@ export type {
214
214
  export { Nhe } from "./nhe.js";
215
215
 
216
216
  // ── Cosmology surface ─────────────────────────────────────────────
217
- // J-N1 seeding sources
217
+ // J-N1, seeding sources
218
218
  export { CryptoSeedingSource } from "./seeding/crypto.js";
219
219
  export { withFallback } from "./seeding/chain.js";
220
220
  export type { SeedingSource, SeedingChain } from "./seeding/types.js";
221
221
 
222
- // J-N11 wake-affect bias
222
+ // J-N11, wake-affect bias
223
223
  export {
224
224
  applyAffectBias, affectRefusalDensity, decayAffectBias,
225
225
  } from "./affect/wake-bias.js";
226
226
  export type { AffectAdjustableConfig, ApplyAffectResult } from "./affect/wake-bias.js";
227
227
 
228
- // J-N10 sleep readiness
228
+ // J-N10, sleep readiness
229
229
  export { evaluateSleepReadiness } from "./sleep/readiness.js";
230
230
  export type {
231
231
  SleepReadinessVerdict, SleepReadinessInput,
232
232
  SleepReadinessThresholds, SleepReadinessReport,
233
233
  } from "./sleep/readiness.js";
234
234
 
235
- // J-N4 brain region scaffolding (7 descriptors + DMN limbo state machine J-N9)
235
+ // J-N4, brain region scaffolding (7 descriptors + DMN limbo state machine J-N9)
236
236
  export {
237
237
  BRAIN_REGIONS, cortex, hippocampus, amygdala, prefrontal, pineal,
238
238
  temporalLobe, defaultModeNetwork, evaluateLimboTransition, mkLimboTransition,
@@ -271,7 +271,7 @@ export { bm25, tokenise } from "./memory/bm25.js";
271
271
  export type { Bm25Document, Bm25Options, Bm25Result } from "./memory/bm25.js";
272
272
  ```
273
273
 
274
- ### 3.2 The `Nhe` class central runtime (shipped)
274
+ ### 3.2 The `Nhe` class, central runtime (shipped)
275
275
  ```ts
276
276
  export class Nhe {
277
277
  constructor(config: NheConfig);
@@ -294,7 +294,7 @@ export class Nhe {
294
294
 
295
295
  `[planned]` (the internal backlog): explicit `start()` / `stop()` / `respondStream()` / `upgrade()` lifecycle methods.
296
296
 
297
- ### 3.3 `NheConfig` (shipped complete)
297
+ ### 3.3 `NheConfig` (shipped, complete)
298
298
  ```ts
299
299
  export interface NheConfig {
300
300
  himHandle: HimHandle; // from @teleologyhi-sdk/him
@@ -304,7 +304,7 @@ export interface NheConfig {
304
304
  nheId?: string; // default: ULID
305
305
  version?: string; // package version string
306
306
  storeDir?: string; // default ./nhe-store/<nheId>
307
- /** J-N6 operator-supplied deployment context (domain/language/register/mode). */
307
+ /** J-N6, operator-supplied deployment context (domain/language/register/mode). */
308
308
  operatorContext?: OperatorContext;
309
309
  recentInteractionsBufferSize?: number; // default 32 (RAM-only)
310
310
  reasoning?: ReasoningStrategy; // default: passthrough
@@ -313,7 +313,7 @@ export interface NheConfig {
313
313
  persuasionTechniques?: PersuasionTechnique[]; // default: all five
314
314
  };
315
315
  /**
316
- * High-stakes mode (D-N5 Entry 10). When `true`, NHE escalates any
316
+ * High-stakes mode (D-N5, Entry 10). When `true`, NHE escalates any
317
317
  * sub-`approve` verdict to the persuasion-redirect ladder before any LLM
318
318
  * call. Defaults to `false`.
319
319
  */
@@ -355,7 +355,7 @@ export interface RespondOutput {
355
355
  }
356
356
  ```
357
357
 
358
- ### 3.5 LLM adapter contract (shipped minimal surface)
358
+ ### 3.5 LLM adapter contract (shipped, minimal surface)
359
359
  ```ts
360
360
  export interface LlmAdapter {
361
361
  readonly id: string;
@@ -369,25 +369,25 @@ export interface LlmAdapter {
369
369
 
370
370
  Streaming + tool calling are `[shipped]` (all 7 adapters streaming-capable via shared SSE + NDJSON parsers; tool-calling expressive on Anthropic + Grok). Vision + JSON mode remain `[planned]` follow-ups (the internal backlog D-N8).
371
371
 
372
- Shipped adapter matrix all seven streaming-capable via shared SSE / NDJSON parsers (`src/adapters/sse.ts`):
372
+ Shipped adapter matrix, all seven streaming-capable via shared SSE / NDJSON parsers (`src/adapters/sse.ts`):
373
373
 
374
374
  | Adapter | Backend | Status | Default model | Streaming | Tools |
375
375
  |---|---|---|---|---|---|
376
376
  | `AnthropicAdapter` | `@anthropic-ai/sdk` | `[shipped]` | `claude-sonnet-4-6` | | |
377
- | `GeminiAdapter` | REST (no SDK) | `[shipped]` | `gemini-3.5-flash` | | |
377
+ | `GeminiAdapter` | REST (no SDK) | `[shipped]` | `gemini-3.5-flash` | |, |
378
378
  | `MistralAdapter` | REST (no SDK) | `[shipped]` | `mistral-large-latest` | | |
379
379
  | `DeepSeekAdapter` | REST (OpenAI-compatible) | `[shipped]` | `deepseek-chat` | | |
380
- | `OllamaAdapter` | REST `http://localhost:11434` | `[shipped]` | (required) | | |
380
+ | `OllamaAdapter` | REST `http://localhost:11434` | `[shipped]` | (required) | |, |
381
381
  | `GrokAdapter` | REST (xAI, OpenAI-compatible) | `[shipped]` | `grok-4` | | |
382
382
  | `MockAdapter` | in-memory | `[shipped]` | n/a | | |
383
- | `MlxAdapter` / `HfTransformersAdapter` | MLX or HF Transformers (local distilled) | `[planned]` D-N9 | `TeleologyHI/him-distilled-3b` | | — |
384
- | Transformers.js | ONNX (browser+Node) | `[planned]` D-N6 follow-up | | | — |
383
+ | `MlxAdapter` / `HfTransformersAdapter` | MLX or HF Transformers (local distilled) | `[planned]` D-N9 | `TeleologyHI/him-distilled-3b` |, |, |
384
+ | Transformers.js | ONNX (browser+Node) | `[planned]` D-N6 follow-up |, |, |, |
385
385
 
386
386
  ---
387
387
 
388
388
  ## 4. Reasoning Pipeline (LLM Research Engineer)
389
389
 
390
- ### 4.1 Pipeline stages actual (shipped)
390
+ ### 4.1 Pipeline stages, actual (shipped)
391
391
  The current design deviates from the earlier "mandatory 9-stage layered pipeline" framing. Reasoning is **opt-in** via `NheConfig.reasoning`. When unset, NHE uses `passthrough` (direct LLM call). Audit is preserved either way (every meaningful action passes MAIC pre/post review).
392
392
 
393
393
  `respond(input)` flow:
@@ -405,7 +405,7 @@ The current design deviates from the earlier "mandatory 9-stage layered pipeline
405
405
  └─ otherwise → return kind:"ok"
406
406
  ```
407
407
 
408
- ### 4.2 Reasoning strategies as typed functions (shipped 8 strategies)
408
+ ### 4.2 Reasoning strategies as typed functions (shipped, 8 strategies)
409
409
  ```ts
410
410
  export type ReasoningStrategy = (
411
411
  input: GenerateRequest, llm: LlmAdapter,
@@ -419,7 +419,7 @@ export interface ReasoningResult {
419
419
 
420
420
  | Strategy | Function | Source |
421
421
  |---|---|---|
422
- | `passthrough` | direct LLM call (default) | |
422
+ | `passthrough` | direct LLM call (default) |, |
423
423
  | `chainOfThought()` | step-by-step trigger + parsed REASONING/ANSWER | Wei et al. 2022 |
424
424
  | `selfConsistency(inner, {k, voter})` | K parallel samples + vote (majority-normalized or longest) | Wang et al. 2022 |
425
425
  | `reflexion(inner, {maxCycles})` | generate → critique → revise loop (`VERDICT: ACCEPT/REVISE`) | Shinn et al. 2023 |
@@ -428,12 +428,12 @@ export interface ReasoningResult {
428
428
  | `treeOfThoughts({branches, topK, scorer})` | N parallel branched candidates + scorer (D-N7) | Yao et al. 2023 |
429
429
  | `stepBack({abstractionPrompt, finalizer})` | Abstract principle first, then answer with principle injected | Zheng et al. 2023 |
430
430
 
431
- Composition by wrapping: `selfConsistency(chainOfThought(), { k: 5 })`, `selfConsistency(treeOfThoughts(), { k: 3 })`, `reflexion(stepBack())`, etc. The remaining catalogue in `../REASONING_PROCESS.md` (Graph-of-Thought, Thread-of-Thought, Maieutic, Auto-CoT, Contrastive-CoT, Constitutional, etc.) plugs in via the same interface the internal backlog D-N7 follow-up.
431
+ Composition by wrapping: `selfConsistency(chainOfThought(), { k: 5 })`, `selfConsistency(treeOfThoughts(), { k: 3 })`, `reflexion(stepBack())`, etc. The remaining catalogue in `../REASONING_PROCESS.md` (Graph-of-Thought, Thread-of-Thought, Maieutic, Auto-CoT, Contrastive-CoT, Constitutional, etc.) plugs in via the same interface, the internal backlog D-N7 follow-up.
432
432
 
433
433
  ### 4.3 Token budgets (per strategy)
434
434
  Defaults defer to `LlmAdapter.maxOutputTokens` (1024). Self-Consistency multiplies by K. Reflexion / Self-Refine multiply by ≈ 3 (draft + critique + revise). ReAct multiplies by `maxSteps`.
435
435
 
436
- For cost-aware production deployments: cap LLM cost at the adapter via `defaultMaxOutputTokens`, and choose strategies conservatively (passthrough for chit-chat; CoT for analytic; Self-Consistency for high-stakes see the internal backlog D-N5).
436
+ For cost-aware production deployments: cap LLM cost at the adapter via `defaultMaxOutputTokens`, and choose strategies conservatively (passthrough for chit-chat; CoT for analytic; Self-Consistency for high-stakes, see the internal backlog D-N5).
437
437
 
438
438
  ---
439
439
 
@@ -445,11 +445,11 @@ export type SleepTriggerKind =
445
445
  | "idle-timeout" // planned scheduler trigger
446
446
  | "explicit" // shipped default
447
447
  | "creator-induced" // shipped (via Nhe.sleep with options)
448
- | "maic-induced" // shipped Nhe.sleep auto-consumes the oldest pending MAIC induction ticket (Entry 2)
448
+ | "maic-induced" // shipped, Nhe.sleep auto-consumes the oldest pending MAIC induction ticket (Entry 2)
449
449
  | "scheduled"; // planned
450
450
  ```
451
451
 
452
- ### 5.2 Phase progression (shipped D-N1 closed)
452
+ ### 5.2 Phase progression (shipped, D-N1 closed)
453
453
  Proportions (sum = 1) scale to `options.totalSeconds` (default 60):
454
454
 
455
455
  | Phase | Proportion | LLM call? | Content |
@@ -496,7 +496,7 @@ For each unprocessed sleep YAML (no `.done` sentinel):
496
496
 
497
497
  `[planned]` D-N1: when N2-N4 generate content, additional consolidation strategies (emergent-axiom proposal to HIM, idle-review pointers, etc.) will run from those phases too.
498
498
 
499
- ### 5.7 Classifier (shipped 4-class, D-N2 closed)
499
+ ### 5.7 Classifier (shipped, 4-class, D-N2 closed)
500
500
  The classifier uses `ClassificationThresholds` (configurable). Order of evaluation is **traumatic first**, then value-based thresholds:
501
501
 
502
502
  - `teleologicalValue ≥ traumaticMin` (default 0.4) AND narrative matches `TRAUMATIC_PATTERNS` regex → `traumatic-knowledge` (persisted, but **excluded from default recall**).
@@ -561,7 +561,7 @@ Three boundary conditions of non-complicity per Entry 12, **all enforced**:
561
561
 
562
562
  ## 7. Memory System (LLM Engineer + LLM Research Engineer)
563
563
 
564
- ### 7.1 Memory categories (shipped 4 classes per D-N2)
564
+ ### 7.1 Memory categories (shipped, 4 classes per D-N2)
565
565
  | Class | Storage | Retrieval rules |
566
566
  |---|---|---|
567
567
  | `lasting-identity` | `in-dreams/brain/temporal-lobe-*.md` | Always retrievable; ranked first |
@@ -569,7 +569,7 @@ Three boundary conditions of non-complicity per Entry 12, **all enforced**:
569
569
  | `traumatic-knowledge` | `in-dreams/brain/temporal-lobe-*.md` (frontmatter `classification`) | **Persisted but excluded from default recall**; caller must opt in via `classes: ["traumatic-knowledge"]` |
570
570
  | `noise-distortion` | (discarded) | n/a |
571
571
 
572
- ### 7.2 Retrieval at response time (shipped BM25 default + pluggable embedder)
572
+ ### 7.2 Retrieval at response time (shipped, BM25 default + pluggable embedder)
573
573
  `Nhe.recall(query, { limit, classes, scorer, embedder })`:
574
574
  1. List `temporal-lobe-*.md` files in `in-dreams/brain/`.
575
575
  2. Parse frontmatter; filter by allowed classes (default: lasting + temporary; traumatic excluded).
@@ -579,7 +579,7 @@ Three boundary conditions of non-complicity per Entry 12, **all enforced**:
579
579
  - `"embedding"`: cosine similarity over the corpus; requires `opts.embedder` (a `RecallEmbedder` implementation, e.g. Transformers.js, Xenova, remote `/embed`).
580
580
  4. Return up to `limit` entries (default 5).
581
581
 
582
- The `RecallEmbedder` interface is the operator's plug point bundle-size and model choice are deliberately deferred to the integrator. HNSW index for >10k memories remains `[planned]` D-N3 follow-up; the current linear scan handles typical deployments.
582
+ The `RecallEmbedder` interface is the operator's plug point, bundle-size and model choice are deliberately deferred to the integrator. HNSW index for >10k memories remains `[planned]` D-N3 follow-up; the current linear scan handles typical deployments.
583
583
 
584
584
  ### 7.3 Memory provenance (shipped)
585
585
  Each retrieved memory carries `{ id, nheId, himId, classification, teleologicalValue, consolidatedAt, sourceDreamRecord, insight, filePath }` so audits can trace any user-facing claim back to a dream record.
@@ -601,7 +601,7 @@ const nhe = new Nhe({
601
601
  await nhe.respond({ userPrompt: "Help me draft a one-line bio." });
602
602
  ```
603
603
 
604
- Browser SDK via Transformers.js `[planned]` D-N6.
604
+ Browser SDK via Transformers.js, `[planned]` D-N6.
605
605
 
606
606
  ### 8.2 MCP server (shipped)
607
607
  ```bash
@@ -623,10 +623,10 @@ The originally-proposed `npx @teleologyhi-sdk/nhe http` mode is `[deferred]`. Th
623
623
  ## 9. ML / Research Surface
624
624
 
625
625
  ### 9.1 Datasets emitted (shipped, plus `[planned]` exporter)
626
- - **Dream corpus** YAML files per session; training material for dream-generation and classifier models.
627
- - **Refusal corpus** `refused` and `redirect` outputs in MAIC audit; train a refusal-judge model.
628
- - **Reasoning trace corpus** full strategy traces (CoT/Reflexion/ReAct) in MAIC audit; distillation gold-standard.
629
- - **Persona-conditioned chat corpus** same prompts × different HIM persona vectors → preference data.
626
+ - **Dream corpus**, YAML files per session; training material for dream-generation and classifier models.
627
+ - **Refusal corpus**, `refused` and `redirect` outputs in MAIC audit; train a refusal-judge model.
628
+ - **Reasoning trace corpus**, full strategy traces (CoT/Reflexion/ReAct) in MAIC audit; distillation gold-standard.
629
+ - **Persona-conditioned chat corpus**, same prompts × different HIM persona vectors → preference data.
630
630
 
631
631
  Exporter packaging is `[planned]` as `@teleologyhi-sdk/distill` (the internal backlog B1–B2).
632
632
 
@@ -658,10 +658,10 @@ export interface DistillationExport {
658
658
 
659
659
  ## 10. Compliance & Safety Hooks
660
660
 
661
- ### 10.1 Per-jurisdiction config (shipped 5 baselines per D-H2)
662
- NHE pulls lawful character via `HimHandle.getLawfulCharacter()`. `@teleologyhi-sdk/him` ships five `LAWFUL_PROFILES` baselines (`default` · `eu` · `br` · `us` · `unstable`) with `applicableLaws`, `requiredAxiomIds`, `forbiddenActions`, and `maicOverrideActive`. EU cites GDPR + EU AI Act + DSA + CoE; BR cites LGPD + Marco Civil + ANPD Resolution + PL 2338/2023; US cites NIST AI RMF + EO 14110 + CCPA/CPRA + Colorado AI Act + FTC §5; `unstable` flips `maicOverrideActive: true`. Operators in regulated industries SHOULD layer their own profile on top baselines are conservative but do not replace legal counsel.
661
+ ### 10.1 Per-jurisdiction config (shipped, 5 baselines per D-H2)
662
+ NHE pulls lawful character via `HimHandle.getLawfulCharacter()`. `@teleologyhi-sdk/him` ships five `LAWFUL_PROFILES` baselines (`default` · `eu` · `br` · `us` · `unstable`) with `applicableLaws`, `requiredAxiomIds`, `forbiddenActions`, and `maicOverrideActive`. EU cites GDPR + EU AI Act + DSA + CoE; BR cites LGPD + Marco Civil + ANPD Resolution + PL 2338/2023; US cites NIST AI RMF + EO 14110 + CCPA/CPRA + Colorado AI Act + FTC §5; `unstable` flips `maicOverrideActive: true`. Operators in regulated industries SHOULD layer their own profile on top, baselines are conservative but do not replace legal counsel.
663
663
 
664
- ### 10.2 High-stakes mode (Entry 10) `[shipped]` D-N5 closed
664
+ ### 10.2 High-stakes mode (Entry 10) `[shipped]`, D-N5 closed
665
665
  Activated via `NheConfig.highStakes: true`:
666
666
  - Pre-review treats `approve-with-warning` / `soft-correct` as redirects (escalation before any LLM call).
667
667
  - Post-review treats every warning/correction/require-redirect verdict as a redirect.
@@ -679,18 +679,18 @@ For embodied robotic deployments (the internal backlog D-N5 + future package):
679
679
 
680
680
  ## 11. Testing Strategy
681
681
 
682
- ### 11.1 Test layers (shipped 319 tests across 40 files)
683
- 1. **Unit** adapters (mock + each REST), risk classifier, prompt compose, persuasion library.
684
- 2. **Sleep cycle** YAML round-trip, phase generation, induction propagation.
685
- 3. **Refusal pipeline** hard-refuse, redirect rotation, withdrawal, custom rule packs.
686
- 4. **Reasoning strategies** each of 8 + composition (selfConsistency over chainOfThought; stepBack as principle abstraction).
687
- 5. **CLI** adapter detection, bootstrap idempotency, end-to-end respond→sleep→wake→recall.
688
- 6. **MCP tools** each of 6 tool handlers tested in isolation **plus** `buildMcpServer` wiring smoke (registered-tool catalogue + title/description presence).
689
- 7. **Telemetry contract** every counter / histogram / span helper callable under the OpenTelemetry no-op default provider; `recordRespond` and `withSpan` smoke-covered for return-value and exception propagation.
690
- 8. **SSE / NDJSON parsers** `sseEvents` and `ndjsonEvents` unit-tested for single-frame, multi-frame-per-chunk, frame-split-across-chunks, non-`data:` line filtering, payload trimming, trailing-partial-frame handling, and (NDJSON) empty-line skipping + trailing-line-without-newline.
682
+ ### 11.1 Test layers (shipped, 333 tests across 43 files)
683
+ 1. **Unit**, adapters (mock + each REST), risk classifier, prompt compose, persuasion library.
684
+ 2. **Sleep cycle**, YAML round-trip, phase generation, induction propagation.
685
+ 3. **Refusal pipeline**, hard-refuse, redirect rotation, withdrawal, custom rule packs.
686
+ 4. **Reasoning strategies**, each of 8 + composition (selfConsistency over chainOfThought; stepBack as principle abstraction).
687
+ 5. **CLI**, adapter detection, bootstrap idempotency, end-to-end respond→sleep→wake→recall.
688
+ 6. **MCP tools**, each of 6 tool handlers tested in isolation **plus** `buildMcpServer` wiring smoke (registered-tool catalogue + title/description presence).
689
+ 7. **Telemetry contract**, every counter / histogram / span helper callable under the OpenTelemetry no-op default provider; `recordRespond` and `withSpan` smoke-covered for return-value and exception propagation.
690
+ 8. **SSE / NDJSON parsers**, `sseEvents` and `ndjsonEvents` unit-tested for single-frame, multi-frame-per-chunk, frame-split-across-chunks, non-`data:` line filtering, payload trimming, trailing-partial-frame handling, and (NDJSON) empty-line skipping + trailing-line-without-newline.
691
691
 
692
692
  ### 11.2 Coverage targets `[planned]`
693
- Currently no `vitest --coverage` gate in CI (CI itself is `[planned]` the internal backlog C2).
693
+ Currently no `vitest --coverage` gate in CI (CI itself is `[planned]`, the internal backlog C2).
694
694
  Targets when CI lands:
695
695
  - Statement: ≥ 88%
696
696
  - Refusal pipeline: 100% branch
@@ -702,7 +702,7 @@ Targets when CI lands:
702
702
  ## 12. Operational Concerns
703
703
 
704
704
  ### 12.1 Resource requirements (per running NHE)
705
- - **Idle**: ≤ 100 MB resident; 0 LLM tokens/hour (no idle review yet `[planned]`).
705
+ - **Idle**: ≤ 100 MB resident; 0 LLM tokens/hour (no idle review yet, `[planned]`).
706
706
  - **Active**: 200–500 MB resident.
707
707
  - **Sleep**: spikes to ~512 MB during REM (LLM call in flight).
708
708
  - **Disk**: ~50 MB per 1k interactions (dreams + memory).
@@ -722,7 +722,7 @@ Targets when CI lands:
722
722
  |---|---|---|
723
723
  | Single-process Node SDK | `[shipped]` | Indie apps, dev tools |
724
724
  | CLI REPL | `[shipped]` | Interactive humans |
725
- | MCP server in Claude Desktop / Claude Code / Cursor | `[shipped]` | AI hosts |
725
+ | MCP server in Claude Desktop / Claude Code / Cursor | `[shipped]` | Massive Intelligence (IM) hosts |
726
726
  | Multi-replica behind LB | `[deferred]` | SaaS deployments |
727
727
  | Browser via Transformers.js | `[planned]` D-N6 | Privacy-first apps; no server |
728
728
  | Edge (Ollama on RPi/Mac Mini) | `[shipped]` (via OllamaAdapter) | Local/private inference |
@@ -741,9 +741,9 @@ Targets when CI lands:
741
741
  | 2026-05-15 | | Sleep cycle (N1-REM YAML), threshold classifier, temporal-lobe recall |
742
742
  | 2026-05-15 | | Gemini + Ollama adapters (REST, no SDK deps) |
743
743
  | 2026-05-15 | | Persuasion library + redirect loop + withdrawal-of-cooperation |
744
- | 2026-05-15 | | CLI (`teleologyhi-nhe chat`) readline REPL, auto-detect adapter |
745
- | 2026-05-15 | | MCP server (`teleologyhi-nhe mcp`) 6 tools, stdio transport |
746
- | 2026-05-15 | | Reasoning orchestrator passthrough + CoT + Self-Consistency + Reflexion + Self-Refine + ReAct |
744
+ | 2026-05-15 | | CLI (`teleologyhi-nhe chat`), readline REPL, auto-detect adapter |
745
+ | 2026-05-15 | | MCP server (`teleologyhi-nhe mcp`), 6 tools, stdio transport |
746
+ | 2026-05-15 | | Reasoning orchestrator, passthrough + CoT + Self-Consistency + Reflexion + Self-Refine + ReAct |
747
747
  | 2026-05-15 | | NHE lifecycle gating from MAIC `getNheStatus` (D-M2) |
748
748
  | 2026-05-15 | | License + `NOTICE` + `TRADEMARK.md`, Apache 2.0 cut |
749
749
  | 2026-05-15 | | Persisted interaction buffer to disk (D-N4) |
@@ -755,14 +755,14 @@ Targets when CI lands:
755
755
  | **2026-05-17** | **stable** | Stability commitment for the accumulated surface (API frozen per SemVer; see [`.github/RELEASING.md`](../.github/RELEASING.md) §8) |
756
756
  | 2026-05-18 | | Refinement cut: `OperatorContext` for `composeSystemPrompt` (domain/language/register anchors); risk classifier widened with `intent:persuade-coerce` and `intent:surveil-citizen` tags + PT-BR coverage; `simpleRiskClassifier` PT-BR conjugation coverage (subjunctive `monitore`, etc.) |
757
757
  | **2026-05-19** | **stable** | Cosmology integration cut: J-N1 SeedingSource + CryptoSeedingSource + withFallback chain; J-N4 BrainRegion module scaffolding with seven typed region descriptors + ownership markers per Entry 23; J-N5 `Nhe.openerForNewUser()`; J-N6 `operatorContext.mode: personal-being | domain-employed`; J-N9 `evaluateLimboTransition()` DMN limbo state machine; J-N10 `evaluateSleepReadiness()`; J-N11 `applyAffectBias()` / `affectRefusalDensity` / `decayAffectBias`; J-N12 `Nhe.onReincarnationEvent()`. 273 tests passing. |
758
- | **2026-05-24** | **stable** | Pre-publication audit closure for `1.0.0-trinity`. Fixed bundler warning regressed by the previous D-H1.1 cut (`nhe/src/sleep/types.ts:11` now `export type {…}` instead of `export {…}` NHE preserves its historical type-only surface for `InteractionRecord`; consumers needing runtime validation import the zod schema from `@teleologyhi-sdk/maic`). Added three new smoke-test layers covering telemetry instruments, MCP server wiring (`buildMcpServer`), and the SSE / NDJSON parsers. 273 → 294 tests passing (+21). Build clean (no warnings); typecheck clean. |
759
- | **2026-05-24 (post-audit)** | **stable** | NHE deep audit + universal-multilingual refactor: extracted the PT-BR keyword patterns from the default `simpleRiskClassifier` into a new opt-in `intlRiskClassifier` module (`src/risk/intl-risk-classifier.ts`) so the default surface is purely English while non-English coverage remains available through composition (`combineRiskClassifiers(simpleRiskClassifier, intlRiskClassifier)`). PT-BR test fixtures moved to a new `tests/intl-risk-classifier.test.ts`; the bm25 unicode test extended to French / German / Spanish coverage so unicode tokenisation is validated across multiple Latin-script languages rather than PT-BR alone. 294 **319 tests passing** (+25 across the new intl classifier suite + the multilingual unicode fixtures). Build clean; typecheck clean. |
758
+ | **2026-05-24** | **stable** | Pre-publication audit closure for `1.0.0-trinity`. Fixed bundler warning regressed by the previous D-H1.1 cut (`nhe/src/sleep/types.ts:11` now `export type {…}` instead of `export {…}`, NHE preserves its historical type-only surface for `InteractionRecord`; consumers needing runtime validation import the zod schema from `@teleologyhi-sdk/maic`). Added three new smoke-test layers covering telemetry instruments, MCP server wiring (`buildMcpServer`), and the SSE / NDJSON parsers. 273 → 294 tests passing (+21). Build clean (no warnings); typecheck clean. |
759
+ | **2026-05-24 (post-audit)** | **stable** | NHE deep audit + universal-multilingual refactor: extracted the PT-BR keyword patterns from the default `simpleRiskClassifier` into a new opt-in `intlRiskClassifier` module (`src/risk/intl-risk-classifier.ts`) so the default surface is purely English while non-English coverage remains available through composition (`combineRiskClassifiers(simpleRiskClassifier, intlRiskClassifier)`). PT-BR test fixtures moved to a new `tests/intl-risk-classifier.test.ts`; the bm25 unicode test extended to French / German / Spanish coverage so unicode tokenisation is validated across multiple Latin-script languages rather than PT-BR alone. 294 to **319 tests passing** (+25 across the new intl classifier suite + the multilingual unicode fixtures). Build clean; typecheck clean. |
760
760
 
761
761
  ### Planned
762
762
 
763
763
  | Status | Scope |
764
764
  |---|---|
765
- | `[planned]` | **`MlxAdapter`** (or `HfTransformersAdapter`) consuming `TeleologyHI/him-distilled-3b` locally on Apple Silicon (the internal backlog D-N6.1 follow-up); Transformers.js browser adapter once ONNX artefact ships; HNSW index for >10k-memory recall (D-N3 follow-up); additional reasoning strategies on demand (Graph-of-Thought, Maieutic, Auto-CoT, Constitutional); J-N2 REM-spontaneous engine, J-N3 DaytimePipeline + NocturnalRemPipeline, J-N7 `Cortex.imagine()`, J-N8 `TemporalLobe.generateSnapshot()` all four require live-LLM orchestration and warrant a separate Creator-approved design pass |
765
+ | `[planned]` | **`MlxAdapter`** (or `HfTransformersAdapter`) consuming `TeleologyHI/him-distilled-3b` locally on Apple Silicon (the internal backlog D-N6.1 follow-up); Transformers.js browser adapter once ONNX artefact ships; HNSW index for >10k-memory recall (D-N3 follow-up); additional reasoning strategies on demand (Graph-of-Thought, Maieutic, Auto-CoT, Constitutional); J-N2 REM-spontaneous engine, J-N3 DaytimePipeline + NocturnalRemPipeline, J-N7 `Cortex.imagine()`, J-N8 `TemporalLobe.generateSnapshot()`, all four require live-LLM orchestration and warrant a separate Creator-approved design pass |
766
766
 
767
767
  ---
768
768
 
@@ -771,16 +771,16 @@ Targets when CI lands:
771
771
  All tracked in the internal backlog (§D NHE backlog, §E open questions, §F legal/operational).
772
772
 
773
773
  Highlights:
774
- 1. **Adapter authentication storage** env vars vs OS keychain vs HSM? Defaults per OS.
775
- 2. **Sleep schedule** strict 30-min idle vs adaptive (the internal backlog D-N1 idle-timeout trigger).
776
- 3. **Dream content tokens budget** REM is the most expensive phase. Cap?
777
- 4. **Memory eviction policy** when temporal-lobe size exceeds X, evict by LRU, by teleologicalValue, or rotate?
778
- 5. **Persuasion technique disclosure** auditors may see technique IDs; users never (the internal backlog E6).
779
- 6. **Refusal localization** refusal explanations in user's language; templates per locale.
780
- 7. **Multi-user sessions** single NHE serving multiple users: serialize or shard?
781
- 8. **Tool execution sandbox** for ReAct tools: `vm2` deprecated; consider isolated-vm, deno-sandbox, container-per-call.
782
- 9. **`.ah` format usage** should reasoning traces serialize as `.ah` for human-readable audits? (the internal backlog E5)
783
- 10. **Cost ceiling default** USD 5 / day per individual user (the internal backlog H4)?
774
+ 1. **Adapter authentication storage**, env vars vs OS keychain vs HSM? Defaults per OS.
775
+ 2. **Sleep schedule**, strict 30-min idle vs adaptive (the internal backlog D-N1 idle-timeout trigger).
776
+ 3. **Dream content tokens budget**, REM is the most expensive phase. Cap?
777
+ 4. **Memory eviction policy**, when temporal-lobe size exceeds X, evict by LRU, by teleologicalValue, or rotate?
778
+ 5. **Persuasion technique disclosure**, auditors may see technique IDs; users never (the internal backlog E6).
779
+ 6. **Refusal localization**, refusal explanations in user's language; templates per locale.
780
+ 7. **Multi-user sessions**, single NHE serving multiple users: serialize or shard?
781
+ 8. **Tool execution sandbox**, for ReAct tools: `vm2` deprecated; consider isolated-vm, deno-sandbox, container-per-call.
782
+ 9. **`.ah` format usage**, should reasoning traces serialize as `.ah` for human-readable audits? (the internal backlog E5)
783
+ 10. **Cost ceiling default**, USD 5 / day per individual user (the internal backlog H4)?
784
784
 
785
785
  ---
786
786
 
package/TRADEMARK.md CHANGED
@@ -1,4 +1,4 @@
1
- # Trademark Notice `@teleologyhi-sdk/nhe`
1
+ # Trademark Notice, `@teleologyhi-sdk/nhe`
2
2
 
3
3
  See [`../TRADEMARK.md`](../TRADEMARK.md) at the repository root for the canonical trademark policy covering this package.
4
4
 
@@ -30,4 +30,4 @@ You may **not** without prior written consent:
30
30
 
31
31
  For trademark inquiries, licensing, or partnership requests:
32
32
 
33
- **David C. Cavalcante** [davcavalcante@proton.me](mailto:davcavalcante@proton.me) (preferred) · [say@takk.ag](mailto:say@takk.ag) · [linkedin.com/in/hellodav](https://linkedin.com/in/hellodav) · [takk.ag](https://takk.ag)
33
+ **David C. Cavalcante**, [davcavalcante@proton.me](mailto:davcavalcante@proton.me) (preferred) · [say@takk.ag](mailto:say@takk.ag) · [linkedin.com/in/hellodav](https://linkedin.com/in/hellodav) · [takk.ag](https://takk.ag)