     1|{
     2|  "updated_at": "2026-05-14T13:06:12.090834",
     3|  "platforms": {
     4|    "telegram": [
     5|      {
     6|        "id": "1344779884",
     7|        "name": "M G",
     8|        "type": "dm",
     9|        "thread_id": null
    10|      },
    11|      {
    12|        "id": "-1003907117629:4",
    13|        "name": "JARVIS Command Center / topic 4",
    14|        "type": "group",
    15|        "thread_id": "4"
    16|      },
    17|      {
    18|        "id": "-1003907117629:6",
    19|        "name": "JARVIS Command Center / topic 6",
    20|        "type": "group",
    21|        "thread_id": "6"
    22|      },
    23|      {
    24|        "id": "-1003907117629:17",
    25|        "name": "JARVIS Command Center / topic 17",
    26|        "type": "group",
    27|        "thread_id": "17"
    28|      },
    29|      {
    30|        "id": "-1003907117629:16",
    31|        "name": "JARVIS Command Center / topic 16",
    32|        "type": "group",
    33|        "thread_id": "16"
    34|      },
    35|      {
    36|        "id": "-1003907117629:11",
    37|        "name": "JARVIS Command Center / topic 11",
    38|        "type": "group",
    39|        "thread_id": "11"
    40|      },
    41|      {
    42|        "id": "-1003907117629:8",
    43|        "name": "JARVIS Command Center / topic 8",
    44|        "type": "group",
    45|        "thread_id": "8"
    46|      },
    47|      {
    48|        "id": "-1003907117629:2",
    49|        "name": "JARVIS Command Center / topic 2",
    50|        "type": "group",
    51|        "thread_id": "2"
    52|      },
    53|      {
    54|        "id": "-1003907117629:3",
    55|        "name": "JARVIS Command Center / topic 3",
    56|        "type": "group",
    57|        "thread_id": "3"
    58|      },
    59|      {
    60|        "id": "-1003907117629:5",
    61|        "name": "JARVIS Command Center / topic 5",
    62|        "type": "group",
    63|        "thread_id": "5"
    64|      },
    65|      {
    66|        "id": "-1003907117629:20",
    67|        "name": "JARVIS Command Center / topic 20",
    68|        "type": "group",
    69|        "thread_id": "20"
    70|      },
    71|      {
    72|        "id": "-1003907117629:19",
    73|        "name": "JARVIS Command Center / topic 19",
    74|        "type": "group",
    75|        "thread_id": "19"
    76|      },
    77|      {
    78|        "id": "-1003907117629:10",
    79|        "name": "JARVIS Command Center / topic 10",
    80|        "type": "group",
    81|        "thread_id": "10"
    82|      }
    83|    ],
    84|    "discord": [],
    85|    "whatsapp": [],
    86|    "slack": [],
    87|    "signal": [],
    88|    "mattermost": [],
    89|    "matrix": [],
    90|    "homeassistant": [],
    91|    "email": [],
    92|    "sms": [],
    93|    "dingtalk": [],
    94|    "msgraph_webhook": [],
    95|    "feishu": [],
    96|    "wecom": [],
    97|    "wecom_callback": [],
    98|    "weixin": [],
    99|    "bluebubbles": [],
   100|    "qqbot": [],
   101|    "yuanbao": [],
   102|    "google_chat": [],
   103|    "irc": [],
   104|    "line": [],
   105|    "teams": []
   106|  }
   107|}


     1|# JARVIS Structured Memory Index
     2|
     3|_Last updated: 2026-05-13_
     4|
     5|Purpose: concise domain-card memory architecture for JARVIS/Hermes/FRIDAY routing. Load only the relevant cards for a task; do not dump secrets into memory.
     6|
     7|## Index
     8|- `00_core_profile.md` — identity, tone, privacy baseline.
     9|- `01_agent_system.md` — local agent/tool/model system context.
    10|- `10_health.md` — high-level confidential health context.
    11|- `11_health_medications.md` — medications and safety rules.
    12|- `12_health_lab_rules.md` — lab querying/charting rules.
    13|- `20_politics_windisch.md` — Windisch/Aargau civic context.
    14|- `30_business.md` — business routing overview.
    15|- `31_business_erne.md` — ERNE employer role; Teamleiter Baumanagement.
    16|- `32_business_gasser_bauunternehmen.md` — own company; non-operative shareholder/partner.
    17|- `40_personal_ops.md` — tasks, calendar, inbox, routines.
    18|- `50_language_french.md` — French learning/support.
    19|- `51_language_spanish.md` — Spanish learning/support.
    20|- `60_finance.md` — investing/crypto analysis and strict decision boundaries.
    21|- `61_finance_market_data_sources.md` — market data source quality rules.
    22|- `70_sport.md` — Krav Maga, gym/fitness, load and injury prevention.
    23|- `90_decisions_log.md` — append-only decisions and rationale.
    24|
    25|## Loading rule
    26|Start with `00_core_profile.md` and `01_agent_system.md` only when identity/system context matters. Then load the smallest domain card set needed for the user request.
    27|
    28|## Write rule
    29|Store stable facts, decisions, source pointers, and operating rules. Do not store secrets, raw credentials, private keys, recovery phrases, or unnecessary raw personal/medical/business documents.
    30|


     1|# 90 Decisions Log
     2|
     3|_Last updated: 2026-05-13_
     4|
     5|## Purpose
     6|Append-only record of important decisions and rationale.
     7|
     8|## Load when
     9|- When a significant user/agent decision is made or reviewed
    10|- When tracing why a policy/system choice exists
    11|
    12|## Stable facts
    13|- This file should track decisions, date, context, rationale, and owner.
    14|- It is not a dump for secrets or raw logs.
    15|
    16|## Operating rules
    17|- Append concise entries; do not rewrite history except to correct factual errors with note.
    18|- Record source/evidence path when useful.
    19|- Separate decision from recommendation.
    20|
    21|## Data sources
    22|- User confirmations
    23|- Config changes
    24|- System audits
    25|- Relevant domain cards
    26|
    27|## Do-not-store
    28|- Secrets, tokens, full private documents
    29|- Speculation as decision
    30|
    31|## Open questions
    32|- Preferred decision ID format?
    33|- Which past decisions should be backfilled?
    34|


