Files
archie/internal/daemon/repository_access.go
T
sam e3ffefdc7d
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
fix(identity): use System as the one root identity and record who created every task (#1851)
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.
2026-11-10 20:01:16 +11:00

51 lines
1.7 KiB
Go

package daemon
import (
"context"
"fmt"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/identity"
"github.com/samcharles93/archie-core/internal/domain/workflow"
workflowtask "github.com/samcharles93/archie-core/internal/domain/workflow/task"
"github.com/samcharles93/archie-core/internal/forge"
"github.com/samcharles93/archie-core/internal/worktree"
)
// RepositoryAccess holds host-side clients for one authorised operation.
// It is never included in the container handoff.
type RepositoryAccess struct {
Repository config.Repo
Connection config.ForgeConnection
Trees *worktree.Manager
Forge forge.Forge
}
// Repository resolves current credentials and permissions for the run's
// execution identity, never the identity that originally requested the task.
func (d *Daemon) Repository(ctx context.Context, task *workflow.Task, operation string) (RepositoryAccess, error) {
if d.ResolveRepository == nil {
return RepositoryAccess{}, fmt.Errorf("repository connections unavailable")
}
run := *task
if run.WorkflowDefinitionYAML != "" {
iface, err := workflowtask.ParseWorkflowInterface(run.WorkflowDefinitionYAML)
if err != nil || iface.Identity == "" {
return RepositoryAccess{}, fmt.Errorf("workflow execution identity unavailable")
}
_, name, err := d.declaredIdentity(ctx, &run, iface.Identity)
if err != nil {
return RepositoryAccess{}, err
}
run.Identity = name
}
ctx, err := d.workflowContext(ctx, &run)
if err != nil {
return RepositoryAccess{}, err
}
if _, err := d.databaseExecutionIdentity(ctx, &run, identity.IdentityID(run.Identity)); err != nil {
return RepositoryAccess{}, err
}
return d.ResolveRepository(ctx, &run, operation)
}