Offline, LLM-free, dependency-free (pure-stdlib) SERIALIZABILITY & INTERFERENCE AUDITOR for the AGENT PARALLEL TOOL-CALL plane.
The series' first entry on the interleaving leg. Experiments 001–042 all audit calls one at a time — what a call may do (001–010), what one channel promises (011–021), what the seams between channels leak (022), what happens on retry (038), on cancel (042), on the way back (041). Every one of them assumes the calls happened in some order. skein audits the case where they did not: the batch the model emitted in a single turn, dispatched concurrently by a harness that has no idea which of those calls touch the same thing.
skein audit --session session.jsonl --profile effects.json
MCP 2026-07-28 removed sessions from the protocol core and told servers that need cross-call state to mint an explicit handle and have the model pass it back as an ordinary tool argument (SEP-2567). In the same season, both major labs shipped wide parallel-subagent modes, and orchestration harnesses that batch every tool call a model emits in one turn became a product category. Put those together and you get the oldest bug in databases, rebuilt from parts nobody thinks of as a database: shared mutable state addressed by a value the model holds, mutated by calls dispatched with no ordering between them, against effects that sometimes cannot be undone.
The 2026 literature saw it and answered with runtimes — Atomix's transactional settlement, CoAgent's monotonic pre-order, three verified Rust runtimes realizing an L0–L4 consistency hierarchy. Each is correct and each asks you to replace your execution layer, and none of them can say anything about the thousands of sessions you already logged.
skein is the cheap half nobody shipped. Given a captured session (JSONL, one event per line, which every harness already has) plus a declarative effect profile saying what each tool reads, writes, appends, deletes or enumerates, it builds the conflict graph of the observed schedule and answers one question with a proof: does this schedule have an equivalent serial order? When it does not, skein names the anomaly, names the two calls, names the resource, and prints the wave plan that would have been safe. It never calls a model, opens a socket, or imports a third-party package.
The smallest thing that proves the idea is a checker whose verdict on a
money-moving batch is not a warning but a derivation: two payments.charge
calls and a cart.add_item form a strongly connected region of the conflict
graph, one member commits an external effect declared uncompensable, therefore
the schedule has no serial equivalent and cannot be rolled back to obtain
one. That is IRR01, and it is critical for a reason a linter cannot express.
Python 3.11+. No dependencies at runtime; pytest only to run the tests.
# audit a capture (the headline demo)
python -m skein audit \
--session fixtures/defective-commerce/session.jsonl \
--profile fixtures/defective-commerce/profile.json
# machine-readable, for CI
python -m skein audit --session S --profile P --format json --fail-on high
# what should have run in parallel
python -m skein plan --session S --profile P
# the rule catalog
python -m skein rules
# tests
python -m pytest # 563 testsOr with make: make setup && make test && make run.
Exit codes. 0 the report passed the gate · 1 the report failed the gate
(--fail-under, default 80, and/or --fail-on SEVERITY) · 2 the invocation
or an input was wrong. --min-severity hides findings from the printed list but
never changes the score — a quiet console cannot raise the grade.
Five event kinds; only call_start and call_end are required.
{"kind":"meta","seq":1,"timestamp_resolution_ms":50,"clock":"shared"}
{"kind":"batch","seq":6,"ts":2000,"actor":"main","batch":"b2","calls":["c3","c4","c5"]}
{"kind":"call_start","seq":7,"ts":2000,"actor":"main","batch":"b2","call_id":"c3",
"tool":"payments.charge","args":{"cart_id":"cart-9d1e77c2","account":"acct-40021"}}
{"kind":"call_end","seq":12,"ts":2300,"call_id":"c3","status":"ok","result":{"posted":true}}
{"kind":"message","seq":19,"ts":1900,"actor":"main","role":"assistant","text":"..."}actor carries subagent identity, so a main agent and its subagents are one
capture. batch records what the model emitted in a single turn — the issue
order — which is what makes SER06 (effects landed backwards) and CAU03
(producer and consumer dispatched together) decidable.
{
"version": 1,
"settings": { "fanout_threshold": 3, "shared_clock": true },
"invariants": [{ "id": "promo-budget", "resources": ["promo:budget", "promo:*"] }],
"tools": {
"cart.add_item": { "accesses": [{ "mode": "append", "resource": "cart:{cart_id}" }] },
"fs.list": { "accesses": [{ "mode": "enumerate", "resource": "fs:{dir}/**" }] },
"payments.charge": {
"exclusive": true,
"accesses": [
{ "mode": "read", "resource": "cart:{cart_id}" },
{ "mode": "write", "resource": "ledger:{account}",
"durability": "external", "compensable": false }
]
}
}
}Resource templates interpolate the call's own arguments, so cart:{cart_id}
resolves per call to the concrete handle the server minted. Patterns support
* (one segment) and ** (trailing, recursive), which is how an enumeration of
fs:/repo/src/** is known to collide with a write to fs:/repo/src/app.py.
Per tool you may also declare commutes_with, requires_after, exclusive,
parallel_safe, idempotent and compensated_by. parallel_safe is a claim
skein will contradict (EXC02) rather than trust.
session.jsonl ─┐
├─► session.py ──► Invocation[] (paired, accesses resolved)
effects.json ──┴─► profile.py ──► Profile (tools, invariants, settings)
│
schedule.py ──────┴──► Relation(a,b) ∈ {left, right, concurrent}
Conflict[] (mode pair × resource overlap)
│
graph.py ─────────┴──► conflict graph → Tarjan SCC → regions
→ greedy wave plan
dataflow.py ──────────► ValueIndex (provenance by availability seq)
│
analyzer.py ──────┴──► 26 rules in 6 families → Finding[]
scoring.py ───────────► weights, per-rule caps, grade clamps
report.py ────────────► text | json cli.py ──► exit code
The formal core. Nodes are invocations. A conflict between two invocations whose order is provable (a decisive gap between them) contributes one directed edge; a conflict between two concurrent invocations contributes both, because the capture does not say which way it went and either is possible. A strongly connected component of size ≥ 2 in that graph is a set of invocations for which no serial order reproduces the observed schedule. That is the whole claim.
Pairwise races are reported by their own rules (SER02 lost update, STA03
read/write race, …) so SER01 is reserved for components of size ≥ 3 — a cycle
that survives even after each pair is individually ordered. IRR01 uses the
honest ≥ 2 threshold, because an irreversible effect inside any conflict cycle
is already unrecoverable.
Conservatism is directional. Where skein cannot decide, it assumes the
hazard and says so: intervals separated by less than the capture's declared
timestamp resolution are treated as concurrent and raise COV03; a call with
no call_end runs to the end of the session and raises COV02; a tool absent
from the profile contributes no conflicts and raises COV01. Coverage is a
finding family, not a silent skip.
| Family | Rules | What it decides |
|---|---|---|
| SER serialization | SER01 non-serializable region · SER02 lost update · SER03 dirty read · SER04 write skew across a declared invariant · SER05 non-repeatable read · SER06 tool-effect reordering | the schedule has no equivalent serial order |
| STA staleness | STA01 stale value propagated downstream · STA02 phantom enumeration · STA03 read raced by a write · STA04 read raced by a delete | a value was read out from under a concurrent writer |
| CAU causality | CAU01 provenance violation · CAU02 declared ordering precondition violated · CAU03 producer and consumer in the same batch | a call depended on a result it could not have had |
| IRR irreversibility | IRR01 uncompensable external effect inside a conflict cycle (critical) · IRR02 concurrent uncompensable external effects (critical) · IRR03 compensable claim with no compensator · IRR04 uncompensable effect raced on its own precondition | the damage in a race cannot be undone |
| EXC isolation hygiene | EXC01 exclusive tool ran concurrently · EXC02 parallel_safe claim contradicted · EXC03 cross-actor write collision · EXC04 excessive concurrent writers | declared isolation was not actually obtained |
| COV coverage | COV01 unprofiled tool · COV02 unterminated invocation · COV03 overlap undecidable at this resolution · COV04 unresolved resource template · COV05 cross-actor timing without a shared clock | what skein could not decide, said out loud |
STA01, STA02, CAU01/CAU03 and SER06 are the detection-side
counterparts of the four anomalies formalized in TLA+ by
arXiv:2606.17182 — stale-generation,
phantom-tool, causal-cascade and tool-effect reordering.
Severity weights (critical 30, high 14, medium 7, low 3, info 0) with a per-rule cap so one noisy rule cannot bury a critical, and categorical grade clamps so arithmetic cannot rescue a bad report: any critical clamps the grade to F, any high to at most C, any medium to at most B. A score is an average; a grade is a verdict.
skein plan re-partitions each observed batch into conflict-free waves by
greedy colouring over the static conflict relation — the question a scheduler
must answer before dispatching. On the commerce fixture the three-call batch
comes back as three waves, because an exclusive money-moving tool cannot share a
wave with anything.
A — a concurrency-control runtime. Wrap the harness's dispatcher: take locks or a snapshot per call, validate write sets at commit, compensate on abort. This is what Atomix and CoAgent do, and it is correct by construction.
Rejected. It has to be reimplemented per framework, it adds latency and a lock manager to every call, it needs the write set before dispatch (which is the thing you usually do not know), and it is structurally unable to say anything about a session that already ran. For a single-run prototype it would also have been unverifiable: proving a runtime correct needs the runtime.
B — post-hoc schedule analysis from a capture plus a declarative profile. Chosen. Zero runtime cost, framework-agnostic, runs in CI over logs that already exist, and every verdict is a derivation you can re-check by hand from the two input files. Its ceiling is the profile: skein sees exactly the resources someone declared, and a tool nobody described is a blind spot it reports rather than hides.
Cost inside B. Conflict enumeration is O(n²·a²) over invocations × accesses,
with an LRU-memoized segment matcher underneath. A sweep-line over interval
endpoints would make it near-linear, and was rejected as premature: real
captures are hundreds of calls, the four fixtures analyse in single-digit
milliseconds, and the pairwise loop is the version a reader can check. Memory is
one Invocation per call plus one index entry per significant scalar; nothing
is retained across runs.
A third choice worth naming. Provenance uses exact scalar matching behind a significance filter (long strings, id-shaped short strings, numbers ≥ 100) rather than fuzzy or transform-aware matching. A value that is reformatted or encoded between producer and consumer is therefore not tracked. That is deliberate: a missed link is a missing finding, and a fabricated link is a false accusation about causality. This checker prefers the first.
$ python -m skein audit \
--session fixtures/defective-commerce/session.jsonl \
--profile fixtures/defective-commerce/profile.json \
--min-severity high --no-plan
skein 1.0.0 -- parallel tool-call serializability audit
session: fixtures/defective-commerce/session.jsonl
profile: fixtures/defective-commerce/profile.json
schedule
--------
16 invocations, 4 batch(es), actors: main
8 concurrent pair(s), 10 conflicting access pair(s) (9 of them concurrent)
4 non-serializable region(s), largest 3 invocation(s)
unprofiled tools: telemetry.emit
findings
--------
!! IRR01 [critical] uncompensable external effect inside a conflict cycle
calls: c3, c4, c5
resource: ledger:acct-40021
c3(payments.charge) commits an uncompensable external effect on
ledger:acct-40021 while inside a conflict region of 3 invocations (c3,
c4, c5); the schedule has no serial equivalent and the effect cannot be
undone to obtain one
fix: External uncompensable effects must be exclusive. Never dispatch
them inside a batch that touches their resources.
!! IRR02 [critical] concurrent uncompensable external effects
calls: c3, c4
resource: ledger:acct-40021
c3(payments.charge) and c4(payments.charge) both commit uncompensable
external effects on ledger:acct-40021 at the same time
fix: Serialize them behind a single owner with an idempotency key.
! CAU01 [high] provenance violation
calls: c1, c2
c2(cart.total) was issued at seq 3 carrying $.cart_id = 'cart-9d1e77c2',
a value whose first appearance anywhere in the capture is the result of
c1(cart.create) in a call that only completed at seq 5; the consumer
cannot have learned it from the producer
fix: Never let the model synthesize an identifier a tool is supposed to
mint. Await the producer, then pass its handle through.
! SER04 [high] write skew across a declared invariant
calls: c10, c11
resource: promo-budget
c10(promo.apply) and c11(promo.apply) ran concurrently, each read inside
invariant 'promo-budget' and each wrote a different member of it; both
decisions were legal alone and the pair is not
fix: Materialize the invariant: read and write it through one tool, or
take an exclusive lease over the invariant's resources.
... (SER01, SER02 x2, SER03, EXC01 x3, IRR04 x2 elided)
scoring
-------
CAU01: 1 x 14 = 14 -> -14
EXC01: 3 x 14 = 42 -> -35 (capped)
IRR01: 1 x 30 = 30 -> -30
...
SER06: 5 x 7 = 35 -> -18 (capped)
STA03: 5 x 7 = 35 -> -18 (capped)
verdict
-------
2 critical, 11 high, 16 medium, 2 low, 0 info
score 0/100 grade F
$ echo $?
1
And the plan for the same batch:
$ python -m skein plan --session fixtures/defective-commerce/session.jsonl \
--profile fixtures/defective-commerce/profile.json
batch 'b2' (actor main, width 3) -- UNSAFE: needs 3 waves
wave 1: c3
wave 2: c4
wave 3: c5
Four captures ship with the prototype. Their exact rule sets, per-rule counts,
scores and grades are asserted in tests/test_fixtures.py, so the engine cannot
drift without a test failing first.
| Fixture | Shape | Result |
|---|---|---|
clean-coding |
one agent, wide read fan-out then two disjoint writes | 0 findings, 100/A |
clean-commerce |
stateless MCP handles; two appends that commute, a cart.total after they settle, an exclusive charge dispatched alone, a subagent on a disjoint namespace |
0 findings, 100/A |
defective-coding |
a main agent and two subagents sharing one checkout instead of one worktree each | 14 rules, 10 high / 11 medium / 1 low, 0/F |
defective-commerce |
the same storefront, dispatched by a harness that batches everything | 17 rules, 2 critical / 11 high / 16 medium / 2 low, 0/F |
The clean fixtures earn their place: they exercise append/append commutativity,
prefix disjointness, commutes_with, an exclusive tool scheduled correctly and a
cross-actor overlap on unrelated resources — all the paths that a checker with a
sloppy conflict matrix would false-positive on.
defective-coding is the failure most readers will recognise: two fs.edit
calls on /repo/src/app.py in one batch (lost update, effects landed backwards),
a subagent writing the same file from outside (cross-actor collision), a
directory listing running across all three (phantom enumeration), a config read
that raced a write and whose value reached a later git.commit (stale value
propagated), and a build id consumed in the same batch that minted it.
Stated plainly, because a checker that overstates its reach is worse than none.
- skein decides that the capture cannot rule a hazard out — not that damage occurred. A non-serializable region means no serial order explains the schedule; whether the losing write mattered depends on data skein never sees.
- The profile is the ceiling. Effects are declared, never inferred from
tool schemas or names. An undeclared tool contributes no conflicts and raises
COV01; an undeclared resource is simply invisible. - The resource model is a pattern over
scheme:path. It cannot express predicate-level conflicts ("rows where status='open'") or content-level ones; approximate those with a prefix, accepting the false positives that follows. - Concurrency is inferred from wall-clock overlap. A harness that stamps a
whole batch with one timestamp will be read as fully concurrent — correct,
but coarse. Cross-actor comparisons without a declared shared clock raise
COV05, and skein does not attempt clock-skew correction. - Provenance is exact-match only (see the third design choice above). Transformed, encoded or partially-quoted values are not linked.
- Greedy wave colouring is safe, not minimal. It never puts two conflicting calls in one wave; it may use more waves than the optimum.
- Timestamps are compared, never converted. Units are whatever the capture used; the fixtures use milliseconds.
- This is not a substitute for runtime concurrency control. It tells you which batches your harness must stop issuing, and which sessions already went wrong. Preventing the next one is still the runtime's job.
- Sessions are held in memory; a multi-gigabyte capture is out of scope.
--fail-underdefaults to 80, which no capture with a high-severity finding can reach after clamping. Tune it per repo before wiring it into CI.
3,766 lines of engine across 16 modules, 3,546 lines of tests (563 tests, all passing), four ground-truth fixtures, 26 rules, zero runtime dependencies.
skein/ errors resources model rules profile session schedule graph
dataflow analyzer scoring report cli version
fixtures/ clean-coding clean-commerce defective-coding defective-commerce
tests/ resources profile session schedule graph dataflow rules_catalog
analyzer_rules scoring fixtures report cli
MIT licensed. Part of dev-experiments-365.