feat(db): add template-mirror tracking columns#351
Closed
buremba wants to merge 2 commits into
Closed
Conversation
Adds managed_by_template_agent_id and source_template_org_id to entity_types, entity_relationship_types, event_classifiers, and watchers. When a user installs a template agent, the install flow mirrors that agent's canonical entity types, relationship types, classifiers and watcher definitions from the template org into the user's personal org. The two new columns record the provenance of those mirrored rows so they can be re-synced on template updates and treated as read-only by the user-org owner. Partial indexes only cover non-NULL rows so user-authored entity types/relationships/classifiers/watchers stay un-indexed (the common case).
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Apr 25, 2026
- Add IF NOT EXISTS to ALTER TABLE ADD COLUMN so a rollback + re-apply doesn't fail on column-exists. - Rename indexes from idx_*_managed_by_template to idx_*_template_agent_id to match the existing idx_<table>_<column> convention (cf. idx_cc_watcher_id).
Member
Author
|
Closing per docs/plans/world-model.md — schema cloning is dead weight once vocabularies live in shared public_catalog orgs and agents resolve them via cross-org references. No template-mirror tracking columns are needed because there is no mirror. If we ever bring back per-tenant schema overrides, the right shape is local entity_types in the tenant org, not duplicated catalog rows. New plan replaces this with: organization.kind + visibility, denormalized source/target org_ids on entity_relationships, app-level write guard for cross-org refs. |
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
managed_by_template_agent_idandsource_template_org_idtoentity_types,entity_relationship_types,event_classifiers, andwatchers.WHERE managed_by_template_agent_id IS NOT NULL) keep user-authored rows unindexed.This is the first slice of the personal-finance agent's platform foundation; downstream PRs (install flow, WhatsApp routing) will use these columns.
Test plan