Skip to content

refactor: renew authored scenario and showcase surfaces #317

Closed

Description

@Sinity

Context

The post-mypy/source-renewal survey identified one coherent quiet-but-important surface cluster that was not fully covered by the current CLI/MCP/UI and verification issues. The concern is not simple file size; it is duplicated conceptual substrate around authored scenarios, showcase generation, rendering payloads, and site publication.

Scope

Audit and renew the authored-surface cluster:

  • polylogue/scenarios/
  • polylogue/showcase/
  • polylogue/rendering/
  • polylogue/site/

Highest-risk files from the scratch survey:

  • polylogue/scenarios/execution.py
  • polylogue/scenarios/corpus.py
  • polylogue/showcase/generators.py
  • polylogue/showcase/workspace.py
  • polylogue/rendering/blocks.py
  • polylogue/rendering/core_markdown.py
  • polylogue/site/builder.py

Problems to remove

  • repeated payload coercion helpers such as integer/float/string-tuple coercion
  • multiple to_payload / from_payload micro-systems over loose dictionaries
  • render payload shaping assembled through ad hoc dictionaries instead of typed view models
  • orchestration files mixing model definition, normalization, and execution wiring

Acceptance criteria

  • Introduce or reuse one shared typed payload/view substrate for scenario/showcase/rendering boundaries.
  • Replace duplicated coercion helpers with narrow typed helpers or model methods.
  • Make render/site payload shaping explicit enough that authored scenarios and showcase outputs share contracts instead of parallel dictionaries.
  • Keep behavior-preserving rewrites unless the audit exposes a real correctness issue.
  • Land as one or more coherent PRs with focused checks and devtools verify.

Related work

Activity

  1. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Starting #317 on branch feature/refactor/authored-surface-contracts from origin/master at e85a0d26.

    Execution boundary:

    • First pass will map existing scenario/showcase/rendering/site payload contracts and duplicated coercion helpers.
    • Primary target is a behavior-preserving typed payload/view substrate shared across authored scenarios, showcase generation, rendering, and site publication boundaries.
    • I will avoid turning this into TUI/site functional completion; feat: complete TUI and site builder to functional state #198 remains the next tranche after the contracts are stable.
    • Durable decisions and verification will be mirrored here as the PR progresses.
  2. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Implementation checkpoint on feature/refactor/authored-surface-contracts:

    • Added polylogue.authored_payloads as the shared authored-surface payload contract layer.
    • Removed the payload-helper re-export from polylogue.scenarios; scenarios, showcase reporting, QA rendering, and site manifest serialization now import the contract directly.
    • Collapsed duplicate QA markdown/summary mapping/count coercion into the shared helpers.
    • Added focused unit coverage for string-keyed payload validation, canonical JSON, count coercion, and typed payload record serialization.

    Verification so far:

    • ruff check polylogue/authored_payloads.py polylogue/scenarios polylogue/showcase polylogue/site tests/unit/scenarios/test_authored_payloads.py tests/unit/showcase/test_report.py tests/unit/site/test_builder.py
    • mypy polylogue/authored_payloads.py polylogue/scenarios polylogue/showcase polylogue/site tests/unit/scenarios/test_authored_payloads.py tests/unit/showcase/test_report.py tests/unit/site/test_builder.py
    • pytest -q tests/unit/scenarios/test_authored_payloads.py tests/unit/scenarios tests/unit/showcase/test_report.py tests/unit/showcase/test_exercise_catalog.py tests/unit/showcase/test_generators.py tests/unit/showcase/test_workspace.py tests/unit/showcase/test_qa_markdown.py tests/unit/site/test_builder.py tests/unit/rendering/test_rendering.py (149 passed)
    • devtools render-all --check
    • devtools lab-scenario verify-baselines (Ran 40 exercises, all baselines match)
    • devtools verify (all checks passed)

    Decision: rendering already had typed records, and site already had a Pydantic publication manifest, so this slice only wires their manifest-facing payload methods into the shared authored payload contract instead of inventing a second rendering/site DTO layer.

  3. Sinity commented on Apr 22, 2026

    @Sinity
    OwnerAuthor

    Closed by PR #367 (refactor: share authored payload contracts (#367)), merged as a1470092794e123238b3aec1f3e5723e7d04a3be.

    Merge basis:

    • Local devtools verify passed end-to-end.
    • Pre-push devtools verify --quick passed.
    • devtools lab-scenario verify-baselines matched all 40 tier-0 exercises.
    • Remote checks observed green before merge: PR metadata, GitGuardian, CodeQL, lint, typecheck, Nix build/check, and showcase verification.
    • Python matrix / Analyze / CodeRabbit were still pending when merged under the explicit CI-quota guidance; the local full pytest baseline had already passed.
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:qaarea:sitetype:refactor

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions