Skip to content

refactor: enforce features/ structure for all library packages - #263

Merged
NTCoding merged 4 commits into
mainfrom
refactor/enforce-features-structure-for-libraries
Feb 7, 2026
Merged

NTCoding merged 4 commits into
mainfrom
refactor/enforce-features-structure-for-libraries

Conversation

@NTCoding

@NTCoding NTCoding commented Feb 7, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Remove domain/query library exceptions from ADR-002 — all packages now use features/ structure
  • Restructure riviere-extract-ts, riviere-builder, and riviere-query into src/features/{name}/domain/
  • Update dep cruiser root-structure rule, eslint ignore paths, typedoc entry points, and fixture imports

Test plan

  • All builds pass (nx run-many -t build)
  • All tests pass (nx run-many -t test)
  • Depcruise clean (pnpm depcruise)
  • Lint, typecheck, typedoc all pass
  • CI checks pass on PR

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor

    • Consolidated package entry points and reworked public exports to surface functionality at package roots.
  • Documentation

    • Clarified architecture guidance for library packaging, entry points, and allowed folder structures.
  • Tests

    • Added deduplication unit tests and updated test fixtures/imports for consistent resolution.
  • Chores

    • Updated build/docs/test configs and small enforcement rules; increased test timeout for stability.

Remove domain/query library exceptions from ADR-002. Restructure
riviere-extract-ts, riviere-builder, and riviere-query to use
features/ sub-folders. Update dep cruiser root-structure rule,
eslint ignore paths, typedoc entry points, and fixture imports
to match new structure.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai

coderabbitai Bot commented Feb 7, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR moves package public entry points to package-root barrels (src/index.ts), updates package.json/typedoc entries, rewrites dependency-cruiser/ADR rules to allow root barrels, adjusts many relative import paths and tests, and adds/updates unit tests for deduplication.

Changes

Cohort / File(s) Summary
Repo config & docs
\.dependency-cruiser.mjs, docs/architecture/adr/ADR-002-allowed-folder-structures.md, eslint.config.mjs
Allow src/index.ts at package roots in dependency-cruiser rule; ADR rewritten to clarify library package structure and local exceptions; eslint glob adjusted to packages/riviere-query/src/features/querying/queries/**/*.ts.
riviere-builder — package entry & docs
packages/riviere-builder/package.json, packages/riviere-builder/typedoc.json, packages/riviere-builder/src/index.ts
Switched main/module/types and exports from dist/domain/* / src/domain/index.ts to root dist/index.* / src/index.ts; added root barrel export * from './features/building/domain' and updated TypeDoc entry.
riviere-builder — imports & tests
packages/riviere-builder/src/__fixtures__/builder-fixtures.ts, packages/riviere-builder/src/features/building/.../*.spec.ts, packages/riviere-builder/src/features/building/domain/enrichment/*.ts, packages/riviere-builder/src/platform/.../deduplicate.spec.ts
Adjusted many relative import paths to deeper locations; added unit tests for deduplicateStateTransitions; removed an outdated test suite in one deduplicate spec.
riviere-extract-ts — package entry & API surface
packages/riviere-extract-ts/package.json, packages/riviere-extract-ts/src/index.ts, packages/riviere-extract-ts/src/shell/index.ts, packages/riviere-extract-ts/typedoc.json
Moved package entrypoints from shell to root index (dist/index.* / src/index.ts); created comprehensive src/index.ts re-exporting domain extraction APIs; emptied src/shell/index.ts of those re-exports; updated TypeDoc entry.
riviere-extract-ts — imports & tests
packages/riviere-extract-ts/src/features/extraction/.../*.ts, .../*.spec.ts, packages/riviere-extract-ts/vitest.config.mts
Updated many relative import paths to match reorganized layout; added testTimeout: 15000 to Vitest config.
riviere-query — package entry & docs
packages/riviere-query/package.json, packages/riviere-query/typedoc.json, packages/riviere-query/src/index.ts
Switched package entrypoints from dist/queries/* to dist/index.*; updates exports to point to src/index.ts; added root barrel re-exporting ./features/querying/queries.
riviere-query — tests
packages/riviere-query/src/features/querying/queries/*.spec.ts
Adjusted many test fixture import paths to traverse additional directory levels (e.g., ../platform/... → ../../../platform/...) to reflect new layout.
API surface changes (exports)
packages/riviere-extract-ts/src/index.ts, packages/riviere-extract-ts/src/shell/index.ts, packages/riviere-builder/src/index.ts, packages/riviere-query/src/index.ts, packages/*/typedoc.json
Added new root-barrel exports (riviere-extract-ts, riviere-builder, riviere-query) and removed corresponding re-exports from their previous shell/domain barrels; TypeDoc entryPoints updated to ./src/index.ts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

