Pragmatic Local-First AI for Enterprise Code Discovery
The hype around generative AI in software engineering is everywhere: Paste your entire codebase into a million-token context window, and let the AI rewrite your legacy architecture.
For Principal Engineers and Enterprise Architects working in regulated industries (financial services, healthcare, defense), this approach fails on three fundamental fronts:
- Information Security and IP Protection: You cannot stream proprietary financial business logic, compliance rules, or customer workflows to public multi-tenant cloud APIs.
- Context Window Degradation (Lost in the Middle): LLM reasoning capability drops precipitously as context windows fill with hundreds of thousands of unstructured tokens. The model misses subtle state mutations and hallucinates non-existent APIs.
- Lack of Deterministic Verification: An LLM generating code without grounded tools is an unreliable narrator. Enterprise engineering requires mathematically verifiable proof, not statistical guesses.
To solve legacy modernization with AI, you do not need bigger cloud prompts. You need Local-First, Tool-Assisted System Discovery.
+-------------------------------------------------------------------------+
| THE LOCAL-FIRST AI CODE DISCOVERY ARCHITECTURE |
+-------------------------------------------------------------------------+
| [ LOCAL REPOSITORIES & AST INDEX ] --> Ruby/Tree-sitter AST & schema |
| │ |
| v |
| [ DETERMINISTIC QUERY ENGINES ] --> CareerOS / MCP Tool Servers |
| │ |
| v |
| [ BOUNDED AGENTIC REASONING ] --> Progressive Disclosure Context |
+-------------------------------------------------------------------------+
1. Principle 1: Deterministic Tools Precede Probabilistic Prompts
An AI agent should never attempt to “remember” or infer database schemas, class hierarchies, or API contracts from raw text.
Instead, equip the agent with deterministic query tools via the Model Context Protocol (MCP):
- Structured Query Engines: Give the agent local tools to query schema indexes, foreign key relationships, and dependency graphs with millisecond latency.
- AST Code Intelligence: Use Tree-sitter or language-native AST parsers to extract exact symbol definitions, method call graphs, and class inheritances deterministically.
- Exact Keyword and Regex Search: Fast ripgrep interfaces provide ground-truth factual verification that no vector database can match for exact symbol lookups.
By placing deterministic query tools beneath the model, the LLM acts as an analytical synthesizer rather than an inaccurate search index.
2. Principle 2: Progressive Disclosure Context Architecture
When human architects investigate a 10-year-old monolith, they do not read every file simultaneously. They practice Progressive Disclosure:
- Scan high-level system topology and boundaries.
- Identify the specific subsystem and state machine involved.
- Drill down into individual methods and database locks only when necessary.
Your AI tooling should mirror this exact human cognitive pattern.
[ LEVEL 1: TOPOLOGY MAP ] ──> Identify interaction surfaces & boundaries
│
v
[ LEVEL 2: COMPONENT GRAPH ] ──> Query state machines & table relationships
│
v
[ LEVEL 3: ATOMIC CODE ] ──> Inspect precise methods & transactions
By querying context progressively through local MCP tools, the agent operates in focused, 4,000-token working sets where its reasoning and code synthesis capabilities remain razor sharp.
3. Principle 3: Local Peer Synchronization and Message Buses
In enterprise development, systems do not exist in isolation. Modern development involves multiple coordinated workspaces: application repos, infrastructure manifests, test runners, and personal developer operating systems.
Rather than relying on brittle cloud synchronization:
- Local Peer Mutexes: Use filesystem-level atomic locks (such as
CareerOS::PeerMutex) to coordinate reads and writes between peer repositories safely. - Decoupled Local Message Buses: Connect multi-repo workflows using lightweight, local message brokers (
zdots-ctx bus) where local agents publish events (e.g.REQUEST_EXECUTIVE_BRIEF,LEAD_EVALUATION_COMPLETED) without network latency or external exposure.
4. Building the CareerOS Platform: A Living Case Study
We applied these exact local-first principles to build the CareerOS Datalake and Agentic Architecture within this very repository:
- Deterministic Knowledge Graph: A 500KB structured datalake spanning 29 positions, 136 skills, 156 blog posts, and 211 technical interviews.
- STDIO JSON-RPC MCP Server: Exposing targeted query tools (
query_career_history,get_technology_provenance,generate_executive_brief) locally without external dependencies. - Automated Verification Gates: CI pipelines executing 77 RSpec tests, simulating ATS plain-text parsing, and asserting zero em dashes across all generated surfaces in under 0.3 seconds.
Summary: The Future of Engineering AI is Local and Deterministic
The path to scalable, trusted AI assistance in enterprise engineering is not bigger cloud context windows.
The real breakthrough is local-first system cartography:
- Keep proprietary code, architecture maps, and compliance logic securely on local machines.
- Build deterministic MCP query tools over language ASTs and structured schemas.
- Guide AI models with progressive disclosure and strict automated verification gates.
When you pair local deterministic intelligence with disciplined agentic workflows, you give your engineering team superpowers while keeping your systems private, calm, and completely under your control.