Slice 103: Sync Policy Boundaries
Scope#
Split workflows/sync/policy.py into a facade over focused deterministic
policy modules:
snapshots.pyowns transcript snapshot reading, line counting, and content hashes.entries.pyowns ledger-entry state transitions.identity.pyowns workspace/session/ledger identity helpers.decisions.pyowns cursor decisions and pending-run reconciliation.reporting.pyowns skip/start summary row construction.guidance.pyowns generated Ingest title and cursor guidance.policy.pyremains the import facade used bySyncWorkflow.
Out Of Scope#
- No sync behavior changes.
- No ledger schema changes.
- No background-job policy changes.
- No new automation behavior.
Design Notes#
Slice 95 correctly separated sync orchestration from deterministic sync policy. The current pressure is inside that policy module: it now mixes transcript IO, cursor hashing, ledger identity, pending reconciliation, transition builders, summary row construction, and prompt guidance in one 417-line file.
Cosmic Python's service-layer chapter distinguishes orchestration from lower
level behavior: it says an application service "drives the application by
following a bunch of simple steps" and warns that putting too much logic into
the service layer can produce an anemic domain
(docs/reference/cosmic-python/chapter_04_service_layer.md). For CodeAlmanac,
SyncWorkflow should continue to drive the use case; the deterministic sync
rules should have names that match their reasons to change.
Files#
src/codealmanac/workflows/sync/policy.pysrc/codealmanac/workflows/sync/snapshots.pysrc/codealmanac/workflows/sync/entries.pysrc/codealmanac/workflows/sync/identity.pysrc/codealmanac/workflows/sync/decisions.pysrc/codealmanac/workflows/sync/reporting.pysrc/codealmanac/workflows/sync/guidance.pytests/test_architecture.pydocs/python-port-live-agreement.mddocs/python-port/ownership-map.mddocs/python-port/idea-evolution.mddocs/python-port/next-agent-brief.mddocs/python-port/verification-matrix.mddocs/python-port/worklog.md
Tests#
- Architecture guard: sync service remains orchestration-only and sync policy stays split by rule family.
- Focused sync workflow tests for status, foreground run, background run, and pending reconciliation.
- Public CLI dogfood for
sync statusagainst a temp transcript if practical; otherwise focused service tests remain the behavior proof. - Full
uv run pytest. - Full
uv run ruff check ..