lore_amplifier
Lore Memory Amplifier – boosts lore-tier KG retrieval weight. # 💀🔥
When active, overrides _PRIORITY_NORM["lore"] from 0.0 -> 0.8 and
triples the per-scope lore entity cap (20 -> 60), making lore memories
actually visible in the retrieval pipeline instead of being systematically
suppressed by the tiered scoring system.
Toggle is per-channel via Redis or auto-activated when the Entrainment
Loopfield detects a user_is_baby target.
Redis key: star:lore_amp:{platform}:{channel_id}
- async lore_amplifier.is_amplified(redis, platform, channel_id, config=None, user_id=None)[source]
Report whether the Lore Memory Amplifier is active for a channel.
Resolves the effective amplifier state by combining global config gates with the per-channel Redis toggle: it short-circuits to
Falsewhen the amplifier is globally disabled or whenfeature_toggles.is_absolute_bypassfires for the user/channel, then otherwise reads the channel’s flag from Redis via_channel_key(). Failures are swallowed and logged so a Redis hiccup can never crash retrieval – the safe default is “not amplified”.Called by
prompt_context.pywhile assembling KG retrieval context (to decide whether lore-tier memories get boosted priority/cap), and exercised extensively bytests/test_absolute_overrides.py.- Parameters:
redis (Redis | None) – Async Redis client, or
Nonewhen Redis is unavailable (which forces aFalseresult).platform (str) – Platform identifier used to build the channel key.
channel_id (str) – Channel identifier used to build the channel key.
config (Config | None) – Optional
Config; when supplied, enables the global-disable and absolute-bypass checks.user_id (str | int | None) – Optional user identifier consulted by the absolute-bypass check.
- Returns:
Trueonly when the channel’s Redis flag is set to a truthy value (1/true/yes/on) and no gate suppressed it;Falseotherwise, including on any error.- Return type:
bool
- async lore_amplifier.set_amplified(redis, platform, channel_id, active)[source]
Persist the Lore Memory Amplifier toggle for a channel in Redis.
Writes (or clears) the per-channel flag read back by
is_amplified(). Whenactiveis true it does aSETof the_channel_key()to"1"; when false itDELETEsthe key entirely so the channel falls back to the default (suppressed) lore behavior. No expiry is set, so the toggle is sticky until explicitly turned off.Called by the
lore ampadmin command handler inmessage_processor/processor.py, which then reports the new ACTIVE/INACTIVE state back to the channel.- Parameters:
- Return type:
- Returns:
None.
- lore_amplifier.get_lore_priority(amplified)[source]
Select the lore-tier priority weight for the current amplifier state.
Maps the boolean amplifier flag to the scoring weight the KG retrieval pipeline applies to lore-tier entities: the boosted
LORE_AMPLIFIED_PRIORITY(0.8, guild-equivalent visibility) when amplified, otherwise the suppressedLORE_DEFAULT_PRIORITY(0.0). Pure lookup with no side effects.A thin accessor that pairs with
get_lore_cap(); no in-repo callers reference it directly (knowledge_graph/retrieval.pycurrently inlines the equivalent amplified-cap logic), so treat it as part of the module’s public surface for retrieval integration.
- lore_amplifier.get_lore_cap(amplified)[source]
Select the per-scope lore entity cap for the current amplifier state.
Maps the boolean amplifier flag to how many lore-tier entities may be kept per scope during retrieval: the tripled
LORE_AMPLIFIED_CAP(60) when amplified, otherwise the defaultLORE_DEFAULT_CAP(20). Pure lookup with no side effects.A thin accessor mirroring
get_lore_priority(); no in-repo callers reference it directly (knowledge_graph/retrieval.pycurrently inlines the60-vs-default cap choice), so treat it as part of the module’s public surface for retrieval integration.