Skip to content

release: v0.10.0 - #19

Merged
Kidkender merged 32 commits into
mainfrom
release/v0.10.0
Nov 13, 2026
Merged

Kidkender merged 32 commits into
mainfrom
release/v0.10.0

Conversation

@Kidkender

@Kidkender Kidkender commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Collects the open PRs for the next version (0.10.0) so they reach main together, with CI run on the combined result. Each PR is merged with --no-ff, so GitHub marks it merged once this lands.

Included

Merge notes

Verified

On a clean worktree, the CI steps: npm ci, npm run build (23 workspaces), npm run test — 1437 tests pass, 4 skipped, none failing.

The last commit, chore: release v0.10.0, bumps the changed packages, moves internal ^ ranges that no longer cover them (protocol ^0.6.0, go-parser ^0.4.0 in lens) and turns [Unreleased] into [0.10.0] with release notes and publish order. Merge with a merge commit, not squash: the v0.10.0 tag goes on that commit, and GitHub marks #12–#18 merged only if their commits land.

…ig reader

- `archmind visualize` passed no options to explain(), so finding types listed
  in archmind.json `ignoreFindings` still appeared in the HTML report. It now
  reads the config and passes `{ ignore }`, like `archmind findings`.
- nestjs-parser drops its private copy of loadUserConfig and uses the one in
  @kidkender/archmind-protocol (same behavior); requires protocol ^0.5.1.
…tions

The Spring Boot adapter never loaded archmind.json, so `guards` had no effect
on Spring Boot projects. It now reads the config through loadUserConfig:
annotation names under `guards.auth_gate` emit ir:auth_gate, names under
`guards.authz_check` emit ir:auth_gate -> ir:authz_check. The config wins over
the built-in rules, so a listed Shiro `@RequiresRoles` is no longer
ir:unknown_middleware. A malformed archmind.json is ignored. Requires
protocol ^0.5.1.

docs: bring next-version-ideas.md in line with v0.9.1 (benchmark CLI, graph
diff, CI and lens shipped; modular Laravel partial; new items #10 and #11;
reordered priorities).
…e files over 32 KiB

Every parser wrapped readFileSync and tree-sitter's parse() in one bare
`catch { return <empty> }`, so a parse failure read as "this file has nothing
in it". That also hid a real bug: tree-sitter 0.21 throws "Invalid argument"
for input past its default 32 KiB buffer, and only route-parser passed a
bufferSize, so controllers and services larger than 32 KiB silently produced
no auth, transaction, isolation or guard nodes.

All read+parse sites now go through php-source.ts / java-source.ts:
- an unreadable file (missing, a directory, no access) yields nothing, as before
- the parse buffer is sized to the source
- a parse failure is printed on stderr with the file path and the file is skipped

Catches around JSON.parse of composer.json / archmind.json and readdirSync are
unchanged. The pass-level catches in graph-augmenter.ts are left for later.
go-parser emitted none of the nodes the missing_tenant_scope detector needs,
so the finding never fired on Gin projects.

On a route that resolves a tenant (a middleware whose name carries a tenant
key, a c.Get("tenant_id")-style read from the Gin context, or an accessor such
as GetTenantID(c) / tenant.FromContext(ctx)), go-parser now emits an
ir:tenant_context node and classifies every GORM query in the handler and up
to two calls below it (handler -> service -> repository, through struct
fields): ir:scoped_query when its Where/Scopes/Joins arguments carry a tenant
signal, otherwise ir:unscoped_query / ir:unscoped_write with a
missing_tenant_scope edge. A write whose record literal sets the tenant counts
as scoped. Routes that resolve no tenant get none of these nodes, so
single-tenant apps and existing topology baselines are unaffected.

Signals are configurable in archmind.json `isolation.tenantSignals` /
`isolation.tenantContextKeys` (defaults: tenant, organization_id, org_id).

explainer: missing_tenant_scope also accepts ir:tenant_context as the tenant
node (ir:runtime_inject would have raised hidden_runtime_dependency on every
tenant route), and gives GORM-style advice for Gin graphs.

Limits: syntactic only; GORM global scopes, callbacks, plugins and Scopes(fn)
without a tenant name are not seen; at most 25 query nodes per route.
…builds

CI on main has failed since at least 2026-10-15: `npm run build --workspaces`
builds alphabetically, so on a fresh checkout `aql` is compiled before
`protocol` has a dist/ and tsc cannot resolve it.

- scripts/build-workspaces.mjs builds each workspace after the workspaces it
  depends on (dependencies/peerDependencies hard, devDependencies soft — dropped
  only to get past a cycle); the root `build` script runs it.
- explainer: exclude src/__tests__ and src/benchmark from the tsc build. They
  are already left out of the published package, and compiling them made
  explainer need scorer (scorer -> llm-client -> prompt-builder -> explainer).
