Skip to content

Make pause state durable and survive process restarts #29

@mikewheeleer

Description

@mikewheeleer

Implement durable, observable pause state

Description

The paused boolean in src/index.ts drives the pause middleware, /api/v1/admin/status, the deep-health status, and the stableroute_paused metric — but it is a plain in-process variable that resets to false on every restart. An operator who pauses the service before a deploy would find it silently un-paused afterward. This issue makes pause state durable and records pause/unpause as audit events.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-backend only.
  • Persist paused (via the storage adapter if available, else a small state file) and restore it on startup.
  • Emit admin.paused / admin.unpaused events via recordEvent so the audit log captures operator actions.
  • Keep the existing middleware allowance for /api/v1/admin/unpause so recovery is always possible.
  • Reflect the restored state in /api/v1/admin/status, deep health, and the metric.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b enhancement/admin-29-durable-pause
  • Implement changes
    • Write code in: src/index.ts — persist/restore pause; emit events.
    • Write comprehensive tests in: src/__tests__/index.test.ts — assert events recorded; simulate restore from persisted state.
    • Add documentation: document durable pause in README.md.
    • Add TSDoc on the persistence helper.
    • Validate security: pause/unpause must respect the admin guard once it lands.
  • Test and commit

Test and commit

  • Run npm run build, npm run lint, and npm test.
  • Cover edge cases: pause→restart→still paused, unpause clears, events emitted.
  • Paste full npm test output in the PR.

Example commit message

feat(admin): make pause state durable and audited

Guidelines

  • Minimum 95 percent test coverage for impacted code.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions