```ts
export function resolveAccess(
  rules: Array<{ effect: string; action: string; path: string[] }>,
  request: { action: string; path: string[] }
): { decision: string; rule: number } {
  if (request.action === "") {
    throw new Error("Request action cannot be empty");
  }

  let bestDecision = "deny";
  let bestRuleIndex = -1;

  for (let i = 0; i < rules.length; i++) {
    const rule = rules[i];

    if (rule.effect !== "allow" && rule.effect !== "deny") {
      throw new Error("Invalid rule effect");
    }

    if (rule.action === "" || request.action === "") {
      throw new Error("Action cannot be empty");
    }

    const pathMatch = rule.path.every((segment, index) => segment === request.path[index]);
    const actionMatch = rule.action === "any" || rule.action === request.action;

    if (pathMatch && actionMatch) {
      if (
        rule.path.length > rules[bestRuleIndex]?.path.length ||
        (rule.path.length === rules[bestRuleIndex]?.path.length &&
          rule.action !== "any" &&
          rules[bestRuleIndex]?.action === "any") ||
        (rule.path.length === rules[bestRuleIndex]?.path.length &&
          rule.action === rules[bestRuleIndex]?.action &&
          rule.effect === "deny")
      ) {
        bestDecision = rule.effect;
        bestRuleIndex = i;
      }
    }
  }

  return { decision: bestDecision, rule: bestRuleIndex };
}
```