Task 14: apps/fluxer runtime (effect executor, config, logging) (#14) #50
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/14-app-runtime"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: task/7-gateway-machine-transport, task/12-platform-persistence, task/13-devserver (merged into this branch at
3aae67d; the diff againstfoundationincludes them until they land).What was built
apps/fluxeris now a library plus a thin binary:runtime.rs—Runtime::new(config, paths),start(self) -> (mpsc::Sender<CoreEvent>, mpsc::Receiver<CoreEvent>, Handle). A tokio task owns theApp, applies events and executes effects in order:ApiviaApiClient(GETsDiscover/Me/FetchMessagestried 3 times with 0.5 s / 1 s backoff on transport errors, 5xx and short rate limits; everything else once ->EffectFailed), gateway viaConnection(one task per connection; retries the first socket with backoff),Persistviafluxer_platform::Storeon a blocking worker (strictly ordered, consecutiveSaveSettingscoalesced),Scheduleviatokio::time::sleep,OpenUrlvia the system opener,Notifylogged until Task 23.AppSnapshot = Arc<App>is published on awatchchannel once per batch of events (Handle::snapshots()), so the store is copied at most once per batch.config.rs—--instance/FLUXER_INSTANCE,FLUXER_LOG,--devserver [scenario],--record <dir>,--debug-info.logging.rs— stderr + daily-rotated files inpaths.log_dir(tracing-appender),EnvFilter, panic hook writingpanic-<ts>.txt.debug_info.rs— version, git sha (newbuild.rs), OS, wgpu adapters (name, backend, driver), paths.record.rs—gateway.jsonl/rest.jsonlwithauthorization,token,*_token,email,password,new_password,phone,ticketvalues replaced by"<redacted>".main.rs— headless until Task 17: starts the runtime, logs session changes, stops cleanly on Ctrl-C.How it was tested
apps/fluxer/tests/runtime.rs(in-process devserver, no keyring, temp dirs):runtime_logs_in_against_devserver_and_reaches_ready,record_mode_redacts_tokens, plusui_events_fetch_history_and_send_a_message,logout_disconnects_and_returns_to_the_login_screen,start_outside_a_tokio_runtime_brings_its_own.cargo run -p fluxer -- --devserver --record <dir>(reaches READY, 2 guilds, Ctrl-C exits 0, recording has no token),--debug-info,--version, bad--instance.cargo xtask cigreen locally (Linux).cargo clippy/test -p fluxer --no-default-featuresalso green.Deviations from the plan / things to look at
fluxer-apiandfluxer-gateway(separate commit683bfd8):ApiClient::with_observerandConnection::connect_with_tap. Record mode needs the raw frames and bodies, which neither crate exposed (GatewayEventis not evenSerialize). Both hooks are opt-in and carry no headers.src/lib.rs(integration tests cannot import a bin-only crate) andbuild.rs(git sha).start's tuple: the plan does not say what theReceiver<CoreEvent>yields. Here it is every event the store reduced, in order (forUiMessage::Core); advisory, bounded (1024), skipped when full or dropped.--devserveris hermetic:Storealways uses the real OS keyring outside its own unit tests, so devserver mode (and therefore the tests) uses in-memory persistence instead of settings file/keyring/cache.fluxer-devserveris an optional dependency behind the default-ondevserverfeature; Task 25 should package with--no-default-features.--instance/FLUXER_INSTANCEis saved to settings (the keyring entry is per instance host andStorederives it from the settings file); the cache of the previous instance is cleared on a switch.SendMessage/EditMessage/DeleteMessage) go through one FIFO so two quick sends cannot swap; other requests run concurrently.tracing-appender,tracing-subscriber,wgpu = 27(the version iced 0.14 uses on the Task 16 branch).deny.toml:CC0-1.0(hexf-parse via naga) andRUSTSEC-2024-0436(paste via metal), the same two entries Task 16 adds; expect a mechanical conflict there. The dependency merges neededtoml = "1"with default features (platform writes TOML, devserver only parses).UserAction::RegenerateStatusToken(core has no event to receive a generated token) and startingfluxer-status-api; headers are not recorded at all rather than recorded withAuthorizationredacted.codeis deliberately not redacted (it is the API's error-code member).Closes #14
🤖 Generated with Claude Code
Independent review: Task 14 (app-runtime) at
a2ce504Scope:
git diff 3aae67d..origin/task/14-app-runtime. Read cold; the implementer's notes were verified, not trusted.Checks
runtime_logs_in_against_devserver_and_reaches_readywaits on the snapshot forAuth::LoggedInplus non-empty guilds, thenGatewayState::Ready.record_mode_redacts_tokensreads the live session token (asserts it starts withflx_), asserts the recording is non-empty, holds the login exchange and READY, and that no file contains the token or the fixture e-mail. Neither is vacuous. Both pass.Runtime::new(config: Config, paths: Paths) -> Runtime,fn start(self) -> (mpsc::Sender<CoreEvent>, mpsc::Receiver<CoreEvent>, Handle),AppSnapshot = Arc<App>overwatch(Handle::snapshots()),Configwith--instance/FLUXER_INSTANCE,FLUXER_LOG,--devserver [scenario],--record <dir>,--debug-infoall exist as written. GET retry is 3 tries (0.5 s, 1 s), unit-tested with paused time. Thefluxer-api/fluxer-gatewaychanges are additive (with_observer,connect_with_tap); existing signatures are untouched.fluxer-coreandfluxer-uiare not touched. No non-testunwrap/panicon server data (the oneexpectis on theDEFAULT_INSTANCEconstant, with a test). No real tokens in code or fixtures; logs name persist ops without their payloads.cargo xtask ciin the review worktree (Linux): green (fmt, clippy, deny, tests; screenshot step skipped as configured). Also ran:cargo clippy -p fluxer --no-default-features --all-targets -- -D warningsclean;fluxer --debug-infoprints version, sha, OS, adapters, backend, paths;fluxer --devserver --record <dir>reaches READY, writes no settings/keyring/cache, and the recording contains noflx_string. Windows was not run here.Findings (none blocking)
apps/fluxer/src/runtime.rs(shutdown):writes_task.abort()drops queued or in-flight message send/edit/delete requests on shutdown, whileHandle::shutdownis documented as waiting for queued writes. A message sent just before quitting can be lost without the store hearing about it. Consider draining with the same 5 s timeout as persistence.apps/fluxer/src/runtime.rs(Persistence::execute): a failed persist op is only logged; no event reaches the store. The plan says everything else fails once intoEffectFailed. A token that could not be saved to the keyring is invisible to the user until the next start.apps/fluxer/src/runtime.rs(switch_instance):--instance/FLUXER_INSTANCErewritessettings.tomland empties the previous instance's cache before login. A one-off environment variable therefore changes the saved instance permanently. The cache is disposable per spec, so not data loss, but this is a behaviour decision the plan did not make; worth aquestionor a note for Task 17.apps/fluxer/src/record.rs:session_idandauth_session_id_hashare recorded as is, andAuthorizationis omitted instead of written as"<redacted>". The plan's list (Authorization,token,email) is covered; scrub the session identifiers too before recordings of a real session become fixtures.apps/fluxer/src/runtime.rs(retry_get): stacks onfluxer-api's own retry-once on 429, so a rate-limited GET can be sent up to 6 times.UserAction::RegenerateStatusToken(core comment says the runtime generates it),Effect::Notifyand startingfluxer-status-apiare not wired. Per CLAUDE.md these needfollow-upissues linked from this PR before merge. The cross-crate touch (fluxer-api,fluxer-gateway) is in its own commit and opt-in, but the plan did not name it.Verdict: APPROVE (0 blocking, 6 minor; local CI green on Linux, Windows left to the integrator).
Finalizer: branch head
a2ce504is up to date withfoundation,cargo xtask cipasses locally and the Linux runner is green. Both Windows jobs (runs 75, 76) failed because the runner disk is full (os error 112), before any code was tested; see #51. Not labelledready-to-mergeuntil a Windows run is green; re-run the Windows job once space is freed.