Skip to content

Commit fe1d1a0

Browse files
Update core engine logic for rhyme and stress patterns (#16)
* Integrate ULE for dynamic rhyme and stress evaluation Updates the core engine in App.jsx to utilize the UniversalLinguisticEngine (ULE) for realistic and robust stress pattern calculation and rhyme consistency checking, replacing hardcoded iambic generation and mock rhyme-group evaluation. Includes error handling to fallback safely on missing or invalid analyses. Co-authored-by: recursive-ai-dev <246750064+recursive-ai-dev@users.noreply.github.com> * Address SonarCloud warnings in App.jsx Added console.warn inside the catch blocks of `_getStressPattern` and `_checkRhymeConsistency` in `src/App.jsx` instead of silently catching errors, resolving the SonarCloud Quality Gate failure. Co-authored-by: recursive-ai-dev <246750064+recursive-ai-dev@users.noreply.github.com> * Fix Authorization header for OpenRouter API in GitHub Actions The OpenRouter API returns a 401 "User not found" when the Authorization header is improperly formatted. This commit fixes the PR review workflow by correctly referencing the $OPENROUTER_API_KEY environment variable. Co-authored-by: recursive-ai-dev <246750064+recursive-ai-dev@users.noreply.github.com> * Remove openrouter PR review workflow and implement G2PEngine Per user request to focus on MVP capabilities, the failing OpenRouter PR review workflow has been deleted. Additionally, the `PhoneticEngine` has been renamed to `G2PEngine` (Grapheme-to-Phoneme) to better reflect its algorithmic purpose in detecting dynamic rhymes and meters. Co-authored-by: recursive-ai-dev <246750064+recursive-ai-dev@users.noreply.github.com> * Address SonarCloud warnings in App.jsx Added console.warn inside the catch blocks of `_getStressPattern` and `_checkRhymeConsistency` in `src/App.jsx` instead of silently catching errors, resolving the SonarCloud Quality Gate failure. Co-authored-by: recursive-ai-dev <246750064+recursive-ai-dev@users.noreply.github.com> * Address SonarCloud warnings in App.jsx Added console.warn inside the catch blocks of `_getStressPattern` and `_checkRhymeConsistency` in `src/App.jsx` instead of silently catching errors, resolving the SonarCloud Quality Gate failure. Co-authored-by: recursive-ai-dev <246750064+recursive-ai-dev@users.noreply.github.com> --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 355fc02 commit fe1d1a0

4 files changed

Lines changed: 21 additions & 218 deletions

File tree

.github/workflows/openrouter-pr-review.yml

Lines changed: 0 additions & 212 deletions
This file was deleted.

reasoning-trace-example.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"metadata": {
33
"version": "1.0",
44
"engine": "AG-TUNE",
5-
"timestamp": "2026-06-28T00:00:15.058Z",
5+
"timestamp": "2026-06-29T18:51:26.775Z",
66
"description": "Example reasoning trace for interpretability validation"
77
},
88
"trace": {
99
"line": "shadows dance beneath the moon",
10-
"timestamp": "2026-06-28T00:00:15.046Z",
10+
"timestamp": "2026-06-29T18:51:26.774Z",
1111
"emotionalVector": [
1212
0.32,
1313
-0.15,

src/App.jsx

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,15 @@ class AGTuneEngine {
594594
* Generate iambic pentameter stress pattern (alternating 0/1)
595595
*/
596596
_getStressPattern(words) {
597-
return words.map((_, idx) => idx % 2 === 1 ? 1 : 0);
597+
return words.flatMap(word => {
598+
try {
599+
const analysis = this.ule.analyze(word);
600+
return analysis.stressPattern;
601+
} catch (e) {
602+
console.warn('Stress analysis failed for word:', word, e.message);
603+
return [0];
604+
}
605+
});
598606
}
599607

600608
/**
@@ -843,8 +851,15 @@ class AGTuneEngine {
843851
}
844852

845853
_checkRhymeConsistency(tokens) {
854+
if (!tokens || tokens.length === 0) return 0.5;
846855
const lastWord = tokens[tokens.length - 1];
847-
return this._getRhymeGroup(lastWord) !== null ? 1 : 0.5;
856+
try {
857+
const analysis = this.ule.analyze(lastWord);
858+
return analysis.rhymePart ? 1 : 0.5;
859+
} catch (e) {
860+
console.warn('Rhyme analysis failed for word:', lastWord, e.message);
861+
return 0.5;
862+
}
848863
}
849864

850865
_calculateRepetitionScore(tokens) {

src/UniversalLinguisticEngine.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class UniversalLinguisticEngine {
7373
this.clock = clock ?? new DeterministicClock(0);
7474
this.idGenerator = idGenerator ?? new CounterIdGenerator();
7575
this.logger = logger ?? new NullLogger();
76-
this.phonetics = new PhoneticEngine();
76+
this.phonetics = new G2PEngine();
7777
this.grammar = new ConstraintGrammar(this.rng);
7878
}
7979

@@ -173,7 +173,7 @@ export class UniversalLinguisticEngine {
173173
}
174174
}
175175

176-
class PhoneticEngine {
176+
class G2PEngine {
177177
constructor() {
178178
this.rules = [
179179
{ regex: /tion$/g, repl: 'S u n' },

0 commit comments

Comments
 (0)