Deterministic context slicing with cryptographic admissibility verification for conversation DAGs
Project description
admissibility-kernel
Python bindings for the Admissibility Kernel - deterministic context slicing with cryptographic verification for conversation DAGs.
Installation
pip install admissibility-kernel
Quick Start
from admissibility_kernel import (
AdmissibilityKernel,
Role,
Phase,
EdgeType,
)
# Create a kernel instance
kernel = AdmissibilityKernel(
hmac_secret=b"my_secret_key_32bytes_minimum!!!",
max_nodes=100,
max_radius=5,
)
# Add turns to the graph
kernel.add_turn(
turn_id="550e8400-e29b-41d4-a716-446655440001",
session_id="session_1",
role=Role.User,
phase=Phase.Exploration,
salience=0.8,
)
kernel.add_turn(
turn_id="550e8400-e29b-41d4-a716-446655440002",
session_id="session_1",
role=Role.Assistant,
phase=Phase.Consolidation,
salience=0.9,
)
# Add edges
kernel.add_edge(
parent_id="550e8400-e29b-41d4-a716-446655440001",
child_id="550e8400-e29b-41d4-a716-446655440002",
edge_type=EdgeType.Reply,
)
# Get a context slice
slice_export = kernel.slice("550e8400-e29b-41d4-a716-446655440002")
print(f"Slice ID: {slice_export.slice_id}")
print(f"Contains {slice_export.num_turns} turns")
print(f"Turn IDs: {slice_export.turn_ids}")
# Verify the slice
is_valid = kernel.verify(slice_export)
print(f"Token valid: {is_valid}")
Low-Level API
For more control, use the individual components:
from admissibility_kernel import (
InMemoryGraphStore,
ContextSlicer,
SlicePolicy,
TurnSnapshot,
Edge,
TokenVerifier,
Role,
Phase,
EdgeType,
)
# Create store and add data
store = InMemoryGraphStore()
turn = TurnSnapshot(
turn_id="550e8400-e29b-41d4-a716-446655440001",
session_id="session_1",
role=Role.User,
phase=Phase.Consolidation,
salience=0.8,
depth=1,
sibling_index=0,
homogeneity=0.5,
temporal=0.5,
complexity=1.0,
created_at=1000,
)
store.add_turn(turn)
# Configure policy
policy = SlicePolicy(
max_nodes=256,
max_radius=10,
salience_weight=0.3,
distance_decay=0.9,
)
# Create slicer with HMAC secret
secret = b"my_secret_key_32bytes_minimum!!!"
slicer = ContextSlicer(store, policy, list(secret))
# Get slice
slice_export = slicer.slice("550e8400-e29b-41d4-a716-446655440001")
# Verify with TokenVerifier
verifier = TokenVerifier(list(secret))
is_valid = verifier.verify(slice_export)
Features
- Deterministic slicing: Same input always produces identical output
- HMAC-signed tokens: Cryptographic verification of slice integrity
- Priority-queue BFS: Novel algorithm for context boundary expansion
- Phase-aware scoring: Synthesis > Consolidation > Exploration weighting
- High performance: Rust core with Python bindings
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file admissibility_kernel-0.1.0.tar.gz.
File metadata
- Download URL: admissibility_kernel-0.1.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de1c9d273f886ffccefddd5716e788f52acf90ee45f308dae102aa1931525c74
|
|
| MD5 |
0f60127ecdcc604916cd18339fc39ac4
|
|
| BLAKE2b-256 |
7d8032061d22493b7bba00cab11026388d00136095b4dc338ffc311ef2cba14f
|
File details
Details for the file admissibility_kernel-0.1.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: admissibility_kernel-0.1.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 431.9 kB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea9328adbcc40b51e9a79eae34df7a90577dafa856d9abb6b872ab1aa91cf752
|
|
| MD5 |
c37caf4cb3a7db320dccef0034cfc7f1
|
|
| BLAKE2b-256 |
019dedb777538833fc2376bdcc8bb76508cda77333a12263675d6dc26e8d1e62
|