Skip to content

Add the entity tools - #2537

Merged
pournasserian merged 4 commits into
v2from
2534-entity-tools
Oct 19, 2026
Merged

pournasserian merged 4 commits into
v2from
2534-entity-tools

Conversation

@pournasserian

Copy link
Copy Markdown
Member

Closes #2534

What

The F-ENT (#2417) entity tools (MCP-01, P1). Agents read facts, relations, unsourced facts and the blast radius, and propose one fact with its source, or a relation, in the write-tool conventions of #2514.

  • EntityTools (FluentCMS.Core.Builtin.Tools):
    • Reads: get_entity_facts (source, owner, validity and the unsourced flag, for the latest draft or a version), get_entity_relations (both directions), list_unsourced_facts (the site or one entity type) and get_blast_radius (the published entries a set's entity changes affect, with old and new values per path).
    • set_entity_fact proposes one fact with its value, source, owner and validity, and keeps the other facts. A property left out is stored as null, so a fact without a source is flagged unsourced.
    • relate_entities proposes a relation. It sets a single reference field, or adds to a list of references without duplicates, and keeps the field's metadata. A field that is not a reference field is refused with the new field_not_relation. A plain entry is refused with entry_not_entity.
    • Both writes read the version given as base_version, change it in a copy, and propose an update from the published version, or a create while the entity was never published, as update_entry does.
  • ProposedEntryWrite: the propose flow EntryTools used, moved into a shared helper with the update rule and the hints, so entry and entity writes commit a version and its operation the same way.
  • ToolArgumentsReader gains RequiredValue, for an argument that can be any JSON value but null (a fact's value), and OptionalObject.
  • ToolJson renders facts, flags, relations and the blast radius. The ENT rows of McpCoverageTests list the new tools; stale facts stay open on F-ENT: Entity registry with sources, validity and blast radius #2417.

Why

S1's pipeline agent changes one fact per product, with the export as its source. With update_entry alone it would have to resend each whole entity. set_entity_fact and relate_entities change only the fact or relation they name, and go through the same validation, reference checks, fact index and change set as any entry write. The reads make the earlier F-ENT slices (#2528, #2530, #2533) reachable over MCP.

Choices worth a look:

Tests

Unit (Core):

  • EntityToolsConformanceTests; McpCoverageTests with the new rows.

Integration over MCP, each on SQLite and PostgreSQL:

  • S1: two prices set from the export in one session's set; the blast radius lists exactly the two products' published pages with the old and new price, not the third product's page. The fact reads back sourced.
  • A fact set without a source reads back flagged and is listed by list_unsourced_facts.
  • relate_entities adds a spec and sets a category; get_entity_relations shows both outgoing, and the spec shows the product incoming.
  • A base version that does not exist, a field the type lacks (with a hint to the schema document), a plain entry, a field that is not a reference (with a hint to the content type) and a related entity of the wrong type are all refused, and nothing is stored.

The full suite ran locally against a postgres:17 container as well as SQLite. No migration, no new package and no new project reference.

Checklist

  • Linked to an issue a maintainer has confirmed
  • Targets v2
  • Tests or docs updated where behaviour changed
  • No tool-generated co-author trailers or footers

@pournasserian pournasserian added this to the M1 Governance core milestone Oct 19, 2026
@pournasserian pournasserian added type:feature New capability v2 FluentCMS v2 (v2 branch) area:entities labels Oct 19, 2026
@pournasserian
pournasserian merged commit b2247e7 into v2 Oct 19, 2026
2 checks passed
@pournasserian
pournasserian deleted the 2534-entity-tools branch October 19, 2026 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:feature New capability v2 FluentCMS v2 (v2 branch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the entity tools

1 participant