@sema-agent/core
Version:
Stateless, task-oriented AI agent core
45 lines (44 loc) • 2.96 kB
TypeScript
/**
* design/98 §6.3 — the ONE reading of "is this governance baseline usable", shared by the deployment
* CAPABILITY predicate (`workflowsCapability`, which drives the surfaced `/workflows` affordance AND
* the orchestration-prompt injection) and the MOUNT-time validator (`createRunWorkflowTool`, which
* refuses loudly with a code).
*
* Why one function rather than two agreeing predicates: this seam split three times inside one
* release window, each time one level deeper. First the capability tested `!== undefined` while the
* mount tested truthiness (a JSON `null` announced workflows the tool never mounted). Then both
* tested the container while the mount refused an unusable `base` SLOT (`{ base: null }` announced
* workflows that hard-failed every opted-in task). Then the slot readings agreed but the mount
* additionally refused a malformed `worktreeBase` and malformed face lists — the same split again,
* one field further in. Two predicates that must "stay in agreement" are a standing invitation to
* drift; the only shape that cannot drift is a single function both call.
*
* The contract: {@link governanceBaselineProblem} returns `null` when the mount would SUCCEED, and
* a describable problem when the mount would REFUSE. Every mount-time refusal must be reachable
* from here, so a deployment is never told it has workflows it cannot actually run.
*/
export interface GovernanceBaselineProblem {
/** Which slot/field is wrong, in the spelling a deployment configures (`base.excludeTools`). */
readonly where: string;
/** What was found there, for the operator-facing message (`null`, `a string`, `an array`). */
readonly found: string;
/** The coded refusal the mount raises for this problem. */
readonly code: "config.invalid_governance_baseline" | "config.invalid_tool_name_set";
}
/** Name a bad value WITHOUT throwing on it (a bigint / cyclic object / poisoned `toJSON` must not
* crash the describer and cost the refusal its name). */
export declare function describeBaselineValue(v: unknown): string;
/**
* The single validity reading. `null` ⇒ the mount would succeed ⇒ the capability may be announced.
*
* `base` is the control plane every script-spawned child inherits, so a non-object there refuses:
* ungoverned is spelled by not configuring `workflowGovernanceBaseline` at all, never by an
* unusable anchor. `worktreeBase` is the optional overlay whose documented absence means "base
* governs every child" — `null`/absent is that absence, any other non-object is garbage and refuses
* rather than impersonating either absence or an overlay.
*/
export declare function governanceBaselineProblem(baseline: unknown): GovernanceBaselineProblem | null;
/** The mount's refusal, minted from the shared reading so the message and the code have one home. */
export declare function governanceBaselineError(p: GovernanceBaselineProblem): Error & {
code: string;
};