@kontourai/survey 0.2.1 → 0.3.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/README.md
CHANGED
|
@@ -183,6 +183,20 @@ preserved. Producers still own scalar semantics, validation, candidate ranking,
|
|
|
183
183
|
review policy, and whether a value should be verified, proposed, rejected, or
|
|
184
184
|
assumed.
|
|
185
185
|
|
|
186
|
+
## Reviewed candidate resolutions
|
|
187
|
+
|
|
188
|
+
Use `reviewedCandidateResolution` when a producer has multiple candidate
|
|
189
|
+
observations for the same target and a review outcome selects one candidate.
|
|
190
|
+
The helper wraps `candidateReviewRecord`, attaches the review outcome to the
|
|
191
|
+
selected candidate, defaults the candidate set to `resolved`, defaults the
|
|
192
|
+
selected claim status from the review outcome, and defaults unselected
|
|
193
|
+
candidates to `superseded`. Producers can override selected or unselected claim
|
|
194
|
+
statuses when their domain workflow needs a different posture.
|
|
195
|
+
|
|
196
|
+
This is useful for corrected documents, source-of-truth choices, and review
|
|
197
|
+
queues where losing candidates should remain visible for transparency rather
|
|
198
|
+
than disappearing from the trust trail.
|
|
199
|
+
|
|
186
200
|
## Repeated observations
|
|
187
201
|
|
|
188
202
|
Use `repeatedObservation` when a producer wants to describe a repeated field or
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export type { CandidateSetStatus, Candidate, CandidateSet, ClaimTarget, Extraction, LocatorScheme, RawSource, RawSourceKind, ReviewOutcome, ReviewStatus, SurveyInput, } from "./types.js";
|
|
2
2
|
export { candidateReviewRecord, SurveyInputBuilder } from "./builder.js";
|
|
3
3
|
export type { CandidateReviewRecordInput, SurveyClaimRecord, SurveyInputBuilderArgs, SurveyObservationInput, } from "./builder.js";
|
|
4
|
+
export { reviewedCandidateResolution } from "./reviewed-candidate-resolution.js";
|
|
5
|
+
export type { ReviewedCandidateResolutionInput } from "./reviewed-candidate-resolution.js";
|
|
4
6
|
export { buildSurveyTrustInput } from "./to-surface.js";
|
|
5
7
|
export { fieldObservation } from "./field-observation.js";
|
|
6
8
|
export type { FieldObservationInput } from "./field-observation.js";
|
package/dist/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { candidateReviewRecord, SurveyInputBuilder } from "./builder.js";
|
|
2
|
+
export { reviewedCandidateResolution } from "./reviewed-candidate-resolution.js";
|
|
2
3
|
export { buildSurveyTrustInput } from "./to-surface.js";
|
|
3
4
|
export { fieldObservation } from "./field-observation.js";
|
|
4
5
|
export { repeatedObservation } from "./repeated-observation.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type SurveyClaimRecord, type SurveyObservationInput } from "./builder.js";
|
|
2
|
+
import type { CandidateSet, ClaimTarget, ReviewOutcome } from "./types.js";
|
|
3
|
+
export interface ReviewedCandidateResolutionInput {
|
|
4
|
+
id: string;
|
|
5
|
+
target: string;
|
|
6
|
+
observations: SurveyObservationInput[];
|
|
7
|
+
selectedCandidateId: string;
|
|
8
|
+
rationale?: string;
|
|
9
|
+
metadata?: Record<string, unknown>;
|
|
10
|
+
status?: CandidateSet["status"];
|
|
11
|
+
reviewOutcome: Omit<ReviewOutcome, "id" | "candidateSetId" | "candidateId"> & {
|
|
12
|
+
id?: string;
|
|
13
|
+
candidateId?: string;
|
|
14
|
+
};
|
|
15
|
+
selectedClaimStatus?: ClaimTarget["status"];
|
|
16
|
+
unselectedClaimStatus?: ClaimTarget["status"];
|
|
17
|
+
}
|
|
18
|
+
export declare function reviewedCandidateResolution(input: ReviewedCandidateResolutionInput): SurveyClaimRecord[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { candidateReviewRecord } from "./builder.js";
|
|
2
|
+
export function reviewedCandidateResolution(input) {
|
|
3
|
+
return candidateReviewRecord({
|
|
4
|
+
id: input.id,
|
|
5
|
+
target: input.target,
|
|
6
|
+
selectedCandidateId: input.selectedCandidateId,
|
|
7
|
+
status: input.status ?? candidateSetStatusForReview(input.reviewOutcome.status),
|
|
8
|
+
rationale: input.rationale,
|
|
9
|
+
metadata: input.metadata,
|
|
10
|
+
reviewOutcome: {
|
|
11
|
+
...input.reviewOutcome,
|
|
12
|
+
candidateId: input.reviewOutcome.candidateId ?? input.selectedCandidateId,
|
|
13
|
+
},
|
|
14
|
+
observations: input.observations.map((observation) => ({
|
|
15
|
+
...observation,
|
|
16
|
+
claim: {
|
|
17
|
+
...observation.claim,
|
|
18
|
+
status: observation.claim.status ?? claimStatusForObservation(input, observation),
|
|
19
|
+
},
|
|
20
|
+
})),
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function claimStatusForObservation(input, observation) {
|
|
24
|
+
if (observationCandidateId(observation) === input.selectedCandidateId) {
|
|
25
|
+
return input.selectedClaimStatus ?? input.reviewOutcome.status;
|
|
26
|
+
}
|
|
27
|
+
return input.unselectedClaimStatus ?? "superseded";
|
|
28
|
+
}
|
|
29
|
+
function observationCandidateId(observation) {
|
|
30
|
+
return observation.candidate?.id ?? `${observation.id}.candidate`;
|
|
31
|
+
}
|
|
32
|
+
function candidateSetStatusForReview(status) {
|
|
33
|
+
if (status === "proposed")
|
|
34
|
+
return "needs-review";
|
|
35
|
+
return "resolved";
|
|
36
|
+
}
|
package/package.json
CHANGED