Commit Graph

53 Commits

Author SHA1 Message Date
cb4a01d1bb PEP-252: вход в сервисы через OAuth — ядро, обновление токенов, отзыв, мок и тесты
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 12:09:31 +00:00
c8652e57ae PEP-254: журнал Access Hub до действия и с цепочкой хэшей, контрольные точки, выгрузка; свой ключ данных у каждого подключения
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 09:30:19 +00:00
2315ae7b86 Merge branch 'main' into task/pep-249
All checks were successful
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 46с
peppa/build build: success за 32с
peppa/test test: success за 1411с
peppa-ci / ci (pull_request) Successful in 25m34s
2026-11-23 17:05:59 +00:00
1bf8c913c0 PEP-249: каталог сервисов, права чтение/запись, проверка ключа, короткое имя в MCP
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 15:00:08 +00:00
1461fd9ffd PEP-213: замер медленных страниц и SQL, warning в Bugsink, сводка на /observability
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 14:56:43 +00:00
0cded8d4ad PEP-220: уборка журналов работы (срок 1 день), индексы, итог на /observability
All checks were successful
peppa/lint lint: success за 2с
peppa/typecheck typecheck: success за 46с
peppa/build build: success за 33с
peppa/test test: success за 1282с
peppa-ci / ci (pull_request) Successful in 23m22s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 05:09:39 +00:00
52d10be6c5 PEP-234: Access Hub — подключения пользователей, разрешения агентам, серверный шлюз, журнал
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-22 05:19:11 +00:00
81730b63c4 PEP-227: потерянный разговор Claude — новый запуск вместо resume по кругу; диалог кредитов модели
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 14:54:19 +00:00
aff895db27 PEP-214: индексы горячих запросов, keyPrefix вместо LIKE по settings, PRAGMA optimize
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 18:56:42 +05:00
65a5d15aae PEP-216: Главная и «Подписки» без задержек — прогресс без запроса на проект, поток, индекс событий
Главная 80 → 30 мс, 40 запросов разом p95 2,98 → 1,12 с; «Подписки» 36 → 22 мс.
Замер на копии живой базы (apps/web/scripts/bench-pages.ts).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-20 16:31:10 +05:00
7189fd2457 PEP-219: индекс events(session_id, type) — доска не перебирает все события на каждую сессию
listSessions считает переключения подписки подзапросом по events для каждой
сессии; без индекса это полный просмотр ~40 000 строк × 746 сессий (4,4 с на
копии живой базы, 0,008 с с индексом).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 20:57:39 +05:00
204c8e3388 PEP-205: очередь проверок не встаёт молча, лимит и вход Codex не роняют агентов
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 23:50:03 +05:00
218f35af86 PEP-197: фабрика не ставит себе задачи по кругу — «Предложено», пределы, дубли, версия с финишем
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-17 17:55:09 +05:00
Асель
02981bdebf PEP-163: merge main — the projects migration is 0022 after attachments (0021); deleted projects stay off the superadmin's dashboard
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 20:01:31 +05:00
Асель
cdbab4466d PEP-159: вложения в чате с аналитиком, комментариях и новой задаче
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 16:03:45 +05:00
Асель
5a36687f42 PEP-166: a limit banner replayed by a resumed Claude conversation is history, not a new limit of the subscription it moved to
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 15:07:53 +05:00
Асель
2f924ac6b3 PEP-163: удаление проекта — неделя у суперадмина, потом насовсем
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-16 14:38:43 +05:00
Асель
45754f1f23 PEP-149: message types — end of turn is progress, ask_pm with options and default, report_blocker, no «continue» button
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 13:05:59 +05:00
Асель
fec0a698e7 PEP-143: feedback table, core, feedback agent tick, bot mode and buttons
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-16 11:23:09 +05:00
Асель
f9a4b3c56e PEP-109: a chat's Telegram group is linked through the user's own bot
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-15 16:01:10 +05:00
Асель
3159e888d2 PEP-90: sign in and register with Google (OAuth code + PKCE), link with eGov in Settings
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-15 12:40:26 +05:00
Асель
01d58973ab PEP-85: every user's own Telegram bot — token from BotFather, polled and answered through it
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 22:57:07 +05:00
Асель
b3766d200d PEP-62: chats model, projection of events into project chats, master feed, post to chat
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 19:10:49 +05:00
Асель
5b41e7d779 PEP-75: a team of agents — Kazakh names on the board, a character in the prompt
Also: «Открыть терминал» on live session cards.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-14 18:49:34 +05:00
Асель
ca57f9543b PEP-17/40: agent sandbox per runner (docker + agent relay) and runner hosts over SSH
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 07:57:28 +05:00
Асель
acf2bb9623 PEP-21/28: runner service (command queue in the watchdog), watchdog 2.0 auto-recovery and escalation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 07:34:09 +05:00
Асель
9149c75840 PEP-19/54: project secrets for agents, secrets audit and two-key PEPPA_SECRET rotation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 07:19:57 +05:00
Асель
14916079bc PEP-5/43/47/48: usage and limits, story budgets, factory metrics, audit journal
- PEP-5: statusLine hook (cost, context, 5h/7d limit windows), transcript tokens,
  sessions.usage, usage strip over every page, runner usage, bot /status, MCP get_usage
- PEP-43: project/story budgets in settings, watchdog pause (Escape, question to the PM:
  extend x2 / remove limit / stop), start/resume guard, budget on the story card
- PEP-47: project metrics tab (cycle time, first pass, review returns, questions, runner
  hours, PM wait, limits, spend by week/agent/epic), MCP get_metrics
- PEP-48: event authors (actor columns, AsyncLocalStorage context), question_answered,
  /journal for superadmins, project journal tab, authors in the story feed
- Migration 0007_usage_audit; OpenSpec changes archived

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:52:13 +05:00
Асель
6b75324971 PEP-10/27/53: runners with a story queue, a git worktree per runner, free runners
- Runner settings with inheritance system → project → story (settings rows):
  mode story (default, one runner per story) / queue, context fresh / continue,
  workspace shared / worktree, maxRunners. No rows = behaviour as before.
- runner_tasks: a runner's story history and queue; sessions.name, sessions.workspace_path
  (migration 0007_runners).
- moveTask → startTaskOnRunner; runnerTick in the watchdog moves free queue runners to
  their next story (fresh: same tmux, new generation without resume; continue: message),
  reassigns queues of dead runners, removes finished runners' worktrees (clean + pushed).
- Free runners («Новый терминал»), rename, «Оформить стори»; the Stop hook doesn't ping
  for free runners or stories that left work.
- Web: «Новый терминал» (runners page, project sessions tab) with voice input,
  project/story runner settings, runner stories in the details panel; CLI peppa runner …
- e2e: packages/testkit/test/runners.test.ts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:38:02 +05:00
Асель
f6e3725e5f PEP-34/42: board order, archive, epic progress, story dependencies, epic planner (core, runner, MCP)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:28:53 +05:00
Асель
6ab17456af PEP-44, PEP-46: review preview with screenshots; Gitea issues, PR comments, manual merge
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:06:57 +05:00
Асель
c7283063c9 PEP-39: rotate a limited session to a free subscription of the pool at the turn boundary
Limit marks the subscription «лимит до …»; the watchdog relaunches the session on another
usable subscription of the same provider (Claude/OpenCode resume the conversation, Codex
starts afresh), threshold banner switches after the turn, max 3 switches/hour, simple
fairness between projects, subscription_switched events + Telegram message, web shows
subscription and switch history. Migration 0004 (sessions.rotate_reason).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 05:31:22 +05:00
Асель
ea4bdf38ff PEP-29/35/55: notification prefs and routing, Web Push outbox, daily digest; mock-push, tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 05:10:20 +05:00
Асель
07ff13111d PEP-26: reviewer agent before the PM's review — queue, claude -p on the PR diff, findings back to the agent, project settings, card; lint example in the template
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 04:59:32 +05:00
Асель
9054774f96 PEP-67: subscriptions and pools in core/db, sign-in and checks in runner, OpenCode provider, mocks, tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 03:48:25 +05:00
Асель
414e4500e4 PEP-68: local users without Gitea — password login, superadmin management
- users.password_hash/password_set_at/disabled_at (migration 0002_local_users)
- core/local-users.ts: scrypt, passwordLogin with attempt limits, create/reset/disable
- isSuperadmin(db, user) = platform.admins; isUserAllowed honours disabled_at
- web: /auth/password + login form, /users for superadmins, Settings → password
- Gitea login with a local user's login is refused (giteaLoginRefusal)
- local users: projects in peppa-bot namespace, members without Gitea collaboration
- CLI: peppa user add|passwd|disable|enable; tests in testkit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 03:20:21 +05:00
Асель
ed49767c31 PEP-65: eGov QR login through the KazEDS relay (sign.aitu.uz)
Login page and Settings → eGov: relay session with a server-side challenge/nonce, QR + eGov Mobile
deep link, polling, one-shot completion; IIN from the signer's certificate (own DER reader),
users.egov_iin. The relay is trusted (PM decision): no own XMLDSig check. CLI peppa user egov,
mock-kazeds-relay, tests. Dev mode: /_next/static is no-store (Cloudflare cached stale chunks).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 01:14:10 +05:00
Асель
3a282b8054 PEP-36 stage 2: SQLite (node:sqlite, WAL) instead of Postgres
- packages/db: schema on sqlite-core (timestamps as epoch ms → Date, JSON as text,
  booleans 0/1), one baseline migration; node:sqlite client under drizzle's
  better-sqlite3 session (busy_timeout first, WAL, BEGIN IMMEDIATE, retries on
  SQLITE_BUSY, lazy open, async transaction callbacks refused); PEPPA_DB
  (default ~/.peppa/peppa.db)
- live updates: notify() pokes the bot over a unix socket; the bot also watches
  PRAGMA data_version every second (writes by other processes)
- Postgres specifics ported: createTask transaction is synchronous, no
  `for update skip locked`, `count(*)`, json_extract instead of ->>, json_each
  instead of @>
- `peppa db migrate` and `peppa db migrate-to-sqlite <file>` (read-only
  snapshot of Postgres, FK order from the schema, row count + foreign key
  checks, file appears only when they pass); old Postgres schema kept in
  packages/cli/legacy-pg-migrations for the migration and its test
- daily VACUUM INTO backup from the watchdog (7 copies, admin alert on failure)
- tests: a temp SQLite file per test file; storage.test.ts (20 processes,
  per-project numbering across processes, socket/data_version, migration from
  Postgres incl. a dangling foreign key, backups); two test races fixed
- CI: no per-run Postgres database; PEPPA_TEST_PG only for the migration test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 17:23:24 +05:00
Асель
59c3b583de PEP-57: CD — deploy workflow, preview/staging/prod, health check and rollback, releases
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 14:49:24 +05:00
Асель
cae49d5b54 PEP-57: CI feedback — check runs, red checks back to the agent, review/merge gates
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 14:37:10 +05:00
Асель
498013472f PEP-58: Bugsink — production errors become Peppa incidents and tasks
- infra: Bugsink 2.6.3 in docker (infra/bugsink, scripts/bugsink-up.sh), database
  bugsink in Peppa's Postgres, Traefik route bugsink.telecom.quest
- packages/bugsink: REST API client + custom-webhook payload parsing
- incidents (migration 0011): incident_settings, error_sources, incidents; ingest from
  webhook POST /api/hooks/bugsink/<secret> and a 2-minute poll in the watchdog
