From 56b7e836aabd02a048459284b9450ac4a790ca20 Mon Sep 17 00:00:00 2001 From: Chris Huber Date: Sun, 7 Jun 2026 20:47:02 -0400 Subject: [PATCH] fix: register workspace preload artifacts early --- data-machine-code.php | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/data-machine-code.php b/data-machine-code.php index cafc375..fa742ac 100644 --- a/data-machine-code.php +++ b/data-machine-code.php @@ -65,6 +65,25 @@ function datamachine_code_has_datamachine_integration(): bool { return class_exists('DataMachine\Abilities\PermissionHelper'); } +/** + * Register DMC-owned bundle artifact hooks. + * + * Bundle artifact type discovery can run before the rest of DMC's Data Machine + * integrations are available. Keep these hooks registered independently so + * imported agent bundles can materialize DMC-owned artifacts during install. + */ +function datamachine_code_register_bundle_artifacts(): void { + static $registered = false; + + if ( $registered ) { + return; + } + + $registered = true; + ( new \DataMachineCode\Bundle\WorkspacePreloadArtifact() )->register(); +} +datamachine_code_register_bundle_artifacts(); + /** * Register optional Data Machine integrations. */ @@ -77,10 +96,6 @@ function datamachine_code_register_datamachine_integrations(): void { $registered = true; - // Bundle artifact types are Data Machine-specific and are only registered - // when the bundle importer substrate is present. - ( new \DataMachineCode\Bundle\WorkspacePreloadArtifact() )->register(); - // Project active workspace identity into Data Machine's engine_data snapshot. \DataMachineCode\Runtime\ActiveWorkspaceProjector::register();