@hasna/projects
Version:
High-level project management CLI, MCP server, SDK, and AI SDK agent loop for coding agents
62 lines • 4 kB
TypeScript
import type { GuardedProjectMutationBounds, GuardedProjectMutationControl, GuardedProjectMutationDirection, GuardedProjectReadRequest, GuardedProjectReadResult, GuardedProjectMutationReceipt, GuardedProjectMutationReceiptRow, JsonObject, ProjectResourceLink, UpdateWorkspaceInput, Workspace } from "../types/workspace.js";
export declare const GUARDED_PROJECT_MUTATION_ROUTE = "projects.guarded-metadata-mutation.v1";
export declare const GUARDED_PROJECT_MUTATION_EVENT = "guarded_metadata_mutation";
export declare const GUARDED_PROJECT_MUTATION_ROLLBACK_EVENT = "guarded_metadata_mutation_rollback";
export declare const COMPLETE_STABLE_PROJECT_ID_PATTERN = "^wks_[A-Za-z0-9_-]{12,}$";
export declare function assertCompleteStableProjectId(value: string): void;
export declare function assertPositiveBounds(bounds: GuardedProjectMutationBounds): void;
export declare function canonicalJson(value: unknown): string;
export declare function sha256(value: string): string;
export declare function requestDigest(patch: UpdateWorkspaceInput): string;
export declare function preconditionDigest(input: {
project_id: string;
expected_revision: string;
}): string;
export declare function deriveGuardedIdempotencyKey(input: {
operation_id: string;
step_id: string;
direction: GuardedProjectMutationDirection;
target_id: string;
request_digest: string;
precondition_digest: string;
}): string;
export declare function normalizePatch(patch: UpdateWorkspaceInput): UpdateWorkspaceInput;
export declare function workspaceRevision(workspace: Workspace): string;
export declare function workspaceSnapshot(workspace: Workspace): JsonObject;
export declare function rowToGuardedReceipt(row: GuardedProjectMutationReceiptRow): GuardedProjectMutationReceipt;
export declare function timedOut(startedAtMs: number, timeBudgetMs: number): boolean;
export declare function responseControl(payload: unknown, bounds: GuardedProjectMutationBounds, startedAtMs: number, operation?: string, completeness?: Pick<GuardedProjectMutationControl, "complete" | "truncated">): GuardedProjectMutationControl;
export declare function withResponseControl<T extends Record<string, unknown>>(payload: T, bounds: GuardedProjectMutationBounds, startedAtMs: number, operation?: string, completeness?: Pick<GuardedProjectMutationControl, "complete" | "truncated">): T & {
response_control: GuardedProjectMutationControl;
};
export declare function buildGuardedProjectReadResult(project: Workspace, input: GuardedProjectReadRequest, startedAtMs: number, resourceLinks?: {
links: ProjectResourceLink[];
max_items: number;
collection_digest: string;
}): GuardedProjectReadResult;
/**
* The receipt identity for ONE logical guarded attempt.
*
* The id is a hash of the operation identity (operation/step/direction/
* idempotency key/outcome/target and, for a terminal outcome, its reason), so
* the same logical attempt always derives the same `receipt_id` — including a
* RETRY of an operation-id whose earlier attempt failed. Both receipt writers
* (`insertGuardedProjectMutationReceipt` locally, `PgStore.insertGuardedReceipt`
* hosted) therefore write idempotently: `ON CONFLICT (receipt_id) DO NOTHING`
* plus a read-back returns the first recorded row for that id instead of
* raising a primary-key violation, and a retry keeps the fail-closed outcome of
* the attempt that was actually recorded (A3-00870). Because that conflict path
* skips the AFTER-INSERT foreign-key check, each writer also re-checks the
* candidate's `target_id` itself when the insert inserted nothing. See the
* writer comments for the full contract; this function only fixes the identity.
*/
export declare function buildReceiptId(input: {
operation_id: string;
step_id: string;
direction: GuardedProjectMutationDirection;
idempotency_key: string;
outcome: string;
target_id: string;
suffix?: string;
}): string;
//# sourceMappingURL=guarded-project-mutation.d.ts.map