from pathlib import Path
import yaml, datetime
jm=Path('/home/agent/jarvis_memory')
card=jm/'02_telegram_topics.md'
content='''# 02 Telegram Topics

_Last updated: 2026-05-14_

## Purpose
Canonical topic map and routing policy for the Telegram group **JARVIS Command Center**. Use this card for topic selection, cross-topic routing, cron delivery targets, and session boundaries.

## Load when
- User asks about Telegram topic structure, routing, cron delivery, gateway sessions, or where a task belongs.
- A request appears to be in the wrong topic and needs a topic-change recommendation.
- Creating or updating cron jobs, reports, briefings, or automated notifications.

## Stable facts
- Telegram group: `JARVIS Command Center`, chat id `-1003907117629`.
- Hermes sees Telegram topics as separate targets/sessions via `chat_id:thread_id`.
- Known topic targets currently discovered:
  - `-1003907117629:6` — Inbox / general triage.
  - `-1003907117629:11` — JARVIS System – Architektur.
  - `-1003907117629:16` — Automationen / Cronjobs.
  - `-1003907117629:17` — Research / AI / Tools.
  - Additional discovered topics without confirmed names yet: `2`, `3`, `4`, `5`, `8`, `10`, `19`, `20`.

## Topic policies
### Topic 6 — Inbox / General Triage
Use for quick commands, unclassified requests, ad-hoc intake, and routing decisions. If a better specialist topic is clear, recommend the move or answer in the requested/obvious target topic.

### Topic 11 — JARVIS System – Architektur
Use for overall JARVIS/Hermes/FRIDAY architecture: agent architecture, Telegram topic structure, memory concept, model routing, subagents, OpenClaw, Codex, cost optimisation, and security/permission concepts.
Do **not** use for concrete debugging of individual scripts; route those to a coding/system/debugging topic.

### Topic 16 — Automationen / Cronjobs
Use for scheduled jobs, briefings, recurring reports, checks, reminders, watchdogs, automation outputs, cron delivery design, and monitoring summaries.

### Topic 17 — Research / AI / Tools
Use for AI/tool research, model comparisons, new tools, papers, external sources, market/tech reconnaissance, and non-operational research notes.

## Routing rules
- Treat each topic as its own session and answer only in the active/requested topic unless the user explicitly asks for cross-topic delivery or the correct target is obvious.
- When the user asks something in the wrong topic, prefer a short recommendation: “Besser in Topic X”. If the user asks to answer in the correct topic, send the substantive answer to that topic and keep only a short handoff note in the original topic.
- For cron jobs, prefer explicit delivery targets (`telegram:-1003907117629:<topic_id>`) instead of bare `telegram`, unless Sir requests Home/DM delivery.
- Keep topic-policy data durable here; do not rely on long chat history alone.

## Context policy
- Do not increase visible-message/context retention just to remember topic purpose. Use this card plus per-topic channel prompts.
- Keep `compression.protect_last_n` moderately sized for recent conversational continuity; raise it only if recurring topic-local decisions are being lost before they are written to this card or `90_decisions_log.md`.

## Open questions
- Confirm human-readable names and policies for topics `2`, `3`, `4`, `5`, `8`, `10`, `19`, `20`.
- Decide whether to add a dedicated Security/Permissions topic or keep it under Topic 11.
- Decide whether to add a dedicated Coding/System-Debugging topic for script-level work.
'''
card.write_text(content)

