Skip to content

fix(schemas): run semantic role annotation before privacy threshold (#800) - #887

Merged
Sinity merged 1 commit into
masterfrom
feature/fix/schema-drift-800
May 7, 2026
Merged

Sinity merged 1 commit into
masterfrom
feature/fix/schema-drift-800

Conversation

@Sinity

@Sinity Sinity commented May 7, 2026

Copy link
Copy Markdown
Owner

Swap annotation order so semantic roles are classified before privacy threshold applies. 1 file +2/-2. All gates passed.

…800)

Swap _annotate_schema and _annotate_semantic_and_relational so
semantic roles (message_role) are annotated before the privacy
threshold (min_conversation_count=3) runs. This ensures role fields
are visible when the privacy threshold evaluates them.

Previously the privacy threshold could suppress fields before
semantic role detection had a chance to classify them.

Co-Authored-By: Claude Opus 4.7 <[email protected]>
Copilot AI review requested due to automatic review settings May 7, 2026 08:01
@Sinity
Sinity merged commit b7d9e6e into master May 7, 2026
@Sinity
Sinity deleted the feature/fix/schema-drift-800 branch May 7, 2026 08:01
@coderabbitai

coderabbitai Bot commented May 7, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@Sinity has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 24 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 276f0ba4-6502-4665-ac43-1e8790b65f99

📥 Commits

Reviewing files that changed from the base of the PR and between e87e000 and 0bd2c2a.

📒 Files selected for processing (1)
  • polylogue/schemas/generation/schema_builder.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix/schema-drift-800

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the schema generation pipeline so semantic-role/relational annotations are applied before field-stat annotations that enforce privacy-related filtering, ensuring semantic classification runs on the fullest available field stats before privacy thresholds affect downstream annotations.

Changes:

  • Reordered cluster schema annotation steps to run _annotate_semantic_and_relational() before _annotate_schema() (which applies privacy-config filtering).
  • Moved pin loading earlier to support semantic-role selection prior to privacy-aware annotation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sinity added a commit that referenced this pull request May 7, 2026
Two-line ordering fix in
`polylogue/schemas/generation/schema_builder.py`. The
schema-generation pipeline applied the cross-conversation
privacy threshold before semantic-role annotation, so values
that should have been protected by the
`x-polylogue-semantic-role="message_role"` exemption (record
types like `attachment`, `system`, `permission-mode`) were
dropped before the annotator could mark them as structural.
Reorders the steps so semantic-role classification runs first.
PR #921 builds on this with the structural-role exemption
logic.

Refs #800
Sinity added a commit that referenced this pull request May 7, 2026
Three targeted fixes building on PR #887's schema-pipeline
reordering:

1. Fields tagged `x-polylogue-semantic-role="message_role"` now
   bypass the cross-conversation privacy threshold
   (`min_conversation_count=3` becomes 1) so structural protocol
   record-type tokens like `attachment`, `custom-title`,
   `file-history-snapshot`, `last-prompt`, `permission-mode`,
   `queue-operation`, `system` survive schema generation.
2. `detect_drift()` is now wired into `devtools schema-audit
   --check-drift` via a new `check_schema_drift()` audit check
   that loads samples from the archive DB and runs drift
   detection against committed schemas. The function existed but
   no audit tool ever called it.
3. `tests/unit/core/test_schema_privacy.py`:
   `TestStructuralRoleExemption` proves `message_role` values
   survive `min=3` while non-role fields stay filtered.

End-to-end schema regeneration from live data and full
schema-promote remain blocked on the blob-store work in #818.

Refs #800
Sinity added a commit that referenced this pull request May 7, 2026
Two-line ordering fix in
`polylogue/schemas/generation/schema_builder.py`. The
schema-generation pipeline applied the cross-conversation
privacy threshold before semantic-role annotation, so values
that should have been protected by the
`x-polylogue-semantic-role="message_role"` exemption (record
types like `attachment`, `system`, `permission-mode`) were
dropped before the annotator could mark them as structural.
Reorders the steps so semantic-role classification runs first.
PR #921 builds on this with the structural-role exemption
logic.

Refs #800
Sinity added a commit that referenced this pull request May 7, 2026
Three targeted fixes building on PR #887's schema-pipeline
reordering:

1. Fields tagged `x-polylogue-semantic-role="message_role"` now
   bypass the cross-conversation privacy threshold
   (`min_conversation_count=3` becomes 1) so structural protocol
   record-type tokens like `attachment`, `custom-title`,
   `file-history-snapshot`, `last-prompt`, `permission-mode`,
   `queue-operation`, `system` survive schema generation.
2. `detect_drift()` is now wired into `devtools schema-audit
   --check-drift` via a new `check_schema_drift()` audit check
   that loads samples from the archive DB and runs drift
   detection against committed schemas. The function existed but
   no audit tool ever called it.
3. `tests/unit/core/test_schema_privacy.py`:
   `TestStructuralRoleExemption` proves `message_role` values
   survive `min=3` while non-role fields stay filtered.

End-to-end schema regeneration from live data and full
schema-promote remain blocked on the blob-store work in #818.

Refs #800
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants