3 Commits

Author SHA1 Message Date
cleveragents-auto ee1ec2b56d chore: worker ruff auto-fix (pre-push lint gate) 2026-05-29 07:21:08 -04:00
HAL9000 5ede1c018a fix(server,sync): use A2aRequest.method not .operation in tests and helpers
The new entity-sync feature introduced A2aRequest with a `method` field
(JSON-RPC 2.0 wire format), but several test/helper files used the wrong
field name `operation` when constructing requests or logging, and checked
non-existent `.status`/`.data` attributes on A2aResponse instead of
`.result`/`.error`.

Fixes:
- asgi_app.py: log `a2a_request.method`, not `.operation` (typecheck error)
- server_lifecycle_steps.py: send `method` key in JSON-RPC payload; look
  up status in `result` dict, not top-level response body
- server_lifecycle.feature: expect "healthy" (what the handler returns),
  not "ok"
- entity_sync_steps.py: construct A2aRequest(method=...) not (operation=...);
  assert on .result/.error instead of .status/.data
- robot/helper_entity_sync.py: same method= and result/error fixes across
  sync_pull, sync_push, sync_status, sync_facade_no_service helpers
- robot/helper_server_lifecycle.py: same method= and result path fixes

ISSUES CLOSED: #1125
2026-05-29 07:21:08 -04:00
freemo ff9c6540a2 feat(server): entity sync (_cleveragents/sync/*)
Implement entity synchronization between client and server using
the _cleveragents/sync/* A2A extension methods per the specification.

Sync models (src/cleveragents/a2a/sync_models.py):
- Pydantic v2 models for pull/push/status requests and responses
- VectorClock with increment, merge, happens-before, and concurrency
  detection for distributed conflict detection
- SyncEntitySnapshot, SyncConflict, SyncState, SyncQueueEntry models
- SyncEntityType enum: actor, skill, action, plan, session
- ConflictResolution enum: last_writer_wins, manual, server_wins,
  client_wins

SyncService (src/cleveragents/application/services/sync_service.py):
- pull(): download server namespace entities to local cache with
  incremental sync (since timestamps) and force-overwrite option
- push(): push local entity definitions to server namespace with
  configurable conflict resolution strategy
- status(): compare local and server entity versions, detect drift,
  report local-ahead, server-ahead, and concurrent conflicts
- resolve_conflict(): manually resolve detected conflicts with
  winner selection (local or server)
- Offline queue: enqueue_offline() and process_offline_queue() for
  retry on reconnect, with max-retries enforcement
- The local/ namespace is never synced per specification

A2A facade (src/cleveragents/a2a/facade.py):
- Replaced sync stub handlers with real _handle_sync_pull,
  _handle_sync_push, _handle_sync_status routing to SyncService
- Added sync_service property and TYPE_CHECKING import
- Facade returns stubs when no SyncService is registered

Tests:
- Behave BDD: features/entity_sync.feature (65 scenarios, 247 steps)
  covering models, vector clocks, pull/push/status, conflict resolution,
  offline queue, facade integration, constructor validation, edge cases
- Robot Framework: robot/entity_sync.robot (8 integration tests)

ISSUES CLOSED: #866
2026-05-29 07:21:08 -04:00