Use the seeded System identity for root; record who created every task #1851

Closed
opened 2026-11-10 08:45:54 +00:00 by sam · 2 comments
Owner

Nothing records who created a forge-polled task. On the live instance all 253 forge tasks have an empty identity, and all 243 task_queued and 12 work_request_submitted events have no task id, actor or principal.

Causes:

  • daemon.sourceTag stores "" when the polling identity is RootIdentityID, and task.Task.Identity documents empty as "the root identity".
  • RootIdentityID is identity.StableID(IdentityNames(cfg)[0]), an identity derived from the config's bot_user. It is a second "root" next to the seeded identity.SystemID (kind system), which is why the execution identities page lists System plus a bot named after the forge account.
  • Daemon.acknowledge emits task_queued with repo, issue and title only.

Wanted:

  • identity.SystemID is the one root/instance identity. The bot_user-derived root identity and the empty-string sentinel go.
  • A polled task stores the identity that polled it, never "". Instance-level work is attributed to System.
  • Task-creation events carry the task id, actor and principal.
  • Existing rows are migrated in the same change: empty tasks.identity and the root key in identity-grants move to the identity they stand for, so the dedupe key (tasks_current_item_key, the intake idempotency key) does not re-queue existing issues.

Done when a newly polled task and its task_queued event name the identity that created it, no code path writes an empty identity, and a migrated instance re-polls without duplicating tasks.

Nothing records who created a forge-polled task. On the live instance all 253 forge tasks have an empty `identity`, and all 243 `task_queued` and 12 `work_request_submitted` events have no task id, actor or principal. Causes: - `daemon.sourceTag` stores `""` when the polling identity is `RootIdentityID`, and `task.Task.Identity` documents empty as "the root identity". - `RootIdentityID` is `identity.StableID(IdentityNames(cfg)[0])`, an identity derived from the config's `bot_user`. It is a second "root" next to the seeded `identity.SystemID` (kind `system`), which is why the execution identities page lists System plus a bot named after the forge account. - `Daemon.acknowledge` emits `task_queued` with repo, issue and title only. Wanted: - `identity.SystemID` is the one root/instance identity. The `bot_user`-derived root identity and the empty-string sentinel go. - A polled task stores the identity that polled it, never `""`. Instance-level work is attributed to System. - Task-creation events carry the task id, actor and principal. - Existing rows are migrated in the same change: empty `tasks.identity` and the `root` key in `identity-grants` move to the identity they stand for, so the dedupe key (`tasks_current_item_key`, the intake idempotency key) does not re-queue existing issues. Done when a newly polled task and its `task_queued` event name the identity that created it, no code path writes an empty identity, and a migrated instance re-polls without duplicating tasks.
Author
Owner

Fixed in e3ffefdc7 on main. System is the one root: it polls forge connections, tasks never store an empty identity (CHECK constraint), and task_queued/work_request_submitted carry task id, actor and principal. Migration 0072 moves empty task identities, the identity-grants root key and the old root's connection permits to System; a dry run on a snapshot of the live database moved 253 tasks and both connections' permits as intended. Regression test TestPolledTaskKeepsItsCreatingIdentity fails on the old code. task check passes. Not deployed.

Fixed in e3ffefdc7 on main. System is the one root: it polls forge connections, tasks never store an empty identity (CHECK constraint), and task_queued/work_request_submitted carry task id, actor and principal. Migration 0072 moves empty task identities, the identity-grants root key and the old root's connection permits to System; a dry run on a snapshot of the live database moved 253 tasks and both connections' permits as intended. Regression test TestPolledTaskKeepsItsCreatingIdentity fails on the old code. task check passes. Not deployed.
Author
Owner

Verified on the live instance, which now runs the commit that carries the fix (e3ffefdc7 is an ancestor of the deployed 1.62.0-19-g255e0c7ee): migration 0072 is applied, all 253 tasks that held an empty identity now hold System, the identity-grants root key and the old root's connection permits are on System, and the table refuses an empty identity. Since the migration the poller has run every 10s against the three repositories and created no task and emitted no task_queued event, so the migrated rows match the poller's identity and the dedupe key no longer re-queues existing issues. No issue has carried the dispatch label since the deploy, so the first newly polled task is the one live observation left; TestPolledTaskKeepsItsCreatingIdentity pins that envelope's identity and idempotency key, and task_queued is now built from the stored task with its id, actor and principal. Closing.

Verified on the live instance, which now runs the commit that carries the fix (e3ffefdc7 is an ancestor of the deployed 1.62.0-19-g255e0c7ee): migration 0072 is applied, all 253 tasks that held an empty identity now hold System, the identity-grants root key and the old root's connection permits are on System, and the table refuses an empty identity. Since the migration the poller has run every 10s against the three repositories and created no task and emitted no task_queued event, so the migrated rows match the poller's identity and the dedupe key no longer re-queues existing issues. No issue has carried the dispatch label since the deploy, so the first newly polled task is the one live observation left; TestPolledTaskKeepsItsCreatingIdentity pins that envelope's identity and idempotency key, and task_queued is now built from the stored task with its id, actor and principal. Closing.
sam closed this issue 2026-11-10 14:50:41 +00:00
sam added the bug label 2026-11-12 15:52:53 +00:00
sam added the task label 2026-11-14 14:45:21 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1851