feat(mcp): check_env struct-level granularity via composes selectors

Patch to v1.1.1. check_env could only reason at module granularity, so a var
that lives on one struct of a multi-struct module (e.g. EINHERJAR_SERVER_CORS_ORIGINS
on web.Config, not web/server.Config) couldn't be flagged dead when the app
composes the sibling struct. Adds struct-level selectors to close that gap.

internal/tools (check_env):
- New `composes` input: exact config structs as module/subpackage/Struct selectors
  (e.g. web/server/Config, db-postgres/Config, core/logz/Config), alongside or
  instead of the coarse `modules` list.
- not-composed now reasons over the union of composed vars (from modules AND
  struct selectors), so it surfaces struct-level dead vars. Coarse modules:["web"]
  keeps the prior behavior.
- parseStructSelector helper; errors on malformed or non-existent selectors.

Tests: struct-level dead-var catch (CORS flagged with web/server/Config but not
with module web), bad-selector errors; existing calls updated to the new arg.
Version bumped to v1.1.1 (badge + serverVersion). No dependency changes.
This commit is contained in:
2026-08-07 19:38:00 -06:00
parent 850b63607c
commit cff5a7b4c8
6 changed files with 135 additions and 24 deletions
+2 -2
View File
@@ -47,8 +47,8 @@ type Rule struct {
type Context struct {
Fset *token.FileSet
File *ast.File
Imports map[string]string // path → local name (e.g. "code.nochebuena.dev/einherjar/core/launcher" → "launcher")
Calls []CallSite // every function call in the file
Imports map[string]string // path → local name (e.g. "code.nochebuena.dev/einherjar/core/launcher" → "launcher")
Calls []CallSite // every function call in the file
}
// CallSite is a recorded function call. Func is the textual form