Python SDK for shellbound Django applications. Provides ShellApp, ShardContext, ShellboundMiddleware. Emits Chronicle events to stdout in dev mode. Includes fix for IndexError in apps.py when DJANGO_SETTINGS_MODULE has no dots (e.g. instance_settings). Shard name now falls back safely without eager default argument parsing. Implements SHELLBOUND-APP-0001 §4 (dev mode). Wired into entropyopposition as of 2026-03-18.
27 lines
736 B
Python
27 lines
736 B
Python
"""Shard context — identity and governance state from shell registration."""
|
|
|
|
from dataclasses import dataclass, field
|
|
import uuid
|
|
|
|
|
|
@dataclass
|
|
class ShardContext:
|
|
"""Context returned by ShellApp.register().
|
|
|
|
Holds all identity and governance information for this shard instance.
|
|
"""
|
|
|
|
shard_name: str
|
|
shard_id: str = field(default_factory=lambda: str(uuid.uuid4()))
|
|
shard_did: str = ""
|
|
svid: str = ""
|
|
accord_hash: str = ""
|
|
ffc_did: str = ""
|
|
is_governed: bool = False
|
|
language: str = "python"
|
|
version: str = "0.0.0"
|
|
|
|
@property
|
|
def actor_did(self) -> str:
|
|
"""The DID for events from this shard."""
|
|
return self.shard_did or f"did:web:local:shard:{self.shard_name}"
|