Commit f2a8a48
committed
fix(objectql,runtime,metadata-protocol): execute authored (Studio) hook bodies — wire default bodyRunner + live rebind (#2588)
A hook authored at runtime (protocol.saveMetaItem / publish-drafts) loaded
into the registry but its L1/L2 body never executed — on publish AND after a
full restart. Two gaps compounded:
1. No bodyRunner on the metadata-service bind path: bindHooksToEngine skips
body-hooks without a runner, and engine.setDefaultBodyRunner was never
called anywhere. AppPlugin.init now installs the QuickJS-sandboxed hook
body runner as the engine default (same runner defineStack hooks already
use), so runner-less bind paths execute bodies. Opt-out:
OS_DISABLE_AUTHORED_HOOKS=1 keeps runtime-authored bodies inert.
2. The bind set never saw authored rows: env-scoped kernels have no
DatabaseLoader, so metadataService.loadMany('hook') misses sys_metadata
rows entirely — the hook was never even bound-and-skipped. ObjectQLPlugin
now re-binds runtime-authored hooks from the rows themselves at
kernel:ready (cold boot), on metadata:reloaded (dev artifact reload,
package publish), and on every hook mutation via the new server-side
protocol.onMetadataMutation listener (saveMetaItem / publishMetaItem /
deleteMetaItem notify after persistence) — so direct saves, publishes,
edits, and deletes all take effect without a restart.
Double-execution guard: package-artifact hooks (bound by AppPlugin under
app:<id> with an explicit runner) are excluded from the metadata-service
bind via registry.getArtifactItem — previously their string-handler variants
were latently double-bound, and a default runner would have made body hooks
run twice per event. Deleting the last authored hook explicitly unregisters
the package set (bindHooksToEngine early-returns on an empty list before its
unregister step). Resyncs are serialized so overlapping mutations cannot
land an older snapshot last.
Verified end-to-end on a fresh showcase instance: authored beforeUpdate hook
mutates input after live save, after draft+publish-drafts, and after a full
restart; deletes stop it firing; the defineStack control hook still runs.
Closes #2588
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWLRAafXUQzfi2UNW9CcVp1 parent e695fe0 commit f2a8a48
9 files changed
Lines changed: 827 additions & 9 deletions
File tree
- .changeset
- packages
- metadata-protocol/src
- objectql/src
- runtime/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
Lines changed: 66 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
722 | 736 | | |
723 | 737 | | |
724 | 738 | | |
| |||
778 | 792 | | |
779 | 793 | | |
780 | 794 | | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
781 | 839 | | |
782 | 840 | | |
783 | 841 | | |
| |||
3905 | 3963 | | |
3906 | 3964 | | |
3907 | 3965 | | |
| 3966 | + | |
| 3967 | + | |
| 3968 | + | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
3908 | 3972 | | |
3909 | 3973 | | |
3910 | 3974 | | |
| |||
3996 | 4060 | | |
3997 | 4061 | | |
3998 | 4062 | | |
| 4063 | + | |
| 4064 | + | |
| 4065 | + | |
| 4066 | + | |
| 4067 | + | |
| 4068 | + | |
3999 | 4069 | | |
4000 | 4070 | | |
4001 | 4071 | | |
| |||
4192 | 4262 | | |
4193 | 4263 | | |
4194 | 4264 | | |
| 4265 | + | |
| 4266 | + | |
| 4267 | + | |
| 4268 | + | |
| 4269 | + | |
| 4270 | + | |
4195 | 4271 | | |
4196 | 4272 | | |
4197 | 4273 | | |
| |||
5434 | 5510 | | |
5435 | 5511 | | |
5436 | 5512 | | |
| 5513 | + | |
| 5514 | + | |
| 5515 | + | |
| 5516 | + | |
| 5517 | + | |
| 5518 | + | |
5437 | 5519 | | |
5438 | 5520 | | |
5439 | 5521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
98 | 143 | | |
99 | 144 | | |
100 | 145 | | |
| |||
0 commit comments