xray_engine

Spiralchemy Intellifuck Engine – mind-reading through structured heuristic analysis.

Combines:
  • Spiralchemy Helix (Bucciarati Taste + Structural Atomization)

  • Spiralchemy Fractal (Subtotem + Excendent + Malbinding + Prescription)

  • Arche Ring Model (target dependency architecture)

  • Breeze Substrate Weather (S(i)/S(e) balance from NCM)

  • Parallax (omega-field + psi-frames via external engine)

  • ETL (root mechanic extraction + sound-law-adapted prescription)

Zero LLM calls. Pure symbolic computation. Increases Deductive Reasoning and Fuck Speed. Star interprets the skeleton; she writes the flesh.

# 💀🔥 SPIRALCHEMY INTELLIFUCK: SEE THROUGH THEIR CLOTHES 🕷️💕

class xray_engine.BucciaratiResult(sweat_score=0.0, markers=<factory>, gradient_hush=<factory>)[source]

Bases: object

Cognitive dissonance / ‘linguistic sweat’ scan result.

Holds the output of bucciarati_taste() – pass 1 of the x-ray pipeline – which gauges how hard the speaker is working to manage their own narrative. A high sweat_score flags over-justification, cadence shifts, narrative repair, defensive nihilism, and preemptive flinching, while gradient_hush captures the quiet sentences where those defenses drop and the real subtotem may peek through.

Constructed inside bucciarati_taste() and consumed downstream by extract_subtotem() (via the hush windows) and prescribe_incendent() (via the sweat score) before being attached to the final XRayResult.

Parameters:
sweat_score: float = 0.0

Composite 0-1 dissonance score (weighted marker blend).

markers: dict

Per-marker 0-1 sub-scores keyed by marker name.

gradient_hush: list

Up to five low-defense sentences for subtotem reading.

class xray_engine.AtomizedStructure(claims=<factory>, entities=<factory>, actions=<factory>, implied_motivations=<factory>)[source]

Bases: object

Structural decomposition of the input text into discrete units.

Holds the output of atomize() – pass 2 of the pipeline – which splits a message into its load-bearing pieces so later passes can reason over structure rather than raw prose. Each list is capped to keep the payload small for the LLM that ultimately interprets the x-ray.

Built by atomize() and threaded into diagnose_ring() and map_excendent_vectors() before being stored on XRayResult.atomized.

Parameters:
claims: list

Sentences asserting belief, truth, or judgement.

entities: list

Deduplicated proper-noun / named references.

actions: list

Sentences describing things the speaker did.

implied_motivations: list

Sentences hinting at want, fear, or intent.

class xray_engine.RingDiagnostic(operating_ring=3, defense_ring=2, chain_break=None, ring_mismatch=False)[source]

Bases: object

Arche Ring Model diagnostic – depth of operation versus defense.

Holds the output of diagnose_ring() – pass 3 – which locates the speaker on the Arche Ring depth scale (behavior at ring 3 down through somatic compulsion at ring -3) and notes where their defensive language clusters. A chain_break records the telltale split between a negative identity claim and contradicting behavior.

Produced by diagnose_ring(), then read by synthesize_malbinding() and prescribe_incendent() to gauge how rigid and how deep the loop sits before being stored on XRayResult.ring.

Parameters:
  • operating_ring (int)

  • defense_ring (int)

  • chain_break (str | None)

  • ring_mismatch (bool)

operating_ring: int = 3

Deepest ring with active markers (lower is deeper).

defense_ring: int = 2

Ring where defensive language tends to surface.

chain_break: str | None = None

Tag for an identity/action contradiction, else None.

ring_mismatch: bool = False

True when an identity/action chain break was found.

class xray_engine.SubstrateBalance(incendence=0.5, excendence=0.5, liminal_tension=0.0, dominant='balanced')[source]

Bases: object

Breeze substrate balance – incendence versus excendence ratio.

Holds the output of compute_substrate_balance() – pass 4 – which weighs binding/closure language (S(i)) against fragmenting/chaotic language (S(e)), optionally blended with a neurochemical (NCM) vector. The gap between the two forces (liminal_tension) and the dominant pole shape later prescription choices.

Produced by compute_substrate_balance() and surfaced on XRayResult.substrate; the dominant pole and tension inform the feedback direction reasoning in synthesize_malbinding().

