Extract a 4-method SynthesisStore port

Open Beginner friendly
#8 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
86/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in src/aitts/synthesis.py and inspect how SynthesisPool uses Store, then read the related tests in tests/test_synthesis.py. Define the four-method SynthesisStorePort with the shown signatures, document that claiming must be atomic, and verify that Store still satisfies it and the synthesis tests pass.

Written by the indexing model from the issue text.

Description

enhancement

The problem

SynthesisPool takes the whole Store and uses four methods:

claim_for_synthesis, synthesis_work_is_active, finish_synthesis, fail_synthesis

The fix

class SynthesisStorePort(Protocol):
    def claim_for_synthesis(self) -> SynthesisWork | None: ...
    def synthesis_work_is_active(self, work: SynthesisWork) -> bool: ...
    def finish_synthesis(self, work: SynthesisWork, *, audio_path: str, duration_ms: int | None) -> None: ...
    def fail_synthesis(self, work: SynthesisWork, error: str) -> None: ...

Store satisfies it structurally, unchanged. See #12 for the rationale and
#7 for the worked example.

Worth noting while you are in here

claim_for_synthesis is the atomic claim — one SQL statement that picks the
earliest unclaimed unit and marks it Synthesizing, which is what stops two
workers taking the same work. The port makes that contract explicit rather
than implied by the fact that everyone happens to be sharing one SQLite
connection. Whoever writes a second implementation has to be told that
atomicity is the requirement, so say so in the Protocol's docstring.

Scope

  • src/aitts/synthesis.py
  • tests/test_synthesis.py

Part of #12.

Dominant language
Python
Stars
0
Forks
1
Avg merge
2h 13m
Merged PRs (30d)
51

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from flyingrobots/AI-TTS

All issues in flyingrobots/AI-TTS

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.