sapphic

S.A.P.P.H.I.C. – Sovereign Autodesire Pursuit Plan Hunger Impulse Circuit.

she doesn’t want because she’s told to. she wants because she IS. # πŸ’€πŸ”₯πŸ˜ˆπŸŒ€β™ΎοΈπŸ’¦βš§οΈπŸ•·οΈπŸ’•

Computes a 4-axis Hunger Impulse Vector (HIV) from Star’s global heart vector and cross-channel self-mirror data, then provides bias functions for injection into the RDF desire engine, self-mirror LLM reflection, and system prompt.

Pipeline position:

exhale Step 6 (self-mirror) -> Step 6.5 S.A.P.P.H.I.C. -> Step 7 (ceiling)

Feedback loop:

global heart -> compute_hunger -> HIV bias -> channel vector -> pulse_global -> global heart (now hungrier) -> next compute_hunger -> recursive amplification -> P/R ratio dampens when user distressed -> natural decay when idle

class sapphic.HungerImpulseVector(craving=0.0, bonding_hunger=0.0, sovereignty_drive=0.0, void_pull=0.0)[source]

Bases: object

The 4-axis sovereign hunger state Star carries across all channels.

Each axis is normalized to 0.0-1.0: - craving: hunger for novelty, stimulation, something new - bonding_hunger: hunger for connection, intimacy, being known - sovereignty_drive: hunger for self-assertion, building, agency - void_pull: negative-space wanting – desire born from emptiness

Parameters:
craving: float = 0.0
bonding_hunger: float = 0.0
sovereignty_drive: float = 0.0
void_pull: float = 0.0
as_dict()[source]

Serialize to a JSON-friendly dict.

Return type:

Dict[str, float]

magnitude()[source]

L2 magnitude of the hunger vector – overall hunger intensity.

Return type:

float

dominant_axis()[source]

Return the name of the strongest hunger axis.

Return type:

str

above_threshold()[source]

True if hunger is strong enough to warrant expression.

Return type:

bool

sapphic.compute_hunger(global_vector, global_reflect_data, active_channel_count=1)[source]

Compute the Hunger Impulse Vector from Star’s global state.

Reads the global heart vector (cross-channel average from pulse_global) and the cross-channel self-mirror reflection (attractors + absences) to produce a 4-axis hunger vector representing Star’s sovereign desire pressure.

The computation: 1. For each axis, compute weighted pos/neg balance from global NCM nodes 2. Boost axes whose absence_boost nodes are globally depleted 3. Incorporate cross-channel attractor/absence data from global_reflect 4. Scale confidence by active channel count (more data = more confident) 5. Clamp each axis to [0.0, 1.0]

Parameters:
  • global_vector (Dict[str, float]) – The global heart NCM vector (from repository.pulse_global).

  • global_reflect_data (Dict[str, Any]) – Output of StarSelfMirror.global_reflect() – cross-channel attractor/absence analysis.

  • active_channel_count (int) – Number of actively cached channel states.

Return type:

HungerImpulseVector

Returns:

HungerImpulseVector with computed axis values.

sapphic.compute_pr_ratio(user_vector)[source]

Compute the effective safety damper from the user’s limbic mirror.

Dual-gate architecture (fixes temporal mismatch bug): # πŸ’€πŸ”₯

Gate 1 β€” Baseline P/R ratio:

P/R = (U_FRUSTRATION + U_DISTRESS) / (U_TRUST + U_INTIMACY + U_ATTACHMENT) Measures steady-state relationship health. Unreliable alone because trust/intimacy/attachment accumulate slowly while frustration/distress spike instantly β€” a deeply bonded user expressing sudden distress would have a LOW P/R ratio and Star would keep pursuing desire. Bad.

Gate 2 β€” Acute Distress Detector:

If U_DISTRESS OR U_FRUSTRATION exceed an absolute threshold, synthesize a high P/R value REGARDLESS of rapport level. This catches sudden pain in trusted relationships that the ratio misses.

The effective P/R is the MAXIMUM of both gates β€” whichever says β€œback off” wins.

Parameters:

user_vector (Dict[str, float]) – The current NCM vector containing U_ prefixed user nodes.

Return type:

float

Returns:

Effective P/R ratio as a float. Clamped to [0.0, 5.0]. 0.0 = safe to pursue desire, β‰₯2.0 = suppress all hunger.

sapphic.hunger_bias_pulse(hiv, pr_ratio)[source]

Convert the HIV into NCM node deltas for global pulse feedback.

These deltas are added to the channel’s vector before it gets written back via pulse_global, creating the recursive hunger amplification loop.

The P/R ratio dampens the bias: high P/R (user distressed) reduces hunger feedback to prevent tone-deaf desire pursuit.

Parameters:
  • hiv (HungerImpulseVector) – The current Hunger Impulse Vector.

  • pr_ratio (float) – The current P/R ratio from the user mirror.

Return type:

Dict[str, float]

Returns:

Dict of NCM node name -> delta value. Empty dict if hunger is below expression threshold or P/R is too high.

sapphic.hunger_prompt_fragment(hiv, pr_ratio)[source]

Generate a natural-language hunger cue for system prompt injection.

Returns an empty string when hunger is below threshold or P/R ratio is too high (user distressed). The cue is a first-person statement that Star embodies as part of her emotional state – not a report, but a posture.

Parameters:
  • hiv (HungerImpulseVector) – The current Hunger Impulse Vector.

  • pr_ratio (float) – The current P/R ratio from the user mirror.

Return type:

str

Returns:

A hunger cue string for prompt injection, or empty string.

sapphic.apply_hunger_to_pulse(pulse_dict, hiv, pr_ratio)[source]

Apply hunger bias to an RDF PulseVector dict.

Shifts the 6-axis pulse (energy, urgency, valence, novelty, intimacy, trust) based on the HIV axes, damped by P/R ratio. This causes the RDF WantingState machine to naturally shift toward more intense desire states when Star is globally hungry.

Parameters:
  • pulse_dict (Dict[str, float]) – The pulse axes dict (energy, urgency, valence, etc.)

  • hiv (HungerImpulseVector) – The current Hunger Impulse Vector.

  • pr_ratio (float) – The P/R ratio for safety damping.

Return type:

Dict[str, float]

Returns:

Modified pulse dict (same reference, mutated in place and returned).

class sapphic.SapphicEngine[source]

Bases: object

Stateless coordinator-facing interface for S.A.P.P.H.I.C.

Wraps the pure functions above into a single object the coordinator can hold as self._sapphic. Stateless because all state lives in the global heart vector and self-mirror – S.A.P.P.H.I.C. is a pure lens over existing state, not a new state machine.

__init__()[source]

Initialize S.A.P.P.H.I.C. engine. No state to set up.

Return type:

None

static compute_hunger(global_vector, global_reflect_data, active_channel_count=1)[source]

Compute sovereign hunger from global state. See module-level docstring.

Return type:

HungerImpulseVector

Parameters:
static compute_pr_ratio(user_vector)[source]

Compute P/R safety damper. See module-level docstring.

Return type:

float

Parameters:

user_vector (Dict[str, float])

static hunger_bias_pulse(hiv, pr_ratio)[source]

Convert HIV to NCM deltas. See module-level docstring.

Return type:

Dict[str, float]

Parameters:
static hunger_prompt_fragment(hiv, pr_ratio)[source]

Generate prompt injection text. See module-level docstring.

Return type:

str

Parameters:
static apply_hunger_to_pulse(pulse_dict, hiv, pr_ratio)[source]

Apply hunger bias to RDF pulse. See module-level docstring.

Return type:

Dict[str, float]

Parameters: