Skip to content

Deepen lexical ambiguity handling - #55

Merged
simongonzalezdc merged 1 commit into
mainfrom
semantic-ambiguity-hardening
Apr 22, 2026
Merged

simongonzalezdc merged 1 commit into
mainfrom
semantic-ambiguity-hardening

Conversation

@simongonzalezdc

Copy link
Copy Markdown
Member

Summary

  • adds explicit lexical ambiguity rules for coger/tomar/agarrar/recoger-style senses
  • injects matched ambiguity constraints into semantic translation prompts
  • hardens es-MX fixtures around file pickup, package pickup, and transit take/catch
  • adds requiredOutputGroups so certification can require multiple semantic traits, not just one token from a loose list
  • verifies both qwen3.5-9b and qwen3.6-35b pass the new es-MX live ambiguity fixture set

Why

The previous dialect profile had prose like "avoid literal coger," but that was too thin: it did not model which verb should be used for file pickup vs transit vs physical grab vs photo/medicine senses, and the fixture evaluator could pass when only one loose token matched. This change turns that dialect depth into executable constraints.

Verification

  • pnpm --filter @espanol/cli exec vitest run src/__tests__/lexical-ambiguity.test.ts src/__tests__/semantic-context.test.ts src/__tests__/dialect-eval.test.ts src/__tests__/adversarial-dialect-fixtures.test.ts
  • pnpm dialect:eval -- --dialects=es-MX --out=/tmp/dialectos-mx-ambiguity-eval
  • qwen3.5-9b live: LLM_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-MX --out=/tmp/dialectos-mx-ambiguity-live-qwen35
  • qwen3.6-35b live: LLM_API_URL=http://127.0.0.1:1234/v1/chat/completions LLM_API_FORMAT=openai LLM_MODEL=qwen3.6-35b-a3b LLM_ALLOW_LOCAL=1 LLM_TIMEOUT_MS=240000 pnpm dialect:eval -- --live --provider=llm --fixtures=packages/cli/src/__tests__/fixtures/dialect-adversarial --dialects=es-MX --out=/tmp/dialectos-mx-ambiguity-live-qwen36
  • pnpm build
  • pnpm test
  • pnpm audit --audit-level low
  • git diff --check
  • npm pack dry-run guard for all publishable packages

Dialect quality was still too thin around coger/tomar/agarrar-style ambiguity. This adds explicit lexical ambiguity rules, inserts them into semantic prompts, and makes certification fixtures assert multi-trait output groups so outputs must preserve both the object and the correct action sense.

Constraint: Provider quality must be tested through executable fixtures, not prose-only dialect notes.

Rejected: Keep requiredOutputAny only | it allowed one token to satisfy a multi-part semantic requirement

Confidence: high

Scope-risk: moderate

Directive: Add new ambiguous verbs as lexical ambiguity rules plus required output groups; do not bury them only in free-text notes.

Tested: pnpm build; pnpm test; pnpm audit --audit-level low; focused lexical/dialect fixture tests; live qwen3.5-9b and qwen3.6-35b es-MX adversarial eval; npm pack dry-run guard

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0b385122e5

ℹ️ 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".

{
id: "pickup-package",
dialects: TABOO_RISK_COGER_DIALECTS,
sourcePattern: /\b(pick up|grab|get|take)\b.{0,40}\b(package|packages|parcel|order|badge|ticket)\b/i,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Tighten pickup-package regex to avoid order-detail false matches

The pickup-package trigger currently matches any pick up|get|take ... order text, so common phrases like “Get order details” or “Take customer orders” will incorrectly receive physical-pickup guidance (recoger/retirar). In those scenarios, the new ambiguity prompt can push translations toward the wrong action and meaning. Narrowing this rule (for example by removing bare order or requiring explicit pickup/package cues) would avoid misclassifying non-pickup content.

Useful? React with 👍 / 👎.

@simongonzalezdc
simongonzalezdc merged commit 39ba8c9 into main Apr 22, 2026
6 checks passed
@simongonzalezdc
simongonzalezdc deleted the semantic-ambiguity-hardening branch April 22, 2026 19:00
@kilo-code-bot

kilo-code-bot Bot commented Apr 22, 2026 •

Copy link
Copy Markdown

Code Review Roast 🔥

Verdict: 1 Pre-existing Issue | Recommendation: Merge

Oh wait, this PR is actually clean. I had my flamethrower warmed up and everything. But there's a pre-existing comment on pickup-package at line 28 flagging the regex being too loose — that one is worth addressing before merge if it's actionable.

Overview

Severity Count
🤏 nitpick 1
Issue Details (click to expand)
File Line Roast
packages/cli/src/lib/lexical-ambiguity.ts 28 Pre-existing regex over-match concern (by another reviewer)

🏆 Best part: The requiredOutputGroups feature is genuinely clever — it lets certification require multiple semantic traits together rather than just one token from a loose list. That's the kind of hardening that actually matters.

💀 Worst part: The pre-existing regex comment is still open — pickup-package matching "order" (like "Get order details") is a legitimate concern worth addressing.

📊 Overall: Like a well-seasoned cast iron skillet — mostly fine, with one stubborn spot that needs a bit more scrubbing.

Files Reviewed (9 files)
  • packages/cli/src/lib/lexical-ambiguity.ts - new file
  • packages/cli/src/lib/semantic-context.ts - integration
  • packages/cli/src/__tests__/lexical-ambiguity.test.ts - new file
  • packages/cli/src/__tests__/adversarial-dialect-fixtures.test.ts - fixture schema
  • packages/cli/src/__tests__/dialect-eval.test.ts - fixture schema
  • scripts/dialect-eval.mjs - evaluator logic
  • scripts/dialect-certify.mjs - certification logic
  • packages/cli/src/__tests__/fixtures/dialect-adversarial/es-MX.json - fixtures
  • packages/cli/src/__tests__/fixtures/dialect-eval/es-MX.json - fixtures

Reviewed by minimax-m2.5 · 397,827 tokens

simongonzalezdc added a commit that referenced this pull request Nov 11, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant