Skip to content

feat(db): operations.client table and the Hub login's grants on it (step 4.2, U2) - #48

Merged
leandrotcawork merged 5 commits into
mainfrom
feat/conexus-e042-grants
Oct 17, 2026
Merged

leandrotcawork merged 5 commits into
mainfrom
feat/conexus-e042-grants

Conversation

@leandrotcawork

@leandrotcawork leandrotcawork commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Adds Conexus's client record, the table operations.client, and the grants the founder approved for it, in a pull request of its own before the step's code (data D11). Card: docs/steps/e042-cadastro-de-cliente.md, U2.

What changes

  • apps/server/src/hub/operations/tables.ts: schema operations (data D4), table client: company_id text PRIMARY KEY with no foreign key to identity (data D17); cnpj text NOT NULL, unique as client_cnpj_key, CHECK (cnpj ~ '^[0-9A-Z]{12}[0-9]{2}$'); legal_name text NOT NULL, 1 to 150 characters by CHECK; revision integer NOT NULL DEFAULT 0 CHECK (revision >= 0); attempt_key text NOT NULL, unique as client_attempt_key_key; registered_at timestamptz NOT NULL. The two unique constraints are named so the registration maps the 23505 by constraint name (code C52).
  • apps/server/migrations/20261017010336_operations_client: generated by drizzle-kit 1.0.0-rc.4; only adds (data D6).
  • apps/server/migrations/20261017010337_operations_grants: custom SQL. USAGE on schema operations, SELECT, INSERT, UPDATE on operations.client for hub_runtime, no DELETE.
  • apps/server/database-grants.sql: the snapshot gains the schema and table owners and the two grants.
  • apps/server/src/platform/catalog.test.ts: the Hub login receives 42501 on DELETE from operations.client.

The founder's word

Card page, "A decisão sua pedida nesta etapa": "Aprovo" (option A: hub_runtime reads, inserts and updates, never deletes), 2026-10-16. The card was approved at 819b1157ca1edc62fb83a5f31d07faa391e32716.

The roadmap's approval line

check-approval refused every tip since the card merged: docs/roadmap.md had no line for step 4.2. This PR adds Cartão da etapa 4.2 aprovado em 2026-10-16 (commit 819b1157ca1edc62fb83a5f31d07faa391e32716): "Aprovo". The line puts the roadmap over its 1,500-word ceiling, so three lines of closed steps lose words. No founder answer, approval or use line changes:

  • Etapa 1: "Publica uma mudança no Hub e volta atrás." Removed: uma mudança no Hub.
  • Etapa 3: "Entra com e-mail e senha, e sai." Removed: com e-mail e senha,.
  • Etapa 4.1: "Cria a senha no convite, e cancela ou recusa um." Removed: e.

Declared departure: a test-only fix in session.test.ts

CI's removals (1) shard reported broken-baseline session-total-lifetime twice: the test "prazo total: usada a cada 25 min…" failed with the protection in place. Cause: elapse added each step's span to the session's timestamps, so the session's age was the virtual 8 h minus 1 s plus every real second since sign-in. As the first test of a cold shard, it spent more than 1 s and crossed the boundary at "8 h menos 1 s" (reproduced locally with a 1.5 s pause after sign-in: actual: 'SIGNED_OUT'). ageTo now sets the age from the database clock right before each read, so setup time never counts. The steps, limits and assertions stay the same; with the pause the test passes, and both session-total-lifetime and session-total-at-read are still caught.

Declared departure: a test-only fix in database.test.ts

The next CI run failed server (4) on "uma leitura parada além do prazo" with Missing expected rejection after 112 ms. Cause: the test fired the holder of advisory lock 777 without waiting for it, so a fast runner let the read take 777 first, and the read never stalled. The read now starts once pg_locks shows 777 granted to the holder (5 s guard). The read deadline, the 15 s check and every assertion are unchanged; read-deadline-is-the-database is still caught.

Proof

  • catalog.test.ts and migrate.test.ts on a local PostgreSQL 18 shaped like CI: 25 of 25 pass, including the snapshot equality and the new 42501.
  • npm run migrations -- --base origin/main: ok. biome check ., knip, deps, server typecheck, docs: clean.

No new dependency. No code reads the table yet; U3 on the step branch does.

@leandrotcawork
leandrotcawork merged commit 7364445 into main Oct 17, 2026
24 of 26 checks passed
@leandrotcawork
leandrotcawork deleted the feat/conexus-e042-grants 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