Skip to content

Renew privacy, audit, and utility runtime contracts #281

Closed

Description

@Sinity

Problem

The schema/runtime precision tranche in #280 removes another central weak-contract cluster, but the remaining non-CLI residue is still concentrated in a utility/runtime band that sits under multiple surfaces:

  • polylogue/schemas/privacy.py
  • polylogue/schemas/audit_models.py
  • polylogue/schemas/redaction_report.py
  • polylogue/scenarios/runtime.py
  • polylogue/pipeline/prepare.py
  • polylogue/lib/query_sorting.py
  • polylogue/lib/query_plan.py
  • polylogue/lib/outcomes.py

These files are not blocked on missing annotations. They are blocked on semantically weak utility contracts: Any-typed query/runtime helpers, payload reports that still serialize through broad dicts, and runtime wrappers that hide the real shape of their inputs and outputs.

Outcome

Run a non-CLI utility/runtime precision tranche that replaces the remaining weak helper and report contracts here with explicit typed helpers, narrower payload models, and cleaner sort/prepare/runtime interfaces.

Acceptance Criteria

  • privacy.py, audit_models.py, and redaction_report.py expose typed payload/report surfaces instead of dict[str, Any] style serialization.
  • scenarios/runtime.py and pipeline/prepare.py stop using their current broad Any runtime arguments where a stable typed protocol or narrower input contract is possible.
  • lib/query_sorting.py, lib/query_plan.py, and lib/outcomes.py reduce their remaining Any-typed sort/result helpers in favor of explicit generic or typed result contracts.
  • Adjacent tests are updated where those contracts are exercised so the renewed helpers are proven rather than just annotated.
  • ruff check, mypy, and targeted pytest slices pass for the touched tranche before PR.

Notes

This tranche should stay away from the active CLI/query-surface work and keep the scope on reusable substrate/runtime utilities only.

Activity

  1. added
    type:refactor
    on Apr 21, 2026
  2. 40 remaining items

  3. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting #281 on feature/refactor/privacy-audit-runtime-contracts.

    Initial boundary:

    • Keep this focused on reusable privacy/audit/runtime/query utility contracts.
    • Avoid active CLI/query surface redesign except where tests or call sites need a typed contract adjustment.
    • First pass will inspect the named files and adjacent tests, then batch the implementation so the tranche lands as a coherent contract renewal rather than isolated annotations.

    Planned verification before PR: targeted ruff check, mypy, focused pytest slices for the touched files, and a full devtools verify if the tranche crosses enough shared substrate to justify it.

  4. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Implementation checkpoint for #281 on feature/refactor/privacy-audit-runtime-contracts:

    Commits so far:

    • 1b56e028 refactor(schema): type privacy and audit report contracts
    • ac7fabad refactor(runtime): narrow execution and query contracts

    What changed:

    • Added a shared SchemaPrivacyConfig protocol and routed schema generation/privacy guard helpers through it instead of duplicating partial privacy protocols.
    • Added typed machine-payload surfaces for outcome counts, audit summaries/checks, redaction decisions, field reports, and schema redaction summaries.
    • Added typed runner invocation plus generic runner dispatch for in-process authored executions, and moved synthetic benchmark dispatch onto that path.
    • Added explicit SQL pushdown value/params contracts, a minimal query sort protocol, typed result windows, and a PrepareRepository protocol for prepare persistence.

    Focused verification so far:

    • targeted ruff check over touched files -> passed
    • targeted mypy over touched files and adjacent tests -> passed
    • 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
  5. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Verification update for #281:

    Full local baseline now passes:

    • devtools verify -> all checks passed

    One issue surfaced during the first full run and is fixed in the branch: ConversationFilter._sql_pushdown_params() still advertised dict[str, object] after the query plan contract narrowed to SqlPushdownParams. I folded that adjacent call-site fix into the runtime/query commit before rerunning the full baseline.

    Current commits:

    • 1b56e028 refactor(schema): type privacy and audit report contracts
    • f3acafac refactor(runtime): narrow execution and query contracts
  6. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    PR opened for #281:

    Verification in PR body includes the focused ruff/mypy/pytest slices, full devtools verify, and pre-push quick verification.

  7. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Closeout for #281:

    • PR: refactor: renew privacy audit runtime contracts (#369) #369
    • Merge commit: b54a0516ae11b8e3e0c92e00093e7162f6e677b1
    • Scope landed:
      • shared schema privacy protocol across privacy guards and generation helpers
      • typed outcome/audit/redaction report payloads
      • typed runner invocation and generic runner dispatch for authored in-process runners
      • explicit SQL pushdown params, query sort/window, filter call-site, and prepare repository contracts

    Verification:

    • targeted ruff check -> passed
    • targeted mypy -> passed
    • focused pytest slice -> 221 passed
    • devtools verify -> all checks passed
    • pre-push quick verification -> all checks passed

    Remote completed checks were green before merge; the long Python matrix/CodeQL jobs were still in progress and accepted under the current CI-quota constraint after full local verification.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:pipelinearea:schemaarea:storagetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions