Commit Graph

943 Commits

Author SHA1 Message Date
Дмитрий db469fbb89 feat(pdn): ретеншен ПДн удалённых лидов — анонимизация soft-deleted сделок — F-P1
152-ФЗ блокер B1/F-P1: телефоны и имена контактов soft-deleted сделок не
вычищались и хранились бессрочно. Добавлена плановая команда-ретеншен.

Команда pd:scrub-soft-deleted-deals анонимизирует phone/contact_name/phones
сделок с deleted_at старше N дней; N из system_settings
pd_scrub_soft_deleted_deals_days, по умолчанию no-op — юр.срок не зашит в код.
Значения затирания идентичны PdErasureService. Cross-tenant через
pgsql_supplier BYPASSRLS, идемпотентно, summary-запись в pd_processing_log
системным актором. Планировщик ежедневно 03:30 МСК с heartbeat.

Схема v8.41: partial index deals_deleted_at_index ON deals deleted_at WHERE
deleted_at IS NOT NULL для дешёвой выборки; счётчик индексов 120 на 121.

F-T2 проверен: /api/admin за middleware saas-admin fail-closed 503 — кодовой
правки не требует.

TDD: 4 Pest ScrubSoftDeletedDealsCommandTest GREEN. Escape-per-write — печать
церемонии не опечатывала план.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 17:24:48 +03:00
Дмитрий 714d6885f9 feat(security): middleware безопасных HTTP-заголовков — закрытие ZAP Medium anti-clickjacking
X-Frame-Options SAMEORIGIN + X-Content-Type-Options nosniff + Referrer-Policy на все web-ответы (go-live аудит 17.06). CSP вынесен отдельно (SPA Vue+Vuetify). TDD-тест на публичном /.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 17:12:32 +03:00
Дмитрий 71234d719a fix(dashboard): верхняя строка дашборда — настоящие числа вместо заглушки — F5
Строка-приветствие показывала захардкоженную рыбу: +3 новых лида с утра,
сегодня 11 / вчера 38, средняя стоимость 2 248 руб. Числа ни к чему не были
привязаны — остаток прототипа Sprint 4.

Бэкенд: DashboardController.summary отдаёт avg_lead_cost_rub — среднее
фактически списанных rub-сумм за окно периода: AVG price_per_lead_kopecks
WHERE charge_source rub делить на 100; null если в окне нет rub-списаний.
Тот же источник, что карточка сделки F2.

Фронт: DashboardPageHead принимает пропы сегодня/вчера/средняя; сегодня и
вчера берутся из activity.points последняя точка сегодня; средняя из
avg_lead_cost_rub, прочерк при null. Размытое +3 с утра убрано.

TDD: 2 Pest DashboardSummaryTest 10/10 + 4 vitest DashboardPageHead;
полная фронт-сюита 959 passed / 3 skipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 16:02:04 +03:00
Дмитрий e752575825 fix(billing): столбец «Операция» в обзоре — ярлык по типу операции — F4
История транзакций в обзоре биллинга показывала пустой столбец «Операция»:
списания за лид LedgerService создаёт без description, а таблица выводила
поле как есть без запасного текста. Добавлен ярлык по типу операции
с приоритетом сохранённого description. Косметика отображения,
денежных значений не касается. TDD: 2 vitest, 955 passed / 3 skipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 15:07:26 +03:00
Дмитрий d0c6fcd55f fix(billing): единый источник runway — дашборд = биллинг (F3)
Дашборд считал «хватит на дни» от legacy balance_leads (≈0 для рублёвых тенантов)
и расходился с биллингом. Введён общий RunwayCalculator; оба контроллера считают
runway от affordable leads (рубли→лиды по тарифу, BalanceToLeadsConverter). Фронт
DashboardView больше не режет число дней до 7 сегментов полосы. TDD: 4 Pest нового
сервиса + обновлён DashboardSummary + 1 vitest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 14:07:22 +03:00
Дмитрий d5f8b11526 feat(deals): карточка показывает реальную стоимость лида — F2
Backend: GET /api/deals/{id} отдаёт cost_kopecks — снимок rub-списания из
lead_charges по deal_id, либо null для prepaid/не списано. Frontend: ApiDeal.cost_kopecks
→ MockDeal.costKopecks → карточка DealDetailBody показывает formatCost(costKopecks/100)
либо прочерк вместо вводящего в заблуждение 0 рублей. TDD: 3 Pest + 4 vitest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 13:30:46 +03:00
Дмитрий 5c39b65c78 feat(deals): карточка сделки показывает Город — F1
Поле Город добавлено в секцию Параметры DealDetailBody со значением deal.city,
прочерк при пустом. TDD: 2 теста в DealDetailBody.spec.ts. Чистое отображение,
денежных полей не касается.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 12:40:49 +03:00
Дмитрий 59831cf7dc imitation phase1 merge
# Conflicts:
#	app/app/Console/Commands/PhoneRangesImportCommand.php
#	app/app/Jobs/RouteSupplierLeadJob.php
#	app/app/Services/LeadRegionResolver.php
#	app/database/migrations/2026_05_31_100000_create_phone_ranges_and_resolution_log.php
#	app/tests/Feature/Console/PhoneRangesImportCommandTest.php
#	app/tests/Feature/Jobs/RouteSupplierLeadJobTest.php
#	app/tests/Feature/PartitionsCreateMonthsTest.php
#	cspell-words.txt
#	docs/observer/STATUS.md
#	tools/enforce-powershell-gate.test.mjs
#	tools/enforce-router-gate.mjs
#	tools/enforce-router-gate.test.mjs
#	tools/enforce-tdd-gate.test.mjs
#	tools/enforce-tdd-real-test-verifier.mjs
#	tools/enforce-tdd-real-test-verifier.test.mjs
#	tools/enforce-verify-record.test.mjs
#	tools/mcp-tool-classifier.test.mjs
#	tools/shell-content-rules.test.mjs
2026-06-17 08:03:35 +03:00
Дмитрий 2d76f53563 F-5 eslint: 0 problems
DealDetailDrawer: default для tenantId (require-default-prop). AdminPdSubjectRequestsView: v-slot:[...] в #[...] (v-slot-style, auto-fix). 2 region-спека: disable-комментарий no-explicit-any для VueWrapper-кастов F-3 - по конвенции 9 соседних тестов.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 07:22:08 +03:00
Дмитрий ae286b9a0d WIP чекпойнт: lead-region/supplier бэкенд + фронт-редизайн + Pint + тесты
92 файла одной пачкой. Исключены чужие зоны: CLAUDE.md, .claude/settings.json, docs/observer/.pii-counters.json.
gitleaks staged: no leaks found. Не верифицировано тестами - сохранение труда в историю.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 05:17:12 +03:00
Дмитрий 989afff5ad F-3 type: 3 vue-tsc TS2345 в region-тестах - cast findComponent к VueWrapper any + props - vue-tsc чисто
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 04:38:55 +03:00
Дмитрий b87d9208ca F-2 refactor: цвет stat-success вынесен из инлайна в scoped-правило по прецеденту .sep - тест TenantsStatsHeader зелёный
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 03:35:48 +03:00
Дмитрий d39a10cd2e F-2 a11y Tenants: label поиска по ИНН + AA-класс stat-success счётчика активных - 2 теста зелёные, регрессия 946 passed
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 03:17:32 +03:00
Дмитрий 9171f1dc60 chore: regenerate larastan baseline - absorb lead-region drift
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 13:43:12 +03:00
Дмитрий e80f465c83 fix: 152-FZ erasure - surgical scrub of deals.phones JSONB plus email no-op, F-P1b
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 11:54:45 +03:00
Дмитрий 963b5c6c2b fix(security): composer update — patch 14 CVE (laravel/framework, guzzle psr7, symfony yaml/http-foundation)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 08:08:30 +03:00
Дмитрий 25a2d551af feat: merge lead-region cascade to main — deals-city + rossvyaz normalize, prod-parity verified
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 07:28:33 +03:00
Дмитрий 4022a71bac feat: merge lead-region cascade to main — deals-city + rossvyaz normalize, prod-parity verified
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 07:17:38 +03:00
Дмитрий c7762b2d38 chore: prune brain test-layer to claude-brain
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 05:03:55 +03:00
Дмитрий cbb70b3985 chore(imitation): remove DB password from tracked phpunit.xml (B4)
DB_USERNAME/DB_PASSWORD now come from the untracked local .env (dev creds postgres/liderra_dev_pass that already match liderra_testing on the same local Postgres). phpunit.xml keeps only the non-secret DB_DATABASE/DB_CONNECTION override. Verified: tests still connect (FakeDaDataClientTest 3/3 GREEN) without the env vars in phpunit.xml. .env.testing remains gitignored.
2026-06-04 05:21:39 +03:00
Дмитрий f3e214e22a feat(imitation): imitation:seed command to populate local portal
Self-contained app-namespace artisan command (NEVER on production) that funds local imitation clients on a shared B2 supplier, disables DaData (region from tag), rebuilds the routing snapshot, then injects synthetic leads through the real RouteSupplierLeadJob so deals/charges/notifications appear for hands-on UI review. The lead payload encodes the supplier unique_key as a domain so RouteSupplierLeadJob re-resolves the real supplier (parseProjectField then resolveOrStub). Test asserts exit 0 + new deals.
2026-06-04 05:09:29 +03:00
Дмитрий efee04b5d4 test(imitation): topologies + money + intake checks 2026-06-04 04:58:20 +03:00
Дмитрий 852be5eae0 test(imitation): X1 step-3 substitution + X3 source breakdown 2026-06-04 04:45:37 +03:00
Дмитрий aadfcafc96 test(imitation): scenarios G5/G6 special leads + dedup 2026-06-04 04:38:12 +03:00
Дмитрий c3ee3e77c6 test(imitation): scenario G3 orphan lead 2026-06-04 04:29:35 +03:00
Дмитрий cafc161b17 test(imitation): scenarios E1/E2/F freezes + limit 2026-06-04 04:25:00 +03:00
Дмитрий 0a0efe05bf test(imitation): scenario D delivery days 2026-06-04 04:19:30 +03:00
Дмитрий 631e3cc4f4 test(imitation): scenarios B/C region cascade 2026-06-04 04:14:57 +03:00
Дмитрий 8d724055eb fix(imitation): correct seedPhoneRange columns + import_id FK (F1)
ImitationTestCase::seedPhoneRange used non-existent columns (range_from/range_to/region_name) and omitted the required import_id FK, so every Россвязь-branch test that called it failed. Now seeds a phone_ranges_imports anchor row and inserts phone_ranges with the real columns (def_code/from_num/to_num/operator/region/subject_code/imported_at/import_id), mirroring the verified RossvyazPrefixLookup parsing. Found during Task 5.
2026-06-04 03:54:22 +03:00
Дмитрий 8df2bdaa35 test(imitation): scenario A weighted lottery + distribution stats 2026-06-03 20:21:22 +03:00
Дмитрий ad458bc535 test(imitation): region resolution cascade coverage 2026-06-03 20:08:49 +03:00
Дмитрий b7a2f66cb9 fix(migrations): clean migrate:fresh resilience (partition parent guard + delta idempotency)
Restores a working migrate:fresh without the reverted blanket catch-all. (1) MonthlyPartitionManager::ensureMonth skips a partitioned table whose parent does not exist yet (targeted pg_class relkind='p' guard) instead of crashing — the initial schema-load runs partitions:create-months before later delta-migrations create their own partitioned tables. (2) migration 0001 runs with $withinTransaction=false so the schema.sql DDL is committed before partitions:create-months opens its second pgsql_supplier connection. (3) re-applies the clean idempotency guards on add_balance_freeze (DROP POLICY IF EXISTS) and add_paused_at (column/index existence checks) since schema.sql already contains those objects. migrate:fresh now rebuilds liderra_testing cleanly; MonthlyPartitionManagerTest 15/15 incl. new resilience guard test.
2026-06-03 20:01:55 +03:00
Дмитрий a21554152d feat(imitation): test clients + single-project matrix seeder 2026-06-03 19:37:49 +03:00
Дмитрий ceb7637876 feat(imitation): snapshot forge + condition levers 2026-06-03 19:09:12 +03:00
Дмитрий 78c2e1bde3 revert(imitation): drop out-of-scope migration edits from 6f81d136 + dead webhook_log test
Reverts 6f81d136 production-migration edits (load_initial_schema withinTransaction=false + try/catch, idempotency guards) and coupled migrate:fresh guard tests to baseline; imitation suite uses DatabaseTransactions on a pre-migrated DB so the reverted migrate:fresh resilience is not needed for Phase 1. Also drops the orphaned ensureMonth webhook_log test (webhook_log removed from PARTITIONED_TABLES in 2026_05_24_140000_drop_legacy_webhook_artefacts).
2026-06-03 18:58:13 +03:00
Дмитрий 6f81d13612 chore(imitation): Task 0.5 — test env, reference-seed base, migrate:fresh resilience 2026-06-03 16:49:23 +03:00
Дмитрий 29ec68d3cc docs(imitation): plan — execution status + corrections (namespace, subject codes, Task 0.5 env provision) 2026-06-03 16:25:52 +03:00
Дмитрий 0cd6063af6 feat(imitation): deterministic fake DaData phone client 2026-06-03 15:35:46 +03:00
Дмитрий 39d9b0b51b docs(imitation): Task 0 — pin verified signatures + plan corrections 2026-06-03 14:57:48 +03:00
Дмитрий 1a746087f0 feat(deals): backfill command for «Город» on existing deals
deals:backfill-region-city fills deals.city from the lead resolved_subject_code (deals -> supplier_lead_deliveries -> supplier_leads) for deals where city is still empty, idempotently and across all tenants (BYPASSRLS). --dry-run reports the count without writing. Whitelisted in artisan-run.yml (dry-run read-only; real run requires confirm_apply). TDD: +4 tests GREEN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 13:38:10 +03:00
Дмитрий e62edb5b69 feat(deals): fill «Город» (deals.city) with resolved region name
The UI «Город» column binds to deals.city but nothing ever populated it — the region was only stored as a numeric code on supplier_leads + the resolution log. RouteSupplierLeadJob now writes the resolved subject name (RussianRegions::CODE_TO_NAME) into deals.city on deal creation (the lead's real region, even if subject_code is substituted on routing step 3), and updates it in the CSV-merge branch when the webhook resolution outranks the tag. New deals now display the region. TDD: +2 tests in RouteSupplierLeadJobTest; 24 job tests GREEN.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-02 13:16:31 +03:00
Дмитрий bfe95a24d1 fix(region): wrap phone_ranges swap in a transaction + drop stray comment (code-review) 2026-06-01 07:32:15 +03:00
Дмитрий a5019b6112 feat(region): phone-region:smoke staging command 2026-06-01 07:21:15 +03:00
Дмитрий 7715ca16fe feat(region): RouteSupplierLeadJob — resolve region + persist + fail-safe log + step-3 substitution + CSV-merge 2026-06-01 07:21:08 +03:00
Дмитрий aad37cac35 feat(region): Deal — region_substituted + phone_operator fields 2026-06-01 07:21:01 +03:00
Дмитрий 0bb1143836 feat(region): LeadRouter cascade routing (exact→all-RF→fallback) + weighted pick variant В + routing_step 2026-06-01 07:19:54 +03:00
Дмитрий d9c0ca1b59 test(region): createRoutingSnapshotFromProject accepts regions param 2026-06-01 07:19:46 +03:00
Дмитрий 594835ffdf feat(region): LeadRegionResolver orchestrator (full qc cascade) 2026-06-01 07:19:37 +03:00
Дмитрий 4bba80eebc feat(region): DaData layer (region map, config, enum, client, budget guard) 2026-06-01 07:19:29 +03:00
Дмитрий c068834eb6 feat(region): phone-ranges:import command (parse/map/dry-run/idempotency) 2026-06-01 07:18:23 +03:00