# Historical Nuhet cleanup evidence through successor startup - 2026-10-05

This is an evidence archive, not an operational runbook. Every former migration, campaign activation, rate, canary and immediate-purge proposal below is retired. Do not execute historical instructions. Follow [the current retention checkpoint](../known-spam-campaign-recovery.md).

## Status

Successor startup (2026-10-05): user-facing root `p_9ac9f4823d66` has read the opening handoff and full checkpoint. Fresh supported state verifies DESKTOP-7NVPSJ5, workspace `w_de89eeeeb938`, title `NUHET: CLEAN UP #1`, Windows cwd `C:\Users\zerav`, and preservation of the original pane. Effective runtime is workspace-write with restricted network; full access was not inherited. Approved WSL runner/audit preflight returned exit 0, same branch and HEAD `9172df55`, only this checkpoint modified and diff check clean; no applicable project/ancestor instructions found. Latest remote master was freshly fetched at `4168cba27ba15a81fbd75824d613e3587364d0f5`, merge base `8fd696b8`; integration is pending. Card #1921 and doctrine freshly read, sole Jonathan/In Progress/high/estimate90 verified. Subsequent card assignment/column calls and read-only Nuhet probe returned `user rejected MCP tool call`; they have not been retried. Startup message to originating pane is pending approval/delivery. No live command, account change or migration attempted. Root owns recovery/integration; one native in-thread worker prepares the code candidate from a hash-verified tracked-source snapshot in approved scratch because its UNC reads are denied. Native apply_patch cannot traverse the UNC reparse point; root applies patches in approved scratch and brokers guarded copies through the approved WSL runner. Pinning remains unavailable. Independent review, tests, integration, deployment gates and exact cohort review remain pending.

CURRENT DIRECTION (user request 2026-10-05): withdraw the immediate known-spam purge plan. Spam accounts must use the same non-destructive deletion marking and 12-calendar-month grace period as all other accounts. Retain their users, relationships, files and statistics throughout that period; permanent account-data cleanup must have no spam, queue or explicit-ID retention bypass. Interpret "other danger tools" within account-data deletion scope, not as permission to remove unrelated mail/media/admin functionality. No application code or production state has yet been changed for this new direction. The earlier deployment/audit history below remains evidence, not an activation plan.

GitHub PR #1448 was squash-merged to `master` as `97f1b90ff436bade3904e41ff8f7ef24a366b43c` and the user fast-forwarded production `/var/www/html` to that exact commit. Xhronos card #1921 remains open and In Progress. The original campaign ended 2026-10-01 without activation. On 2026-10-05, Xherd successfully executed read-only SSH, privileged Artisan checks, and a renewed complete full-audit dry-run using the shared `Nuhet` host profile. SSH access and the visible-pane execution path are now verified. All 1,815 scoped candidates are still full-audit eligible, with zero exclusions. The campaign remains disabled and expired; the last preflight failed because the claim table is missing. No campaign migration, activation, dispatch, or deletion has occurred. Nuhet MCP remains read-only.

## Scope and worktree

- Read-only live Nuhet MCP on 2026-09-24 found 1,815 active, free companies in IDs 43269-45090 with names containing `tw1.ru` (1,260) or `swtest.ru` (555). All were older than 30 days, had no Stripe record or main-user login/activity in the inspected fields, and had no relevant pending or failed cleanup jobs. This is a candidate count, not a full-audit deletion approval. The previous 20 user-run deletions, IDs 43249-43268, are separate and complete.
- Isolated worktree `/var/www/nuhet-spam-campaign-20260924`, branch `codex/nuhet-spam-campaign-20260924`, rebased on fresh `origin/master` at `8fd696b829c18956f72460cb55c710b66cc37d99` (two unrelated DMARC commits). Local implementation commit after rebase `97f8038c`; checkpoint commit `c96a1b96`. Primary `/var/www/nuhet` was not edited.
- Fresh handoff filesystem/Git check on 2026-10-05: same branch, current local HEAD `9172df55f661c1981da2f5cb4b956456f0c4bbe8`; only this recovery document is uncommitted and `git diff --check` passed. Successor must verify latest main/ancestry before integration; no Git network operation was performed for this handoff.
- Fixed cohort, full `CompanyCleanupAudit` revalidation, bounded paginated dry-run, explicit database queue, separate per-company queue names, at most 24 in flight and three processed per scheduler tick. `config/known_spam_campaign.php` enables nothing by default and ends 2026-10-01 23:59:59.
- Claim migration adds a company claim table and `BEFORE UPDATE` trigger. Queued claims cancel on company changes. While a worker owns a per-company MySQL named lock, other sessions cannot update that company; the worker revalidates scope, age, activity, claim token, and frozen fingerprint before invoking `CustomerCleanup` and checks lock ownership before and after it. `--preflight` checks queue/claim safeguards read-only even with activation off.

## Verification and open gates

- Focused SQLite unit suite: 31 tests, 196 assertions passed after rebase. Real two-connection disposable MariaDB test: 1 test, 5 assertions passed after rebase against the actual migration and lock service. Repository-wide suite: 199 tests, 1,158 assertions passed after fixing an unrelated new DMARC test fixture to match its production migration (`match_method`, `processing_error`); one PHPUnit deprecation remains. PHP lint passed for changed campaign PHP classes and migration before rebase. Disposable database was removed; no `nuhet_claim_test_` database remained in `SHOW DATABASES`. Production reports MySQL 8.0.34, not MariaDB, so disabled production migration and trigger preflight remain mandatory.
- Independent final review found no immediate SQL/control-flow activation blocker under the single persistent `mysql` connection assumption. A lost/reconnected DB session during `CustomerCleanup` is not fully covered; the post-cleanup lock check catches loss but cannot undo partial cleanup. Treat this as a halt-and-investigate condition, not an automatic retry. The reviewer also confirmed `--preflight` is account/job read-only.
- Production migration and `--preflight` must be verified after deployment while the campaign remains disabled. Production dry-run pages must be reviewed with full audit, and backup/restore readiness confirmed. Require explicit user approval for permanent deletion of this exact cohort, rate, and window before setting the activation flag. Monitor failures and reconcile actual deletions daily; halt on unexpected results. Do not widen to other accounts as a shortcut to a clean slate.
- Temporary test bootstrap/cache files were removed after verification. GitHub has no automated checks or deployments for this PR; the only active push webhook targets Slack. After the production code pull, stale Laravel config cache initially made the campaign appear empty. The user ran `config:cache` as `www-data`; fresh `config:show` reports the expected disabled config, IDs 43269-45090, patterns `tw1.ru`/`swtest.ru`, package 1, 30-day age, 24 in flight, 3 jobs/tick. On 2026-09-25 the user ran the complete paginated production dry-run: four pages of 500, 500, 500, and 315; all 1,815 were full-audit eligible, no exclusions, and the last page reported `has_more=no`. This was read-only. Fresh 2026-09-28 Nuhet MCP independently found the same 1,815 matching active companies, zero campaign pending/failed jobs, no claim table, and no pre-existing trigger on `companies`. The user confirmed a backup was done; its exact timestamp, database/storage coverage, and restore-test status were not supplied. Treat full-server coverage and a usable restore path as an explicit condition of the disabled migration handoff.

## Next actions

1. Successor CREATED on 2026-10-05 after user answered "Yes, proceed and make this happen" to the exact continuation proposal. "NUHET: CLEAN UP #1", tab `t_183b569d4c04`, pane `p_9ac9f4823d66`, is visible/running as Codex in the same verified workspace `w_de89eeeeb938` (`C:\Users\zerav`); original tab/pane remain present. Creation returned model `gpt-6.1-sol`, effort `xhigh`, permission mode `manual`, and `not_inherited=[permission_mode]`. The complete handoff is queued as its first message; receipt/readback do not establish that it was read or startup/runtime/tool/service preflight passed. Those confirmations remain pending. No supported pin control or pin-state readback is exposed, so pinning is unverified. The new root must independently preflight before implementation and then owns task code/checkpoint writes; originating root finishes only this narrow transfer metadata and performs no duplicate implementation. Latest user explicitly requires removal of obsolete commands when replacement is complete. Preserve this task, branch, worktree and documentation edits; do not ask for the same creation approval or create another successor for missing verification controls.
2. Establish the universal retention guard before retiring entry points: deletion marking preserves all account data; the retention clock starts at the actual deletion timestamp, not registration age or expiry; marking twice cannot shorten/reset the grace period; restoration cancels eligibility. Permanent cleanup must require a still-deleted company older than 12 calendar months, revalidated before mutation, including when an explicit ID or an old serialized queue job is supplied. Keep billing/payment side effects outside a blanket data-restore promise and preserve legitimate cancellation semantics unless an actual conflict is found.
3. Explicit acceptance requirement from latest user: clean up old commands no longer needed once the replacement works. Retire the immediate-purge campaign command/schedule/runner/claims activation flow and AutoRemoveCompanies permanent-dispatch behavior, remove stale registrations/references/config/docs/tests as appropriate, and verify command discovery no longer exposes dangerous obsolete entry points. Review old serialized CompanyDispatcher payload compatibility; do not simply remove a class while jobs can reference it. Do not install the unused claim migration or trigger. A schema cleanup, if needed on any environment where it was applied, requires a separate verified forward migration and live gate, not deletion of historical state or ad-hoc rollback. Necessary inert compatibility handling is distinct from retaining an executable purge shortcut; document any deliberate temporary compatibility remnant.
4. Local trace found three additional retention bypasses: CustomerCleanup --company-id selects without deleted_at/age restrictions; its fallback purges allow_sendouts=0 accounts after one month; CompanyController::deactivate queues CompanyDispatcher after expiry plus seven days, and that worker invokes destructive CustomerCleanup before --keep-company soft-deletes the company. Replace data destruction at these stages with appropriate non-destructive deletion marking, while preserving unrelated cancellation, notification and restore behavior. Inspect the complete relevant call graph and authorization/account-access checks before implementation; this trace is not an exhaustive proof all paths are mapped.
5. Add regression tests: deleted/recent/spam/active/restored accounts, exact 12-month boundary and repeated marking, preservation of users/relations/files/statistics, explicit-ID and stale-job refusal, no immediate purge schedule/dispatch, and isolation from unrelated accounts. Consequential code requires independent review, root acceptance, focused/full tests and fresh state verification. The existing test split recommendation should be assessed within the affected test work, not as a separate broad refactor.
6. Deploy only the verified candidate using the approved guarded Git-bundle path; do not use config:cache. Current production source comparison for app/Console/Commands/CustomerCleanup.php remains unverified after a denied read-only command; do not bypass or silently retry that decision. No production account changes follow from local implementation or deployment authority: explicitly review a bounded dry-run and the soft-delete operation before applying it to the fixed spam cohort. No scope widening to all inactive accounts.

Fresh 2026-10-05 read-only Nuhet MCP verification before this policy change found zero campaign pending jobs, zero campaign failed jobs, and zero legacy pending/failed jobs in IDs 43249-45090. This is not a full residual-data audit and does not prove absence of older partial deletions outside or inside that scope.

## Safety review - 2026-10-05

Historical review of the now-withdrawn immediate-purge plan. The new universal grace-period direction supersedes the migration/activation/canary proposal below. Its partial-deletion findings remain relevant to the eventual retention cleanup; a grace period alone does not make that permanent purge atomic.

No production command, migration, configuration change or deletion was submitted during this review. The local reviewed release was inspected in full for the migration, claims, scope, runner, dispatcher, cleanup command and eligibility audit. The actual production `CustomerCleanup.php` comparison remains unverified after the previous denial; local findings are not proof of its current live contents.

- Image recovery is last resort. This server also hosts other applications; whole-server restoration can roll back unrelated legitimate changes. The user explicitly rejects treating that as smooth or easy. A verified targeted recovery procedure must cover the precise affected database records, statistics tables and files, and be rehearsed in isolation before deletion. No such procedure or export has been implemented or tested yet.
- `app/Console/Commands/CustomerCleanup.php` (659 lines, 28,005 bytes) performs sequential permanent row deletes, media/import directory deletion, and statistics-table drops on a separate connection. It contains no enclosing transaction or compensating recovery. Returning an error, timeout, or loss of DB session can leave partial cleanup. `--keep-company` only preserves a soft-deleted company row after removing its data; it is NOT a quarantine or undo mode.
- Eligibility and deletion footprints differ. For example, cleanup removes `user_comments` by `user_id OR author_user_id`, whereas the audit checks only `user_id`; cleanup also deletes user/company-created `notices` (not the audited `notice_user` pivot), user-owned media regardless of company, and reseller relations not listed in the audit. These are code-level coverage gaps, not evidence those rows exist for this cohort. Review the complete deletion footprint and add conservative exclusions/tests before treating the 1,815 eligible results as sufficient deletion evidence.
- The company trigger guards `UPDATE companies`, not every user/child-table write. Verify that the frozen state and worker controls prevent relevant concurrent activity through all application and background paths; the current trigger alone cannot prove that. Named-lock checks only before/after cleanup also leave the already-recorded connection-loss partial-deletion risk open.
- The migration adds a trigger on every company update even while campaign activation is off. Its table creation and trigger creation are separate DDL statements, with a catch path that drops the claim table. Interruption can leave partial schema state; a lost acknowledgement after trigger creation warrants explicit inspection before any retry or table removal. Never blindly rerun or roll back a migration after an uncertain result. MySQL atomic DDL does not make the entire multi-statement migration transactional: see [MySQL 8.0 atomic DDL](https://dev.mysql.com/doc/refman/8.0/en/atomic-ddl.html) and [implicit commits](https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html).
- Existing real-engine tests used MariaDB, not production MySQL 8.0.34, and exercised the two-connection claim trigger rather than the complete real deletion footprint. A production-equivalent isolated rehearsal must include unrelated-account preservation, interruption/connection-loss behavior, schema recovery and account-level restoration. Do not install a new runtime or copy production private data without the applicable authority and storage controls.
- Before a canary, enforce an exact approved company ID and max-in-flight/max-jobs of one with a controlled one-shot path that cannot be multiplied by the scheduler. Current `--limit`/`--after-id` apply only to reporting; ordinary `--apply` can freeze/queue up to 24 and process three. A one-account canary gate is not implemented or verified yet. Increase throughput only after fresh deletion-footprint checks, canary acceptance and explicit activation approval; any discrepancy or partial failure halts work without automatic retry.

Next safe work is local hardening and tests plus a concrete isolated rehearsal/recovery plan, not an activation command. Prior backup-first migration advice is superseded by this safety hold. The existing deferred campaign-test split recommendation below remains unchanged.

## SSH readiness verification - 2026-10-05

- Updated Xherd daemon 0.291.0 on the Windows machine exposes the shared `Nuhet` profile, working directory `/var/www/html`, password authentication, stored sudo support, and per-command confirmation. `ssh_get_notes` now returns successfully.
- Read-only connection returned `nuhetftp`, `post.nuhet.se`, `/var/www/html`, and the expected sudo/www-data group membership. A separate `sudo=true` call returned `root` and successfully ran Artisan via `runuser -u www-data`.
- Fresh production checkout: clean tracked `master` at `4168cba27ba15a81fbd75824d613e3587364d0f5`. Server clock returned 2026-10-05T11:56:44+02:00. `/var/www/html` is on a 243 GB filesystem with 208 GB used, 24 GB available, 90% used. No AGENTS.md or AGENTS.override.md files were returned from the checked production ancestors. Do not force production back to the earlier campaign merge commit.
- `config:show known_spam_campaign` reports enabled=false, end=2026-10-01 23:59:59, IDs 43269-45090, patterns `tw1.ru` and `swtest.ru`, package 1, age 30 days, max in flight 24, max jobs per tick 3. `KnownSpamCleanupCampaign --preflight` exited 1 with: `Campaign claim table is missing; cleanup remains disabled.` This is an application preparation failure, not SSH or sudo authentication failure.
- The earlier 2026-10-05 read-only Nuhet MCP check found 1,815 matching active companies; zero campaign pending jobs; zero campaign failed jobs; no claim table; no migration entry for `2026_09_24_000001_create_known_spam_cleanup_claims`. At that point the last full-audit report was from 2026-09-25; it was subsequently refreshed successfully as recorded below.
- The initial supplemental full audit was requested as a bounded five-page read-only SSH command in a visible terminal pane, with campaign release ancestry/diff guards. Xherd returned `denied by user` at the confirmation deadline; no execution output was produced and the command was not retried in that turn. Fresh workspace state returned afterward and showed no new terminal pane in the Nuhet tab. The existing exited SSH pane was preserved. At that point only short headless SSH/sudo capability was verified; the visible-pane path was subsequently verified after explicit renewed user authorization.
- Later on 2026-10-05, the user explicitly approved requesting the read-only audit again with `Proceed`. Fresh Xherd diagnostics and host inventory returned, the shared `Nuhet` deployment notes were read, and the new visible-pane sudo SSH audit completed with exit 0. It verified `root`, `post.nuhet.se`, `/var/www/html`, release ancestry, and all 1,815 candidates across pages 500/500/500/315. All were eligible; there were zero exclusions, enabled=no throughout, and final has_more=no followed by `NUHET_READ_ONLY_AUDIT_COMPLETE`. Only `app/Console/Kernel.php` showed changes among the checked campaign paths (two insertions); the subsequent inspection confirmed unrelated command registrations only. This approval covered the read-only audit, not campaign activation or permanent deletion. No account-changing command was submitted. The host inventory initially waited, then returned successfully; no cause was established or runtime settings changed. The resulting exited SSH pane is preserved.
- The follow-up config/migration/preflight check completed: production HEAD is still `4168cba27ba15a81fbd75824d613e3587364d0f5` with no tracked changes; effective campaign remains disabled with the original expired dates and unchanged cohort/rate. The exact claim migration is `Pending`. Preflight returned exit 1 specifically because the claim table is missing. Kernel's two new lines only register `BackfillHardBouncedReceivers` and `ReconcileArchivedHardBounces`; they do not alter cleanup scheduling. Company/User model paths show no diff. A local dispatcher read identified the actual `CustomerCleanup` command path. The final read-only comparison for that command returned `denied by user`; no execution output was produced, it was not retried, and its current diff is NOT VERIFIED. This denial does not invalidate the completed 1,815-candidate dry-run, but it remains a code-verification gate before destructive activation.
- IMPORTANT newly available host doctrine: never run `php artisan config:cache` on this host. Host notes record that rebuilding the config cache previously blanked runtime `env()` calls and broke SMS. The earlier user-run 2026-09-24 config rebuild preceded discovery of this warning; no new config rebuild was performed and no claim is made about current SMS health. Future campaign-only setting changes must preserve unrelated cached values.
- Host notes also prohibit assuming GitHub credentials exist on production. A future authorized code deployment uses a locally verified Git bundle uploaded by SFTP and a guarded fast-forward, not ad-hoc credential setup or GitHub fetch. Do not use the Xhronos deploy key for Nuhet.

GitHub PR #1448 and the merge commit are linked to Xhronos #1921. The card remains In Progress until the production campaign is verified. Do not deploy or activate without the remaining release gates.

## Maintenance recommendation

`tests/Unit/CompanyCleanupAuditTest.php` is now 1,017 lines and mixes audit, legacy report, and campaign coverage, making focused navigation/review harder. After the safety gate, move campaign-specific tests to `tests/Unit/KnownSpamCleanupCampaignTest.php`, extract shared fixture/setup helpers only as needed, and run both suites plus test discovery to verify behavior. This is not needed for the current disabled candidate.

## Continuity

At least five known context compactions. Earlier successor decision: declined for now; continued here. Current decision: approved successor created as `NUHET: CLEAN UP #1`, tab `t_183b569d4c04`, pane `p_9ac9f4823d66`; materialization/title/vendor/workspace and preservation of original are verified. Opening-message receipt is queued, not proof of reading; startup/preflight and pinning remain unverified as recorded above. Originating root made no application-code or production changes for this reversal and now stops project writes. This document is the recovery checkpoint; verify it again before final handoff.
