@disclosureos/schema 2.0.0-beta.1 → 2.0.0-beta.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/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.0.0-beta.3
4
+
5
+ ### Minor Changes
6
+
7
+ - 4f80b20: Add research-entities 0.2.0 and claim-history 0.4.0 with exact document editions, digital artifact custody, scoped identifiers and attributable artifact reviews. Validate supplied snapshot references and edition-specific citations without inferring source authenticity or complete custody. Keep existing contract schemas and explicit entry points unchanged.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [4f80b20]
12
+ - @disclosureos/records@2.0.0-beta.3
13
+ - @disclosureos/instruments@2.0.0-beta.3
14
+ - @disclosureos/observables@2.0.0-beta.3
15
+ - @disclosureos/origins@2.0.0-beta.3
16
+
17
+ ## 2.0.0-beta.2
18
+
19
+ ### Minor Changes
20
+
21
+ - 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.
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [25d01be]
26
+ - @disclosureos/records@2.0.0-beta.2
27
+ - @disclosureos/instruments@2.0.0-beta.2
28
+ - @disclosureos/observables@2.0.0-beta.2
29
+ - @disclosureos/origins@2.0.0-beta.2
30
+
3
31
  ## 2.0.0-beta.1
4
32
 
5
33
  ### Minor Changes
package/README.md CHANGED
@@ -187,3 +187,26 @@ 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
193
+
194
+ The source tree adds public witness/account/procedure declarations, entity-addressed
195
+ claim history 0.3.0 and supplied-snapshot review, published in 2.0.0-beta.2.
196
+ 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.
199
+
200
+ ## Document editions and digital custody: C2b candidate
201
+
202
+ The source tree adds research-entities 0.2.0 and claim-history 0.4.0 with exact
203
+ edition citations, digital custody actions, scoped identifiers and attributable
204
+ artifact reviews. These additions are not in published 2.0.0-beta.2. Existing
205
+ contract schemas and versioned entry points remain unchanged.
206
+
207
+ Use `parseArchivalEntities` / `parseArchivalClaimHistory` from records and
208
+ `evaluateArchivalClaimHistory` from schema through their `/experimental/v2`
209
+ entries. A successful supplied-document check does not authenticate source
210
+ artifacts, complete custody or certify a scientific profile.
211
+ See the [contract guide](../../docs/c2/archival.md) and
212
+ [worked example](../../examples/v2/archival-editions-demo/README.md).
@@ -1702,4 +1702,35 @@ declare const CONTEXT_MEASUREMENT_ROLES: {
1702
1702
  };
1703
1703
  declare function evaluateContextClaimHistory(input: unknown, options: ContextReviewOptions): Promise<ContextReviewResult>;
1704
1704
 
