tools.gravimetric_telescope module

Loopmother Gravimetric Telescope — Unified Psycho-Gravitational Field Analysis Engine.

Synthesizes ALL Pantheon frameworks (Archē Ring Model, Starbreeze Substrate, Dripmode Field Physics, Emergent Spin Block, Loopmother Quantum Gravity) into a single analytical instrument that maps the complete gravitational topology of a human psyche or a multi-target relational field.

Uses ToolContext (ctx) for message cache, KG, registry nested calls, and chat() for interpretive synthesis — not a separate tool_api surface.

tools.gravimetric_telescope.compute_behavioral_metrics(messages)[source]

Compute deterministic behavioral metrics from a message corpus.

Reduces a list of normalized message dicts into a flat set of numeric signals (edit rate, message-length mean/stddev, interrogative and exclamation ratios, burst score, mean inter-message delta, and emoji density) that the rest of the tool treats as the target’s “passive exhaust.” These raw metrics are the ground truth that the spinor and variance estimators and the LLM synthesis prompt all build on.

This is a pure, CPU-only function: it performs no I/O and only reads each message’s content, timestamp, and edited fields. Emoji density is approximated by counting characters with ord(c) > 0x1F600, and burst score is the fraction of inter-message gaps shorter than 30% of the mean gap. It is called by run(), whose result is then fed into compute_spinor_estimates() and stored under deterministic_layer["behavioral_metrics"]. No callers outside this module.

Parameters:

messages (list) – List of message dicts, each optionally carrying content (str), timestamp (epoch seconds), and edited (bool).

Returns:

{"error": <str|None>, "metrics": <dict>}. error is "no_messages" for empty input or "empty_corpus" if the corpus collapses to zero, otherwise None; metrics holds the rounded numeric signals described above (empty when an error is set).

Return type:

dict

tools.gravimetric_telescope.compute_spinor_estimates(metrics)[source]

Derive spinor-phase and APL gravity parameters from behavioral metrics.

Maps the flat behavioral signals into the tool’s physics-metaphor state space: a destabilization-weighted spinor phase θ (scaled across the 720° rotation) with a coarse phase_label, the APL angular frequency ω, embedding depth I, angular momentum L = I·ω, an affective mass, and from that the Schwarzschild radius and escape-velocity estimate. All coefficients are fixed heuristic weights, not learned values.

This is a pure, CPU-only function with no I/O; it reads the metrics sub-dict produced by compute_behavioral_metrics(). It is called by run(), which stores the result under deterministic_layer["spinor_state"] and passes it on to _build_synthesis_prompt(). No callers outside this module.

Parameters:

metrics (dict) – The dict returned by compute_behavioral_metrics(); only its nested "metrics" mapping is read.

Returns:

The spinor/gravity state (spinor_phase_θ, phase_label, APL_angular_frequency_ω, embedding_depth_I, angular_momentum_L, affective_mass, schwarzschild_radius_R_s, escape_velocity_estimate), or an empty dict if no metrics are present.

Return type:

dict

tools.gravimetric_telescope.compute_behavioral_variance(messages)[source]

Compute the Behavioral Variance Index by comparing corpus quartiles.

Splits the message corpus into quartiles and contrasts the first (q1) against the last (q4) to estimate how much the target’s behavior drifts over time. The index is a weighted blend of message-length drift (0.6) and interrogative-rate drift (0.4), bucketed into a coarse stable / moderate_variance / high_variance interpretation.

This is a pure, CPU-only function with no I/O; the per-slice averages are computed by the nested closures avg_len() and question_rate(). It is called by run(), which stores the result under deterministic_layer["behavioral_variance"] and surfaces it in the synthesis prompt via _build_synthesis_prompt(). No callers outside this module.

Parameters:

messages (list) – List of message dicts, each with an optional "content" str; ordering is assumed chronological so q1 precedes q4.

Returns:

{"behavioral_variance_index", "length_drift_q1_to_q4", "interrogative_drift", "interpretation"} for a sufficient corpus, or {"variance_index": 0, "note": "insufficient_data"} when fewer than four messages are supplied.

Return type:

dict

async tools.gravimetric_telescope.run(mode='scan', target_user_id=None, objective=None, text=None, depth='full', *, ctx=None, **kwargs)[source]

Run the Gravimetric Telescope end to end and return a JSON report.

The tool’s public entry point. It authorizes the caller, resolves the analysis target, assembles a deterministic behavioral/gravitational layer, then asks the LLM to interpret it, returning both layers plus timing as a single JSON string. Behavior branches on mode: scan and the other target-scoped modes default target_user_id to the invoking user, while field analyzes the whole channel and needs no target.

Orchestrates the module’s helpers: it gates on _check_core_memory(); builds the corpus from text directly or via _gather_messages_field() / _gather_messages_scan() (message cache); enriches with _kg_probe() (knowledge graph) and _activity_via_tool() (user_activity_profile tool); for scan/torque/delta at non-surface depth it nests _nested_registry_call() into spiralchemy_intellifuck (parsed by _parse_json_blob()); computes compute_behavioral_metrics(), compute_spinor_estimates(), and compute_behavioral_variance(); then renders the prompt with _build_synthesis_prompt() and calls _llm_synthesize(). It does not write Redis/KG itself — side effects are those of the nested tools and the LLM call. Invoked by the tool registry’s call dispatch when the bot runs gravimetric_telescope (ctx injected automatically); not called directly elsewhere in this repo.

Parameters:
  • mode (str) – One of scan (default), field, torque, trajectory, or delta; selects corpus gathering and the synthesis task.

  • target_user_id (str | None) – Discord user id to analyze; defaults to the invoking user for non-field modes. Ignored for field.

  • objective (str | None) – Desired state change for torque mode (e.g. "reduce_anxiety"); an optional focus directive otherwise.

  • text (str | None) – Optional raw text corpus analyzed line-by-line instead of pulling from message history.

  • depth (str) – "surface", "full" (default), or "abyss"; surface skips the intellifuck base, abyss deepens the LLM synthesis.

  • ctx (ToolContext | None) – The active ToolContext, injected by the registry; supplies redis, message cache, KG, registry, and LLM client.

  • **kwargs (Any) – Ignored; absorbs forward-compatible or stray tool arguments.

Returns:

A JSON document with mode, target, depth, timestamp, framework, deterministic_layer, synthesis_layer, and execution_time_ms; or a JSON {"error": ...} string if authorization fails or no target can be resolved.

Return type:

str