Repository navigation
feat(plugin): wire on_instance_spawn hook (CLI + daemon) - #60
Merged
Merged
Conversation
- Add HookOnInstanceSpawn constant in protocol.go. - Define InstanceSpawnPayload struct matching instancer.Instance fields. - Update TestHelperProcess and add TestManager_InstanceSpawnHookDelivered test.
- Dispatch on_instance_spawn after store.Put in instanceSpawnCmd. - Add instanceSpawnPayload helper and unit tests in cmd/instance_plugin_test.go.
- Add PluginManager field to instancer.Options and Server. - Dispatch on_instance_spawn after store.Put in Server.spawn handler. - Add Server.Close method to terminate plugin subprocesses. - Wire PluginManager loading and clean shutdown in cmd/instancer.go. - Add TestServer_Spawn_DispatchesPluginHook integration test.
ademboukabes
force-pushed
the
feat/plugin-instance-spawn-hook
branch
from
October 13, 2026 19:57
f93b0dd to
d6a1d47
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #40.
Wires the
on_instance_spawnlifecycle hook into both spawn paths across the CLI and daemon:mctf instance spawn(cmd/instance.go)POST /spawn(internal/instancer/server.go+cmd/instancer.go)What changed
Protocol & Payload (
internal/plugin/):HookOnInstanceSpawn = "on_instance_spawn".InstanceSpawnPayloadstruct containing:event,instance_id,challenge_slug,team_id,ports,flag,containers, andexpires_at.TestHelperProcessininternal/plugin/plugin_test.goto handleon_instance_spawn.TestManager_InstanceSpawnHookDeliveredverifying payload delivery and serialization over JSON-RPC.CLI Wiring (
cmd/instance.go):instanceSpawnCmd, initialized one-shotplugin.Managerwithplugin.Load(...)and deferredpm.Close().on_instance_spawnafter instance creation and store persistence (instStore.Put(inst)).instanceSpawnPayloadhelper to mapinstancer.Instanceintoplugin.InstanceSpawnPayload.cmd/instance_plugin_test.go.HTTP Daemon Wiring (
internal/instancer/server.go&cmd/instancer.go):PluginManager *plugin.Managertoinstancer.Optionsand attached persistentpm *plugin.Managertoinstancer.Server.on_instance_spawnwithins.spawnhandler immediately following store persistence (s.store.Put(inst)).Server.Close()to ensure graceful termination of plugin subprocesses on server shutdown.cmd/instancer.go).fork/execpenalty).TestServer_Spawn_DispatchesPluginHookininternal/instancer/server_test.go.Crash Isolation:
Documentation & Reference Plugin:
docs/spec/plugins.mdmarkingon_instance_spawnas shipped with JSON schema and field descriptions.examples/sample-event/plugins/logger.shto subscribe to and logon_instance_spawn.docs/BACKLOG.mdtracking.Verification
golangci-lint run ./...&go vet ./...✅ (0 issues)go test -race ./...✅ (100% tests pass, including plugin, CLI, and instancer daemon tests)make build✅./mctf -C examples/sample-event validate✅./mctf -C examples/sample-event generate --check✅