Task: Tenancy, login and tests

Table of Contents

This page documents a task in the Tenancy foundation story. It captures the goal, current status, acceptance, and any notes or results.

Goal

Wire tenancy into login + session creation, and prepare the C++ test infrastructure to set tenant context transparently.

Status

Field Value
State DONE
Parent story Tenancy foundation
Now Completed 2026-02-01.
Waiting on None.
Next None.
Last touched 2026-02-01

Acceptance

  • BEFORE INSERT triggers on iam_login_info_tbl + iam_sessions_tbl populate tenant_id from app.current_tenant_id when not supplied explicitly.
  • ores_iam_validate_tenant_fn uses coalesce(p_tenant_id, ores_iam_current_tenant_id_fn()).
  • ores_test_ddl_user and ores_test_dml_user default app.current_tenant_id to the system tenant in setup_template.sql.
  • C++ database_helper::set_system_tenant_context() callable from test constructors.

Plan

Captured during execution; cleared into the parent story on close.

Notes

The triggers are what make pre-existing C++ code 'just work' under tenancy — it doesn't have to know about tenant_id everywhere.

Result

Tenancy plumbed through login + tests transparently.

Emacs 29.1 (Org mode 9.6.6)