Skip to content

engine: k3po zilla extension cannot assert the affinity of an individual stream (read option zilla:affinity) #3199

Closed

Description

@jfallows

Problem

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.

Activity

  1. jfallows commented on Nov 13, 2026

    @jfallows
    ContributorAuthor

    Design note

    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.


    Generated by Claude Code

  2. self-assigned this
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions