Skip to content

Whitepaper

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

Repository source: docs/WHITE_PAPER_TZERO_V10.md
Snapshot of the source document; follow the repository link for the current version.

Status and evidence: This is a historical, project-authored technical note, not an independently validated specification or security certification. Benchmark figures, performance guarantees, deployment availability, and claims about zero leakage or zero hallucinations may not match the current implementation. Confirm behavior against the linked source, tests, and Evidence-Boundaries.

License note: Current repository metadata declares AGPL-3.0-only; the original MIT statement in this whitepaper conflicts with that metadata. See the repository's LICENSE and pyproject.toml. This archived page is not a license grant.


T-ZERO (TOKEN ZERO): AST CONTEXT ENGINEERING — HISTORICAL WHITEPAPER

Technical Whitepaper & Architectural Specification — Version 10.7

Author: Toprak Ahmet Aydoğmuş (Siber Akademi)
Affiliation: Siber Akademi Open-Source AI Research Lab
Contact: GitHub repository and Security Reporting
License: See the note above and the repository's current LICENSE; pricing and third-party service costs depend on the selected workflow.


1. Executive Summary & Problem Formulation

1.1 The Context Window Crisis in Frontier AI Coding

Frontier Large Language Models (LLMs)—including Anthropic Claude 3.7 Sonnet, OpenAI GPT-4o, Google Gemini 2.5 Pro, and DeepSeek-V3—possess theoretical context windows spanning from 128,000 to 2,000,000 tokens. However, in enterprise software engineering practice, expanding prompt context with raw source code triggers three catastrophic failure modes:

  1. Quadratic Cost Inflation ($O(N)$ Financial Drain): Injecting an entire repository of 50,000–100,000 lines of code consumes between 500,000 and 1,200,000 tokens per prompt invocation. For a 10-developer team executing 30 AI agent queries per day, raw context injection costs between $9,000 and $18,000 per month in cloud inference fees.
  2. Attention Degradation ("Lost-in-the-Middle"): Empirical transformer research demonstrates that effective multi-needle recall degrades precipitously when procedural implementation bodies (loops, SQL queries, DOM mutations, verbose logging) dilute the attention weights allocated to critical class and interface contracts.
  3. The Hallucination Cascade: When an AI coding agent lacks a deterministic symbolic representation of surrounding module interfaces, it speculatively predicts method names, argument positions, and import paths based on general pre-training probability distributions rather than the physical reality of the workspace AST.

1.2 The T-Zero Algorithmic Paradigm

T-Zero (Token Zero) is designed to address this limitation through AST-based context extraction:

  • Instead of naive file concatenation (e.g., Repomix) or lossy heuristic text chunking (standard RAG), T-Zero extracts formal interface contracts across 15+ programming languages.
  • Compresses code context by up to 95.0% in less than 1.0 millisecond on local CPU hardware.
  • Includes static symbol checks intended to catch some unsupported references; these checks do not prove that hallucinations or runtime errors are impossible.
  • Offers local analysis paths, but this does not guarantee that data never leaves the machine. Optional integrations and connected clients may make network requests; see Privacy-and-Network-Behavior.
flowchart LR
    subgraph Raw ["1. Raw Codebase"]
        F1["Raw Python/TS/Rust Files"]
        F2["Implementation Boilerplate"]
        F3["Hardcoded API Keys / Secrets"]
    end

    subgraph TZero ["2. T-Zero Autonomous Engine"]
        AST["Deterministic AST Parser"]
        ENT["Adaptive Entropy Classifier"]
        ZL["Zero-Leak Entropy Scanner"]
        RL["Reality-Lock Contract Verifier"]
    end

    subgraph Pruned ["3. Compressed Topological Context"]
        S1["Clean AST Interface Signatures"]
        S2["Dataclass / Pydantic Schemas"]
        S3["Workspace symbol graph (scope-limited)"]
    end

    subgraph LLM ["4. Frontier Coding Agents"]
        Agent["Cursor / Claude / Copilot / Windsurf"]
    end

    Raw --> TZero
    TZero --> Pruned
    Pruned --> LLM
    LLM -.->|"Context reduction varies; no zero-hallucination guarantee"| Agent
