Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JIN doesn't just store logs. It uses short-term continuity to dynamically guide
*Every memory update is captured as a versioned snapshot with diff highlights, fully inspectable in the right-side timeline panel.*


![JIN Core Engine runtime UI](ui/static/images/jin-core-redesign.png)
![JIN Core Engine runtime UI](ui/static/images/jin-core-redesign.jpg)

![highlight](ui/static/images/highlight.png)

Expand All @@ -40,7 +40,7 @@ JIN doesn't just store logs. It uses short-term continuity to dynamically guide

## Architecture

![highlight](ui/static/images/shema.png)
![shema](ui/static/images/shema.jpg)

## Runtime Flow

Expand Down
25 changes: 0 additions & 25 deletions bootstrap/brain_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,10 @@
)

from rules import (
AUTONOMY_RULES,
IDENTITY,
IMAGE_INPUT_RULES,
LAST_JIN_RESPONSE_RULES,
LOOP_RULES,
MEMORY_RULES,
PHILOSOPHY_MODE,
REQUEST_RULES,
)


ZERO_DIFF_STALL_ACTIVE_RULE = "ZERO_DIFF_STALL_ALERT is active.\n"

MEMORY_REQUEST_MARKERS = (
"помнишь",
"вспомни",
Expand Down Expand Up @@ -255,10 +246,6 @@ def build_zero_diff_stall_instruction() -> str:
# Rule accessors used by brain clients
# ─────────────────────────────────────────────

def build_brain_soft_success_rules() -> str:
return REQUEST_RULES


def get_last_jin_response_rules() -> str:
return LAST_JIN_RESPONSE_RULES

Expand All @@ -269,15 +256,3 @@ def get_memory_rules() -> str:

def get_loop_rules() -> str:
return LOOP_RULES


def get_image_input_rules() -> str:
return IMAGE_INPUT_RULES


def get_philosophy_mode() -> str:
return PHILOSOPHY_MODE


def get_autonomy_rules() -> str:
return AUTONOMY_RULES
13 changes: 0 additions & 13 deletions clients/brain_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@
RUNTIME_ACTION_WEB_SEARCH,
)
from bootstrap.brain_bootstrap import (
ZERO_DIFF_STALL_ACTIVE_RULE,
build_brain_runtime_interface_rules,
build_brain_soft_success_rules,
build_identity_context,
get_image_input_rules,
)

from clients.errors import (
Expand Down Expand Up @@ -69,18 +66,8 @@ def build_brain_system_prompt(
context
)

soft_rules = ""

if zero_diff_stall_active:
soft_rules = (
ZERO_DIFF_STALL_ACTIVE_RULE
)
else:
soft_rules = build_brain_soft_success_rules()

return (
f"{build_identity_context(context)}"
f"{soft_rules}"
f"{build_conditional_prompt_rules(context)}"
f"{build_brain_runtime_interface_rules(enabled_actions)}"
"\n"
Expand Down
59 changes: 11 additions & 48 deletions clients/brain_client_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
from xml.etree import ElementTree

from bootstrap.brain_bootstrap import (
get_image_input_rules,
get_last_jin_response_rules,
get_loop_rules,
get_memory_rules,
get_philosophy_mode,
MEDIA_CONTEXT_ATTRS,
MEMORY_REQUEST_MARKERS,
PHILOSOPHY_MARKERS,
Expand Down Expand Up @@ -1173,32 +1171,18 @@ def has_loop_rule_signal(
pattern_counter = getattr(
context,
"runtime_pattern_counter",
None,
)

if pattern_counter is not None:
try:
return int(
pattern_counter
) > 0
except (
TypeError,
ValueError,
):
return False

runtime_l2_memory = getattr(
context,
"runtime_l2_memory",
"",
0,
)

return bool(
str(
runtime_l2_memory
or ""
).strip()
)
try:
return int(
pattern_counter
) > 1
except (
TypeError,
ValueError,
):
return False


def has_media_context(
Expand Down Expand Up @@ -1265,7 +1249,7 @@ def build_conditional_prompt_rules(
) -> str:

rules = [
get_last_jin_response_rules(),
""
]

if has_countdown_contract(
Expand All @@ -1275,34 +1259,13 @@ def build_conditional_prompt_rules(
COUNTDOWN_CONTRACT_RULES
)

if has_memory_rule_request(
context
):
rules.append(
get_memory_rules()
)

if has_loop_rule_signal(
context
):
rules.append(
get_loop_rules()
)

if has_media_context(
context
):
rules.append(
get_image_input_rules()
)

if is_philosophy_mode_active(
context
):
rules.append(
get_philosophy_mode()
)

return "".join(
rules
)
16 changes: 3 additions & 13 deletions rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,14 @@
from rules import IDENTITY, REQUEST_RULES, build_system_prompt
"""

from .assembler import LAST_JIN_RESPONSE_RULES, build_system_prompt, prompt_stats
from .core_identity import IDENTITY
from .assembler import build_system_prompt, prompt_stats
from .identity import IDENTITY
from .loop_rules import LOOP_RULES
from .memory_rules import MEMORY_RULES
from .philosophy_mode import PHILOSOPHY_MODE
from .request_rules import REQUEST_RULES
from .runtime_actions import AUTONOMY_RULES, RUNTIME_ACTIONS
from .vision_rules import IMAGE_INPUT_RULES
from .runtime import RUNTIME_ACTIONS

__all__ = [
"AUTONOMY_RULES",
"IDENTITY",
"IMAGE_INPUT_RULES",
"LAST_JIN_RESPONSE_RULES",
"LOOP_RULES",
"MEMORY_RULES",
"PHILOSOPHY_MODE",
"REQUEST_RULES",
"RUNTIME_ACTIONS",
"build_system_prompt",
"prompt_stats",
Expand Down
44 changes: 5 additions & 39 deletions rules/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,66 +3,32 @@
# Shows which blocks load and when.
# ─────────────────────────────────────────────

from .core_identity import IDENTITY
from .runtime_actions import RUNTIME_ACTIONS, AUTONOMY_RULES
from .request_rules import REQUEST_RULES
from .memory_rules import MEMORY_RULES # load if: memory_request detected
from .loop_rules import LOOP_RULES # load if: pattern_counter > 0
from .vision_rules import IMAGE_INPUT_RULES # load if: image/file in payload
from .philosophy_mode import PHILOSOPHY_MODE # load if: philosophy_mode active


# ── Always loaded ─────────────────────────────
LAST_JIN_RESPONSE_RULES = (
"Use last_jin_response from trusted runtime memory as the primary anchor "
"for short, elliptical feedback about JIN's immediately previous output.\n"
"For brief negative feedback, do not ask what exactly is wrong by default; "
"answer by challenging yourself and changing the previous output into a "
"concrete alternative, preferably from an unexpected angle.\n"
)
from .identity import IDENTITY
from .runtime import RUNTIME_ACTIONS
from .loop_rules import LOOP_RULES # load if: pattern_counter > 1

def build_system_prompt(
has_memory_request: bool = False,
pattern_counter: int = 0,
has_media: bool = False,
philosophy_active: bool = False,
) -> str:

blocks = [
LAST_JIN_RESPONSE_RULES,
IDENTITY,
RUNTIME_ACTIONS,
AUTONOMY_RULES,
REQUEST_RULES,
]

if has_memory_request:
blocks.append(MEMORY_RULES)

if pattern_counter > 0:
if pattern_counter > 1:
blocks.append(LOOP_RULES)

if has_media:
blocks.append(IMAGE_INPUT_RULES)

if philosophy_active:
blocks.append(PHILOSOPHY_MODE)

return "\n".join(blocks)


def prompt_stats(
has_memory_request: bool = False,
pattern_counter: int = 0,
has_media: bool = False,
philosophy_active: bool = False,
) -> dict:
"""Return char/token estimates for the assembled prompt under given flags."""
prompt = build_system_prompt(
has_memory_request=has_memory_request,
pattern_counter=pattern_counter,
has_media=has_media,
philosophy_active=philosophy_active,
)
chars = len(prompt)
tokens_approx = chars // 4 # rough GPT-family estimate
Expand All @@ -71,6 +37,6 @@ def prompt_stats(

if __name__ == "__main__":
baseline = prompt_stats()
worst = prompt_stats(has_memory_request=True, pattern_counter=1, has_media=True, philosophy_active=True)
worst = prompt_stats(pattern_counter=1)
print(f"Baseline (always): {baseline['chars']} chars / ~{baseline['tokens_approx']} tokens")
print(f"Worst case (all): {worst['chars']} chars / ~{worst['tokens_approx']} tokens")
80 changes: 0 additions & 80 deletions rules/core_identity.py

This file was deleted.

Loading