arch(modules): installable modules must be stateless -- expose M.new() for stateful operations #124
Labels
No labels
coordination/cross-repo
coordination/needed
effort
large
effort
medium
effort
small
meta/duplicate
meta/planning
meta/wontfix
priority
high
priority
low
priority
medium
session
blocker
session
handover
session
next
status
blocked
status
done
status
in-progress
status
review
status
to-go
type
admin
type/architecture
type
bug
type
config
type
deployment
type
docs
type/documentation
type
enhancement
type
feature
type
handover
type
infrastructure
type
installation
type
maintenance
type
migration
type
research
type
security
type/task
type/tech-debt
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
DAW/fragjan#124
Loading…
Add table
Add a link
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?
Principle
Installable DAW modules MUST be stateless.
Modules are loaded once via require() and cached by Lua. If a module
holds state in module-level variables, all callers share that state.
This makes modules non-instantiable and causes subtle bugs when the
same module is used for multiple purposes simultaneously.
Rule
Installable modules (managed by the module manager, living in
var/modules/) MUST NOT hold state in module-level variables.
If a module needs state (e.g. an open file handle), it MUST expose
a constructor:
The caller (adapter) is responsible for managing instances.
Known violation
daw.log.file (DAW/daw-modul-log-file) holds a file handle in a
module-level variable:
Fixed in DAW/daw-modul-log-file (separate issue).
Scope
Acceptance criteria
mutable state (no module-level variables that change after load)
References
Semantic static analysis required for this rule -- blocked on DAW/fragjan#107 (scanner primitive). Moving to later milestone.