Skip to content

[Phase B1] Introduce Persona and OutputFormat domain concepts (registry + strategy) #21

@terisuke

Description

@terisuke

Tracked under ADR 0002 — Phase B. Detail: implementation plan §B1.

Problem

The current draft pipeline assumes one author and one output format. Hard-coded examples:

  • internal/domain/article/draft.go:25-35 requires a # title first line and rejects code fences.
  • internal/application/draft/prompt.go:12-51 injects "Noteにそのまま貼り付けられる日本語Markdown記事" into every system message.
  • internal/infrastructure/note/fetcher.go:234-246 rejects any host other than note.com.

To support both Terisuke (本人) and Cloudia (架空キャラクター) on note / cor-jp blog / Zenn / Qiita / homepage, we need two orthogonal first-class concepts in the domain.

Scope

New packages:

  • internal/domain/persona
    • types: Persona, PersonaID, PersonaSeed, Registry
  • internal/domain/format
    • types: OutputFormat, FormatID, Validator, Registry

Hooks:

  • domain/article.NewDraft accepts format_id, dispatches validation to the format's Validator instead of the current hard-coded rules.
  • domain/brief.ArticleBriefSession gains persona_id, output_format_id.
  • application/draft.BuildPrompt becomes BuildPrompt(persona, format, guide, brief) and pulls a per-format system fragment.

Acceptance criteria

  • go test ./... passes with at least the existing note_article format registered.
  • A unit test exists per format validator (added in Phase B3).
  • No conditional if format == "note_article" exists in application/handler code; all branching is through strategy dispatch.
  • BuildPrompt is unit-tested for each registered format.
  • Existing scenario tests (cor_instrument × note) produce byte-identical or near-identical drafts to before this refactor (regression safety).

Out of scope

  • Specific format implementations beyond note_article (those land in Phase B3).
  • Persistence of persona/format ids (Phase C).
  • Source fetcher changes (Phase B2).

Dependencies

  • Should land before B3 (templates) and B4 (persona seeds).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions