Migrate automation resources to organisation ownership #57
Notifications
Due Date
No due date set.
Blocks
Reference: sam/archie#57
Reference in new issue
Block a user
Approved ownership model: accounts own login methods, personal API tokens and preferences; instance owns authentication providers, execution infrastructure, installed extensions, secret-engine infrastructure and organisation limits; organisations own execution identities, connections, model configuration, workflows, schedules and channels; workspaces group organisation resources and initially inherit organisation permissions. Migrate currently global automation configuration into its existing owning organisation, preserving values and never widening access. Remove superseded runtime configuration paths after their consumers use organisation-scoped service contracts. Do not introduce new services or cross-service table access.
Acceptance criteria
Existing configuration retains its organisation and effective permissions; tasks resolve configuration within their organisation; cross-organisation reads and execution are refused; unrelated capabilities remain usable when a dependency is unavailable. Verify migration semantics and organisation security boundaries.
Notes
Investigation 2026-10-17 (third agent, ownership slice): current state of the migration, verified against source.
Already organisation-owned and working end to end: model configuration (org-model-policy plus per-org providers/aliases, resolved by ModelsFor and the gateway chat model manager keyed by org), workflow definitions and workflow enablement (per-org seeding in the control plane, resolved by the daemon through workflowContext), event sources, mappings and bindings (org_id from the edastore org migration).
Instance-only boundary: controlplane.instanceOnlyKinds still holds RepositoryPoliciesKind, ChannelSettingsKind, SchedulingPolicyKind, ReviewSettingsKind, TaskPolicyKind, ToolSettingsKind, PluginSettingsKind, ContainerRuntimePoliciesKind, AgentProfileKind, ExtensionSettingsKind, UpdateSettingsKind and WorkflowExecutionSettingsKind, and checkOrgWrite refuses every other org's write. runtime_config.go is the only consumer that layers them, and it reads the system org alone.
Confirmed gap, not yet fixed: SchedulesKind is deliberately absent from instanceOnlyKinds, so an organisation can save its own schedules, but the only runtime consumer (the daemon scheduling engine through controlplane.Client.Schedules and its scheduleResourceStore) reads one org. Runs scheduled by any other organisation are stored and never dispatched. Same shape applies to channel settings once channels move to the organisation.
Blocker for the rest: a shared process resolving several tenants needs per-org acting context. Reads already model this (org.WithScope, postgres scopeOrg, InstanceScope) but acting for another org does not exist: the org travels from the caller's principal (rpcidentity Outgoing/Callers), so a daemon or scheduler cannot submit a task or deliver a message as another org. That is what the identity work in archie-core-kgxw.13 must provide before schedules, channels and per-org task policy can be resolved at their points of use.
Not attempted in this session: two-org effective-resource demonstration, migration of existing records, apply-status per org.
2026-10-17 schedules slice, paused for a decision. Reading each org's schedules is mechanical: control-plane org comes only from the caller principal, so the daemon would enumerate orgs (state-store ListOrgs + ListOrgAgents for a principal per org), key engine jobs as org/id, and Get/MarkRun under that org. Two blockers are product decisions: (1) chat-kind jobs deliver through the instance messaging channels, so an org could message any chat the instance bot reaches; channels need org ownership first (runtime_config channel settings are also single-org). (2) workflow-kind jobs submit via gateway StoreTaskCreator, which needs a [chat] identity profile with a default repo; non-system orgs have none, so a job needs to name the org agent it runs as (and a workflow), not inherit the daemon chat identity.
Schedules slice landed: daemon ticks every org's schedules (ListOrgs + ListOrgAgents principal, jobs keyed org/id); state store lets unscoped internal services read the org directory. Non-system chat and workflow schedules are refused and advanced; follow-ups filed as children of the epic.
2026-10-27 schedule firings slice (commit 01135924 on worktree-agent-a96275cae3df43e25): schedules now fire via captures + bindings (the 2026-10-17 note about chat/workflow job kinds is stale). Reproduced: every schedule-fired capture had no org and landed in the system org, so an org's schedule trigger binding never fired and system-org bindings with no schedule filter fired on every org's schedules. Fix: claims carry the owning org (instance schedules map to the system org), the capture is stored under it (honoured only for the reserved schedule source). Not verified against a live database (no Postgres tests per policy). Remaining: channel settings/scheduling policy per org (3z4fd.12), existing-record migration check, two-org end-to-end demonstration, per-org apply-status; remaining instanceOnlyKinds are still system-org only.
2026-10-27 ownership slice (branch worktree-agent-a134425508bc8bed9, ba9ebebd). (a) Remaining instanceOnlyKinds triaged, no kind converted: ToolSettings, PluginSettings, ContainerRuntimePolicies, AgentProfile, WorkflowExecutionSettings, ExtensionSettings, UpdateSettings, AuditRetention, ScheduleSettings are execution infrastructure/extensions/limits, instance-wide per the approved model (comment on instanceOnlyKinds). ChannelSettings, SchedulingPolicy and TaskPolicy (notify webhook) wait on org-owned channels in 3z4fd.12. (b) Apply status is instance-admin only (instanceOnly endpoint, no org surface), so per-org records are not needed; the real defect was workflow-definitions and playbooks reads for other orgs overwriting the (process,kind) row with a version not comparable to the system org's. Reporter now ignores reports made under a non-system org; one table test. (c) Migrations checked: resources keyed (org_id,kind) since 0021, task/eda child rows backfilled in 0042, schedule captures carry their org. 0065 deliberately drops the old schedules resource without copying (old chat/spawn job shapes have no capture+binding equivalent; solo instance); not an orphaning of org rows. Not verified against a live database. Remaining: 3z4fd.12 kinds, two-org end-to-end demonstration.
2026-10-27: All kinds resolved: per-org channels/policies landed with 3z4fd.12 (
be4fd100). Remaining for close: one two-org end-to-end demonstration on a running stack.Imported from beads
archie-core-3z4fd.8· GitHub #1685 · type task · priority P1 · created 2026-10-16Triaged: no code change is needed for this. The implementation this issue asks for is already in the tree; what remains is evidence, not code.
What I verified in /data/worktree:
What remains is the last note in the issue itself: "one two-org end-to-end demonstration on a running stack", i.e. running the existing stack under two organisations, setting distinct values, and recording that each resolves in its own org. That is a verification run (task e2e:up, task e2e:stack/seed, then the dashboard/API paths), not a repository change. The acceptance criteria in the body all have implementation behind them; none names behaviour that is currently wrong.
What I did not verify: I ran no live stack (read-only analysis), so the two-org demonstration, existing-record migration against a real database, and per-org apply status are unconfirmed here. If the two-org run later shows a real divergence, that would be a defect and a new issue with the failing path.
Optional follow-up, not started: capture the demonstration as a repeatable e2e check under e2e/checks (the harness is run by hand, never by the gate), so the evidence can be re-run per release.