Skip to content

feat: add opt-in ontology write tools for Jarvis graph agent#1465

Merged
Evanfeenstra merged 1 commit into
mainfrom
feat/ontology-edit-tools
Jul 12, 2026
Merged

feat: add opt-in ontology write tools for Jarvis graph agent#1465
Evanfeenstra merged 1 commit into
mainfrom
feat/ontology-edit-tools

Conversation

@Evanfeenstra

Copy link
Copy Markdown
Collaborator

What

Adds opt-in ontology write tools to the Jarvis graph agent so it can modify the knowledge-graph schema on the fly, rather than committing ontology changes to code. Changes are posted directly to the graph via the existing Jarvis /v2/schema endpoints.

Tools registered (gated behind toolsConfig.ontology_edit)

Tool Endpoint
ontology_create_type POST /v2/schema
ontology_update_type PUT /v2/schema/<ref_id>
ontology_delete_type DELETE /v2/schema/<ref_id_or_type> (soft delete)
ontology_create_edge POST /v2/schema/edge
ontology_update_edge PUT /v2/schema/edge/<ref_id>
ontology_delete_edge DELETE /v2/schema/edge/<ref_id>
ontology_rename_attribute PUT /v2/schema/<ref_id>/attribute

How it works

  • toolsJarvis.ts: new jarvisMutate helper (POST/PUT/DELETE) mirroring jarvisFetch; surfaces Jarvis errorCode/message back to the agent verbatim. Write tools registered via registerOntologyWriteTools, gated by a new ontologyEdit option — next to the existing graph_sub_agent gating.
  • tools.ts: ontology_edit added to the ToolName union / TOOL_NAMES / DEFAULT_DESCRIPTIONS (a group gate, like graph_sub_agent); the registerJarvisTools call passes ontologyEdit.
  • agent.ts: ONTOLOGY_EDIT_GUIDANCE injected into GRAPH_SYSTEM only when the flag is on (same conditional-injection pattern as qs/learn_concepts). Enforces inspect-before-mutate, smallest-change, reserved-name/CHILD_OF protection, valid type descriptors, and explicit user confirmation for destructive ops.

Default posture stays read-only — writes are strictly opt-in.

Usage

{
  "repo_url": "https://github.com/stakwork/mikeoss",
  "prompt": "Add a citationCount int attribute to the Statute node type",
  "mode": "graph",
  "toolsConfig": { "ontology_edit": true }
}

Not included / follow-ups

  • "Record in migrations" is not wired. This PR only handles posting changes directly to the graph; changes leave no :Migration trail and aren't reproducible across environments. That needs Jarvis-side work (a new endpoint recording a replayable payload, or the agent emitting a BaseMigration file).
  • No allowDelete sub-flag yet — ontology_edit: true enables destructive tools too, with confirmation enforced via prompt only. The object form ({ ontology_edit: { allowDelete: false } }) could add a hard guardrail later.

Testing

  • tsc --noEmit clean
  • src/__tests__/tools.test.ts passes (21/21)

Register ontology write tools (create/update/delete node & edge types,
rename attribute) that POST/PUT/DELETE directly against Jarvis /v2/schema.
Gated behind the opt-in toolsConfig.ontology_edit flag so the default
posture stays read-only. Injects inspect-before-mutate guidance into the
graph system prompt, requiring explicit user confirmation for destructive
changes.
@Evanfeenstra Evanfeenstra merged commit b120ea8 into main Jul 12, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant