Skip to content

feat: two companies isolated by scope and row policy, and the Central deletes a client (step 5) - #54

Merged
leandrotcawork merged 74 commits into
mainfrom
feat/conexus-e05-build
Oct 17, 2026
Merged

leandrotcawork merged 74 commits into
mainfrom
feat/conexus-e05-build

Conversation

@leandrotcawork

@leandrotcawork leandrotcawork commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Etapa 5, "Duas empresas", from the card approved at f64ebb5 (docs/steps/e05-duas-empresas.md).

Aguarda a palavra do fundador

Two pieces were added by firstmate's provisional A, after the U1 census found two gaps in the card's matrix. Each is its own commit, so either can be swapped for B without unpicking the rest. PR #51 is the record for his word. Nothing here merges before it.

  • A1, 97e4b47. One SECURITY DEFINER function, auth.is_installation_administrator(person). It is owned by the non-login role hub_administrators, has a fixed search_path, and only hub_operator may execute it. Every operator policy uses it. Why: when the operator's administrator check reads auth.user from auth.member's policy, and the operator reads owners in auth.user, each policy expands the other, and PostgreSQL refuses ("infinite recursion detected in policy"). The card's point 4 says a SECURITY DEFINER goes back to the card. Criterion 18 and its removal entry operator-policy-admin-only cover it.
  • A2, 6a7af1f. hub_invitation reads the members of that invitation's company only. Why: the card gave the invitation scope INSERT on members without SELECT. Better Auth's accept counts the members (crud-invites.mjs:276), and step 4.1's link view shows them, so both broke.

The grant lists are in their own PRs: U2 and A1's role and grants in #53 (phase 1), and U7 in #55 (phase 2). Each waits for the founder's word (D11). This PR carries #53's commits, so #53 merges first, and #54 never merges alone.

Also waiting for the founder's word:

  • A register replay after a deletion (review, Opus finding 5). A replay of a registration with its old attempt key, after the client was deleted, finds no row and registers the client again. Holding the key would take new state, and treating the replay as a new registration is a product rule. Unchanged here; it waits for his call in the morning.
  • The card's two-word trim. The card was 4,002 words against its 4,000 ceiling. The smallest trim removes the two words "enquanto isso" from "a construção segue local enquanto isso" (section "O que você faz, e quando"). It is commit a69cda1, made from PR 50's head and merged here. It is pushed as feat/conexus-e05-card-trim, ready to fast-forward PR 50. I did not push it to PR 50's branch, because that branch is checked out in another lane's worktree. The approval check now sees the card differ from f64ebb5 until he confirms the trim.

Criteria and their proofs (L19)

# Proof
1 catalog.test.ts (RLS on, no FORCE; snapshot); isolation.test.ts "sem contexto"
2 isolation.test.ts "positivo"; companies.test.ts
3 isolation.test.ts "filtro esquecido"
4 isolation.test.ts "escrita"
5 isolation.test.ts "conexão reciclada"
6 The 4.1 and 4.2 suites, assertions unchanged; invitations.test.ts "ritmo entre empresas"
7 database.check.ts, compiled by isolation.test.ts "o tipo"
8 client-deletion.test.ts "apagar: fora"; sign-up.test.ts "apagar só pela Central"
9 client-deletion.test.ts "apagar"
10 client-deletion.test.ts "apagar: recusas"
11 client-deletion.test.ts "apagar: concorrência" (6 of 6 local runs green) and "apagar: concorrência com o link" (fails with 500 when the fix is taken out; removal invitation-link-deleted)
12 client-deletion.test.ts "log"
13 delete-client-dialog.test.tsx; T23 in the pinned Chromium (below)
14 register-client-form.test.tsx "recarregar durante um cadastro que não decidiu…": the app itself goes to the list and asks
15 scripts/removals.json: invitation-link-deleted, rls-company-policy, scope-role-set, scope-in-signature, operator-policy-admin-only, client-delete-revision, client-delete-operator-only, each run with --only and caught
16 tests/e2e/two-companies.test.ts, added to npm run e2e
17 The suite under phase 2, as a CI matrix leg from U3 on; the U7 PR (full server suite 269 of 269 on its migration); B1–B5 on a Neon branch of the Hub at its direct address, in phase 1 and phase 2; the rollback to v0.4.2 and the sleep, after release
18 isolation.test.ts "operador sem papel"