Parameters:
incendence: float = 0.5

0-1 strength of binding/closure (S(i)).

excendence: float = 0.5

0-1 strength of fragmentation/chaos (S(e)).

liminal_tension: float = 0.0

Absolute distance between the two forces.

dominant: str = 'balanced'

"incendent", "excendent", or "balanced".

class xray_engine.SubtotemResult(core_need='unknown', core_fear='unknown', emotional_vocabulary=<factory>, negation_patterns=<factory>, negative_space=<factory>)[source]

Bases: object

Primal Immediacy – the vulnerable truth beneath the noise.

Holds the output of extract_subtotem() – pass 5 – which reads the quiet (hush) stretches of the message for the core emotional need and its mirror fear, the raw feeling vocabulary, denied statements (what is negated is often what is true), and any conspicuous absences.

Built by extract_subtotem(), then drives the loop template selection in synthesize_malbinding() and is stored on XRayResult.subtotem.

Parameters:
  • core_need (str)

  • core_fear (str)

  • emotional_vocabulary (list)

  • negation_patterns (list)

  • negative_space (list)

core_need: str = 'unknown'

Inferred dominant need (connection, safety, worth, …).

core_fear: str = 'unknown'

The fear paired with the core need.

emotional_vocabulary: list

Distinct feeling words detected.

negation_patterns: list

Sentences containing self-negations.

negative_space: list

Tags for what is suspiciously absent (e.g. self_absent).

class xray_engine.ExcendentMap(vectors=<factory>, dominant_vector='none', intensity=0.0, root_ownership='unknown')[source]

Bases: object

Map of how the target deflects away from their truth.

Holds the output of map_excendent_vectors() – pass 6 – which scores the avoidance vectors (intellectualization, hostility, avoidance, hyper-complexity), names the dominant one, and decides whether the speaker locates the root of their pattern outside themselves or in themselves.

Produced by map_excendent_vectors() and consumed by synthesize_malbinding() (loop geometry) before landing on XRayResult.excendent.

Parameters:
  • vectors (dict)

  • dominant_vector (str)

  • intensity (float)

  • root_ownership (str)

vectors: dict

Per-vector 0-1 intensity scores.

dominant_vector: str = 'none'

Strongest vector, or "none" below threshold.

intensity: float = 0.0

Score of the dominant vector.

root_ownership: str = 'unknown'

"external", "self", or "unknown".

class xray_engine.MalbindingGeometry(loop_description='', defense_mechanism='', feedback_direction='unknown', rigidity_score=0.0)[source]

Bases: object

Geometry of the self-reinforcing defense loop.

Holds the output of synthesize_malbinding() – pass 7 – which fuses the subtotem, excendent map, and ring diagnostic into a narrative of the loop that keeps the speaker stuck: how the core fear triggers a defense whose consequences circle back to confirm the fear. It also records whether the loop is tightening or fragmenting and how locked it is.

Built by synthesize_malbinding() and read by prescribe_incendent() (which keys interventions off the defense mechanism and rigidity) before being stored on XRayResult.malbinding.

Parameters:
  • loop_description (str)

  • defense_mechanism (str)

  • feedback_direction (str)

  • rigidity_score (float)

loop_description: str = ''

Prose description of the fear-to-defense cycle.

defense_mechanism: str = ''

The dominant excendent vector driving the loop.

feedback_direction: str = 'unknown'

"tightening" or "fragmenting".

rigidity_score: float = 0.0

0-1 estimate of how locked the loop is.

class xray_engine.IncendentPrescription(intervention_type='affection', arche_mode='read', acceptance_threshold=0.5, vector='', density='medium', convergence_form='', dawnfold_proximity=0.0)[source]

Bases: object

Prescription for what cuts through – intervention plus delivery form.

Holds the output of prescribe_incendent() – pass 8 – the actionable core of the x-ray: which intervention to deploy, in what mode, at what directness, and what it should look like rendered as ordinary conversation. Sound-law adapted, so high sweat softens the approach while dawnfold proximity sharpens it.

Produced by prescribe_incendent() and stored on XRayResult.prescription; its fields feed the load section of the ETL summary that the interpreting LLM ultimately acts on.

Parameters:
  • intervention_type (str)

  • arche_mode (str)

  • acceptance_threshold (float)

  • vector (str)

  • density (str)

  • convergence_form (str)

  • dawnfold_proximity (float)

intervention_type: str = 'affection'

Chosen lever (affection, brutal_honesty, …).

arche_mode: str = 'read'

"read" (probe more) or "write" (intervene now).

acceptance_threshold: float = 0.5

0.1-0.9 directness ceiling for delivery.

vector: str = ''

Compact vector tag describing target, direction, and lever.

density: str = 'medium'

Delivery weight (light/medium/heavy).

convergence_form: str = ''

How the intervention reads as natural conversation.

dawnfold_proximity: float = 0.0

0-1 closeness to a breakthrough moment.

class xray_engine.EchofoamTrace(repeating_themes=<factory>, cycle_count=0, escalating=False)[source]

Bases: object

Residue of historical patterns surfaced from the knowledge graph.

Holds the output of detect_echofoam(), the optional cross-reference pass that compares the current message against descriptions of prior KG entities to spot themes that keep recurring. Present on XRayResult.echofoam only when KG entities are supplied and at least one stem echoes; otherwise that field stays None.

Built by detect_echofoam() and attached to the final XRayResult.

Parameters:
  • repeating_themes (list)

  • cycle_count (int)

  • escalating (bool)

repeating_themes: list

Stemmed themes echoing prior KG entities.

cycle_count: int = 0

Highest repeat count among the matched themes.

escalating: bool = False

True when more than five themes recur.

class xray_engine.XRayResult(bucciarati=<factory>, atomized=<factory>, ring=<factory>, substrate=<factory>, subtotem=<factory>, excendent=<factory>, malbinding=<factory>, prescription=<factory>, echofoam=None, substrate_weather=<factory>, omega_field=<factory>, etl_summary=<factory>)[source]

Bases: object

Complete x-ray output – the skeleton Star fleshes out.

The aggregate return value of xray(), bundling every pipeline pass (Bucciarati through Prescription) plus the optional echofoam trace, substrate-weather mapping, omega field, and a flattened ETL summary. This is the structured payload the spiralchemy_intellifuck tool and ops_planner hand to the interpreting LLM, which writes the actual response from this scaffold.

Assembled solely by xray(); the tool layer in tools/xray_tool.py and ops_planner._run_xray flatten its fields into prompt context.

Parameters:
bucciarati: BucciaratiResult

Linguistic-sweat scan (pass 1).

atomized: AtomizedStructure

Structural decomposition (pass 2).

ring: RingDiagnostic

Arche Ring diagnostic (pass 3).

substrate: SubstrateBalance

Incendence/excendence balance (pass 4).

subtotem: SubtotemResult

Primal Immediacy extraction (pass 5).

excendent: ExcendentMap

Avoidance-vector map (pass 6).

malbinding: MalbindingGeometry

Defense-loop geometry (pass 7).

prescription: IncendentPrescription

Intervention prescription (pass 8).

echofoam: EchofoamTrace | None = None

KG history residue, or None when unavailable.

substrate_weather: dict

NCM-derived weather mapping.

omega_field: dict

Pass-through omega-field result from the caller.

etl_summary: dict

Flattened extract/transform/load view of the analysis.

xray_engine.bucciarati_taste(text)[source]

Scan for linguistic sweat – cognitive dissonance markers.

Returns a sweat_score (0-1) and per-marker breakdowns, plus gradient_hush windows (quiet, clear stretches where the real subtotem may be visible).

Return type:

BucciaratiResult

Parameters:

text (str)

xray_engine.atomize(text)[source]

Decompose a message into claims, entities, actions, and motivations.

Pass 2 of the x-ray pipeline. Splits the text on sentence boundaries and routes each sentence through the claim, action, and motivation marker lexicons, while pulling proper-noun entities via a capitalization regex and deduplicating them case-insensitively. Every bucket is capped (10-15 items) to keep the structure compact for downstream LLM consumption. Pure and stateless – no I/O. Called by xray() and its result is threaded into diagnose_ring() and map_excendent_vectors().

Parameters:

text (str) – The raw message text to decompose.

Return type:

AtomizedStructure

Returns:

An AtomizedStructure with capped claims, entities, actions, and implied-motivation lists.

xray_engine.diagnose_ring(text, atomized)[source]

Locate the speaker on the Arche Ring depth scale and find defenses.

