Skip to content

Install the syn event handler for the adapter's scopes only - #2

Draft
vheathen wants to merge 4 commits into
mainfrom
per-scope-event-handler
Draft

vheathen wants to merge 4 commits into
mainfrom
per-scope-event-handler

Conversation

@vheathen

@vheathen vheathen commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

The adapter now sets its conflict handler for each Commanded application's scope with :syn.set_event_handler/2 and leaves syn's node-wide handler alone. ConflictResolution.adapter_scope?/1 goes away, so this ships as 0.2.0; the CHANGELOG lists what a host has to change.

This stays a draft until syn releases :syn.set_event_handler/2 (ostinelli/syn#93). Until then the branch takes syn from the Qarma-inspect/syn fork at 260ea0b and is merged into integration, which applications pin by commit. Hex refuses git dependencies, so mix hex.build fails on this branch, and its CI step has continue-on-error until the dependency goes back to Hex.

Closes #1

The next change installs the adapter's event handler for each Commanded
application's scope with :syn.set_event_handler/2. Released syn 3.4.2 has
no such function. It is proposed upstream in ostinelli/syn#93 (issue
ostinelli/syn#91) and lives in the Qarma-inspect/syn fork at 1b4a030,
which this branch pins by commit.

mix hex.build fails on this branch, because Hex refuses git
dependencies. main stays on released syn and is what goes to Hex.

Refs #1
syn keeps one event handler per node. The adapter took that handler over,
passed the callbacks of other scopes on to the handler it had found, and
imitated syn's default rule for them when there was none. A handler the
host installed afterwards replaced the adapter's in every scope and had
to pass the adapter's scopes back through adapter_scope?/1. Without
that, a host handler that resolved conflicts itself left the loser of a
conflict in the adapter's scopes running next to the winner, and one
that left conflicts to syn had syn kill the loser with an exit the
adapter treats as a crash, which reached the supervisors.

:syn.set_event_handler/2 installs a handler for one scope, and syn then
calls it for that scope alone. The adapter installs ConflictResolution
that way, before the node joins the scope, and sets no other handler in
syn. The forwarding, the imitation of syn's rule and adapter_scope?/1 go
with it. Removing adapter_scope?/1 is a breaking change, and so is the
end of the forwarding for a host that named ConflictResolution under
config :syn, event_handler:; the CHANGELOG says what each host has to
change. This ships as 0.2.0 when it reaches main.

Refs #1
The syn fork at 1b4a030 already carries the snapshot fix proposed in
ostinelli/syn#90, so the README's advice to keep scopes small until syn
releases it applies to syn 3.4.2 only.

ConflictResolution named under config :syn, event_handler: decides
conflicts in the host's own scopes by the adapter's rule when both
registrations carry :started_at; the CHANGELOG only described the other
case.

The comment on install_for_scope/1 said the order protects the conflict
rule. A conflict needs a registration of the node's own, which comes
later; the order keeps the callbacks of the first exchange away from a
host's node-wide handler.

Refs #1
The Qarma-inspect/syn fork's integration branch now carries upstream
master, where ostinelli/syn#90, #94 and #95 and the maintainer's fixes
of snapshot races have landed, with the per-scope event handlers of
ostinelli/syn#93 on top.

Refs #1
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.

Install the syn event handler for the adapter's scopes only

1 participant