Skip to content

feat(hydra-gates): dependency analysis and modularity view tools for every app - #942

Merged
rubenvdlinde merged 1 commit into
mainfrom
feat/dependency-views-tools
Nov 18, 2026
Merged

rubenvdlinde merged 1 commit into
mainfrom
feat/dependency-views-tools

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

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, --components and --out.
  • rate_component_views.py <app> --report R.json: the estimated modularity rating under views A to E, built with the scorer's own structure() and rating_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 NAME and --merge NAME[,NAME] (default Kernel and Core).
  • deptrac_areas.py <app>: writes a deptrac config with one layer per functional area. --shared names the area every other area may use, and --check reports a stale file.
  • deptrac_summary.py, deptrac.sh <app> layers|FILE.yaml and a generic deptrac/layers.yaml for the Nextcloud layout.
  • README section: what the tools measure, the commands, and how to install deptrac.
  • Three test suites, plus their rows in 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.json requires deptrac/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, and component_of_factory(files, app). The package scorer has none of these. It has scope_file_components() / scope_component_factory(), switched on by COMPONENTS_FROM_SCOPE. The ported tools adapt to the package scorer, which is unchanged:

  • The components file is parsed by the scorer's own scope_file_components(), via a temporary copy named sigrid.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 sets COMPONENTS_FROM_SCOPE and restores both values on exit.
  • Files no pattern matches are (no component), the package scorer's name for them, not Remainder.

Verified locally

  • python3 scripts/lib/test_analyse_dependencies.py: 13 tests OK
  • python3 scripts/lib/test_rate_component_views.py: 15 tests OK
  • python3 scripts/lib/test_deptrac_tools.py: 8 tests OK
  • python3 scripts/lib/test_check_sig_maintainability.py: OK (scorer untouched)
  • python3 tests/test-partition-helper-suites.py: OK
  • HELPER_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:

  • Same graph and the same component counts. Lines of code differ by 0.15% (459,345 against 458,671). The package scorer counts PHP #[ attribute lines as code, and the openregister copy counted them as comments.
  • Views B to E give the same ratings. View A (one component) is now reported as unrated with a warning, because the package scorer does not rate a single component. The openregister copy rated it 5.5.
  • deptrac_areas.py reproduces openregister's areas.yaml byte for byte, apart from the header.
  • deptrac.sh <openregister> layers runs with openregister's installed deptrac.
  • On pipelinq, which has no components file, the functional view is skipped with a message.

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)

…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
@rubenvdlinde
rubenvdlinde merged commit 36a3833 into main Nov 18, 2026
56 checks passed
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