Repository navigation
Show the refusal of a database that requires an unsupported extension in the app (ADR-083 §2) - #3427
Conversation
Pragmatic code review: PR #3427 (S7, refusal view)Review Type: Initial Review (medium depth). Head What I ran:
Contract check against S6:
Requirements CheckACCEPTANCE
TESTS
OWNED FILES / DO NOT TOUCH: ✅. The diff is TS and Svelte only. It doesn't touch Rust, extension-api, ui-extensions*, labs-settings or On the questions I was asked to scrutinise1. The store reads the database itself instead of catching REQUIRES_EXTENSION centrally. The reasoning is sound.
2. The
3.
4. The view.
5. The type guard. Accepting only https is right. It is stricter than 6. Tests. They are well isolated and test what they claim. The routed-daemon fake ( Code Review Findings🟡 1. Every activation now waits for the target database to open before the selection commits📁 await invoke('set_active_database', { id });
if (seq !== this.switchSeq) return;
const refusal = await this.readRefusal(); // first routed request → waits on get_or_open
if (seq !== this.switchSeq) return;
this.activeDatabaseId = id;Before this PR, the commit followed This has two effects on the normal path, where nearly every switch lands:
The PR body lists "one more command" under its changes to existing behaviour, but not that the commit now blocks on the open. Recommendation (not blocking): one of the following.
Principle: KISS/YAGNI on the hot path. Don't charge every switch for a rare case when a signal you already have can tell the cases apart. 🟡 2. No test pins
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
e0dcb30 to
9ecc3bf
Compare
Address review (round 1)The fixes are in commit 9ecc3bf. The branch is also rebased onto main at 1534f76, which carries the hard ban from #3420. Addressed
Skipped
Checks
Re-review decisionRE-REVIEW NEEDED. The selection flow in |
Pragmatic code re-review: PR #3427 (S7, refusal view)Review Type: Re-Review (medium depth). Only the round-1 fix commit Base: the branch is rebased onto What I ran on head
S6 contract: I re-checked it on S6's current head Previous Review SummaryRound 1 had 8 items: 2 🟡, 4 🟢 and 2 nits. Status now: 6 addressed (both 🟡 and all four 🟢) and 2 nits skipped, with reasons I accept.
How 🟡1 is fixed:
On the points raised for this round1. Does routing point at Yes, given the same assumption all frontend routing already makes: Tauri handles
2. Switch A's check resolving after switch B started but before B commits. This is acceptable. The result describes A, because it was sent while routing pointed at A, and A really is refused. So the store records a true fact about the database still selected. B's commit then reassigns The visible effect is that the refusal view can appear for A while B is in flight, if B is pre-read because the listing marks it refused. The view then gives way to B's own outcome. No test covers exactly this interleaving. I don't think one is needed, because both halves are each pinned: the "no longer selected" drop and "the commit reassigns 3. The warn branch and the doc. Both are correct. See the nit below for one small tidy-up. 4. Are the new tests brittle? No.
Code Review Findings (new in this round)🟢 Nit: one condition in the warn branch📁 if (typeof err === 'object' && err !== null && 'code' in err) {
if (err.code === 'REQUIRES_EXTENSION') {Nit: the two nested 🟢 Nit: a database that is refused but not marked in the listing loses the startup conflicts notice📁 When the restored database is refused but the listing doesn't mark it, the selection commits with This is practically unreachable: at boot the listing was fetched moments before, and S6's Recommendation: APPROVEEvery round-1 finding is addressed, and the redesign is a clear improvement:
The tests pin the new behaviour without timing fragility. Still outstanding before merge and release, as before:
|
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
9ecc3bf to
661bcf4
Compare
Address review (round 2)The branch is rebased onto main at 33ed106, which includes #3426. Re-review nits
No logic changed in this round's TS, so these alone need no re-review. New since round 2, at the coordinator's request: 661bcf4 (Rust)The token-stream task in
Re-review decisionRE-REVIEW NEEDED for 661bcf4, since it is new Rust logic. |
Pragmatic code re-review, round 3: PR #3427Review Type: Re-Review (medium depth). In scope: Rebase check: How I checked it:
Previous Review SummaryRound 2 had 2 items, both 🟢 nits: 1 addressed and 1 skipped, as I suggested. Every round-1 item stays addressed, since those commits are unchanged.
Round 3: the token-stream retry loop (
|
| Condition | Status | Notes |
|---|---|---|
(1) Only a status that unsupported_extensions recognises changes the behaviour; every other error keeps the 2s retry exactly |
✅ | is_database_refusal is exactly unsupported_extensions(status).is_some(). wait_to_resubscribe skips the sleep only when that holds and changed() returns Ok. A plain failed_precondition("model not ready") and unavailable are both pinned as not refusals. |
| (2) After a refusal, the loop resumes once the active database changes | ✅ | the_loop_waits_out_a_refusal_and_resubscribes_once_the_active_database_changes runs the real resubscribe_forever. It makes 1 attempt across 20s of paused time, then 2 within 1 ms of a generation bump. Production passes ` |
(3) Crate-scoped build, test and test:changed |
⏳ | This is the author's run, which I didn't repeat on the shared slot. The PR summary reports clippy -D warnings and fmt as clean, and 7 of 7 mutations killed. |
On the points to scrutinise:
(a) Behaviour for Ok and for errors other than the refusal. It is preserved.
Ok(()), meaning the stream ended or a database change interrupted it, gives the same info line and thensleep(2s).- Any other
Errgives the same warn text and thensleep(2s). - The one observable difference is the warn line's
errorfield: see the nit below. - Swapping the error type from
Stringtotonic::Statusdoesn't change control flow. Both?sites forward the same statuses that used to be stringified.
(b) The receiver taken before the attempt, and the clone given to the attempt. There is no double wake and no missed wake.
Receiver::clonecopies the seen-version. So the attempt's clone and the outer receiver both start at the current generation, and each tracks changes on its own.- Ok path: the clone sees the change inside
try_subscribe'sselect!and returnsOk.wait_to_resubscribenever polls the outer receiver onOk, so the next iteration's fresh receiver discards the pending change. There is a single 2s sleep, as before. - Refusal path: the refusal comes from the initial RPC, before the
select!ever runs. A change made between taking the receiver and the refusal is therefore still unseen on the outer receiver, andchanged()returns at once.the_loop_does_not_miss_a_change_during_the_refused_attemptpins this. - Ordering against
set_active_database: it rebuilds the routed clients under the write lock and bumps the generation after releasing it. If the receiver was taken after the bump, the attempt necessarily got the new client. If it was taken before, the bump is seen. Either way no change is lost, and at worst one extra attempt goes to the same new database.
(c) Falling back to the delay when the sender is gone.
- This is correct.
changed()returnsErronce the sender is closed, which falls through tosleep(delay), so there is no spin.a_refusal_falls_back_to_the_delay_once_the_client_is_gonepins it. - In production the sender is
Arc<watch::Sender>insideGrpcClient, which this task owns, so the fallback is defensive only.
(d) Closure lifetimes.
- Both closures capture
appandgrpcby shared reference from the spawnedasync moveblock, which owns them for the task's life. - The future that
try_subscribe(&app, &grpc, …)returns borrows through those shared captures, which is sound forFnMutbecause shared references areCopy. - The two closures share their borrows without conflict.
- The spawned future stays
'static + Send, since it owns its captures.
(e) The paused-clock tests.
- They are deterministic. With
start_paused, tokio advances time only when every task is idle. So aftersend_modify, the woken loop task runs before the test's 1 ms timer can fire. - The exact
elapsed()assertions (ZEROandRESUBSCRIBE_DELAY) hold because auto-advance jumps straight to timer deadlines. - "11 attempts in 20 s + 1 ms" is exact, at t = 0, 2, …, 20.
- Each loop test
abort()s its task. - They prove condition (2) at the loop level, as described above.
(f) Log levels.
- The refusal logs at
info, once per attempt, and attempts now happen only on a database change or channel rebuild. So it is once per change, instead of awarnevery 2s. - Other failures stay at
warn, andOkstays atinfo.
(g) Product-name wording. It is clean. The text is "requires an extension this build does not support", and the hard ban passes.
Code Review Findings (new in this round)
🟢 Nit: the warn line now prints the whole tonic::Status, not just its message
📁 packages/desktop-app/app-lib/src/commands/local_agent.rs (resubscribe_forever, the Err(e) arm)
tracing::warn!(error = %e, "Token stream subscription failed; reconnecting in 2s")e used to be the String from e.message(). It is now tonic::Status, and tonic 0.12.3's Display writes status: {code:?}, message: {msg:?}, details: {bytes:?}, metadata: {MetadataMap:?}. So while the daemon is unreachable, every 2s warn line carries the full metadata map and the details bytes, where before it carried only the message.
Recommendation: use tracing::warn!(code = ?e.code(), error = %e.message(), …) to keep the old, compact line. This is optional.
🟢 Follow-up (out of scope for this PR): the node watcher has the same pattern, already bounded
📁 packages/desktop-app/app-lib/src/watcher.rs (run)
WatchNodes is routed, so with a refused active database stream_once fails with the same refusal. It then logs warn! and retries on its exponential backoff, capped at BACKOFF_MAX = 30s. The backoff select! already wakes on db_changed, so a switch recovers at once, and the noise is bounded to one warn every 30s or less.
A one-line follow-up would bring the two loops into line. On is_database_refusal, skip the sleep arm and wait only on db_changed or cancellation, and log at info. This is not needed for this PR.
Recommendation: APPROVE
661bcf4a meets the coordinator's conditions (1) and (2) exactly. It keeps every non-refusal path identical apart from the log formatting nit. Its race handling around the generation receiver is correct, and its tests are deterministic.
The TS nit commit is a no-op refactor. The rebased round-1 and round-2 commits are unchanged.
Before merge:
- the author's crate-scoped Rust run and
test:changed(condition 3); - the merge gate;
- the real-device smoke run of a refused database before the release.
mstomar125
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review, round 3): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Address review (round 3)The head is now 6a6af77, on main at 33ed106. Round-3 findings
Checks on the final head
Re-review decisionNO RE-REVIEW NEEDED. The only change since the round-3 APPROVE is the log formatting. |
… in place of the workspace (ADR-083 §2) - types/requires-extension.ts: RequiresExtensionCommandError (code REQUIRES_EXTENSION, requiresExtension payload) and its guard, which accepts only a well-formed payload with an https download link. - database store: after routing to a database it is about to select, read it once (list_conflicts, one record) and record the REQUIRES_EXTENSION payload as the selection's refusal, before the selection commits. A listing that marks the selected database requires_extension with no refusal recorded reads it again. A refused activation evicts the previous database's caches and reloads nothing; the next switch or create replaces the refusal. evictAndReloadActiveDatabase splits into evictDatabaseCaches and reloadDatabaseStores. - database-requires-extension.svelte: renders the payload's message, download label and URL verbatim (openUrl), and offers a switch to another registered database or the existing create flow. No contact link, and nothing that moves, renames or resets the file. - app-shell: shows the view in place of the sidebar and panes while the active database is refused, leaving the overlay slot mounted; holds the startup conflicts notice and pauses the indexing-queue poll meanwhile. - Databases settings: a requires_extension row reads "Needs an extension this app doesn't support" instead of "Unknown". Co-Authored-By: Claude Opus 5.5 <[email protected]>
…database refused - A database the listing marks requires_extension is still read before its selection commits (it needs the refusal's text, and writes to it are refused anyway). Any other database commits at once, and checkSelectedDatabase reads it right after, so a switch to a database that opens no longer waits for its open while routing already points at it. The same check runs when a later listing marks the selected database with no refusal recorded, and drops a result for a database no longer selected. - readRefusal warns when a REQUIRES_EXTENSION error carries a payload the guard rejects. - evictDatabaseCaches' comment says what it evicts and that the sidebar stores' lists wait for reloadDatabaseStores. - Tests: a refused activation still fires onDatabaseActivated after eviction, from load() and from switchTo(); a switch to an unmarked database does not wait for its open; refusals found after the commit; the malformed-payload warning; the command-sequence tests follow the read's new place. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…oad warning Co-Authored-By: Claude Opus 5.5 <[email protected]>
… 2s while the active database is refused The token-stream task re-subscribed every 2s after any failure, so while the daemon refused the active database (it requires an extension this build does not support, ADR-083 §2) it asked again forever, logging a warning each time. - resubscribe_forever runs the loop over an active-database generation receiver, taken before each attempt so a change during it is not missed, and an attempt that gets a clone of it. - wait_to_resubscribe: after the refusal (recognised only by nodespace_proto::requires_extension::unsupported_extensions), wait for the active database to switch or the channel to be rebuilt, then resubscribe at once; if the client is gone, fall back to the delay. Every other outcome keeps the 2s retry. - try_subscribe returns the tonic::Status, so the loop can tell the refusal apart. - Tests (paused clock): the loop waits out a refusal and resubscribes once the generation changes, does not miss a change during the refused attempt, and retries any other failure every 2s; the wait decision on its own; the classifier. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…and message, not the whole status Co-Authored-By: Claude Opus 5.5 <[email protected]>
6a6af77 to
27fe9e4
Compare
Closes #3413
Slice S7 of #3413, the last one: the app's refusal view for a database that requires an extension core doesn't support (ADR-081 step 3, ADR-083 §2). It consumes the app-lib contract from S6 (#3426, merged).
Most of the change is TypeScript and Svelte. At the coordinator's request, one small Rust commit makes the app-lib token-stream retry loop stop probing a refused database (see "Token-stream retry loop" below). The branch is rebased onto main at 33ed106.
How the refusal reaches the view
S6's contract: a command routed to a refused database rejects with
CommandError { code: 'REQUIRES_EXTENSION', requiresExtension: { unsupportedExtensions, message, downloadLabel, downloadUrl } }.list_databasesmarks the databaserequires_extension, but carries no text.REQUIRES_EXTENSIONbelonged to, and could mark the wrong one refused.list_conflictswithlimit: 1, the cheapest routed read that goes throughstatus_to_command_error.get_stale_root_countwould not do: it mapsUnimplementedto 0 without touching the database.requires_extensionis read afterset_active_databaseand before the selection commits, under the same switch-sequence guards as the rest ofload()andswitchTo(). The refusal commits with the selection, so the workspace never mounts against it.checkSelectedDatabasethen reads it and records a refusal if one comes back (a listing older than the database file). A switch to a database that opens therefore never waits for its open; that wait would widen the window in which routing points at the new database while the old workspace is still editable.databaseStore.activeRefusalis the payload, keyed to the active id. A check result for a database that is no longer selected is dropped.requires_extension, with no refusal recorded, reads it again. This covers a read that failed for another reason. It is skipped while a switch is in flight.readRefusallogs a warning.onDatabaseActivatedat the same point, so hook timing and the 2.0 API are unchanged.switchTo, which evicts and reloads.Changes to existing behaviour
load()andswitchTo()send one more command,list_conflictswith limit 1:pin_window_databasefor a database the listing does not mark;set_active_databaseandpin_window_databasefor one it marks refused.evictAndReloadActiveDatabasesplits intoevictDatabaseCachesandreloadDatabaseStores. The calls are the same, and each store's invalidation still precedes its load.app-shell-overlayslot stays mounted, so slot mount semantics are unchanged. While the database is refused:requires_extensionrow as "Needs an extension this app doesn't support" instead of "Unknown". The listing has no ids or text, so the row can't name the extension.Token-stream retry loop (Rust,
app-lib/src/commands/local_agent.rs)The loop re-subscribed to the daemon's token stream every 2s after any failure. While the active database is refused, that meant probing forever and logging a warning each time.
nodespace_proto::requires_extension::unsupported_extensionsrecognises as the refusal. The task then waits for the active database to switch, or the shared channel to be rebuilt (subscribe_active_database), and resubscribes at once.resubscribe_foreverruns the loop. It takes the active-database receiver before each attempt, so a change during the attempt is not missed.wait_to_resubscribeholds the wait decision. It falls back to the delay if the client is gone, so it never spins.Acceptance (quoted from the slice) and where each is met
pro, or "This database needs an extension this app doesn't support (‹id›)" otherwise. It shows a "Download NodeSpace Pro" link, a compile-time constant pointing athttps://nodespace.aiuntil a direct link exists, and actions to switch to another registered database or create a new one. No contact link. It never offers to move or modify the file.database-requires-extension.svelterenderspayload.messageas its heading. S6'sextension_namesrenders both sentences.payload.downloadLabeland openspayload.downloadUrlthroughopenUrl. Both come from S6's constants, pinned bythe_download_link_is_pinned.DatabaseNameDialog, thencreateandswitchTo).bun run test:changedpasses, and the merge gate passes. Core's first release can be cut after this lands.test:changedpassed on the frontend and Chromium tiers; Rust, skill and scripts were skipped for a frontend-only diff. The merge gate is the coordinator's.git grep -nP 'NodeSpace Pro|https://nodespace\.ai' -- packages/desktop-app/srcreturns 0. The fixtures use "Fixture App" andhttps://example.test/….src/lib/types/requires-extension.ts. The guard accepts only a well-formed payload: string ids, string message and label, and an https download URL.git diff origin/main --statover the extension API and ui-extensions files is empty.DatabaseInfoandCommandErrorare untouched.Other #3413 items, delivered by earlier slices
mailto:throughopenUrl;collaboration.entryslot, suppressed for a registered contribution;EXTENSION_API_VERSION2.0.required_extensionsfield;FAILED_PRECONDITION, nothing written, the daemon keeps serving);db listmarker, and the tray marker;REQUIRES_EXTENSIONmapping;extension_namesmodule and its download-link pin.SKILL.md,references/cli.md), and the ratchet's one-file allowlist with the hard ban.Tests
tests/components/database-requires-extension.test.tsopenUrlwithpayload.downloadUrldatabaseStore.switchTowith another registered id; neither the refused database nor another listed-refused one is offeredcreate+switchToREQUIRES_EXTENSIONon the first read marks the restored database refused, evicts the boot-time loads and reloads nothingtests/stores/database.test.tsload()'s read wins; a superseded switch's read is discarded; the refusal belongs to its own idload()and fromswitchTo()onDatabaseActivatedonce, after eviction, fromload()and fromswitchTo()REQUIRES_EXTENSIONpayload records no refusal and warnstests/components/app-shell-database-refusal.test.tstests/types/requires-extension.test.tstests/components/settings/database-settings.test.tsRust mutation check. I applied 7 single-point mutations to the token-stream loop. All 7 were killed: the classifier forced true and forced false, resuming only after the delay, no client-gone fallback, every error waiting for a change, the loop ignoring the decision, and the receiver taken after the attempt.
TypeScript mutation check. I applied 45 single-point mutations, one at a time, each run against its test file. All 45 were killed. They covered:
Verify
git grep -nP 'NodeSpace Pro|https://nodespace\.ai' -- packages/desktop-app/src→ 0git grep -nP mailto -- packages/desktop-app/src/lib/components/database-requires-extension.svelte→ 0git diff origin/main --statoverlib/extension-api,plugins/ui-extensions.tsandplugins/ui-extensions.svelte.ts→ emptybun run --cwd packages/desktop-app test src/tests/extension-api→ 46 passed (the snapshot is still 2.0, unchanged)bun run scripts/check-pro-boundary.ts(the hard ban from Remove the multi-user skill guidance and make the Pro-boundary check a hard ban #3420) → passes, every marker 0cargo clippy -p nodespace-app-lib --all-targets -- -D warningsis clean, andcargo fmt --checkis clean.local_agenttests → 7 passedbun run test:changedon the final head (6a6af77) passed: frontend 88 s, scripts 23 s, Chromium 3 s, Rust workspace nextest 50 s.Ratchet
No marker hit anywhere on the branch. It is rebased onto main at 33ed106, which includes #3420's hard ban and #3426's allowlisted display-name module.
Review
db_changedafter the refusal.Still needed before the release
required_extensions: ["pro"], then launch the app. Check:app-shell.svelteanddatabase-settings.sveltewere already not Prettier-clean on main. I left them as they were.DB reset: none for this slice. S6 requires one.
🤖 Generated with Claude Code