suite_feed: (document_id, revision) is UNIQUE (Fable's review of db4a14c)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+13
−2
internal/docs/migrations/0012_suite_feed_revisions.sql+5 −1internal/docs/suite_test.go+8 −1
CI cancelled — superseded by a newer push — run details
diff --git a/internal/docs/migrations/0012_suite_feed_revisions.sql b/internal/docs/migrations/0012_suite_feed_revisions.sql| index 031d462..69223f4 100644 |
| --- a/internal/docs/migrations/0012_suite_feed_revisions.sql |
| +++ b/internal/docs/migrations/0012_suite_feed_revisions.sql |
| @@ -6,4 +6,8 @@ |
| -- the log is append-only, so without this the probe is a scan of a table |
| -- that only grows. It serves Rule's history read (issued) too, which asks |
| -- the same (document, revision) pairs. |
| -CREATE INDEX IF NOT EXISTS suite_feed_document_revision ON suite_feed (document_id, revision); |
| +-- |
| +-- UNIQUE (Fable's review of db4a14c): the invariant is then the schema's |
| +-- and not only bumpRevision's, so a future path that announces without |
| +-- bumping fails loudly instead of reissuing a revision. |
| +CREATE UNIQUE INDEX IF NOT EXISTS suite_feed_document_revision ON suite_feed (document_id, revision); |
diff --git a/internal/docs/suite_test.go b/internal/docs/suite_test.go| index c9a6299..9784972 100644 |
| --- a/internal/docs/suite_test.go |
| +++ b/internal/docs/suite_test.go |
| @@ -1580,7 +1580,8 @@ func TestSuiteRevisionsRedrawAndNeverFallBack(t *testing.T) { |
| // MUTATION-TESTED 2026-11-02, each reverted: logRevisionTaken checking only |
| // the current revision (the revision-10 rule) → "the rename took revision |
| // <first>, one the log already held"; 0012 deleted → "the log probe's plan |
| -// is [{Detail:SCAN suite_feed}]"; logRevisionTaken returning false, |
| +// is [{Detail:SCAN suite_feed}]"; 0012's UNIQUE dropped → "suite_feed |
| +// took a second row"; logRevisionTaken returning false, |
| // nil on a failed read → "a log that cannot be read: taken false and no |
| // error". |
| func TestSuiteARevisionIsNeverOneTheLogHolds(t *testing.T) { |
| @@ -1629,6 +1630,12 @@ func TestSuiteARevisionIsNeverOneTheLogHolds(t *testing.T) { |
| t.Errorf("the log probe's plan is %+v, want a search on suite_feed_document_revision", plan) |
| } |
| + // The schema holds the rule too: a second row for a revision the log |
| + // already holds is refused, whatever path writes it. |
| + if err := announce(app.store.db, doc.ID, fresh, false); err == nil { |
| + t.Errorf("suite_feed took a second row at revision %d for one document", fresh) |
| + } |
| + |
| // A log that cannot be read is an error, never "not taken". Asked of |
| // the probe directly: through a bump, announce's insert into the same |
| // missing table would fail anyway and hide whether the probe did. |