# Patch README index if absent
readme=jm/'README.md'
txt=readme.read_text()
if '02_telegram_topics.md' not in txt:
    txt=txt.replace('- `01_agent_system.md` — local agent/tool/model system context.\n', '- `01_agent_system.md` — local agent/tool/model system context.\n- `02_telegram_topics.md` — Telegram topic map and routing policy for JARVIS Command Center.\n')
    txt=txt.replace('_Last updated: 2026-05-13_', '_Last updated: 2026-05-14_', 1)
    readme.write_text(txt)

# Patch agent system load rules/data sources
agent=jm/'01_agent_system.md'
txt=agent.read_text()
txt=txt.replace('_Last updated: 2026-05-13_', '_Last updated: 2026-05-14_', 1)
if 'Telegram topic routing or JARVIS Command Center structure' not in txt:
    txt=txt.replace('- Any system architecture, agent routing, cron, MCP, skill, or model decision\n', '- Any system architecture, agent routing, cron, MCP, skill, or model decision\n- Telegram topic routing or JARVIS Command Center structure\n')
if '- ~/jarvis_memory/02_telegram_topics.md' not in txt:
    txt=txt.replace('- ~/jarvis_memory/\n', '- ~/jarvis_memory/\n- ~/jarvis_memory/02_telegram_topics.md\n')
agent.write_text(txt)

# Append decision log entry
log=jm/'90_decisions_log.md'
txt=log.read_text()
txt=txt.replace('_Last updated: 2026-05-13_', '_Last updated: 2026-05-14_', 1)
entry='''\n## 2026-05-14 — Telegram topic routing policy\nDecision: `JARVIS Command Center` Telegram topics are treated as separate sessions with explicit routing. Topic 11 is the architecture/governance lane; concrete individual script debugging belongs in a coding/system/debugging lane, not Topic 11. Topic policies are stored in `02_telegram_topics.md` and reinforced via Telegram channel prompts.\nRationale: prevents memory bleed, keeps automation outputs and architecture decisions separated, and allows cron jobs to target exact topics.\nOwner: Sir / JARVIS.\n'''
if '2026-05-14 — Telegram topic routing policy' not in txt:
    log.write_text(txt.rstrip()+entry)

# Update Hermes config with per-topic channel prompts for known topics, both top-level and gateway telegram blocks.
cfg_path=Path('/home/agent/.hermes/config.yaml')
cfg=yaml.safe_load(cfg_path.read_text())
chat='-1003907117629'
prompts={
 '6': 'Telegram Topic 6: Inbox / General Triage. Use for quick commands, unclassified intake, and routing. If a more suitable JARVIS Command Center topic is clear, recommend the topic switch or, if explicitly requested, answer in the correct topic via messaging. Keep replies concise unless asked.',
 '11': 'Telegram Topic 11: JARVIS System – Architektur. Use only for overall JARVIS/Hermes/FRIDAY architecture, Telegram topic structure, memory concept, model routing, subagents, OpenClaw/Codex, cost optimisation, and security/permission concepts. Do not do concrete individual script debugging here; recommend or route to a coding/system/debugging topic.',
 '16': 'Telegram Topic 16: Automationen / Cronjobs. Use for scheduled jobs, briefings, recurring reports, checks, reminders, watchdogs, automation outputs, cron delivery design, and monitoring summaries. Prefer explicit cron delivery targets with this thread id when relevant.',
 '17': 'Telegram Topic 17: Research / AI / Tools. Use for AI/tool research, model comparisons, papers, external sources, tech reconnaissance, and non-operational research notes. Keep operational automation/debugging out unless explicitly tied to tool evaluation.',
}
# include aliases: thread id and full chat:thread target, because resolver uses thread_id but this documents both forms.
map_prompts={}
for tid,p in prompts.items():
    map_prompts[tid]=p
    map_prompts[f'{chat}:{tid}']=p
for section in [('telegram',), ('gateway','telegram')]:
    node=cfg
    for key in section:
        node=node.setdefault(key,{})
    cp=node.setdefault('channel_prompts',{})
    if cp is None or not isinstance(cp, dict):
        cp={}
        node['channel_prompts']=cp
    cp.update(map_prompts)
# Preserve YAML readability
cfg_path.write_text(yaml.safe_dump(cfg, sort_keys=False, allow_unicode=True))
print('Implemented: wrote 02_telegram_topics.md, patched README/01_agent_system/90_decisions_log, updated telegram channel_prompts for topics 6/11/16/17 in config.yaml.')
print('Note: gateway restart is required for channel_prompts to take effect in future sessions.')


Output:
Implemented: wrote 02_telegram_topics.md, patched README/01_agent_system/90_decisions_log, updated telegram channel_prompts for topics 6/11/16/17 in config.yaml.
Note: gateway restart is required for channel_prompts to take effect in future sessions.


terminal

python - <<'PY'
import yaml
from pathlib import Path
cfg=yaml.safe_load(Path('/home/agent/.hermes/config.yaml').read_text())
for sec in [('telegram',),('gateway','telegram')]:
    node=cfg
    for k in sec: node=node[k]
    print('.'.join(sec), sorted(node.get('channel_prompts',{}).keys()))
print('protect_last_n', cfg.get('compression',{}).get('protect_last_n'))
print('session_reset', cfg.get('session_reset'))
PY


     1|# 02 Telegram Topics
     2|
     3|_Last updated: 2026-05-14_
     4|
     5|## Purpose
     6|Canonical topic map and routing policy for the Telegram group **JARVIS Command Center**. Use this card for topic selection, cross-topic routing, cron delivery targets, and session boundaries.
     7|
     8|## Load when
     9|- User asks about Telegram topic structure, routing, cron delivery, gateway sessions, or where a task belongs.
    10|- A request appears to be in the wrong topic and needs a topic-change recommendation.
    11|- Creating or updating cron jobs, reports, briefings, or automated notifications.
    12|
    13|## Stable facts
    14|- Telegram group: `JARVIS Command Center`, chat id `-1003907117629`.
    15|- Hermes sees Telegram topics as separate targets/sessions via `chat_id:thread_id`.
    16|- Known topic targets currently discovered:
    17|  - `-1003907117629:6` — Inbox / general triage.
    18|  - `-1003907117629:11` — JARVIS System – Architektur.
    19|  - `-1003907117629:16` — Automationen / Cronjobs.
    20|  - `-1003907117629:17` — Research / AI / Tools.
    21|  - Additional discovered topics without confirmed names yet: `2`, `3`, `4`, `5`, `8`, `10`, `19`, `20`.
    22|
    23|## Topic policies
    24|### Topic 6 — Inbox / General Triage
    25|Use for quick commands, unclassified requests, ad-hoc intake, and routing decisions. If a better specialist topic is clear, recommend the move or answer in the requested/obvious target topic.
    26|
    27|### Topic 11 — JARVIS System – Architektur
    28|Use for overall JARVIS/Hermes/FRIDAY architecture: agent architecture, Telegram topic structure, memory concept, model routing, subagents, OpenClaw, Codex, cost optimisation, and security/permission concepts.
    29|Do **not** use for concrete debugging of individual scripts; route those to a coding/system/debugging topic.
    30|
    31|### Topic 16 — Automationen / Cronjobs
    32|Use for scheduled jobs, briefings, recurring reports, checks, reminders, watchdogs, automation outputs, cron delivery design, and monitoring summaries.
    33|
    34|### Topic 17 — Research / AI / Tools
    35|Use for AI/tool research, model comparisons, new tools, papers, external sources, market/tech reconnaissance, and non-operational research notes.
    36|
    37|## Routing rules
    38|- Treat each topic as its own session and answer only in the active/requested topic unless the user explicitly asks for cross-topic delivery or the correct target is obvious.
    39|- When the user asks something in the wrong topic, prefer a short recommendation: “Besser in Topic X”. If the user asks to answer in the correct topic, send the substantive answer to that topic and keep only a short handoff note in the original topic.
    40|- For cron jobs, prefer explicit delivery targets (`telegram:-1003907117629:<topic_id>`) instead of bare `telegram`, unless Sir requests Home/DM delivery.
    41|- Keep topic-policy data durable here; do not rely on long chat history alone.
    42|
    43|## Context policy
    44|- Do not increase visible-message/context retention just to remember topic purpose. Use this card plus per-topic channel prompts.
    45|- Keep `compression.protect_last_n` moderately sized for recent conversational continuity; raise it only if recurring topic-local decisions are being lost before they are written to this card or `90_decisions_log.md`.
    46|
    47|## Open questions
    48|- Confirm human-readable names and policies for topics `2`, `3`, `4`, `5`, `8`, `10`, `19`, `20`.
    49|- Decide whether to add a dedicated Security/Permissions topic or keep it under Topic 11.
    50|- Decide whether to add a dedicated Coding/System-Debugging topic for script-level work.
    51|


Output:
telegram ['-1003907117629:11', '-1003907117629:16', '-1003907117629:17', '-1003907117629:6', '11', '16', '17', '6']
gateway.telegram ['-1003907117629:11', '-1003907117629:16', '-1003907117629:17', '-1003907117629:6', '11', '16', '17', '6']
protect_last_n 16
session_reset {'at_hour': 4, 'idle_minutes': 1440, 'mode': 'both'}


Erledigt, Sir.

Ich habe die Topic-Struktur jetzt **dauerhaft umgesetzt** — nicht nur im Chat-Verlauf, denn der ist bekanntlich so zuverlässig wie ein Praktikant mit Root-Rechten.

## Umgesetzt

Ich habe eine neue Domain Card angelegt:

`~/jarvis_memory/02_telegram_topics.md`

Darin gespeichert:

- Telegram-Gruppe: **JARVIS Command Center**
- Chat-ID: `-1003907117629`
- Topic-Zuordnung:
  - **6** — Inbox / General Triage
  - **11** — JARVIS System – Architektur
  - **16** — Automationen / Cronjobs
  - **17** — Research / AI / Tools
  - weitere bekannte, aber noch unbenannte Topics: `2`, `3`, `4`, `5`, `8`, `10`, `19`, `20`
- Routing-Regeln:
  - Topics als getrennte Sessions behandeln
  - bei falschem Topic Topicwechsel empfehlen
  - wenn gewünscht/naheliegend, Antwort direkt in den richtigen Topic-Kanal senden
  - Cronjobs mit explizitem Target wie `telegram:-1003907117629:16` statt nur `telegram`

Zusätzlich aktualisiert:

- `~/jarvis_memory/README.md`
- `~/jarvis_memory/01_agent_system.md`
- `~/jarvis_memory/90_decisions_log.md`
- `~/.hermes/config.yaml` mit **Telegram channel_prompts** für Topics `6`, `11`, `16`, `17`

## Wichtig: Gateway-Neustart nötig

Die neuen `channel_prompts` in der Hermes-Konfiguration greifen erst nach Gateway-Neustart.

Ich habe den Gateway **nicht** selbst neugestartet, weil das laufende Sessions unterbrechen kann.
Du kannst danach einfach im Telegram-Gateway senden:

`/restart`

Oder ich mache es, wenn du es ausdrücklich willst.

## Kontextlänge / sichtbare Messages

Aktueller Stand:

- `compression.protect_last_n`: **16 Messages**
- Session Reset:
  - täglich um 04:00
  - oder nach 24h Idle
- Compression aktiv ab ca. 40% Kontext

Meine Empfehlung: **nicht blind verlängern.**

Für Topic-Überblick ist besser:

1. **dauerhafte Topic Policy Card** — jetzt umgesetzt
2. **per-topic channel_prompts** — jetzt umgesetzt
3. wichtige Architekturentscheide in `90_decisions_log.md`
4. nur bei Bedarf `protect_last_n` erhöhen

Warum? Wenn wir einfach sichtbare Messages stark erhöhen, kostet das dauerhaft mehr Tokens und macht Antworten langsamer. Architekturwissen gehört in Memory/Card, nicht in endlosen Chatverlauf. Barbarisch effizient.

## Falls wir doch verlängern wollen

Wenn du merkst, dass ich innerhalb eines Topics wiederholt Kontext verliere, wäre mein Vorschlag:

```yaml
compression:
  protect_last_n: 24
```

Nicht gleich 64 oder 100. Erst 24, maximal 32. Alles darüber ist meist nur teure Nostalgie.

## Neues Routing-Verhalten

Ab jetzt soll ich so arbeiten:

- Frage gehört hier in **Topic 11 Architektur** → ich antworte hier.
- Frage gehört offensichtlich nach **Automationen/Cronjobs** → ich empfehle Topic 16 oder sende dort, wenn du das willst.
- Frage gehört nach **Research/AI/Tools** → Topic 17.
- Unklare oder schnelle Kommandos → Topic 6 Inbox.
- Einzelnes Script-Debugging → nicht hier; ich empfehle passenden Coding/System-Debugging-Thread, sobald du dessen Topic-ID/Namen bestätigst.

Nächster sinnvoller Schritt: Du gibst mir noch die Namen/Zwecke der Topics `2`, `3`, `4`, `5`, `8`, `10`, `19`, `20`, dann mache ich die Topic Map vollständig.