@flowdesk/core 0.1.0 → 0.1.3
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 +44 -0
- package/dist/authority-promotion.d.ts +70 -0
- package/dist/authority-promotion.d.ts.map +1 -0
- package/dist/authority-promotion.js +388 -0
- package/dist/authority-promotion.js.map +1 -0
- package/dist/chat-control-authority.d.ts +83 -0
- package/dist/chat-control-authority.d.ts.map +1 -0
- package/dist/chat-control-authority.js +238 -0
- package/dist/chat-control-authority.js.map +1 -0
- package/dist/chat-hook-authority-probe.d.ts +39 -0
- package/dist/chat-hook-authority-probe.d.ts.map +1 -0
- package/dist/chat-hook-authority-probe.js +153 -0
- package/dist/chat-hook-authority-probe.js.map +1 -0
- package/dist/chat-routing.d.ts.map +1 -1
- package/dist/chat-routing.js +18 -15
- package/dist/chat-routing.js.map +1 -1
- package/dist/connector-gateway.d.ts +34 -0
- package/dist/connector-gateway.d.ts.map +1 -0
- package/dist/connector-gateway.js +147 -0
- package/dist/connector-gateway.js.map +1 -0
- package/dist/connector-profile.d.ts +41 -0
- package/dist/connector-profile.d.ts.map +1 -0
- package/dist/connector-profile.js +125 -0
- package/dist/connector-profile.js.map +1 -0
- package/dist/controlled-conformance-doc-write.d.ts +44 -0
- package/dist/controlled-conformance-doc-write.d.ts.map +1 -0
- package/dist/controlled-conformance-doc-write.js +142 -0
- package/dist/controlled-conformance-doc-write.js.map +1 -0
- package/dist/controlled-redacted-audit-export-write.d.ts +45 -0
- package/dist/controlled-redacted-audit-export-write.d.ts.map +1 -0
- package/dist/controlled-redacted-audit-export-write.js +145 -0
- package/dist/controlled-redacted-audit-export-write.js.map +1 -0
- package/dist/core-completion-safety-contracts.d.ts +35 -0
- package/dist/core-completion-safety-contracts.d.ts.map +1 -0
- package/dist/core-completion-safety-contracts.js +98 -0
- package/dist/core-completion-safety-contracts.js.map +1 -0
- package/dist/dispatch-attempt-manifest.d.ts +59 -0
- package/dist/dispatch-attempt-manifest.d.ts.map +1 -0
- package/dist/dispatch-attempt-manifest.js +294 -0
- package/dist/dispatch-attempt-manifest.js.map +1 -0
- package/dist/dispatch-idempotency.d.ts +89 -0
- package/dist/dispatch-idempotency.d.ts.map +1 -0
- package/dist/dispatch-idempotency.js +275 -0
- package/dist/dispatch-idempotency.js.map +1 -0
- package/dist/external-auth-policy.d.ts +49 -0
- package/dist/external-auth-policy.d.ts.map +1 -0
- package/dist/external-auth-policy.js +166 -0
- package/dist/external-auth-policy.js.map +1 -0
- package/dist/fake-remote-connector-adapter.d.ts +37 -0
- package/dist/fake-remote-connector-adapter.d.ts.map +1 -0
- package/dist/fake-remote-connector-adapter.js +162 -0
- package/dist/fake-remote-connector-adapter.js.map +1 -0
- package/dist/fallback-decision.d.ts +29 -0
- package/dist/fallback-decision.d.ts.map +1 -0
- package/dist/fallback-decision.js +93 -0
- package/dist/fallback-decision.js.map +1 -0
- package/dist/fallback-regate-plan.d.ts +34 -0
- package/dist/fallback-regate-plan.d.ts.map +1 -0
- package/dist/fallback-regate-plan.js +122 -0
- package/dist/fallback-regate-plan.js.map +1 -0
- package/dist/fds1-schema-probe-result.d.ts +37 -0
- package/dist/fds1-schema-probe-result.d.ts.map +1 -0
- package/dist/fds1-schema-probe-result.js +115 -0
- package/dist/fds1-schema-probe-result.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -1
- package/dist/lane-heartbeat.d.ts +49 -0
- package/dist/lane-heartbeat.d.ts.map +1 -0
- package/dist/lane-heartbeat.js +149 -0
- package/dist/lane-heartbeat.js.map +1 -0
- package/dist/lane-lifecycle-record.d.ts +32 -0
- package/dist/lane-lifecycle-record.d.ts.map +1 -0
- package/dist/lane-lifecycle-record.js +134 -0
- package/dist/lane-lifecycle-record.js.map +1 -0
- package/dist/lane-stall-projection.d.ts +43 -0
- package/dist/lane-stall-projection.d.ts.map +1 -0
- package/dist/lane-stall-projection.js +272 -0
- package/dist/lane-stall-projection.js.map +1 -0
- package/dist/model-availability-cache.d.ts +286 -0
- package/dist/model-availability-cache.d.ts.map +1 -0
- package/dist/model-availability-cache.js +1109 -0
- package/dist/model-availability-cache.js.map +1 -0
- package/dist/operational-intelligence.d.ts +38 -0
- package/dist/operational-intelligence.d.ts.map +1 -0
- package/dist/operational-intelligence.js +107 -0
- package/dist/operational-intelligence.js.map +1 -0
- package/dist/production-approval-source.d.ts +61 -0
- package/dist/production-approval-source.d.ts.map +1 -0
- package/dist/production-approval-source.js +226 -0
- package/dist/production-approval-source.js.map +1 -0
- package/dist/production-enablement.d.ts +92 -1
- package/dist/production-enablement.d.ts.map +1 -1
- package/dist/production-enablement.js +421 -8
- package/dist/production-enablement.js.map +1 -1
- package/dist/production-verification.d.ts +31 -0
- package/dist/production-verification.d.ts.map +1 -0
- package/dist/production-verification.js +126 -0
- package/dist/production-verification.js.map +1 -0
- package/dist/provider-usage-collector.d.ts +7 -0
- package/dist/provider-usage-collector.d.ts.map +1 -1
- package/dist/provider-usage-collector.js +64 -10
- package/dist/provider-usage-collector.js.map +1 -1
- package/dist/release1-contracts.d.ts +8 -2
- package/dist/release1-contracts.d.ts.map +1 -1
- package/dist/release1-contracts.js +2 -1
- package/dist/release1-contracts.js.map +1 -1
- package/dist/remote-write-connector-gate.d.ts +91 -0
- package/dist/remote-write-connector-gate.d.ts.map +1 -0
- package/dist/remote-write-connector-gate.js +291 -0
- package/dist/remote-write-connector-gate.js.map +1 -0
- package/dist/runtime-lane-productization.d.ts +78 -0
- package/dist/runtime-lane-productization.d.ts.map +1 -0
- package/dist/runtime-lane-productization.js +270 -0
- package/dist/runtime-lane-productization.js.map +1 -0
- package/dist/sanitized-auth-capture.d.ts +50 -0
- package/dist/sanitized-auth-capture.d.ts.map +1 -0
- package/dist/sanitized-auth-capture.js +164 -0
- package/dist/sanitized-auth-capture.js.map +1 -0
- package/dist/schema-artifacts.d.ts.map +1 -1
- package/dist/schema-artifacts.js +37 -6
- package/dist/schema-artifacts.js.map +1 -1
- package/dist/schema-registry.d.ts.map +1 -1
- package/dist/schema-registry.js +21 -0
- package/dist/schema-registry.js.map +1 -1
- package/dist/session-evidence.d.ts +117 -0
- package/dist/session-evidence.d.ts.map +1 -1
- package/dist/session-evidence.js +581 -1
- package/dist/session-evidence.js.map +1 -1
- package/dist/state-paths.d.ts +1 -1
- package/dist/state-paths.d.ts.map +1 -1
- package/dist/state-paths.js +56 -6
- package/dist/state-paths.js.map +1 -1
- package/dist/status.d.ts +7 -0
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +89 -1
- package/dist/status.js.map +1 -1
- package/dist/validators.d.ts +1 -0
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +30 -7
- package/dist/validators.js.map +1 -1
- package/package.json +11 -2
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { evaluateFlowDeskRemoteWriteConnectorExecutionReadinessV1, } from "./remote-write-connector-gate.js";
|
|
2
|
+
import { invalid, valid, validateNoForbiddenRawPayloads, validateOpaqueId, validateOpaqueRef, } from "./validators.js";
|
|
3
|
+
const disabledFakeRemoteConnectorAuthority = {
|
|
4
|
+
remote_write_attempted: false,
|
|
5
|
+
connector_write_attempted: false,
|
|
6
|
+
github_write_attempted: false,
|
|
7
|
+
storage_write_attempted: false,
|
|
8
|
+
database_write_attempted: false,
|
|
9
|
+
url_write_attempted: false,
|
|
10
|
+
raw_path_write_attempted: false,
|
|
11
|
+
remote_write_authority_enabled: false,
|
|
12
|
+
external_write_authority_enabled: false,
|
|
13
|
+
dispatch_authority_enabled: false,
|
|
14
|
+
providerCall: false,
|
|
15
|
+
actualLaneLaunch: false,
|
|
16
|
+
runtimeExecution: false,
|
|
17
|
+
};
|
|
18
|
+
function isRecord(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20
|
+
}
|
|
21
|
+
function rejectUnknownProperties(value, allowed, label) {
|
|
22
|
+
const unknown = Object.keys(value).filter((key) => !allowed.includes(key));
|
|
23
|
+
return unknown.length === 0
|
|
24
|
+
? valid()
|
|
25
|
+
: invalid(`${label} unknown properties: ${unknown.join(",")}`);
|
|
26
|
+
}
|
|
27
|
+
function validateRedactedFakeRemoteRef(value) {
|
|
28
|
+
const ref = validateOpaqueRef(value, "redacted_remote_ref");
|
|
29
|
+
if (!ref.ok)
|
|
30
|
+
return ref;
|
|
31
|
+
if (typeof value !== "string" || !value.startsWith("fake-remote-"))
|
|
32
|
+
return invalid("redacted_remote_ref must be a fake remote opaque ref");
|
|
33
|
+
return validateNoForbiddenRawPayloads(value, "redacted_remote_ref");
|
|
34
|
+
}
|
|
35
|
+
export function prepareFlowDeskFakeRemoteConnectorWriteV1(input) {
|
|
36
|
+
const readiness = evaluateFlowDeskRemoteWriteConnectorExecutionReadinessV1({
|
|
37
|
+
capability: input.capability,
|
|
38
|
+
writePlan: input.writePlan,
|
|
39
|
+
consumedApproval: input.consumedApproval,
|
|
40
|
+
});
|
|
41
|
+
const remoteRefResult = validateRedactedFakeRemoteRef(input.redactedRemoteRef);
|
|
42
|
+
const errors = [...readiness.errors, ...remoteRefResult.errors];
|
|
43
|
+
const blockedLabels = [...readiness.blocked_labels];
|
|
44
|
+
if (!remoteRefResult.ok)
|
|
45
|
+
blockedLabels.push("redacted_remote_ref_invalid");
|
|
46
|
+
if (readiness.state !== "ready" || errors.length > 0) {
|
|
47
|
+
return {
|
|
48
|
+
schema_version: "flowdesk.fake_remote_connector_write_result.v1",
|
|
49
|
+
workflow_id: input.writePlan.workflow_id,
|
|
50
|
+
attempt_id: input.writePlan.attempt_id,
|
|
51
|
+
connector_kind: input.writePlan.connector_kind,
|
|
52
|
+
connector_ref: input.writePlan.connector_ref,
|
|
53
|
+
target_ref: input.writePlan.target_ref,
|
|
54
|
+
content_hash_ref: input.writePlan.content_hash_ref,
|
|
55
|
+
ok: errors.length === 0,
|
|
56
|
+
errors,
|
|
57
|
+
state: "blocked",
|
|
58
|
+
blocked_labels: [...new Set(blockedLabels.length === 0 ? ["readiness_blocked"] : blockedLabels)],
|
|
59
|
+
fake_remote_write_attempted: false,
|
|
60
|
+
...disabledFakeRemoteConnectorAuthority,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
schema_version: "flowdesk.fake_remote_connector_write_result.v1",
|
|
65
|
+
workflow_id: input.writePlan.workflow_id,
|
|
66
|
+
attempt_id: input.writePlan.attempt_id,
|
|
67
|
+
connector_kind: input.writePlan.connector_kind,
|
|
68
|
+
connector_ref: input.writePlan.connector_ref,
|
|
69
|
+
target_ref: input.writePlan.target_ref,
|
|
70
|
+
content_hash_ref: input.writePlan.content_hash_ref,
|
|
71
|
+
redacted_remote_ref: input.redactedRemoteRef,
|
|
72
|
+
ok: true,
|
|
73
|
+
errors: [],
|
|
74
|
+
state: "fake_write_recorded",
|
|
75
|
+
blocked_labels: [],
|
|
76
|
+
fake_remote_write_attempted: true,
|
|
77
|
+
...disabledFakeRemoteConnectorAuthority,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function validateFlowDeskFakeRemoteConnectorWriteResultV1(value) {
|
|
81
|
+
if (!isRecord(value))
|
|
82
|
+
return invalid("fake remote connector write result must be an object");
|
|
83
|
+
const record = value;
|
|
84
|
+
const errors = [];
|
|
85
|
+
const allowed = [
|
|
86
|
+
"schema_version",
|
|
87
|
+
"workflow_id",
|
|
88
|
+
"attempt_id",
|
|
89
|
+
"connector_kind",
|
|
90
|
+
"connector_ref",
|
|
91
|
+
"target_ref",
|
|
92
|
+
"content_hash_ref",
|
|
93
|
+
"redacted_remote_ref",
|
|
94
|
+
"ok",
|
|
95
|
+
"errors",
|
|
96
|
+
"state",
|
|
97
|
+
"blocked_labels",
|
|
98
|
+
"fake_remote_write_attempted",
|
|
99
|
+
"remote_write_attempted",
|
|
100
|
+
"connector_write_attempted",
|
|
101
|
+
"github_write_attempted",
|
|
102
|
+
"storage_write_attempted",
|
|
103
|
+
"database_write_attempted",
|
|
104
|
+
"url_write_attempted",
|
|
105
|
+
"raw_path_write_attempted",
|
|
106
|
+
"remote_write_authority_enabled",
|
|
107
|
+
"external_write_authority_enabled",
|
|
108
|
+
"dispatch_authority_enabled",
|
|
109
|
+
"providerCall",
|
|
110
|
+
"actualLaneLaunch",
|
|
111
|
+
"runtimeExecution",
|
|
112
|
+
];
|
|
113
|
+
errors.push(...rejectUnknownProperties(record, allowed, "fake remote connector write result").errors);
|
|
114
|
+
if (record.schema_version !== "flowdesk.fake_remote_connector_write_result.v1")
|
|
115
|
+
errors.push("fake remote connector write result schema_version is invalid");
|
|
116
|
+
for (const [valueToCheck, label] of [
|
|
117
|
+
[record.workflow_id, "workflow_id"],
|
|
118
|
+
[record.attempt_id, "attempt_id"],
|
|
119
|
+
])
|
|
120
|
+
if (valueToCheck !== undefined)
|
|
121
|
+
errors.push(...validateOpaqueId(valueToCheck, label).errors);
|
|
122
|
+
for (const [valueToCheck, label] of [
|
|
123
|
+
[record.connector_ref, "connector_ref"],
|
|
124
|
+
[record.target_ref, "target_ref"],
|
|
125
|
+
[record.content_hash_ref, "content_hash_ref"],
|
|
126
|
+
])
|
|
127
|
+
if (valueToCheck !== undefined)
|
|
128
|
+
errors.push(...validateOpaqueRef(valueToCheck, label).errors);
|
|
129
|
+
if (record.redacted_remote_ref !== undefined)
|
|
130
|
+
errors.push(...validateRedactedFakeRemoteRef(record.redacted_remote_ref).errors);
|
|
131
|
+
if (record.state !== "fake_write_recorded" && record.state !== "blocked")
|
|
132
|
+
errors.push("fake remote connector write result state is invalid");
|
|
133
|
+
if (typeof record.ok !== "boolean")
|
|
134
|
+
errors.push("fake remote connector write result ok must be boolean");
|
|
135
|
+
if (!Array.isArray(record.errors))
|
|
136
|
+
errors.push("fake remote connector write result errors must be an array");
|
|
137
|
+
if (!Array.isArray(record.blocked_labels))
|
|
138
|
+
errors.push("blocked_labels must be an array");
|
|
139
|
+
if (typeof record.fake_remote_write_attempted !== "boolean")
|
|
140
|
+
errors.push("fake_remote_write_attempted must be boolean");
|
|
141
|
+
if (record.state === "fake_write_recorded" && record.fake_remote_write_attempted !== true)
|
|
142
|
+
errors.push("fake_write_recorded requires fake_remote_write_attempted=true");
|
|
143
|
+
if (record.state === "blocked" && record.fake_remote_write_attempted !== false)
|
|
144
|
+
errors.push("blocked fake remote connector results cannot attempt fake writes");
|
|
145
|
+
if (record.remote_write_attempted !== false ||
|
|
146
|
+
record.connector_write_attempted !== false ||
|
|
147
|
+
record.github_write_attempted !== false ||
|
|
148
|
+
record.storage_write_attempted !== false ||
|
|
149
|
+
record.database_write_attempted !== false ||
|
|
150
|
+
record.url_write_attempted !== false ||
|
|
151
|
+
record.raw_path_write_attempted !== false ||
|
|
152
|
+
record.remote_write_authority_enabled !== false ||
|
|
153
|
+
record.external_write_authority_enabled !== false ||
|
|
154
|
+
record.dispatch_authority_enabled !== false ||
|
|
155
|
+
record.providerCall !== false ||
|
|
156
|
+
record.actualLaneLaunch !== false ||
|
|
157
|
+
record.runtimeExecution !== false)
|
|
158
|
+
errors.push("fake remote connector write result cannot enable real remote, connector, dispatch, provider, lane, or runtime authority");
|
|
159
|
+
errors.push(...validateNoForbiddenRawPayloads(record, "fake_remote_connector_write_result").errors);
|
|
160
|
+
return errors.length === 0 ? valid() : invalid(...errors);
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=fake-remote-connector-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-remote-connector-adapter.js","sourceRoot":"","sources":["../src/fake-remote-connector-adapter.ts"],"names":[],"mappings":"AACA,OAAO,EACN,wDAAwD,GAIxD,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACN,OAAO,EAEP,KAAK,EACL,8BAA8B,EAC9B,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AA6BzB,MAAM,oCAAoC,GAAG;IAC5C,sBAAsB,EAAE,KAAc;IACtC,yBAAyB,EAAE,KAAc;IACzC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,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ValidationResult } from "./validators.js";
|
|
2
|
+
export declare const FLOWDESK_FALLBACK_REASON_LABELS: readonly ["provider_unhealthy", "quota_exhausted", "runtime_incompatible", "policy_ineligible", "manual_reselection_requested"];
|
|
3
|
+
export type FlowDeskFallbackReasonLabelV1 = (typeof FLOWDESK_FALLBACK_REASON_LABELS)[number];
|
|
4
|
+
export interface FlowDeskFallbackDecisionV1 {
|
|
5
|
+
schema_version: "flowdesk.fallback_decision.v1";
|
|
6
|
+
decision_id: string;
|
|
7
|
+
workflow_id: string;
|
|
8
|
+
parent_attempt_id: string;
|
|
9
|
+
new_attempt_id: string;
|
|
10
|
+
from_provider_qualified_model_id: string;
|
|
11
|
+
to_provider_qualified_model_id: string;
|
|
12
|
+
reason_label: FlowDeskFallbackReasonLabelV1;
|
|
13
|
+
depth: number;
|
|
14
|
+
max_depth: number;
|
|
15
|
+
fresh_evidence_refs: string[];
|
|
16
|
+
fresh_guard_decision_ref: string;
|
|
17
|
+
fresh_approval_ref: string;
|
|
18
|
+
fresh_pre_dispatch_audit_ref: string;
|
|
19
|
+
policy_eligibility_ref: string;
|
|
20
|
+
runtime_compatibility_ref: string;
|
|
21
|
+
state: "requires_full_regate" | "blocked_terminal";
|
|
22
|
+
automatic_fallback_authorized: false;
|
|
23
|
+
dispatch_authority_enabled: false;
|
|
24
|
+
providerCall: false;
|
|
25
|
+
actualLaneLaunch: false;
|
|
26
|
+
runtimeExecution: false;
|
|
27
|
+
}
|
|
28
|
+
export declare function validateFlowDeskFallbackDecisionV1(value: unknown): ValidationResult;
|
|
29
|
+
//# sourceMappingURL=fallback-decision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-decision.d.ts","sourceRoot":"","sources":["../src/fallback-decision.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,gBAAgB,EAMrB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,+BAA+B,iIAMlC,CAAC;AACX,MAAM,MAAM,6BAA6B,GACxC,CAAC,OAAO,+BAA+B,CAAC,CAAC,MAAM,CAAC,CAAC;AAElD,MAAM,WAAW,0BAA0B;IAC1C,cAAc,EAAE,+BAA+B,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,gCAAgC,EAAE,MAAM,CAAC;IACzC,8BAA8B,EAAE,MAAM,CAAC;IACvC,YAAY,EAAE,6BAA6B,CAAC;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,wBAAwB,EAAE,MAAM,CAAC;IACjC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4BAA4B,EAAE,MAAM,CAAC;IACrC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,yBAAyB,EAAE,MAAM,CAAC;IAClC,KAAK,EAAE,sBAAsB,GAAG,kBAAkB,CAAC;IACnD,6BAA6B,EAAE,KAAK,CAAC;IACrC,0BAA0B,EAAE,KAAK,CAAC;IAClC,YAAY,EAAE,KAAK,CAAC;IACpB,gBAAgB,EAAE,KAAK,CAAC;IACxB,gBAAgB,EAAE,KAAK,CAAC;CACxB;AAiBD,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAuDnF"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { invalid, valid, validateConcreteProviderQualifiedModelId, validateNoForbiddenRawPayloads, validateOpaqueId, validateOpaqueRef, } from "./validators.js";
|
|
2
|
+
export const FLOWDESK_FALLBACK_REASON_LABELS = [
|
|
3
|
+
"provider_unhealthy",
|
|
4
|
+
"quota_exhausted",
|
|
5
|
+
"runtime_incompatible",
|
|
6
|
+
"policy_ineligible",
|
|
7
|
+
"manual_reselection_requested",
|
|
8
|
+
];
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11
|
+
}
|
|
12
|
+
function refs(value, label) {
|
|
13
|
+
if (!Array.isArray(value) || value.length < 3)
|
|
14
|
+
return invalid(`${label} must include fresh usage, health, and runtime evidence refs`);
|
|
15
|
+
const errors = [];
|
|
16
|
+
for (const [index, ref] of value.entries()) {
|
|
17
|
+
errors.push(...validateOpaqueRef(ref, `${label}[${index}]`).errors);
|
|
18
|
+
if (typeof ref === "string" && /fallback/i.test(ref))
|
|
19
|
+
errors.push(`${label}[${index}] must not be fallback-derived evidence`);
|
|
20
|
+
}
|
|
21
|
+
return errors.length === 0 ? valid() : invalid(...errors);
|
|
22
|
+
}
|
|
23
|
+
export function validateFlowDeskFallbackDecisionV1(value) {
|
|
24
|
+
if (!isRecord(value))
|
|
25
|
+
return invalid("fallback decision must be an object");
|
|
26
|
+
const record = value;
|
|
27
|
+
const errors = [];
|
|
28
|
+
const allowed = new Set([
|
|
29
|
+
"schema_version",
|
|
30
|
+
"decision_id",
|
|
31
|
+
"workflow_id",
|
|
32
|
+
"parent_attempt_id",
|
|
33
|
+
"new_attempt_id",
|
|
34
|
+
"from_provider_qualified_model_id",
|
|
35
|
+
"to_provider_qualified_model_id",
|
|
36
|
+
"reason_label",
|
|
37
|
+
"depth",
|
|
38
|
+
"max_depth",
|
|
39
|
+
"fresh_evidence_refs",
|
|
40
|
+
"fresh_guard_decision_ref",
|
|
41
|
+
"fresh_approval_ref",
|
|
42
|
+
"fresh_pre_dispatch_audit_ref",
|
|
43
|
+
"policy_eligibility_ref",
|
|
44
|
+
"runtime_compatibility_ref",
|
|
45
|
+
"state",
|
|
46
|
+
"automatic_fallback_authorized",
|
|
47
|
+
"dispatch_authority_enabled",
|
|
48
|
+
"providerCall",
|
|
49
|
+
"actualLaneLaunch",
|
|
50
|
+
"runtimeExecution",
|
|
51
|
+
]);
|
|
52
|
+
for (const key of Object.keys(record))
|
|
53
|
+
if (!allowed.has(key))
|
|
54
|
+
errors.push(`unknown properties: ${key}`);
|
|
55
|
+
errors.push(...validateOpaqueId(record.decision_id, "decision_id").errors);
|
|
56
|
+
errors.push(...validateOpaqueId(record.workflow_id, "workflow_id").errors);
|
|
57
|
+
errors.push(...validateOpaqueId(record.parent_attempt_id, "parent_attempt_id").errors);
|
|
58
|
+
errors.push(...validateOpaqueId(record.new_attempt_id, "new_attempt_id").errors);
|
|
59
|
+
errors.push(...validateConcreteProviderQualifiedModelId(record.from_provider_qualified_model_id).errors);
|
|
60
|
+
errors.push(...validateConcreteProviderQualifiedModelId(record.to_provider_qualified_model_id).errors);
|
|
61
|
+
if (record.schema_version !== "flowdesk.fallback_decision.v1")
|
|
62
|
+
errors.push("fallback decision schema_version is invalid");
|
|
63
|
+
if (!FLOWDESK_FALLBACK_REASON_LABELS.includes(record.reason_label ?? ""))
|
|
64
|
+
errors.push("fallback reason_label is invalid");
|
|
65
|
+
if (typeof record.depth !== "number" || !Number.isInteger(record.depth) || record.depth < 1)
|
|
66
|
+
errors.push("fallback depth is invalid");
|
|
67
|
+
if (record.max_depth !== 2)
|
|
68
|
+
errors.push("fallback max_depth must be 2");
|
|
69
|
+
if ((record.depth ?? 0) > (record.max_depth ?? 0))
|
|
70
|
+
errors.push("fallback depth exceeds max_depth");
|
|
71
|
+
if (record.parent_attempt_id === record.new_attempt_id)
|
|
72
|
+
errors.push("fallback must use a new attempt id");
|
|
73
|
+
if (record.from_provider_qualified_model_id === record.to_provider_qualified_model_id)
|
|
74
|
+
errors.push("fallback must change binding");
|
|
75
|
+
errors.push(...refs(record.fresh_evidence_refs, "fresh_evidence_refs").errors);
|
|
76
|
+
for (const [value, label] of [
|
|
77
|
+
[record.fresh_guard_decision_ref, "fresh_guard_decision_ref"],
|
|
78
|
+
[record.fresh_approval_ref, "fresh_approval_ref"],
|
|
79
|
+
[record.fresh_pre_dispatch_audit_ref, "fresh_pre_dispatch_audit_ref"],
|
|
80
|
+
[record.policy_eligibility_ref, "policy_eligibility_ref"],
|
|
81
|
+
[record.runtime_compatibility_ref, "runtime_compatibility_ref"],
|
|
82
|
+
])
|
|
83
|
+
errors.push(...validateOpaqueRef(value, label).errors);
|
|
84
|
+
if (record.state !== "requires_full_regate" && record.state !== "blocked_terminal")
|
|
85
|
+
errors.push("fallback state is invalid");
|
|
86
|
+
if (record.depth === record.max_depth && record.state !== "blocked_terminal")
|
|
87
|
+
errors.push("max-depth fallback must be terminal blocked");
|
|
88
|
+
if (record.automatic_fallback_authorized !== false || record.dispatch_authority_enabled !== false || record.providerCall !== false || record.actualLaneLaunch !== false || record.runtimeExecution !== false)
|
|
89
|
+
errors.push("fallback decision cannot enable runtime authority");
|
|
90
|
+
errors.push(...validateNoForbiddenRawPayloads(record, "fallback_decision").errors);
|
|
91
|
+
return errors.length === 0 ? valid() : invalid(...errors);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=fallback-decision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-decision.js","sourceRoot":"","sources":["../src/fallback-decision.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,EAEP,KAAK,EACL,wCAAwC,EACxC,8BAA8B,EAC9B,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,oBAAoB;IACpB,iBAAiB;IACjB,sBAAsB;IACtB,mBAAmB;IACnB,8BAA8B;CACrB,CAAC;AA6BX,SAAS,QAAQ,CAAC,KAAc;IAC/B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,IAAI,CAAC,KAAc,EAAE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,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,KAAK,kBAAkB;QAAE,MAAM,CAAC,IAAI,CAAC,6CAA6C,CAAC,CAAC;IACzI,IAAI,MAAM,CAAC,6BAA6B,KAAK,KAAK,IAAI,MAAM,CAAC,0BAA0B,KAAK,KAAK,IAAI,MAAM,CAAC,YAAY,KAAK,KAAK,IAAI,MAAM,CAAC,gBAAgB,KAAK,KAAK,IAAI,MAAM,CAAC,gBAAgB,KAAK,KAAK;QAAE,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAC/Q,MAAM,CAAC,IAAI,CAAC,GAAG,8BAA8B,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FlowDeskFallbackDecisionV1 } from "./fallback-decision.js";
|
|
2
|
+
import type { FlowDeskProductionApprovalSourceV1 } from "./production-approval-source.js";
|
|
3
|
+
import { type ValidationResult } from "./validators.js";
|
|
4
|
+
export interface FlowDeskFallbackRegatePlanV1 extends ValidationResult {
|
|
5
|
+
schema_version: "flowdesk.fallback_regate_plan.v1";
|
|
6
|
+
workflow_id?: string;
|
|
7
|
+
parent_attempt_id?: string;
|
|
8
|
+
new_attempt_id?: string;
|
|
9
|
+
decision_ref?: string;
|
|
10
|
+
from_provider_qualified_model_id?: string;
|
|
11
|
+
to_provider_qualified_model_id?: string;
|
|
12
|
+
state: "full_regate_required" | "blocked";
|
|
13
|
+
required_fresh_evidence_refs: string[];
|
|
14
|
+
required_guard_decision_ref?: string;
|
|
15
|
+
required_approval_ref?: string;
|
|
16
|
+
required_pre_dispatch_audit_ref?: string;
|
|
17
|
+
policy_eligibility_ref?: string;
|
|
18
|
+
runtime_compatibility_ref?: string;
|
|
19
|
+
consumed_fallback_approval_ref?: string;
|
|
20
|
+
safe_next_actions: ["/flowdesk-status", "/flowdesk-run"] | ["/flowdesk-status"];
|
|
21
|
+
automatic_fallback_authorized: false;
|
|
22
|
+
provider_switch_attempted: false;
|
|
23
|
+
dispatch_authority_enabled: false;
|
|
24
|
+
realOpenCodeDispatch: false;
|
|
25
|
+
providerCall: false;
|
|
26
|
+
actualLaneLaunch: false;
|
|
27
|
+
runtimeExecution: false;
|
|
28
|
+
}
|
|
29
|
+
export declare function planFlowDeskFallbackRegateV1(input: {
|
|
30
|
+
decision: FlowDeskFallbackDecisionV1;
|
|
31
|
+
consumedApproval: FlowDeskProductionApprovalSourceV1;
|
|
32
|
+
}): FlowDeskFallbackRegatePlanV1;
|
|
33
|
+
export declare function validateFlowDeskFallbackRegatePlanV1(value: unknown): ValidationResult;
|
|
34
|
+
//# sourceMappingURL=fallback-regate-plan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-regate-plan.d.ts","sourceRoot":"","sources":["../src/fallback-regate-plan.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,iCAAiC,CAAC;AAC1F,OAAO,EAEN,KAAK,gBAAgB,EAMrB,MAAM,iBAAiB,CAAC;AAMzB,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;IACrE,cAAc,EAAE,kCAAkC,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC,CAAC,EAAE,MAAM,CAAC;IAC1C,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,KAAK,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC1C,4BAA4B,EAAE,MAAM,EAAE,CAAC;IACvC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,+BAA+B,CAAC,EAAE,MAAM,CAAC;IACzC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACxC,iBAAiB,EAAE,CAAC,kBAAkB,EAAE,eAAe,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChF,6BAA6B,EAAE,KAAK,CAAC;IACrC,yBAAyB,EAAE,KAAK,CAAC;IACjC,0BAA0B,EAAE,KAAK,CAAC;IAClC,oBAAoB,EAAE,KAAK,CAAC;IAC5B,YAAY,EAAE,KAAK,CAAC;IACpB,gBAAgB,EAAE,KAAK,CAAC;IACxB,gBAAgB,EAAE,KAAK,CAAC;CACxB;AAgCD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IACnD,QAAQ,EAAE,0BAA0B,CAAC;IACrC,gBAAgB,EAAE,kCAAkC,CAAC;CACrD,GAAG,4BAA4B,CA8B/B;AAED,wBAAgB,oCAAoC,CACnD,KAAK,EAAE,OAAO,GACZ,gBAAgB,CAiGlB"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { promoteFlowDeskFallbackReselectionRegateV1 } from "./authority-promotion.js";
|
|
2
|
+
import { invalid, valid, validateNoForbiddenRawPayloads, validateOpaqueId, validateOpaqueRef, validateSchemaArtifactValue, } from "./validators.js";
|
|
3
|
+
function isRegateRecord(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
|
+
}
|
|
6
|
+
const disabledRegateAuthority = {
|
|
7
|
+
automatic_fallback_authorized: false,
|
|
8
|
+
provider_switch_attempted: false,
|
|
9
|
+
dispatch_authority_enabled: false,
|
|
10
|
+
realOpenCodeDispatch: false,
|
|
11
|
+
providerCall: false,
|
|
12
|
+
actualLaneLaunch: false,
|
|
13
|
+
runtimeExecution: false,
|
|
14
|
+
};
|
|
15
|
+
function blockedPlan(decision, errors) {
|
|
16
|
+
return {
|
|
17
|
+
schema_version: "flowdesk.fallback_regate_plan.v1",
|
|
18
|
+
...invalid(...errors),
|
|
19
|
+
workflow_id: decision.workflow_id,
|
|
20
|
+
parent_attempt_id: decision.parent_attempt_id,
|
|
21
|
+
new_attempt_id: decision.new_attempt_id,
|
|
22
|
+
decision_ref: decision.decision_id,
|
|
23
|
+
from_provider_qualified_model_id: decision.from_provider_qualified_model_id,
|
|
24
|
+
to_provider_qualified_model_id: decision.to_provider_qualified_model_id,
|
|
25
|
+
state: "blocked",
|
|
26
|
+
required_fresh_evidence_refs: [],
|
|
27
|
+
safe_next_actions: ["/flowdesk-status"],
|
|
28
|
+
...disabledRegateAuthority,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
export function planFlowDeskFallbackRegateV1(input) {
|
|
32
|
+
const promotion = promoteFlowDeskFallbackReselectionRegateV1(input);
|
|
33
|
+
if (!promotion.ok || promotion.fallback_reselection_regate_authority_enabled !== true) {
|
|
34
|
+
return blockedPlan(input.decision, promotion.errors.length > 0 ? promotion.errors : ["fallback regate plan blocked"]);
|
|
35
|
+
}
|
|
36
|
+
const plan = {
|
|
37
|
+
schema_version: "flowdesk.fallback_regate_plan.v1",
|
|
38
|
+
...valid(),
|
|
39
|
+
workflow_id: input.decision.workflow_id,
|
|
40
|
+
parent_attempt_id: input.decision.parent_attempt_id,
|
|
41
|
+
new_attempt_id: input.decision.new_attempt_id,
|
|
42
|
+
decision_ref: input.decision.decision_id,
|
|
43
|
+
from_provider_qualified_model_id: input.decision.from_provider_qualified_model_id,
|
|
44
|
+
to_provider_qualified_model_id: input.decision.to_provider_qualified_model_id,
|
|
45
|
+
state: "full_regate_required",
|
|
46
|
+
required_fresh_evidence_refs: [...input.decision.fresh_evidence_refs],
|
|
47
|
+
required_guard_decision_ref: input.decision.fresh_guard_decision_ref,
|
|
48
|
+
required_approval_ref: input.decision.fresh_approval_ref,
|
|
49
|
+
required_pre_dispatch_audit_ref: input.decision.fresh_pre_dispatch_audit_ref,
|
|
50
|
+
policy_eligibility_ref: input.decision.policy_eligibility_ref,
|
|
51
|
+
runtime_compatibility_ref: input.decision.runtime_compatibility_ref,
|
|
52
|
+
consumed_fallback_approval_ref: input.consumedApproval.approval_id,
|
|
53
|
+
safe_next_actions: ["/flowdesk-status", "/flowdesk-run"],
|
|
54
|
+
...disabledRegateAuthority,
|
|
55
|
+
};
|
|
56
|
+
const redaction = validateNoForbiddenRawPayloads(plan, "fallback_regate_plan");
|
|
57
|
+
return redaction.ok ? plan : blockedPlan(input.decision, redaction.errors);
|
|
58
|
+
}
|
|
59
|
+
export function validateFlowDeskFallbackRegatePlanV1(value) {
|
|
60
|
+
if (!isRegateRecord(value))
|
|
61
|
+
return invalid("fallback regate plan must be an object");
|
|
62
|
+
const errors = [];
|
|
63
|
+
const schemaCheck = validateSchemaArtifactValue("flowdesk.fallback_regate_plan.v1", value);
|
|
64
|
+
if (!schemaCheck.ok)
|
|
65
|
+
errors.push(...schemaCheck.errors);
|
|
66
|
+
const record = value;
|
|
67
|
+
if (record.schema_version !== "flowdesk.fallback_regate_plan.v1")
|
|
68
|
+
errors.push("fallback regate plan schema_version is invalid");
|
|
69
|
+
if (record.state !== "full_regate_required" && record.state !== "blocked")
|
|
70
|
+
errors.push("fallback regate plan state is invalid");
|
|
71
|
+
if (typeof record.ok !== "boolean")
|
|
72
|
+
errors.push("fallback regate plan ok must be boolean");
|
|
73
|
+
if (!Array.isArray(record.errors))
|
|
74
|
+
errors.push("fallback regate plan errors must be an array");
|
|
75
|
+
if (!Array.isArray(record.required_fresh_evidence_refs)) {
|
|
76
|
+
errors.push("fallback regate plan required_fresh_evidence_refs must be an array");
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
for (const [index, ref] of record.required_fresh_evidence_refs.entries())
|
|
80
|
+
errors.push(...validateOpaqueRef(ref, `required_fresh_evidence_refs[${index}]`).errors);
|
|
81
|
+
}
|
|
82
|
+
if (!Array.isArray(record.safe_next_actions))
|
|
83
|
+
errors.push("fallback regate plan safe_next_actions must be an array");
|
|
84
|
+
if (record.workflow_id !== undefined)
|
|
85
|
+
errors.push(...validateOpaqueId(record.workflow_id, "workflow_id").errors);
|
|
86
|
+
if (record.parent_attempt_id !== undefined)
|
|
87
|
+
errors.push(...validateOpaqueId(record.parent_attempt_id, "parent_attempt_id").errors);
|
|
88
|
+
if (record.new_attempt_id !== undefined)
|
|
89
|
+
errors.push(...validateOpaqueId(record.new_attempt_id, "new_attempt_id").errors);
|
|
90
|
+
if (record.decision_ref !== undefined)
|
|
91
|
+
errors.push(...validateOpaqueRef(record.decision_ref, "decision_ref").errors);
|
|
92
|
+
if (record.required_guard_decision_ref !== undefined)
|
|
93
|
+
errors.push(...validateOpaqueRef(record.required_guard_decision_ref, "required_guard_decision_ref").errors);
|
|
94
|
+
if (record.required_approval_ref !== undefined)
|
|
95
|
+
errors.push(...validateOpaqueRef(record.required_approval_ref, "required_approval_ref").errors);
|
|
96
|
+
if (record.required_pre_dispatch_audit_ref !== undefined)
|
|
97
|
+
errors.push(...validateOpaqueRef(record.required_pre_dispatch_audit_ref, "required_pre_dispatch_audit_ref").errors);
|
|
98
|
+
if (record.policy_eligibility_ref !== undefined)
|
|
99
|
+
errors.push(...validateOpaqueRef(record.policy_eligibility_ref, "policy_eligibility_ref")
|
|
100
|
+
.errors);
|
|
101
|
+
if (record.runtime_compatibility_ref !== undefined)
|
|
102
|
+
errors.push(...validateOpaqueRef(record.runtime_compatibility_ref, "runtime_compatibility_ref").errors);
|
|
103
|
+
if (record.consumed_fallback_approval_ref !== undefined)
|
|
104
|
+
errors.push(...validateOpaqueRef(record.consumed_fallback_approval_ref, "consumed_fallback_approval_ref").errors);
|
|
105
|
+
if (record.automatic_fallback_authorized !== false)
|
|
106
|
+
errors.push("fallback regate plan must not authorize automatic fallback");
|
|
107
|
+
if (record.provider_switch_attempted !== false)
|
|
108
|
+
errors.push("fallback regate plan must not record provider switching");
|
|
109
|
+
if (record.dispatch_authority_enabled !== false)
|
|
110
|
+
errors.push("fallback regate plan must not enable dispatch authority");
|
|
111
|
+
if (record.realOpenCodeDispatch !== false)
|
|
112
|
+
errors.push("fallback regate plan must not enable realOpenCodeDispatch");
|
|
113
|
+
if (record.providerCall !== false)
|
|
114
|
+
errors.push("fallback regate plan must not enable providerCall");
|
|
115
|
+
if (record.actualLaneLaunch !== false)
|
|
116
|
+
errors.push("fallback regate plan must not enable actualLaneLaunch");
|
|
117
|
+
if (record.runtimeExecution !== false)
|
|
118
|
+
errors.push("fallback regate plan must not enable runtimeExecution");
|
|
119
|
+
errors.push(...validateNoForbiddenRawPayloads(value, "fallback_regate_plan").errors);
|
|
120
|
+
return errors.length === 0 ? valid() : invalid(...errors);
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=fallback-regate-plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback-regate-plan.js","sourceRoot":"","sources":["../src/fallback-regate-plan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0CAA0C,EAAE,MAAM,0BAA0B,CAAC;AAGtF,OAAO,EACN,OAAO,EAEP,KAAK,EACL,8BAA8B,EAC9B,gBAAgB,EAChB,iBAAiB,EACjB,2BAA2B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,SAAS,cAAc,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AA4BD,MAAM,uBAAuB,GAAG;IAC/B,6BAA6B,EAAE,KAAc;IAC7C,yBAAyB,EAAE,KAAc;IACzC,0BAA0B,EAAE,KAAc;IAC1C,oBAAoB,EAAE,KAAc;IACpC,YAAY,EAAE,KAAc;IAC5B,gB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,IAAI,MAAM,CAAC,6BAA6B,KAAK,KAAK;QACjD,MAAM,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;IAC3E,IAAI,MAAM,CAAC,yBAAyB,KAAK,KAAK;QAC7C,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IACxE,IAAI,MAAM,CAAC,0BAA0B,KAAK,KAAK;QAC9C,MAAM,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;IACxE,IAAI,MAAM,CAAC,oBAAoB,KAAK,KAAK;QACxC,MAAM,CAAC,IAAI,CAAC,2DAA2D,CAAC,CAAC;IAC1E,IAAI,MAAM,CAAC,YAAY,KAAK,KAAK;QAChC,MAAM,CAAC,IAAI,CAAC,mDAAmD,CAAC,CAAC;IAClE,IAAI,MAAM,CAAC,gBAAgB,KAAK,KAAK;QACpC,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;IACtE,IAAI,MAAM,CAAC,gBAAgB,KAAK,KAAK;QACpC,MAAM,CAAC,IAAI,CAAC,uDAAuD,CAAC,CAAC;IACtE,MAAM,CAAC,IAAI,CAAC,GAAG,8BAA8B,CAAC,KAAK,EAAE,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAC;IACrF,OAAO,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ValidationResult } from "./validators.js";
|
|
2
|
+
export declare const FLOWDESK_FDS1_SCHEMA_PROBE_OUTCOMES: readonly ["probe_pass", "probe_blocked", "probe_invalid"];
|
|
3
|
+
export type FlowDeskFds1SchemaProbeOutcomeV1 = (typeof FLOWDESK_FDS1_SCHEMA_PROBE_OUTCOMES)[number];
|
|
4
|
+
export interface FlowDeskFds1SchemaProbeResultV1 {
|
|
5
|
+
schema_version: "flowdesk.fds1_schema_probe_result.v1";
|
|
6
|
+
probe_id: string;
|
|
7
|
+
tool_name: string;
|
|
8
|
+
request_schema_ref: string;
|
|
9
|
+
response_schema_ref: string;
|
|
10
|
+
outcome: FlowDeskFds1SchemaProbeOutcomeV1;
|
|
11
|
+
observed_at: string;
|
|
12
|
+
unknown_property_rejected: boolean;
|
|
13
|
+
malformed_event_rejected: boolean;
|
|
14
|
+
provider_facing_conversion_checked: boolean;
|
|
15
|
+
runtime_validator_checked: boolean;
|
|
16
|
+
failure_labels: string[];
|
|
17
|
+
evidence_refs: string[];
|
|
18
|
+
dispatch_authority_enabled: false;
|
|
19
|
+
providerCall: false;
|
|
20
|
+
runtimeExecution: false;
|
|
21
|
+
actualLaneLaunch: false;
|
|
22
|
+
}
|
|
23
|
+
export declare function createFlowDeskFds1SchemaProbeResultV1(input: {
|
|
24
|
+
probeId: string;
|
|
25
|
+
toolName: string;
|
|
26
|
+
requestSchemaRef: string;
|
|
27
|
+
responseSchemaRef: string;
|
|
28
|
+
observedAt: string;
|
|
29
|
+
unknownPropertyRejected: boolean;
|
|
30
|
+
malformedEventRejected: boolean;
|
|
31
|
+
providerFacingConversionChecked: boolean;
|
|
32
|
+
runtimeValidatorChecked: boolean;
|
|
33
|
+
failureLabels?: string[];
|
|
34
|
+
evidenceRefs?: string[];
|
|
35
|
+
}): FlowDeskFds1SchemaProbeResultV1;
|
|
36
|
+
export declare function validateFlowDeskFds1SchemaProbeResultV1(value: unknown): ValidationResult;
|
|
37
|
+
//# sourceMappingURL=fds1-schema-probe-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fds1-schema-probe-result.d.ts","sourceRoot":"","sources":["../src/fds1-schema-probe-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,gBAAgB,EAKrB,MAAM,iBAAiB,CAAC;AAEzB,eAAO,MAAM,mCAAmC,2DAItC,CAAC;AACX,MAAM,MAAM,gCAAgC,GAC3C,CAAC,OAAO,mCAAmC,C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.js";
|
|
2
|
+
export const FLOWDESK_FDS1_SCHEMA_PROBE_OUTCOMES = [
|
|
3
|
+
"probe_pass",
|
|
4
|
+
"probe_blocked",
|
|
5
|
+
"probe_invalid",
|
|
6
|
+
];
|
|
7
|
+
function isRecord(value) {
|
|
8
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
+
}
|
|
10
|
+
function validateStringArray(value, label) {
|
|
11
|
+
if (!Array.isArray(value))
|
|
12
|
+
return invalid(`${label} must be an array`);
|
|
13
|
+
const errors = [];
|
|
14
|
+
for (const [index, item] of value.entries()) {
|
|
15
|
+
if (typeof item !== "string" || item.length === 0 || item.length > 160)
|
|
16
|
+
errors.push(`${label}[${index}] must be a bounded string`);
|
|
17
|
+
errors.push(...validateNoForbiddenRawPayloads(item, `${label}[${index}]`).errors);
|
|
18
|
+
}
|
|
19
|
+
return errors.length === 0 ? valid() : invalid(...errors);
|
|
20
|
+
}
|
|
21
|
+
export function createFlowDeskFds1SchemaProbeResultV1(input) {
|
|
22
|
+
const failureLabels = [...(input.failureLabels ?? [])];
|
|
23
|
+
if (!input.unknownPropertyRejected)
|
|
24
|
+
failureLabels.push("unknown_property_not_rejected");
|
|
25
|
+
if (!input.malformedEventRejected)
|
|
26
|
+
failureLabels.push("malformed_event_not_rejected");
|
|
27
|
+
if (!input.providerFacingConversionChecked)
|
|
28
|
+
failureLabels.push("provider_facing_conversion_unchecked");
|
|
29
|
+
if (!input.runtimeValidatorChecked)
|
|
30
|
+
failureLabels.push("runtime_validator_unchecked");
|
|
31
|
+
const outcome = failureLabels.length === 0 ? "probe_pass" : "probe_blocked";
|
|
32
|
+
return {
|
|
33
|
+
schema_version: "flowdesk.fds1_schema_probe_result.v1",
|
|
34
|
+
probe_id: input.probeId,
|
|
35
|
+
tool_name: input.toolName,
|
|
36
|
+
request_schema_ref: input.requestSchemaRef,
|
|
37
|
+
response_schema_ref: input.responseSchemaRef,
|
|
38
|
+
outcome,
|
|
39
|
+
observed_at: input.observedAt,
|
|
40
|
+
unknown_property_rejected: input.unknownPropertyRejected,
|
|
41
|
+
malformed_event_rejected: input.malformedEventRejected,
|
|
42
|
+
provider_facing_conversion_checked: input.providerFacingConversionChecked,
|
|
43
|
+
runtime_validator_checked: input.runtimeValidatorChecked,
|
|
44
|
+
failure_labels: [...new Set(failureLabels)],
|
|
45
|
+
evidence_refs: [...(input.evidenceRefs ?? [])],
|
|
46
|
+
dispatch_authority_enabled: false,
|
|
47
|
+
providerCall: false,
|
|
48
|
+
runtimeExecution: false,
|
|
49
|
+
actualLaneLaunch: false,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export function validateFlowDeskFds1SchemaProbeResultV1(value) {
|
|
53
|
+
if (!isRecord(value))
|
|
54
|
+
return invalid("FDS-1 schema probe result must be an object");
|
|
55
|
+
const record = value;
|
|
56
|
+
const errors = [];
|
|
57
|
+
const allowed = new Set([
|
|
58
|
+
"schema_version",
|
|
59
|
+
"probe_id",
|
|
60
|
+
"tool_name",
|
|
61
|
+
"request_schema_ref",
|
|
62
|
+
"response_schema_ref",
|
|
63
|
+
"outcome",
|
|
64
|
+
"observed_at",
|
|
65
|
+
"unknown_property_rejected",
|
|
66
|
+
"malformed_event_rejected",
|
|
67
|
+
"provider_facing_conversion_checked",
|
|
68
|
+
"runtime_validator_checked",
|
|
69
|
+
"failure_labels",
|
|
70
|
+
"evidence_refs",
|
|
71
|
+
"dispatch_authority_enabled",
|
|
72
|
+
"providerCall",
|
|
73
|
+
"runtimeExecution",
|
|
74
|
+
"actualLaneLaunch",
|
|
75
|
+
]);
|
|
76
|
+
for (const key of Object.keys(record))
|
|
77
|
+
if (!allowed.has(key))
|
|
78
|
+
errors.push(`unknown properties: ${key}`);
|
|
79
|
+
if (record.schema_version !== "flowdesk.fds1_schema_probe_result.v1")
|
|
80
|
+
errors.push("FDS-1 probe schema_version is invalid");
|
|
81
|
+
errors.push(...validateOpaqueId(record.probe_id, "probe_id").errors);
|
|
82
|
+
errors.push(...validateOpaqueRef(record.tool_name, "tool_name").errors);
|
|
83
|
+
errors.push(...validateOpaqueRef(record.request_schema_ref, "request_schema_ref").errors);
|
|
84
|
+
errors.push(...validateOpaqueRef(record.response_schema_ref, "response_schema_ref").errors);
|
|
85
|
+
if (!FLOWDESK_FDS1_SCHEMA_PROBE_OUTCOMES.includes(record.outcome ?? ""))
|
|
86
|
+
errors.push("FDS-1 probe outcome is invalid");
|
|
87
|
+
if (typeof record.observed_at !== "string" ||
|
|
88
|
+
!Number.isFinite(Date.parse(record.observed_at)))
|
|
89
|
+
errors.push("observed_at must be parseable");
|
|
90
|
+
for (const key of [
|
|
91
|
+
"unknown_property_rejected",
|
|
92
|
+
"malformed_event_rejected",
|
|
93
|
+
"provider_facing_conversion_checked",
|
|
94
|
+
"runtime_validator_checked",
|
|
95
|
+
])
|
|
96
|
+
if (typeof record[key] !== "boolean")
|
|
97
|
+
errors.push(`${key} must be boolean`);
|
|
98
|
+
errors.push(...validateStringArray(record.failure_labels, "failure_labels").errors);
|
|
99
|
+
errors.push(...validateStringArray(record.evidence_refs, "evidence_refs").errors);
|
|
100
|
+
if (record.outcome === "probe_pass" &&
|
|
101
|
+
(record.unknown_property_rejected !== true ||
|
|
102
|
+
record.malformed_event_rejected !== true ||
|
|
103
|
+
record.provider_facing_conversion_checked !== true ||
|
|
104
|
+
record.runtime_validator_checked !== true ||
|
|
105
|
+
(record.failure_labels?.length ?? 0) > 0))
|
|
106
|
+
errors.push("FDS-1 probe_pass requires all checks and no failures");
|
|
107
|
+
if (record.dispatch_authority_enabled !== false ||
|
|
108
|
+
record.providerCall !== false ||
|
|
109
|
+
record.runtimeExecution !== false ||
|
|
110
|
+
record.actualLaneLaunch !== false)
|
|
111
|
+
errors.push("FDS-1 probe cannot enable runtime authority");
|
|
112
|
+
errors.push(...validateNoForbiddenRawPayloads(record, "fds1_schema_probe_result").errors);
|
|
113
|
+
return errors.length === 0 ? valid() : invalid(...errors);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=fds1-schema-probe-result.js.map
|