docs: document sdk dedupe and group contracts

This commit is contained in:
Peter Steinberger
2026-06-04 22:27:50 -04:00
parent a4087c54b5
commit de4571da4b
3 changed files with 14 additions and 0 deletions
+6
View File
@@ -9,34 +9,40 @@ import type { GroupPolicy } from "../config/types.base.js";
export { resolveOpenProviderRuntimeGroupPolicy };
export type { GroupPolicy };
/** Reason code returned when evaluating a sender against group policy. */
export type SenderGroupAccessReason =
| "allowed"
| "disabled"
| "empty_allowlist"
| "sender_not_allowlisted";
/** Sender-level group access decision plus the effective group policy. */
export type SenderGroupAccessDecision = {
allowed: boolean;
groupPolicy: GroupPolicy;
providerMissingFallbackApplied: boolean;
reason: SenderGroupAccessReason;
};
/** Reason code returned when evaluating a configured group route. */
export type GroupRouteAccessReason =
| "allowed"
| "disabled"
| "empty_allowlist"
| "route_not_allowlisted"
| "route_disabled";
/** Route-level group access decision plus the effective group policy. */
export type GroupRouteAccessDecision = {
allowed: boolean;
groupPolicy: GroupPolicy;
reason: GroupRouteAccessReason;
};
/** Reason code returned when evaluating a precomputed allowlist match. */
export type MatchedGroupAccessReason =
| "allowed"
| "disabled"
| "missing_match_input"
| "empty_allowlist"
| "not_allowlisted";
/** Matched-input group access decision plus the effective group policy. */
export type MatchedGroupAccessDecision = {
allowed: boolean;
groupPolicy: GroupPolicy;
+6
View File
@@ -7,6 +7,7 @@ import { readJsonFileWithFallback, writeJsonFileAtomically } from "./json-store.
type PersistentDedupeData = Record<string, number>;
/** Configuration for a disk-backed dedupe namespace cache. */
export type PersistentDedupeOptions = {
/** Milliseconds a recorded key remains recent; `0` keeps keys until cache pruning. */
ttlMs: number;
@@ -20,6 +21,7 @@ export type PersistentDedupeOptions = {
onDiskError?: (error: unknown) => void;
};
/** Per-call options used when checking or recording a dedupe key. */
export type PersistentDedupeCheckOptions = {
/** Logical bucket for the key; omitted/blank values use `global`. */
namespace?: string;
@@ -29,6 +31,7 @@ export type PersistentDedupeCheckOptions = {
onDiskError?: (error: unknown) => void;
};
/** Disk-backed dedupe guard that records recently seen keys per namespace. */
export type PersistentDedupe = {
/** Returns true only when the key was not recently seen and was recorded for future checks. */
checkAndRecord: (key: string, options?: PersistentDedupeCheckOptions) => Promise<boolean>;
@@ -42,11 +45,13 @@ export type PersistentDedupe = {
memorySize: () => number;
};
/** Claim attempt result for dedupe flows that need in-flight ownership. */
export type ClaimableDedupeClaimResult =
| { kind: "claimed" }
| { kind: "duplicate" }
| { kind: "inflight"; pending: Promise<boolean> };
/** Options for a claimable dedupe guard, either persistent or memory-only. */
export type ClaimableDedupeOptions =
| {
ttlMs: number;
@@ -65,6 +70,7 @@ export type ClaimableDedupeOptions =
onDiskError?: undefined;
};
/** Dedupe guard that lets one caller own a key while others wait or detect duplicates. */
export type ClaimableDedupe = {
/** Starts ownership of a key, reports duplicates, or returns the active claim's pending result. */
claim: (
+2
View File
@@ -42,6 +42,7 @@ export function resolveRuntimeEnv(params: {
logger: LoggerLike;
exitError?: (code: number) => Error;
}): RuntimeEnv;
/** @deprecated Import from `openclaw/plugin-sdk/runtime` instead. */
export function resolveRuntimeEnv(params: {
runtime?: undefined;
logger: LoggerLike;
@@ -61,6 +62,7 @@ export function resolveRuntimeEnvWithUnavailableExit(params: {
logger: LoggerLike;
unavailableMessage?: string;
}): RuntimeEnv;
/** @deprecated Import from `openclaw/plugin-sdk/runtime` instead. */
export function resolveRuntimeEnvWithUnavailableExit(params: {
runtime?: undefined;
logger: LoggerLike;