Changelog - 2026-11-04
A model can be scoped through its parent with access.through
New Feature Breaking ChangeIn one line. settings.access: { through: ScopeThrough.of({ entity, relation }) } scopes a child model by its parent's own access, so a child with only a foreign key needs no copied tenant column. A create or a move must name a parent the caller may reach; update and delete select only the rows the parent's scope allows.
What changed
ScopeThrough.of({ entity, relation }). It returns the value ofaccess.throughand checksrelationagainst the entity: a misspelled name, a to-many relation or a name held in a plainstringdoes not compile.ScopeThroughis a class with a private constructor, so a hand-written{ relation: 'x' }does not compile either. It is exported by@venizia/ignis-kerneland@venizia/ignis, with theTOneRelationNameOftype.- How a read is scoped. The child keeps the rows whose foreign key is in the set the parent's own scope allows, built with the
inSqloperator. The parent'sresolvereceives the sameoperation.UNRESTRICTEDandnullcome from the parent: a parent that resolves no scope denies the child, and athroughmodel has noonMissing. Several hops chain, up to 5. A row with a null foreign key is invisible under a restricting scope, and visible underUNRESTRICTED. - Checks at boot. The relation exists and is a
onewith a single-column key, the parent has anaccess, there is no cycle and no chain longer than 5, the model declares noonMissing,columnsorwrite, and it declares exactly one ofresolveandthrough. A foreign key with no index is a warning. - Writes name a parent the caller may reach. One query checks the parent keys of a create, or of an update that changes the foreign key, against the parent's scope for the write's
operation. A missing parent, a parent outside the scope, a null key and an absent key give the same 403, so a foreign parent's existence does not leak. The check and the write share one transaction (the caller's, or one the repository opens); on Postgres the parents are readFOR SHARE.IRelationalQueryExecutorhas a newsupportsRowLockflag:truefor Postgres,falsefor SQLite. TModelAccessSettingsis a resolver (IModelAccessSettings) or a through (IModelAccessThroughSettings), never both.columnsandwritestay with the resolver.
Who is affected
- Models with
resolve. No action needed. - Code that reads
settings.accessfrom model metadata and calls.resolveon it. See Breaking changes. - Apps that copy a tenant column onto child tables to scope them. They can drop the copy and the service check; the guide shows the measured cost of each.
- Code that implements
IRelationalQueryExecutor. Addreadonly supportsRowLock: boolean. - Code that implements
IRelationalQueryDialectwithout extending the engine's filter builder. AddresolveThrough,toParentWhereandresolveAccessScope.PostgresQueryDialectandSqliteQueryDialecthave them. - A repository subclass that overrides or calls
guardScopedWrite. It isasyncnow: it returns aPromiseof the rows and takes an optionaltransaction.awaitit. - Apps with a
throughmodel. A create, an update, a soft delete or a restore that is given no transaction opens one: an extra transaction per write, and on SQLite it takes the write lock. It opens even when an update does not change the foreign key, although no parent is checked then. - A model whose
accessdeclares both or neither ofresolveandthrough. The application no longer starts. The types already refuse both cases; this reaches only a model cast past them.
Breaking changes
WARNING
IModelSettings.access and getAccessSettings() are TModelAccessSettings now, a union. Code that takes access from the metadata and calls access.resolve(...) no longer compiles.
Before:
const scope = metadata.settings.access.resolve({ operation: 'read' });After:
const { access } = metadata.settings;
if (access && !access.through) {
const scope = access.resolve({ operation: 'read' });
}A model's own settings.access: { resolve } is unchanged, and so is IModelAccessSettings.
Details
The model settings guide has the full example, the SQL, and the measured cost of through against a copied column.