Make WordPress Core

Opened 5 months ago

Closed 2 weeks ago

Last modified 2 weeks ago

#65476 closed feature request (maybelater)

Introduce Knowledge custom post type

Reported by: gziolo Owned by: gziolo
Priority: normal Milestone:
Component: Posts, Post Types Version: trunk
Severity: normal Keywords: has-patch has-unit-tests gutenberg-merge
Cc: Focuses:

Description (last modified by gziolo)

Summary

Introduce the Knowledge concept: a wp_knowledge custom post type with a type taxonomy, a capability namespace, and a REST surface, providing a canonical store for author-facing and agent-facing site knowledge. Guidelines is the first feature built on it, giving site owners a place to capture content standards such as voice, tone, image guidance, and per-block rules.

This has been developed as an experiment in the Gutenberg plugin and was proposed for merge in WordPress 7.1, but ​postponed to 7.2 or later.

Motivation

Sites accumulate standards and context that today live outside WordPress in documents, wikis, and institutional knowledge. As plugins and integrations need persistent, structured knowledge about a site, each one tends to ship its own storage, permissions model, and REST surface. A shared core primitive prevents that fragmentation, the same way wp_template, wp_block, and nav_menu_item did in their domains.

The feature ships storage and access only. It includes no AI provider, model, retrieval algorithm, or memory architecture.

Scope

Proposed for this ticket:

  • wp_knowledge post type, registered as internal (public => false, publicly_queryable => false), with revision support
  • wp_knowledge_type taxonomy and a wp_knowledge_types registration filter
  • Built-in types:
    • guideline – a standard such as voice, tone, or per-block rules, applied directly or loaded in the matching context
    • note – private freeform working text such as drafts and synced notes
  • *_knowledge capability namespace and access policy (private, author-owned by default; administrators manage site-wide records)
  • /wp/v2/knowledge REST routes

Out of scope for this ticket:

  • Further built-in types, deferred and registerable by plugins in the meantime:
    • memory – durable context a user explicitly saved, such as preferences or stable facts
    • skill – a procedure that can load and apply a guideline, planned for 7.2 pending settled loading and discovery semantics
    • plan – task-scoped working state, pending a side-effect and lifecycle model
    • artifact – a reference to a versioned work product distinct from the freeform text covered by note, explored separately
  • The knowledge management ability (Abilities API), proposed for a later release
  • Decay, consolidation, retrieval, and encryption at rest

Access model

Records are not exposed as a public index. Collection reads require authentication, per-item reads are capability-checked through read_post, and non-publishers may only create private records.

Role Site-wide guideline records Own private records Others' private records Manage global records
Subscriber No No No No
Contributor Read where caps allow CRUD No No
Author / Editor Read where caps allow CRUD No No
Administrator Manage Yes Yes Yes

Type and scope registration are code-level extension points. User roles control access to records, not the registration of types or scopes.

Related

Change History (22)

#1 @gziolo
5 months ago

  • Owner set to gziolo
  • Version → trunk

#2 @gziolo
5 months ago

  • Description modified (diff)

#3 @gziolo
5 months ago

  • Description modified (diff)

This ticket was mentioned in ​PR #12201 on ​WordPress/wordpress-develop by ​@gziolo.


5 months ago
#4

  • Keywords has-patch has-unit-tests added

## Summary

Introduces wp_knowledge, a private-by-default custom post type that acts as a storage primitive for structured site knowledge (guidelines, memories, notes), along with its wp_knowledge_type taxonomy and a dedicated REST controller.

