Technical improvement roadmap
Status
Section titled “Status”Superseded on 2026-08-28 by the complete remediation plan, which is the canonical execution authority. This document remains available as historical context and must not be used to infer the current scope; in particular, the new plan explicitly keeps the .env.example findings outside its execution boundary without closing them.
Objective
Section titled “Objective”Bring MonStaff from a functioning early product to a defensible multi-tenant service without rewriting the modular monolith.
Phase 0 — Immediate containment
Section titled “Phase 0 — Immediate containment”Status: proposed
- Rotate all credentials exposed in
.env.exampleand replace them with placeholders. - Add secret scanning and inspect Git history only after rotation.
- Fix every admin query to scope records by
project.organizationId. - Stream or directly presign desktop-update uploads; reduce the temporary size limit.
- Correct
OLLAMA_BASE_URLand create the update bucket in production Compose.
Exit evidence: rotated provider records, cross-tenant regression tests, bounded upload test and rendered deployment configuration.
Phase 1 — Authorization and data integrity
Section titled “Phase 1 — Authorization and data integrity”Status: proposed
- Introduce central
requireProjectMember,requireOrgAdmin,requireTimeEntryOwnerand resource-in-organization policies. - Apply them to projects, issues, timers, screenshots, activity and import mappings.
- Reconcile removed GitHub memberships.
- Add the one-running-timer partial unique constraint.
- Make screenshot/object deletion idempotent and recoverable.
Dependency: agreed security model.
Phase 2 — Identity redesign
Section titled “Phase 2 — Identity redesign”Status: proposed
- Replace bearer-token deep links with a one-time authorization code.
- Use Authorization Code + PKCE and secret, expiring state.
- Store/consume challenge state atomically in PostgreSQL or Redis.
- Introduce short access tokens and rotating, revocable refresh tokens.
- Re-read current server-side authorization for sensitive actions.
Phase 3 — Quality and dependency baseline
Section titled “Phase 3 — Quality and dependency baseline”Status: proposed
- Add a clean root typecheck and real lint scripts.
- Fix desktop contract/type errors.
- Add security-first unit and integration tests.
- Gate deploy and release on full verification.
- Upgrade Fastify/JWT, Electron, AWS SDK/XML parser and build tooling in controlled groups.
- Enable automated dependency update and vulnerability scanning.
Phase 4 — Durable asynchronous work
Section titled “Phase 4 — Durable asynchronous work”Status: proposed
- Introduce a worker and durable job queue for imports and large GitHub syncs.
- Add lease, heartbeat, cancellation, checkpoints and recovery.
- Add idempotency keys and server deduplication to desktop retries.
- Encrypt queued local payloads or replace embedded bearer tokens with safe references.
- Standardize outbound timeouts, backoff and retry eligibility.
Phase 5 — Operability and scale
Section titled “Phase 5 — Operability and scale”Status: proposed
- Separate liveness and readiness and expose dependency status.
- Add metrics, tracing/correlation and security audit events.
- Move unbounded analytics to paginated database aggregation.
- Establish PostgreSQL/S3 backup and recovery tests and disruption budgets.
- Pin images, run non-root and add security/network policies.
- Define service-level objectives and alert thresholds.
Completion protocol
Section titled “Completion protocol”When work lands, update the relevant item to completed with date, commit, tests and residual risk. Update the risk register separately; implementation alone does not prove closure.