@disclosureos/schema 2.0.0-beta.1 → 2.0.0-beta.2
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/CHANGELOG.md +14 -0
- package/README.md +9 -0
- package/dist/experimental/v2/index.d.ts +26 -1
- package/dist/experimental/v2/index.js +448 -2
- package/dist/experimental/v2/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 25d01be: Add versioned public witness/account/procedure declarations and entity-addressed claim history with supplied-snapshot review. Preserve sourced qualifications, historical precision, missingness and attributable credibility vocabulary without calculating credibility scores. Existing contracts and profile dispatch remain unchanged.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [25d01be]
|
|
12
|
+
- @disclosureos/records@2.0.0-beta.2
|
|
13
|
+
- @disclosureos/instruments@2.0.0-beta.2
|
|
14
|
+
- @disclosureos/observables@2.0.0-beta.2
|
|
15
|
+
- @disclosureos/origins@2.0.0-beta.2
|
|
16
|
+
|
|
3
17
|
## 2.0.0-beta.1
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -187,3 +187,12 @@ Start with the [developer compatibility guide](../../docs/experimental/migration
|
|
|
187
187
|
for breaking changes, parser/version boundaries, supported migration workflows,
|
|
188
188
|
exit handling, profile differences and non-destructive local rollback. This is an
|
|
189
189
|
experimental checkout workflow; merging package changes does not deploy the Index.
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## Witnesses and accounts: C2a candidate
|
|
193
|
+
|
|
194
|
+
The source tree adds public witness/account/procedure declarations, entity-addressed
|
|
195
|
+
claim history 0.3.0 and supplied-snapshot review. These additions are not included
|
|
196
|
+
in the published 2.0.0-beta.1 packages. See the [contract, worked example and
|
|
197
|
+
verification boundaries](../../docs/c2/README.md). Qualifications and reviewer
|
|
198
|
+
judgments remain separate; no credibility score is calculated.
|
|
@@ -1702,4 +1702,29 @@ declare const CONTEXT_MEASUREMENT_ROLES: {
|
|
|
1702
1702
|
};
|
|
1703
1703
|
declare function evaluateContextClaimHistory(input: unknown, options: ContextReviewOptions): Promise<ContextReviewResult>;
|
|
1704
1704
|
|
|
1705
|
-
|
|
1705
|
+
interface ResearchReviewOptions {
|
|
1706
|
+
/** Exact UTF-8 document bytes keyed by SHA-256. Nothing is fetched or normalized. */
|
|
1707
|
+
documents: ReadonlyMap<string, Uint8Array>;
|
|
1708
|
+
}
|
|
1709
|
+
interface ResearchReviewResult {
|
|
1710
|
+
success: boolean;
|
|
1711
|
+
issues: ContextIssue[];
|
|
1712
|
+
snapshots: Array<DocumentSnapshotRef & {
|
|
1713
|
+
status: "passed" | "failed" | "unavailable";
|
|
1714
|
+
}>;
|
|
1715
|
+
checks: {
|
|
1716
|
+
structural: "passed" | "failed";
|
|
1717
|
+
semantic: "passed" | "failed" | "not_checked";
|
|
1718
|
+
profile: "not_checked";
|
|
1719
|
+
external: "passed" | "failed" | "not_checked";
|
|
1720
|
+
};
|
|
1721
|
+
currentClaimRefs: string[];
|
|
1722
|
+
integrityScope: "supplied_entities_context_observation_and_acquisition_snapshot_bytes";
|
|
1723
|
+
temporalNormalization: "not_checked";
|
|
1724
|
+
sourceArtifactIntegrity: "not_checked";
|
|
1725
|
+
scientificInterpretation: "not_checked";
|
|
1726
|
+
multiSensorFusion: "not_checked";
|
|
1727
|
+
}
|
|
1728
|
+
declare function evaluateResearchClaimHistory(input: unknown, options: ResearchReviewOptions): Promise<ResearchReviewResult>;
|
|
1729
|
+
|
|
1730
|
+
export { ACQUISITION_BINDINGS_PROFILE, ACQUISITION_BINDINGS_SCHEMA_ID, ASSESSMENT_DOCUMENTATION_PROFILE, type AcquisitionBindingOptions, type AcquisitionBindingResult, type AcquisitionBindings, AcquisitionBindingsSchema, type AssessmentDocumentation, type AssessmentDocumentationCompletion, type AssetCheck, type BindingAssetCheck, type BindingIssue, type BindingIssueCode, CONTEXT_MEASUREMENT_ROLES, type CompletionStatus, type ContextReviewOptions, type ContextReviewResult, DATASET_RELEASE_PROFILE, DATASET_RELEASE_SCHEMA_ID, DOCUMENTATION_COMPLETION_POLICY, DOCUMENTATION_REQUIREMENTS, type DatasetIssue, type DatasetPacketInput, type DatasetRelease, type DatasetReleaseResult, DatasetReleaseSchema, type DocumentationAction, type DocumentationCompletionResult, type DocumentationIssue, type DocumentationIssueCode, type DocumentationOptions, type DocumentationRequirement, type DocumentationRequirementId, type DocumentationResult, HISTORICAL_TESTIMONY_PROFILE, HISTORICAL_TESTIMONY_REQUIREMENTS, HISTORICAL_TESTIMONY_SELECTION_SCHEMA_ID, type HistoricalTestimonyCompletionStatus, type HistoricalTestimonyIssue, type HistoricalTestimonyReport, type HistoricalTestimonyRequirement, type HistoricalTestimonyRequirementId, type HistoricalTestimonyResult, type HistoricalTestimonySelection, HistoricalTestimonySelectionSchema, INSTRUMENT_RESEARCH_COMPLETION_POLICY, INSTRUMENT_RESEARCH_PREREQUISITES_PROFILE, INSTRUMENT_RESEARCH_REQUIREMENTS, INSTRUMENT_RESEARCH_REVIEW_SCHEMA_ID, type InstrumentResearchCompletionResult, type InstrumentResearchOptions, type InstrumentResearchResult, type InstrumentResearchReview, InstrumentResearchReviewSchema, MEASUREMENT_BINDINGS_PROFILE, MEASUREMENT_BINDINGS_SCHEMA_ID, MIGRATION_COMPATIBILITY_SCHEMA_ID, MIGRATION_LEGACY_SCORES_SCHEMA_ID, MIGRATION_RESOLUTION_SCHEMA_ID, MIGRATION_REVIEW_SCHEMA_ID, type MeasurementBindingIssue, type MeasurementBindingResult, type MeasurementBindings, MeasurementBindingsSchema, type MigrationCompatibility, MigrationCompatibilitySchema, type MigrationLegacyScores, MigrationLegacyScoresSchema, type MigrationResolution, MigrationResolutionSchema, type MigrationReview, MigrationReviewSchema, PHYSICAL_SAMPLE_PROFILE, PHYSICAL_SAMPLE_REQUIREMENTS, PHYSICAL_SAMPLE_SELECTION_SCHEMA_ID, PROFILE_EVALUATION_POLICY, PROFILE_EVALUATION_SCHEMA_ID, PROFILE_PREPARATION_SCHEMA_ID, type PhysicalSampleIssue, type PhysicalSampleRecordCheck, type PhysicalSampleReport, type PhysicalSampleRequirement, type PhysicalSampleRequirementId, type PhysicalSampleResult, type PhysicalSampleSelection, PhysicalSampleSelectionSchema, type ProductBindingCheck, type ProfileEvaluation, type ProfileEvaluationOptions, type ProfileEvaluationReceipt, type ProfileEvaluationResult, ProfileEvaluationSchema, type ProfilePreparation, ProfilePreparationSchema, RELEASED_DOCUMENT_PROFILE, RELEASED_DOCUMENT_REQUIREMENTS, RELEASED_DOCUMENT_SELECTION_SCHEMA_ID, REPRODUCTION_PACKET_PROFILE, REPRODUCTION_PACKET_SCHEMA_ID, RESEARCH_EVALUATION_POLICY, RESEARCH_EVALUATION_SCHEMA_ID, type ReleasedDocumentCompletionStatus, type ReleasedDocumentIssue, type ReleasedDocumentReport, type ReleasedDocumentRequirement, type ReleasedDocumentRequirementId, type ReleasedDocumentResult, type ReleasedDocumentSelection, ReleasedDocumentSelectionSchema, type ReproductionFileCheck, type ReproductionPacket, type ReproductionPacketResult, ReproductionPacketSchema, type ResearchCompletionAction, type ResearchCompletionRequirement, type ResearchCompletionStatus, type ResearchEvaluation, type ResearchEvaluationOptions, type ResearchEvaluationOutput, type ResearchEvaluationReceipt, type ResearchEvaluationResult, ResearchEvaluationSchema, type ResearchRequirementId, type ResearchReviewAssetCheck, type ResearchReviewOptions, type ResearchReviewResult, SOURCE_INTAKE_PROFILE, SOURCE_INTAKE_SCHEMA_ID, type SourceIntake, type SourceIntakeResult, SourceIntakeSchema, acquisitionBindingsJsonSchema, datasetReleaseJsonSchema, evaluateAcquisitionBindings, evaluateAssessmentDocumentation, evaluateContextClaimHistory, evaluateDatasetRelease, evaluateDocumentationCompletion, evaluateHistoricalTestimony, evaluateInstrumentResearchCompletion, evaluateInstrumentResearchPrerequisites, evaluateMeasurementBindings, evaluatePhysicalSamples, evaluateProfileEvaluation, evaluateReleasedDocuments, evaluateReproductionPacket, evaluateResearchClaimHistory, evaluateResearchEvaluation, evaluateSourceIntake, historicalTestimonySelectionJsonSchema, instrumentResearchReviewJsonSchema, measurementBindingsJsonSchema, migrationCompatibilityJsonSchema, migrationLegacyScoresJsonSchema, migrationResolutionJsonSchema, migrationReviewJsonSchema, physicalSampleSelectionJsonSchema, profileEvaluationJsonSchema, profilePreparationJsonSchema, releasedDocumentSelectionJsonSchema, reproductionPacketJsonSchema, researchEvaluationJsonSchema, sourceIntakeJsonSchema };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseExperimentalClaimHistory, compareUtcInstants, parseContextClaimHistory, parseObservationContext, parseExperimentalObservation, contextAssertions } from '@disclosureos/records/experimental/v2';
|
|
1
|
+
import { parseExperimentalClaimHistory, compareUtcInstants, parseContextClaimHistory, parseObservationContext, parseExperimentalObservation, parseResearchClaimHistory, parseResearchEntities, researchEntityAssertions, researchEntityContextReferences, contextAssertions } from '@disclosureos/records/experimental/v2';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { parseAcquisitionContext } from '@disclosureos/instruments/experimental/v2';
|
|
4
4
|
|
|
@@ -4929,7 +4929,453 @@ async function evaluateContextClaimHistory(input, options) {
|
|
|
4929
4929
|
multiSensorFusion: "not_checked"
|
|
4930
4930
|
};
|
|
4931
4931
|
}
|
|
4932
|
+
function equal2(a, b) {
|
|
4933
|
+
if (a === b) return true;
|
|
4934
|
+
if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
|
|
4935
|
+
if (Array.isArray(a) || Array.isArray(b))
|
|
4936
|
+
return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((v, i) => equal2(v, b[i]));
|
|
4937
|
+
const x = a, y = b;
|
|
4938
|
+
return Object.keys(x).length === Object.keys(y).length && Object.keys(x).every(
|
|
4939
|
+
(k) => Object.prototype.hasOwnProperty.call(y, k) && equal2(x[k], y[k])
|
|
4940
|
+
);
|
|
4941
|
+
}
|
|
4942
|
+
async function evaluateResearchClaimHistory(input, options) {
|
|
4943
|
+
const history = parseResearchClaimHistory(input);
|
|
4944
|
+
const issues = history.issues.map((i) => ({
|
|
4945
|
+
code: i.code,
|
|
4946
|
+
stage: i.stage,
|
|
4947
|
+
pointer: i.pointer,
|
|
4948
|
+
message: i.message
|
|
4949
|
+
}));
|
|
4950
|
+
const snapshots = [];
|
|
4951
|
+
const contexts = /* @__PURE__ */ new Map();
|
|
4952
|
+
const entityDocuments = /* @__PURE__ */ new Map();
|
|
4953
|
+
const problem = (code, pointer6, message, stage = "semantic") => issues.push({ code, pointer: pointer6, message, stage });
|
|
4954
|
+
async function load(ref5, pointer6) {
|
|
4955
|
+
const supplied = options.documents.get(ref5.sha256);
|
|
4956
|
+
const bytes = supplied ? Uint8Array.from(supplied) : void 0;
|
|
4957
|
+
if (!bytes) {
|
|
4958
|
+
snapshots.push({ ...ref5, status: "unavailable" });
|
|
4959
|
+
problem(
|
|
4960
|
+
"SNAPSHOT.UNAVAILABLE",
|
|
4961
|
+
pointer6,
|
|
4962
|
+
"Required snapshot bytes were not supplied.",
|
|
4963
|
+
"external"
|
|
4964
|
+
);
|
|
4965
|
+
return;
|
|
4966
|
+
}
|
|
4967
|
+
if ([
|
|
4968
|
+
...new Uint8Array(
|
|
4969
|
+
await globalThis.crypto.subtle.digest("SHA-256", bytes)
|
|
4970
|
+
)
|
|
4971
|
+
].map((b) => b.toString(16).padStart(2, "0")).join("") !== ref5.sha256) {
|
|
4972
|
+
snapshots.push({ ...ref5, status: "failed" });
|
|
4973
|
+
problem(
|
|
4974
|
+
"SNAPSHOT.DIGEST",
|
|
4975
|
+
pointer6,
|
|
4976
|
+
"Supplied bytes do not match the reference digest.",
|
|
4977
|
+
"external"
|
|
4978
|
+
);
|
|
4979
|
+
return;
|
|
4980
|
+
}
|
|
4981
|
+
let value;
|
|
4982
|
+
try {
|
|
4983
|
+
value = JSON.parse(
|
|
4984
|
+
new TextDecoder("utf-8", { fatal: true }).decode(bytes)
|
|
4985
|
+
);
|
|
4986
|
+
} catch {
|
|
4987
|
+
snapshots.push({ ...ref5, status: "failed" });
|
|
4988
|
+
problem(
|
|
4989
|
+
"SNAPSHOT.JSON",
|
|
4990
|
+
pointer6,
|
|
4991
|
+
"Snapshot is not a UTF-8 JSON document.",
|
|
4992
|
+
"external"
|
|
4993
|
+
);
|
|
4994
|
+
return;
|
|
4995
|
+
}
|
|
4996
|
+
snapshots.push({ ...ref5, status: "passed" });
|
|
4997
|
+
if (!value || typeof value !== "object" || value.id !== ref5.documentId) {
|
|
4998
|
+
problem(
|
|
4999
|
+
"SNAPSHOT.IDENTITY",
|
|
5000
|
+
pointer6,
|
|
5001
|
+
"Snapshot document ID does not match its reference."
|
|
5002
|
+
);
|
|
5003
|
+
return;
|
|
5004
|
+
}
|
|
5005
|
+
return value;
|
|
5006
|
+
}
|
|
5007
|
+
async function checkContext(context, observation, p) {
|
|
5008
|
+
const sources = new Map([
|
|
5009
|
+
...observation.sources.map((s) => [`source:${s.id}`, s]),
|
|
5010
|
+
...observation.products.map((s) => [`product:${s.id}`, s])
|
|
5011
|
+
]);
|
|
5012
|
+
const methods = new Map(
|
|
5013
|
+
observation.methods.map((m) => [`method:${m.id}`, m])
|
|
5014
|
+
);
|
|
5015
|
+
const measurements = new Map(
|
|
5016
|
+
observation.measurements.map((m) => [m.id, m])
|
|
5017
|
+
);
|
|
5018
|
+
let acquisitionIds;
|
|
5019
|
+
if (context.acquisitionRef) {
|
|
5020
|
+
const value = await load(context.acquisitionRef, `${p}/acquisitionRef`);
|
|
5021
|
+
if (value !== void 0) {
|
|
5022
|
+
const acquisition = parseAcquisitionContext(value);
|
|
5023
|
+
if (!acquisition.success)
|
|
5024
|
+
problem(
|
|
5025
|
+
"CONTEXT.ACQUISITION",
|
|
5026
|
+
`${p}/acquisitionRef`,
|
|
5027
|
+
"Acquisition snapshot does not satisfy its declared contract.",
|
|
5028
|
+
acquisition.checks.structural === "failed" ? "structural" : "semantic"
|
|
5029
|
+
);
|
|
5030
|
+
else
|
|
5031
|
+
acquisitionIds = new Set(
|
|
5032
|
+
acquisition.data.acquisitions.map((a) => a.id)
|
|
5033
|
+
);
|
|
5034
|
+
}
|
|
5035
|
+
}
|
|
5036
|
+
for (const [index, entity] of context.entities.entries()) {
|
|
5037
|
+
const ep = `${p}/entities/${index}`;
|
|
5038
|
+
for (const { field, assertion } of contextAssertions(entity)) {
|
|
5039
|
+
const prov = assertion.content.provenance;
|
|
5040
|
+
if (prov) {
|
|
5041
|
+
const source = sources.get(prov.sourceRef);
|
|
5042
|
+
if (!source)
|
|
5043
|
+
problem(
|
|
5044
|
+
"REF.LOCAL_RESOLUTION",
|
|
5045
|
+
ep,
|
|
5046
|
+
"Context source is absent from the scoped observation."
|
|
5047
|
+
);
|
|
5048
|
+
else if (source.digest && prov.sourceDigest && source.digest.value !== prov.sourceDigest.value)
|
|
5049
|
+
problem(
|
|
5050
|
+
"SOURCE.DIGEST_MISMATCH",
|
|
5051
|
+
ep,
|
|
5052
|
+
"Source digest declarations differ."
|
|
5053
|
+
);
|
|
5054
|
+
}
|
|
5055
|
+
const value = assertion.content.value;
|
|
5056
|
+
if (value === void 0) continue;
|
|
5057
|
+
if (field === "productRefs") {
|
|
5058
|
+
for (const ref5 of value)
|
|
5059
|
+
if (!sources.has(ref5))
|
|
5060
|
+
problem(
|
|
5061
|
+
"REF.LOCAL_RESOLUTION",
|
|
5062
|
+
ep,
|
|
5063
|
+
"Collection artifact is not declared."
|
|
5064
|
+
);
|
|
5065
|
+
}
|
|
5066
|
+
if (field === "acquisitionIds") {
|
|
5067
|
+
for (const id12 of value)
|
|
5068
|
+
if (!acquisitionIds?.has(id12))
|
|
5069
|
+
problem(
|
|
5070
|
+
"REF.ACQUISITION",
|
|
5071
|
+
ep,
|
|
5072
|
+
"Acquisition ID needs a supplied, valid acquisition snapshot."
|
|
5073
|
+
);
|
|
5074
|
+
}
|
|
5075
|
+
if (field === "position") {
|
|
5076
|
+
const checked = parseExperimentalObservation({
|
|
5077
|
+
...observation,
|
|
5078
|
+
position: { state: "known", value, sourceRefs: [prov.sourceRef] }
|
|
5079
|
+
});
|
|
5080
|
+
if (!checked.success)
|
|
5081
|
+
problem(
|
|
5082
|
+
"CONTEXT.POSITION",
|
|
5083
|
+
ep,
|
|
5084
|
+
"Context position must satisfy the observation frame, unit and source-reference rules."
|
|
5085
|
+
);
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
for (const selection of entity.selections ?? []) {
|
|
5089
|
+
if (methods.get(selection.methodRef)?.version !== selection.methodVersion)
|
|
5090
|
+
problem(
|
|
5091
|
+
"METHOD.VERSION_MISMATCH",
|
|
5092
|
+
ep,
|
|
5093
|
+
"Selection method/version must match the observation inventory."
|
|
5094
|
+
);
|
|
5095
|
+
}
|
|
5096
|
+
const proximityLinks = contextAssertions(entity).flatMap(
|
|
5097
|
+
({ field, assertion }) => {
|
|
5098
|
+
if (field !== "proximity" || !assertion.content.value) return [];
|
|
5099
|
+
const value = assertion.content.value;
|
|
5100
|
+
return [
|
|
5101
|
+
...value.distanceMeasurementId ? [
|
|
5102
|
+
{
|
|
5103
|
+
id: assertion.id,
|
|
5104
|
+
role: "distance",
|
|
5105
|
+
measurementId: value.distanceMeasurementId,
|
|
5106
|
+
relatedPlaceId: value.targetPlaceId
|
|
5107
|
+
}
|
|
5108
|
+
] : [],
|
|
5109
|
+
...value.bearingMeasurementId ? [
|
|
5110
|
+
{
|
|
5111
|
+
id: assertion.id,
|
|
5112
|
+
role: "bearing",
|
|
5113
|
+
measurementId: value.bearingMeasurementId,
|
|
5114
|
+
relatedPlaceId: value.targetPlaceId
|
|
5115
|
+
}
|
|
5116
|
+
] : []
|
|
5117
|
+
];
|
|
5118
|
+
}
|
|
5119
|
+
);
|
|
5120
|
+
for (const link of [...entity.measurements ?? [], ...proximityLinks]) {
|
|
5121
|
+
const role = CONTEXT_MEASUREMENT_ROLES[link.role];
|
|
5122
|
+
const measurement = measurements.get(link.measurementId);
|
|
5123
|
+
if (!measurement) {
|
|
5124
|
+
problem(
|
|
5125
|
+
"REF.MEASUREMENT",
|
|
5126
|
+
ep,
|
|
5127
|
+
"Measurement is absent from the scoped observation."
|
|
5128
|
+
);
|
|
5129
|
+
continue;
|
|
5130
|
+
}
|
|
5131
|
+
if (!role.entities.includes(entity.kind) || !role.quantities.includes(
|
|
5132
|
+
measurement.quantity
|
|
5133
|
+
) || !role.units.includes(measurement.value.unit))
|
|
5134
|
+
problem(
|
|
5135
|
+
"CONTEXT.MEASUREMENT_ROLE",
|
|
5136
|
+
ep,
|
|
5137
|
+
"Measurement entity, quantity and unit must match the declared role."
|
|
5138
|
+
);
|
|
5139
|
+
const value = measurement.value.value;
|
|
5140
|
+
if ([
|
|
5141
|
+
"count",
|
|
5142
|
+
"size",
|
|
5143
|
+
"speed",
|
|
5144
|
+
"wind_speed",
|
|
5145
|
+
"duration",
|
|
5146
|
+
"distance",
|
|
5147
|
+
"water_depth",
|
|
5148
|
+
"coordinate_precision",
|
|
5149
|
+
"time_alignment"
|
|
5150
|
+
].includes(link.role) && value < 0)
|
|
5151
|
+
problem(
|
|
5152
|
+
"CONTEXT.MEASUREMENT_RANGE",
|
|
5153
|
+
ep,
|
|
5154
|
+
"This role cannot be negative."
|
|
5155
|
+
);
|
|
5156
|
+
if (link.role === "count" && !Number.isInteger(value))
|
|
5157
|
+
problem("CONTEXT.MEASUREMENT_RANGE", ep, "Count must be an integer.");
|
|
5158
|
+
if (["heading", "bearing"].includes(link.role) && (value < 0 || value > 360))
|
|
5159
|
+
problem(
|
|
5160
|
+
"CONTEXT.MEASUREMENT_RANGE",
|
|
5161
|
+
ep,
|
|
5162
|
+
"Direction must lie between zero and 360 degrees."
|
|
5163
|
+
);
|
|
5164
|
+
if (["relative_humidity", "moon_illumination"].includes(link.role) && (value < 0 || value > (measurement.value.unit === "1" ? 1 : 100)))
|
|
5165
|
+
problem(
|
|
5166
|
+
"CONTEXT.MEASUREMENT_RANGE",
|
|
5167
|
+
ep,
|
|
5168
|
+
"Fraction lies outside its unit range."
|
|
5169
|
+
);
|
|
5170
|
+
if (["distance", "bearing"].includes(link.role) && !link.relatedPlaceId)
|
|
5171
|
+
problem(
|
|
5172
|
+
"CONTEXT.RELATED_PLACE",
|
|
5173
|
+
ep,
|
|
5174
|
+
"Distance and bearing must identify the other place."
|
|
5175
|
+
);
|
|
5176
|
+
}
|
|
5177
|
+
}
|
|
5178
|
+
}
|
|
5179
|
+
if (history.success) {
|
|
5180
|
+
let resolveEntity2 = function(reference, pointer6, assertionId) {
|
|
5181
|
+
const document = entityDocuments.get(reference.document.sha256);
|
|
5182
|
+
if (!document) return;
|
|
5183
|
+
const entity = document.entities.find(
|
|
5184
|
+
(e) => e.kind === reference.target.kind && e.id === reference.target.id
|
|
5185
|
+
);
|
|
5186
|
+
if (!entity) {
|
|
5187
|
+
problem(
|
|
5188
|
+
"REF.ENTITY",
|
|
5189
|
+
pointer6,
|
|
5190
|
+
"Typed entity is absent from the selected snapshot."
|
|
5191
|
+
);
|
|
5192
|
+
return;
|
|
5193
|
+
}
|
|
5194
|
+
const assertions = researchEntityAssertions(entity);
|
|
5195
|
+
if (reference.target.field && !assertions.some((a) => a.field === reference.target.field))
|
|
5196
|
+
problem(
|
|
5197
|
+
"REF.FIELD",
|
|
5198
|
+
pointer6,
|
|
5199
|
+
"Target field has no supplied assertions."
|
|
5200
|
+
);
|
|
5201
|
+
if (assertionId && (!reference.target.field || !assertions.some(
|
|
5202
|
+
(a) => a.field === reference.target.field && a.assertion.id === assertionId
|
|
5203
|
+
)))
|
|
5204
|
+
problem(
|
|
5205
|
+
"REF.ASSERTION",
|
|
5206
|
+
pointer6,
|
|
5207
|
+
"Input must select an existing assertion on its named field."
|
|
5208
|
+
);
|
|
5209
|
+
}, resolve2 = function(reference, pointer6, assertionId) {
|
|
5210
|
+
const context = contexts.get(reference.document.sha256);
|
|
5211
|
+
if (!context) return;
|
|
5212
|
+
const entity = context.entities.find(
|
|
5213
|
+
(e) => e.kind === reference.target.kind && e.id === reference.target.id
|
|
5214
|
+
);
|
|
5215
|
+
if (!entity) {
|
|
5216
|
+
problem(
|
|
5217
|
+
"REF.ENTITY",
|
|
5218
|
+
pointer6,
|
|
5219
|
+
"Typed entity is absent from the selected snapshot."
|
|
5220
|
+
);
|
|
5221
|
+
return;
|
|
5222
|
+
}
|
|
5223
|
+
const assertions = contextAssertions(entity);
|
|
5224
|
+
if (reference.target.field && !assertions.some((a) => a.field === reference.target.field))
|
|
5225
|
+
problem(
|
|
5226
|
+
"REF.FIELD",
|
|
5227
|
+
pointer6,
|
|
5228
|
+
"Target field has no supplied assertions."
|
|
5229
|
+
);
|
|
5230
|
+
if (assertionId && (!reference.target.field || !assertions.some(
|
|
5231
|
+
(a) => a.field === reference.target.field && a.assertion.id === assertionId
|
|
5232
|
+
)))
|
|
5233
|
+
problem(
|
|
5234
|
+
"REF.ASSERTION",
|
|
5235
|
+
pointer6,
|
|
5236
|
+
"Assessment input must select an existing assertion on its named field."
|
|
5237
|
+
);
|
|
5238
|
+
};
|
|
5239
|
+
for (const [i, ref5] of history.data.contextRefs.entries()) {
|
|
5240
|
+
const p = `/contextRefs/${i}`;
|
|
5241
|
+
const value = await load(ref5, p);
|
|
5242
|
+
if (value === void 0) continue;
|
|
5243
|
+
const parsed = parseObservationContext(value);
|
|
5244
|
+
if (!parsed.success) {
|
|
5245
|
+
issues.push(
|
|
5246
|
+
...parsed.issues.map((i2) => ({ ...i2, pointer: p + i2.pointer }))
|
|
5247
|
+
);
|
|
5248
|
+
continue;
|
|
5249
|
+
}
|
|
5250
|
+
const context = parsed.data;
|
|
5251
|
+
const observationBytes = await load(
|
|
5252
|
+
context.observationRef,
|
|
5253
|
+
`${p}/observationRef`
|
|
5254
|
+
);
|
|
5255
|
+
if (observationBytes === void 0) continue;
|
|
5256
|
+
const observation = parseExperimentalObservation(observationBytes);
|
|
5257
|
+
if (!observation.success || !equal2(observationBytes, history.data.observation)) {
|
|
5258
|
+
problem(
|
|
5259
|
+
"CONTEXT.OBSERVATION_SCOPE",
|
|
5260
|
+
p,
|
|
5261
|
+
"Context must select the same complete observation snapshot as the history.",
|
|
5262
|
+
observation.checks.structural === "failed" ? "structural" : "semantic"
|
|
5263
|
+
);
|
|
5264
|
+
continue;
|
|
5265
|
+
}
|
|
5266
|
+
await checkContext(context, observation.data, p);
|
|
5267
|
+
contexts.set(ref5.sha256, context);
|
|
5268
|
+
}
|
|
5269
|
+
for (const [i, ref5] of history.data.entityRefs.entries()) {
|
|
5270
|
+
const p = `/entityRefs/${i}`;
|
|
5271
|
+
const value = await load(ref5, p);
|
|
5272
|
+
if (value === void 0) continue;
|
|
5273
|
+
const parsed = parseResearchEntities(value);
|
|
5274
|
+
if (!parsed.success) {
|
|
5275
|
+
issues.push(
|
|
5276
|
+
...parsed.issues.map((i2) => ({ ...i2, pointer: p + i2.pointer }))
|
|
5277
|
+
);
|
|
5278
|
+
continue;
|
|
5279
|
+
}
|
|
5280
|
+
const entities = parsed.data;
|
|
5281
|
+
const raw = await load(entities.observationRef, `${p}/observationRef`);
|
|
5282
|
+
if (raw === void 0) continue;
|
|
5283
|
+
const observation = parseExperimentalObservation(raw);
|
|
5284
|
+
if (!observation.success || !equal2(raw, history.data.observation)) {
|
|
5285
|
+
problem(
|
|
5286
|
+
"ENTITIES.OBSERVATION_SCOPE",
|
|
5287
|
+
p,
|
|
5288
|
+
"Research entities must select the same complete observation snapshot as the history."
|
|
5289
|
+
);
|
|
5290
|
+
continue;
|
|
5291
|
+
}
|
|
5292
|
+
const contextSnapshots = new Set(
|
|
5293
|
+
history.data.contextRefs.map((r) => JSON.stringify(r))
|
|
5294
|
+
);
|
|
5295
|
+
for (const r of entities.contextRefs)
|
|
5296
|
+
if (!contextSnapshots.has(JSON.stringify(r)))
|
|
5297
|
+
problem(
|
|
5298
|
+
"REF.LOCAL_RESOLUTION",
|
|
5299
|
+
p,
|
|
5300
|
+
"Entity context dependency must be declared in the history and checked."
|
|
5301
|
+
);
|
|
5302
|
+
const sources = new Map([
|
|
5303
|
+
...observation.data.sources.map((x) => [`source:${x.id}`, x]),
|
|
5304
|
+
...observation.data.products.map(
|
|
5305
|
+
(x) => [`product:${x.id}`, x]
|
|
5306
|
+
)
|
|
5307
|
+
]);
|
|
5308
|
+
for (const [j, entity] of entities.entities.entries()) {
|
|
5309
|
+
const ep = `${p}/entities/${j}`;
|
|
5310
|
+
for (const { field, assertion } of researchEntityAssertions(entity)) {
|
|
5311
|
+
const prov = assertion.content.provenance;
|
|
5312
|
+
if (prov) {
|
|
5313
|
+
const source = sources.get(prov.sourceRef);
|
|
5314
|
+
if (!source)
|
|
5315
|
+
problem(
|
|
5316
|
+
"REF.LOCAL_RESOLUTION",
|
|
5317
|
+
ep,
|
|
5318
|
+
"Entity source is absent from the scoped observation."
|
|
5319
|
+
);
|
|
5320
|
+
else if (source.digest && prov.sourceDigest && source.digest.value !== prov.sourceDigest.value)
|
|
5321
|
+
problem(
|
|
5322
|
+
"SOURCE.DIGEST_MISMATCH",
|
|
5323
|
+
ep,
|
|
5324
|
+
"Source digest declarations differ."
|
|
5325
|
+
);
|
|
5326
|
+
}
|
|
5327
|
+
const value2 = assertion.content.value;
|
|
5328
|
+
const refs = field === "sourceDocument" && typeof value2 === "string" ? [value2] : field === "supportRefs" && Array.isArray(value2) ? value2 : [];
|
|
5329
|
+
for (const r of refs)
|
|
5330
|
+
if (!sources.has(r))
|
|
5331
|
+
problem(
|
|
5332
|
+
"REF.LOCAL_RESOLUTION",
|
|
5333
|
+
ep,
|
|
5334
|
+
"Account or procedure artifact is not declared in the observation."
|
|
5335
|
+
);
|
|
5336
|
+
}
|
|
5337
|
+
for (const reference of researchEntityContextReferences(entity))
|
|
5338
|
+
resolve2(reference, ep);
|
|
5339
|
+
}
|
|
5340
|
+
entityDocuments.set(ref5.sha256, entities);
|
|
5341
|
+
}
|
|
5342
|
+
for (const [i, claim] of history.data.claims.entries()) {
|
|
5343
|
+
if (claim.subject.kind === "entity")
|
|
5344
|
+
resolveEntity2(claim.subject.reference, `/claims/${i}/subject`);
|
|
5345
|
+
if (claim.kind === "assessment")
|
|
5346
|
+
for (const [j, ref5] of (claim.entityInputRefs ?? []).entries())
|
|
5347
|
+
resolveEntity2(
|
|
5348
|
+
ref5,
|
|
5349
|
+
`/claims/${i}/entityInputRefs/${j}`,
|
|
5350
|
+
ref5.assertionId
|
|
5351
|
+
);
|
|
5352
|
+
if (claim.subject.kind === "context")
|
|
5353
|
+
resolve2(claim.subject.reference, `/claims/${i}/subject`);
|
|
5354
|
+
if (claim.kind === "assessment")
|
|
5355
|
+
for (const [j, ref5] of (claim.contextInputRefs ?? []).entries())
|
|
5356
|
+
resolve2(ref5, `/claims/${i}/contextInputRefs/${j}`, ref5.assertionId);
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
5359
|
+
const external = snapshots.some((s) => s.status === "failed") ? "failed" : snapshots.some((s) => s.status === "unavailable") || !snapshots.length ? "not_checked" : "passed";
|
|
5360
|
+
return {
|
|
5361
|
+
success: history.success && issues.length === 0,
|
|
5362
|
+
issues,
|
|
5363
|
+
snapshots,
|
|
5364
|
+
checks: {
|
|
5365
|
+
structural: issues.some((i) => i.stage === "structural") ? "failed" : history.checks.structural,
|
|
5366
|
+
semantic: history.checks.structural === "failed" || issues.some((i) => i.stage === "structural") ? "not_checked" : issues.some((i) => i.stage !== "external") ? "failed" : issues.length ? "not_checked" : "passed",
|
|
5367
|
+
profile: "not_checked",
|
|
5368
|
+
external
|
|
5369
|
+
},
|
|
5370
|
+
currentClaimRefs: history.success && issues.length === 0 ? history.currentClaimRefs : [],
|
|
5371
|
+
integrityScope: "supplied_entities_context_observation_and_acquisition_snapshot_bytes",
|
|
5372
|
+
temporalNormalization: "not_checked",
|
|
5373
|
+
sourceArtifactIntegrity: "not_checked",
|
|
5374
|
+
scientificInterpretation: "not_checked",
|
|
5375
|
+
multiSensorFusion: "not_checked"
|
|
5376
|
+
};
|
|
5377
|
+
}
|
|
4932
5378
|
|
|
4933
|
-
export { ACQUISITION_BINDINGS_PROFILE, ACQUISITION_BINDINGS_SCHEMA_ID, ASSESSMENT_DOCUMENTATION_PROFILE, AcquisitionBindingsSchema, CONTEXT_MEASUREMENT_ROLES, DATASET_RELEASE_PROFILE, DATASET_RELEASE_SCHEMA_ID, DOCUMENTATION_COMPLETION_POLICY, DOCUMENTATION_REQUIREMENTS, DatasetReleaseSchema, HISTORICAL_TESTIMONY_PROFILE, HISTORICAL_TESTIMONY_REQUIREMENTS, HISTORICAL_TESTIMONY_SELECTION_SCHEMA_ID, HistoricalTestimonySelectionSchema, INSTRUMENT_RESEARCH_COMPLETION_POLICY, INSTRUMENT_RESEARCH_PREREQUISITES_PROFILE, INSTRUMENT_RESEARCH_REQUIREMENTS, INSTRUMENT_RESEARCH_REVIEW_SCHEMA_ID, InstrumentResearchReviewSchema, MEASUREMENT_BINDINGS_PROFILE, MEASUREMENT_BINDINGS_SCHEMA_ID, MIGRATION_COMPATIBILITY_SCHEMA_ID, MIGRATION_LEGACY_SCORES_SCHEMA_ID, MIGRATION_RESOLUTION_SCHEMA_ID, MIGRATION_REVIEW_SCHEMA_ID, MeasurementBindingsSchema, MigrationCompatibilitySchema, MigrationLegacyScoresSchema, MigrationResolutionSchema, MigrationReviewSchema, PHYSICAL_SAMPLE_PROFILE, PHYSICAL_SAMPLE_REQUIREMENTS, PHYSICAL_SAMPLE_SELECTION_SCHEMA_ID, PROFILE_EVALUATION_POLICY, PROFILE_EVALUATION_SCHEMA_ID, PROFILE_PREPARATION_SCHEMA_ID, PhysicalSampleSelectionSchema, ProfileEvaluationSchema, ProfilePreparationSchema, RELEASED_DOCUMENT_PROFILE, RELEASED_DOCUMENT_REQUIREMENTS, RELEASED_DOCUMENT_SELECTION_SCHEMA_ID, REPRODUCTION_PACKET_PROFILE, REPRODUCTION_PACKET_SCHEMA_ID, RESEARCH_EVALUATION_POLICY, RESEARCH_EVALUATION_SCHEMA_ID, ReleasedDocumentSelectionSchema, ReproductionPacketSchema, ResearchEvaluationSchema, SOURCE_INTAKE_PROFILE, SOURCE_INTAKE_SCHEMA_ID, SourceIntakeSchema, acquisitionBindingsJsonSchema, datasetReleaseJsonSchema, evaluateAcquisitionBindings, evaluateAssessmentDocumentation, evaluateContextClaimHistory, evaluateDatasetRelease, evaluateDocumentationCompletion, evaluateHistoricalTestimony, evaluateInstrumentResearchCompletion, evaluateInstrumentResearchPrerequisites, evaluateMeasurementBindings, evaluatePhysicalSamples, evaluateProfileEvaluation, evaluateReleasedDocuments, evaluateReproductionPacket, evaluateResearchEvaluation, evaluateSourceIntake, historicalTestimonySelectionJsonSchema, instrumentResearchReviewJsonSchema, measurementBindingsJsonSchema, migrationCompatibilityJsonSchema, migrationLegacyScoresJsonSchema, migrationResolutionJsonSchema, migrationReviewJsonSchema, physicalSampleSelectionJsonSchema, profileEvaluationJsonSchema, profilePreparationJsonSchema, releasedDocumentSelectionJsonSchema, reproductionPacketJsonSchema, researchEvaluationJsonSchema, sourceIntakeJsonSchema };
|
|
5379
|
+
export { ACQUISITION_BINDINGS_PROFILE, ACQUISITION_BINDINGS_SCHEMA_ID, ASSESSMENT_DOCUMENTATION_PROFILE, AcquisitionBindingsSchema, CONTEXT_MEASUREMENT_ROLES, DATASET_RELEASE_PROFILE, DATASET_RELEASE_SCHEMA_ID, DOCUMENTATION_COMPLETION_POLICY, DOCUMENTATION_REQUIREMENTS, DatasetReleaseSchema, HISTORICAL_TESTIMONY_PROFILE, HISTORICAL_TESTIMONY_REQUIREMENTS, HISTORICAL_TESTIMONY_SELECTION_SCHEMA_ID, HistoricalTestimonySelectionSchema, INSTRUMENT_RESEARCH_COMPLETION_POLICY, INSTRUMENT_RESEARCH_PREREQUISITES_PROFILE, INSTRUMENT_RESEARCH_REQUIREMENTS, INSTRUMENT_RESEARCH_REVIEW_SCHEMA_ID, InstrumentResearchReviewSchema, MEASUREMENT_BINDINGS_PROFILE, MEASUREMENT_BINDINGS_SCHEMA_ID, MIGRATION_COMPATIBILITY_SCHEMA_ID, MIGRATION_LEGACY_SCORES_SCHEMA_ID, MIGRATION_RESOLUTION_SCHEMA_ID, MIGRATION_REVIEW_SCHEMA_ID, MeasurementBindingsSchema, MigrationCompatibilitySchema, MigrationLegacyScoresSchema, MigrationResolutionSchema, MigrationReviewSchema, PHYSICAL_SAMPLE_PROFILE, PHYSICAL_SAMPLE_REQUIREMENTS, PHYSICAL_SAMPLE_SELECTION_SCHEMA_ID, PROFILE_EVALUATION_POLICY, PROFILE_EVALUATION_SCHEMA_ID, PROFILE_PREPARATION_SCHEMA_ID, PhysicalSampleSelectionSchema, ProfileEvaluationSchema, ProfilePreparationSchema, RELEASED_DOCUMENT_PROFILE, RELEASED_DOCUMENT_REQUIREMENTS, RELEASED_DOCUMENT_SELECTION_SCHEMA_ID, REPRODUCTION_PACKET_PROFILE, REPRODUCTION_PACKET_SCHEMA_ID, RESEARCH_EVALUATION_POLICY, RESEARCH_EVALUATION_SCHEMA_ID, ReleasedDocumentSelectionSchema, ReproductionPacketSchema, ResearchEvaluationSchema, SOURCE_INTAKE_PROFILE, SOURCE_INTAKE_SCHEMA_ID, SourceIntakeSchema, acquisitionBindingsJsonSchema, datasetReleaseJsonSchema, evaluateAcquisitionBindings, evaluateAssessmentDocumentation, evaluateContextClaimHistory, evaluateDatasetRelease, evaluateDocumentationCompletion, evaluateHistoricalTestimony, evaluateInstrumentResearchCompletion, evaluateInstrumentResearchPrerequisites, evaluateMeasurementBindings, evaluatePhysicalSamples, evaluateProfileEvaluation, evaluateReleasedDocuments, evaluateReproductionPacket, evaluateResearchClaimHistory, evaluateResearchEvaluation, evaluateSourceIntake, historicalTestimonySelectionJsonSchema, instrumentResearchReviewJsonSchema, measurementBindingsJsonSchema, migrationCompatibilityJsonSchema, migrationLegacyScoresJsonSchema, migrationResolutionJsonSchema, migrationReviewJsonSchema, physicalSampleSelectionJsonSchema, profileEvaluationJsonSchema, profilePreparationJsonSchema, releasedDocumentSelectionJsonSchema, reproductionPacketJsonSchema, researchEvaluationJsonSchema, sourceIntakeJsonSchema };
|
|
4934
5380
|
//# sourceMappingURL=index.js.map
|
|
4935
5381
|
//# sourceMappingURL=index.js.map
|