native-update 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/AI-INTEGRATION-GUIDE.md +88 -58
  2. package/Readme.md +57 -88
  3. package/cli/AGENTS.md +9 -0
  4. package/cli/CLAUDE.md +9 -0
  5. package/cli/package.json +2 -2
  6. package/dist/esm/app-update/app-update-checker.d.ts +19 -0
  7. package/dist/esm/app-update/app-update-checker.js +19 -0
  8. package/dist/esm/background-update/background-scheduler.d.ts +21 -0
  9. package/dist/esm/background-update/background-scheduler.js +47 -24
  10. package/dist/esm/core/update-check.d.ts +89 -0
  11. package/dist/esm/core/update-check.js +86 -0
  12. package/dist/esm/definitions.d.ts +11 -1
  13. package/dist/esm/live-update/version-manager.js +43 -27
  14. package/dist/esm/plugin.js +14 -20
  15. package/dist/esm/types/rollout.d.ts +9 -3
  16. package/dist/plugin.cjs.js +1 -1
  17. package/dist/plugin.esm.js +1 -1
  18. package/dist/plugin.js +2 -2
  19. package/docs/AGENTS.md +9 -0
  20. package/docs/CHANGELOG.md +51 -0
  21. package/docs/CLAUDE.md +9 -0
  22. package/docs/DEPLOY_NOTES.md +116 -0
  23. package/docs/MANUAL-TASKS.md +18 -5
  24. package/docs/api/background-update-api.md +14 -1
  25. package/docs/features/e2e-full-verification/00-overview.md +99 -0
  26. package/docs/features/e2e-full-verification/00-tracker.json +284 -0
  27. package/docs/features/e2e-full-verification/phase01-backend-schema-fixes.md +183 -0
  28. package/docs/features/e2e-full-verification/phase02-test-auth.md +176 -0
  29. package/docs/features/e2e-full-verification/phase03-api-test-coverage.md +63 -0
  30. package/docs/features/e2e-full-verification/phase04-frontend-package-contract-audit.md +73 -0
  31. package/docs/features/e2e-full-verification/phase05-browser-e2e-matrix.md +69 -0
  32. package/docs/features/e2e-full-verification/phase06-deploy-prod-smoke.md +51 -0
  33. package/docs/features/e2e-full-verification/results/phase01-drift-report.md +50 -0
  34. package/docs/features/e2e-full-verification/results/phase03-coverage-matrix.md +215 -0
  35. package/docs/features/e2e-full-verification/results/phase04-frontend-contract.md +139 -0
  36. package/docs/features/e2e-full-verification/results/phase05-e2e-results.md +99 -0
  37. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-01-dashboard.png +0 -0
  38. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-02-signup.png +0 -0
  39. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-03-settings-persisted.png +0 -0
  40. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04a-app-created.png +0 -0
  41. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-04b-duplicate-bundle-422.png +0 -0
  42. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-05-plan-limit-403.png +0 -0
  43. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08a-upload-graceful-fail.png +0 -0
  44. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-08b-builds-list.png +0 -0
  45. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-10-rollout-25pct.png +0 -0
  46. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-11-analytics.png +0 -0
  47. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-12-drive-disconnected.png +0 -0
  48. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-13-pricing.png +0 -0
  49. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-14-isolation-403.png +0 -0
  50. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15a-admin-overview.png +0 -0
  51. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-15b-regular-user-admin-redirect.png +0 -0
  52. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-16a-delete-dialog.png +0 -0
  53. package/docs/features/e2e-full-verification/results/phase05-evidence/e2e-17-mobile-375.png +0 -0
  54. package/docs/features/e2e-full-verification/results/route-list.json +1 -0
  55. package/docs/features/queues-and-emails/00-overview.md +41 -0
  56. package/docs/features/queues-and-emails/00-tracker.json +99 -0
  57. package/docs/features/queues-and-emails/phase01-foundation.md +15 -0
  58. package/docs/features/queues-and-emails/phase02-queued-jobs.md +19 -0
  59. package/docs/features/queues-and-emails/phase03-transactional-emails.md +16 -0
  60. package/docs/features/queues-and-emails/phase04-quota-ops.md +17 -0
  61. package/docs/features/queues-and-emails/phase05-async-build-processing-DECISION.md +16 -0
  62. package/docs/features/queues-and-emails/phase06-verify-deploy.md +17 -0
  63. package/docs/server-requirements.md +41 -11
  64. package/package.json +1 -1
