In an Archil transactional-store mock, write the transaction boundary before explaining rollback. A key with a staged value should be readable inside its transaction and unreachable to outside readers until commit.
What to prepare for Archil
Archil describes a managed filesystem interface. Its SWE bank includes an in-memory transactional key-value store. The example focuses on a single transaction overlay so you can discuss the fidelity required by a real persistent store separately. Archil file system product Archil team background
Model one open transaction over a key-value map
Initialize a store with committed keys. Opening a transaction creates an empty staging map. A read first checks staging. Rollback discards staging; commit applies all staged writes. Only one active transaction is allowed. The sample does not include concurrent clients. Related PracHub question
class Store:
def __init__(self, data):
self.committed = dict(data)
self.stage = None
def begin(self):
if self.stage is not None:
raise ValueError('active transaction')
self.stage = {}
def get(self, key):
if self.stage is not None and key in self.stage:
return self.stage[key]
return self.committed.get(key)
def put(self, key, value):
if self.stage is None:
raise ValueError('no transaction')
self.stage[key] = value
def finish(self, commit):
if self.stage is None:
raise ValueError('no transaction')
if commit:
self.committed.update(self.stage)
self.stage = None
store = Store({'a': 'old'})
store.begin()
store.put('a', 'new')
assert store.get('a') == 'new' and store.committed['a'] == 'old'
store.finish(False)
assert store.get('a') == 'old'
store.begin()
store.put('a', 'new')
store.finish(True)
assert store.get('a') == 'new'
Expected O(1) for a read and write and O(staged keys) for commit. A dictionary assignment is not a durable commit. A filesystem-backed solution might log intent and recovery state, with reporting tied to the actual atomic boundary.
A follow-up to work through
Write key A as new inside a transaction and show that a reader of the committed map still sees previous. Roll back and confirm no staging survives. Then discuss crash recovery when a commit finished but the response was lost. Workload tests should distinguish atomic visibility and durability across process loss.
def recover(committed, attempt):
return 'committed' if attempt in committed else 'unknown'
assert recover({'p1'}, 'p1') == 'committed'
assert recover({'p1'}, 'p2') == 'unknown'
What to bring to a mock interview
Bring a project story with a published result and intermediate state. Explain which read paths could see partial work and what your fix guaranteed.