Update .gitignore to exclude Python-related files and directories. Enhance AGENTS.md and README.md with clarifications on documentation structure and product identity. Add technical architecture references and local setup instructions. Revise privacy guardrails and product identity documents for consistency. Remove obsolete memory and context documentation. Expand reflection spaces documentation to define context boundaries and lifecycle. Ensure all changes align with the ongoing development of the Kanshō project.

This commit is contained in:
Lars committed 2026-08-21 15:48:43 +02:00
1 parent 3a367b7bcc
commit d62673e48b
89 files changed
+13463 -241

No files matched your search

+71
View File
@@ -0,0 +1,71 @@
"""Context placeholders {{key}}. Implementations register here; templates never define ad-hoc keys."""
from __future__ import annotations
import re
from dataclasses import dataclass
from typing import Any, Callable
CONTEXT_PATTERN = re.compile(r"\{\{([a-z][a-z0-9_]*)\}\}")
class PlaceholderError(Exception):
def __init__(self, code: str, message: str):
super().__init__(message)
self.code = code
self.message = message
@dataclass(frozen=True)
class Placeholder:
key: str
description: str
data_class: str
resolver: Callable[[dict[str, Any]], Any]
_REGISTRY: dict[str, Placeholder] = {}
def register(placeholder: Placeholder) -> None:
if placeholder.data_class == "A":
raise PlaceholderError(
"class_a_context_key_forbidden",
"Klasse-A-Werte gehören nicht in {{key}}-Kontext. Identität läuft über [[…]].",
)
_REGISTRY[placeholder.key] = placeholder
def get(key: str) -> Placeholder | None:
return _REGISTRY.get(key)
def list_placeholders() -> list[dict]:
return [
{
"key": item.key,
"description": item.description,
"data_class": item.data_class,
"syntax": f"{{{{{item.key}}}}}",
}
for item in sorted(_REGISTRY.values(), key=lambda item: item.key)
]
def extract_keys(template: str) -> list[str]:
return CONTEXT_PATTERN.findall(template or "")
def resolve_template(template: str, context: dict[str, Any]) -> str:
keys = extract_keys(template)
unknown = sorted({key for key in keys if key not in _REGISTRY})
if unknown:
raise PlaceholderError(
"unknown_placeholder",
"Unbekannte Kontext-Platzhalter: " + ", ".join(f"{{{{{key}}}}}" for key in unknown),
)
rendered = template
for key in keys:
spec = _REGISTRY[key]
value = spec.resolver(context)
rendered = rendered.replace("{{" + key + "}}", "" if value is None else str(value))
return rendered