This repository has been archived on 2026-04-16. You can view files and clone it, but cannot push or open issues or pull requests.
substrate-sdk-python/substrate_sdk/context.py
Tyler King 89a054d656 initial: substrate-sdk-python v0.1.0
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.
2026-03-18 13:53:58 -04:00

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}"