T23, done locally on PostgreSQL 18 in Docker with Playwright's Chromium 153. The dialog was checked at 1366, 390 and 320 px in both themes, with a keyboard pass. There is no horizontal scroll at any width, and on phones the dialog sits 16 px from each edge. Focus starts in the field and stays inside the dialog. Enter does nothing until the name is typed. The console was clean, and a trace of the deletion was recorded.

Departures that follow from a card contract (L7)

  1. Lock order (F5). A correction and a deletion now lock the company first, then the operator's row, then the client. This is the order the owner's invitation and its accept already keep. The card's F5 described 4.2's correction as locking the client, then the company. That order deadlocked a deletion against a renewal (40P01), and step 4.2's correction against a renewal the same way. Criterion 11 ("um vence pelo lock") requires the change.
  2. The operator's invitation SELECT. With a company in scope, the operator reads that company's invitations, because a filtered DELETE reads through the SELECT policy.
  3. Row locks need UPDATE. FOR SHARE and FOR NO KEY UPDATE need the UPDATE grant and policy, so each scope that locks a row holds UPDATE on it.
  4. The first person. The first-person command runs through libraryInstallation, with no scope, because nobody is signed in yet.
  5. Phase 2 in tests. From U3 on, a harness and a CI matrix leg applied the second phase, so this release is proved on it (criterion 17). U7 removes both.
  6. Planted failures. invitation-acceptance.test.ts and password-write.test.ts now revoke and grant on hub_invitation instead of hub_runtime, because that role writes now. Their assertions are unchanged.
  7. Test files. The U4 tests are in client-deletion.test.ts, because clients.test.ts would pass Biome's 300 lines. The native-route refusal sits in sign-up.test.ts, next to its twin "empresa só pela Central", because companies.test.ts is at 269 lines.
  8. deleteCompany takes the company lock itself. Removal client-delete-operator-only targets disableOrganizationDeletion, because row policy already hides the client from anyone who is not the operator.
  9. A losing accept. An accept that loses the race to a deletion answers 4.1's 422 INVITATION_CLOSED. The link answers 404, as criterion 11 asks.
  10. The AlertDialog. It is built on the installed Base UI 1.9.0 AlertDialog, in the sheet's dress. It was not fetched from shadcn's registry, because no outside call was authorized.
  11. The list's notice. It rides on a notice search parameter of the list route. That route file is outside U5's declared radius.
  12. V55. The old design's button-danger and button-danger-confirm are built as button variants and listed as built in components.md.
  13. Decision 0039 rides in this PR. U1 asked for its record to enter main in a PR of its own (docs: propose decision 0039, company scope and row policy (step 5, U1) #51) before the proof code. docs: propose decision 0039, company scope and row policy (step 5, U1) #51 is open, and its commit is merged here.
  14. feat(db): step 5 scope roles and their grants, phase 1 (step 5, U2) #53's lines are inside this PR. The scope roles' migration, A1's migration and database-grants.sql are here as well as in feat(db): step 5 scope roles and their grants, phase 1 (step 5, U2) #53. The merge order is feat(db): step 5 scope roles and their grants, phase 1 (step 5, U2) #53, then feat: two companies isolated by scope and row policy, and the Central deletes a client (step 5) #54.
  15. The lock order changes 4.2's correct() (departure 1). The card's F5 says the build stops if a fit fails. This is a fix to a real deadlock, not a new rule. The same defect is in feat: the Operations Central registers a client, and its administrator joins as first owner (step 4.2) #52; firstmate routes the fix there.
  16. Lock-only grants are one column (review): created_at or updated_at, which no command writes. isolation.test.ts "positivo" now writes the company's invitation instead of the company row, which a company's routes only lock.
  17. The roadmap trim. The approval line took docs/roadmap.md to 1,510 words. Prose was trimmed in sections 2 and 3, with no decision or approval line touched; it is now at 1,497.
  18. Decision 0039 within 350 words. The Decision is shorter, the State names A1 and A2 as provisional until docs: propose decision 0039, company scope and row policy (step 5, U1) #51, and the Result in feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) #55 is one line. The per-item results and the Neon setup are in this body.
  19. J delivered as the founder said it. A sessionStorage mark is set before a registration is sent. A reload that finds it goes to the current list with "O último cadastro ficou sem resposta. O cliente está nesta lista?". The list's notice then leaves the address, so a reload or a copied link does not repeat it.
  20. Dialog accessibility. Base UI's modal marks the page behind aria-hidden (FloatingFocusManager, markOthers). The dialog's test now checks that the page's buttons are hidden while it is open. The extra Tab stop that reaches body comes from Base UI's focus guards and is left as is.
  21. deleteCompanyOn has no check afterwards. The adapter returns no row count, and a read through the same row policy as the DELETE could never fire (C50).
  22. installationRead. The status page reads its starts in a read-only, repeatable-read transaction again. Narrowing the unscoped doors by type, with a dependency-cruiser fence, is issue Step 5: type the unscoped database doors narrowly and fence their callers #59.

Closing list

  • The Neon run (B9). Done under firstmate's 002 and 004. A fresh branch e05-proof of the Hub's project was created, with a new empty database. The owner's password was reset on that branch only. The run used the direct address, which docs/how-to/hub-server.md names as the Hub runtime's kind. isolation.test.ts passed 7 of 7, and the catalog's RLS checks passed, in phase 1 and in phase 2. Then the branch was deleted. The run read no company row, and no credential reached the repository. The 0039 Result, in the U7 PR, records it.
  • After the merge. Check that v0.5.0 rolls back to v0.4.2 and that the database still sleeps. Then ship U7 as v0.5.1, once the founder has confirmed H.
  • Changed code. About 940 lines without tests or generated files, against the card's 3,150. The budget script cannot count while two cards are in docs/steps.
  • CI's docs check stays red only for second-card (L5), until the 4.2 card leaves docs/steps. The roadmap is at 1,497 words and the card at 4,000 with the trim.
  • The Neon run in detail.
    • Setup: PostgreSQL 18 on Neon (the patch was not read); 18.6 locally. A fresh branch e05-proof of the Hub's project, a new empty database e05_proof owned by hub_owner, migrated from zero by the suites, at the direct address.
    • Phase 1 (v0.5.0): B1 (RLS on, no FORCE; "sem contexto"), B2 ("positivo"), B3 ("filtro esquecido"), B4 ("escrita") and B5 ("conexão reciclada") pass, with criterion 18 ("operador sem papel") and "o tipo". That is 7 of 7, plus 1 of 1 catalog check.
    • Phase 2 (feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) #55): the same 7 of 7, plus 2 of 2 catalog checks, including the runtime login's 42501 on the four tables.
  • Issues opened for the review's future items: Step 5: a company scope's policies do not require the person to be a member #56, Step 5: no row policy on auth.session, auth.account and auth.verification #57, Step 5: evaluate the operator's administrator check once per statement #58 and Step 5: type the unscoped database doors narrowly and fence their callers #59.
  • The PR's base. The task spec says main, and the Definition of done says feat/conexus-e042-build. This PR targets feat/conexus-e042-build, so the diff is step 5 alone.
  • Approval line. Added to docs/roadmap.md.

The review's push (006)

Head 027a229. Proof for this push:

  • Server suite: phase 1, 267 of 270, with two tests that timed out under load and pass alone (boot.test.ts "mudada", main.test.ts "log por pedido"); phase 2, 269 of 270, one skipped by phase.
  • Web: 127 of 128, with correct-client-form "200" timing out under load and passing alone twice.
  • Checks: lint, typecheck, deps, suppressions and migrations are ok; the docs check shows only second-card.

The delta check's push (007)

  • J's mark. It is cleared when the form unmounts, so leaving it inside the app after an undecided answer no longer sends the next "Cadastrar cliente" to the list. A reload runs no cleanup and keeps the mark. New test: "sair do formulário pelo app…", which fails without the cleanup.
  • feat(db): step 5 scope roles and their grants, phase 1 (step 5, U2) #53. hub_invitation's UPDATE on auth."user" is narrowed to name, email_verified and updated_at, what the password command writes. A person's role cannot be written from the link scope. The invitation suites pass, 60 of 61 with one skipped by phase.
  • asPerson. After a database error inside the work, the transaction is aborted and re-entering the company scope fails with 25P02. The work's failure is now the one that rises. New test: "asPerson: a falha da consulta é a que sobe…", which fails with the old finally. The function moved out of openDatabase to stay under the 60-line limit.
  • 0039's Result (feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) #55) points to this body's per-item list. It says the Neon patch version is read at the next authorized Neon call, at U7's release.

For the founder's review of the screen texts

  • J2. After a reload during an undecided registration, the list says "O último cadastro ficou sem resposta. O cliente está nesta lista?" with no action beside it. The question asks him to look; the founder decides whether that is enough, or whether he wants an action, such as "Cadastrar de novo".

…ients through identity's ports (step 4.2, U3)
…rrection, behind the operator's menu link (step 4.2, U4)
…ration deletes the test companies (step 4.2, U5)
…t, and native joins no longer protect a reachable path
…perator policies need the administrator, closed scope switch, no session clearing, CNPJ as consequence)
…reads nothing, auth.user predicate on its own row, no session exception)
…s bound each scope's role (step 5, U3)

