Custom Violation Types — full CRUD system for user-defined violation types persisted in the database, appearing in the violation form dropdown alongside hardcoded types
AGENTS.md — authoritative developer/AI agent reference covering data integrity rules, coding standards, schema change checklist, and forward-thinking guidelines
Custom Violation Types (feat)
Database
New violation_types table auto-migrated on startup (db/database.js)
type_key auto-generated as custom_<slug> to prevent collisions with hardcoded violation keys
All write actions audited via existing audit() helper
API — server.js
GET /api/violation-types — all custom types
POST /api/violation-types — create; auto-generates unique type_key
PUT /api/violation-types/:id — edit name, category, chapter, description, points, fields
DELETE /api/violation-types/:id — blocked with 409 if any violations reference the type
ViolationTypeModal.jsx (new component)
Name, category (datalist autocomplete from existing categories + free-type for new groups), handbook chapter reference, description/reference text
Fixed vs. sliding point toggle (fixed = exact value, sliding = min/max range with supervisor discretion)
Context field checkboxes: Incident Time, Minutes Late, Amount, Location, Additional Details
Edit mode pre-populates all fields; delete button with usage guard
ViolationForm.jsx
Fetches custom types on mount; merged into dropdown via mergedGroups memo (custom types appear in their category group alongside hardcoded types)
resolveViolation() checks hardcoded registry first, then custom type map — recidivist escalation, repeat badge, tier warning, and point slider all work identically for custom types
+ Add Type button above dropdown opens create modal
Edit Type button appears inline when a custom type is selected
Newly created type auto-selects after save; deleted type clears selection if active
Custom types marked with ✦ in dropdown and green Custom badge in context box
AGENTS.md (docs)
Covers: immutable scoring fields, soft-delete contract, audit log rules, tier system canonical source, migration pattern, schema change checklist, coding standards (backend + frontend), PDF generation, deployment notes, and explicit anti-patterns.
Test plan
Add a new fixed-point custom violation type; confirm it appears in dropdown under correct category
Add a sliding-point type; confirm point slider respects min/max
Submit a violation using a custom type; confirm it records correctly and PDF generates
Edit a custom type; confirm changes reflect immediately in dropdown
Attempt to delete a custom type that has violations; confirm 409 error message
Delete a custom type with no violations; confirm it disappears from dropdown
Add a custom type with a new category name; confirm new <optgroup> appears in dropdown
## Summary
- **Custom Violation Types** — full CRUD system for user-defined violation types persisted in the database, appearing in the violation form dropdown alongside hardcoded types
- **AGENTS.md** — authoritative developer/AI agent reference covering data integrity rules, coding standards, schema change checklist, and forward-thinking guidelines
## Custom Violation Types (feat)
### Database
- New `violation_types` table auto-migrated on startup (`db/database.js`)
- `type_key` auto-generated as `custom_<slug>` to prevent collisions with hardcoded violation keys
- All write actions audited via existing `audit()` helper
### API — `server.js`
- `GET /api/violation-types` — all custom types
- `POST /api/violation-types` — create; auto-generates unique `type_key`
- `PUT /api/violation-types/:id` — edit name, category, chapter, description, points, fields
- `DELETE /api/violation-types/:id` — blocked with `409` if any violations reference the type
### `ViolationTypeModal.jsx` (new component)
- Name, category (datalist autocomplete from existing categories + free-type for new groups), handbook chapter reference, description/reference text
- Fixed vs. sliding point toggle (fixed = exact value, sliding = min/max range with supervisor discretion)
- Context field checkboxes: Incident Time, Minutes Late, Amount, Location, Additional Details
- Edit mode pre-populates all fields; delete button with usage guard
### `ViolationForm.jsx`
- Fetches custom types on mount; merged into dropdown via `mergedGroups` memo (custom types appear in their category group alongside hardcoded types)
- `resolveViolation()` checks hardcoded registry first, then custom type map — recidivist escalation, repeat badge, tier warning, and point slider all work identically for custom types
- `+ Add Type` button above dropdown opens create modal
- `Edit Type` button appears inline when a custom type is selected
- Newly created type auto-selects after save; deleted type clears selection if active
- Custom types marked with `✦` in dropdown and green **Custom** badge in context box
## AGENTS.md (docs)
Covers: immutable scoring fields, soft-delete contract, audit log rules, tier system canonical source, migration pattern, schema change checklist, coding standards (backend + frontend), PDF generation, deployment notes, and explicit anti-patterns.
## Test plan
- [ ] Add a new fixed-point custom violation type; confirm it appears in dropdown under correct category
- [ ] Add a sliding-point type; confirm point slider respects min/max
- [ ] Submit a violation using a custom type; confirm it records correctly and PDF generates
- [ ] Edit a custom type; confirm changes reflect immediately in dropdown
- [ ] Attempt to delete a custom type that has violations; confirm `409` error message
- [ ] Delete a custom type with no violations; confirm it disappears from dropdown
- [ ] Add a custom type with a new category name; confirm new `<optgroup>` appears in dropdown
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Custom Violation Types (feat)
Database
violation_typestable auto-migrated on startup (db/database.js)type_keyauto-generated ascustom_<slug>to prevent collisions with hardcoded violation keysaudit()helperAPI —
server.jsGET /api/violation-types— all custom typesPOST /api/violation-types— create; auto-generates uniquetype_keyPUT /api/violation-types/:id— edit name, category, chapter, description, points, fieldsDELETE /api/violation-types/:id— blocked with409if any violations reference the typeViolationTypeModal.jsx(new component)ViolationForm.jsxmergedGroupsmemo (custom types appear in their category group alongside hardcoded types)resolveViolation()checks hardcoded registry first, then custom type map — recidivist escalation, repeat badge, tier warning, and point slider all work identically for custom types+ Add Typebutton above dropdown opens create modalEdit Typebutton appears inline when a custom type is selected✦in dropdown and green Custom badge in context boxAGENTS.md (docs)
Covers: immutable scoring fields, soft-delete contract, audit log rules, tier system canonical source, migration pattern, schema change checklist, coding standards (backend + frontend), PDF generation, deployment notes, and explicit anti-patterns.
Test plan
409error message<optgroup>appears in dropdown🤖 Generated with Claude Code