Problem/Motivation

The ai_context_item content entity provided by the AI Context (Context Control Center) module stores its scope (Global, Use Cases, Tags, Site Sections,
Entity Bundles, Target Entities, Languages) in a map base field with arbitrary keys.

Drupal core's \Drupal\Core\DefaultContent\Importer calls $item->get($property_name) for every key found in a field's YAML payload. MapItem::propertyDefinitions() returns an empty
array, so get() throws "Property is unknown." as soon as the YAML contains anything other than an empty map.

The inverse direction is also broken: drush content:export ai_context_item N normalises the map field to scope: - { } even when the entity has {"global":["global"]} stored in the
database.

The consequence is that recipes that ship content/ai_context_item/*.yml files (for example Varbase AI Context) cannot pre-populate the scope.
Every imported item lands with an empty scope, no agent picks it up at runtime, and the operator must edit each item by hand after applying the recipe — defeating the purpose of shipping starter context items.

Proposed resolution

Add a new config action plugin setAiContextItemsDefaultScope to the varbase_recipes module that lets recipes assign a scope to imported ai_context_item entities in pure YAML, without
shipping the scope through the content import path.

Design:

  • The action attaches to one of the ai_context.scope_settings.* config objects shipped by the ai_context module — for example ai_context.scope_settings.global or
    ai_context.scope_settings.use_case. The scope plugin id is derived from the segment after the prefix.
  • Recipes pass an array of scope values as the action value.
  • Because Drupal recipes run config actions before the content step, the action's apply() registers an in-process listener on RecipeAppliedEvent. The listener fires after content import has
    finished, loads every ai_context_item whose scope is still empty, and writes [scope_id => values] via \Drupal\ai_context\Entity\AiContextItem::setScopeValues().
  • Items that already carry a scope are skipped, so the action is idempotent and re-applying the recipe is safe.

Example — apply Global scope to all imported items:

config:
    actions:
      ai_context.scope_settings.global:
        setAiContextItemsDefaultScope:
          - global

Example — apply a Use Case scope:

config:
    actions:
      ai_context.scope_settings.use_case:
        setAiContextItemsDefaultScope:
          - writing_words
          - working_in_canvas

Remaining tasks

  • ✅ File an issue about this project
  • ✅ Addition/Change/Update/Fix to this project
  • ✅ Testing to ensure no regression
  • ➖ Automated unit/functional testing coverage
  • ✅ Developer Documentation support on feature change/addition
  • ➖ User Guide Documentation support on feature change/addition
  • ➖ UX/UI designer responsibilities
  • ➖ Accessibility and Readability
  • ✅ Code review from 1 Varbase core team member
  • ✅ Full testing and approval
  • ✅ Credit contributors
  • ✅ Review with the product owner
  • ✅ Update Release Notes
  • ❌ Release varbase-11.0.0-beta1, varbase_starter-beta1, varbase_recipes-1.0.0-beta1

User interface changes

  • N/A

API changes

  • N/A

Data model changes

  • N/A

Release notes snippet

  • fix: #3589734 Add setAiContextItemsDefaultScope config action to apply scope values to imported AI Context items

Comments

rajab natshah created an issue. See original summary.

  • rajab natshah committed 9979f5db on 1.0.x
    fix: #3589734 Add setAiContextItemsDefaultScope config action to apply...
rajab natshah’s picture

Assigned: rajab natshah » josebc
Issue summary: View changes
Status: Active » Needs review
Issue tags: +varbase-11.0.0-beta1, +varbase_starter-beta1, +varbase_recipes-1.0.0-beta1
rajab natshah’s picture

Assigned: josebc » Unassigned
Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

rajab natshah’s picture

Issue summary: View changes
rajab natshah’s picture

Issue summary: View changes

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

rajab natshah’s picture