You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
engine: k3po zilla extension cannot assert the affinity of an individual stream (read option zilla:affinity) #3199
The k3po zilla extension can check an expected affinity only per accept: option zilla:affinity on an accept is copied to every accepted channel and compared in ZillaStreamFactory.onBegin as part of BEGIN handling, before any script statement runs (read on develop at 5556779 and on the accept-side affinity fix; not run). The read option handlers of the extension (ZillaTypeSystem read options) cover flags, ack and window only; no script uses a per-stream read option zilla:affinity.
A script that accepts several streams on one address, each opened with a different affinity, therefore cannot assert the affinity of an individual stream: one accept-level expectation cannot fit streams that legitimately carry different values, and a second accept at the same address replaces the first in the harness's per-address server map.
Expected
A script can assert the affinity a given stream was opened with, with read option zilla:affinity <value> on that stream, in the same way it asserts read option zilla:flags, ack and window on a stream.
A mismatch fails that stream's script in the way the other read options do; a stream without the assertion is unaffected; the accept-level option keeps its current meaning.
Test plan (test-first)
In specs/engine.spec and runtime/engine: a script pair with two streams of different affinities accepted on one address, each asserted with read option zilla:affinity, a mismatch scenario that fails for the right reason (the peers disagree on the affinity of one stream), and the unchanged accept-level scenarios. The first commit contains the failing scripts. Read runtime/engine/AGENTS.md first; the pattern to mirror is how the extension handles the existing read options and how the accept-affinity option was made effective.
Pattern mirrored.read option zilla:ack and zilla:window for the wiring: the option is declared in ZillaTypeSystem.readOptions(), a ReadOptionFactory is registered in ZillaBehaviorSystem, and a command handler runs when the script reaches the statement. The failure behaviour comes from read option zilla:flags, whose handler fails its future with a ScriptProgressException carrying the statement's region info. Adding OPTION_AFFINITY to the read options is a one-entry addition to the type system; the language grammar is not touched.
Where the value lives.ZillaStreamFactory.onBegin records the BEGIN's affinity on the channel (sourceAffinity, next to sourceId and sourceAuth) once the stream's own check has passed. Every stream, accepted or connected, therefore carries the affinity it was actually opened with.
Mismatch.ReadAffinityOptionHandler is a command handler like ReadAckOptionHandler. When the script reaches read option zilla:affinity <value> it compares the value with the channel's sourceAffinity. A mismatch fails the handler future with a ScriptProgressException ("Expected affinity: 0x…, but was: 0x…") with the statement's region info, so that stream's script fails the same way a mismatched read option zilla:flags does. Streams whose script has no such statement are unaffected.
Coexistence with the accept-level option.option zilla:affinity on an accept keeps its meaning: it is copied to each accepted child and checked in onBegin before any statement runs. The per-stream statement is independent, so an accept without the option accepts any affinity and each stream asserts its own. Per-address server map handling is unchanged.
Test plan (test-first). The extension's own scripts live in runtime/engine/src/test/scripts/.../k3po/ext/simplex and are exercised by SimplexIT, so that is where they go (not specs/engine.spec). First commit, failing:
handshake.read.affinity: two streams with different affinities on one address, each asserted with read option zilla:affinity.
handshake.read.affinity.mismatch: the client opens with one affinity and the server asserts another; expected to fail with the mismatch message.
The existing accept-level scenarios (handshake.affinity, handshake.circuit.id.mismatch) stay unchanged.
Each is one method in SimplexIT. Expected failure before the change: the script fails to parse, because zilla:affinity is not a read option.
Activity
jfallows commentedon Nov 13, 2026
Design note
Pattern mirrored.
read option zilla:ackandzilla:windowfor the wiring: the option is declared inZillaTypeSystem.readOptions(), aReadOptionFactoryis registered inZillaBehaviorSystem, and a command handler runs when the script reaches the statement. The failure behaviour comes fromread option zilla:flags, whose handler fails its future with aScriptProgressExceptioncarrying the statement's region info. AddingOPTION_AFFINITYto the read options is a one-entry addition to the type system; the language grammar is not touched.Where the value lives.
ZillaStreamFactory.onBeginrecords the BEGIN's affinity on the channel (sourceAffinity, next tosourceIdandsourceAuth) once the stream's own check has passed. Every stream, accepted or connected, therefore carries the affinity it was actually opened with.Mismatch.
ReadAffinityOptionHandleris a command handler likeReadAckOptionHandler. When the script reachesread option zilla:affinity <value>it compares the value with the channel'ssourceAffinity. A mismatch fails the handler future with aScriptProgressException("Expected affinity: 0x…, but was: 0x…") with the statement's region info, so that stream's script fails the same way a mismatchedread option zilla:flagsdoes. Streams whose script has no such statement are unaffected.Coexistence with the accept-level option.
option zilla:affinityon anacceptkeeps its meaning: it is copied to each accepted child and checked inonBeginbefore any statement runs. The per-stream statement is independent, so an accept without the option accepts any affinity and each stream asserts its own. Per-address server map handling is unchanged.Test plan (test-first). The extension's own scripts live in
runtime/engine/src/test/scripts/.../k3po/ext/simplexand are exercised bySimplexIT, so that is where they go (notspecs/engine.spec). First commit, failing:handshake.read.affinity: two streams with different affinities on one address, each asserted withread option zilla:affinity.handshake.read.affinity.mismatch: the client opens with one affinity and the server asserts another; expected to fail with the mismatch message.handshake.affinity,handshake.circuit.id.mismatch) stay unchanged.Each is one method in
SimplexIT. Expected failure before the change: the script fails to parse, becausezilla:affinityis not a read option.Generated by Claude Code