Skip to content

Python Core Analysis Reference

Toprak Ahmet Aydoğmuş edited this page Nov 30, 2026 · 2 revisions

T-Zero Algorithm Python Analysis Reference

Coverage: 22 modules | 119 classes | 346 functions | 13822 source lines.

Generated from the canonical Python package in the T-Zero Algorithm source tree.

Scope: Analysis, quality, policy, dependency, security, graph, contract, budget, and measurement modules. Source docstrings are not independent validation of their claims.

How to read this reference

  • Declarations are extracted from Python AST and linked to source line ranges.
  • Signatures show parsed arguments and annotations. Defaults are quoted after personal-identifier, contact, and wallet redaction.
  • Docstrings are source text, not independently verified promises; personal identifiers, contact details, and wallet-like values are redacted.
  • Missing docstrings are explicitly marked. This catalog does not guess behavior.
  • This is a symbol map, not a line-by-line rewrite of every function body; use the linked implementation to inspect control flow and side effects.

tzero/tzero_arch_test.py

Source: tzero/tzero_arch_test.py
Source size: 463 lines | 1 classes | 8 functions

Module docstring:

T-Zero Automated Architecture Test Suite Generator & Validator.

Generates self-contained, zero-dependency `unittest` test suites from `tzero.rules.json`
enforcing layer boundaries, circular import prohibition, and zero-leak security
in standard CI/CD pipelines without external frameworks.

Author: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v10.8.0 Master Edition.

_should_skip_dir

Kind: Function
Source: tzero/tzero_arch_test.py:27-35

Signature:

def _should_skip_dir(dir_name: str) -> bool:

Source docstring:

Returns True if the directory should be skipped during AST analysis.

_extract_ast_imports

Kind: Function
Source: tzero/tzero_arch_test.py:38-73

Signature:

def _extract_ast_imports(filepath: str, rel_p: str, top_level_only: bool = False) -> Set[Tuple[str, int]]:

Source docstring:

Extracts imported module names and their line numbers from a python file.

ArchitectureTestSuiteGenerator

Kind: Class
Source: tzero/tzero_arch_test.py:76-463

Declaration:

class ArchitectureTestSuiteGenerator:

Source docstring:

Generates and executes zero-dependency architectural guard test suites.

ArchitectureTestSuiteGenerator.__init__

Kind: Method
Source: tzero/tzero_arch_test.py:79-82

Signature:

def __init__(self, project_dir: str = '.', rules_path: Optional[str] = None):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ArchitectureTestSuiteGenerator._load_rules

Kind: Method
Source: tzero/tzero_arch_test.py:84-116

Signature:

def _load_rules(self) -> Dict[str, Any]:

Source docstring:

Loads rules from tzero.rules.json or returns sensible enterprise defaults.

ArchitectureTestSuiteGenerator.generate_test_code

Kind: Method
Source: tzero/tzero_arch_test.py:118-325

Signature:

def generate_test_code(self) -> str:

Source docstring:

Generates the full Python source code for the standalone architecture test suite.

ArchitectureTestSuiteGenerator.write_test_file

Kind: Method
Source: tzero/tzero_arch_test.py:327-338

Signature:

def write_test_file(self, target_path: Optional[str] = None) -> str:

Source docstring:

Writes the generated architecture test file to disk.

ArchitectureTestSuiteGenerator.run_live_audit

Kind: Method
Source: tzero/tzero_arch_test.py:340-463

Signature:

def run_live_audit(self) -> Dict[str, Any]:

Source docstring:

Runs in-memory live validation of layer rules, circular imports, and zero-leak security.

ArchitectureTestSuiteGenerator.run_live_audit.dfs

Kind: Nested function
Source: tzero/tzero_arch_test.py:414-426

Signature:

def dfs(node: str, path: List[str]):

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_benchmark.py

Source: tzero/tzero_benchmark.py
Source size: 477 lines | 5 classes | 6 functions

Module docstring:


Siber Akademi — T-Zero Autonomous Benchmark & Performance Optimization Engine.
Developer: [redacted] (Siber Akademi)
Version: 12.3.4
License: MIT

Performs quantitative multi-model benchmarks comparing raw codebase context
against T-Zero AST-compressed representations across Claude 3.5 Sonnet, GPT-4o,
Gemini 1.5 Pro, and DeepSeek V3. Generates ANSI terminal views, JSON metrics,
Markdown summaries, and vector-animated macOS terminal recordings for READMEs.

TierMetric

Kind: Class
Source: tzero/tzero_benchmark.py:26-32

Declaration:

class TierMetric:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ModelBenchmarkItem

Kind: Class
Source: tzero/tzero_benchmark.py:36-44

Declaration:

class ModelBenchmarkItem:

Source docstring: none; consult the linked implementation instead of inferring behavior.

BenchmarkReport

Kind: Class
Source: tzero/tzero_benchmark.py:48-64

Declaration:

class BenchmarkReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TZeroBenchmarkEngine

Kind: Class
Source: tzero/tzero_benchmark.py:67-401

Declaration:

class TZeroBenchmarkEngine:

Source docstring:

Enterprise AST Context & Multi-Model Benchmark Engine.

TZeroBenchmarkEngine.run_benchmark

Kind: Method
Source: tzero/tzero_benchmark.py:80-176

Signature:

def run_benchmark(cls, workspace_dir: str = '.') -> BenchmarkReport:

Source docstring:

Executes full multi-tier benchmark on the target workspace.

TZeroBenchmarkEngine.render_cli

Kind: Method
Source: tzero/tzero_benchmark.py:179-214

Signature:

def render_cli(cls, rep: BenchmarkReport) -> None:

Source docstring:

Renders rich ANSI terminal output resembling macOS terminal.

TZeroBenchmarkEngine.generate_animated_svg

Kind: Method
Source: tzero/tzero_benchmark.py:217-374

Signature:

def generate_animated_svg(cls, rep: BenchmarkReport, output_file: str = 'assets/tzero_terminal_benchmark.svg') -> str:

Source docstring:

Generates a stunning, pixel-perfect animated macOS terminal SVG recording.

TZeroBenchmarkEngine.export_markdown_table

Kind: Method
Source: tzero/tzero_benchmark.py:377-401

Signature:

def export_markdown_table(cls, rep: BenchmarkReport) -> str:

Source docstring:

Generates comprehensive markdown table for README.

JarvisBenchmarkOptimizer

Kind: Class
Source: tzero/tzero_benchmark.py:404-441

Declaration:

class JarvisBenchmarkOptimizer:

Source docstring:

Jarvis Autonomous Context Auto-Tuner & Optimization Agent.

JarvisBenchmarkOptimizer.auto_tune_context

Kind: Method
Source: tzero/tzero_benchmark.py:408-441

Signature:

def auto_tune_context(cls, workspace_dir: str = '.', target_token_budget: int = 64000) -> Dict[str, Any]:

Source docstring:

Autonomously analyzes codebase size and tunes compression tiers.

main

Kind: Function
Source: tzero/tzero_benchmark.py:444-473

Signature:

def main():

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_blackboard.py

Source: tzero/tzero_blackboard.py
Source size: 257 lines | 4 classes | 16 functions

Module docstring:


Siber Akademi — T-Zero Multi-Agent Swarm Blackboard & In-Memory Working Memory.
Developer: [redacted] (Siber Akademi)
License: AGPL-3.0-only

Provides thread-safe inter-agent blackboard communication, symbol-level reservation locks,
shared architectural invariants, and zero-token AST context caching for multi-agent swarms.
100% Free, Zero External Dependencies, 100% Zero-Leak Certified.

BlackboardEntry

Kind: Class
Source: tzero/tzero_blackboard.py:23-29

Declaration:

class BlackboardEntry:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolLock

Kind: Class
Source: tzero/tzero_blackboard.py:33-37

Declaration:

class SymbolLock:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SharedInvariant

Kind: Class
Source: tzero/tzero_blackboard.py:41-46

Declaration:

class SharedInvariant:

Source docstring: none; consult the linked implementation instead of inferring behavior.

MultiAgentBlackboard

Kind: Class
Source: tzero/tzero_blackboard.py:49-251

Declaration:

class MultiAgentBlackboard:

Source docstring:

Thread-safe, high-speed shared working memory for autonomous agent swarms.

MultiAgentBlackboard.__init__

Kind: Method
Source: tzero/tzero_blackboard.py:55-61

Signature:

def __init__(self, workspace_root: str = '.'):

Source docstring: none; consult the linked implementation instead of inferring behavior.

MultiAgentBlackboard.get_instance

Kind: Method
Source: tzero/tzero_blackboard.py:64-68

Signature:

def get_instance(cls, workspace_root: str = '.') -> 'MultiAgentBlackboard':

Source docstring: none; consult the linked implementation instead of inferring behavior.

MultiAgentBlackboard.reset_instance

Kind: Method
Source: tzero/tzero_blackboard.py:71-73

Signature:

def reset_instance(cls):

Source docstring: none; consult the linked implementation instead of inferring behavior.

MultiAgentBlackboard.claim_symbol

Kind: Method
Source: tzero/tzero_blackboard.py:78-93

Signature:

def claim_symbol(self, agent_id: str, file_path: str, symbol_name: str) -> bool:

Source docstring:

Claims exclusive modification lock for an AST symbol. Returns True if granted.

MultiAgentBlackboard.release_symbol

Kind: Method
Source: tzero/tzero_blackboard.py:95-106

Signature:

def release_symbol(self, agent_id: str, file_path: str, symbol_name: str) -> bool:

Source docstring:

Releases modification lock for an AST symbol. Returns True if successfully released.

MultiAgentBlackboard.get_active_locks

Kind: Method
Source: tzero/tzero_blackboard.py:108-111

Signature:

def get_active_locks(self) -> List[SymbolLock]:

Source docstring:

Returns list of currently held symbol locks.

MultiAgentBlackboard.post_invariant

Kind: Method
Source: tzero/tzero_blackboard.py:116-127

Signature:

def post_invariant(self, source_agent: str, description: str, severity: str = 'HIGH') -> str:

Source docstring:

Publishes an invariant rule that all swarming agents must respect.

MultiAgentBlackboard.get_invariants

Kind: Method
Source: tzero/tzero_blackboard.py:129-132

Signature:

def get_invariants(self) -> List[SharedInvariant]:

Source docstring:

Retrieves all shared invariants posted on the blackboard.

MultiAgentBlackboard.post_discovery

Kind: Method
Source: tzero/tzero_blackboard.py:137-149

Signature:

def post_discovery(self, author_agent: str, topic: str, payload: Any, tags: Optional[List[str]] = None) -> str:

Source docstring:

Appends a new discovery or progress update to the shared blackboard.

MultiAgentBlackboard.query_discoveries

Kind: Method
Source: tzero/tzero_blackboard.py:151-159

Signature:

def query_discoveries(self, topic: Optional[str] = None, tag: Optional[str] = None) -> List[BlackboardEntry]:

Source docstring:

Queries discoveries filtered by topic or tag.

MultiAgentBlackboard.cache_ast_summary

Kind: Method
Source: tzero/tzero_blackboard.py:164-168

Signature:

def cache_ast_summary(self, file_path: str, summary: str):

Source docstring:

Caches compressed AST signature so other subagents don't re-parse.

MultiAgentBlackboard.get_ast_summary

Kind: Method
Source: tzero/tzero_blackboard.py:170-174

Signature:

def get_ast_summary(self, file_path: str) -> Optional[str]:

Source docstring:

Retrieves cached AST signature for file if present.

MultiAgentBlackboard.export_status_markdown

Kind: Method
Source: tzero/tzero_blackboard.py:179-208

Signature:

def export_status_markdown(self) -> str:

Source docstring:

Produces comprehensive Markdown report of blackboard state for LLM context.

MultiAgentBlackboard.persist_to_disk

Kind: Method
Source: tzero/tzero_blackboard.py:210-226

Signature:

def persist_to_disk(self, file_path: Optional[str] = None):

Source docstring:

Persists state to JSON file.

MultiAgentBlackboard.load_from_disk

Kind: Method
Source: tzero/tzero_blackboard.py:228-251

Signature:

def load_from_disk(self, file_path: Optional[str] = None) -> bool:

Source docstring:

Loads state from JSON file if available.

get_shared_blackboard

Kind: Function
Source: tzero/tzero_blackboard.py:254-256

Signature:

def get_shared_blackboard(workspace_root: str = '.') -> MultiAgentBlackboard:

Source docstring:

Convenience accessor for the singleton MultiAgentBlackboard.

tzero/tzero_bridge.py

Source: tzero/tzero_bridge.py
Source size: 559 lines | 3 classes | 13 functions

Module docstring:


Siber Akademi — T-Zero Universal Polyglot Type & Schema Transpiler.
Developer: [redacted] (Siber Akademi)
License: MIT

Transpiles Python @dataclass and Pydantic data models into TypeScript interfaces,
Rust structs, and Go structs deterministically via AST.

ModelField

Kind: Class
Source: tzero/tzero_bridge.py:20-24

Declaration:

class ModelField:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TranspiledModel

Kind: Class
Source: tzero/tzero_bridge.py:28-36

Declaration:

class TranspiledModel:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge

Kind: Class
Source: tzero/tzero_bridge.py:39-558

Declaration:

class PolyglotTypeBridge:

Source docstring:

Deterministic Polyglot Type & Schema Transpiler.

PolyglotTypeBridge._parse_py_type

Kind: Method
Source: tzero/tzero_bridge.py:120-154

Signature:

def _parse_py_type(cls, node: ast.AST) -> Tuple[str, bool]:

Source docstring:

Returns (base_type_str, is_optional).

PolyglotTypeBridge._to_ts_type

Kind: Method
Source: tzero/tzero_bridge.py:157-170

Signature:

def _to_ts_type(cls, py_type: str, is_optional: bool) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge._to_rust_type

Kind: Method
Source: tzero/tzero_bridge.py:173-186

Signature:

def _to_rust_type(cls, py_type: str, is_optional: bool) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge._to_go_type

Kind: Method
Source: tzero/tzero_bridge.py:189-202

Signature:

def _to_go_type(cls, py_type: str, is_optional: bool) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge._to_kotlin_type

Kind: Method
Source: tzero/tzero_bridge.py:205-218

Signature:

def _to_kotlin_type(cls, py_type: str, is_optional: bool) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge._to_swift_type

Kind: Method
Source: tzero/tzero_bridge.py:221-234

Signature:

def _to_swift_type(cls, py_type: str, is_optional: bool) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge.parse_python_models

