Skip to content

feat(db): the Hub's login loses its reach on a company's tables, phase 2 (step 5, U7) - #55

Merged
leandrotcawork merged 75 commits into
mainfrom
feat/conexus-e05-phase2
Oct 17, 2026
Merged

leandrotcawork merged 75 commits into
mainfrom
feat/conexus-e05-phase2

Conversation

@leandrotcawork

@leandrotcawork leandrotcawork commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Step 5, U7: the second phase (D11). Aguarda a palavra do fundador on the grant list, and his confirmation of H, before it merges. It ships after v0.5.0 is checked, as v0.5.1.

  • The migration 20261017051515_runtime_loses_company_reach drops the runtime_transition policies on auth.company, auth.member, auth.invitation and operations.client. It also revokes all of hub_runtime's grants on those four tables. A -- contract: line states D6's contraction.
  • database-grants.sql loses hub_runtime's four table grants. This is the list for the founder's word.
  • The test harness for the second phase (CONEXUS_TEST_PHASE) goes, and so does CI's phase matrix leg. The catalog test's phase-2 skips are gone: "o login do Hub não lê nem grava as tabelas de empresa" now always runs.
  • Decision 0039's Result, one line to stay within its 350 words: PostgreSQL 18.6 locally, B1–B8 pass; on Neon, PostgreSQL 18 with the patch not read, in a new branch database at the direct address, phases 1 and 2, B1–B5 pass. The per-item results and the setup are in feat: two companies isolated by scope and row policy, and the Central deletes a client (step 5) #54's body. The rollback and the sleep are checked after release.
  • One-column lock grants. This PR changes no grant of a scope role: phase 2 only revokes hub_runtime. The narrowing to one column for lock-only UPDATEs is in feat(db): step 5 scope roles and their grants, phase 1 (step 5, U2) #53, which this branch carries through the build.

Proof: the full server suite on this branch passes 269 of 269. catalog.test.ts passes 18 of 18, including the snapshot equality. npm run migrations is ok.

Base: feat/conexus-e05-build (#54), so the diff is U7 alone. It is retargeted once #54 lands.

…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
…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.
… its people stay (step 5, U4)

DELETE /api/clients/{companyId} deletes the client's record, then its company,
members and invitations through the organization adapter, in one transaction.
The plugin's own deletion route is closed. A correction and a deletion now lock
the company before the operator's row, the order the owner's invitation keeps:
the other order deadlocked a deletion or a correction against a renewal.
…step 5, U5)

An alert dialog on the client's page asks for the client's name, sends it with
the revision read, and leaves for the list with a notice on 204 or 404. An
answer that did not settle keeps the dialog. The old design's danger buttons
are built: neutral on the page, full danger at the confirmation (design V55).
A reload during a registration loses the key and redoes nothing (J).
…es one (step 5, U6)

The journey of the card in Chromium against a real Hub: B's address answers
not found to A's owner, the Central deletes B once its name is typed, B's CNPJ
registers again, B's owner still signs in, B's link no longer opens, and A
stays.
…e 2 (step 5, U7)

Drops the transition policies and revokes hub_runtime's grants on
auth.company, auth.member, auth.invitation and operations.client, after
v0.5.0 runs on the scope roles alone. The test harness and the CI leg that
applied this phase ahead of its migration go with it.
developmentconexus-ops and others added 25 commits October 17, 2026 03:48
…ep 5, U5)

Only a reload, which runs no cleanup, keeps the mark; an in-app exit after an
undecided answer no longer sends the next registration to the list.
…tep 5)

After a database error the transaction is aborted and entering the company
scope again fails with 25P02; that error no longer replaces the first one.
…-mail and stamp (step 5, U2)

UPDATE on auth.user for hub_invitation narrows to the columns the password
command writes; a person's role is not writable from the link scope.
…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
…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.
…tep 5, U7)

The second phase's migration is generated again after 20261017110517, which v0.5.0 applies, so the
history no longer branches (drizzle-kit check); its SQL is unchanged. boundaries.md's deletion entry
wraps at 100 columns; library-adapter-joins-transaction also names the phase-2 renewal test, which
now catches it. Decision 0039 holds main's A1 and A2 and the result under its 350 words.
Main's tree is the build branch's at ea81cc9, already merged here.
accept-one-transaction and client-one-transaction take out runWithTransaction, but since
joiningTransaction the plugin's own transaction joins the Hub's through the adapter as well, so
their tests stay green and the rows prove nothing (testing T12). boundaries.md names the tests that
guard both joins.
@leandrotcawork
leandrotcawork changed the base branch from feat/conexus-e05-build to main October 17, 2026 14:28
@leandrotcawork
leandrotcawork merged commit 47df71b into main Oct 17, 2026
13 checks passed
@leandrotcawork
leandrotcawork deleted the feat/conexus-e05-phase2 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