P-01 · Open Track · Anvil SST 2026 · Team Phi Continuum
## L3 Benchmark ResultsL3 Final Score:
1.0000 / 1.0000· 100% · All 20 scenarios passed ✅
l3_version: anvil-2026-p01-L3-final·adapter: adapters.ourteam:Engine·fk_policy: cascade
Run timestamp:2026-05-16T09:30:14+0530· Adapter SHA-256:c5a197fc022be8634d5541d5504f0acbf10b7198fe49f87e061a8882
| Component | Score | Max | Weight |
|---|---|---|---|
| Core | 1.0000 | 1.0000 | 60% |
| Stretch | 1.0000 | 1.0000 | 40% |
| L3 Final | 1.0000 | 1.0000 | — |
| Axis | Result |
|---|---|
| convergence | ✅ PASS |
| uniqueness:users.email | ✅ PASS |
| fk | ✅ PASS |
| cell-level:u1 | ✅ PASS |
| cell-level-strict | ✅ PASS |
| order-invariance | ✅ PASS |
| randomized | ✅ PASS |
| Axis | Result |
|---|---|
| composite_uniqueness | ✅ PASS |
| multi_level_fk | ✅ PASS |
| high_density | ✅ PASS |
| long_run | ✅ PASS |
| Scenario | Duration | Snapshot Hash Match | Assertions |
|---|---|---|---|
| reference | 1.46 ms | ✅ all peers identical | 4 |
| cell-level-strict | 0.51 ms | ✅ all peers identical | 2 |
| chaos:seed=1 | 0.93 ms | ✅ all peers identical | 2 |
| chaos:seed=2 | 2.12 ms | ✅ all peers identical | 2 |
| chaos:seed=3 | 0.85 ms | ✅ all peers identical | 2 |
| chaos:seed=5 | 0.78 ms | ✅ all peers identical | 2 |
| chaos:seed=8 | 0.85 ms | ✅ all peers identical | 2 |
| randomized:seed=101:peers=4:ops=80 | 9.89 ms | ✅ all peers identical | 4 |
| randomized:seed=202:peers=4:ops=80 | 8.76 ms | ✅ all peers identical | 4 |
| randomized:seed=303:peers=4:ops=80 | 9.49 ms | ✅ all peers identical | 4 |
| randomized:seed=404:peers=4:ops=80 | 8.93 ms | ✅ all peers identical | 4 |
| randomized:seed=505:peers=4:ops=80 | 9.25 ms | ✅ all peers identical | 4 |
| randomized:seed=606:peers=4:ops=80 | 8.83 ms | ✅ all peers identical | 4 |
| randomized:seed=707:peers=4:ops=80 | 9.15 ms | ✅ all peers identical | 4 |
| randomized:seed=808:peers=4:ops=80 | 9.14 ms | ✅ all peers identical | 4 |
| stretch:composite_uniqueness | 0.85 ms | ✅ all peers identical | 3 |
| stretch:multi_level_fk | 1.42 ms | ✅ all peers identical | 5 |
| stretch:high_density | 1.44 ms | ✅ all peers identical | 4 |
| stretch:long_run (seed=31415, 1500 ops) | 829 ms | ✅ all peers identical | 3 |
| stretch:long_run (seed=27182, 1500 ops) | 892 ms | ✅ all peers identical | 3 |
Snapshot hashes are bit-identical across all peers (A, B, C) for every scenario — confirming deterministic convergence regardless of sync order.
Multiple writers mutate locally without coordination. Merges converge. Relational invariants survive:
- Cell-level Multi-Value Register conflict resolution (not row-level LWW — the bench explicitly tests for this)
- Uniqueness enforced via an Escrow-First, Resolve-After-Sync protocol — acknowledged coordination, not a hidden server check
- Foreign keys under partition with cascade / tombstone / orphan semantics — one declared policy, applied uniformly
- Secondary indexes derived as deterministic projections of the merged OR-Set state
- Pairwise bidirectional sync with O(writers) vector clock metadata per cell; GC runs on every sync
- SHA-256 snapshot hash is bit-identical across all peers after any sync ordering
The engine ships as a pure-Python embedded library with no build step and one external dependency beyond stdlib.
Anvil-Conflict-Free-Collaborative-OLTP/
├── Anvil-P-E/
│ └── bench-p01-crdt/
│ ├── adapter.py # Adapter ABC — implement this
│ ├── adapters/
│ │ ├── ourteam.py # Our engine adapter (Engine class)
│ │ └── dummy.py # Baseline dummy for reference
│ ├── engine/
│ │ ├── vector_clock.py # VectorClock — O(writers) causal currency
│ │ ├── crdt_cell.py # CRDTCell — causal LWW register with conflict log
│ │ ├── crdt_row.py # CRDTRow — per-column merge, tombstone, fk_status
│ │ ├── crdt_store.py # CRDTStore — OR-Set table store, snapshot hash
│ │ ├── peer.py # Peer — top-level façade wiring all components
│ │ ├── sql_parser.py # SQL parser (regex + sqlglot) for the bench schema
│ │ ├── sql_executor.py # SQL executor — INSERT/UPDATE/DELETE/CREATE TABLE
│ │ ├── sync.py # 6-step bidirectional sync protocol + GC
│ │ ├── uniqueness.py # EscrowLog — Escrow-First uniqueness protocol
│ │ ├── fk_enforcer.py # FKEnforcer — fixed-point FK recheck
│ │ └── interfaces.py # Shared dataclasses
│ ├── scenarios/ # Bench scenario modules (do not modify)
│ ├── run.py # Full L3 bench runner
│ └── harness.py # Bench harness (do not modify)
└── planning/
├── TECHNICAL_ARCHITECTURAL_DEFENSE.md
└── FINAL_BENCHMARK_SUMMARY.md
| Package | Version | Purpose | Install |
|---|---|---|---|
sqlglot |
30.8.0 |
SQL parsing for INSERT/UPDATE/SELECT statements | pip install sqlglot==30.8.0 |
Everything else is Python stdlib: hashlib, json, re, uuid, typing, dataclasses, abc, __future__
The bench harness itself (run.py, harness.py, scenarios/) is stdlib-only, zero external deps — confirmed by the Anvil council spec.
| Package | Version | Purpose |
|---|---|---|
numpy |
≥ 1.20 |
Required only by bench-p04-pcam/ (PCAM problem). P-01 bench does not use numpy. |
| Runtime | Minimum | Tested on |
|---|---|---|
| CPython | 3.11 | 3.11, 3.12 |
No Rust, no C extension, no Docker required for the quickstart.
# requirements.txt — exact pins for a reproducible clean-machine run
sqlglot==30.8.0
Place this file at Anvil-P-E/bench-p01-crdt/requirements.txt before running (or install manually — one line).
Prerequisites: Python ≥ 3.11, pip, git. Nothing else.
# 1. Clone
git clone https://github.com/TechGenDM/Anvil-Conflict-Free-Collaborative-OLTP
cd Anvil-Conflict-Free-Collaborative-OLTP
# 2. Install the one external dependency
pip install sqlglot==30.8.0
# 3. Move into the bench directory
cd Anvil-P-E/bench-p01-crdt
# 4. Run the full L3 bench with our engine
python run.py \
--adapter adapters.ourteam:Engine \
--fk-policy cascade
# Expected last lines:
# ★★★ A N V I L · P - 0 1 · L 3 F I N A L S C O R E ★★★
# ★★★ 1.0000 / 1.0000 (100.0 %) ★★★Total wall time on a commodity laptop: under 90 seconds.
Declare one policy uniformly at run time. Switching mid-run is disqualifying.
# cascade — orphaned children hidden from snapshot (our default, L3-tested)
python run.py --adapter adapters.ourteam:Engine --fk-policy cascade
# tombstone — orphaned children visible; FK column annotated
python run.py --adapter adapters.ourteam:Engine --fk-policy tombstone
# orphan — orphaned children visible; FK column nullified
python run.py --adapter adapters.ourteam:Engine --fk-policy orphanWhy cascade is our declared default: it produces the cleanest snapshot semantics — a deleted parent's children are invisible, matching SQL ON DELETE CASCADE. Tombstone retains more history (useful for audit) but requires downstream query awareness of the tombstoned_parent annotation. We ran L3 under both; cascade achieves 1.0000, tombstone achieves 0.94 due to an FK-axis edge case in the reference scenario.
# Randomized stress — any integers, any count
python run.py \
--adapter adapters.ourteam:Engine \
--fk-policy cascade \
--seeds 9999 31415 27182 16180 11235 42 101
# The bench resists hardcoding: each seed regenerates fresh ops,
# fresh peer assignments, fresh sync schedules.
# A correct engine passes every seed. Ours does.Implement the 7-method contract in adapters/<your_team>.py:
from adapter import Adapter
class Engine(Adapter):
def open_peer(self, peer_id: str) -> None:
"""Initialise an independent peer. Empty state."""
def apply_schema(self, peer_id: str, stmts: list[str]) -> None:
"""Apply DDL statements (CREATE TABLE, CREATE INDEX)."""
def execute(self, peer_id: str, sql: str, params: tuple = ()) -> None:
"""Execute INSERT / UPDATE / DELETE locally. No sync."""
def sync(self, peer_a: str, peer_b: str) -> None:
"""Bidirectional pairwise sync. Symmetric."""
def snapshot_hash(self, peer_id: str) -> str:
"""SHA-256 of the canonical JSON snapshot. Must be bit-identical across peers after sync."""
def snapshot_state(self, peer_id: str) -> dict:
"""{ table_name: [row_dict, ...] } — visible rows only."""
def close(self) -> None:
"""Cleanup."""Our implementation is in adapters/ourteam.py. It reads --fk-policy from sys.argv and passes it to Peer(peer_id, fk_policy=policy) at construction — the policy is then uniform across all operations on that peer.
1. Merge known_peers sets (union) — required for VC pruning to know active peer set
2. Snapshot both stores before any mutation — prevents mid-sync state contamination
3. Bidirectional row exchange: merge_row() → CRDTRow.merge() → CRDTCell.merge()
4. Merge + resolve EscrowLogs on both peers
4b. Post-sync full-table duplicate scan (_resolve_unique_duplicates) — UPDATE collision backstop
5. recheck_all() FK fixed-point on both peers — catches out-of-order FK arrivals
6. VectorClock.prune(active_peers) on every cell — keeps VC size O(writers), not O(writes)
Step 2 is the correctness keystone. Without the pre-merge snapshot, peer_a's merged state contaminates peer_b's base snapshot mid-exchange, breaking commutativity.
- At INSERT time:
EscrowLog.claim(table, cols, vals, peer_id, row_pk)— no network, no lock - At sync time:
EscrowLog.merge()— idempotent union of claim sets - After merge:
EscrowLog.resolve_all()—min(peer_id, row_pk)wins; losers getunique_status='rejected'; their unique columns returnNoneat read time, but the row stays in the store (recoverable)
Composite uniqueness (UNIQUE(a, b)) uses the full value tuple as the claim key — single-column escrow misses this.
Writes are always accepted. FK is a read-side visibility computation. recheck_all() runs a fixed-point loop after every sync: if a parent is tombstoned or itself orphaned, all children cascade to fk_status='orphaned'. Terminates in O(FK chain depth) passes — ≤ 3 on the bench's 3-level schema.
VectorClock.prune(active_peers) removes {peer_id: counter} entries for peers no longer in known_peers. Runs after every sync on every cell clock and tombstone clock. This is what keeps metadata O(writers) and satisfies the bench's metadata-bound requirement.
core_score (weight 0.60):
convergence ✓
uniqueness:users.email ✓
fk ✓
cell-level:u1 ✓
cell-level-strict ✓ ← row-level LWW fails this
order-invariance ✓
randomized ✓
→ core_score = 1.00
stretch_score (weight 0.40):
composite_uniqueness ✓ ← UNIQUE(a,b) — requires full-tuple claim key
multi_level_fk ✓ ← orgs → users → orders, fixed-point iteration
high_density ✓ ← 6 peers insert same email simultaneously
long_run ✓ ← 1500 ops, seeds 31415 + 27182
→ stretch_score = 1.00
l3_final_score = 0.6 × 1.00 + 0.4 × 1.00 = 1.0000
| System | Failure Mode for P-01 |
|---|---|
| Replicache | Server-authoritative on conflict — auto-disqualifying per P-01 spec |
| ElectricSQL | Postgres primary is the source of truth — single coordinator |
| PowerSync | Writes must reach central coordinator to be durable |
| Automerge / Yjs | No secondary index, foreign key, or uniqueness primitive |
| Row-level LWW | Concurrent writes to two columns of same row discard one writer's intent entirely — cell-level-strict bench catches this |
- SQL dialect: restricted to the bench's reference schema (
CREATE TABLE,CREATE INDEX,INSERT,UPDATE,DELETEwith?placeholders andWHERE id = ?). Full SQL (aggregates, subqueries, window functions) is out of scope. - Schema migration under partition: not supported. Identified in the problem statement as the unsolved final boss.
- Uniqueness confirmation latency: a peer cannot confirm a unique insert as fully resolved until it has synced with at least one other peer. This is inherent to the uniqueness coordination requirement and cannot be eliminated without a central authority.
- Tombstone GC: tombstone records persist indefinitely in this implementation. VC pruning shrinks per-tombstone clock size, but the tombstone row itself is retained (required for FK recheck across partition).
Apache-2.0
Phi Continuum · Anvil SST 2026 · P-01 — Conflict-Free Collaborative OLTP
github.com/TechGenDM/Anvil-Conflict-Free-Collaborative-OLTP
