/**
 * ServiceContractGate — runtime enforcement of team `ServiceContract`s.
 *
 * Cross-team requests must pass through the gate before a WorkItem is
 * enqueued on the target team's pool. The gate makes a pure-function
 * decision by matching the requested `requestType` string against the
 * target team's `serviceContract.accepts` and `serviceContract.avoids`
 * phrases.
 *
 * Design choices:
 * - **No LLM.** Plain case-insensitive substring match — predictable and
 *   cheap enough to run on every dispatch.
 * - **Fail closed.** If `accepts` is missing, empty, or matches nothing,
 *   the request is rejected. Teams must explicitly declare what they take.
 * - **`avoids` beats `accepts`.** An avoided phrase wins even if the
 *   request also matches an accepted phrase — the negative signal is
 *   assumed stronger (e.g. "frontend bugfix" is accepted but "production
 *   frontend bugfix" is avoided).
 * - **Same-team requests skip the gate.** Teams don't contract with
 *   themselves; internal work flows normally.
 *
 * Wired into the task-pool `addItem` flow via `maybeEnforceContract` in
 * `controllers/task-pool/task-pool.controller.ts`. The service itself is
 * stateless and standalone so it can also be called from skills or a
 * future ServiceGateway layer.
 *
 * @module services/v3/service-contract-gate.service
 */
import type { Team } from '../../types/index.js';
export { matchRule } from './contract-matcher.js';
/**
 * Reason codes for a rejected request. Callers use these to produce a
 * targeted error message (e.g. "out of scope" vs "ambiguous, please
 * specify a supported service type").
 */
export type GateRejectionReason = 'missing_target' | 'missing_request_type' | 'no_contract' | 'empty_contract' | 'in_avoids' | 'no_match';
/**
 * The decision returned by the gate.
 */
export type GateDecision = {
    outcome: 'accept';
    /** The accepts[] phrase that matched the request. */
    matchedRule: string;
} | {
    outcome: 'reject';
    reason: GateRejectionReason;
    /** Which rule matched (only populated for `in_avoids`). */
    matchedRule?: string;
    /** Human-readable explanation suitable for surfacing to the requester. */
    message: string;
};
/**
 * Inputs the gate needs to make a decision.
 */
export interface GateRequest {
    /** Team making the request. Optional — undefined means "external/user". */
    fromTeamId?: string;
    /** Team that would receive the work. */
    toTeam: Team | undefined;
    /** Free-text description of the requested service type (short phrase). */
    requestType: string;
}
/**
 * Stateless gate that evaluates a cross-team request against the target's
 * `ServiceContract`. Safe to instantiate once and reuse, or to call
 * {@link check} via an ad-hoc instance.
 *
 * @example
 * ```typescript
 * const gate = new ServiceContractGate();
 * const decision = gate.check({
 *   fromTeamId: 'marketing',
 *   toTeam: engineeringTeam,
 *   requestType: 'frontend bugfix',
 * });
 * if (decision.outcome === 'reject') {
 *   throw new Error(decision.message);
 * }
 * ```
 */
export declare class ServiceContractGate {
    /**
     * Decide whether the target team may accept this request.
     *
     * @param req - Request details (from, to, type)
     * @returns Structured decision with outcome + reason + message
     */
    check(req: GateRequest): GateDecision;
}
//# sourceMappingURL=service-contract-gate.service.d.ts.map