@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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +172 -0
  3. package/dist/admin-session.d.ts +56 -0
  4. package/dist/attachment-broker-controller.d.ts +73 -0
  5. package/dist/authenticated-project-service.d.ts +18 -0
  6. package/dist/autonomy-envelope.d.ts +40 -0
  7. package/dist/capability-grant.d.ts +122 -0
  8. package/dist/credential-lease-controller.d.ts +85 -0
  9. package/dist/daemon-control.d.ts +48 -0
  10. package/dist/daemon-launcher.d.ts +46 -0
  11. package/dist/daemon-metadata.d.ts +126 -0
  12. package/dist/daemon-protocol.d.ts +59 -0
  13. package/dist/event-store.d.ts +109 -0
  14. package/dist/evidence-candidate.d.ts +95 -0
  15. package/dist/index.d.ts +38 -0
  16. package/dist/index.js +8468 -0
  17. package/dist/ipc-endpoint.d.ts +6 -0
  18. package/dist/ipc-protocol.d.ts +24 -0
  19. package/dist/legacy-shadow-adapter.d.ts +33 -0
  20. package/dist/management-receipt-cache.d.ts +53 -0
  21. package/dist/plan-version.d.ts +91 -0
  22. package/dist/project-client.d.ts +31 -0
  23. package/dist/project-daemon.d.ts +2 -0
  24. package/dist/project-daemon.js +5722 -0
  25. package/dist/project-server.d.ts +48 -0
  26. package/dist/project-service.d.ts +121 -0
  27. package/dist/protocol-decoder.d.ts +16 -0
  28. package/dist/runtime-compatibility.d.ts +99 -0
  29. package/dist/sanitize.d.ts +11 -0
  30. package/dist/service-protocol.d.ts +82 -0
  31. package/dist/task-aggregate.d.ts +92 -0
  32. package/dist/task-contract.d.ts +74 -0
  33. package/dist/transition-engine.d.ts +37 -0
  34. package/dist/verification-check-binding.d.ts +23 -0
  35. package/dist/verification-check-registry.d.ts +43 -0
  36. package/dist/verification-execution-lease.d.ts +76 -0
  37. package/dist/verification-issuance-coordinator.d.ts +110 -0
  38. package/dist/verification-ledger-store.d.ts +20 -0
  39. package/dist/verification-planner.d.ts +76 -0
  40. package/dist/verification-run-contract.d.ts +84 -0
  41. package/dist/verification-tool-gateway.d.ts +74 -0
  42. package/dist/workflow-state.d.ts +5 -0
  43. package/dist/workspace-snapshot-fence.d.ts +20 -0
  44. package/package.json +44 -0
