Copilot commented on code in PR #15067:
URL: https://github.com/apache/gravitino/pull/15067#discussion_r4610950895


##########
design-docs/gravitino-kb-article-design.md:
##########
@@ -0,0 +1,988 @@
+<!--
+  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 history**: store Markdown or HTML. Keep a snapshot of the 
title, body, Domains
+   and bindings for each effective content change, and expose readable version 
history.
+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**: changes take effect immediately. This 
proposal defines
+   no proposal, reviewer, approval queue or review API.
+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**: clients use REST; MCP tools are read-only. An 
article editor is
+   outside this contribution.
+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. **Tags and policies on articles**: this proposal adds neither tag 
association nor policies
+   for articles. An article binding does not change a target's policies.
+6. **Ranked, fuzzy or semantic search and RAG**: substring search is 
sufficient for this scope.
+   There is no embedding index or answer-generation service.
+7. **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.
+8. **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.
+9. **Article hierarchy, comparison and rollback**: articles form a flat list. 
History reads
+   snapshots; it does not compare them or restore them as new content.
+
+---
+
+## Delivery Scope and Tracking
+
+This is a design contribution. Merging it delivers no runtime feature. The 
local task IDs
+`T1`–`T14` in [Task Breakdown](#task-breakdown) describe implementation PRs; 
they are not GitHub
+issue numbers and do not imply that issues have been filed.
+
+| 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 |
+
+The Domain APIs are present on `main`. Article membership and the 
nonempty-Domain drop guard
+still need integration work in T5. Term bindings depend on the stable IDs, 
status checks and
+deletion hooks described in the Glossary design; that document is not evidence 
that the runtime
+interfaces have shipped. Article storage, ordinary asset bindings and other 
independent work
+can proceed before the Term integration is ready.
+
+Article history is included from the start. This differs from Glossary Step 1, 
which has a
+revision number and audit but no content snapshots. The two objects share 
definition privileges
+and Domain conventions, not an identical storage or delivery plan.
+
+---
+
+## 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 history shows both 
snapshots.
+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
+}
+ArticleVersion { articleId, version, title, body, domainIds[], bindings[], 
status, audit_info }
+ArticleBinding { articleId, targetType, targetId, audit_info }

Review Comment:
   `ArticleVersion` includes a `status` field, but the versioning rules below 
say article status is unversioned, and `version_status=APPROVED` is stored for 
every content version even when the article is `DRAFT`. A version read 
therefore has no well-defined historical status despite the DTO/storage model 
implying one. Please remove that field from the version contract or define a 
separate, consistently persisted historical status and distinguish it from the 
storage-row status.



##########
design-docs/gravitino-kb-article-design.md:
##########
@@ -0,0 +1,988 @@
+<!--
+  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 history**: store Markdown or HTML. Keep a snapshot of the 
title, body, Domains
+   and bindings for each effective content change, and expose readable version 
history.
+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**: changes take effect immediately. This 
proposal defines
+   no proposal, reviewer, approval queue or review API.
+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**: clients use REST; MCP tools are read-only. An 
article editor is
+   outside this contribution.
+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. **Tags and policies on articles**: this proposal adds neither tag 
association nor policies
+   for articles. An article binding does not change a target's policies.
+6. **Ranked, fuzzy or semantic search and RAG**: substring search is 
sufficient for this scope.
+   There is no embedding index or answer-generation service.
+7. **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.
+8. **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.
+9. **Article hierarchy, comparison and rollback**: articles form a flat list. 
History reads
+   snapshots; it does not compare them or restore them as new content.
+
+---
+
+## Delivery Scope and Tracking
+
+This is a design contribution. Merging it delivers no runtime feature. The 
local task IDs
+`T1`–`T14` in [Task Breakdown](#task-breakdown) describe implementation PRs; 
they are not GitHub
+issue numbers and do not imply that issues have been filed.
+
+| 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 |
+
+The Domain APIs are present on `main`. Article membership and the 
nonempty-Domain drop guard
+still need integration work in T5. Term bindings depend on the stable IDs, 
status checks and
+deletion hooks described in the Glossary design; that document is not evidence 
that the runtime
+interfaces have shipped. Article storage, ordinary asset bindings and other 
independent work
+can proceed before the Term integration is ready.
+
+Article history is included from the start. This differs from Glossary Step 1, 
which has a
+revision number and audit but no content snapshots. The two objects share 
definition privileges
+and Domain conventions, not an identical storage or delivery plan.
+
+---
+
+## 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 history shows both 
snapshots.
+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
+}
+ArticleVersion { articleId, version, title, body, domainIds[], bindings[], 
status, audit_info }
+ArticleBinding { articleId, targetType, targetId, audit_info }
+ArticleDomain  { articleId, domainId, audit_info }
+```
+
+- **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.
+- **Generated name**: `name` is optional on create. Lower-case the title, 
replace runs of
+  non-ASCII letters and digits with `-`, trim the separators and cut to 128 
characters. If the
+  result is empty, use `article-<shortId>` with 8 random lower-case 
alphanumeric characters,
+  regenerating on collision. A derived-name collision adds `-2`, `-3`, and so 
on, cutting the
+  base further to keep the whole name within 128 characters. A duplicate 
explicit name is `409`.
+- **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; no owner column is added to the article table.
+- **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 private 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 is
+expected to appear in history.
+
+- 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.
+- History lists versions newest first, with version, title, version status and 
audit information,
+  without bodies. Reading one version returns its body, Domains and bindings. 
Resolve stored
+  IDs to current names; mark deleted targets or Domains as deleted rather than 
resolving a
+  same-name replacement. Apply the article's current read check to all history 
reads.
+- 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. Do not
+reuse `glossary_term_domain_rel`, and do not infer Article membership from 
backing tags. Domain
+and Glossary integration share lifecycle rules, not physical membership rows.
+
+- 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 Glossary definition privileges on the metalake. `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, load and version history    | 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, history, nested results, reverse 
lookups and MCP.
+Definition grants on a single article are rejected. Reader roles need only 
VIEW; until the
+platform provides an all-users role, admins grant it explicitly rather than 
assuming `PUBLIC`.
+
+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, history 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. `If-Match` handling is new work in this 
proposal and must be
+implemented in the server and clients rather than assumed to exist on current 
resources.
+
+### 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.
+
+| 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`     | Read visible summaries only     
                  |
+| `GET /kb-articles/{article}`                    | No body                    
                    | `article`               | Read full current article       
                  |
+| `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}/versions`           | No body                    
                    | `versions`              | Read version summaries, newest 
first              |
+| `GET /kb-articles/{article}/versions/{version}` | Positive version number    
                    | `version`               | Read one snapshot; missing 
version is `404`       |

Review Comment:
   The article name is not stated to forbid `/`, but all single-article routes 
put `{article}` in one path segment (`GET`, `PUT`, `DELETE`, versions and 
bindings). An otherwise valid explicit name containing `/` would be split by 
the REST router and cannot be addressed. Align this with the glossary/domain 
contracts by specifying URL-encoding/client behavior for article names, or 
explicitly rejecting `/` during validation.



##########
design-docs/gravitino-kb-article-design.md:
##########
@@ -0,0 +1,988 @@
+<!--
+  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 history**: store Markdown or HTML. Keep a snapshot of the 
title, body, Domains
+   and bindings for each effective content change, and expose readable version 
history.
+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**: changes take effect immediately. This 
proposal defines
+   no proposal, reviewer, approval queue or review API.
+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**: clients use REST; MCP tools are read-only. An 
article editor is
+   outside this contribution.
+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. **Tags and policies on articles**: this proposal adds neither tag 
association nor policies
+   for articles. An article binding does not change a target's policies.
+6. **Ranked, fuzzy or semantic search and RAG**: substring search is 
sufficient for this scope.
+   There is no embedding index or answer-generation service.
+7. **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.
+8. **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.
+9. **Article hierarchy, comparison and rollback**: articles form a flat list. 
History reads
+   snapshots; it does not compare them or restore them as new content.
+
+---
+
+## Delivery Scope and Tracking
+
+This is a design contribution. Merging it delivers no runtime feature. The 
local task IDs
+`T1`–`T14` in [Task Breakdown](#task-breakdown) describe implementation PRs; 
they are not GitHub
+issue numbers and do not imply that issues have been filed.
+
+| 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 |
+
+The Domain APIs are present on `main`. Article membership and the 
nonempty-Domain drop guard
+still need integration work in T5. Term bindings depend on the stable IDs, 
status checks and
+deletion hooks described in the Glossary design; that document is not evidence 
that the runtime
+interfaces have shipped. Article storage, ordinary asset bindings and other 
independent work
+can proceed before the Term integration is ready.
+
+Article history is included from the start. This differs from Glossary Step 1, 
which has a
+revision number and audit but no content snapshots. The two objects share 
definition privileges
+and Domain conventions, not an identical storage or delivery plan.
+
+---
+
+## 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 history shows both 
snapshots.
+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
+}
+ArticleVersion { articleId, version, title, body, domainIds[], bindings[], 
status, audit_info }
+ArticleBinding { articleId, targetType, targetId, audit_info }
+ArticleDomain  { articleId, domainId, audit_info }
+```
+
+- **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.
+- **Generated name**: `name` is optional on create. Lower-case the title, 
replace runs of
+  non-ASCII letters and digits with `-`, trim the separators and cut to 128 
characters. If the
+  result is empty, use `article-<shortId>` with 8 random lower-case 
alphanumeric characters,
+  regenerating on collision. A derived-name collision adds `-2`, `-3`, and so 
on, cutting the
+  base further to keep the whole name within 128 characters. A duplicate 
explicit name is `409`.
+- **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; no owner column is added to the article table.
+- **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 private 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 is
+expected to appear in history.
+
+- 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.
+- History lists versions newest first, with version, title, version status and 
audit information,
+  without bodies. Reading one version returns its body, Domains and bindings. 
Resolve stored
+  IDs to current names; mark deleted targets or Domains as deleted rather than 
resolving a
+  same-name replacement. Apply the article's current read check to all history 
reads.
+- 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. Do not
+reuse `glossary_term_domain_rel`, and do not infer Article membership from 
backing tags. Domain
+and Glossary integration share lifecycle rules, not physical membership rows.
+
+- 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 Glossary definition privileges on the metalake. `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, load and version history    | 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, history, nested results, reverse 
lookups and MCP.
+Definition grants on a single article are rejected. Reader roles need only 
VIEW; until the
+platform provides an all-users role, admins grant it explicitly rather than 
assuming `PUBLIC`.
+
+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, history 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. `If-Match` handling is new work in this 
proposal and must be
+implemented in the server and clients rather than assumed to exist on current 
resources.
+
+### 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.
+
+| 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`     | Read visible summaries only     
                  |
+| `GET /kb-articles/{article}`                    | No body                    
                    | `article`               | Read full current article       
                  |
+| `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}/versions`           | No body                    
                    | `versions`              | Read version summaries, newest 
first              |
+| `GET /kb-articles/{article}/versions/{version}` | Positive version number    
                    | `version`               | Read one snapshot; missing 
version is `404`       |
+| `GET /kb-articles/{article}/terms`              | No body                    
                    | `terms`                 | Read visible current Term 
bindings                |
+| `POST /kb-articles/{article}/terms`             | `termsToAdd`, 
`termsToRemove`: name arrays     | `terms`                 | Change Term 
bindings atomically                   |
+| `GET /kb-articles/{article}/objects`            | No body                    
                    | `objects`               | Read visible current asset 
bindings               |
+| `POST /kb-articles/{article}/objects`           | `objectsToAdd`, 
`objectsToRemove`: identifiers | `objects`               | Change asset 
bindings atomically                  |
+| `GET /glossary/terms/{term}/kb-articles`        | `includeDeprecated`, 
default `false`           | `articles`              | Authorize Term root, then 
read article summaries  |
+| `GET /objects/{type}/kb-articles`               | `namespace`, `name`, 
`includeDeprecated`       | `articles`              | Authorize asset root, 
then read article 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.
+
+#### 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 readable bound Terms and objects. 
Bound Term details
+include current status; object details use `ArticleObjectIdentifier`. Owner 
information is
+resolved through the existing Owner model, not stored in the version snapshot. 
`audit_info`
+follows the standard AuditInfo DTO. A version read returns the versioned 
fields and its audit
+information, rather than presenting unversioned fields as historical values.
+
+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`. No existing Tag route or parser changes.
+
+| 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 and escaped substring patterns with `LOWER(value) LIKE 
LOWER(?)` on all
+  three databases. Do not rely on database collation. `%`, `_` and `\` in user 
input match
+  literally. A full-text index may replace this implementation without 
changing the API.

Review Comment:
   This does not make literal `%`, `_` and `\\` matching portable across the 
three databases: the SQL shown has no explicit `ESCAPE` clause, and backslash 
escaping differs with database settings. The existing cross-database 
implementation uses a dedicated escape character (for example `!`) and `ESCAPE 
'!'` (see 
`core/src/main/java/org/apache/gravitino/storage/relational/service/SchemaPOStorageOps.java:139-146`).
 Specify that same pattern escaping and clause here so the stated search 
semantics are implementable consistently.



##########
design-docs/gravitino-kb-article-design.md:
##########
@@ -0,0 +1,988 @@
+<!--
+  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 history**: store Markdown or HTML. Keep a snapshot of the 
title, body, Domains
+   and bindings for each effective content change, and expose readable version 
history.
+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**: changes take effect immediately. This 
proposal defines
+   no proposal, reviewer, approval queue or review API.
+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**: clients use REST; MCP tools are read-only. An 
article editor is
+   outside this contribution.
+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. **Tags and policies on articles**: this proposal adds neither tag 
association nor policies
+   for articles. An article binding does not change a target's policies.
+6. **Ranked, fuzzy or semantic search and RAG**: substring search is 
sufficient for this scope.
+   There is no embedding index or answer-generation service.
+7. **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.
+8. **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.
+9. **Article hierarchy, comparison and rollback**: articles form a flat list. 
History reads
+   snapshots; it does not compare them or restore them as new content.
+
+---
+
+## Delivery Scope and Tracking
+
+This is a design contribution. Merging it delivers no runtime feature. The 
local task IDs
+`T1`–`T14` in [Task Breakdown](#task-breakdown) describe implementation PRs; 
they are not GitHub
+issue numbers and do not imply that issues have been filed.
+
+| 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 |
+
+The Domain APIs are present on `main`. Article membership and the 
nonempty-Domain drop guard
+still need integration work in T5. Term bindings depend on the stable IDs, 
status checks and
+deletion hooks described in the Glossary design; that document is not evidence 
that the runtime
+interfaces have shipped. Article storage, ordinary asset bindings and other 
independent work
+can proceed before the Term integration is ready.
+
+Article history is included from the start. This differs from Glossary Step 1, 
which has a
+revision number and audit but no content snapshots. The two objects share 
definition privileges
+and Domain conventions, not an identical storage or delivery plan.
+
+---
+
+## 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 history shows both 
snapshots.
+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
+}
+ArticleVersion { articleId, version, title, body, domainIds[], bindings[], 
status, audit_info }
+ArticleBinding { articleId, targetType, targetId, audit_info }
+ArticleDomain  { articleId, domainId, audit_info }
+```
+
+- **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.
+- **Generated name**: `name` is optional on create. Lower-case the title, 
replace runs of
+  non-ASCII letters and digits with `-`, trim the separators and cut to 128 
characters. If the

Review Comment:
   The generated-name rule says to replace runs of “non-ASCII letters and 
digits,” so ordinary separators such as spaces and `/` are left in the result. 
For a title like the example `Revenue Calculation Guide`, this produces a name 
with spaces rather than the documented hyphenated slug and can also create an 
unaddressable slash-containing name. Please define this as replacing each run 
of characters other than ASCII letters and digits.



##########
design-docs/gravitino-kb-article-design.md:
##########
@@ -0,0 +1,988 @@
+<!--
+  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 history**: store Markdown or HTML. Keep a snapshot of the 
title, body, Domains
+   and bindings for each effective content change, and expose readable version 
history.
+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**: changes take effect immediately. This 
proposal defines
+   no proposal, reviewer, approval queue or review API.
+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**: clients use REST; MCP tools are read-only. An 
article editor is
+   outside this contribution.
+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. **Tags and policies on articles**: this proposal adds neither tag 
association nor policies
+   for articles. An article binding does not change a target's policies.
+6. **Ranked, fuzzy or semantic search and RAG**: substring search is 
sufficient for this scope.
+   There is no embedding index or answer-generation service.
+7. **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.
+8. **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.
+9. **Article hierarchy, comparison and rollback**: articles form a flat list. 
History reads
+   snapshots; it does not compare them or restore them as new content.
+
+---
+
+## Delivery Scope and Tracking
+
+This is a design contribution. Merging it delivers no runtime feature. The 
local task IDs
+`T1`–`T14` in [Task Breakdown](#task-breakdown) describe implementation PRs; 
they are not GitHub
+issue numbers and do not imply that issues have been filed.
+
+| 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 |
+
+The Domain APIs are present on `main`. Article membership and the 
nonempty-Domain drop guard
+still need integration work in T5. Term bindings depend on the stable IDs, 
status checks and
+deletion hooks described in the Glossary design; that document is not evidence 
that the runtime
+interfaces have shipped. Article storage, ordinary asset bindings and other 
independent work
+can proceed before the Term integration is ready.
+
+Article history is included from the start. This differs from Glossary Step 1, 
which has a
+revision number and audit but no content snapshots. The two objects share 
definition privileges
+and Domain conventions, not an identical storage or delivery plan.
+
+---
+
+## 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 history shows both 
snapshots.
+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
+}
+ArticleVersion { articleId, version, title, body, domainIds[], bindings[], 
status, audit_info }
+ArticleBinding { articleId, targetType, targetId, audit_info }
+ArticleDomain  { articleId, domainId, audit_info }
+```
+
+- **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.
+- **Generated name**: `name` is optional on create. Lower-case the title, 
replace runs of
+  non-ASCII letters and digits with `-`, trim the separators and cut to 128 
characters. If the
+  result is empty, use `article-<shortId>` with 8 random lower-case 
alphanumeric characters,
+  regenerating on collision. A derived-name collision adds `-2`, `-3`, and so 
on, cutting the
+  base further to keep the whole name within 128 characters. A duplicate 
explicit name is `409`.
+- **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; no owner column is added to the article table.
+- **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 private 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 is
+expected to appear in history.
+
+- 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.
+- History lists versions newest first, with version, title, version status and 
audit information,
+  without bodies. Reading one version returns its body, Domains and bindings. 
Resolve stored
+  IDs to current names; mark deleted targets or Domains as deleted rather than 
resolving a
+  same-name replacement. Apply the article's current read check to all history 
reads.
+- 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. Do not
+reuse `glossary_term_domain_rel`, and do not infer Article membership from 
backing tags. Domain
+and Glossary integration share lifecycle rules, not physical membership rows.
+
+- 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 Glossary definition privileges on the metalake. `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, load and version history    | 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, history, nested results, reverse 
lookups and MCP.
+Definition grants on a single article are rejected. Reader roles need only 
VIEW; until the
+platform provides an all-users role, admins grant it explicitly rather than 
assuming `PUBLIC`.
+
+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, history 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. `If-Match` handling is new work in this 
proposal and must be
+implemented in the server and clients rather than assumed to exist on current 
resources.
+
+### 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.
+
+| 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`     | Read visible summaries only     
                  |
+| `GET /kb-articles/{article}`                    | No body                    
                    | `article`               | Read full current article       
                  |
+| `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}/versions`           | No body                    
                    | `versions`              | Read version summaries, newest 
first              |
+| `GET /kb-articles/{article}/versions/{version}` | Positive version number    
                    | `version`               | Read one snapshot; missing 
version is `404`       |
+| `GET /kb-articles/{article}/terms`              | No body                    
                    | `terms`                 | Read visible current Term 
bindings                |
+| `POST /kb-articles/{article}/terms`             | `termsToAdd`, 
`termsToRemove`: name arrays     | `terms`                 | Change Term 
bindings atomically                   |
+| `GET /kb-articles/{article}/objects`            | No body                    
                    | `objects`               | Read visible current asset 
bindings               |
+| `POST /kb-articles/{article}/objects`           | `objectsToAdd`, 
`objectsToRemove`: identifiers | `objects`               | Change asset 
bindings atomically                  |

Review Comment:
   The term/object binding endpoints return the complete current set, and 
`ArticleSummary` also embeds readable bound Terms, but the design imposes no 
page size or continuation contract. Because binding count is not bounded and 
the snapshot is retained indefinitely, one article or one list page can create 
very large responses and nested lookup work. Define bounded binding pagination 
(including how totals and incomplete results are reported) or cap the binding 
set.



-- 
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]

Reply via email to