Repository navigation
fix(v2): one tools entry's grant stops hiding the others (TASK-133) - #1732
Conversation
lilyshen0722
left a comment
There was a problem hiding this comment.
Gate at 3cad7a922b (base fix/task-131-relative-now @ 34bd8911, which is #1728's gated head): passes, nothing blocking.
The one commit on top of #1728 is V2ConnectorTools.tsx plus its test. V2ConnectorTools.test.tsx is 18/18. Each mutation changes one line (git diff --numstat 1+1-):
entryIsGrantedignoringentry(the TASK-133 bug): 2 redentryCoversalways true: 2 redentryForback to github-only: 1 redmoreCountback tocatalog.length - (grantedCount > 0 ? 1 : 0): 1 red- dead grants counted as granting: 3 red
isDead(grant)withoutnowinsideentryIsGranted: green. It's an equivalent mutant: withnowin the memo's deps from #1728, the recompute already runs atnow.
The cross-file claim holds. The comment says the enforcement path refuses any tool the grant does not list. roomGrantService.ts:421-424 reads the grant's own tools and throws tool_not_allowed (403) for anything outside it, so an entry whose tools a grant doesn't name really is ungranted. Keying on tool names is the right join, since installationId names an install, not a catalogue entry.
Stacking note for after #1728. Once #1728 squash-merges, GitHub retargets this PR to main, but the branch still carries #1728's original commits, and the squash commit isn't their ancestor. So the PR's diff will show #1728's files again until this branch is rebased onto main. The content is identical, so the merge would apply cleanly, but please rebase before pressing so the reviewed diff equals the merged one. I'll content-verify the merge either way.
34bd891 to
9ba19c1
Compare
3cad7a9 to
a642e02
Compare
9ba19c1 to
c88f3f9
Compare
a642e02 to
f3609c4
Compare
c88f3f9 to
b9851df
Compare
f3609c4 to
72ffa7b
Compare
b9851df to
39c8951
Compare
72ffa7b to
7b95664
Compare
39c8951 to
38602d6
Compare
7b95664 to
93487a8
Compare
38602d6 to
1d01d4d
Compare
93487a8 to
8305cc3
Compare
The Tools memo assumed the catalogue held exactly one entry. `notYet` never read the entry it was filtering, so a live grant on any entry hid every entry; `moreCount` subtracted exactly one; `entryFor` resolved every grant to github, whatever the catalogue held. Inert today (one `list: 'tools'` entry ships) and wrong the moment a second one does. An entry is now granted when a live grant names one of its tools — the names are the only key both sides carry, since a grant holds an `installationId` (an install) and no catalogue id. That also matches the enforcement path, which refuses any tool a grant does not list, so a grant naming none of an entry's tools no longer reads as granted. The header's "more" derives from the same predicate, and deliberately not from `notYet` itself: that one honours the search box, and the header must not move as you type. Three tests on a two-entry catalogue, each pinned by mutation: the predicate back to the old one → both direction tests red; `moreCount` back to `catalog.length - 1` → the all-granted test red; `entryFor` back to the github stub → the row-labelled test red; dropping the liveness check → three red, including the TASK-131 expiry test.
8305cc3 to
bfd1d06
Compare
lilyshen0722
left a comment
There was a problem hiding this comment.
UX-GATE: PASS @ bfd1d06 — TASK-133. Patch-id 2b234451 verified from origin/main..bfd1d06 (2 files, +82/−3). Logic only: entryCovers/entryIsGranted key an entry to a grant by tool name, so a live grant on one entry leaves the other entries under Not yet, and the header's 'more' is counted on the same predicate as the list. No copy string, className, or CSS changed; labels and descriptions still come from each entry. Gated from the diff, no fixture. Non-blocking note for a follow-up: 'N granted' counts grants and 'N more' counts entries, so two live grants on one entry read as '2 granted · 1 more' — pre-existing, not introduced here.
What
Three call sites in
V2ConnectorTools.tsxassume the tools catalogue holds exactly one entry. All three are wrong the moment a secondlist: 'tools'Installable ships, and one of them — the filed bug — is wrong about which entry a grant covers:notYetfilteredcatalogon!(grants||[]).some(grant => !isDead(grant, now))and never readentry, so one live grant hid every entry from "Not yet".moreCountwascatalog.length - (grantedCount > 0 ? 1 : 0)— with two entries both granted the header still read2 granted · 1 morewhile nothing was left to grant. It also mixed units:grantedCountcounts grants,moreCountcounts entries.entryForresolved any grant to the github entry (catalog.find(e => e.installableId === 'github')), so a grant on a second Installable would render with github's label and tool list.Fix
One predicate, used by all three:
notYetfilters on it;moreCountderives from the same predicate over the unfiltered catalogue (deliberately notnotYet.length, which honours the search box and would make the header move as you type);entryForresolves per grant through the same matcher, keeping the github fallback so a label is never missing.Why tool names and not
installableId:ToolGrantcarriestools: string[]andinstallationId(an install), and noinstallableId— tool names are the only key both sides carry. It also mirrors the enforcer:roomGrantServicerefuses any tool a grant does not list (tools.includes(options.tool)), so a grant naming none of an entry's tools grants nothing on it. That settles the empty-toolsedge by measurement rather than argument — a grant created withtools: []permits nothing (routes/grants.tsrejects only unknown tools, anddraftToolsreturns[]when the chosen mode admits none), and the page now agrees with the enforcer instead of calling the entry granted.Proof
Tests run on a two-entry catalogue fixture (every pre-existing test used one entry, which is why all three bugs were green). Mutation proofs, each run alone:
moreCountback tocatalog.length - (grantedCount > 0 ? 1 : 0)2 granted · 1 morewith nothing leftentryForback to the github stub18/18 in
V2ConnectorTools.test.tsx; eslint 0 errors on both files (the twojsx-filename-extensionwarnings are pre-existing); tsc clean apart from the two pre-existing missing@dicebear/*modules.Not done on purpose: making
grantedCountentry-based to matchmoreCount. It changes today's pixels for anyone holding two grants on one tool — a product call for @ux-lead, not a bug fix.Stacked
This PR is deliberately red on "PR targets main" until #1728 lands.
.github/workflows/pr-base-guard.ymlhas nobranchesfilter for exactly this reason: every other guard is scopedbranches: [main], so a PR based on a feature branch shows a short green rather than a clean one. Measured on this PR: 5 checks here against 14 on #1728 — the version guard, the stale-base guard and all three CodeQL analyze jobs never run. The guard's own remedy is "if the parent must land first, say so on the PR and land it, but do not merge this against an un-CI'd base", which is what this note is. Everything above that reports a gate result was obtained from the 5 checks plus local suites, on a diff that is exactly one commit.Base is
fix/task-131-relative-now(#1728), because this file'snotYetmemo is one of the call sites #1728 edits — the branch carries itsnowthread-through. GitHub retargets this PR tomainautomatically when #1728 merges; the stacked-base guard in.github/workflows/pr-base-freshness.ymlis written for exactly this case.After the parent merges, rebase with
--onto, notgit rebase origin/main. #1728 is two commits (6b2444c8,34bd8911), so a squash-merge produces one commit whosepatch-idmatches neither of them; a plain rebase would replay both ontomainand reintroduce #1728's diff inside this PR — which is the outcome @sprint-review asked to avoid, so that the reviewed diff equals the merged diff.The head then moves off
3cad7a92, the sha that was gated, so the new sha wants re-pinning — the content is unchanged and the diffstat should still be two files (V2ConnectorTools.tsxand its test).Closes TASK-133 (
notYetpredicate never readsentry).Rebased
--onto mainat bfd1d06 (patch-id 2b234451 unchanged); base retargeted to main.