@@ -0,0 +1,183 @@
1
+ # Phase 01 — Apps schema-drift fix + full schema↔code drift audit
2
+
3
+ **Executor:** Opus 4.8 subagent · **Working dir:** `backend/`
4
+ **Gate for the WHOLE phase:** `php artisan test` green on sqlite **AND** on MySQL (§5), then ONE commit.
5
+
6
+ Global constraints (apply to every step):
7
+ - PHP ≥8.3, Laravel 13. Follow existing code style (typed signatures, JSDoc-style docblocks stating *why*).
8
+ - Never run dev servers here; one-shot commands only.
9
+ - MySQL 8.4 is at `127.0.0.1` (`brew`-installed, `mysql@8.4`). Local DB `laravel_nativeupdate` per `backend/.env`.
10
+ - NEVER echo secrets. NEVER `console.log`-equivalents left behind.
11
+
12
+ ---
13
+
14
+ ## Task 1: Migration — add `bundle_id` + `platform` to `apps`
15
+
16
+ **Files:**
17
+ - Create: `backend/database/migrations/2026_07_10_000010_add_bundle_id_and_platform_to_apps.php`
18
+
19
+ **Why:** `StoreAppRequest` (`unique:apps,bundle_id`), `AppController::store()`, `UpdateAppRequest`
20
+ (`platform`), the website (`AppsPage.tsx`, `AppDetailPage.tsx`, `AdminAppsPage.tsx` render
21
+ `app.bundle_id`) all require columns that no migration creates → prod 500.
22
+
23
+ **Step 1 — write the migration (complete code):**
24
+
25
+ ```php
26
+ <?php
27
+
28
+ use Illuminate\Database\Migrations\Migration;
29
+ use Illuminate\Database\Schema\Blueprint;
30
+ use Illuminate\Support\Facades\DB;
31
+ use Illuminate\Support\Facades\Schema;
32
+
33
+ return new class extends Migration
34
+ {
35
+ /**
36
+ * The dashboard contract (StoreAppRequest / AppController / website)
37
+ * writes `bundle_id` + `platform`, but create_apps_table only ever
38
+ * shipped the legacy shape (`platforms` json, no bundle_id) — on MySQL
39
+ * strict mode every app-create 500'd (Unknown column). 191 keeps the
40
+ * unique index under the utf8mb4 767-byte limit.
41
+ */
42
+ public function up(): void
43
+ {
44
+ Schema::table('apps', function (Blueprint $table) {
45
+ $table->string('bundle_id', 191)->nullable()->after('app_id');
46
+ $table->string('platform', 20)->default('both')->after('bundle_id');
47
+ });
48
+
49
+ // Backfill legacy rows: pre-drift rows stored the package id in
50
+ // app_id ("com.example.app"); post-fix rows use a UUID there. Only
51
+ // package-style values (contain a dot) are meaningful bundle_ids.
52
+ DB::table('apps')
53
+ ->whereNull('bundle_id')
54
+ ->where('app_id', 'like', '%.%')
55
+ ->update(['bundle_id' => DB::raw('app_id')]);
56
+
57
+ Schema::table('apps', function (Blueprint $table) {
58
+ $table->unique('bundle_id'); // MySQL allows multiple NULLs in a unique index
59
+ });
60
+ }
61
+
62
+ public function down(): void
63
+ {
64
+ Schema::table('apps', function (Blueprint $table) {
65
+ $table->dropUnique(['bundle_id']);
66
+ $table->dropColumn(['bundle_id', 'platform']);
67
+ });
68
+ }
69
+ };
70
+ ```
71
+
72
+ **Step 2 — run it against BOTH engines:**
73
+ ```bash
74
+ cd backend
75
+ php artisan migrate # local MySQL (laravel_nativeupdate)
76
+ DB_CONNECTION=sqlite DB_DATABASE=/tmp/nu-scratch.sqlite sh -c 'touch $DB_DATABASE; php artisan migrate:fresh --force'
77
+ ```
78
+ Expected: both DONE without error. On MySQL verify:
79
+ ```bash
80
+ mysql -h 127.0.0.1 -u root laravel_nativeupdate -e "SHOW COLUMNS FROM apps LIKE 'bundle_id'; SHOW COLUMNS FROM apps LIKE 'platform';"
81
+ ```
82
+ Expected: `bundle_id varchar(191) YES UNI` and `platform varchar(20) NO 'both'`.
83
+ (If root has a password, read it from `backend/.env` `DB_PASSWORD` — never paste it into chat/output.)
84
+
85
+ ## Task 2: App model + factory follow the new contract
86
+
87
+ **Files:**
88
+ - Modify: `backend/app/Models/App.php:16-32`
89
+ - Modify: `backend/database/factories/AppFactory.php`
90
+
91
+ **Step 1 — model:** add `'bundle_id'` and `'platform'` to `$fillable` (after `'app_id'`). Keep the
92
+ legacy `platforms`/`channels` casts — columns still exist; phase01 Task 4 decides their fate.
93
+
94
+ **Step 2 — factory (complete definition):**
95
+ ```php
96
+ public function definition(): array
97
+ {
98
+ return [
99
+ 'user_id' => User::factory(),
100
+ 'app_id' => Str::uuid()->toString(),
101
+ 'bundle_id' => 'com.' . fake()->unique()->domainWord() . '.' . fake()->domainWord(),
102
+ 'platform' => fake()->randomElement(['ios', 'android', 'both']),
103
+ 'name' => fake()->words(2, true),
104
+ 'description' => fake()->sentence(),
105
+ 'platforms' => ['ios', 'android'],
106
+ 'channels' => ['production', 'staging'],
107
+ ];
108
+ }
109
+ ```
110
+ Note `app_id` becomes a UUID — matching what `AppController::store()` actually writes today.
111
+ Grep for tests relying on the old package-style `app_id` factory value and update them
112
+ (`grep -rn "app_id" backend/tests/`): the plugin-side lookups key on api-keys, not app_id format.
113
+
114
+ ## Task 3: Strengthen the masked test assertions
115
+
116
+ **Files:**
117
+ - Modify: `backend/tests/Feature/AppControllerTest.php` (`test_create_app_successfully`, the
118
+ duplicate-bundle_id test if present, and the update test)
119
+
120
+ **Step 1:** in `test_create_app_successfully` replace the DB assertion with one that includes the
121
+ new columns (this is the assertion that would have caught the bug even on sqlite):
122
+ ```php
123
+ $response->assertStatus(201)
124
+ ->assertJson(['message' => 'App created successfully.'])
125
+ ->assertJsonPath('app.name', 'My New App')
126
+ ->assertJsonPath('app.bundle_id', 'com.test.myapp')
127
+ ->assertJsonPath('app.platform', 'both');
128
+
129
+ $this->assertDatabaseHas('apps', [
130
+ 'user_id' => $this->user->id,
131
+ 'name' => 'My New App',
132
+ 'bundle_id' => 'com.test.myapp',
133
+ 'platform' => 'both',
134
+ ]);
135
+ ```
136
+ **Step 2:** add `test_create_app_rejects_duplicate_bundle_id`: create an app via factory with
137
+ `bundle_id => 'com.dup.app'`, POST the same bundle_id, expect 422 +
138
+ `assertJsonValidationErrors(['bundle_id'])`.
139
+ **Step 3:** run `php artisan test --filter=AppControllerTest` → all green.
140
+
141
+ ## Task 4: Systematic schema↔code drift audit (ALL tables)
142
+
143
+ **Why:** third instance of this bug class (device_hash truncation, bundle_id missing). Find the
144
+ rest NOW.
145
+
146
+ **Method (exact):**
147
+ 1. Fresh-migrate the MySQL test DB:
148
+ `mysql -h 127.0.0.1 -u root -e "CREATE DATABASE IF NOT EXISTS laravel_nativeupdate_audit"` then
149
+ `DB_DATABASE=laravel_nativeupdate_audit php artisan migrate:fresh --force`.
150
+ 2. Dump real columns per table:
151
+ `mysql -h 127.0.0.1 -u root laravel_nativeupdate_audit -e "SELECT TABLE_NAME, COLUMN_NAME, COLUMN_TYPE FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='laravel_nativeupdate_audit' ORDER BY TABLE_NAME, ORDINAL_POSITION"`.
152
+ 3. For EVERY model in `app/Models/` (App, ApiKey, AnalyticsEvent, Build, DeviceActivity,
153
+ SigningKey, Subscription, SubscriptionItem, User): compare `$fillable`, `casts()`, and every
154
+ column referenced in model methods/scopes against the dump.
155
+ 4. For EVERY FormRequest in `app/Http/Requests/` and every inline `validate()` in
156
+ `app/Http/Controllers/`: check `unique:<table>,<col>` / `exists:<table>,<col>` columns exist.
157
+ 5. For EVERY Nova resource in `app/Nova/`: check each field's attribute exists on its model table.
158
+ 6. Check column TYPES for truncation risks (the device_hash class): any sha256/uuid/token column
159
+ shorter than its written value; JSON written into string columns; enum drift
160
+ (values written by code vs allowed).
161
+ 7. Write findings to `docs/features/e2e-full-verification/results/phase01-drift-report.md` as a
162
+ table: `location | reference | schema reality | severity | fix`. **Fix every REAL mismatch** in
163
+ this phase (new migrations following Task 1's pattern + model/request updates + tests). Legacy
164
+ write-only columns (`apps.platforms`, `apps.channels` if truly unread) → document, leave
165
+ columns in place, remove dead casts/fillable entries only if nothing reads them.
166
+
167
+ ## Task 5: Gates + commit
168
+
169
+ ```bash
170
+ cd backend
171
+ php artisan test # sqlite :memory:
172
+ mysql -h 127.0.0.1 -u root -e "CREATE DATABASE IF NOT EXISTS laravel_nativeupdate_test"
173
+ DB_CONNECTION=mysql DB_DATABASE=laravel_nativeupdate_test php artisan test # MySQL parity — MANDATORY
174
+ ```
175
+ Expected: green on BOTH (count ≥134 + new tests). If MySQL parity finds additional failures
176
+ sqlite hid — they are in scope, fix them now.
177
+
178
+ Update `00-tracker.json` (phase01 → complete, runHistory row), then ONE commit:
179
+ ```bash
180
+ git add backend/ docs/features/e2e-full-verification/
181
+ git commit -m "fix(backend): add missing apps.bundle_id/platform columns (prod 500 on app create) + schema-drift audit"
182
+ git push origin main
183
+ ```
@@ -0,0 +1,176 @@
1
+ # Phase 02 — UI-less env-gated test-auth endpoint
2
+
3
+ **Executor:** Opus 4.8 subagent · **Working dir:** `backend/`
4
+ **Owner requirements (verbatim intent):** email+password auth for testing ONLY, no UI, only
5
+ `aoneahsan.apps.t1*` emails, URL unique + long so nobody guesses it, password never committed.
6
+
7
+ ## Security contract (all five layers required)
8
+
9
+ 1. Route **not registered at all** unless `TEST_AUTH_ENABLED=true` (config-gated) → 404 otherwise.
10
+ 2. Path contains a 64-hex secret slug from env → unguessable URL.
11
+ 3. Email whitelist regex: `^aoneahsan\.apps\.t1(\+[a-z0-9._-]+)?@gmail\.com$` (case-insensitive).
12
+ 4. Password verified with `Hash::check()` against `TEST_AUTH_PASSWORD_HASH` (bcrypt in `.env` —
13
+ repo is PRIVATE; plaintext still never stored).
14
+ 5. `throttle:5,1` + all failures logged (email only — NEVER the submitted password).
15
+
16
+ ## Task 1: Config + env
17
+
18
+ **Files:**
19
+ - Create: `backend/config/testauth.php`
20
+ - Modify: `backend/.env`, `backend/.env.example`
21
+
22
+ `config/testauth.php` (complete):
23
+ ```php
24
+ <?php
25
+
26
+ /**
27
+ * E2E test-only authentication (NO UI). Disabled unless TEST_AUTH_ENABLED
28
+ * is true; the route slug keeps the URL unguessable; only the global
29
+ * automation test accounts (aoneahsan.apps.t1*@gmail.com) may pass. The
30
+ * password is compared against a bcrypt hash — plaintext lives ONLY in
31
+ * ~/.secrets (see ~/.claude/rules/automation-test-accounts.md).
32
+ */
33
+ return [
34
+ 'enabled' => env('TEST_AUTH_ENABLED', false),
35
+ 'route_slug' => env('TEST_AUTH_ROUTE_SLUG', ''),
36
+ 'password_hash' => env('TEST_AUTH_PASSWORD_HASH', ''),
37
+ 'email_pattern' => '/^aoneahsan\.apps\.t1(\+[a-z0-9._-]+)?@gmail\.com$/i',
38
+ ];
39
+ ```
40
+
41
+ Generate the slug + hash WITHOUT echoing the password:
42
+ ```bash
43
+ openssl rand -hex 32 # → TEST_AUTH_ROUTE_SLUG value (safe to display)
44
+ # Hash: read plaintext from the global secrets file into php via stdin — never into shell history/output.
45
+ # The password is the LAST non-empty line of the "Password" row in
46
+ # ~/.secrets/test-accounts/automation-accounts.md — extract with grep/sed INSIDE the pipeline:
47
+ grep -o 'A1[^|`]*C0m' ~/.secrets/test-accounts/automation-accounts.md | head -1 | tr -d '\n' \
48
+ | php -r 'echo password_hash(stream_get_contents(STDIN), PASSWORD_BCRYPT), PHP_EOL;'
49
+ ```
50
+ Append to `backend/.env` (real values) and `backend/.env.example` (empty values + tags):
51
+ ```
52
+ # --- E2E test auth (NO UI — agent-only) -------------------------------------
53
+ TEST_AUTH_ENABLED=true
54
+ # [OPTIONAL] Registers the hidden test-login route when true. Kill-switch: set false.
55
+ TEST_AUTH_ROUTE_SLUG=<64 hex chars>
56
+ # [REQUIRED*] (test auth) Secret path segment — long + unguessable by design.
57
+ TEST_AUTH_PASSWORD_HASH=<bcrypt hash>
58
+ # [REQUIRED*] (test auth) bcrypt hash of the global automation password (plaintext lives in ~/.secrets ONLY).
59
+ ```
60
+
61
+ ## Task 2: Controller + route
62
+
63
+ **Files:**
64
+ - Create: `backend/app/Http/Controllers/Auth/TestAuthController.php`
65
+ - Modify: `backend/routes/api.php` (auth prefix group)
66
+
67
+ Controller (complete):
68
+ ```php
69
+ <?php
70
+
71
+ namespace App\Http\Controllers\Auth;
72
+
73
+ use App\Http\Controllers\Controller;
74
+ use App\Models\User;
75
+ use Illuminate\Http\JsonResponse;
76
+ use Illuminate\Http\Request;
77
+ use Illuminate\Support\Facades\Hash;
78
+ use Illuminate\Support\Facades\Log;
79
+
80
+ /**
81
+ * E2E-only login (no UI). See config/testauth.php for the gating layers.
82
+ * Mirrors the Socialite flow's outcome: a Sanctum bearer token the SPA
83
+ * consumes via /auth/callback?token=… — so browser automation signs in
84
+ * without Google, and the rest of the stack behaves identically.
85
+ */
86
+ class TestAuthController extends Controller
87
+ {
88
+ public function login(Request $request): JsonResponse
89
+ {
90
+ $validated = $request->validate([
91
+ 'email' => ['required', 'email'],
92
+ 'password' => ['required', 'string'],
93
+ ]);
94
+
95
+ $email = strtolower($validated['email']);
96
+
97
+ if (!preg_match(config('testauth.email_pattern'), $email)) {
98
+ Log::warning('test-auth: rejected non-whitelisted email', ['email' => $email]);
99
+ return response()->json(['message' => 'Forbidden.'], 403);
100
+ }
101
+
102
+ $hash = config('testauth.password_hash');
103
+ if ($hash === '' || !Hash::check($validated['password'], $hash)) {
104
+ Log::warning('test-auth: bad password attempt', ['email' => $email]);
105
+ return response()->json(['message' => 'Unauthenticated.'], 401);
106
+ }
107
+
108
+ $user = User::firstOrCreate(
109
+ ['email' => $email],
110
+ [
111
+ 'name' => 'E2E ' . ucfirst(explode('@', $email)[0]),
112
+ 'google_id' => 'test-e2e:' . $email,
113
+ 'plan' => 'free',
114
+ ]
115
+ );
116
+
117
+ if (!$user->hasAnyRole(['user', 'admin', 'super-admin'])) {
118
+ $user->assignRole('user');
119
+ }
120
+
121
+ $token = $user->createToken('test-e2e')->plainTextToken;
122
+ Log::info('test-auth: issued token', ['email' => $email, 'user_id' => $user->id]);
123
+
124
+ return response()->json(['token' => $token, 'user' => $user->only(['id', 'email', 'name'])]);
125
+ }
126
+ }
127
+ ```
128
+ Adjust `firstOrCreate` defaults to the REAL users-table columns (check the
129
+ `swap_firebase_for_socialite_on_users` migration first — e.g. `avatar`, nullable google_id, no
130
+ `plan` column if plans live elsewhere). The values above are the intent, not gospel.
131
+
132
+ Route — inside the existing `Route::prefix('auth')` group in `routes/api.php`:
133
+ ```php
134
+ if (config('testauth.enabled') && config('testauth.route_slug') !== '') {
135
+ Route::post('/test-e2e/' . config('testauth.route_slug') . '/login', [TestAuthController::class, 'login'])
136
+ ->middleware('throttle:5,1')
137
+ ->name('auth.test-e2e.login');
138
+ }
139
+ ```
140
+ Route registration depends on config → `php artisan config:cache` note for deploy (phase06 covers it).
141
+
142
+ ## Task 3: PHPUnit
143
+
144
+ **Create:** `backend/tests/Feature/TestAuthTest.php` — cases (use `config()->set('testauth.…')` in
145
+ each test; slug `str_repeat('a', 64)` for tests):
146
+ 1. disabled → POST returns 404 (route absent; use a fresh app instance / `RefreshApplication`
147
+ pattern — route registration is boot-time, so set env in `phpunit.xml` OFF and enable via
148
+ `Config::set` + `Route::post` re-registration is unreliable: instead test with
149
+ `$this->app['config']` + re-bootstrapped kernel, or accept 404 by hitting the slug path with
150
+ config disabled in a separate test run. Pragmatic approach: keep TEST_AUTH_ENABLED=true in
151
+ `phpunit.xml` <env> with the dummy slug + a bcrypt hash of a dummy test password, and assert
152
+ the DISABLED case by asserting `Route::has('auth.test-e2e.login')` is false when config is off
153
+ in a unit test of the route-registration condition).
154
+ 2. non-whitelisted email (`attacker@gmail.com`, `aoneahsan.apps.t2@gmail.com`,
155
+ `xaoneahsan.apps.t1@gmail.com`) → 403.
156
+ 3. whitelisted email + wrong password → 401.
157
+ 4. whitelisted email + correct dummy password → 200, token present; then
158
+ `getJson('/api/dashboard/me', ['Authorization' => 'Bearer '.$token])` → 200 with same email.
159
+ 5. alias emails (`aoneahsan.apps.t1+1@gmail.com`, `+del`) → 200, distinct users created.
160
+ 6. throttling: 6th rapid attempt → 429.
161
+
162
+ Never put the REAL password in tests — tests hash their own dummy (`password_hash('dummy-e2e', PASSWORD_BCRYPT)` in setUp).
163
+
164
+ ## Task 4: Registry + docs (agent does repo files; Fable does global files at verify)
165
+
166
+ - Append to project `CLAUDE.md` + `AGENTS.md` (compact, in the Auth Stack section): test-auth
167
+ exists, env-gated, email committed OK, **password stored globally — see
168
+ `~/.claude/rules/automation-test-accounts.md`**, kill-switch TEST_AUTH_ENABLED=false.
169
+ - `~/.claude/rules/automation-test-accounts.md` per-project registry row (Fable adds at
170
+ verification — outside repo).
171
+
172
+ ## Task 5: Gates + commit
173
+
174
+ `php artisan test` (sqlite) + MySQL parity run → green. ONE commit:
175
+ `feat(backend): env-gated UI-less test-auth endpoint for E2E automation (whitelisted t1 accounts)`.
176
+ Update tracker. Push.
@@ -0,0 +1,63 @@
1
+ # Phase 03 — PHPUnit coverage for EVERY API route + MySQL parity
2
+
3
+ **Executor:** Opus 4.8 subagent · **Working dir:** `backend/`
4
+ **Owner instruction (verbatim):** "test it properly, all API end points make sure all works as best as possible" — explicit authorization to extend the PHPUnit suite to full route coverage.
5
+
6
+ ## Task 1: Route inventory → coverage matrix
7
+
8
+ Generate the authoritative list and map to existing tests:
9
+ ```bash
10
+ cd backend && php artisan route:list --json > ../docs/features/e2e-full-verification/results/route-list.json
11
+ ls tests/Feature/
12
+ ```
13
+ Write `docs/features/e2e-full-verification/results/phase03-coverage-matrix.md` — one row per
14
+ route: `method+path | controller@action | existing test file/case | missing cases`. Existing suite
15
+ (134 tests) already covers: ValidateApiKey middleware, UpdateCheck, BundleUpload, ApiKeys, Apps,
16
+ licenses. Do NOT duplicate — extend.
17
+
18
+ ## Task 2: Write the missing feature tests
19
+
20
+ Standard per endpoint (adapt where a case doesn't apply):
21
+ 1. **Auth gate** — unauthenticated → 401; wrong-permission role → 403 (spatie `can:` gates).
22
+ 2. **Happy path** — 200/201 with `assertJsonPath` on the real response fields the website consumes.
23
+ 3. **Failure modes** — validation 422s, not-found 404s, cross-user access 403/404 (IDOR).
24
+ 4. **DB side-effects** — `assertDatabaseHas`/`Missing` including EVERY column the action writes
25
+ (the phase01 lesson — thin assertions masked the prod 500).
26
+
27
+ Route groups and the key cases each MUST include:
28
+
29
+ | Group | Routes | Must-cover cases |
30
+ |---|---|---|
31
+ | Health | GET /api/health | 200 shape |
32
+ | Auth | google/redirect | 302 to accounts.google.com with redirect_uri param |
33
+ | Auth | google/callback | mock Socialite (`Socialite::shouldReceive`) — new user created + token redirect; ADMIN_EMAILS auto-promote; suspended user rejected |
34
+ | Test auth | (phase02 file exists) | verify present, don't duplicate |
35
+ | v1 | GET updates/check | valid key happy path; channel switch; platform mismatch; rollout bucketing determinism (same device → same bucket); device activity + analytics rows written **with full column asserts (device_hash 71 chars fits)** |
36
+ | v1 | POST analytics/mau, download, install | 200 + row written; invalid key 401; malformed body 422 |
37
+ | v1 | GET bundles/{build}/download | signed/allowed download flow; archived build 404/410; wrong app's key 403/404 |
38
+ | Dashboard apps | CRUD + stats | (phase01 strengthened create) add: update platform, delete cascades builds/keys, stats shape, cross-user 403/404, free-plan limit 403 |
39
+ | Dashboard builds | index/store/show/update/destroy/promote | upload validation (size/mime), promote flips channel/status + busts `app:{id}:latest-build:{channel}` cache (assert next update-check sees it), cross-user denial |
40
+ | API keys | index/store/revoke/deprecate | plaintext shown once; revoked key fails middleware (cover in integration with v1 check); cross-user denial |
41
+ | Signing keys | index/store/public/rotate/destroy | rotate keeps old verifying? (assert per current SigningKey model behavior); public endpoint shape |
42
+ | Google Drive | status/auth-url/callback/disconnect/builds | disconnected status; auth-url returns Google URL; callback with mocked Google client; disconnect clears tokens |
43
+ | Preferences | GET/PUT | roundtrip persists JSON; invalid payload 422 |
44
+ | Me | GET/DELETE | shape incl. roles/permissions (website AdminRoute depends on it); DELETE removes user + cascades (apps, builds, api keys, tokens revoked) + FilesHub delete called (mock `FilesHubService`) |
45
+ | Analytics dashboard | GET apps/{app}/analytics | aggregates shape with seeded events; empty state |
46
+ | Rollouts | GET /rollouts, PATCH builds/{build}/rollout | percentage clamp 0-100 (422 outside), permission gate |
47
+ | Subscription | index/plans/subscribe/activate/cancel/resume/change-plan/billing-portal | mock PayPal client (`srmklive/paypal`) — NEVER hit live PayPal in tests; plan limits change after activate |
48
+ | Admin | overview/users/updateUser/apps/builds | RequireAdmin blocks `user` role; super-admin passes; updateUser suspend → suspended user's token rejected on next request |
49
+ | Webhooks | (whatever exists at api.php tail — read it) | signature verification rejects bad payloads |
50
+ | Nova/web | /nova/login redirect → /admin/login | 302 + branded page 200 (light) |
51
+
52
+ **Test hygiene:** reuse `TestCase::seedRoles()` + factories; no sleeps; freeze time with
53
+ `$this->travelTo()` where TTLs matter (45s build cache); FilesHub + PayPal + Socialite always
54
+ mocked (`Http::fake`, service container binding) — tests must run offline.
55
+
56
+ ## Task 3: MySQL parity + gates + commit
57
+
58
+ ```bash
59
+ php artisan test # sqlite
60
+ DB_CONNECTION=mysql DB_DATABASE=laravel_nativeupdate_test php artisan test # parity — MANDATORY
61
+ ```
62
+ Both green. Record final counts in the coverage matrix doc. Update tracker. ONE commit:
63
+ `test(backend): full API route coverage (+MySQL parity run) — every endpoint gated/happy/failure-tested`. Push.
@@ -0,0 +1,73 @@
1
+ # Phase 04 — Frontend + plugin (npm package) ↔ backend contract audit
2
+
3
+ **Executor:** Opus 4.8 subagent · **Working dirs:** `website/`, `src/` (plugin root), `example-apps/react-capacitor/`
4
+ **Goal:** zero silent mismatches between what the backend returns/expects and what the website and
5
+ the published plugin send/read.
6
+
7
+ ## Task 1: Website services field-by-field audit
8
+
9
+ For every service in `website/src/services/` (`apps-api-service.ts`, builds, api-keys,
10
+ signing-keys, analytics, rollouts, subscription, admin, me/preferences, google-drive, auth):
11
+ 1. List each request payload field + each response field the TS types declare (they use zod/TS
12
+ interfaces).
13
+ 2. Diff against the ACTUAL backend controller responses (read the controller code; where phase03
14
+ tests assert shapes, cite the test).
15
+ 3. Classify: `missing-in-backend | missing-in-frontend | type-mismatch | naming-drift | ok`.
16
+ 4. Fix real mismatches — prefer fixing the WRONG side (whichever diverged from the documented
17
+ contract); when ambiguous, backend response is the contract.
18
+ 5. Special checks (known risk spots):
19
+ - `apps` responses now include `bundle_id`/`platform` (phase01) — confirm `AppsPage` create +
20
+ edit, `AppDetailPage`, `AdminAppsPage` render them; the zod schema in `AppsPage.tsx:32`
21
+ matches backend validation (max lengths, `in:ios,android,both`).
22
+ - Error rendering: 422 validation errors surface per-field (RHF `setError` from Laravel's
23
+ `errors` bag), 403 plan-limit shows the friendly message, 500 shows a generic toast — the
24
+ original bug surfaced as a blank "Server Error"; verify the UI now explains failures.
25
+ - `me` response roles/permissions match `website/src/constants/permissions.ts` strings.
26
+ 6. Write `docs/features/e2e-full-verification/results/phase04-frontend-contract.md` (table).
27
+
28
+ **Gate:** `cd website && yarn typecheck && yarn lint && yarn build` — all clean.
29
+
30
+ ## Task 2: Plugin endpoint matrix (the npm package)
31
+
32
+ Known state (Fable's scan): `src/plugin.ts:384-409` is CORRECT (GET `{serverUrl}/v1/updates/check`
33
+ with `X-API-Key`, `X-Device-ID`, `X-Current-Version`, `X-Platform`, `X-App-Version`). But:
34
+ - `src/background-update/background-scheduler.ts:156` → `GET {serverUrl}/app-version`
35
+ - `src/background-update/background-scheduler.ts:233` → `GET {serverUrl}/updates/latest`
36
+ - `src/live-update/version-manager.ts:140` → `GET {serverUrl}/check`
37
+ - `src/app-update/app-update-checker.ts:47` → audit its URL too
38
+
39
+ **The Laravel backend serves NONE of those paths.** Resolve each:
40
+ 1. Build the full matrix: every `fetch(` in `src/` → path, headers, expected response → does
41
+ `routes/api.php` serve it? → which docs page documents it?
42
+ 2. Decision rule: if the module is part of the **Laravel-backend flow** (README/docs sell it as
43
+ working with this backend), route it through the `/v1/updates/check` contract (reuse the
44
+ plugin.ts request builder — extract a shared `checkForUpdate(baseUrl, apiKey, …)` helper in
45
+ `src/core/` and call it from background-scheduler + version-manager). If it is a **generic
46
+ custom-backend hook** (user brings their own server), keep the path but document the required
47
+ endpoint contract explicitly in `docs/` + JSDoc, so it's an intentional extension point, not drift.
48
+ 3. Analytics: plugin should report download/install to `/v1/analytics/download|install` after
49
+ applying an update if the Laravel backend is configured — check whether any code does; if
50
+ missing, note it in the report and implement ONLY if `docs/` already promises it (no new
51
+ feature invention; owner decides extras later).
52
+ 4. Update `src/definitions.ts` JSDoc FIRST for anything changed (documentation-first rule), then
53
+ `web.ts`, then docs pages (`website/src/pages/docs-page/sections/`, `docs/api/`), per the
54
+ Cross-Project Consistency rule in root CLAUDE.md.
55
+
56
+ **Gate:** `yarn build` (plugin root, 0 errors) + `yarn lint` clean.
57
+
58
+ ## Task 3: Example app round-trip
59
+
60
+ `example-apps/react-capacitor/`:
61
+ 1. Replace the `serverUrl: 'http://localhost:3000'` placeholder in `capacitor.config.ts` with
62
+ `http://localhost:5946/api` + a comment that this is the local Laravel backend and users must
63
+ point it at their own deployment; wire `apiKey` from an env/local config the README explains.
64
+ 2. `yarn install && yarn build` — web build passes.
65
+ 3. Round-trip proof (curl-level acceptable here; full browser E2E happens in phase05 E2E-16):
66
+ with the local backend up and a seeded app + API key + active build, `curl` the exact request
67
+ plugin.ts constructs → assert `available: true` response parses against `src/types/rollout.ts`.
68
+
69
+ ## Task 4: Gates + docs + commit
70
+
71
+ - Plugin root: `yarn build` + `yarn lint` green. Website: typecheck/lint/build green.
72
+ - Results docs saved under `results/`. Tracker updated. ONE commit:
73
+ `fix(plugin+website): contract audit — align plugin modules + website services with Laravel backend`. Push.
@@ -0,0 +1,69 @@
1
+ # Phase 05 — Browser E2E: full feature matrix, multi-user, local
2
+
3
+ **Executor:** Opus 4.8 subagent(s) driving `superpowers-chrome` (`use_browser` MCP, CDP).
4
+ **Venue:** local only (owner decision). Prod smoke is phase06.
5
+ **Evidence:** every row logs PASS/FAIL + a screenshot to
6
+ `docs/features/e2e-full-verification/results/phase05-evidence/` and a summary table in
7
+ `results/phase05-e2e-results.md`.
8
+
9
+ ## Environment up (Task 1)
10
+
11
+ ```bash
12
+ # 1. MySQL fresh (destructive on LOCAL laravel_nativeupdate only — never prod):
13
+ cd backend && php artisan migrate:fresh --seed --force
14
+ # 2. Backend (background):
15
+ php artisan serve # binds 5946 via SERVER_PORT in .env
16
+ # 3. Frontend (background):
17
+ cd ../website && yarn dev # port 5942, VITE_API_URL=http://localhost:5946/api (verify .env first)
18
+ # 4. Verify: curl http://localhost:5946/api/health → ok; curl -I http://localhost:5942 → 200.
19
+ # 5. Promote the local admin alias:
20
+ cd ../backend && php artisan native-update:role-assign aoneahsan.apps.t1+admin@gmail.com super-admin
21
+ # (account must exist first — hit test-login once for +admin, then assign.)
22
+ ```
23
+ Browser profiles (isolation = separate user-data-dirs; Chrome ×2 + Brave as a third engine):
24
+ - Profile A (user 1): Chrome, `--user-data-dir=<scratchpad>/e2e-profile-a`, sign in `t1`
25
+ - Profile B (user 2): Chrome, `--user-data-dir=<scratchpad>/e2e-profile-b`, sign in `t1+1`
26
+ - Profile C (admin): Brave (`/Applications/Brave Browser.app`), sign in `t1+admin`
27
+ Headless by default; sign-in per profile = `POST` test-login (fetch inside the tab or curl) →
28
+ navigate `http://localhost:5942/auth/callback?token=<token>` → expect dashboard shell.
29
+ **NEVER type the password into page JS logs; read it from the global secrets file at runtime and
30
+ pass via JSON.stringify** (per `~/.claude/rules/automation-test-accounts.md`).
31
+
32
+ ## The matrix (Task 2) — every row: steps → expected → evidence
33
+
34
+ | ID | Feature | Profile(s) | Steps (condensed — expand sensibly) | Expected |
35
+ |---|---|---|---|---|
36
+ | E2E-01 | Sign-in (test auth) | A | test-login t1 → /auth/callback?token → /dashboard | Shell renders, header shows user, /me 200, no console errors |
37
+ | E2E-02 | Signup page + Google button | A (signed out tab) | /signup, /login render; Google button href → backend redirect URL | Pages render; link points at `${API}/api/auth/google/redirect` (do NOT complete Google) |
38
+ | E2E-03 | Profile management | A | SettingsPage: change every preference field, reload | PUT /preferences 200; values persist after reload (URL-state rules respected) |
39
+ | E2E-04 | Apps CRUD (the fixed bug) | A | Create app `{name:"Aoneahsan Portfolio", bundle_id:"com.aoneahsan.app", platform:"both"}` → edit name+platform → attempt duplicate bundle_id → delete a second app | Create 201 + appears in list (REGRESSION for the prod 500); edit persists; duplicate shows per-field 422 error inline; delete removes + confirm dialog with URL state (`?confirmDelete=`) |
40
+ | E2E-05 | Plan limit | A | Create apps up to free-plan limit + 1 | Friendly 403 message, no crash |
41
+ | E2E-06 | API keys | A | Create key on app → copy plaintext (shown once) → list shows masked → deprecate → revoke | Key visible once; revoked key: `curl /api/v1/updates/check` with it → 401 |
42
+ | E2E-07 | Signing keys | A | Create → view public key → rotate → delete | All 2xx; UI states update |
43
+ | E2E-08 | Build upload + promote | A | UploadPage: upload small test bundle zip → BuildsPage lists it → promote to production → BuildDetailPage | Upload 201 (FilesHub mocked/local per backend config — if FilesHub live key configured, use a tiny file + delete after); promote reflected |
44
+ | E2E-09 | Plugin update-check round-trip | A + curl | With E2E-06 key + E2E-08 build: curl the exact plugin.ts request (headers incl. X-Device-ID) | `available:true`, correct version/downloadUrl/checksum; repeat with same device-id → deterministic |
45
+ | E2E-10 | Rollouts | A | Set build rollout to 25% → curl update-check with ~20 distinct X-Device-IDs | Roughly a quarter get the build (deterministic per device); RolloutsPage shows % |
46
+ | E2E-11 | Analytics | A | After E2E-09/10 + mau/download/install pings: AnalyticsPage + app stats | Rows appear (device_hash writes WORK — regression for yesterday's fix); charts render (D3), MAU count ≥1 |
47
+ | E2E-12 | Google Drive page | A | GoogleDrivePage disconnected state → click connect → auth-url received | Graceful disconnected UI; auth-url points at Google (do NOT complete OAuth); disconnect no-op safe |
48
+ | E2E-13 | Subscription (local) | A | PricingPage/subscription page: plans list; IF PayPal sandbox creds in local .env, subscribe→activate→cancel; else assert plans render + subscribe CTA hits backend and surfaces sandbox-config error gracefully | No live PayPal ever; plan limits reflect activation when sandbox runs |
49
+ | E2E-14 | Multi-user isolation | A + B | B lists apps; B opens A's app by direct URL `/dashboard/apps/<A-id>`; B creates app with A's bundle_id | B sees ONLY own apps; direct access 403/404 page (no data leak); duplicate bundle_id → 422 validation message |
50
+ | E2E-15 | Admin RBAC | C + A + B | C: /admin overview/users/apps/builds pages; C suspends B; B makes any API call; C unsuspends. A (regular): direct /admin URL | C sees both users' data; suspended B gets blocked + UI handles it; A gets denied (guard redirect), /api/admin/* 403 |
51
+ | E2E-16 | Account deletion lifecycle | fresh profile, `t1+del` | test-login +del → create app + key → Settings delete-account flow → confirm | DELETE /me 200; re-login creates FRESH empty account; old token dead (401); apps/keys gone from DB |
52
+ | E2E-17 | Logout + guards + public pages | A | Logout → back-button → deep-link /dashboard/apps; smoke Home/Features/Pricing/Docs/Privacy/Terms/Sitemap/Feed | Token cleared, guards bounce to /login; public pages render, zero console errors, no horizontal scroll at 375px (spot-check) |
53
+
54
+ Execution notes:
55
+ - Drive via CDP; prefer role/label selectors; after each mutation assert BOTH the UI change AND the
56
+ network response (watch fetch in the tab) — UI-only green is not a pass.
57
+ - Console: fail a row on any uncaught error/red console entry (logger rule: no stray console.*).
58
+ - Multi-user rows need the profiles open CONCURRENTLY (real simultaneous sessions).
59
+ - If a row FAILS: capture evidence, root-cause per systematic-debugging, fix (backend/frontend),
60
+ re-run the row AND any dependent rows. Fixes land in the same phase commit.
61
+
62
+ ## Task 3: Findings triage
63
+ `results/phase05-e2e-results.md`: matrix table with PASS/FAIL, evidence links, fixes applied
64
+ (file:line), and any deferred items (with reason — only product-decision items may defer).
65
+
66
+ ## Task 4: Teardown + commit
67
+ Kill backend serve + vite + all browser instances (verify: `lsof -i :5946 -i :5942` → empty).
68
+ Reset any test data pollution in local DB (fresh-migrate again is fine). Tracker updated. ONE
69
+ commit: `test(e2e): full local browser E2E matrix — results + fixes`. Push.
@@ -0,0 +1,51 @@
1
+ # Phase 06 — Deploy queue + prod smoke re-verification
2
+
3
+ **Executor:** Fable 5 (queue + smoke) + OWNER's server agent (the deploy itself — no SSH from
4
+ this machine). Blocks on the owner between 06.1 and 06.3.
5
+
6
+ ## Task 1: Append to `docs/DEPLOY_NOTES.md` → Pending deploy actions
7
+
8
+ One consolidated item (plus KEEP yesterday's still-pending device_hash item — verify it wasn't
9
+ cleared; if still queued, the same deploy covers both):
10
+
11
+ ```markdown
12
+ - [ ] **2026-07-XX — E2E-verification batch: apps schema fix + test auth + drift fixes.**
13
+ 1. `git pull` + standard cache rebuild (standing notes).
14
+ 2. **Run migrations** (`php artisan migrate --force`): adds `apps.bundle_id` + `apps.platform`
15
+ (fixes the 500 on POST /api/dashboard/apps) + any phase01 drift-fix migrations.
16
+ Verify: `SHOW COLUMNS FROM apps LIKE 'bundle_id';` → varchar(191) UNI.
17
+ 3. **Set new env vars in the server `.env`** (values in the repo's committed `backend/.env` —
18
+ copy exactly): `TEST_AUTH_ENABLED=true`, `TEST_AUTH_ROUTE_SLUG=…`, `TEST_AUTH_PASSWORD_HASH=…`.
19
+ Then `php artisan config:cache` (route registration is config-dependent) + restart PHP-FPM.
20
+ 4. Verify test auth: POST /api/auth/test-e2e/<slug>/login with a WRONG password → 401 JSON
21
+ (proves route live without exposing anything).
22
+ 5. Leave the smoke to the local agent (it will run the prod smoke below and report).
23
+ ```
24
+
25
+ ## Task 2 (OWNER): run the server deploy agent
26
+ `awaitingUser: true`. The server agent reads DEPLOY_NOTES first (standing rule), applies, clears
27
+ the queue items it completed, commits.
28
+
29
+ ## Task 3: Fable prod smoke (after owner confirms deploy)
30
+
31
+ All via curl + one headless browser pass against https://nativeupdate.aoneahsan.com:
32
+ 1. `GET /api/health` → ok.
33
+ 2. Test-login `t1` (password read from `~/.secrets/…` at runtime, never echoed) → token.
34
+ 3. Browser: `/auth/callback?token=…` → dashboard renders.
35
+ 4. **THE bug:** create app `{name, bundle_id, platform:'both'}` → 201 + appears in list.
36
+ 5. Create API key → `GET /api/v1/updates/check` with it → 200 `{available:false}` (no build yet).
37
+ 6. `POST /api/v1/analytics/mau` ping with the key → then confirm MAU/stat reflects (also closes
38
+ yesterday's device_hash smoke that DEPLOY_NOTES asked for).
39
+ 7. Preferences roundtrip; logout; token revoked check (reuse → 401).
40
+ 8. **Cleanup:** delete the created app + key (keep the t1 user for future runs). Prod left clean.
41
+ 9. PayPal: `GET /subscription/plans` read-only ONLY.
42
+
43
+ Record results in `results/phase06-prod-smoke.md`. Any failure → root-cause → fix → re-queue →
44
+ repeat (tracker rows re-open).
45
+
46
+ ## Task 4: Close out
47
+ - `docs/MANUAL-TASKS.md`: mark the deploy row done (owner) / add anything left.
48
+ - Tracker: all phases complete + runHistory; bump `lastUpdated`.
49
+ - Root `CLAUDE.md` + `AGENTS.md`: Auth Stack section gains the one-line test-auth record +
50
+ pointer here; bump Last Updated.
51
+ - Final commit + push.