# Container Domain Schema — Layer 2 Domain Entity Type # KNO Schema Version: 0.1.0 # Status: Draft # Last Updated: 2026-10-22 # # A container is an entity whose job is to hold other entities. It carries # identity, a title and provenance of its own, and its substance is the # complete entities under `_contains`. It carries no body: the text of a # held document lives inside that document's own field tree # (document-schema 0.11.0, DOC-BODY-01), never in the container around it. # # Why now. Foundry's email template files declare `type: container` for a # template family and for each of its revisions (#6067 § 2.11; the fixture # `docs/planning/email-templates-execution/fixtures/template-closure.body-node.kno` # lint-kno-file-refs-ignore: a pfi-foundry path, not this repository's # at pfi-foundry commit c98ad854239e62ca059bed84232333855cd59265). The # validator reads its domain types from `specs/*-schema.kno`, so without # this file every such container fails BASIC-005. The owner ruled that the # schema is written and reviewed before those templates ship (#6067 comment # 234889; task #6295). # # THREE-GATE (kno-foundational-principles § 0.6): # - Gate 1 (Distinctness): PASS. A container is not a manifest (`manifest` # describes the files of a packed or unpacked bundle and names ONE # primary entity; a container is itself an entity whose children are # peers), not a document (a document has a body; a container has none), # not a bundle definition (an installable set of Capabilities with a # composition manifest), and not a KAML section (`kno-section` is the # shape of a spec's own prose sections). No existing schema admits an # entity that exists only to group complete entities. # - Gate 2 (Reusability): PASS. Every Foundry template family is one # container holding one container per revision (two tiers in one file); # the same shape fits any grouping of complete entities that moves as a # unit (a release's documents, a review packet, a course's chapters). # - Gate 3 (Clarity): PASS. Without it, grouping is spelled ad hoc # (`type: manifest` on things that are not manifests, or an untyped map) # and the validator cannot say what a held entity's neighbours are. # The schema says one thing: a container holds and never carries. # # WHAT IT DOES NOT DO. It does not validate the entities it holds. A held # document is validated by document-schema, a held container by this # schema again, and the validator slice of #6067 (Phase 3) descends one # level per entity. It does not define Foundry's template semantics: those # live under `extensions.pfi-foundry.email-template` and are Foundry's. # ============================================================================= # SCHEMA DECLARATION (RFC-007) # ============================================================================= $schema: kno@0.0.9 # ============================================================================= # BASIC TIER # ============================================================================= id: 01M5GVCP1MANJR49DKZ47111YD slug: container-schema type: spec version: 0.1.0 # ============================================================================= # STANDARD TIER # ============================================================================= title: "Container Domain Schema" purpose: | Define the `container` entity type: an entity that holds complete entities under `_contains` and carries no body of its own. **The problem.** KAML makes every entity a container (`_contains` is a reserved key on any entity), but nothing names the entity whose only job is to hold. Foundry's email templates need one: a template family holds revisions, and a revision holds the subject, text and HTML documents that travel together. With no schema for `type: container`, the validator rejects every such file (BASIC-005). **The rule.** A container holds and never carries. Its children are complete entities (each with a `type`, and an `id` whenever anything outside the container refers to it). A held document keeps its body in its own tree, as document-schema 0.11.0 requires; the container never supplies, selects or duplicates it. Children are addressed by in-file fragment or, when they carry `id`, by Identity XRI. # ============================================================================= # RICH TIER # ============================================================================= provenance: origin: id: 01M5GVCP1MANJR49DKZ47111YD timestamp: "2026-10-22T03:50:00Z" tool: ai-assisted-authoring issue: "forge#6295" note: | Grounded in Foundry's template files read at their current heads: pfi-foundry worktree feat-416-template-body-nodes, HEAD a4b36edd; the two fixtures under docs/planning/email-templates-execution/fixtures/ last changed at c98ad854 (template-closure.body-node.kno, the target shape; template-closure.candidate.kno, the frozen E-shape the census measured). Composition follows the #6067 council's elected plan (comment 233172) and the owner's rulings (comments 234513, 234871, 234889). The schema is deliberately silent on what a container is for: that is the holder's `purpose` or an extension's business. taxonomy: topics: - containers - composition - domain-schemas keywords: - container - _contains - grouping - revision - template relationships: depends_on: - xri: "kno://specs/kno-spec" reason: "KAML container structure: `_contains`, `_index`, `contains`" composes: - xri: "kno://specs/identity-schema" reason: "Layer 1: id, canonical_id" - xri: "kno://specs/history-schema" reason: "Layer 1: _history" related_to: - xri: "kno://specs/document-schema" reason: "A held document keeps its body inside its own tree (DOC-BODY-01); the container never carries it" - xri: "kno://specs/manifest" reason: "Sibling, not parent: a manifest describes a bundle's files and names one primary entity; a container's children are peers" - xri: "kno://specs/bundle-definition-schema" reason: "Sibling: an installable set of Capabilities with its own composition manifest" quality: completeness: 0.7 last_reviewed: "2026-10-22" review_status: draft reviewed_by: "claude" # ============================================================================= # HISTORY (P9 Temporal — composed from history-schema.kno) # ============================================================================= _history: version: 1 created: "2026-10-22T03:50:00Z" created_by: "claude" modified: "2026-10-22T03:50:00Z" modified_by: "claude" # ============================================================================= # SPECIFICATION CONTENT # ============================================================================= spec: status: Draft changelog: - version: "0.1.0" date: "2026-10-22" changes: - "Initial container domain schema (#6295; #6067 open point 10, the owner's ruling in comment 234889): an entity that holds complete entities under `_contains` and carries no body. Grounded in Foundry's template fixtures at pfi-foundry c98ad854." - "Conformance entries CON-HOLD-01 (holds, never carries), CON-CHILD-01 (children are entities), CON-BODY-01 (a held document's body stays in the document), CON-ADDR-01 (addressing by fragment or Identity XRI) and CON-EXT-01 (namespaced extensions)." description: | ## What a container is A container is the entity you reach for when several complete entities move together and the group itself needs identity, a title and provenance: a template family and its revisions, a release's documents, a review packet. KAML already lets any entity hold children under `_contains`; `type: container` names the entity whose children are its substance. ## What a container holds Every value under `_contains` is a complete entity: a mapping with a `type`, and an `id` whenever anything outside the container refers to it (an in-file fragment from a sibling, an Identity XRI from another file, a `revision_xris` list in an extension). A child may be a document, another container, or any other typed entity; it is validated by its own schema, not by this one. The validator descends one level per entity. ## What a container never does A container holds and never carries. It has no `content`, no `source_xri`, no `source_snapshot` and no `_contains.body`: a container is not a document and must not be read as one. In particular it never supplies a body to a held document. Under document-schema 0.11.0 a document's body lives in exactly one place inside that document's own field tree, the root `content` scalar or a format-typed `_contains.body` node; a document inside a container reads its body there and nowhere else (DOC-BODY-01, DOC-SRC-05). The E-shape Foundry measured before #6067, in which a document named a sibling format node through `source_xri`, is the shape that rule retires. ## Addressing a held entity, and a held document's body | Target | Address | | ------------------------------------------ | --------------------------------------------------------------------------------------------------- | | A child, from inside the same file | the fragment `#` of its `_contains` key, nested as `#/` (`#revision-one/text-document`) | | A child, from another file or an extension | its Identity XRI `pspace:///`, which requires the child to carry `id` | | A held document's body | through the document: `.content` or `._contains.body.content`, never a container path | | A body node shared by a second document | only once promoted to the entity tier (`id` and `version` on the node), as `pspace:///`; the second document captures it with `source_snapshot` (document-schema DOC-SRC-03) | | A sibling container (a previous revision) | its Identity XRI (`pspace://container/`), address only, no version suffix | A part-tier body node (no `id`) is not addressable from outside its document; a pointer at `#//_contains/body` is a finding, not an address. ## Extensions What a container is for belongs to its holder. A holder records that under `extensions.`, where the namespace is reverse-DNS-like and owned by whoever defines the keys (`pfi-foundry.email-template`). An extension never redefines a reserved KAML key and never carries a body for a held document. ## Validation today `scripts/validate-kno.ts` admits `type: container` because this file exists (domain types are discovered from `specs/*-schema.kno`); it checks the KAML tiers and that every `_contains` child is a mapping and SHOULD carry an `id`. The `spec.schema` below is executable: the API's unit test `container-contract.test.ts` compiles it with Ajv (draft-07) and runs Foundry's two fixtures and the schema's own examples against it. Validating held entities against their own schemas is the #6067 validator slice (Phase 3). # =========================================================================== # SCHEMA (draft-07 keywords: the API's Ajv harness runs in that mode) # =========================================================================== schema: type: object required: - id - type - version - title - _contains # A container holds and never carries (CON-HOLD-01). The fourth carrier, # a body node at `_contains.body`, is refused under `_contains` below. not: anyOf: - required: [content] - required: [source_xri] - required: [source_snapshot] properties: # ----------------------------------------------------------------------- # BASIC TIER # ----------------------------------------------------------------------- $schema: type: string description: | Schema declaration. `container@0.1.0` pins this contract; the generic `kno@0.0.9` is accepted for a container that pins nothing beyond KAML. examples: - "container@0.1.0" - "kno@0.0.9" id: type: string pattern: "^[0-9A-HJKMNP-TV-Z]{26}$" description: ULID of this container (immutable birth identity, RFC-013). slug: type: string pattern: "^[a-z0-9][a-z0-9-]*$" description: Human-readable handle; never a reference target. type: const: container description: Always "container" for this schema. version: type: string pattern: "^\\d+\\.\\d+\\.\\d+$" description: | Version of this container entity. Bump it when a child is added, removed or replaced; a child's own edits bump the child. # ----------------------------------------------------------------------- # STANDARD TIER # ----------------------------------------------------------------------- title: type: string minLength: 1 description: What this container is, for a person. description: type: string description: Optional longer description. purpose: type: string description: | Why this container exists, in the holder's words. Free text; the machine-readable role of a container lives in an extension. # ----------------------------------------------------------------------- # RICH TIER # ----------------------------------------------------------------------- provenance: type: object description: Origin of this container (kno-foundational-principles § 0.7, § 0.8). relationships: type: object description: Outbound edges; children are reached by fragment or Identity XRI, not restated here. extensions: type: object description: | Holder-defined semantics, one key per namespace (CON-EXT-01). A namespace is reverse-DNS-like: at least two dotted labels of lowercase letters, digits and hyphens, owned by whoever defines the keys beneath it. propertyNames: pattern: "^[a-z0-9][a-z0-9-]*(\\.[a-z0-9][a-z0-9-]*)+$" additionalProperties: type: object _history: type: object description: History block (history-schema); optional. # ----------------------------------------------------------------------- # CONTAINER TIER # ----------------------------------------------------------------------- _index: type: array description: Navigation hints (kno-spec); optional. items: type: object required: [path] properties: path: type: string line: type: integer minimum: 1 contains: type: array description: The manifest list of what is inside, for discovery without parsing `_contains`; optional. items: type: object required: [xri] properties: xri: type: string role: type: string title: type: string _contains: type: object minProperties: 1 description: | The held entities, one per key (CON-CHILD-01). Each value is a complete entity: a mapping with a `type`, and an `id` whenever anything outside the container refers to it. A held document keeps its body inside its own tree (CON-BODY-01); a held container validates against this schema again. The key `body` is refused here: a body node belongs to a document, never to a container (CON-HOLD-01). not: required: [body] additionalProperties: type: object required: [type] properties: type: type: string minLength: 1 id: type: string version: type: string # =========================================================================== # CONFORMANCE # Levels: MUST | SHOULD | closure (the validator slice resolves entities). # =========================================================================== conformance: - id: CON-HOLD-01 level: MUST rule: >- A container has no `content`, `source_xri` or `source_snapshot`, and no `_contains.body`; it is never read as a document. - id: CON-CHILD-01 level: MUST / SHOULD rule: >- `_contains` is present and holds at least one child; every child is a mapping with a `type` (MUST). A child carries an `id` (SHOULD; MUST when any fragment, Identity XRI or extension list refers to it). - id: CON-BODY-01 level: closure MUST rule: >- A held document's body lives inside that document's own field tree (document-schema DOC-BODY-01); the container never supplies, selects or duplicates it, and no address of the form `#/_contains/body` is a body address. - id: CON-ADDR-01 level: SHOULD (MUST at next MAJOR) rule: >- A child is addressed by the in-file fragment of its `_contains` key or by its Identity XRI `pspace:///`; address only, no `@version` suffix. A sibling container is addressed by Identity XRI. - id: CON-EXT-01 level: MUST rule: >- Every key under `extensions` is a reverse-DNS-like namespace whose value is a mapping; an extension never redefines a reserved KAML key and never carries a body for a held document. # =========================================================================== # EXAMPLES # =========================================================================== examples: - title: "A template family holding one revision of three documents" description: >- The shape of Foundry's email templates (pfi-foundry c98ad854, template-closure.body-node.kno), reduced to one revision. The family container holds a revision container; the revision holds three `document@0.11.0` entities, each with a part-tier body node. The family's own semantics live under its extension. yaml: | $schema: container@0.1.0 id: 01M5GVCP1N6AST6HFJVFCW32KR type: container version: 0.1.0 title: "Brief-ready email template" extensions: pfi-foundry.email-template: selector: namespace: app type: brief-ready locale: en revision_xris: - "#revision-one" _contains: revision-one: $schema: container@0.1.0 id: 01M5GVCP1NE7ZKZACCEBJGPC0F type: container version: 0.1.0 title: "Revision 1" _contains: subject-document: $schema: document@0.11.0 id: 01M5GVCP1N0WYSWJFMV2D9HRZ6 type: document version: 0.1.0 title: "Subject" purpose: template source_format: plaintext _contains: body: type: plaintext content: "Brief for {{name}}" text-document: $schema: document@0.11.0 id: 01M5GVCP1NRSP2ARCCC4EGD9MP type: document version: 0.1.0 title: "Text body" purpose: template source_format: plaintext _contains: body: type: plaintext content: | Hello {{name}}, Your brief is ready: {{action_url}} html-document: $schema: document@0.11.0 id: 01M5JN3Q9RNDRT8S8TFYXMJRJP type: document version: 0.1.0 title: "HTML body" purpose: template source_format: html _contains: body: type: html content:

