Rename the instance's built-in org id from default to org-sys. The default workspace id stays default.
Context
internal/domain/org/org.go:22DefaultOrgID OrgID = "default". Everything in Go uses this constant; only SQL and one test hardcode the string.
SQL that hardcodes 'default' as an org id: internal/infrastructure/postgres/queries/orgupgrade.sql (EnsureDefaultOrg, EnsureDefaultWorkspace, AssignDefaultOrgIdentities, the Stamp* queries).
Tables with an org_id column (see migrations 0012, 0013, 0014, 0016, 0017, 0021, 0023): orgs(id), workspaces, memberships, org_agents, tasks, events, transitions, resources, resource_history, step_executions, access_policies (+ its second table in 0016), bindings, mappings, captures, sources, event_types, tool_calls, installed_packages and its two child tables. Most columns have DEFAULT 'default'.
FKs: workspaces/memberships/org_agents REFERENCES orgs(id) (no ON UPDATE). installed_packages children have composite FKs on (org_id, name).
Test fixture internal/app/statestore/policy_guard_test.go:35 uses "default".
Steps
Change DefaultOrgID to "org-sys". Leave DefaultWorkspaceID alone.
In queries/orgupgrade.sql replace the org-id 'default' literals with 'org-sys' (workspace ids stay 'default'). Org name becomes 'System'. Run task db:generate.
Add migration internal/infrastructure/postgres/migrations/00NN_org_sys.sql (next free number). Up, in one transaction:
a. INSERT INTO orgs (id, name) SELECT 'org-sys', 'System' WHERE EXISTS (SELECT 1 FROM orgs WHERE id = 'default') ON CONFLICT DO NOTHING;
b. Drop the installed_packages child FKs, UPDATE <table> SET org_id = 'org-sys' WHERE org_id = 'default' for every table listed above, re-add the FKs exactly as they were.
c. ALTER TABLE <t> ALTER COLUMN org_id SET DEFAULT 'org-sys' for every column whose default was 'default'.
d. DELETE FROM orgs WHERE id = 'default';
Down: the exact reverse.
Update the test constant in policy_guard_test.go to "org-sys".
grep -rn "'default'" internal/infrastructure/postgres/queries and grep -rn 'org.*"default"' internal cmd to confirm no org-id literal is left (workspace ones are fine).
Out of scope
Renaming the workspace. Any UI change. Any change to how orgs are resolved.
Stop when
DefaultOrgID == "org-sys" and no SQL query hardcodes 'default' as an org id.
Migration up runs on a fresh DB and on a DB that already has default rows (go test ./internal/infrastructure/postgres/ uses a throwaway Postgres; run it).
task check passes.
Commit refactor(org): rename the default org to org-sys, bd close this bead. Stop.
Rules for this ticket
Read CLAUDE.md first. Follow it: smallest change, no new binaries, no compatibility shims, comments say why briefly.
Do ONLY the steps below. Anything else you notice: file it with bd create (one line of why) and carry on. Do not fix it.
Do not refactor, rename or reformat code outside the listed files.
No new tests unless a step says so.
Run task check once at the end. If it fails twice on the same problem, stop and write what failed in a bead comment (bd comments add <id> "...") instead of looping.
Timebox: if you have not reached "Stop when" after the steps, stop, comment what is left, and leave the bead open.
Close reason
Closed
Imported from beads archie-core-kgxw.1 · GitHub #1279 · type task · priority P1 · created 2026-10-05 · closed 2026-10-05
## Goal
Rename the instance's built-in org id from `default` to `org-sys`. The default workspace id stays `default`.
## Context
- `internal/domain/org/org.go:22` `DefaultOrgID OrgID = "default"`. Everything in Go uses this constant; only SQL and one test hardcode the string.
- SQL that hardcodes `'default'` as an org id: `internal/infrastructure/postgres/queries/orgupgrade.sql` (EnsureDefaultOrg, EnsureDefaultWorkspace, AssignDefaultOrgIdentities, the Stamp* queries).
- Tables with an `org_id` column (see migrations 0012, 0013, 0014, 0016, 0017, 0021, 0023): orgs(id), workspaces, memberships, org_agents, tasks, events, transitions, resources, resource_history, step_executions, access_policies (+ its second table in 0016), bindings, mappings, captures, sources, event_types, tool_calls, installed_packages and its two child tables. Most columns have `DEFAULT 'default'`.
- FKs: workspaces/memberships/org_agents `REFERENCES orgs(id)` (no ON UPDATE). installed_packages children have composite FKs on (org_id, name).
- Test fixture `internal/app/statestore/policy_guard_test.go:35` uses `"default"`.
## Steps
1. Change `DefaultOrgID` to `"org-sys"`. Leave `DefaultWorkspaceID` alone.
2. In `queries/orgupgrade.sql` replace the org-id `'default'` literals with `'org-sys'` (workspace ids stay `'default'`). Org name becomes `'System'`. Run `task db:generate`.
3. Add migration `internal/infrastructure/postgres/migrations/00NN_org_sys.sql` (next free number). Up, in one transaction:
a. `INSERT INTO orgs (id, name) SELECT 'org-sys', 'System' WHERE EXISTS (SELECT 1 FROM orgs WHERE id = 'default') ON CONFLICT DO NOTHING;`
b. Drop the installed_packages child FKs, `UPDATE <table> SET org_id = 'org-sys' WHERE org_id = 'default'` for every table listed above, re-add the FKs exactly as they were.
c. `ALTER TABLE <t> ALTER COLUMN org_id SET DEFAULT 'org-sys'` for every column whose default was `'default'`.
d. `DELETE FROM orgs WHERE id = 'default';`
Down: the exact reverse.
4. Update the test constant in `policy_guard_test.go` to `"org-sys"`.
5. `grep -rn "'default'" internal/infrastructure/postgres/queries` and `grep -rn 'org.*"default"' internal cmd` to confirm no org-id literal is left (workspace ones are fine).
## Out of scope
Renaming the workspace. Any UI change. Any change to how orgs are resolved.
## Stop when
- [ ] `DefaultOrgID == "org-sys"` and no SQL query hardcodes `'default'` as an org id.
- [ ] Migration up runs on a fresh DB and on a DB that already has `default` rows (`go test ./internal/infrastructure/postgres/` uses a throwaway Postgres; run it).
- [ ] `task check` passes.
- [ ] Commit `refactor(org): rename the default org to org-sys`, `bd close` this bead. Stop.
## Rules for this ticket
- Read CLAUDE.md first. Follow it: smallest change, no new binaries, no compatibility shims, comments say why briefly.
- Do ONLY the steps below. Anything else you notice: file it with `bd create` (one line of why) and carry on. Do not fix it.
- Do not refactor, rename or reformat code outside the listed files.
- No new tests unless a step says so.
- Run `task check` once at the end. If it fails twice on the same problem, stop and write what failed in a bead comment (`bd comments add <id> "..."`) instead of looping.
- Timebox: if you have not reached "Stop when" after the steps, stop, comment what is left, and leave the bead open.
### Close reason
Closed
---
_Imported from beads `archie-core-kgxw.1` · GitHub #1279 · type task · priority P1 · created 2026-10-05 · closed 2026-10-05_
sam
added the hightask labels 2026-10-27 13:35:45 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Goal
Rename the instance's built-in org id from
defaulttoorg-sys. The default workspace id staysdefault.Context
internal/domain/org/org.go:22DefaultOrgID OrgID = "default". Everything in Go uses this constant; only SQL and one test hardcode the string.'default'as an org id:internal/infrastructure/postgres/queries/orgupgrade.sql(EnsureDefaultOrg, EnsureDefaultWorkspace, AssignDefaultOrgIdentities, the Stamp* queries).org_idcolumn (see migrations 0012, 0013, 0014, 0016, 0017, 0021, 0023): orgs(id), workspaces, memberships, org_agents, tasks, events, transitions, resources, resource_history, step_executions, access_policies (+ its second table in 0016), bindings, mappings, captures, sources, event_types, tool_calls, installed_packages and its two child tables. Most columns haveDEFAULT 'default'.REFERENCES orgs(id)(no ON UPDATE). installed_packages children have composite FKs on (org_id, name).internal/app/statestore/policy_guard_test.go:35uses"default".Steps
DefaultOrgIDto"org-sys". LeaveDefaultWorkspaceIDalone.queries/orgupgrade.sqlreplace the org-id'default'literals with'org-sys'(workspace ids stay'default'). Org name becomes'System'. Runtask db:generate.internal/infrastructure/postgres/migrations/00NN_org_sys.sql(next free number). Up, in one transaction:a.
INSERT INTO orgs (id, name) SELECT 'org-sys', 'System' WHERE EXISTS (SELECT 1 FROM orgs WHERE id = 'default') ON CONFLICT DO NOTHING;b. Drop the installed_packages child FKs,
UPDATE <table> SET org_id = 'org-sys' WHERE org_id = 'default'for every table listed above, re-add the FKs exactly as they were.c.
ALTER TABLE <t> ALTER COLUMN org_id SET DEFAULT 'org-sys'for every column whose default was'default'.d.
DELETE FROM orgs WHERE id = 'default';Down: the exact reverse.
policy_guard_test.goto"org-sys".grep -rn "'default'" internal/infrastructure/postgres/queriesandgrep -rn 'org.*"default"' internal cmdto confirm no org-id literal is left (workspace ones are fine).Out of scope
Renaming the workspace. Any UI change. Any change to how orgs are resolved.
Stop when
DefaultOrgID == "org-sys"and no SQL query hardcodes'default'as an org id.defaultrows (go test ./internal/infrastructure/postgres/uses a throwaway Postgres; run it).task checkpasses.refactor(org): rename the default org to org-sys,bd closethis bead. Stop.Rules for this ticket
bd create(one line of why) and carry on. Do not fix it.task checkonce at the end. If it fails twice on the same problem, stop and write what failed in a bead comment (bd comments add <id> "...") instead of looping.Close reason
Closed
Imported from beads
archie-core-kgxw.1· GitHub #1279 · type task · priority P1 · created 2026-10-05 · closed 2026-10-05