Review effort 4/5

Poem

🐰 I hopped through folders, found the root,
Moved exports home and tightened the route,
Tests chased paths both near and far,
Barrels align — a neat little star,
A joyful hop — index now en route!

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly reflects the main objective: enforcing a features/ structure across all library packages, which is the primary refactoring goal described in the PR summary.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/enforce-features-structure-for-libraries

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@packages/riviere-builder/src/platform/domain/collection-utils/deduplicate.spec.ts`:
- Line 2: The test file deduplicate.spec.ts under the platform domain layer
imports and tests the features-layer function deduplicateStateTransitions; move
that test file so it sits next to the implementation of
deduplicateStateTransitions in the features building/domain/enrichment tests,
update the import to a local relative import (remove cross-layer import), and
run tests to ensure no remaining platform→features test dependency remains.

In `@packages/riviere-extract-ts/src/index.ts`:
- Around line 15-33: The public barrel currently exports the 11 internal rule
functions (evaluateLiteralRule, evaluateFromClassNameRule,
evaluateFromMethodNameRule, evaluateFromFilePathRule, evaluateFromPropertyRule,
evaluateFromDecoratorArgRule, evaluateFromDecoratorNameRule,
evaluateFromGenericArgRule, evaluateFromMethodSignatureRule,
evaluateFromConstructorParamsRule, evaluateFromParameterTypeRule); remove these
from the public export list in packages/riviere-extract-ts/src/index.ts and
either re-export them from an internal testing path (e.g., ./internal or
./testing) or keep them as non-exported/private functions inside
./features/extraction/domain/value-extraction; update any unit tests to import
from the new internal path if needed and ensure public API continues to export
only applyTransforms, ExtractionError, ExtractionContext/Result types,
ParameterInfo, and MethodSignature so consumers use
ExtractionConfig/extractComponents only.

Comment thread packages/riviere-builder/src/platform/domain/collection-utils/deduplicate.spec.ts Outdated
Comment thread packages/riviere-extract-ts/src/index.ts
Move deduplicateStateTransitions tests from platform layer to
features/building/domain/enrichment (fixes cross-layer test dependency).
Remove 11 internal evaluate*Rule functions from riviere-extract-ts
public API (only used internally).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Feb 7, 2026 •

Copy link
Copy Markdown

Deploying living-architecture with  Cloudflare Pages  Cloudflare Pages

Latest commit: dd75d31
Status: ✅  Deploy successful!
Preview URL: https://7fc5c7f3.living-architecture.pages.dev
Branch Preview URL: https://refactor-enforce-features-st.living-architecture.pages.dev

View logs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@packages/riviere-builder/src/features/building/domain/enrichment/deduplicate-transitions.spec.ts`:
- Around line 49-92: Add a test that covers the reverse trigger-asymmetry: call
deduplicateStateTransitions with an existing transition that includes trigger:
'submit' and an incoming transition without a trigger (both with same from/to)
and assert the incoming one is treated as non-duplicate (i.e., result contains
the incoming transition or the expected retained transition). Locate the test
suite around deduplicate-transitions.spec.ts where other trigger-asymmetry cases
are defined and mirror the structure of the existing "treats different triggers
as non-duplicates" test but swap which side has the trigger.

…t timeout

Remove 11 evaluate*Rule functions from value-extraction index (knip
flagged as unused). Increase riviere-extract-ts testTimeout to 15s
to address flaky test failures under parallel load (see #264).

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@packages/riviere-extract-ts/src/features/extraction/domain/value-extraction/index.ts`:
- Around line 8-10: The exports here use fragile deep-relative imports for
applyTransforms and ExtractionError (from '../../../../platform/...'); replace
them with a stable import surface—either add a barrel file in platform/domain
(exporting string-transforms/transforms and ast-literals/literal-detection) and
re-export from that barrel, or configure a TypeScript path alias (e.g.,
`@platform/domain/`*) and update the exports to import applyTransforms and
ExtractionError from the new stable path; update the export statements in
index.ts to reference the barrel or alias so cross-boundary moves won't break.

Covers case where existing has trigger but incoming does not.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@sonarqubecloud

sonarqubecloud Bot commented Feb 7, 2026

Copy link
Copy Markdown

@NTCoding
NTCoding merged commit a963a45 into main Feb 7, 2026
14 of 15 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