SKILL: section-validator
Purpose
Build and maintain the 4 deterministic verification gates (Stage 3). Gates run on the full draft text with zero LLM calls. They validate, auto-fix formatting, and flag issues for review.
When to Use
- Building or modifying any gate
- Adding new entity extraction patterns
- Debugging false positives / false negatives
- Extending verified provisions coverage
Architecture Context (v5.1 — what's running)
4 gates run sequentially on draft.draft_artifacts[0].text (full document text). Total time: ~0.1s.
draft_freetext -> evidence_anchoring -> lkb_compliance -> postprocess -> citation_validator -> review
All gates are deterministic — zero LLM calls.
Gate 1: Evidence Anchoring (evidence_anchoring.py)
For each extracted entity (date, amount, reference) in the draft:
- Check if exists in intake facts, evidence, or user_request
- If YES -> keep as-is
- If NO -> replace token with
{{PLACEHOLDER}}
Entity Parsers
- Date parser: handles 15.03.2024, 15/03/2024, 15th March 2024, etc. Excludes Section/Article/Order numbers
- Amount parser: handles Rs. 20,00,000/-, INR 20 lakh, Rupees Twenty Lakhs. Indian comma notation. Excludes years/days/percentages
- Reference parser: cheque no., UTR, NEFT Ref — keyword-aware
Output
evidence_anchoring_issues — list of dicts with type and description
- Modified draft text with unsupported tokens replaced
Gate 2: LKB Compliance (lkb_compliance.py)
Checks draft against LKB entry for the classified cause type:
- Primary acts cited — are the LKB primary_acts referenced in draft?
- Superseded law check — auto-replaces old acts with current (e.g., IPC -> BNS, CrPC -> BNSS)
Auto-Fix
- Superseded law references auto-replaced (deterministic substitution)
- Missing primary acts -> flagged as issue for review
Output
- Issues merged into
postprocess_issues
Gate 3: Postprocess (postprocess.py)
Deterministic formatting fixes on the draft text:
- Paragraph numbering — fix sequential numbering gaps
- Annexure labels — ensure Annexure A, B, C format
- Verification clause — ensure Order VI Rule 15 CPC clause present
- Spacing — normalize whitespace, line breaks
- and/or fix — replace "and/or" with "and" (Indian legal convention)
- Paragraph breaks — split run-together numbered paragraphs
- Annexure list — split semicolon-separated items
- Prayer items — ensure prayer sub-items on separate lines
Output
postprocess_issues — list of formatting fixes applied
- Modified draft text with all fixes applied
Gate 4: Citation Validator (citation_validator.py)
Every statutory citation in the draft must:
- Exist in
verified_provisions (from enrichment) OR be a well-known procedural provision
- Not be a fabricated case citation (AIR/SCC/ILR)
Case Citation Patterns (flagged as ERROR)
(2015) 5 SCC 123
AIR 2015 SC 123
2015 SCC OnLine SC 123
ILR 2015 KAR 123
Well-Known Provisions (always allowed)
- CPC: Section 26, Order VI Rule 15, Order VII Rule 1, Section 34, Section 151
- Constitution: Article 14, 19, 21, 226, 32
- Evidence Act: Section 65B
Output
citation_issues — list of dicts with severity and message
- Enabled/disabled via
DRAFTING_CITATION_VALIDATOR_ENABLED setting
Key Files
| File |
What |
nodes/evidence_anchoring.py |
Gate 1: fact -> intake tracing |
nodes/lkb_compliance.py |
Gate 2: act citation + superseded law check |
nodes/postprocess.py |
Gate 3: formatting fixes |
nodes/citation_validator.py |
Gate 4: provision verification |
nodes/_utils.py |
Shared helpers (placeholder collection, encoding cleanup) |
Settings
DRAFTING_CITATION_VALIDATOR_ENABLED: bool = True
Rules
- NEVER modify legal substance — only replace unsupported tokens or flag claims
- NEVER remove sentences — only flag them
- Entity extraction must be deterministic (no LLM)
- Gates run on full document text (
draft.draft_artifacts[0].text)
- False positives are better than false negatives
- All gates run regardless of individual failures (graceful degradation)
- Gate issues are summarized for review via
_build_gate_errors_summary()
Anti-Patterns
- Do NOT use LLM for any gate — deterministic only
- Do NOT block pipeline on gate warnings — flag and continue
- Do NOT auto-remove flagged citations — let review handle
- Do NOT flag placeholder usage as an issue
- Do NOT auto-fix substantive legal content — only formatting
1---2name: section-validator3description: SKILL: section-validator4---5# SKILL: section-validator67## Purpose8Build and maintain the 4 deterministic verification gates (Stage 3). Gates run on the full draft text with zero LLM calls. They validate, auto-fix formatting, and flag issues for review.910## When to Use11- Building or modifying any gate12- Adding new entity extraction patterns13- Debugging false positives / false negatives14- Extending verified provisions coverage1516## Architecture Context (v5.1 — what's running)17184 gates run sequentially on `draft.draft_artifacts[0].text` (full document text). Total time: ~0.1s.1920```21draft_freetext -> evidence_anchoring -> lkb_compliance -> postprocess -> citation_validator -> review22```2324All gates are deterministic — zero LLM calls.2526---2728## Gate 1: Evidence Anchoring (`evidence_anchoring.py`)2930For each extracted entity (date, amount, reference) in the draft:311. Check if exists in intake facts, evidence, or user_request322. If YES -> keep as-is333. If NO -> replace token with `{{PLACEHOLDER}}`3435### Entity Parsers36- **Date parser**: handles 15.03.2024, 15/03/2024, 15th March 2024, etc. Excludes Section/Article/Order numbers37- **Amount parser**: handles Rs. 20,00,000/-, INR 20 lakh, Rupees Twenty Lakhs. Indian comma notation. Excludes years/days/percentages38- **Reference parser**: cheque no., UTR, NEFT Ref — keyword-aware3940### Output41- `evidence_anchoring_issues` — list of dicts with `type` and `description`42- Modified draft text with unsupported tokens replaced4344---4546## Gate 2: LKB Compliance (`lkb_compliance.py`)4748Checks draft against LKB entry for the classified cause type:491. **Primary acts cited** — are the LKB primary_acts referenced in draft?502. **Superseded law check** — auto-replaces old acts with current (e.g., IPC -> BNS, CrPC -> BNSS)5152### Auto-Fix53- Superseded law references auto-replaced (deterministic substitution)54- Missing primary acts -> flagged as issue for review5556### Output57- Issues merged into `postprocess_issues`5859---6061## Gate 3: Postprocess (`postprocess.py`)6263Deterministic formatting fixes on the draft text:641. **Paragraph numbering** — fix sequential numbering gaps652. **Annexure labels** — ensure Annexure A, B, C format663. **Verification clause** — ensure Order VI Rule 15 CPC clause present674. **Spacing** — normalize whitespace, line breaks685. **and/or fix** — replace "and/or" with "and" (Indian legal convention)696. **Paragraph breaks** — split run-together numbered paragraphs707. **Annexure list** — split semicolon-separated items718. **Prayer items** — ensure prayer sub-items on separate lines7273### Output74- `postprocess_issues` — list of formatting fixes applied75- Modified draft text with all fixes applied7677---7879## Gate 4: Citation Validator (`citation_validator.py`)8081Every statutory citation in the draft must:821. Exist in `verified_provisions` (from enrichment) OR be a well-known procedural provision832. Not be a fabricated case citation (AIR/SCC/ILR)8485### Case Citation Patterns (flagged as ERROR)86- `(2015) 5 SCC 123`87- `AIR 2015 SC 123`88- `2015 SCC OnLine SC 123`89- `ILR 2015 KAR 123`9091### Well-Known Provisions (always allowed)92- CPC: Section 26, Order VI Rule 15, Order VII Rule 1, Section 34, Section 15193- Constitution: Article 14, 19, 21, 226, 3294- Evidence Act: Section 65B9596### Output97- `citation_issues` — list of dicts with `severity` and `message`98- Enabled/disabled via `DRAFTING_CITATION_VALIDATOR_ENABLED` setting99100---101102## Key Files103104| File | What |105|------|------|106| `nodes/evidence_anchoring.py` | Gate 1: fact -> intake tracing |107| `nodes/lkb_compliance.py` | Gate 2: act citation + superseded law check |108| `nodes/postprocess.py` | Gate 3: formatting fixes |109| `nodes/citation_validator.py` | Gate 4: provision verification |110| `nodes/_utils.py` | Shared helpers (placeholder collection, encoding cleanup) |111112---113114## Settings115116```117DRAFTING_CITATION_VALIDATOR_ENABLED: bool = True118```119120---121122## Rules123- NEVER modify legal substance — only replace unsupported tokens or flag claims124- NEVER remove sentences — only flag them125- Entity extraction must be deterministic (no LLM)126- Gates run on full document text (`draft.draft_artifacts[0].text`)127- False positives are better than false negatives128- All gates run regardless of individual failures (graceful degradation)129- Gate issues are summarized for review via `_build_gate_errors_summary()`130131## Anti-Patterns132- Do NOT use LLM for any gate — deterministic only133- Do NOT block pipeline on gate warnings — flag and continue134- Do NOT auto-remove flagged citations — let review handle135- Do NOT flag placeholder usage as an issue136- Do NOT auto-fix substantive legal content — only formatting