AMCS Lyrics Generator
Produces complete song lyrics that satisfy structural, stylistic, and policy constraints while maintaining full source provenance through hash-pinned retrieval.
When to Use
Invoke this skill after PLAN and STYLE generation to create lyrics. Runs in parallel with PRODUCER node and feeds into COMPOSE.
Input Contract
inputs:
- name: sds_lyrics
type: amcs://schemas/lyrics-1.0.json
required: true
description: Lyrics entity from SDS with constraints and preferences
- name: plan
type: amcs://schemas/plan-1.0.json
required: true
description: Section order and target word counts
- name: style
type: amcs://schemas/style-1.0.json
required: true
description: Musical style for thematic alignment
- name: sources
type: array[amcs://schemas/source-1.0.json]
required: false
description: External knowledge sources for retrieval
- name: blueprint
type: amcs://schemas/blueprint-1.0.json
required: true
description: Genre-specific lyrical patterns and lexicon
- name: seed
type: integer
required: true
description: Determinism seed (use seed+2 for this node)
Output Contract
outputs:
- name: lyrics
type: string
description: Complete lyrics text with section markers
- name: citations
type: array[citation]
description: |
Source chunks used with provenance:
- chunk_hash: SHA-256 of source text
- source_id: UUID of source
- text: Actual source snippet
- weight: Influence weight (0-1)
- name: metrics
type: object
description: |
Quality metrics:
- rhyme_tightness: 0-1 score
- singability: 0-1 score (syllable consistency)
- hook_density: count per section
Determinism Requirements
- Seed:
run_seed + 2 for LLM generation and retrieval tie-breaking
- Temperature: 0.3 for lyrics generation
- Top-p: 0.85
- Retrieval: Deterministic source chunk selection:
- Fixed top-k (k=5 per source)
- Sort by chunk_hash lexicographically for tie-breaking
- Store all chunk hashes in citations
- Hashing: Hash every source chunk (SHA-256) for pinned retrieval
Constraints & Policies
- Section order MUST match
plan.section_order
- Total lines MUST NOT exceed
sds_lyrics.constraints.max_lines
- Each section MUST satisfy
section_requirements (min/max lines, must_end_with_hook)
- Rhyme scheme MUST match
sds_lyrics.rhyme_scheme (e.g., AABB, ABAB)
- Syllable count per line MUST be within ±2 of
sds_lyrics.syllables_per_line
- Profanity filter MUST enforce
sds_lyrics.constraints.explicit:
- If false, replace profanity with [[REDACTED]] or safe alternatives
- If true, allow explicit content but score it in metrics
- Hook strategy MUST align with
sds_lyrics.hook_strategy:
- "chant": Repeat hook phrase ≥3 times in chorus
- "lyrical": Strong memorable phrase, ≥2 occurrences
- "melodic": Focus on singable phonetics
- "call-response": Alternating lines
- Source citations MUST include ALL retrieved chunks with hashes
Implementation Guidance
Step 1: Prepare Source Retrieval (if sources provided)
- For each source in
sources:
- Construct deterministic query from
style.mood + plan.section_order[0]
- Retrieve top-k=5 chunks from MCP source
- Sort chunks by SHA-256 hash lexicographically (tie-breaking)
- Store each chunk:
{chunk_hash, source_id, text}
- Apply source weights from
sds_lyrics.source_citations
- Store all chunks in citations array
Step 2: Generate Section-by-Section
For each section in plan.section_order:
Retrieve Section Constraints:
- Get
section_requirements[section] for min/max lines
- Get
target_word_counts[section] from plan
Build Context:
- Include style mood, energy, themes
- Include relevant source chunks (prioritize by weight)
- Include rhyme scheme and meter
Generate Lyrics:
- Use LLM with seed
run_seed + 2 + section_index
- Temperature: 0.3
- Enforce syllable target:
sds_lyrics.syllables_per_line ± 2
- Enforce rhyme scheme
- If section is "Chorus" and
must_end_with_hook, ensure last line is hook
Apply Profanity Filter:
- If
explicit = false, scan for profanity
- Replace with [[REDACTED]] or safe synonym
- Log replacements
Store Section:
- Prepend section marker:
[Verse 1], [Chorus], etc.
- Append to complete lyrics text
Step 3: Enforce Hook Strategy
If hook_strategy = "chant":
- Identify hook phrase (usually chorus last line)
- Count occurrences across all chorus sections
- Ensure ≥3 occurrences
If hook_strategy = "lyrical":
- Ensure at least 2 chorus sections contain identical hook line
If hook_strategy = "call-response":
- Alternate line structure in chorus sections
Step 4: Calculate Metrics
Rhyme Tightness:
- For each section, check line-end rhyme against scheme
- Score: (matching_rhymes / expected_rhymes)
Singability:
- For each line, count syllables
- Score: 1 - (avg_deviation_from_target / target)
Hook Density:
- Count hook occurrences per section
- Store as
metrics.hook_density
Step 5: Validate and Return
- Check total lines ≤
max_lines
- Validate all section requirements met
- Compute hash of complete lyrics text
- Return
{lyrics, citations, metrics, _hash}
Examples
Example 1: Christmas Pop with Family Source
Input:
{
"sds_lyrics": {
"language": "en",
"pov": "1st",
"tense": "present",
"rhyme_scheme": "AABB",
"syllables_per_line": 8,
"hook_strategy": "chant",
"section_order": ["Intro", "Verse", "Chorus", "Verse", "Chorus"],
"constraints": {
"explicit": false,
"max_lines": 40,
"section_requirements": {
"Chorus": {"min_lines": 6, "must_end_with_hook": true}
}
},
"source_citations": [{"source_id": "family-doc-uuid", "weight": 0.8}]
},
"sources": [
{
"source_id": "family-doc-uuid",
"chunks": [
{"hash": "abc123", "text": "Our family gathers every Christmas Eve..."},
{"hash": "abc456", "text": "The kids love decorating the tree together..."}
]
}
],
"seed": 44
}
Output:
{
"lyrics": "[Intro]\nSnowflakes falling, lights aglow\n\n[Verse]\nGathering 'round on Christmas Eve (8 syllables)\nThe kids decorate, we all believe (8 syllables)\n\n[Chorus]\nFamily time is what we need (8 syllables)\nLove and joy in every deed (8 syllables)\nSinging carols, feeling free (8 syllables)\nChristmas magic, you and me (8 syllables)\nFamily time is what we need (8 syllables - HOOK)\nLove and joy in every deed (8 syllables)\n\n[Verse]\n...\n\n[Chorus]\n...",
"citations": [
{
"chunk_hash": "abc123",
"source_id": "family-doc-uuid",
"text": "Our family gathers every Christmas Eve...",
"weight": 0.8
},
{
"chunk_hash": "abc456",
"source_id": "family-doc-uuid",
"text": "The kids love decorating the tree together...",
"weight": 0.8
}
],
"metrics": {
"rhyme_tightness": 0.95,
"singability": 0.88,
"hook_density": 3
},
"_hash": "ghi789..."
}
Common Pitfalls
- Missing Citations: Not recording source chunk hashes breaks determinism
- Syllable Variance: Exceeding ±2 syllable tolerance reduces singability
- Hook Absence: Missing hooks in "chant" strategy fails validation
- Profanity Leak: Not filtering when
explicit=false violates policy
- Section Overflow: Exceeding
max_lines per section truncates lyrics
- Rhyme Scheme Break: Not enforcing scheme reduces rhyme_tightness score
- Non-Deterministic Retrieval: Not sorting chunks by hash causes variation across runs
1---2name: amcs-lyrics-generator3description: Generate song lyrics with citations from pinned sources. Enforces rhyme scheme, meter, syllable counts, hook strategy, and profanity filter while retrieving from MCP sources with deterministic hash-based pinning. Use when creating lyrics with structural constraints, source attribution, and policy compliance.4---5
6# AMCS Lyrics Generator
7
8Produces complete song lyrics that satisfy structural, stylistic, and policy constraints while maintaining full source provenance through hash-pinned retrieval.
9
10## When to Use
11
12Invoke this skill after PLAN and STYLE generation to create lyrics. Runs in parallel with PRODUCER node and feeds into COMPOSE.
13
14## Input Contract
15
16```yaml
17inputs:
18 - name: sds_lyrics
19 type: amcs://schemas/lyrics-1.0.json
20 required: true
21 description: Lyrics entity from SDS with constraints and preferences
22 - name: plan
23 type: amcs://schemas/plan-1.0.json
24 required: true
25 description: Section order and target word counts
26 - name: style
27 type: amcs://schemas/style-1.0.json
28 required: true
29 description: Musical style for thematic alignment
30 - name: sources
31 type: array[amcs://schemas/source-1.0.json]
32 required: false
33 description: External knowledge sources for retrieval
34 - name: blueprint
35 type: amcs://schemas/blueprint-1.0.json
36 required: true
37 description: Genre-specific lyrical patterns and lexicon
38 - name: seed
39 type: integer
40 required: true
41 description: Determinism seed (use seed+2 for this node)
42```
43
44## Output Contract
45
46```yaml
47outputs:
48 - name: lyrics
49 type: string
50 description: Complete lyrics text with section markers
51 - name: citations
52 type: array[citation]
53 description: |
54 Source chunks used with provenance:
55 - chunk_hash: SHA-256 of source text
56 - source_id: UUID of source
57 - text: Actual source snippet
58 - weight: Influence weight (0-1)
59 - name: metrics
60 type: object
61 description: |
62 Quality metrics:
63 - rhyme_tightness: 0-1 score
64 - singability: 0-1 score (syllable consistency)
65 - hook_density: count per section
66```
67
68## Determinism Requirements
69
70- **Seed**: `run_seed + 2` for LLM generation and retrieval tie-breaking
71- **Temperature**: 0.3 for lyrics generation
72- **Top-p**: 0.85
73- **Retrieval**: Deterministic source chunk selection:
74 - Fixed top-k (k=5 per source)
75 - Sort by chunk_hash lexicographically for tie-breaking
76 - Store all chunk hashes in citations
77- **Hashing**: Hash every source chunk (SHA-256) for pinned retrieval
78
79## Constraints & Policies
80
81- Section order MUST match `plan.section_order`
82- Total lines MUST NOT exceed `sds_lyrics.constraints.max_lines`
83- Each section MUST satisfy `section_requirements` (min/max lines, must_end_with_hook)
84- Rhyme scheme MUST match `sds_lyrics.rhyme_scheme` (e.g., AABB, ABAB)
85- Syllable count per line MUST be within ±2 of `sds_lyrics.syllables_per_line`
86- Profanity filter MUST enforce `sds_lyrics.constraints.explicit`:
87 - If false, replace profanity with [[REDACTED]] or safe alternatives
88 - If true, allow explicit content but score it in metrics
89- Hook strategy MUST align with `sds_lyrics.hook_strategy`:
90 - "chant": Repeat hook phrase ≥3 times in chorus
91 - "lyrical": Strong memorable phrase, ≥2 occurrences
92 - "melodic": Focus on singable phonetics
93 - "call-response": Alternating lines
94- Source citations MUST include ALL retrieved chunks with hashes
95
96## Implementation Guidance
97
98### Step 1: Prepare Source Retrieval (if sources provided)
99
1001. For each source in `sources`:
101 - Construct deterministic query from `style.mood + plan.section_order[0]`
102 - Retrieve top-k=5 chunks from MCP source
103 - Sort chunks by SHA-256 hash lexicographically (tie-breaking)
104 - Store each chunk: `{chunk_hash, source_id, text}`
1052. Apply source weights from `sds_lyrics.source_citations`
1063. Store all chunks in citations array
107
108### Step 2: Generate Section-by-Section
109
110For each section in `plan.section_order`:
111
1121. **Retrieve Section Constraints**:
113 - Get `section_requirements[section]` for min/max lines
114 - Get `target_word_counts[section]` from plan
115
1162. **Build Context**:
117 - Include style mood, energy, themes
118 - Include relevant source chunks (prioritize by weight)
119 - Include rhyme scheme and meter
120
1213. **Generate Lyrics**:
122 - Use LLM with seed `run_seed + 2 + section_index`
123 - Temperature: 0.3
124 - Enforce syllable target: `sds_lyrics.syllables_per_line` ± 2
125 - Enforce rhyme scheme
126 - If section is "Chorus" and `must_end_with_hook`, ensure last line is hook
127
1284. **Apply Profanity Filter**:
129 - If `explicit = false`, scan for profanity
130 - Replace with [[REDACTED]] or safe synonym
131 - Log replacements
132
1335. **Store Section**:
134 - Prepend section marker: `[Verse 1]`, `[Chorus]`, etc.
135 - Append to complete lyrics text
136
137### Step 3: Enforce Hook Strategy
138
1391. If `hook_strategy = "chant"`:
140 - Identify hook phrase (usually chorus last line)
141 - Count occurrences across all chorus sections
142 - Ensure ≥3 occurrences
143
1442. If `hook_strategy = "lyrical"`:
145 - Ensure at least 2 chorus sections contain identical hook line
146
1473. If `hook_strategy = "call-response"`:
148 - Alternate line structure in chorus sections
149
150### Step 4: Calculate Metrics
151
1521. **Rhyme Tightness**:
153 - For each section, check line-end rhyme against scheme
154 - Score: (matching_rhymes / expected_rhymes)
155
1562. **Singability**:
157 - For each line, count syllables
158 - Score: 1 - (avg_deviation_from_target / target)
159
1603. **Hook Density**:
161 - Count hook occurrences per section
162 - Store as `metrics.hook_density`
163
164### Step 5: Validate and Return
165
1661. Check total lines ≤ `max_lines`
1672. Validate all section requirements met
1683. Compute hash of complete lyrics text
1694. Return `{lyrics, citations, metrics, _hash}`
170
171## Examples
172
173### Example 1: Christmas Pop with Family Source
174
175**Input**:
176```json
177{
178 "sds_lyrics": {
179 "language": "en",
180 "pov": "1st",
181 "tense": "present",
182 "rhyme_scheme": "AABB",
183 "syllables_per_line": 8,
184 "hook_strategy": "chant",
185 "section_order": ["Intro", "Verse", "Chorus", "Verse", "Chorus"],
186 "constraints": {
187 "explicit": false,
188 "max_lines": 40,
189 "section_requirements": {
190 "Chorus": {"min_lines": 6, "must_end_with_hook": true}
191 }
192 },
193 "source_citations": [{"source_id": "family-doc-uuid", "weight": 0.8}]
194 },
195 "sources": [
196 {
197 "source_id": "family-doc-uuid",
198 "chunks": [
199 {"hash": "abc123", "text": "Our family gathers every Christmas Eve..."},
200 {"hash": "abc456", "text": "The kids love decorating the tree together..."}
201 ]
202 }
203 ],
204 "seed": 44
205}
206```
207
208**Output**:
209```json
210{
211 "lyrics": "[Intro]\nSnowflakes falling, lights aglow\n\n[Verse]\nGathering 'round on Christmas Eve (8 syllables)\nThe kids decorate, we all believe (8 syllables)\n\n[Chorus]\nFamily time is what we need (8 syllables)\nLove and joy in every deed (8 syllables)\nSinging carols, feeling free (8 syllables)\nChristmas magic, you and me (8 syllables)\nFamily time is what we need (8 syllables - HOOK)\nLove and joy in every deed (8 syllables)\n\n[Verse]\n...\n\n[Chorus]\n...",
212 "citations": [
213 {
214 "chunk_hash": "abc123",
215 "source_id": "family-doc-uuid",
216 "text": "Our family gathers every Christmas Eve...",
217 "weight": 0.8
218 },
219 {
220 "chunk_hash": "abc456",
221 "source_id": "family-doc-uuid",
222 "text": "The kids love decorating the tree together...",
223 "weight": 0.8
224 }
225 ],
226 "metrics": {
227 "rhyme_tightness": 0.95,
228 "singability": 0.88,
229 "hook_density": 3
230 },
231 "_hash": "ghi789..."
232}
233```
234
235## Common Pitfalls
236
2371. **Missing Citations**: Not recording source chunk hashes breaks determinism
2382. **Syllable Variance**: Exceeding ±2 syllable tolerance reduces singability
2393. **Hook Absence**: Missing hooks in "chant" strategy fails validation
2404. **Profanity Leak**: Not filtering when `explicit=false` violates policy
2415. **Section Overflow**: Exceeding `max_lines` per section truncates lyrics
2426. **Rhyme Scheme Break**: Not enforcing scheme reduces rhyme_tightness score
2437. **Non-Deterministic Retrieval**: Not sorting chunks by hash causes variation across runs