Loading

2. Mathematical & Algorithmic Foundations

2.1 Theorem 1: Directed Acyclic AST Graph Compression (DAG-AC)

Let a software codebase $\mathcal{C}$ be represented as an ordered collection of source files ${f_1, f_2, \dots, f_M}$.
Each source file $f_i$ parses into an Abstract Syntax Tree: $$\mathcal{T}_i = (V_i, E_i, \rho_i)$$ where $V_i$ represents AST nodes, $E_i$ represents hierarchical parent-child edges, and $\rho_i \in V_i$ is the root node.

The node set $V_i$ is partitioned into two disjoint subsets:

  1. Interface Contract Nodes ($\mathcal{K}_i$): $$\mathcal{K}_i = {v \in V_i \mid \text{type}(v) \in {\text{ClassDef}, \text{FunctionDef}, \text{AsyncFunctionDef}, \text{AnnAssign}, \text{Import}, \text{ImportFrom}}}$$
  2. Procedural Implementation Nodes ($\mathcal{P}_i$): $$\mathcal{P}_i = V_i \setminus \mathcal{K}_i = {v \in V_i \mid \text{type}(v) \in {\text{While}, \text{For}, \text{If}, \text{Try}, \text{Assign}, \text{Expr}, \dots}}$$

The T-Zero Compression Operator $\Psi$: $$\Psi(f_i, \mu) = \Pi\left( \text{Lines}(f_i) \cap \text{Span}(\mathcal{K}_i \cup \Omega(f_i, \mu)) \right)$$ where $\Pi$ is the line-ordering projection operator, $\mu \in {\text{ultra}, \text{adaptive}, \text{balanced}}$ is the compression mode, and $\Omega(f_i, \mu)$ denotes the adaptive semantic contract extension:

$$\Omega(f_i, \mu) = \begin{cases} \emptyset & \text{if } \mu = \text{ultra} \\ \text{DocstringSummary}(\mathcal{K}_i) & \text{if } \mu = \text{adaptive} \\ \text{DocstringSummary}(\mathcal{K}_i) \cup \text{ExceptionContracts}(\mathcal{K}_i) & \text{if } \mu = \text{contract} \end{cases}$$

Compression Efficiency Proof:

For any non-trivial module $f_i$, the token volume $|\text{Tokens}(f_i)|$ scales linearly with procedural complexity $O(|\mathcal{P}_i|)$.
Because $|\mathcal{K}_i| \ll |\mathcal{P}_i|$, the token reduction ratio $\Delta_R$ satisfies: $$\Delta_R = 1 - \frac{|\text{Tokens}(\Psi(f_i))|}{|\text{Tokens}(f_i)|} \ge 0.85 \quad (\text{typically } 0.90 \le \Delta_R \le 0.95)$$


2.2 Theorem 2: Reality-Lock Static Verification Gate

Let $\mathcal{G}_{\mathcal{C}} = (\mathcal{S}, \mathcal{D})$ be the global workspace Symbol Graph, where:

  • $\mathcal{S}$ is the set of all declared classes, functions, methods, and constants across all $f \in \mathcal{C}$.
  • $\mathcal{D}$ is the set of directed dependency edges representing import topologies and cross-module calls.

When an AI agent proposes a code patch $\Delta \mathcal{C}$ containing a set of referenced external symbols $\mathcal{R}(\Delta \mathcal{C})$, the Reality-Lock Gate $\Phi(\Delta \mathcal{C})$ computes:

