Skip to content

[NS 2] flatten mounted module fields (tables/reducers/procedures/views) into the root module#5168

Open
aasoni wants to merge 1 commit into
alessandro/sub-module-mountsfrom
alessandro/module-ids-handle-mounts
Open

[NS 2] flatten mounted module fields (tables/reducers/procedures/views) into the root module#5168
aasoni wants to merge 1 commit into
alessandro/sub-module-mountsfrom
alessandro/module-ids-handle-mounts

Conversation

@aasoni
Copy link
Copy Markdown
Contributor

@aasoni aasoni commented Jun 2, 2026

Description of Changes

For each mounted sub-module table and function we need to create them and make them accessible by the host. To do this they are "flattened" into the root module by creating a prefixed identifier (e.g. "<namespace>.<table name>").

API and ABI breaking changes

No

Expected complexity level and risk

3 - Complexity of the code change is manageable. Risk is not too high as the changes should only apply to sub-modules. Modules without submodules should be unaffected and handled by existing code.

Testing

The following testing was done for on the entire namespace feature (which is made of 5 PRs)

Module:

  • root module can import another module and mount it with a namespace under its schema
  • root module and submodule can have the same function and table names without conflicting
  • ctx.db.lib.lib_table is readable/writable inside root module reducer
  • ctx.db.lib.lib_table is readable/writable inside root module procedure withTx block
  • library_reducer(ctx.as.lib) is callable inside root module reducer

Client

  • Client can subscribe to lib.library_table
  • Client can subscribe to lib.library_view
  • Client can call lib/library_reducer
  • Client can call lib/library_procedure
  • Client can subscribe to lib.sublib.sublib_table
  • Client can subscribe to lib.sublib.sublib_view
  • Client can call lib/sublib/sublib_reducer
  • Client can call lib/sublib/sublib_procedure

CLI

  • CLI can subscribe to lib.library_table
  • CLI can subscribe to lib.library_view
  • CLI can call lib/library_reducer
  • CLI can call lib/library_procedure
  • CLI can subscribe to lib.sublib.sublib_table
  • CLI can subscribe to lib.sublib.sublib_view
  • CLI can call lib/sublib/sublib_reducer
  • CLI can call lib/sublib/sublib_procedure

Migration

  • Module migrates without issue from having a submodule to not having a submodule
  • Module migrates without issue from not having a submodule to having a submodule
  • Module migrates without issue when having a submodule and root module change occurs (change reducer signature, add table, add column with default, change reducer function body, change index)
  • Module migrates without issue when having a submodule and a submodule change occurs (change reducer signature, add table, add column with default, change reducer function body, change index)

Commit Log

  • Module loads fine from commit log
  • Module snapshot is created without issue
  • Module loads fine from snapshot

@aasoni aasoni force-pushed the alessandro/sub-module-mounts branch from a5dfaf5 to c8cac1d Compare June 3, 2026 08:00
@aasoni aasoni force-pushed the alessandro/module-ids-handle-mounts branch from e7921b1 to 50ab365 Compare June 3, 2026 08:03
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