R364 — Semantic Layer Atop R363
Paraphrased Clauses Now Caught — And A Draft Fix Is Generated
Cascadia uploaded v3 where "paid safe leave" was reworded as "protective leave for personal safety reasons." R363 regex missed it (false negative). R364 semantic caught it with 0.98 confidence. The one genuine missing clause (NY workplace violence) triggered an LLM-generated fix proposal — citation NOT LLM-generated, injected from form_compliance_specs.
What R364 added on top of R363. Same upload pipeline; same dept routing; same HITL fabric. New: every R363 regex check now runs alongside an Ollama phi3 semantic check (via the existing /api/chat gateway, 0.4-3s/rule). Disagreements between the two engines are surfaced, not hidden. For each genuine gap, an LLM proposes 2-3 paragraphs of handbook prose. Citations come from the form_compliance_specs table to prevent E_PROMPT_0004 (LLM hallucinated statutes).
Revision Chains + Compliance
R364 In-Round Failure (Caught + Fixed Per R355)
E_PROMPT_0005 fired. First semantic run truncated v3 to first 600 chars. The PROTECTIVE LEAVE section started at byte 887 of the handbook — invisible to the LLM. So semantic ALSO said missing.
Fix (same round, R355 discipline). Switched r364_semantic_compliance.py to keyword-anchor window selection: scan the doc for any keyword associated with the rule (e.g. NYC_paid_safe_leave → ["leave","safe","sick","psl","protective"]), center a 700-char window on the first hit, fall back to head-window if no anchor.
Result after patch: semantic caught NYC_paid_safe_leave at byte 891 with confidence 0.98 — the exact section it had missed.
How R364 Works
- Dual-engine — each revision runs both regex (R363) and Ollama phi3 semantic via /api/chat
- Anchor window — for each rule, semantic prompt sees a 700-char window centered on rule-relevant keywords (E_PROMPT_0005 fix)
- Conservative verdict — final = present if EITHER engine says present (minimize false-negatives)
- Disagreement surfacing — when engines diverge, both verdicts logged + flagged in UI
- Fix generation — for each genuine gap, LLM drafts 2-3 paragraphs of handbook prose; citation injected from spec table (E_PROMPT_0004 prevention)
- Same HITL fabric — fix-suggestions ride on the R361 queue + R360 dept routing + R362 lifecycle