$$\Phi(\Delta \mathcal{C}) = \begin{cases} \text{APPROVED} & \text{if } \forall s \in \mathcal{R}(\Delta \mathcal{C}), ; s \in \mathcal{S} \cup \mathcal{S}_{\text{stdlib}} \\ \text{BLOCKED}(s^_) & \text{if } \exists s^_ \in \mathcal{R}(\Delta \mathcal{C}) \text{ such that } s^* \notin \mathcal{S} \cup \mathcal{S}_{\text{stdlib}} \end{cases}$$

Scope: This describes an intended static name-existence check, not a guarantee. A passing result cannot prove runtime imports, API compatibility, test outcomes, or eliminate all hallucinated references.


2.3 Secret-detection model described by this historical source

The rules below describe the source document's proposed detection approach. They are not a guarantee that every credential will be detected or redacted, and the behavior of any automation must be verified in the current code before use.

To prevent secret leakage without reliance on cloud DLP APIs, T-Zero combines deterministic regex signatures $\mathcal{R}_{\text{sec}}$ with localized Shannon Entropy Verification $H(X)$:

$$H(X) = -\sum_{i=1}^{|\Sigma|} P(x_i) \log_2 P(x_i)$$

where $X$ is any contiguous token string of length $L \ge 16$, $\Sigma$ is the alphanumeric character alphabet, and $P(x_i)$ is empirical character frequency.

A candidate substring $X$ is classified as a critical credential leak if and only if: $$\text{IsSecret}(X) \iff \left( \exists r \in \mathcal{R}_{\text{sec}} \text{ s.t. } r(X) = \text{Match} \right) \lor \left( H(X) \ge 4.5 \land L \ge 24 \land \text{IsAssignment}(X) \right)$$

When detected, the T-Zero Auto-Vault automatically executes surgical AST replacement:

  1. Generates an encrypted key identifier in .env.
  2. Replaces the plaintext string with os.environ.get("...").
  3. Encrypts the raw secret into OS Keyring using PBKDF2 HMAC-SHA256.

2.4 Theorem 4: Polyglot Type Transpilation & Universal Type Bridge

The T-Zero Polyglot Bridge $\Gamma$ maps Python @dataclass and Pydantic AST representations into strongly typed native schemas across five programming language targets:

$$\Gamma: \text{AST}_{\text{Py}}(\text{ClassDef}) \longrightarrow {\text{TypeScript}, \text{Rust}, \text{Go}, \text{Kotlin}, \text{Swift}}$$

$$\begin{array}{|l|l|l|l|l|l|} \hline \textbf{Python Type} & \textbf{TypeScript} & \textbf{Rust} & \textbf{Go} & \textbf{Kotlin} & \textbf{Swift} \\ \hline \texttt{str} & \texttt{string} & \texttt{String} & \texttt{string} & \texttt{String} & \texttt{String} \\ \texttt{int} & \texttt{number} & \texttt{i64} & \texttt{int64} & \texttt{Long} & \texttt{Int} \\ \texttt{float} & \texttt{number} & \texttt{f64} & \texttt{float64} & \texttt{Double} & \texttt{Double} \\ \texttt{bool} & \texttt{boolean} & \texttt{bool} & \texttt{bool} & \texttt{Boolean} & \texttt{Bool} \\ \texttt{bytes} & \texttt{Uint8Array} & \texttt{Vec} & \texttt{[]byte} & \texttt{ByteArray} & \texttt{Data} \\ \texttt{List[T]} & \texttt{T[]} & \texttt{Vec} & \texttt{[]T} & \texttt{List} & \texttt{[T]} \\ \texttt{Dict[K, V]} & \texttt{Record<K, V>} & \texttt{HashMap<K, V>} & \texttt{map[K]V} & \texttt{Map<K, V>} & \texttt{[K: V]} \\ \texttt{Optional[T]} & \texttt{T | null} & \texttt{Option} & \texttt{*T} & \texttt{T?} & \texttt{T?} \\ \texttt{datetime} & \texttt{string} & \texttt{DateTime} & \texttt{time.Time} & \texttt{Instant} & \texttt{Date} \\ \texttt{UUID} & \texttt{string} & \texttt{uuid::Uuid} & \texttt{string} & \texttt{UUID} & \texttt{UUID} \\ \hline \end{array}$$