Kind: Method
Source: tzero/tzero_bridge.py:237-324

Signature:

def parse_python_models(cls, py_code: str) -> List[TranspiledModel]:

Source docstring:

Parses Python classes and generates TypeScript, Rust, and Go interfaces.

PolyglotTypeBridge.transpile_file

Kind: Method
Source: tzero/tzero_bridge.py:327-351

Signature:

def transpile_file(cls, py_file_path: str, target_lang: str = 'ts') -> str:

Source docstring:

Reads Python file and returns transpiled definitions in requested language.

PolyglotTypeBridge._camel_to_snake

Kind: Method
Source: tzero/tzero_bridge.py:354-356

Signature:

def _camel_to_snake(name: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge._map_source_type_to_python

Kind: Method
Source: tzero/tzero_bridge.py:359-426

Signature:

def _map_source_type_to_python(cls, type_str: str, source_lang: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge.reverse_transpile

Kind: Method
Source: tzero/tzero_bridge.py:429-547

Signature:

def reverse_transpile(cls, code: str, source_lang: str = 'ts', model_flavor: str = 'dataclass') -> str:

Source docstring:

Parses TypeScript interfaces, Rust structs, or Go structs and emits idiomatic Python models.

PolyglotTypeBridge.reverse_transpile._extract_brace_blocks

Kind: Nested function
Source: tzero/tzero_bridge.py:435-452

Signature:

def _extract_brace_blocks(src: str, header_re: re.Pattern) -> List[Tuple[str, str]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTypeBridge.render_cli

Kind: Method
Source: tzero/tzero_bridge.py:550-558

Signature:

def render_cli(cls, py_file: str, lang: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_budget.py

Source: tzero/tzero_budget.py
Source size: 211 lines | 2 classes | 4 functions

Module docstring:

T-Zero Autonomous AST Token Budget Enforcer & Compression Certifier.

Calculates exact token density, automatically determines the optimal multi-tier
AST pruning depth (T-1 to T-4) to fit within specified LLM context budgets,
and issues cryptographically verifiable SHA-256 compression certificates.

Capabilities:
- Dynamic context budget optimization across popular LLMs (Claude, GPT, Gemini, DeepSeek).
- Automatic tier selection (T-1 Skeletons -> T-2 Typed Signatures -> T-3 AST Tree -> T-4 Graph).
- Cryptographic SHA-256 context integrity certificate (.tzero/compression_cert.json).
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).

Author: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v12.3.4 Master Edition.

CompressionCertificate

Kind: Class
Source: tzero/tzero_budget.py:34-46

Declaration:

class CompressionCertificate:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTTokenBudgetOptimizer

Kind: Class
Source: tzero/tzero_budget.py:49-211

Declaration:

class ASTTokenBudgetOptimizer:

Source docstring:

Optimizes codebase token payloads to satisfy strict AI context window budgets.

ASTTokenBudgetOptimizer.estimate_raw_tokens

Kind: Method
Source: tzero/tzero_budget.py:66-121

Signature:

def estimate_raw_tokens(cls, workspace_root: str, max_files: int = 300) -> Tuple[int, int, str]:

Source docstring:

Calculates raw token count and aggregated content hash for the workspace.

ASTTokenBudgetOptimizer.optimize_budget

Kind: Method
Source: tzero/tzero_budget.py:124-178

Signature:

def optimize_budget(cls, workspace_root: str = '.', target_tokens: Optional[int] = None, model_name: str = 'claude-3-7') -> CompressionCertificate:

Source docstring:

Determines the optimal AST reduction tier to satisfy target token budget.

ASTTokenBudgetOptimizer.save_certificate

Kind: Method
Source: tzero/tzero_budget.py:181-189

Signature:

def save_certificate(cls, cert: CompressionCertificate, output_path: Optional[str] = None) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTTokenBudgetOptimizer.format_markdown_certificate

Kind: Method
Source: tzero/tzero_budget.py:192-211

Signature:

def format_markdown_certificate(cls, cert: CompressionCertificate) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_contracts.py

Source: tzero/tzero_contracts.py
Source size: 1114 lines | 8 classes | 24 functions

Module docstring:

T-Zero Autonomous AST Public API Contract & Semantic Versioning Guardian.

Analyzes AST signature changes between code revisions, determining if modifications
are backward-compatible or introduce breaking changes to public callers.

Capabilities:
- Detects removed public functions, methods, and classes.
- Flags added required parameters without defaults (caller breaking change).
- Detects parameter deletions, reorderings, and return type modifications.
- Recommends exact Semantic Versioning (SemVer) bump: MAJOR, MINOR, or PATCH.
- Computes Git revision contract diffs (HEAD vs uncommitted, or base_ref vs HEAD).
- 100% Offline, $0 cost, zero external dependencies (pure Python standard library).

Author: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v12.3.4 Master Edition.

SemVerBump

Kind: Class
Source: tzero/tzero_contracts.py:36-39

Declaration:

class SemVerBump(str, Enum):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ParameterContract

Kind: Class
Source: tzero/tzero_contracts.py:43-49

Declaration:

class ParameterContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

FunctionContract

Kind: Class
Source: tzero/tzero_contracts.py:53-66

Declaration:

class FunctionContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

FunctionContract.required_param_count

Kind: Method
Source: tzero/tzero_contracts.py:61-62

Signature:

def required_param_count(self) -> int:

Source docstring: none; consult the linked implementation instead of inferring behavior.

FunctionContract.param_names

Kind: Method
Source: tzero/tzero_contracts.py:65-66

Signature:

def param_names(self) -> List[str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ClassContract

Kind: Class
Source: tzero/tzero_contracts.py:70-74

Declaration:

class ClassContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ContractViolation

Kind: Class
Source: tzero/tzero_contracts.py:78-82

Declaration:

class ContractViolation:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ContractDiffReport

Kind: Class
Source: tzero/tzero_contracts.py:86-95

Declaration:

class ContractDiffReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ContractDiffReport.is_breaking

Kind: Method
Source: tzero/tzero_contracts.py:94-95

Signature:

def is_breaking(self) -> bool:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor

Kind: Class
Source: tzero/tzero_contracts.py:98-774

Declaration:

class ASTContractExtractor:

Source docstring:

Extracts public API signatures and contracts from an AST tree.

ASTContractExtractor.extract_from_code

Kind: Method
Source: tzero/tzero_contracts.py:104-127

Signature:

def extract_from_code(cls, code: str) -> Tuple[Dict[str, FunctionContract], Dict[str, ClassContract]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._extract_function

Kind: Method
Source: tzero/tzero_contracts.py:130-168

Signature:

def _extract_function(cls, node: Any) -> FunctionContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._extract_class

Kind: Method
Source: tzero/tzero_contracts.py:171-185

Signature:

def _extract_class(cls, node: ast.ClassDef) -> ClassContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._strip_comments

Kind: Method
Source: tzero/tzero_contracts.py:188-229

Signature:

def _strip_comments(cls, code: str) -> str:

Source docstring:

Removes single-line (//) and multi-line (/* */) comments preserving strings.

ASTContractExtractor._split_param_list

Kind: Method
Source: tzero/tzero_contracts.py:232-275

Signature:

def _split_param_list(raw_params: str) -> List[str]:

Source docstring:

Splits parameter string by commas outside of () [] {} <> quotes.

ASTContractExtractor._find_matching_paren

Kind: Method
Source: tzero/tzero_contracts.py:278-305

Signature:

def _find_matching_paren(text: str, start_idx: int) -> int:

Source docstring:

Given start_idx of '(', returns index of matching ')'.

ASTContractExtractor._find_matching_brace

Kind: Method
Source: tzero/tzero_contracts.py:308-335

Signature:

def _find_matching_brace(text: str, start_idx: int) -> int:

Source docstring:

Given start_idx of '{', returns index of matching '}'.

ASTContractExtractor._parse_ts_param

Kind: Method
Source: tzero/tzero_contracts.py:338-382

Signature:

def _parse_ts_param(cls, p: str) -> ParameterContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._parse_go_params

Kind: Method
Source: tzero/tzero_contracts.py:385-409

Signature:

def _parse_go_params(cls, raw: str) -> List[ParameterContract]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._parse_rust_param

Kind: Method
Source: tzero/tzero_contracts.py:412-423

Signature:

def _parse_rust_param(cls, p: str) -> Optional[ParameterContract]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._parse_java_param

Kind: Method
Source: tzero/tzero_contracts.py:426-456

Signature:

def _parse_java_param(cls, p: str) -> ParameterContract:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._extract_ts_contracts

Kind: Method
Source: tzero/tzero_contracts.py:459-584

Signature:

def _extract_ts_contracts(cls, clean_code: str, functions: Dict[str, FunctionContract], classes: Dict[str, ClassContract]) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._extract_go_contracts

Kind: Method
Source: tzero/tzero_contracts.py:587-644

Signature:

def _extract_go_contracts(cls, clean_code: str, functions: Dict[str, FunctionContract], classes: Dict[str, ClassContract]) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._extract_rust_contracts

Kind: Method
Source: tzero/tzero_contracts.py:647-701

Signature:

def _extract_rust_contracts(cls, clean_code: str, functions: Dict[str, FunctionContract], classes: Dict[str, ClassContract]) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor._extract_java_cs_contracts

Kind: Method
Source: tzero/tzero_contracts.py:704-756

Signature:

def _extract_java_cs_contracts(cls, clean_code: str, functions: Dict[str, FunctionContract], classes: Dict[str, ClassContract]) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractExtractor.extract_polyglot_contracts

Kind: Method
Source: tzero/tzero_contracts.py:759-774

Signature:

def extract_polyglot_contracts(cls, code: str, file_path: str = 'module.ts') -> Tuple[Dict[str, FunctionContract], Dict[str, ClassContract]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractComparator

Kind: Class
Source: tzero/tzero_contracts.py:777-1113

Declaration:

class ASTContractComparator:

Source docstring:

Compares two versions of public AST contracts and evaluates breaking changes.

ASTContractComparator.compare_code

Kind: Method
Source: tzero/tzero_contracts.py:781-872

Signature:

def compare_code(cls, old_code: str, new_code: str, file_path: str = 'code.py') -> ContractDiffReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractComparator._compare_function_signatures

Kind: Method
Source: tzero/tzero_contracts.py:875-922

Signature:

def _compare_function_signatures(cls, old_fn: FunctionContract, new_fn: FunctionContract, symbol_name: str, breaking: List[ContractViolation], additions: List[ContractViolation], modifications: List[ContractViolation]):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTContractComparator.compare_git_revision

Kind: Method
Source: tzero/tzero_contracts.py:925-976

Signature:

def compare_git_revision(cls, repo_dir: str = '.', base_ref: str = 'HEAD~1') -> List[ContractDiffReport]:

Source docstring:

Compares public API contracts between base_ref and working tree / HEAD.

ASTContractComparator.format_sarif_report

Kind: Method
Source: tzero/tzero_contracts.py:979-1066

Signature:

def format_sarif_report(cls, reports: List[ContractDiffReport]) -> Dict[str, Any]:

Source docstring:

Formats contract diff reports into an industry-standard SARIF 2.1.0 JSON object.

ASTContractComparator.format_markdown_report

Kind: Method
Source: tzero/tzero_contracts.py:1069-1113

Signature:

def format_markdown_report(cls, reports: List[ContractDiffReport]) -> str:

Source docstring:

Formats the contract diffs into a GitHub PR Shield Markdown document.

tzero/tzero_cost.py

Source: tzero/tzero_cost.py
Source size: 166 lines | 3 classes | 4 functions

Module docstring:


Siber Akademi — T-Zero Real-Time Token Cost & Financial ROI Cockpit.
Developer: [redacted] (Siber Akademi)
License: AGPL-3.0-only

Calculates exact token footprints, API cost per query, and team financial ROI
comparing raw full-codebase injection against T-Zero AST-pruned context
across Claude 3.5 Sonnet, Claude 3 Opus, GPT-4o, Gemini 1.5 Pro, and DeepSeek V3.

ModelCostComparison

Kind: Class
Source: tzero/tzero_cost.py:22-29

Declaration:

class ModelCostComparison:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CostReport

Kind: Class
Source: tzero/tzero_cost.py:33-40

Declaration:

class CostReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TokenCostCalculator

Kind: Class
Source: tzero/tzero_cost.py:43-153

Declaration:

class TokenCostCalculator:

Source docstring:

Calculates quantitative financial ROI and token savings across LLM models.

TokenCostCalculator.calculate_cost

Kind: Method
Source: tzero/tzero_cost.py:61-104

Signature:

def calculate_cost(cls, workspace_dir: str = '.') -> CostReport:

Source docstring:

Computes comprehensive cost and token reduction metrics for the workspace.

TokenCostCalculator.render_cli

Kind: Method
Source: tzero/tzero_cost.py:107-129

Signature:

def render_cli(cls, report: CostReport) -> None:

Source docstring:

Renders rich ANSI terminal cost & ROI cockpit.

TokenCostCalculator.to_json

Kind: Method
Source: tzero/tzero_cost.py:132-153

Signature:

def to_json(cls, report: CostReport) -> str:

Source docstring:

Serializes report into JSON.

main

Kind: Function
Source: tzero/tzero_cost.py:156-162

Signature:

def main():

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_debt.py

Source: tzero/tzero_debt.py
Source size: 563 lines | 6 classes | 19 functions

Module docstring:

T-Zero Autonomous AST Code Health, Cognitive Complexity & Technical Debt Index.

Computes exact AST-based cognitive complexity, standard Maintainability Index (MI 0-100),
Halstead volume approximations, and financial technical debt refactoring estimates ($ / hours).

Capabilities:
- Cognitive Complexity analysis (Sonarqube-style nesting & branching weights).
- Cyclomatic Complexity & Maintainability Index (MI 0-100: Green / Yellow / Red).
- God Class & Long Method code smell detection.
- Debt Marker Tracker (TODO, FIXME, HACK, XXX, TEMP).
- Quantitative Refactoring Hours & Financial Debt ROI computation.
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).

Author: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v12.3.4 Master Edition.

FunctionHealth

Kind: Class
Source: tzero/tzero_debt.py:36-43

Declaration:

class FunctionHealth:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ClassHealth

Kind: Class
Source: tzero/tzero_debt.py:47-54

Declaration:

class ClassHealth:

Source docstring: none; consult the linked implementation instead of inferring behavior.

FileHealthReport

Kind: Class
Source: tzero/tzero_debt.py:58-71

Declaration:

class FileHealthReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

WorkspaceHealthReport

Kind: Class
Source: tzero/tzero_debt.py:75-85

Declaration:

class WorkspaceHealthReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor

Kind: Class
Source: tzero/tzero_debt.py:88-159

Declaration:

class ASTCognitiveComplexityVisitor(ast.NodeVisitor):

Source docstring:

Calculates cognitive complexity based on nesting penalties and structural breaks.

ASTCognitiveComplexityVisitor.__init__

Kind: Method
Source: tzero/tzero_debt.py:91-93

Signature:

def __init__(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_FunctionDef

Kind: Method
Source: tzero/tzero_debt.py:95-100

Signature:

def visit_FunctionDef(self, node: ast.FunctionDef):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_AsyncFunctionDef

Kind: Method
Source: tzero/tzero_debt.py:102-106

Signature:

def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_If

Kind: Method
Source: tzero/tzero_debt.py:108-125

Signature:

def visit_If(self, node: ast.If):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_For

Kind: Method
Source: tzero/tzero_debt.py:127-132

Signature:

def visit_For(self, node: ast.For):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_AsyncFor

Kind: Method
Source: tzero/tzero_debt.py:134-139

Signature:

def visit_AsyncFor(self, node: ast.AsyncFor):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_While

Kind: Method
Source: tzero/tzero_debt.py:141-146

Signature:

def visit_While(self, node: ast.While):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_ExceptHandler

Kind: Method
Source: tzero/tzero_debt.py:148-153

Signature:

def visit_ExceptHandler(self, node: ast.ExceptHandler):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTCognitiveComplexityVisitor.visit_BoolOp

Kind: Method
Source: tzero/tzero_debt.py:155-159

Signature:

def visit_BoolOp(self, node: ast.BoolOp):

Source docstring: none; consult the linked implementation instead of inferring behavior.

CodeHealthAnalyzer

Kind: Class
Source: tzero/tzero_debt.py:162-531

Declaration:

class CodeHealthAnalyzer:

Source docstring:

Analyzes AST maintainability index, cognitive complexity, and technical debt.

CodeHealthAnalyzer.compute_cognitive_complexity

Kind: Method
Source: tzero/tzero_debt.py:168-171

Signature:

def compute_cognitive_complexity(cls, node: ast.AST) -> int:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CodeHealthAnalyzer.compute_cyclomatic_complexity

Kind: Method
Source: tzero/tzero_debt.py:174-182

Signature:

def compute_cyclomatic_complexity(cls, node: ast.AST) -> int:

Source docstring:

Computes McCabe cyclomatic complexity: decision points + 1.

CodeHealthAnalyzer.compute_maintainability_index

Kind: Method
Source: tzero/tzero_debt.py:185-195

Signature:

def compute_maintainability_index(cls, code: str, cyclomatic: int) -> float:

Source docstring:

Computes SEI/Microsoft Maintainability Index normalized to 0-100.

CodeHealthAnalyzer.extract_debt_markers

Kind: Method
Source: tzero/tzero_debt.py:207-222

Signature:

def extract_debt_markers(cls, code: str) -> List[Dict[str, Any]]:

Source docstring:

Finds TODO, FIXME, HACK, XXX, TEMP debt comments (Python '#' and C-style '//').

CodeHealthAnalyzer.attach_marker_scopes

Kind: Method
Source: tzero/tzero_debt.py:225-253

Signature:

def attach_marker_scopes(markers: List[Dict[str, Any]], tree: ast.AST) -> Dict[str, int]:

Source docstring:

Sets each marker's 'scope' to its innermost enclosing class/function.

        Returns a histogram {scope: marker_count} sorted by count (descending).

CodeHealthAnalyzer.attach_marker_scopes.walk

Kind: Nested function
Source: tzero/tzero_debt.py:232-240

Signature:

def walk(node: ast.AST, prefix: str) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CodeHealthAnalyzer.analyze_file

Kind: Method
Source: tzero/tzero_debt.py:256-392

Signature:

def analyze_file(cls, file_path: str, code: Optional[str] = None) -> FileHealthReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CodeHealthAnalyzer.analyze_workspace

Kind: Method
Source: tzero/tzero_debt.py:395-492

Signature:

def analyze_workspace(cls, workspace_root: str = '.', max_files: int = 250) -> WorkspaceHealthReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CodeHealthAnalyzer.format_markdown_report

Kind: Method
Source: tzero/tzero_debt.py:495-531

Signature:

def format_markdown_report(cls, report: WorkspaceHealthReport) -> str:

Source docstring:

Formats the technical debt index into an executive GitHub Markdown document.

format_debt_markers_markdown

Kind: Function
Source: tzero/tzero_debt.py:535-563

Signature:

def format_debt_markers_markdown(report: WorkspaceHealthReport, limit: int = 50) -> str:

Source docstring:

Renders every debt marker grouped by file and scope, sorted by weight (heaviest first).

tzero/tzero_deps.py

Source: tzero/tzero_deps.py
Source size: 484 lines | 1 classes | 15 functions

Module docstring:

T-Zero dependency bootstrap and environment doctor (standard library only).

* ``ensure_dependencies()`` checks installed package versions and prints a manual
  installation command when something is missing.
* ``run_doctor()`` reports the state of Python, packages, tkinter, Git and keyring.

Developer: [redacted] (Siber Akademi)

Dependency

Kind: Class
Source: tzero/tzero_deps.py:27-35

Declaration:

class Dependency(NamedTuple):

Source docstring: none; consult the linked implementation instead of inferring behavior.

Dependency.spec

Kind: Method
Source: tzero/tzero_deps.py:34-35

Signature:

def spec(self) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_version_tuple

Kind: Function
Source: tzero/tzero_deps.py:48-55

Signature:

def _version_tuple(version: str) -> Tuple[int, ...]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

installed_version

Kind: Function
Source: tzero/tzero_deps.py:58-64

Signature:

def installed_version(dep: Dependency) -> Optional[str]:

Source docstring:

Returns the installed version string, or None when the distribution is unknown.

check_dependency

Kind: Function
Source: tzero/tzero_deps.py:67-78

Signature:

def check_dependency(dep: Dependency) -> Tuple[str, Optional[str]]:

Source docstring:

Returns (status, version) where status is 'ok', 'outdated' or 'missing'.

_err

Kind: Function
Source: tzero/tzero_deps.py:81-87

Signature:

def _err(message: str) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ensure_dependencies

Kind: Function
Source: tzero/tzero_deps.py:90-140

Signature:

def ensure_dependencies(include_mcp: bool = False, *, install: bool = False) -> bool:

Source docstring:

Check dependencies, with installation available to explicit callers.

    Returns True when everything needed is available afterwards.

_line

Kind: Function
Source: tzero/tzero_deps.py:143-144

Signature:

def _line(level: str, text: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_tzero_scripts_directory

Kind: Function
Source: tzero/tzero_deps.py:147-153

Signature:

def _tzero_scripts_directory() -> Path:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_append_windows_user_path

Kind: Function
Source: tzero/tzero_deps.py:156-177

Signature:

def _append_windows_user_path(scripts: Path) -> bool:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_append_windows_user_path.normalize

Kind: Nested function
Source: tzero/tzero_deps.py:162-163

Signature:

def normalize(value: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_append_shell_path

Kind: Function
Source: tzero/tzero_deps.py:180-194

Signature:

def _append_shell_path(scripts: Path, config: Path) -> bool:

Source docstring: none; consult the linked implementation instead of inferring behavior.

add_to_user_path

Kind: Function
Source: tzero/tzero_deps.py:197-227

Signature:

def add_to_user_path(shell: Optional[str] = None) -> int:

Source docstring:

Add an installed T-Zero launcher to the user's PATH on explicit request.

main

Kind: Function
Source: tzero/tzero_deps.py:230-243

Signature:

def main() -> int:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_run_deep_subsystem_check

Kind: Function
Source: tzero/tzero_deps.py:246-407

Signature:

def _run_deep_subsystem_check() -> int:

Source docstring:

Exercise all 9 v11 offline subsystems and report pass/fail. Returns failure count.

run_doctor

Kind: Function
Source: tzero/tzero_deps.py:410-480

Signature:

def run_doctor(deep: bool = False) -> int:

Source docstring:

Checks the environment and returns a process exit code.

tzero/tzero_drift.py

Source: tzero/tzero_drift.py
Source size: 208 lines | 3 classes | 4 functions

Module docstring:


Siber Akademi — T-Zero Instruction & Architecture Drift Scorer.
Developer: [redacted] (Siber Akademi)
License: AGPL-3.0-only

Quantifies how closely LLM code generations and workspace modifications adhere
to initial system prompt rules, negative constraints, and architectural boundaries.
Directly measures the "Lost in the Middle" attention degradation phenomenon:
proves high SNR via AST pruning prevents instruction decay over long sessions.

DriftFinding

Kind: Class
Source: tzero/tzero_drift.py:24-30

Declaration:

class DriftFinding:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DriftReport

Kind: Class
Source: tzero/tzero_drift.py:34-40

Declaration:

class DriftReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DriftAnalyzer

Kind: Class
Source: tzero/tzero_drift.py:43-195

Declaration:

class DriftAnalyzer:

Source docstring:

Measures instruction drift and architectural rule decay across the codebase.

DriftAnalyzer.analyze_workspace

Kind: Method
Source: tzero/tzero_drift.py:52-139

Signature:

def analyze_workspace(cls, workspace_dir: str = '.') -> DriftReport:

Source docstring:

Analyzes active workspace files for rule drift, security drift, and complexity.

DriftAnalyzer.render_cli

Kind: Method
Source: tzero/tzero_drift.py:142-172

Signature:

def render_cli(cls, report: DriftReport) -> None:

Source docstring:

Renders rich ANSI terminal drift score report.

DriftAnalyzer.to_json

Kind: Method
Source: tzero/tzero_drift.py:175-195

Signature:

def to_json(cls, report: DriftReport) -> str:

Source docstring:

Serializes drift report into JSON.

main

Kind: Function
Source: tzero/tzero_drift.py:198-204

Signature:

def main():

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_features.py

Source: tzero/tzero_features.py
Source size: 3269 lines | 14 classes | 80 functions

Module docstring:

Siber Akademi — T-Zero Advanced Intelligence Suite.

Developer: [redacted] (Siber Akademi)
LinkedIn: [personal link omitted]
Bio & Socials: [personal link omitted]
GitHub: https://github.com/toprakahmetaydogmus/TZeroAlgorithm

Modules Included:
  1. ChangeImpactAnalyzer: Blast radius and change impact dependency tracer.
  2. ArchitectureRuleEngine: T-4 architectural boundary enforcement and CI gate.
  3. AgentRulesGenerator: One-click export for .cursorrules, .cursor/rules/*.mdc, .clinerules, and Copilot.
  4. LocalSemanticCodeSearch: 100% private, local BM25 + TF-IDF hybrid code search & RAG engine.
  5. TokenROICalculator: Token compression ratio, developer ROI, and cost savings telemetry.
  6. DashboardRequestHandler / launch_web_dashboard: Lightweight zero-dependency local web dashboard server (localhost:7300).

get_ignore_patterns

Kind: Function
Source: tzero/tzero_features.py:38-61

Signature:

def get_ignore_patterns(base_dir: str) -> List[str]:

Source docstring:

Reads .gitignore and .tzeroignore patterns from project directory.

should_skip_dir

Kind: Function
Source: tzero/tzero_features.py:64-76

Signature:

def should_skip_dir(root: str, base_dir: str) -> bool:

Source docstring:

Helper to check if a subdirectory should be skipped relative to base project dir.

should_skip_file

Kind: Function
Source: tzero/tzero_features.py:79-89

Signature:

def should_skip_file(file_path: str, base_dir: str) -> bool:

Source docstring:

Helper to check if a file matches .gitignore or .tzeroignore patterns.

ChangeImpactAnalyzer

Kind: Class
Source: tzero/tzero_features.py:96-352

Declaration:

class ChangeImpactAnalyzer:

Source docstring:

Calculates blast radius and change impact for modified symbols and files.

    Traces AST definitions, call references, and inbound import graphs to compute
    risk scores and affected modules before making code changes.

ChangeImpactAnalyzer.__init__

Kind: Method
Source: tzero/tzero_features.py:103-113

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ChangeImpactAnalyzer._add_symbol_def

Kind: Method
Source: tzero/tzero_features.py:115-119

Signature:

def _add_symbol_def(self, symbol: str, rel_path: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ChangeImpactAnalyzer._build_index

Kind: Method
Source: tzero/tzero_features.py:121-137

Signature:

def _build_index(self):

Source docstring:

Scans python files and builds symbol and dependency maps.

ChangeImpactAnalyzer._index_file_ast

Kind: Method
Source: tzero/tzero_features.py:139-164

Signature:

def _index_file_ast(self, rel_path: str, code: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ChangeImpactAnalyzer._get_file_refs

Kind: Method
Source: tzero/tzero_features.py:166-192

Signature:

def _get_file_refs(self, rel_path: str, content: str) -> Tuple[Dict[str, Set[int]], Dict[str, Set[int]], Dict[str, Set[int]]]:

Source docstring:

Builds and caches a per-file AST reference index in a single traversal.

ChangeImpactAnalyzer.analyze_symbol

Kind: Method
Source: tzero/tzero_features.py:194-301

Signature:

def analyze_symbol(self, symbol_name: str) -> Dict[str, Any]:

Source docstring:

Calculates the blast radius for modifying a specific symbol (class/function).

        Uses AST analysis over workspace code to accurately discover call sites and
        attribute accesses without false positives from comments and string literals.

ChangeImpactAnalyzer.format_report

Kind: Method
Source: tzero/tzero_features.py:303-352

Signature:

def format_report(self, analysis: Dict[str, Any]) -> str:

Source docstring:

Formats the analysis into an actionable markdown blast radius report.

ArchitectureRuleEngine

Kind: Class
Source: tzero/tzero_features.py:383-538

Declaration:

class ArchitectureRuleEngine:

Source docstring:

Enforces active architectural boundary rules (T-4) across modules.

    Prevents spaghetti code, circular imports, and architecture erosion.
    Can be used as a CLI gate in GitHub Actions CI (`--enforce-boundaries`).

ArchitectureRuleEngine.__init__

Kind: Method
Source: tzero/tzero_features.py:390-393

Signature:

def __init__(self, project_dir: str, config_path: Optional[str] = None):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ArchitectureRuleEngine._load_rules

Kind: Method
Source: tzero/tzero_features.py:395-402

Signature:

def _load_rules(self) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ArchitectureRuleEngine.generate_default_rules

Kind: Method
Source: tzero/tzero_features.py:405-408

Signature:

def generate_default_rules(target_path: str):

Source docstring:

Generates a starter tzero.rules.json file.

ArchitectureRuleEngine._matches_layer

Kind: Method
Source: tzero/tzero_features.py:410-418

Signature:

def _matches_layer(self, file_rel: str, patterns: List[str]) -> bool:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ArchitectureRuleEngine.enforce_boundaries

Kind: Method
Source: tzero/tzero_features.py:420-518

Signature:

def enforce_boundaries(self) -> Dict[str, Any]:

Source docstring:

Scans codebase and verifies all import rules.

ArchitectureRuleEngine.format_report

Kind: Method
Source: tzero/tzero_features.py:520-538

Signature:

def format_report(self, result: Dict[str, Any]) -> str:

Source docstring:

Formats the audit results into a terminal or markdown report.

AgentRulesGenerator

Kind: Class
Source: tzero/tzero_features.py:545-761

Declaration:

class AgentRulesGenerator:

Source docstring:

Generates production-grade native rule files for AI coding agents.

AgentRulesGenerator.generate_cursorrules

Kind: Method
Source: tzero/tzero_features.py:549-576

Signature:

def generate_cursorrules(project_name: str, tech_stack: str = 'Python / Modern Toolchain') -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentRulesGenerator.generate_clinerules

Kind: Method
Source: tzero/tzero_features.py:579-591

Signature:

def generate_clinerules(project_name: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentRulesGenerator.generate_copilot_instructions

Kind: Method
Source: tzero/tzero_features.py:594-604

Signature:

def generate_copilot_instructions(project_name: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentRulesGenerator.generate_cursor_mdc_rules

Kind: Method
Source: tzero/tzero_features.py:607-658

Signature:

def generate_cursor_mdc_rules(project_name: str, project_dir: Optional[str] = None) -> Dict[str, str]:

Source docstring:

Generates modern modular .cursor/rules/*.mdc format dynamically from tzero.rules.json.

AgentRulesGenerator.generate_windsurfrules

Kind: Method
Source: tzero/tzero_features.py:661-670

Signature:

def generate_windsurfrules(project_name: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentRulesGenerator.generate_claude_instructions

Kind: Method
Source: tzero/tzero_features.py:673-685

Signature:

def generate_claude_instructions(project_name: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentRulesGenerator.export_all

Kind: Method
Source: tzero/tzero_features.py:688-761

Signature:

def export_all(cls, project_dir: str) -> List[str]:

Source docstring:

Exports all agent rules into the target repository.

LocalSemanticCodeSearch

Kind: Class
Source: tzero/tzero_features.py:768-998

Declaration:

class LocalSemanticCodeSearch:

Source docstring:

100% Local, zero-network hybrid BM25 + symbol token code search with Reciprocal Rank Fusion (RRF).

    Indexes functions, classes, docstrings, and signatures into an in-memory
    vector/lexical index with AST-aware chunking, allowing natural language queries
    without sending code to any external embedding API.

LocalSemanticCodeSearch.__init__

Kind: Method
Source: tzero/tzero_features.py:776-782

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

LocalSemanticCodeSearch._tokenize

Kind: Method
Source: tzero/tzero_features.py:785-793

Signature:

def _tokenize(text: str) -> List[str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

LocalSemanticCodeSearch._index_codebase

Kind: Method
Source: tzero/tzero_features.py:795-881

Signature:

def _index_codebase(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

LocalSemanticCodeSearch.search

Kind: Method
Source: tzero/tzero_features.py:883-984

Signature:

def search(self, query: str, top_k: int = 5) -> List[Dict[str, Any]]:

Source docstring:

Performs hybrid BM25 + Symbol Match search with Reciprocal Rank Fusion (RRF).

LocalSemanticCodeSearch.format_search_results

Kind: Method
Source: tzero/tzero_features.py:986-998

Signature:

def format_search_results(self, query: str, results: List[Dict[str, Any]]) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TokenROICalculator

Kind: Class
Source: tzero/tzero_features.py:1005-1059

Declaration:

class TokenROICalculator:

Source docstring:

Calculates quantitative token reduction savings and economic ROI.

TokenROICalculator.calculate

Kind: Method
Source: tzero/tzero_features.py:1009-1035

Signature:

def calculate(raw_tokens: int, reduced_tokens: int, team_size: int = 5, queries_per_day: int = 30) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TokenROICalculator.format_report

Kind: Method
Source: tzero/tzero_features.py:1040-1059

Signature:

def format_report(cls, metrics: Dict[str, Any]) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

GitDiffContextBuilder

Kind: Class
Source: tzero/tzero_features.py:1066-1220

Declaration:

class GitDiffContextBuilder:

Source docstring:

Computes incremental git diff context and downstream blast radius dependencies.

    Extracts only modified symbol signatures + affected callers/importers,
    achieving 98%+ token savings compared to whole-repository prompt ingestion.

GitDiffContextBuilder.__init__

Kind: Method
Source: tzero/tzero_features.py:1073-1075

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

GitDiffContextBuilder.get_diff_changed_files

Kind: Method
Source: tzero/tzero_features.py:1077-1117

Signature:

def get_diff_changed_files(self, base_ref: str = 'HEAD~1') -> List[Dict[str, Any]]:

Source docstring:

Finds changed files using local git diff without external network calls.

GitDiffContextBuilder.build_diff_context

Kind: Method
Source: tzero/tzero_features.py:1119-1220

Signature:

def build_diff_context(self, base_ref: str = 'HEAD~1') -> Dict[str, Any]:

Source docstring:

Builds hyper-compact diff context payload.

DashboardRequestHandler

Kind: Class
Source: tzero/tzero_features.py:1478-1604

Declaration:

class DashboardRequestHandler(http.server.BaseHTTPRequestHandler):

Source docstring:

Zero-dependency secure HTTP handler serving the T-Zero Web Dashboard and REST APIs.

DashboardRequestHandler._get_project_mtime

Kind: Method
Source: tzero/tzero_features.py:1488-1502

Signature:

def _get_project_mtime(cls) -> float:

Source docstring:

Finds latest modification timestamp across files to detect stale cache.

DashboardRequestHandler.get_engines

Kind: Method
Source: tzero/tzero_features.py:1505-1518

Signature:

def get_engines(cls) -> Tuple[LocalSemanticCodeSearch, ChangeImpactAnalyzer, ArchitectureRuleEngine]:

Source docstring:

Returns initialized analysis engines, auto-refreshing cache if files changed.

DashboardRequestHandler.log_message

Kind: Method
Source: tzero/tzero_features.py:1520-1521

Signature:

def log_message(self, format, *args):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DashboardRequestHandler._send_security_headers

Kind: Method
Source: tzero/tzero_features.py:1523-1530

Signature:

def _send_security_headers(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DashboardRequestHandler.do_OPTIONS

Kind: Method
Source: tzero/tzero_features.py:1532-1535

Signature:

def do_OPTIONS(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DashboardRequestHandler.do_GET

Kind: Method
Source: tzero/tzero_features.py:1537-1595

Signature:

def do_GET(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DashboardRequestHandler._send_json

Kind: Method
Source: tzero/tzero_features.py:1597-1604

Signature:

def _send_json(self, data: Any):

Source docstring: none; consult the linked implementation instead of inferring behavior.

launch_web_dashboard

Kind: Function
Source: tzero/tzero_features.py:1607-1633

Signature:

def launch_web_dashboard(project_dir: str = '.', port: int = 7300, open_browser: bool = True):

Source docstring:

Starts the zero-dependency local web dashboard server.

_SelfHealingTransformer

Kind: Class
Source: tzero/tzero_features.py:1696-1749

Declaration:

class _SelfHealingTransformer(ast.NodeTransformer):

Source docstring:

AST transformer that automatically corrects hallucinated imports, function names, and kwargs.

_SelfHealingTransformer.__init__

Kind: Method
Source: tzero/tzero_features.py:1698-1701

Signature:

def __init__(self, fixes: Dict[str, Any]):

Source docstring: none; consult the linked implementation instead of inferring behavior.

_SelfHealingTransformer.visit_ImportFrom

Kind: Method
Source: tzero/tzero_features.py:1703-1709

Signature:

def visit_ImportFrom(self, node: ast.ImportFrom) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_SelfHealingTransformer.visit_Name

Kind: Method
Source: tzero/tzero_features.py:1711-1714

Signature:

def visit_Name(self, node: ast.Name) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

_SelfHealingTransformer.visit_Call

Kind: Method
Source: tzero/tzero_features.py:1716-1749

Signature:

def visit_Call(self, node: ast.Call) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroHallucinationGuard

Kind: Class
Source: tzero/tzero_features.py:1752-2476

Declaration:

class ZeroHallucinationGuard:

Source docstring:

Pre-flight validator that eliminates AI coding hallucinations before code is applied.

    5-Tier Zero-Hallucination Architecture:
      1. Ghost Dependency Guard: Blocks imports of non-existent packages (validates against stdlib, requirements.txt, pyproject.toml, and installed packages).
      2. AST Symbol & Module Guard: Verifies imports against workspace modules and declared __all__ / exported symbols.
      3. AST Call & Keyword Argument Guard: Validates positional counts and parameter names against known function signatures.
      4. Schema & Field Contract Guard: Validates class instantiations, dataclasses, and attribute accesses against known fields.
      5. Return Type & Chaining Guard: Detects invalid chaining or iterations on functions returning None or primitive types.
      + Self-Healing AST Patcher: Automatically synthesizes corrected, hallucination-free code via AST node transformation.
      + Grounding Contract Generator: Emits immutable Type & Symbol boundary contracts for prompt pinning.

ZeroHallucinationGuard.__init__

Kind: Method
Source: tzero/tzero_features.py:1765-1778

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroHallucinationGuard._load_installed_and_stdlib

Kind: Method
Source: tzero/tzero_features.py:1780-1842

Signature:

def _load_installed_and_stdlib(self):

Source docstring:

Loads Python standard library modules, installed environment packages, and alias mappings.

ZeroHallucinationGuard._load_dependency_manifests

Kind: Method
Source: tzero/tzero_features.py:1844-1881

Signature:

def _load_dependency_manifests(self):

Source docstring:

Scans project directory for requirements.txt, pyproject.toml, and setup.py to find declared dependencies.

ZeroHallucinationGuard._build_catalog

Kind: Method
Source: tzero/tzero_features.py:1883-1907

Signature:

def _build_catalog(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroHallucinationGuard._index_module_ast

Kind: Method
Source: tzero/tzero_features.py:1909-1962

Signature:

def _index_module_ast(self, mod_path: str, stem: str, tree: ast.AST):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroHallucinationGuard._extract_func_sig

Kind: Method
Source: tzero/tzero_features.py:1964-2028

Signature:

def _extract_func_sig(self, node: ast.FunctionDef | ast.AsyncFunctionDef) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroHallucinationGuard.validate_code

Kind: Method
Source: tzero/tzero_features.py:2030-2421

Signature:

def validate_code(self, proposed_code: str, target_file: str = '') -> Dict[str, Any]:

Source docstring:

Validates proposed code against workspace symbol, dependency manifests, and call contracts.

ZeroHallucinationGuard.repair_code

Kind: Method
Source: tzero/tzero_features.py:2423-2428

Signature:

def repair_code(self, proposed_code: str, target_file: str = '') -> str:

Source docstring:

Returns auto-healed code if hallucinations exist and can be safely repaired, or original code.

ZeroHallucinationGuard.generate_grounding_contract

Kind: Method
Source: tzero/tzero_features.py:2430-2476

Signature:

def generate_grounding_contract(self, focus_modules: Optional[List[str]] = None, task_intent: str = '') -> str:

Source docstring:

Emits an immutable AST Type & Symbol grounding contract for prompt pinning.

SmartSkeletonContextBuilder

Kind: Class
Source: tzero/tzero_features.py:2483-2593

Declaration:

class SmartSkeletonContextBuilder:

Source docstring:

Builds focus-aware hybrid context with full implementation for the target
    and ultra-compressed T-3 AST skeletons for surrounding 1st-degree ecosystem.

SmartSkeletonContextBuilder.__init__

Kind: Method
Source: tzero/tzero_features.py:2488-2490

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SmartSkeletonContextBuilder.build_skeleton

Kind: Method
Source: tzero/tzero_features.py:2492-2593

Signature:

def build_skeleton(self, focus_file: str, focus_symbol: str = '', task_intent: str = '') -> str:

Source docstring:

Returns full target code + 1st-degree AST skeletons and matching reusable helpers.

RepositoryPageRank

Kind: Class
Source: tzero/tzero_features.py:2600-2697

Declaration:

class RepositoryPageRank:

Source docstring:

Pure-Python PageRank implementation to identify the architectural backbone of a codebase.

RepositoryPageRank.__init__

Kind: Method
Source: tzero/tzero_features.py:2603-2605

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

RepositoryPageRank.rank

Kind: Method
Source: tzero/tzero_features.py:2607-2681

Signature:

def rank(self, top_k: int = 15, damping: float = 0.85, max_iter: int = 40) -> List[Dict[str, Any]]:

Source docstring:

Calculates PageRank centrality for all files in the repository.

RepositoryPageRank.format_report

Kind: Method
Source: tzero/tzero_features.py:2683-2697

Signature:

def format_report(self, rankings: List[Dict[str, Any]]) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer

Kind: Class
Source: tzero/tzero_features.py:2704-2834

Declaration:

class SymbolCallChainTracer:

Source docstring:

Traces upstream callers and downstream callees across the workspace AST.

SymbolCallChainTracer.__init__

Kind: Method
Source: tzero/tzero_features.py:2707-2711

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer._build_call_graph

Kind: Method
Source: tzero/tzero_features.py:2713-2726

Signature:

def _build_call_graph(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer._index_calls

Kind: Method
Source: tzero/tzero_features.py:2728-2741

Signature:

def _index_calls(self, tree: ast.AST):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer.trace

Kind: Method
Source: tzero/tzero_features.py:2743-2781

Signature:

def trace(self, symbol_name: str, max_depth: int = 3) -> Dict[str, Any]:

Source docstring:

Traces upstream callers and downstream callees up to max_depth.

SymbolCallChainTracer.trace.trace_upstream

Kind: Nested function
Source: tzero/tzero_features.py:2745-2756

Signature:

def trace_upstream(sym: str, depth: int, visited: Set[str]) -> List[Dict[str, Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer.trace.trace_downstream

Kind: Nested function
Source: tzero/tzero_features.py:2758-2769

Signature:

def trace_downstream(sym: str, depth: int, visited: Set[str]) -> List[Dict[str, Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer.format_report

Kind: Method
Source: tzero/tzero_features.py:2783-2834

Signature:

def format_report(self, trace_result: Dict[str, Any]) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolCallChainTracer.format_report.render_tree

Kind: Nested function
Source: tzero/tzero_features.py:2796-2800

Signature:

def render_tree(items: List[Dict[str, Any]], key: str, prefix: str = ''):

Source docstring: none; consult the linked implementation instead of inferring behavior.

detect_circular_dependencies

Kind: Function
Source: tzero/tzero_features.py:2841-2895

Signature:

def detect_circular_dependencies(import_graph: Any) -> List[List[str]]:

Source docstring:

Detects import cycles (A -> B -> A) using Depth-First Search with recursion stack.
    Accepts either an explicit adjacency graph Dict[str, Set[str]] or a project_dir path.

detect_circular_dependencies.dfs

Kind: Nested function
Source: tzero/tzero_features.py:2873-2889

Signature:

def dfs(node: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DeadCodeFinder

Kind: Class
Source: tzero/tzero_features.py:2902-2997

Declaration:

class DeadCodeFinder:

Source docstring:

Discovers unused, unreferenced functions and classes across the codebase AST.

DeadCodeFinder.__init__

Kind: Method
Source: tzero/tzero_features.py:2905-2906

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DeadCodeFinder.find_dead_symbols

Kind: Method
Source: tzero/tzero_features.py:2908-2979

Signature:

def find_dead_symbols(self) -> Dict[str, Any]:

Source docstring:

Scans codebase to detect declared functions/classes never imported or referenced.

DeadCodeFinder.format_report

Kind: Method
Source: tzero/tzero_features.py:2981-2995

Signature:

def format_report(self, res: Dict[str, Any]) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ReusableHelperSuggester

Kind: Class
Source: tzero/tzero_features.py:3004-3267

Declaration:

class ReusableHelperSuggester:

Source docstring:

Discovers, ranks, and surfaces reusable utility and helper functions across repository AST.

    Prevents LLMs and developers from reinventing existing functions that may have been pruned
    from the context window or located in separate utility packages.

ReusableHelperSuggester.__init__

Kind: Method
Source: tzero/tzero_features.py:3011-3014

Signature:

def __init__(self, project_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ReusableHelperSuggester._ensure_indexed

Kind: Method
Source: tzero/tzero_features.py:3016-3019

Signature:

def _ensure_indexed(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ReusableHelperSuggester._index_codebase

Kind: Method
Source: tzero/tzero_features.py:3021-3038

Signature:

def _index_codebase(self):

Source docstring:

Scans workspace python files and extracts reusable helper functions.

ReusableHelperSuggester._extract_helpers_from_file

Kind: Method
Source: tzero/tzero_features.py:3040-3124

Signature:

def _extract_helpers_from_file(self, rel_path: str, code: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ReusableHelperSuggester.suggest_helpers

Kind: Method
Source: tzero/tzero_features.py:3126-3180

Signature:

def suggest_helpers(self, query: str = '', target_file: str = '', top_k: int = 5) -> List[Dict[str, Any]]:

Source docstring:

Searches repository helpers matching natural language query, function name, or task.

ReusableHelperSuggester.check_reinvention_guard

Kind: Method
Source: tzero/tzero_features.py:3182-3215

Signature:

def check_reinvention_guard(self, code_snippet: str, target_file: str = '', top_k: int = 3) -> Dict[str, Any]:

Source docstring:

Inspects newly written code snippet to detect if it re-implements existing workspace helpers.

ReusableHelperSuggester.format_helpers_report

Kind: Method
Source: tzero/tzero_features.py:3217-3247

Signature:

def format_helpers_report(self, results: List[Dict[str, Any]], query: str = '', include_body: bool = True) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ReusableHelperSuggester.format_guard_report

Kind: Method
Source: tzero/tzero_features.py:3249-3267

Signature:

def format_guard_report(self, report: Dict[str, Any], include_body: bool = True) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_golden.py

Source: tzero/tzero_golden.py
Source size: 352 lines | 3 classes | 6 functions

Module docstring:

T-Zero Autonomous Golden Baseline & AST Regression Engine.

Captures a cryptographically signed baseline snapshot of all public AST signatures
across the workspace and verifies against accidental regressions in CI/CD pipelines.

Capabilities:
- Zero-drift public API golden snapshot generation (.tzero/goldens.json).
- Deterministic signature diffing (removed symbols, altered parameters, return type drift).
- Pre-merge regression guard: fails CI if public contract breaks without explicit baseline update.
- 100% Offline, $0 cost, zero cloud dependencies (Python standard library only).

Author: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v12.3.4 Master Edition.

SymbolSignature

Kind: Class
Source: tzero/tzero_golden.py:34-40

Declaration:

class SymbolSignature:

Source docstring: none; consult the linked implementation instead of inferring behavior.

GoldenBaseline

Kind: Class
Source: tzero/tzero_golden.py:44-50

Declaration:

class GoldenBaseline:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTGoldenRegressionEngine

Kind: Class
Source: tzero/tzero_golden.py:53-351

Declaration:

class ASTGoldenRegressionEngine:

Source docstring:

Extracts and verifies golden AST signature baselines for zero-drift CI pipelines.

ASTGoldenRegressionEngine.extract_file_signatures

Kind: Method
Source: tzero/tzero_golden.py:57-117

Signature:

def extract_file_signatures(cls, file_path: str, code: str) -> List[SymbolSignature]:

Source docstring:

Extracts all public function, class, and method signatures from Python code.

ASTGoldenRegressionEngine._extract_function_signature

Kind: Method
Source: tzero/tzero_golden.py:120-158

Signature:

def _extract_function_signature(cls, node: Any) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTGoldenRegressionEngine.generate_baseline

Kind: Method
Source: tzero/tzero_golden.py:161-216

Signature:

def generate_baseline(cls, workspace_root: str = '.', max_files: int = 300) -> GoldenBaseline:

Source docstring:

Scans workspace and generates the golden contract baseline.

ASTGoldenRegressionEngine.save_baseline

Kind: Method
Source: tzero/tzero_golden.py:219-224

Signature:

def save_baseline(cls, baseline: GoldenBaseline, file_path: Optional[str] = None) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTGoldenRegressionEngine.verify_against_golden

Kind: Method
Source: tzero/tzero_golden.py:227-305

Signature:

def verify_against_golden(cls, workspace_root: str = '.', golden_path: Optional[str] = None) -> Dict[str, Any]:

Source docstring:

Compares current working tree AST signatures against the golden baseline.

ASTGoldenRegressionEngine.format_markdown_report

Kind: Method
Source: tzero/tzero_golden.py:308-351

Signature:

def format_markdown_report(cls, report: Dict[str, Any]) -> str:

Source docstring:

Formats the golden regression comparison into a clear Markdown document.

tzero/tzero_graph_rag.py

Source: tzero/tzero_graph_rag.py
Source size: 263 lines | 2 classes | 6 functions

Module docstring:

T-Zero Vectorless Semantic Graph & Local Code-RAG Engine (100% Offline, Zero-Cost).

Combines lexical BM25 token relevance, AST structural symbols, and PageRank
graph centrality into a unified hybrid retrieval pipeline without external embeddings.

GraphRagChunk

Kind: Class
Source: tzero/tzero_graph_rag.py:19-33

Declaration:

class GraphRagChunk:

Source docstring: none; consult the linked implementation instead of inferring behavior.

VectorlessGraphRAG

Kind: Class
Source: tzero/tzero_graph_rag.py:36-262

Declaration:

class VectorlessGraphRAG:

Source docstring:

100% Offline, private Graph RAG combining BM25, AST Call Graph, and Centrality.

VectorlessGraphRAG.__init__

Kind: Method
Source: tzero/tzero_graph_rag.py:39-47

Signature:

def __init__(self, workspace_dir: str):

Source docstring: none; consult the linked implementation instead of inferring behavior.

VectorlessGraphRAG.tokenize

Kind: Method
Source: tzero/tzero_graph_rag.py:50-71

Signature:

def tokenize(text: str) -> List[str]:

Source docstring:

Sub-word aware identifier tokenization.

VectorlessGraphRAG.index_workspace

Kind: Method
Source: tzero/tzero_graph_rag.py:73-167

Signature:

def index_workspace(self, file_limit: int = 500) -> int:

Source docstring:

Scan workspace and index code structures into graph RAG nodes.

VectorlessGraphRAG._compute_graph_centrality

Kind: Method
Source: tzero/tzero_graph_rag.py:169-191

Signature:

def _compute_graph_centrality(self, damping: float = 0.85, iterations: int = 25) -> None:

Source docstring:

Compute node centrality for connected files.

VectorlessGraphRAG._score_bm25

Kind: Method
Source: tzero/tzero_graph_rag.py:193-209

Signature:

def _score_bm25(self, query_tokens: List[str], chunk_tokens: List[str], k1: float = 1.2, b: float = 0.75) -> float:

Source docstring:

Standard BM25 scoring for query tokens against chunk tokens.

VectorlessGraphRAG.query

Kind: Method
Source: tzero/tzero_graph_rag.py:211-262

Signature:

def query(self, query_text: str, top_k: int = 5, graph_weight: float = 0.35, bm25_weight: float = 0.65) -> List[Dict[str, Any]]:

Source docstring:

Execute hybrid search combining BM25 and graph centrality ranking.

tzero/tzero_guard.py

Source: tzero/tzero_guard.py
Source size: 352 lines | 1 classes | 6 functions

Module docstring:

T-Zero Git Pre-Commit Zero-Leak & Token Security Guard.

Automatically intercepts git commits, scanning staged files for:
1. Zero-Leak Security: Blocks accidental commits of API keys, tokens, private keys, passwords.
2. Token Bloat Alert: Warns when uncompressed staged files exceed recommended token thresholds.
3. Micro-Patch companion suggestion.

Developer: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v7.0.0 Master Edition.

GitSecurityGuard

Kind: Class
Source: tzero/tzero_guard.py:41-342

Declaration:

class GitSecurityGuard:

Source docstring:

Enterprise pre-commit guard ensuring zero secret leaks and optimal prompt tokens.

GitSecurityGuard.install_hook

Kind: Method
Source: tzero/tzero_guard.py:47-154

Signature:

def install_hook(cls, repo_dir: str = '.') -> Dict[str, Any]:

Source docstring:

Installs pre-commit hook into target repository while preserving existing hooks.

GitSecurityGuard.uninstall_hook

Kind: Method
Source: tzero/tzero_guard.py:157-173

Signature:

def uninstall_hook(cls, repo_dir: str = '.') -> Dict[str, Any]:

Source docstring:

Uninstalls T-Zero pre-commit hook and restores any backed-up user hook cleanly.

GitSecurityGuard.scan_staged_content

Kind: Method
Source: tzero/tzero_guard.py:176-218

Signature:

def scan_staged_content(cls, files_map: Dict[str, str], total_input: Optional[int] = None, skipped_files: Optional[List[str]] = None, errored_files: Optional[List[str]] = None) -> Dict[str, Any]:

Source docstring:

Scans in-memory staged files map {filename: content} for secrets and token bloat.

GitSecurityGuard.scan_directory

Kind: Method
Source: tzero/tzero_guard.py:221-266

Signature:

def scan_directory(cls, repo_dir: str = '.') -> Dict[str, Any]:

Source docstring:

Scans all repository files for hardcoded secrets, keys, and credentials.

GitSecurityGuard.run_cli_check

Kind: Method
Source: tzero/tzero_guard.py:269-342

Signature:

def run_cli_check(cls, repo_dir: str = '.') -> int:

Source docstring:

Executes pre-commit check on currently staged git files.

main

Kind: Function
Source: tzero/tzero_guard.py:345-347

Signature:

def main():

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_hallucination_proof.py

Source: tzero/tzero_hallucination_proof.py
Source size: 901 lines | 4 classes | 3 functions

Module docstring:

Siber Akademi — T-Zero Empirical Zero-Hallucination Proof & Benchmark Engine.

Developer: [redacted] (Siber Akademi)
License: MIT

Formal Proof & Empirical Benchmark:
Demonstrates with 100.0% mathematical & AST verification that T-Zero's
Pre-Flight Reality-Lock compiler eliminates AI coding hallucinations
(0.0% escape rate) across 60 diverse real-world test scenarios.

HallucinationBenchmarkCase

Kind: Class
Source: tzero/tzero_hallucination_proof.py:24-31

Declaration:

class HallucinationBenchmarkCase:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CaseExecutionResult

Kind: Class
Source: tzero/tzero_hallucination_proof.py:35-46

Declaration:

class CaseExecutionResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationProofResult

Kind: Class
Source: tzero/tzero_hallucination_proof.py:50-68

Declaration:

class HallucinationProofResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationProofEngine

Kind: Class
Source: tzero/tzero_hallucination_proof.py:608-894

Declaration:

class HallucinationProofEngine:

Source docstring:

Deterministic AST Reality-Lock Benchmark and Verification Suite.

HallucinationProofEngine.run_proof_benchmark

Kind: Method
Source: tzero/tzero_hallucination_proof.py:612-703

Signature:

def run_proof_benchmark(cls, workspace_dir: str = '.') -> HallucinationProofResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationProofEngine.render_cli

Kind: Method
Source: tzero/tzero_hallucination_proof.py:706-745

Signature:

def render_cli(cls, rep: HallucinationProofResult) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationProofEngine.export_artifacts

Kind: Method
Source: tzero/tzero_hallucination_proof.py:748-894

Signature:

def export_artifacts(cls, rep: HallucinationProofResult, out_dir: str = 'docs') -> Dict[str, str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_mutation.py

Source: tzero/tzero_mutation.py
Source size: 463 lines | 4 classes | 11 functions

Module docstring:

T-Zero Autonomous AST Mutation Testing & Test Quality Engine.

Evaluates test suite robustness and detects phantom/tautological tests
by injecting subtle AST mutations into code and validating if existing tests fail (kill the mutant).

Features:
- Pure AST mutation: Comparison, boolean, arithmetic, and constant operators.
- 100% Offline & Zero-Dependency: Uses Python standard library (ast, unittest, subprocess).
- In-memory & isolated tempfile execution without modifying git working tree.
- Calculates Mutation Score (0-100%) and recommends precise assertion patches.

Author: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v10.8.0 Master Edition.

Mutant

Kind: Class
Source: tzero/tzero_mutation.py:36-45

Declaration:

class Mutant:

Source docstring: none; consult the linked implementation instead of inferring behavior.

MutationReport

Kind: Class
Source: tzero/tzero_mutation.py:49-58

Declaration:

class MutationReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationTransformer

Kind: Class
Source: tzero/tzero_mutation.py:61-162

Declaration:

class ASTMutationTransformer(ast.NodeTransformer):

Source docstring:

Generates targeted single-point mutations in an AST tree.

ASTMutationTransformer.__init__

Kind: Method
Source: tzero/tzero_mutation.py:89-93

Signature:

def __init__(self, target_mutation_index: int):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationTransformer.visit_Compare

Kind: Method
Source: tzero/tzero_mutation.py:95-112

Signature:

def visit_Compare(self, node: ast.Compare) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationTransformer.visit_BoolOp

Kind: Method
Source: tzero/tzero_mutation.py:114-130

Signature:

def visit_BoolOp(self, node: ast.BoolOp) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationTransformer.visit_BinOp

Kind: Method
Source: tzero/tzero_mutation.py:132-148

Signature:

def visit_BinOp(self, node: ast.BinOp) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationTransformer.visit_Constant

Kind: Method
Source: tzero/tzero_mutation.py:150-162

Signature:

def visit_Constant(self, node: ast.Constant) -> ast.AST:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationEngine

Kind: Class
Source: tzero/tzero_mutation.py:165-463

Declaration:

class ASTMutationEngine:

Source docstring:

Orchestrates mutation generation, test execution, and mutation score computation.

ASTMutationEngine.count_mutation_points

Kind: Method
Source: tzero/tzero_mutation.py:169-177

Signature:

def count_mutation_points(cls, code: str) -> int:

Source docstring:

Counts total possible mutation opportunities in code.

ASTMutationEngine.generate_mutants

Kind: Method
Source: tzero/tzero_mutation.py:180-213

Signature:

def generate_mutants(cls, code: str, max_mutants: int = 15) -> List[Mutant]:

Source docstring:

Generates up to max_mutants distinct AST mutations.

ASTMutationEngine._build_allowed_test_entries

Kind: Method
Source: tzero/tzero_mutation.py:221-241

Signature:

def _build_allowed_test_entries(cls, roots: List[str]) -> Dict[str, str]:

Source docstring:

Builds an allowlist mapping real filesystem paths to verified on-disk paths.

ASTMutationEngine._sanitize_target_path

Kind: Method
Source: tzero/tzero_mutation.py:244-257

Signature:

def _sanitize_target_path(target_path: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTMutationEngine.run_mutation_analysis

Kind: Method
Source: tzero/tzero_mutation.py:260-433

Signature:

def run_mutation_analysis(cls, target_file: str, test_command: Optional[str] = None, max_mutants: int = 10, timeout_seconds: float = 6.0) -> MutationReport:

Source docstring:

Executes full mutation testing on target_file against test_command.

ASTMutationEngine.format_markdown_report

Kind: Method
Source: tzero/tzero_mutation.py:436-463

Signature:

def format_markdown_report(cls, report: MutationReport) -> str:

Source docstring:

Formats the mutation analysis into clean GitHub-style Markdown.

tzero/tzero_neural_cortex.py

Source: tzero/tzero_neural_cortex.py
Source size: 1425 lines | 40 classes | 62 functions

Module docstring:


T-ZERO NEURAL CORTEX & AGENT-OS CORE ENGINE (v9.0.0-OMNI)
---------------------------------------------------------
Developer: [redacted] (Siber Akademi)
Version: 9.0.0-OMNI
License: Zero-Cost Offline Open Architecture

Provides:
- 105 Comprehensive Enterprise AI Capabilities Matrix (7 Pillars)
- 12 Built-in Specialized Autonomous Subagents (T-Zero Fleet)
- Matryoshka Multi-Layer Context Engine (L0, L1, L2, L3)
- Shadow Workspace & CoW Virtual Overlay File System
- AgentForge Dynamic Persona & Subagent Synthesizer
- HallucinationGuard AST Reality-Lock Validator
- NeuralSwarmConflictFree DAG Coordinator

CapabilityCategory

Kind: Class
Source: tzero/tzero_neural_cortex.py:38-53

Declaration:

class CapabilityCategory(str, Enum):

Source docstring: none; consult the linked implementation instead of inferring behavior.

Capability

Kind: Class
Source: tzero/tzero_neural_cortex.py:57-79

Declaration:

class Capability:

Source docstring: none; consult the linked implementation instead of inferring behavior.

Capability.to_dict

Kind: Method
Source: tzero/tzero_neural_cortex.py:68-79

Signature:

def to_dict(self) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry

Kind: Class
Source: tzero/tzero_neural_cortex.py:82-250

Declaration:

class CapabilityRegistry:

Source docstring:

Manages the full 105 T-Zero Enterprise AI Capability Matrix across 7 Pillars.

CapabilityRegistry.__init__

Kind: Method
Source: tzero/tzero_neural_cortex.py:85-87

Signature:

def __init__(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry.register

Kind: Method
Source: tzero/tzero_neural_cortex.py:89-90

Signature:

def register(self, cap: Capability) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry.get

Kind: Method
Source: tzero/tzero_neural_cortex.py:92-93

Signature:

def get(self, cap_id: str) -> Optional[Capability]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry.list_all

Kind: Method
Source: tzero/tzero_neural_cortex.py:95-96

Signature:

def list_all(self) -> List[Capability]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry.search

Kind: Method
Source: tzero/tzero_neural_cortex.py:98-110

Signature:

def search(self, query: str = '', category: Optional[CapabilityCategory] = None, pillar_num: Optional[int] = None) -> List[Capability]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry.to_dict

Kind: Method
Source: tzero/tzero_neural_cortex.py:112-113

Signature:

def to_dict(self) -> List[Dict[str, Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CapabilityRegistry._bootstrap_105_capabilities

Kind: Method
Source: tzero/tzero_neural_cortex.py:115-250

Signature:

def _bootstrap_105_capabilities(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

MatryoshkaResolutionEngine

Kind: Class
Source: tzero/tzero_neural_cortex.py:257-311

Declaration:

class MatryoshkaResolutionEngine:

Source docstring:

Provides multi-layer progressive resolution for any file or code snippet:
    L0: 10-token purpose summary
    L1: 50-token exported symbols
    L2: 200-token AST signatures and typed interfaces
    L3: 100% full implementation source code

MatryoshkaResolutionEngine.resolve_layers

Kind: Method
Source: tzero/tzero_neural_cortex.py:266-311

Signature:

def resolve_layers(cls, source_code: str, filename_hint: str = 'module.py') -> Dict[str, str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine

Kind: Class
Source: tzero/tzero_neural_cortex.py:318-380

Declaration:

class ShadowWorkspaceEngine:

Source docstring:

In-memory Copy-on-Write overlay file system with atomic rollback.

ShadowWorkspaceEngine.__init__

Kind: Method
Source: tzero/tzero_neural_cortex.py:321-324

Signature:

def __init__(self, workspace_root: str = '.'):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.stage

Kind: Method
Source: tzero/tzero_neural_cortex.py:326-327

Signature:

def stage(self, rel_path: str, content: str) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.checkpoint

Kind: Method
Source: tzero/tzero_neural_cortex.py:329-331

Signature:

def checkpoint(self) -> int:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.rollback

Kind: Method
Source: tzero/tzero_neural_cortex.py:333-337

Signature:

def rollback(self) -> None:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.get_staged

Kind: Method
Source: tzero/tzero_neural_cortex.py:339-340

Signature:

def get_staged(self, rel_path: str) -> Optional[str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.list_staged

Kind: Method
Source: tzero/tzero_neural_cortex.py:342-343

Signature:

def list_staged(self) -> List[str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.dry_run_diff

Kind: Method
Source: tzero/tzero_neural_cortex.py:345-364

Signature:

def dry_run_diff(self) -> Dict[str, str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ShadowWorkspaceEngine.commit_atomic

Kind: Method
Source: tzero/tzero_neural_cortex.py:366-380

Signature:

def commit_atomic(self) -> Tuple[bool, List[str]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

StaticCallGraphEngine

Kind: Class
Source: tzero/tzero_neural_cortex.py:389-438

Declaration:

class StaticCallGraphEngine:

Source docstring:

Builds callers and callees DAG using AST inspection (CAP-003).

StaticCallGraphEngine.build_graph

Kind: Method
Source: tzero/tzero_neural_cortex.py:392-438

Signature:

def build_graph(cls, source_code: str) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

StaticCallGraphEngine.build_graph.CallVisitor

Kind: Class
Source: tzero/tzero_neural_cortex.py:399-423

Declaration:

class CallVisitor(ast.NodeVisitor):

Source docstring: none; consult the linked implementation instead of inferring behavior.

StaticCallGraphEngine.build_graph.CallVisitor.__init__

Kind: Method
Source: tzero/tzero_neural_cortex.py:400-401

Signature:

def __init__(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

StaticCallGraphEngine.build_graph.CallVisitor.visit_FunctionDef

Kind: Method
Source: tzero/tzero_neural_cortex.py:403-409

Signature:

def visit_FunctionDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

StaticCallGraphEngine.build_graph.CallVisitor.visit_AsyncFunctionDef

Kind: Method
Source: tzero/tzero_neural_cortex.py:411-412

Signature:

def visit_AsyncFunctionDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

StaticCallGraphEngine.build_graph.CallVisitor.visit_Call

Kind: Method
Source: tzero/tzero_neural_cortex.py:414-423

Signature:

def visit_Call(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

BackwardProgramSlicer

Kind: Class
Source: tzero/tzero_neural_cortex.py:441-481

Declaration:

class BackwardProgramSlicer:

Source docstring:

Static backward program slicing on CFG/DFG (CAP-004).

BackwardProgramSlicer.slice

Kind: Method
Source: tzero/tzero_neural_cortex.py:444-481

Signature:

def slice(cls, source_code: str, target_var: str, target_line: int = -1) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

BlastRadiusCalculator

Kind: Class
Source: tzero/tzero_neural_cortex.py:484-502

Declaration:

class BlastRadiusCalculator:

Source docstring:

Calculates downstream change blast radius (0-100 impact score) (CAP-005).

BlastRadiusCalculator.calculate_blast_radius

Kind: Method
Source: tzero/tzero_neural_cortex.py:487-502

Signature:

def calculate_blast_radius(cls, symbol: str, code_or_files: Any) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SurgicalASTPatcher

Kind: Class
Source: tzero/tzero_neural_cortex.py:505-543

Declaration:

class SurgicalASTPatcher:

Source docstring:

Replaces target AST nodes directly without line-drift errors (CAP-006).

SurgicalASTPatcher.patch_node

Kind: Method
Source: tzero/tzero_neural_cortex.py:508-543

Signature:

def patch_node(cls, source_code: str, target_name: str, replacement_code: str) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SurgicalASTPatcher.patch_node.Patcher

Kind: Class
Source: tzero/tzero_neural_cortex.py:520-534

Declaration:

class Patcher(ast.NodeTransformer):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SurgicalASTPatcher.patch_node.Patcher.visit_FunctionDef

Kind: Method
Source: tzero/tzero_neural_cortex.py:521-526

Signature:

def visit_FunctionDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SurgicalASTPatcher.patch_node.Patcher.visit_AsyncFunctionDef

Kind: Method
Source: tzero/tzero_neural_cortex.py:527-528

Signature:

def visit_AsyncFunctionDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SurgicalASTPatcher.patch_node.Patcher.visit_ClassDef

Kind: Method
Source: tzero/tzero_neural_cortex.py:529-534

Signature:

def visit_ClassDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

Type3CloneDetector

Kind: Class
Source: tzero/tzero_neural_cortex.py:546-599

Declaration:

class Type3CloneDetector:

Source docstring:

Detects Type-3/4 semantic code duplicates via normalized AST statement patterns (CAP-007).

Type3CloneDetector.detect_clones

Kind: Method
Source: tzero/tzero_neural_cortex.py:549-599

Signature:

def detect_clones(cls, source_code: str, min_statements: int = 4) -> List[Dict[str, Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

Type3CloneDetector.detect_clones.normalize_func

Kind: Nested function
Source: tzero/tzero_neural_cortex.py:558-581

Signature:

def normalize_func(fn_node: ast.FunctionDef) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

Type3CloneDetector.detect_clones.normalize_func.Normalizer

Kind: Class
Source: tzero/tzero_neural_cortex.py:569-578

Declaration:

class Normalizer(ast.NodeTransformer):

Source docstring: none; consult the linked implementation instead of inferring behavior.

Type3CloneDetector.detect_clones.normalize_func.Normalizer.visit_Name

Kind: Method
Source: tzero/tzero_neural_cortex.py:570-578

Signature:

def visit_Name(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

CyclomaticComplexityEngine

Kind: Class
Source: tzero/tzero_neural_cortex.py:602-637

Declaration:

class CyclomaticComplexityEngine:

Source docstring:

Computes McCabe Cyclomatic Complexity for every function and branch in AST (CAP-010).

CyclomaticComplexityEngine.analyze

Kind: Method
Source: tzero/tzero_neural_cortex.py:605-637

Signature:

def analyze(cls, source_code: str) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaintFlowTracker

Kind: Class
Source: tzero/tzero_neural_cortex.py:640-687

Declaration:

class TaintFlowTracker:

Source docstring:

Traces untrusted user inputs to sensitive execution sinks (CAP-013).

TaintFlowTracker.scan

Kind: Method
Source: tzero/tzero_neural_cortex.py:646-687

Signature:

def scan(cls, source_code: str) -> List[Dict[str, Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTranspiler

Kind: Class
Source: tzero/tzero_neural_cortex.py:690-730

Declaration:

class PolyglotTranspiler:

Source docstring:

Transpiles Python AST dataclasses & signatures to TypeScript interfaces (CAP-012, CAP-027).

PolyglotTranspiler.to_typescript

Kind: Method
Source: tzero/tzero_neural_cortex.py:693-730

Signature:

def to_typescript(cls, source_code: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PropertyFuzzGenerator

Kind: Class
Source: tzero/tzero_neural_cortex.py:733-742

Declaration:

class PropertyFuzzGenerator:

Source docstring:

Synthesizes boundary fuzz vectors for testing code survivability (CAP-039).

PropertyFuzzGenerator.generate_fuzz_vectors

Kind: Method
Source: tzero/tzero_neural_cortex.py:736-742

Signature:

def generate_fuzz_vectors(cls) -> Dict[str, List[Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

EntropySecretScrubber

Kind: Class
Source: tzero/tzero_neural_cortex.py:745-778

Declaration:

class EntropySecretScrubber:

Source docstring:

Zero-Leak entropy & regex secret scrubber with bidirectional token masking (CAP-095).

EntropySecretScrubber.calculate_entropy

Kind: Method
Source: tzero/tzero_neural_cortex.py:754-757

Signature:

def calculate_entropy(cls, text: str) -> float:

Source docstring: none; consult the linked implementation instead of inferring behavior.

EntropySecretScrubber.scrub

Kind: Method
Source: tzero/tzero_neural_cortex.py:760-771

Signature:

def scrub(cls, text: str) -> Tuple[str, Dict[str, str]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

EntropySecretScrubber.restore

Kind: Method
Source: tzero/tzero_neural_cortex.py:774-778

Signature:

def restore(cls, scrubbed_text: str, redaction_map: Dict[str, str]) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DeveloperDNACloner

Kind: Class
Source: tzero/tzero_neural_cortex.py:781-816

Declaration:

class DeveloperDNACloner:

Source docstring:

Clones developer coding style conventions directly from workspace AST (CAP-078).

DeveloperDNACloner.analyze_style

Kind: Method
Source: tzero/tzero_neural_cortex.py:784-816

Signature:

def analyze_style(cls, source_code: str) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentReport

Kind: Class
Source: tzero/tzero_neural_cortex.py:824-842

Declaration:

class AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentReport.to_dict

Kind: Method
Source: tzero/tzero_neural_cortex.py:833-842

Signature:

def to_dict(self) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

BaseFleetAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:845-850

Declaration:

class BaseFleetAgent:

Source docstring: none; consult the linked implementation instead of inferring behavior.

BaseFleetAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:849-850

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SecuritySentinelAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:853-881

Declaration:

class SecuritySentinelAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SecuritySentinelAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:857-881

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTArchitectAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:884-907

Declaration:

class ASTArchitectAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTArchitectAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:888-907

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DeadCodePurgerAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:910-941

Declaration:

class DeadCodePurgerAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DeadCodePurgerAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:914-941

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TestSynthesizerAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:944-969

Declaration:

class TestSynthesizerAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

TestSynthesizerAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:948-969

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTranspilerAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:972-993

Declaration:

class PolyglotTranspilerAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

PolyglotTranspilerAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:976-993

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

BugHunterAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:996-1015

Declaration:

class BugHunterAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

BugHunterAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1000-1015

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

PerformanceProfilerAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:1018-1040

Declaration:

class PerformanceProfilerAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

PerformanceProfilerAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1022-1040

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DocstringGeneratorAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:1043-1068

Declaration:

class DocstringGeneratorAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DocstringGeneratorAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1047-1068

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DependencyAuditorAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:1071-1099

Declaration:

class DependencyAuditorAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DependencyAuditorAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1075-1099

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

RefactorModernizerAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:1102-1123

Declaration:

class RefactorModernizerAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

RefactorModernizerAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1106-1123

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationValidatorAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:1126-1151

Declaration:

class HallucinationValidatorAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationValidatorAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1130-1151

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

DevOpsReleaseAgent

Kind: Class
Source: tzero/tzero_neural_cortex.py:1154-1168

Declaration:

class DevOpsReleaseAgent(BaseFleetAgent):

Source docstring: none; consult the linked implementation instead of inferring behavior.

DevOpsReleaseAgent.evaluate

Kind: Method
Source: tzero/tzero_neural_cortex.py:1158-1168

Signature:

def evaluate(self, mission_goal: str, context: str = '') -> AgentReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TZeroAgentFleet

Kind: Class
Source: tzero/tzero_neural_cortex.py:1171-1197

Declaration:

class TZeroAgentFleet:

Source docstring:

Manages the 12 specialized built-in autonomous subagents.

TZeroAgentFleet.__init__

Kind: Method
Source: tzero/tzero_neural_cortex.py:1174-1188

Signature:

def __init__(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

TZeroAgentFleet.list_agents

Kind: Method
Source: tzero/tzero_neural_cortex.py:1190-1191

Signature:

def list_agents(self) -> List[Dict[str, Any]]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TZeroAgentFleet.get_agent

Kind: Method
Source: tzero/tzero_neural_cortex.py:1193-1194

Signature:

def get_agent(self, name: str) -> Optional[BaseFleetAgent]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TZeroAgentFleet.evaluate_all

Kind: Method
Source: tzero/tzero_neural_cortex.py:1196-1197

Signature:

def evaluate_all(self, mission: str, context: str = '') -> List[AgentReport]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

AgentForge

Kind: Class
Source: tzero/tzero_neural_cortex.py:1204-1270

Declaration:

class AgentForge:

Source docstring:

Dynamically synthesizes domain-tailored AI subagents based on workspace AST.

AgentForge.synthesize_subagent

Kind: Method
Source: tzero/tzero_neural_cortex.py:1207-1270

Signature:

def synthesize_subagent(self, role: str, task: str, workspace_dir: str = '.', tier_level: str = 'T-2') -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationIssue

Kind: Class
Source: tzero/tzero_neural_cortex.py:1278-1283

Declaration:

class HallucinationIssue:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationValidationResult

Kind: Class
Source: tzero/tzero_neural_cortex.py:1287-1291

Declaration:

class HallucinationValidationResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

HallucinationGuard

Kind: Class
Source: tzero/tzero_neural_cortex.py:1294-1365

Declaration:

class HallucinationGuard:

Source docstring:

Pre-flight AST reality-lock validator that detects phantom imports & hallucinated methods.

HallucinationGuard.validate_code

Kind: Method
Source: tzero/tzero_neural_cortex.py:1303-1365

Signature:

def validate_code(self, source_code: str) -> HallucinationValidationResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SwarmMissionPlan

Kind: Class
Source: tzero/tzero_neural_cortex.py:1373-1377

Declaration:

class SwarmMissionPlan:

Source docstring: none; consult the linked implementation instead of inferring behavior.

NeuralSwarmCoordinator

Kind: Class
Source: tzero/tzero_neural_cortex.py:1380-1425

Declaration:

class NeuralSwarmCoordinator:

Source docstring:

Coordinates multi-agent execution using blast-radius file locks and DAG pipelines.

NeuralSwarmCoordinator.__init__

Kind: Method
Source: tzero/tzero_neural_cortex.py:1383-1384

Signature:

def __init__(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

NeuralSwarmCoordinator.create_mission_plan

Kind: Method
Source: tzero/tzero_neural_cortex.py:1386-1403

Signature:

def create_mission_plan(self, mission_title: str, tasks: List[Dict[str, Any]]) -> SwarmMissionPlan:

Source docstring: none; consult the linked implementation instead of inferring behavior.

NeuralSwarmCoordinator.execute_mission

Kind: Method
Source: tzero/tzero_neural_cortex.py:1405-1425

Signature:

def execute_mission(self, plan: SwarmMissionPlan) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_reachability.py

Source: tzero/tzero_reachability.py
Source size: 272 lines | 3 classes | 11 functions

Module docstring:

T-Zero Cross-Module AST Call-Graph Reachability & Dead-Code Pruning Engine.

Performs static AST call-graph reachability analysis across multi-file codebases,
discovering reachable symbols from specified entrypoints and pruning unreferenced
functions and dead classes to assemble ultra-compact, Zero-Waste LLM prompt contexts.

Developer: [redacted] (Siber Akademi)
Part of T-Zero Context Architect v7.0.0 Master Edition.

SymbolNode

Kind: Class
Source: tzero/tzero_reachability.py:18-42

Declaration:

class SymbolNode:

Source docstring:

Represents a callable symbol (function or class) in the codebase AST.

SymbolNode.__init__

Kind: Method
Source: tzero/tzero_reachability.py:20-27

Signature:

def __init__(self, name: str, file_path: str, start_line: int, end_line: int, code: str, is_class: bool = False):

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolNode.symbol_id

Kind: Method
Source: tzero/tzero_reachability.py:30-31

Signature:

def symbol_id(self) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SymbolNode.to_dict

Kind: Method
Source: tzero/tzero_reachability.py:33-42

Signature:

def to_dict(self) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

CallExtractorVisitor

Kind: Class
Source: tzero/tzero_reachability.py:45-55

Declaration:

class CallExtractorVisitor(ast.NodeVisitor):

Source docstring:

AST Visitor to extract invoked function and class names within a symbol body.

CallExtractorVisitor.__init__

Kind: Method
Source: tzero/tzero_reachability.py:47-48

Signature:

def __init__(self):

Source docstring: none; consult the linked implementation instead of inferring behavior.

CallExtractorVisitor.visit_Call

Kind: Method
Source: tzero/tzero_reachability.py:50-55

Signature:

def visit_Call(self, node: ast.Call):

Source docstring: none; consult the linked implementation instead of inferring behavior.

CallGraphReachabilityEngine

Kind: Class
Source: tzero/tzero_reachability.py:58-272

Declaration:

class CallGraphReachabilityEngine:

Source docstring:

Enterprise AST graph reachability engine for zero-waste LLM prompt synthesis.

CallGraphReachabilityEngine.__init__

Kind: Method
Source: tzero/tzero_reachability.py:66-71

Signature:

def __init__(self, workspace_root: str = '.'):

Source docstring: none; consult the linked implementation instead of inferring behavior.

CallGraphReachabilityEngine.scan_workspace

Kind: Method
Source: tzero/tzero_reachability.py:73-92

Signature:

def scan_workspace(self):

Source docstring:

Discovers and parses all Python files in the workspace root.

CallGraphReachabilityEngine._parse_file

Kind: Method
Source: tzero/tzero_reachability.py:94-132

Signature:

def _parse_file(self, rel_path: str, content: str):

Source docstring:

Parses a single Python file into AST and indexes classes, functions, and top-level calls.

CallGraphReachabilityEngine._is_main_guard

Kind: Method
Source: tzero/tzero_reachability.py:135-147

Signature:

def _is_main_guard(node: ast.If) -> bool:

Source docstring:

Checks if an AST If block represents if __name__ == '__main__':.

CallGraphReachabilityEngine.build_reachability_graph

Kind: Method
Source: tzero/tzero_reachability.py:149-218

Signature:

def build_reachability_graph(self, entrypoints: Optional[List[str]] = None) -> Dict[str, Any]:

Source docstring:

Calculates reachable vs dead symbols using BFS graph traversal.

CallGraphReachabilityEngine.generate_zero_waste_prompt

Kind: Method
Source: tzero/tzero_reachability.py:220-272

Signature:

def generate_zero_waste_prompt(self, entrypoints: Optional[List[str]] = None) -> Dict[str, Any]:

Source docstring:

Assembles a streamlined prompt context containing strictly reachable code.

tzero/tzero_scip.py

Source: tzero/tzero_scip.py
Source size: 387 lines | 3 classes | 11 functions

Module docstring:

T-Zero SCIP / LSIF Cross-Language Index Importer.

Loads compiler-exact SCIP JSON and LSIF NDJSON symbol indexes into a unified
cross-file definition/reference call graph without running external paid services.

100% Free, Local, Offline, Zero-Leak Certified.

_read_varint

Kind: Function
Source: tzero/tzero_scip.py:19-33

Signature:

def _read_varint(raw: bytes, offset: int = 0) -> Tuple[int, int]:

Source docstring:

Reads a varint from raw bytes starting at offset. Returns (value, new_offset).

_iter_wire_fields

Kind: Function
Source: tzero/tzero_scip.py:36-63

Signature:

def _iter_wire_fields(raw: bytes) -> Iterator[Tuple[int, int, Any]]:

Source docstring:

Iterates (tag, wire_type, value) tuples from protobuf binary wire bytes.

SymbolLocation

Kind: Class
Source: tzero/tzero_scip.py:67-72

Declaration:

class SymbolLocation:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexGraph

Kind: Class
Source: tzero/tzero_scip.py:76-121

Declaration:

class ScipIndexGraph:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexGraph.trace_symbol

Kind: Method
Source: tzero/tzero_scip.py:83-113

Signature:

def trace_symbol(self, symbol_query: str) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexGraph.export_tzero_graph

Kind: Method
Source: tzero/tzero_scip.py:115-121

Signature:

def export_tzero_graph(self) -> Dict[str, Any]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexImporter

Kind: Class
Source: tzero/tzero_scip.py:124-380

Declaration:

class ScipIndexImporter:

Source docstring:

Loads SCIP JSON or LSIF NDJSON indexes into ScipIndexGraph.

ScipIndexImporter._uri_to_rel

Kind: Method
Source: tzero/tzero_scip.py:128-134

Signature:

def _uri_to_rel(cls, uri: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexImporter.from_scip_dict

Kind: Method
Source: tzero/tzero_scip.py:137-179

Signature:

def from_scip_dict(cls, payload: Dict[str, Any]) -> ScipIndexGraph:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexImporter.from_lsif_lines

Kind: Method
Source: tzero/tzero_scip.py:182-261

Signature:

def from_lsif_lines(cls, lines: List[str]) -> ScipIndexGraph:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexImporter.from_lsif_lines._range_loc

Kind: Nested function
Source: tzero/tzero_scip.py:230-239

Signature:

def _range_loc(rv: Any, sym: str, role: str) -> SymbolLocation:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexImporter.from_scip_protobuf_bytes

Kind: Method
Source: tzero/tzero_scip.py:264-337

Signature:

def from_scip_protobuf_bytes(cls, raw: bytes) -> ScipIndexGraph:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ScipIndexImporter.load

Kind: Method
Source: tzero/tzero_scip.py:340-380

Signature:

def load(cls, path: str) -> ScipIndexGraph:

Source docstring: none; consult the linked implementation instead of inferring behavior.

run_scip_import_cli

Kind: Function
Source: tzero/tzero_scip.py:383-387

Signature:

def run_scip_import_cli(path: str, symbol: Optional[str] = None) -> int:

Source docstring: none; consult the linked implementation instead of inferring behavior.

tzero/tzero_security.py

Source: tzero/tzero_security.py
Source size: 917 lines | 3 classes | 20 functions

Module docstring:


Siber Akademi — T-Zero 100% Zero-Leak Security & Shannon Entropy Engine.
Developer: [redacted] (Siber Akademi)
License: MIT

Centralized, high-throughput offline security engine providing:
1. Signature-based secret scanning across 20+ cloud, AI, payment, and VCS providers.
2. Shannon Entropy mathematical anomaly detection for raw un-prefixed cryptographic keys.
3. AST-level and textual Zero-Leak secret redaction ([ZERO_LEAK_MASKED_...]).
4. Git pre-commit, MCP, and CLI verification integrations.

calculate_shannon_entropy

Kind: Function
Source: tzero/tzero_security.py:27-44

Signature:

def calculate_shannon_entropy(data: str) -> float:

Source docstring:

Calculates Shannon entropy (bits per symbol) of a given string.

    Higher entropy indicates higher randomness (e.g. cryptographic keys,
    base64-encoded secrets, high-entropy tokens).
    Standard English text: ~2.5 - 3.5
    Source code identifiers: ~3.0 - 3.8
    Random Base64 / Hex secrets (32+ chars): ~4.5 - 6.0

SecretRule

Kind: Class
Source: tzero/tzero_security.py:67-73

Declaration:

class SecretRule:

Source docstring: none; consult the linked implementation instead of inferring behavior.

SecretFinding

Kind: Class
Source: tzero/tzero_security.py:251-260

Declaration:

class SecretFinding:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroLeakEngine

Kind: Class
Source: tzero/tzero_security.py:263-916

Declaration:

class ZeroLeakEngine:

Source docstring:

Enterprise 100% Zero-Leak security scanner and sanitizer.

ZeroLeakEngine._iter_pem_block_spans

Kind: Method
Source: tzero/tzero_security.py:272-284

Signature:

def _iter_pem_block_spans(cls, text: str) -> List[Tuple[int, int]]:

Source docstring:

Linearly locates complete PEM BEGIN..END block byte spans without polynomial regex backtracking.

ZeroLeakEngine._mask_pem_blocks

Kind: Method
Source: tzero/tzero_security.py:287-299

Signature:

def _mask_pem_blocks(cls, text: str, replacement: str = '[ZERO_LEAK_MASKED_PRIVATE_KEY]') -> str:

Source docstring:

Replaces complete PEM BEGIN..END blocks linearly cleanly.

ZeroLeakEngine.is_placeholder

Kind: Method
Source: tzero/tzero_security.py:302-305

Signature:

def is_placeholder(cls, s: str) -> bool:

Source docstring:

Determines if a candidate string is an intentional placeholder/mock.

ZeroLeakEngine.is_natural_or_identifier

Kind: Method
Source: tzero/tzero_security.py:308-322

Signature:

def is_natural_or_identifier(cls, s: str) -> bool:

Source docstring:

Rejects common false positives (all-lowercase slugs, public project/team IDs).

ZeroLeakEngine.scan_text

Kind: Method
Source: tzero/tzero_security.py:325-442

Signature:

def scan_text(cls, text: str, check_entropy: bool = True) -> List[SecretFinding]:

Source docstring:

Scans in-memory text (including comments and multiline PEM blocks) for secrets.

ZeroLeakEngine.scan_text._in_pem_block

Kind: Nested function
Source: tzero/tzero_security.py:352-353

Signature:

def _in_pem_block(ln: int) -> bool:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroLeakEngine.mask_preview

Kind: Method
Source: tzero/tzero_security.py:445-450

Signature:

def mask_preview(cls, line: str, max_len: int = 70) -> str:

Source docstring:

Sanitizes line for safe terminal output and logging.

ZeroLeakEngine.sanitize_text

Kind: Method
Source: tzero/tzero_security.py:453-487

Signature:

def sanitize_text(cls, text: str, allow_incomplete_pem: bool = False) -> str:

Source docstring:

Sanitizes text by masking all detected secrets with Zero-Leak tokens.

ZeroLeakEngine.sanitize_text._replace_match

Kind: Function
Source: tzero/tzero_security.py:472-476

Signature:

def _replace_match(m):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroLeakEngine.sanitize_text._replace_entropy

Kind: Nested function
Source: tzero/tzero_security.py:480-484

Signature:

def _replace_entropy(m):

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroLeakEngine._sanitize_string_value

Kind: Method
Source: tzero/tzero_security.py:490-502

Signature:

def _sanitize_string_value(cls, val: str, allow_incomplete_pem: bool = False) -> str:

Source docstring:

Sanitize an extracted string value even when unquoted inside an AST literal.

ZeroLeakEngine.sanitize_ast

Kind: Method
Source: tzero/tzero_security.py:505-524

Signature:

def sanitize_ast(cls, tree: ast.AST) -> ast.AST:

Source docstring:

Walks an AST tree and replaces hardcoded string literals containing secrets.

ZeroLeakEngine.scan_files_map

Kind: Method
Source: tzero/tzero_security.py:527-554

Signature:

def scan_files_map(cls, files_map: Dict[str, str]) -> Dict[str, Any]:

Source docstring:

Scans in-memory files map {relative_path: file_content}.

ZeroLeakEngine.scan_workspace

Kind: Method
Source: tzero/tzero_security.py:557-573

Signature:

def scan_workspace(cls, workspace_dir: str = '.', exclude_tests: bool = True) -> dict:

Source docstring:

Scans a workspace directory for any hardcoded secrets and returns violations dict.

ZeroLeakEngine.resolve_project_root

Kind: Method
Source: tzero/tzero_security.py:576-587

Signature:

def resolve_project_root(cls, target_path: str) -> str:

Source docstring:

Resolve nearest project root (.git ancestor) or target directory consistently.

ZeroLeakEngine.check_env_git_status

Kind: Method
Source: tzero/tzero_security.py:590-629

Signature:

def check_env_git_status(cls, env_file_path: str, gitignore_path: Optional[str] = None) -> Dict[str, Any]:

Source docstring:

Use Git check-ignore/ls-files when available (fallback to real rule parsing).

ZeroLeakEngine._load_existing_env

Kind: Method
Source: tzero/tzero_security.py:632-644

Signature:

def _load_existing_env(cls, env_file_path: Optional[str]) -> Dict[str, str]:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ZeroLeakEngine.auto_migrate_to_env

Kind: Method
Source: tzero/tzero_security.py:647-807

Signature:

def auto_migrate_to_env(cls, code_str: str, env_file_path: Optional[str] = None, gitignore_path: Optional[str] = None, shared_env_registry: Optional[Dict[str, str]] = None, dry_run: bool = False) -> Tuple[str, str, int, str]:

Source docstring:

Extract hardcoded secrets to .env atomically without variable collisions or partial writes.

ZeroLeakEngine.migrate_files_atomically

Kind: Method
Source: tzero/tzero_security.py:810-916

Signature:

def migrate_files_atomically(cls, file_paths: List[str], env_file_path: str, gitignore_path: Optional[str] = None) -> Dict[str, Any]:

Source docstring:

Atomically migrate multiple files using a shared env table with rollback on write errors.

tzero/tzero_semantic_merge.py

Source: tzero/tzero_semantic_merge.py
Source size: 213 lines | 2 classes | 7 functions

Module docstring:


Siber Akademi — T-Zero AST Semantic 3-Way Merge & Conflict Healer.
Developer: [redacted] (Siber Akademi)
License: AGPL-3.0-only

Performs AST-aware 3-way code merging and automated resolution of git conflict blocks.
Safely combines independent function additions, deduplicates polyglot imports,
and eliminates broken syntax markers without relying on external cloud APIs.
100% Free, Zero External Dependencies, 100% Zero-Leak Certified.

MergeResult

Kind: Class
Source: tzero/tzero_semantic_merge.py:22-29

Declaration:

class MergeResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

ASTSemanticMerger

Kind: Class
Source: tzero/tzero_semantic_merge.py:32-208

Declaration:

class ASTSemanticMerger:

Source docstring:

Semantic AST-aware 3-way merger and git conflict block healer.

ASTSemanticMerger._find_conflict_blocks

Kind: Method
Source: tzero/tzero_semantic_merge.py:38-65

Signature:

def _find_conflict_blocks(cls, text: str) -> List[Tuple[str, str, str]]:

Source docstring:

Scans text linearly O(N) for git conflict blocks without regex backtracking.

ASTSemanticMerger.has_conflict_markers

Kind: Method
Source: tzero/tzero_semantic_merge.py:68-70

Signature:

def has_conflict_markers(cls, text: str) -> bool:

Source docstring:

Returns True if file contains standard git conflict markers.

ASTSemanticMerger.extract_ast_symbols

Kind: Method
Source: tzero/tzero_semantic_merge.py:73-95

Signature:

def extract_ast_symbols(cls, code: str) -> Dict[str, str]:

Source docstring:

Extracts top-level functions, classes, and imports as symbol_name -> code string.

ASTSemanticMerger.heal_conflict_file

Kind: Method
Source: tzero/tzero_semantic_merge.py:98-182

Signature:

def heal_conflict_file(cls, content: str) -> MergeResult:

Source docstring:


        Scans content for git conflict blocks (<<<<<<< ... ======= ... >>>>>>>)
        and attempts semantic AST healing.

ASTSemanticMerger.heal_file_on_disk

Kind: Method
Source: tzero/tzero_semantic_merge.py:185-195

Signature:

def heal_file_on_disk(cls, file_path: str, write_in_place: bool = True) -> MergeResult:

Source docstring:

Reads a file with git conflict markers, heals it, and optionally overwrites it.

ASTSemanticMerger.render_cli

Kind: Method
Source: tzero/tzero_semantic_merge.py:198-208

Signature:

def render_cli(cls, res: MergeResult, file_hint: str = 'file'):

Source docstring: none; consult the linked implementation instead of inferring behavior.

heal_conflicts

Kind: Function
Source: tzero/tzero_semantic_merge.py:211-213

Signature:

def heal_conflicts(content: str) -> MergeResult:

Source docstring:

Convenience functional interface.

tzero/tzero_task_benchmark.py

Source: tzero/tzero_task_benchmark.py
Source size: 506 lines | 4 classes | 10 functions

Module docstring:


T-Zero Task-Completion & Real Tokenizer Benchmark Engine
=========================================================
Empirically benchmarks token reduction and task-completion correctness
comparing Raw Codebase Ingestion against T-Zero Tier-2 Smart Skeletons.
Uses official BPE tokenizer (tiktoken cl100k_base / o200k_base) for exact token counts.

Author: Siber Akademi ([redacted])
License: MIT

count_bpe_tokens

Kind: Function
Source: tzero/tzero_task_benchmark.py:32-40

Signature:

def count_bpe_tokens(text: str, model_encoding: str = 'cl100k_base') -> int:

Source docstring:

Calculates exact BPE tokens using tiktoken if available, else standard char/4 fallback.

detect_installed_ollama_model

Kind: Function
Source: tzero/tzero_task_benchmark.py:43-58

Signature:

def detect_installed_ollama_model(ollama_url: str = 'http://127.0.0.1:11434') -> Optional[str]:

Source docstring:

Auto-detects already installed models on local Ollama without triggering any downloads.

TaskEvaluationResult

Kind: Class
Source: tzero/tzero_task_benchmark.py:62-73

Declaration:

class TaskEvaluationResult:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaskBenchmarkReport

Kind: Class
Source: tzero/tzero_task_benchmark.py:77-86

Declaration:

class TaskBenchmarkReport:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaskCompletionBenchmark

Kind: Class
Source: tzero/tzero_task_benchmark.py:89-481

Declaration:

class TaskCompletionBenchmark:

Source docstring:


    Evaluates whether an AI coding agent with signature-only surrounding context
    (T-Zero Tier-2 Smart Skeleton) can successfully synthesize correct, valid,
    and non-hallucinated code compared to raw full-file context ingestion.

TaskCompletionBenchmark.prune_to_ast_skeleton

Kind: Method
Source: tzero/tzero_task_benchmark.py:246-277

Signature:

def prune_to_ast_skeleton(cls, python_code: str) -> str:

Source docstring:

Prunes function/method bodies to docstrings & ellipsis, preserving full signatures & types.

TaskCompletionBenchmark.prune_to_ast_skeleton.SkeletonPruner

Kind: Class
Source: tzero/tzero_task_benchmark.py:253-273

Declaration:

class SkeletonPruner(ast.NodeTransformer):

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaskCompletionBenchmark.prune_to_ast_skeleton.SkeletonPruner.visit_FunctionDef

Kind: Method
Source: tzero/tzero_task_benchmark.py:254-263

Signature:

def visit_FunctionDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaskCompletionBenchmark.prune_to_ast_skeleton.SkeletonPruner.visit_AsyncFunctionDef

Kind: Method
Source: tzero/tzero_task_benchmark.py:265-273

Signature:

def visit_AsyncFunctionDef(self, node):

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaskCompletionBenchmark.evaluate_all

Kind: Method
Source: tzero/tzero_task_benchmark.py:280-282

Signature:

def evaluate_all(cls) -> TaskBenchmarkReport:

Source docstring:

Executes standard 3-task offline benchmark evaluation.

TaskCompletionBenchmark._build_adversarial_tasks

Kind: Method
Source: tzero/tzero_task_benchmark.py:285-328

Signature:

def _build_adversarial_tasks(cls) -> List[Dict[str, str]]:

Source docstring:

Synthesizes 8 multi-file cross-domain verification tasks for adversarial accuracy audits.

TaskCompletionBenchmark._query_ollama_implementation

Kind: Method
Source: tzero/tzero_task_benchmark.py:331-361

Signature:

def _query_ollama_implementation(pruned_dep: str, task_title: str, ollama_model: str, ollama_url: str) -> str:

Source docstring: none; consult the linked implementation instead of inferring behavior.

TaskCompletionBenchmark.evaluate_suite

Kind: Method
Source: tzero/tzero_task_benchmark.py:364-461

Signature:

def evaluate_suite(cls, suite: str = 'core', ollama_model: Optional[str] = None, ollama_url: str = 'http://127.0.0.1:11434/api/generate', limit_tasks: Optional[int] = None) -> TaskBenchmarkReport:

Source docstring:

Executes benchmark evaluation across 'core' (3 tasks) or 'adversarial' (8 tasks), optionally querying Ollama.

TaskCompletionBenchmark.format_terminal_summary

Kind: Method
Source: tzero/tzero_task_benchmark.py:464-481

Signature:

def format_terminal_summary(cls, report: TaskBenchmarkReport) -> str:

Source docstring:

Formats ANSI-styled benchmark summary table.

Clone this wiki locally