rule: detect require() calls that do not load daw.mainjan #129

Closed
opened 2026-06-26 10:34:27 +02:00 by michael · 1 comment
Owner

Goal

A fragjan rule that detects all require() calls in a file that do not
load daw.mainjan -- making invisible static coupling visible.

Background

DAW architecture: require() is only permitted for daw.mainjan.
All other capabilities are resolved via m:ask(). Violations are easy
to miss in review -- a dedicated rule makes them unforgeable.

Expected behavior

Flags every require() call where the argument is not "daw.mainjan":

local mainjan = require("daw.mainjan")   -- [OK] allowed
local log     = require("adapters.log")  -- [WARN] violation
local json    = require("daw.json")      -- [WARN] violation

Rule definition (sketch)

schema: fragjan_rule/v1
rule_id: no-require-except-mainjan
enabled: true
priority: 100

when:
  target_type: file
  file_pattern: "*.lua"

check:
  primitive: daw.fragjan.check.pattern
  match_type: regex
  pattern: 'require\s*\(\s*["\'](?!daw\.mainjan)[^"\']+["\']\s*\)'

result:
  severity: warn
  message: "{file}:{line} -- require() not allowed except for daw.mainjan"

Notes

  • Needs to be built and tested in a new chat session
  • Claude tends to introduce require() calls -- this rule makes violations
    visible before they reach review
  • Candidate for daw-lua-architecture pack
## Goal A fragjan rule that detects all require() calls in a file that do not load daw.mainjan -- making invisible static coupling visible. ## Background DAW architecture: require() is only permitted for daw.mainjan. All other capabilities are resolved via m:ask(). Violations are easy to miss in review -- a dedicated rule makes them unforgeable. ## Expected behavior Flags every require() call where the argument is not "daw.mainjan": ```lua local mainjan = require("daw.mainjan") -- [OK] allowed local log = require("adapters.log") -- [WARN] violation local json = require("daw.json") -- [WARN] violation ``` ## Rule definition (sketch) ```yaml schema: fragjan_rule/v1 rule_id: no-require-except-mainjan enabled: true priority: 100 when: target_type: file file_pattern: "*.lua" check: primitive: daw.fragjan.check.pattern match_type: regex pattern: 'require\s*\(\s*["\'](?!daw\.mainjan)[^"\']+["\']\s*\)' result: severity: warn message: "{file}:{line} -- require() not allowed except for daw.mainjan" ``` ## Notes - Needs to be built and tested in a new chat session - Claude tends to introduce require() calls -- this rule makes violations visible before they reach review - Candidate for daw-lua-architecture pack
Author
Owner

Done

Rule implemented in daw-lua-architecture pack using daw.fragjan.check.linepattern
with exclude_if_contains: 'daw.mainjan'.

Tested against DAW/fragjan: 128 errors found across 26 files.
Tested against DAW/daw-lua-mainjan: 6 errors found -- confirmed working.

Note: regex match_type in daw.fragjan.check.pattern does not support
Lua-incompatible syntax (no lookahead). linepattern is the correct primitive.

## Done Rule implemented in daw-lua-architecture pack using daw.fragjan.check.linepattern with exclude_if_contains: 'daw.mainjan'. Tested against DAW/fragjan: 128 errors found across 26 files. Tested against DAW/daw-lua-mainjan: 6 errors found -- confirmed working. Note: regex match_type in daw.fragjan.check.pattern does not support Lua-incompatible syntax (no lookahead). linepattern is the correct primitive.
michael 2026-06-26 11:18:30 +02:00
michael added this to the Basic Version milestone 2026-06-26 11:38:02 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
DAW/fragjan#129
No description provided.