- incident policy per project: notify / backlog (default) / start / ask (Telegram
  buttons) / triage (claude -p with the owner's token, falls back to ask)
- daily task cap, environments, ignore pattern; manual "fixed" until PEP-57;
  REGRESSED returns the task to the backlog
- web «Ошибки» section, bot buttons, MCP tools for agents and the PM, help, RULES.md
- testkit: mock-bugsink, mock-triage, incidents.test.ts (one test per scenario,
  plus a live run against the real Bugsink with PEPPA_LIVE_BUGSINK=1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 14:31:32 +05:00
Асель
685810eb80 PEP-56: runner continues on its own after the usage limit resets
- parseResetTime: 'resets 5pm', 'resets at 3:10 AM', 'resets in 2h 15m',
  'try again at 23:30'; nearest future time, local clock
- recordLimit (hook StopFailure and the watchdog's banner path): status
  rate_limited, resume_at = reset + 60 s, or probes 30 → 60 → 120 min when
  unknown or the limit came back right after a resume; cap 6/day;
  PEPPA_LIMIT_AUTORESUME=off; PM is told 'continues at HH:MM'
- watchdog: at resume_at nudges the live agent or relaunches it with
  resume (vanished/dead rate-limited runners wait instead of failing); the
  limit message is closed as resolved; tick(db, { now }) for tests
- mocks: limit with resetInSec / unknown reset (claude and codex)
- tests: one per spec scenario + Codex (82 e2e total, green)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 03:50:58 +05:00
Асель
824ba56b74 PEP-2: Telegram per user — pairing from Settings, delivery by project access
- users.telegram_* replace the single global binding; one-time /start code
  per user (web Settings → Telegram, or peppa telegram pair <login>);
  a chat belongs to one user
- agent questions go to the project's owner and members who paired; an
  answer (button or reply) is accepted only from someone with access to
  the project; messages are closed for every recipient; /status is scoped
- CLI: telegram pair|status|unpair <login>, user ensure mock-<name>;
  dev stand pairs its test PM per user
- tests: several-users journey (bob without access, then as a member);
  70 e2e total, green
- BREAKING: the old global binding is removed; users pair again in Settings

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 03:44:30 +05:00
Асель
56b6224587 PEP-12: share projects with other users
- project_members / project_invites; owner adds people by Gitea login,
  invitations are applied at first login; members get the owner's access
  except member management; a member can leave
- access everywhere via projectForUser / userProjectIds (owner or member):
  web inbox, sessions, project pages, MCP
- shareProject / unshareProject: login checked in Gitea, repo collaborator
  (write) added by the owner's client or peppa-bot; missing admin rights
  don't block membership (repoAccess flag)
- web: Members block on the project page, 'shared' badge; MCP:
  list_members, add_member, remove_member; Help updated
- tests: 5 sharing journeys on mock-gitea (64 e2e total, green); test DB
  now also clears users and OAuth clients between files
- OpenSpec: pep-12 archived (project-sharing, web-auth)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-12 22:35:56 +05:00
Асель
3f55248150 PEP-13: connect Claude from the web for remote users
- Settings → Claude: Peppa runs 'claude setup-token' in tmux, shows the
  claude.com sign-in link, the user pastes the code into the form; the
  1-year token is stored encrypted on the user (users.claude_token_enc)
- Claude sessions of the owner's projects get CLAUDE_CODE_OAUTH_TOKEN;
  projects without an owner token keep using the machine login
- disconnect / reconnect; setup times out after 10 min and its tmux
  session (and scrollback with the token) is killed right after saving
- mock-claude setup-token; 2 new tests (56 e2e total, green)
- verified on prod: the button yields the real claude.com authorize URL
- OpenSpec: pep-13 archived into spec agent-credentials

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 22:06:37 +05:00
Асель
39367b1d82 PEP-8: remote MCP for ChatGPT with Peppa as OAuth 2.1 server
- OAuth: RFC 8414/9728 metadata, RFC 7591 dynamic registration,
  authorization code + PKCE S256 with a consent screen after Gitea login,
  refresh token rotation; tokens and codes stored hashed; revoke in web
- /mcp: stateless Streamable HTTP, Bearer → user; PM tools from
  @peppa/mcp/manager: projects, goals, tasks, create, move (board
  semantics, starts agents), inbox, answer/accept — owner-scoped
- login keeps ?next= through Gitea OAuth; Settings page with MCP URL and
  connected apps
- 5 new tests (53 e2e total, green); verified on prod as a client:
  DCR → consent → token → MCP over HTTPS → revoke → 401
- OpenSpec: pep-8 archived into spec remote-mcp

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:38:09 +05:00
Асель
00c8f79a36 PEP-7: autonomous mode — board moves start agents, PM only for stoppers
- web board (Backlog / In progress / Review / Done) with drag-and-drop and
  buttons; moveTask starts an agent on In progress, stops on Backlog/Done
- routine proposals go straight to apply; request_approval/ask_pm only for
  architectural stoppers (RULES.md, MCP hints, template pushed to Gitea)
- Stop hook keeps the agent going (decision: block, max 2 in a row,
  sessions.auto_nudges reset by a human answer) instead of pinging the PM
- review: ready-for-review message with Accept (acceptTask → done, session
  stopped) in Telegram and web; a text reply goes back to the agent
- mock-claude honours Stop-hook block; 6 new e2e tests (48 total, green)
- OpenSpec: pep-7 archived (task-autonomy, web-workspace board)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 21:21:11 +05:00
Асель
2b0f2fd984 PEP-1: web platform with Gitea login, projects, goals, tasks, sessions
- web: Gitea OAuth2 login, signed session cookie, everything behind login;
  inbox with answers, project board (goals → tasks), task page with
  OpenSpec artifacts, questions and session controls; new project form;
  auto-refresh, light/dark, mobile
- users + projects.owner_id; tokens AES-256-GCM encrypted; owner-only access
- provisionProject (runner): new or existing Gitea repo, peppa-bot
  collaborator, template + openspec init, push, rollback; used by web and
  peppa project create (replaces scripts/bootstrap-project.sh)
- peppa web login-link, peppa project owner; Gitea OAuth app script
- bins/template resolved via PEPPA_ROOT (works inside the Next build)
- testkit: mock-gitea + 10 tests (42 e2e total, all green)
- OpenSpec: pep-1-web-platform archived into specs web-auth,
  project-provisioning, web-workspace

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:55:02 +05:00
Асель
9cf0d53303 Add Telegram bot: pairing, durable outbox, answers from buttons and replies
- bot: own Bot API client, long polling with persisted offset, updates
  claimed before acting (no replay after restart), outbox with retries
  (429 retry_after, 5xx), /start pairing code (hashed, single use, 10 min),
  only the paired chat/user is served
- PM questions rendered per kind: approve button / reply to reject,
  option buttons, allow/always/deny, alerts with continue or resume/stop;
  messages are closed with who answered what, incl. terminal answers
- stopping/resuming a session expires its open questions
- CLI: peppa telegram pair|status|unpair; launchd agent for the bot
- testkit: mock-telegram + 11 bot journeys (32 e2e tests, all green)
- fix: keep the tmux server alive when empty (exit-empty off) — a new
  session could die with a server shutting down after the last kill
- fix: test env must load before runner modules (no leaks to real tmux)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:26:58 +05:00
Асель
1df550bb86 Add Codex provider, mock agents and end-to-end CJM suite
- runner: provider abstraction (claude | codex); per-run launch.sh keeps
  long argv out of tmux; Codex via notify callback + -c config for rules
  and the peppa MCP server; session env carries DATABASE_URL/PEPPA_HOME
- testkit: mock-claude / mock-codex driven by scenarios — real hooks,
  notify, MCP calls, raw-mode TUI input with bracketed paste, permission
  dialog, usage limits, hangs, crashes, /clear
- 21 CJM tests on an isolated DB, tmux server and state dir (all green)
- fix: watchdog crash/stall alerts showed blank lines instead of the tail
- bins load .env without overriding the caller's env; tmux socket option
- AGENTS.md (was CLAUDE.md) and shared RULES.md: mock-first rule with a
  mock prefix for anything blocked on external dependencies

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 20:09:43 +05:00