-
Notifications
You must be signed in to change notification settings - Fork 0
feat(core): portable org identity — locally-minted org_id, stamped on tenant-scoped rows (ACE-056/057) #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
55d6208
feat(core): portable org identity — mint a locally-minted org_id and …
vishalkalbi27 b59f22e
fix(core): keep the org-less DATASOURCE_URL channel working once an o…
vishalkalbi27 722f211
docs(core): correct the resolved_org_id docstring to match the artifa…
vishalkalbi27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
packages/agami-core/src/migrations/core/012_users_org_id.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| -- Tenant-scope the users table (F14 / ACE-057). The serving + runtime tables already carry `org_id` | ||
| -- (added earlier); `users` is the last per-customer table that didn't. Adding it here lets an | ||
| -- authorized-user roster ride along when a self-hosted deployment is lifted into hosted as one tenant. | ||
| -- | ||
| -- Plain ADD COLUMN with a constant default is portable across SQLite + Postgres (no table rebuild) — | ||
| -- same shape as 007_user_names.sql. It DEFAULTs to the 'local' sentinel so existing rows land on it; | ||
| -- the minted uuid isn't known here (a static .sql migration can't generate one — SQLite has no uuid | ||
| -- function, and run_migrations applies static SQL only), so model_deploy runs a code backfill right | ||
| -- after migrations that moves every 'local' row (here and in the serving/runtime tables) onto the | ||
| -- resolved org_id. | ||
| -- | ||
| -- Unlike the serving tables, `org_id` is NOT part of the primary key here: `users.id` (uuid4) is the | ||
| -- PK and logins resolve by the global `UNIQUE(username)` — correct for single-tenant (N=1). An indexed | ||
| -- non-PK column is the right shape; `username` stays globally unique (a per-org unique is a paid | ||
| -- multi-tenant concern, out of scope). | ||
|
|
||
| ALTER TABLE users ADD COLUMN org_id TEXT NOT NULL DEFAULT 'local'; | ||
| CREATE INDEX idx_users_org ON users (org_id); |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked this — the graceful failure you're describing is already in place, so no change here.
_read_yamldoes open the file unguarded, so it raisesFileNotFoundError. Butcli.main()has a purpose-built handler for exactly that case (cli.py:1332-1339):Verified:
That's a clear error and a non-zero exit, using the repo's established convention (exit 3 = "no model", distinct from 1 = validation and 2 = usage) shared by every other
smsubcommand. Adding a local guard would makeensure-org-idreport this condition differently from its siblings, which is the opposite of what we want.