- nestjs-parser: declare laravel-parser and springboot-parser as
  devDependencies; its cross-framework tests import them.
- lsp: keep @kidkender/archmind-analysis external. Bundling it pulled in
  go-parser, whose tree-sitter-go native module esbuild cannot bundle and which
  needs tree-sitter 0.25 while lsp runs 0.21.
- go-parser: findGoFiles returns `/`-separated paths on every OS (the scanner
  tests failed on Windows); the mcp-server cache test looks files up the same way.

Verified on a clean worktree: npm ci, build (22 workspaces), npm test all pass.
New @kidkender/archmind-express-parser (0.1.0), JavaScript and TypeScript:

- detect: isExpressProject / findExpressRoot — package.json depends on
  express and not on NestJS, at the root or one directory down (server/,
  backend/); node_modules is never taken for the app.
- scanner: .js/.cjs/.mjs/.ts/.cts/.mts server files, `/`-separated, skipping
  tests, declarations, build output and front-end folders.
- project: an in-memory ts-morph project over those files; module resolution
  between files will be done by the extractors, so require() and ES imports
  are handled alike.
- adapter: parseExpressSources (synthetic fixtures) and parseExpressProjectAt
  (reads archmind.json guards and ownershipSources). Route extraction comes
  next; for now it returns no graphs.
- scope: finds where a name is declared by walking lexical scopes (variables,
  destructuring, parameters, functions, classes, ES imports, import = require).
- evaluator: demand-driven values for routing: apps and routers (express(),
  express.Router(), Router(), require('express').Router()), CommonJS and ES
  modules (module.exports, exports.x, export default, re-exports, ".js"
  specifiers for TS sources), string constants, concatenation and templates,
  objects, arrays, class statics and instances. A registrar parameter
  (require('./routes')(app)) takes the values passed at its call sites; a
  wrapper (catchAsync(fn), fn.bind(x)) stands for the function it wraps.
- routes: collects verb, route() chain and use() registrations, evaluates a
  forEach callback once per array element so each path stays with its router,
  expands mounts into full paths and builds each route's middleware chain in
  Express order (path-scoped use, arrays of middleware, parent middleware
  before a mount). Paths that do not resolve to a string are reported.
- graph: one IR graph per route, middleware (ir:unknown_middleware until
  classified) then the handler, linked by precedes.

On the six corpus repos used to build it: 163 of 163 route registration sites
found (regex count), 2 static-file paths from a Map loop reported unresolved.
…d validation

classifyMiddleware decides, in order: archmind.json guards; (err, req, res,
next) error handlers; optional auth (auth.optional, credentialsRequired:
false), which blocks nothing; the npm package behind the value (passport,
express-jwt, celebrate, express-validator, express-rate-limit, csurf, helmet,
cors, body parsers, ...); the name (checkJwt, checkRole, isAdmin, validate*,
*Limiter; auth(...)/authorize(...) with roles is both an auth gate and an
authorization check); and for project middleware the body (jwt.verify or the
authorization header → auth; a role/permission check that answers 401/403 →
authorization; csrf; a middleware that never stops the request →
infrastructure).

Graphs now carry ir:auth_gate, ir:authz_check and ir:validation_gate; rate
limiting, optional auth and CSRF are ir:unknown_middleware with that role (no
IR type yet); infrastructure and error handlers are left out.

The evaluator records calls to package members (externalCall), so
`const limiter = rateLimit()` and `body("email").isEmail()` keep their package;
a method chain is named after the call it starts from.
…handler bodies

analyzeHandler reads the handler function:
- service calls: calls into project functions in service-like files
  (service, repository, provider, model, ...) or methods reached through a
  module, object or instance become ir:service_call nodes (ir:calls from the
  handler, at most 15); utilities, helpers in the handler's own file and
  req/res/next calls are left out.
- transactions, in the handler or one call below it: $transaction,
  withTransaction, startTransaction, and x.transaction(...) when x is a
  database handle by name or comes from an ORM package (sequelize, typeorm,
  knex, mongoose, prisma, ...).
- ownership: a call to a configured ownership source → ir:authz_check
  "ownership:<name>", as in the Go adapter.

Ownership and the transaction follow the handler in the precedes chain.

The evaluator resolves `this` in class methods, constructor parameter
properties, `this.x = ...` in constructors, typed properties and base
classes, so class controllers reach their services.
- analysis: NestJS → Spring Boot → Gin → Express → Laravel; analyzeExpress.
  A route counts as throttled when a node has role "rate_limiting" (Express
  rate limiters, Laravel throttle:), not only when an auth node is named so —
  otherwise every rate-limited login route reported no_rate_limiting.
- CLI: framework "express", detected after every other signal; parseProject
  branch.
