@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,76 @@
|
|
|
1
|
+
import type { VerificationRunContract } from './verification-run-contract.js';
|
|
2
|
+
import type { WorkspaceSnapshotFenceDescriptor } from './workspace-snapshot-fence.js';
|
|
3
|
+
export declare const VERIFICATION_EXECUTION_LEASE_SCHEMA_VERSION: 1;
|
|
4
|
+
export interface VerificationExecutionLeaseCredential {
|
|
5
|
+
readonly leaseId: string;
|
|
6
|
+
readonly secret: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VerificationExecutionLeaseDescriptor {
|
|
9
|
+
readonly schemaVersion: typeof VERIFICATION_EXECUTION_LEASE_SCHEMA_VERSION;
|
|
10
|
+
readonly leaseId: string;
|
|
11
|
+
readonly runId: string;
|
|
12
|
+
readonly taskId: string;
|
|
13
|
+
readonly verifierClientId: string;
|
|
14
|
+
readonly issuedAt: string;
|
|
15
|
+
readonly expiresAt: string;
|
|
16
|
+
}
|
|
17
|
+
export interface VerificationExecutionBinding {
|
|
18
|
+
readonly runId: string;
|
|
19
|
+
readonly taskId: string;
|
|
20
|
+
readonly verifierClientId: string;
|
|
21
|
+
readonly planFingerprint: string;
|
|
22
|
+
readonly workspaceManifestHash: string;
|
|
23
|
+
}
|
|
24
|
+
export interface VerificationLeaseIssuancePrecondition {
|
|
25
|
+
readonly taskRevision: number;
|
|
26
|
+
readonly activeContractVersion: number;
|
|
27
|
+
readonly activePlanVersion: number;
|
|
28
|
+
readonly activePlanFingerprint: string;
|
|
29
|
+
readonly workflowState: 'proposed_complete' | 'verifying';
|
|
30
|
+
readonly workspaceManifestHash: string;
|
|
31
|
+
readonly workspaceSnapshot: WorkspaceSnapshotFenceDescriptor;
|
|
32
|
+
readonly candidateObservation: {
|
|
33
|
+
readonly sequence: number;
|
|
34
|
+
readonly observationId: string;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface VerificationExecutionLeaseConsumption {
|
|
38
|
+
readonly leaseId: string;
|
|
39
|
+
readonly runId: string;
|
|
40
|
+
readonly verifierClientId: string;
|
|
41
|
+
readonly consumedAt: string;
|
|
42
|
+
readonly bindingHash: string;
|
|
43
|
+
}
|
|
44
|
+
export type IssueVerificationExecutionLeaseResult = {
|
|
45
|
+
readonly issued: true;
|
|
46
|
+
readonly run: VerificationRunContract;
|
|
47
|
+
readonly lease: VerificationExecutionLeaseDescriptor;
|
|
48
|
+
readonly credential: VerificationExecutionLeaseCredential;
|
|
49
|
+
} | {
|
|
50
|
+
readonly issued: false;
|
|
51
|
+
readonly code: 'run_invalid' | 'run_conflict' | 'run_expired' | 'already_issued' | 'canonical_task_missing' | 'canonical_state_invalid' | 'canonical_state_mismatch' | 'canonical_candidate_missing' | 'canonical_candidate_invalid' | 'canonical_candidate_mismatch' | 'workspace_snapshot_missing' | 'workspace_snapshot_invalid' | 'workspace_snapshot_stale' | 'workspace_mismatch';
|
|
52
|
+
readonly message: string;
|
|
53
|
+
};
|
|
54
|
+
export type ConsumeVerificationExecutionLeaseResult = {
|
|
55
|
+
readonly authorized: true;
|
|
56
|
+
readonly run: VerificationRunContract;
|
|
57
|
+
readonly consumption: VerificationExecutionLeaseConsumption;
|
|
58
|
+
} | {
|
|
59
|
+
readonly authorized: false;
|
|
60
|
+
readonly code: 'invalid_credential' | 'already_consumed' | 'expired' | 'binding_mismatch' | 'stored_run_invalid';
|
|
61
|
+
readonly message: string;
|
|
62
|
+
};
|
|
63
|
+
export type VerificationExecutionLeaseStatus = {
|
|
64
|
+
readonly state: 'missing';
|
|
65
|
+
readonly leaseId: string;
|
|
66
|
+
} | {
|
|
67
|
+
readonly state: 'active' | 'expired' | 'consumed';
|
|
68
|
+
readonly lease: VerificationExecutionLeaseDescriptor;
|
|
69
|
+
readonly consumption: VerificationExecutionLeaseConsumption | null;
|
|
70
|
+
};
|
|
71
|
+
export declare function verificationExecutionLeaseId(runId: string): string;
|
|
72
|
+
export declare function createVerificationExecutionLeaseSecret(): string;
|
|
73
|
+
export declare function verificationExecutionLeaseSecretHash(secret: string): string;
|
|
74
|
+
export declare function verificationExecutionBindingHash(binding: VerificationExecutionBinding): string;
|
|
75
|
+
export declare function verificationExecutionLeaseSecretMatches(secret: string, expectedHash: string): boolean;
|
|
76
|
+
//# sourceMappingURL=verification-execution-lease.d.ts.map
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { GovernanceEventStore } from './event-store.js';
|
|
2
|
+
import type { GovernanceEvidenceCandidateLedgerEntry } from './evidence-candidate.js';
|
|
3
|
+
import type { TaskAggregate } from './task-aggregate.js';
|
|
4
|
+
import type { EvidenceKind } from './task-contract.js';
|
|
5
|
+
import type { VerificationCheckBindingResolution } from './verification-check-registry.js';
|
|
6
|
+
import type { IssueVerificationExecutionLeaseResult } from './verification-execution-lease.js';
|
|
7
|
+
import type { VerificationPlanDraftV1 } from './verification-planner.js';
|
|
8
|
+
import { type VerificationRunIssuanceIssue, type VerificationRunRequestV1 } from './verification-run-contract.js';
|
|
9
|
+
export type VerificationIssuanceCoordinatorMode = 'legacy' | 'enforced';
|
|
10
|
+
export interface VerificationCheckBindingResolver {
|
|
11
|
+
bindingFor(checkId: string, evidenceKind: EvidenceKind): VerificationCheckBindingResolution;
|
|
12
|
+
}
|
|
13
|
+
export interface VerificationExecutionLeaseIssuer {
|
|
14
|
+
issueVerificationExecutionLeaseIfCurrent: GovernanceEventStore['issueVerificationExecutionLeaseIfCurrent'];
|
|
15
|
+
recordWorkspaceSnapshot?: GovernanceEventStore['recordWorkspaceSnapshot'];
|
|
16
|
+
}
|
|
17
|
+
export interface VerificationWorkspaceSnapshotRecorder {
|
|
18
|
+
recordWorkspaceSnapshot: GovernanceEventStore['recordWorkspaceSnapshot'];
|
|
19
|
+
}
|
|
20
|
+
export interface VerificationIssuanceCoordinatorOptions {
|
|
21
|
+
/** Defaults to legacy; construction alone cannot enable governed issuance. */
|
|
22
|
+
readonly mode?: VerificationIssuanceCoordinatorMode | undefined;
|
|
23
|
+
readonly verifierClientId: string;
|
|
24
|
+
readonly ttlMs: number;
|
|
25
|
+
readonly maxDurationMs: number;
|
|
26
|
+
readonly now: () => string;
|
|
27
|
+
readonly captureWorkspaceIdentity: () => Promise<{
|
|
28
|
+
readonly manifestHash: string;
|
|
29
|
+
}>;
|
|
30
|
+
readonly workspaceSnapshots?: VerificationWorkspaceSnapshotRecorder | undefined;
|
|
31
|
+
readonly checkBindings: VerificationCheckBindingResolver;
|
|
32
|
+
readonly leaseIssuer: VerificationExecutionLeaseIssuer;
|
|
33
|
+
}
|
|
34
|
+
export interface VerificationIssuanceCoordinatorInput {
|
|
35
|
+
readonly task: TaskAggregate | null;
|
|
36
|
+
readonly draft: VerificationPlanDraftV1;
|
|
37
|
+
readonly candidates: readonly GovernanceEvidenceCandidateLedgerEntry[];
|
|
38
|
+
/** The complete model-proposable surface. Registry bindings are not accepted here. */
|
|
39
|
+
readonly request: VerificationRunRequestV1;
|
|
40
|
+
}
|
|
41
|
+
type VerificationLeaseFailure = Extract<IssueVerificationExecutionLeaseResult, {
|
|
42
|
+
issued: false;
|
|
43
|
+
}>;
|
|
44
|
+
type VerificationLeaseSuccess = Extract<IssueVerificationExecutionLeaseResult, {
|
|
45
|
+
issued: true;
|
|
46
|
+
}>;
|
|
47
|
+
export type VerificationIssuanceCoordinatorResult = {
|
|
48
|
+
readonly route: 'legacy';
|
|
49
|
+
readonly handled: false;
|
|
50
|
+
readonly reason: 'coordinator_disabled';
|
|
51
|
+
} | {
|
|
52
|
+
readonly route: 'governed';
|
|
53
|
+
readonly handled: true;
|
|
54
|
+
readonly issued: false;
|
|
55
|
+
readonly phase: 'authority';
|
|
56
|
+
readonly code: 'authority_unavailable';
|
|
57
|
+
readonly message: string;
|
|
58
|
+
} | {
|
|
59
|
+
readonly route: 'governed';
|
|
60
|
+
readonly handled: true;
|
|
61
|
+
readonly issued: false;
|
|
62
|
+
readonly phase: 'workspace';
|
|
63
|
+
readonly code: 'workspace_identity_unavailable' | 'workspace_mismatch' | 'workspace_snapshot_unavailable' | 'workspace_snapshot_invalid';
|
|
64
|
+
readonly message: string;
|
|
65
|
+
} | {
|
|
66
|
+
readonly route: 'governed';
|
|
67
|
+
readonly handled: true;
|
|
68
|
+
readonly issued: false;
|
|
69
|
+
readonly phase: 'run_contract';
|
|
70
|
+
readonly issues: readonly VerificationRunIssuanceIssue[];
|
|
71
|
+
} | {
|
|
72
|
+
readonly route: 'governed';
|
|
73
|
+
readonly handled: true;
|
|
74
|
+
readonly issued: false;
|
|
75
|
+
readonly phase: 'check_registry';
|
|
76
|
+
readonly code: Extract<VerificationCheckBindingResolution, {
|
|
77
|
+
bound: false;
|
|
78
|
+
}>['code'] | 'check_registry_unavailable';
|
|
79
|
+
readonly message: string;
|
|
80
|
+
} | {
|
|
81
|
+
readonly route: 'governed';
|
|
82
|
+
readonly handled: true;
|
|
83
|
+
readonly issued: false;
|
|
84
|
+
readonly phase: 'internal';
|
|
85
|
+
readonly code: 'bound_run_invariant_failed' | 'lease_result_mismatch';
|
|
86
|
+
readonly message: string;
|
|
87
|
+
} | {
|
|
88
|
+
readonly route: 'governed';
|
|
89
|
+
readonly handled: true;
|
|
90
|
+
readonly issued: false;
|
|
91
|
+
readonly phase: 'lease';
|
|
92
|
+
readonly code: VerificationLeaseFailure['code'] | 'lease_unavailable';
|
|
93
|
+
readonly message: string;
|
|
94
|
+
} | {
|
|
95
|
+
readonly route: 'governed';
|
|
96
|
+
readonly handled: true;
|
|
97
|
+
readonly issued: true;
|
|
98
|
+
readonly run: Extract<VerificationLeaseSuccess['run'], {
|
|
99
|
+
schemaVersion: 2;
|
|
100
|
+
}>;
|
|
101
|
+
readonly lease: VerificationLeaseSuccess['lease'];
|
|
102
|
+
readonly credential: VerificationLeaseSuccess['credential'];
|
|
103
|
+
};
|
|
104
|
+
export declare class VerificationIssuanceCoordinator {
|
|
105
|
+
#private;
|
|
106
|
+
constructor(options: VerificationIssuanceCoordinatorOptions);
|
|
107
|
+
issue(input: VerificationIssuanceCoordinatorInput): Promise<VerificationIssuanceCoordinatorResult>;
|
|
108
|
+
}
|
|
109
|
+
export {};
|
|
110
|
+
//# sourceMappingURL=verification-issuance-coordinator.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { type ConsumeVerificationExecutionLeaseResult, type IssueVerificationExecutionLeaseResult, type VerificationExecutionBinding, type VerificationExecutionLeaseCredential, type VerificationExecutionLeaseStatus, type VerificationLeaseIssuancePrecondition } from './verification-execution-lease.js';
|
|
3
|
+
import { type VerificationRunContract } from './verification-run-contract.js';
|
|
4
|
+
import { type RecordWorkspaceSnapshotResult, type WorkspaceSnapshotFenceDescriptor } from './workspace-snapshot-fence.js';
|
|
5
|
+
export interface SqliteVerificationLedgerOptions {
|
|
6
|
+
readonly now: () => string;
|
|
7
|
+
readonly verificationLeaseSecret?: (() => string) | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare class SqliteVerificationLedger {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(db: DatabaseSync, options: SqliteVerificationLedgerOptions);
|
|
12
|
+
initializeSchema(): void;
|
|
13
|
+
recordWorkspaceSnapshot(projectId: string, manifestHash: string): RecordWorkspaceSnapshotResult;
|
|
14
|
+
readLatestWorkspaceSnapshot(projectId: string): WorkspaceSnapshotFenceDescriptor | null;
|
|
15
|
+
issue(run: VerificationRunContract): IssueVerificationExecutionLeaseResult;
|
|
16
|
+
issueIfCurrent(run: VerificationRunContract, precondition: VerificationLeaseIssuancePrecondition): IssueVerificationExecutionLeaseResult;
|
|
17
|
+
consume(credential: VerificationExecutionLeaseCredential, binding: VerificationExecutionBinding): ConsumeVerificationExecutionLeaseResult;
|
|
18
|
+
readStatus(leaseId: string): VerificationExecutionLeaseStatus;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=verification-ledger-store.d.ts.map
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { GovernanceEvidenceCandidateLedgerEntry } from './evidence-candidate.js';
|
|
2
|
+
import type { TaskAggregate } from './task-aggregate.js';
|
|
3
|
+
import { type EvidenceKind } from './task-contract.js';
|
|
4
|
+
export declare const VERIFICATION_PLANNER_INPUT_SCHEMA_VERSION: 1;
|
|
5
|
+
export declare const VERIFICATION_PLAN_DRAFT_SCHEMA_VERSION: 1;
|
|
6
|
+
export declare const MAX_VERIFICATION_CANDIDATE_PROPOSALS = 512;
|
|
7
|
+
export interface VerificationPlanningScopeV1 {
|
|
8
|
+
readonly taskId: string;
|
|
9
|
+
readonly contractVersion: number;
|
|
10
|
+
readonly planFingerprint: string;
|
|
11
|
+
readonly workspaceManifestHash: string;
|
|
12
|
+
}
|
|
13
|
+
export interface VerificationCandidateProposalV1 {
|
|
14
|
+
readonly requiredCheckId: string;
|
|
15
|
+
readonly candidateId: string;
|
|
16
|
+
}
|
|
17
|
+
export interface VerificationPlannerInputV1 {
|
|
18
|
+
readonly schemaVersion: typeof VERIFICATION_PLANNER_INPUT_SCHEMA_VERSION;
|
|
19
|
+
readonly scope: VerificationPlanningScopeV1;
|
|
20
|
+
readonly proposals: readonly VerificationCandidateProposalV1[];
|
|
21
|
+
}
|
|
22
|
+
export type VerificationPlannerIssueCode = 'task_missing' | 'active_contract_missing' | 'contract_invalid' | 'invalid_schema_version' | 'task_mismatch' | 'contract_version_mismatch' | 'scope_identity_invalid' | 'proposal_limit_exceeded';
|
|
23
|
+
export interface VerificationPlannerIssue {
|
|
24
|
+
readonly code: VerificationPlannerIssueCode;
|
|
25
|
+
readonly path: string;
|
|
26
|
+
readonly message: string;
|
|
27
|
+
}
|
|
28
|
+
export type VerificationProposalRejectionCode = 'proposal_invalid' | 'duplicate_proposal' | 'unknown_required_check' | 'candidate_missing' | 'candidate_ambiguous' | 'candidate_ineligible' | 'candidate_task_mismatch' | 'candidate_plan_mismatch' | 'candidate_workspace_mismatch';
|
|
29
|
+
export type VerificationProposalDisposition = {
|
|
30
|
+
readonly state: 'accepted_as_proposal';
|
|
31
|
+
readonly requiredCheckId: string;
|
|
32
|
+
readonly candidateId: string;
|
|
33
|
+
} | {
|
|
34
|
+
readonly state: 'rejected';
|
|
35
|
+
readonly requiredCheckId: string | null;
|
|
36
|
+
readonly candidateId: string | null;
|
|
37
|
+
readonly code: VerificationProposalRejectionCode;
|
|
38
|
+
readonly path: string;
|
|
39
|
+
};
|
|
40
|
+
export interface VerificationCheckDraftV1 {
|
|
41
|
+
readonly requiredCheckId: string;
|
|
42
|
+
readonly expectedEvidenceKind: EvidenceKind;
|
|
43
|
+
readonly required: boolean;
|
|
44
|
+
readonly requirementIds: readonly string[];
|
|
45
|
+
readonly acceptanceCriterionIds: readonly string[];
|
|
46
|
+
readonly state: 'unassigned' | 'candidates_proposed';
|
|
47
|
+
readonly proposedCandidateIds: readonly string[];
|
|
48
|
+
/** A proposed tool result is never sufficient evidence by itself. */
|
|
49
|
+
readonly evidenceSatisfied: false;
|
|
50
|
+
}
|
|
51
|
+
export interface VerificationPlanDraftV1 {
|
|
52
|
+
readonly schemaVersion: typeof VERIFICATION_PLAN_DRAFT_SCHEMA_VERSION;
|
|
53
|
+
readonly draftId: string;
|
|
54
|
+
readonly status: 'draft';
|
|
55
|
+
readonly scope: VerificationPlanningScopeV1;
|
|
56
|
+
readonly checks: readonly VerificationCheckDraftV1[];
|
|
57
|
+
readonly proposalDispositions: readonly VerificationProposalDisposition[];
|
|
58
|
+
readonly summary: {
|
|
59
|
+
readonly requiredCheckCount: number;
|
|
60
|
+
readonly requiredChecksWithCandidates: number;
|
|
61
|
+
readonly allRequiredChecksHaveCandidates: boolean;
|
|
62
|
+
readonly requiredEvidenceSatisfied: false;
|
|
63
|
+
readonly nextAction: 'repropose_candidates' | 'independent_verification';
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export type VerificationPlanningResult = {
|
|
67
|
+
readonly planned: false;
|
|
68
|
+
readonly issues: readonly VerificationPlannerIssue[];
|
|
69
|
+
} | {
|
|
70
|
+
readonly planned: true;
|
|
71
|
+
readonly issues: readonly VerificationPlannerIssue[];
|
|
72
|
+
readonly draft: VerificationPlanDraftV1;
|
|
73
|
+
};
|
|
74
|
+
export declare function calculateVerificationPlanDraftId(draft: Pick<VerificationPlanDraftV1, 'schemaVersion' | 'status' | 'scope' | 'checks'>): string;
|
|
75
|
+
export declare function buildVerificationPlanDraft(task: TaskAggregate | null, candidates: readonly GovernanceEvidenceCandidateLedgerEntry[], input: VerificationPlannerInputV1): VerificationPlanningResult;
|
|
76
|
+
//# sourceMappingURL=verification-planner.d.ts.map
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { type AutonomyTier } from './autonomy-envelope.js';
|
|
2
|
+
import type { GovernanceEvidenceCandidateLedgerEntry } from './evidence-candidate.js';
|
|
3
|
+
import type { TaskAggregate } from './task-aggregate.js';
|
|
4
|
+
import { type EvidenceKind } from './task-contract.js';
|
|
5
|
+
import { type VerificationCheckBindingV1 } from './verification-check-binding.js';
|
|
6
|
+
import { type VerificationPlanDraftV1 } from './verification-planner.js';
|
|
7
|
+
export declare const VERIFICATION_RUN_REQUEST_SCHEMA_VERSION: 1;
|
|
8
|
+
export declare const VERIFICATION_RUN_CONTRACT_V1_SCHEMA_VERSION: 1;
|
|
9
|
+
export declare const VERIFICATION_RUN_CONTRACT_SCHEMA_VERSION: 2;
|
|
10
|
+
export declare const MAX_VERIFICATION_RUN_TTL_MS: number;
|
|
11
|
+
export declare const MAX_VERIFICATION_RUN_DURATION_MS: number;
|
|
12
|
+
export interface VerificationRunRequestV1 {
|
|
13
|
+
readonly schemaVersion: typeof VERIFICATION_RUN_REQUEST_SCHEMA_VERSION;
|
|
14
|
+
readonly draftId: string;
|
|
15
|
+
readonly requiredCheckId: string;
|
|
16
|
+
readonly candidateId: string;
|
|
17
|
+
}
|
|
18
|
+
/** Supplied by the deterministic daemon/transport, never by the model request payload. */
|
|
19
|
+
export interface VerificationRunAuthorityContext {
|
|
20
|
+
readonly verifierClientId: string;
|
|
21
|
+
readonly issuedAt: string;
|
|
22
|
+
readonly ttlMs: number;
|
|
23
|
+
readonly maxDurationMs: number;
|
|
24
|
+
}
|
|
25
|
+
export interface BoundVerificationRunAuthorityContext extends VerificationRunAuthorityContext {
|
|
26
|
+
/** Derived from the trusted immutable registry, never from the model request. */
|
|
27
|
+
readonly checkBinding: VerificationCheckBindingV1;
|
|
28
|
+
}
|
|
29
|
+
export interface VerificationRunContractV1 {
|
|
30
|
+
readonly schemaVersion: typeof VERIFICATION_RUN_CONTRACT_V1_SCHEMA_VERSION;
|
|
31
|
+
readonly runId: string;
|
|
32
|
+
readonly status: 'authorized';
|
|
33
|
+
readonly draftId: string;
|
|
34
|
+
readonly taskId: string;
|
|
35
|
+
readonly contractVersion: number;
|
|
36
|
+
readonly planFingerprint: string;
|
|
37
|
+
readonly workspaceManifestHash: string;
|
|
38
|
+
readonly requiredCheckId: string;
|
|
39
|
+
readonly expectedEvidenceKind: EvidenceKind;
|
|
40
|
+
readonly candidateId: string;
|
|
41
|
+
readonly candidateSource: string;
|
|
42
|
+
readonly verifierClientId: string;
|
|
43
|
+
readonly authorization: {
|
|
44
|
+
readonly operation: 'focused_check';
|
|
45
|
+
readonly mode: 'automatic';
|
|
46
|
+
readonly autonomyTier: AutonomyTier;
|
|
47
|
+
};
|
|
48
|
+
readonly limits: {
|
|
49
|
+
readonly issuedAt: string;
|
|
50
|
+
readonly expiresAt: string;
|
|
51
|
+
readonly ttlMs: number;
|
|
52
|
+
readonly maxDurationMs: number;
|
|
53
|
+
};
|
|
54
|
+
readonly resultPolicy: {
|
|
55
|
+
readonly executorMayApprove: false;
|
|
56
|
+
readonly independentToolEvidenceRequired: true;
|
|
57
|
+
readonly freshWorkspaceIdentityRequired: true;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export interface VerificationRunContractV2 extends Omit<VerificationRunContractV1, 'schemaVersion' | 'runId'> {
|
|
61
|
+
readonly schemaVersion: typeof VERIFICATION_RUN_CONTRACT_SCHEMA_VERSION;
|
|
62
|
+
readonly runId: string;
|
|
63
|
+
readonly checkBinding: VerificationCheckBindingV1;
|
|
64
|
+
}
|
|
65
|
+
export type VerificationRunContract = VerificationRunContractV1 | VerificationRunContractV2;
|
|
66
|
+
export type VerificationRunContractWithoutId = Omit<VerificationRunContractV1, 'runId'> | Omit<VerificationRunContractV2, 'runId'>;
|
|
67
|
+
export type VerificationRunIssuanceIssueCode = 'task_missing' | 'active_contract_missing' | 'workflow_state_invalid' | 'draft_invalid' | 'draft_scope_mismatch' | 'request_invalid' | 'required_check_missing' | 'required_check_drifted' | 'candidate_not_proposed' | 'candidate_missing' | 'candidate_ambiguous' | 'candidate_ineligible' | 'candidate_scope_mismatch' | 'verifier_identity_invalid' | 'verifier_not_independent' | 'operation_not_authorized' | 'check_binding_invalid' | 'check_binding_mismatch' | 'authority_time_invalid' | 'authority_limits_invalid';
|
|
68
|
+
export interface VerificationRunIssuanceIssue {
|
|
69
|
+
readonly code: VerificationRunIssuanceIssueCode;
|
|
70
|
+
readonly path: string;
|
|
71
|
+
readonly message: string;
|
|
72
|
+
}
|
|
73
|
+
export type VerificationRunIssuanceResult = {
|
|
74
|
+
readonly issued: true;
|
|
75
|
+
readonly contract: VerificationRunContract;
|
|
76
|
+
} | {
|
|
77
|
+
readonly issued: false;
|
|
78
|
+
readonly issues: readonly VerificationRunIssuanceIssue[];
|
|
79
|
+
};
|
|
80
|
+
export declare function calculateVerificationRunId(contract: VerificationRunContractWithoutId): string;
|
|
81
|
+
export declare function isVerificationRunContractIntegrityValid(contract: VerificationRunContract): boolean;
|
|
82
|
+
export declare function issueVerificationRunContract(task: TaskAggregate | null, draft: VerificationPlanDraftV1, candidates: readonly GovernanceEvidenceCandidateLedgerEntry[], request: VerificationRunRequestV1, authority: VerificationRunAuthorityContext): VerificationRunIssuanceResult;
|
|
83
|
+
export declare function issueBoundVerificationRunContract(task: TaskAggregate | null, draft: VerificationPlanDraftV1, candidates: readonly GovernanceEvidenceCandidateLedgerEntry[], request: VerificationRunRequestV1, authority: BoundVerificationRunAuthorityContext): VerificationRunIssuanceResult;
|
|
84
|
+
//# sourceMappingURL=verification-run-contract.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { GovernanceEventStore } from './event-store.js';
|
|
2
|
+
import type { VerificationCheckDescriptor } from './verification-check-binding.js';
|
|
3
|
+
import type { VerificationCheckRegistry, VerificationCheckRegistryDenialCode } from './verification-check-registry.js';
|
|
4
|
+
import type { ConsumeVerificationExecutionLeaseResult, VerificationExecutionLeaseConsumption, VerificationExecutionLeaseCredential } from './verification-execution-lease.js';
|
|
5
|
+
import type { VerificationRunContract } from './verification-run-contract.js';
|
|
6
|
+
export declare const VERIFICATION_TOOL_GATEWAY_REQUEST_SCHEMA_VERSION: 1;
|
|
7
|
+
export type VerificationToolGatewayMode = 'legacy' | 'enforced';
|
|
8
|
+
/**
|
|
9
|
+
* Contains only canonical identities and a one-time credential. Tool names,
|
|
10
|
+
* commands, paths, and arguments are deliberately not accepted at this boundary.
|
|
11
|
+
*/
|
|
12
|
+
export interface VerificationToolGatewayRequestV1 {
|
|
13
|
+
readonly schemaVersion: typeof VERIFICATION_TOOL_GATEWAY_REQUEST_SCHEMA_VERSION;
|
|
14
|
+
readonly credential: VerificationExecutionLeaseCredential;
|
|
15
|
+
readonly expected: {
|
|
16
|
+
readonly runId: string;
|
|
17
|
+
readonly taskId: string;
|
|
18
|
+
readonly planFingerprint: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export interface VerificationWorkspaceIdentity {
|
|
22
|
+
readonly manifestHash: string;
|
|
23
|
+
}
|
|
24
|
+
export interface VerificationExecutionLeaseConsumer {
|
|
25
|
+
consumeVerificationExecutionLease: GovernanceEventStore['consumeVerificationExecutionLease'];
|
|
26
|
+
}
|
|
27
|
+
export interface VerificationToolGatewayOptions<Result> {
|
|
28
|
+
/** Defaults to legacy so construction alone can never enable enforcement. */
|
|
29
|
+
readonly mode?: VerificationToolGatewayMode | undefined;
|
|
30
|
+
readonly verifierClientId: string;
|
|
31
|
+
readonly leaseConsumer: VerificationExecutionLeaseConsumer;
|
|
32
|
+
readonly captureWorkspaceIdentity: () => Promise<VerificationWorkspaceIdentity>;
|
|
33
|
+
readonly checkRegistry: VerificationCheckRegistry<Result>;
|
|
34
|
+
}
|
|
35
|
+
type VerificationLeaseDenialCode = Extract<ConsumeVerificationExecutionLeaseResult, {
|
|
36
|
+
readonly authorized: false;
|
|
37
|
+
}>['code'];
|
|
38
|
+
type VerificationToolGatewayDenialCode = VerificationLeaseDenialCode | 'request_invalid' | 'workspace_identity_unavailable';
|
|
39
|
+
export type VerificationToolGatewayResult<Result> = {
|
|
40
|
+
readonly route: 'legacy';
|
|
41
|
+
readonly handled: false;
|
|
42
|
+
readonly reason: 'gateway_disabled';
|
|
43
|
+
} | {
|
|
44
|
+
readonly route: 'governed';
|
|
45
|
+
readonly handled: true;
|
|
46
|
+
readonly authorized: false;
|
|
47
|
+
readonly code: VerificationToolGatewayDenialCode;
|
|
48
|
+
readonly message: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly route: 'governed';
|
|
51
|
+
readonly handled: true;
|
|
52
|
+
readonly authorized: true;
|
|
53
|
+
readonly outcome: 'succeeded';
|
|
54
|
+
readonly run: VerificationRunContract;
|
|
55
|
+
readonly consumption: VerificationExecutionLeaseConsumption;
|
|
56
|
+
readonly check: VerificationCheckDescriptor;
|
|
57
|
+
readonly result: Result;
|
|
58
|
+
} | {
|
|
59
|
+
readonly route: 'governed';
|
|
60
|
+
readonly handled: true;
|
|
61
|
+
readonly authorized: true;
|
|
62
|
+
readonly outcome: 'failed';
|
|
63
|
+
readonly code: 'focused_check_failed' | VerificationCheckRegistryDenialCode;
|
|
64
|
+
readonly message: string;
|
|
65
|
+
readonly run: VerificationRunContract;
|
|
66
|
+
readonly consumption: VerificationExecutionLeaseConsumption;
|
|
67
|
+
};
|
|
68
|
+
export declare class VerificationToolGateway<Result> {
|
|
69
|
+
#private;
|
|
70
|
+
constructor(options: VerificationToolGatewayOptions<Result>);
|
|
71
|
+
execute(request: VerificationToolGatewayRequestV1): Promise<VerificationToolGatewayResult<Result>>;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=verification-tool-gateway.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const WORKFLOW_STATES: readonly ['draft', 'scoped', 'planned', 'authorized', 'executing', 'proposed_complete', 'verifying', 'reviewing', 'ready_to_merge', 'completed', 'blocked', 'replan_requested', 'rolling_back', 'rolled_back', 'rollback_failed', 'failed', 'cancelled'];
|
|
2
|
+
export type WorkflowState = (typeof WORKFLOW_STATES)[number];
|
|
3
|
+
export declare function isTerminalWorkflowState(state: WorkflowState): boolean;
|
|
4
|
+
export declare function isSuccessfulWorkflowState(state: WorkflowState): boolean;
|
|
5
|
+
//# sourceMappingURL=workflow-state.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const WORKSPACE_SNAPSHOT_FENCE_SCHEMA_VERSION: 1;
|
|
2
|
+
export interface WorkspaceSnapshotFenceDescriptor {
|
|
3
|
+
readonly schemaVersion: typeof WORKSPACE_SNAPSHOT_FENCE_SCHEMA_VERSION;
|
|
4
|
+
readonly snapshotId: string;
|
|
5
|
+
readonly projectId: string;
|
|
6
|
+
readonly revision: number;
|
|
7
|
+
readonly manifestHash: string;
|
|
8
|
+
readonly capturedAt: string;
|
|
9
|
+
}
|
|
10
|
+
export type RecordWorkspaceSnapshotResult = {
|
|
11
|
+
readonly recorded: true;
|
|
12
|
+
readonly snapshot: WorkspaceSnapshotFenceDescriptor;
|
|
13
|
+
} | {
|
|
14
|
+
readonly recorded: false;
|
|
15
|
+
readonly code: 'workspace_snapshot_invalid';
|
|
16
|
+
readonly message: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function workspaceSnapshotFenceId(projectId: string, revision: number, manifestHash: string, capturedAt: string): string;
|
|
19
|
+
export declare function isWorkspaceSnapshotFenceDescriptorValid(snapshot: WorkspaceSnapshotFenceDescriptor): boolean;
|
|
20
|
+
//# sourceMappingURL=workspace-snapshot-fence.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wrongstack/governance",
|
|
3
|
+
"version": "0.298.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"description": "Deterministic workflow contracts and transition policy for WrongStack orchestration.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/WrongStack/WrongStack.git",
|
|
9
|
+
"directory": "packages/governance"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/WrongStack/WrongStack#readme",
|
|
12
|
+
"bugs": "https://github.com/WrongStack/WrongStack/issues",
|
|
13
|
+
"author": "ECOSTACK TECHNOLOGY OÜ",
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"!dist/**/*.map",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^26.1.1",
|
|
31
|
+
"typescript": "^7.0.2",
|
|
32
|
+
"vitest": "^4.1.10"
|
|
33
|
+
},
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public",
|
|
36
|
+
"provenance": true
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "node ../../scripts/build-package.mjs",
|
|
40
|
+
"typecheck": "tsc --noEmit",
|
|
41
|
+
"test": "vitest run --root ../.. packages/governance/tests",
|
|
42
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\""
|
|
43
|
+
}
|
|
44
|
+
}
|