A non-system org can arm a schedule trigger #49

Closed
opened 2026-10-27 13:34:44 +00:00 by sam · 1 comment
Owner

Schedules fire a schedule-fired capture into the owning org, and the org's binding dispatches it. But the schedule-fired mapping is seeded only in the system org, and GetMapping/ListMappings are org-scoped, so a non-system org cannot create the binding (400 mapping not found) and dispatch would fail with 'mapping does not exist'.

Done when: a second org can create a schedule trigger from the dashboard, its firing creates a task in that org running as an agent assigned to that org, and the shared mapping stays read-only to non-system orgs.

Notes

5495c5f6: built_in mappings (schedule-fired) readable by every org, writes stay org-scoped. Remaining: demonstrate a second org's schedule trigger creating a task in that org (needs a running stack).


Imported from beads archie-core-3z4fd.11 · GitHub #1704 · type task · priority P2 · created 2026-10-16

Schedules fire a schedule-fired capture into the owning org, and the org's binding dispatches it. But the schedule-fired mapping is seeded only in the system org, and GetMapping/ListMappings are org-scoped, so a non-system org cannot create the binding (400 mapping not found) and dispatch would fail with 'mapping does not exist'. Done when: a second org can create a schedule trigger from the dashboard, its firing creates a task in that org running as an agent assigned to that org, and the shared mapping stays read-only to non-system orgs. ### Notes 5495c5f6: built_in mappings (schedule-fired) readable by every org, writes stay org-scoped. Remaining: demonstrate a second org's schedule trigger creating a task in that org (needs a running stack). --- _Imported from beads `archie-core-3z4fd.11` · GitHub #1704 · type task · priority P2 · created 2026-10-16_
sam added the mediumtask labels 2026-10-27 13:34:44 +00:00
sam self-assigned this 2026-10-27 13:34:44 +00:00
Author
Owner

Triaged: no code change is needed for this. No production change is outstanding in this worktree; the issue is at a verification stage, not a build stage.

What is already in place (verified by reading the tree):

  • Built-in mapping visibility: 0066_mapping_built_in.sql adds mappings.built_in and marks schedule-fired/org-sys built_in. queries/edastore.sql GetMapping and ListMappings include OR mappings.built_in (edastore.go passes scopeOrg), so a non-system org can now read the mapping.
  • Read-only to other orgs: UpdateMapping/DeleteMapping still filter by scope_org, so only org-sys can write it.
  • Firing lands in the owning org: scheduleOrg maps an org-owned schedule to its org and an instance schedule to org-sys; InsertCapture honours the schedule org; the schedule-fired event type is seeded so the capture is identified in any org.
  • Dispatch per org: daemon.dispatchBindings/dispatchOrgBindings run under each org's principal and ListUndispatchedCaptures is scoped by org.OrgFromContext.
  • Agent assigned to the org: workflow_identity.go databaseExecutionIdentity requires the declared identity to be an active agent whose principal and ListOrgAgents assignment match the task's org.

What is not verified: the second and third done-when clauses have no automated coverage. e2e/checks/org-schedule-trigger.cjs only proves a beta binding on schedule-fired is accepted (201) and appears on the workflow page. Nothing fires a schedule and asserts the beta task/agent, and nothing asserts that a beta update/delete of schedule-fired is refused. That is a running-stack demonstration, which the issue note itself says is what remains and which this read-only environment cannot run. Also note the demonstration needs a beta-owned schedule (the check filters on the instance-owned issue-discovery, which fires into org-sys) and an agent assigned to org-beta (e2e/seed.sh creates org-beta with no agents).

Recommendation to the operator: run task e2e:up, then task e2e:check -- org-schedule-trigger, then on the stack create a schedule from Beta via the trigger editor's "New schedule…", assign/settle a Beta agent, arm the trigger, and run the schedule now; confirm a task in org-beta runs as that agent and that a Beta edit/delete of schedule-fired returns the scoped refusal. If any step fails, that failure names the defect and a new triage should pick the workflow — the failing step, not the existing code, would then decide between a fix and a feasibility write-up.

Triaged: no code change is needed for this. No production change is outstanding in this worktree; the issue is at a verification stage, not a build stage. What is already in place (verified by reading the tree): - Built-in mapping visibility: `0066_mapping_built_in.sql` adds `mappings.built_in` and marks `schedule-fired`/`org-sys` built_in. `queries/edastore.sql` `GetMapping` and `ListMappings` include `OR mappings.built_in` (edastore.go passes `scopeOrg`), so a non-system org can now read the mapping. - Read-only to other orgs: `UpdateMapping`/`DeleteMapping` still filter by `scope_org`, so only org-sys can write it. - Firing lands in the owning org: `scheduleOrg` maps an org-owned schedule to its org and an instance schedule to org-sys; `InsertCapture` honours the schedule org; the schedule-fired event type is seeded so the capture is identified in any org. - Dispatch per org: `daemon.dispatchBindings`/`dispatchOrgBindings` run under each org's principal and `ListUndispatchedCaptures` is scoped by `org.OrgFromContext`. - Agent assigned to the org: `workflow_identity.go` `databaseExecutionIdentity` requires the declared identity to be an active agent whose principal and `ListOrgAgents` assignment match the task's org. What is not verified: the second and third done-when clauses have no automated coverage. `e2e/checks/org-schedule-trigger.cjs` only proves a beta binding on `schedule-fired` is accepted (201) and appears on the workflow page. Nothing fires a schedule and asserts the beta task/agent, and nothing asserts that a beta update/delete of `schedule-fired` is refused. That is a running-stack demonstration, which the issue note itself says is what remains and which this read-only environment cannot run. Also note the demonstration needs a beta-owned schedule (the check filters on the instance-owned `issue-discovery`, which fires into org-sys) and an agent assigned to org-beta (`e2e/seed.sh` creates org-beta with no agents). Recommendation to the operator: run `task e2e:up`, then `task e2e:check -- org-schedule-trigger`, then on the stack create a schedule from Beta via the trigger editor's "New schedule…", assign/settle a Beta agent, arm the trigger, and run the schedule now; confirm a task in org-beta runs as that agent and that a Beta edit/delete of `schedule-fired` returns the scoped refusal. If any step fails, that failure names the defect and a new triage should pick the workflow — the failing step, not the existing code, would then decide between a fix and a feasibility write-up.
sam closed this issue 2026-11-08 22:08:49 +00:00
sam added a new dependency 2026-11-14 14:45:19 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#49