- MCP: detectFramework recognises Express (not when artisan is present);
  getGraphs caches Express graphs and re-parses when a JS/TS file changes
  (mtime, as for Go); tool descriptions name Express; get_dependents indexes
  Express service calls.
- analysis, CLI and MCP depend on express-parser and keep it external in
  their bundles.

express-parser:
- does not look below a root that is another backend (artisan, composer.json,
  go.mod, pom.xml, build.gradle, nest-cli.json), so a Laravel app with a Node
  server in server/ stays Laravel;
- reports node files relative to the project root when the app is one
  directory down;
- service symbols use Owner::method ("userService::createUser");
- an auth factory split into auth gate + authorization check carries its
  roles on the authorization node only (duplicate_authorization fired on
  every auth("perm") route).
…sactions

- research/cross-framework: Express versions of auth-only, auth-authz,
  auth-validation, auth-service-call and auth-transaction.
- cross-framework.test: for each pattern Express emits the expected semantic
  node types, matches NestJS and Laravel on the security layers plus the
  pattern's own concern, and uses only IR node types and edge relations.
  Not covered for Express: side effects, API resources, cron.
- Transactions now carry their writes as ir:txn_write (Entity::operation,
  linked by ir:wraps): TypeORM manager.save(Order, ...), Sequelize/Mongoose
  Order.create(...), Prisma tx.order.create(...) and the array form, and for
  an unmanaged transaction the calls in the same function that pass it
  ({ transaction: t } / { session }).
- Fix two regexes in handler.ts whose \b had been written as a backspace
  character (unmanaged-transaction option, and repo\b in the service path).
…ion, document

Measured on six projects not read before (research/express-corpus): 101 of 101
real route registrations, every route that opens a transaction in a production
Sequelize app, and 9 of 15 security middleware classified correctly blind.
Rules fixed from that (general, not per-project):

- authorization: role names with a User suffix (isAdminUser, isSuperUser) and
  bodies that read role flags off the user (req.user.isSuperUser) and answer
  403;
- authentication: `const { authorization } = req.headers`, "Bearer ", compound
  names (verifyAuthToken, checkAccessToken); a token read that always ends in
  next() with no top-level exit is optional auth, not a gate;
- infrastructure: express-ejs-layouts, express-status-monitor, nocache,
  cookie-session; old-style expressValidator() installs, body()/check()
  validate;
- transactions and ownership are looked for in every project function the
  handler calls, including helpers in the route file (only service-like ones
  become service-call nodes).

After the fixes: 15 of 15 security middleware on that set (no longer blind);
the tuning set classifies exactly as before.

Docs: packages/express-parser/README.md; research/express-corpus with the
projects, commits, method, results and the two measuring scripts; root README
and CHANGELOG (Unreleased).
…pass catches

- package.json: `npm run trace` pointed at apps/cli/dist/index.js; the CLI
  builds to index.cjs.
- retrieval, nestjs-parser, mcp-server: maxWorkers 50 so each test file gets
  its own process. Their tests load the tree-sitter parsers (Laravel, Spring
  Boot, Go), whose module-level Parser fails intermittently when Jest reuses a
  worker across files — retrieval's cross-framework test failed 15 cases once
  and passed on rerun. Same fix laravel-parser already has.
- laravel-parser graph-augmenter: the transaction, isolation, audit-log and
  nested service-call passes, and a queued job's handle(), no longer swallow
  errors silently. The parsers already turn unreadable files into empty
  results, so what reaches these catches is a bug; it is now reported on
  stderr with the pass and file, and the pass is skipped as before.
…ported and skipped

