fix(identity): use System as the one root identity and record who created every task (#1851)
deploy / plan (push) Successful in 25s
deploy / gate (push) Successful in 7m57s
deploy / agent-image (push) Successful in 21s
deploy / dist-zip (push) Skipped
deploy / archied-image (push) Successful in 2m12s

Drop the bot_user-derived root identity and the empty-identity sentinel. System
polls forge connections and owns instance-level work; a polled task stores the
polling identity, task_queued and work_request_submitted carry task id, actor
and principal, and an empty task identity is refused. Migration 0072 moves
empty tasks.identity, the identity-grants root key and the old root's
connection permits to System so a re-poll dedups.
This commit is contained in:
sam committed 2026-11-10 20:01:16 +11:00
1 parent 04798b990a
commit e3ffefdc7d
36 files changed
+283 -189

No files matched your search

+12 -13
View File
@@ -13,13 +13,13 @@ import { useSettingsStore } from "@/stores/settings";
import DraftHint from "./DraftHint.vue";
import KindGate from "./KindGate.vue";
/** The identity-grants document: the default credential services,
* and per identity a list that replaces the default. */
/** The identity-grants document: credential services per identity ID. The
* System entry is the default; another identity's list replaces it. */
interface IdentityGrants {
root: string[] | null;
identities?: Record<string, string[]>;
identities?: Record<string, string[] | null>;
}
const SYSTEM_ID = "00000000-0000-5000-8000-000000000001";
const KIND = "identity-grants";
const store = useSettingsStore();
const org = useOrgStore();
@@ -35,16 +35,15 @@ const addable = computed(() =>
org.activeIdentities.filter((a) => a.kind !== "user" && a.kind !== "system" && !(a.id in (grants.value?.identities ?? {}))),
);
const others = computed(() => Object.entries(grants.value?.identities ?? {}).filter(([id]) => id !== SYSTEM_ID));
// Identity ids are free text, so identities are written as whole maps rather
// than by a dotted per-id path.
function setRoot(services: string[]) {
form.value?.api.setFieldValue("root", services);
}
function setIdentity(id: string, services: string[]) {
form.value?.api.setFieldValue("identities", (prev: Record<string, string[]> | undefined) => ({ ...prev, [id]: services }));
form.value?.api.setFieldValue("identities", (prev: Record<string, string[] | null> | undefined) => ({ ...prev, [id]: services }));
}
function removeIdentity(id: string) {
form.value?.api.setFieldValue("identities", (prev: Record<string, string[]> | undefined) => {
form.value?.api.setFieldValue("identities", (prev: Record<string, string[] | null> | undefined) => {
const { [id]: _, ...rest } = prev ?? {};
return rest;
});
@@ -58,14 +57,14 @@ function removeIdentity(id: string) {
<ItemGroup v-if="grants">
<Item as="div" role="listitem" variant="outline" size="sm" class="flex-wrap">
<span class="w-40 shrink-0 text-label max-sm:w-24 max-sm:truncate">Default</span>
<ToggleGroup class="flex-wrap" type="multiple" variant="outline" size="sm" :model-value="grants.root ?? []" aria-label="Default grants" @update:model-value="(v) => setRoot(v as string[])">
<ToggleGroup class="flex-wrap" type="multiple" variant="outline" size="sm" :model-value="grants.identities?.[SYSTEM_ID] ?? []" aria-label="Default grants" @update:model-value="(v) => setIdentity(SYSTEM_ID, v as string[])">
<ToggleGroupItem v-for="service in store.credentialServices" :key="service" :value="service" class="font-mono text-caption">{{ service }}</ToggleGroupItem>
</ToggleGroup>
<DraftHint :kind="KIND" path="root" />
<DraftHint :kind="KIND" path="identities" />
</Item>
<Item v-for="(services, id) in grants.identities" :key="id" as="div" role="listitem" variant="outline" size="sm">
<Item v-for="[id, services] in others" :key="id" as="div" role="listitem" variant="outline" size="sm">
<span class="w-40 shrink-0 truncate text-label max-sm:w-24">{{ org.identityName(String(id)) }}</span>
<ToggleGroup class="flex-wrap" type="multiple" variant="outline" size="sm" :model-value="services" :aria-label="`${org.identityName(String(id))} grants`" @update:model-value="(v) => setIdentity(String(id), v as string[])">
<ToggleGroup class="flex-wrap" type="multiple" variant="outline" size="sm" :model-value="services ?? []" :aria-label="`${org.identityName(String(id))} grants`" @update:model-value="(v) => setIdentity(String(id), v as string[])">
<ToggleGroupItem v-for="service in store.credentialServices" :key="service" :value="service" class="font-mono text-caption">{{ service }}</ToggleGroupItem>
</ToggleGroup>
<Button variant="ghost" size="sm" class="ml-auto" :aria-label="`Remove ${org.identityName(String(id))}`" @click="removeIdentity(String(id))"><X /></Button>