@kontourai/survey 1.6.1 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/index.d.ts +1 -1
- package/dist/src/raw-source.d.ts +2 -1
- package/dist/src/raw-source.js +1 -0
- package/dist/src/to-surface.js +32 -1
- package/dist/src/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { CandidateSetStatus, Candidate, CandidateSet, ClaimTarget, EscalationDimension, EscalationRecord, Extraction, Interpretation, LocatorScheme, RawSource, RawSourceKind, ReviewAuthorizing, ReviewAuthorizingAuthorizedAction, ReviewAuthorizingExchange, ReviewAuthorizingExplicitStatement, ReviewAuthorizingKind, ReviewOutcome, ReviewStatus, SurveyInput, } from "./types.js";
|
|
1
|
+
export type { CandidateSetStatus, Candidate, CandidateSet, ClaimTarget, EscalationDimension, EscalationRecord, Extraction, Interpretation, LocatorScheme, ProvenanceResolution, RawSource, RawSourceKind, ReviewAuthorizing, ReviewAuthorizingAuthorizedAction, ReviewAuthorizingExchange, ReviewAuthorizingExplicitStatement, ReviewAuthorizingKind, ReviewOutcome, ReviewStatus, SurveyInput, } from "./types.js";
|
|
2
2
|
export { SURVEY_INPUT_CONTRACT_VERSION } from "./types.js";
|
|
3
3
|
export { reviewResourceApiVersion } from "./review-resource.js";
|
|
4
4
|
export type { CandidateRole, ClaimTargetHint, ProducerPolicy, ExtractionReference, ResourceEnvelope, ResourceMetadata, ReviewActor, ReviewCandidate, ReviewDecision, ReviewDecisionMode, ReviewDecisionSpec, ReviewDecisionStatus, ReviewItem, ReviewItemSpec, ReviewItemStatus, ReviewLocator, ReviewResource, ReviewResourceApiVersion, ReviewResourceKind, ReviewSession, ReviewSessionEvent, ReviewSessionEventSpec, ReviewSessionEventStatus, ReviewSessionEventType, ReviewSessionSpec, ReviewSessionStatus, SourceReference, SurveyRecordProjectionHint, } from "./review-resource.js";
|
package/dist/src/raw-source.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LocatorScheme, RawSource } from "./types.js";
|
|
1
|
+
import type { LocatorScheme, ProvenanceResolution, RawSource } from "./types.js";
|
|
2
2
|
export type ChecksumInput = string | {
|
|
3
3
|
algorithm?: string;
|
|
4
4
|
value: string;
|
|
@@ -7,6 +7,7 @@ export interface RawSourceInput {
|
|
|
7
7
|
id?: string;
|
|
8
8
|
sourceRef: string;
|
|
9
9
|
observedAt: string;
|
|
10
|
+
resolution?: ProvenanceResolution;
|
|
10
11
|
fetchedAt?: string;
|
|
11
12
|
checksum?: ChecksumInput;
|
|
12
13
|
locatorScheme: LocatorScheme;
|
package/dist/src/raw-source.js
CHANGED
package/dist/src/to-surface.js
CHANGED
|
@@ -66,7 +66,7 @@ export function buildSurveyTrustBundle(input, options = {}) {
|
|
|
66
66
|
evidence.push({
|
|
67
67
|
id: evidenceId,
|
|
68
68
|
claimId: projection.id,
|
|
69
|
-
evidenceType: projection.evidenceType ?? evidenceTypeFor(rawSource),
|
|
69
|
+
evidenceType: projection.evidenceType ?? (rawSource.resolution ? evidenceTypeForResolution(rawSource, rawSource.resolution) : evidenceTypeFor(rawSource)),
|
|
70
70
|
method: projection.evidenceMethod ?? "extraction",
|
|
71
71
|
sourceRef: rawSource.sourceRef,
|
|
72
72
|
sourceLocator: extraction.locator,
|
|
@@ -81,6 +81,7 @@ export function buildSurveyTrustBundle(input, options = {}) {
|
|
|
81
81
|
...(policyStandard ? { policyStandard } : {}),
|
|
82
82
|
rawSourceKind: rawSource.kind,
|
|
83
83
|
locatorScheme: rawSource.locatorScheme,
|
|
84
|
+
...(rawSource.resolution ? { provenanceResolution: rawSource.resolution } : {}),
|
|
84
85
|
confidence: candidate.confidence ?? extraction.confidence,
|
|
85
86
|
},
|
|
86
87
|
});
|
|
@@ -364,6 +365,36 @@ function evidenceTypeFor(rawSource) {
|
|
|
364
365
|
return "crawl_observation";
|
|
365
366
|
return "attestation";
|
|
366
367
|
}
|
|
368
|
+
function evidenceTypeForResolution(rawSource, resolution) {
|
|
369
|
+
switch (resolution) {
|
|
370
|
+
case "testimony":
|
|
371
|
+
case "supersession":
|
|
372
|
+
return "attestation";
|
|
373
|
+
case "observation":
|
|
374
|
+
return rawSource.kind === "web-page" ? "crawl_observation" : "source_excerpt";
|
|
375
|
+
case "extraction":
|
|
376
|
+
return evidenceTypeForOrigin(rawSource.kind);
|
|
377
|
+
case "precedence-selection":
|
|
378
|
+
case "carry-forward":
|
|
379
|
+
return evidenceTypeForOrigin(rawSource.kind);
|
|
380
|
+
default:
|
|
381
|
+
return assertNever(resolution);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function evidenceTypeForOrigin(kind) {
|
|
385
|
+
if (kind === "policy-standard")
|
|
386
|
+
return "policy_rule";
|
|
387
|
+
if (kind === "uploaded-document")
|
|
388
|
+
return "document_citation";
|
|
389
|
+
if (kind === "web-page")
|
|
390
|
+
return "crawl_observation";
|
|
391
|
+
if (kind === "manual-entry")
|
|
392
|
+
return "attestation";
|
|
393
|
+
return "source_excerpt";
|
|
394
|
+
}
|
|
395
|
+
function assertNever(value) {
|
|
396
|
+
throw new Error(`Unsupported provenance resolution: ${String(value)}`);
|
|
397
|
+
}
|
|
367
398
|
function policyStandardFields(rawSource) {
|
|
368
399
|
const metadata = rawSource.metadata?.policyStandard;
|
|
369
400
|
const metadataRecord = isRecord(metadata) ? metadata : {};
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ConfidenceBasis, DerivationEdge, EvidenceMethod, EvidenceType, ImpactLevel, TrustStatus } from "@kontourai/surface";
|
|
2
2
|
export type RawSourceKind = "uploaded-document" | "web-page" | "api-record" | "manual-entry" | "policy-standard" | "inquiry-question" | "agent-utterance" | "system-schema";
|
|
3
|
+
export type ProvenanceResolution = "extraction" | "testimony" | "supersession" | "precedence-selection" | "carry-forward" | "observation";
|
|
3
4
|
export type LocatorScheme = "pdf" | "text" | "html" | "structured-field" | "text-span";
|
|
4
5
|
export interface RawSource {
|
|
5
6
|
id: string;
|
|
6
7
|
kind: RawSourceKind;
|
|
8
|
+
resolution?: ProvenanceResolution;
|
|
7
9
|
sourceRef: string;
|
|
8
10
|
observedAt: string;
|
|
9
11
|
fetchedAt?: string;
|
package/package.json
CHANGED