mega-plant/docs/superpowers/plans/2026-10-21-plant-clock.md

3.3 KiB

Plant Clock Implementation Plan

Goal: Employee badge scanning in Plant using the Infrastructure confirmation flow. Architecture: Existing operator/mechanic roster, testable clock service, PocketBase adapter and private audit collections, authenticated APIs, mobile scanner and attendance view. Spec: docs/superpowers/specs/2026-10-21-plant-clock-design.md

  • Test and implement QR identity, local-day action rules, stale confirmation, recent-scan guard, idempotency, concurrency locks, missed-out audit and elapsed time.
  • Add idempotent private schema setup and authenticated lookup/scan/roster APIs. Verify on isolated in-memory storage; create only new collections on Plant.
  • Add scanner, site picker, camera/manual lookup, GPS acknowledgement, confirmation and safe retry. Add employee status/history/QR downloads and navigation.
  • Run tests, typecheck, production build, auth checks and browser flows. Audit both new routes at 375x812 and 768x1024; screenshot routes and confirmation/error states.

Review focus: ambiguous badges fail closed; failed save retries reuse the same request; old IN never becomes today's OUT; two devices cannot toggle a worker twice from one confirmation; denied camera/GPS has an explicit usable fallback. Existing employees and financial data must remain untouched.

Verification

Production webpack build and typecheck passed. Unit tests: 45 passed, 6 pre-existing skips. Live temporary-worker integration passed IN, OUT, retry, stale/recent rejection, history, private database access and lock release. Auth route checks passed. Browser decoded a generated badge video, saved IN and two-tap recent OUT, rendered the QR badge and download link. Temporary worker/scans removed. Mobile screenshots and audits cover /clock and /employees at 375x812 and 768x1024.

Final review: abandoned-lock and overlapping-retry findings fixed and regression-tested; reviewer confirmed both resolved.

Forgejo merge and standalone PWA follow-up

  • Save recovery branch/stash, fast-forward local main to b0c70e9 (13 Forgejo commits), reapply clock work and resolve lockfile/auth-test conflicts.
  • Verify 76 upstream-modified files remain byte-for-byte equal; review six intentional integration files. Preserve all remote dependency metadata, adding only jsqr.
  • Accept existing Plant NAME | CODE badges and Infrastructure code-only badges; reuse upstream vector QR/PDF helpers.
  • Separate /clock from the dashboard, add independent manifest, icons, install help and scoped login/onboarding/logout.
  • Production build passed (upstream purchase-parser pdfjs ESM warning remains); typecheck and 67 active tests passed, six existing skips.
  • Production PWA/auth/clock integration passed. Chrome offered its real native install prompt. Camera decoded a Plant-format badge; shared vector PDF download passed.
  • First-password setup, sign-out and fresh sign-in returned to the correct /clock routes. Upstream running/invoice pages passed smoke checks.
  • /clock, /employees, /clock/login and /clock/change-password passed 375x812 and 768x1024 audits: no horizontal page overflow, undersized text or small tap targets. Screenshots: /tmp/plant-merged-pwa-mobile.

Phone installation requires deploying this build on the HTTPS Plant host. Deployment is a separate step. The pre-merge recovery stash is retained.