Hello {{name}},

Read your brief

- title: "A second revision pointing at its predecessor by identity" description: >- A revision container inside the same family as the example above. It has an identity of its own and names revision one (`01M5GVCP1NE7ZKZACCEBJGPC0F`) by Identity XRI, address only (CON-ADDR-01); it never copies the predecessor's documents or reaches into their bodies. Its subject document keeps the identity it had in revision one and bumps its version. yaml: | $schema: container@0.1.0 id: 01M5H0VP79ZKHSP36E5ZCY4R82 type: container version: 0.1.0 title: "Revision 2" extensions: pfi-foundry.email-template: previous_revision_xri: "pspace://container/01M5GVCP1NE7ZKZACCEBJGPC0F" _contains: subject-document: $schema: document@0.11.0 id: 01M5GVCP1N0WYSWJFMV2D9HRZ6 type: document version: 0.1.1 title: "Subject" purpose: template source_format: plaintext _contains: body: type: plaintext content: "Updated brief for {{name}}" # ============================================================================= # CONTAINER TIER — Navigation Index # ============================================================================= _index: - path: "identity" line: 53 keywords: [id, type, version, container] - path: "spec/description" line: 164 keywords: [holds, never-carries, addressing, extensions] - path: "spec/schema" line: 233 keywords: [_contains, extensions, not, additionalProperties] - path: "spec/conformance" line: 387 keywords: [CON-HOLD-01, CON-CHILD-01, CON-BODY-01, CON-ADDR-01, CON-EXT-01] - path: "examples" line: 423 keywords: [template, revision, body-node] contains: - xri: "#identity" role: section title: "Schema Metadata" keywords: [id, type, version] - xri: "#spec" role: section title: "Container Schema" keywords: [holds, children, addressing, conformance] - xri: "#examples" role: section title: "Usage Examples" keywords: [template, revision]