Mock Proliferation: When 100+ Stub Implementations Signal Incomplete Integration
The LEO backend audit results revealed extensive use of stub and mock implementations throughout the application layer — not just in tests, but in production code — indicating that many components were architecturally shaped but not functionally integrated.
- Reference
- L010
- Project
- LEO
- Status
- Documented
- Evidence
- high
- Source
- 010-mock-stub-proliferation-large-codebase.md
Context
The backend audit script (backend/audit_results.txt) scanned the codebase for specific patterns and logged matches. The output reveals a pattern of stub/mock usage that extends well beyond test infrastructure into production service code.
The Question
How widespread was the use of mock and stub implementations in the production codebase, and what does this indicate about the state of integration?
What Was Found
The audit results (backend/audit_results.txt) document numerous instances:
Execution adapters explicitly labeled as stubs:
app/execution/adapters/shell.py— "Shell Adapter — Stub"app/execution/adapters/browser.py— "Browser Adapter — Stub"app/execution/adapters/calendar.py— "Calendar Adapter — Stub"app/execution/adapters/github.py— "GitHub Adapter — Stub"app/execution/adapters/external_api.py— "External API Adapter — Stub"app/execution/adapters/filesystem.py— "Filesystem Adapter — Stub"app/execution/adapters/memory.py— "Memory Adapter — Stub"app/execution/adapters/search.py— "Search Adapter — Stub"app/execution/adapters/email.py— "Email Adapter — Stub"app/execution/adapters/python_sandbox.py— "Python Sandbox Adapter — Stub"
These raise StubNotImplemented with messages like: "ShellAdapter is a stub. Operation 'X' not yet wired."
Personality layer — explicit mock comments:
app/personality/integrity/validator.py: "Mock implementation. Real one would use LLM to verify fact preservation."app/personality/expression/manager.py: "Mocks the LLM prompt execution." Returns mock string ifsemantic.facts[0].startswith("MOCK:")app/personality/memory_reference/adapter.py: "Clean the text (mocking stripping DB data)"app/personality/memory_reference/planner.py: "Determine category based on content (mocking)"app/personality/memory_reference/relevance.py: "Mock relevance logic: Use the semantic score + a keyword bump"app/personality/speech/manager.py: "Load Baseline Identity (Mocking dynamic load for now)"
Research layer — explicit stub comments:
app/research/validator.py: Usesrandom.uniform()for authority_score, freshness_score, consistency_score (line 87-89 in audit)app/research/planner.py: "Deterministic stub: We assume simple web search followed by extraction."app/research/synthesizer.py:assumptions=["Generated via heuristic stub"]
Kernel diagnostics:
app/kernel/diagnostics.py:memory_usage_mb=150.5, # Mock value
Recovery:
app/recovery/executor.py: "we use a mock interface since the specific repair..."app/recovery/safety.py: "Dependencies are healthy (mocked for now)"
Evidence
backend/audit_results.txt— extensive list of mock/stub patterns with file paths and line numbers- All execution adapter files in
backend/app/execution/adapters/ backend/app/personality/— multiple mock commentsbackend/app/research/— stub validator using random scores
Diagnosis
Established: 10+ execution adapters are explicitly labeled as stubs and raise errors when called. Multiple personality subsystem components use mock LLM calls. The research validator uses random.uniform() for scores.
Likely: The stub adapters represent planned integration points: the architecture was designed to support shell execution, browser automation, GitHub integration, etc., and the interfaces were built, but the actual integrations were not yet implemented. This is a legitimate scaffolding pattern — build the interface first, implement later.
The use of mock LLM calls in production personality code (expression/manager.py) indicates that the personality expression subsystem was implemented against a mock LLM interface, not the real LLM provider. This means the personality behavior was tested and validated against mocked responses, not real model outputs.
Unknown: How much of the application's observable behavior depended on mock/stub paths rather than real implementations. Whether any of the stub adapters were ever replaced with real implementations in later phases.
What Changed
No documented corrective changes for the stub implementations.
What I Learned
Stub proliferation in production code (not just tests) is a distinct architectural smell from stub proliferation in test code. In tests, stubs are appropriate. In production code, stubs labeled "not yet wired" represent incomplete features — the architecture is defined but not implemented.
The combination of: (a) stub execution adapters, (b) mock LLM calls in personality code, (c) random scores in research validation, and (d) hardcoded mock values in diagnostics suggests that significant portions of the system were built at the architecture layer without completing the integration layer.
What I Would Do Differently
Hindsight observation: Stubs in production code should be tracked as TODO items with explicit completion criteria. The raise StubNotImplemented pattern is better than silently failing, but it should be accompanied by issue tracking. Random score generation in a validator that runs in production is particularly problematic — it would produce inconsistent, non-reproducible results.
Broader Principle
A large number of stub implementations in production code indicates that the system was built top-down (interface first, implementation later). This is a valid architectural approach but requires discipline: stubs should be tracked, prioritized, and replaced systematically. Left unaddressed, stub proliferation creates a system that is architecturally complete but functionally shallow.
Technical References
backend/audit_results.txtbackend/app/execution/adapters/(all stub files)backend/app/personality/expression/manager.pybackend/app/research/validator.pybackend/app/kernel/diagnostics.py
Failure sequence
On the record- Attempt
- How widespread was the use of mock and stub implementations in the production codebase, and what does this indicate about the state of integration?
- Failure
- Diagnosis
- **Established:** 10+ execution adapters are explicitly labeled as stubs and raise errors when called. Multiple personality subsystem components use mock LLM calls. The research validator uses `random.uniform()` for scores. **Likely:** The stub adapters represent planned integration points: the architecture was designed to support shell execution, browser automation, GitHub integration, etc., and the interfaces were built, but the actual integrations were not yet implemented. This is a legitimate scaffolding pattern — build the interface first, implement later. The use of mock LLM calls in production personality code (`expression/manager.py`) indicates that the personality expression subsystem was implemented against a mock LLM interface, not the real LLM provider. This means the personality behavior was tested and validated against mocked responses, not real model outputs. **Unknown:** How much of the application's observable behavior depended on mock/stub paths rather than real implementations. Whether any of the stub adapters were ever replaced with real implementations in later phases.
- Lesson
- Stub proliferation in production code (not just tests) is a distinct architectural smell from stub proliferation in test code. In tests, stubs are appropriate. In production code, stubs labeled "not yet wired" represent incomplete features — the architecture is defined but not implemented. The combination of: (a) stub execution adapters, (b) mock LLM calls in personality code, (c) random scores in research validation, and (d) hardcoded mock values in diagnostics suggests that significant portions of the system were built at the architecture layer without completing the integration layer.
- Next iteration
- No documented corrective changes for the stub implementations.