1705
- 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, 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, evaluateResearchEvaluation, evaluateSourceIntake, historicalTestimonySelectionJsonSchema, instrumentResearchReviewJsonSchema, measurementBindingsJsonSchema, migrationCompatibilityJsonSchema, migrationLegacyScoresJsonSchema, migrationResolutionJsonSchema, migrationReviewJsonSchema, physicalSampleSelectionJsonSchema, profileEvaluationJsonSchema, profilePreparationJsonSchema, releasedDocumentSelectionJsonSchema, reproductionPacketJsonSchema, researchEvaluationJsonSchema, sourceIntakeJsonSchema };
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
+
1729
+ declare function evaluateResearchClaimHistory(input: unknown, options: ResearchReviewOptions): Promise<ResearchReviewResult>;
1730
+
1731
+ type ArchivalReviewOptions = ResearchReviewOptions;
1732
+ type ArchivalReviewResult = ResearchReviewResult;
1733
+ /** Checks 0.4 histories and exact 0.2 entity snapshots; never fetches source files or authenticates them. */
1734
+ declare function evaluateArchivalClaimHistory(input: unknown, options: ArchivalReviewOptions): Promise<ArchivalReviewResult>;
1735
+
1736
+ export { ACQUISITION_BINDINGS_PROFILE, ACQUISITION_BINDINGS_SCHEMA_ID, ASSESSMENT_DOCUMENTATION_PROFILE, type AcquisitionBindingOptions, type AcquisitionBindingResult, type AcquisitionBindings, AcquisitionBindingsSchema, type ArchivalReviewOptions, type ArchivalReviewResult, 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, evaluateArchivalClaimHistory, 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, contextAssertions, parseArchivalClaimHistory, parseResearchClaimHistory, parseArchivalEntities, parseResearchEntities, researchEntityAssertions, archivalArtifactReferences, researchEntityContextReferences } 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,523 @@ 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 evaluateEntityHistory(input, options, archival) {
4943
+ const history = archival ? parseArchivalClaimHistory(input) : 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
+ }, resolveCitation2 = function(citation, pointer6) {
5239
+ const document = entityDocuments.get(citation.document.sha256);
5240
+ if (!document) return;
5241
+ const edition = document.entities.find(
5242
+ (e) => e.kind === "source_edition" && e.id === citation.editionId
5243
+ );
5244
+ if (!edition || edition.kind !== "source_edition") {
5245
+ problem(
5246
+ "REF.ENTITY",
5247
+ pointer6,
5248
+ "Citation edition is absent from the selected entity snapshot."
5249
+ );
5250
+ return;
5251
+ }
5252
+ if (edition.artifact.sourceRef !== citation.artifact.sourceRef || edition.artifact.digest.value !== citation.artifact.digest.value)
5253
+ problem(
5254
+ "ARCHIVE.CITATION_SCOPE",
5255
+ pointer6,
5256
+ "Citation artifact differs from the selected edition, even if titles or page numbers match."
5257
+ );
5258
+ const pages = edition.fields.pageCount;
5259
+ if (citation.locator.kind === "page" && pages?.length === 1 && pages[0].content.state === "known" && citation.locator.page > pages[0].content.value)
5260
+ problem(
5261
+ "ARCHIVE.PAGE_BOUNDS",
5262
+ pointer6,
5263
+ "Citation exceeds the edition's explicitly declared page count."
5264
+ );
5265
+ };
5266
+ for (const [i, ref5] of history.data.contextRefs.entries()) {
5267
+ const p = `/contextRefs/${i}`;
5268
+ const value = await load(ref5, p);
5269
+ if (value === void 0) continue;
5270
+ const parsed = parseObservationContext(value);
5271
+ if (!parsed.success) {
5272
+ issues.push(
5273
+ ...parsed.issues.map((i2) => ({ ...i2, pointer: p + i2.pointer }))
5274
+ );
5275
+ continue;
5276
+ }
5277
+ const context = parsed.data;
5278
+ const observationBytes = await load(
5279
+ context.observationRef,
5280
+ `${p}/observationRef`
5281
+ );
5282
+ if (observationBytes === void 0) continue;
5283
+ const observation = parseExperimentalObservation(observationBytes);
5284
+ if (!observation.success || !equal2(observationBytes, history.data.observation)) {
5285
+ problem(
5286
+ "CONTEXT.OBSERVATION_SCOPE",
5287
+ p,
5288
+ "Context must select the same complete observation snapshot as the history.",
5289
+ observation.checks.structural === "failed" ? "structural" : "semantic"
5290
+ );
5291
+ continue;
5292
+ }
5293
+ await checkContext(context, observation.data, p);
5294
+ contexts.set(ref5.sha256, context);
5295
+ }
5296
+ for (const [i, ref5] of history.data.entityRefs.entries()) {
5297
+ const p = `/entityRefs/${i}`;
5298
+ const value = await load(ref5, p);
5299
+ if (value === void 0) continue;
5300
+ const parsed = archival ? parseArchivalEntities(value) : parseResearchEntities(value);
5301
+ if (!parsed.success) {
5302
+ issues.push(
5303
+ ...parsed.issues.map((i2) => ({ ...i2, pointer: p + i2.pointer }))
5304
+ );
5305
+ continue;
5306
+ }
5307
+ const entities = parsed.data;
5308
+ const raw = await load(entities.observationRef, `${p}/observationRef`);
5309
+ if (raw === void 0) continue;
5310
+ const observation = parseExperimentalObservation(raw);
5311
+ if (!observation.success || !equal2(raw, history.data.observation)) {
5312
+ problem(
5313
+ "ENTITIES.OBSERVATION_SCOPE",
5314
+ p,
5315
+ "Research entities must select the same complete observation snapshot as the history."
5316
+ );
5317
+ continue;
5318
+ }
5319
+ const contextSnapshots = new Set(
5320
+ history.data.contextRefs.map((r) => JSON.stringify(r))
5321
+ );
5322
+ for (const r of entities.contextRefs)
5323
+ if (!contextSnapshots.has(JSON.stringify(r)))
5324
+ problem(
5325
+ "REF.LOCAL_RESOLUTION",
5326
+ p,
5327
+ "Entity context dependency must be declared in the history and checked."
5328
+ );
5329
+ const sources = new Map([
5330
+ ...observation.data.sources.map((x) => [`source:${x.id}`, x]),
5331
+ ...observation.data.products.map(
5332
+ (x) => [`product:${x.id}`, x]
5333
+ )
5334
+ ]);
5335
+ for (const [j, entity] of entities.entities.entries()) {
5336
+ const ep = `${p}/entities/${j}`;
5337
+ for (const { field, assertion } of researchEntityAssertions(entity)) {
5338
+ const prov = assertion.content.provenance;
5339
+ if (prov) {
5340
+ const source = sources.get(prov.sourceRef);
5341
+ if (!source)
5342
+ problem(
5343
+ "REF.LOCAL_RESOLUTION",
5344
+ ep,
5345
+ "Entity source is absent from the scoped observation."
5346
+ );
5347
+ else if (source.digest && prov.sourceDigest && source.digest.value !== prov.sourceDigest.value)
5348
+ problem(
5349
+ "SOURCE.DIGEST_MISMATCH",
5350
+ ep,
5351
+ "Source digest declarations differ."
5352
+ );
5353
+ }
5354
+ const value2 = assertion.content.value;
5355
+ const refs = field === "sourceDocument" && typeof value2 === "string" ? [value2] : field === "supportRefs" && Array.isArray(value2) ? value2 : [];
5356
+ for (const r of refs)
5357
+ if (!sources.has(r))
5358
+ problem(
5359
+ "REF.LOCAL_RESOLUTION",
5360
+ ep,
5361
+ "Account or procedure artifact is not declared in the observation."
5362
+ );
5363
+ }
5364
+ if (archival) {
5365
+ for (const ref6 of archivalArtifactReferences(entity)) {
5366
+ const source = sources.get(ref6.sourceRef);
5367
+ if (!source?.digest || source.digest.value !== ref6.digest.value)
5368
+ problem(
5369
+ "ARCHIVE.ARTIFACT_IDENTITY",
5370
+ ep,
5371
+ "Archival artifact must name the same SHA-256 declaration as the scoped observation inventory."
5372
+ );
5373
+ }
5374
+ if (entity.kind === "digital_artifact") {
5375
+ for (const assertion of entity.fields.declaredHashes ?? [])
5376
+ if ("value" in assertion.content) {
5377
+ for (const declaration2 of assertion.content.value)
5378
+ if (declaration2.hash.algorithm === "sha256" && declaration2.appliesTo.kind === "artifact" && declaration2.hash.value.toLowerCase() !== declaration2.appliesTo.reference.digest.value)
5379
+ problem(
5380
+ "ARCHIVE.HASH_DECLARATION",
5381
+ ep,
5382
+ "Declared SHA-256 differs from the selected artifact identity. No original-file or legacy hash verification is implied."
5383
+ );
5384
+ }
5385
+ }
5386
+ }
5387
+ for (const reference of researchEntityContextReferences(entity))
5388
+ resolve2(reference, ep);
5389
+ }
5390
+ entityDocuments.set(ref5.sha256, entities);
5391
+ }
5392
+ for (const [i, claim] of history.data.claims.entries()) {
5393
+ if (archival) {
5394
+ if ("editionCitation" in claim && claim.editionCitation)
5395
+ resolveCitation2(
5396
+ claim.editionCitation,
5397
+ `/claims/${i}/editionCitation`
5398
+ );
5399
+ if ("editionInputRefs" in claim)
5400
+ for (const [j, citation] of (claim.editionInputRefs ?? []).entries())
5401
+ resolveCitation2(citation, `/claims/${i}/editionInputRefs/${j}`);
5402
+ }
5403
+ if (claim.subject.kind === "entity")
5404
+ resolveEntity2(claim.subject.reference, `/claims/${i}/subject`);
5405
+ if (claim.kind === "assessment")
5406
+ for (const [j, ref5] of (claim.entityInputRefs ?? []).entries())
5407
+ resolveEntity2(
5408
+ ref5,
5409
+ `/claims/${i}/entityInputRefs/${j}`,
5410
+ ref5.assertionId
5411
+ );
5412
+ if (claim.subject.kind === "context")
5413
+ resolve2(claim.subject.reference, `/claims/${i}/subject`);
5414
+ if (claim.kind === "assessment")
5415
+ for (const [j, ref5] of (claim.contextInputRefs ?? []).entries())
5416
+ resolve2(ref5, `/claims/${i}/contextInputRefs/${j}`, ref5.assertionId);
5417
+ }
5418
+ }
5419
+ const external = snapshots.some((s) => s.status === "failed") ? "failed" : snapshots.some((s) => s.status === "unavailable") || !snapshots.length ? "not_checked" : "passed";
5420
+ return {
5421
+ success: history.success && issues.length === 0,
5422
+ issues,
5423
+ snapshots,
5424
+ checks: {
5425
+ structural: issues.some((i) => i.stage === "structural") ? "failed" : history.checks.structural,
5426
+ 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",
5427
+ profile: "not_checked",
5428
+ external
5429
+ },
5430
+ currentClaimRefs: history.success && issues.length === 0 ? history.currentClaimRefs : [],
5431
+ integrityScope: "supplied_entities_context_observation_and_acquisition_snapshot_bytes",
5432
+ temporalNormalization: "not_checked",
5433
+ sourceArtifactIntegrity: "not_checked",
5434
+ scientificInterpretation: "not_checked",
5435
+ multiSensorFusion: "not_checked"
5436
+ };
5437
+ }
5438
+
5439
+ // src/experimental/v2/research-entities-review.ts
5440
+ async function evaluateResearchClaimHistory(input, options) {
5441
+ return evaluateEntityHistory(input, options, false);
5442
+ }
5443
+
5444
+ // src/experimental/v2/archival-review.ts
5445
+ async function evaluateArchivalClaimHistory(input, options) {
5446
+ return evaluateEntityHistory(input, options, true);
5447
+ }
4932
5448
 
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 };
5449
+ 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, evaluateArchivalClaimHistory, 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
5450
  //# sourceMappingURL=index.js.map
4935
5451
  //# sourceMappingURL=index.js.map