@wrongstack/governance 0.298.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +172 -0
- package/dist/admin-session.d.ts +56 -0
- package/dist/attachment-broker-controller.d.ts +73 -0
- package/dist/authenticated-project-service.d.ts +18 -0
- package/dist/autonomy-envelope.d.ts +40 -0
- package/dist/capability-grant.d.ts +122 -0
- package/dist/credential-lease-controller.d.ts +85 -0
- package/dist/daemon-control.d.ts +48 -0
- package/dist/daemon-launcher.d.ts +46 -0
- package/dist/daemon-metadata.d.ts +126 -0
- package/dist/daemon-protocol.d.ts +59 -0
- package/dist/event-store.d.ts +109 -0
- package/dist/evidence-candidate.d.ts +95 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.js +8468 -0
- package/dist/ipc-endpoint.d.ts +6 -0
- package/dist/ipc-protocol.d.ts +24 -0
- package/dist/legacy-shadow-adapter.d.ts +33 -0
- package/dist/management-receipt-cache.d.ts +53 -0
- package/dist/plan-version.d.ts +91 -0
- package/dist/project-client.d.ts +31 -0
- package/dist/project-daemon.d.ts +2 -0
- package/dist/project-daemon.js +5722 -0
- package/dist/project-server.d.ts +48 -0
- package/dist/project-service.d.ts +121 -0
- package/dist/protocol-decoder.d.ts +16 -0
- package/dist/runtime-compatibility.d.ts +99 -0
- package/dist/sanitize.d.ts +11 -0
- package/dist/service-protocol.d.ts +82 -0
- package/dist/task-aggregate.d.ts +92 -0
- package/dist/task-contract.d.ts +74 -0
- package/dist/transition-engine.d.ts +37 -0
- package/dist/verification-check-binding.d.ts +23 -0
- package/dist/verification-check-registry.d.ts +43 -0
- package/dist/verification-execution-lease.d.ts +76 -0
- package/dist/verification-issuance-coordinator.d.ts +110 -0
- package/dist/verification-ledger-store.d.ts +20 -0
- package/dist/verification-planner.d.ts +76 -0
- package/dist/verification-run-contract.d.ts +84 -0
- package/dist/verification-tool-gateway.d.ts +74 -0
- package/dist/workflow-state.d.ts +5 -0
- package/dist/workspace-snapshot-fence.d.ts +20 -0
- package/package.json +44 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { GovernanceAttachmentBrokerLifecycleEvent } from './attachment-broker-controller.js';
|
|
2
|
+
import { type GovernanceCapabilityGrantRegistryOptions, type IssuedGovernanceCapabilityGrant, type IssueGovernanceCapabilityGrantOptions } from './capability-grant.js';
|
|
3
|
+
import type { GovernanceDaemonControlPort, GovernanceDaemonShutdownNotice } from './daemon-control.js';
|
|
4
|
+
import { type GovernanceDecisionContextProvider } from './project-service.js';
|
|
5
|
+
export declare const GOVERNANCE_IPC_MAX_CONNECTIONS = 128;
|
|
6
|
+
export declare const GOVERNANCE_IPC_SOCKET_TIMEOUT_MS = 10000;
|
|
7
|
+
export interface GovernanceProjectServerOptions {
|
|
8
|
+
readonly projectRoot: string;
|
|
9
|
+
readonly projectId: string;
|
|
10
|
+
readonly resolveDecisionContext?: GovernanceDecisionContextProvider | undefined;
|
|
11
|
+
readonly grantRegistry?: Omit<GovernanceCapabilityGrantRegistryOptions, 'auditSink'> | undefined;
|
|
12
|
+
readonly daemonControl?: GovernanceDaemonControlPort | undefined;
|
|
13
|
+
readonly onDaemonShutdownResponseFlushed?: ((notice: GovernanceDaemonShutdownNotice) => void) | undefined;
|
|
14
|
+
}
|
|
15
|
+
export declare class GovernanceProjectServer {
|
|
16
|
+
readonly projectRoot: string;
|
|
17
|
+
readonly projectId: string;
|
|
18
|
+
readonly endpoint: string;
|
|
19
|
+
readonly databasePath: string;
|
|
20
|
+
private readonly options;
|
|
21
|
+
private readonly sockets;
|
|
22
|
+
private readonly pendingSockets;
|
|
23
|
+
private state;
|
|
24
|
+
private listener;
|
|
25
|
+
private store;
|
|
26
|
+
private authenticated;
|
|
27
|
+
private grants;
|
|
28
|
+
private lastListenerError;
|
|
29
|
+
constructor(options: GovernanceProjectServerOptions);
|
|
30
|
+
get storageOpen(): boolean;
|
|
31
|
+
get ready(): boolean;
|
|
32
|
+
get listenerError(): Error | null;
|
|
33
|
+
start(): Promise<void>;
|
|
34
|
+
issueGrant(options: IssueGovernanceCapabilityGrantOptions): IssuedGovernanceCapabilityGrant;
|
|
35
|
+
revokeGrant(grantId: string, reason?: string): boolean;
|
|
36
|
+
recordAttachmentBrokerEvent(event: GovernanceAttachmentBrokerLifecycleEvent): void;
|
|
37
|
+
close(): Promise<void>;
|
|
38
|
+
private ensureEndpointParent;
|
|
39
|
+
private listen;
|
|
40
|
+
private onConnection;
|
|
41
|
+
private accept;
|
|
42
|
+
private handleLine;
|
|
43
|
+
private send;
|
|
44
|
+
private persistGrantAuditEvent;
|
|
45
|
+
private persistDaemonShutdownAudit;
|
|
46
|
+
private closeListener;
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=project-server.d.ts.map
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import type { GovernanceAttachmentBrokerControllerSnapshot } from './attachment-broker-controller.js';
|
|
2
|
+
import type { GovernanceCapabilityGrant, GovernanceServiceCredential } from './capability-grant.js';
|
|
3
|
+
import type { AppendGovernanceObservationResult, GovernanceCommandExecution, GovernanceCommandReceipt, GovernanceEventStore, StoredGovernanceObservation } from './event-store.js';
|
|
4
|
+
import { type GovernanceEvidenceCandidateLedgerEntry } from './evidence-candidate.js';
|
|
5
|
+
import { GOVERNANCE_SERVICE_PROTOCOL_VERSION, type GovernanceServiceClientContext, type GovernanceServiceRequest } from './service-protocol.js';
|
|
6
|
+
import type { GovernanceCommand, GovernanceDecisionContext, GovernanceEvent, TaskAggregate } from './task-aggregate.js';
|
|
7
|
+
import type { RecordWorkspaceSnapshotResult } from './workspace-snapshot-fence.js';
|
|
8
|
+
export type { GovernanceServiceCapability, GovernanceServiceClientContext, GovernanceServiceRequest, } from './service-protocol.js';
|
|
9
|
+
export { GOVERNANCE_SERVICE_CAPABILITIES, GOVERNANCE_SERVICE_PROTOCOL_VERSION, } from './service-protocol.js';
|
|
10
|
+
export type GovernanceServiceResult = {
|
|
11
|
+
readonly type: 'health';
|
|
12
|
+
readonly projectId: string;
|
|
13
|
+
readonly protocolVersion: typeof GOVERNANCE_SERVICE_PROTOCOL_VERSION;
|
|
14
|
+
readonly status: 'ready';
|
|
15
|
+
} | {
|
|
16
|
+
readonly type: 'task';
|
|
17
|
+
readonly task: TaskAggregate | null;
|
|
18
|
+
} | {
|
|
19
|
+
readonly type: 'events';
|
|
20
|
+
readonly events: readonly GovernanceEvent[];
|
|
21
|
+
} | {
|
|
22
|
+
readonly type: 'receipt';
|
|
23
|
+
readonly receipt: GovernanceCommandReceipt | null;
|
|
24
|
+
} | {
|
|
25
|
+
readonly type: 'observations';
|
|
26
|
+
readonly observations: readonly StoredGovernanceObservation[];
|
|
27
|
+
} | {
|
|
28
|
+
readonly type: 'evidence_candidates';
|
|
29
|
+
readonly taskId: string;
|
|
30
|
+
readonly candidates: readonly GovernanceEvidenceCandidateLedgerEntry[];
|
|
31
|
+
readonly nextAfterSequence: number | null;
|
|
32
|
+
} | {
|
|
33
|
+
readonly type: 'command_result';
|
|
34
|
+
readonly execution: GovernanceCommandExecution;
|
|
35
|
+
} | {
|
|
36
|
+
readonly type: 'observation_result';
|
|
37
|
+
readonly result: AppendGovernanceObservationResult;
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: 'workspace_snapshot_recorded';
|
|
40
|
+
readonly result: RecordWorkspaceSnapshotResult;
|
|
41
|
+
} | {
|
|
42
|
+
readonly type: 'capability_grant_issued';
|
|
43
|
+
readonly grant: GovernanceCapabilityGrant;
|
|
44
|
+
readonly credential: GovernanceServiceCredential;
|
|
45
|
+
} | {
|
|
46
|
+
readonly type: 'runtime_attachment_claimed';
|
|
47
|
+
readonly control: {
|
|
48
|
+
readonly grant: GovernanceCapabilityGrant;
|
|
49
|
+
readonly credential: GovernanceServiceCredential;
|
|
50
|
+
};
|
|
51
|
+
readonly model: {
|
|
52
|
+
readonly grant: GovernanceCapabilityGrant;
|
|
53
|
+
readonly credential: GovernanceServiceCredential;
|
|
54
|
+
};
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: 'runtime_attachment_released';
|
|
57
|
+
readonly controlGrantId: string;
|
|
58
|
+
readonly modelGrantId: string;
|
|
59
|
+
} | {
|
|
60
|
+
readonly type: 'own_capability_grant';
|
|
61
|
+
readonly grant: GovernanceCapabilityGrant;
|
|
62
|
+
} | {
|
|
63
|
+
readonly type: 'daemon_status';
|
|
64
|
+
readonly projectId: string;
|
|
65
|
+
readonly pid: number;
|
|
66
|
+
readonly instanceId: string;
|
|
67
|
+
readonly startedAt: string;
|
|
68
|
+
readonly attachmentBroker?: GovernanceAttachmentBrokerControllerSnapshot | undefined;
|
|
69
|
+
} | {
|
|
70
|
+
readonly type: 'daemon_shutdown_accepted';
|
|
71
|
+
readonly instanceId: string;
|
|
72
|
+
readonly requestedBy: string;
|
|
73
|
+
readonly reason: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: 'capability_grants';
|
|
76
|
+
readonly grants: readonly GovernanceCapabilityGrant[];
|
|
77
|
+
readonly nextCursor?: string | undefined;
|
|
78
|
+
} | {
|
|
79
|
+
readonly type: 'capability_grant_revoked';
|
|
80
|
+
readonly grantId: string;
|
|
81
|
+
readonly revoked: boolean;
|
|
82
|
+
} | {
|
|
83
|
+
readonly type: 'capability_grant_rotated';
|
|
84
|
+
readonly previousGrantId: string;
|
|
85
|
+
readonly grant: GovernanceCapabilityGrant;
|
|
86
|
+
readonly credential: GovernanceServiceCredential;
|
|
87
|
+
};
|
|
88
|
+
export type GovernanceServiceErrorCode = 'unsupported_protocol' | 'invalid_request' | 'authentication_failed' | 'permission_denied' | 'identity_mismatch' | 'project_mismatch' | 'store_failure' | 'request_in_progress';
|
|
89
|
+
export type GovernanceServiceResponse = {
|
|
90
|
+
readonly ok: true;
|
|
91
|
+
readonly requestId: string;
|
|
92
|
+
readonly result: GovernanceServiceResult;
|
|
93
|
+
} | {
|
|
94
|
+
readonly ok: false;
|
|
95
|
+
readonly requestId: string;
|
|
96
|
+
readonly error: {
|
|
97
|
+
readonly code: GovernanceServiceErrorCode;
|
|
98
|
+
readonly message: string;
|
|
99
|
+
readonly details?: readonly {
|
|
100
|
+
readonly code: string;
|
|
101
|
+
readonly path: string;
|
|
102
|
+
readonly message: string;
|
|
103
|
+
}[] | undefined;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export type GovernanceDecisionContextProvider = (command: GovernanceCommand) => GovernanceDecisionContext;
|
|
107
|
+
export declare class GovernanceProjectService {
|
|
108
|
+
readonly projectId: string;
|
|
109
|
+
private readonly store;
|
|
110
|
+
/** Trusted policy adapter owned by the future daemon, never selected by request payloads. */
|
|
111
|
+
private readonly resolveDecisionContext;
|
|
112
|
+
constructor(projectId: string, store: GovernanceEventStore,
|
|
113
|
+
/** Trusted policy adapter owned by the future daemon, never selected by request payloads. */
|
|
114
|
+
resolveDecisionContext?: GovernanceDecisionContextProvider);
|
|
115
|
+
handleUnknown(input: unknown, client: GovernanceServiceClientContext): GovernanceServiceResponse;
|
|
116
|
+
handle(request: GovernanceServiceRequest, client: GovernanceServiceClientContext): GovernanceServiceResponse;
|
|
117
|
+
close(): void;
|
|
118
|
+
private handleAuthorized;
|
|
119
|
+
private commandBelongsToProject;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=project-service.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type GovernanceServiceRequest } from './service-protocol.js';
|
|
2
|
+
export type GovernanceProtocolDecodeIssueCode = 'expected_object' | 'expected_array' | 'unknown_field' | 'invalid_value' | 'semantic_invalid' | 'resource_limit';
|
|
3
|
+
export interface GovernanceProtocolDecodeIssue {
|
|
4
|
+
readonly code: GovernanceProtocolDecodeIssueCode;
|
|
5
|
+
readonly path: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
}
|
|
8
|
+
export type GovernanceServiceRequestDecodeResult = {
|
|
9
|
+
readonly decoded: true;
|
|
10
|
+
readonly request: GovernanceServiceRequest;
|
|
11
|
+
} | {
|
|
12
|
+
readonly decoded: false;
|
|
13
|
+
readonly issues: readonly GovernanceProtocolDecodeIssue[];
|
|
14
|
+
};
|
|
15
|
+
export declare function decodeGovernanceServiceRequest(input: unknown): GovernanceServiceRequestDecodeResult;
|
|
16
|
+
//# sourceMappingURL=protocol-decoder.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { type ConnectGovernanceAdminSessionOptions, type ConnectGovernanceAdminSessionResult, type GovernanceAdminSession, type GovernanceAdminSessionLeaseOptions, type GovernanceAdminSessionSnapshot } from './admin-session.js';
|
|
2
|
+
import { type GovernanceCapabilityGrant, type GovernanceServiceCredential } from './capability-grant.js';
|
|
3
|
+
import { type GovernanceProjectDaemonLaunch, launchGovernanceProjectDaemon } from './daemon-launcher.js';
|
|
4
|
+
import { type GovernanceDaemonMetadata, inspectGovernanceDaemon, readGovernanceDaemonAttachmentBroker } from './daemon-metadata.js';
|
|
5
|
+
import { connectGovernanceProjectClient, GovernanceProjectClient } from './project-client.js';
|
|
6
|
+
import type { GovernanceServiceResponse } from './project-service.js';
|
|
7
|
+
import { type GovernanceRuntimeModelCapability } from './service-protocol.js';
|
|
8
|
+
export declare const GOVERNANCE_COMPATIBILITY_ADMIN_TTL_MS: number;
|
|
9
|
+
export declare const GOVERNANCE_COMPATIBILITY_MODEL_TTL_MS: number;
|
|
10
|
+
export type GovernanceModelCapability = GovernanceRuntimeModelCapability;
|
|
11
|
+
export interface ExistingGovernanceAdminCredential {
|
|
12
|
+
readonly grantId: string;
|
|
13
|
+
readonly credential: GovernanceServiceCredential;
|
|
14
|
+
}
|
|
15
|
+
export interface PrepareGovernanceCompatibilityOptions {
|
|
16
|
+
readonly projectRoot: string;
|
|
17
|
+
readonly projectId: string;
|
|
18
|
+
readonly adminClientId: string;
|
|
19
|
+
readonly modelClientId: string;
|
|
20
|
+
readonly modelCapabilities: readonly GovernanceModelCapability[];
|
|
21
|
+
readonly adminTtlMs?: number | undefined;
|
|
22
|
+
readonly modelTtlMs?: number | undefined;
|
|
23
|
+
readonly timeoutMs?: number | undefined;
|
|
24
|
+
readonly existingAdmin?: ExistingGovernanceAdminCredential | undefined;
|
|
25
|
+
readonly adminLease?: GovernanceAdminSessionLeaseOptions | undefined;
|
|
26
|
+
}
|
|
27
|
+
export type GovernanceCompatibilityFallbackCode = 'invalid_options' | 'inspection_failed' | 'existing_owner_requires_credential' | 'unsafe_daemon_state' | 'attachment_rejected' | 'launch_failed' | 'admin_session_rejected' | 'model_grant_rejected' | 'model_connection_rejected';
|
|
28
|
+
export type GovernanceCompatibilityCleanup = 'not_required' | 'admin_session_stopped' | 'attachment_grants_released' | 'launched_daemon_shutdown_requested' | 'cleanup_failed' | 'unavailable';
|
|
29
|
+
export interface GovernanceCompatibilityFallback {
|
|
30
|
+
readonly mode: 'legacy';
|
|
31
|
+
readonly code: GovernanceCompatibilityFallbackCode;
|
|
32
|
+
readonly phase: 'validate' | 'inspect' | 'attach' | 'launch' | 'provision';
|
|
33
|
+
readonly message: string;
|
|
34
|
+
readonly cleanup: GovernanceCompatibilityCleanup;
|
|
35
|
+
}
|
|
36
|
+
export interface GovernanceModelSessionSnapshot {
|
|
37
|
+
readonly projectId: string;
|
|
38
|
+
readonly clientId: string;
|
|
39
|
+
readonly grantId: string;
|
|
40
|
+
readonly capabilities: readonly GovernanceModelCapability[];
|
|
41
|
+
readonly expiresAt: string;
|
|
42
|
+
}
|
|
43
|
+
declare const GOVERNANCE_MODEL_SESSION_CONSTRUCTION: unique symbol;
|
|
44
|
+
export declare class GovernanceModelSession {
|
|
45
|
+
#private;
|
|
46
|
+
constructor(construction: typeof GOVERNANCE_MODEL_SESSION_CONSTRUCTION, client: GovernanceProjectClient, grant: GovernanceCapabilityGrant);
|
|
47
|
+
request(input: unknown): Promise<GovernanceServiceResponse>;
|
|
48
|
+
snapshot(): GovernanceModelSessionSnapshot;
|
|
49
|
+
}
|
|
50
|
+
export interface GovernanceCompatibilityRuntimeSnapshot {
|
|
51
|
+
readonly source: 'attached' | 'launched';
|
|
52
|
+
readonly closed: boolean;
|
|
53
|
+
readonly daemon: GovernanceAdminSessionSnapshot['daemon'];
|
|
54
|
+
readonly control: {
|
|
55
|
+
readonly kind: 'admin' | 'attachment';
|
|
56
|
+
readonly clientId: string;
|
|
57
|
+
readonly grantId: string;
|
|
58
|
+
readonly expiresAt: string;
|
|
59
|
+
};
|
|
60
|
+
readonly admin: GovernanceAdminSessionSnapshot | null;
|
|
61
|
+
readonly model: GovernanceModelSessionSnapshot;
|
|
62
|
+
}
|
|
63
|
+
type GovernanceCompatibilityControl = {
|
|
64
|
+
readonly kind: 'admin';
|
|
65
|
+
readonly session: GovernanceAdminSession;
|
|
66
|
+
} | {
|
|
67
|
+
readonly kind: 'attachment';
|
|
68
|
+
readonly client: GovernanceProjectClient;
|
|
69
|
+
readonly metadata: GovernanceDaemonMetadata;
|
|
70
|
+
readonly grant: GovernanceCapabilityGrant;
|
|
71
|
+
};
|
|
72
|
+
declare const GOVERNANCE_COMPATIBILITY_RUNTIME_CONSTRUCTION: unique symbol;
|
|
73
|
+
export declare class GovernanceCompatibilityRuntime {
|
|
74
|
+
#private;
|
|
75
|
+
readonly model: GovernanceModelSession;
|
|
76
|
+
constructor(construction: typeof GOVERNANCE_COMPATIBILITY_RUNTIME_CONSTRUCTION, source: 'attached' | 'launched', control: GovernanceCompatibilityControl, model: GovernanceModelSession);
|
|
77
|
+
snapshot(): GovernanceCompatibilityRuntimeSnapshot;
|
|
78
|
+
close(): Promise<GovernanceServiceResponse | null>;
|
|
79
|
+
shutdownDaemon(reason?: string): Promise<GovernanceServiceResponse>;
|
|
80
|
+
recordWorkspaceSnapshot(manifestHash: string): Promise<GovernanceServiceResponse>;
|
|
81
|
+
private revokeModelGrant;
|
|
82
|
+
}
|
|
83
|
+
export type PrepareGovernanceCompatibilityResult = {
|
|
84
|
+
readonly mode: 'governed';
|
|
85
|
+
readonly runtime: GovernanceCompatibilityRuntime;
|
|
86
|
+
} | GovernanceCompatibilityFallback;
|
|
87
|
+
interface GovernanceCompatibilityAdapters {
|
|
88
|
+
readonly inspect: typeof inspectGovernanceDaemon;
|
|
89
|
+
readonly launch: typeof launchGovernanceProjectDaemon;
|
|
90
|
+
readonly connectAttached: (options: ConnectGovernanceAdminSessionOptions) => Promise<ConnectGovernanceAdminSessionResult>;
|
|
91
|
+
readonly connectLaunched: (launch: GovernanceProjectDaemonLaunch, options?: GovernanceAdminSessionLeaseOptions) => Promise<ConnectGovernanceAdminSessionResult>;
|
|
92
|
+
readonly connectModel: typeof connectGovernanceProjectClient;
|
|
93
|
+
readonly readAttachmentBroker: typeof readGovernanceDaemonAttachmentBroker;
|
|
94
|
+
}
|
|
95
|
+
export declare function prepareGovernanceCompatibilityRuntime(options: PrepareGovernanceCompatibilityOptions): Promise<PrepareGovernanceCompatibilityResult>;
|
|
96
|
+
/** Internal source-test seam. Package consumers use prepareGovernanceCompatibilityRuntime. */
|
|
97
|
+
export declare function prepareGovernanceCompatibilityRuntimeWithAdapters(options: PrepareGovernanceCompatibilityOptions, adapters: GovernanceCompatibilityAdapters): Promise<PrepareGovernanceCompatibilityResult>;
|
|
98
|
+
export {};
|
|
99
|
+
//# sourceMappingURL=runtime-compatibility.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redact governance credentials (`wsg_`-prefixed tokens) from a message and
|
|
3
|
+
* cap its length. Single source of truth for the whole workspace — imported by
|
|
4
|
+
* the governance runtime-compatibility and credential-lease paths, and
|
|
5
|
+
* re-exported by `@wrongstack/runtime/governance-sanitize` for the CLI's
|
|
6
|
+
* legacy-fallback path. Lives in `@wrongstack/governance` (a dependency-free
|
|
7
|
+
* leaf package) so both governance and runtime can use it without an import
|
|
8
|
+
* cycle (runtime depends on governance, never the reverse).
|
|
9
|
+
*/
|
|
10
|
+
export declare function sanitizeGovernanceMessage(message: string): string;
|
|
11
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { GovernanceObservation } from './event-store.js';
|
|
2
|
+
import type { GovernanceCommand } from './task-aggregate.js';
|
|
3
|
+
export declare const GOVERNANCE_SERVICE_PROTOCOL_VERSION: 1;
|
|
4
|
+
export declare const GOVERNANCE_SERVICE_CAPABILITIES: readonly ['task_read', 'audit_read', 'command_submit', 'shadow_observe', 'workspace_snapshot_record', 'runtime_attach', 'runtime_attachment_release', 'daemon_status_read', 'capability_admin', 'daemon_control'];
|
|
5
|
+
export type GovernanceServiceCapability = (typeof GOVERNANCE_SERVICE_CAPABILITIES)[number];
|
|
6
|
+
export declare const GOVERNANCE_RUNTIME_MODEL_CAPABILITIES: readonly ["task_read", "audit_read", "command_submit", "shadow_observe"];
|
|
7
|
+
export type GovernanceRuntimeModelCapability = (typeof GOVERNANCE_RUNTIME_MODEL_CAPABILITIES)[number];
|
|
8
|
+
export interface GovernanceServiceClientContext {
|
|
9
|
+
readonly clientId: string;
|
|
10
|
+
/** Assigned by the transport/policy layer, never accepted from request payloads. */
|
|
11
|
+
readonly capabilities: ReadonlySet<GovernanceServiceCapability>;
|
|
12
|
+
}
|
|
13
|
+
export interface GovernanceServiceRequestMetadata {
|
|
14
|
+
readonly protocolVersion: typeof GOVERNANCE_SERVICE_PROTOCOL_VERSION;
|
|
15
|
+
readonly requestId: string;
|
|
16
|
+
}
|
|
17
|
+
export type GovernanceServiceRequest = GovernanceServiceRequestMetadata & ({
|
|
18
|
+
readonly type: 'health';
|
|
19
|
+
} | {
|
|
20
|
+
readonly type: 'read_task';
|
|
21
|
+
readonly taskId: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly type: 'read_events';
|
|
24
|
+
readonly taskId: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly type: 'read_receipt';
|
|
27
|
+
readonly commandId: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly type: 'read_observations';
|
|
30
|
+
readonly taskId?: string | undefined;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: 'read_evidence_candidates';
|
|
33
|
+
readonly taskId: string;
|
|
34
|
+
readonly afterSequence?: number | undefined;
|
|
35
|
+
readonly limit?: number | undefined;
|
|
36
|
+
} | {
|
|
37
|
+
readonly type: 'read_audit_observations';
|
|
38
|
+
} | {
|
|
39
|
+
readonly type: 'read_own_capability_grant';
|
|
40
|
+
} | {
|
|
41
|
+
readonly type: 'read_daemon_status';
|
|
42
|
+
} | {
|
|
43
|
+
readonly type: 'request_daemon_shutdown';
|
|
44
|
+
readonly expectedInstanceId: string;
|
|
45
|
+
readonly reason?: string | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
readonly type: 'submit_command';
|
|
48
|
+
readonly command: GovernanceCommand;
|
|
49
|
+
} | {
|
|
50
|
+
readonly type: 'record_observation';
|
|
51
|
+
readonly observation: GovernanceObservation;
|
|
52
|
+
} | {
|
|
53
|
+
readonly type: 'record_workspace_snapshot';
|
|
54
|
+
readonly manifestHash: string;
|
|
55
|
+
} | {
|
|
56
|
+
readonly type: 'issue_capability_grant';
|
|
57
|
+
readonly clientId: string;
|
|
58
|
+
readonly capabilities: readonly GovernanceServiceCapability[];
|
|
59
|
+
readonly ttlMs: number;
|
|
60
|
+
} | {
|
|
61
|
+
readonly type: 'claim_runtime_attachment';
|
|
62
|
+
readonly controlClientId: string;
|
|
63
|
+
readonly modelClientId: string;
|
|
64
|
+
readonly modelCapabilities: readonly GovernanceRuntimeModelCapability[];
|
|
65
|
+
readonly ttlMs: number;
|
|
66
|
+
} | {
|
|
67
|
+
readonly type: 'release_runtime_attachment';
|
|
68
|
+
} | {
|
|
69
|
+
readonly type: 'list_capability_grants';
|
|
70
|
+
readonly cursor?: string | undefined;
|
|
71
|
+
readonly limit?: number | undefined;
|
|
72
|
+
} | {
|
|
73
|
+
readonly type: 'revoke_capability_grant';
|
|
74
|
+
readonly grantId: string;
|
|
75
|
+
readonly reason?: string | undefined;
|
|
76
|
+
} | {
|
|
77
|
+
readonly type: 'rotate_capability_grant';
|
|
78
|
+
readonly grantId: string;
|
|
79
|
+
readonly ttlMs: number;
|
|
80
|
+
readonly reason?: string | undefined;
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=service-protocol.d.ts.map
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type PlanVersionV1 } from './plan-version.js';
|
|
2
|
+
import { type TaskContractV1 } from './task-contract.js';
|
|
3
|
+
import { type GovernanceActor, type TransitionFacts } from './transition-engine.js';
|
|
4
|
+
import type { WorkflowState } from './workflow-state.js';
|
|
5
|
+
export interface GovernanceCommandMetadata {
|
|
6
|
+
readonly commandId: string;
|
|
7
|
+
readonly taskId: string;
|
|
8
|
+
readonly expectedRevision: number;
|
|
9
|
+
readonly actor: GovernanceActor;
|
|
10
|
+
readonly issuedAt: string;
|
|
11
|
+
}
|
|
12
|
+
export type GovernanceCommand = GovernanceCommandMetadata & ({
|
|
13
|
+
readonly type: 'create_task';
|
|
14
|
+
readonly projectId: string;
|
|
15
|
+
readonly contract: TaskContractV1;
|
|
16
|
+
} | {
|
|
17
|
+
readonly type: 'attach_plan_version';
|
|
18
|
+
readonly plan: PlanVersionV1;
|
|
19
|
+
} | {
|
|
20
|
+
readonly type: 'transition_task';
|
|
21
|
+
readonly to: WorkflowState;
|
|
22
|
+
});
|
|
23
|
+
export interface GovernanceDecisionContext {
|
|
24
|
+
/** Trusted facts computed by deterministic policy/adapters, never copied from model arguments. */
|
|
25
|
+
readonly transitionFacts?: TransitionFacts | undefined;
|
|
26
|
+
}
|
|
27
|
+
export type GovernanceEventPayload = {
|
|
28
|
+
readonly type: 'task_created';
|
|
29
|
+
readonly projectId: string;
|
|
30
|
+
readonly contract: TaskContractV1;
|
|
31
|
+
} | {
|
|
32
|
+
readonly type: 'plan_version_attached';
|
|
33
|
+
readonly plan: PlanVersionV1;
|
|
34
|
+
} | {
|
|
35
|
+
readonly type: 'workflow_transitioned';
|
|
36
|
+
readonly from: WorkflowState;
|
|
37
|
+
readonly to: WorkflowState;
|
|
38
|
+
};
|
|
39
|
+
export interface GovernanceEvent {
|
|
40
|
+
readonly eventId: string;
|
|
41
|
+
readonly commandId: string;
|
|
42
|
+
readonly taskId: string;
|
|
43
|
+
readonly revision: number;
|
|
44
|
+
readonly actor: GovernanceActor;
|
|
45
|
+
readonly occurredAt: string;
|
|
46
|
+
readonly payload: GovernanceEventPayload;
|
|
47
|
+
}
|
|
48
|
+
export interface TaskAggregate {
|
|
49
|
+
readonly taskId: string;
|
|
50
|
+
readonly projectId: string;
|
|
51
|
+
readonly revision: number;
|
|
52
|
+
readonly state: WorkflowState;
|
|
53
|
+
readonly contracts: readonly TaskContractV1[];
|
|
54
|
+
readonly activeContractVersion: number;
|
|
55
|
+
readonly plans: readonly PlanVersionV1[];
|
|
56
|
+
readonly activePlanVersion: number | null;
|
|
57
|
+
readonly replanRequestedFromPlanVersion: number | null;
|
|
58
|
+
readonly createdAt: string;
|
|
59
|
+
readonly updatedAt: string;
|
|
60
|
+
}
|
|
61
|
+
export type CommandRejectionCode = 'stale_revision' | 'task_already_exists' | 'task_missing' | 'task_identity_mismatch' | 'project_identity_mismatch' | 'initial_contract_version_invalid' | 'contract_invalid' | 'plan_invalid' | 'plan_supersession_invalid' | 'plan_attach_state_invalid' | 'active_plan_missing' | 'replan_version_missing' | 'transition_facts_missing' | 'transition_rejected';
|
|
62
|
+
export type GovernanceCommandDecision = {
|
|
63
|
+
readonly accepted: true;
|
|
64
|
+
readonly event: GovernanceEvent;
|
|
65
|
+
} | {
|
|
66
|
+
readonly accepted: false;
|
|
67
|
+
readonly code: CommandRejectionCode;
|
|
68
|
+
readonly message: string;
|
|
69
|
+
readonly details?: readonly unknown[] | undefined;
|
|
70
|
+
};
|
|
71
|
+
export type EventApplyRejectionCode = 'first_event_not_task_created' | 'duplicate_task_created' | 'task_id_mismatch' | 'event_revision_gap' | 'event_state_mismatch' | 'event_requires_existing_task';
|
|
72
|
+
export type EventApplyResult = {
|
|
73
|
+
readonly applied: true;
|
|
74
|
+
readonly aggregate: TaskAggregate;
|
|
75
|
+
} | {
|
|
76
|
+
readonly applied: false;
|
|
77
|
+
readonly code: EventApplyRejectionCode;
|
|
78
|
+
readonly message: string;
|
|
79
|
+
};
|
|
80
|
+
export type TaskReplayResult = {
|
|
81
|
+
readonly replayed: true;
|
|
82
|
+
readonly aggregate: TaskAggregate;
|
|
83
|
+
} | {
|
|
84
|
+
readonly replayed: false;
|
|
85
|
+
readonly eventIndex: number;
|
|
86
|
+
readonly code: EventApplyRejectionCode;
|
|
87
|
+
readonly message: string;
|
|
88
|
+
};
|
|
89
|
+
export declare function decideGovernanceCommand(aggregate: TaskAggregate | null, command: GovernanceCommand, context?: GovernanceDecisionContext): GovernanceCommandDecision;
|
|
90
|
+
export declare function applyGovernanceEvent(aggregate: TaskAggregate | null, event: GovernanceEvent): EventApplyResult;
|
|
91
|
+
export declare function replayTaskEvents(events: readonly GovernanceEvent[]): TaskReplayResult;
|
|
92
|
+
//# sourceMappingURL=task-aggregate.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type AutonomyEnvelope } from './autonomy-envelope.js';
|
|
2
|
+
export declare const TASK_CONTRACT_SCHEMA_VERSION: 1;
|
|
3
|
+
export declare const CONTRACT_SOURCES: readonly ['explicit_user', 'project_policy', 'deterministic_inference', 'model_proposal'];
|
|
4
|
+
export type ContractSource = (typeof CONTRACT_SOURCES)[number];
|
|
5
|
+
export declare const EVIDENCE_KINDS: readonly ['test', 'typecheck', 'lint', 'build', 'static_analysis', 'security', 'api_compatibility', 'schema', 'performance', 'review'];
|
|
6
|
+
export type EvidenceKind = (typeof EVIDENCE_KINDS)[number];
|
|
7
|
+
export declare const REVIEW_DIMENSIONS: readonly ['correctness', 'requirements_traceability', 'security_permissions', 'api_schema_compatibility', 'testing_evidence', 'performance_resources', 'concurrency_recovery', 'maintainability_architecture'];
|
|
8
|
+
export type ReviewDimension = (typeof REVIEW_DIMENSIONS)[number];
|
|
9
|
+
export declare const ROLLBACK_CLASSES: readonly ['isolated_discard', 'git_revert', 'verified_compensation', 'manual_only', 'irreversible'];
|
|
10
|
+
export type RollbackClass = (typeof ROLLBACK_CLASSES)[number];
|
|
11
|
+
export declare const CONTRACT_ASSUMPTION_STATUSES: readonly ['unverified', 'verified', 'rejected', 'expired'];
|
|
12
|
+
export declare const BASELINE_POLICIES: readonly ['required', 'optional', 'read_only'];
|
|
13
|
+
export interface TaskRequirement {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly text: string;
|
|
16
|
+
readonly acceptanceCriteriaIds: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
export interface AcceptanceCriterion {
|
|
19
|
+
readonly id: string;
|
|
20
|
+
readonly statement: string;
|
|
21
|
+
readonly evidenceKinds: readonly EvidenceKind[];
|
|
22
|
+
}
|
|
23
|
+
export interface RequiredCheck {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly kind: EvidenceKind;
|
|
26
|
+
readonly required: boolean;
|
|
27
|
+
readonly requirementIds: readonly string[];
|
|
28
|
+
}
|
|
29
|
+
export interface ContractAssumption {
|
|
30
|
+
readonly id: string;
|
|
31
|
+
readonly statement: string;
|
|
32
|
+
readonly source: ContractSource;
|
|
33
|
+
readonly status: (typeof CONTRACT_ASSUMPTION_STATUSES)[number];
|
|
34
|
+
}
|
|
35
|
+
export interface TaskContractV1 {
|
|
36
|
+
readonly schemaVersion: typeof TASK_CONTRACT_SCHEMA_VERSION;
|
|
37
|
+
readonly taskId: string;
|
|
38
|
+
readonly contractVersion: number;
|
|
39
|
+
readonly projectId: string;
|
|
40
|
+
readonly sourceRequest: string;
|
|
41
|
+
readonly policyVersion: string;
|
|
42
|
+
readonly repository: {
|
|
43
|
+
readonly rootIdentity: string;
|
|
44
|
+
readonly baselinePolicy: (typeof BASELINE_POLICIES)[number];
|
|
45
|
+
};
|
|
46
|
+
readonly requirements: readonly TaskRequirement[];
|
|
47
|
+
readonly acceptanceCriteria: readonly AcceptanceCriterion[];
|
|
48
|
+
readonly autonomy: AutonomyEnvelope;
|
|
49
|
+
readonly requiredChecks: readonly RequiredCheck[];
|
|
50
|
+
readonly requiredReviewDimensions: readonly ReviewDimension[];
|
|
51
|
+
readonly rollbackClass: RollbackClass;
|
|
52
|
+
readonly assumptions: readonly ContractAssumption[];
|
|
53
|
+
readonly sources: {
|
|
54
|
+
readonly requirements: ContractSource;
|
|
55
|
+
readonly scope: ContractSource;
|
|
56
|
+
readonly checks: ContractSource;
|
|
57
|
+
readonly autonomy: ContractSource;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export type ContractValidationIssueCode = 'invalid_schema_version' | 'invalid_contract_version' | 'required_value_missing' | 'duplicate_id' | 'unknown_acceptance_criterion' | 'unknown_requirement' | 'path_scope_missing' | 'path_scope_conflict' | 'invalid_budget' | 'auto_replan_exceeds_budget' | 'approval_operation_not_allowed' | 'operation_exceeds_tier';
|
|
61
|
+
export interface ContractValidationIssue {
|
|
62
|
+
readonly code: ContractValidationIssueCode;
|
|
63
|
+
readonly path: string;
|
|
64
|
+
readonly message: string;
|
|
65
|
+
}
|
|
66
|
+
export type ContractValidationResult = {
|
|
67
|
+
readonly valid: true;
|
|
68
|
+
} | {
|
|
69
|
+
readonly valid: false;
|
|
70
|
+
readonly issues: readonly ContractValidationIssue[];
|
|
71
|
+
};
|
|
72
|
+
export declare function validateTaskContractV1(contract: TaskContractV1): ContractValidationResult;
|
|
73
|
+
export declare function freezeTaskContractV1(contract: TaskContractV1): TaskContractV1;
|
|
74
|
+
//# sourceMappingURL=task-contract.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { WorkflowState } from './workflow-state.js';
|
|
2
|
+
export declare const GOVERNANCE_ACTORS: readonly ['model', 'human', 'policy', 'system'];
|
|
3
|
+
export type GovernanceActor = (typeof GOVERNANCE_ACTORS)[number];
|
|
4
|
+
export type AuthorizationKind = 'none' | 'automatic' | 'human';
|
|
5
|
+
export interface TransitionFacts {
|
|
6
|
+
readonly contractApproved: boolean;
|
|
7
|
+
readonly planApproved: boolean;
|
|
8
|
+
readonly withinAutonomyEnvelope: boolean;
|
|
9
|
+
readonly authorization: AuthorizationKind;
|
|
10
|
+
readonly executionGrantValid: boolean;
|
|
11
|
+
readonly snapshotCurrent: boolean;
|
|
12
|
+
readonly requiredEvidenceSatisfied: boolean;
|
|
13
|
+
readonly blockingFindings: number;
|
|
14
|
+
readonly rollbackVerified: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface TransitionProposal {
|
|
17
|
+
readonly from: WorkflowState;
|
|
18
|
+
readonly to: WorkflowState;
|
|
19
|
+
readonly actor: GovernanceActor;
|
|
20
|
+
readonly currentRevision: number;
|
|
21
|
+
readonly expectedRevision: number;
|
|
22
|
+
/** Trusted facts computed by governance adapters/policy, never copied from model arguments. */
|
|
23
|
+
readonly facts: TransitionFacts;
|
|
24
|
+
}
|
|
25
|
+
export type TransitionRejectionCode = 'stale_revision' | 'illegal_transition' | 'authorization_missing' | 'contract_not_approved' | 'plan_not_approved' | 'outside_autonomy_envelope' | 'execution_grant_missing' | 'stale_snapshot' | 'evidence_missing' | 'blocking_findings' | 'model_cannot_self_admit' | 'rollback_unverified';
|
|
26
|
+
export type TransitionDecision = {
|
|
27
|
+
readonly allowed: true;
|
|
28
|
+
readonly from: WorkflowState;
|
|
29
|
+
readonly to: WorkflowState;
|
|
30
|
+
readonly nextRevision: number;
|
|
31
|
+
} | {
|
|
32
|
+
readonly allowed: false;
|
|
33
|
+
readonly code: TransitionRejectionCode;
|
|
34
|
+
readonly message: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function decideTransition(proposal: TransitionProposal): TransitionDecision;
|
|
37
|
+
//# sourceMappingURL=transition-engine.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type EvidenceKind } from './task-contract.js';
|
|
2
|
+
export declare const VERIFICATION_CHECK_BINDING_SCHEMA_VERSION: 1;
|
|
3
|
+
export interface VerificationCheckDescriptor {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly evidenceKind: EvidenceKind;
|
|
6
|
+
readonly handlerVersion: string;
|
|
7
|
+
readonly executionClass: 'trusted_deterministic';
|
|
8
|
+
}
|
|
9
|
+
export interface VerificationCheckBindingV1 {
|
|
10
|
+
readonly schemaVersion: typeof VERIFICATION_CHECK_BINDING_SCHEMA_VERSION;
|
|
11
|
+
readonly registryFingerprint: string;
|
|
12
|
+
readonly checkId: string;
|
|
13
|
+
readonly evidenceKind: EvidenceKind;
|
|
14
|
+
readonly handlerVersion: string;
|
|
15
|
+
readonly executionClass: 'trusted_deterministic';
|
|
16
|
+
readonly handlerFingerprint: string;
|
|
17
|
+
}
|
|
18
|
+
export declare function calculateVerificationCheckHandlerFingerprint(descriptor: VerificationCheckDescriptor): string;
|
|
19
|
+
export declare function calculateVerificationCheckRegistryFingerprint(descriptors: readonly VerificationCheckDescriptor[]): string;
|
|
20
|
+
export declare function createVerificationCheckBinding(registryFingerprint: string, descriptor: VerificationCheckDescriptor): VerificationCheckBindingV1;
|
|
21
|
+
export declare function isVerificationCheckBindingIntegrityValid(binding: VerificationCheckBindingV1): boolean;
|
|
22
|
+
export declare function verificationCheckBindingMatches(binding: VerificationCheckBindingV1, registryFingerprint: string, descriptor: VerificationCheckDescriptor): boolean;
|
|
23
|
+
//# sourceMappingURL=verification-check-binding.d.ts.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type EvidenceKind } from './task-contract.js';
|
|
2
|
+
import { type VerificationCheckBindingV1, type VerificationCheckDescriptor } from './verification-check-binding.js';
|
|
3
|
+
import type { VerificationExecutionLeaseConsumption } from './verification-execution-lease.js';
|
|
4
|
+
import { type VerificationRunContract } from './verification-run-contract.js';
|
|
5
|
+
export declare const MAX_VERIFICATION_CHECK_REGISTRATIONS = 256;
|
|
6
|
+
export interface FocusedVerificationExecutionContext {
|
|
7
|
+
readonly run: VerificationRunContract;
|
|
8
|
+
readonly consumption: VerificationExecutionLeaseConsumption;
|
|
9
|
+
readonly workspaceManifestHash: string;
|
|
10
|
+
}
|
|
11
|
+
export interface VerificationCheckRegistration<Result> extends VerificationCheckDescriptor {
|
|
12
|
+
readonly run: (context: FocusedVerificationExecutionContext) => Promise<Result>;
|
|
13
|
+
}
|
|
14
|
+
export type VerificationCheckRegistryDenialCode = 'check_not_registered' | 'evidence_kind_mismatch' | 'check_binding_missing' | 'check_binding_drifted' | 'execution_context_invalid';
|
|
15
|
+
export type VerificationCheckBindingResolution = {
|
|
16
|
+
readonly bound: true;
|
|
17
|
+
readonly binding: VerificationCheckBindingV1;
|
|
18
|
+
} | {
|
|
19
|
+
readonly bound: false;
|
|
20
|
+
readonly code: 'check_not_registered' | 'evidence_kind_mismatch';
|
|
21
|
+
readonly message: string;
|
|
22
|
+
};
|
|
23
|
+
export type VerificationCheckRegistryExecutionResult<Result> = {
|
|
24
|
+
readonly executed: false;
|
|
25
|
+
readonly code: VerificationCheckRegistryDenialCode;
|
|
26
|
+
readonly message: string;
|
|
27
|
+
} | {
|
|
28
|
+
readonly executed: true;
|
|
29
|
+
readonly descriptor: VerificationCheckDescriptor;
|
|
30
|
+
readonly result: Result;
|
|
31
|
+
};
|
|
32
|
+
export declare class VerificationCheckRegistryConfigurationError extends Error {
|
|
33
|
+
constructor(message: string);
|
|
34
|
+
}
|
|
35
|
+
export declare class VerificationCheckRegistry<Result> {
|
|
36
|
+
#private;
|
|
37
|
+
constructor(registrations: readonly VerificationCheckRegistration<Result>[]);
|
|
38
|
+
list(): readonly VerificationCheckDescriptor[];
|
|
39
|
+
fingerprint(): string;
|
|
40
|
+
bindingFor(checkId: string, evidenceKind: EvidenceKind): VerificationCheckBindingResolution;
|
|
41
|
+
execute(context: FocusedVerificationExecutionContext): Promise<VerificationCheckRegistryExecutionResult<Result>>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=verification-check-registry.d.ts.map
|