fix(db): refuse a negative item index on field corrections (#47) - #57
Merged
Merged
Conversation
…ns (#47, test-first) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJ5vaKvTYiMvdngT4d3xo1
Migration 0016 adds the same check that extracted_fields already has. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DJ5vaKvTYiMvdngT4d3xo1
Owner
Author
Frischer Review (read-only Subagent)Nichts blockierend, keine should-Befunde. Bestätigt: Constraint-Name folgt
Generated by Claude Code |
Fluory
marked this pull request as ready for review
September 24, 2026 11:19
15 tasks
…on-index-check-47 # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Warum
Fixes #47 ·
app.extracted_fieldsverbietet eine negative Positionsnummer per CHECK,app.field_correctionsnicht. Die Prüfung incorrectFieldverhindert es heute – die Datenbank als zweite Linie fehlte.Arbeitsstand
field_corrections.item_index.correctField).data-model.md, CHANGELOG,verifygrün, CI grün, frischer Review ohne Befund.Was ist passiert (Klartext)
Korrekturen an Positionen merken sich, zu welcher Position (0, 1, 2 …) sie gehören. Bisher hat nur der Programmcode verhindert, dass dort eine negative Zahl landet. Jetzt lehnt auch die Datenbank so einen Eintrag ab – genauso, wie sie es für die erkannten Werte schon tut. Für Nutzer ändert sich nichts; es ist eine zusätzliche Sicherung gegen künftige Programmfehler.
Plan-Pflicht (SYSTEM.md §4)
Impact Manifest
db(Schema, Migration), Test inreview.0016_correction_item_index_check.sql:ADD CONSTRAINT field_corrections_item_index_check CHECK (item_index is null or item_index >= 0).item_index = -1alsapp_rwscheitert mit23514;nullund≥ 0gehen weiter.tests/integration/review.test.ts(roh alsapp_rwim Tenant-Kontext),rls-guardunverändert grün.ALTERsieht alle Zeilen, auch die per Forced RLS verborgenen (lokal nachgestellt: eine Testzeile aus dem roten Lauf ließ die Migration scheitern – nach Entfernen lief sie durch). Einziger Schreiber istcorrectField, der negative Werte schon ablehnt.field_correctionsbeimALTER(Pilot: kleine Tabelle). Rollback:DROP CONSTRAINT.Geändert
src/db/schema/app.ts:check("field_corrections_item_index_check", …)src/db/migrations/0016_correction_item_index_check.sql,meta/(generiert)tests/integration/review.test.ts: Negativ- und Positivfalldocs/technical/data-model.md,CHANGELOG.mdNachweis (SYSTEM.md §11)
verify:changed: grün –review.test+rls-guard21/21 (vorher rot: Insert mit -1 ging durch)verify: grün (lokal und CIcheck)verify:full/ E2E-Spec: nicht betroffenDoku-Entscheidung (genau eine)
docs/technical/data-model.md[Unreleased](sichtbares Feature oder Verhalten – im selben PR, nie „später")Entferntes oder Umbenanntes:
docs/+ README gegrept, Treffer bereinigt: nichts entferntDateigrößen und neue Bausteine (SYSTEM.md §7)
Dateien über 500 Zeilen im Diff (Ausnahmen: generierter Code, Lockfiles, Fixtures, Migrationen, Schemas, Ressourcen, Doku, Konfiguration):
Über 800 Zeilen mit neuer Fachlogik oder über 1000 Zeilen (P1/P2): nicht betroffen
Neue Shared-Komponente, Utility-Datei, Adapter oder fachlicher Service:
Subagent-Einsätze
Risiken / offene Punkte
### Fixedan) – reine Textzeilen.🤖 Generated with Claude Code
https://claude.ai/code/session_01DJ5vaKvTYiMvdngT4d3xo1