@opengeni/contracts 0.50.0 → 2.2.0-canary.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/dist/agent-authored-durable-text.d.ts +64 -0
- package/dist/atlassian.d.ts +1 -0
- package/dist/atlassian.js +14 -13
- package/dist/{chunk-Y3MLSLB4.js → chunk-3SIZGL3O.js} +42 -30
- package/dist/chunk-3SIZGL3O.js.map +1 -0
- package/dist/{chunk-JBCIY7QD.js → chunk-7RMTKFJW.js} +45 -22
- package/dist/chunk-7RMTKFJW.js.map +1 -0
- package/dist/{chunk-Q6A7XT2N.js → chunk-7ZZ3R27P.js} +9598 -6021
- package/dist/chunk-7ZZ3R27P.js.map +1 -0
- package/dist/{chunk-5UDNP7AO.js → chunk-MRWYRAS5.js} +56 -8
- package/dist/chunk-MRWYRAS5.js.map +1 -0
- package/dist/{chunk-LW7OH6CS.js → chunk-N6GRVXAJ.js} +6 -5
- package/dist/chunk-N6GRVXAJ.js.map +1 -0
- package/dist/{chunk-TZ6YEYN4.js → chunk-NVJMJWLL.js} +3 -1
- package/dist/chunk-NVJMJWLL.js.map +1 -0
- package/dist/chunk-PX3VCKAU.js +29 -0
- package/dist/chunk-PX3VCKAU.js.map +1 -0
- package/dist/{chunk-LSB7GRLG.js → chunk-TXTQIYCV.js} +15 -11
- package/dist/chunk-TXTQIYCV.js.map +1 -0
- package/dist/{chunk-CADSX6UN.js → chunk-Y3KNXVTD.js} +2 -2
- package/dist/chunk-YBW5JSA3.js +251 -0
- package/dist/chunk-YBW5JSA3.js.map +1 -0
- package/dist/company-brain-governed-writes.d.ts +475 -0
- package/dist/company-brain.d.ts +398 -0
- package/dist/company-profile.d.ts +268 -0
- package/dist/connection-authority.d.ts +501 -0
- package/dist/connection-authority.js +364 -0
- package/dist/connection-authority.js.map +1 -0
- package/dist/connector-attachments.d.ts +95 -0
- package/dist/connector-attachments.js +51 -0
- package/dist/connector-attachments.js.map +1 -0
- package/dist/editable-artifact-codec-registry.d.ts +16 -7
- package/dist/editable-artifact-codec-registry.js +18 -8
- package/dist/editable-artifact-committed-transaction.d.ts +2 -2
- package/dist/editable-artifact-committed-transaction.js +2 -2
- package/dist/editable-artifact-live.d.ts +11 -12
- package/dist/editable-artifact-live.js +111 -46
- package/dist/editable-artifact-live.js.map +1 -1
- package/dist/editable-artifact-serialized-commit.d.ts +2 -1
- package/dist/editable-artifact-serialized-commit.js +9 -8
- package/dist/editable-artifact-versions.d.ts +20 -5
- package/dist/editable-artifact-versions.js +23 -5
- package/dist/editable-artifacts.d.ts +2 -0
- package/dist/editable-artifacts.js +51 -39
- package/dist/google-drive.d.ts +89 -1
- package/dist/google-drive.js +78 -17
- package/dist/google-drive.js.map +1 -1
- package/dist/governed-learning-activation.d.ts +154 -0
- package/dist/governed-learning-evaluator.d.ts +152 -0
- package/dist/index.d.ts +12395 -1426
- package/dist/index.js +837 -115
- package/dist/interaction.d.ts +68 -0
- package/dist/knowledge.d.ts +192 -0
- package/dist/organization-membership-lifecycle.d.ts +516 -0
- package/dist/permissions.d.ts +52 -0
- package/dist/personal-github.d.ts +319 -0
- package/dist/personal-github.js +209 -0
- package/dist/personal-github.js.map +1 -0
- package/dist/preference-registry.d.ts +17 -0
- package/dist/remember.d.ts +331 -0
- package/dist/sandbox-file-artifacts.d.ts +56 -0
- package/dist/sandbox-snapshots.d.ts +21 -0
- package/dist/slack-bot-scopes.d.ts +34 -14
- package/dist/slack-bot-scopes.js +5 -1
- package/dist/spreadsheet-artifact-commands.d.ts +2 -3
- package/dist/spreadsheet-artifact-commands.js +4 -2
- package/dist/spreadsheet-artifact-query.js +3 -2
- package/dist/task-notes.d.ts +42 -1
- package/dist/tool-result-spill.d.ts +16 -0
- package/dist/workspace-instruction-policies.d.ts +81 -0
- package/dist/workspace-learning-administration.d.ts +289 -0
- package/package.json +13 -1
- package/src/agent-authored-durable-text.ts +105 -0
- package/src/company-brain-governed-writes.ts +356 -0
- package/src/company-brain.ts +201 -0
- package/src/company-profile.ts +122 -1
- package/src/connection-authority.ts +413 -0
- package/src/connector-attachments.ts +327 -0
- package/src/editable-artifact-codec-registry.ts +55 -17
- package/src/editable-artifact-committed-transaction.ts +44 -31
- package/src/editable-artifact-live.ts +123 -57
- package/src/editable-artifact-serialized-commit.ts +2 -1
- package/src/editable-artifact-versions.ts +26 -5
- package/src/editable-artifacts.ts +2 -0
- package/src/google-drive.ts +76 -4
- package/src/governed-learning-activation.ts +191 -0
- package/src/governed-learning-evaluator.ts +176 -0
- package/src/index.ts +3182 -483
- package/src/interaction.ts +55 -1
- package/src/knowledge.ts +133 -6
- package/src/organization-membership-lifecycle.ts +330 -0
- package/src/permissions.ts +55 -0
- package/src/personal-github.ts +267 -0
- package/src/preference-registry.ts +17 -0
- package/src/remember.ts +242 -0
- package/src/sandbox-file-artifacts.ts +65 -0
- package/src/sandbox-snapshots.ts +78 -0
- package/src/slack-bot-scopes.ts +81 -9
- package/src/spreadsheet-artifact-commands.ts +12 -13
- package/src/task-notes.ts +14 -1
- package/src/tool-result-spill.ts +35 -0
- package/src/workspace-instruction-policies.ts +30 -0
- package/src/workspace-learning-administration.ts +88 -0
- package/dist/chunk-5UDNP7AO.js.map +0 -1
- package/dist/chunk-BVGIYW7D.js +0 -11
- package/dist/chunk-BVGIYW7D.js.map +0 -1
- package/dist/chunk-JBCIY7QD.js.map +0 -1
- package/dist/chunk-LSB7GRLG.js.map +0 -1
- package/dist/chunk-LW7OH6CS.js.map +0 -1
- package/dist/chunk-Q6A7XT2N.js.map +0 -1
- package/dist/chunk-TZ6YEYN4.js.map +0 -1
- package/dist/chunk-Y3MLSLB4.js.map +0 -1
- /package/dist/{chunk-CADSX6UN.js.map → chunk-Y3KNXVTD.js.map} +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
const sha256 = z.string().regex(/^[0-9a-f]{64}$/);
|
|
4
|
+
const boundedActor = z.string().trim().min(1).max(1_024);
|
|
5
|
+
|
|
6
|
+
export const GovernedLearningActivationDestination = z.enum(["instruction_policy", "preference"]);
|
|
7
|
+
export const GovernedLearningActivationAuthorityKind = z.enum(["automatic", "human_confirmed"]);
|
|
8
|
+
export type GovernedLearningActivationAuthorityKind = z.infer<
|
|
9
|
+
typeof GovernedLearningActivationAuthorityKind
|
|
10
|
+
>;
|
|
11
|
+
export type GovernedLearningActivationDestination = z.infer<
|
|
12
|
+
typeof GovernedLearningActivationDestination
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
export const GovernedLearningActivationCaller = z
|
|
16
|
+
.object({
|
|
17
|
+
workspaceId: z.string().uuid(),
|
|
18
|
+
subjectId: boundedActor,
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
|
21
|
+
export type GovernedLearningActivationCaller = z.infer<typeof GovernedLearningActivationCaller>;
|
|
22
|
+
|
|
23
|
+
export const ActivateGovernedLearningDecisionRequest = z
|
|
24
|
+
.object({
|
|
25
|
+
operationId: z.string().uuid(),
|
|
26
|
+
decisionReceiptId: z.string().uuid(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
export type ActivateGovernedLearningDecisionRequest = z.infer<
|
|
30
|
+
typeof ActivateGovernedLearningDecisionRequest
|
|
31
|
+
>;
|
|
32
|
+
|
|
33
|
+
export const UndoGovernedLearningActivationRequest = z
|
|
34
|
+
.object({
|
|
35
|
+
operationId: z.string().uuid(),
|
|
36
|
+
activationReceiptId: z.string().uuid(),
|
|
37
|
+
})
|
|
38
|
+
.strict();
|
|
39
|
+
export type UndoGovernedLearningActivationRequest = z.infer<
|
|
40
|
+
typeof UndoGovernedLearningActivationRequest
|
|
41
|
+
>;
|
|
42
|
+
|
|
43
|
+
const destinationBoundary = {
|
|
44
|
+
destination: GovernedLearningActivationDestination,
|
|
45
|
+
destinationProposalId: z.string().uuid(),
|
|
46
|
+
destinationRevisionId: z.string().uuid(),
|
|
47
|
+
destinationOldRevisionId: z.string().uuid().nullable(),
|
|
48
|
+
destinationOldContentHash: sha256.nullable(),
|
|
49
|
+
destinationOldVersion: z.number().int().nonnegative(),
|
|
50
|
+
destinationNewContentHash: sha256,
|
|
51
|
+
destinationNewVersion: z.number().int().positive(),
|
|
52
|
+
destinationEventId: z.string().uuid(),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Immutable content-free proof that one final automatic evaluator receipt was
|
|
57
|
+
* revalidated and applied through the destination-owned lifecycle.
|
|
58
|
+
*/
|
|
59
|
+
export const GovernedLearningActivationReceipt = z
|
|
60
|
+
.object({
|
|
61
|
+
id: z.string().uuid(),
|
|
62
|
+
operationId: z.string().uuid(),
|
|
63
|
+
inputHash: sha256,
|
|
64
|
+
accountId: z.string().uuid(),
|
|
65
|
+
workspaceId: z.string().uuid(),
|
|
66
|
+
decisionReceiptId: z.string().uuid(),
|
|
67
|
+
initiatingHumanSubjectId: boundedActor,
|
|
68
|
+
serviceActorSubjectId: boundedActor,
|
|
69
|
+
policyRevisionId: z.string().uuid(),
|
|
70
|
+
policyHash: sha256,
|
|
71
|
+
policyActivationVersion: z.number().int().positive(),
|
|
72
|
+
sourceKind: z.enum(["scoped-knowledge-evidence", "task-note"]),
|
|
73
|
+
sourceId: z.string().uuid(),
|
|
74
|
+
sourceAuthorityHash: sha256,
|
|
75
|
+
proposalId: z.string().uuid(),
|
|
76
|
+
claimId: z.string().uuid(),
|
|
77
|
+
evidenceId: z.string().uuid(),
|
|
78
|
+
knowledgePreviousReviewId: z.string().uuid(),
|
|
79
|
+
knowledgePreviousReviewRevision: z.number().int().positive(),
|
|
80
|
+
knowledgeApprovalReviewId: z.string().uuid(),
|
|
81
|
+
knowledgeApprovalReviewRevision: z.number().int().positive(),
|
|
82
|
+
knowledgeApprovalInputHash: sha256,
|
|
83
|
+
...destinationBoundary,
|
|
84
|
+
outcome: z.literal("activated"),
|
|
85
|
+
effectiveAt: z.string().datetime(),
|
|
86
|
+
/**
|
|
87
|
+
* `automatic`: a final eligible evaluator receipt under an automatic policy.
|
|
88
|
+
* `human_confirmed`: the exact initiating human answered the bound
|
|
89
|
+
* `remember:<proposalId>` structured human-input question with `save`.
|
|
90
|
+
*/
|
|
91
|
+
authorityKind: GovernedLearningActivationAuthorityKind,
|
|
92
|
+
humanInputRequestId: z.string().uuid().nullable(),
|
|
93
|
+
rollback: z
|
|
94
|
+
.object({
|
|
95
|
+
supported: z.literal(true),
|
|
96
|
+
mechanism: z.literal("exact_head_and_latest_review"),
|
|
97
|
+
})
|
|
98
|
+
.strict(),
|
|
99
|
+
createdAt: z.string().datetime(),
|
|
100
|
+
})
|
|
101
|
+
.strict();
|
|
102
|
+
export type GovernedLearningActivationReceipt = z.infer<typeof GovernedLearningActivationReceipt>;
|
|
103
|
+
|
|
104
|
+
export const ActivateHumanConfirmedLearningDecisionRequest = z
|
|
105
|
+
.object({
|
|
106
|
+
operationId: z.string().uuid(),
|
|
107
|
+
decisionReceiptId: z.string().uuid(),
|
|
108
|
+
humanInputRequestId: z.string().uuid(),
|
|
109
|
+
})
|
|
110
|
+
.strict();
|
|
111
|
+
export type ActivateHumanConfirmedLearningDecisionRequest = z.infer<
|
|
112
|
+
typeof ActivateHumanConfirmedLearningDecisionRequest
|
|
113
|
+
>;
|
|
114
|
+
|
|
115
|
+
/** Append-only compensation proof. Undo never deletes prior evidence. */
|
|
116
|
+
export const GovernedLearningActivationUndoReceipt = z
|
|
117
|
+
.object({
|
|
118
|
+
id: z.string().uuid(),
|
|
119
|
+
operationId: z.string().uuid(),
|
|
120
|
+
inputHash: sha256,
|
|
121
|
+
accountId: z.string().uuid(),
|
|
122
|
+
workspaceId: z.string().uuid(),
|
|
123
|
+
activationReceiptId: z.string().uuid(),
|
|
124
|
+
initiatingHumanSubjectId: boundedActor,
|
|
125
|
+
serviceActorSubjectId: boundedActor,
|
|
126
|
+
destination: GovernedLearningActivationDestination,
|
|
127
|
+
knowledgeApprovalReviewId: z.string().uuid(),
|
|
128
|
+
knowledgeRevocationReviewId: z.string().uuid(),
|
|
129
|
+
knowledgeRevocationReviewRevision: z.number().int().positive(),
|
|
130
|
+
knowledgeRevocationInputHash: sha256,
|
|
131
|
+
destinationActivatedRevisionId: z.string().uuid(),
|
|
132
|
+
destinationRestoredRevisionId: z.string().uuid().nullable(),
|
|
133
|
+
destinationActivatedContentHash: sha256,
|
|
134
|
+
destinationRestoredContentHash: sha256.nullable(),
|
|
135
|
+
destinationOldVersion: z.number().int().positive(),
|
|
136
|
+
destinationNewVersion: z.number().int().positive(),
|
|
137
|
+
destinationEventId: z.string().uuid(),
|
|
138
|
+
outcome: z.literal("undone"),
|
|
139
|
+
superseded: z.literal(false),
|
|
140
|
+
effectiveAt: z.string().datetime(),
|
|
141
|
+
createdAt: z.string().datetime(),
|
|
142
|
+
})
|
|
143
|
+
.strict();
|
|
144
|
+
export type GovernedLearningActivationUndoReceipt = z.infer<
|
|
145
|
+
typeof GovernedLearningActivationUndoReceipt
|
|
146
|
+
>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Immutable content-free proof that the exact initiating human confirmed a
|
|
150
|
+
* user-directed Knowledge claim (`remember` with lane `knowledge`) through the
|
|
151
|
+
* bound structured human-input question, after which the claim's latest
|
|
152
|
+
* `proposed` review was superseded by an `approved` service review.
|
|
153
|
+
*/
|
|
154
|
+
export const RememberKnowledgeConfirmationReceipt = z
|
|
155
|
+
.object({
|
|
156
|
+
id: z.string().uuid(),
|
|
157
|
+
operationId: z.string().uuid(),
|
|
158
|
+
inputHash: sha256,
|
|
159
|
+
accountId: z.string().uuid(),
|
|
160
|
+
workspaceId: z.string().uuid(),
|
|
161
|
+
sessionId: z.string().uuid(),
|
|
162
|
+
turnId: z.string().uuid(),
|
|
163
|
+
executionGeneration: z.number().int().positive(),
|
|
164
|
+
initiatingHumanSubjectId: boundedActor,
|
|
165
|
+
serviceActorSubjectId: boundedActor,
|
|
166
|
+
claimId: z.string().uuid(),
|
|
167
|
+
evidenceId: z.string().uuid(),
|
|
168
|
+
taskNoteId: z.string().uuid(),
|
|
169
|
+
taskNoteTextHash: sha256,
|
|
170
|
+
humanInputRequestId: z.string().uuid(),
|
|
171
|
+
previousReviewId: z.string().uuid(),
|
|
172
|
+
previousReviewRevision: z.number().int().positive(),
|
|
173
|
+
approvalReviewId: z.string().uuid(),
|
|
174
|
+
approvalReviewRevision: z.number().int().positive(),
|
|
175
|
+
createdAt: z.string().datetime(),
|
|
176
|
+
})
|
|
177
|
+
.strict();
|
|
178
|
+
export type RememberKnowledgeConfirmationReceipt = z.infer<
|
|
179
|
+
typeof RememberKnowledgeConfirmationReceipt
|
|
180
|
+
>;
|
|
181
|
+
|
|
182
|
+
export const ConfirmRememberKnowledgeClaimRequest = z
|
|
183
|
+
.object({
|
|
184
|
+
operationId: z.string().uuid(),
|
|
185
|
+
claimId: z.string().uuid(),
|
|
186
|
+
humanInputRequestId: z.string().uuid(),
|
|
187
|
+
})
|
|
188
|
+
.strict();
|
|
189
|
+
export type ConfirmRememberKnowledgeClaimRequest = z.infer<
|
|
190
|
+
typeof ConfirmRememberKnowledgeClaimRequest
|
|
191
|
+
>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { WorkspaceLearningMode } from "./workspace-learning-policy";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Automatic is intentionally conservative in the first evaluator tranche.
|
|
6
|
+
* This constant is platform-owned rather than caller-selectable so an agent or
|
|
7
|
+
* connector cannot lower the admission floor inside one request.
|
|
8
|
+
*/
|
|
9
|
+
export const GOVERNED_LEARNING_AUTOMATIC_CONFIDENCE_FLOOR_BPS = 8_500;
|
|
10
|
+
export const GOVERNED_LEARNING_MAX_CONFLICT_COUNT = 1_000;
|
|
11
|
+
|
|
12
|
+
export const GovernedLearningDecisionOutcome = z.enum([
|
|
13
|
+
"off",
|
|
14
|
+
"suggest",
|
|
15
|
+
"automatic",
|
|
16
|
+
"confidence",
|
|
17
|
+
"conflict",
|
|
18
|
+
"stale",
|
|
19
|
+
"revoked",
|
|
20
|
+
]);
|
|
21
|
+
export type GovernedLearningDecisionOutcome = z.infer<typeof GovernedLearningDecisionOutcome>;
|
|
22
|
+
|
|
23
|
+
/** Stable order used by TypeScript, SQL constraints, and public receipts. */
|
|
24
|
+
export const GOVERNED_LEARNING_REASON_ORDER = [
|
|
25
|
+
"policy_off",
|
|
26
|
+
"evidence_revoked",
|
|
27
|
+
"proposal_stale",
|
|
28
|
+
"evidence_conflict",
|
|
29
|
+
"confidence_below_floor",
|
|
30
|
+
"policy_suggest",
|
|
31
|
+
"policy_automatic",
|
|
32
|
+
] as const;
|
|
33
|
+
|
|
34
|
+
export const GovernedLearningDecisionReason = z.enum(GOVERNED_LEARNING_REASON_ORDER);
|
|
35
|
+
export type GovernedLearningDecisionReason = z.infer<typeof GovernedLearningDecisionReason>;
|
|
36
|
+
|
|
37
|
+
export const GovernedLearningDecisionFacts = z
|
|
38
|
+
.object({
|
|
39
|
+
effectiveMode: WorkspaceLearningMode,
|
|
40
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
41
|
+
conflictCount: z.number().int().min(0).max(GOVERNED_LEARNING_MAX_CONFLICT_COUNT),
|
|
42
|
+
stale: z.boolean(),
|
|
43
|
+
revoked: z.boolean(),
|
|
44
|
+
})
|
|
45
|
+
.strict();
|
|
46
|
+
export type GovernedLearningDecisionFacts = z.infer<typeof GovernedLearningDecisionFacts>;
|
|
47
|
+
|
|
48
|
+
export const GovernedLearningDecision = z
|
|
49
|
+
.object({
|
|
50
|
+
outcome: GovernedLearningDecisionOutcome,
|
|
51
|
+
reasons: z
|
|
52
|
+
.array(GovernedLearningDecisionReason)
|
|
53
|
+
.min(1)
|
|
54
|
+
.max(GOVERNED_LEARNING_REASON_ORDER.length),
|
|
55
|
+
automaticEligible: z.boolean(),
|
|
56
|
+
confidenceFloorBps: z.literal(GOVERNED_LEARNING_AUTOMATIC_CONFIDENCE_FLOOR_BPS),
|
|
57
|
+
})
|
|
58
|
+
.strict()
|
|
59
|
+
.superRefine((decision, context) => {
|
|
60
|
+
if (decision.automaticEligible !== (decision.outcome === "automatic")) {
|
|
61
|
+
context.addIssue({
|
|
62
|
+
code: "custom",
|
|
63
|
+
path: ["automaticEligible"],
|
|
64
|
+
message: "automatic eligibility must exactly match the automatic outcome",
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
const indexes = decision.reasons.map((reason) =>
|
|
68
|
+
GOVERNED_LEARNING_REASON_ORDER.indexOf(reason),
|
|
69
|
+
);
|
|
70
|
+
if (indexes.some((value, index) => index > 0 && value <= indexes[index - 1]!)) {
|
|
71
|
+
context.addIssue({
|
|
72
|
+
code: "custom",
|
|
73
|
+
path: ["reasons"],
|
|
74
|
+
message: "governed-learning reasons must be unique and in canonical order",
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
export type GovernedLearningDecision = z.infer<typeof GovernedLearningDecision>;
|
|
79
|
+
|
|
80
|
+
export const GovernedLearningEvaluationAttempt = z
|
|
81
|
+
.object({
|
|
82
|
+
workspaceId: z.string().uuid(),
|
|
83
|
+
subjectId: z.string().trim().min(1).max(1_024),
|
|
84
|
+
sessionId: z.string().uuid(),
|
|
85
|
+
turnId: z.string().uuid(),
|
|
86
|
+
attemptId: z.string().uuid(),
|
|
87
|
+
executionGeneration: z.number().int().positive(),
|
|
88
|
+
})
|
|
89
|
+
.strict();
|
|
90
|
+
export type GovernedLearningEvaluationAttempt = z.infer<typeof GovernedLearningEvaluationAttempt>;
|
|
91
|
+
|
|
92
|
+
export const EvaluateGovernedLearningProposalRequest = z
|
|
93
|
+
.object({
|
|
94
|
+
operationId: z.string().uuid(),
|
|
95
|
+
policySnapshotId: z.string().uuid(),
|
|
96
|
+
proposalId: z.string().uuid(),
|
|
97
|
+
claimId: z.string().uuid(),
|
|
98
|
+
evidenceId: z.string().uuid(),
|
|
99
|
+
})
|
|
100
|
+
.strict();
|
|
101
|
+
export type EvaluateGovernedLearningProposalRequest = z.infer<
|
|
102
|
+
typeof EvaluateGovernedLearningProposalRequest
|
|
103
|
+
>;
|
|
104
|
+
|
|
105
|
+
const sha256 = z.string().regex(/^[0-9a-f]{64}$/);
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Content-free immutable evidence. Hashes and bounded enums identify exactly
|
|
109
|
+
* what was evaluated without copying proposal, fact, citation, or note text.
|
|
110
|
+
*/
|
|
111
|
+
export const GovernedLearningDecisionReceipt = z
|
|
112
|
+
.object({
|
|
113
|
+
id: z.string().uuid(),
|
|
114
|
+
operationId: z.string().uuid(),
|
|
115
|
+
inputHash: sha256,
|
|
116
|
+
accountId: z.string().uuid(),
|
|
117
|
+
workspaceId: z.string().uuid(),
|
|
118
|
+
sessionId: z.string().uuid(),
|
|
119
|
+
turnId: z.string().uuid(),
|
|
120
|
+
attemptId: z.string().uuid(),
|
|
121
|
+
executionGeneration: z.number().int().positive(),
|
|
122
|
+
initiatingHumanSubjectId: z.string().min(1).max(1_024),
|
|
123
|
+
policySnapshotId: z.string().uuid(),
|
|
124
|
+
policySnapshotHash: sha256,
|
|
125
|
+
policyRevisionId: z.string().uuid().nullable(),
|
|
126
|
+
policyActivationVersion: z.number().int().nonnegative(),
|
|
127
|
+
sourceKind: z.enum(["scoped-knowledge-evidence", "task-note"]),
|
|
128
|
+
sourceId: z.string().uuid(),
|
|
129
|
+
proposalId: z.string().uuid(),
|
|
130
|
+
proposalInputHash: sha256,
|
|
131
|
+
proposalContentHash: sha256,
|
|
132
|
+
claimId: z.string().uuid(),
|
|
133
|
+
claimInputHash: sha256,
|
|
134
|
+
evidenceId: z.string().uuid(),
|
|
135
|
+
evidenceInputHash: sha256,
|
|
136
|
+
evidenceContentHash: sha256,
|
|
137
|
+
evidenceAuthorityHash: sha256,
|
|
138
|
+
reviewRevision: z.number().int().positive(),
|
|
139
|
+
reviewState: z.enum(["proposed", "approved", "rejected", "revoked"]),
|
|
140
|
+
effectiveMode: WorkspaceLearningMode,
|
|
141
|
+
confidenceBps: z.number().int().min(0).max(10_000),
|
|
142
|
+
conflictCount: z.number().int().min(0).max(GOVERNED_LEARNING_MAX_CONFLICT_COUNT),
|
|
143
|
+
outcome: GovernedLearningDecisionOutcome,
|
|
144
|
+
reasons: z
|
|
145
|
+
.array(GovernedLearningDecisionReason)
|
|
146
|
+
.min(1)
|
|
147
|
+
.max(GOVERNED_LEARNING_REASON_ORDER.length),
|
|
148
|
+
automaticEligible: z.boolean(),
|
|
149
|
+
confidenceFloorBps: z.literal(GOVERNED_LEARNING_AUTOMATIC_CONFIDENCE_FLOOR_BPS),
|
|
150
|
+
createdAt: z.string().datetime(),
|
|
151
|
+
})
|
|
152
|
+
.strict()
|
|
153
|
+
.superRefine((receipt, context) => {
|
|
154
|
+
const decision = GovernedLearningDecision.safeParse({
|
|
155
|
+
outcome: receipt.outcome,
|
|
156
|
+
reasons: receipt.reasons,
|
|
157
|
+
automaticEligible: receipt.automaticEligible,
|
|
158
|
+
confidenceFloorBps: receipt.confidenceFloorBps,
|
|
159
|
+
});
|
|
160
|
+
if (!decision.success) {
|
|
161
|
+
for (const issue of decision.error.issues) {
|
|
162
|
+
context.addIssue({ ...issue, path: issue.path });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if (
|
|
166
|
+
receipt.sourceKind === "scoped-knowledge-evidence" &&
|
|
167
|
+
receipt.sourceId !== receipt.evidenceId
|
|
168
|
+
) {
|
|
169
|
+
context.addIssue({
|
|
170
|
+
code: "custom",
|
|
171
|
+
path: ["sourceId"],
|
|
172
|
+
message: "scoped-Knowledge evaluation must use its exact evidence id as the source id",
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
export type GovernedLearningDecisionReceipt = z.infer<typeof GovernedLearningDecisionReceipt>;
|