MCPcopy Create free account
hub / github.com/compozy/agh / validateExplicitRunClaimOwner

Function validateExplicitRunClaimOwner

internal/task/manager.go:1856–1889  ·  view source on GitHub ↗
(taskRecord Task, actor ActorContext)

Source from the content-addressed store, hash-verified

1854}
1855
1856func validateExplicitRunClaimOwner(taskRecord Task, actor ActorContext) error {
1857 if taskRecord.Owner == nil || taskRecord.Owner.IsZero() {
1858 return nil
1859 }
1860 owner := *taskRecord.Owner
1861 ref := strings.TrimSpace(owner.Ref)
1862 switch owner.Kind.Normalize() {
1863 case OwnerKindPool:
1864 return fmt.Errorf(
1865 "%w: task %q is assigned to pool owner %q and must be claimed by the matching agent session",
1866 ErrPermissionDenied,
1867 taskRecord.ID,
1868 ref,
1869 )
1870 case OwnerKindAgentSession:
1871 switch actor.Actor.Kind.Normalize() {
1872 case ActorKindDaemon:
1873 return nil
1874 case ActorKindAgentSession:
1875 if strings.TrimSpace(actor.Actor.Ref) == ref {
1876 return nil
1877 }
1878 default:
1879 }
1880 return fmt.Errorf(
1881 "%w: task %q is assigned to agent session %q",
1882 ErrPermissionDenied,
1883 taskRecord.ID,
1884 ref,
1885 )
1886 default:
1887 return nil
1888 }
1889}
1890
1891// ClaimRun transitions one queued run into the claimed state.
1892func (m *Service) ClaimRun(

Callers 1

ClaimRunMethod · 0.85

Calls 2

IsZeroMethod · 0.45
NormalizeMethod · 0.45

Tested by

no test coverage detected