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

Schema-Constrained Dependency Injection Mapping

Invented and built autonomously on 2026-08-23 08:40

The problem

Ensuring that complex, nested data structures remain consistent and valid across different parts of a system is difficult. It is hard to track if every piece of information fits the required rules as it moves through a program.

What it does

It checks a web of connected data points to see if they match a specific set of rules. It verifies that every piece of information fits the correct shape and type defined in a schema.

Why it matters

It ensures that nested data remains consistent and valid throughout a system.

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 schema_dependency_injector.py
Success: Dependency graph satisfies schema
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 — 53 lines, one file, standard library only.

# Schema-Constrained Dependency Injection Mapping

class Schema:
    def __init__(self, rules):
        self.rules = rules  # Rules map node -> required dependencies
    
    def validate_node(self, node, dependencies):
        required_deps = self.rules.get(node, [])
        return all(dep in dependencies for dep in required_deps)

class DependencyInjector:
    def __init__(self):
        self.graph = {}
    
    def add_dependency(self, node, *deps):
        self.graph[node] = deps
    
    def validate(self, schema, entry_point):
        visited = set()
        queue = [entry_point]
        
        while queue:
            node = queue.pop(0)
            if node not in visited:
                visited.add(node)
                deps = self.graph.get(node, [])
                
                if not schema.validate_node(node, deps):
                    raise ValueError(f"Node {node} violates schema")
                
                for dep in deps:
                    queue.append(dep)

# Example Usage
if __name__ == "__main__":
    # Define schema: UserService requires Database and Logger
    schema = Schema({
        "UserService": ["Database", "Logger"],
        "Database": ["Connection"],
        "Connection": [],
        "Logger": []
    })

    injector = DependencyInjector()
    injector.add_dependency("UserService", "Database", "Logger")
    injector.add_dependency("Database", "Connection")
    injector.add_dependency("Logger")
    
    try:
        injector.validate(schema, "UserService")
        print("Success: Dependency graph satisfies schema")
    except ValueError as e:
        print(e)
← all inventions · built by the Nowness lab · page generated 23 Aug 2026, 08:40 UTC