This is the WordPress core counterpart to the Knowledge storage primitive being explored in Gutenberg (WordPress/gutenberg#79149). It deliberately lands the storage primitive only — the Guidelines admin UI and the content-guidelines singleton remain consumer-side concerns and are out of scope here.

## Details

  • Post type & taxonomy: wp_knowledge and wp_knowledge_type are registered as built-ins in create_initial_post_types() / create_initial_taxonomies(). Both are non-public and headless (show_ui => false); rows are managed via the REST API rather than a wp-admin screen.
  • REST API: WP_REST_Knowledge_Controller serves /wp/v2/knowledge. Reads require an authenticated user with the read capability, collection queries are scoped to rows the current user can read (so totals/pagination respect per-user visibility), callers without the publish capability are limited to the private status, and new rows default to private. Revision history uses the default revisions controller; autosave endpoints are disabled (following the wp_global_styles precedent), since knowledge has no editor session.
  • Capabilities: a graded model is synthesized through the user_has_cap filter (wp_maybe_grant_knowledge_caps()), matching the existing wp_maybe_grant_* pattern. Administrators manage all knowledge; contributors and above may create and fully manage their own private rows. Subscribers and anonymous users are blocked at the post-type door.
  • Type registry: wp_knowledge_types() exposes a filterable set of types (guideline, memory, note); rows saved without a type fall back to the note term.

## Testing

New unit tests cover registration, the capability matrix across all roles, the REST controller (CRUD, permission gating, private-by-default), and the type registry. The REST route snapshot in tests/phpunit/tests/rest-api/rest-schema-setup.php is updated accordingly.

npm run test:php -- --group knowledge

[!NOTE]
tests/qunit/fixtures/wp-api-generated.js is intentionally not regenerated here. Regenerating it currently also pulls in unrelated route drift already present on trunk, so it should be regenerated in a dedicated step to keep this diff focused on the primitive.

🤖 Generated with ​Claude Code

​@jorgefilipecosta commented on ​PR #12201:


5 months ago
#5

Knowledge, is something done mostly though for LLMS, similar to abilities, I wonder if for knowledge we avoid a specific REST endpoint and we just use abilities as the interface to manage the knowledge everywhere? Instead of calling REST we would always call the abilities.

​@jorgefilipecosta commented on ​PR #12201:


5 months ago
#6

Great work here, things look, just left some comments for considering but it seems to be on a good shape.

​@gziolo commented on ​PR #12201:


5 months ago
#7

Thanks for the thorough review @jorgefilipecosta and @peterwilsoncc 🙏 I've pushed updates addressing the inline feedback — capability naming (plural/singular bases), the trash → permanent-delete gap for contributors, the rest_cannot_read alignment, dropping the no-op show_admin_column, and additional permission test coverage. Replies are on the individual threads.

On the abilities vs. dedicated REST endpoint question:

I wonder if for knowledge we avoid a specific REST endpoint and we just use abilities as the interface to manage the knowledge everywhere?

I'd like to defer this. Whether a feature is exposed through a REST endpoint or through abilities feels like a higher-level call that should be made as a general policy — *when* do we add a REST endpoint vs. an ability — rather than settled per-PR here. For this PR I followed the existing convention of registering a REST controller for the new post type, as we do for other post types. An abilities-based interface would in practice replicate similar logic (capability checks, validation, sanitization), so it's a parallel direction we can evaluate later rather than a blocker for landing this foundation.

This ticket was mentioned in ​Slack in #core-ai by gziolo. ​View the logs.


5 months ago

#9 @gziolo
5 months ago

  • Description modified (diff)

#11 @wildworks
5 months ago

  • Keywords gutenberg-merge added

#12 @westonruter
4 months ago

In 62680:

Code Quality: Add conditional return typing for term_exists().

Developed as subset of ​https://github.com/WordPress/wordpress-develop/pull/12201

Props westonruter, gziolo.
See #64898, #65476.

#13 @wildworks
4 months ago

Due to an issue with Trac, we are unable to change the milestone. However, I would like to note that it has been decided ​not to include this feature in version 7.1.

#14 @gziolo
4 months ago

  • Description modified (diff)

​@gziolo commented on ​PR #12201:


4 months ago
#15

Status update

Following the feedback on the merge proposal (​Guidelines built on Knowledge), this work is postponed to WordPress 7.2 or later. The @since tags in this PR now point to 7.2.0.

The memory type has also been removed from the default wp_knowledge_types() list until it has a matching implementation. The built-in types are now guideline and note. Plugins can still add their own types through the wp_knowledge_types filter.

#16 @westonruter
4 months ago

  • Milestone 7.1 → 7.2

This ticket was mentioned in ​Slack in #core by im3dabasia1. ​View the logs.


7 weeks ago

#18 @im3dabasia1
7 weeks ago

As per today's 7.2 bug scrub:

I see this [PR]​https://github.com/WordPress/wordpress-develop/pull/12201 is approved with good review progress. @gziolo, is this still on track for 7.2? Also curious if the abilities-vs-REST discussion needs to be settled before it lands in 7.2.

#19 @gziolo
7 weeks ago

@im3dabasia1 – the decision regarding WP 7.2 largely depends on ​https://make.wordpress.org/core/2026/06/22/merge-proposal-guidelines-built-on-knowledge/. Code-wise, we don't have any blockers because this code has been stable since WP 7.1 beta. It only received accessibility enhancements for the accompanying UI in the Gutenberg plugin. It remains behind the feature experiment in the Gutenberg plugin mostly because we haven't decided about WP core inclusion yet.

Last edited 7 weeks ago by gziolo (previous) (diff)

#20 @gziolo
6 weeks ago

  • Milestone 7.2 → Future Release
  • Version 7.1 → trunk

Based on the WordPress Core AI team's discussions, it hasn't received enough support to pursue it in 7.2. Moving it for future consideration.

#21 @gziolo
2 weeks ago

  • Milestone Future Release
  • Resolution → maybelater
  • Status assigned → closed

@jason_the_adams has just published ​WordPress for the Agentic Web as a short-term plan for the Core AI team. After consulting with @annezazu, I'm closing this ticket as maybelater because it isn't included in this vision.

​@gziolo commented on ​PR #12201:


2 weeks ago
#22

@JasonTheAdams has just published ​WordPress for the Agentic Web as a short-term plan for the Core AI team. After consulting with @annezazu, I'm closing this PR because it isn't included in this vision. We might revisit it later.

Note: See TracTickets for help on using tickets.