The operator's policies and the invitation scope's read of members come in the next two commits,
each provisional until the founder's word; the Central's and the link's tests turn green with them.
…through one SECURITY DEFINER helper (step 5, U3, provisional A)

Firstmate's provisional choice A of 2026-10-17, waiting for the founder's word: the helper is
owned by hub_administrators, a role that cannot log in and reads only administrators' rows, and
only hub_operator executes it. Without it the operator's policies on auth.member and auth.user
expand each other, which PostgreSQL refuses. Swapping it for option B replaces this commit.
…company (step 5, U3, provisional A)

Firstmate's provisional choice A of 2026-10-17, waiting for the founder's word: Better Auth's accept
counts the company's members for its limit and reads back the member it inserts, and step 4.1's link
view reads whether the person joined and whether the company has a member yet. Swapping it for
option B replaces this commit.
@leandrotcawork

Copy link
Copy Markdown
Collaborator Author

Reviewer: Claude Sonnet 5.5 (claude-sonnet-5-5) (delta 027a229..3d2d1cd)

Conferência 2 de no máximo 3.

Rules read: .agents/skills/conexus-review/SKILL.md (step 9, the delta check) at main 7364445, and the first delta check's report (Opus, 027a229). Reviewed: 3d2d1cdea3cf9a20a8c135622686b33399fc29f1 (git fetch origin pull/54/head, sha confirmed). I also reviewed #53 at 6023cc7 (delta from 0f62e7e) and #55 at 475a26f (delta from 45686f1). I read every changed line of git diff 027a229 3d2d1cd (7 files; snapshot.json is unchanged) and of both PR deltas. PR 53's delta is the same two grant files as PR 54's. PR 55's delta is PR 54's plus the 0039 Result.

