It is difficult to verify if a sequence of data changes has been tampered with or remains consistent over time. Tracking these changes manually makes it hard to spot where a record was altered.
It links every change in a sequence together like a chain and assigns a reliability score to each step. It automatically flags any part of the history that doesn't match the expected pattern.
It provides a clear way to verify the integrity of a timeline of events.
It was run inside an isolated container with no network access. This is the exact command and the real output it produced — captured process output, not written by a model.
$ python3 audit_tool.py Temporal-Audit-Resilience Trust Score: 16.38/100 Chain Validation Results: State 1: ✓ - Hash: 3cddda7d... State 2: ✓ - Hash: 0979ee31... State 3: ✗ - Hash: 18491fc6... State 4: ✓ - Hash: b4fc2a1c... State 5: ✓ - Hash: 9fc7e911...
A screenshot of that run.
A clean run proves this does what is shown above, in a CPU-only sandbox. It is a small research demo — not a production tool, and nothing here was published anywhere.
All of it — 94 lines, one file, standard library only.
#!/usr/bin/env python3
import hashlib
import json
import time
class HashChainedState:
def __init__(self, previous_hash, current_data):
self.previous_hash = previous_hash
self.current_data = current_data
self.timestamp = time.time()
self.hash = self.calculate_hash()
self.success = current_data.get('success', True)
def calculate_hash(self):
data_str = json.dumps(self.current_data, sort_keys=True)
prev_hash = self.previous_hash if self.previous_hash else ''
input_str = prev_hash + data_str + str(self.timestamp)
return hashlib.sha256(input_str.encode()).hexdigest()
def calculate_resilience_score(transitions):
"""
Recursive trust decay algorithm from State-Dynamic-Resilience
"""
if not transitions:
return 0.0
base_score = 100.0
decay_rate = 0.8 # 20% trust decay per transition
current_score = base_score
for i, transition in enumerate(transitions):
# Apply decay based on position and success
if not transition.success:
current_score *= 0.5 # 50% penalty for failed transition
current_score *= decay_rate
# Prevent score from dropping below minimum
current_score = max(current_score, 10.0)
return current_score
def calculate_trust_score(chain):
"""
Combines hash chain integrity verification with resilience scoring
"""
# Verify chain integrity
chain_valid = True
last_hash = None
for transition in chain:
calculated_hash = transition.calculate_hash()
if transition.hash != calculated_hash:
chain_valid = False
break
last_hash = transition.hash
if not chain_valid:
return 0.0 # Invalid chain = zero trust
# Calculate resilience score
resilience = calculate_resilience_score(chain)
return resilience
if __name__ == "__main__":
# Create a sample chain of states
chain = []
prev_hash = None
# Simulate 5 state transitions
for i in range(5):
data = {
'event': f'Event {i+1}',
'timestamp': time.time(),
'success': True,
'metadata': {
'source': 'AI Agent 01',
'impact_score': i * 0.1 + 0.5
}
}
if i == 2: # Simulate a failed transition
data['success'] = False
new_state = HashChainedState(prev_hash, data)
chain.append(new_state)
prev_hash = new_state.hash
# Calculate and display trust score
trust_score = calculate_trust_score(chain)
print(f"Temporal-Audit-Resilience Trust Score: {trust_score:.2f}/100")
print("\nChain Validation Results:")
for i, state in enumerate(chain):
status = "✓" if state.success else "✗"
print(f"State {i+1}: {status} - Hash: {state.hash[:8]}...")