The isolation parser is made to throw for the service file only; the test
checks the stderr warning names the pass, the file and the error, that the
rest of the graph (the service's calls, the transaction) is still built, and
that later passes of the same service (its guard clause) still run.
…n_transaction"

"within_transaction" is neither an IR relation nor a tracked legacy one, so
validateGraph reported it as unknown. None of the conformance fixtures opened a
transaction, which is how it went unnoticed. Writes now hang off the
transaction by ir:wraps, as in Laravel and Express graphs (nothing reads the
old relation). New conformance suite on the auth-transaction fixture; it fails
on the old emitter.
… layer

over_authorized_route counted every ir:validation_gate as a third
authorization layer ("FormRequest::authorize"), and delegated_validation
reported validators as delegating authorization. Both are about Laravel's
FormRequest::authorize(); a NestJS ValidationPipe, Spring @Valid, Gin binding
or Express celebrate / express-validator only checks the input. They fired on
ordinary authenticated, role-checked, validated routes outside Laravel (on one
Express project: 5 over_authorized_route, 12 delegated_validation).

The FormRequest meaning now applies when graph.framework is "laravel" or unset
(legacy and hand-built graphs keep their behaviour). Outside Laravel a route has
at most two authorization layers, so over_authorized_route does not fire there.
The NestJS detector test that asserted the old behaviour is updated.
…sers

retrieval, nestjs-parser and mcp-server load the tree-sitter parsers, whose
module-level parser fails when Jest reuses a worker process across test files.
On the GitHub runner Jest has few workers, so retrieval's regression and
cross-framework suites failed every run once the build itself was fixed.
maxWorkers 50 gives each file its own process, as laravel-parser already does.
Same change as in fix/minor-issues, so both merge cleanly.
…hole trees per lookup

Parsing files over 32 KiB (previous commit) exposed a cost that small files
hid: every module (controller, transaction, isolation, guard clause, audit log)
re-parsed the controller or service for every route, and each method lookup
walked the whole tree through `.children`, which builds a JS array at every
node. On invoiceninja the CLI ran for over 10 minutes and the machine ran out
of memory; 19 routes of InvoiceController alone took 6.2 s and 517 MB.

- php-source: parsed files are reused while their content is unchanged (up to
  32 files, least recently used dropped; an edited file is parsed again).
- findMethod is shared by the five modules (their identical private copies are
  removed) and uses descendantsOfType, with a per-tree name index.
- extractUseMap is computed once per tree (callers get a copy).

InvoiceController's 19 routes: 261 parses → 20, 6.2 s → 0.8 s, 517 MB → 20 MB,
same 196 nodes. Full invoiceninja: completes in 36 s (139 s before the 32 KiB
fix, when its large files were skipped). monica and akaunting graphs are
identical before and after.
The CLI only treated a project as Go when go.mod sat at the root, then asked
isGinProject; analysis and the MCP server already rely on isGinProject alone,
which also finds a go.mod one directory down (api/, server/) and returns false
for a root that has composer.json. Such a project fell through to the Laravel
default and showed no routes.

On zgiai/zgi (go.mod in api/): Laravel, 0 routes → Go, 226 routes. ginfast
(go.mod at the root) unchanged; isGinProject is false for the Laravel, Spring
Boot, NestJS and Express projects checked.
gatherServiceCalls folds a mutating call into the relationship accessor it is
chained on ($user->apiTokens()->delete() → one "User::apiTokens()->delete")
and skips the accessor when recursing with `child !== objNode`. tree-sitter
0.21 does not always return the same JS object for the same node — it depends
on its node cache and on garbage collection — so in some runs the accessor was
visited again and emitted as a duplicate service call. That made output vary
between identical runs (koel: 1943 / 1946 / 1943 nodes; one koel method gave
two different results in 6 of 50 calls) and, with the parse cache of the
previous commit, made BookStack consistently wrong (3922 instead of 3917).

Nodes are now compared by start/end index and type. Same build, three runs:
koel 1933 and BookStack 3917 every time. New test repeats the koel pattern 60
times; it fails on the old comparison.
… model wrappers

Real multi-tenant Gin apps rarely query GORM straight from a struct field, so
the first version found no queries on them. Isolation now:

- resolves handlers and callees through package-level registries, embedded
  structs, typed locals and constructor return types
  (api.Controllers.BoardApi.X, service.GroupApp.Board.X, NewSysRoleList());
- reads the tenant from tenant-named fields (claims.TenantID) and
  tenant-named functions handed the Gin context (TenantScope(c));
- treats read/write calls on DAO, repository and model wrappers as queries,
  judged at the call site when the wrapper takes its conditions as variadic
  arguments, and judges Scopes(funcs...) by the caller's arguments;
- counts operations covered by a tenant-setting GORM callback as scoped;
- skips models declared without a tenant field (shared tables), ignores
  Preload("Tenant"), and follows conditions built in variables (subqueries).

Measured on two real apps: thingspanel goes from 1 to 129 routes with a
tenant context and 15 distinct unscoped sites; ginfast from 0 to 40, with
8 distinct unscoped sites.
Route paths were the plain concatenation of every Group() prefix and the
route path, so groups written without slashes (Group("api").Group("v1")
.POST("device")) came out as "apiv1device" instead of /api/v1/device, and
"/api/" + "/users" as "/api//users". Gin joins them with path.Join, keeping a
trailing slash on the relative path; joinPaths does the same.

thingspanel-backend-community: 233 of 267 routes had a malformed path, now 0.
ginfast: 2 of 122, now 0. Route counts unchanged.
lsp's build keeps @kidkender/archmind-analysis external (it pulls in
go-parser's native tree-sitter-go, which esbuild cannot bundle), but the
package listed it only under devDependencies, so an installed lsp 0.1.4
would fail with MODULE_NOT_FOUND on start. It is now a dependency (^0.3.0).
@Kidkender
Kidkender merged commit b39766c into main Nov 13, 2026
1 check passed
@Kidkender
Kidkender deleted the release/v0.10.0 branch November 13, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant