CI / lint (push) Successful in 3s
CI / extension-version (push) Successful in 3s
Build images / sign-extension (push) Successful in 4s
Build images / build-agent (push) Successful in 7s
CI / frontend-build (push) Successful in 25s
CI / backend-lint-and-test (push) Successful in 32s
Build images / build-web (push) Successful in 1m3s
Build images / smoke-web (push) Skipped
Build images / build-ml (push) Successful in 1m53s
Build images / promote (push) Skipped
CI / integration (push) Successful in 2m12s
The point of the milestone rather than its tail. Two of the operator's artists post a deliberately cropped fragment on Patreon to signal that the real thing has landed in their Discord; this proposes those pairs. Confirm-only, following the FC-6.3 series matcher. A wrongly-asserted association tells the operator two different pieces are one, which is strictly worse than no link: no link leaves them where they already were, a wrong one actively misinforms and then propagates into whatever reads it. So the matcher's job is a SHORT list worth reading, not a long list worth trusting. **The threshold sits above every single signal weight, and that is the design.** Proximity is 0.55, declaration 0.45, the cut 0.60 — so neither signal can carry a pair alone. That makes "time proximity alone is never sufficient" an arithmetic property rather than an aspiration: on a busy day an artist posts several times, and a matcher that could pair on proximity alone would turn every one of those days into false pairs until the review queue got abandoned. A guard test asserts the relationship against WEIGHTS directly, so it survives any refactor of the scorer, and says in its own failure message not to fix it by lowering the assertion. **Crop-to-source matching is HELD, on the plan's instruction** — real work with real false-positive risk, worth building only once signals 1 and 2 are shown insufficient against the operator's actual artists. Worth stating: a naive whole-image SigLIP similarity is NOT that signal. A cropped teaser and its full version are precisely the pair a whole-image comparison handles worst, so adding one as a "bonus" would mostly add noise while looking like progress. Two premises in the plan corrected in the building: * **E4 is not actually a prerequisite.** A Patreon Source and a Discord Source the operator has added under one Artist already share `Post.artist_id`, and the synthetic grouping inherits it. E4 EXTENDS this to creators FC has to learn the association for; it is not needed to represent one FC was told. Same-artist is then a hard filter, not a scored signal — two different creators posting minutes apart is a coincidence, not evidence. * **`link_extract` cannot supply the declaration signal.** It exists, but `SUPPORTED_HOSTS` is file hosts only and `host_for()` returns None for a Discord URL, so no ExternalLink row is ever written for one. The signal reads the post body directly instead. And a bug my own test would have caught: `declared_signal` stripped the HTML before looking for an invite, but `html_to_plain` discards attributes and these creators put the invite in an anchor's `href` — so the strongest form of the signal was being thrown away, leaving only whatever the link text said. The invite now matches the raw body; the bare mention still matches stripped text, so `\bdiscord\b` is tested against prose rather than against markup. Dismissed rows are kept, not deleted: the row is what remembers the rejection, and re-proposing a rejected pair on every scan is the one behaviour that makes a review queue get ignored. Both FKs CASCADE, so E3's one-DELETE reversal cannot leave a proposal pointing at a post that no longer exists. Only ACCEPTED links reach the post payload. A pending proposal is a question for the review queue, not a claim to render beside the artwork. UI (rule 27) follows in the next commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LNXXULQDjVZmbuNa2G9mD9
101 lines
4.1 KiB
Python
101 lines
4.1 KiB
Python
"""PostAssociation — "this Patreon post announced that Discord drop".
|
|
|
|
Milestone 388, step E5, and the point of the milestone rather than its tail.
|
|
|
|
Two of the operator's artists post a deliberately CROPPED fragment on Patreon
|
|
to signal that the real thing has landed in their Discord. The Patreon post is
|
|
the announcement; the Discord grouping (milestone 388 E2) is the payload. This
|
|
row is the link between them.
|
|
|
|
## Directional, and NOT a merge
|
|
|
|
`announcement` → `payload` is asymmetric on purpose. The teaser announces the
|
|
drop; the drop does not announce the teaser, and a symmetric "related posts"
|
|
edge would lose the only thing that makes the pair interesting.
|
|
|
|
Nor are the two collapsed into one post. The creator published twice,
|
|
deliberately, on two platforms with different audiences — flattening that
|
|
hides the very behaviour being modelled, and would destroy the operator's
|
|
ability to see that the Patreon post is a teaser at all.
|
|
|
|
## Confirm-only, following FC-6.3 (task 737)
|
|
|
|
`status` starts at `pending` and nothing is linked until the operator accepts.
|
|
A wrongly-asserted association tells them two different pieces are one, which
|
|
is worse than no link: no link leaves them where they already are, a wrong one
|
|
actively misinforms. Same reason the series matcher writes to a review queue
|
|
instead of filing posts on its own.
|
|
|
|
`status` is a plain String, no CHECK — matching `series_suggestion.status`,
|
|
which records the same check-existing-enums lesson.
|
|
|
|
## Why pHash could not do this, and the correction matters
|
|
|
|
The original plan claimed this link was already sitting in `image_provenance`
|
|
via pHash dedup. It is not. `compute_phash` is `imagehash.phash` at
|
|
`hash_size=8` — a DCT hash over the WHOLE image, robust to rescaling and
|
|
recompression but NOT to cropping, because a crop changes the global
|
|
signature. Cross-platform provenance still links straight re-posts; it does
|
|
nothing for a cropped teaser and its full version, which is precisely the pair
|
|
the operator described. Hence a scored proposal rather than a lookup.
|
|
"""
|
|
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import (
|
|
JSON,
|
|
DateTime,
|
|
Float,
|
|
ForeignKey,
|
|
Integer,
|
|
String,
|
|
UniqueConstraint,
|
|
func,
|
|
)
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from .base import Base
|
|
|
|
|
|
class PostAssociation(Base):
|
|
__tablename__ = "post_association"
|
|
__table_args__ = (
|
|
UniqueConstraint(
|
|
"announcement_post_id", "payload_post_id",
|
|
name="uq_post_association_pair",
|
|
),
|
|
)
|
|
|
|
id: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
# The teaser — a real post the creator wrote (Patreon, today).
|
|
announcement_post_id: Mapped[int] = mapped_column(
|
|
ForeignKey("post.id", ondelete="CASCADE"), nullable=False, index=True
|
|
)
|
|
# What it announced — a synthetic Discord grouping, today. CASCADE on both
|
|
# sides: an association to a post that no longer exists is not a fact worth
|
|
# keeping, and E3's reversal path (delete the grouping) should not leave a
|
|
# dangling proposal behind.
|
|
payload_post_id: Mapped[int] = mapped_column(
|
|
ForeignKey("post.id", ondelete="CASCADE"), nullable=False, index=True
|
|
)
|
|
|
|
score: Mapped[float] = mapped_column(Float, nullable=False)
|
|
# Per-signal strengths as scored, so a proposal stays explicable after the
|
|
# weights or the threshold are tuned. Without it, "why was this suggested"
|
|
# is unanswerable the moment anything moves.
|
|
signals: Mapped[dict | None] = mapped_column(JSON, nullable=True)
|
|
# pending | linked | dismissed. A DISMISSED row is kept, not deleted — it
|
|
# is what stops the matcher proposing the same rejected pair on every
|
|
# subsequent scan, which is the behaviour that makes a review queue
|
|
# unusable.
|
|
status: Mapped[str] = mapped_column(
|
|
String(16), nullable=False, server_default="pending", index=True
|
|
)
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), nullable=False, server_default=func.now()
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), nullable=False,
|
|
server_default=func.now(), onupdate=func.now(),
|
|
)
|