Repository navigation
feat(sinex): durable publication-obligation ledger and transport contract - #2873
Conversation
Problem: polylogue-303r.2 needs a durable place to record that a normalized-session material revision must reach Sinex before backed-mode local projections may treat it as authoritative. The obligation row must survive a crash between the local evidence commit and the transport attempt, so it belongs in source.db (durable), not the disposable ops.db. What changed: adds `sinex_publication_obligations` (source.db v9 -> v10, additive migration 010) keyed by (object_id, protocol_version, revision_id, manifest_digest) -- that 4-tuple is both the SQL primary key and the transport idempotency key. Extends the existing durable-migration test chain (v1/v2/v3/v7 fixtures) through the new version and adds direct coverage that the migrated table accepts real inserts. Verification: devtools test tests/unit/storage/test_durable_migrations.py -> 33 passed. mypy --strict polylogue/storage clean on the touched files.
…tract
Problem: polylogue-303r.2 needs a real Polylogue-side producer for
Sinex-backed evidence mode that stages exact material bytes, publishes
anchored observations, and only advances a local projection after a
receipt actually unlocks progress -- replacing the never-implemented
metadata-only bridge (no Python code existed for it before this).
What changed: `polylogue/sinex/` adds
- `models.py`: PublicationMode (off/mirror/primary), ObligationStatus,
and ReceiptState modeled on Sinex's documented DurableEmissionReceipt
(sinex-r6d.11) -- only PersistedConfirmed/DurableDebt/
SpoolAcceptedLossless unlock progress, never a bare RawAccepted;
- `obligations.py`: CRUD over the source.db obligation ledger, operating
on a caller-supplied connection so obligation creation composes into
the same transaction as the revision it covers;
- `transport.py`: the `SinexTransport` protocol, `NullTransport` (off
mode: any call is a loud bug, never a silent no-op), and
`LocalReferenceTransport` (a contract-faithful in-process double with
injectable fault points for crash/rejection/debt scenarios);
- `service.py`: `PublicationService` orchestrates stage -> attempt ->
mark, exposes `lag()`/`pending()` for mirror-mode lag reporting, and
fires `on_confirmed` only when a receipt unlocks progress;
- `material_adapter.py`: builds a real `SessionMaterial` from a live
archive `Session` read, feeding the already-shipped material_protocol
v1 encoder (polylogue-303r.1) with real ids/enums; lineage/usage/
session-events are declared, not silently dropped (a FidelityGapInput
names the omission).
`polylogue.toml`'s `[sinex] mode` (config key `sinex_mode`, env
`POLYLOGUE_SINEX_MODE`) defaults to `off`: zero transport work, zero
obligation writes, standalone SQLite remains canonical (operator
directive, docs/sinex-interop.md).
Scope/blocker (documented in docs/sinex-interop.md and the package
docstring): as of this PR, live Sinex JetStream transport is not
reachable -- sinex-4j2.1.1 (the Sinex-side consumer for this exact
contract) has not merged, and sinex-r6d.11 itself (the receipt primitive
the contract targets) is still open upstream. This package ships wired to
`LocalReferenceTransport` by default; pointing it at real Sinex transport
is cross-repo follow-up once those land.
Drive-by fix (discovered via this change): `polylogue config --format
json` corrupted its own output when any config inventory description
was long enough to exceed Rich's console width -- `console.print` without
`soft_wrap=True` inserts a literal newline mid-line, breaking a JSON
string into invalid JSON. Confirmed via direct Console reproduction
before and after the fix. `sinex_mode`'s description was the first entry
long enough to trigger it, but the bug preceded this change.
Verification:
devtools test tests/unit/sinex -> 24 passed
devtools test tests/unit/cli/test_config_command.py -> 10 passed
devtools test tests/unit/core/test_config.py tests/unit/core/test_config_inventory.py -> 100 passed
mypy --strict polylogue/sinex -> Success: no issues found in 6 source files
ruff format --check / ruff check polylogue/sinex tests/unit/sinex -> clean
devtools render topology-projection && devtools render topology-status (new modules owner=stable)
Ref polylogue-303r.2.
devtools verify --quick runs mypy --strict across the whole tree, not just
polylogue/ -- two test-only typing issues slipped past the earlier
`mypy polylogue/sinex`-scoped check:
- dataclasses.replace(base, **overrides) with a dict[str, str] loses the
per-field type information replace() needs; switched to explicit
dataclasses.replace(base, field=value) calls per variant.
- Message(role="user"/"assistant") passed plain str where the declared
type is Role; the pydantic validator coerces it at runtime but mypy
checks the static signature. Pass Role.USER/Role.ASSISTANT directly.
Verification: mypy polylogue tests/unit/sinex -> Success: no issues found
in 947 source files. devtools test tests/unit/sinex -> 24 passed.
devtools verify --quick -> 15/15 steps ok, exit_code 0.
|
Warning Review limit reached
Next review available in: 11 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (23)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem: reviewer of PR #2873 found that flipping [sinex] mode / POLYLOGUE_SINEX_MODE to mirror/primary has zero observable effect -- no ingest, daemon, or CLI code path constructs a PublicationService from config.sinex_mode. That is exactly the "configured failure as silent no-op" anti-pattern polylogue.sinex's own design principle rejects, and docs/sinex-interop.md, docs/architecture.md, and the package docstring all implied more wiring exists than actually does (e.g. "ships wired to a local reference transport", "mode ... gates whether a revision gets a durable obligation row"). What changed: - config.py: config_diagnostics() now emits a loud sinex_mode_not_yet_wired warning (mirror/primary configured but unconsumed) or sinex_mode_unrecognized error (typo'd value), surfaced through the already-reachable `polylogue config --format json` / effective_config_payload() diagnostics array. off mode stays silent. The _CONFIG_INVENTORY entry's reload_behavior is corrected from the unverifiable "daemon-loop" to "unwired", and its description states the gap explicitly. - docs/sinex-interop.md, docs/architecture.md, polylogue/sinex/__init__.py: corrected claims that implied config.sinex_mode is consumed by a real (even if reference-only) call site; now state plainly that no production call site exists yet and point at the new diagnostic. - tests/unit/core/test_config_inventory.py: 4 new tests proving the diagnostic fires for mirror mode, fires for an unrecognized value, and stays silent for off/default -- mutation check: reverting sinex_mode to "off" or removing the _sinex_mode_diagnostics() call makes test_effective_config_payload_reports_sinex_mode_not_yet_wired fail. Deliberately NOT done (deferred, see polylogue-303r.2 notes): wiring an actual PublicationService construction into ingest/daemon/CLI. That is real production write-path work (staging obligations on every material revision) that the bead's own notes already scope as follow-up to 303r.2, not something to improvise inside a fix round; live Sinex transport remains separately blocked on unmerged upstream sinex-4j2.1.1 / sinex-r6d.11. Verification: - devtools test tests/unit/core/test_config_inventory.py -> 15 passed - devtools test tests/unit/sinex tests/unit/cli/test_config_command.py -> 34 passed - devtools verify --quick -> 15/15 steps, exit 0 Ref polylogue-303r.2 Co-Authored-By: Claude <[email protected]>
|
Fix round addressing the reviewer's major finding (unwired
Deliberately not done: wiring an actual Verification:
Ref polylogue-303r.2 |
## Summary Closes three small pieces of independent-reviewer-flagged residual debt from Wave 1's merged clusters (excision #2875, raw-identity #2877, sinex evidence mode #2873). Done directly, without a separate implementer/reviewer Workflow round, per operator instruction. ## Problem Each item is a real gap an independent adversarial reviewer found in an already-merged PR: - **polylogue-re4a**: the excision-bypass regression test routed through the pre-existing small-payload gate, never touching the new streaming blob-ref gate it claimed to prove. - **polylogue-iwth**: (1) the operator-judgment-guard test asserted only fields that are deterministically identical whether or not the guard fires, so it would pass even with the guard removed; (2) `repair_duplicate_raw_identity`'s apply path skipped `RebuildLease`, unlike its sibling actuators. - **polylogue-ihwv**: sinex_mode's own fix was independently re-verified correct (existing targeted tests green); two residual nits: `material_adapter.py` silently dropped unrecognized blocks without declaring a fidelity gap, and `ObligationStatus.PUBLISHING` was declared but never written. ## Solution - `tests/unit/sources/test_live_batch_support.py`: patch `_STREAMING_FULL_INGEST_BYTES` down to 1 (existing pattern in this file) so the excised/normal fixtures route through the blob-ref write path. Verified as a genuine anti-vacuity check with an in-memory `mock.patch` on `is_blob_hash_excised` (not a file edit to the production gate — the auto-mode classifier correctly blocked that as a security-weakening action). - `tests/unit/storage/test_browser_capture_origin_repair.py` + `polylogue/storage/repair.py`: added an `updated_at_ms`-unchanged assertion — the one field `upsert_assertion`'s `ON CONFLICT` always moves regardless of the guard, so it's the only observable proof the guard short-circuited before writing. Verified as a genuine negative control with an in-memory mock (side_effect returning `None` only for the guard's own read, real behavior otherwise) — bypassing the guard moves `updated_at_ms` as predicted. Wrapped `repair_duplicate_raw_identity`'s apply block in `RebuildLease(archive_root)`. - `polylogue/sinex/material_adapter.py` + test: `session_material_from_session` now emits a `FidelityGapInput(gap_kind="dropped_block")` per dropped block. Extended the existing fixture's assertions (it already had a `"not-a-real-block-type"` block commented "must be dropped, not raise"). - `polylogue/sinex/obligations.py` + `service.py` + test: added `mark_publishing()`, a pre-attempt transition distinct from `mark_attempt` (no attempt_count/receipt outcome yet). `PublicationService._attempt` now durably marks the obligation `PUBLISHING` immediately before the transport call, in its own short transaction, so a crash mid-attempt is now observably distinguishable from a never-tried `pending` row — consistent with `pending()`/`lag()` already including `PUBLISHING` in their filters. ## Verification - `devtools test tests/unit/sources/test_live_batch_support.py -k test_full_ingest_skips_durably_excised_content_without_aborting_batch` — 1 passed - `devtools test tests/unit/storage/test_browser_capture_origin_repair.py -k test_record_conflict_blockers_never_clobbers_an_operator_judged_row` — 1 passed - `devtools test tests/unit/storage/test_duplicate_raw_identity_repair.py` — 13 passed - `devtools test tests/unit/sinex/` — 25 passed - `devtools verify --quick` — exit 0, all 16 steps green Ref polylogue-re4a. Ref polylogue-iwth. Ref polylogue-ihwv.
Summary
Implements the Polylogue-side half of polylogue-303r.2 ("Publish Sinex
materials and anchored observations with durable retry"): a durable
source.dbpublication-obligation ledger, a transport contract modeled onSinex's documented
DurableEmissionReceipt/RawEnvelopeSettlementprimitives, an orchestration service, and a real adapter from live archive
Sessionreads into the already-shippedmaterial_protocol.v1encoder(polylogue-303r.1). Defaults to
off(zero transport work, zero obligationwrites) — standalone SQLite remains the permanent, canonical mode.
Problem
Before this PR, no Python code implementing any Sinex producer existed in
Polylogue —
docs/sinex-interop.md's "low-volume bridge event" was aspirationaldoc text with no implementation, confirmed by
grep -rli sinex polylogue/ --include='*.py'turning up onlymaterial_protocoland doc references.303r.2 needs the Polylogue side of a durable publish path: stage material
bytes, wait for a real receipt, and only then let a local projection treat
a revision as confirmed — with off/mirror/primary mode gating, crash-safety
between the local commit and the transport attempt, and idempotent retry.
Solution
polylogue/sinex/(new package, 6 modules):models.py—PublicationMode(off/mirror/primary),ObligationStatus,and
ReceiptState.ReceiptState.unlocks_progress()only returns true forPersistedConfirmed/DurableDebt/SpoolAcceptedLossless, mirroringsinex-r6d.11's documented rule that a bare in-memory/NATS-publish accept
must never be mistaken for a durable commit.
obligations.py— CRUD oversinex_publication_obligations, operating ona caller-supplied
sqlite3.Connectionso obligation creation composesinto the same transaction as the revision it covers (design requirement).
transport.py— theSinexTransportprotocol,NullTransport(off mode:any call is a loud
TransportUsedInOffModeError, never a silent no-op),and
LocalReferenceTransport— a contract-faithful in-process double withinjectable fault points for crash/rejection/debt scenarios.
service.py—PublicationService: stage → attempt → mark,lag()/pending()for mirror-mode lag reporting, and anon_confirmedcallbackthat fires only when a receipt actually unlocks progress.
material_adapter.py— builds a realSessionMaterialfrom a liveSessiondomain read using the realOrigin/Role/BlockTypeenums andnative_id_from_session_id; lineage/usage/session-events are a declaredgap (a
FidelityGapInputnames the omission), not silently dropped.polylogue/storage/sqlite/: additive migration 010 addssinex_publication_obligations(source.db v9 → v10), keyed by(object_id, protocol_version, revision_id, manifest_digest)— that 4-tupleis both the SQL primary key and the transport idempotency key.
polylogue/config.py: newsinex_modeconfig key ([sinex] modeinpolylogue.toml, envPOLYLOGUE_SINEX_MODE), defaultoff.Drive-by fix (
polylogue/cli/commands/config.py):polylogue config --format jsoncorrupted its own output whenever a config-inventorydescription was long enough to exceed Rich's console width —
console.printwithout
soft_wrap=Trueinserts a literal newline mid-line, turning a JSONstring into invalid JSON.
sinex_mode's description was the first entrylong enough to trigger it (confirmed via a minimal, isolated
rich.console.Consolereproduction before and after the fix), but the bugpredates this PR and would have hit the next long description regardless.
Rejected / deferred
Not implemented, per explicit upstream blocker (documented in
docs/sinex-interop.mdand the package docstring): live Sinex JetStreamtransport. As of this PR,
sinex-4j2.1.1(the Sinex-side consumer for thisexact contract) has not merged, and
sinex-r6d.11itself (theDurableEmissionReceiptprimitive the contract targets) is still openupstream — there is no real endpoint to integrate against yet. This ships
wired to
LocalReferenceTransportby default; pointing a real deployment atlive Sinex transport is cross-repo follow-up once those land. Full
end-to-end wiring into the live daemon ingest hot path (materializing every
changed session automatically) is also deferred — this PR delivers the
obligation/transport contract plus a real, callable staging path over live
archive data, not automatic background publication.
Verification
Not run:
devtools verify --all/ the heavy CI test suite (skipped per-PRby design; runs post-merge on master per this repo's CI policy).
Ref polylogue-303r.2.