Skip to content

SYN-10404: Implement Storm event callbacks in the data model#4800

Open
invisig0th wants to merge 19 commits intosynapse-3xxfrom
SYN-10404
Open

SYN-10404: Implement Storm event callbacks in the data model#4800
invisig0th wants to merge 19 commits intosynapse-3xxfrom
SYN-10404

Conversation

@invisig0th
Copy link
Contributor

@invisig0th invisig0th commented Mar 14, 2026

Summary

New: Declarative Storm on callbacks in the data model

Forms and Props can now declare Storm queries that run automatically on lifecycle events via an 'on' key in their info dict:

  • datamodel.py: Prop parses on.set.q / on.del.q; Form parses on.add.q / on.del.q. Storm callbacks execute after Python callbacks in wasSet(), wasDel(), wasAdded(), wasDeleted(). Added postFormInit() lifecycle hook so type classes can register Python callbacks on the fully-constructed Form.
  • view.py: Added runOnStorm(node, storm) — executes Storm as the calling user with asroot elevation, guarded by migration/safemode checks.

Removed: Old hooks infrastructure

  • cortex.py: Removed _propSetHooks dict, _setPropSetHook(), and _callPropSetHook().
  • editor.py: Removed _callPropSetHook call from ProtoNode.set().
  • datamodel.py: Removed hooks dict loading loop from model definitions.

inet:fqdn callbacks: Python on the type class

  • inet.py: Zone/suffix callbacks are now methods on the Fqdn type class, registered via postFormInit(): _onAddFqdn, _onSetIsSuffix, _onSetIsZone, _onSetZone. Old module-level callbacks, the hooks dict in modeldefs, and Storm on keys on inet:fqdn and its props are all removed.

it:dev:str: Storm on:add callback

  • infotech.py: Old _onFormItDevStr Python callback replaced with declarative 'on': {'add': {'q': '[ :norm=$node ]'}}.

Test plan

  • test_storm_on_callbacks covers on:add, on:set, on:del callbacks
  • Verifies non-admin user can trigger callbacks (runs as root)
  • Verifies error handling (bad Storm query logs error, doesn't crash)
  • Verifies it:dev:str norm callback works via Storm
  • All test_model_inet.py tests pass (53 tests)
  • All test_cortex.py tests pass (185 tests)

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 90.08264% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.46%. Comparing base (309076d) to head (e7ad52e).

Files with missing lines Patch % Lines
synapse/datamodel.py 73.80% 11 Missing ⚠️
synapse/lib/view.py 90.90% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (90.08%) is below the target coverage (97.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@               Coverage Diff               @@
##           synapse-3xx    #4800      +/-   ##
===============================================
- Coverage        96.46%   96.46%   -0.01%     
===============================================
  Files              256      256              
  Lines            62472    62503      +31     
===============================================
+ Hits             60266    60291      +25     
- Misses            2206     2212       +6     
Flag Coverage Δ
linux 96.46% <90.08%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@invisig0th invisig0th closed this Mar 14, 2026
@invisig0th invisig0th deleted the SYN-10404 branch March 14, 2026 10:47
@invisig0th invisig0th restored the SYN-10404 branch March 14, 2026 10:48
@invisig0th invisig0th reopened this Mar 14, 2026
… onto synapse-3xx)

Add ``on`` key support in data model property and form info declarations
for Storm event callbacks. Callbacks run as root user and are guarded by
migration/safemode checks. Convert it:dev:str _onFormItDevStr to
declarative Storm on:add callback.
@invisig0th invisig0th changed the base branch from master to synapse-3xx March 14, 2026 11:07
Update runOnStorm to resolve the user from the current Storm runtime
scope rather than always using root. The callback still runs with
asroot=True for elevated permissions.
Replace the 4 Python hook callbacks for inet:fqdn (onAddFqdn,
onSetFqdnIsSuffix, onSetFqdnIsZone, onSetFqdnZone) with declarative
Storm on-event callbacks. Remove the hooks infrastructure from the
data model, cortex, and editor since it is no longer used.
@invisig0th invisig0th marked this pull request as ready for review March 14, 2026 14:30
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