audit: review exported API surface and package documentation #6
Labels
No labels
athena
athena-gemini
audit
clotho
clotho-gemini
codex
darbs-claude
security
wiki
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: core/go#6
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Review the exported API surface of core/go. For each package:
Post findings as a comment on this issue. Do not make code changes — this is a review task.
Exported API Audit Report
This audit reviewed the exported API surface across 14 key packages in the core/go repository.
Executive Summary
The codebase demonstrates strong documentation practices overall, with most exported symbols having clear doc comments. However, several areas require attention regarding naming conventions, missing documentation, and potential API design improvements.
1. Framework Core (pkg/framework/core/)
Package Purpose: Central dependency injection framework managing services, lifecycle, and inter-service communication.
Missing Documentation:
Naming Convention Issues:
ACTION,QUERY,QUERYALL,PERFORM- All-caps method names deviate from Go conventions. Should beAction,Query,QueryAll,PerformSymbols That Should Be Unexported:
Missing Error Handling:
Other API Design Concerns:
SetInstanceandGetInstanceprovide global mutable state which could be problematic in testing/concurrent scenarios2. MCP Server (pkg/mcp/)
Package Purpose: Model Context Protocol server providing tools for file operations, RAG, metrics, process management, and browser automation.
Missing Documentation:
Optiontype (line 35)WithSubsystemfunction parameters could use more detail about subsystem lifecyclewebviewInstanceglobal variable (tools_webview.go:16)Symbols That Should Be Unexported:
webviewInstance(tools_webview.go:16) - Global mutable state, should be unexporteddetectLanguageFromPath(mcp.go:440)parseDuration(tools_metrics.go:181)convertMetricCounts(tools_metrics.go:161)Missing Error Handling:
registerProcessTools,registerWSTools, etc. returnboolbut don't expose why features are unavailableCallToolRequestOther API Design Concerns:
webviewInstance) creates concurrency issuesRun()3. WebSocket Hub (pkg/ws/)
Package Purpose: Real-time WebSocket communication hub with channel-based subscriptions.
Missing Documentation:
Symbols That Should Be Unexported:
mustMarshal(line 444)Clientstruct fields (hub, conn, send, subscriptions, mu) - should all be unexportedMissing Error Handling:
mustMarshalignores errors which could lead to silent failuresBroadcasterror return behavior not documented when internal channel blocksOther API Design Concerns:
CheckOrigincurrently accepts all origins - documented but potentially dangerous default4. Browser Automation (pkg/webview/)
Package Purpose: Chrome DevTools Protocol client for browser automation.
Missing Documentation:
Actioninterface (actions.go:10)ConsoleWatcherstruct fieldsExceptionWatcherstruct fieldsAngularHelperstruct fieldsSymbols That Should Be Unexported:
cdpMessage,cdpResponse,cdpEvent,cdpError,targetInfo(cdp.go)ClickAction,TypeAction, etc.) could be unexported with factory functionsgetString,formatJSValue,containsString,findStringMissing Error Handling:
Evaluatemethod allows arbitrary JavaScript execution - security implications noted but could be clearerOther API Design Concerns:
ActionSequenceprovides nice fluent API5. Process Management (pkg/process/)
Package Purpose: External process execution with output capture and lifecycle management.
Missing Documentation:
Processstruct fields need internal doc comments for maintainabilityRingBuffertype and methods need documentationMissing Error Handling:
Wait()returns genericexec.ExitErrorlosing specific exit code informationSignalmethod has incomplete implementation (noted in comments)Other API Design Concerns:
RingBufferfor output capture is well-designed6. CLI Framework (pkg/cli/)
Package Purpose: CLI application framework with commands, layouts, and ANSI styling.
Missing Documentation:
AppVersion,BuildCommit,BuildDate,BuildPreRelease(app.go:27-30)completionCmd(app.go:97)Symbols That Should Be Unexported:
completionCmd(app.go:97)Missing Error Handling:
Main()exits with code 1 for all errors - may want more granular exit codesOther API Design Concerns:
7. Configuration (pkg/config/)
Package Purpose: Layered configuration management with file, environment, and flag support.
Missing Documentation:
Symbols That Should Be Unexported:
Loadfunction (line 175) is deprecated - should be unexportedOther API Design Concerns:
8. Logging (pkg/log/)
Package Purpose: Structured logging with levels, rotation, and style support.
Missing Documentation:
identityfunction (log.go:130)Symbols That Should Be Unexported:
identityfunction (log.go:130)Other API Design Concerns:
9. Cryptography (pkg/crypt/)
Package Purpose: Encryption, hashing, HMAC, and key derivation functions.
Missing Documentation:
Other API Design Concerns:
EncryptAESandEncrypthave identical APIs - consider consolidating10. Build System (pkg/build/)
Package Purpose: Project detection and cross-compilation for multiple project types.
Missing Documentation:
Builderinterface methods could use more detailed doc commentsConfigstruct fields need individual doc commentsOther API Design Concerns:
Builderinterface11. AI/LLM Client (pkg/agentic/)
Package Purpose: API client for core-agentic service providing task management.
Missing Documentation:
NewClientandNewClientFromConfigcould document authentication requirementsOther API Design Concerns:
12. Agent CI / Clotho (pkg/agentci/)
Package Purpose: Dual-run verification orchestrator for AI agent CI/CD.
Missing Documentation:
RunModetype and constants could use more explanationSpinnerstruct fields need doc commentsWeavemethod is placeholder but public - should document future plansMissing Error Handling:
Weavecurrently just compares strings - weak implementation for public APIClothoConfigorAgentConfiginputsOther API Design Concerns:
13. Forgejo Client (pkg/forge/)
Package Purpose: Thin wrapper around Forgejo SDK for repository and issue management.
Missing Documentation:
Other API Design Concerns:
14. Git Operations (pkg/git/)
Package Purpose: Multi-repository git operations with status checking and sync.
Missing Documentation:
StatusOptionscould document behavior when Names map is incompleteSymbols That Should Be Unexported:
gitCommand(line 226)gitInteractive(line 166)getStatus(line 72)getAheadBehind(line 126)Other API Design Concerns:
Priority Recommendations
1. Critical - Naming Conventions
ACTION,QUERY,QUERYALL,PERFORMin core package toAction,Query,QueryAll,Perform2. High - Global State
webviewInstancein pkg/mcp/tools_webview.go3. High - Unexported Symbols
completionCmdin pkg/cli4. Medium - Missing Documentation
5. Medium - API Design
6. Low - Future Enhancements
Statistics
Conclusion
The core/go repository demonstrates strong engineering practices with comprehensive documentation, good error handling, and thoughtful API design. The primary concerns are around naming convention violations in the core framework and excessive use of global state in some packages. Addressing the priority recommendations would significantly improve API consistency and maintainability.