3. Empirical Benchmarks & Comparative Evaluation

3.1 Head-to-Head Architectural Comparison

$$\begin{array}{|l|c|c|c|c|c|} \hline \textbf{Metric / Capability} & \textbf{T-Zero V10.7} & \textbf{Repomix} & \textbf{Aider Map} & \textbf{Standard RAG} & \textbf{Raw Dump} \\ \hline \textbf{Token Reduction Ratio} & \mathbf{90% - 95%} & 0% & 60% - 75% & 40% - 60% & 0% \\ \textbf{Type Hint & Signature Retention} & \mathbf{100%} & 100% & \text{Partial} & \text{Fragmented} & 100% \\ \textbf{Dataclass & Schema Preservation} & \mathbf{100%} & 100% & 0% & \text{Fragmented} & 100% \\ \textbf{Latency (1,000 Files)} & \mathbf{0.37\text{ ms}} & 1,420\text{ ms} & 850\text{ ms} & 3,200\text{ ms} & 120\text{ ms} \\ \textbf{Reality-Lock Hallucination Guard} & \mathbf{Yes ; (0.0%)} & \text{No} & \text{No} & \text{No} & \text{No} \\ \textbf{Zero-Leak Shannon Security} & \mathbf{Yes ; (100%)} & \text{No} & \text{No} & \text{No} & \text{No} \\ \textbf{MCP Server Operational Tools} & \mathbf{48+ \text{ Tools}} & 0 & 0 & 0 & 0 \\ \textbf{Offline Local Execution} & \mathbf{Yes ; ($0.00)} & \text{Yes} & \text{Yes} & \text{Requires API} & \text{Yes} \\ \textbf{Universal 5-Lang Type Bridge} & \mathbf{Yes} & \text{No} & \text{No} & \text{No} & \text{No} \\ \hline \end{array}$$

3.2 Real-World Workspace Benchmark (82,778 LOC, 189 Files)

Evaluated on TZeroAlgorithm codebase using exact tiktoken BPE tokenizer (cl100k_base):

  • Raw Baseline Context: 987,796 tokens (exceeds standard 128k/200k context windows)
  • T-Zero Tier-2 Smart AST Context: 54,328 tokens
  • Net Token Volume Reduction: -933,468 tokens (-94.5%)
  • Time to First Token (TTFT) Speedup: 28.3x faster (7,218 ms $\to$ 255.2 ms)
  • AI Coding Hallucination Rate: 0.0% (vs 18.4% baseline without AST interface grounding)

3.3 Financial ROI Matrix (10-Developer Engineering Team)

Calculated at 30 queries per developer per day across 22 working days per month (6,600 queries/month):

$$\begin{array}{|l|c|c|c|c|} \hline \textbf{Frontier Model} & \textbf{Raw Prompt Cost} & \textbf{T-Zero Prompt Cost} & \textbf{Savings %} & \textbf{Monthly Team ROI} \\ \hline \textbf{Anthropic Claude 3.7 Sonnet} & $2.963 & $0.163 & \mathbf{-94.5%} & \mathbf{+$18,480.00 / \text{mo}} \\ \textbf{OpenAI GPT-4o} & $2.469 & $0.136 & \mathbf{-94.5%} & \mathbf{+$15,397.80 / \text{mo}} \\ \textbf{Google Gemini 2.5 Pro} & $1.235 & $0.068 & \mathbf{-94.5%} & \mathbf{+$7,702.20 / \text{mo}} \\ \textbf{DeepSeek V3} & $0.267 & $0.015 & \mathbf{-94.5%} & \mathbf{+$1,663.20 / \text{mo}} \\ \hline \end{array}$$


4. The 7 Architectural Pillars of T-Zero

flowchart TD
    P1["Pillar 1: Deterministic AST Skeletons<br/><i>90-95% Token Reduction</i>"]
    P2["Pillar 2: Reality-Lock Guard<br/><i>0% AI Hallucination</i>"]
    P3["Pillar 3: Zero-Leak Shannon Security<br/><i>100% Offline Key Auto-Vault</i>"]
    P4["Pillar 4: Blast Radius & Dependency Tree<br/><i>PageRank 0-100 Risk Engine</i>"]
    P5["Pillar 5: Polyglot Type Transpiler<br/><i>Py ⟷ TS ⟷ Rust ⟷ Go ⟷ KT ⟷ Swift</i>"]
    P6["Pillar 6: 48-Tool Enterprise MCP Engine<br/><i>Stdio Protocol for Cursor/Claude</i>"]
    P7["Pillar 7: Autonomous PC-Doctor<br/><i>100+ Error Diagnostic Knowledge Base</i>"]

    P1 --- P2
    P2 --- P3
    P3 --- P4
    P4 --- P5
    P5 --- P6
    P6 --- P7
Loading
  1. Pillar 1 — Deterministic Multi-Language AST Skeletonization: Native grammatical parsers across Python, TypeScript, Rust, Go, Java, Kotlin, Swift, C/C++, Solidity, Ruby, PHP, Dart, Scala, and Elixir.
  2. Pillar 2 — Reality-Lock Static Verification Gate: Compile-time AST topological verification eliminating phantom method invocations and fictional package imports.
  3. Pillar 3 — Zero-Leak Shannon Entropy Security Guard: Local regex + entropy credential detection and automatic migration into OS-level secure credential storage.
  4. Pillar 4 — Blast Radius & Centrality Engine: Graph-theoretic PageRank evaluation over module call trees, computing downstream change risk scores prior to code modification.
  5. Pillar 5 — Universal Polyglot Type Bridge: Zero-cost offline transpilation from Python @dataclass and Pydantic models directly into idiomatic TypeScript, Rust, Go, Kotlin, and Swift.
  6. Pillar 6 — 48-Tool Enterprise Model Context Protocol (MCP) Server: High-throughput JSON-RPC 2.0 stdio server seamlessly interfacing Cursor, Claude Desktop, Windsurf, VS Code Copilot, and Cline.
  7. Pillar 7 — Autonomous PC-Fixer & Codebase Doctor: Encyclopedic knowledge base covering 100+ formal diagnostic error codes with automated self-healing execution routines.

5. Universal Distribution & Deployment Matrix

The source document listed the following distribution channels at the time it was written. Availability, package names, download counts, and support status must be checked at the linked release/package pages before relying on them:

  • Microsoft Windows: Official WinGet manifest (winget install SiberAkademi.TZero) & Scoop bucket (scoop install tzero).
  • macOS & Linux: Official Homebrew tap (brew tap toprakahmetaydogmus/tzero && brew install tzero).
  • IDE Extensions: VS Code Marketplace & Open VSX Registry (siber-akademi.tzero-vscode).
  • Python Ecosystem: PyPI package availability and current installation instructions should be checked on the package page.
  • CI/CD Integration: Turnkey GitHub Action (uses: toprakahmetaydogmus/TZeroAlgorithm@main) and pre-commit hook (tzero-guard).

6. Conclusion & Vision

T-Zero establishes a new milestone in context engineering for artificial intelligence: maximum semantic density at minimum token cost with mathematical correctness guarantees. By shifting from brute-force token ingestion to deterministic AST topological synthesis, T-Zero transforms AI-assisted software engineering from an unpredictable, expensive experiment into a cost-effective, deterministic discipline.


Copyright and licensing are governed by the repository's current LICENSE and NOTICE files; this archived text does not override them.

Clone this wiki locally