@tsantosfp_2026/piece-coach-migration-ai 1.1.1 → 2.0.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/package.json +1 -1
- package/src/index.js +516 -48
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -52846,6 +52846,313 @@ var require_output_schemas = __commonJS({
|
|
|
52846
52846
|
}
|
|
52847
52847
|
});
|
|
52848
52848
|
|
|
52849
|
+
// dist/src/lib/source-policy.generated.js
|
|
52850
|
+
var require_source_policy_generated = __commonJS({
|
|
52851
|
+
"dist/src/lib/source-policy.generated.js"(exports2) {
|
|
52852
|
+
"use strict";
|
|
52853
|
+
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
52854
|
+
exports2.SOURCE_EVIDENCE_POLICY = exports2.SOURCE_POLICY_AUTHORITY = void 0;
|
|
52855
|
+
exports2.SOURCE_POLICY_AUTHORITY = {
|
|
52856
|
+
contractId: "OPENCODE_AI_ENRICHMENT_V1_2",
|
|
52857
|
+
contractVersion: "1.2.0",
|
|
52858
|
+
sha256: "b0529ae1d72659e5b1d211d9d7ac500550e9cf65aca971dd0cc1f3df6acbd15b",
|
|
52859
|
+
producerRelevanceSha256: "200d2b9b876bd6d00806e9161b2d2a7cdbf976441b56ab0c5047337fff7a15cc"
|
|
52860
|
+
};
|
|
52861
|
+
exports2.SOURCE_EVIDENCE_POLICY = {
|
|
52862
|
+
"ABOUT_V1": {
|
|
52863
|
+
"groundingFieldAllowlist": [
|
|
52864
|
+
"about.hero.heading",
|
|
52865
|
+
"about.intro.body",
|
|
52866
|
+
"about.bio.long",
|
|
52867
|
+
"about.philosophy.heading",
|
|
52868
|
+
"about.philosophy.body",
|
|
52869
|
+
"about.why_coaching.heading",
|
|
52870
|
+
"about.why_coaching.body",
|
|
52871
|
+
"about.industries.heading",
|
|
52872
|
+
"about.industry_1.title",
|
|
52873
|
+
"about.industry_1.description",
|
|
52874
|
+
"about.industry_2.title",
|
|
52875
|
+
"about.industry_2.description",
|
|
52876
|
+
"about.industry_3.title",
|
|
52877
|
+
"about.industry_3.description",
|
|
52878
|
+
"coach.title",
|
|
52879
|
+
"coach.location.city",
|
|
52880
|
+
"coach.location.state",
|
|
52881
|
+
"coach.city_state",
|
|
52882
|
+
"coach.service_area_heading",
|
|
52883
|
+
"coach.service_area_line"
|
|
52884
|
+
],
|
|
52885
|
+
"factFieldAllowlist": [
|
|
52886
|
+
"coach.title",
|
|
52887
|
+
"coach.first_name",
|
|
52888
|
+
"coach.last_name",
|
|
52889
|
+
"verified_context.approved_career_facts",
|
|
52890
|
+
"verified_context.verified_media",
|
|
52891
|
+
"verified_context.approved_service_labels"
|
|
52892
|
+
],
|
|
52893
|
+
"destinationGroundingMap": {
|
|
52894
|
+
"about.hero.heading": {
|
|
52895
|
+
"relevant_relevance_classes": [
|
|
52896
|
+
"ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52897
|
+
"IDENTITY_FACT",
|
|
52898
|
+
"PRACTICE_FACT"
|
|
52899
|
+
],
|
|
52900
|
+
"missing_value_authority": "NONE"
|
|
52901
|
+
},
|
|
52902
|
+
"about.intro.body": {
|
|
52903
|
+
"relevant_relevance_classes": [
|
|
52904
|
+
"ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52905
|
+
"IDENTITY_FACT",
|
|
52906
|
+
"PRACTICE_FACT"
|
|
52907
|
+
],
|
|
52908
|
+
"missing_value_authority": "NONE"
|
|
52909
|
+
},
|
|
52910
|
+
"about.bio.long": {
|
|
52911
|
+
"relevant_relevance_classes": [
|
|
52912
|
+
"ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52913
|
+
"PRACTICE_FACT"
|
|
52914
|
+
],
|
|
52915
|
+
"missing_value_authority": "NONE"
|
|
52916
|
+
},
|
|
52917
|
+
"about.philosophy.heading": {
|
|
52918
|
+
"relevant_relevance_classes": [
|
|
52919
|
+
"ABOUT_PHILOSOPHY_NARRATIVE"
|
|
52920
|
+
],
|
|
52921
|
+
"missing_value_authority": "NONE"
|
|
52922
|
+
},
|
|
52923
|
+
"about.philosophy.body": {
|
|
52924
|
+
"relevant_relevance_classes": [
|
|
52925
|
+
"ABOUT_PHILOSOPHY_NARRATIVE"
|
|
52926
|
+
],
|
|
52927
|
+
"missing_value_authority": "NONE"
|
|
52928
|
+
},
|
|
52929
|
+
"about.why_coaching.heading": {
|
|
52930
|
+
"relevant_relevance_classes": [
|
|
52931
|
+
"ABOUT_WHY_COACHING_NARRATIVE"
|
|
52932
|
+
],
|
|
52933
|
+
"missing_value_authority": "NONE"
|
|
52934
|
+
},
|
|
52935
|
+
"about.why_coaching.body": {
|
|
52936
|
+
"relevant_relevance_classes": [
|
|
52937
|
+
"ABOUT_WHY_COACHING_NARRATIVE"
|
|
52938
|
+
],
|
|
52939
|
+
"missing_value_authority": "NONE"
|
|
52940
|
+
},
|
|
52941
|
+
"about.industries.heading": {
|
|
52942
|
+
"relevant_relevance_classes": [
|
|
52943
|
+
"INDUSTRIES_FACT"
|
|
52944
|
+
],
|
|
52945
|
+
"missing_value_authority": "CONDITIONAL_OMISSION_INDUSTRIES_HEADING"
|
|
52946
|
+
}
|
|
52947
|
+
},
|
|
52948
|
+
"sourceFieldRelevanceMap": {
|
|
52949
|
+
"about.hero.heading": "ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52950
|
+
"about.intro.body": "ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52951
|
+
"about.bio.long": "ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52952
|
+
"about.philosophy.heading": "ABOUT_PHILOSOPHY_NARRATIVE",
|
|
52953
|
+
"about.philosophy.body": "ABOUT_PHILOSOPHY_NARRATIVE",
|
|
52954
|
+
"about.why_coaching.heading": "ABOUT_WHY_COACHING_NARRATIVE",
|
|
52955
|
+
"about.why_coaching.body": "ABOUT_WHY_COACHING_NARRATIVE",
|
|
52956
|
+
"about.industries.heading": "INDUSTRIES_FACT",
|
|
52957
|
+
"about.industry_1.title": "INDUSTRIES_FACT",
|
|
52958
|
+
"about.industry_1.description": "INDUSTRIES_FACT",
|
|
52959
|
+
"about.industry_2.title": "INDUSTRIES_FACT",
|
|
52960
|
+
"about.industry_2.description": "INDUSTRIES_FACT",
|
|
52961
|
+
"about.industry_3.title": "INDUSTRIES_FACT",
|
|
52962
|
+
"about.industry_3.description": "INDUSTRIES_FACT",
|
|
52963
|
+
"coach.title": "PRACTICE_FACT",
|
|
52964
|
+
"coach.city_state": "PRACTICE_FACT",
|
|
52965
|
+
"coach.service_area_heading": "PRACTICE_FACT",
|
|
52966
|
+
"coach.service_area_line": "PRACTICE_FACT",
|
|
52967
|
+
"coach.first_name": "IDENTITY_FACT",
|
|
52968
|
+
"coach.last_name": "IDENTITY_FACT",
|
|
52969
|
+
"verified_context.approved_career_facts": "ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52970
|
+
"verified_context.verified_media": "ABOUT_BIOGRAPHY_NARRATIVE",
|
|
52971
|
+
"verified_context.approved_service_labels": "PRACTICE_FACT"
|
|
52972
|
+
}
|
|
52973
|
+
},
|
|
52974
|
+
"BUSINESS_COACHING_V1": {
|
|
52975
|
+
"groundingFieldAllowlist": [
|
|
52976
|
+
"business_coaching.hero.heading",
|
|
52977
|
+
"business_coaching.hero.body",
|
|
52978
|
+
"business_coaching.intro.body",
|
|
52979
|
+
"coach.title",
|
|
52980
|
+
"coach.location.city",
|
|
52981
|
+
"coach.location.state",
|
|
52982
|
+
"coach.city_state",
|
|
52983
|
+
"coach.service_area_heading",
|
|
52984
|
+
"coach.service_area_line"
|
|
52985
|
+
],
|
|
52986
|
+
"factFieldAllowlist": [
|
|
52987
|
+
"coach.title",
|
|
52988
|
+
"verified_context.approved_service_labels"
|
|
52989
|
+
],
|
|
52990
|
+
"destinationGroundingMap": {
|
|
52991
|
+
"business_coaching.hero.heading": {
|
|
52992
|
+
"relevant_relevance_classes": [
|
|
52993
|
+
"BUSINESS_COACHING_NARRATIVE",
|
|
52994
|
+
"PRACTICE_FACT"
|
|
52995
|
+
],
|
|
52996
|
+
"missing_value_authority": "NONE"
|
|
52997
|
+
},
|
|
52998
|
+
"business_coaching.hero.body": {
|
|
52999
|
+
"relevant_relevance_classes": [
|
|
53000
|
+
"BUSINESS_COACHING_NARRATIVE",
|
|
53001
|
+
"PRACTICE_FACT"
|
|
53002
|
+
],
|
|
53003
|
+
"missing_value_authority": "NONE"
|
|
53004
|
+
},
|
|
53005
|
+
"business_coaching.intro.body": {
|
|
53006
|
+
"relevant_relevance_classes": [
|
|
53007
|
+
"BUSINESS_COACHING_NARRATIVE"
|
|
53008
|
+
],
|
|
53009
|
+
"missing_value_authority": "NONE"
|
|
53010
|
+
}
|
|
53011
|
+
},
|
|
53012
|
+
"sourceFieldRelevanceMap": {
|
|
53013
|
+
"business_coaching.hero.heading": "BUSINESS_COACHING_NARRATIVE",
|
|
53014
|
+
"business_coaching.hero.body": "BUSINESS_COACHING_NARRATIVE",
|
|
53015
|
+
"business_coaching.intro.body": "BUSINESS_COACHING_NARRATIVE",
|
|
53016
|
+
"coach.title": "PRACTICE_FACT",
|
|
53017
|
+
"coach.city_state": "PRACTICE_FACT",
|
|
53018
|
+
"coach.service_area_heading": "PRACTICE_FACT",
|
|
53019
|
+
"coach.service_area_line": "PRACTICE_FACT",
|
|
53020
|
+
"verified_context.approved_service_labels": "PRACTICE_FACT"
|
|
53021
|
+
}
|
|
53022
|
+
},
|
|
53023
|
+
"EXECUTIVE_COACHING_V1": {
|
|
53024
|
+
"groundingFieldAllowlist": [
|
|
53025
|
+
"executive_coaching.hero.heading",
|
|
53026
|
+
"executive_coaching.hero.body",
|
|
53027
|
+
"coach.title",
|
|
53028
|
+
"coach.location.city",
|
|
53029
|
+
"coach.location.state",
|
|
53030
|
+
"coach.city_state",
|
|
53031
|
+
"coach.service_area_heading",
|
|
53032
|
+
"coach.service_area_line"
|
|
53033
|
+
],
|
|
53034
|
+
"factFieldAllowlist": [
|
|
53035
|
+
"coach.title",
|
|
53036
|
+
"verified_context.approved_service_labels"
|
|
53037
|
+
],
|
|
53038
|
+
"destinationGroundingMap": {
|
|
53039
|
+
"executive_coaching.hero.heading": {
|
|
53040
|
+
"relevant_relevance_classes": [
|
|
53041
|
+
"EXECUTIVE_COACHING_NARRATIVE",
|
|
53042
|
+
"PRACTICE_FACT"
|
|
53043
|
+
],
|
|
53044
|
+
"missing_value_authority": "NONE"
|
|
53045
|
+
},
|
|
53046
|
+
"executive_coaching.hero.body": {
|
|
53047
|
+
"relevant_relevance_classes": [
|
|
53048
|
+
"EXECUTIVE_COACHING_NARRATIVE",
|
|
53049
|
+
"PRACTICE_FACT"
|
|
53050
|
+
],
|
|
53051
|
+
"missing_value_authority": "NONE"
|
|
53052
|
+
}
|
|
53053
|
+
},
|
|
53054
|
+
"sourceFieldRelevanceMap": {
|
|
53055
|
+
"executive_coaching.hero.heading": "EXECUTIVE_COACHING_NARRATIVE",
|
|
53056
|
+
"executive_coaching.hero.body": "EXECUTIVE_COACHING_NARRATIVE",
|
|
53057
|
+
"coach.title": "PRACTICE_FACT",
|
|
53058
|
+
"coach.city_state": "PRACTICE_FACT",
|
|
53059
|
+
"coach.service_area_heading": "PRACTICE_FACT",
|
|
53060
|
+
"coach.service_area_line": "PRACTICE_FACT",
|
|
53061
|
+
"verified_context.approved_service_labels": "PRACTICE_FACT"
|
|
53062
|
+
}
|
|
53063
|
+
},
|
|
53064
|
+
"RESULTS_V1": {
|
|
53065
|
+
"groundingFieldAllowlist": [
|
|
53066
|
+
"results.intro.body"
|
|
53067
|
+
],
|
|
53068
|
+
"factFieldAllowlist": [
|
|
53069
|
+
"coach.full_name",
|
|
53070
|
+
"coach.first_name",
|
|
53071
|
+
"coach.last_name",
|
|
53072
|
+
"verified_context.approved_career_facts",
|
|
53073
|
+
"verified_context.approved_service_labels"
|
|
53074
|
+
],
|
|
53075
|
+
"destinationGroundingMap": {
|
|
53076
|
+
"results.intro.body": {
|
|
53077
|
+
"relevant_relevance_classes": [
|
|
53078
|
+
"RESULTS_NARRATIVE"
|
|
53079
|
+
],
|
|
53080
|
+
"missing_value_authority": "D14_RESULTS_BASELINE"
|
|
53081
|
+
}
|
|
53082
|
+
},
|
|
53083
|
+
"sourceFieldRelevanceMap": {
|
|
53084
|
+
"results.intro.body": "RESULTS_NARRATIVE",
|
|
53085
|
+
"coach.full_name": "IDENTITY_FACT",
|
|
53086
|
+
"coach.first_name": "IDENTITY_FACT",
|
|
53087
|
+
"coach.last_name": "IDENTITY_FACT",
|
|
53088
|
+
"verified_context.approved_career_facts": "ABOUT_BIOGRAPHY_NARRATIVE",
|
|
53089
|
+
"verified_context.approved_service_labels": "PRACTICE_FACT"
|
|
53090
|
+
}
|
|
53091
|
+
},
|
|
53092
|
+
"CONTACT_V1": {
|
|
53093
|
+
"groundingFieldAllowlist": [
|
|
53094
|
+
"contact.hero.heading",
|
|
53095
|
+
"contact.intro.body"
|
|
53096
|
+
],
|
|
53097
|
+
"factFieldAllowlist": [
|
|
53098
|
+
"coach.full_name",
|
|
53099
|
+
"coach.first_name",
|
|
53100
|
+
"coach.last_name",
|
|
53101
|
+
"verified_context.approved_service_labels"
|
|
53102
|
+
],
|
|
53103
|
+
"destinationGroundingMap": {
|
|
53104
|
+
"contact.hero.heading": {
|
|
53105
|
+
"relevant_relevance_classes": [
|
|
53106
|
+
"CONTACT_NARRATIVE"
|
|
53107
|
+
],
|
|
53108
|
+
"missing_value_authority": "D15_CONTACT_BASELINE"
|
|
53109
|
+
},
|
|
53110
|
+
"contact.intro.body": {
|
|
53111
|
+
"relevant_relevance_classes": [
|
|
53112
|
+
"CONTACT_NARRATIVE"
|
|
53113
|
+
],
|
|
53114
|
+
"missing_value_authority": "D15_CONTACT_BASELINE"
|
|
53115
|
+
}
|
|
53116
|
+
},
|
|
53117
|
+
"sourceFieldRelevanceMap": {
|
|
53118
|
+
"contact.hero.heading": "CONTACT_NARRATIVE",
|
|
53119
|
+
"contact.intro.body": "CONTACT_NARRATIVE",
|
|
53120
|
+
"coach.full_name": "IDENTITY_FACT",
|
|
53121
|
+
"coach.first_name": "IDENTITY_FACT",
|
|
53122
|
+
"coach.last_name": "IDENTITY_FACT",
|
|
53123
|
+
"verified_context.approved_service_labels": "PRACTICE_FACT"
|
|
53124
|
+
}
|
|
53125
|
+
},
|
|
53126
|
+
"DISCOVERY_CALL_V1": {
|
|
53127
|
+
"groundingFieldAllowlist": [
|
|
53128
|
+
"discovery_call.hero.body"
|
|
53129
|
+
],
|
|
53130
|
+
"factFieldAllowlist": [
|
|
53131
|
+
"coach.full_name",
|
|
53132
|
+
"coach.first_name",
|
|
53133
|
+
"coach.last_name",
|
|
53134
|
+
"verified_context.approved_service_labels"
|
|
53135
|
+
],
|
|
53136
|
+
"destinationGroundingMap": {
|
|
53137
|
+
"discovery_call.hero.body": {
|
|
53138
|
+
"relevant_relevance_classes": [
|
|
53139
|
+
"DISCOVERY_CALL_NARRATIVE"
|
|
53140
|
+
],
|
|
53141
|
+
"missing_value_authority": "D16_DISCOVERY_CALL_BASELINE"
|
|
53142
|
+
}
|
|
53143
|
+
},
|
|
53144
|
+
"sourceFieldRelevanceMap": {
|
|
53145
|
+
"discovery_call.hero.body": "DISCOVERY_CALL_NARRATIVE",
|
|
53146
|
+
"coach.full_name": "IDENTITY_FACT",
|
|
53147
|
+
"coach.first_name": "IDENTITY_FACT",
|
|
53148
|
+
"coach.last_name": "IDENTITY_FACT",
|
|
53149
|
+
"verified_context.approved_service_labels": "PRACTICE_FACT"
|
|
53150
|
+
}
|
|
53151
|
+
}
|
|
53152
|
+
};
|
|
53153
|
+
}
|
|
53154
|
+
});
|
|
53155
|
+
|
|
52849
53156
|
// dist/src/lib/contract.js
|
|
52850
53157
|
var require_contract = __commonJS({
|
|
52851
53158
|
"dist/src/lib/contract.js"(exports2) {
|
|
@@ -52865,6 +53172,7 @@ var require_contract = __commonJS({
|
|
|
52865
53172
|
exports2.validateNarrativeResponse = validateNarrativeResponse;
|
|
52866
53173
|
exports2.narrativeFailure = narrativeFailure;
|
|
52867
53174
|
var node_crypto_1 = require("node:crypto");
|
|
53175
|
+
var source_policy_generated_1 = require_source_policy_generated();
|
|
52868
53176
|
exports2.CONTRACT_ID = "OPENCODE_AI_ENRICHMENT_V1_2";
|
|
52869
53177
|
exports2.CONTRACT_VERSION = "1.2.0";
|
|
52870
53178
|
exports2.PROMPT_IDS = ["ABOUT_V1", "BUSINESS_COACHING_V1", "EXECUTIVE_COACHING_V1", "RESULTS_V1", "CONTACT_V1", "DISCOVERY_CALL_V1"];
|
|
@@ -52886,7 +53194,8 @@ var require_contract = __commonJS({
|
|
|
52886
53194
|
},
|
|
52887
53195
|
exactCopyKeys: [],
|
|
52888
53196
|
conditionalKeys: [{ canonicalField: "about.industries.heading", requiredWhen: "INDUSTRIES_GROUP populated_fields >= 1" }],
|
|
52889
|
-
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "about.industry_1.title", "about.industry_1.description", "about.industry_2.title", "about.industry_2.description", "about.industry_3.title", "about.industry_3.description", "verified_context.approved_career_facts", "verified_context.verified_media", "verified_context.approved_service_labels"]
|
|
53197
|
+
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "about.industry_1.title", "about.industry_1.description", "about.industry_2.title", "about.industry_2.description", "about.industry_3.title", "about.industry_3.description", "verified_context.approved_career_facts", "verified_context.verified_media", "verified_context.approved_service_labels"],
|
|
53198
|
+
sourcePolicy: source_policy_generated_1.SOURCE_EVIDENCE_POLICY.ABOUT_V1
|
|
52890
53199
|
},
|
|
52891
53200
|
BUSINESS_COACHING_V1: {
|
|
52892
53201
|
packetName: "AI Source \u2014 Business Coaching",
|
|
@@ -52894,7 +53203,8 @@ var require_contract = __commonJS({
|
|
|
52894
53203
|
formats: { "business_coaching.hero.heading": "PLAIN_TEXT_STRING", "business_coaching.hero.body": "PLAIN_TEXT_STRING", "business_coaching.intro.body": "HTML_FRAGMENT_STRING" },
|
|
52895
53204
|
exactCopyKeys: [],
|
|
52896
53205
|
conditionalKeys: [],
|
|
52897
|
-
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels", "verified_context.approved_career_facts"]
|
|
53206
|
+
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels", "verified_context.approved_career_facts"],
|
|
53207
|
+
sourcePolicy: source_policy_generated_1.SOURCE_EVIDENCE_POLICY.BUSINESS_COACHING_V1
|
|
52898
53208
|
},
|
|
52899
53209
|
EXECUTIVE_COACHING_V1: {
|
|
52900
53210
|
packetName: "AI Source \u2014 Executive Coaching",
|
|
@@ -52902,7 +53212,8 @@ var require_contract = __commonJS({
|
|
|
52902
53212
|
formats: { "executive_coaching.hero.heading": "PLAIN_TEXT_STRING", "executive_coaching.hero.body": "PLAIN_TEXT_STRING" },
|
|
52903
53213
|
exactCopyKeys: [],
|
|
52904
53214
|
conditionalKeys: [],
|
|
52905
|
-
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels", "verified_context.approved_career_facts"]
|
|
53215
|
+
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels", "verified_context.approved_career_facts"],
|
|
53216
|
+
sourcePolicy: source_policy_generated_1.SOURCE_EVIDENCE_POLICY.EXECUTIVE_COACHING_V1
|
|
52906
53217
|
},
|
|
52907
53218
|
RESULTS_V1: {
|
|
52908
53219
|
packetName: "AI Source \u2014 Results",
|
|
@@ -52910,7 +53221,8 @@ var require_contract = __commonJS({
|
|
|
52910
53221
|
formats: { "results.intro.body": "PLAIN_TEXT_STRING" },
|
|
52911
53222
|
exactCopyKeys: [],
|
|
52912
53223
|
conditionalKeys: [],
|
|
52913
|
-
allowedContextKeys: [...COMMON_CONTEXT, "verified_context.approved_career_facts", "verified_context.approved_service_labels"]
|
|
53224
|
+
allowedContextKeys: [...COMMON_CONTEXT, "verified_context.approved_career_facts", "verified_context.approved_service_labels"],
|
|
53225
|
+
sourcePolicy: source_policy_generated_1.SOURCE_EVIDENCE_POLICY.RESULTS_V1
|
|
52914
53226
|
},
|
|
52915
53227
|
CONTACT_V1: {
|
|
52916
53228
|
packetName: "AI Source \u2014 Contact",
|
|
@@ -52918,7 +53230,8 @@ var require_contract = __commonJS({
|
|
|
52918
53230
|
formats: { "contact.hero.heading": "PLAIN_TEXT_STRING", "contact.intro.body": "PLAIN_TEXT_STRING" },
|
|
52919
53231
|
exactCopyKeys: ["contact.hero.heading", "contact.intro.body"],
|
|
52920
53232
|
conditionalKeys: [],
|
|
52921
|
-
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels"]
|
|
53233
|
+
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels"],
|
|
53234
|
+
sourcePolicy: source_policy_generated_1.SOURCE_EVIDENCE_POLICY.CONTACT_V1
|
|
52922
53235
|
},
|
|
52923
53236
|
DISCOVERY_CALL_V1: {
|
|
52924
53237
|
packetName: "AI Source \u2014 Discovery Call",
|
|
@@ -52926,7 +53239,8 @@ var require_contract = __commonJS({
|
|
|
52926
53239
|
formats: { "discovery_call.hero.body": "PLAIN_TEXT_STRING" },
|
|
52927
53240
|
exactCopyKeys: ["discovery_call.hero.body"],
|
|
52928
53241
|
conditionalKeys: [],
|
|
52929
|
-
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels"]
|
|
53242
|
+
allowedContextKeys: [...COMMON_CONTEXT, ...LOCATION_CONTEXT, "verified_context.approved_service_labels"],
|
|
53243
|
+
sourcePolicy: source_policy_generated_1.SOURCE_EVIDENCE_POLICY.DISCOVERY_CALL_V1
|
|
52930
53244
|
}
|
|
52931
53245
|
};
|
|
52932
53246
|
exports2.ALL_OUTPUT_KEYS = exports2.PROMPT_IDS.flatMap((id) => [...exports2.PROMPT_DEFINITIONS[id].outputKeys]);
|
|
@@ -53035,18 +53349,90 @@ var require_contract = __commonJS({
|
|
|
53035
53349
|
properties: Object.fromEntries(effective.map((key) => [key, { type: "string", minLength: 1, output_format: definition.formats[key] }]))
|
|
53036
53350
|
};
|
|
53037
53351
|
}
|
|
53038
|
-
function assertEvidence(evidence,
|
|
53352
|
+
function assertEvidence(evidence, index) {
|
|
53039
53353
|
assertExactKeys(evidence, EVIDENCE_KEYS, `SOURCE_EVIDENCE_${index}`);
|
|
53040
53354
|
const { evidence_reference: reference, ...digestInput } = evidence;
|
|
53041
53355
|
if (reference !== sha256Canonical(digestInput))
|
|
53042
53356
|
throw new Error(`SOURCE_EVIDENCE_${index}_DIGEST_INVALID`);
|
|
53043
|
-
if (typeof evidence.canonical_field !== "string" || !
|
|
53357
|
+
if (typeof evidence.canonical_field !== "string" || !evidence.canonical_field.trim())
|
|
53044
53358
|
throw new Error(`SOURCE_EVIDENCE_${index}_FIELD_INVALID`);
|
|
53045
53359
|
for (const key of ["page_url", "page_title", "source_locator", "source_text"])
|
|
53046
53360
|
if (typeof evidence[key] !== "string" || !evidence[key].trim())
|
|
53047
53361
|
throw new Error(`SOURCE_EVIDENCE_${index}_${key.toUpperCase()}_INVALID`);
|
|
53048
53362
|
}
|
|
53049
|
-
|
|
53363
|
+
var VERIFIED_CONTEXT_STATUSES = ["EXACT_SOURCE", "VERIFIED_FACT", "DERIVED"];
|
|
53364
|
+
var UNVERIFIED_CONTEXT_AUTHORITIES = ["LEGACY_WEBSITE_EXACT", "AI_REWRITE_FROM_SOURCE"];
|
|
53365
|
+
function verifiedContextAuthority(value, factualProvenance) {
|
|
53366
|
+
if (!isObject(value) || !isObject(value.values) || !isObject(value.evidence))
|
|
53367
|
+
throw new Error("SOURCE_PACKET_VERIFIED_CONTEXT_INVALID");
|
|
53368
|
+
const provenance = factualProvenance === void 0 ? void 0 : factualProvenance;
|
|
53369
|
+
if (provenance !== void 0 && !Array.isArray(provenance))
|
|
53370
|
+
throw new Error("SOURCE_PACKET_FACTUAL_PROVENANCE_INVALID");
|
|
53371
|
+
const eligibleProvenance = (Array.isArray(provenance) ? provenance : []).filter((entry) => isObject(entry) && VERIFIED_CONTEXT_STATUSES.includes(String(entry.status)) && typeof entry.source_authority === "string" && !UNVERIFIED_CONTEXT_AUTHORITIES.includes(entry.source_authority) && !(entry.source_authority === "DERIVED_DETERMINISTIC" && entry.requires_human_review === true) && Array.isArray(entry.source_refs));
|
|
53372
|
+
const provenanceByField = new Map(eligibleProvenance.map((entry) => [String(entry.canonical_field), entry]));
|
|
53373
|
+
const provenanceSourceRefs = new Set(eligibleProvenance.flatMap((entry) => entry.source_refs.map((ref) => JSON.stringify(canonicalize(ref)))));
|
|
53374
|
+
const keys = /* @__PURE__ */ new Set();
|
|
53375
|
+
for (const [key, rawEvidence] of Object.entries(value.evidence)) {
|
|
53376
|
+
const rawValue = getPath(value.values, key);
|
|
53377
|
+
if (rawValue === void 0 || !isObject(rawEvidence))
|
|
53378
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_ENTRY_INVALID:${key}`);
|
|
53379
|
+
assertExactKeys(rawEvidence, ["value", "source_authority", "source_refs", "status"], `SOURCE_PACKET_VERIFIED_CONTEXT_ENTRY:${key}`);
|
|
53380
|
+
if (JSON.stringify(canonicalize(rawEvidence.value)) !== JSON.stringify(canonicalize(rawValue)))
|
|
53381
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_VALUE_MISMATCH:${key}`);
|
|
53382
|
+
if (!VERIFIED_CONTEXT_STATUSES.includes(String(rawEvidence.status)))
|
|
53383
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_STATUS_INVALID:${key}`);
|
|
53384
|
+
if (typeof rawEvidence.source_authority !== "string" || UNVERIFIED_CONTEXT_AUTHORITIES.includes(rawEvidence.source_authority))
|
|
53385
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_AUTHORITY_INVALID:${key}`);
|
|
53386
|
+
if (!Array.isArray(rawEvidence.source_refs) || rawEvidence.source_refs.length === 0 || rawEvidence.source_refs.some((ref) => !isObject(ref)))
|
|
53387
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_SOURCE_REFS_INVALID:${key}`);
|
|
53388
|
+
if (provenance !== void 0) {
|
|
53389
|
+
for (const ref of rawEvidence.source_refs)
|
|
53390
|
+
if (!provenanceSourceRefs.has(JSON.stringify(canonicalize(ref))))
|
|
53391
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_SOURCE_REF_UNBOUND:${key}`);
|
|
53392
|
+
const provenanceField = key.replace(/^coach_identity\.location\./, "coach.location.");
|
|
53393
|
+
const direct = provenanceByField.get(provenanceField);
|
|
53394
|
+
const requiresDirectProvenance = !key.startsWith("verified_context.") && !key.startsWith("coach_identity.location.");
|
|
53395
|
+
if (requiresDirectProvenance && !direct)
|
|
53396
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_PROVENANCE_UNRESOLVED:${key}`);
|
|
53397
|
+
if (direct) {
|
|
53398
|
+
for (const member of ["value", "source_authority", "source_refs", "status"]) {
|
|
53399
|
+
if (JSON.stringify(canonicalize(rawEvidence[member])) !== JSON.stringify(canonicalize(direct[member])))
|
|
53400
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_PROVENANCE_MISMATCH:${key}:${member}`);
|
|
53401
|
+
}
|
|
53402
|
+
}
|
|
53403
|
+
if (key.startsWith("verified_context.")) {
|
|
53404
|
+
const aggregateDomains = {
|
|
53405
|
+
"verified_context.approved_career_facts": (entry) => String(entry.canonical_field).startsWith("about.stat_"),
|
|
53406
|
+
"verified_context.verified_media": (entry) => String(entry.canonical_field).startsWith("about.media."),
|
|
53407
|
+
"verified_context.approved_service_labels": (entry) => ["coach.title", "coach.service_area_heading", "coach.service_area_line"].includes(String(entry.canonical_field))
|
|
53408
|
+
};
|
|
53409
|
+
const inDomain = aggregateDomains[key];
|
|
53410
|
+
if (!inDomain || rawEvidence.source_authority !== "DERIVED_DETERMINISTIC" || rawEvidence.status !== "DERIVED")
|
|
53411
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_AGGREGATE_AUTHORITY_INVALID:${key}`);
|
|
53412
|
+
const records = key === "verified_context.approved_service_labels" ? ["coach.title", "coach.service_area_heading", "coach.service_area_line"].map((field) => provenanceByField.get(field)).filter((entry) => Boolean(entry)) : eligibleProvenance.filter(inDomain);
|
|
53413
|
+
const expectedValue = records.map((entry) => ({ canonical_field: entry.canonical_field, value: entry.value }));
|
|
53414
|
+
const expectedRefs = records.flatMap((entry) => entry.source_refs);
|
|
53415
|
+
if (JSON.stringify(canonicalize(rawEvidence.value)) !== JSON.stringify(canonicalize(expectedValue)))
|
|
53416
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_AGGREGATE_VALUE_INVALID:${key}`);
|
|
53417
|
+
if (JSON.stringify(canonicalize(rawEvidence.source_refs)) !== JSON.stringify(canonicalize(expectedRefs)))
|
|
53418
|
+
throw new Error(`SOURCE_PACKET_VERIFIED_CONTEXT_AGGREGATE_REFS_INVALID:${key}`);
|
|
53419
|
+
}
|
|
53420
|
+
}
|
|
53421
|
+
keys.add(key);
|
|
53422
|
+
}
|
|
53423
|
+
return { keys, values: value.values };
|
|
53424
|
+
}
|
|
53425
|
+
function sourceFieldAllowedForClass(definition, evidenceClass, canonicalField) {
|
|
53426
|
+
if (evidenceClass === "FIELD_EVIDENCE" || evidenceClass === "PAGE_SECTION_EXCERPT")
|
|
53427
|
+
return definition.sourcePolicy.groundingFieldAllowlist.includes(canonicalField);
|
|
53428
|
+
if (evidenceClass === "DETERMINISTIC_FACT" || evidenceClass === "VERIFIED_FACTUAL_CONTEXT" || evidenceClass === "PRACTICE_CONTEXT")
|
|
53429
|
+
return definition.sourcePolicy.factFieldAllowlist.includes(canonicalField);
|
|
53430
|
+
return false;
|
|
53431
|
+
}
|
|
53432
|
+
function jobSourceFieldAllowed(definition, canonicalField) {
|
|
53433
|
+
return definition.sourcePolicy.groundingFieldAllowlist.includes(canonicalField) || definition.sourcePolicy.factFieldAllowlist.includes(canonicalField);
|
|
53434
|
+
}
|
|
53435
|
+
function assertCanonicalSourcePacket(value, expectedPromptId, requireReady = true, verifiedFactualContext, factualProvenance) {
|
|
53050
53436
|
assertExactKeys(value, PACKET_KEYS, "SOURCE_PACKET");
|
|
53051
53437
|
const definition = promptDefinition(value.prompt_id);
|
|
53052
53438
|
if (expectedPromptId && value.prompt_id !== expectedPromptId)
|
|
@@ -53057,13 +53443,19 @@ var require_contract = __commonJS({
|
|
|
53057
53443
|
throw new Error("SOURCE_PACKET_EVIDENCE_STATUS_INVALID");
|
|
53058
53444
|
if (requireReady && value.evidence_status !== "READY")
|
|
53059
53445
|
throw new Error("SOURCE_PACKET_INSUFFICIENT_EVIDENCE");
|
|
53060
|
-
if (!Array.isArray(value.source_evidence_references)
|
|
53446
|
+
if (!Array.isArray(value.source_evidence_references))
|
|
53061
53447
|
throw new Error("SOURCE_PACKET_EVIDENCE_REQUIRED");
|
|
53062
|
-
|
|
53063
|
-
|
|
53064
|
-
|
|
53065
|
-
|
|
53066
|
-
|
|
53448
|
+
const sourceReferences = /* @__PURE__ */ new Map();
|
|
53449
|
+
value.source_evidence_references.forEach((entry, index) => {
|
|
53450
|
+
assertEvidence(entry, index);
|
|
53451
|
+
const reference = String(entry.evidence_reference);
|
|
53452
|
+
if (sourceReferences.has(reference))
|
|
53453
|
+
throw new Error(`SOURCE_EVIDENCE_${index}_DUPLICATE_ID`);
|
|
53454
|
+
sourceReferences.set(reference, entry);
|
|
53455
|
+
});
|
|
53456
|
+
const contextAuthority = verifiedContextAuthority(verifiedFactualContext, factualProvenance);
|
|
53457
|
+
const pool = assertEvidencePool(value.evidence_pool, definition, sourceReferences, contextAuthority);
|
|
53458
|
+
assertGroundingRecords(value.grounding, definition, new Set(pool.pageEntries.keys()), new Set(pool.contextEntries.keys()), pool.relevanceByReference);
|
|
53067
53459
|
const unresolved = (Array.isArray(value.grounding) ? value.grounding : []).filter((record) => record.grounding_status === "NO_SUPPORTING_EVIDENCE" && String(record.grounding_basis).endsWith("UNRESOLVED_POLICY"));
|
|
53068
53460
|
if (value.evidence_status === "READY" && unresolved.length)
|
|
53069
53461
|
throw new Error(`SOURCE_PACKET_UNRESOLVED_POLICY:${unresolved.map((record) => String(record.canonical_field)).join(",")}`);
|
|
@@ -53080,7 +53472,7 @@ var require_contract = __commonJS({
|
|
|
53080
53472
|
if (digest !== sha256Canonical(digestInput))
|
|
53081
53473
|
throw new Error("SOURCE_PACKET_DIGEST_INVALID");
|
|
53082
53474
|
}
|
|
53083
|
-
function assertGroundingRecords(grounding, definition, evidenceReferences, verifiedContextKeys) {
|
|
53475
|
+
function assertGroundingRecords(grounding, definition, evidenceReferences, verifiedContextKeys, relevanceByReference) {
|
|
53084
53476
|
if (!Array.isArray(grounding) || grounding.length !== definition.outputKeys.length)
|
|
53085
53477
|
throw new Error("SOURCE_PACKET_GROUNDING_COUNT_INVALID");
|
|
53086
53478
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -53101,9 +53493,17 @@ var require_contract = __commonJS({
|
|
|
53101
53493
|
throw new Error("SOURCE_PACKET_GROUNDED_REQUIRES_REFERENCES");
|
|
53102
53494
|
if (status !== "GROUNDED" && refs.length)
|
|
53103
53495
|
throw new Error("SOURCE_PACKET_GROUNDING_REFS_UNEXPECTED");
|
|
53104
|
-
for (const ref of refs)
|
|
53496
|
+
for (const ref of refs) {
|
|
53105
53497
|
if (!evidenceReferences.has(ref) && !verifiedContextKeys.has(ref))
|
|
53106
53498
|
throw new Error(`SOURCE_PACKET_GROUNDING_REFERENCE_UNRESOLVED:${ref}`);
|
|
53499
|
+
if (relevanceByReference) {
|
|
53500
|
+
const destinationPolicy = definition.sourcePolicy.destinationGroundingMap[field];
|
|
53501
|
+
const relevance = relevanceByReference.get(ref);
|
|
53502
|
+
if (!destinationPolicy || !relevance || !destinationPolicy.relevant_relevance_classes.includes(relevance)) {
|
|
53503
|
+
throw new Error(`SOURCE_PACKET_GROUNDING_RELEVANCE_INVALID:${field}:${ref}`);
|
|
53504
|
+
}
|
|
53505
|
+
}
|
|
53506
|
+
}
|
|
53107
53507
|
if (typeof record.grounding_basis !== "string" || !record.grounding_basis.trim())
|
|
53108
53508
|
throw new Error("SOURCE_PACKET_GROUNDING_BASIS_INVALID");
|
|
53109
53509
|
});
|
|
@@ -53111,53 +53511,103 @@ var require_contract = __commonJS({
|
|
|
53111
53511
|
if (!seen.has(key))
|
|
53112
53512
|
throw new Error(`SOURCE_PACKET_GROUNDING_MISSING:${key}`);
|
|
53113
53513
|
}
|
|
53114
|
-
function assertEvidencePool(pool) {
|
|
53514
|
+
function assertEvidencePool(pool, definition, sourceReferences, verifiedContext) {
|
|
53115
53515
|
if (!Array.isArray(pool))
|
|
53116
53516
|
throw new Error("SOURCE_PACKET_EVIDENCE_POOL_REQUIRED");
|
|
53117
53517
|
const pageAttributedClasses = ["FIELD_EVIDENCE", "PAGE_SECTION_EXCERPT", "DETERMINISTIC_FACT"];
|
|
53118
53518
|
const contextClasses = ["VERIFIED_FACTUAL_CONTEXT", "PRACTICE_CONTEXT"];
|
|
53519
|
+
const pageEntries = /* @__PURE__ */ new Map();
|
|
53520
|
+
const contextEntries = /* @__PURE__ */ new Map();
|
|
53521
|
+
const relevanceByReference = /* @__PURE__ */ new Map();
|
|
53119
53522
|
for (const raw of pool) {
|
|
53120
53523
|
assertExactKeys(raw, ["evidence_reference", "evidence_class", "canonical_field", "page_url", "page_title", "source_locator", "source_text", "relevance_class"], "SOURCE_PACKET_EVIDENCE_POOL_ENTRY");
|
|
53121
53524
|
const entry = raw;
|
|
53525
|
+
const reference = String(entry.evidence_reference ?? "");
|
|
53526
|
+
if (!reference)
|
|
53527
|
+
throw new Error("SOURCE_PACKET_EVIDENCE_REFERENCE_INVALID");
|
|
53528
|
+
if (pageEntries.has(reference) || contextEntries.has(reference))
|
|
53529
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_POOL_DUPLICATE_ID:${reference}`);
|
|
53122
53530
|
const evidenceClass = String(entry.evidence_class);
|
|
53123
53531
|
if (![...pageAttributedClasses, ...contextClasses].includes(evidenceClass))
|
|
53124
53532
|
throw new Error(`SOURCE_PACKET_EVIDENCE_CLASS_INVALID:${evidenceClass}`);
|
|
53533
|
+
const canonicalField = String(entry.canonical_field ?? "");
|
|
53534
|
+
if (!canonicalField || !sourceFieldAllowedForClass(definition, evidenceClass, canonicalField))
|
|
53535
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_FIELD_INVALID:${evidenceClass}:${canonicalField}`);
|
|
53536
|
+
const relevance = String(entry.relevance_class ?? "");
|
|
53537
|
+
const authoritativeRelevance = definition.sourcePolicy.sourceFieldRelevanceMap[canonicalField];
|
|
53538
|
+
if (!authoritativeRelevance || relevance !== authoritativeRelevance)
|
|
53539
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_RELEVANCE_INVALID:${canonicalField}:${relevance}`);
|
|
53125
53540
|
if (pageAttributedClasses.includes(evidenceClass)) {
|
|
53126
|
-
if (entry.page_url
|
|
53541
|
+
if (typeof entry.page_url !== "string" || !entry.page_url.trim() || typeof entry.page_title !== "string" || !entry.page_title.trim() || typeof entry.source_locator !== "string" || !entry.source_locator.trim())
|
|
53127
53542
|
throw new Error(`SOURCE_PACKET_EVIDENCE_PROVENANCE_INVALID:${evidenceClass}`);
|
|
53128
53543
|
const digestInput = { canonical_field: entry.canonical_field, page_url: entry.page_url, page_title: entry.page_title, source_locator: entry.source_locator, source_text: entry.source_text };
|
|
53129
53544
|
if (entry.evidence_reference !== sha256Canonical(digestInput))
|
|
53130
53545
|
throw new Error(`SOURCE_PACKET_EVIDENCE_DIGEST_INVALID:${String(entry.canonical_field)}`);
|
|
53546
|
+
pageEntries.set(reference, entry);
|
|
53131
53547
|
} else {
|
|
53132
|
-
if (entry.page_url !== null || entry.source_locator !== null)
|
|
53548
|
+
if (entry.page_url !== null || entry.page_title !== null || entry.source_locator !== null)
|
|
53133
53549
|
throw new Error("SOURCE_PACKET_EVIDENCE_CONTEXT_PROVENANCE_UNEXPECTED");
|
|
53134
53550
|
if (entry.evidence_reference !== String(entry.canonical_field ?? ""))
|
|
53135
53551
|
throw new Error("SOURCE_PACKET_EVIDENCE_CONTEXT_KEY_INVALID");
|
|
53552
|
+
if (!verifiedContext.keys.has(canonicalField))
|
|
53553
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_CONTEXT_UNRESOLVED:${canonicalField}`);
|
|
53554
|
+
const contextValue = getPath(verifiedContext.values, canonicalField);
|
|
53555
|
+
if (entry.source_text !== JSON.stringify(canonicalize(contextValue)))
|
|
53556
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_CONTEXT_PROJECTION_INVALID:${canonicalField}`);
|
|
53557
|
+
contextEntries.set(reference, entry);
|
|
53136
53558
|
}
|
|
53137
53559
|
if (typeof entry.source_text !== "string" || !entry.source_text.trim())
|
|
53138
53560
|
throw new Error("SOURCE_PACKET_EVIDENCE_TEXT_REQUIRED");
|
|
53139
53561
|
if (entry.source_text.length > 2e3)
|
|
53140
53562
|
throw new Error("SOURCE_PACKET_EVIDENCE_EXCERPT_OVERBOUND");
|
|
53141
|
-
|
|
53142
|
-
throw new Error("SOURCE_PACKET_EVIDENCE_RELEVANCE_INVALID");
|
|
53563
|
+
relevanceByReference.set(reference, relevance);
|
|
53143
53564
|
}
|
|
53144
53565
|
if (pool.length > 48)
|
|
53145
53566
|
throw new Error("SOURCE_PACKET_EVIDENCE_POOL_OVERBOUND");
|
|
53567
|
+
if (pageEntries.size !== sourceReferences.size)
|
|
53568
|
+
throw new Error("SOURCE_PACKET_EVIDENCE_POOL_PROJECTION_COUNT_INVALID");
|
|
53569
|
+
for (const [reference, source] of sourceReferences) {
|
|
53570
|
+
const entry = pageEntries.get(reference);
|
|
53571
|
+
if (!entry)
|
|
53572
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_POOL_REFERENCE_UNRESOLVED:${reference}`);
|
|
53573
|
+
for (const key of ["evidence_reference", "canonical_field", "page_url", "page_title", "source_locator", "source_text"]) {
|
|
53574
|
+
if (entry[key] !== source[key])
|
|
53575
|
+
throw new Error(`SOURCE_PACKET_EVIDENCE_PROJECTION_MISMATCH:${reference}:${key}`);
|
|
53576
|
+
}
|
|
53577
|
+
}
|
|
53578
|
+
return { pageEntries, contextEntries, relevanceByReference };
|
|
53579
|
+
}
|
|
53580
|
+
function assertPreAiPackageOwnership(input, promptId) {
|
|
53581
|
+
if (!isObject(input.pre_ai_package))
|
|
53582
|
+
throw new Error("BOUNDARY_PRE_AI_PACKAGE_MUST_BE_OBJECT");
|
|
53583
|
+
const { package_digest: packageDigest, ...packageBody } = input.pre_ai_package;
|
|
53584
|
+
if (typeof packageDigest !== "string" || packageDigest !== sha256Canonical(packageBody))
|
|
53585
|
+
throw new Error("BOUNDARY_PRE_AI_PACKAGE_DIGEST_INVALID");
|
|
53586
|
+
if (!Array.isArray(packageBody.aiSourcePackets))
|
|
53587
|
+
throw new Error("BOUNDARY_PRE_AI_PACKAGE_PACKETS_INVALID");
|
|
53588
|
+
const ownedPacket = packageBody.aiSourcePackets.find((packet) => isObject(packet) && packet.prompt_id === promptId && JSON.stringify(canonicalize(packet)) === JSON.stringify(canonicalize(input.source_packet)));
|
|
53589
|
+
if (!ownedPacket)
|
|
53590
|
+
throw new Error(`BOUNDARY_SOURCE_PACKET_NOT_OWNED_BY_PRE_AI_PACKAGE:${promptId}`);
|
|
53591
|
+
if (JSON.stringify(canonicalize(packageBody.verifiedFactualContext)) !== JSON.stringify(canonicalize(input.verified_factual_context))) {
|
|
53592
|
+
throw new Error("BOUNDARY_VERIFIED_CONTEXT_NOT_OWNED_BY_PRE_AI_PACKAGE");
|
|
53593
|
+
}
|
|
53594
|
+
return packageBody;
|
|
53146
53595
|
}
|
|
53147
53596
|
function buildBoundedNarrativeJob(input) {
|
|
53148
|
-
assertExactKeys(input, ["contract_id", "prompt_id", "source_packet", "verified_factual_context", "required_output_schema", "template_baseline"], "BOUNDARY_INPUT");
|
|
53597
|
+
assertExactKeys(input, ["contract_id", "prompt_id", "source_packet", "verified_factual_context", "pre_ai_package", "required_output_schema", "template_baseline"], "BOUNDARY_INPUT");
|
|
53149
53598
|
if (input.contract_id !== exports2.CONTRACT_ID)
|
|
53150
53599
|
throw new Error("BOUNDED_AI_CONTRACT_ID_INVALID");
|
|
53151
53600
|
const definition = promptDefinition(input.prompt_id);
|
|
53152
53601
|
const promptId = input.prompt_id;
|
|
53153
|
-
|
|
53602
|
+
const owningPackage = assertPreAiPackageOwnership(input, promptId);
|
|
53603
|
+
assertCanonicalSourcePacket(input.source_packet, promptId, true, input.verified_factual_context, owningPackage.factualProvenance);
|
|
53154
53604
|
const packet = input.source_packet;
|
|
53155
|
-
if (!isObject(
|
|
53605
|
+
if (!isObject(input.verified_factual_context))
|
|
53156
53606
|
throw new Error("BOUNDED_AI_VERIFIED_CONTEXT_INVALID");
|
|
53157
53607
|
const expectedSchema = effectiveOutputSchemaForPrompt(promptId, Array.isArray(packet.grounding) ? packet.grounding : []);
|
|
53158
53608
|
if (JSON.stringify(canonicalize(input.required_output_schema)) !== JSON.stringify(canonicalize(expectedSchema)))
|
|
53159
53609
|
throw new Error("BOUNDED_AI_OUTPUT_SCHEMA_INVALID");
|
|
53160
|
-
const contextSource =
|
|
53610
|
+
const contextSource = input.verified_factual_context;
|
|
53161
53611
|
if (!isObject(contextSource))
|
|
53162
53612
|
throw new Error("BOUNDED_AI_VERIFIED_CONTEXT_INVALID");
|
|
53163
53613
|
const values = isObject(contextSource.values) ? contextSource.values : {};
|
|
@@ -53217,18 +53667,32 @@ var require_contract = __commonJS({
|
|
|
53217
53667
|
throw new Error("BOUNDED_AI_SOURCE_TEXT_REQUIRED");
|
|
53218
53668
|
if (!Array.isArray(value.source_evidence))
|
|
53219
53669
|
throw new Error("BOUNDED_AI_SOURCE_EVIDENCE_REQUIRED");
|
|
53220
|
-
if (value.source_evidence.length
|
|
53221
|
-
const
|
|
53222
|
-
|
|
53223
|
-
|
|
53224
|
-
|
|
53225
|
-
|
|
53226
|
-
|
|
53227
|
-
|
|
53670
|
+
if (value.source_evidence.length > 0) {
|
|
53671
|
+
const seenEvidence = /* @__PURE__ */ new Set();
|
|
53672
|
+
value.source_evidence.forEach((entry, index) => {
|
|
53673
|
+
assertEvidence(entry, index);
|
|
53674
|
+
if (!jobSourceFieldAllowed(definition, String(entry.canonical_field)))
|
|
53675
|
+
throw new Error(`SOURCE_EVIDENCE_${index}_FIELD_INVALID`);
|
|
53676
|
+
const reference = String(entry.evidence_reference);
|
|
53677
|
+
if (seenEvidence.has(reference))
|
|
53678
|
+
throw new Error(`SOURCE_EVIDENCE_${index}_DUPLICATE_ID`);
|
|
53679
|
+
seenEvidence.add(reference);
|
|
53680
|
+
});
|
|
53228
53681
|
if (typeof value.source_text !== "string" || !value.source_text.trim())
|
|
53229
53682
|
throw new Error("BOUNDED_AI_SOURCE_TEXT_REQUIRED");
|
|
53230
53683
|
if (!Array.isArray(value.source_locators) || value.source_locators.some((entry) => typeof entry !== "string") || new Set(value.source_locators).size !== value.source_locators.length)
|
|
53231
53684
|
throw new Error("BOUNDED_AI_SOURCE_LOCATORS_INVALID");
|
|
53685
|
+
const expectedText = value.source_evidence.map((entry) => entry.source_text).join("\n\n");
|
|
53686
|
+
if (value.source_text !== expectedText)
|
|
53687
|
+
throw new Error("BOUNDED_AI_SOURCE_TEXT_INVALID");
|
|
53688
|
+
const expectedLocators = [...new Set(value.source_evidence.map((entry) => `${String(entry.page_url)}#${String(entry.source_locator)}`))].sort();
|
|
53689
|
+
if (JSON.stringify(value.source_locators) !== JSON.stringify(expectedLocators))
|
|
53690
|
+
throw new Error("BOUNDED_AI_SOURCE_LOCATORS_INVALID");
|
|
53691
|
+
} else {
|
|
53692
|
+
if (value.source_text !== "")
|
|
53693
|
+
throw new Error("BOUNDED_AI_SOURCE_TEXT_INVALID");
|
|
53694
|
+
if (!Array.isArray(value.source_locators) || value.source_locators.length !== 0)
|
|
53695
|
+
throw new Error("BOUNDED_AI_SOURCE_LOCATORS_INVALID");
|
|
53232
53696
|
}
|
|
53233
53697
|
if (!DIGEST.test(String(value.source_packet_digest)))
|
|
53234
53698
|
throw new Error("BOUNDED_AI_PACKET_DIGEST_INVALID");
|
|
@@ -53368,15 +53832,14 @@ var require_contract = __commonJS({
|
|
|
53368
53832
|
seen.add(field);
|
|
53369
53833
|
const groundingRecord = job.grounding.find((record) => record.canonical_field === field);
|
|
53370
53834
|
const groundingRefs = new Set(groundingRecord?.grounding_evidence_references ?? []);
|
|
53371
|
-
const
|
|
53372
|
-
|
|
53373
|
-
|
|
53374
|
-
|
|
53375
|
-
|
|
53376
|
-
|
|
53377
|
-
if (!Array.isArray(raw.verified_context_refs) || raw.verified_context_refs.some((ref) => typeof ref !== "string" || !Object.hasOwn(job.verified_factual_context, ref)))
|
|
53835
|
+
const requestEvidenceRefs = new Set(job.source_evidence.map((entry) => String(entry.evidence_reference)));
|
|
53836
|
+
const authorizedEvidenceRefs = new Set([...groundingRefs].filter((ref) => requestEvidenceRefs.has(ref)));
|
|
53837
|
+
const authorizedContextRefs = new Set([...groundingRefs].filter((ref) => Object.hasOwn(job.verified_factual_context, ref)));
|
|
53838
|
+
if (!Array.isArray(raw.source_refs) || raw.source_refs.some((ref) => typeof ref !== "string" || !authorizedEvidenceRefs.has(ref)) || new Set(raw.source_refs).size !== raw.source_refs.length)
|
|
53839
|
+
issues.push(`PROVENANCE_${index}_SOURCE_REFS_INVALID`);
|
|
53840
|
+
if (!Array.isArray(raw.verified_context_refs) || raw.verified_context_refs.some((ref) => typeof ref !== "string" || !authorizedContextRefs.has(ref)) || new Set(raw.verified_context_refs).size !== raw.verified_context_refs.length)
|
|
53378
53841
|
issues.push(`PROVENANCE_${index}_CONTEXT_REFS_INVALID`);
|
|
53379
|
-
if (Array.isArray(raw.source_refs) && raw.source_refs.length === 0 &&
|
|
53842
|
+
if (groundingRecord?.grounding_status === "GROUNDED" && Array.isArray(raw.source_refs) && raw.source_refs.length === 0 && Array.isArray(raw.verified_context_refs) && raw.verified_context_refs.length === 0)
|
|
53380
53843
|
issues.push(`PROVENANCE_${index}_NO_GROUNDING`);
|
|
53381
53844
|
}
|
|
53382
53845
|
for (const key of effectiveKeys)
|
|
@@ -53386,7 +53849,9 @@ var require_contract = __commonJS({
|
|
|
53386
53849
|
if (!effectiveKeys.includes(key))
|
|
53387
53850
|
continue;
|
|
53388
53851
|
const output = value.outputs[key];
|
|
53389
|
-
const
|
|
53852
|
+
const groundingRecord = job.grounding.find((record) => record.canonical_field === key);
|
|
53853
|
+
const groundingRefs = new Set(groundingRecord?.grounding_evidence_references ?? []);
|
|
53854
|
+
const evidenceMatch = job.source_evidence.filter((entry) => groundingRefs.has(String(entry.evidence_reference))).some((entry) => String(entry.source_text).replace(/\s+/g, " ").trim() === String(output).replace(/\s+/g, " ").trim());
|
|
53390
53855
|
const baselineMatch = (job.template_baseline.elements ?? []).some((element) => String(element.captured_content).replace(/\s+/g, " ").trim() === String(output).replace(/\s+/g, " ").trim());
|
|
53391
53856
|
if (!evidenceMatch && !baselineMatch)
|
|
53392
53857
|
issues.push(`${key}:EXACT_COPY_MISMATCH`);
|
|
@@ -53525,11 +53990,13 @@ var require_pre_ai_contract = __commonJS({
|
|
|
53525
53990
|
throw new Error("PRE_AI_PACKAGE_AI_CONTRACT_INVALID");
|
|
53526
53991
|
if (!["PRE_AI_READY", "PRE_AI_BLOCKED"].includes(String(value.status)))
|
|
53527
53992
|
throw new Error("PRE_AI_PACKAGE_STATUS_INVALID");
|
|
53993
|
+
if (!(0, contract_1.isObject)(value.verifiedFactualContext) || !(0, contract_1.isObject)(value.verifiedFactualContext.values) || !(0, contract_1.isObject)(value.verifiedFactualContext.evidence))
|
|
53994
|
+
throw new Error("PRE_AI_PACKAGE_VERIFIED_CONTEXT_INVALID");
|
|
53528
53995
|
if (!Array.isArray(value.aiSourcePackets) || value.aiSourcePackets.length !== 6)
|
|
53529
53996
|
throw new Error("PRE_AI_PACKAGE_PACKET_COUNT_INVALID");
|
|
53530
53997
|
const seenPrompts = /* @__PURE__ */ new Set();
|
|
53531
53998
|
for (const packet of value.aiSourcePackets) {
|
|
53532
|
-
(0, contract_1.assertCanonicalSourcePacket)(packet, void 0, false);
|
|
53999
|
+
(0, contract_1.assertCanonicalSourcePacket)(packet, void 0, false, value.verifiedFactualContext, value.factualProvenance);
|
|
53533
54000
|
seenPrompts.add(String(packet.prompt_id));
|
|
53534
54001
|
}
|
|
53535
54002
|
if (seenPrompts.size !== 6 || contract_1.PROMPT_IDS.some((promptId) => !seenPrompts.has(promptId)))
|
|
@@ -53550,8 +54017,6 @@ var require_pre_ai_contract = __commonJS({
|
|
|
53550
54017
|
throw new Error("PRE_AI_PACKAGE_TESTIMONIAL_COUNT_INVALID");
|
|
53551
54018
|
if (!(0, contract_1.isObject)(value.frozenCountEvidence) || value.frozenCountEvidence.canonical_fields !== 76 || value.frozenCountEvidence.active_custom_values !== 67 || value.frozenCountEvidence.automated_ai_prompt_groups !== 6 || value.frozenCountEvidence.automated_ai_output_fields !== 17)
|
|
53552
54019
|
throw new Error("PRE_AI_PACKAGE_FROZEN_COUNTS_INVALID");
|
|
53553
|
-
if (!(0, contract_1.isObject)(value.verifiedFactualContext) || !(0, contract_1.isObject)(value.verifiedFactualContext.values) || !(0, contract_1.isObject)(value.verifiedFactualContext.evidence))
|
|
53554
|
-
throw new Error("PRE_AI_PACKAGE_VERIFIED_CONTEXT_INVALID");
|
|
53555
54020
|
const narrativePath = containsFinalNarrative(value.factualCanonicalValues);
|
|
53556
54021
|
if (narrativePath)
|
|
53557
54022
|
throw new Error(`PRE_AI_PACKAGE_FINAL_NARRATIVE_PRESENT:${narrativePath}`);
|
|
@@ -53613,6 +54078,7 @@ var require_transform_narrative_job = __commonJS({
|
|
|
53613
54078
|
var pieces_framework_12 = require_src2();
|
|
53614
54079
|
var pieces_common_1 = require_src4();
|
|
53615
54080
|
var contract_1 = require_contract();
|
|
54081
|
+
var pre_ai_contract_1 = require_pre_ai_contract();
|
|
53616
54082
|
var output_schemas_1 = require_output_schemas();
|
|
53617
54083
|
var PRIVATE_RUNTIME_URL = "http://coach-migration-runtime:3010/narrative/transform";
|
|
53618
54084
|
exports2.transformNarrativeJob = (0, pieces_framework_12.createAction)({
|
|
@@ -53639,13 +54105,15 @@ var require_transform_narrative_job = __commonJS({
|
|
|
53639
54105
|
options: { disabled: false, options: contract_1.PROMPT_IDS.map((value) => ({ label: value, value })) }
|
|
53640
54106
|
}),
|
|
53641
54107
|
source_packet: pieces_framework_12.Property.Json({ displayName: "Canonical Source Packet", description: "Exactly one packet from Extract Canonical PREAI Package.", required: true }),
|
|
53642
|
-
verified_factual_context: pieces_framework_12.Property.Json({ displayName: "Verified Factual Context", description: "The verifiedFactualContext object from the same PREAI package. It is filtered to the prompt allowlist.", required: true }),
|
|
54108
|
+
verified_factual_context: pieces_framework_12.Property.Json({ displayName: "Verified Factual Context", description: "The verifiedFactualContext object from the same PREAI package. It is filtered to the prompt allowlist and enforced as owned by the supplied PREAI package (B-1).", required: true }),
|
|
54109
|
+
pre_ai_package: pieces_framework_12.Property.Json({ displayName: "Owning PREAI Package", description: "The full PREAI package from the same Extract Canonical PREAI Package run as the source packet; its package_digest is the ownership identity binding the packet, verified factual context, and factual provenance (B-1).", required: true }),
|
|
53643
54110
|
required_output_schema: pieces_framework_12.Property.Json({ displayName: "Required Output Schema", description: "Effective schema for the selected prompt; must match the contract-derived effective set exactly.", required: true }),
|
|
53644
54111
|
template_baseline: pieces_framework_12.Property.Json({ displayName: "Template Narrative Baseline", description: "Verified FOCALPOINT_STANDARD template FORM baseline with its manifest digest; form authority only, never factual source.", required: true })
|
|
53645
54112
|
},
|
|
53646
54113
|
outputSchema: output_schemas_1.transformNarrativeJobOutputSchema,
|
|
53647
54114
|
run: async (context) => {
|
|
53648
|
-
const
|
|
54115
|
+
const validatedPackage = (0, pre_ai_contract_1.validatePreAiPackage)(context.propsValue.pre_ai_package);
|
|
54116
|
+
const job = (0, contract_1.buildBoundedNarrativeJob)({ ...context.propsValue, pre_ai_package: validatedPackage });
|
|
53649
54117
|
try {
|
|
53650
54118
|
const response = await pieces_common_1.httpClient.sendRequest({
|
|
53651
54119
|
method: pieces_common_1.HttpMethod.POST,
|