Audited gitgram-ai end to end by actually running the backend against a
live Postgres instance (not just reading/trusting the existing Jest
suite, which mocks Prisma and therefore never hits real FK constraints
or real route wiring).
Critical, feature-breaking bug: Message.senderId/receiverId and
MessageReaction.userId are foreign keys into Account, but every
messaging controller function wrote/read req.userId (a User id) into
those columns directly. Verified live: every message send (1:1 DM and
group chat) failed with a Prisma foreign-key-constraint violation, and
group messages additionally violated the (until now) required
non-null receiverId column since group messages have no single
receiver. Messaging has never worked through this code path. Fixed by
resolving the caller's Account id once per request (matching the
`prisma.account.findFirst({ where: { userId } })` pattern already used
elsewhere in the codebase, e.g. followRequestController) and using it
consistently for every Message/MessageReaction read, write, and
ownership check, while keeping ChatMember/UserBlock/socket rooms on the
real User id they were already consistent with. Added a Prisma
migration making Message.receiverId nullable for group-only messages.
Verified against a live Postgres test database: registered 3 users,
created a group chat, sent and read 1:1 and group messages, reacted,
and marked conversations read -- all succeed now.
Cross-tenant IDOR (same bug class found on Scribase today): GET
/api/v1/messages/chats/:chatId had no membership check at all -- any
authenticated user could read any group chat's messages by chatId
alone (every sibling function in the same file -- getMessage,
reportMessage, assertMessageAccess -- already enforced membership, this
one endpoint was the outlier). Also hardened sendMessage so posting
into a chatId you don't belong to is rejected. Verified live: a
non-member now gets 403 on both reads and writes to a chat they're not
in; an actual member still gets 200.
Unrelated build blocker found while standing up the backend to test
this: gitgram/backend/tsconfig.json set `ignoreDeprecations: "6.0"`,
which the pinned typescript@^5.9.3 doesn't recognize -- `tsc`/`ts-node`
hard-error with TS5103 before compiling a single file. Backend could
not build or boot in dev mode at all. Fixed to "5.0".
SEO gap: gitgram/web (Next.js 14 app dir) had no robots.txt and no
sitemap anywhere, static or dynamic -- zero crawl directives, no
sitemap reference for search engines. Added app/robots.ts (disallows
authenticated-only surfaces, allows public ones) and app/sitemap.ts
(static public marketing/discovery routes).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The talent graph's recruiter monetization was designed (Opportunity → Pilot →
Proof funnel) but never wired to charge. This adds the placement/candidate-unlock
revenue engine on top of the existing talent graph, charged through Creem (a
merchant-of-record with Turkey-based-seller payout support — the portfolio
standard used by bidstage/CalDesk), not Polar/Stripe.
Revenue gate: a recruiter (opportunity owner) unlocks a matched candidate's
contact + full evidence. Gating mirrors the referral gate (owner-only, no
self-unlock, candidate must have real matching evidence). The fee is charged via
a Creem checkout whose custom_price is the exact computed fee, and settled by the
signed checkout.completed webhook, which records the entitlement + receipt.
- Fee math (pure, configurable): flat unlock access fee (TALENT_UNLOCK_FEE_CENTS,
default $49) or a percentage placement success fee (rate + min/max clamps) when
a placement amount is supplied.
- New TalentPlacement model + migration: entitlement/receipt with a compound
unique key (opportunity, candidate, recruiter) for charge idempotency and a
unique providerOrderId; provider defaults to creem.
- Creem adapter (createCreemCheckout) mirroring the reviewed bidstage lib/creem.ts,
and a signed Creem webhook route (HMAC-SHA256, timing-safe) that settles
placements. Amount is revalidated against the quoted fee before unlocking.
- Routes: POST/GET /talent-graph/opportunities/:id/unlocks and gated
GET .../candidates/:candidateId/contact (402 until paid).
- Errors.paymentRequired (402) helper.
- Tests: fee math, gating, charge idempotency, and the signed webhook settlement
path (75 tests). Secrets are env-only (CREEM_API_KEY, CREEM_WEBHOOK_SECRET,
CREEM_PRODUCT_ID) — none committed.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Migration history reconciliation:
The autonomous-build migration history was corrupted — 20260109185732 dropped 13
tables still in the schema (Account, Advertisement, ScheduledPost, Chat,
Organization, Report, …) plus their enums/constraints without recreating them, so
a fresh `prisma migrate deploy` failed on the later repair/ALTER migrations
(ScheduledPost, Advertisement, AccountType, …). Squashed the 16 broken migrations
into a single clean 00000000000000_init generated from the current schema (93
tables, 19 enums, incl. MutedWord/MessageReaction/Post.contentLanguage). Verified:
fresh `migrate deploy` applies cleanly on an empty DB; the running DB was
re-baselined (resolve --applied init) and the backend boots healthy.
context7:
Switch the compose service from a broken raw node:20-alpine + read-only-volume +
npm-install setup to the package's upstream pnpm Dockerfile (build context =
context7 monorepo root), serving StreamableHTTP on container :8080 (host :3100);
point aitm-mcp's CONTEXT7_URL at :8080. Now Up/healthy.
Result: all 9 compose services healthy (gitgram backend+web, postgres, redis,
aitm-api/mcp/website, gitnexus, context7). E2e through containers still 201/200.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replace the accidental from-empty migration (which duplicated all 16 prior
migrations and would break a fresh `migrate deploy`) with a proper incremental
migration adding only the new objects: Post.contentLanguage, the MessageReaction
and MutedWord tables, their indexes, and the MessageReaction foreign keys.
Verified the DDL against the live schema. NOTE: a fresh full `migrate deploy`
still fails on a PRE-EXISTING migration-history drift —
20260514174000_repair_scheduled_posts_schema references "ScheduledPost" which no
earlier migration creates. That predates this work; the running stack baselines
the schema (applied + migrations marked resolved) to sidestep it. Reconciling the
older migration history with schema.prisma is separate follow-up.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The whole stack now comes up healthy under one `docker compose` run (gitgram
backend+web + Postgres/Redis + aitm-api/mcp/website + gitnexus); only the
optional tools-profile context7 remains (pre-existing workspace-build issue).
gitgram/backend/Dockerfile: move to a glibc base (node:20-bookworm-slim). Alpine
musl lacks the glibc loader that @tensorflow/tfjs-node's native libtensorflow
needs (ERR_DLOPEN_FAILED), so NSFW detection now runs for real (no stubbing).
Full install WITH lifecycle scripts in the builder (downloads libtensorflow),
node_modules reused in the runtime stage so devDeps like swagger-ui-express are
present for the NODE_ENV=development compose run; openssl + ffmpeg + libgomp1
runtime libs; create writable /app/logs + /app/uploads for the non-root user.
prisma schema: binaryTargets -> debian/arm64 openssl-3 for the glibc runtime.
nsfwDetectionService: lazy-load tf + nsfwjs so a genuinely-unavailable native
lib degrades gracefully instead of crashing at import (still uses real tfjs).
gitgram/web/Dockerfile: npm ci -> npm install (workspace member's standalone
lockfile drifts after dependency additions).
Verified end-to-end through containers: register/login/post/feed 201/200,
web homepage + GitHub->Gitgram /caelum0x both 200.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
End-to-end smoke (real Postgres + Redis via docker-compose) caught a real bug
that mocked unit tests missed: createPost passed the request `type` straight to
prisma.post.create, so a client sending lowercase "text" (instead of the
uppercase PostType enum) threw PrismaClientValidationError 500. Now normalized
to the PostType enum (case-insensitive, falls back to POST).
Verified end-to-end: register→login→create post→comment→like→feed all succeed
against a live DB (3 posts / 1 comment / 1 user persisted).
Also adds prisma/migrations/20260629000000_marathon_additions (full schema incl.
MutedWord, Post.contentLanguage, MessageReaction) — resolves the deploy-time
migration that was infra-blocked from generating against the Neon pooler.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>