Skip to content

SnapRAID engine interface for jobs and array reads - #23

Merged
firsttris merged 2 commits into
masterfrom
claude/trusting-tesla-543ryb
Oct 9, 2026
Merged

firsttris merged 2 commits into
masterfrom
claude/trusting-tesla-543ryb

Conversation

@firsttris

@firsttris firsttris commented Oct 9, 2026 •

Copy link
Copy Markdown
Owner

Prepares a possible snapraid-daemon mode: everything the UI could get from the daemon's REST API instead of calling the CLI itself now goes through one interface. Behavior is unchanged, the CLI still does all the work.

The interface

SnapRaidEngine in backend/src/engine/engine.ts covers:

  • jobs with progress and output, abort, current and last job
  • the array status (with the disk check), the diff, SMART and the power state

createCliEngine() (engine/cli-engine.ts) wraps the command executor, the parsers and the demo stand-ins as before. Routes, scheduler, WebSocket and main.ts only use getEngine(). wrapJobs() lets main.ts hook into the scheduler's jobs by delegation instead of spreading the engine, so a class-based engine keeps its methods.

Stays with the UI whatever the engine:

  • config editing and validation, dup, list, devices (snapraid-runner.ts is now only these)
  • schedules, notifications, Docker pause and spindown

Tests

  • __tests__/engine-contract.ts describes what every engine has to do: a sync succeeds, the status lists the disks, the diff finds a new file and a sync records it, afterRun runs while the job is still current and the status refuses meanwhile, output reaches onOutput.
  • The contract runs against a fake engine (__tests__/fake-engine.ts) always, and against the CLI engine when SNAPRAID_BIN and SNAPRAID_EXTRA_ARGS=--test-skip-device are set. In CI, without a SnapRAID binary, the CLI run shows as ignored.
  • The scheduler can now be tested and has 7 tests against the fake engine: the nightly routine, a failed sync stopping the scrub, a missing disk skipping the run, a changed filesystem not stopping it, the sync guard, a scrub schedule without the guard.

Not losing track of the daemon

  • docs/architecture.md has a new SnapRAID engine section. It maps each engine method to its snapraid-daemon endpoint and lists what stays CLI-only, the open points for a daemon engine (logs and last runs, RunReport.log, SnapRAID's lock) and a checklist for new daemon versions.
  • The API was reviewed against snapraid-daemon v2.0rc2; the version is in backend/src/engine/REVIEWED_DAEMON_VERSION.
  • snapraid-release.yml became upstream-release.yml with two jobs, both every Monday:
    • snapraid, as before: an issue when a newer stable SnapRAID is out.
    • snapraid-daemon, new: an issue with the engine checklist when snapraid-daemon has a newer tag, release candidates included.

Testing

  • deno check, deno test: 102 passed, 1 ignored. With SnapRAID 14.10 from dev/setup.sh: 103 passed.
  • biome check, npm run typecheck, npm test: 24 passed.
  • mkdocs build --strict: no warnings.
  • Smoke test of the refactored backend against a sandbox: status, smart, probe, diff, a sync via /execute, last-job and last-runs all answered as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JuXnquCPdbG5sBbDyin7yF

claude added 2 commits October 9, 2026 06:21
Everything the UI could get from snapraid-daemon's REST API instead of
calling the CLI itself now goes through SnapRaidEngine: jobs with their
progress and output, abort, the array status, the diff, SMART and the
power state. createCliEngine() wraps the command executor and parsers
as before; routes, scheduler, WebSocket and main only use getEngine().
Config editing, dup, list, devices, schedules, notifications, Docker
pause and spindown stay with the UI whatever the engine.

A contract test suite says what every engine has to do and runs against
a fake engine always and against the CLI engine when a SnapRAID binary
is set (SNAPRAID_BIN, --test-skip-device). The scheduler, untestable
before because it spawned SnapRAID, is now tested against the fake
engine.

docs/architecture.md maps each engine method to its daemon endpoint and
lists what stays CLI-only and the open points for a daemon engine. The
API was reviewed against snapraid-daemon v2.0rc2
(engine/REVIEWED_DAEMON_VERSION); a weekly workflow opens an issue with
the checklist when a newer tag is out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JuXnquCPdbG5sBbDyin7yF
Both checks ask the same question, whether an upstream project has a
newer version, and open an issue with a checklist. upstream-release.yml
runs them as two jobs, snapraid and snapraid-daemon, so one failing
does not stop the other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JuXnquCPdbG5sBbDyin7yF
@firsttris
firsttris merged commit 784446b into master Oct 9, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants