5 Commits

Author SHA1 Message Date
1dbb156695 fix(backend): make npm run dev actually boot (ts-node/express-rate-limit type collision)
`npm run dev` (nodemon --exec ts-node) crashed on startup with 8 TS2769
errors ("RateLimitRequestHandler not assignable to Application") every
time -- the documented quick-start path in README.md never actually
worked.

Root cause: this is an npm workspaces monorepo. express-rate-limit is
only hoisted to the monorepo root node_modules, not nested under
gitgram/backend/node_modules. Its own .d.ts resolves `express` by
walking up node_modules from wherever the package physically lives, so
it lands on the root's hoisted express@4 (and @types/express-serve-
static-core@4.19.8) instead of this package's own pinned express@5.1.0
/ @types/express@5.0.5 -- producing a real-looking but spurious cross-
package type mismatch on every `app.use(limiter)` call.

`npx tsc` / `tsc --noEmit` (the actual build and CI gate) do not hit
this at all and stay green -- confirmed before and after this change.
Set `transpileOnly: true` for the dev-loop ts-node process (the
standard fix for this exact class of ts-node + monorepo hoisting
false positive), so `npm run dev` boots instead of crashing on typings
that aren't a real bug in this project's own code.

Verified for real, not just via tsc:
- Spun up throwaway local postgres+redis containers, ran
  `prisma migrate deploy` (4/4 migrations clean), booted the backend
  with `npm run dev`'s actual command -- it now boots and serves
  /health with a live DB connection; it previously hard-crashed before
  a single request.
- Re-ran the full messaging + cross-tenant IDOR flow live end-to-end:
  registered 3 real users, created a real group chat (A+B), both
  members send/read successfully (201/200), and a non-member (C)
  gets a real 403 on both GET /messages/chats/:chatId and
  POST /messages with that chatId -- the IDOR fix from 487e4312 still
  holds.
- Re-ran tests/messages.test.ts with and without this change (via git
  stash): identical 17 failed / 15 passed both times, proving this is
  the same pre-existing mocked-Prisma flakiness already documented in
  plans/back-catalog.md, not a regression from this fix.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-28 00:58:16 +03:00
487e43129f fix(gitgram): fix broken messaging (Account/User id mismatch) + chat IDOR + SEO gap
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>
2026-10-24 22:20:32 +03:00
beefc08485 chore(backend): keep tsc typecheck green under node10 deprecation
TypeScript 6.x makes moduleResolution=node10 (the legacy "node" resolver) a
hard error (TS5107), so `tsc --noEmit` exited 2 and the backend typecheck gate
was red. Add "ignoreDeprecations": "6.0" as TS itself prescribes; node10/
CommonJS resolution semantics are retained intentionally until a deliberate
resolver bump. Typecheck now exits 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-09-06 12:13:41 +03:00
14b1fe6b2c feat: build out + functionally verify all 7 subprojects to working state
Autonomous multi-agent build/verify drive across gitgram + aitimemachine.
All 7 subprojects now build and run; agents fixed real defects throughout.

Backend (gitgram/backend):
- Migrate to Express 5 typing (ambient .d.ts shims for express-rate-limit,
  @apollo/server, @trpc/server that resolve Express 5 types under workspace
  hoisting); fix 2 real GraphQL typing defects; scope typeRoots to local types
- Fix startup crash (missing `buffer` pkg required by nsfwjs)
- Install ioredis + web-push; build clean, boots (HTTP 200), 1241/1266 tests

Web (gitgram/web): next build green (fix route-slug conflict, remove dead
lib/trpc.ts); document monorepo dual-React vitest harness limitation (71/86)

Mobile (gitgram/mobile): port proximity-unique features (org, starred,
reading-list, languages, snippets) onto modern expo-router + axios stack;
exclude standalone proximity/ from tsconfig + jest; typecheck clean, 8/8 tests

AITM core: fix CLI crash from duplicate command registrations (vendored merge);
secure 2 unauthenticated API routes; 520/520 tests
AITM api-server: fix ioredis construct + a2a SDK decls + test mocks; 715/715
AITM mcp: fix TS5076 syntax + slow gitnexus import; 63/63
AITM website: next build green (88 routes)

Root deps: fix broken @types/uuid stub (real v9), relax override to $@types/uuid

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-28 04:10:22 +03:00
49b183818c Unify gitgram + aitimemachine into the monorepo (de-submodule) and merge vendored engines
Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as
opaque submodule gitlinks on GitHub) into fully-tracked first-party content.

AITM now merges its 7 vendored repos as first-party engines:
- memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts
- git: vendored C git (bundled binary) + gitnexus (in-process code intelligence)
- agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess)

Includes the full session's product build: Gitgram web/mobile/backend features,
AITM website/CLI/MCP, the unified memory layer, engine build tooling
(scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md),
and extensive test suites.

Build artifacts, node_modules, external/, and gemini-cli are gitignored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:14:09 +03:00