yuqi1129 commented on code in PR #15067: URL: https://github.com/apache/gravitino/pull/15067#discussion_r4639166635
########## design-docs/gravitino-kb-article-design.md: ########## @@ -0,0 +1,1055 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Design: Knowledge Base Articles + +## Background + +Gravitino manages data assets and their metadata. A [Glossary Term](glossary-design.md) gives a +short definition of a business concept. Teams also need longer explanations: how revenue is +calculated, why it differs from GMV, and which tables feed it. Today these explanations live in +wikis and documents, apart from the terms and data they describe. Users and agents cannot find +them through the same metadata APIs or follow managed links from an explanation to its data. + +A Knowledge Base (KB) Article is a text document managed under a metalake. It has a title, a +Markdown or HTML body, an owner and a status. It can belong to several +[Domains](domain-design.md) and link to terms and data assets across catalogs. Users and agents +can search for an article, read it, and follow its bindings under their existing privileges. + +--- + +## Goals + +1. **Article object**: add `KnowledgeBaseArticle` as metalake-scoped metadata with an immutable + name and stable numeric ID. A title can change without breaking references to the article. +2. **Content and version storage**: store Markdown or HTML. Keep an internal snapshot of the + title, body, Domains and bindings for each effective content change, and expose the current + content only. Historical version reads are deferred. +3. **Bindings**: link an article to terms and metadata objects. Support reverse lookup from + either target. A binding never grants access to data. +4. **Domains**: organize and filter articles by zero or more Domains. Membership does not change + article privileges in this design. +5. **Status and privileges**: support `DRAFT`, `APPROVED` and `DEPRECATED`, with immediate edits + and definition privileges granted on the metalake. `APPROVED` means available to agents; + it does not record a reviewer's decision. +6. **Discovery**: search titles, synonyms and bodies, with Domain, status and owner filters. + Read-only MCP tools return readable `APPROVED` articles. +7. **APIs and governance**: provide REST, Java and Python APIs, ownership, events and audit. + Concurrent writes must not leave content, snapshots and effective relations out of sync. + +--- + +## Non-Goals + +1. **Review and publication approval**: content and status changes take effect immediately; + approval workflows and review APIs are outside the scope. +2. **Domain-scoped or article-scoped definition grants**: definition privileges are granted on + the metalake. Domains group articles; they do not authorize access to an article. +3. **Web UI and agent writes**: the design provides REST APIs and read-only MCP tools. + A web editor and agent write operations are outside the scope. +4. **File ingestion, attachments and image upload**: the body is text. It may contain ordinary + external links, but Gravitino does not host files, extract text or fetch linked content. +5. **Ranked, fuzzy or semantic search and RAG**: substring search is sufficient for this scope. + There is no embedding index or answer-generation service. +6. **Inferred or transitive bindings**: words and links in the body do not create bindings. + Binding an article to a term does not bind it to that term's assets; binding a table does not + bind its columns. +7. **Metric bindings and version pinning**: bind a Semantic Model as an object, not an individual + metric. A binding points to the target's identity and resolves its current state. +8. **Historical version reads, article hierarchy, comparison and rollback**: public APIs and + Java/Python clients read current content only. Historical reads, comparison and rollback + are deferred. Articles form a flat list without parent-child relationships. + +--- + +## Scope and Dependencies + +The design covers the following capabilities. The task references link each capability to its +implementation work in [Task Breakdown](#task-breakdown). + +| Capability | Scope | Tasks | +| ----------------------------------------------- | ------------------------------------------------- | ------- | +| Article API, entity and four storage tables | New first-class metadata and retained snapshots | T1–T3 | +| Definition privileges and ownership | Metalake grants; current-owner checks | T4 | +| Domain membership | Explicit Article relations; filter and drop guard | T5 | +| Term and asset bindings | Stable IDs, reverse lookup and lifecycle cleanup | T6 | +| REST, conditional editing and search | DTOs, errors, summaries and OpenAPI | T7–T8 | +| Events and audit | Existing listener and audit mechanisms | T9 | +| Java, Python and read-only MCP | Same contracts and visibility as REST | T10–T12 | +| Integration, upgrade, performance and user docs | Release checks and documented operating limits | T13–T14 | + +Domain integration requires stable Domain IDs, hierarchy lookup, access checks and deletion +fencing. Term bindings require stable Term IDs, current-status lookup and deletion hooks. + +The four-table model stores a snapshot for each effective content change and uses `live_version` +to select current content. Retaining snapshots preserves the exact title, body, Domains and +bindings together, at the cost of additional storage and transactional writes. + +Public APIs and Java/Python clients expose current content only. Historical version lists and +individual-version reads can later use the retained snapshots without changing these four +tables or migrating current content. Historical reads must apply the article's current read +check and resolve deleted target IDs without attaching them to same-name replacements. + +--- + +## Usage Scenario + +1. An admin grants an analyst `CREATE_DEFINITION` and a reader `VIEW_DEFINITION` on a metalake. + The analyst also has access to Domain `Finance`, term `net-revenue` and table + `iceberg.sales.orders`. +2. The analyst creates "Revenue Calculation Guide", with a Markdown body, Domain `Finance`, + the term and the table. The server generates a name if none is supplied. The analyst becomes + the owner; the default status is `APPROVED`, and version 1 takes effect immediately. +3. The reader searches for a word from the body and loads the article. Its bindings lead to + the current term and table; each target still requires its own read privilege. +4. The analyst loads the article and saves a new body and another binding with its `ETag`. + One new version becomes effective atomically. The response shows the current version; + the previous snapshot remains in storage. +5. An agent acting as the reader calls `search_kb_articles`, then `get_kb_article`. It receives + the stored body with its format and only the bound objects it can read. +6. To prepare content privately, the analyst can create or set the article to `DRAFT`. Only its + owner with CREATE, or a caller with MANAGE, can read it. Setting it to `APPROVED` makes it + available again without review. +7. When the explanation is outdated, the owner sets it to `DEPRECATED`. It remains readable, + but agents stop returning it. The owner with CREATE or an admin with MANAGE can delete it + directly in any status. Deleting it removes neither the term nor the table. + +--- + +## Design + +### Data model + +`KnowledgeBaseArticle` is directly under a metalake, alongside Tag, Policy and Domain. It is not +under a catalog or schema, because an article can explain data from several catalogs. + +```text +KnowledgeBaseArticle { + name, title, body: { format: MARKDOWN | HTML, content }, + status: DRAFT | APPROVED | DEPRECATED, domains[], comment?, synonyms[], + sourceReference?, properties, version, audit_info +} +ArticleSnapshot { articleId, version, title, body, domainIds[], bindings[], audit_info } +ArticleBinding { articleId, targetType, targetId, audit_info } +ArticleDomain { articleId, domainId, audit_info } +``` + +`ArticleSnapshot` is the internal representation of a stored content version. The Article's +`version` identifies its current content snapshot; its ETag separately guards the store revision. + +- **Identity**: `metalake.articleName`. The name is immutable and unique in the metalake; the + internal numeric article ID is stable. Add `KNOWLEDGE_BASE_ARTICLE` to `MetadataObject.Type` + and `Entity.EntityType`, including the single-level object handling used by owner APIs. +- **Explicit name**: accept 1 to 128 Unicode code points, using letters, digits, combining marks, + `_` and `-`, with at least one letter or digit. Reject other characters with `400`, including + `/`, backslash, whitespace and control characters. Preserve the supplied spelling and case. +- **Generated name**: `name` is optional on create. Lower-case the title using `Locale.ROOT`, + preserve Unicode letters, digits and combining marks, and replace each run of other characters + with `-`. Trim leading/trailing `-` and cut to 128 Unicode code points without splitting a + character. Chinese text is preserved: `收入计算说明` becomes `收入计算说明`, and + `收入 Calculation Guide` becomes `收入-calculation-guide`. Do not transliterate to Pinyin. + Use `article-<shortId>` only when the result contains no Unicode letter or digit, such as an + emoji-only or punctuation-only title. The suffix is 8 random lower-case alphanumeric + characters, regenerated on collision. A derived-name collision adds `-2`, `-3`, and so on, + cutting the base further to keep the whole name within 128 code points. A duplicate explicit + name is `409`. Changing the title later never changes the generated name. +- **Title**: required, nonblank after trimming, at most 512 characters. Compare titles after + trimming and ignoring case, independent of database collation. Among articles that are not + `DEPRECATED`, titles are unique within the metalake. Deprecation releases the title; leaving + `DEPRECATED` checks it again. A conflict is `409`. Different titles can generate the same + name, which is why generated names also need collision suffixes. +- **Owner**: the creator becomes the owner through the existing Owner APIs. Owners may be users + or groups. Persist the relation in the existing `owner_meta` table: `metadata_object_id` is + the stable article ID, `metadata_object_type` is `KNOWLEDGE_BASE_ARTICLE`, and `metalake_id` + identifies its metalake. `owner_id` references the user or group ID and `owner_type` is `USER` + or `GROUP`; owner names are resolved from `user_meta` or `group_meta`. Integrate the Article + type with `OwnerMetaService` and the existing Owner APIs. No owner column is added to the + article tables, and ownership is not part of a content snapshot. +- **Other fields**: `comment` is at most 256 characters. `synonyms` are trimmed, at most 128 + characters each and at most 20 per article; remove duplicates ignoring case. They need not be + unique across articles. `sourceReference` is optional free text of at most 1024 characters, + such as a wiki URL. It is not validated as a URL, followed or fetched. Render it as text unless + a client separately validates it as a safe link. `properties` is a string map. + +#### Body and input validation + +`body.format` is `MARKDOWN` or `HTML`, stored with each version. The server sanitizes every body +on write, including raw HTML embedded in Markdown. Both formats use the same HTML allowlist: +remove scripts, active elements, event-handler attributes and unsafe URLs, including +`javascript:` and `data:` URLs and encoded variants. Preserve ordinary formatting and the safe +parts of the original content. Clients also sanitize HTML when rendering. + +Limit `body.content` by UTF-8 byte length both before and after sanitization. The configurable +limit defaults to 1 MiB (1,048,576 bytes); allowed settings are 1 through 16,777,215 bytes, the +MySQL `MEDIUMTEXT` capacity. An invalid setting prevents startup. An oversized request returns +`400`, without truncation or a stored change. Use the same bounds for create and alter. + +#### Storage + +Persist articles through EntityStore. Add four tables to H2, MySQL and PostgreSQL schemas and +upgrade scripts; use the existing owner and audit storage. + +| Table | Fields beyond common row metadata | Unique key | Other index | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------- | +| `kb_article_meta` | `article_id`, `metalake_id`, `article_name`, `status`, `live_version`, `article_comment`, `synonyms`, `source_reference`, `properties` | `(metalake_id, article_name, deleted_at)` | Primary key: `article_id` | +| `kb_article_version_info` | `id`, `metalake_id`, `article_id`, `version`, `title`, `body_format`, `body_content`, `domains`, `bindings`, `version_status` | `(article_id, version, deleted_at)` | `(metalake_id)` | +| `kb_article_relation_meta` | `id`, `article_id`, `target_id`, `target_type` | `(article_id, target_id, target_type, deleted_at)` | `(target_id, target_type)` | +| `kb_article_domain_rel` | `id`, `article_id`, `domain_id` | `(article_id, domain_id, deleted_at)` | `(domain_id, deleted_at, article_id)` | + +- Follow `tag_meta`, `tag_relation_meta` and `semantic_model_version_info`: numeric IDs, + `audit_info`, `deleted_at`, and `utf8mb4_bin` for MySQL. The article ID is an entity ID; the + other tables have an auto-increment primary key `id`. Relation key columns are non-NULL. +- Article, binding and Domain-relation rows have the usual `current_version` and `last_version` + store columns. Version rows are locked through the article row. These store revisions are + distinct from the article content-version number. +- Use `VARCHAR(128)` for the name, `VARCHAR(512)` for the title, `VARCHAR(256)` for the comment, Review Comment: I checked the proposed column width on the repository’s H2 2.2.224. Inserting a name consisting of 128 copies of U+20000 (𠀀) into VARCHAR(128) fails with “Value too long” and a reported length of 256. All 128 code points are letters accepted by the explicit-name contract. Could the H2 schema allow 256 UTF-16 code units while the API enforces the 128-code-point limit? Please include a round-trip case for this name across the three backends. ########## design-docs/gravitino-kb-article-design.md: ########## @@ -0,0 +1,1055 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Design: Knowledge Base Articles + +## Background + +Gravitino manages data assets and their metadata. A [Glossary Term](glossary-design.md) gives a +short definition of a business concept. Teams also need longer explanations: how revenue is +calculated, why it differs from GMV, and which tables feed it. Today these explanations live in +wikis and documents, apart from the terms and data they describe. Users and agents cannot find +them through the same metadata APIs or follow managed links from an explanation to its data. + +A Knowledge Base (KB) Article is a text document managed under a metalake. It has a title, a +Markdown or HTML body, an owner and a status. It can belong to several +[Domains](domain-design.md) and link to terms and data assets across catalogs. Users and agents +can search for an article, read it, and follow its bindings under their existing privileges. + +--- + +## Goals + +1. **Article object**: add `KnowledgeBaseArticle` as metalake-scoped metadata with an immutable + name and stable numeric ID. A title can change without breaking references to the article. +2. **Content and version storage**: store Markdown or HTML. Keep an internal snapshot of the + title, body, Domains and bindings for each effective content change, and expose the current + content only. Historical version reads are deferred. +3. **Bindings**: link an article to terms and metadata objects. Support reverse lookup from + either target. A binding never grants access to data. +4. **Domains**: organize and filter articles by zero or more Domains. Membership does not change + article privileges in this design. +5. **Status and privileges**: support `DRAFT`, `APPROVED` and `DEPRECATED`, with immediate edits + and definition privileges granted on the metalake. `APPROVED` means available to agents; + it does not record a reviewer's decision. +6. **Discovery**: search titles, synonyms and bodies, with Domain, status and owner filters. + Read-only MCP tools return readable `APPROVED` articles. +7. **APIs and governance**: provide REST, Java and Python APIs, ownership, events and audit. + Concurrent writes must not leave content, snapshots and effective relations out of sync. + +--- + +## Non-Goals + +1. **Review and publication approval**: content and status changes take effect immediately; + approval workflows and review APIs are outside the scope. +2. **Domain-scoped or article-scoped definition grants**: definition privileges are granted on + the metalake. Domains group articles; they do not authorize access to an article. +3. **Web UI and agent writes**: the design provides REST APIs and read-only MCP tools. + A web editor and agent write operations are outside the scope. +4. **File ingestion, attachments and image upload**: the body is text. It may contain ordinary + external links, but Gravitino does not host files, extract text or fetch linked content. +5. **Ranked, fuzzy or semantic search and RAG**: substring search is sufficient for this scope. + There is no embedding index or answer-generation service. +6. **Inferred or transitive bindings**: words and links in the body do not create bindings. + Binding an article to a term does not bind it to that term's assets; binding a table does not + bind its columns. +7. **Metric bindings and version pinning**: bind a Semantic Model as an object, not an individual + metric. A binding points to the target's identity and resolves its current state. +8. **Historical version reads, article hierarchy, comparison and rollback**: public APIs and + Java/Python clients read current content only. Historical reads, comparison and rollback + are deferred. Articles form a flat list without parent-child relationships. + +--- + +## Scope and Dependencies + +The design covers the following capabilities. The task references link each capability to its +implementation work in [Task Breakdown](#task-breakdown). + +| Capability | Scope | Tasks | +| ----------------------------------------------- | ------------------------------------------------- | ------- | +| Article API, entity and four storage tables | New first-class metadata and retained snapshots | T1–T3 | +| Definition privileges and ownership | Metalake grants; current-owner checks | T4 | +| Domain membership | Explicit Article relations; filter and drop guard | T5 | +| Term and asset bindings | Stable IDs, reverse lookup and lifecycle cleanup | T6 | +| REST, conditional editing and search | DTOs, errors, summaries and OpenAPI | T7–T8 | +| Events and audit | Existing listener and audit mechanisms | T9 | +| Java, Python and read-only MCP | Same contracts and visibility as REST | T10–T12 | +| Integration, upgrade, performance and user docs | Release checks and documented operating limits | T13–T14 | + +Domain integration requires stable Domain IDs, hierarchy lookup, access checks and deletion +fencing. Term bindings require stable Term IDs, current-status lookup and deletion hooks. + +The four-table model stores a snapshot for each effective content change and uses `live_version` +to select current content. Retaining snapshots preserves the exact title, body, Domains and +bindings together, at the cost of additional storage and transactional writes. + +Public APIs and Java/Python clients expose current content only. Historical version lists and +individual-version reads can later use the retained snapshots without changing these four +tables or migrating current content. Historical reads must apply the article's current read +check and resolve deleted target IDs without attaching them to same-name replacements. + +--- + +## Usage Scenario + +1. An admin grants an analyst `CREATE_DEFINITION` and a reader `VIEW_DEFINITION` on a metalake. + The analyst also has access to Domain `Finance`, term `net-revenue` and table + `iceberg.sales.orders`. +2. The analyst creates "Revenue Calculation Guide", with a Markdown body, Domain `Finance`, + the term and the table. The server generates a name if none is supplied. The analyst becomes + the owner; the default status is `APPROVED`, and version 1 takes effect immediately. +3. The reader searches for a word from the body and loads the article. Its bindings lead to + the current term and table; each target still requires its own read privilege. +4. The analyst loads the article and saves a new body and another binding with its `ETag`. + One new version becomes effective atomically. The response shows the current version; + the previous snapshot remains in storage. +5. An agent acting as the reader calls `search_kb_articles`, then `get_kb_article`. It receives + the stored body with its format and only the bound objects it can read. +6. To prepare content privately, the analyst can create or set the article to `DRAFT`. Only its + owner with CREATE, or a caller with MANAGE, can read it. Setting it to `APPROVED` makes it + available again without review. +7. When the explanation is outdated, the owner sets it to `DEPRECATED`. It remains readable, + but agents stop returning it. The owner with CREATE or an admin with MANAGE can delete it + directly in any status. Deleting it removes neither the term nor the table. + +--- + +## Design + +### Data model + +`KnowledgeBaseArticle` is directly under a metalake, alongside Tag, Policy and Domain. It is not +under a catalog or schema, because an article can explain data from several catalogs. + +```text +KnowledgeBaseArticle { + name, title, body: { format: MARKDOWN | HTML, content }, + status: DRAFT | APPROVED | DEPRECATED, domains[], comment?, synonyms[], + sourceReference?, properties, version, audit_info +} +ArticleSnapshot { articleId, version, title, body, domainIds[], bindings[], audit_info } +ArticleBinding { articleId, targetType, targetId, audit_info } +ArticleDomain { articleId, domainId, audit_info } +``` + +`ArticleSnapshot` is the internal representation of a stored content version. The Article's +`version` identifies its current content snapshot; its ETag separately guards the store revision. + +- **Identity**: `metalake.articleName`. The name is immutable and unique in the metalake; the + internal numeric article ID is stable. Add `KNOWLEDGE_BASE_ARTICLE` to `MetadataObject.Type` + and `Entity.EntityType`, including the single-level object handling used by owner APIs. +- **Explicit name**: accept 1 to 128 Unicode code points, using letters, digits, combining marks, + `_` and `-`, with at least one letter or digit. Reject other characters with `400`, including + `/`, backslash, whitespace and control characters. Preserve the supplied spelling and case. +- **Generated name**: `name` is optional on create. Lower-case the title using `Locale.ROOT`, + preserve Unicode letters, digits and combining marks, and replace each run of other characters + with `-`. Trim leading/trailing `-` and cut to 128 Unicode code points without splitting a + character. Chinese text is preserved: `收入计算说明` becomes `收入计算说明`, and + `收入 Calculation Guide` becomes `收入-calculation-guide`. Do not transliterate to Pinyin. + Use `article-<shortId>` only when the result contains no Unicode letter or digit, such as an + emoji-only or punctuation-only title. The suffix is 8 random lower-case alphanumeric + characters, regenerated on collision. A derived-name collision adds `-2`, `-3`, and so on, + cutting the base further to keep the whole name within 128 code points. A duplicate explicit + name is `409`. Changing the title later never changes the generated name. +- **Title**: required, nonblank after trimming, at most 512 characters. Compare titles after + trimming and ignoring case, independent of database collation. Among articles that are not + `DEPRECATED`, titles are unique within the metalake. Deprecation releases the title; leaving + `DEPRECATED` checks it again. A conflict is `409`. Different titles can generate the same + name, which is why generated names also need collision suffixes. +- **Owner**: the creator becomes the owner through the existing Owner APIs. Owners may be users + or groups. Persist the relation in the existing `owner_meta` table: `metadata_object_id` is + the stable article ID, `metadata_object_type` is `KNOWLEDGE_BASE_ARTICLE`, and `metalake_id` + identifies its metalake. `owner_id` references the user or group ID and `owner_type` is `USER` + or `GROUP`; owner names are resolved from `user_meta` or `group_meta`. Integrate the Article + type with `OwnerMetaService` and the existing Owner APIs. No owner column is added to the + article tables, and ownership is not part of a content snapshot. +- **Other fields**: `comment` is at most 256 characters. `synonyms` are trimmed, at most 128 + characters each and at most 20 per article; remove duplicates ignoring case. They need not be + unique across articles. `sourceReference` is optional free text of at most 1024 characters, + such as a wiki URL. It is not validated as a URL, followed or fetched. Render it as text unless + a client separately validates it as a safe link. `properties` is a string map. + +#### Body and input validation + +`body.format` is `MARKDOWN` or `HTML`, stored with each version. The server sanitizes every body +on write, including raw HTML embedded in Markdown. Both formats use the same HTML allowlist: +remove scripts, active elements, event-handler attributes and unsafe URLs, including +`javascript:` and `data:` URLs and encoded variants. Preserve ordinary formatting and the safe +parts of the original content. Clients also sanitize HTML when rendering. + +Limit `body.content` by UTF-8 byte length both before and after sanitization. The configurable +limit defaults to 1 MiB (1,048,576 bytes); allowed settings are 1 through 16,777,215 bytes, the +MySQL `MEDIUMTEXT` capacity. An invalid setting prevents startup. An oversized request returns +`400`, without truncation or a stored change. Use the same bounds for create and alter. + +#### Storage + +Persist articles through EntityStore. Add four tables to H2, MySQL and PostgreSQL schemas and +upgrade scripts; use the existing owner and audit storage. + +| Table | Fields beyond common row metadata | Unique key | Other index | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------- | +| `kb_article_meta` | `article_id`, `metalake_id`, `article_name`, `status`, `live_version`, `article_comment`, `synonyms`, `source_reference`, `properties` | `(metalake_id, article_name, deleted_at)` | Primary key: `article_id` | +| `kb_article_version_info` | `id`, `metalake_id`, `article_id`, `version`, `title`, `body_format`, `body_content`, `domains`, `bindings`, `version_status` | `(article_id, version, deleted_at)` | `(metalake_id)` | +| `kb_article_relation_meta` | `id`, `article_id`, `target_id`, `target_type` | `(article_id, target_id, target_type, deleted_at)` | `(target_id, target_type)` | +| `kb_article_domain_rel` | `id`, `article_id`, `domain_id` | `(article_id, domain_id, deleted_at)` | `(domain_id, deleted_at, article_id)` | + +- Follow `tag_meta`, `tag_relation_meta` and `semantic_model_version_info`: numeric IDs, + `audit_info`, `deleted_at`, and `utf8mb4_bin` for MySQL. The article ID is an entity ID; the + other tables have an auto-increment primary key `id`. Relation key columns are non-NULL. +- Article, binding and Domain-relation rows have the usual `current_version` and `last_version` + store columns. Version rows are locked through the article row. These store revisions are + distinct from the article content-version number. +- Use `VARCHAR(128)` for the name, `VARCHAR(512)` for the title, `VARCHAR(256)` for the comment, + `VARCHAR(1024)` for the source reference, `VARCHAR(32)` for status and format, and `VARCHAR(64)` + for target type. The body, properties, bindings and audit JSON use MySQL `MEDIUMTEXT`; + synonyms and Domain snapshots use `TEXT`. Other databases use their native equivalents. +- `domains` is a JSON array of stable Domain IDs. `bindings` is a JSON array of target type and + stable target ID. These snapshots are authoritative; relation tables are projections used by + filters and reverse lookups. There are no database foreign keys; services validate and fence + endpoints in the transaction. +- `live_version` points to the effective snapshot. All creates set it; all content versions have + `version_status=APPROVED`, even when the article's own status is `DRAFT`. The column follows the + `semantic_model_version_info` convention and is reserved for extensions; this delivery never + writes another value. The private `live_version` column may be nullable for extensions, but this + implementation never writes a null live pointer. +- Add the tables to `schema-2.0.0-*.sql` and `upgrade-1.3.0-to-2.0.0-*.sql` while 2.0.0 is + unreleased. If it is released before implementation lands, use the next version's scripts. + Table creation uses `IF NOT EXISTS`; that does not make the whole upgrade script re-runnable. +- Snapshot JSON is private storage, not a client contract. Compatible additions are optional + with documented defaults for older rows. An unrelated edit preserves unknown fields. Reject + an unsupported structure before changing data. An incompatible change needs an explicit + migration; no `schema_version` field is introduced in advance. + +### Status and versions + +| Article status | Ordinary reads | Reverse lookup | MCP | +| -------------- | ------------------------------------ | ---------------------------------- | -------- | +| `DRAFT` | Current owner with CREATE, or MANAGE | Excluded | Excluded | +| `APPROVED` | Effective VIEW | Included | Included | +| `DEPRECATED` | Effective VIEW | Only with `includeDeprecated=true` | Excluded | + +New articles default to `APPROVED`. Create may explicitly set any of the three statuses, and +`updateStatus` may set any of them without transition rules or lifecycle endpoints. Setting a +status creates no content version. Leaving `DEPRECATED` rechecks title uniqueness; an article +may be edited or deleted in any status with the normal privileges. + +The title, body, Domains and bindings are versioned together, following Semantic Model storage. +Owner, article status, comment, synonyms, source reference and properties change directly and +are audited, without a content snapshot. Properties must not be used to hide content that +belongs in the versioned fields. + +- Create writes version 1 with its initial Domains and bindings. +- An effective change to one or more versioned fields writes exactly one new snapshot, using + the highest version number plus one. It advances the live pointer and rewrites effective + bindings and Domain memberships in the same transaction. Any failure rolls back all of them. +- Copy the complete stored snapshot before applying changes, including relations the editor + cannot see. Filter only response data. A body-only edit must not remove hidden bindings or + Domain memberships. +- Public loads, summaries and bindings read the current effective version only. Older snapshots + remain internal. + Stored target and Domain IDs remain unchanged after deletion for later historical resolution. +- Keep every version until article deletion. `JDBCBackend.deleteOldVersionData` returns `0` for + this entity type, so the normal old-version sweep does not remove history. Article deletion + soft-deletes all its versions atomically; normal deletion garbage collection still applies. + +### Domain membership + +An article belongs to zero or more Domains, using explicit `kb_article_domain_rel` rows. +Membership is part of the content snapshot and changes through Article operations. It is +independent of backing-tag assignments, so tag changes cannot silently move an article. + +- Requests and responses use Domain names. Resolve names to stable IDs on write and return the + current names on read. A rename changes neither membership nor history identity. An unknown + Domain returns `404`. +- Follow the Domain model's two levels and shared metalake namespace. A Domain filter includes + the Domain and its subdomains. Domain membership is optional at creation and may change later. +- Article definition privileges remain metalake-scoped. Each added or removed Domain also + requires its ordinary access check, including `USE_DOMAIN` and draft-Domain visibility. + Filter every returned Domain list by that check, without names or counts for hidden Domains. +- `updateDomains` replaces the complete set. Compute additions and removals from the full stored + set and check each changed Domain. An unrelated edit preserves every membership. A caller + cannot silently remove an unseen membership by submitting only the filtered response. +- Domain deletion must check effective Article and Term memberships under the Domain lock. Any + remaining membership returns `409 NonEmptyDomainException`, without member names or counts. + `MANAGE_DOMAIN` alone cannot detach articles. An authorized Article editor first removes + membership through the Article API. Historical snapshots alone do not prevent Domain deletion. +- This extends the current Domain drop path, which already checks its own lifecycle constraints. + Changing or deleting a backing tag does not change Article membership. + +### Bindings and target lifecycle + +| Binding | Supported targets | +| --------------- | --------------------------------------------------------------------------------- | +| Article → Term | `GLOSSARY_TERM`, by stable numeric ID | +| Article → Asset | Catalog, Schema, Table, View, table Column, Fileset, Topic, Model, Semantic Model | + +An article may have no bindings. Bindings point to object identity, not to one target version. +Article→Term, Article→Asset and Term→Asset are independent. There is no inheritance from a table +to columns or from a term to its assets. A binding may cross catalogs or Domains. + +- Adding a binding requires Article edit permission and read access to the target. A missing or + invisible target fails the complete request; no partial binding changes are stored. +- A new Term binding requires the Term to be `APPROVED`; otherwise return `409`. Check target + visibility before returning details of that conflict. Existing bindings remain if a Term + becomes `DRAFT` or `DEPRECATED`; returned Term details carry its current status. +- Add and remove sets apply atomically. Adding an existing binding or removing an absent one + is a no-op and creates no version. A mixed request creates one version if its final set differs. +- Responses omit unreadable targets and any hidden-target count. Stored snapshots remain + complete. A binding never grants or blocks access to the target. +- Rename preserves a binding when the target's registered ID is preserved. Deleting a target + removes effective binding rows, keeps the article and leaves historical snapshots intact. + Each affected surviving article gets one store-revision increment and an audit record per + cleanup transaction, without a new content version. Rebuilding effective relations excludes + deleted targets rather than resurrecting them from snapshots. +- Table-column bindings use the registered column ID and the containing table's authorization + and endpoint fencing. Reuse the platform's column reconciliation and cleanup paths, including + load-triggered reconciliation. Concurrent external column rename has the inherited identity + limitation tracked by [#14279](https://github.com/apache/gravitino/issues/14279); this design + does not promise unconditional preservation when the platform replaces the column ID. +- Store cleanup is atomic with local registered-object changes. External catalog DDL is outside + that database transaction. Keep existing external DDL responses, record cleanup failures, and + use the platform's reconciliation/recovery path; a local rollback cannot undo external DDL. +- Links written in the body are ordinary text URLs, independent of bindings. Renaming a target + updates resolved binding names, but does not rewrite URLs in old or current article text. + +Deleting an article soft-deletes its identity, versions, bindings and Domain memberships in one +transaction. It never deletes targets. Dropping a metalake removes articles through the normal +parent lifecycle. Removing a user does not delete their articles; MANAGE can reassign ownership. + +### Access control + +Use the definition privileges on the metalake: `VIEW_DEFINITION`, `CREATE_DEFINITION` +and `MANAGE_DEFINITIONS`, abbreviated VIEW, CREATE and MANAGE in this section. +`MANAGE_DEFINITIONS` implies CREATE, and CREATE implies VIEW. Expand those implications and +apply explicit Deny rules to every required capability. Every operation requires effective VIEW; +ownership never bypasses Deny. + +| Operation | Required definition privilege | +| --------------------------------- | -------------------------------------------------------------- | +| List and load | VIEW; drafts also require current owner with CREATE, or MANAGE | +| Create | CREATE | +| Edit, set status, change bindings | Current owner with CREATE, or MANAGE | +| Change Domain membership | Current owner with CREATE, or MANAGE; Domain checks also apply | +| Delete in any status | Current owner with CREATE, or MANAGE | +| Reverse lookup | VIEW on the article and read access to the lookup root | + +CREATE alone cannot read another owner's draft, and ownership alone cannot replace CREATE. +Use the same rules on direct reads, lists, nested results, reverse lookups and MCP. +Definition grants on a single article are rejected. Administrators explicitly grant VIEW to +reader roles; there is no implicit `PUBLIC` or anonymous read grant. + +Resolve current article identity, owner and the authenticated principal's group IDs from the +store/principal for each owner-based decision. Do not use shared name-to-ID or owner caches for +that decision. Recheck ownership in write transactions and apply the same rule to generic Owner +transfer authorization. After a committed transfer, new requests on another server cannot use +the former owner's cached rights. Already-authorized in-flight requests are outside that +guarantee. Group membership follows the platform's authenticated-principal freshness rules; +Gravitino does not add a user-to-group membership store. + +Lists, search and counts use the same visibility predicate. A hidden article must not appear in +`total`, nested summaries or candidate lists. Reading an article does not authorize its targets; +loading a reverse lookup first checks the Term or object root, then filters the articles. + +### Locking and conditional editing + +Every effective write advances the article row's `current_version` using the store's +compare-and-set (CAS) check. A concurrent store revision returns `409` with +`OPTIMISTIC_LOCK_CONFLICT_CODE`. A no-op advances neither the store revision nor the content +version, and emits no content-change success event. Validate identity, authorization and any +condition before detecting a no-op. Compare persisted values, treating memberships and bindings +as sets; updates that cancel out are a no-op. + +Plan the complete lock set before acquiring locks. Follow the existing endpoint fences and a +single order: metalake, Domains in ID order, bound target endpoint chains in their established +order, then Article rows in ID order. Revalidate the resolved identities and relation sets under +the locks. If planning discovered a stale set, restart lock planning with a bounded retry; +never retry a failed CAS as an unconditional overwrite. + +- Create, title changes and status changes away from `DEPRECATED` claim a title under an + exclusive metalake-row lock (`SELECT ... FOR UPDATE` on `metalake_meta`). Take its final lock + mode initially rather than upgrading a shared metalake fence. This serializes title claims + within a metalake, including two different article IDs claiming the same title. +- A membership write holds a shared Domain-row lock until commit. Domain drop takes its + exclusive lock, then checks the latest committed memberships, without taking Article locks + while holding that exclusive Domain lock. Either the membership commits and drop fails, or + drop commits and the membership write fails; neither leaves a dangling membership. +- Target removal fences the endpoint against new bindings before collecting affected articles, + then locks Article rows in ID order. Cleanup and ordinary edits cannot lose revision increments. +- Content snapshots, the live pointer and effective relations commit in one transaction. Reads + use a consistent store snapshot for root status, authorization and payload; they do not need + write locks. A read that began before a concurrent commit may return the earlier complete state. + +REST also accepts an optional `If-Match` header, using the last load or write's strong `ETag`. +The token is opaque and unambiguously includes stable metalake ID, article ID and store revision. +It covers all article writes, not just content versions. Names and content-version numbers do +not distinguish a deleted article from a same-name replacement with the same numeric revision. + +| Request | Concurrency headers | +| ------------------------- | -------------------------------------- | +| Create or load an article | Response `ETag` | +| Alter or change bindings | Request `If-Match`; response `ETag` | +| Delete | Request `If-Match`; no response `ETag` | +| Lists and reverse lookups | No `ETag`; load before editing | + +Under the article lock, resolve and authorize the current identity before comparing the token, +and compare before writes or no-op detection. Missing or hidden roots return `404` first; a +malformed token is `400`, and a stale identity or revision is `412`. A failed check changes no +data, revision or success event. Tokens are concurrency guards, not credentials. + +An omitted header or `If-Match: *` skips only token comparison. CAS still applies and can return +`409`; there is no automatic retry. A successful write returns the new token, including the +unchanged token for a valid no-op. Article REST resources and Java/Python clients use the same +conditional-edit contract. + +### REST API + +All paths below start with `/api/metalakes/{metalake}`. Domain is a field or filter, not a path +segment. Successful calls use HTTP `200` and the normal Gravitino response envelope with +`code: 0`, as the Tag APIs do. The table names the other response fields; errors use the usual +error envelope. Article and binding writes also carry the concurrency headers above. + +Article names are stored and returned as Unicode strings, not URL-encoded strings. In every +single-Article route, clients UTF-8 percent-encode the name as one path segment; server routing +decodes it once. Java and Python clients must preserve Chinese and mixed-language names through +create, load, alter, delete and binding calls. Percent-encoded length is not the name length. + +| Method and path | Request | Response fields | Behavior | +| ---------------------------------------- | ----------------------------------------------------------- | ------------------------------ | -------------------------------------------------- | +| `POST /kb-articles` | Create fields below | `article` | Create identity, owner, version 1 and relations | +| `GET /kb-articles` | List filters below | `articles`, `total`, `hasMore` | Read visible summaries only | +| `GET /kb-articles/{article}` | Binding `limit`, `offset` | `article` | Read current content with bounded binding previews | +| `PUT /kb-articles/{article}` | `updates` array | `article` | Apply all changes atomically | +| `DELETE /kb-articles/{article}` | No body | Existing `DropResponse` | Soft-delete article and related rows atomically | +| `GET /kb-articles/{article}/terms` | `limit`, `offset` | `terms`, `hasMore` | Page visible current Term bindings | +| `POST /kb-articles/{article}/terms` | `termsToAdd`, `termsToRemove`: name arrays | `terms`, `hasMore` | Change bindings; return the first bounded page | +| `GET /kb-articles/{article}/objects` | `limit`, `offset` | `objects`, `hasMore` | Page visible current asset bindings | +| `POST /kb-articles/{article}/objects` | `objectsToAdd`, `objectsToRemove`: identifiers | `objects`, `hasMore` | Change bindings; return the first bounded page | +| `GET /glossary/terms/{term}/kb-articles` | `includeDeprecated`, `limit`, `offset` | `articles`, `total`, `hasMore` | Authorize Term root, then page summaries | +| `GET /objects/{type}/kb-articles` | `namespace`, `name`, `includeDeprecated`, `limit`, `offset` | `articles`, `total`, `hasMore` | Authorize asset root, then page summaries | + +The two reverse lookups return only `APPROVED` articles unless `includeDeprecated=true`, which +also includes `DEPRECATED`. They never return drafts. Each returned article, Term, asset and +Domain passes its own visibility check. Reverse lookup does not traverse Term→Asset bindings. + +#### Pagination and binding previews + +Use ordinary `limit` and `offset`, without a cursor token. List, reverse-lookup and binding-list +reads default to `limit=100`, `offset=0`; accept limits from 1 through 10,000 and nonnegative +offsets, rejecting invalid values with `400`. Order bindings by stable `(target_id, target_type)`. +Article summaries retain the title/name ordering described below. Apply root authorization, +status filters and target visibility before offset and limit. A page contains only readable +results, without hidden-object counts. `hasMore` means another readable result exists; clients +continue with the same filters, adding the returned item count to offset. Pages describe unchanged +data; concurrent edits may move results between pages, as with the Article list. + +Binding pages return `terms` or `objects` plus `hasMore`, with no total. Term entries contain +only name and current status, not full definitions or nested Term bindings; object entries use +`ArticleObjectIdentifier`. Query the relation tables for the bounded page rather than loading +the complete snapshot or all target DTOs and then truncating them. Batch target resolution for +the selected page. Article list/reverse pages retain their authorized `total` and add `hasMore`. + +An `ArticleSummary` embeds at most 20 readable Term entries and `termsHasMore`. A full Article +response embeds Term and object previews with `termsHasMore` and `objectsHasMore`. A load accepts +`limit` and `offset` for both binding sets, defaulting to 20 and 0, with the same maximum of 10,000. +These parameters page bindings, not the body. Clients can instead page each set independently +through the dedicated binding endpoints. Create and alter return the default previews; binding +mutations return the first 100 readable entries of the updated set and `hasMore`, plus the +Article ETag. Pagination never changes the complete stored snapshot or the atomic mutation. + +#### Create and alter + +| Create field | Type | Required | Description | +| ----------------- | ------------------------------- | -------- | --------------------------------------------- | +| `name` | string | No | Immutable name; generated when omitted | +| `title` | string | Yes | Unique nondeprecated display title | +| `body` | `{format, content}` | Yes | Text body, sanitized and byte-limited | +| `status` | string enum | No | Defaults to `APPROVED` | +| `domains` | string array | No | Domain names; defaults to an empty set | +| `terms` | string array | No | Approved Term names; defaults to an empty set | +| `objects` | `ArticleObjectIdentifier` array | No | Asset identifiers; defaults to an empty set | +| `comment` | string | No | Short description | +| `synonyms` | string array | No | Other words for the topic; defaults to empty | +| `sourceReference` | string | No | Source text, without URL fetching | +| `properties` | string map | No | Unversioned properties; defaults to empty | + +Example create request: + +```json +{ + "name": "revenue-calculation-guide", + "title": "Revenue Calculation Guide", + "body": { + "format": "MARKDOWN", + "content": "# Revenue\n\nRevenue excludes refunds and taxes." + }, + "domains": ["Finance"], + "terms": ["net-revenue"], + "objects": [ + { "type": "TABLE", "namespace": ["iceberg", "sales"], "name": "orders" } + ] +} +``` + +Create, load and alter return `{ "code": 0, "article": ... }`, where `article` has the typed +fields in [Data model](#data-model), plus the bounded binding previews described above. Bound +Term entries contain name and current status; object entries use `ArticleObjectIdentifier`. +Owner information is resolved through the existing Owner model, not stored in the version snapshot. `audit_info` +follows the standard AuditInfo DTO. These responses expose current content only. + +Alter follows the existing `updates` convention. Supported changes are `updateTitle`, +`updateBody`, `updateDomains`, `updateStatus`, `updateComment`, `updateSynonyms`, +`updateSourceReference`, `setProperty` and `removeProperty`. Domain and synonym updates replace Review Comment: Step 4 of the usage scenario saves a body edit and a new binding together and promises one new version. With the listed updates, the client has to PUT the body and then POST the binding. If the binding fails its target-access check, the new body is already live. Could alter accept Term and asset binding deltas in the same request? An acceptance case could assert that a successful combined edit creates one version and that a rejected binding leaves the body, version and ETag unchanged. If separate saves are intended, please adjust step 4 to describe the two commits. ########## design-docs/gravitino-kb-article-design.md: ########## @@ -0,0 +1,1055 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Design: Knowledge Base Articles + +## Background + +Gravitino manages data assets and their metadata. A [Glossary Term](glossary-design.md) gives a +short definition of a business concept. Teams also need longer explanations: how revenue is +calculated, why it differs from GMV, and which tables feed it. Today these explanations live in +wikis and documents, apart from the terms and data they describe. Users and agents cannot find +them through the same metadata APIs or follow managed links from an explanation to its data. + +A Knowledge Base (KB) Article is a text document managed under a metalake. It has a title, a +Markdown or HTML body, an owner and a status. It can belong to several +[Domains](domain-design.md) and link to terms and data assets across catalogs. Users and agents +can search for an article, read it, and follow its bindings under their existing privileges. + +--- + +## Goals + +1. **Article object**: add `KnowledgeBaseArticle` as metalake-scoped metadata with an immutable + name and stable numeric ID. A title can change without breaking references to the article. +2. **Content and version storage**: store Markdown or HTML. Keep an internal snapshot of the + title, body, Domains and bindings for each effective content change, and expose the current + content only. Historical version reads are deferred. +3. **Bindings**: link an article to terms and metadata objects. Support reverse lookup from + either target. A binding never grants access to data. +4. **Domains**: organize and filter articles by zero or more Domains. Membership does not change + article privileges in this design. +5. **Status and privileges**: support `DRAFT`, `APPROVED` and `DEPRECATED`, with immediate edits + and definition privileges granted on the metalake. `APPROVED` means available to agents; + it does not record a reviewer's decision. +6. **Discovery**: search titles, synonyms and bodies, with Domain, status and owner filters. + Read-only MCP tools return readable `APPROVED` articles. +7. **APIs and governance**: provide REST, Java and Python APIs, ownership, events and audit. + Concurrent writes must not leave content, snapshots and effective relations out of sync. + +--- + +## Non-Goals + +1. **Review and publication approval**: content and status changes take effect immediately; + approval workflows and review APIs are outside the scope. +2. **Domain-scoped or article-scoped definition grants**: definition privileges are granted on + the metalake. Domains group articles; they do not authorize access to an article. +3. **Web UI and agent writes**: the design provides REST APIs and read-only MCP tools. + A web editor and agent write operations are outside the scope. +4. **File ingestion, attachments and image upload**: the body is text. It may contain ordinary + external links, but Gravitino does not host files, extract text or fetch linked content. +5. **Ranked, fuzzy or semantic search and RAG**: substring search is sufficient for this scope. + There is no embedding index or answer-generation service. +6. **Inferred or transitive bindings**: words and links in the body do not create bindings. + Binding an article to a term does not bind it to that term's assets; binding a table does not + bind its columns. +7. **Metric bindings and version pinning**: bind a Semantic Model as an object, not an individual + metric. A binding points to the target's identity and resolves its current state. +8. **Historical version reads, article hierarchy, comparison and rollback**: public APIs and + Java/Python clients read current content only. Historical reads, comparison and rollback + are deferred. Articles form a flat list without parent-child relationships. + +--- + +## Scope and Dependencies + +The design covers the following capabilities. The task references link each capability to its +implementation work in [Task Breakdown](#task-breakdown). + +| Capability | Scope | Tasks | +| ----------------------------------------------- | ------------------------------------------------- | ------- | +| Article API, entity and four storage tables | New first-class metadata and retained snapshots | T1–T3 | +| Definition privileges and ownership | Metalake grants; current-owner checks | T4 | +| Domain membership | Explicit Article relations; filter and drop guard | T5 | +| Term and asset bindings | Stable IDs, reverse lookup and lifecycle cleanup | T6 | +| REST, conditional editing and search | DTOs, errors, summaries and OpenAPI | T7–T8 | +| Events and audit | Existing listener and audit mechanisms | T9 | +| Java, Python and read-only MCP | Same contracts and visibility as REST | T10–T12 | +| Integration, upgrade, performance and user docs | Release checks and documented operating limits | T13–T14 | + +Domain integration requires stable Domain IDs, hierarchy lookup, access checks and deletion +fencing. Term bindings require stable Term IDs, current-status lookup and deletion hooks. + +The four-table model stores a snapshot for each effective content change and uses `live_version` +to select current content. Retaining snapshots preserves the exact title, body, Domains and +bindings together, at the cost of additional storage and transactional writes. + +Public APIs and Java/Python clients expose current content only. Historical version lists and +individual-version reads can later use the retained snapshots without changing these four +tables or migrating current content. Historical reads must apply the article's current read +check and resolve deleted target IDs without attaching them to same-name replacements. + +--- + +## Usage Scenario + +1. An admin grants an analyst `CREATE_DEFINITION` and a reader `VIEW_DEFINITION` on a metalake. + The analyst also has access to Domain `Finance`, term `net-revenue` and table + `iceberg.sales.orders`. +2. The analyst creates "Revenue Calculation Guide", with a Markdown body, Domain `Finance`, + the term and the table. The server generates a name if none is supplied. The analyst becomes + the owner; the default status is `APPROVED`, and version 1 takes effect immediately. +3. The reader searches for a word from the body and loads the article. Its bindings lead to + the current term and table; each target still requires its own read privilege. +4. The analyst loads the article and saves a new body and another binding with its `ETag`. + One new version becomes effective atomically. The response shows the current version; + the previous snapshot remains in storage. +5. An agent acting as the reader calls `search_kb_articles`, then `get_kb_article`. It receives + the stored body with its format and only the bound objects it can read. +6. To prepare content privately, the analyst can create or set the article to `DRAFT`. Only its + owner with CREATE, or a caller with MANAGE, can read it. Setting it to `APPROVED` makes it + available again without review. +7. When the explanation is outdated, the owner sets it to `DEPRECATED`. It remains readable, + but agents stop returning it. The owner with CREATE or an admin with MANAGE can delete it + directly in any status. Deleting it removes neither the term nor the table. + +--- + +## Design + +### Data model + +`KnowledgeBaseArticle` is directly under a metalake, alongside Tag, Policy and Domain. It is not +under a catalog or schema, because an article can explain data from several catalogs. + +```text +KnowledgeBaseArticle { + name, title, body: { format: MARKDOWN | HTML, content }, + status: DRAFT | APPROVED | DEPRECATED, domains[], comment?, synonyms[], + sourceReference?, properties, version, audit_info +} +ArticleSnapshot { articleId, version, title, body, domainIds[], bindings[], audit_info } +ArticleBinding { articleId, targetType, targetId, audit_info } +ArticleDomain { articleId, domainId, audit_info } +``` + +`ArticleSnapshot` is the internal representation of a stored content version. The Article's +`version` identifies its current content snapshot; its ETag separately guards the store revision. + +- **Identity**: `metalake.articleName`. The name is immutable and unique in the metalake; the + internal numeric article ID is stable. Add `KNOWLEDGE_BASE_ARTICLE` to `MetadataObject.Type` + and `Entity.EntityType`, including the single-level object handling used by owner APIs. +- **Explicit name**: accept 1 to 128 Unicode code points, using letters, digits, combining marks, + `_` and `-`, with at least one letter or digit. Reject other characters with `400`, including + `/`, backslash, whitespace and control characters. Preserve the supplied spelling and case. +- **Generated name**: `name` is optional on create. Lower-case the title using `Locale.ROOT`, + preserve Unicode letters, digits and combining marks, and replace each run of other characters + with `-`. Trim leading/trailing `-` and cut to 128 Unicode code points without splitting a + character. Chinese text is preserved: `收入计算说明` becomes `收入计算说明`, and + `收入 Calculation Guide` becomes `收入-calculation-guide`. Do not transliterate to Pinyin. + Use `article-<shortId>` only when the result contains no Unicode letter or digit, such as an + emoji-only or punctuation-only title. The suffix is 8 random lower-case alphanumeric + characters, regenerated on collision. A derived-name collision adds `-2`, `-3`, and so on, + cutting the base further to keep the whole name within 128 code points. A duplicate explicit + name is `409`. Changing the title later never changes the generated name. +- **Title**: required, nonblank after trimming, at most 512 characters. Compare titles after + trimming and ignoring case, independent of database collation. Among articles that are not + `DEPRECATED`, titles are unique within the metalake. Deprecation releases the title; leaving + `DEPRECATED` checks it again. A conflict is `409`. Different titles can generate the same + name, which is why generated names also need collision suffixes. +- **Owner**: the creator becomes the owner through the existing Owner APIs. Owners may be users + or groups. Persist the relation in the existing `owner_meta` table: `metadata_object_id` is + the stable article ID, `metadata_object_type` is `KNOWLEDGE_BASE_ARTICLE`, and `metalake_id` + identifies its metalake. `owner_id` references the user or group ID and `owner_type` is `USER` + or `GROUP`; owner names are resolved from `user_meta` or `group_meta`. Integrate the Article + type with `OwnerMetaService` and the existing Owner APIs. No owner column is added to the + article tables, and ownership is not part of a content snapshot. +- **Other fields**: `comment` is at most 256 characters. `synonyms` are trimmed, at most 128 + characters each and at most 20 per article; remove duplicates ignoring case. They need not be + unique across articles. `sourceReference` is optional free text of at most 1024 characters, + such as a wiki URL. It is not validated as a URL, followed or fetched. Render it as text unless + a client separately validates it as a safe link. `properties` is a string map. + +#### Body and input validation + +`body.format` is `MARKDOWN` or `HTML`, stored with each version. The server sanitizes every body +on write, including raw HTML embedded in Markdown. Both formats use the same HTML allowlist: +remove scripts, active elements, event-handler attributes and unsafe URLs, including +`javascript:` and `data:` URLs and encoded variants. Preserve ordinary formatting and the safe +parts of the original content. Clients also sanitize HTML when rendering. + +Limit `body.content` by UTF-8 byte length both before and after sanitization. The configurable +limit defaults to 1 MiB (1,048,576 bytes); allowed settings are 1 through 16,777,215 bytes, the +MySQL `MEDIUMTEXT` capacity. An invalid setting prevents startup. An oversized request returns +`400`, without truncation or a stored change. Use the same bounds for create and alter. + +#### Storage + +Persist articles through EntityStore. Add four tables to H2, MySQL and PostgreSQL schemas and +upgrade scripts; use the existing owner and audit storage. + +| Table | Fields beyond common row metadata | Unique key | Other index | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------- | +| `kb_article_meta` | `article_id`, `metalake_id`, `article_name`, `status`, `live_version`, `article_comment`, `synonyms`, `source_reference`, `properties` | `(metalake_id, article_name, deleted_at)` | Primary key: `article_id` | +| `kb_article_version_info` | `id`, `metalake_id`, `article_id`, `version`, `title`, `body_format`, `body_content`, `domains`, `bindings`, `version_status` | `(article_id, version, deleted_at)` | `(metalake_id)` | +| `kb_article_relation_meta` | `id`, `article_id`, `target_id`, `target_type` | `(article_id, target_id, target_type, deleted_at)` | `(target_id, target_type)` | +| `kb_article_domain_rel` | `id`, `article_id`, `domain_id` | `(article_id, domain_id, deleted_at)` | `(domain_id, deleted_at, article_id)` | + +- Follow `tag_meta`, `tag_relation_meta` and `semantic_model_version_info`: numeric IDs, + `audit_info`, `deleted_at`, and `utf8mb4_bin` for MySQL. The article ID is an entity ID; the + other tables have an auto-increment primary key `id`. Relation key columns are non-NULL. +- Article, binding and Domain-relation rows have the usual `current_version` and `last_version` + store columns. Version rows are locked through the article row. These store revisions are + distinct from the article content-version number. +- Use `VARCHAR(128)` for the name, `VARCHAR(512)` for the title, `VARCHAR(256)` for the comment, + `VARCHAR(1024)` for the source reference, `VARCHAR(32)` for status and format, and `VARCHAR(64)` + for target type. The body, properties, bindings and audit JSON use MySQL `MEDIUMTEXT`; + synonyms and Domain snapshots use `TEXT`. Other databases use their native equivalents. +- `domains` is a JSON array of stable Domain IDs. `bindings` is a JSON array of target type and + stable target ID. These snapshots are authoritative; relation tables are projections used by + filters and reverse lookups. There are no database foreign keys; services validate and fence + endpoints in the transaction. +- `live_version` points to the effective snapshot. All creates set it; all content versions have + `version_status=APPROVED`, even when the article's own status is `DRAFT`. The column follows the + `semantic_model_version_info` convention and is reserved for extensions; this delivery never + writes another value. The private `live_version` column may be nullable for extensions, but this + implementation never writes a null live pointer. +- Add the tables to `schema-2.0.0-*.sql` and `upgrade-1.3.0-to-2.0.0-*.sql` while 2.0.0 is + unreleased. If it is released before implementation lands, use the next version's scripts. + Table creation uses `IF NOT EXISTS`; that does not make the whole upgrade script re-runnable. +- Snapshot JSON is private storage, not a client contract. Compatible additions are optional + with documented defaults for older rows. An unrelated edit preserves unknown fields. Reject + an unsupported structure before changing data. An incompatible change needs an explicit + migration; no `schema_version` field is introduced in advance. + +### Status and versions + +| Article status | Ordinary reads | Reverse lookup | MCP | +| -------------- | ------------------------------------ | ---------------------------------- | -------- | +| `DRAFT` | Current owner with CREATE, or MANAGE | Excluded | Excluded | +| `APPROVED` | Effective VIEW | Included | Included | +| `DEPRECATED` | Effective VIEW | Only with `includeDeprecated=true` | Excluded | + +New articles default to `APPROVED`. Create may explicitly set any of the three statuses, and +`updateStatus` may set any of them without transition rules or lifecycle endpoints. Setting a +status creates no content version. Leaving `DEPRECATED` rechecks title uniqueness; an article +may be edited or deleted in any status with the normal privileges. + +The title, body, Domains and bindings are versioned together, following Semantic Model storage. +Owner, article status, comment, synonyms, source reference and properties change directly and +are audited, without a content snapshot. Properties must not be used to hide content that +belongs in the versioned fields. + +- Create writes version 1 with its initial Domains and bindings. +- An effective change to one or more versioned fields writes exactly one new snapshot, using + the highest version number plus one. It advances the live pointer and rewrites effective + bindings and Domain memberships in the same transaction. Any failure rolls back all of them. +- Copy the complete stored snapshot before applying changes, including relations the editor + cannot see. Filter only response data. A body-only edit must not remove hidden bindings or + Domain memberships. +- Public loads, summaries and bindings read the current effective version only. Older snapshots + remain internal. + Stored target and Domain IDs remain unchanged after deletion for later historical resolution. +- Keep every version until article deletion. `JDBCBackend.deleteOldVersionData` returns `0` for + this entity type, so the normal old-version sweep does not remove history. Article deletion + soft-deletes all its versions atomically; normal deletion garbage collection still applies. + +### Domain membership + +An article belongs to zero or more Domains, using explicit `kb_article_domain_rel` rows. +Membership is part of the content snapshot and changes through Article operations. It is +independent of backing-tag assignments, so tag changes cannot silently move an article. + +- Requests and responses use Domain names. Resolve names to stable IDs on write and return the + current names on read. A rename changes neither membership nor history identity. An unknown + Domain returns `404`. +- Follow the Domain model's two levels and shared metalake namespace. A Domain filter includes + the Domain and its subdomains. Domain membership is optional at creation and may change later. +- Article definition privileges remain metalake-scoped. Each added or removed Domain also + requires its ordinary access check, including `USE_DOMAIN` and draft-Domain visibility. + Filter every returned Domain list by that check, without names or counts for hidden Domains. +- `updateDomains` replaces the complete set. Compute additions and removals from the full stored + set and check each changed Domain. An unrelated edit preserves every membership. A caller + cannot silently remove an unseen membership by submitting only the filtered response. +- Domain deletion must check effective Article and Term memberships under the Domain lock. Any + remaining membership returns `409 NonEmptyDomainException`, without member names or counts. + `MANAGE_DOMAIN` alone cannot detach articles. An authorized Article editor first removes + membership through the Article API. Historical snapshots alone do not prevent Domain deletion. +- This extends the current Domain drop path, which already checks its own lifecycle constraints. + Changing or deleting a backing tag does not change Article membership. + +### Bindings and target lifecycle + +| Binding | Supported targets | +| --------------- | --------------------------------------------------------------------------------- | +| Article → Term | `GLOSSARY_TERM`, by stable numeric ID | +| Article → Asset | Catalog, Schema, Table, View, table Column, Fileset, Topic, Model, Semantic Model | + +An article may have no bindings. Bindings point to object identity, not to one target version. +Article→Term, Article→Asset and Term→Asset are independent. There is no inheritance from a table +to columns or from a term to its assets. A binding may cross catalogs or Domains. + +- Adding a binding requires Article edit permission and read access to the target. A missing or + invisible target fails the complete request; no partial binding changes are stored. +- A new Term binding requires the Term to be `APPROVED`; otherwise return `409`. Check target + visibility before returning details of that conflict. Existing bindings remain if a Term + becomes `DRAFT` or `DEPRECATED`; returned Term details carry its current status. +- Add and remove sets apply atomically. Adding an existing binding or removing an absent one + is a no-op and creates no version. A mixed request creates one version if its final set differs. +- Responses omit unreadable targets and any hidden-target count. Stored snapshots remain + complete. A binding never grants or blocks access to the target. +- Rename preserves a binding when the target's registered ID is preserved. Deleting a target + removes effective binding rows, keeps the article and leaves historical snapshots intact. + Each affected surviving article gets one store-revision increment and an audit record per + cleanup transaction, without a new content version. Rebuilding effective relations excludes + deleted targets rather than resurrecting them from snapshots. +- Table-column bindings use the registered column ID and the containing table's authorization + and endpoint fencing. Reuse the platform's column reconciliation and cleanup paths, including + load-triggered reconciliation. Concurrent external column rename has the inherited identity + limitation tracked by [#14279](https://github.com/apache/gravitino/issues/14279); this design + does not promise unconditional preservation when the platform replaces the column ID. +- Store cleanup is atomic with local registered-object changes. External catalog DDL is outside + that database transaction. Keep existing external DDL responses, record cleanup failures, and + use the platform's reconciliation/recovery path; a local rollback cannot undo external DDL. +- Links written in the body are ordinary text URLs, independent of bindings. Renaming a target + updates resolved binding names, but does not rewrite URLs in old or current article text. + +Deleting an article soft-deletes its identity, versions, bindings and Domain memberships in one +transaction. It never deletes targets. Dropping a metalake removes articles through the normal +parent lifecycle. Removing a user does not delete their articles; MANAGE can reassign ownership. + +### Access control + +Use the definition privileges on the metalake: `VIEW_DEFINITION`, `CREATE_DEFINITION` +and `MANAGE_DEFINITIONS`, abbreviated VIEW, CREATE and MANAGE in this section. +`MANAGE_DEFINITIONS` implies CREATE, and CREATE implies VIEW. Expand those implications and +apply explicit Deny rules to every required capability. Every operation requires effective VIEW; +ownership never bypasses Deny. + +| Operation | Required definition privilege | +| --------------------------------- | -------------------------------------------------------------- | +| List and load | VIEW; drafts also require current owner with CREATE, or MANAGE | +| Create | CREATE | +| Edit, set status, change bindings | Current owner with CREATE, or MANAGE | +| Change Domain membership | Current owner with CREATE, or MANAGE; Domain checks also apply | +| Delete in any status | Current owner with CREATE, or MANAGE | +| Reverse lookup | VIEW on the article and read access to the lookup root | + +CREATE alone cannot read another owner's draft, and ownership alone cannot replace CREATE. +Use the same rules on direct reads, lists, nested results, reverse lookups and MCP. +Definition grants on a single article are rejected. Administrators explicitly grant VIEW to +reader roles; there is no implicit `PUBLIC` or anonymous read grant. + +Resolve current article identity, owner and the authenticated principal's group IDs from the +store/principal for each owner-based decision. Do not use shared name-to-ID or owner caches for +that decision. Recheck ownership in write transactions and apply the same rule to generic Owner +transfer authorization. After a committed transfer, new requests on another server cannot use +the former owner's cached rights. Already-authorized in-flight requests are outside that +guarantee. Group membership follows the platform's authenticated-principal freshness rules; +Gravitino does not add a user-to-group membership store. + +Lists, search and counts use the same visibility predicate. A hidden article must not appear in +`total`, nested summaries or candidate lists. Reading an article does not authorize its targets; +loading a reverse lookup first checks the Term or object root, then filters the articles. + +### Locking and conditional editing + +Every effective write advances the article row's `current_version` using the store's +compare-and-set (CAS) check. A concurrent store revision returns `409` with +`OPTIMISTIC_LOCK_CONFLICT_CODE`. A no-op advances neither the store revision nor the content +version, and emits no content-change success event. Validate identity, authorization and any +condition before detecting a no-op. Compare persisted values, treating memberships and bindings +as sets; updates that cancel out are a no-op. + +Plan the complete lock set before acquiring locks. Follow the existing endpoint fences and a +single order: metalake, Domains in ID order, bound target endpoint chains in their established +order, then Article rows in ID order. Revalidate the resolved identities and relation sets under +the locks. If planning discovered a stale set, restart lock planning with a bounded retry; +never retry a failed CAS as an unconditional overwrite. + +- Create, title changes and status changes away from `DEPRECATED` claim a title under an + exclusive metalake-row lock (`SELECT ... FOR UPDATE` on `metalake_meta`). Take its final lock + mode initially rather than upgrading a shared metalake fence. This serializes title claims + within a metalake, including two different article IDs claiming the same title. +- A membership write holds a shared Domain-row lock until commit. Domain drop takes its + exclusive lock, then checks the latest committed memberships, without taking Article locks + while holding that exclusive Domain lock. Either the membership commits and drop fails, or + drop commits and the membership write fails; neither leaves a dangling membership. +- Target removal fences the endpoint against new bindings before collecting affected articles, + then locks Article rows in ID order. Cleanup and ordinary edits cannot lose revision increments. +- Content snapshots, the live pointer and effective relations commit in one transaction. Reads + use a consistent store snapshot for root status, authorization and payload; they do not need + write locks. A read that began before a concurrent commit may return the earlier complete state. + +REST also accepts an optional `If-Match` header, using the last load or write's strong `ETag`. +The token is opaque and unambiguously includes stable metalake ID, article ID and store revision. +It covers all article writes, not just content versions. Names and content-version numbers do +not distinguish a deleted article from a same-name replacement with the same numeric revision. + +| Request | Concurrency headers | +| ------------------------- | -------------------------------------- | +| Create or load an article | Response `ETag` | +| Alter or change bindings | Request `If-Match`; response `ETag` | +| Delete | Request `If-Match`; no response `ETag` | +| Lists and reverse lookups | No `ETag`; load before editing | + +Under the article lock, resolve and authorize the current identity before comparing the token, +and compare before writes or no-op detection. Missing or hidden roots return `404` first; a +malformed token is `400`, and a stale identity or revision is `412`. A failed check changes no +data, revision or success event. Tokens are concurrency guards, not credentials. + +An omitted header or `If-Match: *` skips only token comparison. CAS still applies and can return +`409`; there is no automatic retry. A successful write returns the new token, including the +unchanged token for a valid no-op. Article REST resources and Java/Python clients use the same +conditional-edit contract. + +### REST API + +All paths below start with `/api/metalakes/{metalake}`. Domain is a field or filter, not a path +segment. Successful calls use HTTP `200` and the normal Gravitino response envelope with +`code: 0`, as the Tag APIs do. The table names the other response fields; errors use the usual +error envelope. Article and binding writes also carry the concurrency headers above. + +Article names are stored and returned as Unicode strings, not URL-encoded strings. In every +single-Article route, clients UTF-8 percent-encode the name as one path segment; server routing +decodes it once. Java and Python clients must preserve Chinese and mixed-language names through +create, load, alter, delete and binding calls. Percent-encoded length is not the name length. + +| Method and path | Request | Response fields | Behavior | +| ---------------------------------------- | ----------------------------------------------------------- | ------------------------------ | -------------------------------------------------- | +| `POST /kb-articles` | Create fields below | `article` | Create identity, owner, version 1 and relations | +| `GET /kb-articles` | List filters below | `articles`, `total`, `hasMore` | Read visible summaries only | +| `GET /kb-articles/{article}` | Binding `limit`, `offset` | `article` | Read current content with bounded binding previews | +| `PUT /kb-articles/{article}` | `updates` array | `article` | Apply all changes atomically | +| `DELETE /kb-articles/{article}` | No body | Existing `DropResponse` | Soft-delete article and related rows atomically | +| `GET /kb-articles/{article}/terms` | `limit`, `offset` | `terms`, `hasMore` | Page visible current Term bindings | +| `POST /kb-articles/{article}/terms` | `termsToAdd`, `termsToRemove`: name arrays | `terms`, `hasMore` | Change bindings; return the first bounded page | +| `GET /kb-articles/{article}/objects` | `limit`, `offset` | `objects`, `hasMore` | Page visible current asset bindings | +| `POST /kb-articles/{article}/objects` | `objectsToAdd`, `objectsToRemove`: identifiers | `objects`, `hasMore` | Change bindings; return the first bounded page | +| `GET /glossary/terms/{term}/kb-articles` | `includeDeprecated`, `limit`, `offset` | `articles`, `total`, `hasMore` | Authorize Term root, then page summaries | +| `GET /objects/{type}/kb-articles` | `namespace`, `name`, `includeDeprecated`, `limit`, `offset` | `articles`, `total`, `hasMore` | Authorize asset root, then page summaries | + +The two reverse lookups return only `APPROVED` articles unless `includeDeprecated=true`, which +also includes `DEPRECATED`. They never return drafts. Each returned article, Term, asset and +Domain passes its own visibility check. Reverse lookup does not traverse Term→Asset bindings. + +#### Pagination and binding previews + +Use ordinary `limit` and `offset`, without a cursor token. List, reverse-lookup and binding-list +reads default to `limit=100`, `offset=0`; accept limits from 1 through 10,000 and nonnegative +offsets, rejecting invalid values with `400`. Order bindings by stable `(target_id, target_type)`. +Article summaries retain the title/name ordering described below. Apply root authorization, +status filters and target visibility before offset and limit. A page contains only readable +results, without hidden-object counts. `hasMore` means another readable result exists; clients +continue with the same filters, adding the returned item count to offset. Pages describe unchanged +data; concurrent edits may move results between pages, as with the Article list. + +Binding pages return `terms` or `objects` plus `hasMore`, with no total. Term entries contain +only name and current status, not full definitions or nested Term bindings; object entries use +`ArticleObjectIdentifier`. Query the relation tables for the bounded page rather than loading +the complete snapshot or all target DTOs and then truncating them. Batch target resolution for +the selected page. Article list/reverse pages retain their authorized `total` and add `hasMore`. + +An `ArticleSummary` embeds at most 20 readable Term entries and `termsHasMore`. A full Article +response embeds Term and object previews with `termsHasMore` and `objectsHasMore`. A load accepts +`limit` and `offset` for both binding sets, defaulting to 20 and 0, with the same maximum of 10,000. +These parameters page bindings, not the body. Clients can instead page each set independently +through the dedicated binding endpoints. Create and alter return the default previews; binding +mutations return the first 100 readable entries of the updated set and `hasMore`, plus the +Article ETag. Pagination never changes the complete stored snapshot or the atomic mutation. + +#### Create and alter + +| Create field | Type | Required | Description | +| ----------------- | ------------------------------- | -------- | --------------------------------------------- | +| `name` | string | No | Immutable name; generated when omitted | +| `title` | string | Yes | Unique nondeprecated display title | +| `body` | `{format, content}` | Yes | Text body, sanitized and byte-limited | +| `status` | string enum | No | Defaults to `APPROVED` | +| `domains` | string array | No | Domain names; defaults to an empty set | +| `terms` | string array | No | Approved Term names; defaults to an empty set | +| `objects` | `ArticleObjectIdentifier` array | No | Asset identifiers; defaults to an empty set | +| `comment` | string | No | Short description | +| `synonyms` | string array | No | Other words for the topic; defaults to empty | +| `sourceReference` | string | No | Source text, without URL fetching | +| `properties` | string map | No | Unversioned properties; defaults to empty | + +Example create request: + +```json +{ + "name": "revenue-calculation-guide", + "title": "Revenue Calculation Guide", + "body": { + "format": "MARKDOWN", + "content": "# Revenue\n\nRevenue excludes refunds and taxes." + }, + "domains": ["Finance"], + "terms": ["net-revenue"], + "objects": [ + { "type": "TABLE", "namespace": ["iceberg", "sales"], "name": "orders" } + ] +} +``` + +Create, load and alter return `{ "code": 0, "article": ... }`, where `article` has the typed +fields in [Data model](#data-model), plus the bounded binding previews described above. Bound +Term entries contain name and current status; object entries use `ArticleObjectIdentifier`. +Owner information is resolved through the existing Owner model, not stored in the version snapshot. `audit_info` +follows the standard AuditInfo DTO. These responses expose current content only. + +Alter follows the existing `updates` convention. Supported changes are `updateTitle`, +`updateBody`, `updateDomains`, `updateStatus`, `updateComment`, `updateSynonyms`, +`updateSourceReference`, `setProperty` and `removeProperty`. Domain and synonym updates replace +their complete sets. Rename is unsupported. A request changing several versioned fields +creates one version, and an unversioned-only change creates none. + +```json +{ + "updates": [ + { "@type": "updateTitle", "newTitle": "Revenue Calculation and Refunds" }, + { "@type": "updateDomains", "newDomains": ["Finance", "Tax"] } + ] +} +``` + +#### Structured object identifiers + +`ArticleObjectIdentifier` contains `type`, an ordered `namespace` array and `name`. Each component +is an exact string. Resolve them directly to stable IDs; do not concatenate and split a dotted +name through `MetadataObjects.parse`. + +| Type | Namespace | Name | +| -------------------------------------------------------------- | -------------------------- | ----------------- | +| `CATALOG` | `[]` | Catalog name | +| `SCHEMA` | `[catalog]` | Schema name | +| `TABLE`, `VIEW`, `FILESET`, `TOPIC`, `MODEL`, `SEMANTIC_MODEL` | `[catalog, schema]` | Object name | +| `COLUMN` | `[catalog, schema, table]` | Table column name | + +For example, a column whose literal name is `total.amount` stays one name through create, +binding changes, responses, clients and MCP: + +```json +{ + "objectsToAdd": [ + { "type": "COLUMN", "namespace": ["iceberg", "sales", "orders"], "name": "total.amount" } + ], + "objectsToRemove": [] +} +``` + +The object reverse lookup repeats `namespace` in component order and provides `name` separately: + +```http +GET /api/metalakes/demo/objects/column/kb-articles?namespace=iceberg&namespace=sales&namespace=orders&name=total.amount +``` + +Omit `namespace` for a catalog. Encode each path or query value normally; never split a decoded +component or name on `.`. A missing name, unsupported type or invalid component count is `400`. +View columns and individual metrics are outside the supported set. + +#### Lists and search + +`GET /kb-articles` accepts `q`, `domain`, `status`, `owner`, `limit` and `offset`. + +- `q` matches any substring of the current title, a synonym or the current body, ignoring case. + Search the stored body, including markup: a word in an HTML attribute can match. There is no + relevance ranking or conversion to plain text. +- Use bound parameters with `LOWER(value) LIKE LOWER(?) ESCAPE '!'` on all three databases, + following `SchemaPOStorageOps.escapeLikeMetacharacters`. Escape the input in order: `!` to + `!!`, `%` to `!%`, then `_` to `!_`; wrap the result in `%` for substring matching. Backslash + remains a literal character in the bound parameter. Do not rely on database collation or + default backslash escaping. A full-text index may replace this implementation without an + API change. +- `domain` resolves the visible Domain and includes its subdomains. It combines with all other Review Comment: Could the parent filter explicitly expand to only the subdomains visible to the caller, as specified in the [Domain design](https://github.com/apache/gravitino/blob/29ac70856ab891b6c56f2013253369a0a06b2f37/design-docs/domain-design.md#L100)? For example, a reader can see Finance and an approved article, but the article belongs only to Tax, a draft child the reader cannot see. Filtering by Finance should exclude that article from both the page and total. Hiding Tax in the returned summary alone still lets the reader infer membership from the filter result. ########## design-docs/gravitino-kb-article-design.md: ########## @@ -0,0 +1,1055 @@ +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> + +# Design: Knowledge Base Articles + +## Background + +Gravitino manages data assets and their metadata. A [Glossary Term](glossary-design.md) gives a +short definition of a business concept. Teams also need longer explanations: how revenue is +calculated, why it differs from GMV, and which tables feed it. Today these explanations live in +wikis and documents, apart from the terms and data they describe. Users and agents cannot find +them through the same metadata APIs or follow managed links from an explanation to its data. + +A Knowledge Base (KB) Article is a text document managed under a metalake. It has a title, a +Markdown or HTML body, an owner and a status. It can belong to several +[Domains](domain-design.md) and link to terms and data assets across catalogs. Users and agents +can search for an article, read it, and follow its bindings under their existing privileges. + +--- + +## Goals + +1. **Article object**: add `KnowledgeBaseArticle` as metalake-scoped metadata with an immutable + name and stable numeric ID. A title can change without breaking references to the article. +2. **Content and version storage**: store Markdown or HTML. Keep an internal snapshot of the + title, body, Domains and bindings for each effective content change, and expose the current + content only. Historical version reads are deferred. +3. **Bindings**: link an article to terms and metadata objects. Support reverse lookup from + either target. A binding never grants access to data. +4. **Domains**: organize and filter articles by zero or more Domains. Membership does not change + article privileges in this design. +5. **Status and privileges**: support `DRAFT`, `APPROVED` and `DEPRECATED`, with immediate edits + and definition privileges granted on the metalake. `APPROVED` means available to agents; + it does not record a reviewer's decision. +6. **Discovery**: search titles, synonyms and bodies, with Domain, status and owner filters. + Read-only MCP tools return readable `APPROVED` articles. +7. **APIs and governance**: provide REST, Java and Python APIs, ownership, events and audit. + Concurrent writes must not leave content, snapshots and effective relations out of sync. + +--- + +## Non-Goals + +1. **Review and publication approval**: content and status changes take effect immediately; + approval workflows and review APIs are outside the scope. +2. **Domain-scoped or article-scoped definition grants**: definition privileges are granted on + the metalake. Domains group articles; they do not authorize access to an article. +3. **Web UI and agent writes**: the design provides REST APIs and read-only MCP tools. + A web editor and agent write operations are outside the scope. +4. **File ingestion, attachments and image upload**: the body is text. It may contain ordinary + external links, but Gravitino does not host files, extract text or fetch linked content. +5. **Ranked, fuzzy or semantic search and RAG**: substring search is sufficient for this scope. + There is no embedding index or answer-generation service. +6. **Inferred or transitive bindings**: words and links in the body do not create bindings. + Binding an article to a term does not bind it to that term's assets; binding a table does not + bind its columns. +7. **Metric bindings and version pinning**: bind a Semantic Model as an object, not an individual + metric. A binding points to the target's identity and resolves its current state. +8. **Historical version reads, article hierarchy, comparison and rollback**: public APIs and + Java/Python clients read current content only. Historical reads, comparison and rollback + are deferred. Articles form a flat list without parent-child relationships. + +--- + +## Scope and Dependencies + +The design covers the following capabilities. The task references link each capability to its +implementation work in [Task Breakdown](#task-breakdown). + +| Capability | Scope | Tasks | +| ----------------------------------------------- | ------------------------------------------------- | ------- | +| Article API, entity and four storage tables | New first-class metadata and retained snapshots | T1–T3 | +| Definition privileges and ownership | Metalake grants; current-owner checks | T4 | +| Domain membership | Explicit Article relations; filter and drop guard | T5 | +| Term and asset bindings | Stable IDs, reverse lookup and lifecycle cleanup | T6 | +| REST, conditional editing and search | DTOs, errors, summaries and OpenAPI | T7–T8 | +| Events and audit | Existing listener and audit mechanisms | T9 | +| Java, Python and read-only MCP | Same contracts and visibility as REST | T10–T12 | +| Integration, upgrade, performance and user docs | Release checks and documented operating limits | T13–T14 | + +Domain integration requires stable Domain IDs, hierarchy lookup, access checks and deletion +fencing. Term bindings require stable Term IDs, current-status lookup and deletion hooks. + +The four-table model stores a snapshot for each effective content change and uses `live_version` +to select current content. Retaining snapshots preserves the exact title, body, Domains and +bindings together, at the cost of additional storage and transactional writes. + +Public APIs and Java/Python clients expose current content only. Historical version lists and +individual-version reads can later use the retained snapshots without changing these four +tables or migrating current content. Historical reads must apply the article's current read +check and resolve deleted target IDs without attaching them to same-name replacements. + +--- + +## Usage Scenario + +1. An admin grants an analyst `CREATE_DEFINITION` and a reader `VIEW_DEFINITION` on a metalake. + The analyst also has access to Domain `Finance`, term `net-revenue` and table + `iceberg.sales.orders`. +2. The analyst creates "Revenue Calculation Guide", with a Markdown body, Domain `Finance`, + the term and the table. The server generates a name if none is supplied. The analyst becomes + the owner; the default status is `APPROVED`, and version 1 takes effect immediately. +3. The reader searches for a word from the body and loads the article. Its bindings lead to + the current term and table; each target still requires its own read privilege. +4. The analyst loads the article and saves a new body and another binding with its `ETag`. + One new version becomes effective atomically. The response shows the current version; + the previous snapshot remains in storage. +5. An agent acting as the reader calls `search_kb_articles`, then `get_kb_article`. It receives + the stored body with its format and only the bound objects it can read. +6. To prepare content privately, the analyst can create or set the article to `DRAFT`. Only its + owner with CREATE, or a caller with MANAGE, can read it. Setting it to `APPROVED` makes it + available again without review. +7. When the explanation is outdated, the owner sets it to `DEPRECATED`. It remains readable, + but agents stop returning it. The owner with CREATE or an admin with MANAGE can delete it + directly in any status. Deleting it removes neither the term nor the table. + +--- + +## Design + +### Data model + +`KnowledgeBaseArticle` is directly under a metalake, alongside Tag, Policy and Domain. It is not +under a catalog or schema, because an article can explain data from several catalogs. + +```text +KnowledgeBaseArticle { + name, title, body: { format: MARKDOWN | HTML, content }, + status: DRAFT | APPROVED | DEPRECATED, domains[], comment?, synonyms[], + sourceReference?, properties, version, audit_info +} +ArticleSnapshot { articleId, version, title, body, domainIds[], bindings[], audit_info } +ArticleBinding { articleId, targetType, targetId, audit_info } +ArticleDomain { articleId, domainId, audit_info } +``` + +`ArticleSnapshot` is the internal representation of a stored content version. The Article's +`version` identifies its current content snapshot; its ETag separately guards the store revision. + +- **Identity**: `metalake.articleName`. The name is immutable and unique in the metalake; the + internal numeric article ID is stable. Add `KNOWLEDGE_BASE_ARTICLE` to `MetadataObject.Type` + and `Entity.EntityType`, including the single-level object handling used by owner APIs. +- **Explicit name**: accept 1 to 128 Unicode code points, using letters, digits, combining marks, + `_` and `-`, with at least one letter or digit. Reject other characters with `400`, including + `/`, backslash, whitespace and control characters. Preserve the supplied spelling and case. +- **Generated name**: `name` is optional on create. Lower-case the title using `Locale.ROOT`, + preserve Unicode letters, digits and combining marks, and replace each run of other characters + with `-`. Trim leading/trailing `-` and cut to 128 Unicode code points without splitting a + character. Chinese text is preserved: `收入计算说明` becomes `收入计算说明`, and + `收入 Calculation Guide` becomes `收入-calculation-guide`. Do not transliterate to Pinyin. + Use `article-<shortId>` only when the result contains no Unicode letter or digit, such as an + emoji-only or punctuation-only title. The suffix is 8 random lower-case alphanumeric + characters, regenerated on collision. A derived-name collision adds `-2`, `-3`, and so on, + cutting the base further to keep the whole name within 128 code points. A duplicate explicit + name is `409`. Changing the title later never changes the generated name. +- **Title**: required, nonblank after trimming, at most 512 characters. Compare titles after + trimming and ignoring case, independent of database collation. Among articles that are not + `DEPRECATED`, titles are unique within the metalake. Deprecation releases the title; leaving + `DEPRECATED` checks it again. A conflict is `409`. Different titles can generate the same + name, which is why generated names also need collision suffixes. +- **Owner**: the creator becomes the owner through the existing Owner APIs. Owners may be users + or groups. Persist the relation in the existing `owner_meta` table: `metadata_object_id` is + the stable article ID, `metadata_object_type` is `KNOWLEDGE_BASE_ARTICLE`, and `metalake_id` + identifies its metalake. `owner_id` references the user or group ID and `owner_type` is `USER` + or `GROUP`; owner names are resolved from `user_meta` or `group_meta`. Integrate the Article + type with `OwnerMetaService` and the existing Owner APIs. No owner column is added to the + article tables, and ownership is not part of a content snapshot. +- **Other fields**: `comment` is at most 256 characters. `synonyms` are trimmed, at most 128 + characters each and at most 20 per article; remove duplicates ignoring case. They need not be + unique across articles. `sourceReference` is optional free text of at most 1024 characters, + such as a wiki URL. It is not validated as a URL, followed or fetched. Render it as text unless + a client separately validates it as a safe link. `properties` is a string map. + +#### Body and input validation + +`body.format` is `MARKDOWN` or `HTML`, stored with each version. The server sanitizes every body +on write, including raw HTML embedded in Markdown. Both formats use the same HTML allowlist: +remove scripts, active elements, event-handler attributes and unsafe URLs, including +`javascript:` and `data:` URLs and encoded variants. Preserve ordinary formatting and the safe +parts of the original content. Clients also sanitize HTML when rendering. + +Limit `body.content` by UTF-8 byte length both before and after sanitization. The configurable +limit defaults to 1 MiB (1,048,576 bytes); allowed settings are 1 through 16,777,215 bytes, the +MySQL `MEDIUMTEXT` capacity. An invalid setting prevents startup. An oversized request returns +`400`, without truncation or a stored change. Use the same bounds for create and alter. + +#### Storage + +Persist articles through EntityStore. Add four tables to H2, MySQL and PostgreSQL schemas and +upgrade scripts; use the existing owner and audit storage. + +| Table | Fields beyond common row metadata | Unique key | Other index | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------- | +| `kb_article_meta` | `article_id`, `metalake_id`, `article_name`, `status`, `live_version`, `article_comment`, `synonyms`, `source_reference`, `properties` | `(metalake_id, article_name, deleted_at)` | Primary key: `article_id` | +| `kb_article_version_info` | `id`, `metalake_id`, `article_id`, `version`, `title`, `body_format`, `body_content`, `domains`, `bindings`, `version_status` | `(article_id, version, deleted_at)` | `(metalake_id)` | +| `kb_article_relation_meta` | `id`, `article_id`, `target_id`, `target_type` | `(article_id, target_id, target_type, deleted_at)` | `(target_id, target_type)` | +| `kb_article_domain_rel` | `id`, `article_id`, `domain_id` | `(article_id, domain_id, deleted_at)` | `(domain_id, deleted_at, article_id)` | + +- Follow `tag_meta`, `tag_relation_meta` and `semantic_model_version_info`: numeric IDs, + `audit_info`, `deleted_at`, and `utf8mb4_bin` for MySQL. The article ID is an entity ID; the + other tables have an auto-increment primary key `id`. Relation key columns are non-NULL. +- Article, binding and Domain-relation rows have the usual `current_version` and `last_version` + store columns. Version rows are locked through the article row. These store revisions are + distinct from the article content-version number. +- Use `VARCHAR(128)` for the name, `VARCHAR(512)` for the title, `VARCHAR(256)` for the comment, + `VARCHAR(1024)` for the source reference, `VARCHAR(32)` for status and format, and `VARCHAR(64)` + for target type. The body, properties, bindings and audit JSON use MySQL `MEDIUMTEXT`; + synonyms and Domain snapshots use `TEXT`. Other databases use their native equivalents. +- `domains` is a JSON array of stable Domain IDs. `bindings` is a JSON array of target type and + stable target ID. These snapshots are authoritative; relation tables are projections used by + filters and reverse lookups. There are no database foreign keys; services validate and fence + endpoints in the transaction. +- `live_version` points to the effective snapshot. All creates set it; all content versions have + `version_status=APPROVED`, even when the article's own status is `DRAFT`. The column follows the + `semantic_model_version_info` convention and is reserved for extensions; this delivery never + writes another value. The private `live_version` column may be nullable for extensions, but this + implementation never writes a null live pointer. +- Add the tables to `schema-2.0.0-*.sql` and `upgrade-1.3.0-to-2.0.0-*.sql` while 2.0.0 is + unreleased. If it is released before implementation lands, use the next version's scripts. + Table creation uses `IF NOT EXISTS`; that does not make the whole upgrade script re-runnable. +- Snapshot JSON is private storage, not a client contract. Compatible additions are optional + with documented defaults for older rows. An unrelated edit preserves unknown fields. Reject + an unsupported structure before changing data. An incompatible change needs an explicit + migration; no `schema_version` field is introduced in advance. + +### Status and versions + +| Article status | Ordinary reads | Reverse lookup | MCP | +| -------------- | ------------------------------------ | ---------------------------------- | -------- | +| `DRAFT` | Current owner with CREATE, or MANAGE | Excluded | Excluded | +| `APPROVED` | Effective VIEW | Included | Included | +| `DEPRECATED` | Effective VIEW | Only with `includeDeprecated=true` | Excluded | + +New articles default to `APPROVED`. Create may explicitly set any of the three statuses, and +`updateStatus` may set any of them without transition rules or lifecycle endpoints. Setting a +status creates no content version. Leaving `DEPRECATED` rechecks title uniqueness; an article +may be edited or deleted in any status with the normal privileges. + +The title, body, Domains and bindings are versioned together, following Semantic Model storage. +Owner, article status, comment, synonyms, source reference and properties change directly and +are audited, without a content snapshot. Properties must not be used to hide content that +belongs in the versioned fields. + +- Create writes version 1 with its initial Domains and bindings. +- An effective change to one or more versioned fields writes exactly one new snapshot, using + the highest version number plus one. It advances the live pointer and rewrites effective + bindings and Domain memberships in the same transaction. Any failure rolls back all of them. +- Copy the complete stored snapshot before applying changes, including relations the editor + cannot see. Filter only response data. A body-only edit must not remove hidden bindings or + Domain memberships. +- Public loads, summaries and bindings read the current effective version only. Older snapshots + remain internal. + Stored target and Domain IDs remain unchanged after deletion for later historical resolution. +- Keep every version until article deletion. `JDBCBackend.deleteOldVersionData` returns `0` for + this entity type, so the normal old-version sweep does not remove history. Article deletion + soft-deletes all its versions atomically; normal deletion garbage collection still applies. + +### Domain membership + +An article belongs to zero or more Domains, using explicit `kb_article_domain_rel` rows. +Membership is part of the content snapshot and changes through Article operations. It is +independent of backing-tag assignments, so tag changes cannot silently move an article. + +- Requests and responses use Domain names. Resolve names to stable IDs on write and return the + current names on read. A rename changes neither membership nor history identity. An unknown + Domain returns `404`. +- Follow the Domain model's two levels and shared metalake namespace. A Domain filter includes + the Domain and its subdomains. Domain membership is optional at creation and may change later. +- Article definition privileges remain metalake-scoped. Each added or removed Domain also + requires its ordinary access check, including `USE_DOMAIN` and draft-Domain visibility. + Filter every returned Domain list by that check, without names or counts for hidden Domains. +- `updateDomains` replaces the complete set. Compute additions and removals from the full stored + set and check each changed Domain. An unrelated edit preserves every membership. A caller + cannot silently remove an unseen membership by submitting only the filtered response. +- Domain deletion must check effective Article and Term memberships under the Domain lock. Any + remaining membership returns `409 NonEmptyDomainException`, without member names or counts. + `MANAGE_DOMAIN` alone cannot detach articles. An authorized Article editor first removes + membership through the Article API. Historical snapshots alone do not prevent Domain deletion. +- This extends the current Domain drop path, which already checks its own lifecycle constraints. + Changing or deleting a backing tag does not change Article membership. + +### Bindings and target lifecycle + +| Binding | Supported targets | +| --------------- | --------------------------------------------------------------------------------- | +| Article → Term | `GLOSSARY_TERM`, by stable numeric ID | +| Article → Asset | Catalog, Schema, Table, View, table Column, Fileset, Topic, Model, Semantic Model | + +An article may have no bindings. Bindings point to object identity, not to one target version. +Article→Term, Article→Asset and Term→Asset are independent. There is no inheritance from a table +to columns or from a term to its assets. A binding may cross catalogs or Domains. + +- Adding a binding requires Article edit permission and read access to the target. A missing or + invisible target fails the complete request; no partial binding changes are stored. +- A new Term binding requires the Term to be `APPROVED`; otherwise return `409`. Check target + visibility before returning details of that conflict. Existing bindings remain if a Term + becomes `DRAFT` or `DEPRECATED`; returned Term details carry its current status. +- Add and remove sets apply atomically. Adding an existing binding or removing an absent one + is a no-op and creates no version. A mixed request creates one version if its final set differs. +- Responses omit unreadable targets and any hidden-target count. Stored snapshots remain + complete. A binding never grants or blocks access to the target. +- Rename preserves a binding when the target's registered ID is preserved. Deleting a target + removes effective binding rows, keeps the article and leaves historical snapshots intact. + Each affected surviving article gets one store-revision increment and an audit record per + cleanup transaction, without a new content version. Rebuilding effective relations excludes + deleted targets rather than resurrecting them from snapshots. +- Table-column bindings use the registered column ID and the containing table's authorization + and endpoint fencing. Reuse the platform's column reconciliation and cleanup paths, including + load-triggered reconciliation. Concurrent external column rename has the inherited identity + limitation tracked by [#14279](https://github.com/apache/gravitino/issues/14279); this design + does not promise unconditional preservation when the platform replaces the column ID. +- Store cleanup is atomic with local registered-object changes. External catalog DDL is outside + that database transaction. Keep existing external DDL responses, record cleanup failures, and + use the platform's reconciliation/recovery path; a local rollback cannot undo external DDL. +- Links written in the body are ordinary text URLs, independent of bindings. Renaming a target + updates resolved binding names, but does not rewrite URLs in old or current article text. + +Deleting an article soft-deletes its identity, versions, bindings and Domain memberships in one +transaction. It never deletes targets. Dropping a metalake removes articles through the normal +parent lifecycle. Removing a user does not delete their articles; MANAGE can reassign ownership. + +### Access control + +Use the definition privileges on the metalake: `VIEW_DEFINITION`, `CREATE_DEFINITION` +and `MANAGE_DEFINITIONS`, abbreviated VIEW, CREATE and MANAGE in this section. +`MANAGE_DEFINITIONS` implies CREATE, and CREATE implies VIEW. Expand those implications and +apply explicit Deny rules to every required capability. Every operation requires effective VIEW; +ownership never bypasses Deny. + +| Operation | Required definition privilege | +| --------------------------------- | -------------------------------------------------------------- | +| List and load | VIEW; drafts also require current owner with CREATE, or MANAGE | +| Create | CREATE | +| Edit, set status, change bindings | Current owner with CREATE, or MANAGE | +| Change Domain membership | Current owner with CREATE, or MANAGE; Domain checks also apply | +| Delete in any status | Current owner with CREATE, or MANAGE | +| Reverse lookup | VIEW on the article and read access to the lookup root | + +CREATE alone cannot read another owner's draft, and ownership alone cannot replace CREATE. +Use the same rules on direct reads, lists, nested results, reverse lookups and MCP. +Definition grants on a single article are rejected. Administrators explicitly grant VIEW to +reader roles; there is no implicit `PUBLIC` or anonymous read grant. + +Resolve current article identity, owner and the authenticated principal's group IDs from the +store/principal for each owner-based decision. Do not use shared name-to-ID or owner caches for +that decision. Recheck ownership in write transactions and apply the same rule to generic Owner +transfer authorization. After a committed transfer, new requests on another server cannot use +the former owner's cached rights. Already-authorized in-flight requests are outside that +guarantee. Group membership follows the platform's authenticated-principal freshness rules; +Gravitino does not add a user-to-group membership store. + +Lists, search and counts use the same visibility predicate. A hidden article must not appear in +`total`, nested summaries or candidate lists. Reading an article does not authorize its targets; +loading a reverse lookup first checks the Term or object root, then filters the articles. + +### Locking and conditional editing + +Every effective write advances the article row's `current_version` using the store's +compare-and-set (CAS) check. A concurrent store revision returns `409` with +`OPTIMISTIC_LOCK_CONFLICT_CODE`. A no-op advances neither the store revision nor the content +version, and emits no content-change success event. Validate identity, authorization and any +condition before detecting a no-op. Compare persisted values, treating memberships and bindings +as sets; updates that cancel out are a no-op. + +Plan the complete lock set before acquiring locks. Follow the existing endpoint fences and a +single order: metalake, Domains in ID order, bound target endpoint chains in their established +order, then Article rows in ID order. Revalidate the resolved identities and relation sets under +the locks. If planning discovered a stale set, restart lock planning with a bounded retry; +never retry a failed CAS as an unconditional overwrite. + +- Create, title changes and status changes away from `DEPRECATED` claim a title under an + exclusive metalake-row lock (`SELECT ... FOR UPDATE` on `metalake_meta`). Take its final lock + mode initially rather than upgrading a shared metalake fence. This serializes title claims + within a metalake, including two different article IDs claiming the same title. +- A membership write holds a shared Domain-row lock until commit. Domain drop takes its + exclusive lock, then checks the latest committed memberships, without taking Article locks + while holding that exclusive Domain lock. Either the membership commits and drop fails, or + drop commits and the membership write fails; neither leaves a dangling membership. +- Target removal fences the endpoint against new bindings before collecting affected articles, + then locks Article rows in ID order. Cleanup and ordinary edits cannot lose revision increments. +- Content snapshots, the live pointer and effective relations commit in one transaction. Reads + use a consistent store snapshot for root status, authorization and payload; they do not need + write locks. A read that began before a concurrent commit may return the earlier complete state. + +REST also accepts an optional `If-Match` header, using the last load or write's strong `ETag`. +The token is opaque and unambiguously includes stable metalake ID, article ID and store revision. Review Comment: What changes the strong ETag when a bound Term changes status? For the same reader and GET URI, changing a bound Term from APPROVED to DEPRECATED changes the status in the response preview while preserving the binding and the Article revision. A validator derived from the three listed inputs would stay the same across two different representations. Could we define a dedicated Article revision token for conditional edits, or specify how the strong ETag accounts for changes to the returned representation? Two GETs bracketing a Term status change would exercise this case. [RFC 9110 §8.8.1](https://www.rfc-editor.org/rfc/rfc9110.html#section-8.8.1) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
