Repository navigation
feat: Spring Boot archmind.json guards; visualize ignoreFindings; parse errors and files over 32 KiB - #14
Merged
Conversation
…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.
…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.
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.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Three changes, one commit each. Merge after #12 for a green CI build.
Changes
visualizehonoursignoreFindings(c3bcd75).archmind visualizecalledexplain()without options, so finding types listed inarchmind.jsonignoreFindingsstill showed in the HTML report. It now passes{ ignore }, likearchmind findings. nestjs-parser drops its private copy ofloadUserConfigand uses the one in@kidkender/archmind-protocol(same behaviour; requires protocol ^0.5.1).Spring Boot reads
archmind.jsonguards(8a90e63). The adapter never loaded the user config. Annotation names underguards.auth_gatenow emitir:auth_gate, names underguards.authz_checkemitir:auth_gate→ir:authz_check; the config wins over the built-in rules (a listed Shiro@RequiresRolesis no longerir:unknown_middleware). Also updatesdocs/next-version-ideas.mdto match v0.9.1.Parse failures are reported, and files over 32 KiB are parsed (
27a0dde). laravel-parser and springboot-parser wrappedreadFileSyncand tree-sitter'sparse()in one barecatch { return <empty> }. That also hid a real bug: tree-sitter 0.21 throws "Invalid argument" past its default 32 KiB buffer and onlyroute-parserpassed abufferSize, so controllers and services larger than 32 KiB produced no auth, transaction, isolation or guard nodes. All read+parse sites now go throughphp-source.ts/java-source.ts: an unreadable file yields nothing as before, the buffer is sized to the source, and a parse failure is printed on stderr with the file path.Compare tree-sitter nodes by position (
ff7a102).gatherServiceCallsskipped an already-folded relationship accessor withchild !== objNode; tree-sitter 0.21 does not always return the same JS object for the same node (node cache + GC), so some runs emitted a duplicate service call (User::apiTokensnext toUser::apiTokens()->delete). Output varied between identical runs (koel 1943 / 1946 / 1943 nodes) — onmaintoo — and the parse cache below made BookStack consistently wrong. Now compared by start/end index and type; koel 1933 and BookStack 3917 on every run. Needed together with the parse cache.Parse each file once per run (
de35447). Parsing the large files exposed a cost small files hid: every module re-parsed the controller or service for every route, and every method lookup walked the whole tree through.children. On invoiceninja the CLI ran for over 10 minutes and the machine ran out of memory. Parsed files are now reused while their content is unchanged (32-file LRU), the five identicalfindMethodcopies are replaced by one that usesdescendantsOfTypewith a per-tree index, andextractUseMapis computed once per tree.Verified
guards(with / without / malformed config), a ~40 KB Laravel controller and a ~40 KB Spring controller, the parse cache,findMethod, and a 60-run repeat of the koel folding pattern (fails on the old comparison).app/Repositories/SongRepository.php(> 32 KiB) is now read — its queries show up on 31 routes.main, which skipped those files); +372 nodes, transactions 2 → 5. InvoiceController's 19 routes: 261 parses → 20, 6.2 s → 0.8 s, 517 MB → 20 MB.main. No parse-failure warnings on any of the five.ff7a102they varied between runs, onmainas well).guardson RuoYi (Shiro): declaringRequiresPermissions/RequiresRolesturns 157ir:unknown_middlewareinto auth gate + authorization check;exposed_read_endpoint63 → 23. SpringBlade / RuoYi graphs otherwise identical tomain.visualize+ignoreFindingson RuoYi:mainstill lists the ignoredexposed_read_endpoint63 times in the HTML report, this branch 0 times.