Skip to content

feat: database user provider, persisted sync failures, Gemini/Bedrock, and a docs sync - #7

Merged
vheins merged 18 commits into
rustasea:masterfrom
gitfromwildan:feat/milestone-gap-closure
Nov 18, 2026
Merged

vheins merged 18 commits into
rustasea:masterfrom
gitfromwildan:feat/milestone-gap-closure

Conversation

@gitfromwildan

@gitfromwildan gitfromwildan commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes several items that docs/milestones.md listed as missing for M3, M4, and M6, fixes four defects found on the way, and brings the status documents in line with the code.

Fourteen commits, one per scope. Each commit message carries the detail; this description only adds what the commits cannot say on their own.

Changes

Scope Commit Effect
auth feat(auth): add DatabaseUserProvider over the users table Store-backed UserProvider for registration, login, password reset, verification, and profile updates.
app feat(app): read users from the database when the users table exists The runnable app installs that provider at boot when the default guard's provider is eloquent and the users table is reachable. Otherwise auth stays fail-closed.
queue feat(queue): persist failed sync jobs through the database connection A failed inline dispatch lands in failed_jobs as a retryable envelope when a database connection is registered. Also fixes sync dead letters storing a null payload.
ai feat(ai): serve gemini and bedrock through their OpenAI-compatible endpoints provider_from_env no longer rejects the two names.
ai fix(ai): send an embedding model, not the chat model, on embeddings requests Provider-backed embeddings could not work with the default configuration.
rustasea feat(rustasea): re-export rustasea-mail as rustasea::mail Adds the mail-smtp and mail-templates features.
orm fix(orm): decode a UUID stored in a column declared UUID on SQLite Rows read through fetch_json returned null for such an id. The scaffold migrations declare ids this way.
storage fix(storage): accept russh 0.65's PublicKeyOrCertificate in the SFTP host-key check rustasea-storage --features sftp has not compiled since the russh dependency bump, so cargo xtask ci fails on master.
router style(router): use is_none() in the domain route sort key A clippy 1.94 lint that fails -D warnings on master.
validation style(validation): address clippy 1.100 needless_bool in the unique check The one lint the CI toolchain (rustc 1.100.0) adds; it fails the lint job on master too.
deps chore(deps): replace the yanked clipboard-win 5.4.1 in the lockfile Lockfile only (one entry). Unblocks the two generated-code suites that fail in CI on master; #8 carries the identical change.
docs three docs: commits See "Documentation" below.

Behaviour changes

  • The app connects to the database at boot. With the default sqlite://database.sqlite?mode=rwc this creates an empty database.sqlite if none exists.
  • HttpProviderConfig gains a public field, embedding_model. Code that builds the struct with a literal needs the new field. The embedding model resolves from <PROVIDER>_EMBEDDING_MODEL, then a built-in default for openai, gemini, and mistral, then the chat model as before.
  • Sync failures move from the in-memory list to failed_jobs once a database connection is registered. Without one, nothing changes.

Testing

  • cargo xtask ci passes on rustc 1.100.0, the CI toolchain: fmt, clippy -D warnings (workspace and rustasea-storage --features aws,sftp), deps:check, lines:check, check-cycles.
  • cargo test --workspace --no-fail-fast: 1958 passed, 1 failed. That run predates the storage fix and the last two docs commits; rustasea-storage --features aws,sftp was run on its own afterwards and passes.
  • The one local failure was generated_app_compiles_for_every_variant in rustasea-scaffold. In CI on master, Test (workspace) fails on that suite and on generated_module_compiles_in_workspace in rustasea-cli: both compile a generated project offline, so they can only use the crates cargo fetch downloaded for the lockfile, and the lockfile pinned clipboard-win 5.4.1, which is yanked. The last commit replaces it with 5.4.3.
  • cargo-audit and cargo-deny fail on this PR because of RustSec advisories published against dependencies already on master (for example RUSTSEC-2026-0436 in calamine 0.36.1 and RUSTSEC-2026-0387 in crypto-bigint). They are addressed in chore(deps): clear the RustSec advisories failing cargo-audit and cargo-deny #8, not here.
  • The app was started in both states: without a users table it logs that the provider stays fail-closed, with one it logs that users resolve from the database. Both serve GET / with 200.
  • New tests: crates/rustasea-auth/tests/database_user_provider.rs, crates/rustasea-queue/tests/sync_failed_sink.rs, a UUID round trip in crates/rustasea-orm/tests/raw_execution.rs, provider resolution cases in crates/rustasea-ai/tests/http_providers.rs, and two in crates/rustasea-app/src/bootstrap/auth.rs.

Not verified

  • Gemini and Bedrock against the live services. Endpoints, auth, and the default model ids come from the vendors' documentation; only configuration resolution is tested.
  • DatabaseUserProvider on Postgres or MySQL. It runs on SQLite only. It writes NULL as a literal rather than a bound value because the ORM binds Value::Null as an integer, which Postgres rejects for a timestamp column.

Documentation

  • docs/milestones.md. M4 stays Partial. The first docs commit marks it Done and the second reverts that: the scheduler cannot dispatch a due command (dispatch_command always returns an error), pause state is per-process, and after-response events are never flushed. Stale claims are also corrected, such as the app's AppServiceProvider being a no-op.
  • docs/laravel-parity.md. Rows that had fallen behind, including three marked Planned or thin that already exist (ShouldBeUnique, the ability Gate, the batch repository).
  • .agents/documents. As-built status on the roadmap and sprint documents. The 110 implementation-task rows under application/modules were all Todo; they are now 55 done, 53 partial, 2 not started, with what is missing listed for each open row. Plan text is unchanged.

The task-row statuses come from reading the code, not from running tests. I re-checked the surprising ones and every path:line I cite myself; the rest relies on a search pass.

Found, not fixed

Recorded in docs/milestones.md with evidence, and left for separate changes:

  • The AI agent runtime echoes the prompt and never calls a provider (crates/rustasea-ai/src/agent.rs:247).
  • Domain routes ignore the request Host, so a domain route answers for every host (crates/rustasea-router/src/dispatch.rs:57).
  • A bare-word list such as in:admin,editor rejects every value (crates/rustasea-validation/src/rules/support.rs:134).
  • JwtGuard::logout is a no-op (crates/rustasea-auth/src/jwt.rs:270).

Still open from the milestone list: database, cache, and queue bindings in the container at boot (M0), live column introspection for show:model (M1), route registration from the generators (M5), and the database user provider in the scaffold templates (M3).

@vheins, could you review this?

clippy 1.94 rejects `!r.domain.is_some()` (nonminimal_bool) under -D warnings.
SQLite gives a column declared `UUID` NUMERIC affinity, so the driver reports
neither UUID nor BLOB and the row decoder returned null for the id. The scaffold
migrations declare ids this way, so a row read through fetch_json lost its id on
the default SQLite connection. Try a UUID decode as the last fallback.
A failed inline (sync) dispatch was only tracked in a process-local list, so it
vanished on exit and never showed in queue:failed. When a database connection is
registered the failure is now written to its failed_jobs table as a full job
envelope, so queue:retry can re-enqueue it; without one, or if the insert fails,
it still falls back to the in-memory sink.

The job body is captured before the run: executing a job consumes it, so every
sync dead letter previously stored a null payload.
The store-backed UserProvider for registration, login, password reset, email
verification, and profile/timezone updates, against the scaffold users table.
Soft-deleted users do not resolve, a malformed id is treated as an unknown user,
and any database failure surfaces as AuthError::StoreUnavailable.
Adds the mail-smtp and mail-templates features forwarding to the mail crate's
smtp and templates features.
…dpoints

provider_from_env rejected both names. Gemini now resolves to the Gemini API's
OpenAI-compatible base URL with GEMINI_API_KEY; Bedrock resolves to the regional
bedrock-runtime /openai/v1 endpoint with a Bedrock API key
(AWS_BEARER_TOKEN_BEDROCK) and AWS_REGION, so no SigV4 signing is needed.
…equests

OpenAiProvider::embeddings posted the provider's default chat model, which an
embeddings endpoint rejects, so provider-backed Str::to_embeddings could not
work with the default configuration. The config now carries an embedding model:
<PROVIDER>_EMBEDDING_MODEL, else the provider's known embedding model (openai,
gemini, mistral), else the default model as before.
After boot the app replaces the fail-closed user provider with
DatabaseUserProvider when the default guard's provider is ORM-backed (eloquent)
and the users table is reachable, so registration and login persist. A dev seed
user still wins, and with no database or no users table auth stays fail-closed.
Records the database user provider, persisted sync failed jobs, the Gemini and
Bedrock providers, the embedding model fix, and the mail re-export, and corrects
claims that had gone stale: boot already mounts the config loader, the app's
AppServiceProvider is not a no-op, a database session store exists, and
provider-backed embeddings were already implemented. M4 moves to Done.
…host-key check

The russh bump changed Handler::check_server_key to take a
PublicKeyOrCertificate, so rustasea-storage no longer compiled with the sftp
feature. The pin now compares the fingerprint of the presented key, or of the
key a host certificate certifies.
Returns M4 to Partial: the scheduler cannot dispatch a due command, schedule
pause state is per-process, and after-response events are never flushed. The
previous docs commit marked M4 Done on the strength of the failed-job sink
alone; that was wrong.

Records, with path:line evidence, facts found while checking the planning
documents: the AI agent runtime echoes the prompt instead of calling a
provider, domain routes ignore the request Host, JwtGuard::logout is a no-op,
and a bare-word in: rule list rejects every value.

Updates the parity rows for events, batches, unique jobs, sessions, the user
provider, mail, notifications, the gate, the password-reset store, the
scheduler, and the AI SDK, and adds a resolution note to the gap audit.
The roadmap, sprint index, and sprint headers carry the as-built milestone
status with a pointer to docs/milestones.md. The 110 implementation-task rows
under application/modules were all still Todo; each was checked against the
source tree (55 done, 53 partial, 2 not started) and every open row lists what
is missing. Plan text is unchanged.
@github-actions
github-actions Bot requested a review from vheins November 18, 2026 05:43
…heck

CI runs the latest stable (rustc 1.100.0), where clippy rejects the
if-return-false / return-true pair under -D warnings and fails the lint job.
Behaviour is unchanged.
The generated-code tests (generated_module_compiles_in_workspace and
generated_app_compiles_for_every_variant) compile a generated project offline,
so they can only use the crates cargo fetch downloaded for the lockfile. With
the yanked 5.4.1 pinned, both fail in CI to resolve rustyline's clipboard-win
requirement. 5.4.3 replaces it.
@vheins

vheins commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

Review: feat/milestone-gap-closure

Decision: APPROVE_WITH_NITS. No blocking correctness, security, or data-integrity defect found.

Checked with the full diff against eb52d94a:

  • DatabaseUserProvider uses parameterized values, a validated identifier for the table, and only internal constants for column names. The app's Argon2 hashing and the uniform BadCredentials login path are unchanged. Boot fails closed when the pool or the users table is unavailable. The literal NULL workaround is justified by crates/rustasea-orm/src/value.rs:67.
  • The sync dead-letter fix captures as_json() before run_erased, so the stored payload is populated. Persistence writes a full JobPayload envelope, retry_failed re-enqueues it, and the in-memory fallback still runs when no database driver is registered.
  • The deps commit is lockfile-only (+2/-2). The docs commits are honest, including the M4 revert and the SQLite-only limitation.

Non-blocking follow-ups:

  1. crates/rustasea-ai/src/providers/client.rs:49: the new public field breaks downstream struct literals. The changelog promises to call out breaking changes; add that note, and plan #[non_exhaustive].
  2. crates/rustasea-ai/src/providers/client.rs:311-322, :403: the OpenAI embedding default also applies to custom base URLs, and Bedrock falls back to the chat model for embeddings despite the comment saying that is invalid.
  3. crates/rustasea-auth/src/users/provider/database.rs:135: affected == 0 assumes matched-row semantics; MySQL reports changed rows on a no-op update.
  4. crates/rustasea-app/src/bootstrap/auth.rs:291: "database unreachable" also covers an uncompiled Postgres driver; the message should say the driver feature is missing.
  5. crates/rustasea-queue/src/driver.rs:198: sync persistence only recognises a connection named exactly database.

CI: Format, lint & cycles, MSRV, and Test (workspace) are green. cargo-audit and cargo-deny fail on inherited advisories handled by #8. Merge #8 first, then rebase and regenerate Cargo.lock; the clipboard-win hunk is identical in both PRs and will not conflict textually.

…ings without one

- Scope the built-in `text-embedding-3-small` default to the canonical
  api.openai.com base URL; a custom OPENAI_BASE_URL keeps the default model
  unless OPENAI_EMBEDDING_MODEL is set.
- Return a configuration error from `embeddings()` for bedrock when no
  embedding model is configured instead of falling back to the chat model.
- Note the `HttpProviderConfig.embedding_model` field addition as a breaking
  change in the changelog.
…rovider

- Treat an update that matched but changed no rows (MySQL changed-row
  semantics) as success after probing for the live row, instead of returning
  UserNotFound.
- Map a unique-email violation during update_profile to UserExists rather than
  StoreUnavailable.
…th bootstrap

- Match OrmError::UnsupportedDriver separately from an unreachable database so a
  sqlite-only build pointed at Postgres says the driver feature is missing.
- Log both cases through tracing instead of eprintln.
… letters

- Look up the configured default connection instead of the literal `database`
  name when persisting sync failures, falling back to the existing default.
@vheins
vheins merged commit 0e6576b into rustasea:master Nov 18, 2026
4 of 6 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