@@ -0,0 +1,6 @@
1
+ export declare const GOVERNANCE_DATABASE_RELATIVE_PATH: string;
2
+ export declare function canonicalGovernanceProjectRoot(projectRoot: string): string;
3
+ export declare function governanceProjectKey(projectRoot: string): string;
4
+ export declare function governanceProjectServerEndpoint(projectRoot: string): string;
5
+ export declare function governanceProjectDatabasePath(projectRoot: string): string;
6
+ //# sourceMappingURL=ipc-endpoint.d.ts.map
@@ -0,0 +1,24 @@
1
+ import type { GovernanceServiceCredential } from './capability-grant.js';
2
+ import type { GovernanceServiceResponse } from './project-service.js';
3
+ import { GOVERNANCE_SERVICE_PROTOCOL_VERSION } from './service-protocol.js';
4
+ export declare const GOVERNANCE_IPC_MAX_FRAME_BYTES: number;
5
+ export interface GovernanceIpcRequestEnvelope {
6
+ readonly protocolVersion: typeof GOVERNANCE_SERVICE_PROTOCOL_VERSION;
7
+ readonly credential: GovernanceServiceCredential;
8
+ readonly request: unknown;
9
+ }
10
+ export interface GovernanceIpcDecodeIssue {
11
+ readonly path: string;
12
+ readonly message: string;
13
+ }
14
+ export type GovernanceIpcEnvelopeDecodeResult = {
15
+ readonly decoded: true;
16
+ readonly envelope: GovernanceIpcRequestEnvelope;
17
+ } | {
18
+ readonly decoded: false;
19
+ readonly issues: readonly GovernanceIpcDecodeIssue[];
20
+ };
21
+ export declare function decodeGovernanceIpcEnvelope(input: unknown): GovernanceIpcEnvelopeDecodeResult;
22
+ export declare function encodeGovernanceIpcFrame(value: unknown): Buffer;
23
+ export declare function decodeGovernanceIpcResponse(input: unknown): GovernanceServiceResponse;
24
+ //# sourceMappingURL=ipc-protocol.d.ts.map
@@ -0,0 +1,33 @@
1
+ import type { AuthenticatedGovernanceProjectService } from './authenticated-project-service.js';
2
+ import type { GovernanceServiceCredential } from './capability-grant.js';
3
+ import type { GovernanceObservationCategory, StoredGovernanceObservation } from './event-store.js';
4
+ export interface LegacyRuntimeObservation {
5
+ readonly observationId: string;
6
+ readonly taskId?: string | undefined;
7
+ readonly category: GovernanceObservationCategory;
8
+ readonly observedAt: string;
9
+ readonly payload: Readonly<Record<string, unknown>>;
10
+ }
11
+ export type LegacyShadowObservationResult = {
12
+ readonly observed: true;
13
+ readonly idempotentReplay: boolean;
14
+ readonly observation: StoredGovernanceObservation;
15
+ } | {
16
+ readonly observed: false;
17
+ readonly code: string;
18
+ readonly message: string;
19
+ };
20
+ /**
21
+ * Observe-only compatibility adapter. It can append shadow observations but has no command capability
22
+ * and therefore cannot create tasks, transition canonical state, or block the legacy runtime.
23
+ */
24
+ export declare class LegacyGovernanceShadowAdapter {
25
+ private readonly service;
26
+ private readonly source;
27
+ private readonly credential;
28
+ private requestSequence;
29
+ constructor(service: AuthenticatedGovernanceProjectService, source: string, credential: GovernanceServiceCredential);
30
+ observe(observation: LegacyRuntimeObservation): LegacyShadowObservationResult;
31
+ private toResult;
32
+ }
33
+ //# sourceMappingURL=legacy-shadow-adapter.d.ts.map
@@ -0,0 +1,53 @@
1
+ import type { GovernanceServiceCredential } from './capability-grant.js';
2
+ import type { GovernanceServiceResponse } from './project-service.js';
3
+ export declare const GOVERNANCE_MANAGEMENT_RECEIPT_TTL_MS = 30000;
4
+ export declare const GOVERNANCE_MANAGEMENT_RECEIPT_MAX_ENTRIES = 1024;
5
+ export interface GovernanceManagementReceiptCacheOptions {
6
+ readonly now?: (() => number) | undefined;
7
+ readonly ttlMs?: number | undefined;
8
+ readonly maxEntries?: number | undefined;
9
+ }
10
+ export type GovernanceManagementReceiptLookup = {
11
+ readonly kind: 'miss';
12
+ } | {
13
+ readonly kind: 'in_progress';
14
+ } | {
15
+ readonly kind: 'conflict';
16
+ readonly allowAfterRotation: boolean;
17
+ } | {
18
+ readonly kind: 'replay';
19
+ readonly response: GovernanceServiceResponse;
20
+ readonly allowAfterRotation: boolean;
21
+ };
22
+ export interface GovernanceManagementReceiptReservation {
23
+ readonly key: string;
24
+ readonly fingerprint: string;
25
+ readonly requestId: string;
26
+ }
27
+ export declare class GovernanceManagementReceiptCache {
28
+ private readonly now;
29
+ private readonly ttlMs;
30
+ private readonly maxEntries;
31
+ private readonly records;
32
+ constructor(options?: GovernanceManagementReceiptCacheOptions);
33
+ lookup(input: unknown, credential: GovernanceServiceCredential): GovernanceManagementReceiptLookup;
34
+ reserve(options: {
35
+ readonly input: unknown;
36
+ readonly credential: GovernanceServiceCredential;
37
+ /**
38
+ * Raw wire payload to fingerprint for replay-conflict detection. Must be
39
+ * the same form that subsequent `lookup` calls see; defaults to `input`
40
+ * when the caller has no separate wire form. Passing the raw form (and
41
+ * not the decoder-normalized form) keeps the contract immune to a future
42
+ * decoder that adds content-preserving normalization, which would
43
+ * otherwise turn every legitimate retry into a misleading
44
+ * "requestId already used" conflict.
45
+ */
46
+ readonly wireInput?: unknown;
47
+ }): GovernanceManagementReceiptReservation | null;
48
+ commit(reservation: GovernanceManagementReceiptReservation, response: GovernanceServiceResponse, allowAfterRotation?: boolean): void;
49
+ release(reservation: GovernanceManagementReceiptReservation): void;
50
+ clear(): void;
51
+ private pruneExpired;
52
+ }
53
+ //# sourceMappingURL=management-receipt-cache.d.ts.map
@@ -0,0 +1,91 @@
1
+ import { type GovernedOperation, type OperationAutonomyDecision } from './autonomy-envelope.js';
2
+ import { type TaskContractV1 } from './task-contract.js';
3
+ export declare const PLAN_VERSION_SCHEMA_VERSION: 1;
4
+ export interface PlanStepV1 {
5
+ readonly id: string;
6
+ readonly title: string;
7
+ readonly description: string;
8
+ readonly operations: readonly GovernedOperation[];
9
+ readonly expectedPaths: readonly string[];
10
+ readonly requirementIds: readonly string[];
11
+ readonly acceptanceCriteriaIds: readonly string[];
12
+ readonly requiredCheckIds: readonly string[];
13
+ }
14
+ export interface PlanEdgeV1 {
15
+ readonly fromStepId: string;
16
+ readonly toStepId: string;
17
+ }
18
+ export interface PlanVersionV1 {
19
+ readonly schemaVersion: typeof PLAN_VERSION_SCHEMA_VERSION;
20
+ readonly planId: string;
21
+ readonly taskId: string;
22
+ readonly planVersion: number;
23
+ readonly parentPlanVersion: number | null;
24
+ readonly contractVersion: number;
25
+ readonly createdBy: 'model' | 'human' | 'policy' | 'system';
26
+ readonly createdAt: string;
27
+ readonly changeReason: string;
28
+ readonly steps: readonly PlanStepV1[];
29
+ readonly edges: readonly PlanEdgeV1[];
30
+ }
31
+ export declare function calculatePlanVersionFingerprint(plan: PlanVersionV1): string;
32
+ export interface PlanStepAutonomy {
33
+ readonly stepId: string;
34
+ readonly automatic: boolean;
35
+ readonly decisions: readonly OperationAutonomyDecision[];
36
+ }
37
+ export interface PlanAutonomySummary {
38
+ readonly fullyAutonomous: boolean;
39
+ readonly automaticStepIds: readonly string[];
40
+ readonly humanApprovalStepIds: readonly string[];
41
+ readonly steps: readonly PlanStepAutonomy[];
42
+ }
43
+ export type PlanValidationIssueCode = 'contract_invalid' | 'invalid_schema_version' | 'invalid_plan_version' | 'invalid_parent_version' | 'required_value_missing' | 'duplicate_step_id' | 'duplicate_edge' | 'unknown_edge_step' | 'self_edge' | 'cycle_detected' | 'task_mismatch' | 'contract_version_mismatch' | 'operation_not_allowed' | 'expected_path_missing' | 'path_outside_scope' | 'unknown_requirement' | 'unknown_acceptance_criterion' | 'unknown_required_check' | 'requirement_unplanned' | 'required_check_unplanned';
44
+ export interface PlanValidationIssue {
45
+ readonly code: PlanValidationIssueCode;
46
+ readonly path: string;
47
+ readonly message: string;
48
+ }
49
+ export type PlanValidationResult = {
50
+ readonly valid: true;
51
+ } | {
52
+ readonly valid: false;
53
+ readonly issues: readonly PlanValidationIssue[];
54
+ };
55
+ export type PlanSupersessionIssueCode = 'plan_id_mismatch' | 'task_id_mismatch' | 'version_not_sequential' | 'parent_version_mismatch' | 'contract_version_regressed';
56
+ export interface PlanSupersessionIssue {
57
+ readonly code: PlanSupersessionIssueCode;
58
+ readonly message: string;
59
+ }
60
+ export type PlanSupersessionResult = {
61
+ readonly valid: true;
62
+ } | {
63
+ readonly valid: false;
64
+ readonly issues: readonly PlanSupersessionIssue[];
65
+ };
66
+ export type ReplanValidationIssue = PlanValidationIssue | PlanSupersessionIssue | {
67
+ readonly code: 'invalid_completed_auto_replans';
68
+ readonly message: string;
69
+ };
70
+ export type ReplanAuthorizationDecision = {
71
+ readonly valid: true;
72
+ readonly automatic: true;
73
+ readonly requiresHumanApproval: false;
74
+ readonly nextPlanVersion: number;
75
+ } | {
76
+ readonly valid: true;
77
+ readonly automatic: false;
78
+ readonly requiresHumanApproval: true;
79
+ readonly nextPlanVersion: number;
80
+ readonly reason: 'auto_authorization_disabled' | 'auto_replan_budget_exhausted';
81
+ } | {
82
+ readonly valid: false;
83
+ readonly issues: readonly ReplanValidationIssue[];
84
+ };
85
+ export declare function classifyPlanStepAutonomy(contract: TaskContractV1, step: PlanStepV1): PlanStepAutonomy;
86
+ export declare function summarizePlanAutonomy(contract: TaskContractV1, plan: PlanVersionV1): PlanAutonomySummary;
87
+ export declare function validatePlanVersionV1(plan: PlanVersionV1, contract: TaskContractV1): PlanValidationResult;
88
+ export declare function validatePlanSupersession(previous: PlanVersionV1, next: PlanVersionV1): PlanSupersessionResult;
89
+ export declare function decideReplanAuthorization(contract: TaskContractV1, previous: PlanVersionV1, next: PlanVersionV1, completedAutomaticReplans: number): ReplanAuthorizationDecision;
90
+ export declare function freezePlanVersionV1(plan: PlanVersionV1): PlanVersionV1;
91
+ //# sourceMappingURL=plan-version.d.ts.map
@@ -0,0 +1,31 @@
1
+ import type { GovernanceServiceCredential } from './capability-grant.js';
2
+ import { type GovernanceDaemonMetadata } from './daemon-metadata.js';
3
+ import type { GovernanceServiceResponse } from './project-service.js';
4
+ export declare const GOVERNANCE_IPC_DEFAULT_TIMEOUT_MS = 5000;
5
+ export interface GovernanceProjectClientOptions {
6
+ readonly timeoutMs?: number | undefined;
7
+ }
8
+ export interface ConnectGovernanceProjectClientOptions extends GovernanceProjectClientOptions {
9
+ readonly projectRoot: string;
10
+ readonly projectId: string;
11
+ readonly credential: GovernanceServiceCredential;
12
+ }
13
+ export type ConnectGovernanceProjectClientResult = {
14
+ readonly connected: true;
15
+ readonly client: GovernanceProjectClient;
16
+ readonly metadata: GovernanceDaemonMetadata;
17
+ } | {
18
+ readonly connected: false;
19
+ readonly code: 'not_running' | 'endpoint_invalid' | 'project_mismatch' | 'credential_mismatch' | 'authentication_failed' | 'service_rejected';
20
+ readonly message: string;
21
+ };
22
+ export declare class GovernanceProjectClient {
23
+ readonly projectRoot: string;
24
+ readonly endpoint: string;
25
+ private readonly credential;
26
+ private readonly timeoutMs;
27
+ constructor(projectRoot: string, credential: GovernanceServiceCredential, options?: GovernanceProjectClientOptions);
28
+ request(request: unknown): Promise<GovernanceServiceResponse>;
29
+ }
30
+ export declare function connectGovernanceProjectClient(options: ConnectGovernanceProjectClientOptions): Promise<ConnectGovernanceProjectClientResult>;
31
+ //# sourceMappingURL=project-client.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=project-daemon.d.ts.map