Repository navigation
Generalize semantic ambiguity gates - #56
Conversation
The coger/tomar/agarrar issue was a category failure, not a single Mexican term bug. This extends lexical ambiguity handling into reusable rule expectations that attach to any matching fixture across dialects, including Puerto Rican recoger el cuarto as a room-tidying sense. Constraint: Ambiguity fixes must be executable across eval/certification scripts, not one-off prompt prose. Rejected: Add only a Puerto Rico fixture | would repeat the one-off remediation pattern Rejected: Treat recoger as a universal safe replacement | Puerto Rican room cleanup shows object/sense/dialect matters Confidence: high Scope-risk: moderate Directive: For new overloaded verbs, add guidance plus expectations in lexical-ambiguity.ts so every matching eval/certification sample gets gated. Tested: pnpm build; pnpm test; pnpm audit --audit-level low; deterministic default/adversarial dialect eval; qwen3.5-9b live es-PR adversarial eval; npm pack dry-run guard
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7822dbe240
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const { buildLexicalAmbiguityExpectations } = await import( | ||
| pathToFileURL(`${process.cwd()}/packages/cli/dist/lib/lexical-ambiguity.js`).href | ||
| ); |
There was a problem hiding this comment.
Lazy-load lexical expectations for mock eval runs
Importing packages/cli/dist/lib/lexical-ambiguity.js at module load time makes node scripts/dialect-eval.mjs crash with ERR_MODULE_NOT_FOUND on a clean checkout where dist/ has not been built yet, including the default mock path. Before this change, mock eval could run without compiled artifacts, so this introduces a startup regression for pnpm dialect:eval unless users remember to build first.
Useful? React with 👍 / 👎.
| const { buildLexicalAmbiguityExpectations } = await import( | ||
| pathToFileURL(`${process.cwd()}/packages/cli/dist/lib/lexical-ambiguity.js`).href | ||
| ); |
There was a problem hiding this comment.
Avoid hard dependency on dist in certify startup
This top-level dynamic import forces scripts/dialect-certify.mjs to require packages/cli/dist before any sample execution, so pnpm dialect:certify now fails immediately with ERR_MODULE_NOT_FOUND on fresh clones that have not run pnpm build. Because certify's mock mode no longer starts without build artifacts, this is a functional regression in the default workflow.
Useful? React with 👍 / 👎.
| for (const term of sample.forbiddenOutputTerms || []) { | ||
| const lexicalExpectations = buildLexicalAmbiguityExpectations(sample.source, dialect); | ||
|
|
||
| for (const term of [...(sample.forbiddenOutputTerms || []), ...lexicalExpectations.forbiddenOutputTerms]) { |
There was a problem hiding this comment.
🔥 The Roast: You're concatenating arrays of forbidden terms like a toddler stacking blocks — no regard for duplicates. When a term appears in both the sample's forbiddenOutputTerms and the rule's expectations (e.g., "coger"), the loop will process it twice and push identical failure messages. Two copies of the same error don't make it more convincing; they just make you look careless.
🩹 The Fix: Deduplicate before the loop:
const allForbiddenTerms = [...new Set([...(sample.forbiddenOutputTerms || []), ...lexicalExpectations.forbiddenOutputTerms])];
for (const term of allForbiddenTerms) {
if (output && hasForbiddenTerm(output, term)) {
failures.push(`Forbidden output term present: ${term}`);
}
}
📏 Severity: warning
|
|
||
| if (output && sample.requiredOutputGroups?.length) { | ||
| for (const group of sample.requiredOutputGroups) { | ||
| const requiredOutputGroups = [ |
There was a problem hiding this comment.
🔥 The Roast: You're merging requiredOutputGroups arrays with the enthusiasm of a hoarder — no deduplication, so identical groups (like ["recoge","recoger","retira","retirar"]) will be checked twice. If a sample is missing that group, you'll get two identical "missing group" errors. If it's present, you waste cycles needlessly. Either way, it's sloppy.
🩹 The Fix: Deduplicate based on group content:
const mergedGroups = [
...(sample.requiredOutputGroups || []),
...lexicalExpectations.requiredOutputGroups,
];
const uniqueGroups = Array.from(
new Map(mergedGroups.map(g => [g.join('|'), g])).values()
);
// then loop over uniqueGroups
📏 Severity: warning
| for (const term of sample.forbiddenOutputTerms || []) { | ||
| const lexicalExpectations = buildLexicalAmbiguityExpectations(sample.source, dialect); | ||
|
|
||
| for (const term of [...(sample.forbiddenOutputTerms || []), ...lexicalExpectations.forbiddenOutputTerms]) { |
There was a problem hiding this comment.
🔥 The Roast: Same duplication bug as in dialect-eval.mjs but in certify. Forbidden terms are concatenated without deduplication, guaranteeing duplicate failure messages when there's overlap.
🩹 The Fix: Apply the same Set-based deduplication here:
const allForbidden = [...new Set([...(sample.forbiddenOutputTerms || []), ...lexicalExpectations.forbiddenOutputTerms])];
for (const term of allForbidden) { ... }
📏 Severity: warning
|
|
||
| if (output && sample.requiredOutputGroups?.length) { | ||
| for (const group of sample.requiredOutputGroups) { | ||
| const requiredOutputGroups = [ |
There was a problem hiding this comment.
🔥 The Roast: And the required groups merge here suffers the same duplication problem — identical groups from sample and lexical expectations will be checked twice, cluttering the failure output.
🩹 The Fix: Deduplicate groups as shown in dialect-eval:
const merged = [...(sample.requiredOutputGroups || []), ...lexicalExpectations.requiredOutputGroups];
const unique = Array.from(new Map(merged.map(g => [g.join('|'), g])).values());
// use unique
📏 Severity: warning
| guidance: "For taking transportation, use tomar/toma or abordar/aborda by register and dialect. Do not use coger outside Spain/Andorra. Preserve dialect-specific vehicle terms such as guagua where the dialect contract requires them.", | ||
| expectations: (dialect) => ({ | ||
| requiredOutputGroups: [ | ||
| dialect === "es-CU" || dialect === "es-DO" || dialect === "es-PR" |
There was a problem hiding this comment.
🔥 The Roast: Hardcoding the guagua dialect list ("es-CU","es-DO","es-PR") inline is a DRY violation that could drift from the same constant in scripts. Next time someone updates one list and forgets the other, you'll get inconsistent vehicle expectations.
🩹 The Fix: Extract these dialects into a shared constant (e.g., in @espanol/types or a utils module) and import it everywhere. At minimum, define a local constant and reuse it.
📏 Severity: suggestion
Code Review Roast 🔥Verdict: 5 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)
Fix LinkFix these issues in Kilo Cloud 🏆 Best part: The new 💀 Worst part: The duplicate array merging in the eval/certify scripts. It's a basic oversight that turns error reporting into a broken record. Fix the deduplication before this code touches production. 📊 Overall: Like a machismo subjunctive — promising tense action but with a couple of unexpected conjugations that need cleaning up. Files Reviewed (12 files)
Reviewed by step-3.5-flash · 2,422,427 tokens |
Brings GitHub main level with Forgejo main (ef214e5), the canonical repo, so GitHub carries what v0.3.2 is cut from. - **Roast fixes:** dictionary accents and meaning-safe swaps (#50), accented words in the register, voseo, gender and grammar checks (#51), the file sandbox and patched dependencies (#52), honest claims and a pinned toolchain (#53), and adjective agreement, MCP vosotros parity, the real engine in the demo, and no more "first" claim (#55). - **Branding:** the Hermes plugin icon (#54). - **Release:** every version and install path moves to 0.3.2 (#56). - **Security:** the voseo quote regex CodeQL flagged on this PR now runs in linear time (#57). - **Pages:** `docs/CNAME` is removed. The site already serves from kyanitelabs.github.io/DialectOS/ without a redirect. After this merges, both mains have the same files. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01RXhEX6WJsRZUyGhsp5WgGe --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
recoger el cuartoas tidying the room, not package/file pickupWhy
The previous fix was still too close to a one-off. The real failure mode is object/sense/dialect ambiguity:
coger,tomar,agarrar,recoger,retirar, etc. cannot be handled as simple replacements. This patch makes ambiguity an executable category with prompt guidance and scoring gates.Verification
pnpm buildpnpm testpnpm audit --audit-level lowpnpm dialect:eval -- --out=/tmp/dialectos-ambiguity-matrix-evalpnpm dialect:eval -- --fixtures=packages/cli/src/__tests__/fixtures/dialect-adversarial --out=/tmp/dialectos-ambiguity-matrix-adversarialLLM_API_URL=http://127.0.0.1:1234/v1/chat/completions LLM_API_FORMAT=openai LLM_MODEL=qwen3.5-9b LLM_ALLOW_LOCAL=1 LLM_TIMEOUT_MS=180000 pnpm dialect:eval -- --live --provider=llm --fixtures=packages/cli/src/__tests__/fixtures/dialect-adversarial --dialects=es-PR --out=/tmp/dialectos-pr-ambiguity-live-qwen35-finalgit diff --check