mirror of
https://github.com/bitbaum/orangecat.git
synced 2026-12-05 03:27:40 +01:00
Tagging the Cat in a conversation now gets an answer in that conversation, from the Cat's own account. The shape is a queue with two payers. The write path records that a reply is owed and returns, because an LLM round trip must not sit inside the sender's POST; a worker pays the debt. The systemd timer is the DURABILITY path rather than the latency path — the write also kicks a run, so a reply normally lands in seconds, and the tick is what guarantees the question survives a process dying mid-thought. An assistant that silently drops a question is worse than one that is slow. Idempotency is the unique key on (source_type, source_id), which is what makes an at-least-once producer safe, and 23505 is therefore treated as success rather than failure. Concurrency is FOR UPDATE SKIP LOCKED inside claim_cat_mentions, so an inline run overlapping a timer tick cannot answer the same mention twice. Proven on production with two concurrent sessions: two mentions seeded, "A claimed: 1", "B claimed: 1", distinct rows claimed 2 of 2, nothing left pending, scratch table dropped. The dedupe key is the MESSAGE id, and the first draft got that wrong. It fell back to the conversation id when no message id was passed, which would have meant the first question ever asked in a conversation was the only one ever answered — every later insert colliding with the unique constraint and being read as "already queued". The parameter is now required and the fallback is gone, with a test that fails if it returns. "@cat what do you think about this?" works because "this" means the conversation. The Cat reads CAT_CONTEXT_MESSAGE_WINDOW recent messages of the thread it was tagged in and nothing else — no other conversation, no history beyond the window. That is a stated product promise about what tagging consents to, which is why the number lives in config and not in a query. The Cat STAYS in the conversation once tagged, so a follow-up needs no second tag and both people can see it is there, and it can be removed like any participant. That was one of the two open product calls; it is recorded here as an assumption and is reversible. A failure to think is still answered. CAT_FALLBACK_REPLY goes out rather than nothing, because a tag that produces silence is indistinguishable from a broken feature, and this codebase has shipped exactly that before. Layering: parse (pure) -> resolve (one query) -> note (the seam a write path calls) -> queue (durability) -> worker (dispatch) -> reply (what it says). Nothing was added to chat-orchestrator.ts or memory.ts, already 837 and 1062 lines. A new surface gains all of this by calling noteCatMention. Co-authored-by: Georgy Butaev <41178744+g-but@users.noreply.github.com> Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Scripts Directory
This directory contains all automation scripts organized by purpose.
Directory Structure
analysis/- Bundle analysis, documentation checking, and optimization toolsauth-fix/- Scripts to fix authentication and RLS policy issuesdb/- Database operations, migrations, and schema management- Migration scripts moved from root:
apply-migration.js,apply-*-migration.js - Old schema files archived in
db/archive/
- Migration scripts moved from root:
deployment/- Deployment, production setup, and monitoring scriptsdev/- Development helpers, local setup, and debugging toolsdiagnostics/- Health checks and system diagnosticsmaintenance/- Cleanup, optimization, and maintenance scriptsmonitoring/- Performance monitoring and bundle size trackingoauth/- OAuth provider setup and configurationprofile-fix/- Scripts to fix profile-related issuesschema-fix/- Database schema fixes and migrationsstorage/- Supabase storage bucket setup and managementtest/- Testing utilities and validation scripts- Test/debug scripts moved from root:
test-*.js,check-*.js,debug-*.js
- Test/debug scripts moved from root:
Usage
Most scripts can be run with:
node scripts/{category}/script-name.js
For deployment scripts:
bash scripts/deployment/script-name.sh
Important Scripts
scripts/dev/dev-start.js- Main development server starterscripts/deployment/browser-verify.js- Post-deploy browser smoke test (deploys themselves happen on the box — see docs/deployment/DEPLOYMENT_PROCESS.md)scripts/db/apply-migrations.ts- Database migrationsscripts/maintenance/cleanup-console-logs.ts- Remove console.log statements