Repository navigation
feat(annotations): persist durable labeling provenance (#2765) - #2765
Conversation
Problem Typed annotation schemas were process-local, and independent labeling runs could overwrite the same assertion identity. A restart could not recover the construct definition or trace a label to its batch-level actor, prompt, source result, and validation accounting. What changed Advance user.db to schema version 6 through an additive verified-backup migration. Persist canonical fingerprinted schema definitions, register the concrete delegation-discourse schema, and store immutable annotation batch provenance. Scope assertion identities to declared batch ObjectRefs and expose focused ArchiveStore reads for schema and batch metadata. Compatibility Existing user.db v5 archives require the normal authenticated backup receipt before migration. JSONL, CLI, and MCP import remain in polylogue-rxdo.7.2; structural target joins remain in polylogue-kmts. Verification - devtools test focused annotation schema/write/storage and user migration routes: 80 collected, 78 passed before the shared SQL-comment fix; the two migration routes then passed, and the final durable route rerun passed 6/6 - devtools lab policy schema-versioning: schema evolution policy intact - devtools verify --quick: all 15 steps passed - git diff --check: clean Ref polylogue-rxdo.7.1 Co-Authored-By: Claude <[email protected]>
Problem: The durable annotation-schema batch introduced canonical identities, but fresh import order, public ref resolution, Python-equal JSON values, and post-judgment assertion retries still left coherence gaps. Nested mutable provenance could also change the bytes written after construction. What changed: Make the storage import boundary lazy, resolve durable annotation-batch refs through the archive facade, and compare schemas and batches by canonical definitions. Capture batch provenance as an immutable snapshot, reject NFC key collisions, validate persistence inputs, and preserve insert-once assertion state across exact retries and operator judgment. Strengthen durable migration, cold-reopen, corruption, and alias tests. Verification: - devtools test tests/unit/annotations/test_durable_storage.py tests/unit/storage/test_user_annotations_import.py (16 passed) - devtools verify --quick (all 15 steps passed) - devtools lab policy schema-versioning (policy intact) - fresh adversarial closure review: NO LEGITIMATE GAPS Ref polylogue-rxdo.7.1 Co-Authored-By: Claude <[email protected]>
Problem: annotation-batch ref resolution returned complete assertion and validation collections, arbitrary JSON documents, and duplicated every assertion in top-level object refs. Large durable batches therefore violated the bounded public-ref contract. Project complete repository rows into capped public samples with exact totals and omissions. Represent arbitrary JSON as byte-bounded canonical prefixes with exact byte counts and SHA-256 identities, and surface explicit truncation caveats while preserving full repository reads. Co-Authored-By: Claude <[email protected]>
Correct the merged foundation reference and persist the bounded public-ref repair plus current-master verification receipts for polylogue-rxdo.7.1. Co-Authored-By: Claude <[email protected]>
Normalize declaration strings before validation and snapshot caller-owned field, enum, and target-kind sequences into immutable tuples. Hot registry behavior now matches the canonical cold-reopen definition, while NFC collisions and post-registration list mutation fail closed. Co-Authored-By: Claude <[email protected]>
Represent public annotation provenance strings as fixed-budget previews with exact UTF-8 totals and digests. Bound JSON previews, omit unsafe top-level refs and actions when their authority is clipped, and report every count or value truncation while preserving complete durable repository reads. Co-Authored-By: Claude <[email protected]>
Problem: Oversized missing or malformed annotation-batch refs could be echoed through unresolved responses. Canonical provenance also normalized opaque ObjectRef ids, and schema declarations deferred lone-surrogate failures until fingerprinting. What changed: Return a bounded digest descriptor for oversized batch-like misses, preserve exact ObjectRef UTF-8 identity through durable hot/cold replay, and reject invalid declaration Unicode at construction. Add production-route regressions for each boundary. Verification: devtools test <14 focused annotation/API cases> devtools verify --quick (15/15 steps) Co-Authored-By: Claude <[email protected]>
Problem: Python public-ref inputs may contain lone surrogates even though UTF-8, JSON, and SQLite cannot represent them. The oversized-ref helper returned no descriptor for that case, allowing annotation-batch lookup to raise. What changed: Validate ref Unicode before parsing or opening the archive. Invalid inputs now return a fixed-size digest descriptor based on surrogatepass bytes, with exact code-point count and no raw input echo. Verification: devtools test <2 focused production resolver cases> devtools verify --quick (15/15 steps) Co-Authored-By: Claude <[email protected]>
Record the five-pass adversarial audit, the final bounded-ref repairs, and the exact focused and quick verification receipts for rxdo.7.1. Keep the deferred JSONL/MCP and structural-join scope explicit. Co-Authored-By: Claude <[email protected]>
|
Warning Review limit reached
Next review available in: 55 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 (4)
📝 WalkthroughWalkthroughChangesAnnotation durability
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant AnnotationWriter
participant ArchiveStore
participant UserAnnotations
participant UserSQLite
participant ArchiveFacade
AnnotationWriter->>ArchiveStore: save_annotation_schema(schema)
ArchiveStore->>UserAnnotations: persist_annotation_schema(schema)
UserAnnotations->>UserSQLite: insert or verify canonical definition
AnnotationWriter->>ArchiveStore: save_annotation_batch(batch)
ArchiveStore->>UserAnnotations: persist_annotation_batch(batch)
UserAnnotations->>UserSQLite: insert or verify canonical provenance
ArchiveFacade->>ArchiveStore: get_annotation_batch(batch_id)
ArchiveStore-->>ArchiveFacade: batch or missing result
ArchiveFacade-->>AnnotationWriter: bounded annotation-batch payload
Possibly related issues
Suggested labels: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 80b086a161
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/internals.md`:
- Around line 140-145: Update the User schema version 6 documentation to
identify the registered delegation schema as `delegation.discourse@v1`,
replacing the noncanonical `delegation-discourse v1` wording while preserving
the surrounding migration and table details.
In `@polylogue/storage/sqlite/migrations/user/006_annotation_schemas_batches.sql`:
- Around line 7-22: Update the definition_json CHECK constraint in
annotation_schemas to use IS instead of = for both json_extract comparisons
against schema_id and schema_version. Preserve the existing JSON validity and
object checks while ensuring missing or mismatched schema_id/version values fail
validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e7ff3423-c559-48a4-92ab-642a726416fa
📒 Files selected for processing (27)
.beads/issues.jsonlCLAUDE.mddocs/archive-backup.mddocs/internals.mddocs/plans/layering.yamldocs/plans/topology-target.yamldocs/schema.mddocs/topology-status.mdpolylogue/annotations/__init__.pypolylogue/annotations/batch.pypolylogue/annotations/schema.pypolylogue/annotations/write.pypolylogue/api/archive.pypolylogue/cli/commands/status.pypolylogue/core/refs.pypolylogue/storage/sqlite/archive_tiers/archive.pypolylogue/storage/sqlite/archive_tiers/user.pypolylogue/storage/sqlite/archive_tiers/user_annotations.pypolylogue/storage/sqlite/migrations/user/006_annotation_schemas_batches.sqlpolylogue/surfaces/payloads.pytests/unit/annotations/test_durable_storage.pytests/unit/annotations/test_schema.pytests/unit/api/test_facade_contracts.pytests/unit/core/test_refs.pytests/unit/storage/test_archive_tiers_assertions.pytests/unit/storage/test_durable_migrations.pytests/unit/storage/test_user_annotations_import.py
Keep public annotation-batch references lossless when their object id ends with a colon, and retain the established mutable upsert behavior for assertions that are not batch-bound.\n\nAdd regression coverage for both contracts.\n\nCo-Authored-By: Claude <[email protected]>
Make the durable annotation schema CHECK reject missing JSON identity keys in both fresh DDL and the v6 migration, and document the canonical registered schema identifier.\n\nRegression coverage exercises migrated and fresh user tiers.\n\nCo-Authored-By: Claude <[email protected]>
Summary
Persist versioned annotation schemas and independent annotation-batch provenance in the durable user tier. The change registers the concrete
delegation.discourse@v1schema, keeps complete repository reads, and exposes byte-bounded public batch-reference payloads.Problem
The typed annotation foundation remained process-local: schema identity could drift across restarts, batches for the same target were not independently attributable, and public reference resolution could reflect arbitrarily large opaque values. Durable provenance also needed exact retry semantics without normalizing opaque ObjectRef identity.
Solution
annotation_schemasandannotation_batches, with canonical fresh-DDL parity and backup-manifest coverage.annotation-batch:refs through full durable reads while projecting bounded previews with exact counts, omitted-byte evidence, SHA-256 descriptors, and fixed-size invalid-Unicode fallbacks.Built on the typed foundation from PR #2757. Ref
polylogue-rxdo.7.1.Acceptance criteria
delegation.discourse@v1is registered.Deferred: JSONL/CLI/MCP batch import remains
polylogue-rxdo.7.2; structural target joins remainpolylogue-kmts.Verification
devtools test ...— 155 focused durable/schema/ref/migration/public-route tests passed; run20260712T152900Z-focused-test-3014481-3ad91648.20260712T160837Z-focused-test-3325379-546339d8.devtools verify --quick— 15/15 passed; run20260712T161026Z-quick-3331317-d0b5478e.devtools lab policy schema-versioning— 0 derived helpers, 0 invalid durable migrations..agent/scripts/bd-graph-lint— no cycles; only inherited missing-AC findings forpolylogue-2ilzandpolylogue-nu2h.git diff --check— clean.The default testmon selection expanded to 14,730 tests because
surfaces/payloads.pyis a dependency hub, so it was aborted rather than turned into a blanket suite run.devtools verify --allwas not run.Adversarial review
Five independent passes found and drove repairs for mutable schema aliases, NFC key collisions, hot/cold schema divergence, count-only response caps, unbounded missing refs, opaque-ref normalization, and invalid-Unicode escape paths. The fifth pass reported no other legitimate gaps after isolating its final lone-surrogate blocker; that blocker is fixed and regression-pinned.
Summary by CodeRabbit
annotation-batchreference resolution with bounded previews and truncation/caveat reporting.annotation-batchreferences.