# RAMA AG — Workforce Core Rebuild Report

Date: 2026-11-27. Candidate: existing `develop/v1` worktree, baseline commit `7f1a499`. Status: implementation and isolated verification completed; **candidate NOT deployed**. Desktop/mobile visual acceptance remains blocked.

## 1. Executive summary

Refactored the existing Laravel application around one TimeService, retained admin/worker authorization, and implemented selectable compact 13-page and original 14-page SMGV exports. Exact historical source values and immutable closings remain preserved. Only Avni Hoti's first 14 reference pages were used for reference reconciliation. All 561 comparisons passed. This report does not certify GAV rules or production acceptance.

Development: `D:\- CLAUD PROJECTS\RAMA AG\dev-v1`. Existing active application: `C:\Users\PANDAZZ\Desktop\RAMA-AG\rama-workforce-laravel`. The active application source was not replaced. No unrelated project was accessed or changed. No account, password, raw event, historical value, or closing was intentionally changed in the active database.

## 2. Architecture before and after

Existing monolith retained: Laravel, Blade/Livewire, Tailwind/Vite, MariaDB, sq/de and Europe/Zurich. Logical domains:

| Domain | Responsibility |
|---|---|
| Employees | Accounts, profiles, contracts, employment periods, Pensum |
| Time Control | Raw attendance, factual durations, accounting projections, closings |
| Worksites | Sites, memberships, assignments, GPS selection |
| Absences | Requests, absence types, recorded credits |
| Operations | Material orders, work reports, notifications |
| Reporting | Monthly/annual SMGV views, PDF/Excel/ZIP exports |

Previously AttendanceSummaries and SmgvAccounting provided separate orchestration entry points. Their consumers now use request-scoped TimeService. Pure DurationEngine (attendance facts) and TimeEngine (accounting projection) retain distinct responsibilities. Worker shift schedules and contractual Pensum remain distinct concepts. The existing light workspace and dark sidebar design is retained.

## 3. Complexity findings

The pre-edit dependency inventory indexed 503 files, 43,991 lines and 181 application symbols. Dynamic Laravel/Livewire discovery prevented unsafe deletion based on textual reference counts alone. Application PHP changed from 181 files / 16,237 lines to 180 files / 16,303 lines; service files from 39 to 38; time orchestration entry points from two to one. Added reporting and provenance features mean total application lines increased by 66; there is no claimed overall line-count reduction.

## 4. Removed redundant code

Removed `app/Services/AttendanceSummaries.php` and `app/Services/Smgv/SmgvAccounting.php` after migrating consumers. No aliases or duplicate orchestration wrappers remain. Opening import analysis delegates to WorkbookParser, removing roughly 80 duplicate parser lines. Annual PDF rows share a template. Retained discovered routes, policies, commands, operational features and historical migration compatibility where deletion was not justified. No table was removed.

## 5. Consolidated services

TimeService provides attendance summary/history/intervals, month/year/week accounting, employee discovery, rule selection and cache invalidation. Employee and closing lifecycle services invalidate the same request-scoped cache. Import analysis uses the existing parser while keeping confirmation and historical import workflows. SmgvExportService centralizes validated employee/year/layout selection and output construction.

## 6. Database changes

No DDL migration was needed or applied. All 50 table structures, 32 trigger definitions and 20 migration files were verified unchanged. The test database was not reset: existing reviewed schema plus transaction rollback was used. The old reset-based upgrade harness was not executed; its replacement verifies the existing schema and migration hashes. No migrate:fresh, db:wipe or destructive reset was executed.

## 7. Historical preservation

Read-only comparison against the backup confirmed all 11 user rows, including stored credentials, all 6,427 historical value rows and both immutable monthly closings unchanged. Raw events and operational tables were unchanged. All 506 original active source/config/private asset files remained byte-identical at verification. Forty-eight of 50 table contents matched exactly; audit_logs increased from 64 to 65 and session payloads changed during elapsed active application activity. These observations are recorded without attributing their cause; they are not represented as a full database freeze. A later health GET may also create an ordinary session.

Synthetic test accounts/imports were confined to rollback transactions in the RAMA test schema. No source timestamps were fabricated and no real employee was reimported. Historical e4 values and original text remain available even where display uses whole minutes.

## 8. Unified calculation architecture

TimeService is the single orchestration entry point. Daily provenance distinguishes recorded, incomplete, unverified historical, outside employment, future, credit-only and missing data. A recorded zero is distinct from missing input. Historical precision rounding emits a warning; original e4 values remain exact. DST band classification uses local wall-clock time while elapsed attendance retains real duration. Calendar weeks include cross-month/year days; monthly productive totals still include only that month's days. Frozen closing snapshots are returned unchanged.

No new statutory travel, overtime, vacation or GAV formula was activated. Existing operational summaries remain factual projections, not certified payable overtime. The saldo label is explicitly provisional.

## 9. SMGV reference analysis

Source: `C:\Users\PANDAZZ\Downloads\smgv-zeitkontrolle-alle-2026.pdf`, SHA-256 `60b475752329f317556852eec6865be9bad45cdc82dbfef32aa9cff7dc678e15`, 140 pages. Only pages 1–14 belonging to Avni Hoti were extracted, parsed and visually reviewed: Basisblatt, January–December, Jahresübersicht. Other employee records were not mixed into the reference fixture.

The source includes day rows, weekly totals, contractual targets, productive time, supplements, holiday/vacation/absence categories, carry balances, payouts and signatures. September's calendar week can carry August 31's 8 hours without adding September productive hours. This behavior is preserved and labelled.

## 10. PDF and export implementation

Default compact export: one combined **A3 landscape** overview plus twelve A4 landscape month pages, exactly 13 pages per employee. The explicit larger overview paper preserves readable information. Original layout: A4 portrait Basisblatt, twelve A4 landscape months and A4 landscape annual overview, exactly 14 pages. Shared templates retain all reported fields, source status, travel/deduction and explicit monthly total rows; unresolved Karenz credit is labelled rather than invented.

Admin export center supports year and employee selection, all accounting employees including historical/inactive employees, existing month/year views, PDF preview/download, combined PDF, per-employee ZIP and Excel. Selection and layout are validated server-side; a partially invalid ID selection fails rather than silently omitting employees. ZIP and workbook names include stable IDs to avoid equal-name collisions. Excel includes typed values, explicit text and a historical-source sheet with original text, exact e4, source page, import and status. It does not convert user-provided strings to formulas. Both languages expose the layout choice.

## 11. Avni Hoti validation

The isolated reference fixture matched 561/561 applicable daily, weekly, monthly, annual and carry comparisons, with zero discrepancies. Eighteen headline/month checks passed:

| Metric | Expected and actual |
|---|---:|
| Soll | 1,384.00 h |
| Productive | 1,250.00 h |
| Holiday credit | 48.00 h |
| Vacation | 104.00 h |
| Opening time balance | 10.00 h |
| Supplements | 0.50 h |
| January productive | 160.50 h |
| February productive | 167.00 h |
| March productive | 186.50 h |
| April productive | 144.00 h |
| May productive | 148.50 h |
| June productive | 183.50 h |
| July productive | 117.00 h |
| August productive | 143.00 h |
| September productive | 0.00 h |
| October productive | 0.00 h |
| November productive | 0.00 h |
| December productive | 0.00 h |

Reference employment: January 1–August 31, 2026. The **active** employee additionally has one minute of live attendance outside that reference period: 75,001 productive minutes versus the source-only fixture's 75,000. Before/after live benchmark results preserve that minute and both closed months. It was not deleted or adjusted to force agreement with the imported reference.

Protected local outputs are in `D:\- CLAUD PROJECTS\RAMA AG\core-rebuild\output\pdf`: compact PDF, original PDF and Excel. Detailed evidence is protected under `core-rebuild/evidence/reference`.

## 12. Before/after performance

Three local read-only runs against the same active dataset, old source versus candidate; medians:

| Year projection | Before | After |
|---|---:|---:|
| Cold elapsed | 80.08 ms | 89.35 ms |
| Cold queries | 129 | 144 |
| Warm elapsed | 3.54 ms | 5.15 ms |
| Warm queries | 16 | 20 |
| Peak memory | 30 MB | 30 MB |

There is **no measured speedup**: cold overhead is 9.27 ms (about 11.6%), warm overhead 1.61 ms. Candidate work additionally includes complete calendar-week boundaries and provenance; these are not identical-work load tests. Sample export generation measured 5,398.38 ms compact and 4,371.35 ms original in a warmed fixture run, not a production capacity estimate.

## 13. Security and authorization

Existing admin/worker role boundaries and server-side route, controller, service and Livewire guards retained. Forged employee selection and worker export access are covered by tests. No credentials were reset or exposed in reports/packages. Backup and Avni artifacts have local owner-only ACLs. Source release packaging excludes .env files, runtime storage, private documents, dependencies and backup data. Test bootstrap checks exact RAMA schema/account identity and an empty operational fixture state before allowing rollback tests. No shared grants or unrelated server configuration were changed.

## 14. Automated tests

| Check | Result |
|---|---|
| Main MariaDB suite | 587 cases: 489 passed, 98 skipped; 10,344 assertions; 107.261 s |
| SQLite memory suite | 97 cases: 96 passed, 1 skipped; 741 assertions; 8.286 s |
| Non-destructive schema suite | 2 passed; 76 assertions; 0.154 s |
| Final labels/navigation/authorization subset | 25 passed; 7,958 assertions |
| JavaScript runners | 6 passed; timer runner includes 30 internal checks |
| Changed/new non-Blade PHP lint | 41 files passed |
| Vite production build | Passed |
| Blade compile, route cache/clear, git diff whitespace | Passed |

No failures or errors. Main suite skips comprise 97 memory-only fixtures exercised in the separate memory suite and one unmigrated worksite-schema fixture. Memory skip is optional manual HTML-preview capture without QW_MANUAL_PREVIEW_DIR. Across the three principal PHP invocations: 686 executions, 587 passes, 99 skip events and 11,161 assertions; because the memory suite is a subset, there are 589 distinct cases, 587 distinct passes and two deliberate skips. The renamed TimeService test file is discovered and its eight previous accounting cases are retained. Tests run sequentially to avoid shared Blade cache races. No new dependency or lockfile change.

## 15. Visual PDF verification

All 14 Avni source pages were visually reviewed. All 27 generated pages were rendered at 115 dpi and text bounds checked: zero out-of-page characters. Fifteen unique generated layouts were visually inspected, covering compact overview, original basis/annual and all twelve months. Twelve month pages in the two layouts were verified pixel-identical, covering the remaining twelve generated pages. No visible clipping or overlapping values remained. Data-status cells were corrected to share the main day table's columns and the final outputs were re-rendered and inspected.

**Desktop/mobile browser visual acceptance was not completed.** The in-app browser could not reach the local preview. Native Windows Computer Use then stopped because it could not determine the current browser URL with sufficient confidence to enforce policy. Browser work was closed and no alternate browser automation bypass was attempted. Synthetic sq/de preview HTML was prepared, but it is not evidence of a successful visual browser check.

## 16. Build and deployment status

Candidate source, compiled assets, manifest, patch and this report are prepared for local review. No active code deployment, active migration or server restart occurred. Existing release `/health` returned HTTP 200 with status ok; that verifies the existing release only. The active root receives this report as documentation, not candidate code.

Deployment is pending desktop/mobile sq/de visual acceptance and a real login/device GPS smoke check. When acceptance is available: renew source/data backup and preflight; enter maintenance for RAMA only; apply the reviewed file set including the two deletions while preserving .env, APP_KEY, private storage and namespace configuration; no migration is needed because all 20 files are unchanged; refresh RAMA autoload/caches/assets; restart RAMA only; verify health, login, both roles/languages, employee selection, reporting and GPS workflow; then end maintenance. Never import the synthetic Avni fixture into active storage.

The release archive is source material, not a blind overwrite installer. The tracked diff lists removals; the manifest inventories new/current source and built assets. No commit, push or remote publication was performed. Existing credentials and environment must be supplied from the preserved installation, never from the release archive.

## 17. Backup and recovery

Before application implementation, an owner-protected application ZIP captured 506 files including configuration/private application assets, with every entry SHA-256 verified. A consistent read-only MariaDB snapshot captured 50 InnoDB tables, 6,821 rows, full DDL and 32 trigger definitions in `core-rebuild/protected-backup`; gzip/JSON and all row hashes were verified.

Restore verification copied all 50 table structures into connection-local temporary tables on the RAMA test connection, reinserted 6,821 backup rows, checked 72 foreign-key relationships and found zero content-hash mismatches. No existing table was dropped or reset; temporary tables disappeared on connection close. Trigger execution was not replayed in this temporary-table exercise. Trigger definitions and current schema behavior are checked separately. A full cold restore including trigger installation on a fresh database was **not** rehearsed.