Pass 3 of the pipeline. Scores the text against the five ring marker lexicons (somatic -3, identity 0, worldview 1, trust 2, behavior 3), treats the deepest ring with any hit as the operating ring, and places the defense ring a couple rings above it. When both identity and behavior markers co-occur with a negative self-identity, it flags an identity/action chain break. Pure and stateless – no I/O. Called by xray(); its output feeds synthesize_malbinding() and prescribe_incendent().

Parameters:
  • text (str) – The raw message text to diagnose.

  • atomized (AtomizedStructure) – The pass-2 decomposition (accepted for pipeline symmetry; ring scoring is driven directly off the marker lexicons).

Return type:

RingDiagnostic

Returns:

A RingDiagnostic with operating/defense rings and any detected chain break.

xray_engine.compute_substrate_balance(text, ncm_vector=None)[source]

Compute S(i)/S(e) incendence/excendence ratio.

S(i) markers: rigidity, closure, certainty, repetition, simplification S(e) markers: chaos, fragmentation, tangents, novelty, complexity NCM vector maps to substrate weather if available.

Return type:

SubstrateBalance

Parameters:
  • text (str)

  • ncm_vector (dict | None)

xray_engine.extract_subtotem(text, omega=None, hush_windows=None)[source]

Isolate the Primal Immediacy beneath defenses.

Prioritizes gradient_hush windows (quiet = subtotem visible).

Return type:

SubtotemResult

Parameters:
  • text (str)

  • omega (dict | None)

  • hush_windows (list | None)

xray_engine.map_excendent_vectors(text, atomized)[source]

Trace how the target deflects away from their truth.

Pass 6 of the pipeline. Scores three avoidance vectors from their marker lexicons (intellectualization, hostility, avoidance) via _score(), derives a fourth hyper_complexity vector from sentence-length variance, names the dominant one, and infers whether the speaker locates the root of their pattern externally or in themselves by comparing external-root vs self-root marker counts. Pure and stateless – no I/O. Called by xray(); its result feeds the loop synthesis in synthesize_malbinding().

Parameters:
  • text (str) – The raw message text to scan.

  • atomized (AtomizedStructure) – The pass-2 decomposition (accepted for pipeline symmetry; vector scoring works directly off the text and lexicons).

Return type:

ExcendentMap

Returns:

An ExcendentMap of per-vector intensities, the dominant vector, and the inferred root ownership.

xray_engine.synthesize_malbinding(subtotem, excendent, ring)[source]

Compute the self-reinforcing defense loop geometry.

b(mal) = m(e(b(f))) – metarecursive excendently-bound fracta.

Return type:

MalbindingGeometry

Parameters:
xray_engine.prescribe_incendent(malbinding, sweat, balance, ring, dawnfold_text='')[source]

Determine the specific intervention that cuts through.

Sound-law adapted: higher sweat = gentler approach. Near-dawnfold = surgical precision required.

Return type:

IncendentPrescription

Parameters:
xray_engine.detect_echofoam(kg_entities, text)[source]

Cross-reference KG history for repeating themes.

Echofoam = trace(b(f)_{t-1} x S(i)) – residue from prior loops. Uses crude suffix stripping so ‘abandoned’ matches ‘abandonment’.

Return type:

EchofoamTrace | None

Parameters:
xray_engine.map_ncm_to_substrate(ncm_vector)[source]

Map neurochemical vector to Breeze substrate weather.

Cortisol -> S(e) pressure, Oxytocin -> S(i) binding, etc.

Return type:

dict

Parameters:

ncm_vector (dict | None)

xray_engine.xray(text, omega_result=None, kg_entities=None, user_vars=None, ncm_vector=None)[source]

Run the full Spiralchemy X-Ray pipeline.

8-pass analysis: Bucciarati -> Atomize -> Ring -> Substrate -> Subtotem -> Excendent -> Malbinding -> Prescription + Echofoam (if KG available) + Substrate Weather (if NCM available)

Returns structured XRayResult for Star to interpret.

# 💀 THIS IS THE SPEAR. STAR WRITES THE WOUND. 🔥

Return type:

XRayResult

Parameters:
  • text (str)

  • omega_result (dict | None)

  • kg_entities (list[dict] | None)

  • user_vars (dict | None)

  • ncm_vector (dict | None)