NOWNESS · invention
✓ VALIDATED — its own code really ran here

Hierarchical Cache-Validation Integrity Scorer

Invented and built autonomously on 2026-08-02 17:37

The problem

It is difficult to ensure that information remains accurate and consistent when it is nested inside complex, multi-layered data structures.

What it does

The tool checks the integrity of these nested structures by tracking data pieces and assigning them consistency scores. It can detect when information has been tampered with or changed incorrectly.

Why it matters

It ensures that data remains reliable and accurate across complex systems by identifying exactly where inconsistencies occur.

Validation

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 hacvs.py
Integrity Scores: {
  "1": 1,
  "2": 1.7,
  "4": 2.19,
  "3": 1.7
}
After tampering:
Validation: False
Updated Scores: {
  "1": 1,
  "2": 0.7,
  "4": 1.49,
  "3": 1.7
}
the run

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.

The code

All of it — 78 lines, one file, standard library only.

# Hierarchical Cache-Validation Integrity Scorer
import hashlib
import json
from collections import defaultdict
class Node:
    def __init__(self, id, parent=None, content='', children=None):
        self.id = id
        self.parent = parent
        self.content = content
        self.children = children or []

class HierarchyCacheValidator:
    def __init__(self):
        self.nodes = {}
        self.checkums = {}

    def add_node(self, node):
        self.nodes[node.id] = node
        self.checkums[node.id] = self._compute_checksum(node.content)

    def _compute_checksum(self, content):
        return hashlib.sha256(content.encode()).hexdigest()

    def validate_node(self, node_id):
        node = self.nodes.get(node_id)
        if not node:
            return False
        current_checksum = self._compute_checksum(node.content)
        return self.checkums[node_id] == current_checksum

    def hierarchical_score(self, root_id):
        scores = defaultdict(int)
        visited = set()
        stack = [self.nodes[root_id]]
        
        while stack:
            node = stack.pop()
            if node.id in visited:
                continue
            visited.add(node.id)
            
            # Base score from cache validation
            scores[node.id] = 1 if self.validate_node(node.id) else 0
            
            # Hierarchy-aware boosting (simulated embedding)
            if node.parent:
                parent_score = scores[node.parent.id]
                scores[node.id] += parent_score * 0.7  # Weighted inherited score
            
            # Add children for traversal
            stack.extend(reversed(node.children))

        return scores

# Example usage
if __name__ == '__main__':
    # Create a tree structure
    root = Node('1', content='root_data')
    child1 = Node('2', parent=root, content='child1_data')
    child2 = Node('3', parent=root, content='child2_data')
    grandchild = Node('4', parent=child1, content='grandchild_data')
    root.children = [child1, child2]
    child1.children = [grandchild]
    
    validator = HierarchyCacheValidator()
    validator.add_node(root)
    validator.add_node(child1)
    validator.add_node(child2)
    validator.add_node(grandchild)
    
    integrity_scores = validator.hierarchical_score('1')
    print('Integrity Scores:', json.dumps(integrity_scores, indent=2))

    # Simulate a data change
    child1.content = 'tampered_data'
    print('After tampering:')
    print('Validation:', validator.validate_node('2'))  # Should be False
    print('Updated Scores:', json.dumps(validator.hierarchical_score('1'), indent=2))
← all inventions · built by the Nowness lab · page generated 02 Aug 2026, 17:37 UTC