feat(agents): schema-mirror install flow for template agents#353
Closed
buremba wants to merge 3 commits into
Closed
feat(agents): schema-mirror install flow for template agents#353buremba wants to merge 3 commits into
buremba wants to merge 3 commits into
Conversation
New installAgentFromTemplate(templateAgentId, targetOrganizationId, userId) creates an agent row in the target org with template_agent_id set, then mirrors the template org's entity_types and entity_relationship_types into the target org tagged managed_by_template_agent_id + source_template_org_id. Core properties: - Idempotent. Re-running against the same target updates rather than creating duplicates. - Safe. The mirror never overwrites rows the user authored directly (managed_by_template_agent_id IS NULL). Slug collisions with user rows or with a different template agent abort with a descriptive error. - Re-syncable. resyncInstalledAgent() lets template schema evolution propagate to every installed instance. Watchers and classifiers are deferred to a follow-up — watchers need the watcher_versions + reaction_script dance, classifiers are scoped per- entity so they interact with entity mirroring. Paired with an integration test under __tests__/integration/agents/ that covers: create on first install, idempotency, managed_by tagging, re-sync propagation, refusal to install into the template's own org, refusal to overwrite user-authored rows.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
3 tasks
Defense in depth: previously installAgentFromTemplate trusted the caller to have already authorised the user against the target org. The public install route does enforce that (it derives targetOrganizationId from the authenticated user's personal org), but any future caller could bypass it. Add an explicit membership lookup against the "member" table inside installAgentFromTemplate. Refuses when: - user has no member row in the target org - user is a plain member (only owner/admin can install) Adds two tests for the new error paths.
Member
Author
|
Closing per docs/plans/world-model.md — installAgentFromTemplate's schema mirroring is replaced by reference, not copy. Templates become entities of type agent_template in a public_catalog org with uses_catalog relationships; the user's agent reads vocabulary from those catalogs at boot via a schema search path. Install becomes ~30 lines: insert agent row in user's tenant + provision $member (#359). The 1221 LOC of mirror logic + idempotency + user-authored protection all evaporate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New `packages/owletto-backend/src/agents/install.ts` with `installAgentFromTemplate()` and `resyncInstalledAgent()`. Creates an agent row in the target org with `template_agent_id` set, then mirrors the template org's `entity_types` and `entity_relationship_types` into the target org tagged `managed_by_template_agent_id` + `source_template_org_id` (columns added by #351).
Deferred to follow-up PRs: mirroring `event_classifiers` (entity-scoped complexity) and `watchers` (needs `watcher_versions` + reaction_script handling).
Stacked on
Targets `feat/schema-mirror-tracking-cols` (#351). Rebase onto main once #351 merges.
Test plan