Skip to content

refactor: renew privacy audit runtime contracts (#369) - #369

Merged
Sinity merged 2 commits into
masterfrom
feature/refactor/privacy-audit-runtime-contracts
Apr 22, 2026
Merged

Sinity merged 2 commits into
masterfrom
feature/refactor/privacy-audit-runtime-contracts

Conversation

@Sinity

@Sinity Sinity commented Apr 22, 2026

Copy link
Copy Markdown
Owner

Summary

Renew the non-CLI privacy, audit, runtime, query, and prepare helper contracts named in #281.

Closes #281

Problem

The remaining utility/runtime precision tranche was no longer mostly missing annotations; it was still broad at semantic boundaries. Privacy config behavior was described through duplicate partial protocols, schema audit and redaction JSON payloads were assembled as inline dictionaries, runner dispatch returned opaque objects even when the authored execution was runner-backed, SQL pushdown params were exposed as dict[str, object], query sorting consumed the full query plan instead of the actual sort/window surface, and prepare persistence depended on the concrete repository class.

Solution

  • Added a shared SchemaPrivacyConfig protocol and routed schema generation privacy helpers through it.
  • Added typed payload surfaces for OutcomeCounts, AuditSummary, audit check JSON, redaction decisions, field reports, and schema redaction summaries.
  • Added typed runner invocation and generic dispatch_runner_execution, and moved synthetic benchmark dispatch to the typed runner path.
  • Added explicit SQL pushdown value/params contracts and updated query plan/filter call sites.
  • Added a minimal query sort protocol plus ResultWindow for finalization.
  • Added PrepareRepository as the persistence protocol needed by record preparation.
  • Extended focused tests for audit/redaction payloads, outcome counts, runner dispatch, and query pushdown contracts.

Verification

  • ruff check polylogue/schemas/privacy_config.py polylogue/schemas/privacy.py polylogue/schemas/generation_support.py polylogue/schemas/generation_schema_builder.py polylogue/schemas/generation_workflow.py polylogue/schemas/generation_provider_bundle.py polylogue/schemas/generation_provider_bundle_packages.py polylogue/schemas/generation_redaction.py polylogue/schemas/generation_field_annotations.py polylogue/schemas/redaction_report.py polylogue/schemas/audit_models.py polylogue/lib/outcomes.py polylogue/lib/query_sorting.py polylogue/lib/query_fields.py polylogue/lib/query_plan.py polylogue/scenarios/runtime.py polylogue/scenarios/__init__.py devtools/benchmark_campaigns.py polylogue/pipeline/prepare.py tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/scenarios/test_runtime.py tests/unit/lib/test_outcomes.py tests/unit/core/test_query_fields.py -> all checks passed
  • mypy polylogue/schemas/privacy.py polylogue/schemas/privacy_config.py polylogue/schemas/audit_models.py polylogue/schemas/redaction_report.py polylogue/schemas/generation_support.py polylogue/schemas/generation_schema_builder.py polylogue/schemas/generation_workflow.py polylogue/schemas/generation_provider_bundle.py polylogue/schemas/generation_provider_bundle_packages.py polylogue/schemas/generation_redaction.py polylogue/schemas/generation_field_annotations.py polylogue/scenarios/runtime.py polylogue/scenarios/__init__.py devtools/benchmark_campaigns.py polylogue/pipeline/prepare.py polylogue/lib/query_sorting.py polylogue/lib/query_fields.py polylogue/lib/query_plan.py polylogue/lib/outcomes.py tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/scenarios/test_runtime.py tests/unit/lib/test_outcomes.py tests/unit/core/test_query_fields.py -> success
  • pytest -q tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/core/test_schema_privacy.py tests/unit/core/test_privacy_config.py tests/unit/core/test_schema_generation.py tests/unit/scenarios/test_runtime.py tests/unit/lib/test_outcomes.py tests/unit/core/test_query_fields.py tests/unit/pipeline/test_prepare_records.py -> 221 passed
  • devtools verify -> all checks passed
  • git push -u origin feature/refactor/privacy-audit-runtime-contracts -> pre-push quick verification passed

Sinity added 2 commits April 23, 2026 01:19
Problem: #281 identified the privacy, schema audit, and redaction report layer as a remaining weak-contract band where machine payloads were assembled as broad inline dictionaries and privacy config protocols were duplicated across generation helpers.

What changed: add a shared SchemaPrivacyConfig protocol, route generation privacy helpers through it, and give outcome, audit, redaction decision, field, and summary payloads typed to_json surfaces. The report JSON output now delegates to those typed payload objects instead of ad hoc nested dict assembly.

Verification: ruff check on touched files; mypy on touched schema/outcome files and tests; pytest -q tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/core/test_schema_privacy.py tests/unit/core/test_privacy_config.py tests/unit/core/test_schema_generation.py tests/unit/lib/test_outcomes.py.

Ref #281
Problem: #281 also called out reusable runtime/query helpers whose public contracts were broader than their actual behavior, including untyped runner dispatch, storage pushdown params, sorting/finalization inputs, and prepare persistence dependencies.

What changed: add typed runner invocation and generic runner dispatch, make synthetic benchmark runners consume that typed path, define SQL pushdown value contracts, introduce a minimal query sort protocol and result window, and narrow prepare persistence to a PrepareRepository protocol instead of a concrete repository class.

Verification: ruff check on touched files; mypy on touched runtime/query/prepare files and tests; pytest -q tests/unit/scenarios/test_runtime.py tests/unit/core/test_query_fields.py tests/unit/pipeline/test_prepare_records.py.

Ref #281
@coderabbitai

coderabbitai Bot commented Apr 22, 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 9 minutes and 49 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 9 minutes and 49 seconds.

⌛ 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: 75784fa7-527a-4ddb-9406-c364ac3fa6f6

📥 Commits

Reviewing files that changed from the base of the PR and between 73fd9e8 and f3acafa.

📒 Files selected for processing (25)
  • devtools/benchmark_campaigns.py
  • polylogue/lib/filters.py
  • polylogue/lib/outcomes.py
  • polylogue/lib/query_fields.py
  • polylogue/lib/query_plan.py
  • polylogue/lib/query_sorting.py
  • polylogue/pipeline/prepare.py
  • polylogue/scenarios/__init__.py
  • polylogue/scenarios/runtime.py
  • polylogue/schemas/audit_models.py
  • polylogue/schemas/generation_field_annotations.py
  • polylogue/schemas/generation_provider_bundle.py
  • polylogue/schemas/generation_provider_bundle_packages.py
  • polylogue/schemas/generation_redaction.py
  • polylogue/schemas/generation_schema_builder.py
  • polylogue/schemas/generation_support.py
  • polylogue/schemas/generation_workflow.py
  • polylogue/schemas/privacy.py
  • polylogue/schemas/privacy_config.py
  • polylogue/schemas/redaction_report.py
  • tests/unit/core/test_audit.py
  • tests/unit/core/test_query_fields.py
  • tests/unit/core/test_redaction_report.py
  • tests/unit/lib/test_outcomes.py
  • tests/unit/scenarios/test_runtime.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/refactor/privacy-audit-runtime-contracts

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.

@Sinity Sinity changed the title refactor: renew privacy audit runtime contracts refactor: renew privacy audit runtime contracts (#369) Apr 22, 2026
@Sinity
Sinity merged commit b54a051 into master Apr 22, 2026
10 of 13 checks passed
@Sinity
Sinity deleted the feature/refactor/privacy-audit-runtime-contracts branch April 22, 2026 23:34
@Sinity

Sinity commented May 1, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ 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".

@Sinity
Sinity requested a review from Copilot May 1, 2026 01:53
@Sinity
Sinity removed the request for review from Copilot May 1, 2026 02:15
Sinity added a commit that referenced this pull request May 7, 2026
## Summary

Renew the non-CLI privacy, audit, runtime, query, and prepare helper contracts named in #281.

Closes #281

## Problem

The remaining utility/runtime precision tranche was no longer mostly missing annotations; it was still broad at semantic boundaries. Privacy config behavior was described through duplicate partial protocols, schema audit and redaction JSON payloads were assembled as inline dictionaries, runner dispatch returned opaque objects even when the authored execution was runner-backed, SQL pushdown params were exposed as `dict[str, object]`, query sorting consumed the full query plan instead of the actual sort/window surface, and prepare persistence depended on the concrete repository class.

## Solution

- Added a shared `SchemaPrivacyConfig` protocol and routed schema generation privacy helpers through it.
- Added typed payload surfaces for `OutcomeCounts`, `AuditSummary`, audit check JSON, redaction decisions, field reports, and schema redaction summaries.
- Added typed runner invocation and generic `dispatch_runner_execution`, and moved synthetic benchmark dispatch to the typed runner path.
- Added explicit SQL pushdown value/params contracts and updated query plan/filter call sites.
- Added a minimal query sort protocol plus `ResultWindow` for finalization.
- Added `PrepareRepository` as the persistence protocol needed by record preparation.
- Extended focused tests for audit/redaction payloads, outcome counts, runner dispatch, and query pushdown contracts.

## Verification

- `ruff check polylogue/schemas/privacy_config.py polylogue/schemas/privacy.py polylogue/schemas/generation_support.py polylogue/schemas/generation_schema_builder.py polylogue/schemas/generation_workflow.py polylogue/schemas/generation_provider_bundle.py polylogue/schemas/generation_provider_bundle_packages.py polylogue/schemas/generation_redaction.py polylogue/schemas/generation_field_annotations.py polylogue/schemas/redaction_report.py polylogue/schemas/audit_models.py polylogue/lib/outcomes.py polylogue/lib/query_sorting.py polylogue/lib/query_fields.py polylogue/lib/query_plan.py polylogue/scenarios/runtime.py polylogue/scenarios/__init__.py devtools/benchmark_campaigns.py polylogue/pipeline/prepare.py tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/scenarios/test_runtime.py tests/unit/lib/test_outcomes.py tests/unit/core/test_query_fields.py` -> all checks passed
- `mypy polylogue/schemas/privacy.py polylogue/schemas/privacy_config.py polylogue/schemas/audit_models.py polylogue/schemas/redaction_report.py polylogue/schemas/generation_support.py polylogue/schemas/generation_schema_builder.py polylogue/schemas/generation_workflow.py polylogue/schemas/generation_provider_bundle.py polylogue/schemas/generation_provider_bundle_packages.py polylogue/schemas/generation_redaction.py polylogue/schemas/generation_field_annotations.py polylogue/scenarios/runtime.py polylogue/scenarios/__init__.py devtools/benchmark_campaigns.py polylogue/pipeline/prepare.py polylogue/lib/query_sorting.py polylogue/lib/query_fields.py polylogue/lib/query_plan.py polylogue/lib/outcomes.py tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/scenarios/test_runtime.py tests/unit/lib/test_outcomes.py tests/unit/core/test_query_fields.py` -> success
- `pytest -q tests/unit/core/test_audit.py tests/unit/core/test_redaction_report.py tests/unit/core/test_schema_privacy.py tests/unit/core/test_privacy_config.py tests/unit/core/test_schema_generation.py tests/unit/scenarios/test_runtime.py tests/unit/lib/test_outcomes.py tests/unit/core/test_query_fields.py tests/unit/pipeline/test_prepare_records.py` -> 221 passed
- `devtools verify` -> all checks passed
- `git push -u origin feature/refactor/privacy-audit-runtime-contracts` -> pre-push quick verification passed
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.

Renew privacy, audit, and utility runtime contracts

1 participant