Osy#the first language built for agents
Agents firstAgentic appsWorkflowsDurable Execution — built inSecurityTestingThe editorThe UI modelOne program

Reference / Entity

sealed

sealed entity <Name> { <members> }

Declares that no type may derive from this entity. A type is open unless it says otherwise, exactly as in C#. Sealing says nothing about who may read or write the type.

stable1 example compiled by CIentitymodelinheritance

Summary#

sealed entity Invoice { … } declares that no type may derive from this one. It is C#'s keyword with C#'s default: a type is open unless sealed.

Sealing is a decision a type makes about itself. It has nothing to do with access — a sealed entity's rows are read and written exactly as any other's, governed by its security { } block.

Signature#

sealed entity <Name> { <members> }

Description#

What does sealed do?#

An attempt to derive from a sealed type is a compile error, naming the sealed type:

sealed entity Invoice { [Required] string Number; }
entity CreditNote : Invoice { … }   // ✗ 'Invoice' is `sealed`, so no type may derive from it

Seal a type when its shape and its rules are the whole story and a subtype would only blur them — a ledger entry, an audit row, a settled document. Leave it open when deriving is a use you intend to support.

What sealing is NOT — access control, partial, class#

  • Sealing is not access control. It does not restrict reading or writing; that is the security { } block, and a sealed entity takes one exactly as any other does.
  • Sealing is compatible with partial. partial entity X { security { … } } states more about this type; sealing refuses a new type. C# treats them as orthogonal for the same reason. (sealed on a partial is refused, though — a partial does not declare the type, so it cannot decide what may derive from it.)
  • A class is sealed already, by fact rather than by declaration: nothing can derive from an in-memory value type in Osy#, so writing the word there would say nothing and is refused.

The platform seals its own types#

Every type the platform ships is sealed, with deliberate, reviewed exceptions for the ones you are meant to extend. So if a platform type takes a : Base clause, that is a commitment rather than an oversight.

Examples#

// Nothing derives from a posted ledger entry — its shape and its rules ARE the record.
sealed entity LedgerEntry {
  [Required, MaxLength(40)] string Reference;
  [Required] decimal Amount;
}

// A document, on the other hand, is a shape other kinds of document build on.
entity Document {
  [Required, MaxLength(200)] string Title;
}

entity Contract : Document {
  [Required, MaxLength(80)] string Counterparty;
}

See also#

  • entity Sub : Base — what deriving actually gives you, and what it refuses
  • entity — the entity declaration itself
  • security { } — who may read and write a type, which sealing does not touch

Related

entity Sub : Base

Derives one entity from another. The subtype is its own type with its own name, its own security and its own workflows…

entity

Declares a persisted type — a table of rows the app stores, queries and secures. Every entity gets an Id and audit…

security { }

The rules that decide who may read and write an entity's rows. A where clause filters by the row (the owner sees their…