Ran

  • Grant probe. My own postgres:18 container (same digest as CI, --rm, now stopped), migrated by createTestDatabase. I read has_column_privilege(role, table, column, 'UPDATE') for every hub_* role. information_schema.column_privileges shows only the current user's grants here, so it listed hub_runtime alone. hub_invitation on auth.user is now email_verified, name, updated_at; role is not writable. The other scope roles are as in delta 1: hub_company has company/member created_at and user/session updated_at; hub_operator has user updated_at. A scratch file did this and is deleted.
  • J, web. vitest run src/hub/operations/: 4 files, 35 of 35 passed. I took the cleanup out (return () => void inFlight(false)): the new test "sair do formulário pelo app…" fails (1 failed, 10 passed). The test can fail.
  • asPerson. database.test.ts and catalog.test.ts, isolation.test.ts: 36 passed, 0 failed, 1 skipped (the phase-2 opt-in). I put the old try/finally back: "asPerson: a falha da consulta é a que sobe…" fails (11 passed, 1 failed). The test can fail.
  • Invitation, password, deletion, sign-up, companies suites. 12 files, 65 of 65 passed. This covers the narrowed hub_invitation grant through the real accept and password flows.
  • Lint. biome check on apps/server/src/platform and apps/web/src/hub/operations: clean.
  • Docs. check-docs.ts shows only second-card. 0039 is 327 words (350 limit).
  • Read, not run. CI at 3d2d1cd: the run is queued on the self-hosted runner (the earlier one was cancelled). I did not run Chromium; no screen changed in this push.

The first delta check's findings

  1. J's marker outlives the registration (Bloqueia): fixed. register-client-form.tsx:49-56 returns a cleanup that clears the mark, so an in-app exit clears it and a reload (no cleanup) keeps it. The new test follows the in-app path and the removal above fails it. The reload test now restores sessionStorage after cleanup() (register-client-form.test.tsx:158-161), so it keeps modelling a reload. I found no new defect: the effect's first branch still clears the mark before navigating; the cleanup sets it false again, which is harmless.
  2. hub_invitation UPDATE on auth."user" (Fechamento): fixed. UPDATE (name, email_verified, updated_at) in the migration and three database-grants.sql lines; the probe confirms it, and the accept and password suites pass. auth.session stays table-wide for UPDATE (the delta-1 note said "possibly"; not required).
  3. asPerson finally replaces the failure (Fechamento): fixed. asPersonIn (database.ts:161-184) re-enters in a catch that swallows its own failure, then rethrows the work's error. On success, a failed re-entry still throws. The new test checks both the 22012 failure and that a non-database failure leaves the scope back at hub_company. The move out of openDatabase is a plain extraction.
  4. 0039 Result pointer (Fechamento): fixed in feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) #55. The Result there points to this PR's per-item list and no longer says "unread". The wording "patch read at U7's release" records a future read as if done; say the patch number once it is read. The State is shortened in this PR (327 words).
  5. J2 on the founder's text list: fixed. The PR body has "For the founder's review of the screen texts", with J2 and the option "Cadastrar de novo".

Findings

  1. Fechamento. asPersonIn has no blank line before export function openDatabase (database.ts:183-184). Biome accepts it; add the line.
  2. Fechamento. The J cleanup also clears the mark when the operator leaves the form in the app while the POST is still in flight; a later reload then asks nothing about that send. The mark is for a page that dies mid-send, and the in-app exit leaves the page alive, so this is the cost of finding 1's fix, not a regression. Say so in the next card's J text or leave it.
  3. Issue futura. hub_invitation keeps table-wide INSERT on auth."user", so a forgotten column list there could still insert a role. Only code that sets a role can do it, and the same class sits in Step 5: type the unscoped database doors narrowly and fence their callers #59 (unscoped doors); a column list on INSERT can follow with it.

Verdict

approve: the Bloqueia of delta 1 (J's marker) is fixed with a test that fails without the fix, the other four items are fixed or properly pointed, and the fixes created no Bloqueia. The founder keeps the merge and his words on #51, #53 and #55; CI at 3d2d1cd was still queued.

…ntence; the rename keeps its own company lock

The registration opens the client with the bounced invitation's id, and the note shows only while
that invitation is the client's live one, so a cancel or a new invitation removes it. Its words are
4.1's for a refused address. renameCompanyOn locks the company again, a no-op after the
correction's lock that keeps the port safe alone; the removal row now checks the lock order by the
renewal race.
…at/conexus-e05-build

# Conflicts:
#	apps/server/src/hub/operations/clients.ts
#	apps/server/src/hub/operations/routes.ts
#	scripts/removals.json
…exus-e042-build) into feat/conexus-e05-build
@leandrotcawork
leandrotcawork changed the base branch from feat/conexus-e042-build to main October 17, 2026 09:40
…tep 5, U3)

operator_all on auth.company splits: the Central still reads and creates any
company, but UPDATE and DELETE hold only for the scope's company, as on
members, invitations and clients. An unfiltered change in A's scope leaves B
and an empty C.
…s company scope (step 5)

accept-one-transaction and client-one-transaction name libraryCommandOn's
line, which libraryInstallationOn now repeats. membership-page-anchor-scoped
survived because the person scope's member policy holds the same rule; its
row becomes person-member-policy, caught by isolation 'positivo'. New row
operator-company-scope.
deleteCompanyOn's comment cites the plugin's closed endpoint (crud-org.mjs:255) and its
membership refusal (:264-268), and no longer C50; boundaries.md says no check follows the
deletion, as the code does. deleteClient's body takes the company name schema and a shared
Revision, so an empty or over-long name is malformed. The delete dialog invalidates the list
by a key derived from the operation (web W11).
A member's invitation, renewal and cancellation now go through the plugin's endpoints, still in
the company's scope; the mail after them keeps the sender's scope and takes main's delivered or
refused outcome; the owner's mail keeps the operator's scope. Both sides' removal rows stay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since step 4.2's closing a member renews through the plugin's endpoint with resend, whose
expiry write uses ctx.context.adapter (crud-invites.mjs:135-143) instead of getCurrentAdapter,
so it left the company scope's transaction for the Hub's login, and failed in phase 2. The
adapter createAuth gives the library now reaches getCurrentAdapter on every call. New test:
a refusal after the plugin's write takes the new expiry back; removal
library-adapter-joins-transaction.
…#51) into feat/conexus-e05-build

The card, roadmap and decision 0039 take main's approved text.
…conexus-e05-build

Its tree is already main's; the merge makes the approved card commit 3fa4793 an ancestor for the
approval check.
@leandrotcawork

Copy link
Copy Markdown
Collaborator Author

Reviewer: Claude Opus 5.5 (claude-opus-5-5) (delta 3d2d1cd..aac9842)

Conferência 3 de no máximo 3.

Rules read: AGENTS.md and .agents/skills/conexus-review/SKILL.md (step 9, the delta check) at main 22f82e9; the second delta check's report (3d2d1cd); and the native audit of step 5, read in full. Reviewed: aac9842758610e2fd4805ad246ff72348adfb75f (git fetch origin pull/54/head; the head has not moved). I read every changed line of the PR's own commits (50abecc, cdc07e4, 14838f0, 1c27cf2, aac9842). For the merges I used git show --remerge-diff. Besides #75 (f1f5f50), the range also has da92084 (delta 2's blank line), 4dc5780 and 6fd56ea, which merged step 4.2 (#52). Their conflict resolutions only keep this step's scope argument, checkPace(deps.database, …) and admitted on 4.2's code. I found no new logic in them.

Ran

