Repository navigation
Description
Why
Gaze's side effect taxonomy (internal/taxonomy/types.go) currently defines 37 effect types rooted in Go's semantics. As gaze evolves to support external analyzers for other languages (see #95), the taxonomy needs to accommodate language-specific effects without losing its coherence as a universal classification system.
Python, for example, has side effects with no Go equivalent:
- Yield / YieldFrom — generators produce values lazily
- AsyncGeneratorYield — async iteration with side effects
- DecoratorMutation — decorators that modify function/class behavior
- DescriptorProtocol —
__set__,__delete__,__set_name__hooks - ContextManager —
__enter__/__exit__side effects - MonkeyPatch — runtime attribute assignment on modules/classes
- ModuleLevelEffect — code that executes at import time
- ExceptionClass — specific exception types (vs Go's error value returns)
Conversely, Go has effects with no Python equivalent:
- SentinelError —
var ErrFoo = errors.New(...)pattern - DeferredReturnMutation — defer modifying named return values
- ChannelClose — closing a channel as a signal
The taxonomy needs a strategy for handling this divergence.
Proposed Approach: Universal Abstract Types with Language Detail
Layer 1: Universal Types (scored by gaze core)
Define ~30 abstract effect types that are language-neutral. Each has a clear semantic definition independent of any language's syntax:
| Universal Type | Definition | Go Mapping | Python Mapping |
|---|---|---|---|
ReturnValue |
Function produces an output value | return value | return value |
ErrorSignal |
Function signals a failure condition | error return | raise exception |
SentinelErrorDecl |
Module-level error constant/class declaration | var ErrX = errors.New(...) |
class XError(Exception) |
ReceiverMutation |
Method mutates its receiver/self | receiver field assignment | self.x = ... |
ArgumentMutation |
Function mutates a passed argument | pointer param mutation | mutable arg mutation |
GlobalMutation |
Function modifies module/package-level state | package var assignment | global x; x = ... |
ContainerMutation |
In-place mutation of a collection | slice/map mutation | list/dict/set mutation |
StreamOutput |
Writing to an output stream | io.Writer calls |
print(), sys.stdout.write() |
FileSystemWrite |
Writing to the filesystem | os.WriteFile, etc. |
open('w'), pathlib |
DatabaseWrite |
Mutating persistent storage | DB driver calls | SQLAlchemy, DB-API |
ConcurrencySpawn |
Creating a concurrent execution context | goroutine | Thread.start(), create_task() |
ChannelSend |
Sending a value to a concurrency primitive | ch <- val |
queue.put() |
ChannelClose |
Closing a concurrency primitive | close(ch) |
— (no equivalent) |
ProcessTermination |
Terminating the process | panic, os.Exit |
sys.exit(), os._exit() |
LogWrite |
Writing to a logging system | slog.*, log.* |
logging.* |
CallbackInvocation |
Invoking a function-typed argument | calling func param | calling callable arg |
HTTPResponseWrite |
Writing an HTTP response | http.ResponseWriter |
WSGI/ASGI response |
ContextCancellation |
Cancelling a context/scope | context.Cancel() |
asyncio.Task.cancel() |
DeferredMutation |
Cleanup/finalization that mutates state | defer modifying returns |
— (no equivalent) |
GeneratorYield |
Producing a value via lazy iteration | — (no equivalent) | yield, yield from |
AsyncGeneratorYield |
Async lazy iteration with effects | — (no equivalent) | async for yields |
MetaprogrammingMutation |
Runtime code/class modification | — (no equivalent) | decorators, metaclasses |
DescriptorEffect |
Attribute access protocol side effects | — (no equivalent) | __set__, __delete__ |
ResourceManagement |
Scoped resource acquire/release | — (no equivalent) | __enter__/__exit__ |
ImportSideEffect |
Code executed at module load time | init() functions |
module-level statements |
MonkeyPatch |
Runtime modification of external objects | — (rare in Go) | module/class attr assignment |
Layer 2: Language Detail (in protocol responses)
External analyzers report the universal type plus optional language-specific detail:
{
"type": "ErrorSignal",
"tier": "P0",
"line": 42,
"detail": {
"language_type": "RaiseException",
"exception_class": "ValueError",
"message_pattern": "invalid input: {}"
}
}Gaze core scores on type + tier. Report formatters can surface detail for language-specific context. The detail field is opaque to gaze's scoring engine — it's passed through to reports and AI pipelines.
Tier Assignments
Tiers should also be universal. The existing P0-P4 system works:
| Tier | Criterion | Universal Types |
|---|---|---|
| P0 | Must detect — core function contract | ReturnValue, ErrorSignal, SentinelErrorDecl, ReceiverMutation, ArgumentMutation |
| P1 | High value — common side effects | GlobalMutation, StreamOutput, ChannelSend, ContainerMutation, ChannelClose, DeferredMutation, GeneratorYield |
| P2 | Important — infrastructure effects | FileSystemWrite, DatabaseWrite, ConcurrencySpawn, ProcessTermination, LogWrite, CallbackInvocation, HTTPResponseWrite, ContextCancellation, MetaprogrammingMutation, DescriptorEffect, ResourceManagement, ImportSideEffect, MonkeyPatch, AsyncGeneratorYield |
| P3 | Nice to have | (defined per language) |
| P4 | Exotic | (defined per language) |
Impact
internal/taxonomy/types.go: Rename/generalize existingSideEffectTypeconstants. Add new universal types. Preserve backward compatibility via aliases for the Go-specific names.internal/taxonomy/priority.go: Update tier mappings for new universal types.- JSON Schema (
internal/report/schema.go): Update to include new types and detail field. - Classification engine: No changes to scoring logic — universal types map to the same tiers and boosts.
- Reports: May optionally display language detail when available.
- External analyzer protocol (feat: external analyzer protocol (JSON-RPC over stdin/stdout) for multi-language support #95): Protocol schema references universal types.
Constitution Alignment
I. Accuracy
Assessment: PASS — Universal types are semantic equivalents of the existing Go types. No accuracy is lost for Go analysis. Language-specific detail is additive.
II. Minimal Assumptions
Assessment: PASS — The taxonomy makes no assumptions about which language produced the data. Types are defined by their semantic meaning ("function signals failure"), not by language syntax ("function returns error").
III. Actionable Output
Assessment: PASS — Reports using universal types are equally actionable. Language detail enhances actionability by providing language-specific remediation context.
IV. Testability
Assessment: PASS — Universal types can be tested with language-neutral fixtures. Each language analyzer tests its own mapping to universal types independently.
Open Questions
- Backward compatibility: Should the existing Go-specific constant names (
ErrorReturn,PointerArgMutation, etc.) be preserved as aliases, or renamed to universal names in a breaking change? - Extensibility: Should analyzers be allowed to report custom types not in the universal set? If so, how should gaze score them? (Default to a configurable tier? Require mapping to a parent universal type?)
- P3/P4 tiers: Should these be language-specific (each analyzer defines its own P3/P4 types) or universal (gaze defines them all, some are N/A for certain languages)?
Related
- feat: external analyzer protocol (JSON-RPC over stdin/stdout) for multi-language support #95 — External analyzer protocol (JSON-RPC over stdin/stdout)
- snake-eyes — Python analyzer (first consumer of this taxonomy)
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone ✔️
Activity
feat: scaffold snake-eyes project with tooling, docs, and constitution
feat: generalize side effect taxonomy for multi-language support
feat: generalize side effect taxonomy for multi-language support
feat: generalize side effect taxonomy for multi-language support