Repository navigation
feat(hydra-gates): dependency analysis and modularity view tools for every app - #942
Merged
Merged
Conversation
…every app Port the dependency analysis, the component-view rating, and the deptrac config and summary helpers from openregister into scripts/lib, next to the gate-122 scorer they import. The app root is an argument, the components file defaults to <app>/sigrid.components.yaml, and an app without one gets the directory views only. The foundation merge of view D is set with --foundation and --merge (default Kernel and Core). deptrac stays a per-app vendor-bin install; the package ships a generic layers.yaml and deptrac.sh. Assisted-by: ClaudeCode:claude-opus-5-5
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.
What this adds
Openregister's dependency and modularity tools, made usable for every app. They live in
hydra-gates/scripts/lib/, next to gate 122's scorer, and import that copy of the scorer. No gate runs them. Every number is an estimate on the scorer's 0.5 to 5.5 scale.analyse_dependencies.py <app>: the directory view and the functional view (hidden code, communication lines, violation degree), layering by role, cycles (Tarjan), and per-area exposure and two-way pairs. Supports--rev,--componentsand--out.rate_component_views.py <app> --report R.json: the estimated modularity rating under views A to E, built with the scorer's ownstructure()andrating_estimate(). Also gives targets per rating, exposure by kind and by component, and the foundation's back-references. The D merge is set with--foundation NAMEand--merge NAME[,NAME](default Kernel and Core).deptrac_areas.py <app>: writes a deptrac config with one layer per functional area.--sharednames the area every other area may use, and--checkreports a stale file.deptrac_summary.py,deptrac.sh <app> layers|FILE.yamland a genericdeptrac/layers.yamlfor the Nextcloud layout.tests/helper-suite-timings.tsv.The components file defaults to
<app>/sigrid.components.yaml. Without one, the directory view, layering, cycles and views A and B still run, and C, D and E are skipped with a message. deptrac is not a package dependency. Each app installs it through bamarni vendor-bin:vendor-bin/deptrac/composer.jsonrequiresdeptrac/deptrac^4.7, which I checked on Packagist (latest 4.7.2).How it differs from the openregister copies
The openregister scorer copy carries a pattern-components patch:
pattern_components(),pattern_component_of_factory(), an environment variable naming the components file, andcomponent_of_factory(files, app). The package scorer has none of these. It hasscope_file_components()/scope_component_factory(), switched on byCOMPONENTS_FROM_SCOPE. The ported tools adapt to the package scorer, which is unchanged:scope_file_components(), via a temporary copy namedsigrid.yaml. On openregister's real file both parsers give the same 10 components with the same patterns.structure()is pointed at a definition through a small context manager. It setsCOMPONENTS_FROM_SCOPEand restores both values on exit.(no component), the package scorer's name for them, notRemainder.Verified locally
python3 scripts/lib/test_analyse_dependencies.py: 13 tests OKpython3 scripts/lib/test_rate_component_views.py: 15 tests OKpython3 scripts/lib/test_deptrac_tools.py: 8 tests OKpython3 scripts/lib/test_check_sig_maintainability.py: OK (scorer untouched)python3 tests/test-partition-helper-suites.py: OKHELPER_SHARDS=6 HELPER_SHARD=1 bash tests/run-helper-suites.sh(the shard that owns the new suites): 75 passed. 2 failed only because ajv was not installed locally (test_gate116_connections_declaration_scope.sh,test_gate_45_to_55_acceptance.sh); CI installs it before this step.Control runs against openregister main, compared with the original tools:
#[attribute lines as code, and the openregister copy counted them as comments.deptrac_areas.pyreproduces openregister'sareas.yamlbyte for byte, apart from the header.deptrac.sh <openregister> layersruns with openregister's installed deptrac.One small fix over the original: the "most references inside the cyclic set" list now breaks ties by file name. Before, it followed set order and could change from run to run.
Written with Claude Code (claude-opus-5-5)