# RAMA AG — Phase 02B Controlled Deployment Report

Date: 26 November 2026 (times are local, Europe/Zurich).
Status: **DEPLOYED AND VERIFIED — release `rama-v0.2.0` is live at `http://localhost:3400`.**

Labels used in this report:
- **[VERIFIED]** — executed and checked against real evidence.
- **[SIMULATED]** — exercised in an isolated environment with synthetic data or emulated devices, not on real hardware or with real users.
- **[NOT EXECUTED]** — deliberately not run.
- **[OPEN]** — unresolved item or limitation.

No credentials, APP_KEY values or employee personal data appear in this report. Database figures are counts or hashes only. Synthetic accounts and data used for testing existed only in the test database and have been removed.

---

## 1. Executive summary

The two-role release (Administrator, Employee) is live on the active RAMA project and database.

The owner approved:
- the ten business defaults from the Phase 02 report, section 3;
- the release itself;
- restoring the backup into the test database for the recovery rehearsal (option 3);
- the maintenance window.

Sequence, all completed:
1. Release frozen and tagged.
2. Protected RAMA-only backup taken.
3. Backup restored and verified in the test database.
4. Migrations rehearsed on the restored copy.
5. Full regression and an isolated browser pass.
6. Read-only preflight of the live database.
7. Maintenance stop of the RAMA server only.
8. Code activated, migrations run in the reviewed order, schema verified.
9. Caches cleared and the server restarted.
10. Post-deployment verification.

Every check passed. There were no failed or partially applied migrations, and no recovery action was needed.

- RAMA was offline for about 2 minutes (22:28:14 to 22:30:09).
- Quality Workforce was not accessed. Shared MariaDB grants and server settings were not changed.
- No SMGV work was started.

## 2. Release version and Git commit [VERIFIED]

| Item | Value |
| --- | --- |
| Version / tag | `0.2.0` / `rama-v0.2.0` (annotated tag object `e10efc7`, local only, never pushed) |
| Release commit (now active `main` HEAD) | `9f9e831c1a53d611012b9d98e2a230b021607a13` |
| Release lineage | `675f1c3` (Phase 01 baseline) → `52b6174` (adds Phase 01 audit report) → `9f9e831` (Phase 02) |
| Staging working commit | `be70ba9` on branch `phase02` (same file tree as `9f9e831`), after staging snapshot `33af30d` |
| Deployment path | Fast-forward of active `main` from `675f1c3` to `rama-v0.2.0`; the original history is preserved |
| Remotes | None. Nothing was published |

Change set from `675f1c3`: 19 files added, 141 modified, 6 deleted. That includes both new migrations and all new source, test and language files.

Compiled Vite assets (`public/build`) are gitignored. They were deployed from the verified release ZIP.

## 3. Release verification [VERIFIED]

- The active baseline is commit `675f1c3`. All 449 of 449 baseline files matched `phase02-active-file-baseline.json` before deployment.
- All 477 of 477 entries in the release manifest matched the staging tree.
- The release ZIP's SHA-256 (`b159a9ad…cbff`) matches the `.sha256` file.
- Change review:
  - 147 tracked files really differ.
  - 77 more appeared modified but differ only in line endings.
  - 26 files were new and untracked.
  - The tagged tree and the staging working tree differ in 87 files, all only in line endings; none differ in content.
- The old `RAMA_AG_PHASE_02_REVIEW.patch` covers tracked files only. It was not used for deployment.
- Release package in `D:\- CLAUD PROJECTS\RAMA AG\releases\rama-v0.2.0\`, covered by `SHA256SUMS`:

  | File | SHA-256 |
  | --- | --- |
  | `rama-v0.2.0.bundle` (full git bundle, verified) | `f209c33b3d67f3c6eb6c8832155bcee51aed8f3affd3b8dd0cb29fdd3561b670` |
  | `RAMA_AG_v0.2.0_FULL_FROM_675f1c3.diff` (166 files, incl. new files and both migrations) | `77d43906fed565299bf256d90839975768071300f3b9594e6ade04eaa6f4fbad` |
  | `RAMA_AG_PHASE_02_RELEASE.zip` | `b159a9ad98db78d6a28c18cea9ac3b7e426085a0ebff54bd9657eef9cb16cbff` |
  | `RAMA_AG_PHASE_02_RELEASE_MANIFEST.json` | `f24ce417090ca53002743c5e7d431c1d06b5ea0ca7c3a4c111fdd0f00dd25a65` |
  | `RELEASE_METADATA.json` (version, tag, commits, baseline, staging commits, 18 ordered migrations, creation date) | `28d20f3ce8e9212625a74fa8d30a3c494cf36ba595a9366751e938d45002b27d` |

- After activation, all 477 deployed files are identical in content to the verified release, ignoring line endings. The 20 `public/build` files match the manifest byte for byte.
- Rebuilding the assets reproduced 18 of 20 files exactly. `app.css` and the Vite manifest differ only because Tailwind also scanned the untracked review patch in staging and added 8 extra utility classes; none of them is used in the release source. The shipped CSS is correct.

## 4. Backup location and checksums [VERIFIED]

Location: `D:\- CLAUD PROJECTS\RAMA AG\backups\phase02b-predeploy-20261126-220045\`. It sits outside the deployable directory. Folder permissions allow only the owner's Windows account and SYSTEM, with inherited permissions removed. Every file is listed in `SHA256SUMS`: 38 entries, all re-verified, 0 mismatches. `SHA256SUMS` itself has SHA-256 `bd4cb34a7c71aeade781d35ee8dea748252589db5b45a402abcf0ed82a093ff7`.

| Content | Path | SHA-256 (prefix) |
| --- | --- | --- |
| Live DB at 22:00: schema with checks and foreign keys, all records, all 26 triggers; no DROP statements | `db/rama_workforce_laravel.sql` | `8b13c053…` |
| Reference values for the restore check (per-table row counts, checksums and structure hashes; trigger fingerprints; migrations) | `db/verification.json` | `6670e859…` |
| **Final pre-migration recovery point** (taken after the RAMA server was stopped) | `db-final-predeploy/rama_workforce_laravel.sql` | `199e520d…` |
| Its reference values | `db-final-predeploy/verification.json` | `299162e5…` |
| Test DB before the rehearsal | `db-test-predrill/…` | `6b914b45…` |
| Full git history of the active repo (all refs) | `source/rama-active-repo.bundle` | `c06376b0…` |
| Full source snapshot (incl. vendor, portable PHP, storage; excl. node_modules and .git) | `source/rama-active-source.zip` | `b6dce00c…` |
| Protected environment files (contain APP_KEY and DB credentials; never printed) | `config/` | listed in SHA256SUMS |
| Private storage and attachments (only placeholder files; no attachments existed) | `storage/app/` | listed |
| Startup configuration (server command, PHP 8.3.36 path, php.ini, DB endpoint) | `startup/` | listed |
| Phase 01 compiled assets and the two moved report files | `predeploy-moved-files/` | listed |

The backups were made with RAMA's own PHP (PDO) and the RAMA database account. The MariaDB client tools live inside the Quality project folder, so they were deliberately not used.

## 5. Recovery rehearsal results [VERIFIED]

Approved option 3: restore into `rama_workforce_laravel_test`. The test database was backed up first.

- The test DB was emptied with the `rama_test` account, then the live backup was restored (90 statements).
- Checked against `db/verification.json`:
  - 32 of 32 tables.
  - Row counts 32/32.
  - Per-table checksums 32/32.
  - Table structure, constraints and keys 32/32.
  - 16 of 16 migrations.
  - Users by role/status identical (1 active Administrator).
  - All 26 integrity triggers identical by name, table, timing, event and code.
- **Result: the backup restores completely and correctly.**
- The restored live data was removed from the test database immediately after verification.

## 6. Migration dry-run results [VERIFIED]

The unmodified release code was run on the restored copy: `APP_ENV=testing`, guards unchanged, deployment approval flag not set.

- `2026_11_26_100000_expand_two_role_workflows`: done in 0.59 s, exit 0.
- `2026_11_26_110000_switch_to_two_runtime_roles`: done in 0.12 s, exit 0.
- Checks afterwards:
  - 18 migrations, 34 tables.
  - The 26 original triggers unchanged.
  - `notification_outbox` and `phase02_migration_archives` present.
  - The users role check allows only `admin` and `worker`. A rolled-back test change to `foreman` was refused by that check.
  - Foreman order grants removed and archived; the admin accept and cancel grants kept.
  - The Administrator row is identical on all original columns.
  - The legacy compatibility columns are retained.
  - Existing record counts are unchanged.
- The structure of the upgraded copy is identical to a freshly migrated 18-migration database (34 of 34 tables, 26 of 26 triggers).

## 7. Automated test results [VERIFIED]

MariaDB suites ran only against `rama_workforce_laravel_test`, one after another.

| Run | Tests | Passed | Skipped | Failed | Assertions |
| --- | ---: | ---: | ---: | ---: | ---: |
| Staging: main (MariaDB test DB) | 540 | 442 | 98 | 0 | 8,662 |
| Staging: memory (SQLite) | 97 | 96 | 1 | 0 | 741 |
| Staging: upgrade | 2 | 2 | 0 | 0 | 27 |
| Staging: two-role acceptance (`PhaseTwoArchitectureTest`) | 20 | 20 | 0 | 0 | 112 |
| Staging: focused SQLite suites | 97 | 96 | 1 | 0 | 741 |
| Frontend: Node tests (work timer, worksite selection) | 6 | 6 | 0 | 0 | — |
| Frontend: syntax check of all 12 `resources/js` files | 12 | 12 | 0 | 0 | — |
| **After deployment: memory (active tree)** | 97 | 96 | 1 | 0 | 741 |
| **After deployment: main (active tree, test DB only)** | 540 | 442 | 98 | 0 | 8,662 |

The focused SQLite suites were: demo-worksites 26/26, employee-dashboard 36 passed + 1 skipped, employee-management 10/10, return-travel 13/13, six-step-travel 11/11.

The skips are the documented ones: SQLite fixture classes are skipped inside the MariaDB run and run separately, there is one pre-migration-only schema case, and one optional browser-preview export.

JUnit XML files are in `D:\- CLAUD PROJECTS\RAMA AG\phase02b-evidence\`.

The test runs churned 4 tracked Livewire temp fixture files; they were restored afterwards. The working tree is clean apart from the untracked handover report and this report.

[NOT EXECUTED] `tests/quality-worksite-browser.mjs`, an old helper named after Quality.

## 8. Interactive browser and mobile results [SIMULATED]

**Setup:**
- The staging release ran on `127.0.0.1:3401` with `APP_ENV=testing` against the test database. This is the only combination the isolation guard allows without code changes.
- It was driven by an isolated headless Microsoft Edge with its own profile, through the DevTools protocol.
- The desktop app's built-in browser pane was hidden and could not take input, which is why headless Edge was used.
- Accounts: 1 Administrator and 2 Employees seeded synthetically, plus 1 more Employee created through the UI.
- 33 screenshots are in `phase02b-evidence\screens`.
- The server and browser were stopped afterwards, and the test DB was reset to an empty 18-migration schema.

**Administrator, desktop 1440×900, German and Albanian:**
- Dashboard.
- Employee management: the create dialog offers exactly two roles, Mitarbeiter/Punëtor and Administrator, and the role filter offers only admin and worker. An employee was created through the UI.
- Worksite created with GPS coordinates, radius and assignments.
- Leave: one request approved; one rejected with a reason, which the employee sees.
- Material order accepted.
- Daily report review is read-only, with no approval buttons; its PDF returns 200.
- Company-wide weekly report: suggestion, draft, close, archive, with worksite attribution; the PDF returns 200.
- Monthly report: Excel (.xlsx) 200, PDF 200.
- Settings, including the required-notification delivery panel; attendance overview; schedules; notification history.

**Employee, mobile 390×844, Albanian and German:**
- Login.
- Worksite selection.
- Automatic attendance (travel → start of work → break → back from break → close day) with GPS recorded at check-in and check-out.
- GPS permission denied: the app reports it and saves nothing.
- Manual attendance with a backdated time and a reason, labelled as manual.
- Daily report: draft, then submit (final).
- Material request, leave request and personal attendance history.
- Notifications of decisions received.

**Layout and errors:**
- No horizontal scrolling at 390 px on any page checked: dashboard, workers, leave, orders, weekly reports, worksites, settings.
- No browser console errors, no 5xx responses, and no new application log errors.

**Authorization and ownership:**
- An Employee requesting `/workers`, `/worksites`, `/worksites/create`, `/worksites/1/edit`, `/reports/monthly/export` or `/reports/monthly/pdf` gets 403.
- The company weekly PDF returns 404 for an Employee.
- Another employee's daily PDF returns 404, while the employee's own returns 200.
- Unauthenticated requests are redirected to login.
- Scanning every visited page for foreman, Vorarbeiter, Kryepunëtor or Teamleiter found nothing.

**Schema-readiness middleware:** with `notification_outbox` temporarily renamed in the test DB, `/login`, `/dashboard` and `/health` returned 503 "RAMA release awaits the approved Phase 02 database deployment". After it was restored, they returned 200.

**GPS:** all coordinates were simulated through browser emulation (about ±12 m near the synthetic worksite). **No real device and no real GPS were used.**

**Not exercised in the browser [NOT EXECUTED]:**
- Private absence (the clicks had no effect in the headless run).
- Return travel (the button is locked in this configuration).
- Forged Livewire calls (covered only by the automated acceptance tests).
- CSRF (switched off by Laravel in `APP_ENV=testing`; verified on the live system instead, see section 15).

## 9. Active migration results [VERIFIED]

- **Preflight** (read-only, RAMA account):
  - Identity `rama_workforce_laravel` / `rama_local@127.0.0.1` / port 3307.
  - 32 tables, 26 triggers, 16 migrations, Phase 02 not yet applied.
  - Exactly 1 active Administrator.
  - No legacy-role accounts, no manager relationships on users or worksites, no weekly reports or legacy drafts.
  - All operational tables empty.
  - The baseline migrations in the release are unchanged; only the 2 new files were added.
- **Maintenance:**
  - Only the RAMA server processes on :3400 were stopped (the `artisan serve` launcher and the `php -S` worker); no other RAMA processes were running.
  - Quality's listener on :3200 was not touched.
  - A final recovery dump was taken. The only change since the 22:00 backup was one new session row.
- **Activation:**
  - The two untracked Phase 01/02 report files were moved aside first. They were identical to the release versions apart from line endings.
  - `git merge --ff-only rama-v0.2.0`.
  - `public/build` was replaced from the checksum-verified ZIP; the old assets were kept in the backup.
- **Migrations:** run with the verified RAMA PHP 8.3.36 from the canonical project path, with the live `.env` (`APP_ENV=local`) and the approval flag set only inside that shell:
  - 22:29:04 `2026_11_26_100000_expand_two_role_workflows`: 599 ms, exit 0, batch 2.
  - 22:29:05 `2026_11_26_110000_switch_to_two_runtime_roles`: 128 ms, exit 0, batch 3.
  - The flag was removed immediately afterwards (`finally` block; confirmed absent).
- Caches cleared: config, route, view, event. No config or route cache existed.
- RAMA was restarted with the same command (`artisan serve --host=127.0.0.1 --port=3400 --tries=1 --no-reload`). The new server process is pid 47480; the logs are `.tools\rama-serve-v0.2.0.log` and `.tools\rama-serve-v0.2.0.err.log`.
- Maintenance window: 22:28:14 to 22:30:09.

## 10. Final database structure [VERIFIED]

`rama_workforce_laravel`:
- **18 migrations** (16 in batch 1, plus batches 2 and 3).
- **34 tables**, including the new `notification_outbox` and `phase02_migration_archives`.
- **26 triggers**.

The structure is identical, table by table, to the rehearsed dry-run result (34 of 34).

New in the leave table:
- decision fields `decided_by_id`, `decided_at`, `rejection_reason`, with a foreign key to `users`;
- the status check now allows `pending`, `approved` and `rejected`.

Other schema changes:
- The notification type check now includes `LEAVE_REJECTED`.
- The weekly report gains neutral preparer and company-week identity fields.
- The grant target check now allows only Admin-role or explicit-user grants.

Legacy compatibility columns are retained: `users.foreman_id`, `worksites.foreman_id`, `weekly_team_reports.foreman_id`, `leave_requests.approved_by_id`, `leave_requests.approved_at`.

## 11. Final two-role architecture [VERIFIED]

- **Runtime:** `app/Enums/Role.php` defines only `Admin` and `Worker`.
  - The Foreman dashboard component, its views and its language files (de/sq) are removed.
  - "foreman" appears 0 times in routes and 0 times in `app/`, apart from the documented V1 snapshot compatibility reader (`app/Support/WeeklySnapshot.php`).
- **Persisted:** `users_role_check` = `` `role` in ('admin','worker') ``.
- **Order authority:** grants are now only admin/accept_order and admin/cancel_order. The two foreman grants were archived (1 archive row) and removed.
- The role selector and filter offer only Administrator and Mitarbeiter/Punëtor [SIMULATED on the identical release code; see section 8].
- The Foreman dashboard is not reachable: the code is absent [VERIFIED].

## 12. Administrator preservation [VERIFIED]

- Exactly 1 active Administrator before and after deployment.
- The Administrator's user row, the audit log row and the company settings row are **byte-identical** before and after the migrations, compared in the dump-level output.
- The password was not reset, read or changed.
- Existing sessions were preserved (all 3 pre-deployment session rows are unchanged).
- [OPEN] The Administrator's own login on the live system after deployment has not been performed. It needs the owner's credentials (see section 16).

## 13. Integrity trigger verification [VERIFIED]

All 26 original triggers are identical by name, table, timing, event and SHA-256 of their code at every stage:
- the backup;
- the restored copy;
- after the dry run;
- after the live migrations, compared with the final pre-migration recovery point.

No trigger was dropped, disabled or recreated.

## 14. Application availability [VERIFIED]

- `GET /health` → 200 `{"status":"ok"}`. `GET /up` → 200. `GET /login` → 200.
- Every protected route (`/dashboard`, `/workers`, `/leave`, `/reports`, `/orders`, `/attendance`, `/schedules`, `/settings`, `/worksites`, `/notifications`) → 302 to `/login`. `/` → 302 to `/dashboard`.
- The login page loads the new assets (`app-BZ1tcEsc.css` → 200).
- No unexpected 500 or 503 responses. The schema-readiness gate is satisfied.

## 15. Security and isolation verification

- [VERIFIED] **Configuration:**
  - `artisan about` reports: environment `local`, debug OFF, mail `array`, broadcasting `null`, sessions/cache/queue on database, DB `mariadb`.
  - `RamaIsolationServiceProvider` is unchanged: dedicated database, account and port only; outbound mail and non-database notifications cancelled; stray HTTP requests blocked.
- [VERIFIED] **CSRF:** `POST /login` without a token → 419.
- [VERIFIED] **Headers and cookie:**
  - `X-Frame-Options: DENY`.
  - CSP present (unchanged; still allows `'unsafe-eval'` for Alpine, plus OpenStreetMap map tiles).
  - Session cookie `rama_ag_session` is HttpOnly and SameSite=Lax.
- [VERIFIED] **Preserved as before:** live `.env`, APP_KEY, database account, session and cache namespaces, private storage, port 3400 and the project path. The staging `.env` and `.env.testing` were never copied.
- [VERIFIED] **Quality isolation:**
  - Quality Workforce and its database were not accessed, queried, started or stopped. No cross-database query was made during Phase 02B.
  - Port 3200 was only observed as listening.
  - The MariaDB binaries inside the Quality folder were not executed.
  - No shared grants, PUBLIC permissions or server settings were changed.
- [VERIFIED] **Live DB access:**
  - Writes happened only through the two reviewed migrations.
  - Every other access was read-only SELECTs in READ ONLY sessions: preflight, dumps, verification.
  - No fixture or destructive test suite ran against the live database.
  - The deployment checks themselves (curl/PowerShell requests) created 21 anonymous session rows. These are normal Laravel session-lifecycle rows, not business records.
- [OPEN] The shared-server PUBLIC grants on `test` and `test_%` schemas, noted in Phase 01, remain. They need a server administrator and were out of scope.

## 16. Outstanding limitations

1. [OPEN] **Owner login and smoke test on the live system.** The owner should sign in at `http://localhost:3400` with their existing credentials and confirm:
   - the dashboard;
   - employee management (only two roles);
   - leave, orders and reports pages;
   - Albanian and German;
   - one check at phone width.
   This was not done here because it requires the owner's credentials.
2. [OPEN] **Real-device acceptance:** real phone, real GPS and permission prompts. Only simulated GPS was tested.
3. [NOT EXECUTED] **In the browser:** private absence, return travel and forged Livewire calls (the latter is covered by the automated tests only). Multi-process load or stress testing was also not run.
4. [OPEN] The release CSS was built while the staging tree also contained an untracked review patch. Any future rebuild should be run from a clean tree.
5. [OPEN] `phase02_migration_archives` holds the archived legacy grants and configuration. Keep it; any future contract or cleanup needs a separately approved migration.
6. [OPEN] The server runs as a user-level background process (`artisan serve`). There is no Windows service and no auto-restart after a reboot. This is the same as before the deployment.
7. [OPEN] The schema-readiness gate also returns 503 on `/health` if the schema ever falls behind the code. Monitoring should treat a 503 from `/health` as "schema not ready".
8. Not affected by this phase: SMGV/GAV accounting, external email, attendance calculation logic and the platform design.

## 17. Recovery instructions

There was no failure, so no recovery was performed. If a rollback becomes necessary:

1. Stop only the RAMA server on :3400. If new real records may have been written since 22:30, capture a fresh read-only dump first, preserve the logs, and **do not** restore over new real data without explicit owner approval.
2. **Code:**
   - In the project, run `git checkout 675f1c3`, or `git reset --hard 675f1c3` on `main` after confirming the working tree holds nothing to keep.
   - Restore `public/build` from `backups\…\predeploy-moved-files\public-build-phase01`.
   - Restore the two report files from the same folder if needed.
3. **Database:** the migrations' `down()` methods deliberately refuse, and MariaDB DDL is not transactional. Recovery is a RAMA-only restore of `db-final-predeploy/rama_workforce_laravel.sql`:
   - check its SHA-256 against `SHA256SUMS`;
   - restore it into an **empty** `rama_workforce_laravel` schema; the file contains no DROP statements, so the existing tables must be removed under owner approval first;
   - use the same PDO restore procedure that was rehearsed in section 5.
   - Then verify against `db-final-predeploy/verification.json`: 32 tables, 26 triggers, 16 migrations, 1 Administrator, identical row checksums.
4. Never use `migrate:fresh`, `migrate:rollback`, `truncate`, or drop and recreate triggers.
5. Clear the caches and restart RAMA with the command in `backups\…\startup\STARTUP.txt`. Then check `/health`.

Recovery-point SHA-256: `199e520ddc2a8ef00d02e85003c627fa8ac59fa070d8283f7a0a0205d9eeae3a`.

## 18. Recommendation for Phase 03

1. First close items 1 and 2 of section 16: the owner's live login and smoke test, then a short real-phone GPS check.
2. With explicit approval, start **Phase 03 — SMGV PDF Reverse Engineering**. Work read-only on `smgv-zeitkontrolle-alle-2026.pdf`, which is currently in the owner's Downloads folder:
   - map the 14-page-per-employee structure, its fields and its totals;
   - separate values that can be derived from captured data from values that need GAV/SMGV rules or owner input;
   - list every open accounting question.
3. Do not invent formulas or claim SMGV/GAV compliance. Keep the Administrator-only access requirement in the Phase 03 specification. Apply the Black Titanium design direction only in later authorized UI phases.

**STOP.** Phase 02B is complete. Phase 03 has not been started and needs explicit approval.