The guarded restore helper passes offline verification, refuses any nonempty target and requires an explicit owner-reviewed restore flag plus exact RAMA account/schema identity. Actual persistent restore was not executed. Destructive preparation of an existing schema needs separate approval. Because deployment has no database changes, initial rollback is the preserved application code/assets with current data retained. Never discard real writes made after backup; any database recovery requires reconciliation and the separately reviewed empty-target process.

## 18. Limitations and GAV review

Active deployment remains unfinished because desktop/mobile visual acceptance was blocked by Computer Use's URL verification. Real-device GPS and human credential login are unverified in this run; synthetic workflow and authorization tests passed. The source matches Avni's documented historical values, not a legal certification of every current rule. Unverified GAV, travel, vacation, deduction, Karenz and rounding decisions remain draft or explicitly unresolved. Historical source precision is preserved; minute display may warn about rounding. Contractual target and factual shift schedule are different inputs. Full cold database/trigger recovery remains a documented unperformed rehearsal. Local performance measurements show added overhead, not an optimization claim.

Evidence: `core-rebuild/evidence/BACKEND_AUDIT.md`, dependency map, source metrics, JUnit/JSON test summaries, schema/migration fixtures, benchmark-before/after, active-preservation, restore-verification, pdf-page-verification, visual-review and protected reference comparisons. The temporary preview server was stopped and development storage/config/build paths were confirmed independent regular directories/files.

### Changed source files

- `README.md`
- `app/Domain/Smgv/TimeEngine.php`
- `app/Http/Controllers/SmgvExportController.php`
- `app/Livewire/AttendanceOverview.php`
- `app/Livewire/Smgv/Absences.php`
- `app/Livewire/Smgv/Annual.php`
- `app/Livewire/Smgv/Balances.php`
- `app/Livewire/Smgv/Basisblatt.php`
- `app/Livewire/Smgv/Closing.php`
- `app/Livewire/Smgv/Concerns/SmgvContext.php`
- `app/Livewire/Smgv/Exports.php`
- `app/Livewire/Smgv/Monthly.php`
- `app/Livewire/Smgv/Overview.php`
- `app/Livewire/WorkerAttendance.php`
- `app/Livewire/WorkerHistory.php`
- `app/Providers/AppServiceProvider.php`
- `app/Services/AttendanceSummaries.php`
- `app/Services/DashboardService.php`
- `app/Services/MonthlyReportService.php`
- `app/Services/Smgv/SmgvAccounting.php`
- `app/Services/Smgv/SmgvEmployees.php`
- `app/Services/Smgv/SmgvExportService.php`
- `app/Services/Smgv/SmgvHistoricalImport.php`
- `app/Services/Smgv/SmgvImportService.php`
- `app/Services/Smgv/SmgvLifecycle.php`
- `app/Services/TimeService.php`
- `config/rama.php`
- `lang/de/common.php`
- `lang/de/core.php`
- `lang/de/smgv.php`
- `lang/sq/common.php`
- `lang/sq/core.php`
- `lang/sq/smgv.php`
- `phpunit.xml`
- `resources/views/livewire/smgv/exports.blade.php`
- `resources/views/pdf/smgv/_annual.blade.php`
- `resources/views/pdf/smgv/basisblatt.blade.php`
- `resources/views/pdf/smgv/compact.blade.php`
- `resources/views/pdf/smgv/sheets.blade.php`
- `tests/Feature/AttendanceHistoryTest.php`
- `tests/Feature/ManualAttendanceTest.php`
- `tests/Feature/ReturnTravelTest.php`
- `tests/Feature/SixStepTravelTest.php`
- `tests/Feature/SmgvAccountingTest.php`
- `tests/Feature/SmgvCenterTest.php`
- `tests/Feature/SmgvHistoricalImportTest.php`
- `tests/Feature/TimeServiceTest.php`
- `tests/Feature/WorkforceCoreTest.php`
- `tests/Fixtures/core-migration-hashes.json`
- `tests/Fixtures/core-schema-baseline.json`
- `tests/Unit/SmgvTimeEngineTest.php`
- `tests/Upgrade/CoreSchemaTest.php`
- `tests/bootstrap.php`
- `tests/upgrade.xml`