My own postgres:18 (CI's digest, --rm, stopped with docker stop), set up like .github/actions/test-database (superuser postgres, non-superuser conexus_owner).

  • Server, phase 1 and phase 2. src/hub/identity/*.test.ts, src/platform/isolation.test.ts and src/hub/operations/*.test.ts with CONEXUS_TEST_PHASE=1: 134 of 134 passed. With =2: 134 of 134 passed.
  • Removals.
    • node scripts/removals.ts --only library-adapter-joins-transaction: caught.
    • --only operator-company-scope: caught.
    • The first row again with CONEXUS_TEST_PHASE=2: survived. This is expected, because in phase 2 the raw write is refused anyway (finding 2).
  • Phase-2 claim in boundaries.md. I took the wrapper out by hand: "renovar: o administrador renovando o convite de um dono" fails with 42501 from drizzle-adapter … withReturning, as boundaries.md says. I reverted the edit.
  • UPDATE half of item 1. I dropped and id = … from operator_update by hand: "operador sem papel" fails. I reverted the edit.
  • Web. vitest run src/hub: 11 files, 105 of 105 passed. biome check .: clean. check-docs: 71 documents ok.
  • Read, not run. CI at aac9842: check is red on "Approval of the step card" only. That is expected until docs: card of step 5, Duas empresas #50 lands on main, and it is not a code finding. The other jobs were pending at review time.

Item 5, joiningTransaction (apps/server/src/hub/identity/auth.ts:154-177)

  • It is the library's own mechanism. getCurrentAdapter(fallback) is exported from @better-auth/core/context 1.7.8 (dist/context/transaction.mjs:22-28) and returns als.getStore()?.adapter || fallback. The internal adapter calls it 17 times. The organization adapter calls it on every method (plugins/organization/adapter.mjs:126-794). The wrapper only gives the plain adapter the same lookup.
  • Nothing changes outside a transaction. With no store, the lookup returns target. Inside the store that auth/base.mjs:51 opens with runWithAdapter(ctx.adapter), the store's adapter is the proxy itself (ctx.adapter is options.database(options), db/adapter-base.mjs:14, context/create-context.mjs:195). The found === joining ? target : found line sends that case to target as well. So getSession stays on the pool, as hub_runtime, the same as before, and the session suite passed in both phases. Every function the adapter factory returns is already async (core/dist/db/adapter/factory.mjs:420-835), so the proxy's async wrapper changes no signature. transaction itself also passes through, and createAsIsTransaction closes over the raw adapter.
  • Other raw-adapter paths. In 1.7.8, ctx.context.adapter.<method> appears in crud-invites.mjs:109,138, crud-members.mjs:294,314,421, has-permission.mjs:10, crud-access-control.mjs and api/middlewares/authorization.mjs. Of the plugin endpoints the Hub calls (createInvitation, cancelInvitation, acceptInvitation, createUser, password reset, sign-in and sign-out), the only one that reaches a raw call is the resend write at crud-invites.mjs:138. The :109 read needs dynamicAccessControl, which is off. The Hub does not call updateMemberRole or leaveOrganization. The wrapper now covers all of them.
  • Size and nativeness. The wrapper is 23 lines, with one removal row and a test that rolls the plugin's expiry back through a trigger. I see no smaller piece: the alternative is to write the expiry in the Hub, which is parallel logic. Upstream should use getCurrentAdapter in the resend branch, and then the wrapper can go (finding 3).

Items 1 to 4

  1. Operator scope on auth.company: fixed. operator_all becomes select and insert for any company, and update and delete for id = conexus.company_id only (identity/tables.ts:198-202, migration …110517). It is generated by pgPolicy, with no hand-written SQL beyond the header. The test (isolation.test.ts:257-271) issues an unfiltered UPDATE and delete … where id <> A in A's scope, and B and an empty C stay. The removal row is caught.
  2. The four Fechamento of the audit: fixed.
  3. asyncUtilTimeout: 5000: fine. It uses Testing Library's own configure (apps/web/vitest.setup.ts:5). testTimeout: 10_000 is unchanged in vitest.config.ts.
  4. Merge of main (fix: members invite through the plugin's endpoints again, the operator alone through its adapter; close step 4.2 #75, ci: no setup-node npm cache on the self-hosted runners #77): separated above. The resolution routes a member's renewal through the plugin's resend. That is what opened item 5's escape, so aac9842 is the direct follow-up. I found nothing else.

Findings

  1. Fechamento. docs/reference/boundaries.md:161 is a 158-character line that 14838f0 left mid-paragraph. The lines around it wrap at 100. Rewrap it.
  2. Issue futura. library-adapter-joins-transaction is caught only in phase 1. Once phase 2 ships (feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) #55), its test survives the removal, and only "renovar: o administrador renovando o convite de um dono" guards the wrapper, through 42501. When PR 55 lands, add that test to the row, or add a phase-2 row.
  3. Issue futura. Report the resend branch upstream (crud-invites.mjs:138 writes through ctx.context.adapter, not getCurrentAdapter). Once the library joins the transaction itself, the removal row will show that joiningTransaction can be deleted.
  4. Issue futura. operator-company-scope takes out only the DELETE scope. The UPDATE scope is caught by the same test (I ran it by hand), but it has no row of its own.

Verdict

approve: items 1 to 5 are fixed or sound. Item 5 is the library's own getCurrentAdapter, it changes nothing on the pool, and it is proven by its removal. Both phases pass, and the fixes created no Bloqueia. Firstmate merges on green CI once the card check clears with #50.

@leandrotcawork
leandrotcawork merged commit d92ad2a into main Oct 17, 2026
leandrotcawork pushed a commit that referenced this pull request Oct 17, 2026
Main's tree is the build branch's at ea81cc9, already merged here.
@leandrotcawork
leandrotcawork deleted the feat/conexus-e05-build branch November 12, 2026 20:38
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