Repository navigation
fix(mapper): read .reylo/ offline whatever the database url, or none - #9
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
ℹ️ No critical issues. One example README still documents the old keying, and there's one perf caveat for Postgres.
Reviewed changes
Initial review of the single commit, which takes the database server out of the .reylo/ cache key so that a build with another URL, no URL, or a moved project reads the entries a type check wrote.
- Server-free entry key:
Session.entryFilenow hashes only the entry version, the engine fingerprint, the dialect and the statement.#server()is gone, and each entry's recordedschemafingerprint is now the only freshness check. - No-URL read path: with neither a URL nor
schema,#analyzeserves.reylo/as-is, the same way it does when the database is unreachable. A miss,force, or a missing engine returns the existingmissingUrlerror (code 4). - Dialect without a URL: the new
installedEnginestakes the dialect from the single installed engine whether or notschemais set. The "which database?" error still fires only underschema. - Docs and tests:
03-inference.mdxnow says a build needs no URL. There's a new offline test (no URL, another URL, a copied project) and a rewritten keying test.
ℹ️ examples/esbuild/README.md still tells builds to set the same DATABASE_URL
The "Build without a database" section wasn't updated. It still tells readers to build with the same DATABASE_URL "even though it cannot connect: Reylo keys each analysis by the scheme, user, host, port and database of the URL". It also says a build "with another URL, or none" fails. After this PR, both statements are false. The first one keeps pushing readers toward the problem this PR fixes: putting the production host and user into the build's environment.
Technical details
# Stale offline-build guidance after the cache key change
## Affected sites
- examples/esbuild/README.md:62 — says to build with the same `DATABASE_URL` because entries are keyed by the URL's scheme/user/host/port/database
- examples/esbuild/README.md:64-66 — the example build command sets `DATABASE_URL=postgres://db.internal:5432/app`, which is no longer needed
- examples/esbuild/README.md:68 — "So does a build with another URL, or none" (fails at that file); another URL or no URL now reads `.reylo/`
- examples/nub/README.md:48 (softer) — "`nub src/main.ts` needs `DATABASE_URL` ... as the type check does"; now true only for a statement `.reylo/` lacks
## Required outcome
- The example docs match `site/content/sections/03-inference.mdx:82`: a build that can't reach the database reads `.reylo/` and needs no database URL.
- A statement `.reylo/` lacks still fails. With no URL, the message is the `No database URL: ...` one (`missingUrl`), not the `.reylo has no analysis of this statement` one.claude-opus-5-5 | 𝕏
4b820c8 to
95bab96
Compare
There was a pro 8000 blem hiding this comment.
ℹ️ The earlier feedback is addressed. One minor note inline about how the offline fallback picks an entry.
Reviewed changes
Since 4b820c8, 95bab96 gives each server its own entry again and adds a fallback that reads any server's entry when the database can't be reached.
- Entry per statement and server:
entryFileis now<statementKey>-<server hash>.json. Two Postgres databases with different OIDs no longer overwrite each other's entries. - Offline fallback:
#offlineEntryreads this session's own entry first. If there is none, it reads the newest valid entry for the statement from any server. This covers both the unreachable‑URL path and the no‑URL path. - Online path tightened: a reachable database now reads only its own entry, and only when that entry's fingerprint matches.
- Docs and tests: the esbuild and nub READMEs and
03-inference.mdxnow say a build needs no URL. A new test switches between two databases and checks that each one reuses its own entry.
claude-opus-5-5 | 𝕏
There was a problem hiding this comment.
ℹ️ The mtime concern is fixed. Two small cleanups are noted inline.
Reviewed changes
Since 95bab96, 261c734 makes the offline fallback order entries by the write time each entry records, not by the file's mtime.
- Recorded write time:
Entrygained an optionalat, and#analyzesets it withDate.now()when it writes an entry. - Fallback ordering:
#offlineEntrynow does one pass and keeps the entry with the largestat. It usesstatSync().mtimeMsonly for an entry that has noat. - Test: the two-database test now takes both databases away and swaps the files' mtimes. It then checks that a URL with no entry of its own reads the entry with the later
at.
claude-opus-5-5 | 𝕏
There was a problem hiding this comment.
✅ No new issues found. Both cleanups from the last review are addressed.
Reviewed changes
Since 261c734, 87b08b7 simplifies how the offline fallback orders entries.
- Required
atonEntry:atis now a required field, and its JSDoc sits on the field.Entrykeeps its own description on hover. - Recorded time only:
#offlineEntrydrops thestatSyncmtime fallback and its import. A missingatcounts as-Infinity, and the function returns the{ file, entry }pair directly.
claude-opus-5-5 | 𝕏
87b08b7 to
751a969
Compare
There was a problem hiding this comment.
✅ No new issues found. The rebase onto
mainresolves cleanly against the removal ofschemain #6.
Reviewed changes
Since 87b08b7, the branch was squashed into 751a969 and rebased onto main, which had removed the schema-files feature. The only net change is that the PR's schema handling is gone.
schemabranches dropped insrc/analyze.ts: the no-URL guards are now just!this.project.url.#server()no longer returns"schema".schema.fatalno longer tags its outcome withschema: true. The offline and online entry logic is otherwise unchanged.schemabranches dropped insrc/project.ts: the"schema" names a schema of which database?and MySQLschemaerrors are gone. With no URL,installedEngines(root)picks the dialect only when exactly one engine is installed, and otherwise it stayspostgres.- Comments updated: the file headers no longer mention the schema files. No references to
schema-files.tsremain insrc/ortests/.
claude-opus-5-5 | 𝕏
An entry was found by the server it was read from, so a build that could not connect had to set the type check's exact url, a SQLite project its database file at the same absolute path, and a build with no url failed before it read the cache. Each database keeps its own entry, and a session that cannot reach its database, or has no url, reads the statement's newest entry from any, by the time it records.
751a969 to
70c02fa
Compare

A build that couldn't reach the database read
.reylo/only under the type check's exact URL. Each entry was found by the server it was read from: scheme, user, host, port and database, or for SQLite the database file's absolute path. So:What changes
src/analyze.ts: an entry's file is named by its statement (the statement, the engine's fingerprint, the dialect), then by its server (never the password). Online, a session reads and writes its own server's entry, as before, so two databases keep an entry each. That matters on Postgres, whose schema fingerprint holds object ids, so a dev and a test database built by the same migrations still differ. A session that can't reach its database, or has no URL, reads its own server's entry where there is one, else the newest entry for the statement from any server. "Newest" means the write time each entry now records, since a copy of.reylo/(cp -r,fs.cpSync, a CI artifact) may reset the files' times. With no URL and no entry, it's the existing "No database URL" error.src/project.ts: with no URL, the dialect is the one engine package the project installed.Entries written before this change keep the old file names and become orphans, read by nothing, in a directory git ignores.
Verified
.reylo/and with its database gone, type-checks and builds with noDATABASE_URLand with one it can't reach.RESULTS.mdonly in the 24 S11 round-trip rows thatmainalready fails.