Repository navigation
SnapRAID engine interface for jobs and array reads - #23
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
SnapRaidEngineinbackend/src/engine/engine.tscovers:createCliEngine()(engine/cli-engine.ts) wraps the command executor, the parsers and the demo stand-ins as before. Routes, scheduler, WebSocket andmain.tsonly usegetEngine().wrapJobs()letsmain.tshook 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:
dup,list,devices(snapraid-runner.tsis now only these)Tests
__tests__/engine-contract.tsdescribes 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,afterRunruns while the job is still current and the status refuses meanwhile, output reachesonOutput.__tests__/fake-engine.ts) always, and against the CLI engine whenSNAPRAID_BINandSNAPRAID_EXTRA_ARGS=--test-skip-deviceare set. In CI, without a SnapRAID binary, the CLI run shows as ignored.Not losing track of the daemon
docs/architecture.mdhas 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.v2.0rc2; the version is inbackend/src/engine/REVIEWED_DAEMON_VERSION.snapraid-release.ymlbecameupstream-release.ymlwith 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 fromdev/setup.sh: 103 passed.biome check,npm run typecheck,npm test: 24 passed.mkdocs build --strict: no warnings./execute,last-jobandlast-runsall answered as before.🤖 Generated with Claude Code
https://claude.ai/code/session_01JuXnquCPdbG5sBbDyin7yF